!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).turf={})}(this,(function(t){"use strict";var e=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*e,kilometers:6371.0088,kilometres:6371.0088,meters:e,metres:e,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:e/1852,radians:1,yards:6967335.223679999},r={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e,yards:1.0936133},i={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function o(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function a(t,e,n){switch(t){case"Point":return s(e).geometry;case"LineString":return h(e).geometry;case"Polygon":return u(e).geometry;case"MultiPoint":return m(e).geometry;case"MultiLineString":return d(e).geometry;case"MultiPolygon":return g(e).geometry;default:throw new Error(t+" is invalid")}}function s(t,e,n){if(void 0===n&&(n={}),!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(!C(t[0])||!C(t[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:t},e,n)}function l(t,e,n){return void 0===n&&(n={}),f(t.map((function(t){return s(t,e)})),n)}function u(t,e,n){void 0===n&&(n={});for(var r=0,i=t;r=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function _(t,e){void 0===e&&(e="kilometers");var r=n[e];if(!r)throw new Error(e+" units is invalid");return t*r}function x(t,e){void 0===e&&(e="kilometers");var r=n[e];if(!r)throw new Error(e+" units is invalid");return t/r}function b(t,e){return E(x(t,e))}function w(t){var e=t%360;return e<0&&(e+=360),e}function E(t){return t%(2*Math.PI)*180/Math.PI}function S(t){return t%360*Math.PI/180}function M(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return _(x(t,e),n)}function T(t,e,n){if(void 0===e&&(e="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var r=i[e];if(!r)throw new Error("invalid original units");var o=i[n];if(!o)throw new Error("invalid final units");return t/r*o}function C(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function I(t){return!!t&&t.constructor===Object}function A(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!C(t))throw new Error("bbox must only contain numbers")}))}function L(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}var P=Object.freeze({__proto__:null,earthRadius:e,factors:n,unitsFactors:r,areaFactors:i,feature:o,geometry:a,point:s,points:l,polygon:u,polygons:c,lineString:h,lineStrings:p,featureCollection:f,multiLineString:d,multiPoint:m,multiPolygon:g,geometryCollection:y,round:v,radiansToLength:_,lengthToRadians:x,lengthToDegrees:b,bearingToAzimuth:w,radiansToDegrees:E,degreesToRadians:S,convertLength:M,convertArea:T,isNumber:C,isObject:I,validateBBox:A,validateId:L});function R(t,e,n){if(null!==t)for(var r,i,o,a,s,l,u,c,h=0,p=0,f=t.type,d="FeatureCollection"===f,m="Feature"===f,g=d?t.features.length:1,y=0;ys||f>l||d>u)return a=o,s=n,l=f,u=d,void(i=0);var m=h([a,o],t.properties);if(!1===e(m,n,r,d,i))return!1;i++,a=o}))&&void 0}}}))}function H(t,e,n){var r=n,i=!1;return j(t,(function(t,o,a,s,l){r=!1===i&&void 0===n?t:e(r,t,o,a,s,l),i=!0})),r}function q(t,e){if(!t)throw new Error("geojson is required");V(t,(function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var a=0;at[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]=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 Q(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 $(t){if(t.length>1&&C(t[0])&&C(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return $(t[0]);throw new Error("coordinates must only contain numbers")}function tt(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)}function et(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}function nt(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var r=0,i=t.features;r=0&&m>=0&&m=0;c--)if(Math.abs(e[c][0][0]-l)<=1e-7&&Math.abs(e[c][0][1]-u)<=1e-7){for(var h=a.path.length-2;h>=0;--h)e[c].unshift(a.path[h]);s=!0;break}s||(e[n++]=a.path)}var p}))})),e}(function(t,e){for(var n=t.length-1,r=t[0].length-1,i={rows:n,cols:r,cells:[]},o=0;o=e?8:0,s|=u>=e?4:0,s|=c>=e?2:0;var p,f,d,m,g=!1;if(5==(s|=h>=e?1:0)||10===s){var y=(l+u+c+h)/4;5===s&&yn;){if(r-n>600){var o=r-n+1,a=e-n+1,s=Math.log(o),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);xt(t,e,Math.max(n,Math.floor(e-a*l/o+u)),Math.min(r,Math.floor(e+(o-a)*l/o+u)),i)}var c=t[e],h=n,p=r;for(bt(t,n,e),i(t[r],c)>0&&bt(t,n,r);h0;)p--}0===i(t[n],c)?bt(t,n,p):bt(t,++p,r),p<=e&&(n=p+1),e<=p&&(r=p-1)}}function bt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function wt(t,e){return te?1:0}yt.default=vt;var Et=Mt,St=Mt;function Mt(t,e){if(!(this instanceof Mt))return new Mt(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function Tt(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY}function kt(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function zt(t,e,n,r,i){for(var o,a=[e,n];a.length;)(n=a.pop())-(e=a.pop())<=r||(o=e+Math.ceil((n-e)/r/2)*r,yt(t,o,e,n,i),a.push(e,o,o,n))}function Ft(t){var e={exports:{}};return t(e,e.exports),e.exports}Mt.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],r=this.toBBox;if(!Ot(t,e))return n;for(var i,o,a,s,l=[];e;){for(i=0,o=e.children.length;i=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(i,o,e)},_split:function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),a=kt(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,Ct(n,this.toBBox),Ct(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},_splitRoot:function(t,e){this.data=kt([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ct(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var r,i,o,a,s,l,u,c,h,p,f,d,m,g;for(l=u=1/0,r=e;r<=n-e;r++)h=i=It(t,0,r,this.toBBox),p=o=It(t,r,n,this.toBBox),void 0,void 0,void 0,void 0,f=Math.max(h.minX,p.minX),d=Math.max(h.minY,p.minY),m=Math.min(h.maxX,p.maxX),g=Math.min(h.maxY,p.maxY),a=Math.max(0,m-f)*Math.max(0,g-d),s=Rt(i)+Rt(o),a=e;i--)o=t.children[i],At(l,t.leaf?a(o):o),u+=Dt(l);return u},_adjustParentBBoxes:function(t,e,n){for(var r=n;r>=0;r--)At(e[r],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():Ct(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},Et.default=St;var Bt=function(t,e,n){var r=t*e,i=Ut*t,o=i-(i-t),a=t-o,s=Ut*e,l=s-(s-e),u=e-l,c=a*u-(r-o*l-a*l-o*u);return n?(n[0]=c,n[1]=r,n):[c,r]},Ut=+(Math.pow(2,27)+1),Vt=function(t,e){var n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){var n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);var i,o,a=new Array(n+r),s=0,l=0,u=0,c=Math.abs,h=t[l],p=c(h),f=e[u],d=c(f);p=r?(i=h,(l+=1)=r?(i=h,(l+=1)>1;return["sum(",n(t.slice(0,e)),",",n(t.slice(e)),")"].join("")}function r(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var i=[],o=0;o0){if(a<=0)return s;r=i+a}else{if(!(i<0))return s;if(a>=0)return s;r=-(i+a)}var l=33306690738754716e-32*r;return s>=l||s<=-l?s:o(t,e,n)},function(t,e,n,r){var i=t[0]-r[0],o=e[0]-r[0],s=n[0]-r[0],l=t[1]-r[1],u=e[1]-r[1],c=n[1]-r[1],h=t[2]-r[2],p=e[2]-r[2],f=n[2]-r[2],d=o*c,m=s*u,g=s*l,y=i*c,v=i*u,_=o*l,x=h*(d-m)+p*(g-y)+f*(v-_),b=7771561172376103e-31*((Math.abs(d)+Math.abs(m))*Math.abs(h)+(Math.abs(g)+Math.abs(y))*Math.abs(p)+(Math.abs(v)+Math.abs(_))*Math.abs(f));return x>b||-x>b?x:a(t,e,n,r)}];function l(t){var e=s[t.length];return e||(e=s[t.length]=i(t.length)),e.apply(void 0,t)}!function(){for(;s.length<=5;)s.push(i(s.length));for(var e=[],n=["slow"],r=0;r<=5;++r)e.push("a"+r),n.push("o"+r);var o=["function getOrientation(",e.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=5;++r)o.push("case ",r,":return o",r,"(",e.slice(0,r).join(),");");o.push("}var s=new Array(arguments.length);for(var i=0;i0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function Jt(t,e){return te?1:0}Yt.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r},_down:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=s,t=o}e[t]=i}},Xt.default=Zt;var Kt=function(t,e){for(var n=t[0],r=t[1],i=!1,o=0,a=e.length-1;or!=c>r&&n<(u-s)*(r-l)/(c-l)+s&&(i=!i)}return i},Qt=qt[3],$t=ee,te=ee;function ee(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;for(var r,i=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;or[0]&&(r=a),a[1]i[1]&&(i=a)}var s=[e,n,r,i],l=s.slice();for(o=0;o1&&Wt(t[o[u-2]],t[o[u-1]],l)<=0;)u-=1,o.pop();for(o.push(s),u=a.length;u>1&&Wt(t[a[u-2]],t[a[u-1]],l)>=0;)u-=1,a.pop();a.push(s)}n=new Array(a.length+o.length-2);for(var c=0,h=(r=0,o.length);r0;--p)n[c++]=a[p];return n}(l),c=[];for(o=0;oo||s.push({node:c,dist:h})}for(;s.length&&!s.peek().node.children;){var p=s.pop(),f=p.node,d=ce(f,e,n),m=ce(f,r,i);if(p.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function ae(t,e,n){for(var r,i,o,a,s=Math.min(t[0],e[0]),l=Math.min(t[1],e[1]),u=Math.max(t[0],e[0]),c=Math.max(t[1],e[1]),h=n.search({minX:s,minY:l,maxX:u,maxY:c}),p=0;p0!=Qt(r,i,a)>0&&Qt(o,a,r)>0!=Qt(o,a,i)>0)return!1;return!0}function se(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function le(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function ue(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function ce(t,e,n){var r=e[0],i=e[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((t[0]-r)*o+(t[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=t[0]-r)*o+(a=t[1]-i)*a}function he(t,e,n,r,i,o,a,s){var l,u,c,h,p=n-t,f=r-e,d=a-i,m=s-o,g=t-i,y=e-o,v=p*p+f*f,_=p*d+f*m,x=d*d+m*m,b=p*g+f*y,w=d*g+m*y,E=v*x-_*_,S=E,M=E;0===E?(u=0,S=1,h=w,M=x):(h=v*w-_*b,(u=_*w-x*b)<0?(u=0,h=w,M=x):u>S&&(u=S,h=w+_,M=x)),h<0?(h=0,-b<0?u=0:-b>v?u=S:(u=-b,S=v)):h>M&&(h=M,-b+_<0?u=0:-b+_>v?u=S:(u=-b+_,S=v));var T=(1-(c=0===h?0:h/M))*i+c*a-((1-(l=0===u?0:u/S))*t+l*n),C=(1-c)*o+c*s-((1-l)*e+l*r);return T*T+C*C}function pe(t,e){void 0===e&&(e={}),e.concavity=e.concavity||1/0;var n=[];if(R(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var r=$t(n,e.concavity);return r.length>3?u([r]):null}function fe(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=K(t),i=rt(e),o=i.type,a=e.bbox,s=i.coordinates;if(a&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(r,a))return!1;"Polygon"===o&&(s=[s]);for(var l=!1,u=0;ut[1]!=u>t[1]&&t[0]<(l-a)*(t[1]-s)/(u-s)+a&&(r=!r)}return r}function me(t,e){var n=[];return k(t,(function(t){var r=!1;if("Point"===t.geometry.type)B(e,(function(e){fe(t,e)&&(r=!0)})),r&&n.push(t);else{if("MultiPoint"!==t.geometry.type)throw new Error("Input geometry must be a Point or MultiPoint");var i=[];B(e,(function(e){R(t,(function(t){fe(t,e)&&(r=!0,i.push(t))}))})),r&&n.push(m(i))}})),f(n)}function ge(t,e,n){void 0===n&&(n={});var r=K(t),i=K(e),o=S(i[1]-r[1]),a=S(i[0]-r[0]),s=S(r[1]),l=S(i[1]),u=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(l);return _(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),n.units)}function ye(t,e){var n=!1;return f(function(t){if(t.length<3)return[];t.sort(_e);for(var e,n,r,i,o,a,s=t.length-1,l=t[s].x,u=t[0].x,c=t[s].y,h=c;s--;)t[s].yh&&(h=t[s].y);var p,f=u-l,d=h-c,m=f>d?f:d,g=.5*(u+l),y=.5*(h+c),v=[new ve({__sentinel:!0,x:g-20*m,y:y-m},{__sentinel:!0,x:g,y:y+20*m},{__sentinel:!0,x:g+20*m,y:y-m})],_=[],x=[];s=t.length;for(;s--;){for(x.length=0,p=v.length;p--;)(f=t[s].x-v[p].x)>0&&f*f>v[p].r?(_.push(v[p]),v.splice(p,1)):f*f+(d=t[s].y-v[p].y)*d>v[p].r||(x.push(v[p].a,v[p].b,v[p].b,v[p].c,v[p].c,v[p].a),v.splice(p,1));for(xe(x),p=x.length;p;)n=x[--p],e=x[--p],r=t[s],i=n.x-e.x,o=n.y-e.y,a=2*(i*(r.y-n.y)-o*(r.x-n.x)),Math.abs(a)>1e-12&&v.push(new ve(e,n,r))}Array.prototype.push.apply(_,v),s=_.length;for(;s--;)(_[s].a.__sentinel||_[s].b.__sentinel||_[s].c.__sentinel)&&_.splice(s,1);return _}(t.features.map((function(t){var r={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?r.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,r.z=t.geometry.coordinates[2]),r}))).map((function(t){var e=[t.a.x,t.a.y],r=[t.b.x,t.b.y],i=[t.c.x,t.c.y],o={};return n?(e.push(t.a.z),r.push(t.b.z),i.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},u([[e,r,i,e]],o)})))}$t.default=te;var ve=function(t,e,n){this.a=t,this.b=e,this.c=n;var r,i,o=e.x-t.x,a=e.y-t.y,s=n.x-t.x,l=n.y-t.y,u=o*(t.x+e.x)+a*(t.y+e.y),c=s*(t.x+n.x)+l*(t.y+n.y),h=2*(o*(n.y-e.y)-a*(n.x-e.x));this.x=(l*u-a*c)/h,this.y=(o*c-s*u)/h,r=this.x-t.x,i=this.y-t.y,this.r=r*r+i*i};function _e(t,e){return e.x-t.x}function xe(t){var e,n,r,i,o,a=t.length;t:for(;a;)for(n=t[--a],e=t[--a],r=a;r;)if(o=t[--r],e===(i=t[--r])&&n===o||e===o&&n===i){t.splice(a,2),t.splice(r,2),a-=2;continue t}}function be(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return we(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach((function(n){switch(n){case"type":case"features":return;default:e[n]=t[n]}})),e.features=t.features.map((function(t){return we(t)})),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Se(t);default:throw new Error("unknown GeoJSON type")}}function we(t){var e={type:"Feature"};return Object.keys(t).forEach((function(n){switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}})),e.properties=Ee(t.properties),e.geometry=Se(t.geometry),e}function Ee(t){var e={};return t?(Object.keys(t).forEach((function(n){var r=t[n];"object"==typeof r?null===r?e[n]=null:Array.isArray(r)?e[n]=r.map((function(t){return t})):e[n]=Ee(r):e[n]=r})),e):e}function Se(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map((function(t){return Se(t)})),e):(e.coordinates=Me(t.coordinates),e)}function Me(t){var e=t;return"object"!=typeof e[0]?e.slice():e.map((function(t){return Me(t)}))}function Te(t){return t[0].toString()+","+t[1].toString()}function Ce(t){return t}function Ie(t,e){var n=function(t){if(null==t)return Ce;var e,n,r=t.scale[0],i=t.scale[1],o=t.translate[0],a=t.translate[1];return function(t,s){s||(e=n=0);var l=2,u=t.length,c=new Array(u);for(c[0]=(e+=t[0])*r+o,c[1]=(n+=t[1])*i+a;l1)for(var o,s,l=1,u=a(i[0]);lu&&(s=i[0],i[0]=i[l],i[l]=s,u=o);return i})).filter((function(t){return t.length>0}))}}var Le=Object.prototype.hasOwnProperty;function Pe(t,e,n,r,i,o){3===arguments.length&&(r=o=Array,i=null);for(var a=new r(t=1<=t)throw new Error("full hashmap");c=a[u=u+1&l]}return a[u]=r,s[u]=o,o},maybeSet:function(r,o){for(var u=e(r)&l,c=a[u],h=0;c!=i;){if(n(c,r))return s[u];if(++h>=t)throw new Error("full hashmap");c=a[u=u+1&l]}return a[u]=r,s[u]=o,o},get:function(r,o){for(var u=e(r)&l,c=a[u],h=0;c!=i;){if(n(c,r))return s[u];if(++h>=t)break;c=a[u=u+1&l]}return o},keys:function(){for(var t=[],e=0,n=a.length;e>7^Oe[2]^Oe[3])}function ze(t,e,n,r){Fe(t,e,n),Fe(t,e,e+r),Fe(t,e+r,n)}function Fe(t,e,n){for(var r,i=e+(n---e>>1);er&&(r=o),ai&&(i=a)}function l(t){t.forEach(s)}function u(t){t.forEach(l)}for(var c in t)o(t[c]);return r>=e&&i>=n?[e,n,r,i]:void 0}(t=function(t){var e,n,r={};for(e in t)r[e]=null==(n=t[e])?{type:null}:("FeatureCollection"===n.type?Be:"Feature"===n.type?Ue:Ve)(n);return r}(t)),r=e>0&&n&&function(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=o-r?(n-1)/(o-r):1,l=a-i?(n-1)/(a-i):1;function u(t){return[Math.round((t[0]-r)*s),Math.round((t[1]-i)*l)]}function c(t,e){for(var n,o,a,u,c,h=-1,p=0,f=t.length,d=new Array(f);++h=0){var o=h[n];i===e&&o===r||i===r&&o===e||(++f,p[n]=1)}else c[n]=e,h[n]=r}}function b(t){return ke(o[t])}function w(t,e){return Re(o[t],o[e])}u=c=h=null;var E,S=function(t,e,n,r,i){3===arguments.length&&(r=Array,i=null);for(var o=new r(t=1<=t)throw new Error("full hashset");l=o[s=s+1&a]}return o[s]=r,!0},has:function(r){for(var s=e(r)&a,l=o[s],u=0;l!=i;){if(n(l,r))return!0;if(++u>=t)break;l=o[s=s+1&a]}return!1},values:function(){for(var t=[],e=0,n=o.length;e2&&Je(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1))}if(n.push(e[e.length-1]),i=n.length,Ye(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return Je(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1),n}function Ye(t,e){return t[0]===e[0]&&t[1]===e[1]}function Je(t,e,n){var r=n[0],i=n[1],o=t[0],a=t[1],s=e[0],l=e[1],u=s-o,c=l-a;return 0==(r-o)*c-(i-a)*u&&(Math.abs(u)>=Math.abs(c)?u>0?o<=r&&r<=s:s<=r&&r<=o:c>0?a<=i&&i<=l:l<=i&&i<=a)}function Ke(t,e,n){var r=e.x,i=e.y,o=n.x-r,a=n.y-i;if(0!==o||0!==a){var s=((t.x-r)*o+(t.y-i)*a)/(o*o+a*a);s>1?(r=n.x,i=n.y):s>0&&(r+=o*s,i+=a*s)}return(o=t.x-r)*o+(a=t.y-i)*a}function Qe(t,e,n,r,i){for(var o,a=r,s=e+1;sa&&(o=s,a=l)}a>r&&(o-e>1&&Qe(t,e,o,r,i),i.push(t[o]),n-o>1&&Qe(t,o,n,r,i))}function $e(t,e){var n=t.length-1,r=[t[0]];return Qe(t,0,n,e,r),r.push(t[n]),r}function tn(t,e,n){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return $e(t=n?t:function(t,e){for(var n,r,i,o,a,s=t[0],l=[s],u=1,c=t.length;ue&&(l.push(n),s=n);return s!==n&&l.push(n),l}(t,r),r)}function en(t,e,n){return tn(t.map((function(t){return{x:t[0],y:t[1],z:t[2]}})),e,n).map((function(t){return t.z?[t.x,t.y,t.z]:[t.x,t.y]}))}function nn(t,e,n){return t.map((function(t){var r=t.map((function(t){return{x:t[0],y:t[1]}}));if(r.length<4)throw new Error("invalid polygon");for(var i=tn(r,e,n).map((function(t){return[t.x,t.y]}));!rn(i);)i=tn(r,e-=.01*e,n).map((function(t){return[t.x,t.y]}));return i[i.length-1][0]===i[0][0]&&i[i.length-1][1]===i[0][1]||i.push(i[0]),i}))}function rn(t){return!(t.length<3||3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}var on=function(){function t(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(var e=0;et&&(e.push(r),n=i)}return e},t.prototype.vector=function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}},t.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var n=e/this.duration;if(n>=1)return this.points[this.length-1];var r=Math.floor((this.points.length-1)*n);return function(t,e,n,r,i){var o=function(t){var e=t*t;return[e*t,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t);return{x:i.x*o[0]+r.x*o[1]+n.x*o[2]+e.x*o[3],y:i.y*o[0]+r.y*o[1]+n.y*o[2]+e.y*o[3],z:i.z*o[0]+r.z*o[1]+n.z*o[2]+e.z*o[3]}}((this.length-1)*n-r,this.points[r],this.controls[r][1],this.controls[r+1][0],this.points[r+1])},t}();function an(t,e){void 0===e&&(e={});for(var n=e.resolution||1e4,r=e.sharpness||.85,i=[],o=rt(t).coordinates.map((function(t){return{x:t[0],y:t[1]}})),a=new on({duration:n,points:o,sharpness:r}),s=function(t){var e=a.pos(t);Math.floor(t/100)%2==0&&i.push([e.x,e.y])},l=0;l=ge(t.slice(0,2),[e,i])){var o=(n+i)/2;return[e,o-(r-e)/2,r,o+(r-e)/2]}var a=(e+r)/2;return[a-(i-n)/2,n,a+(i-n)/2,i]}function cn(t,e,n,r){void 0===r&&(r={});var i=K(t),o=S(i[0]),a=S(i[1]),l=S(n),u=x(e,r.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(l));return s([E(o+Math.atan2(Math.sin(l)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),E(c)],r.properties)}function hn(t,e,n){void 0===n&&(n={});for(var r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&"Feature"===t.type&&t.properties?t.properties:{},o=[],a=0;a80*n){r=o=t[0],i=a=t[1];for(var d=n;do&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?1/u:0}return bn(p,f,n,r,i,u),f}function _n(t,e,n,r,i){var o,a;if(i===Un(t,e,n,r)>0)for(o=e;o=e;o-=r)a=zn(o,t[o],t[o+1],a);return a&&Dn(a,a.next)&&(Fn(a),a=a.next),a}function xn(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Dn(r,r.next)&&0!==Rn(r.prev,r,r.next))r=r.next;else{if(Fn(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function bn(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=In(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,l,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?En(t,r,i,o):wn(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Fn(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?bn(t=Sn(t,e,n),e,n,r,i,o,2):2===a&&Mn(t,e,n,r,i,o):bn(xn(t),e,n,r,i,o,1);break}}}function wn(t){var e=t.prev,n=t,r=t.next;if(Rn(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Ln(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Rn(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function En(t,e,n,r){var i=t.prev,o=t,a=t.next;if(Rn(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=In(s,l,e,n,r),p=In(u,c,e,n,r),f=t.prevZ,d=t.nextZ;f&&f.z>=h&&d&&d.z<=p;){if(f!==t.prev&&f!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Rn(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==t.prev&&d!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Rn(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Rn(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&Ln(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Rn(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Sn(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!Dn(i,o)&&Nn(i,r,r.next,o)&&On(i,o)&&On(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Fn(r),Fn(r.next),r=t=o),r=r.next}while(r!==t);return r}function Mn(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Pn(a,s)){var l=kn(a,s);return a=xn(a,a.next),l=xn(l,l.next),bn(a,e,n,r,i,o),void bn(l,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function Tn(t,e){return t.x-e.x}function Cn(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x=r.x&&r.x>=c&&i!==r.x&&Ln(on.x)&&On(r,t)&&(n=r,p=l),r=r.next;return n}(t,e)){var n=kn(e,t);xn(n,n.next)}}function In(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function An(t){var e=t,n=t;do{e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function Pn(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Nn(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&On(t,e)&&On(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Rn(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Dn(t,e){return t.x===e.x&&t.y===e.y}function Nn(t,e,n,r){return!!(Dn(t,e)&&Dn(n,r)||Dn(t,r)&&Dn(n,e))||Rn(t,e,n)>0!=Rn(t,e,r)>0&&Rn(n,r,t)>0!=Rn(n,r,e)>0}function On(t,e){return Rn(t.prev,t,t.next)<0?Rn(t,e,t.next)>=0&&Rn(t,t.prev,e)>=0:Rn(t,e,t.prev)<0||Rn(t,t.next,e)<0}function kn(t,e){var n=new Bn(t.i,t.x,t.y),r=new Bn(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function zn(t,e,n,r){var i=new Bn(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Fn(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Bn(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Un(t,e,n,r){for(var i=0,o=e,a=n-r;o0&&(r+=t[i-1].length,n.holes.push(r))}return n}(t),n=gn(e.vertices,e.holes,2),r=[],i=[];n.forEach((function(t,r){var o=n[r];i.push([e.vertices[2*o],e.vertices[2*o+1]])}));for(var o=0;oi?n:i,r>o?r:o]}(t,r),n.push(i),r})),n})(n,t.properties).forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),f(e)}vn.deviation=function(t,e,n,r){var i=e&&e.length,o=i?e[0]*n:t.length,a=Math.abs(Un(t,0,o,n));if(i)for(var s=0,l=e.length;s0&&(r+=t[i-1].length,n.holes.push(r))}return n},gn.default=yn;var Hn=Ft((function(t,e){function n(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function r(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(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:t},e,r)}function i(t,e,r){void 0===r&&(r={});for(var i=0,o=t;i=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n},e.radiansToLength=c,e.lengthToRadians=h,e.lengthToDegrees=function(t,e){return p(h(t,e))},e.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},e.radiansToDegrees=p,e.degreesToRadians=function(t){return t%360*Math.PI/180},e.convertLength=function(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(h(t,e),n)},e.convertArea=function(t,n,r){if(void 0===n&&(n="meters"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=e.areaFactors[n];if(!i)throw new Error("invalid original units");var o=e.areaFactors[r];if(!o)throw new Error("invalid final units");return t/i*o},e.isNumber=f,e.isObject=function(t){return!!t&&t.constructor===Object},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!f(t))throw new Error("bbox must only contain numbers")}))},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}}));function qn(t,e,n){if(null!==t)for(var r,i,o,a,s,l,u,c,h=0,p=0,f=t.type,d="FeatureCollection"===f,m="Feature"===f,g=d?t.features.length:1,y=0;ys||p>l||f>u)return a=o,s=n,l=p,u=f,void(i=0);var d=Hn.lineString([a,o],t.properties);if(!1===e(d,n,r,f,i))return!1;i++,a=o}))&&void 0}}}))}function Kn(t,e){if(!t)throw new Error("geojson is required");Yn(t,(function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var a=0;at[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2] line1 must only contain 2 coordinates");if(2!==r.length)throw new Error(" line2 must only contain 2 coordinates");var i=n[0][0],o=n[0][1],a=n[1][0],l=n[1][1],u=r[0][0],c=r[0][1],h=r[1][0],p=r[1][1],f=(p-c)*(a-i)-(h-u)*(l-o);if(0===f)return null;var d=((h-u)*(o-c)-(p-c)*(i-u))/f,m=((a-i)*(o-c)-(l-o)*(i-u))/f;return d>=0&&d<=1&&m>=0&&m<=1?s([i+d*(a-i),o+d*(l-o)]):null}function gr(t,e,n){void 0===n&&(n={});var r=s([1/0,1/0],{dist:1/0}),i=0;return V(t,(function(t){for(var o=Q(t),a=0;a0&&((y=g.features[0]).properties.dist=ge(e,y,n),y.properties.location=i+ge(l,y,n)),l.properties.dist180?-360:i[0]-o[0]>180?360:0,M(function(t,n,r){var i=r=void 0===r?e:Number(r),o=t[1]*Math.PI/180,a=n[1]*Math.PI/180,s=a-o,l=Math.abs(n[0]-t[0])*Math.PI/180;l>Math.PI&&(l-=2*Math.PI);var u=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),c=Math.abs(u)>1e-11?s/u:Math.cos(o);return Math.sqrt(s*s+c*c*l*l)*i}(i,o),"meters",r.units)}function vr(t,e,n){if(void 0===n&&(n={}),n.method||(n.method="geodesic"),n.units||(n.units="kilometers"),!t)throw new Error("pt is required");if(Array.isArray(t)?t=s(t):"Point"===t.type?t=o(t):et(t,"Point","point"),!e)throw new Error("line is required");Array.isArray(e)?e=h(e):"LineString"===e.type?e=o(e):et(e,"LineString","line");var r=1/0,i=t.geometry.coordinates;return j(e,(function(t){var e=t.geometry.coordinates[0],o=t.geometry.coordinates[1],a=function(t,e,n,r){var i=[n[0]-e[0],n[1]-e[1]],o=_r([t[0]-e[0],t[1]-e[1]],i);if(o<=0)return xr(t,e,{method:r.method,units:"degrees"});var a=_r(i,i);if(a<=o)return xr(t,n,{method:r.method,units:"degrees"});var s=o/a;return xr(t,[e[0]+s*i[0],e[1]+s*i[1]],{method:r.method,units:"degrees"})}(i,e,o,n);a=0&&u<=1&&(p.onLine1=!0),c>=0&&c<=1&&(p.onLine2=!0),!(!p.onLine1||!p.onLine2)&&[p.x,p.y])}function wr(t){for(var e=function(t){return"FeatureCollection"!==t.type?"Feature"!==t.type?f([o(t)]):f([t]):t}(t),n=fn(e),r=!1,i=0;!r&&i0){e+=Math.abs(Cr(t[0]));for(var n=1;n2){for(a=0;a=c&&p===i.length-1);p++){if(c>e&&0===o.length){if(!(a=e-c))return o.push(i[p]),h(o);s=pn(i[p],i[p-1])-180,l=cn(i[p],a,s,r),o.push(l.geometry.coordinates)}if(c>=n)return(a=n-c)?(s=pn(i[p],i[p-1])-180,l=cn(i[p],a,s,r),o.push(l.geometry.coordinates),h(o)):(o.push(i[p]),h(o));if(c>=e&&o.push(i[p]),p===i.length-1)return h(o);c+=ge(i[p],i[p+1],r)}if(ci)return!1}else if(0!==f)return!1;return r?"start"===r?Math.abs(h)>=Math.abs(p)?h>0?s0?l=Math.abs(p)?h>0?s<=o&&o0?l<=a&&a=Math.abs(p)?h>0?s0?l=Math.abs(p)?h>0?s<=o&&o<=u:u<=o&&o<=s:p>0?l<=a&&a<=c:c<=a&&a<=l}function Dr(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;switch(i){case"Point":switch(o){case"MultiPoint":return function(t,e){var n,r=!1;for(n=0;ne[0]||t[2]e[1]||t[3] is required");if("number"!=typeof n)throw new Error(" must be a number");if("number"!=typeof r)throw new Error(" must be a number");!1!==i&&void 0!==i||(t=JSON.parse(JSON.stringify(t)));var o=Math.pow(10,n);return R(t,(function(t){!function(t,e,n){t.length>n&&t.splice(n,t.length);for(var r=0;r=1||l<=0||u>=1||u<=0))){var m=d,g=!o[m];g&&(o[m]=!0),e?i.push(e(d,t,n,c,h,l,a,s,p,f,u,g)):i.push(d)}}function m(t,e){var n,i,o,a,s=r[t][e],l=r[t][e+1];return s[0]p[e.isect].coord?-1:1}));for(l=[];w.length>0;){var C=w.pop(),I=C.isect,A=C.parent,L=C.winding,P=l.length,R=[p[I].coord],D=I;if(p[I].ringAndEdge1Walkable)var N=p[I].ringAndEdge1,O=p[I].nxtIsectAlongRingAndEdge1;else N=p[I].ringAndEdge2,O=p[I].nxtIsectAlongRingAndEdge2;for(;!Wr(p[I].coord,p[O].coord);){R.push(p[O].coord);var k=void 0;for(r=0;r1)for(e=0;e=0==e}function qr(t){for(var e=0,n=0;n1&&n.push(h(u)),f(n)}function ni(t,e){if(!e.features.length)throw new Error("lines must contain features");if(1===e.features.length)return e.features[0];var n,r=1/0;return k(e,(function(e){var i=gr(e,t).properties.dist;ic&&f.push(cn(t,e,c,i).geometry.coordinates),h(f,l)}function oi(t){var e=t%360;return e<0&&(e+=360),e}function ai(t,e){void 0===e&&(e={});var n=rt(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),n.type){case"Polygon":return si(n,e);case"MultiPolygon":return function(t,e){void 0===e&&(e={});var n=rt(t).coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{},i=[];return n.forEach((function(t){i.push(li(t,r))})),f(i)}(n,e);default:throw new Error("invalid poly")}}function si(t,e){return void 0===e&&(e={}),li(rt(t).coordinates,e.properties?e.properties:"Feature"===t.type?t.properties:{})}function li(t,e){return t.length>1?d(t,e):h(t[0],e)}function ui(t,e){var n,r,i;void 0===e&&(e={});var o=e.properties,a=null===(n=e.autoComplete)||void 0===n||n,s=null===(r=e.orderCoords)||void 0===r||r;if("FeatureCollection"===(null!==(i=e.mutate)&&void 0!==i&&i||(t=be(t)),t.type)){var l=[];return t.features.forEach((function(t){l.push(Q(ci(t,{},a,s)))})),g(l,o)}return ci(t,o,a,s)}function ci(t,e,n,r){e=e||("Feature"===t.type?t.properties:{});var i=rt(t),o=i.coordinates,a=i.type;if(!o.length)throw new Error("line must contain coordinates");switch(a){case"LineString":return n&&(o=hi(o)),u([o],e);case"MultiLineString":var s=[],l=0;return o.forEach((function(t){if(n&&(t=hi(t)),r){var e=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.abs(e-r)*Math.abs(n-i)}(J(h(t)));e>l?(s.unshift(t),l=e):s.push(t)}else s.push(t)})),u(s,e);default:throw new Error("geometry type "+a+" is not supported")}}function hi(t){var e=t[0],n=e[0],r=e[1],i=t[t.length-1],o=i[0],a=i[1];return n===o&&r===a||t.push(e),t}function pi(t,e){var n,r,i,o,a,s,l;for(r=1;r<=8;r*=2){for(n=[],o=!(di(i=t[t.length-1],e)&r),a=0;ae[2]&&(n|=2),t[1]e[3]&&(n|=8),n}function mi(t,e){for(var n=[],r=0,i=t;r0&&(o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]||o.push(o[0]),o.length>=4&&n.push(o))}return n}$r.prototype.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),n=Math.sin(t*this.g)/Math.sin(this.g),r=e*Math.cos(this.start.y)*Math.cos(this.start.x)+n*Math.cos(this.end.y)*Math.cos(this.end.x),i=e*Math.cos(this.start.y)*Math.sin(this.start.x)+n*Math.cos(this.end.y)*Math.sin(this.end.x),o=e*Math.sin(this.start.y)+n*Math.sin(this.end.y),a=Yr*Math.atan2(o,Math.sqrt(Math.pow(r,2)+Math.pow(i,2)));return[Yr*Math.atan2(i,r),a]},$r.prototype.Arc=function(t,e){var n=[];if(!t||t<=2)n.push([this.start.lon,this.start.lat]),n.push([this.end.lon,this.end.lat]);else for(var r=1/(t-1),i=0;ip&&(m>c&&dc&&ml&&(l=g)}var y=[];if(s&&l0&&Math.abs(x-n[_-1][0])>p){var b=parseFloat(n[_-1][0]),w=parseFloat(n[_-1][1]),E=parseFloat(n[_][0]),S=parseFloat(n[_][1]);if(b>-180&&b-180&&n[_-1][0]c&&b<180&&-180===E&&_+1c&&n[_-1][0]<180){v.push([180,n[_][1]]),_++,v.push([n[_][0],n[_][1]]);continue}if(bc){var M=b;b=E,E=M;var T=w;w=S,S=T}if(b>c&&E=180&&bc?180:-180,I]),(v=[]).push([n[_-1][0]>c?-180:180,I]),y.push(v)}else v=[],y.push(v);v.push([x,n[_][1]])}else v.push([n[_][0],n[_][1]])}}else{var A=[];y.push(A);for(var L=0;L=0;s--)if(u[s]!=c[s])return!1;for(s=u.length-1;s>=0;s--)if(l=u[s],!n(t[l],o[l],a))return!1;return typeof t==typeof o}(t,o,a))};function r(t){return null==t}function i(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length||"function"!=typeof t.copy||"function"!=typeof t.slice||t.length>0&&"number"!=typeof t[0])}}));function _i(t,e,n){if(void 0===n&&(n={}),!I(n=n||{}))throw new Error("options is invalid");var r,i=n.tolerance||0,o=[],a=pr(),s=jn(t);return a.load(s),j(e,(function(t){var e=!1;t&&(k(a.search(t),(function(n){if(!1===e){var o=Q(t).sort(),a=Q(n).sort();vi(o,a)||(0===i?Pr(o[0],n)&&Pr(o[1],n):gr(n,o[0]).properties.dist<=i&&gr(n,o[1]).properties.dist<=i)?(e=!0,r=r?xi(r,t):t):(0===i?Pr(a[0],t)&&Pr(a[1],t):gr(t,a[0]).properties.dist<=i&&gr(t,a[1]).properties.dist<=i)&&(r=r?xi(r,n):n)}})),!1===e&&r&&(o.push(r),r=void 0))})),r&&o.push(r),f(o)}function xi(t,e){var n=Q(e),r=Q(t),i=r[0],o=r[r.length-1],a=t.geometry.coordinates;return vi(n[0],i)?a.unshift(n[1]):vi(n[0],o)?a.push(n[1]):vi(n[1],i)?a.unshift(n[0]):vi(n[1],o)&&a.push(n[0]),t}function bi(t){var e=t%360;return e<0&&(e+=360),e}function wi(t,e,n){var r;return void 0===n&&(n={}),(r=n.final?Ei(K(e),K(t)):Ei(K(t),K(e)))>180?-(360-r):r}function Ei(t,e){var n=S(t[1]),r=S(e[1]),i=S(e[0]-t[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);var o=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(E(Math.atan2(i,o))+360)%360}function Si(t,n,r,i){void 0===i&&(i={});var o=n<0,a=M(Math.abs(n),i.units,"meters");o&&(a=-Math.abs(a));var l=K(t),u=function(t,n,r,i){var o=n/(i=void 0===i?e:Number(i)),a=t[0]*Math.PI/180,s=S(t[1]),l=S(r),u=o*Math.cos(l),c=s+u;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var h=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),p=Math.abs(h)>1e-11?u/h:Math.cos(s);return[(180*(a+o*Math.sin(l)/p)/Math.PI+540)%360-180,180*c/Math.PI]}(l,a,r);return u[0]+=u[0]-l[0]>180?-360:l[0]-u[0]>180?360:0,s(u,i.properties)}function Mi(t,e,n,r,i,o){for(var a=0;a0?Ci(e,s,i)<0||(i=s):n>0&&r<=0&&(Ti(e,s,o)||(o=s)),n=r}return[i,o]}function Ti(t,e,n){return Ci(t,e,n)>0}function Ci(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1])}function Ii(t){for(var e,n,r=Q(t),i=0,o=1;o0}function Ai(t,e){switch("Feature"===t.type?t.geometry.type:t.type){case"GeometryCollection":return B(t,(function(t){Ai(t,e)})),t;case"LineString":return Li(Q(t),e),t;case"Polygon":return Pi(Q(t),e),t;case"MultiLineString":return Q(t).forEach((function(t){Li(t,e)})),t;case"MultiPolygon":return Q(t).forEach((function(t){Pi(t,e)})),t;case"Point":case"MultiPoint":return t}}function Li(t,e){Ii(t)===e&&t.reverse()}function Pi(t,e){Ii(t[0])!==e&&t[0].reverse();for(var n=1;na?128:64,u|=ha?32:16,u|=pa?8:4;var d=+(u|=fa?2:1),m=0;if(17===u||18===u||33===u||34===u||38===u||68===u||72===u||98===u||102===u||132===u||136===u||137===u||152===u||153===u){var g=(c+h+p+f)/4;m=g>a?2:g0?(u=156,m=4):u=152:33===u?m>0?(u=139,m=4):u=137:72===u?m>0?(u=99,m=4):u=98:132===u&&(m>0?(u=39,m=4):u=38)}if(0!=u&&170!=u){var y,v,_,x,b,w,E,S;y=v=_=x=b=w=E=S=.5;var M=[];1===u?(_=1-Mo(e,p,f),S=1-Mo(e,c,f),M.push(_o[u])):169===u?(_=Mo(a,f,p),S=Mo(a,f,c),M.push(_o[u])):4===u?(w=1-Mo(e,h,p),x=Mo(e,f,p),M.push(yo[u])):166===u?(w=Mo(a,p,h),x=1-Mo(a,p,f),M.push(yo[u])):16===u?(b=Mo(e,p,h),v=Mo(e,c,h),M.push(go[u])):154===u?(b=1-Mo(a,h,p),v=1-Mo(a,h,c),M.push(go[u])):64===u?(E=Mo(e,f,c),y=1-Mo(e,h,c),M.push(bo[u])):106===u?(E=1-Mo(a,c,f),y=Mo(a,c,h),M.push(bo[u])):168===u?(x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),M.push(vo[u]),M.push(_o[u])):2===u?(x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),M.push(vo[u]),M.push(_o[u])):162===u?(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),M.push(vo[u]),M.push(_o[u])):8===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),M.push(go[u]),M.push(yo[u])):138===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(go[u]),M.push(yo[u])):32===u?(b=Mo(a,p,h),w=Mo(e,p,h),y=Mo(e,c,h),v=Mo(a,c,h),M.push(go[u]),M.push(yo[u])):42===u?(S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h),M.push(xo[u]),M.push(bo[u])):128===u&&(S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(xo[u]),M.push(bo[u])),5===u?(w=1-Mo(e,h,p),S=1-Mo(e,c,f),M.push(yo[u])):165===u?(w=Mo(a,p,h),S=Mo(a,f,c),M.push(yo[u])):20===u?(x=Mo(e,f,p),v=Mo(e,c,h),M.push(vo[u])):150===u?(x=1-Mo(a,p,f),v=1-Mo(a,h,c),M.push(vo[u])):80===u?(b=Mo(e,p,h),E=Mo(e,f,c),M.push(go[u])):90===u?(b=1-Mo(a,h,p),E=1-Mo(a,c,f),M.push(go[u])):65===u?(_=1-Mo(e,p,f),y=1-Mo(e,h,c),M.push(_o[u])):105===u?(_=Mo(a,f,p),y=Mo(a,c,h),M.push(_o[u])):160===u?(b=Mo(a,p,h),w=Mo(e,p,h),S=Mo(e,f,c),E=Mo(a,f,c),M.push(go[u]),M.push(yo[u])):10===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),S=1-Mo(a,c,f),E=1-Mo(e,c,f),M.push(go[u]),M.push(yo[u])):130===u?(x=1-Mo(e,p,f),_=1-Mo(a,p,f),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(vo[u]),M.push(_o[u])):40===u?(x=Mo(a,f,p),_=Mo(e,f,p),y=Mo(e,c,h),v=Mo(a,c,h),M.push(vo[u]),M.push(_o[u])):101===u?(w=Mo(a,p,h),y=Mo(a,c,h),M.push(yo[u])):69===u?(w=1-Mo(e,h,p),y=1-Mo(e,h,c),M.push(yo[u])):149===u?(S=Mo(a,f,c),v=1-Mo(a,h,c),M.push(xo[u])):21===u?(S=1-Mo(e,c,f),v=Mo(e,c,h),M.push(xo[u])):86===u?(x=1-Mo(a,p,f),E=1-Mo(a,c,f),M.push(vo[u])):84===u?(x=Mo(e,f,p),E=Mo(e,f,c),M.push(vo[u])):89===u?(b=1-Mo(a,h,p),_=Mo(a,f,p),M.push(_o[u])):81===u?(b=Mo(e,p,h),_=1-Mo(e,p,f),M.push(_o[u])):96===u?(b=Mo(a,p,h),w=Mo(e,p,h),E=Mo(e,f,c),y=Mo(a,c,h),M.push(go[u]),M.push(yo[u])):74===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),E=1-Mo(a,c,f),y=1-Mo(e,h,c),M.push(go[u]),M.push(yo[u])):24===u?(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),v=Mo(e,c,h),M.push(go[u]),M.push(_o[u])):146===u?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),v=1-Mo(a,h,c),M.push(go[u]),M.push(_o[u])):6===u?(w=1-Mo(e,h,p),x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),M.push(yo[u]),M.push(vo[u])):164===u?(w=Mo(a,p,h),x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),M.push(yo[u]),M.push(vo[u])):129===u?(_=1-Mo(e,p,f),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(_o[u]),M.push(xo[u])):41===u?(_=Mo(a,f,p),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h),M.push(_o[u]),M.push(xo[u])):66===u?(x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),y=1-Mo(e,h,c),M.push(vo[u]),M.push(_o[u])):104===u?(x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),y=Mo(a,c,h),M.push(_o[u]),M.push(wo[u])):144===u?(b=Mo(e,p,h),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c),M.push(go[u]),M.push(bo[u])):26===u?(b=1-Mo(a,h,p),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h),M.push(go[u]),M.push(bo[u])):36===u?(w=Mo(a,p,h),x=Mo(e,f,p),y=Mo(e,c,h),v=Mo(a,c,h),M.push(yo[u]),M.push(vo[u])):134===u?(w=1-Mo(e,h,p),x=1-Mo(a,p,f),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(yo[u]),M.push(vo[u])):9===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),S=1-Mo(e,c,f),M.push(go[u]),M.push(yo[u])):161===u?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),S=Mo(a,f,c),M.push(go[u]),M.push(yo[u])):37===u?(w=Mo(a,p,h),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h),M.push(yo[u]),M.push(xo[u])):133===u?(w=1-Mo(e,h,p),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c),M.push(yo[u]),M.push(xo[u])):148===u?(x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c),M.push(vo[u]),M.push(bo[u])):22===u?(x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h),M.push(vo[u]),M.push(bo[u])):82===u?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),M.push(go[u]),M.push(_o[u])):88===u?(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),M.push(go[u]),M.push(_o[u])):73===u?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),y=1-Mo(e,h,c),M.push(go[u]),M.push(yo[u])):97===u?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),y=Mo(a,c,h),M.push(go[u]),M.push(yo[u])):145===u?(b=Mo(e,p,h),_=1-Mo(e,p,f),S=Mo(a,f,c),v=1-Mo(a,h,c),M.push(go[u]),M.push(xo[u])):25===u?(b=1-Mo(a,h,p),_=Mo(a,f,p),S=1-Mo(e,c,f),v=Mo(e,c,h),M.push(go[u]),M.push(xo[u])):70===u?(w=1-Mo(e,h,p),x=1-Mo(a,p,f),E=1-Mo(a,c,f),y=1-Mo(e,h,c),M.push(yo[u]),M.push(vo[u])):100===u?(w=Mo(a,p,h),x=Mo(e,f,p),E=Mo(e,f,c),y=Mo(a,c,h),M.push(yo[u]),M.push(vo[u])):34===u?(0===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(xo[u]),M.push(bo[u])):35===u?(4===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(_o[u]),M.push(bo[u])):136===u?(0===m?(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)):(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)),M.push(go[u]),M.push(yo[u]),M.push(xo[u]),M.push(bo[u])):153===u?(0===m?(b=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(_o[u])):102===u?(0===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(yo[u]),M.push(bo[u])):155===u?(4===m?(b=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(xo[u])):103===u?(4===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(yo[u]),M.push(vo[u])):152===u?(0===m?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(vo[u]),M.push(_o[u])):156===u?(4===m?(b=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),v=Mo(e,c,h)):(b=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),v=1-Mo(a,h,c)),M.push(go[u]),M.push(_o[u]),M.push(bo[u])):137===u?(0===m?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)):(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)),M.push(go[u]),M.push(yo[u]),M.push(_o[u])):139===u?(4===m?(b=Mo(a,p,h),w=Mo(e,p,h),_=1-Mo(e,p,f),S=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)):(b=1-Mo(e,h,p),w=1-Mo(a,h,p),_=Mo(a,f,p),S=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)),M.push(go[u]),M.push(yo[u]),M.push(xo[u])):98===u?(0===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(bo[u])):99===u?(4===m?(b=1-Mo(e,h,p),w=1-Mo(a,h,p),x=Mo(a,f,p),_=Mo(e,f,p),E=Mo(e,f,c),y=1-Mo(e,h,c)):(b=Mo(a,p,h),w=Mo(e,p,h),x=1-Mo(e,p,f),_=1-Mo(a,p,f),E=1-Mo(a,c,f),y=Mo(a,c,h)),M.push(go[u]),M.push(yo[u]),M.push(_o[u])):38===u?(0===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(yo[u]),M.push(xo[u]),M.push(bo[u])):39===u?(4===m?(w=1-Mo(e,h,p),x=Mo(e,f,p),S=Mo(e,f,c),E=Mo(a,f,c),y=1-Mo(a,h,c),v=1-Mo(e,h,c)):(w=Mo(a,p,h),x=1-Mo(a,p,f),S=1-Mo(a,c,f),E=1-Mo(e,c,f),y=Mo(e,c,h),v=Mo(a,c,h)),M.push(yo[u]),M.push(vo[u]),M.push(bo[u])):85===u&&(b=1,w=0,x=1,_=0,S=0,E=1,y=0,v=1),(y<0||y>1||v<0||v>1||b<0||b>1||x<0||x>1||S<0||S>1||E<0||E>1)&&console.log("MarchingSquaresJS-isoBands: "+u+" "+d+" "+c+","+h+","+p+","+f+" "+m+" "+y+" "+v+" "+b+" "+w+" "+x+" "+_+" "+S+" "+E),o.cells[s][l]={cval:u,cval_real:d,flipped:m,topleft:y,topright:v,righttop:b,rightbottom:w,bottomright:x,bottomleft:_,leftbottom:S,lefttop:E,edges:M}}}}}return o}(t,e,n);return Di.polygons?(Di.verbose&&console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell"),l=function(t){var e=[],n=0;return t.cells.forEach((function(t,r){t.forEach((function(t,i){if(void 0!==t){var o=So[t.cval](t);"object"==typeof o&&To(o)?"object"==typeof o[0]&&To(o[0])?"object"==typeof o[0][0]&&To(o[0][0])?o.forEach((function(t){t.forEach((function(t){t[0]+=i,t[1]+=r})),e[n++]=t})):(o.forEach((function(t){t[0]+=i,t[1]+=r})),e[n++]=o):console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"):console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates")}}))})),e}(u)):(Di.verbose&&console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"),l=function(t){for(var e=[],n=t.rows,r=t.cols,i=[],o=0;o0){var s=Io(t.cells[o][a]),l=null,u=a,c=o;null!==s&&i.push([s.p[0]+u,s.p[1]+c]);do{if(null===(l=Ao(t.cells[c][u],s.x,s.y,s.o)))break;if(i.push([l.p[0]+u,l.p[1]+c]),u+=l.x,s=l,(c+=l.y)<0||c>=n||u<0||u>=r||void 0===t.cells[c][u]){var h=Co(t,u-=l.x,c-=l.y,l.x,l.y,l.o);if(null===h)break;h.path.forEach((function(t){i.push(t)})),u=h.i,c=h.j,s=h}}while(void 0!==t.cells[c][u]&&t.cells[c][u].edges.length>0);e.push(i),i=[],t.cells[o][a].edges.length>0&&a--}return e}(u)),"function"==typeof Di.successCallback&&Di.successCallback(l),l}var Oi=64,ki=16,zi=[],Fi=[],Bi=[],Ui=[],Vi=[],Gi=[],ji=[],Hi=[],qi=[],Wi=[],Xi=[],Zi=[],Yi=[],Ji=[],Ki=[],Qi=[],$i=[],to=[],eo=[],no=[],ro=[],io=[],oo=[],ao=[];ji[85]=Wi[85]=-1,Hi[85]=Xi[85]=0,qi[85]=Zi[85]=1,eo[85]=io[85]=1,no[85]=oo[85]=0,ro[85]=ao[85]=1,zi[85]=Ui[85]=0,Fi[85]=Vi[85]=-1,Bi[85]=Ki[85]=0,Qi[85]=Yi[85]=0,$i[85]=Ji[85]=1,Gi[85]=to[85]=1,io[1]=io[169]=0,oo[1]=oo[169]=-1,ao[1]=ao[169]=0,Yi[1]=Yi[169]=-1,Ji[1]=Ji[169]=0,Ki[1]=Ki[169]=0,Wi[4]=Wi[166]=0,Xi[4]=Xi[166]=-1,Zi[4]=Zi[166]=1,Qi[4]=Qi[166]=1,$i[4]=$i[166]=0,to[4]=to[166]=0,ji[16]=ji[154]=0,Hi[16]=Hi[154]=1,qi[16]=qi[154]=1,Ui[16]=Ui[154]=1,Vi[16]=Vi[154]=0,Gi[16]=Gi[154]=1,eo[64]=eo[106]=0,no[64]=no[106]=1,ro[64]=ro[106]=0,zi[64]=zi[106]=-1,Fi[64]=Fi[106]=0,Bi[64]=Bi[106]=1,eo[2]=eo[168]=0,no[2]=no[168]=-1,ro[2]=ro[168]=1,io[2]=io[168]=0,oo[2]=oo[168]=-1,ao[2]=ao[168]=0,Yi[2]=Yi[168]=-1,Ji[2]=Ji[168]=0,Ki[2]=Ki[168]=0,Qi[2]=Qi[168]=-1,$i[2]=$i[168]=0,to[2]=to[168]=1,ji[8]=ji[162]=0,Hi[8]=Hi[162]=-1,qi[8]=qi[162]=0,Wi[8]=Wi[162]=0,Xi[8]=Xi[162]=-1,Zi[8]=Zi[162]=1,Yi[8]=Yi[162]=1,Ji[8]=Ji[162]=0,Ki[8]=Ki[162]=1,Qi[8]=Qi[162]=1,$i[8]=$i[162]=0,to[8]=to[162]=0,ji[32]=ji[138]=0,Hi[32]=Hi[138]=1,qi[32]=qi[138]=1,Wi[32]=Wi[138]=0,Xi[32]=Xi[138]=1,Zi[32]=Zi[138]=0,zi[32]=zi[138]=1,Fi[32]=Fi[138]=0,Bi[32]=Bi[138]=0,Ui[32]=Ui[138]=1,Vi[32]=Vi[138]=0,Gi[32]=Gi[138]=1,io[128]=io[42]=0,oo[128]=oo[42]=1,ao[128]=ao[42]=1,eo[128]=eo[42]=0,no[128]=no[42]=1,ro[128]=ro[42]=0,zi[128]=zi[42]=-1,Fi[128]=Fi[42]=0,Bi[128]=Bi[42]=1,Ui[128]=Ui[42]=-1,Vi[128]=Vi[42]=0,Gi[128]=Gi[42]=0,Wi[5]=Wi[165]=-1,Xi[5]=Xi[165]=0,Zi[5]=Zi[165]=0,io[5]=io[165]=1,oo[5]=oo[165]=0,ao[5]=ao[165]=0,Qi[20]=Qi[150]=0,$i[20]=$i[150]=1,to[20]=to[150]=1,Ui[20]=Ui[150]=0,Vi[20]=Vi[150]=-1,Gi[20]=Gi[150]=1,ji[80]=ji[90]=-1,Hi[80]=Hi[90]=0,qi[80]=qi[90]=1,eo[80]=eo[90]=1,no[80]=no[90]=0,ro[80]=ro[90]=1,Yi[65]=Yi[105]=0,Ji[65]=Ji[105]=1,Ki[65]=Ki[105]=0,zi[65]=zi[105]=0,Fi[65]=Fi[105]=-1,Bi[65]=Bi[105]=0,ji[160]=ji[10]=-1,Hi[160]=Hi[10]=0,qi[160]=qi[10]=1,Wi[160]=Wi[10]=-1,Xi[160]=Xi[10]=0,Zi[160]=Zi[10]=0,io[160]=io[10]=1,oo[160]=oo[10]=0,ao[160]=ao[10]=0,eo[160]=eo[10]=1,no[160]=no[10]=0,ro[160]=ro[10]=1,Qi[130]=Qi[40]=0,$i[130]=$i[40]=1,to[130]=to[40]=1,Yi[130]=Yi[40]=0,Ji[130]=Ji[40]=1,Ki[130]=Ki[40]=0,zi[130]=zi[40]=0,Fi[130]=Fi[40]=-1,Bi[130]=Bi[40]=0,Ui[130]=Ui[40]=0,Vi[130]=Vi[40]=-1,Gi[130]=Gi[40]=1,Wi[37]=Wi[133]=0,Xi[37]=Xi[133]=1,Zi[37]=Zi[133]=1,io[37]=io[133]=0,oo[37]=oo[133]=1,ao[37]=ao[133]=0,zi[37]=zi[133]=-1,Fi[37]=Fi[133]=0,Bi[37]=Bi[133]=0,Ui[37]=Ui[133]=1,Vi[37]=Vi[133]=0,Gi[37]=Gi[133]=0,Qi[148]=Qi[22]=-1,$i[148]=$i[22]=0,to[148]=to[22]=0,io[148]=io[22]=0,oo[148]=oo[22]=-1,ao[148]=ao[22]=1,eo[148]=eo[22]=0,no[148]=no[22]=1,ro[148]=ro[22]=1,Ui[148]=Ui[22]=-1,Vi[148]=Vi[22]=0,Gi[148]=Gi[22]=1,ji[82]=ji[88]=0,Hi[82]=Hi[88]=-1,qi[82]=qi[88]=1,Qi[82]=Qi[88]=1,$i[82]=$i[88]=0,to[82]=to[88]=1,Yi[82]=Yi[88]=-1,Ji[82]=Ji[88]=0,Ki[82]=Ki[88]=1,eo[82]=eo[88]=0,no[82]=no[88]=-1,ro[82]=ro[88]=0,ji[73]=ji[97]=0,Hi[73]=Hi[97]=1,qi[73]=qi[97]=0,Wi[73]=Wi[97]=0,Xi[73]=Xi[97]=-1,Zi[73]=Zi[97]=0,Yi[73]=Yi[97]=1,Ji[73]=Ji[97]=0,Ki[73]=Ki[97]=0,zi[73]=zi[97]=1,Fi[73]=Fi[97]=0,Bi[73]=Bi[97]=1,ji[145]=ji[25]=0,Hi[145]=Hi[25]=-1,qi[145]=qi[25]=0,Yi[145]=Yi[25]=1,Ji[145]=Ji[25]=0,Ki[145]=Ki[25]=1,io[145]=io[25]=0,oo[145]=oo[25]=1,ao[145]=ao[25]=1,Ui[145]=Ui[25]=-1,Vi[145]=Vi[25]=0,Gi[145]=Gi[25]=0,Wi[70]=Wi[100]=0,Xi[70]=Xi[100]=1,Zi[70]=Zi[100]=0,Qi[70]=Qi[100]=-1,$i[70]=$i[100]=0,to[70]=to[100]=1,eo[70]=eo[100]=0,no[70]=no[100]=-1,ro[70]=ro[100]=1,zi[70]=zi[100]=1,Fi[70]=Fi[100]=0,Bi[70]=Bi[100]=0,Wi[101]=Wi[69]=0,Xi[101]=Xi[69]=1,Zi[101]=Zi[69]=0,zi[101]=zi[69]=1,Fi[101]=Fi[69]=0,Bi[101]=Bi[69]=0,io[149]=io[21]=0,oo[149]=oo[21]=1,ao[149]=ao[21]=1,Ui[149]=Ui[21]=-1,Vi[149]=Vi[21]=0,Gi[149]=Gi[21]=0,Qi[86]=Qi[84]=-1,$i[86]=$i[84]=0,to[86]=to[84]=1,eo[86]=eo[84]=0,no[86]=no[84]=-1,ro[86]=ro[84]=1,ji[89]=ji[81]=0,Hi[89]=Hi[81]=-1,qi[89]=qi[81]=0,Yi[89]=Yi[81]=1,Ji[89]=Ji[81]=0,Ki[89]=Ki[81]=1,ji[96]=ji[74]=0,Hi[96]=Hi[74]=1,qi[96]=qi[74]=0,Wi[96]=Wi[74]=-1,Xi[96]=Xi[74]=0,Zi[96]=Zi[74]=1,eo[96]=eo[74]=1,no[96]=no[74]=0,ro[96]=ro[74]=0,zi[96]=zi[74]=1,Fi[96]=Fi[74]=0,Bi[96]=Bi[74]=1,ji[24]=ji[146]=0,Hi[24]=Hi[146]=-1,qi[24]=qi[146]=1,Qi[24]=Qi[146]=1,$i[24]=$i[146]=0,to[24]=to[146]=1,Yi[24]=Yi[146]=0,Ji[24]=Ji[146]=1,Ki[24]=Ki[146]=1,Ui[24]=Ui[146]=0,Vi[24]=Vi[146]=-1,Gi[24]=Gi[146]=0,Wi[6]=Wi[164]=-1,Xi[6]=Xi[164]=0,Zi[6]=Zi[164]=1,Qi[6]=Qi[164]=-1,$i[6]=$i[164]=0,to[6]=to[164]=0,io[6]=io[164]=0,oo[6]=oo[164]=-1,ao[6]=ao[164]=1,eo[6]=eo[164]=1,no[6]=no[164]=0,ro[6]=ro[164]=0,Yi[129]=Yi[41]=0,Ji[129]=Ji[41]=1,Ki[129]=Ki[41]=1,io[129]=io[41]=0,oo[129]=oo[41]=1,ao[129]=ao[41]=0,zi[129]=zi[41]=-1,Fi[129]=Fi[41]=0,Bi[129]=Bi[41]=0,Ui[129]=Ui[41]=0,Vi[129]=Vi[41]=-1,Gi[129]=Gi[41]=0,Qi[66]=Qi[104]=0,$i[66]=$i[104]=1,to[66]=to[104]=0,Yi[66]=Yi[104]=-1,Ji[66]=Ji[104]=0,Ki[66]=Ki[104]=1,eo[66]=eo[104]=0,no[66]=no[104]=-1,ro[66]=ro[104]=0,zi[66]=zi[104]=0,Fi[66]=Fi[104]=-1,Bi[66]=Bi[104]=1,ji[144]=ji[26]=-1,Hi[144]=Hi[26]=0,qi[144]=qi[26]=0,io[144]=io[26]=1,oo[144]=oo[26]=0,ao[144]=ao[26]=1,eo[144]=eo[26]=0,no[144]=no[26]=1,ro[144]=ro[26]=1,Ui[144]=Ui[26]=-1,Vi[144]=Vi[26]=0,Gi[144]=Gi[26]=1,Wi[36]=Wi[134]=0,Xi[36]=Xi[134]=1,Zi[36]=Zi[134]=1,Qi[36]=Qi[134]=0,$i[36]=$i[134]=1,to[36]=to[134]=0,zi[36]=zi[134]=0,Fi[36]=Fi[134]=-1,Bi[36]=Bi[134]=1,Ui[36]=Ui[134]=1,Vi[36]=Vi[134]=0,Gi[36]=Gi[134]=0,ji[9]=ji[161]=-1,Hi[9]=Hi[161]=0,qi[9]=qi[161]=0,Wi[9]=Wi[161]=0,Xi[9]=Xi[161]=-1,Zi[9]=Zi[161]=0,Yi[9]=Yi[161]=1,Ji[9]=Ji[161]=0,Ki[9]=Ki[161]=0,io[9]=io[161]=1,oo[9]=oo[161]=0,ao[9]=ao[161]=1,ji[136]=0,Hi[136]=1,qi[136]=1,Wi[136]=0,Xi[136]=1,Zi[136]=0,Qi[136]=-1,$i[136]=0,to[136]=1,Yi[136]=-1,Ji[136]=0,Ki[136]=0,io[136]=0,oo[136]=-1,ao[136]=0,eo[136]=0,no[136]=-1,ro[136]=1,zi[136]=1,Fi[136]=0,Bi[136]=0,Ui[136]=1,Vi[136]=0,Gi[136]=1,ji[34]=0,Hi[34]=-1,qi[34]=0,Wi[34]=0,Xi[34]=-1,Zi[34]=1,Qi[34]=1,$i[34]=0,to[34]=0,Yi[34]=1,Ji[34]=0,Ki[34]=1,io[34]=0,oo[34]=1,ao[34]=1,eo[34]=0,no[34]=1,ro[34]=0,zi[34]=-1,Fi[34]=0,Bi[34]=1,Ui[34]=-1,Vi[34]=0,Gi[34]=0,ji[35]=0,Hi[35]=1,qi[35]=1,Wi[35]=0,Xi[35]=-1,Zi[35]=1,Qi[35]=1,$i[35]=0,to[35]=0,Yi[35]=-1,Ji[35]=0,Ki[35]=0,io[35]=0,oo[35]=-1,ao[35]=0,eo[35]=0,no[35]=1,ro[35]=0,zi[35]=-1,Fi[35]=0,Bi[35]=1,Ui[35]=1,Vi[35]=0,Gi[35]=1,ji[153]=0,Hi[153]=1,qi[153]=1,Yi[153]=-1,Ji[153]=0,Ki[153]=0,io[153]=0,oo[153]=-1,ao[153]=0,Ui[153]=1,Vi[153]=0,Gi[153]=1,Wi[102]=0,Xi[102]=-1,Zi[102]=1,Qi[102]=1,$i[102]=0,to[102]=0,eo[102]=0,no[102]=1,ro[102]=0,zi[102]=-1,Fi[102]=0,Bi[102]=1,ji[155]=0,Hi[155]=-1,qi[155]=0,Yi[155]=1,Ji[155]=0,Ki[155]=1,io[155]=0,oo[155]=1,ao[155]=1,Ui[155]=-1,Vi[155]=0,Gi[155]=0,Wi[103]=0,Xi[103]=1,Zi[103]=0,Qi[103]=-1,$i[103]=0,to[103]=1,eo[103]=0,no[103]=-1,ro[103]=1,zi[103]=1,Fi[103]=0,Bi[103]=0,ji[152]=0,Hi[152]=1,qi[152]=1,Qi[152]=-1,$i[152]=0,to[152]=1,Yi[152]=-1,Ji[152]=0,Ki[152]=0,io[152]=0,oo[152]=-1,ao[152]=0,eo[152]=0,no[152]=-1,ro[152]=1,Ui[152]=1,Vi[152]=0,Gi[152]=1,ji[156]=0,Hi[156]=-1,qi[156]=1,Qi[156]=1,$i[156]=0,to[156]=1,Yi[156]=-1,Ji[156]=0,Ki[156]=0,io[156]=0,oo[156]=-1,ao[156]=0,eo[156]=0,no[156]=1,ro[156]=1,Ui[156]=-1,Vi[156]=0,Gi[156]=1,ji[137]=0,Hi[137]=1,qi[137]=1,Wi[137]=0,Xi[137]=1,Zi[137]=0,Yi[137]=-1,Ji[137]=0,Ki[137]=0,io[137]=0,oo[137]=-1,ao[137]=0,zi[137]=1,Fi[137]=0,Bi[137]=0,Ui[137]=1,Vi[137]=0,Gi[137]=1,ji[139]=0,Hi[139]=1,qi[139]=1,Wi[139]=0,Xi[139]=-1,Zi[139]=0,Yi[139]=1,Ji[139]=0,Ki[139]=0,io[139]=0,oo[139]=1,ao[139]=0,zi[139]=-1,Fi[139]=0,Bi[139]=0,Ui[139]=1,Vi[139]=0,Gi[139]=1,ji[98]=0,Hi[98]=-1,qi[98]=0,Wi[98]=0,Xi[98]=-1,Zi[98]=1,Qi[98]=1,$i[98]=0,to[98]=0,Yi[98]=1,Ji[98]=0,Ki[98]=1,eo[98]=0,no[98]=1,ro[98]=0,zi[98]=-1,Fi[98]=0,Bi[98]=1,ji[99]=0,Hi[99]=1,qi[99]=0,Wi[99]=0,Xi[99]=-1,Zi[99]=1,Qi[99]=1,$i[99]=0,to[99]=0,Yi[99]=-1,Ji[99]=0,Ki[99]=1,eo[99]=0,no[99]=-1,ro[99]=0,zi[99]=1,Fi[99]=0,Bi[99]=1,Wi[38]=0,Xi[38]=-1,Zi[38]=1,Qi[38]=1,$i[38]=0,to[38]=0,io[38]=0,oo[38]=1,ao[38]=1,eo[38]=0,no[38]=1,ro[38]=0,zi[38]=-1,Fi[38]=0,Bi[38]=1,Ui[38]=-1,Vi[38]=0,Gi[38]=0,Wi[39]=0,Xi[39]=1,Zi[39]=1,Qi[39]=-1,$i[39]=0,to[39]=0,io[39]=0,oo[39]=-1,ao[39]=1,eo[39]=0,no[39]=1,ro[39]=0,zi[39]=-1,Fi[39]=0,Bi[39]=1,Ui[39]=1,Vi[39]=0,Gi[39]=0;var so=function(t){return[[t.bottomleft,0],[0,0],[0,t.leftbottom]]},lo=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0]]},uo=function(t){return[[t.topright,1],[1,1],[1,t.righttop]]},co=function(t){return[[0,t.lefttop],[0,1],[t.topleft,1]]},ho=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop]]},po=function(t){return[[t.bottomright,0],[t.bottomleft,0],[1,t.righttop],[1,t.rightbottom]]},fo=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.topleft,1],[t.topright,1]]},mo=function(t){return[[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},go=[],yo=[],vo=[],_o=[],xo=[],bo=[],wo=[],Eo=[];_o[1]=xo[1]=18,_o[169]=xo[169]=18,vo[4]=yo[4]=12,vo[166]=yo[166]=12,go[16]=Eo[16]=4,go[154]=Eo[154]=4,bo[64]=wo[64]=22,bo[106]=wo[106]=22,vo[2]=bo[2]=17,_o[2]=xo[2]=18,vo[168]=bo[168]=17,_o[168]=xo[168]=18,go[8]=_o[8]=9,yo[8]=vo[8]=12,go[162]=_o[162]=9,yo[162]=vo[162]=12,go[32]=Eo[32]=4,yo[32]=wo[32]=1,go[138]=Eo[138]=4,yo[138]=wo[138]=1,xo[128]=Eo[128]=21,bo[128]=wo[128]=22,xo[42]=Eo[42]=21,bo[42]=wo[42]=22,yo[5]=xo[5]=14,yo[165]=xo[165]=14,vo[20]=Eo[20]=6,vo[150]=Eo[150]=6,go[80]=bo[80]=11,go[90]=bo[90]=11,_o[65]=wo[65]=3,_o[105]=wo[105]=3,go[160]=bo[160]=11,yo[160]=xo[160]=14,go[10]=bo[10]=11,yo[10]=xo[10]=14,vo[130]=Eo[130]=6,_o[130]=wo[130]=3,vo[40]=Eo[40]=6,_o[40]=wo[40]=3,yo[101]=wo[101]=1,yo[69]=wo[69]=1,xo[149]=Eo[149]=21,xo[21]=Eo[21]=21,vo[86]=bo[86]=17,vo[84]=bo[84]=17,go[89]=_o[89]=9,go[81]=_o[81]=9,go[96]=wo[96]=0,yo[96]=bo[96]=15,go[74]=wo[74]=0,yo[74]=bo[74]=15,go[24]=vo[24]=8,_o[24]=Eo[24]=7,go[146]=vo[146]=8,_o[146]=Eo[146]=7,yo[6]=bo[6]=15,vo[6]=xo[6]=16,yo[164]=bo[164]=15,vo[164]=xo[164]=16,_o[129]=Eo[129]=7,xo[129]=wo[129]=20,_o[41]=Eo[41]=7,xo[41]=wo[41]=20,vo[66]=wo[66]=2,_o[66]=bo[66]=19,vo[104]=wo[104]=2,_o[104]=bo[104]=19,go[144]=xo[144]=10,bo[144]=Eo[144]=23,go[26]=xo[26]=10,bo[26]=Eo[26]=23,yo[36]=Eo[36]=5,vo[36]=wo[36]=2,yo[134]=Eo[134]=5,vo[134]=wo[134]=2,go[9]=xo[9]=10,yo[9]=_o[9]=13,go[161]=xo[161]=10,yo[161]=_o[161]=13,yo[37]=Eo[37]=5,xo[37]=wo[37]=20,yo[133]=Eo[133]=5,xo[133]=wo[133]=20,vo[148]=xo[148]=16,bo[148]=Eo[148]=23,vo[22]=xo[22]=16,bo[22]=Eo[22]=23,go[82]=vo[82]=8,_o[82]=bo[82]=19,go[88]=vo[88]=8,_o[88]=bo[88]=19,go[73]=wo[73]=0,yo[73]=_o[73]=13,go[97]=wo[97]=0,yo[97]=_o[97]=13,go[145]=_o[145]=9,xo[145]=Eo[145]=21,go[25]=_o[25]=9,xo[25]=Eo[25]=21,yo[70]=wo[70]=1,vo[70]=bo[70]=17,yo[100]=wo[100]=1,vo[100]=bo[100]=17,go[34]=_o[34]=9,yo[34]=vo[34]=12,xo[34]=Eo[34]=21,bo[34]=wo[34]=22,go[136]=Eo[136]=4,yo[136]=wo[136]=1,vo[136]=bo[136]=17,_o[136]=xo[136]=18,go[35]=Eo[35]=4,yo[35]=vo[35]=12,_o[35]=xo[35]=18,bo[35]=wo[35]=22,go[153]=Eo[153]=4,_o[153]=xo[153]=18,yo[102]=vo[102]=12,bo[102]=wo[102]=22,go[155]=_o[155]=9,xo[155]=Eo[155]=23,yo[103]=wo[103]=1,vo[103]=bo[103]=17,go[152]=Eo[152]=4,vo[152]=bo[152]=17,_o[152]=xo[152]=18,go[156]=vo[156]=8,_o[156]=xo[156]=18,bo[156]=Eo[156]=23,go[137]=Eo[137]=4,yo[137]=wo[137]=1,_o[137]=xo[137]=18,go[139]=Eo[139]=4,yo[139]=_o[139]=13,xo[139]=wo[139]=20,go[98]=_o[98]=9,yo[98]=vo[98]=12,bo[98]=wo[98]=22,go[99]=wo[99]=0,yo[99]=vo[99]=12,_o[99]=bo[99]=19,yo[38]=vo[38]=12,xo[38]=Eo[38]=21,bo[38]=wo[38]=22,yo[39]=Eo[39]=5,vo[39]=xo[39]=16,bo[39]=wo[39]=22;var So=[];function Mo(t,e,n){return(t-e)/(n-e)}function To(t){return t.constructor.toString().indexOf("Array")>-1}function Co(t,e,n,r,i,o){for(var a=t.cells[n][e],s=a.cval_real,l=e+r,u=n+i,c=[],h=!1;!h;){if(void 0===t.cells[u]||void 0===t.cells[u][l])if(u-=i,l-=r,s=(a=t.cells[u][l]).cval_real,-1===i)if(0===o)if(1&s)c.push([l,u]),r=-1,i=0,o=0;else{if(!(4&s)){c.push([l+a.bottomright,u]),r=0,i=1,o=1,h=!0;break}c.push([l+1,u]),r=1,i=0,o=0}else{if(!(1&s)){if(4&s){c.push([l+a.bottomright,u]),r=0,i=1,o=1,h=!0;break}c.push([l+a.bottomleft,u]),r=0,i=1,o=0,h=!0;break}c.push([l,u]),r=-1,i=0,o=0}else if(1===i)if(0===o){if(!(s&ki)){if(s&Oi){c.push([l+a.topleft,u+1]),r=0,i=-1,o=0,h=!0;break}c.push([l+a.topright,u+1]),r=0,i=-1,o=1,h=!0;break}c.push([l+1,u+1]),r=1,i=0,o=1}else c.push([l+1,u+1]),r=1,i=0,o=1;else if(-1===r)if(0===o){if(!(s&Oi)){if(1&s){c.push([l,u+a.leftbottom]),r=1,i=0,o=0,h=!0;break}c.push([l,u+a.lefttop]),r=1,i=0,o=1,h=!0;break}c.push([l,u+1]),r=0,i=1,o=0}else{if(!(s&Oi)){console.log("MarchingSquaresJS-isoBands: wtf");break}c.push([l,u+1]),r=0,i=1,o=0}else{if(1!==r){console.log("MarchingSquaresJS-isoBands: we came from nowhere!");break}if(0===o){if(!(4&s)){c.push([l+1,u+a.rightbottom]),r=-1,i=0,o=0,h=!0;break}c.push([l+1,u]),r=0,i=-1,o=1}else{if(!(4&s)){if(s&ki){c.push([l+1,u+a.righttop]),r=-1,i=0,o=1;break}c.push([l+1,u+a.rightbottom]),r=-1,i=0,o=0,h=!0;break}c.push([l+1,u]),r=0,i=-1,o=1}}else if(s=(a=t.cells[u][l]).cval_real,-1===r)if(0===o)if(void 0!==t.cells[u-1]&&void 0!==t.cells[u-1][l])r=0,i=-1,o=1;else{if(!(1&s)){c.push([l+a.bottomright,u]),r=0,i=1,o=1,h=!0;break}c.push([l,u])}else{if(!(s&Oi)){console.log("MarchingSquaresJS-isoBands: found entry from top at "+l+","+u);break}console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!")}else if(1===r){if(0===o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[u+1]&&void 0!==t.cells[u+1][l])r=0,i=1,o=0;else{if(!(s&ki)){c.push([l+a.topleft,u+1]),r=0,i=-1,o=0,h=!0;break}c.push([l+1,u+1]),r=1,i=0,o=1}}else if(-1===i){if(1!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[u][l+1])r=1,i=0,o=1;else{if(!(4&s)){c.push([l+1,u+a.righttop]),r=-1,i=0,o=1,h=!0;break}c.push([l+1,u]),r=0,i=-1,o=1}}else{if(1!==i){console.log("MarchingSquaresJS-isoBands: where did we came from???");break}if(0!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[u][l-1])r=-1,i=0,o=0;else{if(!(s&Oi)){c.push([l,u+a.leftbottom]),r=1,i=0,o=0,h=!0;break}c.push([l,u+1]),r=0,i=1,o=0}}if(u+=i,(l+=r)===e&&u===n)break}return{path:c,i:l,j:u,x:r,y:i,o:o}}function Io(t){if(t.edges.length>0){var e=t.edges[t.edges.length-1],n=t.cval_real;switch(e){case 0:return n&ki?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 1:return 4&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 2:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 3:return 1&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 4:return n&ki?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 5:return 4&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 6:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 7:return 1&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 8:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.righttop],x:-1,y:0,o:1};case 9:return 1&n?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 10:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.righttop],x:-1,y:0,o:1};case 11:return n&Oi?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 12:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 13:return 1&n?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 14:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 15:return n&Oi?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 16:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 17:return n&Oi?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 18:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 19:return n&Oi?{p:[t.bottomleft,0],x:0,y:1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 20:return n&Oi?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 21:return n&ki?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.topright,1],x:0,y:-1,o:1};case 22:return n&Oi?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 23:return n&ki?{p:[0,t.lefttop],x:1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};default:console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t)}}return null}function Ao(t,e,n,r){var i,o,a,s,l,u=t.cval;switch(e){case-1:if(0===r)i=yo[u],a=Wi[u],s=Xi[u],l=Zi[u];else i=go[u],a=ji[u],s=Hi[u],l=qi[u];break;case 1:if(0===r)i=xo[u],a=io[u],s=oo[u],l=ao[u];else i=bo[u],a=eo[u],s=no[u],l=ro[u];break;default:switch(n){case-1:if(0===r)i=wo[u],a=zi[u],s=Fi[u],l=Bi[u];else i=Eo[u],a=Ui[u],s=Vi[u],l=Gi[u];break;case 1:if(0===r)i=_o[u],a=Yi[u],s=Ji[u],l=Ki[u];else i=vo[u],a=Qi[u],s=$i[u],l=to[u]}}if(o=t.edges.indexOf(i),void 0===t.edges[o])return null;switch(function(t,e){delete t.edges[e];for(var n=e+1;n0){var s=r[e-1],l=function(t,e){return!function(t,e){return 0===Fo(zo(t),zo(e))}(t,e)&&function(t,e){var n,r,i=t[0],o=zo(t),a=e[0],s=zo(e),l=Fo(o,s);return function(t,e){return[t[0]+e[0],t[1]+e[1]]}(i,function(t,e){return[t*e[0],t*e[1]]}(Fo((r=i,[(n=a)[0]-r[0],n[1]-r[1]]),s)/l,o))}(t,e)}(n,s);!1!==l&&(s[1]=l,n[0]=l),a.push(s[0]),e===o.length-2&&(a.push(n[0]),a.push(n[1]))}2===o.length&&(a.push(n[0]),a.push(n[1]))}var u,c,h,p,f,d})),h(a,t.properties)}function Uo(t,e,n){var r=e[0]-t[0],i=e[1]-t[1],o=n[0]-e[0];return function(t){return(t>0)-(t<0)||+t}(r*(n[1]-e[1])-o*i)}function Vo(t,e){return e.geometry.coordinates[0].every((function(e){return fe(s(e),t)}))}So[1]=So[169]=so,So[4]=So[166]=lo,So[16]=So[154]=uo,So[64]=So[106]=co,So[168]=So[2]=ho,So[162]=So[8]=po,So[138]=So[32]=fo,So[42]=So[128]=mo,So[5]=So[165]=function(t){return[[0,0],[0,t.leftbottom],[1,t.rightbottom],[1,0]]},So[20]=So[150]=function(t){return[[1,0],[t.bottomright,0],[t.topright,1],[1,1]]},So[80]=So[90]=function(t){return[[1,1],[1,t.righttop],[0,t.lefttop],[0,1]]},So[65]=So[105]=function(t){return[[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},So[160]=So[10]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.leftbottom],[0,t.lefttop]]},So[130]=So[40]=function(t){return[[t.topleft,1],[t.topright,1],[t.bottomright,0],[t.bottomleft,0]]},So[85]=function(){return[[0,0],[0,1],[1,1],[1,0]]},So[101]=So[69]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,1],[t.topleft,1]]},So[149]=So[21]=function(t){return[[t.topright,1],[1,1],[1,0],[0,0],[0,t.leftbottom]]},So[86]=So[84]=function(t){return[[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[1,1]]},So[89]=So[81]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,1]]},So[96]=So[74]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.lefttop],[0,1],[t.topleft,1]]},So[24]=So[146]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[t.topright,1]]},So[6]=So[164]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop]]},So[129]=So[41]=function(t){return[[t.topright,1],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1]]},So[66]=So[104]=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[144]=So[26]=function(t){return[[1,1],[1,t.righttop],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},So[36]=So[134]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[t.topleft,1],[t.topright,1]]},So[9]=So[161]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom]]},So[37]=So[133]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},So[148]=So[22]=function(t){return[[1,1],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},So[82]=So[88]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1]]},So[73]=So[97]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},So[145]=So[25]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},So[70]=So[100]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[34]=function(t){return[mo(t),po(t)]},So[35]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},So[136]=function(t){return[fo(t),ho(t)]},So[153]=function(t){return[uo(t),so(t)]},So[102]=function(t){return[lo(t),co(t)]},So[155]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},So[103]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[152]=function(t){return[uo(t),ho(t)]},So[156]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},So[137]=function(t){return[fo(t),so(t)]},So[139]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},So[98]=function(t){return[po(t),co(t)]},So[99]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},So[38]=function(t){return[lo(t),mo(t)]},So[39]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]};var Go=function(){function t(e){this.id=t.buildId(e),this.coordinates=e,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return t.buildId=function(t){return t.join(",")},t.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter((function(e){return e.from.id!==t.from.id}))},t.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter((function(e){return e.to.id!==t.to.id}))},t.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1},t.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort((function(e,n){var r=e.to,i=n.to;if(r.coordinates[0]-t.coordinates[0]>=0&&i.coordinates[0]-t.coordinates[0]<0)return 1;if(r.coordinates[0]-t.coordinates[0]<0&&i.coordinates[0]-t.coordinates[0]>=0)return-1;if(r.coordinates[0]-t.coordinates[0]==0&&i.coordinates[0]-t.coordinates[0]==0)return r.coordinates[1]-t.coordinates[1]>=0||i.coordinates[1]-t.coordinates[1]>=0?r.coordinates[1]-i.coordinates[1]:i.coordinates[1]-r.coordinates[1];var o=Uo(t.coordinates,r.coordinates,i.coordinates);return o<0?1:o>0?-1:Math.pow(r.coordinates[0]-t.coordinates[0],2)+Math.pow(r.coordinates[1]-t.coordinates[1],2)-(Math.pow(i.coordinates[0]-t.coordinates[0],2)+Math.pow(i.coordinates[1]-t.coordinates[1],2))})),this.outerEdgesSorted=!0)},t.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},t.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},t.prototype.addInnerEdge=function(t){this.innerEdges.push(t)},t}(),jo=function(){function t(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return t.prototype.getSymetric=function(){return this.symetric||(this.symetric=new t(this.to,this.from),this.symetric.symetric=this),this.symetric},t.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},t.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},t.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},t.prototype.toLineString=function(){return h([this.from.coordinates,this.to.coordinates])},t.prototype.compareTo=function(t){return Uo(t.from.coordinates,t.to.coordinates,this.to.coordinates)},t}(),Ho=function(){function t(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return t.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0},t.prototype.get=function(t){return this.edges[t]},Object.defineProperty(t.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t){this.edges.forEach(t)},t.prototype.map=function(t){return this.edges.map(t)},t.prototype.some=function(t){return this.edges.some(t)},t.prototype.isValid=function(){return!0},t.prototype.isHole=function(){var t=this,e=this.edges.reduce((function(e,n,r){return n.from.coordinates[1]>t.edges[e].from.coordinates[1]&&(e=r),e}),0),n=(0===e?this.length:e)-1,r=(e+1)%this.length,i=Uo(this.edges[n].from.coordinates,this.edges[e].from.coordinates,this.edges[r].from.coordinates);return 0===i?this.edges[n].from.coordinates[0]>this.edges[r].from.coordinates[0]:i>0},t.prototype.toMultiPoint=function(){return m(this.edges.map((function(t){return t.from.coordinates})))},t.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map((function(t){return t.from.coordinates}));return t.push(this.edges[0].from.coordinates),this.polygon=u([t])},t.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=ln(this.toPolygon())},t.findEdgeRingContaining=function(t,e){var n,r,i=t.getEnvelope();return e.forEach((function(e){var o,a,l,u,c,h,p=e.getEnvelope();if((r&&(n=r.getEnvelope()),a=i,l=(o=p).geometry.coordinates[0].map((function(t){return t[0]})),u=o.geometry.coordinates[0].map((function(t){return t[1]})),c=a.geometry.coordinates[0].map((function(t){return t[0]})),h=a.geometry.coordinates[0].map((function(t){return t[1]})),Math.max.apply(null,l)!==Math.max.apply(null,c)||Math.max.apply(null,u)!==Math.max.apply(null,h)||Math.min.apply(null,l)!==Math.min.apply(null,c)||Math.min.apply(null,u)!==Math.min.apply(null,h))&&Vo(p,i)){for(var f=t.map((function(t){return t.from.coordinates})),d=void 0,m=function(t){e.some((function(e){return n=t,r=e.from.coordinates,n[0]===r[0]&&n[1]===r[1];var n,r}))||(d=t)},g=0,y=f;g=0;--o){var a=i[o],s=a.symetric,l=void 0,u=void 0;a.label===e&&(l=a),s.label===e&&(u=s),l&&u&&(u&&(r=u),l&&(r&&(r.next=l,r=void 0),n||(n=l)))}r&&(r.next=n)},t.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach((function(n){if(!(n.label>=0)){t.push(n);var r=n;do{r.label=e,r=r.next}while(!n.isEqual(r));e++}})),t},t.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach((function(t){t.label=void 0})),this._findLabeledEdgeRings().forEach((function(e){t._findIntersectionNodes(e).forEach((function(n){t._computeNextCCWEdges(n,e.label)}))}));var e=[];return this.edges.forEach((function(n){n.ring||e.push(t._findEdgeRing(n))})),e},t.prototype._findIntersectionNodes=function(t){var e=[],n=t,r=function(){var r=0;n.from.getOuterEdges().forEach((function(e){e.label===t.label&&++r})),r>1&&e.push(n.from),n=n.next};do{r()}while(!t.isEqual(n));return e},t.prototype._findEdgeRing=function(t){var e=t,n=new Ho;do{n.push(e),e.ring=n,e=e.next}while(!t.isEqual(e));return n},t.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach((function(t){return e.removeEdge(t)})),t.innerEdges.forEach((function(t){return e.removeEdge(t)})),delete this.nodes[t.id]},t.prototype.removeEdge=function(t){this.edges=this.edges.filter((function(e){return!e.isEqual(t)})),t.deleteEdge()},t}();function Wo(t,e){var n=!0;return V(t,(function(t){V(e,(function(e){if(!1===n)return!1;n=function(t,e){switch(t.type){case"Point":switch(e.type){case"Point":return n=t.coordinates,r=e.coordinates,!(n[0]===r[0]&&n[1]===r[1]);case"LineString":return!Xo(e,t);case"Polygon":return!fe(t,e)}break;case"LineString":switch(e.type){case"Point":return!Xo(t,e);case"LineString":return!function(t,e){return dr(t,e).features.length>0}(t,e);case"Polygon":return!Zo(e,t)}break;case"Polygon":switch(e.type){case"Point":return!fe(e,t);case"LineString":return!Zo(t,e);case"Polygon":return!function(t,e){for(var n=0,r=t.coordinates[0];n0}(e,t)}}var n,r;return!1}(t.geometry,e.geometry)}))})),n}function Xo(t,e){for(var n=0;n0}function Yo(t,e,n){var r=n[0]-t[0],i=n[1]-t[1],o=e[0]-t[0],a=e[1]-t[1];return 0==r*a-i*o&&(Math.abs(o)>=Math.abs(a)?o>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:a>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1])}function Jo(t,e){return!(t[0]>e[0]||t[2]e[1]||t[3]0}function ea(t,e){for(var n=!1,r=!1,i=t.coordinates.length,o=0;o=Math.abs(s)?a>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:s>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1]:Math.abs(a)>=Math.abs(s)?a>0?t[0]0?t[1]=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n},ra.prototype.comparePath=function(t,e){var n=this;return t.every((function(t,e){return n.compareCoord(t,this[e])}),e)},ra.prototype.comparePolygon=function(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var n=t.coordinates.slice(1,t.coordinates.length),r=e.coordinates.slice(1,e.coordinates.length),i=this;return n.every((function(t){return this.some((function(e){return i.compareLine(t,e,1,!0)}))}),r)}return!1},ra.prototype.compareFeature=function(t,e){return!(t.id!==e.id||!this.objectComparator(t.properties,e.properties)||!this.compareBBox(t,e))&&this.compare(t.geometry,e.geometry)},ra.prototype.compareBBox=function(t,e){return!!(!t.bbox&&!e.bbox||t.bbox&&e.bbox&&this.compareCoord(t.bbox,e.bbox))},ra.prototype.removePseudo=function(t){return t};var sa=ra;function la(t,e){var n=!1;return V(t,(function(t){V(e,(function(e){if(!0===n)return!0;n=!Wo(t.geometry,e.geometry)}))})),n}var ua=Ft((function(t){function e(t,e,n,r){this.dataset=[],this.epsilon=1,this.minPts=2,this.distance=this._euclideanDistance,this.clusters=[],this.noise=[],this._visited=[],this._assigned=[],this._datasetLength=0,this._init(t,e,n,r)}e.prototype.run=function(t,e,n,r){this._init(t,e,n,r);for(var i=0;i=this.minPts&&(e=this._mergeArrays(e,i))}1!==this._assigned[r]&&this._addToCluster(r,t)}},e.prototype._addToCluster=function(t,e){this.clusters[e].push(t),this._assigned[t]=1},e.prototype._regionQuery=function(t){for(var e=[],n=0;n0){for(l=0;l=0);return t},e.prototype.assign=function(){for(var t,e=!1,n=this.dataset.length,r=0;ri&&(n=r):e=this.minPts)return n},n.prototype._regionQuery=function(t,e){e=e||this.epsilon;for(var n=[],r=0,i=this.dataset.length;r0,f=[];if(n)i="kmrand"==n?function(t,e){for(var n={},r=[],i=e<<2,o=t.length,a=t[0].length>0;r.length0;){var s=t[Math.floor(Math.random()*o)],l=a?s.join("_"):""+s;n[l]||(n[l]=!0,r.push(s))}if(r.length0,a=t[Math.floor(Math.random()*i)];o&&a.join("_");for(r.push(a);r.length0;){var l=a.pop();if(l===n)return wa(l);l.closed=!0;for(var u=t.neighbors(l),c=0,h=u.length;c0)){if(o/=p,p<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=r-l,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>c&&(c=o)}else if(p>0){if(o0)){if(o/=f,f<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=i-u,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o)}else if(f>0){if(o0||h<1)||(c>0&&(t[0]=[l+c*p,u+c*f]),h<1&&(t[1]=[l+h*p,u+h*f]),!0)}}}}}function Ua(t,e,n,r,i){var o=t[1];if(o)return!0;var a,s,l=t[0],u=t.left,c=t.right,h=u[0],p=u[1],f=c[0],d=c[1],m=(h+f)/2,g=(p+d)/2;if(d===p){if(m=r)return;if(h>f){if(l){if(l[1]>=i)return}else l=[m,n];o=[m,i]}else{if(l){if(l[1]1)if(h>f){if(l){if(l[1]>=i)return}else l=[(n-s)/a,n];o=[(i-s)/a,i]}else{if(l){if(l[1]=r)return}else l=[e,a*e+s];o=[r,a*r+s]}else{if(l){if(l[0]0&&(this.content[0]=e,this.bubbleUp(0)),t},remove:function(t){var e=this.content.indexOf(t),n=this.content.pop();e!==this.content.length-1&&(this.content[e]=n,this.scoreFunction(n)0;){var n=(t+1>>1)-1,r=this.content[n];if(!(this.scoreFunction(e)=-ls)){var f=l*l+u*u,d=c*c+h*h,m=(h*f-u*d)/p,g=(l*d-c*f)/p,y=qa.pop()||new Wa;y.arc=t,y.site=i,y.x=m+a,y.y=(y.cy=g+s)+Math.sqrt(m*m+g*g),t.circle=y;for(var v=null,_=os._;_;)if(y.y<_.y||y.y===_.y&&y.x<=_.x){if(!_.L){v=_.P;break}_=_.L}else{if(!_.R){v=_;break}_=_.R}os.insert(v,y),v||(Ha=y)}}}}function Za(t){var e=t.circle;e&&(e.P||(Ha=e.N),os.remove(e),qa.push(e),Ra(e),t.circle=null)}var Ya=[];function Ja(){Ra(this),this.edge=this.site=this.circle=null}function Ka(t){var e=Ya.pop()||new Ja;return e.site=t,e}function Qa(t){Za(t),rs.remove(t),Ya.push(t),Ra(t)}function $a(t){var e=t.circle,n=e.x,r=e.cy,i=[n,r],o=t.P,a=t.N,s=[t];Qa(t);for(var l=o;l.circle&&Math.abs(n-l.circle.x)ss)s=s.L;else{if(!((i=o-ns(s,a))>ss)){r>-ss?(e=s.P,n=s):i>-ss?(e=s,n=s.N):e=n=s;break}if(!s.R){e=s;break}s=s.R}!function(t){is[t.index]={site:t,halfedges:[]}}(t);var l=Ka(t);if(rs.insert(e,l),e||n){if(e===n)return Za(e),n=Ka(e.site),rs.insert(l,n),l.edge=n.edge=ka(e.site,l.site),Xa(e),void Xa(n);if(n){Za(e),Za(n);var u=e.site,c=u[0],h=u[1],p=t[0]-c,f=t[1]-h,d=n.site,m=d[0]-c,g=d[1]-h,y=2*(p*g-f*m),v=p*p+f*f,_=m*m+g*g,x=[(g*v-f*_)/y+c,(p*_-m*v)/y+h];Fa(n.edge,u,d,x),l.edge=ka(u,t,null,x),n.edge=ka(t,d,null,x),Xa(e),Xa(n)}else l.edge=ka(e.site,l.site)}}function es(t,e){var n=t.site,r=n[0],i=n[1],o=i-e;if(!o)return r;var a=t.P;if(!a)return-1/0;var s=(n=a.site)[0],l=n[1],u=l-e;if(!u)return s;var c=s-r,h=1/o-1/u,p=c/u;return h?(-p+Math.sqrt(p*p-2*h*(c*c/(-2*u)-l+u/2+i-o/2)))/h+r:(r+s)/2}function ns(t,e){var n=t.N;if(n)return es(n,e);var r=t.site;return r[1]===e?r[0]:1/0}var rs,is,os,as,ss=1e-6,ls=1e-12;function us(t,e){return e[1]-t[1]||e[0]-t[0]}function cs(t,e){var n,r,i,o=t.sort(us).pop();for(as=[],is=new Array(t.length),rs=new Pa,os=new Pa;;)if(i=Ha,o&&(!i||o[1]ss||Math.abs(i[0][1]-i[1][1])>ss)||delete as[o]}(a,s,l,u),function(t,e,n,r){var i,o,a,s,l,u,c,h,p,f,d,m,g=is.length,y=!0;for(i=0;iss||Math.abs(m-p)>ss)&&(l.splice(s,0,as.push(za(a,f,Math.abs(d-t)ss?[t,Math.abs(h-t)ss?[Math.abs(p-r)ss?[n,Math.abs(h-n)ss?[Math.abs(p-e)=-270&&(m=-m),d<-180&&d>=-360&&(g=-g),"degrees"===o){var y=m*Math.cos(h)+g*Math.sin(h),v=g*Math.cos(h)-m*Math.sin(h);m=y,g=v}p.push([m+c[0],g+c[1]])}return p.push(p[0]),"degrees"===o?u([p],l):No(u([p],l),a,{pivot:s})}function fs(t){var e=t*Math.PI/180;return Math.tan(e)}function ds(t,e){void 0===e&&(e={});var n=0,r=0,i=0;return B(t,(function(t,o,a){var s=e.weight?null==a?void 0:a[e.weight]:void 0;if(!C(s=null==s?1:s))throw new Error("weight value must be a number for feature index "+o);(s=Number(s))>0&&R(t,(function(t){n+=t[0]*s,r+=t[1]*s,i+=s}))})),s([n/i,r/i],e.properties,e)}function ms(t,e,n,r,i){var o=r.tolerance||.001,a=0,l=0,u=0,c=0;if(k(n,(function(e){var n,r=null===(n=e.properties)||void 0===n?void 0:n.weight,i=null==r?1:r;if(!C(i=Number(i)))throw new Error("weight value must be a number");if(i>0){c+=1;var o=i*ge(e,t);0===o&&(o=1);var s=i/o;a+=e.geometry.coordinates[0]*s,l+=e.geometry.coordinates[1]*s,u+=s}})),c<1)throw new Error("no features to measure");var h=a/u,p=l/u;return 1===c||0===i||Math.abs(h-e[0])n&&(n=l,r=o,e.push([]));var u=o-r,c=t.coordinates[l][u+1],h=i[0],p=i[1],f=c[0],d=c[1];e[l].push([.75*h+.25*f,.75*p+.25*d]),e[l].push([.25*h+.75*f,.25*p+.75*d])}),!0),e.forEach((function(t){t.push(t[0])}))}function vs(t,e){var n=0,r=0,i=0;R(t,(function(o,a,s,l,u){l>i&&(i=l,r=a,e.push([[]])),u>n&&(n=u,r=a,e[l].push([]));var c=a-r,h=t.coordinates[l][u][c+1],p=o[0],f=o[1],d=h[0],m=h[1];e[l][u].push([.75*p+.25*d,.75*f+.25*m]),e[l][u].push([.25*p+.75*d,.25*f+.75*m])}),!0),e.forEach((function(t){t.forEach((function(t){t.push(t[0])}))}))}function _s(t,e,n){void 0===n&&(n=2);var r=K(t),i=K(e),o=r[0]-i[0],a=r[1]-i[1];return 1===n?Math.abs(o)+Math.abs(a):Math.pow(Math.pow(o,n)+Math.pow(a,n),1/n)}function xs(t,e){var n=(e=e||{}).threshold||1e4,r=e.p||2,i=e.binary||!1,o=e.alpha||-1,a=e.standardization||!1,s=[];k(t,(function(t){s.push(dn(t))}));for(var l=[],u=0;u0?1:0}(t[0]))*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>r&&(i[0]=r),i[0]<-r&&(i[0]=-r),i[1]>r&&(i[1]=r),i[1]<-r&&(i[1]=-r),i}function Ts(t){var e=180/Math.PI,n=6378137;return[t[0]*e/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*e]}cs.prototype={constructor:cs,polygons:function(){var t=this.edges;return this.cells.map((function(e){var n=e.halfedges.map((function(n){return Ga(e,t[n])}));return n.data=e.site.data,n}))},triangles:function(){var t=[],e=this.edges;return this.cells.forEach((function(n,r){if(o=(i=n.halfedges).length)for(var i,o,a,s,l,u,c=n.site,h=-1,p=e[i[o-1]],f=p.left===c?p.right:p.left;++h=s)return null;var l=t-i.site[0],u=e-i.site[1],c=l*l+u*u;do{i=o.cells[r=a],a=null,i.halfedges.forEach((function(n){var r=o.edges[n],s=r.left;if(s!==i.site&&s||(s=r.right)){var l=t-s[0],u=e-s[1],h=l*l+u*u;h0?t+n[e-1]:t})),o.forEach((function(t){t=2*t*Math.PI/o[o.length-1];var n=Math.random();i.push([n*(e.max_radial_length||10)*Math.sin(t),n*(e.max_radial_length||10)*Math.cos(t)])})),i[i.length-1]=i[0],i=i.map((r=Is(e.bbox),function(t){return[t[0]+r[0],t[1]+r[1]]})),n.push(u([i]))},i=0;ie?1:t0))break;if(null===e.right)break;if(n(t,e.right.key)>0){s=e.right;if(e.right=s.left,s.left=e,null===(e=s).right)break}i.right=e,i=e,e=e.right}}return i.right=e.left,o.left=e.right,e.left=r.right,e.right=r.left,e}function Ws(t,e,n,r){var i=new js(t,e);if(null===n)return i.left=i.right=null,i;var o=r(t,(n=qs(t,n,r)).key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i}function Xs(t,e,n){var r=null,i=null;if(e){var o=n((e=qs(t,e,n)).key,t);0===o?(r=e.left,i=e.right):o<0?(i=e.right,e.right=null,r=e):(r=e.left,e.left=null,i=e)}return{left:r,right:i}}function Zs(t,e,n,r,i){if(t){r(e+(n?"└── ":"├── ")+i(t)+"\n");var o=e+(n?" ":"│ ");t.left&&Zs(t.left,o,!1,r,i),t.right&&Zs(t.right,o,!0,r,i)}}var Ys=function(){function t(t){void 0===t&&(t=Hs),this._root=null,this._size=0,this._comparator=t}return t.prototype.insert=function(t,e){return this._size++,this._root=Ws(t,e,this._root,this._comparator)},t.prototype.add=function(t,e){var n=new js(t,e);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,i=qs(t,this._root,r),o=r(t,i.key);return 0===o?this._root=i:(o<0?(n.left=i.left,n.right=i,i.left=null):o>0&&(n.right=i.right,n.left=i,i.right=null),this._size++,this._root=n),this._root},t.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},t.prototype._remove=function(t,e,n){var r;return null===e?null:0===n(t,(e=qs(t,e,n)).key)?(null===e.left?r=e.right:(r=qs(t,e.left,n)).right=e.right,this._size--,r):e},t.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=qs(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,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return e;e=r<0?e.left:e.right}return null},t.prototype.find=function(t){return this._root&&(this._root=qs(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,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return!0;e=r<0?e.left:e.right}return!1},t.prototype.forEach=function(t,e){for(var n=this._root,r=[],i=!1;!i;)null!==n?(r.push(n),n=n.left):0!==r.length?(n=r.pop(),t.call(e,n),n=n.right):i=!0;return this},t.prototype.range=function(t,e,n,r){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&&n.call(r,a))return this;a=a.right}return this},t.prototype.keys=function(){var t=[];return this.forEach((function(e){var n=e.key;return t.push(n)})),t},t.prototype.values=function(){var t=[];return this.forEach((function(e){var n=e.data;return t.push(n)})),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,n=!1,r=0,i=[];!n;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),r===t)return e;r++,e=e.right}else n=!0;return null},t.prototype.next=function(t){var e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?(n=e,e=e.left):e=e.right}return n},t.prototype.prev=function(t){var e=this._root,n=null;if(null!==t.left){for(n=t.left;n.right;)n=n.right;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?e=e.left:(n=e,e=e.right)}return n},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return function(t){for(var e=t,n=[],r=!1,i=new js(null,null),o=i;!r;)e?(n.push(e),e=e.left):n.length>0?e=(e=o=o.next=n.pop()).right:r=!0;return o.next=null,i.next}(this._root)},t.prototype.load=function(t,e,n){void 0===e&&(e=[]),void 0===n&&(n=!1);var r=t.length,i=this._comparator;if(n&&Qs(t,e,0,r-1,i),null===this._root)this._root=Js(t,e,0,r),this._size=r;else{var o=function(t,e,n){for(var r=new js(null,null),i=r,o=t,a=e;null!==o&&null!==a;)n(o.key,a.key)<0?(i.next=o,o=o.next):(i.next=a,a=a.next),i=i.next;null!==o?i.next=o:null!==a&&(i.next=a);return r.next}(this.toList(),function(t,e){for(var n=new js(null,null),r=n,i=0;i0){var o=n+Math.floor(i/2),a=t[o],s=e[o],l=new js(a,s);return l.left=Js(t,e,n,o),l.right=Js(t,e,o+1,r),l}return null}function Ks(t,e,n){var r=n-e;if(r>0){var i=e+Math.floor(r/2),o=Ks(t,e,i),a=t.head;return a.left=o,t.head=t.head.next,a.right=Ks(t,i+1,n),a}return null}function Qs(t,e,n,r,i){if(!(n>=r)){for(var o=t[n+r>>1],a=n-1,s=r+1;;){do{a++}while(i(t[a],o)<0);do{s--}while(i(t[s],o)>0);if(a>=s)break;var l=t[a];t[a]=t[s],t[s]=l,l=e[a],e[a]=e[s],e[s]=l}Qs(t,e,n,s,i),Qs(t,e,s+1,r,i)}}function $s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tl(t,e){for(var n=0;ne.x?1:t.ye.y?1:0}}]),el(t,[{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,n=0,r=e.length;n=0&&l>=0?au?-1:0:o<0&&l<0?au?1:0:lo?1:0}}}]),t}(),vl=0,_l=function(){function t(e,n,r,i){$s(this,t),this.id=++vl,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=r,this.windings=i}return el(t,null,[{key:"compare",value:function(t,e){var n=t.leftSE.point.x,r=e.leftSE.point.x,i=t.rightSE.point.x,o=e.rightSE.point.x;if(oa&&s>l)return-1;var c=t.comparePoint(e.leftSE.point);if(c<0)return 1;if(c>0)return-1;var h=e.comparePoint(t.rightSE.point);return 0!==h?h:-1}if(n>r){if(as&&a>u)return 1;var p=e.comparePoint(t.leftSE.point);if(0!==p)return p;var f=t.comparePoint(e.rightSE.point);return f<0?1:f>0?-1:1}if(as)return 1;if(io){var m=t.comparePoint(e.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(i!==o){var g=l-a,y=i-n,v=u-s,_=o-r;if(g>y&&v<_)return 1;if(g_)return-1}return i>o?1:iu?1:t.ide.id?1:0}}]),el(t,[{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:te?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,n=this.rightSE.point,r=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x0&&s.swapEvents(),yl.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}},{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,n=this.windings.length;e0){var o=n;n=r,r=o}if(n.prev===r){var a=n;n=r,r=a}for(var s=0,l=r.rings.length;s0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));i=n,o=e,a=-1}return new t(new yl(i,!0),new yl(o,!1),[r],[a])}}]),t}(),xl=function(){function t(e,n,r){if($s(this,t),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=r,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var i=ul.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,a=1,s=e.length;athis.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),o=l)}i.x===o.x&&i.y===o.y||this.segments.push(_l.fromRing(o,i,this))}return el(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,n=this.segments.length;ethis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=n}return el(t,[{key:"getSweepEvents",value:function(){for(var t=this.exteriorRing.getSweepEvents(),e=0,n=this.interiorRings.length;ethis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=n}return el(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,n=this.polys.length;e0&&(t=r)}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}}}]),t}(),Sl=function(){function t(e){$s(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return el(t,[{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,n=this.interiorRings.length;e1&&void 0!==arguments[1]?arguments[1]:_l.compare;$s(this,t),this.queue=e,this.tree=new Ys(n),this.segments=[]}return el(t,[{key:"process",value:function(t){var e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;var r=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!r)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=r,o=r,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 l=null;if(a){var u=a.getIntersection(e);if(null!==u&&(e.isAnEndpoint(u)||(l=u),!a.isAnEndpoint(u)))for(var c=this._splitSafely(a,u),h=0,p=c.length;h0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=a)}else{if(a&&s){var w=a.getIntersection(s);if(null!==w){if(!a.isAnEndpoint(w))for(var E=this._splitSafely(a,w),S=0,M=E.length;SCl)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var _=new Tl(f),x=f.size,b=f.pop();b;){var w=b.key;if(f.size===x){var E=w.segment;throw new Error("Unable to pop() ".concat(w.isLeft?"left":"right"," SweepEvent ")+"[".concat(w.point.x,", ").concat(w.point.y,"] from segment #").concat(E.id," ")+"[".concat(E.leftSE.point.x,", ").concat(E.leftSE.point.y,"] -> ")+"[".concat(E.rightSE.point.x,", ").concat(E.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(f.size>Cl)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(_.segments.length>Il)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var S=_.process(w),M=0,T=S.length;M1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;re.x?1:this.ye.y?1:0},Bl.prototype.clone=function(){},Bl.prototype.copy=function(){return new Bl(this)},Bl.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},Bl.prototype.distance3D=function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return Math.sqrt(e*e+n*n+r*r)},Bl.prototype.distance=function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},Bl.prototype.hashCode=function(){var t=17;return 37*(t=37*t+Bl.hashCode(this.x))+Bl.hashCode(this.y)},Bl.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z},Bl.prototype.interfaces_=function(){return[Ol,kl,Fl]},Bl.prototype.getClass=function(){return Bl},Bl.hashCode=function(){if(1===arguments.length){var t=Dl.doubleToLongBits(arguments[0]);return Math.trunc((t^t)>>>32)}},Ul.DimensionalComparator.get=function(){return Vl},Ul.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800},Ul.NULL_ORDINATE.get=function(){return Dl.NaN},Ul.X.get=function(){return 0},Ul.Y.get=function(){return 1},Ul.Z.get=function(){return 2},Object.defineProperties(Bl,Ul);var Vl=function(t){if(this._dimensionsToTest=2,0===arguments.length);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new Rl("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}};Vl.prototype.compare=function(t,e){var n=t,r=e,i=Vl.compare(n.x,r.x);if(0!==i)return i;var o=Vl.compare(n.y,r.y);return 0!==o?o:this._dimensionsToTest<=2?0:Vl.compare(n.z,r.z)},Vl.prototype.interfaces_=function(){return[zl]},Vl.prototype.getClass=function(){return Vl},Vl.compare=function(t,e){return te?1:Dl.isNaN(t)?Dl.isNaN(e)?0:-1:Dl.isNaN(e)?1:0};var Gl=function(){};Gl.prototype.create=function(){},Gl.prototype.interfaces_=function(){return[]},Gl.prototype.getClass=function(){return Gl};var jl=function(){},Hl={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};jl.prototype.interfaces_=function(){return[]},jl.prototype.getClass=function(){return jl},jl.toLocationSymbol=function(t){switch(t){case jl.EXTERIOR:return"e";case jl.BOUNDARY:return"b";case jl.INTERIOR:return"i";case jl.NONE:return"-"}throw new Rl("Unknown location value: "+t)},Hl.INTERIOR.get=function(){return 0},Hl.BOUNDARY.get=function(){return 1},Hl.EXTERIOR.get=function(){return 2},Hl.NONE.get=function(){return-1},Object.defineProperties(jl,Hl);var ql=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},Wl=function(){},Xl={LOG_10:{configurable:!0}};Wl.prototype.interfaces_=function(){return[]},Wl.prototype.getClass=function(){return Wl},Wl.log10=function(t){var e=Math.log(t);return Dl.isInfinite(e)||Dl.isNaN(e)?e:e/Wl.LOG_10},Wl.min=function(t,e,n,r){var i=t;return en?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var r=arguments[0],i=arguments[1],o=arguments[2];return ro?o:r}},Wl.wrap=function(t,e){return t<0?e- -t%e:t%e},Wl.max=function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var r=arguments[1],i=arguments[2],o=arguments[3],a=arguments[0];return r>a&&(a=r),i>a&&(a=i),o>a&&(a=o),a}},Wl.average=function(t,e){return(t+e)/2},Xl.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(Wl,Xl);var Zl=function(t){this.str=t};Zl.prototype.append=function(t){this.str+=t},Zl.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},Zl.prototype.toString=function(t){return this.str};var Yl=function(t){this.value=t};Yl.prototype.intValue=function(){return this.value},Yl.prototype.compareTo=function(t){return this.valuet?1:0},Yl.isNaN=function(t){return Number.isNaN(t)};var Jl=function(){};Jl.isWhitespace=function(t){return t<=32&&t>=0||127===t},Jl.toUpperCase=function(t){return t.toUpperCase()};var Kl=function t(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){t.call(this,t.parse(arguments[0]))}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.init(r,i)}},Ql={PI:{configurable:!0},TWO_PI:{configurable:!0},PI_2:{configurable:!0},E:{configurable:!0},NaN:{configurable:!0},EPS:{configurable:!0},SPLIT:{configurable:!0},MAX_PRINT_DIGITS:{configurable:!0},TEN:{configurable:!0},ONE:{configurable:!0},SCI_NOT_EXPONENT_CHAR:{configurable:!0},SCI_NOT_ZERO:{configurable:!0}};Kl.prototype.le=function(t){return(this._hi9?(c=!0,h="9"):h="0"+u,a.append(h),n=n.subtract(Kl.valueOf(u)).multiply(Kl.TEN),c&&n.selfAdd(Kl.TEN);var p=!0,f=Kl.magnitude(n._hi);if(f<0&&Math.abs(f)>=s-l&&(p=!1),!p)break}return e[0]=r,a.toString()},Kl.prototype.sqr=function(){return this.multiply(this)},Kl.prototype.doubleValue=function(){return this._hi+this._lo},Kl.prototype.subtract=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e)}},Kl.prototype.equals=function(){if(1===arguments.length){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}},Kl.prototype.isZero=function(){return 0===this._hi&&0===this._lo},Kl.prototype.selfSubtract=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},Kl.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},Kl.prototype.min=function(t){return this.le(t)?this:t},Kl.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof Kl){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){var n,r,i,o,a=arguments[0],s=arguments[1],l=null,u=null,c=null,h=null;return i=this._hi/a,h=(l=(c=Kl.SPLIT*i)-(l=c-i))*(u=(h=Kl.SPLIT*a)-(u=h-a))-(o=i*a)+l*(r=a-u)+(n=i-l)*u+n*r,h=i+(c=(this._hi-o-h+this._lo-i*s)/a),this._hi=h,this._lo=i-h+c,this}},Kl.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">"},Kl.prototype.divide=function(){if(arguments[0]instanceof Kl){var t,e,n,r,i=arguments[0],o=null,a=null,s=null,l=null;t=(n=this._hi/i._hi)-(o=(s=Kl.SPLIT*n)-(o=s-n)),l=o*(a=(l=Kl.SPLIT*i._hi)-(a=l-i._hi))-(r=n*i._hi)+o*(e=i._hi-a)+t*a+t*e;var u=l=n+(s=(this._hi-r-l+this._lo-n*i._lo)/i._hi);return new Kl(u,n-l+s)}if("number"==typeof arguments[0]){var c=arguments[0];return Dl.isNaN(c)?Kl.createNaN():Kl.copy(this).selfDivide(c,0)}},Kl.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo},Kl.prototype.pow=function(t){if(0===t)return Kl.valueOf(1);var e=new Kl(this),n=Kl.valueOf(1),r=Math.abs(t);if(r>1)for(;r>0;)r%2==1&&n.selfMultiply(e),(r/=2)>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n},Kl.prototype.ceil=function(){if(this.isNaN())return Kl.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new Kl(t,e)},Kl.prototype.compareTo=function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0},Kl.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor()},Kl.prototype.setValue=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this}},Kl.prototype.max=function(t){return this.ge(t)?this:t},Kl.prototype.sqrt=function(){if(this.isZero())return Kl.valueOf(0);if(this.isNegative())return Kl.NaN;var t=1/Math.sqrt(this._hi),e=this._hi*t,n=Kl.valueOf(e),r=this.subtract(n.sqr())._hi*(.5*t);return n.add(r)},Kl.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof Kl){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var e,n,r,i,o,a=arguments[0],s=null;return s=(r=this._hi+a)-(i=r-this._hi),n=(o=(s=a-i+(this._hi-s))+this._lo)+(r-(e=r+o)),this._hi=e+n,this._lo=n+(e-this._hi),this}}else if(2===arguments.length){var l,u,c,h,p=arguments[0],f=arguments[1],d=null,m=null,g=null;c=this._hi+p,u=this._lo+f,m=c-(g=c-this._hi),d=u-(h=u-this._lo);var y=(l=c+(g=(m=p-g+(this._hi-m))+u))+(g=(d=f-h+(this._lo-d))+(g+(c-l))),v=g+(l-y);return this._hi=y,this._lo=v,this}},Kl.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof Kl){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){var n,r,i=arguments[0],o=arguments[1],a=null,s=null,l=null,u=null;a=(l=Kl.SPLIT*this._hi)-this._hi,u=Kl.SPLIT*i,a=l-a,n=this._hi-a,s=u-i;var c=(l=this._hi*i)+(u=a*(s=u-s)-l+a*(r=i-s)+n*s+n*r+(this._hi*o+this._lo*i)),h=u+(a=l-c);return this._hi=c,this._lo=h,this}},Kl.prototype.selfSqr=function(){return this.selfMultiply(this)},Kl.prototype.floor=function(){if(this.isNaN())return Kl.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new Kl(t,e)},Kl.prototype.negate=function(){return this.isNaN()?this:new Kl(-this._hi,-this._lo)},Kl.prototype.clone=function(){},Kl.prototype.multiply=function(){if(arguments[0]instanceof Kl){var t=arguments[0];return t.isNaN()?Kl.createNaN():Kl.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return Dl.isNaN(e)?Kl.createNaN():Kl.copy(this).selfMultiply(e,0)}},Kl.prototype.isNaN=function(){return Dl.isNaN(this._hi)},Kl.prototype.intValue=function(){return Math.trunc(this._hi)},Kl.prototype.toString=function(){var t=Kl.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},Kl.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),r=e[0]+1,i=n;if("."===n.charAt(0))i="0"+n;else if(r<0)i="0."+Kl.stringOfChar("0",-r)+n;else if(-1===n.indexOf(".")){var o=r-n.length;i=n+Kl.stringOfChar("0",o)+".0"}return this.isNegative()?"-"+i:i},Kl.prototype.reciprocal=function(){var t,e,n,r,i=null,o=null,a=null,s=null;t=(n=1/this._hi)-(i=(a=Kl.SPLIT*n)-(i=a-n)),o=(s=Kl.SPLIT*this._hi)-this._hi;var l=n+(a=(1-(r=n*this._hi)-(s=i*(o=s-o)-r+i*(e=this._hi-o)+t*o+t*e)-n*this._lo)/this._hi);return new Kl(l,n-l+a)},Kl.prototype.toSciNotation=function(){if(this.isZero())return Kl.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),r=Kl.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(0))throw new Error("Found leading zero: "+n);var i="";n.length>1&&(i=n.substring(1));var o=n.charAt(0)+"."+i;return this.isNegative()?"-"+o+r:o+r},Kl.prototype.abs=function(){return this.isNaN()?Kl.NaN:this.isNegative()?this.negate():new Kl(this)},Kl.prototype.isPositive=function(){return(this._hi>0||0===this._hi)&&this._lo>0},Kl.prototype.lt=function(t){return(this._hit._hi||this._hi===t._hi)&&this._lo>t._lo},Kl.prototype.isNegative=function(){return(this._hi<0||0===this._hi)&&this._lo<0},Kl.prototype.trunc=function(){return this.isNaN()?Kl.NaN:this.isPositive()?this.floor():this.ceil()},Kl.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0},Kl.prototype.interfaces_=function(){return[Fl,Ol,kl]},Kl.prototype.getClass=function(){return Kl},Kl.sqr=function(t){return Kl.valueOf(t).selfMultiply(t)},Kl.valueOf=function(){if("string"==typeof arguments[0]){return Kl.parse(arguments[0])}if("number"==typeof arguments[0]){return new Kl(arguments[0])}},Kl.sqrt=function(t){return Kl.valueOf(t).sqrt()},Kl.parse=function(t){for(var e=0,n=t.length;Jl.isWhitespace(t.charAt(e));)e++;var r=!1;if(e=n);){var u=t.charAt(e);if(e++,Jl.isDigit(u)){var c=u-"0";o.selfMultiply(Kl.TEN),o.selfAdd(c),a++}else{if("."!==u){if("e"===u||"E"===u){var h=t.substring(e);try{l=Yl.parseInt(h)}catch(e){throw e instanceof Error?new Error("Invalid exponent "+h+" in string "+t):e}break}throw new Error("Unexpected character '"+u+"' at position "+e+" in string "+t)}s=a}}var p=o,f=a-s-l;if(0===f)p=o;else if(f>0){var d=Kl.TEN.pow(f);p=o.divide(d)}else if(f<0){var m=Kl.TEN.pow(-f);p=o.multiply(m)}return r?p.negate():p},Kl.createNaN=function(){return new Kl(Dl.NaN,Dl.NaN)},Kl.copy=function(t){return new Kl(t)},Kl.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),r=Math.trunc(Math.floor(n));return 10*Math.pow(10,r)<=e&&(r+=1),r},Kl.stringOfChar=function(t,e){for(var n=new Zl,r=0;r0){if(o<=0)return $l.signum(a);r=i+o}else{if(!(i<0))return $l.signum(a);if(o>=0)return $l.signum(a);r=-i-o}var s=$l.DP_SAFE_EPSILON*r;return a>=s||-a>=s?$l.signum(a):2},$l.signum=function(t){return t>0?1:t<0?-1:0},tu.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties($l,tu);var eu=function(){},nu={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};nu.X.get=function(){return 0},nu.Y.get=function(){return 1},nu.Z.get=function(){return 2},nu.M.get=function(){return 3},eu.prototype.setOrdinate=function(t,e,n){},eu.prototype.size=function(){},eu.prototype.getOrdinate=function(t,e){},eu.prototype.getCoordinate=function(){},eu.prototype.getCoordinateCopy=function(t){},eu.prototype.getDimension=function(){},eu.prototype.getX=function(t){},eu.prototype.clone=function(){},eu.prototype.expandEnvelope=function(t){},eu.prototype.copy=function(){},eu.prototype.getY=function(t){},eu.prototype.toCoordinateArray=function(){},eu.prototype.interfaces_=function(){return[kl]},eu.prototype.getClass=function(){return eu},Object.defineProperties(eu,nu);var ru=function(){},iu=function(t){function e(){t.call(this,"Projective point not representable on the Cartesian plane.")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ru),ou=function(){};ou.arraycopy=function(t,e,n,r,i){for(var o=0,a=e;at._minx?this._minx:t._minx,n=this._miny>t._miny?this._miny:t._miny,r=this._maxx=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return!this.isNull()&&n>=this._minx&&n<=this._maxx&&r>=this._miny&&r<=this._maxy}},su.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof su){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx||nthis._maxy||rthis._maxx&&(this._maxx=e._maxx),e._minythis._maxy&&(this._maxy=e._maxy))}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.isNull()?(this._minx=n,this._maxx=n,this._miny=r,this._maxy=r):(nthis._maxx&&(this._maxx=n),rthis._maxy&&(this._maxy=r))}},su.prototype.minExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0},su.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},su.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"},su.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1},su.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny},su.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},su.prototype.expandBy=function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}},su.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof su){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof Bl){var e=arguments[0];return this.covers(e)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return this.covers(n,r)}},su.prototype.centre=function(){return this.isNull()?null:new Bl((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},su.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof Bl){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof su){var e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y)}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];it._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxyt._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)},su.prototype.hashCode=function(){var t=17;return 37*(t=37*(t=37*(t=37*t+Bl.hashCode(this._minx))+Bl.hashCode(this._maxx))+Bl.hashCode(this._miny))+Bl.hashCode(this._maxy)},su.prototype.interfaces_=function(){return[Ol,Fl]},su.prototype.getClass=function(){return su},su.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],a=arguments[3],s=Math.min(o.x,a.x),l=Math.max(o.x,a.x),u=Math.min(r.x,i.x),c=Math.max(r.x,i.x);return!(u>l||cl||cthis.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}},yu.prototype.isProper=function(){return this.hasIntersection()&&this._isProper},yu.prototype.setPrecisionModel=function(t){this._precisionModel=t},yu.prototype.isInteriorIntersection=function(){var t=this;if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var e=arguments[0],n=0;ni?r:i;else{var a=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);0!==(o=r>i?a:s)||t.equals(e)||(o=Math.max(a,s))}return gu.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o},yu.nonRobustComputeEdgeDistance=function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return gu.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o},vu.DONT_INTERSECT.get=function(){return 0},vu.DO_INTERSECT.get=function(){return 1},vu.COLLINEAR.get=function(){return 2},vu.NO_INTERSECTION.get=function(){return 0},vu.POINT_INTERSECTION.get=function(){return 1},vu.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(yu,vu);var _u=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isInSegmentEnvelopes=function(t){var e=new su(this._inputLines[0][0],this._inputLines[0][1]),n=new su(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)},e.prototype.computeIntersection=function(){if(3!==arguments.length)return t.prototype.computeIntersection.apply(this,arguments);var e=arguments[0],n=arguments[1],r=arguments[2];if(this._isProper=!1,su.intersects(n,r,e)&&0===wu.orientationIndex(n,r,e)&&0===wu.orientationIndex(r,n,e))return this._isProper=!0,(e.equals(n)||e.equals(r))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION},e.prototype.normalizeToMinimum=function(t,e,n,r,i){i.x=this.smallestInAbsValue(t.x,e.x,n.x,r.x),i.y=this.smallestInAbsValue(t.y,e.y,n.y,r.y),t.x-=i.x,t.y-=i.y,e.x-=i.x,e.y-=i.y,n.x-=i.x,n.y-=i.y,r.x-=i.x,r.y-=i.y},e.prototype.safeHCoordinateIntersection=function(t,n,r,i){var o=null;try{o=au.intersection(t,n,r,i)}catch(a){if(!(a instanceof iu))throw a;o=e.nearestEndpoint(t,n,r,i)}return o},e.prototype.intersection=function(t,n,r,i){var o=this.intersectionWithNormalization(t,n,r,i);return this.isInSegmentEnvelopes(o)||(o=new Bl(e.nearestEndpoint(t,n,r,i))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o},e.prototype.smallestInAbsValue=function(t,e,n,r){var i=t,o=Math.abs(i);return Math.abs(e)1e-4&&ou.out.println("Distance = "+i.distance(o))},e.prototype.intersectionWithNormalization=function(t,e,n,r){var i=new Bl(t),o=new Bl(e),a=new Bl(n),s=new Bl(r),l=new Bl;this.normalizeToEnvCentre(i,o,a,s,l);var u=this.safeHCoordinateIntersection(i,o,a,s);return u.x+=l.x,u.y+=l.y,u},e.prototype.computeCollinearIntersection=function(e,n,r,i){var o=su.intersects(e,n,r),a=su.intersects(e,n,i),s=su.intersects(r,i,e),l=su.intersects(r,i,n);return o&&a?(this._intPt[0]=r,this._intPt[1]=i,t.COLLINEAR_INTERSECTION):s&&l?(this._intPt[0]=e,this._intPt[1]=n,t.COLLINEAR_INTERSECTION):o&&s?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||a||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):o&&l?(this._intPt[0]=r,this._intPt[1]=n,!r.equals(n)||a||s?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):a&&s?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||o||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):a&&l?(this._intPt[0]=i,this._intPt[1]=n,!i.equals(n)||o||s?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION},e.prototype.normalizeToEnvCentre=function(t,e,n,r,i){var o=t.xe.x?t.x:e.x,l=t.y>e.y?t.y:e.y,u=n.xr.x?n.x:r.x,p=n.y>r.y?n.y:r.y,f=((o>u?o:u)+(sc?a:c)+(l0&&a>0||o<0&&a<0)return t.NO_INTERSECTION;var s=wu.orientationIndex(r,i,e),l=wu.orientationIndex(r,i,n);return s>0&&l>0||s<0&&l<0?t.NO_INTERSECTION:0===o&&0===a&&0===s&&0===l?this.computeCollinearIntersection(e,n,r,i):(0===o||0===a||0===s||0===l?(this._isProper=!1,e.equals2D(r)||e.equals2D(i)?this._intPt[0]=e:n.equals2D(r)||n.equals2D(i)?this._intPt[0]=n:0===o?this._intPt[0]=new Bl(r):0===a?this._intPt[0]=new Bl(i):0===s?this._intPt[0]=new Bl(e):0===l&&(this._intPt[0]=new Bl(n))):(this._isProper=!0,this._intPt[0]=this.intersection(e,n,r,i)),t.POINT_INTERSECTION)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.nearestEndpoint=function(t,e,n,r){var i=t,o=wu.distancePointLine(t,n,r),a=wu.distancePointLine(e,n,r);return a0?n>0?-i:i:n>0?i:-i;if(0===e||0===n)return r>0?t>0?i:-i:t>0?-i:i;if(e>0?r>0?e<=r||(i=-i,o=t,t=n,n=o,o=e,e=r,r=o):e<=-r?(i=-i,n=-n,r=-r):(o=t,t=-n,n=o,o=e,e=-r,r=o):r>0?-e<=r?(i=-i,t=-t,e=-e):(o=-t,t=n,n=o,o=-e,e=r,r=o):e>=r?(t=-t,e=-e,n=-n,r=-r):(i=-i,o=-t,t=-n,n=o,o=-e,e=-r,r=o),t>0){if(!(n>0))return i;if(!(t<=n))return i}else{if(n>0)return-i;if(!(t>=n))return-i;i=-i,t=-t,n=-n}for(;;){if((r-=(a=Math.floor(n/t))*e)<0)return-i;if(r>e)return i;if(t>(n-=a*t)+n){if(er+r)return-i;n=t-n,r=e-r,i=-i}if(0===r)return 0===n?0:-i;if(0===n)return i;if((e-=(a=Math.floor(t/n))*r)<0)return i;if(e>r)return-i;if(n>(t-=a*n)+t){if(re+e)return i;t=n-t,e=r-e,i=-i}if(0===e)return 0===t?0:i;if(0===t)return-i}};var bu=function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t};bu.prototype.countSegment=function(t,e){if(t.xr&&(n=e.x,r=t.x),this._p.x>=n&&this._p.x<=r&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var i=t.x-this._p.x,o=t.y-this._p.y,a=e.x-this._p.x,s=e.y-this._p.y,l=xu.signOfDet2x2(i,o,a,s);if(0===l)return this._isPointOnSegment=!0,null;s0&&this._crossingCount++}},bu.prototype.isPointInPolygon=function(){return this.getLocation()!==jl.EXTERIOR},bu.prototype.getLocation=function(){return this._isPointOnSegment?jl.BOUNDARY:this._crossingCount%2==1?jl.INTERIOR:jl.EXTERIOR},bu.prototype.isOnSegment=function(){return this._isPointOnSegment},bu.prototype.interfaces_=function(){return[]},bu.prototype.getClass=function(){return bu},bu.locatePointInRing=function(){if(arguments[0]instanceof Bl&&ql(arguments[1],eu)){for(var t=arguments[1],e=new bu(arguments[0]),n=new Bl,r=new Bl,i=1;i1||s<0||s>1)&&(i=!0)}}else i=!0;return i?Wl.min(wu.distancePointLine(t,n,r),wu.distancePointLine(e,n,r),wu.distancePointLine(n,t,e),wu.distancePointLine(r,t,e)):0},wu.isPointInRing=function(t,e){return wu.locatePointInRing(t,e)!==jl.EXTERIOR},wu.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,r=new Bl;t.getCoordinate(0,r);for(var i=r.x,o=r.y,a=1;an.y&&(n=o,r=i)}var a=r;do{(a-=1)<0&&(a=e)}while(t[a].equals2D(n)&&a!==r);var s=r;do{s=(s+1)%e}while(t[s].equals2D(n)&&s!==r);var l=t[a],u=t[s];if(l.equals2D(n)||u.equals2D(n)||l.equals2D(u))return!1;var c=wu.computeOrientation(l,n,u);return 0===c?l.x>u.x:c>0},wu.locatePointInRing=function(t,e){return bu.locatePointInRing(t,e)},wu.distancePointLinePerpendicular=function(t,e,n){var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(i)*Math.sqrt(r)},wu.computeOrientation=function(t,e,n){return wu.orientationIndex(t,e,n)},wu.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new Rl("Line array must contain at least one vertex");for(var n=t.distance(e[0]),r=0;r=1)return o.distance(s);var c=((a.y-o.y)*(s.x-a.x)-(a.x-o.x)*(s.y-a.y))/l;return Math.abs(c)*Math.sqrt(l)}},wu.isOnLine=function(t,e){for(var n=new _u,r=1;r0},Ru.prototype.interfaces_=function(){return[Au]},Ru.prototype.getClass=function(){return Ru};var Du=function(){};Du.prototype.isInBoundary=function(t){return t>1},Du.prototype.interfaces_=function(){return[Au]},Du.prototype.getClass=function(){return Du};var Nu=function(){};Nu.prototype.isInBoundary=function(t){return 1===t},Nu.prototype.interfaces_=function(){return[Au]},Nu.prototype.getClass=function(){return Nu};var Ou=function(){};function ku(t){this.message=t||""}Ou.prototype.add=function(){},Ou.prototype.addAll=function(){},Ou.prototype.isEmpty=function(){},Ou.prototype.iterator=function(){},Ou.prototype.size=function(){},Ou.prototype.toArray=function(){},Ou.prototype.remove=function(){},ku.prototype=new Error,ku.prototype.name="IndexOutOfBoundsException";var zu=function(){};zu.prototype.hasNext=function(){},zu.prototype.next=function(){},zu.prototype.remove=function(){};var Fu=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(){},e.prototype.set=function(){},e.prototype.isEmpty=function(){},e}(Ou);function Bu(t){this.message=t||""}Bu.prototype=new Error,Bu.prototype.name="NoSuchElementException";var Uu=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof Ou&&this.addAll(arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.ensureCapacity=function(){},e.prototype.interfaces_=function(){return[t,Ou]},e.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0},e.prototype.clear=function(){this.array_=[]},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},e.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n},e.prototype.iterator=function(){return new Vu(this)},e.prototype.get=function(t){if(t<0||t>=this.size())throw new ku;return this.array_[t]},e.prototype.isEmpty=function(){return 0===this.array_.length},e.prototype.size=function(){return this.array_.length},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e=1){if(this.get(this.size()-1).equals2D(o))return null}t.prototype.add.call(this,o)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var a=arguments[0],s=arguments[1];return this.add(a,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var l=arguments[0],u=arguments[1];if(arguments[2])for(var c=0;c=0;h--)e.add(l[h],u);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof Bl){var p=arguments[0],f=arguments[1];if(!arguments[2]){var d=this.size();if(d>0){if(p>0){if(this.get(p-1).equals2D(f))return null}if(pv&&(_=-1);for(var x=y;x!==v;x+=_)e.add(m[x],g);return!0}},e.prototype.closeRing=function(){this.size()>0&&this.add(new Bl(this.get(0)),!1)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},Object.defineProperties(e,n),e}(Uu),ju=function(){},Hu={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};Hu.ForwardComparator.get=function(){return qu},Hu.BidirectionalComparator.get=function(){return Wu},Hu.coordArrayType.get=function(){return new Array(0).fill(null)},ju.prototype.interfaces_=function(){return[]},ju.prototype.getClass=function(){return ju},ju.isRing=function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))},ju.ptNotInList=function(t,e){for(var n=0;n=t?e:[]},ju.indexOf=function(t,e){for(var n=0;n0)&&(e=t[n]);return e},ju.extract=function(t,e,n){e=Wl.clamp(e,0,t.length);var r=(n=Wl.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),nr.length)return 1;if(0===n.length)return 0;var i=ju.compare(n,r);return ju.isEqualReversed(n,r)?0:i},Wu.prototype.OLDcompare=function(t,e){var n=t,r=e;if(n.lengthr.length)return 1;if(0===n.length)return 0;for(var i=ju.increasingDirection(n),o=ju.increasingDirection(r),a=i>0?0:n.length-1,s=o>0?0:n.length-1,l=0;l0))return e.value;e=e.right}}return null},ic.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,r,i=this.root_;do{if(n=i,(r=t.compareTo(i.key))<0)i=i.left;else{if(!(r>0)){var o=i.value;return i.value=e,o}i=i.right}}while(null!==i);var a={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return r<0?n.left=a:n.right=a,this.fixAfterInsertion(a),this.size_++,null},ic.prototype.fixAfterInsertion=function(t){var e=this;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)if(tc(t)===nc(tc(tc(t)))){var n=rc(tc(tc(t)));1===$u(n)?(ec(tc(t),0),ec(n,0),ec(tc(tc(t)),1),t=tc(tc(t))):(t===rc(tc(t))&&(t=tc(t),e.rotateLeft(t)),ec(tc(t),0),ec(tc(tc(t)),1),e.rotateRight(tc(tc(t))))}else{var r=nc(tc(tc(t)));1===$u(r)?(ec(tc(t),0),ec(r,0),ec(tc(tc(t)),1),t=tc(tc(t))):(t===nc(tc(t))&&(t=tc(t),e.rotateRight(t)),ec(tc(t),0),ec(tc(tc(t)),1),e.rotateLeft(tc(tc(t))))}this.root_.color=0},ic.prototype.values=function(){var t=new Uu,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=ic.successor(e));)t.add(e.value);return t},ic.prototype.entrySet=function(){var t=new Ku,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=ic.successor(e));)t.add(e);return t},ic.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},ic.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},ic.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},ic.successor=function(t){if(null===t)return null;if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e}for(var n=t.parent,r=t;null!==n&&r===n.right;)r=n,n=n.parent;return n},ic.prototype.size=function(){return this.size_};var oc=function(){};function ac(){}function sc(){this.array_=[],arguments[0]instanceof Ou&&this.addAll(arguments[0])}oc.prototype.interfaces_=function(){return[]},oc.prototype.getClass=function(){return oc},ac.prototype=new Ju,sc.prototype=new ac,sc.prototype.contains=function(t){for(var e=0,n=this.array_.length;e=0;){var a=i.substring(0,o);r.add(a),o=(i=i.substring(o+n)).indexOf(e)}i.length>0&&r.add(i);for(var s=new Array(r.size()).fill(null),l=0;l0)for(var o=i;o0&&r.append(" ");for(var o=0;o0&&r.append(","),r.append(Sc.toString(t.getOrdinate(i,o)))}return r.append(")"),r.toString()}},Tc.ensureValidRing=function(t,e){var n=e.size();return 0===n?e:n<=3?Tc.createClosedRing(t,e,4):e.getOrdinate(0,eu.X)===e.getOrdinate(n-1,eu.X)&&e.getOrdinate(0,eu.Y)===e.getOrdinate(n-1,eu.Y)?e:Tc.createClosedRing(t,e,n+1)},Tc.createClosedRing=function(t,e,n){var r=t.create(n,e.getDimension()),i=e.size();Tc.copy(e,0,r,0,i);for(var o=i;o0&&Tc.reverse(t._points),null}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?cc.FALSE:0},e.prototype.isClosed=function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},e.prototype.getEndPoint=function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},e.prototype.getDimension=function(){return 1},e.prototype.getLength=function(){return wu.computeLength(this._points)},e.prototype.getNumPoints=function(){return this._points.size()},e.prototype.reverse=function(){var t=this._points.copy();return Tc.reverse(t),this.getFactory().createLineString(t)},e.prototype.compareToSameClass=function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e= 2)");this._points=t},e.prototype.isCoordinate=function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 4)")},e.prototype.getGeometryType=function(){return"LinearRing"},e.prototype.copy=function(){return new e(this._points.copy(),this._factory)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.MINIMUM_VALID_SIZE.get=function(){return 4},n.serialVersionUID.get=function(){return-0x3b229e262367a600},Object.defineProperties(e,n),e}(Cc),Nc=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Mu.SORTINDEX_MULTIPOLYGON},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return 1},e.prototype.getDimension=function(){return 2},e.prototype.reverse=function(){for(var t=this._geometries.length,e=new Array(t).fill(null),n=0;n0?e.createPoint(n[0]):e.createPoint():t},Fc.prototype.interfaces_=function(){return[Oc.GeometryEditorOperation]},Fc.prototype.getClass=function(){return Fc};var Bc=function(){};Bc.prototype.edit=function(t,e){return t instanceof Dc?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof Cc?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof Ac?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},Bc.prototype.interfaces_=function(){return[Oc.GeometryEditorOperation]},Bc.prototype.getClass=function(){return Bc};var Uc=function(){var t=this;if(this._dimension=3,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array)this._coordinates=arguments[0],this._dimension=3;else if(Number.isInteger(arguments[0])){var e=arguments[0];this._coordinates=new Array(e).fill(null);for(var n=0;n0){var t=new Zl(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(e=3),e<2?new Uc(t):new Uc(t,e)}},Gc.prototype.interfaces_=function(){return[Gl,Fl]},Gc.prototype.getClass=function(){return Gc},Gc.instance=function(){return Gc.instanceObject},jc.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},jc.instanceObject.get=function(){return new Gc},Object.defineProperties(Gc,jc);var Hc=function(t){function e(){t.call(this),this.map_=new Map}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return this.map_.get(t)||null},e.prototype.put=function(t,e){return this.map_.set(t,e),e},e.prototype.values=function(){for(var t=new Uu,e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t},e.prototype.entrySet=function(){var t=new Ku;return this.map_.entries().forEach((function(e){return t.add(e)})),t},e.prototype.size=function(){return this.map_.size()},e}(Xu),qc=function t(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof Xc){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n)}else if(arguments[0]instanceof t){var r=arguments[0];this._modelType=r._modelType,this._scale=r._scale}},Wc={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};qc.prototype.equals=function(t){if(!(t instanceof qc))return!1;var e=t;return this._modelType===e._modelType&&this._scale===e._scale},qc.prototype.compareTo=function(t){var e=t,n=this.getMaximumSignificantDigits(),r=e.getMaximumSignificantDigits();return new Yl(n).compareTo(new Yl(r))},qc.prototype.getScale=function(){return this._scale},qc.prototype.isFloating=function(){return this._modelType===qc.FLOATING||this._modelType===qc.FLOATING_SINGLE},qc.prototype.getType=function(){return this._modelType},qc.prototype.toString=function(){var t="UNKNOWN";return this._modelType===qc.FLOATING?t="Floating":this._modelType===qc.FLOATING_SINGLE?t="Floating-Single":this._modelType===qc.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},qc.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var t=arguments[0];return Dl.isNaN(t)||this._modelType===qc.FLOATING_SINGLE?t:this._modelType===qc.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof Bl){var e=arguments[0];if(this._modelType===qc.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},qc.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===qc.FLOATING?t=16:this._modelType===qc.FLOATING_SINGLE?t=6:this._modelType===qc.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},qc.prototype.setScale=function(t){this._scale=Math.abs(t)},qc.prototype.interfaces_=function(){return[Fl,Ol]},qc.prototype.getClass=function(){return qc},qc.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},Wc.serialVersionUID.get=function(){return 0x6bee6404e9a25c00},Wc.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(qc,Wc);var Xc=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this)},Zc={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};Xc.prototype.readResolve=function(){return Xc.nameToTypeMap.get(this._name)},Xc.prototype.toString=function(){return this._name},Xc.prototype.interfaces_=function(){return[Fl]},Xc.prototype.getClass=function(){return Xc},Zc.serialVersionUID.get=function(){return-552860263173159e4},Zc.nameToTypeMap.get=function(){return new Hc},Object.defineProperties(Xc,Zc),qc.Type=Xc,qc.FIXED=new Xc("FIXED"),qc.FLOATING=new Xc("FLOATING"),qc.FLOATING_SINGLE=new Xc("FLOATING SINGLE");var Yc=function t(){this._precisionModel=new qc,this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?ql(arguments[0],Gl)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof qc&&(this._precisionModel=arguments[0]):2===arguments.length?(this._precisionModel=arguments[0],this._SRID=arguments[1]):3===arguments.length&&(this._precisionModel=arguments[0],this._SRID=arguments[1],this._coordinateSequenceFactory=arguments[2]))},Jc={serialVersionUID:{configurable:!0}};Yc.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new Bl(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new Bl(t.getMinX(),t.getMinY()),new Bl(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new Bl(t.getMinX(),t.getMinY()),new Bl(t.getMinX(),t.getMaxY()),new Bl(t.getMaxX(),t.getMaxY()),new Bl(t.getMaxX(),t.getMinY()),new Bl(t.getMinX(),t.getMinY())]),null)},Yc.prototype.createLineString=function(t){return t?t instanceof Array?new Cc(this.getCoordinateSequenceFactory().create(t),this):ql(t,eu)?new Cc(t,this):void 0:new Cc(this.getCoordinateSequenceFactory().create([]),this)},Yc.prototype.createMultiLineString=function(){if(0===arguments.length)return new mc(null,this);if(1===arguments.length){return new mc(arguments[0],this)}},Yc.prototype.buildGeometry=function(t){for(var e=null,n=!1,r=!1,i=t.iterator();i.hasNext();){var o=i.next(),a=o.getClass();null===e&&(e=a),a!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(r=!0)}if(null===e)return this.createGeometryCollection();if(n||r)return this.createGeometryCollection(Yc.toGeometryArray(t));var s=t.iterator().next();if(t.size()>1){if(s instanceof Pc)return this.createMultiPolygon(Yc.toPolygonArray(t));if(s instanceof Cc)return this.createMultiLineString(Yc.toLineStringArray(t));if(s instanceof Ac)return this.createMultiPoint(Yc.toPointArray(t));gu.shouldNeverReachHere("Unhandled class: "+s.getClass().getName())}return s},Yc.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},Yc.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Bl){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(ql(arguments[0],eu)){return new Ac(arguments[0],this)}}},Yc.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory},Yc.prototype.createPolygon=function(){if(0===arguments.length)return new Pc(null,null,this);if(1===arguments.length){if(ql(arguments[0],eu)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Dc){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){return new Pc(arguments[0],arguments[1],this)}},Yc.prototype.getSRID=function(){return this._SRID},Yc.prototype.createGeometryCollection=function(){if(0===arguments.length)return new dc(null,this);if(1===arguments.length){return new dc(arguments[0],this)}},Yc.prototype.createGeometry=function(t){return new Oc(this).edit(t,{edit:function(){if(2===arguments.length){var t=arguments[0];return this._coordinateSequenceFactory.create(t)}}})},Yc.prototype.getPrecisionModel=function(){return this._precisionModel},Yc.prototype.createLinearRing=function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(ql(arguments[0],eu)){return new Dc(arguments[0],this)}}},Yc.prototype.createMultiPolygon=function(){if(0===arguments.length)return new Nc(null,this);if(1===arguments.length){return new Nc(arguments[0],this)}},Yc.prototype.createMultiPoint=function(){if(0===arguments.length)return new Rc(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){return new Rc(arguments[0],this)}if(arguments[0]instanceof Array){var t=arguments[0];return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(ql(arguments[0],eu)){var e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));for(var n=new Array(e.size()).fill(null),r=0;r=this.size())throw new Error;return this.array_[t]},ah.prototype.push=function(t){return this.array_.push(t),t},ah.prototype.pop=function(t){if(0===this.array_.length)throw new oh;return this.array_.pop()},ah.prototype.peek=function(){if(0===this.array_.length)throw new oh;return this.array_[this.array_.length-1]},ah.prototype.empty=function(){return 0===this.array_.length},ah.prototype.isEmpty=function(){return this.empty()},ah.prototype.search=function(t){return this.array_.indexOf(t)},ah.prototype.size=function(){return this.array_.length},ah.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&r===wu.CLOCKWISE)&&(i=!0),i&&(this._minIndex=this._minIndex-1)},sh.prototype.getRightmostSideOfSegment=function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var r=rh.LEFT;return n[e].ye._minCoord.x)&&(e._minDe=t,e._minIndex=r,e._minCoord=n[r])},sh.prototype.findRightmostEdgeAtNode=function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)},sh.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}gu.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===rh.LEFT&&(this._orientedDe=this._minDe.getSym())},sh.prototype.interfaces_=function(){return[]},sh.prototype.getClass=function(){return sh};var lh=function(t){function e(n,r){t.call(this,e.msgWithCoord(n,r)),this.pt=r?new Bl(r):null,this.name="TopologyException"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getCoordinate=function(){return this.pt},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.msgWithCoord=function(t,e){return e?t:t+" [ "+e+" ]"},e}(du),uh=function(){this.array_=[]};uh.prototype.addLast=function(t){this.array_.push(t)},uh.prototype.removeFirst=function(){return this.array_.shift()},uh.prototype.isEmpty=function(){return 0===this.array_.length};var ch=function(){this._finder=null,this._dirEdgeList=new Uu,this._nodes=new Uu,this._rightMostCoord=null,this._env=null,this._finder=new sh};ch.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)},ch.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},ch.prototype.computeNodeDepth=function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var r=n.next();if(r.isVisited()||r.getSym().isVisited()){e=r;break}}if(null===e)throw new lh("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var i=t.getEdges().iterator();i.hasNext();){var o=i.next();o.setVisited(!0),this.copySymDepths(o)}},ch.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(rh.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},ch.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},ch.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(rh.RIGHT)>=1&&e.getDepth(rh.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},ch.prototype.computeDepths=function(t){var e=new Ku,n=new uh,r=t.getNode();for(n.addLast(r),e.add(r),t.setVisited(!0);!n.isEmpty();){var i=n.removeFirst();e.add(i),this.computeNodeDepth(i);for(var o=i.getEdges().iterator();o.hasNext();){var a=o.next().getSym();if(!a.isVisited()){var s=a.getNode();e.contains(s)||(n.addLast(s),e.add(s))}}}},ch.prototype.compareTo=function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0},ch.prototype.getEnvelope=function(){if(null===this._env){for(var t=new su,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),r=0;rthis.location.length){var e=new Array(3).fill(null);e[rh.ON]=this.location[rh.ON],e[rh.LEFT]=jl.NONE,e[rh.RIGHT]=jl.NONE,this.location=e}for(var n=0;n1&&t.append(jl.toLocationSymbol(this.location[rh.LEFT])),t.append(jl.toLocationSymbol(this.location[rh.ON])),this.location.length>1&&t.append(jl.toLocationSymbol(this.location[rh.RIGHT])),t.toString()},hh.prototype.setLocations=function(t,e,n){this.location[rh.ON]=t,this.location[rh.LEFT]=e,this.location[rh.RIGHT]=n},hh.prototype.get=function(t){return t1},hh.prototype.isAnyNull=function(){for(var t=0;tt._maxNodeDegree&&(t._maxNodeDegree=n),e=t.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2},fh.prototype.addPoints=function(t,e,n){var r=t.getCoordinates();if(e){var i=1;n&&(i=0);for(var o=i;o=0;s--)this._pts.add(r[s])}},fh.prototype.isHole=function(){return this._isHole},fh.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)},fh.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!wu.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0},fh.prototype.addHole=function(t){this._holes.add(t)},fh.prototype.isShell=function(){return null===this._shell},fh.prototype.getLabel=function(){return this._label},fh.prototype.getEdges=function(){return this._edges},fh.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},fh.prototype.getShell=function(){return this._shell},fh.prototype.mergeLabel=function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,rh.RIGHT);if(n===jl.NONE)return null;if(this._label.getLocation(e)===jl.NONE)return this._label.setLocation(e,n),null}},fh.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this)},fh.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)},gh.prototype.isInResult=function(){return this._isInResult},gh.prototype.isVisited=function(){return this._isVisited},gh.prototype.interfaces_=function(){return[]},gh.prototype.getClass=function(){return gh};var yh=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var e=arguments[0],n=arguments[1];this._coord=e,this._edges=n,this._label=new ph(0,jl.NONE)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isIncidentEdgeInResult=function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();)if(t.next().getEdge().isInResult())return!0;return!1},e.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},e.prototype.getCoordinate=function(){return this._coord},e.prototype.print=function(t){t.println("node "+this._coord+" lbl: "+this._label)},e.prototype.computeIM=function(t){},e.prototype.computeMergedLocation=function(t,e){var n=jl.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var r=t.getLocation(e);n!==jl.BOUNDARY&&(n=r)}return n},e.prototype.setLabel=function(){if(2!==arguments.length)return t.prototype.setLabel.apply(this,arguments);var e=arguments[0],n=arguments[1];null===this._label?this._label=new ph(e,n):this._label.setLocation(e,n)},e.prototype.getEdges=function(){return this._edges},e.prototype.mergeLabel=function(){var t=this;if(arguments[0]instanceof e){var n=arguments[0];this.mergeLabel(n._label)}else if(arguments[0]instanceof ph)for(var r=arguments[0],i=0;i<2;i++){var o=t.computeMergedLocation(r,i);t._label.getLocation(i)===jl.NONE&&t._label.setLocation(i,o)}},e.prototype.add=function(t){this._edges.insert(t),t.setNode(this)},e.prototype.setLabelBoundary=function(t){if(null===this._label)return null;var e=jl.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;if(e===jl.BOUNDARY)n=jl.INTERIOR;else n=jl.BOUNDARY;this._label.setLocation(t,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(gh),vh=function(){this.nodeMap=new ic,this.nodeFact=null;var t=arguments[0];this.nodeFact=t};vh.prototype.find=function(t){return this.nodeMap.get(t)},vh.prototype.addNode=function(){if(arguments[0]instanceof Bl){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof yh){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return null===r?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r)}},vh.prototype.print=function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)},vh.prototype.iterator=function(){return this.nodeMap.values().iterator()},vh.prototype.values=function(){return this.nodeMap.values()},vh.prototype.getBoundaryNodes=function(t){for(var e=new Uu,n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===jl.BOUNDARY&&e.add(r)}return e},vh.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t)},vh.prototype.interfaces_=function(){return[]},vh.prototype.getClass=function(){return vh};var _h=function(){},xh={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};_h.prototype.interfaces_=function(){return[]},_h.prototype.getClass=function(){return _h},_h.isNorthern=function(t){return t===_h.NE||t===_h.NW},_h.isOpposite=function(t,e){return t!==e&&2==(t-e+4)%4},_h.commonHalfPlane=function(t,e){if(t===e)return t;if(2==(t-e+4)%4)return-1;var n=te?t:e)?3:n},_h.isInHalfPlane=function(t,e){return e===_h.SE?t===_h.SE||t===_h.SW:t===e||t===e+1},_h.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new Rl("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?_h.NE:_h.SE:e>=0?_h.NW:_h.SW}if(arguments[0]instanceof Bl&&arguments[1]instanceof Bl){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new Rl("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?_h.NE:_h.SE:r.y>=n.y?_h.NW:_h.SW}},xh.NE.get=function(){return 0},xh.NW.get=function(){return 1},xh.SW.get=function(){return 2},xh.SE.get=function(){return 3},Object.defineProperties(_h,xh);var bh=function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){var t=arguments[0];this._edge=t}else if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2];this._edge=e,this.init(n,r),this._label=null}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];this._edge=i,this.init(o,a),this._label=s}};bh.prototype.compareDirection=function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var a=o.buildMinimalRings(),s=this.findShell(a);null!==s?(this.placePolygonHoles(s,a),e.add(s)):n.addAll(a)}else r.add(o)}return r},Mh.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();)if(e.next().containsPoint(t))return!0;return!1},Mh.prototype.buildMaximalEdgeRings=function(t){for(var e=new Uu,n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&null===r.getEdgeRing()){var i=new mh(r,this._geometryFactory);e.add(i),i.setInResult()}}return e},Mh.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t)}},Mh.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},Mh.prototype.findEdgeRingContaining=function(t,e){for(var n=t.getLinearRing(),r=n.getEnvelopeInternal(),i=n.getCoordinateN(0),o=null,a=null,s=e.iterator();s.hasNext();){var l=s.next(),u=l.getLinearRing(),c=u.getEnvelopeInternal();null!==o&&(a=o.getLinearRing().getEnvelopeInternal());var h=!1;c.contains(r)&&wu.isPointInRing(i,u.getCoordinates())&&(h=!0),h&&(null===o||a.contains(c))&&(o=l)}return o},Mh.prototype.findShell=function(t){for(var e=0,n=null,r=t.iterator();r.hasNext();){var i=r.next();i.isHole()||(n=i,e++)}return gu.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},Mh.prototype.add=function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0];Sh.linkResultDirectedEdges(arguments[1]);var n=this.buildMaximalEdgeRings(e),r=new Uu,i=this.buildMinimalEdgeRings(n,this._shellList,r);this.sortShellsAndHoles(i,this._shellList,r),this.placeFreeHoles(this._shellList,r)}},Mh.prototype.interfaces_=function(){return[]},Mh.prototype.getClass=function(){return Mh};var Th=function(){};Th.prototype.getBounds=function(){},Th.prototype.interfaces_=function(){return[]},Th.prototype.getClass=function(){return Th};var Ch=function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e};Ch.prototype.getItem=function(){return this._item},Ch.prototype.getBounds=function(){return this._bounds},Ch.prototype.interfaces_=function(){return[Th,Fl]},Ch.prototype.getClass=function(){return Ch};var Ih=function(){this._size=null,this._items=null,this._size=0,this._items=new Uu,this._items.add(null)};Ih.prototype.poll=function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t},Ih.prototype.size=function(){return this._size},Ih.prototype.reorder=function(t){for(var e=this,n=null,r=this._items.get(t);2*t<=this._size&&((n=2*t)!==e._size&&e._items.get(n+1).compareTo(e._items.get(n))<0&&n++,e._items.get(n).compareTo(r)<0);t=n)e._items.set(t,e._items.get(n));this._items.set(t,r)},Ih.prototype.clear=function(){this._size=0,this._items.clear()},Ih.prototype.isEmpty=function(){return 0===this._size},Ih.prototype.add=function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)},Ih.prototype.interfaces_=function(){return[]},Ih.prototype.getClass=function(){return Ih};var Ah=function(){};Ah.prototype.visitItem=function(t){},Ah.prototype.interfaces_=function(){return[]},Ah.prototype.getClass=function(){return Ah};var Lh=function(){};Lh.prototype.insert=function(t,e){},Lh.prototype.remove=function(t,e){},Lh.prototype.query=function(){},Lh.prototype.interfaces_=function(){return[]},Lh.prototype.getClass=function(){return Lh};var Ph=function(){if(this._childBoundables=new Uu,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}},Rh={serialVersionUID:{configurable:!0}};Ph.prototype.getLevel=function(){return this._level},Ph.prototype.size=function(){return this._childBoundables.size()},Ph.prototype.getChildBoundables=function(){return this._childBoundables},Ph.prototype.addChildBoundable=function(t){gu.isTrue(null===this._bounds),this._childBoundables.add(t)},Ph.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},Ph.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds},Ph.prototype.interfaces_=function(){return[Th,Fl]},Ph.prototype.getClass=function(){return Ph},Rh.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties(Ph,Rh);var Dh=function(){};Dh.reverseOrder=function(){return{compare:function(t,e){return e.compareTo(t)}}},Dh.min=function(t){return Dh.sort(t),t.get(0)},Dh.sort=function(t,e){var n=t.toArray();e?uc.sort(n,e):uc.sort(n);for(var r=t.iterator(),i=0,o=n.length;iNh.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,t,e),null):(this.expand(this._boundable2,this._boundable1,t,e),null);if(n)return this.expand(this._boundable1,this._boundable2,t,e),null;if(r)return this.expand(this._boundable2,this._boundable1,t,e),null;throw new Rl("neither boundable is composite")},Nh.prototype.isLeaves=function(){return!(Nh.isComposite(this._boundable1)||Nh.isComposite(this._boundable2))},Nh.prototype.compareTo=function(t){var e=t;return this._distancee._distance?1:0},Nh.prototype.expand=function(t,e,n,r){for(var i=t.getChildBoundables().iterator();i.hasNext();){var o=i.next(),a=new Nh(o,e,this._itemDistance);a.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=n}},kh={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};Oh.prototype.getNodeCapacity=function(){return this._nodeCapacity},Oh.prototype.lastNode=function(t){return t.get(t.size()-1)},Oh.prototype.size=function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof Ph?t+=this.size(n):n instanceof Ch&&(t+=1)}return t}},Oh.prototype.removeItem=function(t,e){for(var n=null,r=t.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof Ch&&i.getItem()===e&&(n=i)}return null!==n&&(t.getChildBoundables().remove(n),!0)},Oh.prototype.itemsTree=function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new Uu:t}if(1===arguments.length){for(var e=arguments[0],n=new Uu,r=e.getChildBoundables().iterator();r.hasNext();){var i=r.next();if(i instanceof Ph){var o=this.itemsTree(i);null!==o&&n.add(o)}else i instanceof Ch?n.add(i.getItem()):gu.shouldNeverReachHere()}return n.size()<=0?null:n}},Oh.prototype.insert=function(t,e){gu.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Ch(t,e))},Oh.prototype.boundablesAtLevel=function(){if(1===arguments.length){var t=arguments[0],e=new Uu;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];if(gu.isTrue(n>-2),r.getLevel()===n)return i.add(r),null;for(var o=r.getChildBoundables().iterator();o.hasNext();){var a=o.next();a instanceof Ph?this.boundablesAtLevel(n,a,i):(gu.isTrue(a instanceof Ch),-1===n&&i.add(a))}return null}},Oh.prototype.query=function(){var t=this;if(1===arguments.length){var e=arguments[0];this.build();var n=new Uu;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.query(e,this._root,n),n}if(2===arguments.length){var r=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),r)&&this.query(r,this._root,i)}else if(3===arguments.length)if(ql(arguments[2],Ah)&&arguments[0]instanceof Object&&arguments[1]instanceof Ph)for(var o=arguments[0],a=arguments[2],s=arguments[1].getChildBoundables(),l=0;lt&&(t=r)}}return t+1}},Oh.prototype.createParentBoundables=function(t,e){var n=this;gu.isTrue(!t.isEmpty());var r=new Uu;r.add(this.createNode(e));var i=new Uu(t);Dh.sort(i,this.getComparator());for(var o=i.iterator();o.hasNext();){var a=o.next();n.lastNode(r).getChildBoundables().size()===n.getNodeCapacity()&&r.add(n.createNode(e)),n.lastNode(r).addChildBoundable(a)}return r},Oh.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()},Oh.prototype.interfaces_=function(){return[Fl]},Oh.prototype.getClass=function(){return Oh},Oh.compareDoubles=function(t,e){return t>e?1:t0);for(var n=new Uu,r=0;r0;){var h=c.poll(),p=h.getDistance();if(p>=l)break;h.isLeaves()?(l=p,u=h):h.expandToQueue(c,l)}return[u.getBoundable(0).getItem(),u.getBoundable(1).getItem()]}}else if(3===arguments.length){var f=arguments[2],d=new Ch(arguments[0],arguments[1]),m=new Nh(this.getRoot(),d,f);return this.nearestNeighbour(m)[0]}},e.prototype.interfaces_=function(){return[Lh,Fl]},e.prototype.getClass=function(){return e},e.centreX=function(t){return e.avg(t.getMinX(),t.getMaxX())},e.avg=function(t,e){return(t+e)/2},e.centreY=function(t){return e.avg(t.getMinY(),t.getMaxY())},n.STRtreeNode.get=function(){return Uh},n.serialVersionUID.get=function(){return 0x39920f7d5f261e0},n.xComparator.get=function(){return{interfaces_:function(){return[zl]},compare:function(n,r){return t.compareDoubles(e.centreX(n.getBounds()),e.centreX(r.getBounds()))}}},n.yComparator.get=function(){return{interfaces_:function(){return[zl]},compare:function(n,r){return t.compareDoubles(e.centreY(n.getBounds()),e.centreY(r.getBounds()))}}},n.intersectsOp.get=function(){return{interfaces_:function(){return[t.IntersectsOp]},intersects:function(t,e){return t.intersects(e)}}},n.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(e,n),e}(Oh),Uh=function(t){function e(){var e=arguments[0];t.call(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.computeBounds=function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new su(n.getBounds()):t.expandToInclude(n.getBounds())}return t},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ph),Vh=function(){};Vh.prototype.interfaces_=function(){return[]},Vh.prototype.getClass=function(){return Vh},Vh.relativeSign=function(t,e){return te?1:0},Vh.compare=function(t,e,n){if(e.equals2D(n))return 0;var r=Vh.relativeSign(e.x,n.x),i=Vh.relativeSign(e.y,n.y);switch(t){case 0:return Vh.compareValue(r,i);case 1:return Vh.compareValue(i,r);case 2:return Vh.compareValue(i,-r);case 3:return Vh.compareValue(-r,i);case 4:return Vh.compareValue(-r,-i);case 5:return Vh.compareValue(-i,-r);case 6:return Vh.compareValue(-i,r);case 7:return Vh.compareValue(r,-i)}return gu.shouldNeverReachHere("invalid octant value"),0},Vh.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0};var Gh=function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._segString=t,this.coord=new Bl(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n))};Gh.prototype.getCoordinate=function(){return this.coord},Gh.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},Gh.prototype.compareTo=function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:Vh.compare(this._segmentOctant,this.coord,e.coord)},Gh.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},Gh.prototype.isInterior=function(){return this._isInterior},Gh.prototype.interfaces_=function(){return[Ol]},Gh.prototype.getClass=function(){return Gh};var jh=function(){this._nodeMap=new ic,this._edge=null;var t=arguments[0];this._edge=t};jh.prototype.getSplitCoordinates=function(){var t=new Gu;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next();this.addEdgeCoordinates(n,r,t),n=r}return t.toCoordinateArray()},jh.prototype.addCollapsedNodes=function(){var t=new Uu;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}},jh.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},jh.prototype.findCollapsesFromExistingVertices=function(t){for(var e=0;e=0?e>=0?n>=r?0:1:n>=r?7:6:e>=0?n>=r?3:2:n>=r?4:5}if(arguments[0]instanceof Bl&&arguments[1]instanceof Bl){var i=arguments[0],o=arguments[1],a=o.x-i.x,s=o.y-i.y;if(0===a&&0===s)throw new Rl("Cannot compute the octant for two identical points "+i);return Hh.octant(a,s)}};var qh=function(){};qh.prototype.getCoordinates=function(){},qh.prototype.size=function(){},qh.prototype.getCoordinate=function(t){},qh.prototype.isClosed=function(){},qh.prototype.setData=function(t){},qh.prototype.getData=function(){},qh.prototype.interfaces_=function(){return[]},qh.prototype.getClass=function(){return qh};var Wh=function(){};Wh.prototype.addIntersection=function(t,e){},Wh.prototype.interfaces_=function(){return[qh]},Wh.prototype.getClass=function(){return Wh};var Xh=function(){this._nodeList=new jh(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};Xh.prototype.getCoordinates=function(){return this._pts},Xh.prototype.size=function(){return this._pts.length},Xh.prototype.getCoordinate=function(t){return this._pts[t]},Xh.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},Xh.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},Xh.prototype.setData=function(t){this._data=t},Xh.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:Hh.octant(t,e)},Xh.prototype.getData=function(){return this._data},Xh.prototype.addIntersection=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],r=arguments[3],i=new Bl(arguments[0].getIntersection(r));this.addIntersection(i,n)}},Xh.prototype.toString=function(){return fu.toLineString(new Uc(this._pts))},Xh.prototype.getNodeList=function(){return this._nodeList},Xh.prototype.addIntersectionNode=function(t,e){var n=e,r=n+1;if(r=0&&n>=0||e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof Bl){var r=arguments[0];return wu.orientationIndex(this.p0,this.p1,r)}},Zh.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1])},Zh.prototype.isVertical=function(){return this.p0.x===this.p1.x},Zh.prototype.equals=function(t){if(!(t instanceof Zh))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},Zh.prototype.intersection=function(t){var e=new _u;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},Zh.prototype.project=function(){if(arguments[0]instanceof Bl){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new Bl(t);var e=this.projectionFactor(t),n=new Bl;return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof Zh){var r=arguments[0],i=this.projectionFactor(r.p0),o=this.projectionFactor(r.p1);if(i>=1&&o>=1)return null;if(i<=0&&o<=0)return null;var a=this.project(r.p0);i<0&&(a=this.p0),i>1&&(a=this.p1);var s=this.project(r.p1);return o<0&&(s=this.p0),o>1&&(s=this.p1),new Zh(a,s)}},Zh.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},Zh.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},Zh.prototype.getCoordinate=function(t){return 0===t?this.p0:this.p1},Zh.prototype.distancePerpendicular=function(t){return wu.distancePointLinePerpendicular(t,this.p0,this.p1)},Zh.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},Zh.prototype.midPoint=function(){return Zh.midPoint(this.p0,this.p1)},Zh.prototype.projectionFactor=function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,r=e*e+n*n;return r<=0?Dl.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r},Zh.prototype.closestPoints=function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),r=Dl.MAX_VALUE,i=null,o=this.closestPoint(t.p0);r=o.distance(t.p0),n[0]=o,n[1]=t.p0;var a=this.closestPoint(t.p1);(i=a.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||Dl.isNaN(e))&&(e=1),e},Zh.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},Zh.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},Zh.prototype.distance=function(){if(arguments[0]instanceof Zh){var t=arguments[0];return wu.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof Bl){var e=arguments[0];return wu.distancePointLine(e,this.p0,this.p1)}},Zh.prototype.pointAlong=function(t){var e=new Bl;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e},Zh.prototype.hashCode=function(){var t=Dl.doubleToLongBits(this.p0.x);t^=31*Dl.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=Dl.doubleToLongBits(this.p1.x);return n^=31*Dl.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)},Zh.prototype.interfaces_=function(){return[Ol,Fl]},Zh.prototype.getClass=function(){return Zh},Zh.midPoint=function(t,e){return new Bl((t.x+e.x)/2,(t.y+e.y)/2)},Yh.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(Zh,Yh);var Jh=function(){this.tempEnv1=new su,this.tempEnv2=new su,this._overlapSeg1=new Zh,this._overlapSeg2=new Zh};Jh.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(n,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}},Jh.prototype.interfaces_=function(){return[]},Jh.prototype.getClass=function(){return Jh};var Kh=function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._pts=t,this._start=e,this._end=n,this._context=r};Kh.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]},Kh.prototype.computeSelect=function(t,e,n,r){var i=this._pts[e],o=this._pts[n];if(r.tempEnv1.init(i,o),n-e==1)return r.select(this,e),null;if(!t.intersects(r.tempEnv1))return null;var a=Math.trunc((e+n)/2);e=t.length-1)return t.length-1;for(var r=_h.quadrant(t[n],t[n+1]),i=e+1;ir.getId()&&(r.computeOverlaps(o,e),t._nOverlaps++),t._segInt.isDone())return null}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.SegmentOverlapAction.get=function(){return np},Object.defineProperties(e,n),e}(tp),np=function(t){function e(){t.call(this),this._si=null;var e=arguments[0];this._si=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.overlap=function(){if(4!==arguments.length)return t.prototype.overlap.apply(this,arguments);var e=arguments[1],n=arguments[2],r=arguments[3],i=arguments[0].getContext(),o=n.getContext();this._si.processIntersections(i,e,o,r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Jh),rp=function t(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r)}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(o),this.setJoinStyle(a),this.setMitreLimit(s)}},ip={CAP_ROUND:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},JOIN_ROUND:{configurable:!0},JOIN_MITRE:{configurable:!0},JOIN_BEVEL:{configurable:!0},DEFAULT_QUADRANT_SEGMENTS:{configurable:!0},DEFAULT_MITRE_LIMIT:{configurable:!0},DEFAULT_SIMPLIFY_FACTOR:{configurable:!0}};rp.prototype.getEndCapStyle=function(){return this._endCapStyle},rp.prototype.isSingleSided=function(){return this._isSingleSided},rp.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=rp.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=rp.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==rp.JOIN_ROUND&&(this._quadrantSegments=rp.DEFAULT_QUADRANT_SEGMENTS)},rp.prototype.getJoinStyle=function(){return this._joinStyle},rp.prototype.setJoinStyle=function(t){this._joinStyle=t},rp.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t},rp.prototype.getSimplifyFactor=function(){return this._simplifyFactor},rp.prototype.getQuadrantSegments=function(){return this._quadrantSegments},rp.prototype.setEndCapStyle=function(t){this._endCapStyle=t},rp.prototype.getMitreLimit=function(){return this._mitreLimit},rp.prototype.setMitreLimit=function(t){this._mitreLimit=t},rp.prototype.setSingleSided=function(t){this._isSingleSided=t},rp.prototype.interfaces_=function(){return[]},rp.prototype.getClass=function(){return rp},rp.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)},ip.CAP_ROUND.get=function(){return 1},ip.CAP_FLAT.get=function(){return 2},ip.CAP_SQUARE.get=function(){return 3},ip.JOIN_ROUND.get=function(){return 1},ip.JOIN_MITRE.get=function(){return 2},ip.JOIN_BEVEL.get=function(){return 3},ip.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},ip.DEFAULT_MITRE_LIMIT.get=function(){return 5},ip.DEFAULT_SIMPLIFY_FACTOR.get=function(){return.01},Object.defineProperties(rp,ip);var op=function(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=wu.COUNTERCLOCKWISE,this._inputLine=t||null},ap={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};op.prototype.isDeletable=function(t,e,n,r){var i=this._inputLine[t],o=this._inputLine[e],a=this._inputLine[n];return!!this.isConcave(i,o,a)&&!!this.isShallow(i,o,a,r)&&this.isShallowSampled(i,o,t,n,r)},op.prototype.deleteShallowConcavities=function(){for(var t=this,e=1,n=this.findNextNonDeletedIndex(e),r=this.findNextNonDeletedIndex(n),i=!1;r=0;r--)this.addPt(t[r])},sp.prototype.isRedundant=function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)Math.PI;)t-=up.PI_TIMES_2;for(;t<=-Math.PI;)t+=up.PI_TIMES_2;return t},up.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r)}},up.isAcute=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)>0},up.isObtuse=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)<0},up.interiorAngle=function(t,e,n){var r=up.angle(e,t),i=up.angle(e,n);return Math.abs(i-r)},up.normalizePositive=function(t){if(t<0){for(;t<0;)t+=up.PI_TIMES_2;t>=up.PI_TIMES_2&&(t=0)}else{for(;t>=up.PI_TIMES_2;)t-=up.PI_TIMES_2;t<0&&(t=0)}return t},up.angleBetween=function(t,e,n){var r=up.angle(e,t),i=up.angle(e,n);return up.diff(r,i)},up.diff=function(t,e){var n=null;return(n=tMath.PI&&(n=2*Math.PI-n),n},up.toRadians=function(t){return t*Math.PI/180},up.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?up.COUNTERCLOCKWISE:n<0?up.CLOCKWISE:up.NONE},up.angleBetweenOriented=function(t,e,n){var r=up.angle(e,t),i=up.angle(e,n)-r;return i<=-Math.PI?i+up.PI_TIMES_2:i>Math.PI?i-up.PI_TIMES_2:i},cp.PI_TIMES_2.get=function(){return 2*Math.PI},cp.PI_OVER_2.get=function(){return Math.PI/2},cp.PI_OVER_4.get=function(){return Math.PI/4},cp.COUNTERCLOCKWISE.get=function(){return wu.COUNTERCLOCKWISE},cp.CLOCKWISE.get=function(){return wu.CLOCKWISE},cp.NONE.get=function(){return wu.COLLINEAR},Object.defineProperties(up,cp);var hp=function t(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new Zh,this._seg1=new Zh,this._offset0=new Zh,this._offset1=new Zh,this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new _u,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===rp.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r)},pp={OFFSET_SEGMENT_SEPARATION_FACTOR:{configurable:!0},INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},CURVE_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},MAX_CLOSING_SEG_LEN_FACTOR:{configurable:!0}};hp.prototype.addNextSegment=function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=wu.computeOrientation(this._s0,this._s1,this._s2),r=n===wu.CLOCKWISE&&this._side===rh.LEFT||n===wu.COUNTERCLOCKWISE&&this._side===rh.RIGHT;0===n?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},hp.prototype.addLineEndCap=function(t,e){var n=new Zh(t,e),r=new Zh;this.computeOffsetSegment(n,rh.LEFT,this._distance,r);var i=new Zh;this.computeOffsetSegment(n,rh.RIGHT,this._distance,i);var o=e.x-t.x,a=e.y-t.y,s=Math.atan2(a,o);switch(this._bufParams.getEndCapStyle()){case rp.CAP_ROUND:this._segList.addPt(r.p1),this.addFilletArc(e,s+Math.PI/2,s-Math.PI/2,wu.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case rp.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case rp.CAP_SQUARE:var l=new Bl;l.x=Math.abs(this._distance)*Math.cos(s),l.y=Math.abs(this._distance)*Math.sin(s);var u=new Bl(r.p1.x+l.x,r.p1.y+l.y),c=new Bl(i.p1.x+l.x,i.p1.y+l.y);this._segList.addPt(u),this._segList.addPt(c)}},hp.prototype.getCoordinates=function(){return this._segList.getCoordinates()},hp.prototype.addMitreJoin=function(t,e,n,r){var i=!0,o=null;try{o=au.intersection(e.p0,e.p1,n.p0,n.p1),(r<=0?1:o.distance(t)/Math.abs(r))>this._bufParams.getMitreLimit()&&(i=!1)}catch(t){if(!(t instanceof iu))throw t;o=new Bl(0,0),i=!1}i?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit())},hp.prototype.addFilletCorner=function(t,e,n,r,i){var o=e.x-t.x,a=e.y-t.y,s=Math.atan2(a,o),l=n.x-t.x,u=n.y-t.y,c=Math.atan2(u,l);r===wu.CLOCKWISE?s<=c&&(s+=2*Math.PI):s>=c&&(s-=2*Math.PI),this._segList.addPt(e),this.addFilletArc(t,s,c,r,i),this._segList.addPt(n)},hp.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)0){var n=new Bl((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(n);var r=new Bl((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}},hp.prototype.createCircle=function(t){var e=new Bl(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()},hp.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},hp.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new sp,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*hp.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},hp.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===rp.JOIN_BEVEL||this._bufParams.getJoinStyle()===rp.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,wu.CLOCKWISE,this._distance))},hp.prototype.closeRing=function(){this._segList.closeRing()},hp.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},hp.prototype.interfaces_=function(){return[]},hp.prototype.getClass=function(){return hp},pp.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},pp.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},pp.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},pp.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(hp,pp);var fp=function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e};fp.prototype.getOffsetCurve=function(t,e){if(this._distance=e,0===e)return null;var n=e<0,r=Math.abs(e),i=this.getSegGen(r);t.length<=1?this.computePointCurve(t[0],i):this.computeOffsetCurve(t,n,i);var o=i.getCoordinates();return n&&ju.reverse(o),o},fp.prototype.computeSingleSidedBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=op.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],rh.LEFT),n.addFirstSegment();for(var a=o-2;a>=0;a--)n.addNextSegment(i[a],!0)}else{n.addSegments(t,!1);var s=op.simplify(t,r),l=s.length-1;n.initSideSegments(s[0],s[1],rh.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(s[u],!0)}n.addLastSegment(),n.closeRing()},fp.prototype.computeRingBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);e===rh.RIGHT&&(r=-r);var i=op.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var a=1;a<=o;a++){var s=1!==a;n.addNextSegment(i[a],s)}n.closeRing()},fp.prototype.computeLineBufferCurve=function(t,e){var n=this.simplifyTolerance(this._distance),r=op.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],rh.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var a=op.simplify(t,-n),s=a.length-1;e.initSideSegments(a[s],a[s-1],rh.LEFT);for(var l=s-2;l>=0;l--)e.addNextSegment(a[l],!0);e.addLastSegment(),e.addLineEndCap(a[1],a[0]),e.closeRing()},fp.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case rp.CAP_ROUND:e.createCircle(t);break;case rp.CAP_SQUARE:e.createSquare(t)}},fp.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided())return null;if(0===e)return null;var n=Math.abs(e),r=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],r);else if(this._bufParams.isSingleSided()){var i=e<0;this.computeSingleSidedBufferCurve(t,i,r)}else this.computeLineBufferCurve(t,r);return r.getCoordinates()},fp.prototype.getBufferParameters=function(){return this._bufParams},fp.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor()},fp.prototype.getRingCurve=function(t,e,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return fp.copyCoordinates(t);var r=this.getSegGen(n);return this.computeRingBufferCurve(t,e,r),r.getCoordinates()},fp.prototype.computeOffsetCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=op.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],rh.LEFT),n.addFirstSegment();for(var a=o-2;a>=0;a--)n.addNextSegment(i[a],!0)}else{var s=op.simplify(t,r),l=s.length-1;n.initSideSegments(s[0],s[1],rh.LEFT),n.addFirstSegment();for(var u=2;u<=l;u++)n.addNextSegment(s[u],!0)}n.addLastSegment()},fp.prototype.getSegGen=function(t){return new hp(this._precisionModel,this._bufParams,t)},fp.prototype.interfaces_=function(){return[]},fp.prototype.getClass=function(){return fp},fp.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;no.getMaxY()||t.findStabbedSegments(e,i.getDirectedEdges(),n)}return n}if(3===arguments.length)if(ql(arguments[2],Fu)&&arguments[0]instanceof Bl&&arguments[1]instanceof wh)for(var a=arguments[0],s=arguments[1],l=arguments[2],u=s.getEdge().getCoordinates(),c=0;ct._seg.p1.y&&t._seg.reverse();if(!(Math.max(t._seg.p0.x,t._seg.p1.x)t._seg.p1.y||wu.computeOrientation(t._seg.p0,t._seg.p1,a)===wu.RIGHT)){var h=s.getDepth(rh.LEFT);t._seg.p0.equals(u[c])||(h=s.getDepth(rh.RIGHT));var p=new gp(t._seg,h);l.add(p)}}else if(ql(arguments[2],Fu)&&arguments[0]instanceof Bl&&ql(arguments[1],Fu))for(var f=arguments[0],d=arguments[2],m=arguments[1].iterator();m.hasNext();){var g=m.next();g.isForward()&&t.findStabbedSegments(f,g,d)}},dp.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:Dh.min(e)._leftDepth},dp.prototype.interfaces_=function(){return[]},dp.prototype.getClass=function(){return dp},mp.DepthSegment.get=function(){return gp},Object.defineProperties(dp,mp);var gp=function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new Zh(t),this._leftDepth=e};gp.prototype.compareTo=function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)},gp.prototype.compareX=function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)},gp.prototype.toString=function(){return this._upwardSeg.toString()},gp.prototype.interfaces_=function(){return[Ol]},gp.prototype.getClass=function(){return gp};var yp=function(t,e,n){this.p0=t||null,this.p1=e||null,this.p2=n||null};yp.prototype.area=function(){return yp.area(this.p0,this.p1,this.p2)},yp.prototype.signedArea=function(){return yp.signedArea(this.p0,this.p1,this.p2)},yp.prototype.interpolateZ=function(t){if(null===t)throw new Rl("Supplied point is null.");return yp.interpolateZ(t,this.p0,this.p1,this.p2)},yp.prototype.longestSideLength=function(){return yp.longestSideLength(this.p0,this.p1,this.p2)},yp.prototype.isAcute=function(){return yp.isAcute(this.p0,this.p1,this.p2)},yp.prototype.circumcentre=function(){return yp.circumcentre(this.p0,this.p1,this.p2)},yp.prototype.area3D=function(){return yp.area3D(this.p0,this.p1,this.p2)},yp.prototype.centroid=function(){return yp.centroid(this.p0,this.p1,this.p2)},yp.prototype.inCentre=function(){return yp.inCentre(this.p0,this.p1,this.p2)},yp.prototype.interfaces_=function(){return[]},yp.prototype.getClass=function(){return yp},yp.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)},yp.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},yp.det=function(t,e,n,r){return t*r-e*n},yp.interpolateZ=function(t,e,n,r){var i=e.x,o=e.y,a=n.x-i,s=r.x-i,l=n.y-o,u=r.y-o,c=a*u-s*l,h=t.x-i,p=t.y-o,f=(u*h-s*p)/c,d=(-l*h+a*p)/c;return e.z+f*(n.z-e.z)+d*(r.z-e.z)},yp.longestSideLength=function(t,e,n){var r=t.distance(e),i=e.distance(n),o=n.distance(t),a=r;return i>a&&(a=i),o>a&&(a=o),a},yp.isAcute=function(t,e,n){return!!up.isAcute(t,e,n)&&!!up.isAcute(e,n,t)&&!!up.isAcute(n,t,e)},yp.circumcentre=function(t,e,n){var r=n.x,i=n.y,o=t.x-r,a=t.y-i,s=e.x-r,l=e.y-i,u=2*yp.det(o,a,s,l),c=yp.det(a,o*o+a*a,l,s*s+l*l),h=yp.det(o,o*o+a*a,s,s*s+l*l);return new Bl(r-c/u,i+h/u)},yp.perpendicularBisector=function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new au(t.x+n/2,t.y+r/2,1),o=new au(t.x-r+n/2,t.y+n+r/2,1);return new au(i,o)},yp.angleBisector=function(t,e,n){var r=e.distance(t),i=r/(r+e.distance(n)),o=n.x-t.x,a=n.y-t.y;return new Bl(t.x+i*o,t.y+i*a)},yp.area3D=function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=e.z-t.z,a=n.x-t.x,s=n.y-t.y,l=n.z-t.z,u=i*l-o*s,c=o*a-r*l,h=r*s-i*a,p=u*u+c*c+h*h;return Math.sqrt(p)/2},yp.centroid=function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new Bl(r,i)},yp.inCentre=function(t,e,n){var r=e.distance(n),i=t.distance(n),o=t.distance(e),a=r+i+o,s=(r*t.x+i*e.x+o*n.x)/a,l=(r*t.y+i*e.y+o*n.y)/a;return new Bl(s,l)};var vp=function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new Uu;var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n};vp.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,jl.EXTERIOR,jl.INTERIOR)},vp.prototype.addPolygon=function(t){var e=this,n=this._distance,r=rh.LEFT;this._distance<0&&(n=-this._distance,r=rh.RIGHT);var i=t.getExteriorRing(),o=ju.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&o.length<3)return null;this.addPolygonRing(o,n,r,jl.EXTERIOR,jl.INTERIOR);for(var a=0;a0&&e.isErodedCompletely(s,-e._distance)||e.addPolygonRing(l,n,rh.opposite(r),jl.INTERIOR,jl.EXTERIOR)}},vp.prototype.isTriangleErodedCompletely=function(t,e){var n=new yp(t[0],t[1],t[2]),r=n.inCentre();return wu.distancePointLine(r,n.p0,n.p1)=Dc.MINIMUM_VALID_SIZE&&wu.isCCW(t)&&(o=i,a=r,n=rh.opposite(n));var s=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(s,o,a)},vp.prototype.add=function(t){if(t.isEmpty())return null;t instanceof Pc?this.addPolygon(t):t instanceof Cc?this.addLineString(t):t instanceof Ac?this.addPoint(t):(t instanceof Rc||t instanceof mc||t instanceof Nc||t instanceof dc)&&this.addCollection(t)},vp.prototype.isErodedCompletely=function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var r=t.getEnvelopeInternal(),i=Math.min(r.getHeight(),r.getWidth());return e<0&&2*Math.abs(e)>i},vp.prototype.addCollection=function(t){for(var e=0;e=this._max)throw new Bu;var t=this._parent.getGeometryN(this._index++);return t instanceof dc?(this._subcollectionIterator=new xp(t),this._subcollectionIterator.next()):t},xp.prototype.remove=function(){throw new Error(this.getClass().getName())},xp.prototype.hasNext=function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)},xp.prototype.interfaces_=function(){return[zu]},xp.prototype.getClass=function(){return xp},xp.isAtomic=function(t){return!(t instanceof dc)};var bp=function(){this._geom=null;var t=arguments[0];this._geom=t};bp.prototype.locate=function(t){return bp.locate(t,this._geom)},bp.prototype.interfaces_=function(){return[_p]},bp.prototype.getClass=function(){return bp},bp.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&wu.isPointInRing(t,e.getCoordinates())},bp.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!bp.isPointInRing(t,n))return!1;for(var r=0;r=0;n--){var r=this._edgeList.get(n),i=r.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=r}e.setNext(t)},e.prototype.computeDepths=function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(rh.LEFT),r=t.getDepth(rh.RIGHT),i=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,i)!==r)throw new lh("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],a=arguments[2],s=arguments[0];s=0;o--){var a=e._resultAreaEdgeList.get(o),s=a.getSym();switch(null===n&&a.getEdgeRing()===t&&(n=a),i){case e._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;r=s,i=e._LINKING_TO_OUTGOING;break;case e._LINKING_TO_OUTGOING:if(a.getEdgeRing()!==t)continue;r.setNextMin(a),i=e._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(gu.isTrue(null!==n,"found null for first outgoing dirEdge"),gu.isTrue(n.getEdgeRing()===t,"unable to link last incoming dirEdge"),r.setNextMin(n))},e.prototype.getOutgoingDegree=function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){e.next().isInResult()&&t++}return t}if(1===arguments.length){for(var n=arguments[0],r=0,i=this.iterator();i.hasNext();){i.next().getEdgeRing()===n&&r++}return r}},e.prototype.getLabel=function(){return this._label},e.prototype.findCoveredLineEdges=function(){for(var t=jl.NONE,e=this.iterator();e.hasNext();){var n=e.next(),r=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=jl.INTERIOR;break}if(r.isInResult()){t=jl.EXTERIOR;break}}}if(t===jl.NONE)return null;for(var i=t,o=this.iterator();o.hasNext();){var a=o.next(),s=a.getSym();a.isLineEdge()?a.getEdge().setCovered(i===jl.INTERIOR):(a.isInResult()&&(i=jl.EXTERIOR),s.isInResult()&&(i=jl.INTERIOR))}},e.prototype.computeLabelling=function(e){t.prototype.computeLabelling.call(this,e),this._label=new ph(jl.NONE);for(var n=this.iterator();n.hasNext();)for(var r=n.next().getEdge().getLabel(),i=0;i<2;i++){var o=r.getLocation(i);o!==jl.INTERIOR&&o!==jl.BOUNDARY||this._label.setLocation(i,jl.INTERIOR)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(wp),Sp=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createNode=function(t){return new yh(t,new Ep)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Eh),Mp=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)};Mp.prototype.compareTo=function(t){var e=t;return Mp.compareOriented(this._pts,this._orientation,e._pts,e._orientation)},Mp.prototype.interfaces_=function(){return[Ol]},Mp.prototype.getClass=function(){return Mp},Mp.orientation=function(t){return 1===ju.increasingDirection(t)},Mp.compareOriented=function(t,e,n,r){for(var i=e?1:-1,o=r?1:-1,a=e?t.length:-1,s=r?n.length:-1,l=e?0:t.length-1,u=r?0:n.length-1;;){var c=t[l].compareTo(n[u]);if(0!==c)return c;var h=(l+=i)===a,p=(u+=o)===s;if(h&&!p)return-1;if(!h&&p)return 1;if(h&&p)return 0}};var Tp=function(){this._edges=new Uu,this._ocaMap=new ic};Tp.prototype.print=function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var r=n.getCoordinates(),i=0;i0&&t.print(","),t.print(r[i].x+" "+r[i].y);t.println(")")}t.print(") ")},Tp.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},Tp.prototype.findEdgeIndex=function(t){for(var e=0;e0||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),a=0;o[a++]=new Bl(t.coord);for(var s=t.segmentIndex+1;s<=e.segmentIndex;s++)o[a++]=this.edge.pts[s];return i&&(o[a]=e.coord),new Op(o,new ph(this.edge._label))},Lp.prototype.add=function(t,e,n){var r=new Ap(t,e,n),i=this._nodeMap.get(r);return null!==i?i:(this._nodeMap.put(r,r),r)},Lp.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1},Lp.prototype.interfaces_=function(){return[]},Lp.prototype.getClass=function(){return Lp};var Pp=function(){};Pp.prototype.getChainStartIndices=function(t){var e=0,n=new Uu;n.add(new Yl(e));do{var r=this.findChainEnd(t,e);n.add(new Yl(r)),e=r}while(en?e:n},Rp.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return en&&(i=1),t._depth[e][r]=i}}},Dp.prototype.getDelta=function(t){return this._depth[t][rh.RIGHT]-this._depth[t][rh.LEFT]},Dp.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?jl.EXTERIOR:jl.INTERIOR},Dp.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]},Dp.prototype.add=function(){var t=this;if(1===arguments.length)for(var e=arguments[0],n=0;n<2;n++)for(var r=1;r<3;r++){var i=e.getLocation(n,r);i!==jl.EXTERIOR&&i!==jl.INTERIOR||(t.isNull(n,r)?t._depth[n][r]=Dp.depthAtLocation(i):t._depth[n][r]+=Dp.depthAtLocation(i))}else if(3===arguments.length){var o=arguments[0],a=arguments[1];arguments[2]===jl.INTERIOR&&this._depth[o][a]++}},Dp.prototype.interfaces_=function(){return[]},Dp.prototype.getClass=function(){return Dp},Dp.depthAtLocation=function(t){return t===jl.EXTERIOR?0:t===jl.INTERIOR?1:Dp.NULL_VALUE},Np.NULL_VALUE.get=function(){return-1},Object.defineProperties(Dp,Np);var Op=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new Lp(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new Dp,this._depthDelta=0,1===arguments.length){var n=arguments[0];e.call(this,n,null)}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.pts=r,this._label=i}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getDepth=function(){return this._depth},e.prototype.getCollapsedEdge=function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new e(t,ph.toLineLabel(this._label))},e.prototype.isIsolated=function(){return this._isIsolated},e.prototype.getCoordinates=function(){return this.pts},e.prototype.setIsolated=function(t){this._isIsolated=t},e.prototype.setName=function(t){this._name=t},e.prototype.equals=function(t){if(!(t instanceof e))return!1;var n=t;if(this.pts.length!==n.pts.length)return!1;for(var r=!0,i=!0,o=this.pts.length,a=0;a0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}},e.prototype.print=function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)},e.prototype.computeIM=function(t){e.updateIM(this._label,t)},e.prototype.isCollapsed=function(){return!!this._label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])},e.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])},e.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1},e.prototype.getDepthDelta=function(){return this._depthDelta},e.prototype.getNumPoints=function(){return this.pts.length},e.prototype.printReverse=function(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")},e.prototype.getMonotoneChainEdge=function(){return null===this._mce&&(this._mce=new Rp(this)),this._mce},e.prototype.getEnvelope=function(){if(null===this._env){this._env=new su;for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()},e.prototype.isPointwiseEqual=function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;er||this._maxyo;if(a)return!1;var s=this.intersectsToleranceSquare(t,e);return gu.isTrue(!(a&&s),"Found bad envelope test"),s},Up.prototype.initCorners=function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new Bl(this._maxx,this._maxy),this._corner[1]=new Bl(this._minx,this._maxy),this._corner[2]=new Bl(this._minx,this._miny),this._corner[3]=new Bl(this._maxx,this._miny)},Up.prototype.intersects=function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))},Up.prototype.scale=function(t){return Math.round(t*this._scaleFactor)},Up.prototype.getCoordinate=function(){return this._originalPt},Up.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},Up.prototype.getSafeEnvelope=function(){if(null===this._safeEnv){var t=Up.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new su(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv},Up.prototype.intersectsPixelClosure=function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.hasIntersection()))))},Up.prototype.intersectsToleranceSquare=function(t,e){var n=!1,r=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(r=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&r||t.equals(this._pt)||e.equals(this._pt)))))},Up.prototype.addSnappedNode=function(t,e){var n=t.getCoordinate(e),r=t.getCoordinate(e+1);return!!this.intersects(n,r)&&(t.addIntersection(this.getCoordinate(),e),!0)},Up.prototype.interfaces_=function(){return[]},Up.prototype.getClass=function(){return Up},Vp.SAFE_ENV_EXPANSION_FACTOR.get=function(){return.75},Object.defineProperties(Up,Vp);var Gp=function(){this.tempEnv1=new su,this.selectedSegment=new Zh};Gp.prototype.select=function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}},Gp.prototype.interfaces_=function(){return[]},Gp.prototype.getClass=function(){return Gp};var jp=function(){this._index=null;var t=arguments[0];this._index=t},Hp={HotPixelSnapAction:{configurable:!0}};jp.prototype.snap=function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2],i=e.getSafeEnvelope(),o=new qp(e,n,r);return this._index.query(i,{interfaces_:function(){return[Ah]},visitItem:function(t){t.select(i,o)}}),o.isNodeAdded()}},jp.prototype.interfaces_=function(){return[]},jp.prototype.getClass=function(){return jp},Hp.HotPixelSnapAction.get=function(){return qp},Object.defineProperties(jp,Hp);var qp=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._hotPixel=e,this._parentEdge=n,this._hotPixelVertexIndex=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isNodeAdded=function(){return this._isNodeAdded},e.prototype.select=function(){if(2!==arguments.length)return t.prototype.select.apply(this,arguments);var e=arguments[1],n=arguments[0].getContext();if(null!==this._parentEdge&&n===this._parentEdge&&e===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(n,e)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Gp),Wp=function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new Uu};Wp.prototype.processIntersections=function(t,e,n,r){if(t===n&&e===r)return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];if(this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var l=0;l=0;e--){try{t.bufferReducedPrecision(e)}catch(e){if(!(e instanceof lh))throw e;t._saveException=e}if(null!==t._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],r=Zp.precisionScaleFactor(this._argGeom,this._distance,n),i=new qc(r);this.bufferFixedPrecision(i)}},Zp.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===qc.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},Zp.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t)},Zp.prototype.bufferOriginalPrecision=function(){try{var t=new kp(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof du))throw t;this._saveException=t}},Zp.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry},Zp.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t)},Zp.prototype.interfaces_=function(){return[]},Zp.prototype.getClass=function(){return Zp},Zp.bufferOp=function(){if(2===arguments.length){var t=arguments[1];return new Zp(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Mu&&"number"==typeof arguments[1]){var e=arguments[1],n=arguments[2],r=new Zp(arguments[0]);r.setQuadrantSegments(n);return r.getResultGeometry(e)}if(arguments[2]instanceof rp&&arguments[0]instanceof Mu&&"number"==typeof arguments[1]){var i=arguments[1];return new Zp(arguments[0],arguments[2]).getResultGeometry(i)}}else if(4===arguments.length){var o=arguments[1],a=arguments[2],s=arguments[3],l=new Zp(arguments[0]);l.setQuadrantSegments(a),l.setEndCapStyle(s);return l.getResultGeometry(o)}},Zp.precisionScaleFactor=function(t,e,n){var r=t.getEnvelopeInternal(),i=Wl.max(Math.abs(r.getMaxX()),Math.abs(r.getMaxY()),Math.abs(r.getMinX()),Math.abs(r.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,o)},Yp.CAP_ROUND.get=function(){return rp.CAP_ROUND},Yp.CAP_BUTT.get=function(){return rp.CAP_FLAT},Yp.CAP_FLAT.get=function(){return rp.CAP_FLAT},Yp.CAP_SQUARE.get=function(){return rp.CAP_SQUARE},Yp.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(Zp,Yp);var Jp=function(){this._pt=[new Bl,new Bl],this._distance=Dl.NaN,this._isNull=!0};Jp.prototype.getCoordinates=function(){return this._pt},Jp.prototype.getCoordinate=function(t){return this._pt[t]},Jp.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);rthis._distance&&this.initialize(e,n,r)}},Jp.prototype.interfaces_=function(){return[]},Jp.prototype.getClass=function(){return Jp};var Kp=function(){};Kp.prototype.interfaces_=function(){return[]},Kp.prototype.getClass=function(){return Kp},Kp.computeDistance=function(){if(arguments[2]instanceof Jp&&arguments[0]instanceof Cc&&arguments[1]instanceof Bl)for(var t=arguments[1],e=arguments[2],n=arguments[0].getCoordinates(),r=new Zh,i=0;i0||this._isIn?jl.INTERIOR:jl.EXTERIOR)},of.prototype.interfaces_=function(){return[]},of.prototype.getClass=function(){return of};var af=function t(){if(this._component=null,this._segIndex=null,this._pt=null,2===arguments.length){t.call(this,arguments[0],t.INSIDE_AREA,arguments[1])}else if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2];this._component=e,this._segIndex=n,this._pt=r}},sf={INSIDE_AREA:{configurable:!0}};af.prototype.isInsideArea=function(){return this._segIndex===af.INSIDE_AREA},af.prototype.getCoordinate=function(){return this._pt},af.prototype.getGeometryComponent=function(){return this._component},af.prototype.getSegmentIndex=function(){return this._segIndex},af.prototype.interfaces_=function(){return[]},af.prototype.getClass=function(){return af},sf.INSIDE_AREA.get=function(){return-1},Object.defineProperties(af,sf);var lf=function(t){this._pts=t||null};lf.prototype.filter=function(t){t instanceof Ac&&this._pts.add(t)},lf.prototype.interfaces_=function(){return[pc]},lf.prototype.getClass=function(){return lf},lf.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof Ac?Dh.singletonList(t):lf.getPoints(t,new Uu)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Ac?n.add(e):e instanceof dc&&e.apply(new lf(n)),n}};var uf=function(){this._locations=null;var t=arguments[0];this._locations=t};uf.prototype.filter=function(t){(t instanceof Ac||t instanceof Cc||t instanceof Pc)&&this._locations.add(new af(t,0,t.getCoordinate()))},uf.prototype.interfaces_=function(){return[pc]},uf.prototype.getClass=function(){return uf},uf.getLocations=function(t){var e=new Uu;return t.apply(new uf(e)),e};var cf=function(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new of,this._minDistanceLocation=null,this._minDistance=Dl.MAX_VALUE,2===arguments.length){var t=arguments[0],e=arguments[1];this._geom=[t,e],this._terminateDistance=0}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=n,this._geom[1]=r,this._terminateDistance=i}};cf.prototype.computeContainmentDistance=function(){var t=this;if(0===arguments.length){var e=new Array(2).fill(null);if(this.computeContainmentDistance(0,e),this._minDistance<=this._terminateDistance)return null;this.computeContainmentDistance(1,e)}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=1-n,o=nf.getPolygons(this._geom[n]);if(o.size()>0){var a=uf.getLocations(this._geom[i]);if(this.computeContainmentDistance(a,o,r),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[i]=r[0],this._minDistanceLocation[n]=r[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&ql(arguments[0],Fu)&&ql(arguments[1],Fu)){for(var s=arguments[0],l=arguments[1],u=arguments[2],c=0;cthis._minDistance)return null;for(var i=e.getCoordinates(),o=n.getCoordinate(),a=0;athis._minDistance)return null;for(var p=u.getCoordinates(),f=c.getCoordinates(),d=0;dthis._distance&&this.initialize(e,n,r)}},hf.prototype.interfaces_=function(){return[]},hf.prototype.getClass=function(){return hf};var pf=function(){};pf.prototype.interfaces_=function(){return[]},pf.prototype.getClass=function(){return pf},pf.computeDistance=function(){if(arguments[2]instanceof hf&&arguments[0]instanceof Cc&&arguments[1]instanceof Bl)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=new Zh,i=t.getCoordinates(),o=0;o1||t<=0)throw new Rl("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},ff.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},ff.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},ff.prototype.computeOrientedDistance=function(t,e,n){var r=new mf(e);if(t.apply(r),n.setMaximum(r.getMaxPointDistance()),this._densifyFrac>0){var i=new gf(e,this._densifyFrac);t.apply(i),n.setMaximum(i.getMaxPointDistance())}},ff.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},ff.prototype.interfaces_=function(){return[]},ff.prototype.getClass=function(){return ff},ff.distance=function(){if(2===arguments.length){return new ff(arguments[0],arguments[1]).distance()}if(3===arguments.length){var t=arguments[2],e=new ff(arguments[0],arguments[1]);return e.setDensifyFraction(t),e.distance()}},df.MaxPointDistanceFilter.get=function(){return mf},df.MaxDensifiedByFractionDistanceFilter.get=function(){return gf},Object.defineProperties(ff,df);var mf=function(){this._maxPtDist=new hf,this._minPtDist=new hf,this._euclideanDist=new pf,this._geom=null;var t=arguments[0];this._geom=t};mf.prototype.filter=function(t){this._minPtDist.initialize(),pf.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},mf.prototype.getMaxPointDistance=function(){return this._maxPtDist},mf.prototype.interfaces_=function(){return[Iu]},mf.prototype.getClass=function(){return mf};var gf=function(){this._maxPtDist=new hf,this._minPtDist=new hf,this._geom=null,this._numSubSegs=0;var t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e))};gf.prototype.filter=function(t,e){var n=this;if(0===e)return null;for(var r=t.getCoordinate(e-1),i=t.getCoordinate(e),o=(i.x-r.x)/this._numSubSegs,a=(i.y-r.y)/this._numSubSegs,s=0;sn){this._isValid=!1;var i=r.getCoordinates();this._errorLocation=i[1],this._errorIndicator=t.getFactory().createLineString(i),this._errMsg="Distance between buffer curve and input is too large ("+this._maxDistanceFound+" at "+fu.toLineString(i[0],i[1])+")"}},yf.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=yf.MAX_DISTANCE_DIFF_FRAC*t;return this._minValidDistance=t-e,this._maxValidDistance=t+e,!(!this._input.isEmpty()&&!this._result.isEmpty())||(this._bufDistance>0?this.checkPositiveValid():this.checkNegativeValid(),yf.VERBOSE&&ou.out.println("Min Dist= "+this._minDistanceFound+" err= "+(1-this._minDistanceFound/this._bufDistance)+" Max Dist= "+this._maxDistanceFound+" err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid)},yf.prototype.checkNegativeValid=function(){if(!(this._input instanceof Pc||this._input instanceof Nc||this._input instanceof dc))return null;var t=this.getPolygonLines(this._input);if(this.checkMinimumDistance(t,this._result,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(t,this._result,this._maxValidDistance)},yf.prototype.getErrorIndicator=function(){return this._errorIndicator},yf.prototype.checkMinimumDistance=function(t,e,n){var r=new cf(t,e,n);if(this._minDistanceFound=r.distance(),this._minDistanceFound0&&t>e&&(this._isValid=!1,this._errorMsg="Area of positive buffer is smaller than input",this._errorIndicator=this._result),this._distance<0&&t=2||this._distance>0?null:(this._result.isEmpty()||(this._isValid=!1,this._errorMsg="Result is non-empty",this._errorIndicator=this._result),void this.report("ExpectedEmpty"))},_f.prototype.report=function(t){if(!_f.VERBOSE)return null;ou.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},_f.prototype.getErrorMessage=function(){return this._errorMsg},_f.prototype.interfaces_=function(){return[]},_f.prototype.getClass=function(){return _f},_f.isValidMsg=function(t,e,n){var r=new _f(t,e,n);return r.isValid()?null:r.getErrorMessage()},_f.isValid=function(t,e,n){return!!new _f(t,e,n).isValid()},xf.VERBOSE.get=function(){return!1},xf.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(_f,xf);var bf=function(){this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};bf.prototype.getCoordinates=function(){return this._pts},bf.prototype.size=function(){return this._pts.length},bf.prototype.getCoordinate=function(t){return this._pts[t]},bf.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},bf.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:Hh.octant(this.getCoordinate(t),this.getCoordinate(t+1))},bf.prototype.setData=function(t){this._data=t},bf.prototype.getData=function(){return this._data},bf.prototype.toString=function(){return fu.toLineString(new Uc(this._pts))},bf.prototype.interfaces_=function(){return[qh]},bf.prototype.getClass=function(){return bf};var wf=function(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new Uu,this._intersectionCount=0,this._keepIntersections=!0;var t=arguments[0];this._li=t,this._interiorIntersection=null};wf.prototype.getInteriorIntersection=function(){return this._interiorIntersection},wf.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t},wf.prototype.getIntersectionSegments=function(){return this._intSegments},wf.prototype.count=function(){return this._intersectionCount},wf.prototype.getIntersections=function(){return this._intersections},wf.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},wf.prototype.setKeepIntersections=function(t){this._keepIntersections=t},wf.prototype.processIntersections=function(t,e,n,r){if(!this._findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===r)return null;if(this._isCheckEndSegmentsOnly&&!this.isEndSegment(t,e)&&!this.isEndSegment(n,r))return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&this._li.isInteriorIntersection()&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=i,this._intSegments[1]=o,this._intSegments[2]=a,this._intSegments[3]=s,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)},wf.prototype.isEndSegment=function(t,e){return 0===e||e>=t.size()-2},wf.prototype.hasIntersection=function(){return null!==this._interiorIntersection},wf.prototype.isDone=function(){return!this._findAllIntersections&&null!==this._interiorIntersection},wf.prototype.interfaces_=function(){return[Cp]},wf.prototype.getClass=function(){return wf},wf.createAllIntersectionsFinder=function(t){var e=new wf(t);return e.setFindAllIntersections(!0),e},wf.createAnyIntersectionFinder=function(t){return new wf(t)},wf.createIntersectionCounter=function(t){var e=new wf(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e};var Ef=function(){this._li=new _u,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;var t=arguments[0];this._segStrings=t};Ef.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections()},Ef.prototype.getIntersections=function(){return this._segInt.getIntersections()},Ef.prototype.isValid=function(){return this.execute(),this._isValid},Ef.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Ef.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new wf(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new ep;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null},Ef.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new lh(this.getErrorMessage(),this._segInt.getInteriorIntersection())},Ef.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+fu.toLineString(t[0],t[1])+" and "+fu.toLineString(t[2],t[3])},Ef.prototype.interfaces_=function(){return[]},Ef.prototype.getClass=function(){return Ef},Ef.computeIntersections=function(t){var e=new Ef(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Sf=function t(){this._nv=null;var e=arguments[0];this._nv=new Ef(t.toSegmentStrings(e))};Sf.prototype.checkValid=function(){this._nv.checkValid()},Sf.prototype.interfaces_=function(){return[]},Sf.prototype.getClass=function(){return Sf},Sf.toSegmentStrings=function(t){for(var e=new Uu,n=t.iterator();n.hasNext();){var r=n.next();e.add(new bf(r.getCoordinates(),r))}return e},Sf.checkValid=function(t){new Sf(t).checkValid()};var Mf=function(t){this._mapOp=t};Mf.prototype.map=function(t){for(var e=new Uu,n=0;n0&&r<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)},If.prototype.interfaces_=function(){return[]},If.prototype.getClass=function(){return If};var Af=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new Zh,this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof Cc&&"number"==typeof arguments[1]){var e=arguments[1];t.call(this,arguments[0].getCoordinates(),e)}else if(arguments[0]instanceof Array&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1];this._srcPts=n,this._isClosed=t.isClosed(n),this._snapTolerance=r}};Af.prototype.snapVertices=function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),r=0;r=0&&t.add(o+1,new Bl(i),!1)}},Af.prototype.findSegmentIndexToSnap=function(t,e){for(var n=this,r=Dl.MAX_VALUE,i=-1,o=0;oe&&(e=r)}return e}if(2===arguments.length){var i=arguments[0],o=arguments[1];return Math.min(Lf.computeOverlaySnapTolerance(i),Lf.computeOverlaySnapTolerance(o))}},Lf.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*Lf.SNAP_PRECISION_FACTOR},Lf.snapToSelf=function(t,e,n){return new Lf(t).snapToSelf(e,n)},Pf.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(Lf,Pf);var Rf=function(t){function e(e,n,r){t.call(this),this._snapTolerance=e||null,this._snapPts=n||null,this._isSelfSnap=void 0!==r&&r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(t,e){var n=new Af(t,this._snapTolerance);return n.setAllowSnappingToSourceVertices(this._isSelfSnap),n.snapTo(e)},e.prototype.transformCoordinates=function(t,e){var n=t.toCoordinateArray(),r=this.snapLine(n,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(If),Df=function(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null};Df.prototype.getCommon=function(){return Dl.longBitsToDouble(this._commonBits)},Df.prototype.add=function(t){var e=Dl.doubleToLongBits(t);return this._isFirst?(this._commonBits=e,this._commonSignExp=Df.signExpBits(this._commonBits),this._isFirst=!1,null):Df.signExpBits(e)!==this._commonSignExp?(this._commonBits=0,null):(this._commonMantissaBitsCount=Df.numCommonMostSigMantissaBits(this._commonBits,e),void(this._commonBits=Df.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))))},Df.prototype.toString=function(){if(1===arguments.length){var t=arguments[0],e=Dl.longBitsToDouble(t),n="0000000000000000000000000000000000000000000000000000000000000000"+Dl.toBinaryString(t),r=n.substring(n.length-64);return r.substring(0,1)+" "+r.substring(1,12)+"(exp) "+r.substring(12)+" [ "+e+" ]"}},Df.prototype.interfaces_=function(){return[]},Df.prototype.getClass=function(){return Df},Df.getBit=function(t,e){return 0!=(t&1<>52},Df.zeroLowerBits=function(t,e){return t&~((1<=0;r--){if(Df.getBit(t,r)!==Df.getBit(e,r))return n;n++}return 52};var Nf=function(){this._commonCoord=null,this._ccFilter=new kf},Of={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};Nf.prototype.addCommonBits=function(t){var e=new zf(this._commonCoord);t.apply(e),t.geometryChanged()},Nf.prototype.removeCommonBits=function(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;var e=new Bl(this._commonCoord);e.x=-e.x,e.y=-e.y;var n=new zf(e);return t.apply(n),t.geometryChanged(),t},Nf.prototype.getCommonCoordinate=function(){return this._commonCoord},Nf.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()},Nf.prototype.interfaces_=function(){return[]},Nf.prototype.getClass=function(){return Nf},Of.CommonCoordinateFilter.get=function(){return kf},Of.Translater.get=function(){return zf},Object.defineProperties(Nf,Of);var kf=function(){this._commonBitsX=new Df,this._commonBitsY=new Df};kf.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)},kf.prototype.getCommonCoordinate=function(){return new Bl(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())},kf.prototype.interfaces_=function(){return[Iu]},kf.prototype.getClass=function(){return kf};var zf=function(){this.trans=null;var t=arguments[0];this.trans=t};zf.prototype.filter=function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,r=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,r)},zf.prototype.isDone=function(){return!1},zf.prototype.isGeometryChanged=function(){return!0},zf.prototype.interfaces_=function(){return[fc]},zf.prototype.getClass=function(){return zf};var Ff=function(t,e){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null,this._geom[0]=t,this._geom[1]=e,this.computeSnapTolerance()};Ff.prototype.selfSnap=function(t){return new Lf(t).snapTo(t,this._snapTolerance)},Ff.prototype.removeCommonBits=function(t){this._cbr=new Nf,this._cbr.add(t[0]),this._cbr.add(t[1]);var e=new Array(2).fill(null);return e[0]=this._cbr.removeCommonBits(t[0].copy()),e[1]=this._cbr.removeCommonBits(t[1].copy()),e},Ff.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t},Ff.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),n=ad.overlayOp(e[0],e[1],t);return this.prepareResult(n)},Ff.prototype.checkValid=function(t){t.isValid()||ou.out.println("Snapped geometry is invalid")},Ff.prototype.computeSnapTolerance=function(){this._snapTolerance=Lf.computeOverlaySnapTolerance(this._geom[0],this._geom[1])},Ff.prototype.snap=function(t){var e=this.removeCommonBits(t);return Lf.snap(e[0],e[1],this._snapTolerance)},Ff.prototype.interfaces_=function(){return[]},Ff.prototype.getClass=function(){return Ff},Ff.overlayOp=function(t,e,n){return new Ff(t,e).getResultGeometry(n)},Ff.union=function(t,e){return Ff.overlayOp(t,e,ad.UNION)},Ff.intersection=function(t,e){return Ff.overlayOp(t,e,ad.INTERSECTION)},Ff.symDifference=function(t,e){return Ff.overlayOp(t,e,ad.SYMDIFFERENCE)},Ff.difference=function(t,e){return Ff.overlayOp(t,e,ad.DIFFERENCE)};var Bf=function(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e};Bf.prototype.getResultGeometry=function(t){var e=null,n=!1,r=null;try{e=ad.overlayOp(this._geom[0],this._geom[1],t);n=!0}catch(t){if(!(t instanceof du))throw t;r=t}if(!n)try{e=Ff.overlayOp(this._geom[0],this._geom[1],t)}catch(t){throw t instanceof du?r:t}return e},Bf.prototype.interfaces_=function(){return[]},Bf.prototype.getClass=function(){return Bf},Bf.overlayOp=function(t,e,n){return new Bf(t,e).getResultGeometry(n)},Bf.union=function(t,e){return Bf.overlayOp(t,e,ad.UNION)},Bf.intersection=function(t,e){return Bf.overlayOp(t,e,ad.INTERSECTION)},Bf.symDifference=function(t,e){return Bf.overlayOp(t,e,ad.SYMDIFFERENCE)},Bf.difference=function(t,e){return Bf.overlayOp(t,e,ad.DIFFERENCE)};var Uf=function(){this.mce=null,this.chainIndex=null;var t=arguments[0],e=arguments[1];this.mce=t,this.chainIndex=e};Uf.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},Uf.prototype.interfaces_=function(){return[]},Uf.prototype.getClass=function(){return Uf};var Vf=function t(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,2===arguments.length){var e=arguments[0],n=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=n}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=r,this._xValue=i,this._obj=o}},Gf={INSERT:{configurable:!0},DELETE:{configurable:!0}};Vf.prototype.isDelete=function(){return this._eventType===Vf.DELETE},Vf.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t},Vf.prototype.getObject=function(){return this._obj},Vf.prototype.compareTo=function(t){var e=t;return this._xValuee._xValue?1:this._eventTypee._eventType?1:0},Vf.prototype.getInsertEvent=function(){return this._insertEvent},Vf.prototype.isInsert=function(){return this._eventType===Vf.INSERT},Vf.prototype.isSameLabel=function(t){return null!==this._label&&this._label===t._label},Vf.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex},Vf.prototype.interfaces_=function(){return[Ol]},Vf.prototype.getClass=function(){return Vf},Gf.INSERT.get=function(){return 1},Gf.DELETE.get=function(){return 2},Object.defineProperties(Vf,Gf);var jf=function(){};jf.prototype.interfaces_=function(){return[]},jf.prototype.getClass=function(){return jf};var Hf=function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._properIntersectionPoint=null,this._li=null,this._includeProper=null,this._recordIsolated=null,this._isSelfIntersection=null,this._numIntersections=0,this.numTests=0,this._bdyNodes=null,this._isDone=!1,this._isDoneWhenProperInt=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._li=t,this._includeProper=e,this._recordIsolated=n};Hf.prototype.isTrivialIntersection=function(t,e,n,r){if(t===n&&1===this._li.getIntersectionNum()){if(Hf.isAdjacentSegments(e,r))return!0;if(t.isClosed()){var i=t.getNumPoints()-1;if(0===e&&r===i||0===r&&e===i)return!0}}return!1},Hf.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},Hf.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t},Hf.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},Hf.prototype.isBoundaryPointInternal=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next().getCoordinate();if(t.isIntersection(r))return!0}return!1},Hf.prototype.hasProperIntersection=function(){return this._hasProper},Hf.prototype.hasIntersection=function(){return this._hasIntersection},Hf.prototype.isDone=function(){return this._isDone},Hf.prototype.isBoundaryPoint=function(t,e){return!(null===e||!this.isBoundaryPointInternal(t,e[0])&&!this.isBoundaryPointInternal(t,e[1]))},Hf.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e},Hf.prototype.addIntersections=function(t,e,n,r){if(t===n&&e===r)return null;this.numTests++;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,n,r)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),n.addIntersections(this._li,r,1)),this._li.isProper()&&(this._properIntersectionPoint=this._li.getIntersection(0).copy(),this._hasProper=!0,this._isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this._li,this._bdyNodes)||(this._hasProperInterior=!0))))},Hf.prototype.interfaces_=function(){return[]},Hf.prototype.getClass=function(){return Hf},Hf.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var qf=function(t){function e(){t.call(this),this.events=new Uu,this.nOverlaps=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){Dh.sort(this.events);for(var t=0;te||this._maxo?1:0},Zf.prototype.interfaces_=function(){return[zl]},Zf.prototype.getClass=function(){return Zf};var Yf=function(t){function e(){t.call(this),this._item=null;var e=arguments[0],n=arguments[1],r=arguments[2];this._min=e,this._max=n,this._item=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;n.visitItem(this._item)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Wf),Jf=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var e=arguments[0],n=arguments[1];this._node1=e,this._node2=n,this.buildExtent(this._node1,this._node2)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildExtent=function(t,e){this._min=Math.min(t._min,e._min),this._max=Math.max(t._max,e._max)},e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,n),null!==this._node2&&this._node2.query(t,e,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Wf),Kf=function(){this._leaves=new Uu,this._root=null,this._level=0};Kf.prototype.buildTree=function(){Dh.sort(this._leaves,new Wf.NodeComparator);for(var t=this._leaves,e=null,n=new Uu;;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e}},Kf.prototype.insert=function(t,e,n){if(null!==this._root)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new Yf(t,e,n))},Kf.prototype.query=function(t,e,n){this.init(),this._root.query(t,e,n)},Kf.prototype.buildRoot=function(){if(null!==this._root)return null;this._root=this.buildTree()},Kf.prototype.printNode=function(t){ou.out.println(fu.toLineString(new Bl(t._min,this._level),new Bl(t._max,this._level)))},Kf.prototype.init=function(){if(null!==this._root)return null;this.buildRoot()},Kf.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var n=0;n=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,e[0]),this.insertBoundaryPoint(this._argIndex,e[e.length-1])},e.prototype.getInvalidPoint=function(){return this._invalidPoint},e.prototype.getBoundaryPoints=function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,r=t.iterator();r.hasNext();){var i=r.next();e[n++]=i.getCoordinate().copy()}return e},e.prototype.getBoundaryNodes=function(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes},e.prototype.addSelfIntersectionNode=function(t,e,n){if(this.isBoundaryNode(t,e))return null;n===jl.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n)},e.prototype.addPolygonRing=function(t,e,n){if(t.isEmpty())return null;var r=ju.removeRepeatedPoints(t.getCoordinates());if(r.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=r[0],null;var i=e,o=n;wu.isCCW(r)&&(i=n,o=e);var a=new Op(r,new ph(this._argIndex,jl.BOUNDARY,i,o));this._lineEdgeMap.put(t,a),this.insertEdge(a),this.insertPoint(this._argIndex,r[0],jl.BOUNDARY)},e.prototype.insertPoint=function(t,e,n){var r=this._nodes.addNode(e),i=r.getLabel();null===i?r._label=new ph(t,n):i.setLocation(t,n)},e.prototype.createEdgeSetIntersector=function(){return new qf},e.prototype.addSelfIntersectionNodes=function(t){for(var e=this._edges.iterator();e.hasNext();)for(var n=e.next(),r=n.getLabel().getLocation(t),i=n.eiList.iterator();i.hasNext();){var o=i.next();this.addSelfIntersectionNode(t,o.coord,r)}},e.prototype.add=function(){if(1!==arguments.length)return t.prototype.add.apply(this,arguments);var e=arguments[0];if(e.isEmpty())return null;if(e instanceof Nc&&(this._useBoundaryDeterminationRule=!1),e instanceof Pc)this.addPolygon(e);else if(e instanceof Cc)this.addLineString(e);else if(e instanceof Ac)this.addPoint(e);else if(e instanceof Rc)this.addCollection(e);else if(e instanceof mc)this.addCollection(e);else if(e instanceof Nc)this.addCollection(e);else{if(!(e instanceof dc))throw new Error(e.getClass().getName());this.addCollection(e)}},e.prototype.addCollection=function(t){for(var e=0;e50?(null===this._areaPtLocator&&(this._areaPtLocator=new $f(this._parentGeom)),this._areaPtLocator.locate(t)):this._ptLocator.locate(t,this._parentGeom)},e.prototype.findEdge=function(){if(1===arguments.length){var e=arguments[0];return this._lineEdgeMap.get(e)}return t.prototype.findEdge.apply(this,arguments)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.determineBoundary=function(t,e){return t.isInBoundary(e)?jl.BOUNDARY:jl.INTERIOR},e}(Sh),id=function(){if(this._li=new _u,this._resultPrecisionModel=null,this._arg=null,1===arguments.length){var t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new rd(0,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=Au.OGC_SFS_BOUNDARY_RULE;e.getPrecisionModel().compareTo(n.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(n.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new rd(0,e,r),this._arg[1]=new rd(1,n,r)}else if(3===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2];i.getPrecisionModel().compareTo(o.getPrecisionModel())>=0?this.setComputationPrecision(i.getPrecisionModel()):this.setComputationPrecision(o.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new rd(0,i,a),this._arg[1]=new rd(1,o,a)}};id.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry()},id.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)},id.prototype.interfaces_=function(){return[]},id.prototype.getClass=function(){return id};var od=function(){};od.prototype.interfaces_=function(){return[]},od.prototype.getClass=function(){return od},od.map=function(){if(arguments[0]instanceof Mu&&ql(arguments[1],od.MapOp)){for(var t=arguments[0],e=arguments[1],n=new Uu,r=0;r=t.size()?null:t.get(e)},fd.union=function(t){return new fd(t).union()},dd.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(fd,dd);var md=function(){};function gd(){return new yd}function yd(){this.reset()}md.prototype.interfaces_=function(){return[]},md.prototype.getClass=function(){return md},md.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return ad.createEmptyResult(ad.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),Bf.overlayOp(t,e,ad.UNION)},yd.prototype={constructor:yd,reset:function(){this.s=this.t=0},add:function(t){_d(vd,t,this.t),_d(this,vd.s,this.s),this.s?this.t+=vd.t:this.s=vd.t},valueOf:function(){return this.s}};var vd=new yd;function _d(t,e,n){var r=t.s=e+n,i=r-e,o=r-i;t.t=e-o+(n-i)}var xd=1e-6,bd=Math.PI,wd=bd/2,Ed=bd/4,Sd=2*bd,Md=180/bd,Td=bd/180,Cd=Math.abs,Id=Math.atan,Ad=Math.atan2,Ld=Math.cos,Pd=Math.sin,Rd=Math.sqrt;function Dd(t){return t>1?0:t<-1?bd:Math.acos(t)}function Nd(t){return t>1?wd:t<-1?-wd:Math.asin(t)}function Od(){}function kd(t,e){t&&Ud.hasOwnProperty(t.type)&&Ud[t.type](t,e)}var zd,Fd,Bd={Feature:function(t,e){kd(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++rbd?t-Sd:t<-bd?t+Sd:t,e]}function Qd(t){return function(e,n){return[(e+=t)>bd?e-Sd:e<-bd?e+Sd:e,n]}}function $d(t){var e=Qd(t);return e.invert=Qd(-t),e}function tm(t,e){var n=Ld(t),r=Pd(t),i=Ld(e),o=Pd(e);function a(t,e){var a=Ld(e),s=Ld(t)*a,l=Pd(t)*a,u=Pd(e),c=u*n+s*r;return[Ad(l*i-c*o,s*n-u*r),Nd(c*i+l*o)]}return a.invert=function(t,e){var a=Ld(e),s=Ld(t)*a,l=Pd(t)*a,u=Pd(e),c=u*i-l*o;return[Ad(l*i+u*o,s*n+c*r),Nd(c*n-s*r)]},a}function em(t,e){(e=Hd(e))[0]-=t,Yd(e);var n=Dd(-e[1]);return((-e[2]<0?-n:n)+Sd-xd)%Sd}function nm(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:Od,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function rm(t,e){return Cd(t[0]-e[0])=0;--o)i.point((c=u[o])[0],c[1]);else r(p.x,p.p.x,-1,i);p=p.p}u=(p=p.o).z,f=!f}while(!p.v);i.lineEnd()}}}function am(t){if(e=t.length){for(var e,n,r=0,i=t[0];++re?1:t>=e?0:NaN}Kd.invert=Kd;1===(zd=sm).length&&(Fd=zd,zd=function(t,e){return sm(Fd(t),e)});function lm(t){for(var e,n,r,i=t.length,o=-1,a=0;++o=0;)for(e=(r=t[i]).length;--e>=0;)n[--a]=r[e];return n}var um=1e9,cm=-um;var hm=gd();gd();function pm(t){return t}gd(),gd();var fm=1/0,dm=fm,mm=-fm,gm=mm,ym={point:function(t,e){tmm&&(mm=t);egm&&(gm=e)},lineStart:Od,lineEnd:Od,polygonStart:Od,polygonEnd:Od,result:function(){var t=[[fm,dm],[mm,gm]];return mm=gm=-(dm=fm=1/0),t}};gd();function vm(t,e,n,r){return function(i,o){var a,s,l,u=e(o),c=i.invert(r[0],r[1]),h=nm(),p=e(h),f=!1,d={point:m,lineStart:y,lineEnd:v,polygonStart:function(){d.point=_,d.lineStart=x,d.lineEnd=b,s=[],a=[]},polygonEnd:function(){d.point=m,d.lineStart=y,d.lineEnd=v,s=lm(s);var t=function(t,e){var n=e[0],r=e[1],i=[Pd(n),-Ld(n),0],o=0,a=0;hm.reset();for(var s=0,l=t.length;s=0?1:-1,S=E*w,M=S>bd,T=d*x;if(hm.add(Ad(T*E*Pd(S),m*b+T*Ld(S))),o+=M?w+E*Sd:w,M^p>=n^v>=n){var C=Wd(Hd(h),Hd(y));Yd(C);var I=Wd(i,C);Yd(I);var A=(M^w>=0?-1:1)*Nd(I[2]);(r>A||r===A&&(C[0]||C[1]))&&(a+=M^w>=0?1:-1)}}return(o<-1e-6||o0){for(f||(o.polygonStart(),f=!0),o.lineStart(),t=0;t1&&2&i&&u.push(u.pop().concat(u.shift())),s.push(u.filter(_m))}return d}}function _m(t){return t.length>1}function xm(t,e){return((t=t.x)[0]<0?t[1]-wd-xd:wd-t[1])-((e=e.x)[0]<0?e[1]-wd-xd:wd-e[1])}var bm=vm((function(){return!0}),(function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,a){var s=o>0?bd:-bd,l=Cd(o-n);Cd(l-bd)0?wd:-wd),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),e=0):i!==s&&l>=bd&&(Cd(n-i)xd?Id((Pd(e)*(o=Ld(r))*Pd(n)-Pd(r)*(i=Ld(e))*Pd(t))/(i*o*a)):(e+r)/2}(n,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=o,r=a),i=s},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}}),(function(t,e,n,r){var i;if(null==t)i=n*wd,r.point(-bd,i),r.point(0,i),r.point(bd,i),r.point(bd,0),r.point(bd,-i),r.point(0,-i),r.point(-bd,-i),r.point(-bd,0),r.point(-bd,i);else if(Cd(t[0]-e[0])>xd){var o=t[0]4*e&&m--){var x=a+p,b=s+f,w=l+d,E=Rd(x*x+b*b+w*w),S=Nd(w/=E),M=Cd(Cd(w)-1)e||Cd((y*A+v*L)/_-.5)>.3||a*p+s*f+l*d0,i=Cd(n)>xd;function o(t,e){return Ld(t)*Ld(e)>n}function a(t,e,r){var i=[1,0,0],o=Wd(Hd(t),Hd(e)),a=qd(o,o),s=o[0],l=a-s*s;if(!l)return!r&&t;var u=n*a/l,c=-n*s/l,h=Wd(i,o),p=Zd(i,u);Xd(p,Zd(o,c));var f=h,d=qd(p,f),m=qd(f,f),g=d*d-m*(qd(p,p)-1);if(!(g<0)){var y=Rd(g),v=Zd(f,(-d-y)/m);if(Xd(v,p),v=jd(v),!r)return v;var _,x=t[0],b=e[0],w=t[1],E=e[1];b0^v[1]<(Cd(v[0]-x)bd^(x<=v[0]&&v[0]<=b)){var T=Zd(f,(-d+y)/m);return Xd(T,p),[v,jd(T)]}}}function s(e,n){var i=r?t:bd-t,o=0;return e<-i?o|=1:e>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o}return vm(o,(function(t){var e,n,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(h,p){var f,d=[h,p],m=o(h,p),g=r?m?0:s(h,p):m?s(h+(h<0?bd:-bd),p):0;if(!e&&(u=l=m)&&t.lineStart(),m!==l&&(!(f=a(e,d))||rm(e,f)||rm(d,f))&&(d[0]+=xd,d[1]+=xd,m=o(d[0],d[1])),m!==l)c=0,m?(t.lineStart(),f=a(d,e),t.point(f[0],f[1])):(f=a(e,d),t.point(f[0],f[1]),t.lineEnd()),e=f;else if(i&&e&&r^m){var y;g&n||!(y=a(d,e,!0))||(c=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!m||e&&rm(e,d)||t.point(d[0],d[1]),e=d,l=m,n=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return c|(u&&l)<<1}}}),(function(n,r,i,o){!function(t,e,n,r,i,o){if(n){var a=Ld(e),s=Pd(e),l=r*n;null==i?(i=e+r*Sd,o=e-l/2):(i=em(a,i),o=em(a,o),(r>0?io)&&(i+=r*Sd));for(var u,c=i;r>0?c>o:c0)do{u.point(0===c||3===c?t:n,c>1?r:e)}while((c=(c+s+4)%4)!==h);else u.point(o[0],o[1])}function a(r,i){return Cd(r[0]-t)0?0:3:Cd(r[0]-n)0?2:1:Cd(r[1]-e)0?1:0:i>0?3:2}function s(t,e){return l(t.x,e.x)}function l(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(a){var l,u,c,h,p,f,d,m,g,y,v,_=a,x=nm(),b={point:w,lineStart:function(){b.point=E,u&&u.push(c=[]);y=!0,g=!1,d=m=NaN},lineEnd:function(){l&&(E(h,p),f&&g&&x.rejoin(),l.push(x.result()));b.point=w,g&&_.lineEnd()},polygonStart:function(){_=x,l=[],u=[],v=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=u.length;nr&&(p-o)*(r-a)>(f-a)*(t-o)&&++e:f<=r&&(p-o)*(r-a)<(f-a)*(t-o)&&--e;return e}(),n=v&&e,i=(l=lm(l)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&om(l,s,e,o,a),a.polygonEnd());_=a,l=u=c=null}};function w(t,e){i(t,e)&&_.point(t,e)}function E(o,a){var s=i(o,a);if(u&&c.push([o,a]),y)h=o,p=a,f=s,y=!1,s&&(_.lineStart(),_.point(o,a));else if(s&&g)_.point(o,a);else{var l=[d=Math.max(cm,Math.min(um,d)),m=Math.max(cm,Math.min(um,m))],x=[o=Math.max(cm,Math.min(um,o)),a=Math.max(cm,Math.min(um,a))];!function(t,e,n,r,i,o){var a,s=t[0],l=t[1],u=0,c=1,h=e[0]-s,p=e[1]-l;if(a=n-s,h||!(a>0)){if(a/=h,h<0){if(a0){if(a>c)return;a>u&&(u=a)}if(a=i-s,h||!(a<0)){if(a/=h,h<0){if(a>c)return;a>u&&(u=a)}else if(h>0){if(a0)){if(a/=p,p<0){if(a0){if(a>c)return;a>u&&(u=a)}if(a=o-l,p||!(a<0)){if(a/=p,p<0){if(a>c)return;a>u&&(u=a)}else if(p>0){if(a0&&(t[0]=s+u*h,t[1]=l+u*p),c<1&&(e[0]=s+c*h,e[1]=l+c*p),!0}}}}}(l,x,t,e,n,r)?s&&(_.lineStart(),_.point(o,a),v=!1):(g||(_.lineStart(),_.point(l[0],l[1])),_.point(x[0],x[1]),s||_.lineEnd(),v=!1)}d=o,m=a,g=s}return b}}(b=+t[0][0],a=+t[0][1],s=+t[1][0],l=+t[1][1]),A()):null==b?null:[[b,a],[s,l]]},M.scale=function(t){return arguments.length?(h=+t,I()):h},M.translate=function(t){return arguments.length?(p=+t[0],f=+t[1],I()):[p,f]},M.center=function(t){return arguments.length?(d=t[0]%360*Td,m=t[1]%360*Td,I()):[d*Md,m*Md]},M.rotate=function(t){return arguments.length?(g=t[0]%360*Td,y=t[1]%360*Td,v=t.length>2?t[2]%360*Td:0,I()):[g*Md,y*Md,v*Md]},M.precision=function(t){return arguments.length?(S=Tm(C,E=t*t),A()):Rd(E)},M.fitExtent=function(t,e){return Sm(M,t,e)},M.fitSize=function(t,e){return function(t,e,n){return Sm(t,[[0,0],e],n)}(M,t,e)},function(){return e=t.apply(this,arguments),M.invert=e.invert&&T,I()}}((function(){return t}))()}var Am=function(t,e){var n=Ld(t),r=Ld(e),i=function(t){return(t=Dd(t))&&t/Pd(t)}(n*r);return[i*r*Pd(t),i*Pd(e)]};function Lm(t,n,r,i){var a=t.properties||{},s="Feature"===t.type?t.geometry:t;if("GeometryCollection"===s.type){var l=[];return B(t,(function(t){var e=Lm(t,n,r,i);e&&l.push(e)})),f(l)}var u=function(t){var n=fn(t).geometry.coordinates,r=[-n[0],-n[1]];return Im(Am).scale(79.4188).clipAngle(179.999).rotate(r).scale(e)}(s),c={type:s.type,coordinates:Rm(s.coordinates,u)},h=(new eh).read(c),p=_(x(n,r),"meters"),d=Zp.bufferOp(h,p,i);if(!Pm((d=(new nh).write(d)).coordinates))return o({type:d.type,coordinates:Dm(d.coordinates,u)},a)}function Pm(t){return Array.isArray(t[0])?Pm(t[0]):isNaN(t[0])}function Rm(t,e){return"object"!=typeof t[0]?e(t):t.map((function(t){return Rm(t,e)}))}function Dm(t,e){return"object"!=typeof t[0]?e.invert(t):t.map((function(t){return Dm(t,e)}))}function Nm(t,e,n){void 0===n&&(n={});var r=rt(t),i=rt(e),o=Ll.intersection(r.coordinates,i.coordinates);return 0===o.length?null:1===o.length?u(o[0],n.properties):g(o,n.properties)}function Om(t,e,n){void 0===n&&(n={});var r=JSON.stringify(n.properties||{}),i=t[0],o=t[1],a=t[2],s=t[3],l=(o+s)/2,u=(i+a)/2,c=2*e/ge([i,l],[a,l],n)*(a-i),h=2*e/ge([u,o],[u,s],n)*(s-o),p=c/2,d=2*p,m=Math.sqrt(3)/2*h,g=a-i,y=s-o,v=3/4*d,_=m,x=(g-d)/(d-p/2),b=Math.floor(x),w=(b*v-p/2-g)/2-p/2+v/2,E=Math.floor((y-m)/m),S=(y-E*m)/2,M=E*m-y>m/2;M&&(S-=m/4);for(var T=[],C=[],I=0;I<6;I++){var A=2*Math.PI/6*I;T.push(Math.cos(A)),C.push(Math.sin(A))}for(var L=[],P=0;P<=b;P++)for(var R=0;R<=E;R++){var D=P%2==1;if(!(0===R&&D||0===R&&M)){var N=P*v+i-w,O=R*_+o+S;if(D&&(O-=m/2),!0===n.triangles)zm([N,O],c/2,h/2,JSON.parse(r),T,C).forEach((function(t){n.mask?Nm(n.mask,t)&&L.push(t):L.push(t)}));else{var k=km([N,O],c/2,h/2,JSON.parse(r),T,C);n.mask?Nm(n.mask,k)&&L.push(k):L.push(k)}}}return f(L)}function km(t,e,n,r,i,o){for(var a=[],s=0;s<6;s++){var l=t[0]+e*i[s],c=t[1]+n*o[s];a.push([l,c])}return a.push(a[0].slice()),u([a],r)}function zm(t,e,n,r,i,o){for(var a=[],s=0;s<6;s++){var l=[];l.push(t),l.push([t[0]+e*i[s],t[1]+n*o[s]]),l.push([t[0]+e*i[(s+1)%6],t[1]+n*o[(s+1)%6]]),l.push(t),a.push(u([l],r))}return a}function Fm(t){return g(t)}function Bm(t,e,n){return void 0===n&&(n={}),function(t,e,n,r){void 0===r&&(r={});for(var i=[],o=t[0],a=t[1],s=t[2],l=t[3],c=e/ge([o,a],[s,a],r)*(s-o),h=n/ge([o,a],[o,l],r)*(l-a),p=s-o,d=l-a,m=Math.floor(p/c),g=Math.floor(d/h),y=(d-g*h)/2,v=o+(p-m*c)/2,_=0;_=i&&o===r.length-1);o++){if(i>=e){var a=e-i;if(a){var l=pn(r[o],r[o-1])-180;return cn(r[o],a,l,n)}return s(r[o])}i+=ge(r[o],r[o+1],n)}return s(r[r.length-1])},t.angle=function(t,e,n,r){if(void 0===r&&(r={}),!I(r))throw new Error("options is invalid");if(!t)throw new Error("startPoint is required");if(!e)throw new Error("midPoint is required");if(!n)throw new Error("endPoint is required");var i=t,o=e,a=n,s=w(!0!==r.mercator?pn(i,o):wi(i,o)),l=w(!0!==r.mercator?pn(a,o):wi(a,o)),u=Math.abs(s-l);return!0===r.explementary?360-u:u},t.applyFilter=Bs,t.area=Mr,t.areaFactors=i,t.bbox=J,t.bboxClip=function(t,e){var n=rt(t),r=n.type,i="Feature"===t.type?t.properties:{},o=n.coordinates;switch(r){case"LineString":case"MultiLineString":var a=[];return"LineString"===r&&(o=[o]),o.forEach((function(t){!function(t,e,n){var r,i,o,a,s,l=t.length,u=di(t[0],e),c=[];for(n||(n=[]),r=1;r0)for(var n=0;n0},t.booleanParallel=function(t,e){if(!t)throw new Error("line1 is required");if(!e)throw new Error("line2 is required");if("LineString"!==ba(t,"line1"))throw new Error("line1 must be a LineString");if("LineString"!==ba(e,"line2"))throw new Error("line2 must be a LineString");for(var n=jn(Xe(t)).features,r=jn(Xe(e)).features,i=0;in&&(e.numberOfClusters=n),!0!==e.mutate&&(t=be(t));var r=F(t),i=r.slice(0,e.numberOfClusters),o=_a(r,e.numberOfClusters,i),a={};return o.centroids.forEach((function(t,e){a[e]=t})),k(t,(function(t,e){var n=o.idxs[e];t.properties.cluster=n,t.properties.centroid=a[n]})),t},t.collect=function(t,e,n,r){var i=Et(6),o=e.features.map((function(t){var e;return{minX:t.geometry.coordinates[0],minY:t.geometry.coordinates[1],maxX:t.geometry.coordinates[0],maxY:t.geometry.coordinates[1],property:null===(e=t.properties)||void 0===e?void 0:e[n]}}));return i.load(o),t.features.forEach((function(t){t.properties||(t.properties={});var e=J(t),n=i.search({minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}),o=[];n.forEach((function(e){fe([e.minX,e.minY],t)&&o.push(e.property)})),t.properties[r]=o})),t},t.collectionOf=nt,t.combine=function(t){var e={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return k(t,(function(t){var n,r,i,o;switch(null===(o=t.geometry)||void 0===o?void 0:o.type){case"Point":e.MultiPoint.coordinates.push(t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"MultiPoint":(n=e.MultiPoint.coordinates).push.apply(n,t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"LineString":e.MultiLineString.coordinates.push(t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"MultiLineString":(r=e.MultiLineString.coordinates).push.apply(r,t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"Polygon":e.MultiPolygon.coordinates.push(t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties);break;case"MultiPolygon":(i=e.MultiPolygon.coordinates).push.apply(i,t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties)}})),f(Object.keys(e).filter((function(t){return e[t].coordinates.length})).sort().map((function(t){return o({type:t,coordinates:e[t].coordinates},{collectedProperties:e[t].properties})})))},t.concave=function(t,e){void 0===e&&(e={});var n=e.maxEdge||1/0,r=ye(function(t){var e=[],n={};return k(t,(function(t){if(t.geometry){var r=t.geometry.coordinates.join("-");Object.prototype.hasOwnProperty.call(n,r)||(e.push(t),n[r]=!0)}})),f(e)}(t));if(r.features=r.features.filter((function(t){var r=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],a=ge(r,i,e),s=ge(i,o,e),l=ge(r,o,e);return a<=n&&s<=n&&l<=n})),r.features.length<1)return null;var i=We(r);return 1===i.coordinates.length&&(i.coordinates=i.coordinates[0],i.type="Polygon"),o(i)},t.containsNumber=$,t.convertArea=T,t.convertDistance=M,t.convertLength=M,t.convex=pe,t.coordAll=F,t.coordEach=R,t.coordReduce=D,t.createBins=Fs,t.degrees2radians=S,t.degreesToRadians=S,t.destination=cn,t.difference=function(t,e){var n=rt(t),r=rt(e),i=t.properties||{},o=Ll.difference(n.coordinates,r.coordinates);return 0===o.length?null:1===o.length?u(o[0],i):g(o,i)},t.dissolve=function(t,e){if(!I(e=e||{}))throw new Error("options is invalid");var n=e.propertyName;nt(t,"Polygon","dissolve");var r=[];if(!e.propertyName)return Br(g(Ll.union.apply(null,t.features.map((function(t){return t.geometry.coordinates})))));var i={};k(t,(function(t){Object.prototype.hasOwnProperty.call(i,t.properties[n])||(i[t.properties[n]]=[]),i[t.properties[n]].push(t)}));for(var o=Object.keys(i),a=0;a0&&(a=u(o).geometry),ys(a,s),o=s.slice(0);n.push(u(o,i));break;case"MultiPolygon":o=[[[]]];for(var c=0;c0&&(a=g(o).geometry),vs(a,s),o=s.slice(0);n.push(g(o,i));break;default:throw new Error("geometry is invalid, must be Polygon or MultiPolygon")}})),f(n)},t.polygonTangents=function(t,e){var n,r,i,o,a=Q(t),l=Q(e),u=J(e),c=0,h=null;switch(a[0]>u[0]&&a[0]u[1]&&a[1] is required");if("boolean"!=typeof n)throw new Error(" must be a boolean");if("boolean"!=typeof r)throw new Error(" must be a boolean");!1===r&&(t=be(t));var i=[];switch(t.type){case"GeometryCollection":return B(t,(function(t){Ai(t,n)})),t;case"FeatureCollection":return k(t,(function(t){k(Ai(t,n),(function(t){i.push(t)}))})),f(i)}return Ai(t,n)},t.rhumbBearing=wi,t.rhumbDestination=Si,t.rhumbDistance=yr,t.round=v,t.sample=function(t,e){if(!t)throw new Error("featurecollection is required");if(null==e)throw new Error("num is required");if("number"!=typeof e)throw new Error("num must be a number");return f(function(t,e){for(var n,r,i=t.slice(0),o=t.length,a=o-e;o-- >a;)n=i[r=Math.floor((o+1)*Math.random())],i[r]=i[o],i[o]=n;return i.slice(a)}(t.features,e))},t.sector=function(t,e,n,r,i){if(!I(i=i||{}))throw new Error("options is invalid");var o=i.properties;if(!t)throw new Error("center is required");if(null==n)throw new Error("bearing1 is required");if(null==r)throw new Error("bearing2 is required");if(!e)throw new Error("radius is required");if("object"!=typeof i)throw new Error("options must be an object");if(bi(n)===bi(r))return hn(t,e,i);var a=Q(t),s=ii(t,e,n,r,i),l=[[a]];return R(s,(function(t){l[0].push(t)})),l[0].push(a),u(l,o)},t.segmentEach=j,t.segmentReduce=H,t.shortestPath=function(t,e,n){if(!I(n=n||{}))throw new Error("options is invalid");var r=n.resolution,i=n.minDistance,a=n.obstacles||f([]);if(!t)throw new Error("start is required");if(!e)throw new Error("end is required");if(r&&!C(r)||r<=0)throw new Error("options.resolution must be a number, greater than 0");if(i)throw new Error("options.minDistance is not yet implemented");var l=K(t),u=K(e);switch(t=s(l),e=s(u),it(a)){case"FeatureCollection":if(0===a.features.length)return h([l,u]);break;case"Polygon":a=f([o(rt(a))]);break;default:throw new Error("invalid obstacles")}var c=a;c.features.push(t),c.features.push(e);var p=J(Oo(sn(J(c)),1.15));r||(r=ge([p[0],p[1]],[p[2],p[1]],n)/100),c.features.pop(),c.features.pop();for(var d=p[0],m=p[1],g=p[2],y=p[3],v=r/ge([d,m],[g,m],n)*(g-d),_=r/ge([d,m],[d,y],n)*(y-m),x=g-d,b=y-m,w=Math.floor(x/v),E=Math.floor(b/_),S=(x-w*v)/2,M=[],T=[],A=[],L=[],P=1/0,R=1/0,D=y-(b-E*_)/2,N=0;D>=m;){for(var O=[],k=[],z=d+S,F=0;z<=g;){var B=s([z,D]),U=Ca(B,a);O.push(U?0:1),k.push(z+"|"+D);var V=ge(B,t);!U&&V(r=1))return r;for(;no?n=i:r=i,i=.5*(r-n)+n}return i},r.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var i=o;function o(t,e){this.x=t,this.y=e}o.prototype={clone:function(){return new o(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,n=t.y-this.y;return e*e+n*n},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[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,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),n=Math.sin(t),r=n*this.x+e*this.y;return this.x=e*this.x-n*this.y,this.y=r,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=e.x+n*(this.x-e.x)-r*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(t){return t instanceof o?t:Array.isArray(t)?new o(t[0],t[1]):t};var a="undefined"!=typeof self?self:{},s=Math.pow(2,53)-1;function l(t,e,r,i){var o=new n(t,e,r,i);return function(t){return o.solve(t)}}var u=l(.25,.1,.25,1);function c(t,e,n){return Math.min(n,Math.max(e,t))}function h(t,e,n){var r=n-e,i=((t-e)%r+r)%r+e;return i===e?n:i}function p(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function g(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function y(t,e){t.forEach((function(t){e[t]&&(e[t]=e[t].bind(e))}))}function v(t,e){return-1!==t.indexOf(e,t.length-e.length)}function _(t,e,n){var r={};for(var i in t)r[i]=e.call(n||this,t[i],i,t);return r}function x(t,e,n){var r={};for(var i in t)e.call(n||this,t[i],i,t)&&(r[i]=t[i]);return r}function b(t){return Array.isArray(t)?t.map(b):"object"==typeof t&&t?_(t,b):t}var w={};function E(t){w[t]||("undefined"!=typeof console&&console.warn(t),w[t]=!0)}function S(t,e,n){return(n.y-t.y)*(e.x-t.x)>(e.y-t.y)*(n.x-t.x)}function M(t){for(var e=0,n=0,r=t.length,i=r-1,o=void 0,a=void 0;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(t,n,r,i){var o=r||i;return e[n]=!o||o.toLowerCase(),""})),e["max-age"]){var n=parseInt(e["max-age"],10);isNaN(n)?delete e["max-age"]:e["max-age"]=n}return e}var I=null;function A(t){if(null==I){var e=t.navigator?t.navigator.userAgent:null;I=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return I}function L(t){try{var e=a[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}var P,R,D,N,O=a.performance&&a.performance.now?a.performance.now.bind(a.performance):Date.now.bind(Date),k=a.requestAnimationFrame||a.mozRequestAnimationFrame||a.webkitRequestAnimationFrame||a.msRequestAnimationFrame,z=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame,F={now:O,frame:function(t){var e=k(t);return{cancel:function(){return z(e)}}},getImageData:function(t,e){void 0===e&&(e=0);var n=a.document.createElement("canvas"),r=n.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return n.width=t.width,n.height=t.height,r.drawImage(t,0,0,t.width,t.height),r.getImageData(-e,-e,t.width+2*e,t.height+2*e)},resolveURL:function(t){return P||(P=a.document.createElement("a")),P.href=t,P.href},hardwareConcurrency:a.navigator&&a.navigator.hardwareConcurrency||4,get devicePixelRatio(){return a.devicePixelRatio},get prefersReducedMotion(){return!!a.matchMedia&&(null==R&&(R=a.matchMedia("(prefers-reduced-motion: reduce)")),R.matches)}},B={API_URL:"https://api.mapbox.com",get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},FEEDBACK_URL:"https://apps.mapbox.com/feedback",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},U={supported:!1,testSupport:function(t){!V&&N&&(G?j(t):D=t)}},V=!1,G=!1;function j(t){var e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,N),t.isContextLost())return;U.supported=!0}catch(t){}t.deleteTexture(e),V=!0}a.document&&((N=a.document.createElement("img")).onload=function(){D&&j(D),D=null,G=!0},N.onerror=function(){V=!0,D=null},N.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");var H="01",q=function(t,e){this._transformRequestFn=t,this._customAccessToken=e,this._createSkuToken()};function W(t){return 0===t.indexOf("mapbox:")}q.prototype._createSkuToken=function(){var t=function(){for(var t="",e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",H,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt},q.prototype._isSkuTokenExpired=function(){return Date.now()>this._skuTokenExpiresAt},q.prototype.transformRequest=function(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}},q.prototype.normalizeStyleURL=function(t,e){if(!W(t))return t;var n=J(t);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||e)},q.prototype.normalizeGlyphsURL=function(t,e){if(!W(t))return t;var n=J(t);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||e)},q.prototype.normalizeSourceURL=function(t,e){if(!W(t))return t;var n=J(t);return n.path="/v4/"+n.authority+".json",n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||e)},q.prototype.normalizeSpriteURL=function(t,e,n,r){var i=J(t);return W(t)?(i.path="/styles/v1"+i.path+"/sprite"+e+n,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=""+e+n,K(i))},q.prototype.normalizeTileURL=function(t,e){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!W(t))return t;var n=J(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,(F.devicePixelRatio>=2||512===e?"@2x":"")+(U.supported?".webp":"$1")),n.path=n.path.replace(/^.+\/v4\//,"/"),n.path="/v4"+n.path;var r=this._customAccessToken||function(t){for(var e=0,n=t;e=0&&t.params.splice(i,1)}if("/"!==r.path&&(t.path=""+r.path+t.path),!B.REQUIRE_ACCESS_TOKEN)return K(t);if(!(e=e||B.ACCESS_TOKEN))throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===e[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n);return t.params=t.params.filter((function(t){return-1===t.indexOf("access_token")})),t.params.push("access_token="+e),K(t)},q.prototype.setTransformRequest=function(t){this._transformRequestFn=t};var X=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;function Z(t){return X.test(t)}var Y=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function J(t){var e=t.match(Y);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function K(t){var e=t.params.length?"?"+t.params.join("&"):"";return t.protocol+"://"+t.authority+t.path+e}function Q(t){if(!t)return null;var e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(a.atob(e[1]).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return null}}var $=function(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null};$.prototype.getStorageKey=function(t){var e,n=Q(B.ACCESS_TOKEN);return e=n&&n.u?a.btoa(encodeURIComponent(n.u).replace(/%([0-9A-F]{2})/g,(function(t,e){return String.fromCharCode(Number("0x"+e))}))):B.ACCESS_TOKEN||"",t?"mapbox.eventData."+t+":"+e:"mapbox.eventData:"+e},$.prototype.fetchEventData=function(){var t=L("localStorage"),e=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{var r=a.localStorage.getItem(e);r&&(this.eventData=JSON.parse(r));var i=a.localStorage.getItem(n);i&&(this.anonId=i)}catch(t){E("Unable to read from LocalStorage")}},$.prototype.saveEventData=function(){var t=L("localStorage"),e=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{a.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&a.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){E("Unable to write to LocalStorage")}},$.prototype.processRequests=function(t){},$.prototype.postEvent=function(t,e,n,r){var i=this;if(B.EVENTS_URL){var o=J(B.EVENTS_URL);o.params.push("access_token="+(r||B.ACCESS_TOKEN||""));var a={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:"1.15.2",skuId:H,userId:this.anonId},s=e?p(a,e):a,l={url:K(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=wt(l,(function(t){i.pendingRequest=null,n(t),i.saveEventData(),i.processRequests(r)}))}},$.prototype.queueRequest=function(t,e){this.queue.push(t),this.processRequests(e)};var tt,et,nt=function(t){function e(){t.call(this,"map.load"),this.success={},this.skuToken=""}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.postMapLoadEvent=function(t,e,n,r){this.skuToken=n,(B.EVENTS_URL&&r||B.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return W(t)||Z(t)})))&&this.queueRequest({id:e,timestamp:Date.now()},r)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){var n=this.queue.shift(),r=n.id,i=n.timestamp;r&&this.success[r]||(this.anonId||this.fetchEventData(),g(this.anonId)||(this.anonId=m()),this.postEvent(i,{skuToken:this.skuToken},(function(t){t||r&&(e.success[r]=!0)}),t))}},e}($),rt=new(function(t){function e(e){t.call(this,"appUserTurnstile"),this._customAccessToken=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.postTurnstileEvent=function(t,e){B.EVENTS_URL&&B.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return W(t)||Z(t)}))&&this.queueRequest(Date.now(),e)},e.prototype.processRequests=function(t){var e=this;if(!this.pendingRequest&&0!==this.queue.length){this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();var n=Q(B.ACCESS_TOKEN),r=n?n.u:B.ACCESS_TOKEN,i=r!==this.eventData.tokenU;g(this.anonId)||(this.anonId=m(),i=!0);var o=this.queue.shift();if(this.eventData.lastSuccess){var a=new Date(this.eventData.lastSuccess),s=new Date(o),l=(o-this.eventData.lastSuccess)/864e5;i=i||l>=1||l<-1||a.getDate()!==s.getDate()}else i=!0;if(!i)return this.processRequests();this.postEvent(o,{"enabled.telemetry":!1},(function(t){t||(e.eventData.lastSuccess=o,e.eventData.tokenU=r)}),t)}},e}($)),it=rt.postTurnstileEvent.bind(rt),ot=new nt,at=ot.postMapLoadEvent.bind(ot),st=500,lt=50;function ut(){a.caches&&!tt&&(tt=a.caches.open("mapbox-tiles"))}function ct(t){var e=t.indexOf("?");return e<0?t:t.slice(0,e)}var ht,pt=1/0;function ft(){return null==ht&&(ht=a.OffscreenCanvas&&new a.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.createImageBitmap),ht}var dt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(dt);var mt=function(t){function e(e,n,r){401===n&&Z(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),t.call(this,e),this.status=n,this.url=r,this.name=this.constructor.name,this.message=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.toString=function(){return this.name+": "+this.message+" ("+this.status+"): "+this.url},e}(Error),gt=T()?function(){return self.worker&&self.worker.referrer}:function(){return("blob:"===a.location.protocol?a.parent:a).location.href};function yt(t,e){var n,r=new a.AbortController,i=new a.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:gt(),signal:r.signal}),o=!1,s=!1,l=(n=i.url).indexOf("sku=")>0&&Z(n);"json"===t.type&&i.headers.set("Accept","application/json");var u=function(n,r,o){if(!s){if(n&&"SecurityError"!==n.message&&E(n),r&&o)return c(r);var u=Date.now();a.fetch(i).then((function(n){if(n.ok){var r=l?n.clone():null;return c(n,r,u)}return e(new mt(n.statusText,n.status,t.url))})).catch((function(t){20!==t.code&&e(new Error(t.message))}))}},c=function(n,r,l){("arrayBuffer"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text()).then((function(t){s||(r&&l&&function(t,e,n){if(ut(),tt){var r={status:e.status,statusText:e.statusText,headers:new a.Headers};e.headers.forEach((function(t,e){return r.headers.set(e,t)}));var i=C(e.headers.get("Cache-Control")||"");i["no-store"]||(i["max-age"]&&r.headers.set("Expires",new Date(n+1e3*i["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-n<42e4||function(t,e){if(void 0===et)try{new Response(new ReadableStream),et=!0}catch(t){et=!1}et?e(t.body):t.blob().then(e)}(e,(function(e){var n=new a.Response(e,r);ut(),tt&&tt.then((function(e){return e.put(ct(t.url),n)})).catch((function(t){return E(t.message)}))})))}}(i,r,l),o=!0,e(null,t,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((function(t){s||e(new Error(t.message))}))};return l?function(t,e){if(ut(),!tt)return e(null);var n=ct(t.url);tt.then((function(t){t.match(n).then((function(r){var i=function(t){if(!t)return!1;var e=new Date(t.headers.get("Expires")||0),n=C(t.headers.get("Cache-Control")||"");return e>Date.now()&&!n["no-cache"]}(r);t.delete(n),i&&t.put(n,r.clone()),e(null,r,i)})).catch(e)})).catch(e)}(i,u):u(null,null),{cancel:function(){s=!0,o||r.abort()}}}var vt,_t,xt=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!T()){var n=t.url.substring(0,t.url.indexOf("://"));return(B.REGISTERED_PROTOCOLS[n]||yt)(t,e)}}if(!(/^file:/.test(r=t.url)||/^file:/.test(gt())&&!/^\w+:/.test(r))){if(a.fetch&&a.Request&&a.AbortController&&a.Request.prototype.hasOwnProperty("signal"))return yt(t,e);if(T()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){var n=new a.XMLHttpRequest;for(var r in n.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(n.responseType="arraybuffer"),t.headers)n.setRequestHeader(r,t.headers[r]);return"json"===t.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===t.credentials,n.onerror=function(){e(new Error(n.statusText))},n.onload=function(){if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){var r=n.response;if("json"===t.type)try{r=JSON.parse(n.response)}catch(t){return e(t)}e(null,r,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else e(new mt(n.statusText,n.status,t.url))},n.send(t.body),{cancel:function(){return n.abort()}}}(t,e)},bt=function(t,e){return xt(p(t,{type:"arrayBuffer"}),e)},wt=function(t,e){return xt(p(t,{method:"POST"}),e)},Et="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";vt=[],_t=0;var St=function(t,e){if(U.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),_t>=B.MAX_PARALLEL_IMAGE_REQUESTS){var n={requestParameters:t,callback:e,cancelled:!1,cancel:function(){this.cancelled=!0}};return vt.push(n),n}_t++;var r=!1,i=function(){if(!r)for(r=!0,_t--;vt.length&&_t0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)},At.prototype.setEventedParent=function(t,e){return this._eventedParent=t,this._eventedParentData=e,this};var Lt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}},Pt=function(t,e,n,r){this.message=(t?t+": ":"")+n,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)};function Rt(t){var e=t.value;return e?[new Pt(t.key,e,"constants have been deprecated as of v8")]:[]}function Dt(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e;r":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var Jt=[Ft,Bt,Ut,Vt,Gt,Wt,jt,Zt(Ht),Xt];function Kt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Kt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(var n=0,r=Jt;n255?255:t}function i(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function o(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function a(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{e.parseCSSColor=function(t){var e,s=t.replace(/ /g,"").toLowerCase();if(s in n)return n[s].slice();if("#"===s[0])return 4===s.length?(e=parseInt(s.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===s.length&&(e=parseInt(s.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=s.indexOf("("),u=s.indexOf(")");if(-1!==l&&u+1===s.length){var c=s.substr(0,l),h=s.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[i(h[0]),i(h[1]),i(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var f=(parseFloat(h[0])%360+360)%360/360,d=o(h[1]),m=o(h[2]),g=m<=.5?m*(d+1):m+d-m*d,y=2*m-g;return[r(255*a(y,g,f+1/3)),r(255*a(y,g,f)),r(255*a(y,g,f-1/3)),p];default:return null}}return null}}catch(t){}})).parseCSSColor,ee=function(t,e,n,r){void 0===r&&(r=1),this.r=t,this.g=e,this.b=n,this.a=r};ee.parse=function(t){if(t){if(t instanceof ee)return t;if("string"==typeof t){var e=te(t);if(e)return new ee(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},ee.prototype.toString=function(){var t=this.toArray(),e=t[1],n=t[2],r=t[3];return"rgba("+Math.round(t[0])+","+Math.round(e)+","+Math.round(n)+","+r+")"},ee.prototype.toArray=function(){var t=this.a;return 0===t?[0,0,0,0]:[255*this.r/t,255*this.g/t,255*this.b/t,t]},ee.black=new ee(0,0,0,1),ee.white=new ee(1,1,1,1),ee.transparent=new ee(0,0,0,0),ee.red=new ee(1,0,0,1);var ne=function(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})};ne.prototype.compare=function(t,e){return this.collator.compare(t,e)},ne.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var re=function(t,e,n,r,i){this.text=t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i},ie=function(t){this.sections=t};ie.fromString=function(t){return new ie([new re(t,null,null,null,null)])},ie.prototype.isEmpty=function(){return 0===this.sections.length||!this.sections.some((function(t){return 0!==t.text.length||t.image&&0!==t.image.name.length}))},ie.factory=function(t){return t instanceof ie?t:ie.fromString(t)},ie.prototype.toString=function(){return 0===this.sections.length?"":this.sections.map((function(t){return t.text})).join("")},ie.prototype.serialize=function(){for(var t=["format"],e=0,n=this.sections;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid rgba value ["+[t,e,n,r].join(", ")+"]: 'a' must be between 0 and 1.":"Invalid rgba value ["+("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")+"]: 'r', 'g', and 'b' must be between 0 and 255."}function se(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof ee)return!0;if(t instanceof ne)return!0;if(t instanceof ie)return!0;if(t instanceof oe)return!0;if(Array.isArray(t)){for(var e=0,n=t;e2){var s=t[1];if("string"!=typeof s||!(s in pe)||"object"===s)return e.error('The item type argument of "array" must be one of string, number, boolean',1);o=pe[s],r++}else o=Ht;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],r++}n=Zt(o,a)}else n=pe[i];for(var l=[];r1)&&e.push(r)}}return e.concat(this.args.map((function(t){return t.serialize()})))};var de=function(t){this.type=Wt,this.sections=t};de.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n=t[1];if(!Array.isArray(n)&&"object"==typeof n)return e.error("First argument must be an image or text section.");for(var r=[],i=!1,o=1;o<=t.length-1;++o){var a=t[o];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;var s=null;if(a["font-scale"]&&!(s=e.parse(a["font-scale"],1,Bt)))return null;var l=null;if(a["text-font"]&&!(l=e.parse(a["text-font"],1,Zt(Ut))))return null;var u=null;if(a["text-color"]&&!(u=e.parse(a["text-color"],1,Gt)))return null;var c=r[r.length-1];c.scale=s,c.font=l,c.textColor=u}else{var h=e.parse(t[o],1,Ht);if(!h)return null;var p=h.type.kind;if("string"!==p&&"value"!==p&&"null"!==p&&"resolvedImage"!==p)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:h,scale:null,font:null,textColor:null})}}return new de(r)},de.prototype.evaluate=function(t){return new ie(this.sections.map((function(e){var n=e.content.evaluate(t);return le(n)===Xt?new re("",n,null,null,null):new re(ue(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))},de.prototype.eachChild=function(t){for(var e=0,n=this.sections;e-1),n},me.prototype.eachChild=function(t){t(this.input)},me.prototype.outputDefined=function(){return!1},me.prototype.serialize=function(){return["image",this.input.serialize()]};var ge={"to-boolean":Vt,"to-color":Gt,"to-number":Bt,"to-string":Ut},ye=function(t,e){this.type=t,this.args=e};ye.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var n=t[0];if(("to-boolean"===n||"to-string"===n)&&2!==t.length)return e.error("Expected one argument.");for(var r=ge[n],i=[],o=1;o4?"Invalid rbga value "+JSON.stringify(e)+": expected an array containing either three or four numeric values.":ae(e[0],e[1],e[2],e[3])))return new ee(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new he(n||"Could not parse color from value '"+("string"==typeof e?e:String(JSON.stringify(e)))+"'")}if("number"===this.type.kind){for(var a=null,s=0,l=this.args;s=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Se(t,e){var n=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(n*i*8192),Math.round(r*i*8192)]}function Me(t,e,n){return e[1]>t[1]!=n[1]>t[1]&&t[0]<(n[0]-e[0])*(t[1]-e[1])/(n[1]-e[1])+e[0]}function Te(t,e){for(var n,r,i,o,a,s,l,u=!1,c=0,h=e.length;c0&&s<0||a<0&&s>0}function Ae(t,e,n){for(var r=0,i=n;rn[2]){var i=.5*r,o=t[0]-n[0]>i?-r:n[0]-t[0]>i?r:0;0===o&&(o=t[0]-n[2]>i?-r:n[2]-t[0]>i?r:0),t[0]+=o}we(e,t)}function Oe(t,e,n,r){for(var i=8192*Math.pow(2,r.z),o=[8192*r.x,8192*r.y],a=[],s=0,l=t;s=0)return!1;var n=!0;return t.eachChild((function(t){n&&!Ue(t,e)&&(n=!1)})),n}ze.parse=function(t,e){if(2!==t.length)return e.error("'within' expression requires exactly one argument, but found "+(t.length-1)+" instead.");if(se(t[1])){var n=t[1];if("FeatureCollection"===n.type)for(var r=0;re))throw new he("Input is not a number.");o=a-1}return 0}Ge.prototype.parse=function(t,e,n,r,i){return void 0===i&&(i={}),e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)},Ge.prototype._parse=function(t,e){function n(t,e,n){return"assert"===n?new fe(e,[t]):"coerce"===n?new ye(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var r=t[0];if("string"!=typeof r)return this.error("Expression name must be a string, but found "+typeof r+' instead. If you wanted a literal array, use ["literal", [...]].',0),null;var i=this.registry[r];if(i){var o=i.parse(t,this);if(!o)return null;if(this.expectedType){var a=this.expectedType,s=o.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind&&"array"!==a.kind||"value"!==s.kind)if("color"!==a.kind&&"formatted"!==a.kind&&"resolvedImage"!==a.kind||"value"!==s.kind&&"string"!==s.kind){if(this.checkSubtype(a,s))return null}else o=n(o,a,e.typeAnnotation||"coerce");else o=n(o,a,e.typeAnnotation||"assert")}if(!(o instanceof ce)&&"resolvedImage"!==o.type.kind&&function t(e){if(e instanceof Ve)return t(e.boundExpression);if(e instanceof xe&&"error"===e.name)return!1;if(e instanceof be)return!1;if(e instanceof ze)return!1;var n=e instanceof ye||e instanceof fe,r=!0;return e.eachChild((function(e){r=n?r&&t(e):r&&e instanceof ce})),!!r&&Fe(e)&&Ue(e,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}(o)){var l=new _e;try{o=new ce(o.type,o.evaluate(l))}catch(t){return this.error(t.message),null}}return o}return this.error('Unknown expression "'+r+'". If you wanted a literal array, use ["literal", [...]].',0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':"Expected an array, but found "+typeof t+" instead.")},Ge.prototype.concat=function(t,e,n){var r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new Ge(this.registry,r,e||null,i,this.errors)},Ge.prototype.error=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=""+this.key+e.map((function(t){return"["+t+"]"})).join("");this.errors.push(new kt(r,t))},Ge.prototype.checkSubtype=function(t,e){var n=Kt(t,e);return n&&this.error(n),n};var He=function(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var r=0,i=n;r=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);var c=e.parse(s,u,i);if(!c)return null;i=i||c.type,r.push([a,c])}return new He(i,n,r)},He.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[je(e,r)].evaluate(t)},He.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var We=Object.freeze({__proto__:null,number:qe,color:function(t,e,n){return new ee(qe(t.r,e.r,n),qe(t.g,e.g,n),qe(t.b,e.b,n),qe(t.a,e.a,n))},array:function(t,e,n){return t.map((function(t,r){return qe(t,e[r],n)}))}}),Xe=6/29*3*(6/29),Ze=Math.PI/180,Ye=180/Math.PI;function Je(t){return t>.008856451679035631?Math.pow(t,1/3):t/Xe+4/29}function Ke(t){return t>6/29?t*t*t:Xe*(t-4/29)}function Qe(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function $e(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function tn(t){var e=$e(t.r),n=$e(t.g),r=$e(t.b),i=Je((.4124564*e+.3575761*n+.1804375*r)/.95047),o=Je((.2126729*e+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Je((.0193339*e+.119192*n+.9503041*r)/1.08883)),alpha:t.a}}function en(t){var e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ke(e),n=.95047*Ke(n),r=1.08883*Ke(r),new ee(Qe(3.2404542*n-1.5371385*e-.4985314*r),Qe(-.969266*n+1.8760108*e+.041556*r),Qe(.0556434*n-.2040259*e+1.0572252*r),t.alpha)}function nn(t,e,n){var r=e-t;return t+n*(r>180||r<-180?r-360*Math.round(r/360):r)}var rn={forward:tn,reverse:en,interpolate:function(t,e,n){return{l:qe(t.l,e.l,n),a:qe(t.a,e.a,n),b:qe(t.b,e.b,n),alpha:qe(t.alpha,e.alpha,n)}}},on={forward:function(t){var e=tn(t),n=e.l,r=e.a,i=e.b,o=Math.atan2(i,r)*Ye;return{h:o<0?o+360:o,c:Math.sqrt(r*r+i*i),l:n,alpha:t.a}},reverse:function(t){var e=t.h*Ze,n=t.c;return en({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:nn(t.h,e.h,n),c:qe(t.c,e.c,n),l:qe(t.l,e.l,n),alpha:qe(t.alpha,e.alpha,n)}}},an=Object.freeze({__proto__:null,lab:rn,hcl:on}),sn=function(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(var o=0,a=i;o1})))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:s}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(i=e.parse(i,2,Bt)))return null;var l=[],u=null;"interpolate-hcl"===n||"interpolate-lab"===n?u=Gt:e.expectedType&&"value"!==e.expectedType.kind&&(u=e.expectedType);for(var c=0;c=h)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',f);var m=e.parse(p,d,u);if(!m)return null;u=u||m.type,l.push([h,m])}return"number"===u.kind||"color"===u.kind||"array"===u.kind&&"number"===u.itemType.kind&&"number"==typeof u.N?new sn(u,n,r,i,l):e.error("Type "+Yt(u)+" is not interpolatable.")},sn.prototype.evaluate=function(t){var e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);var r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);var i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);var o=je(e,r),a=sn.interpolationFactor(this.interpolation,r,e[o],e[o+1]),s=n[o].evaluate(t),l=n[o+1].evaluate(t);return"interpolate"===this.operator?We[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?on.reverse(on.interpolate(on.forward(s),on.forward(l),a)):rn.reverse(rn.interpolate(rn.forward(s),rn.forward(l),a))},sn.prototype.eachChild=function(t){t(this.input);for(var e=0,n=this.outputs;e=n.length)throw new he("Array index out of bounds: "+e+" > "+(n.length-1)+".");if(e!==Math.floor(e))throw new he("Array index must be an integer, but found "+e+" instead.");return n[e]},hn.prototype.eachChild=function(t){t(this.index),t(this.input)},hn.prototype.outputDefined=function(){return!1},hn.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var pn=function(t,e){this.type=Vt,this.needle=t,this.haystack=e};pn.parse=function(t,e){if(3!==t.length)return e.error("Expected 2 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Ht);return n&&r?Qt(n.type,[Vt,Ut,Bt,Ft,Ht])?new pn(n,r):e.error("Expected first argument to be of type boolean, string, number or null, but found "+Yt(n.type)+" instead"):null},pn.prototype.evaluate=function(t){var e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return!1;if(!$t(e,["boolean","string","number","null"]))throw new he("Expected first argument to be of type boolean, string, number or null, but found "+Yt(le(e))+" instead.");if(!$t(n,["string","array"]))throw new he("Expected second argument to be of type array or string, but found "+Yt(le(n))+" instead.");return n.indexOf(e)>=0},pn.prototype.eachChild=function(t){t(this.needle),t(this.haystack)},pn.prototype.outputDefined=function(){return!0},pn.prototype.serialize=function(){return["in",this.needle.serialize(),this.haystack.serialize()]};var fn=function(t,e,n){this.type=Bt,this.needle=t,this.haystack=e,this.fromIndex=n};fn.parse=function(t,e){if(t.length<=2||t.length>=5)return e.error("Expected 3 or 4 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Ht);if(!n||!r)return null;if(!Qt(n.type,[Vt,Ut,Bt,Ft,Ht]))return e.error("Expected first argument to be of type boolean, string, number or null, but found "+Yt(n.type)+" instead");if(4===t.length){var i=e.parse(t[3],3,Bt);return i?new fn(n,r,i):null}return new fn(n,r)},fn.prototype.evaluate=function(t){var e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!$t(e,["boolean","string","number","null"]))throw new he("Expected first argument to be of type boolean, string, number or null, but found "+Yt(le(e))+" instead.");if(!$t(n,["string","array"]))throw new he("Expected second argument to be of type array or string, but found "+Yt(le(n))+" instead.");if(this.fromIndex){var r=this.fromIndex.evaluate(t);return n.indexOf(e,r)}return n.indexOf(e)},fn.prototype.eachChild=function(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)},fn.prototype.outputDefined=function(){return!1},fn.prototype.serialize=function(){if(null!=this.fromIndex&&void 0!==this.fromIndex){var t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]};var dn=function(t,e,n,r,i,o){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o};dn.parse=function(t,e){if(t.length<5)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if(t.length%2!=1)return e.error("Expected an even number of arguments.");var n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(var i={},o=[],a=2;aNumber.MAX_SAFE_INTEGER)return u.error("Branch labels must be integers no larger than "+Number.MAX_SAFE_INTEGER+".");if("number"==typeof p&&Math.floor(p)!==p)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,le(p)))return null}else n=le(p);if(void 0!==i[String(p)])return u.error("Branch labels must be unique.");i[String(p)]=o.length}var f=e.parse(l,a,r);if(!f)return null;r=r||f.type,o.push(f)}var d=e.parse(t[1],1,Ht);if(!d)return null;var m=e.parse(t[t.length-1],t.length-1,r);return m?"value"!==d.type.kind&&e.concat(1).checkSubtype(n,d.type)?null:new dn(n,r,d,i,o,m):null},dn.prototype.evaluate=function(t){var e=this.input.evaluate(t);return(le(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)},dn.prototype.eachChild=function(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)},dn.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))&&this.otherwise.outputDefined()},dn.prototype.serialize=function(){for(var t=this,e=["match",this.input.serialize()],n=[],r={},i=0,o=Object.keys(this.cases).sort();i=5)return e.error("Expected 3 or 4 arguments, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1,Ht),r=e.parse(t[2],2,Bt);if(!n||!r)return null;if(!Qt(n.type,[Zt(Ht),Ut,Ht]))return e.error("Expected first argument to be of type array or string, but found "+Yt(n.type)+" instead");if(4===t.length){var i=e.parse(t[3],3,Bt);return i?new gn(n.type,n,r,i):null}return new gn(n.type,n,r)},gn.prototype.evaluate=function(t){var e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);if(!$t(e,["string","array"]))throw new he("Expected first argument to be of type array or string, but found "+Yt(le(e))+" instead.");if(this.endIndex){var r=this.endIndex.evaluate(t);return e.slice(n,r)}return e.slice(n)},gn.prototype.eachChild=function(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)},gn.prototype.outputDefined=function(){return!1},gn.prototype.serialize=function(){if(null!=this.endIndex&&void 0!==this.endIndex){var t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]};var xn=_n("==",(function(t,e,n){return e===n}),vn),bn=_n("!=",(function(t,e,n){return e!==n}),(function(t,e,n,r){return!vn(0,e,n,r)})),wn=_n("<",(function(t,e,n){return e",(function(t,e,n){return e>n}),(function(t,e,n,r){return r.compare(e,n)>0})),Sn=_n("<=",(function(t,e,n){return e<=n}),(function(t,e,n,r){return r.compare(e,n)<=0})),Mn=_n(">=",(function(t,e,n){return e>=n}),(function(t,e,n,r){return r.compare(e,n)>=0})),Tn=function(t,e,n,r,i){this.type=Ut,this.number=t,this.locale=e,this.currency=n,this.minFractionDigits=r,this.maxFractionDigits=i};Tn.parse=function(t,e){if(3!==t.length)return e.error("Expected two arguments.");var n=e.parse(t[1],1,Bt);if(!n)return null;var r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");var i=null;if(r.locale&&!(i=e.parse(r.locale,1,Ut)))return null;var o=null;if(r.currency&&!(o=e.parse(r.currency,1,Ut)))return null;var a=null;if(r["min-fraction-digits"]&&!(a=e.parse(r["min-fraction-digits"],1,Bt)))return null;var s=null;return r["max-fraction-digits"]&&!(s=e.parse(r["max-fraction-digits"],1,Bt))?null:new Tn(n,i,o,a,s)},Tn.prototype.evaluate=function(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))},Tn.prototype.eachChild=function(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)},Tn.prototype.outputDefined=function(){return!1},Tn.prototype.serialize=function(){var t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]};var Cn=function(t){this.type=Bt,this.input=t};Cn.parse=function(t,e){if(2!==t.length)return e.error("Expected 1 argument, but found "+(t.length-1)+" instead.");var n=e.parse(t[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?e.error("Expected argument of type string or array, but found "+Yt(n.type)+" instead."):new Cn(n):null},Cn.prototype.evaluate=function(t){var e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new he("Expected value to be of type string or array, but found "+Yt(le(e))+" instead.")},Cn.prototype.eachChild=function(t){t(this.input)},Cn.prototype.outputDefined=function(){return!1},Cn.prototype.serialize=function(){var t=["length"];return this.eachChild((function(e){t.push(e.serialize())})),t};var In={"==":xn,"!=":bn,">":En,"<":wn,">=":Mn,"<=":Sn,array:fe,at:hn,boolean:fe,case:mn,coalesce:un,collator:be,format:de,image:me,in:pn,"index-of":fn,interpolate:sn,"interpolate-hcl":sn,"interpolate-lab":sn,length:Cn,let:cn,literal:ce,match:dn,number:fe,"number-format":Tn,object:fe,slice:gn,step:He,string:fe,"to-boolean":ye,"to-color":ye,"to-number":ye,"to-string":ye,var:Ve,within:ze};function An(t,e){var n=e[0],r=e[1],i=e[2],o=e[3];n=n.evaluate(t),r=r.evaluate(t),i=i.evaluate(t);var a=o?o.evaluate(t):1,s=ae(n,r,i,a);if(s)throw new he(s);return new ee(n/255*a,r/255*a,i/255*a,a)}function Ln(t,e){return t in e}function Pn(t,e){var n=e[t];return void 0===n?null:n}function Rn(t){return{type:t}}function Dn(t){return{result:"success",value:t}}function Nn(t){return{result:"error",value:t}}function On(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function kn(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function zn(t){return!!t.expression&&t.expression.interpolated}function Fn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Bn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Un(t){return t}function Vn(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function Gn(t,e,n,r,i){return Vn(typeof n===i?r[n]:void 0,t.default,e.default)}function jn(t,e,n){if("number"!==Fn(n))return Vn(t.default,e.default);var r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];var i=je(t.stops.map((function(t){return t[0]})),n);return t.stops[i][1]}function Hn(t,e,n){var r=void 0!==t.base?t.base:1;if("number"!==Fn(n))return Vn(t.default,e.default);var i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];var o=je(t.stops.map((function(t){return t[0]})),n),a=function(t,e,n,r){var i=r-n,o=t-n;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[o][0],t.stops[o+1][0]),s=t.stops[o][1],l=t.stops[o+1][1],u=We[e.type]||Un;if(t.colorSpace&&"rgb"!==t.colorSpace){var c=an[t.colorSpace];u=function(t,e){return c.reverse(c.interpolate(c.forward(t),c.forward(e),a))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=s.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==n&&void 0!==r)return u(n,r,a)}}:u(s,l,a)}function qn(t,e,n){return"color"===e.type?n=ee.parse(n):"formatted"===e.type?n=ie.fromString(n.toString()):"resolvedImage"===e.type?n=oe.fromString(n.toString()):Fn(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),Vn(n,t.default,e.default)}xe.register(In,{error:[{kind:"error"},[Ut],function(t,e){throw new he(e[0].evaluate(t))}],typeof:[Ut,[Ht],function(t,e){return Yt(le(e[0].evaluate(t)))}],"to-rgba":[Zt(Bt,4),[Gt],function(t,e){return e[0].evaluate(t).toArray()}],rgb:[Gt,[Bt,Bt,Bt],An],rgba:[Gt,[Bt,Bt,Bt,Bt],An],has:{type:Vt,overloads:[[[Ut],function(t,e){return Ln(e[0].evaluate(t),t.properties())}],[[Ut,jt],function(t,e){var n=e[1];return Ln(e[0].evaluate(t),n.evaluate(t))}]]},get:{type:Ht,overloads:[[[Ut],function(t,e){return Pn(e[0].evaluate(t),t.properties())}],[[Ut,jt],function(t,e){var n=e[1];return Pn(e[0].evaluate(t),n.evaluate(t))}]]},"feature-state":[Ht,[Ut],function(t,e){return Pn(e[0].evaluate(t),t.featureState||{})}],properties:[jt,[],function(t){return t.properties()}],"geometry-type":[Ut,[],function(t){return t.geometryType()}],id:[Ht,[],function(t){return t.id()}],zoom:[Bt,[],function(t){return t.globals.zoom}],"heatmap-density":[Bt,[],function(t){return t.globals.heatmapDensity||0}],"line-progress":[Bt,[],function(t){return t.globals.lineProgress||0}],accumulated:[Ht,[],function(t){return void 0===t.globals.accumulated?null:t.globals.accumulated}],"+":[Bt,Rn(Bt),function(t,e){for(var n=0,r=0,i=e;r":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i>o}],"filter-id->":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>i}],"filter-<=":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i<=o}],"filter-id-<=":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r<=i}],"filter->=":[Vt,[Ut,Ht],function(t,e){var n=e[0],r=e[1],i=t.properties()[n.value],o=r.value;return typeof i==typeof o&&i>=o}],"filter-id->=":[Vt,[Ht],function(t,e){var n=e[0],r=t.id(),i=n.value;return typeof r==typeof i&&r>=i}],"filter-has":[Vt,[Ht],function(t,e){return e[0].value in t.properties()}],"filter-has-id":[Vt,[],function(t){return null!==t.id()&&void 0!==t.id()}],"filter-type-in":[Vt,[Zt(Ut)],function(t,e){return e[0].value.indexOf(t.geometryType())>=0}],"filter-id-in":[Vt,[Zt(Ht)],function(t,e){return e[0].value.indexOf(t.id())>=0}],"filter-in-small":[Vt,[Ut,Zt(Ht)],function(t,e){var n=e[0];return e[1].value.indexOf(t.properties()[n.value])>=0}],"filter-in-large":[Vt,[Ut,Zt(Ht)],function(t,e){var n=e[0],r=e[1];return function(t,e,n,r){for(;n<=r;){var i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[n.value],r.value,0,r.value.length-1)}],all:{type:Vt,overloads:[[[Vt,Vt],function(t,e){var n=e[1];return e[0].evaluate(t)&&n.evaluate(t)}],[Rn(Vt),function(t,e){for(var n=0,r=e;n0&&"string"==typeof t[0]&&t[0]in In}function Zn(t,e){var n=new Ge(In,[],e?function(t){var e={color:Gt,string:Ut,number:Bt,enum:Ut,boolean:Vt,formatted:Wt,resolvedImage:Xt};return"array"===t.type?Zt(e[t.value]||Ht,t.length):e[t.type]}(e):void 0),r=n.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Dn(new Wn(r,e)):Nn(n.errors)}Wn.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)},Wn.prototype.evaluate=function(t,e,n,r,i,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null;try{var a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new he("Expected value to be one of "+Object.keys(this._enumValues).map((function(t){return JSON.stringify(t)})).join(", ")+", but found "+JSON.stringify(a)+" instead.");return a}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}};var Yn=function(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Be(e.expression)};Yn.prototype.evaluateWithoutErrorHandling=function(t,e,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,o)},Yn.prototype.evaluate=function(t,e,n,r,i,o){return this._styleExpression.evaluate(t,e,n,r,i,o)};var Jn=function(t,e,n,r){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Be(e.expression),this.interpolationType=r};function Kn(t,e){if("error"===(t=Zn(t,e)).result)return t;var n=t.value.expression,r=Fe(n);if(!r&&!On(e))return Nn([new kt("","data expressions not supported")]);var i=Ue(n,["zoom"]);if(!i&&!kn(e))return Nn([new kt("","zoom expressions not supported")]);var o=function t(e){var n=null;if(e instanceof cn)n=t(e.result);else if(e instanceof un)for(var r=0,i=e.args;rr.maximum?[new Pt(e,n,n+" is greater than the maximum value "+r.maximum)]:[]}function nr(t){var e,n,r,i=t.valueSpec,o=Nt(t.value.type),a={},s="categorical"!==o&&void 0===t.value.property,l=!s,u="array"===Fn(t.value.stops)&&"array"===Fn(t.value.stops[0])&&"object"===Fn(t.value.stops[0][0]),c=$n({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new Pt(t.key,t.value,'identity function may not have a "stops" property')];var e=[],n=t.value;return e=e.concat(tr({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Fn(n)&&0===n.length&&e.push(new Pt(t.key,n,"array must have at least one stop")),e},default:function(t){return Sr({key:t.key,value:t.value,valueSpec:i,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===o&&s&&c.push(new Pt(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||c.push(new Pt(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!zn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!On(t.valueSpec)?c.push(new Pt(t.key,t.value,"property functions not supported")):s&&!kn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!u||void 0!==t.value.property||c.push(new Pt(t.key,t.value,'"property" property is required')),c;function h(t){var e=[],o=t.value,s=t.key;if("array"!==Fn(o))return[new Pt(s,o,"array expected, "+Fn(o)+" found")];if(2!==o.length)return[new Pt(s,o,"array length 2 expected, length "+o.length+" found")];if(u){if("object"!==Fn(o[0]))return[new Pt(s,o,"object expected, "+Fn(o[0])+" found")];if(void 0===o[0].zoom)return[new Pt(s,o,"object stop key must have zoom")];if(void 0===o[0].value)return[new Pt(s,o,"object stop key must have value")];if(r&&r>Nt(o[0].zoom))return[new Pt(s,o[0].zoom,"stop zoom values must appear in ascending order")];Nt(o[0].zoom)!==r&&(r=Nt(o[0].zoom),n=void 0,a={}),e=e.concat($n({key:s+"[0]",value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:er,value:p}}))}else e=e.concat(p({key:s+"[0]",value:o[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},o));return Xn(Ot(o[1]))?e.concat([new Pt(s+"[1]",o[1],"expressions are not allowed in function stops.")]):e.concat(Sr({key:s+"[1]",value:o[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function p(t,r){var s=Fn(t.value),l=Nt(t.value),u=null!==t.value?t.value:r;if(e){if(s!==e)return[new Pt(t.key,u,s+" stop domain type must match previous stop domain type "+e)]}else e=s;if("number"!==s&&"string"!==s&&"boolean"!==s)return[new Pt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==o){var c="number expected, "+s+" found";return On(i)&&void 0===o&&(c+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Pt(t.key,u,c)]}return"categorical"!==o||"number"!==s||isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===s&&void 0!==n&&l=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(var e=0,n=t.slice(1);ee?1:0}function ur(t){if(!t)return!0;var e,n=t[0];return t.length<=1?"any"!==n:"=="===n?cr(t[1],t[2],"=="):"!="===n?fr(cr(t[1],t[2],"==")):"<"===n||">"===n||"<="===n||">="===n?cr(t[1],t[2],n):"any"===n?(e=t.slice(1),["any"].concat(e.map(ur))):"all"===n?["all"].concat(t.slice(1).map(ur)):"none"===n?["all"].concat(t.slice(1).map(ur).map(fr)):"in"===n?hr(t[1],t.slice(2)):"!in"===n?fr(hr(t[1],t.slice(2))):"has"===n?pr(t[1]):"!has"===n?fr(pr(t[1])):"within"!==n||t}function cr(t,e,n){switch(t){case"$type":return["filter-type-"+n,e];case"$id":return["filter-id-"+n,e];default:return["filter-"+n,t,e]}}function hr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((function(t){return typeof t!=typeof e[0]}))?["filter-in-large",t,["literal",e.sort(lr)]]:["filter-in-small",t,["literal",e]]}}function pr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function fr(t){return["!",t]}function dr(t){return or(Ot(t.value))?rr(Dt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):function t(e){var n=e.value,r=e.key;if("array"!==Fn(n))return[new Pt(r,n,"array expected, "+Fn(n)+" found")];var i,o=e.styleSpec,a=[];if(n.length<1)return[new Pt(r,n,"filter array must have at least 1 element")];switch(a=a.concat(ir({key:r+"[0]",value:n[0],valueSpec:o.filter_operator,style:e.style,styleSpec:e.styleSpec})),Nt(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===Nt(n[1])&&a.push(new Pt(r,n,'"$type" cannot be use with operator "'+n[0]+'"'));case"==":case"!=":3!==n.length&&a.push(new Pt(r,n,'filter array for operator "'+n[0]+'" must have 3 elements'));case"in":case"!in":n.length>=2&&"string"!==(i=Fn(n[1]))&&a.push(new Pt(r+"[1]",n[1],"string expected, "+i+" found"));for(var s=2;s=c[f+0]&&r>=c[f+1])?(a[p]=!0,o.push(u[p])):a[p]=!1}}},Or.prototype._forEachCell=function(t,e,n,r,i,o,a,s){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!s||s(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,n,r,d,o,a,s))return}},Or.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Or.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Or.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,n=0,r=0;r=0)){var c=t[u];l[u]=Fr[s].shallow.indexOf(u)>=0?c:jr(c,e)}t instanceof Error&&(l.message=t.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==s&&(l.$name=s),l}throw new Error("can't serialize object of type "+typeof t)}function Hr(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Vr(t)||Gr(t)||ArrayBuffer.isView(t)||t instanceof kr)return t;if(Array.isArray(t))return t.map(Hr);if("object"==typeof t){var e=t.$name||"Object",n=Fr[e].klass;if(!n)throw new Error("can't deserialize unregistered class "+e);if(n.deserialize)return n.deserialize(t);for(var r=Object.create(n.prototype),i=0,o=Object.keys(t);i=0?s:Hr(s)}}return r}throw new Error("can't deserialize object of type "+typeof t)}var qr=function(){this.first=!0};qr.prototype.update=function(t,e){var n=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=e):this.lastFloorZoom=128&&t<=255},Arabic:function(t){return t>=1536&&t<=1791},"Arabic Supplement":function(t){return t>=1872&&t<=1919},"Arabic Extended-A":function(t){return t>=2208&&t<=2303},"Hangul Jamo":function(t){return t>=4352&&t<=4607},"Unified Canadian Aboriginal Syllabics":function(t){return t>=5120&&t<=5759},Khmer:function(t){return t>=6016&&t<=6143},"Unified Canadian Aboriginal Syllabics Extended":function(t){return t>=6320&&t<=6399},"General Punctuation":function(t){return t>=8192&&t<=8303},"Letterlike Symbols":function(t){return t>=8448&&t<=8527},"Number Forms":function(t){return t>=8528&&t<=8591},"Miscellaneous Technical":function(t){return t>=8960&&t<=9215},"Control Pictures":function(t){return t>=9216&&t<=9279},"Optical Character Recognition":function(t){return t>=9280&&t<=9311},"Enclosed Alphanumerics":function(t){return t>=9312&&t<=9471},"Geometric Shapes":function(t){return t>=9632&&t<=9727},"Miscellaneous Symbols":function(t){return t>=9728&&t<=9983},"Miscellaneous Symbols and Arrows":function(t){return t>=11008&&t<=11263},"CJK Radicals Supplement":function(t){return t>=11904&&t<=12031},"Kangxi Radicals":function(t){return t>=12032&&t<=12255},"Ideographic Description Characters":function(t){return t>=12272&&t<=12287},"CJK Symbols and Punctuation":function(t){return t>=12288&&t<=12351},Hiragana:function(t){return t>=12352&&t<=12447},Katakana:function(t){return t>=12448&&t<=12543},Bopomofo:function(t){return t>=12544&&t<=12591},"Hangul Compatibility Jamo":function(t){return t>=12592&&t<=12687},Kanbun:function(t){return t>=12688&&t<=12703},"Bopomofo Extended":function(t){return t>=12704&&t<=12735},"CJK Strokes":function(t){return t>=12736&&t<=12783},"Katakana Phonetic Extensions":function(t){return t>=12784&&t<=12799},"Enclosed CJK Letters and Months":function(t){return t>=12800&&t<=13055},"CJK Compatibility":function(t){return t>=13056&&t<=13311},"CJK Unified Ideographs Extension A":function(t){return t>=13312&&t<=19903},"Yijing Hexagram Symbols":function(t){return t>=19904&&t<=19967},"CJK Unified Ideographs":function(t){return t>=19968&&t<=40959},"Yi Syllables":function(t){return t>=40960&&t<=42127},"Yi Radicals":function(t){return t>=42128&&t<=42191},"Hangul Jamo Extended-A":function(t){return t>=43360&&t<=43391},"Hangul Syllables":function(t){return t>=44032&&t<=55215},"Hangul Jamo Extended-B":function(t){return t>=55216&&t<=55295},"Private Use Area":function(t){return t>=57344&&t<=63743},"CJK Compatibility Ideographs":function(t){return t>=63744&&t<=64255},"Arabic Presentation Forms-A":function(t){return t>=64336&&t<=65023},"Vertical Forms":function(t){return t>=65040&&t<=65055},"CJK Compatibility Forms":function(t){return t>=65072&&t<=65103},"Small Form Variants":function(t){return t>=65104&&t<=65135},"Arabic Presentation Forms-B":function(t){return t>=65136&&t<=65279},"Halfwidth and Fullwidth Forms":function(t){return t>=65280&&t<=65519}};function Xr(t){for(var e=0,n=t;e=65097&&t<=65103)||Wr["CJK Compatibility Ideographs"](t)||Wr["CJK Compatibility"](t)||Wr["CJK Radicals Supplement"](t)||Wr["CJK Strokes"](t)||!(!Wr["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Wr["CJK Unified Ideographs Extension A"](t)||Wr["CJK Unified Ideographs"](t)||Wr["Enclosed CJK Letters and Months"](t)||Wr["Hangul Compatibility Jamo"](t)||Wr["Hangul Jamo Extended-A"](t)||Wr["Hangul Jamo Extended-B"](t)||Wr["Hangul Jamo"](t)||Wr["Hangul Syllables"](t)||Wr.Hiragana(t)||Wr["Ideographic Description Characters"](t)||Wr.Kanbun(t)||Wr["Kangxi Radicals"](t)||Wr["Katakana Phonetic Extensions"](t)||Wr.Katakana(t)&&12540!==t||!(!Wr["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Wr["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Wr["Unified Canadian Aboriginal Syllabics"](t)||Wr["Unified Canadian Aboriginal Syllabics Extended"](t)||Wr["Vertical Forms"](t)||Wr["Yijing Hexagram Symbols"](t)||Wr["Yi Syllables"](t)||Wr["Yi Radicals"](t))))}function Yr(t){return!(Zr(t)||function(t){return!!(Wr["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Wr["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Wr["Letterlike Symbols"](t)||Wr["Number Forms"](t)||Wr["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Wr["Control Pictures"](t)&&9251!==t||Wr["Optical Character Recognition"](t)||Wr["Enclosed Alphanumerics"](t)||Wr["Geometric Shapes"](t)||Wr["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Wr["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Wr["CJK Symbols and Punctuation"](t)||Wr.Katakana(t)||Wr["Private Use Area"](t)||Wr["CJK Compatibility Forms"](t)||Wr["Small Form Variants"](t)||Wr["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Jr(t){return t>=1424&&t<=2303||Wr["Arabic Presentation Forms-A"](t)||Wr["Arabic Presentation Forms-B"](t)}function Kr(t,e){return!(!e&&Jr(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Wr.Khmer(t))}function Qr(t){for(var e=0,n=t;e-1&&(ti="error"),$r&&$r(t)};function ri(){ii.fire(new Ct("pluginStateChange",{pluginStatus:ti,pluginURL:ei}))}var ii=new At,oi=function(){return ti},ai=function(){if("deferred"!==ti||!ei)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");ti="loading",ri(),ei&&bt({url:ei},(function(t){t?ni(t):(ti="loaded",ri())}))},si={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:function(){return"loaded"===ti||null!=si.applyArabicShaping},isLoading:function(){return"loading"===ti},setState:function(t){ti=t.pluginStatus,ei=t.pluginURL},isParsed:function(){return null!=si.applyArabicShaping&&null!=si.processBidirectionalText&&null!=si.processStyledBidirectionalText},getPluginURL:function(){return ei}},li=function(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new qr,this.transition={})};li.prototype.isSupportedScript=function(t){return function(t,e){for(var n=0,r=t;nthis.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*e}};var ui=function(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Bn(t))return new Qn(t,e);if(Xn(t)){var n=Kn(t,e);if("error"===n.result)throw new Error(n.value.map((function(t){return t.key+": "+t.message})).join(", "));return n.value}var r=t;return"string"==typeof t&&"color"===e.type&&(r=ee.parse(t)),{kind:"constant",evaluate:function(){return r}}}(void 0===e?t.specification.default:e,t.specification)};ui.prototype.isDataDriven=function(){return"source"===this.expression.kind||"composite"===this.expression.kind},ui.prototype.possiblyEvaluate=function(t,e,n){return this.property.possiblyEvaluate(this,t,e,n)};var ci=function(t){this.property=t,this.value=new ui(t,void 0)};ci.prototype.transitioned=function(t,e){return new pi(this.property,this.value,e,p({},t.transition,this.transition),t.now)},ci.prototype.untransitioned=function(){return new pi(this.property,this.value,null,{},0)};var hi=function(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)};hi.prototype.getValue=function(t){return b(this._values[t].value.value)},hi.prototype.setValue=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ci(this._values[t].property)),this._values[t].value=new ui(this._values[t].property,null===e?void 0:b(e))},hi.prototype.getTransition=function(t){return b(this._values[t].transition)},hi.prototype.setTransition=function(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ci(this._values[t].property)),this._values[t].transition=b(e)||void 0},hi.prototype.serialize=function(){for(var t={},e=0,n=Object.keys(this._values);ethis.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(r=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}(a))}return i};var fi=function(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)};fi.prototype.possiblyEvaluate=function(t,e,n){for(var r=new gi(this._properties),i=0,o=Object.keys(this._values);ir.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}},e.prototype.interpolate=function(t){return t},e}(vi),xi=function(t){this.specification=t};xi.prototype.possiblyEvaluate=function(t,e,n,r){if(void 0!==t.value){if("constant"===t.expression.kind){var i=t.expression.evaluate(e,null,{},n,r);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new li(Math.floor(e.zoom-1),e)),t.expression.evaluate(new li(Math.floor(e.zoom),e)),t.expression.evaluate(new li(Math.floor(e.zoom+1),e)),e)}},xi.prototype._calculate=function(t,e,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:n,to:e}},xi.prototype.interpolate=function(t){return t};var bi=function(t){this.specification=t};bi.prototype.possiblyEvaluate=function(t,e,n,r){return!!t.expression.evaluate(e,null,{},n,r)},bi.prototype.interpolate=function(){return!1};var wi=function(t){for(var e in this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],t){var n=t[e];n.specification.overridable&&this.overridableProperties.push(e);var r=this.defaultPropertyValues[e]=new ui(n,void 0),i=this.defaultTransitionablePropertyValues[e]=new ci(n);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}};Br("DataDrivenProperty",vi),Br("DataConstantProperty",yi),Br("CrossFadedDataDrivenProperty",_i),Br("CrossFadedProperty",xi),Br("ColorRampProperty",bi);var Ei=function(t){function e(e,n){if(t.call(this),this.id=e.id,this.type=e.type,this._featureFilter={filter:function(){return!0},needGeometry:!1},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),n.layout&&(this._unevaluatedLayout=new di(n.layout)),n.paint)){for(var r in this._transitionablePaint=new hi(n.paint),e.paint)this.setPaintProperty(r,e.paint[r],{validate:!1});for(var i in e.layout)this.setLayoutProperty(i,e.layout[i],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new gi(n.paint)}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getCrossfadeParameters=function(){return this._crossfadeParameters},e.prototype.getLayoutProperty=function(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)},e.prototype.setLayoutProperty=function(t,e,n){void 0===n&&(n={}),null!=e&&this._validate(Rr,"layers."+this.id+".layout."+t,t,e,n)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)},e.prototype.getPaintProperty=function(t){return v(t,"-transition")?this._transitionablePaint.getTransition(t.slice(0,-"-transition".length)):this._transitionablePaint.getValue(t)},e.prototype.setPaintProperty=function(t,e,n){if(void 0===n&&(n={}),null!=e&&this._validate(Pr,"layers."+this.id+".paint."+t,t,e,n))return!1;if(v(t,"-transition"))return this._transitionablePaint.setTransition(t.slice(0,-"-transition".length),e||void 0),!1;var r=this._transitionablePaint._values[t],i="cross-faded-data-driven"===r.property.specification["property-type"],o=r.value.isDataDriven(),a=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);var s=this._transitionablePaint._values[t].value;return s.isDataDriven()||o||i||this._handleOverridablePaintPropertyUpdate(t,a,s)},e.prototype._handleSpecialPaintPropertyUpdate=function(t){},e.prototype._handleOverridablePaintPropertyUpdate=function(t,e,n){return!1},e.prototype.isHidden=function(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility},e.prototype.updateTransitions=function(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)},e.prototype.hasTransition=function(){return this._transitioningPaint.hasTransition()},e.prototype.recalculate=function(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)},e.prototype.serialize=function(){var t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),x(t,(function(t,e){return!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)}))},e.prototype._validate=function(t,e,n,r,i){return void 0===i&&(i={}),(!i||!1!==i.validate)&&Dr(this,t.call(Ar,{key:e,layerType:this.type,objectKey:n,value:r,styleSpec:Lt,style:{glyphs:!0,sprite:!0}}))},e.prototype.is3D=function(){return!1},e.prototype.isTileClipped=function(){return!1},e.prototype.hasOffscreenPass=function(){return!1},e.prototype.resize=function(){},e.prototype.isStateDependent=function(){for(var t in this.paint._values){var e=this.paint.get(t);if(e instanceof mi&&On(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1},e}(At),Si={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},Mi=function(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8},Ti=function(){this.isTransferred=!1,this.capacity=-1,this.resize(0)};function Ci(t,e){void 0===e&&(e=1);var n=0,r=0;return{members:t.map((function(t){var i=Si[t.type].BYTES_PER_ELEMENT,o=n=Ii(n,Math.max(e,i)),a=t.components||1;return r=Math.max(r,i),n+=i*a,{name:t.name,type:t.type,components:a,offset:o}})),size:Ii(n,Math.max(r,e)),alignment:e}}function Ii(t,e){return Math.ceil(t/e)*e}Ti.serialize=function(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}},Ti.deserialize=function(t){var e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e},Ti.prototype._trim=function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())},Ti.prototype.clear=function(){this.length=0},Ti.prototype.resize=function(t){this.reserve(t),this.length=t},Ti.prototype.reserve=function(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}},Ti.prototype._refreshViews=function(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")};var Ai=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.int16[r+0]=e,this.int16[r+1]=n,t},e}(Ti);Ai.prototype.bytesPerElement=4,Br("StructArrayLayout2i4",Ai);var Li=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=4*t;return this.int16[o+0]=e,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,t},e}(Ti);Li.prototype.bytesPerElement=8,Br("StructArrayLayout4i8",Li);var Pi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,t},e}(Ti);Pi.prototype.bytesPerElement=12,Br("StructArrayLayout2i4i12",Pi);var Ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=4*t,l=8*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.uint8[l+4]=r,this.uint8[l+5]=i,this.uint8[l+6]=o,this.uint8[l+7]=a,t},e}(Ti);Ri.prototype.bytesPerElement=8,Br("StructArrayLayout2i4ub8",Ri);var Di=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.float32[r+0]=e,this.float32[r+1]=n,t},e}(Ti);Di.prototype.bytesPerElement=8,Br("StructArrayLayout2f8",Di);var Ni=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u){var c=this.length;return this.resize(c+1),this.emplace(c,t,e,n,r,i,o,a,s,l,u)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c){var h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=n,this.uint16[h+2]=r,this.uint16[h+3]=i,this.uint16[h+4]=o,this.uint16[h+5]=a,this.uint16[h+6]=s,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t},e}(Ti);Ni.prototype.bytesPerElement=20,Br("StructArrayLayout10ui20",Ni);var Oi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u,c,h){var p=this.length;return this.resize(p+1),this.emplace(p,t,e,n,r,i,o,a,s,l,u,c,h)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c,h,p){var f=12*t;return this.int16[f+0]=e,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t},e}(Ti);Oi.prototype.bytesPerElement=24,Br("StructArrayLayout4i4ui4i24",Oi);var ki=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.float32[i+0]=e,this.float32[i+1]=n,this.float32[i+2]=r,t},e}(Ti);ki.prototype.bytesPerElement=12,Br("StructArrayLayout3f12",ki);var zi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.uint32[1*t+0]=e,t},e}(Ti);zi.prototype.bytesPerElement=4,Br("StructArrayLayout1ul4",zi);var Fi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l){var u=this.length;return this.resize(u+1),this.emplace(u,t,e,n,r,i,o,a,s,l)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u){var c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=n,this.int16[c+2]=r,this.int16[c+3]=i,this.int16[c+4]=o,this.int16[c+5]=a,this.uint32[h+3]=s,this.uint16[c+8]=l,this.uint16[c+9]=u,t},e}(Ti);Fi.prototype.bytesPerElement=20,Br("StructArrayLayout6i1ul2ui20",Fi);var Bi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o){var a=this.length;return this.resize(a+1),this.emplace(a,t,e,n,r,i,o)},e.prototype.emplace=function(t,e,n,r,i,o,a){var s=6*t;return this.int16[s+0]=e,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,t},e}(Ti);Bi.prototype.bytesPerElement=12,Br("StructArrayLayout2i2i2i12",Bi);var Ui=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i){var o=this.length;return this.resize(o+1),this.emplace(o,t,e,n,r,i)},e.prototype.emplace=function(t,e,n,r,i,o){var a=4*t,s=8*t;return this.float32[a+0]=e,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,t},e}(Ti);Ui.prototype.bytesPerElement=16,Br("StructArrayLayout2f1f2i16",Ui);var Vi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=12*t,a=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,t},e}(Ti);Vi.prototype.bytesPerElement=12,Br("StructArrayLayout2ub2f12",Vi);var Gi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=n,this.uint16[i+2]=r,t},e}(Ti);Gi.prototype.bytesPerElement=6,Br("StructArrayLayout3ui6",Gi);var ji=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g){var y=this.length;return this.resize(y+1),this.emplace(y,t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y){var v=24*t,_=12*t,x=48*t;return this.int16[v+0]=e,this.int16[v+1]=n,this.uint16[v+2]=r,this.uint16[v+3]=i,this.uint32[_+2]=o,this.uint32[_+3]=a,this.uint32[_+4]=s,this.uint16[v+10]=l,this.uint16[v+11]=u,this.uint16[v+12]=c,this.float32[_+7]=h,this.float32[_+8]=p,this.uint8[x+36]=f,this.uint8[x+37]=d,this.uint8[x+38]=m,this.uint32[_+10]=g,this.int16[v+22]=y,t},e}(Ti);ji.prototype.bytesPerElement=48,Br("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ji);var Hi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,E,S,M,T,C){var I=this.length;return this.resize(I+1),this.emplace(I,t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,E,S,M,T,C)},e.prototype.emplace=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,E,S,M,T,C,I){var A=34*t,L=17*t;return this.int16[A+0]=e,this.int16[A+1]=n,this.int16[A+2]=r,this.int16[A+3]=i,this.int16[A+4]=o,this.int16[A+5]=a,this.int16[A+6]=s,this.int16[A+7]=l,this.uint16[A+8]=u,this.uint16[A+9]=c,this.uint16[A+10]=h,this.uint16[A+11]=p,this.uint16[A+12]=f,this.uint16[A+13]=d,this.uint16[A+14]=m,this.uint16[A+15]=g,this.uint16[A+16]=y,this.uint16[A+17]=v,this.uint16[A+18]=_,this.uint16[A+19]=x,this.uint16[A+20]=b,this.uint16[A+21]=w,this.uint16[A+22]=E,this.uint32[L+12]=S,this.float32[L+13]=M,this.float32[L+14]=T,this.float32[L+15]=C,this.float32[L+16]=I,t},e}(Ti);Hi.prototype.bytesPerElement=68,Br("StructArrayLayout8i15ui1ul4f68",Hi);var qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.float32[1*t+0]=e,t},e}(Ti);qi.prototype.bytesPerElement=4,Br("StructArrayLayout1f4",qi);var Wi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=3*t;return this.int16[i+0]=e,this.int16[i+1]=n,this.int16[i+2]=r,t},e}(Ti);Wi.prototype.bytesPerElement=6,Br("StructArrayLayout3i6",Wi);var Xi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n){var r=this.length;return this.resize(r+1),this.emplace(r,t,e,n)},e.prototype.emplace=function(t,e,n,r){var i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=n,this.uint16[i+3]=r,t},e}(Ti);Xi.prototype.bytesPerElement=8,Br("StructArrayLayout1ul2ui8",Xi);var Zi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e){var n=this.length;return this.resize(n+1),this.emplace(n,t,e)},e.prototype.emplace=function(t,e,n){var r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=n,t},e}(Ti);Zi.prototype.bytesPerElement=4,Br("StructArrayLayout2ui4",Zi);var Yi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t){var e=this.length;return this.resize(e+1),this.emplace(e,t)},e.prototype.emplace=function(t,e){return this.uint16[1*t+0]=e,t},e}(Ti);Yi.prototype.bytesPerElement=2,Br("StructArrayLayout1ui2",Yi);var Ji=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._refreshViews=function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)},e.prototype.emplaceBack=function(t,e,n,r){var i=this.length;return this.resize(i+1),this.emplace(i,t,e,n,r)},e.prototype.emplace=function(t,e,n,r,i){var o=4*t;return this.float32[o+0]=e,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,t},e}(Ti);Ji.prototype.bytesPerElement=16,Br("StructArrayLayout4f16",Ji);var Ki=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorPointX:{configurable:!0},anchorPointY:{configurable:!0},x1:{configurable:!0},y1:{configurable:!0},x2:{configurable:!0},y2:{configurable:!0},featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0},anchorPoint:{configurable:!0}};return n.anchorPointX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorPointY.get=function(){return this._structArray.int16[this._pos2+1]},n.x1.get=function(){return this._structArray.int16[this._pos2+2]},n.y1.get=function(){return this._structArray.int16[this._pos2+3]},n.x2.get=function(){return this._structArray.int16[this._pos2+4]},n.y2.get=function(){return this._structArray.int16[this._pos2+5]},n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+8]},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.anchorPoint.get=function(){return new i(this.anchorPointX,this.anchorPointY)},Object.defineProperties(e.prototype,n),e}(Mi);Ki.prototype.size=20;var Qi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new Ki(this,t)},e}(Fi);Br("CollisionBoxArray",Qi);var $i=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},glyphStartIndex:{configurable:!0},numGlyphs:{configurable:!0},vertexStartIndex:{configurable:!0},lineStartIndex:{configurable:!0},lineLength:{configurable:!0},segment:{configurable:!0},lowerSize:{configurable:!0},upperSize:{configurable:!0},lineOffsetX:{configurable:!0},lineOffsetY:{configurable:!0},writingMode:{configurable:!0},placedOrientation:{configurable:!0},hidden:{configurable:!0},crossTileID:{configurable:!0},associatedIconIndex:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.glyphStartIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.numGlyphs.get=function(){return this._structArray.uint16[this._pos2+3]},n.vertexStartIndex.get=function(){return this._structArray.uint32[this._pos4+2]},n.lineStartIndex.get=function(){return this._structArray.uint32[this._pos4+3]},n.lineLength.get=function(){return this._structArray.uint32[this._pos4+4]},n.segment.get=function(){return this._structArray.uint16[this._pos2+10]},n.lowerSize.get=function(){return this._structArray.uint16[this._pos2+11]},n.upperSize.get=function(){return this._structArray.uint16[this._pos2+12]},n.lineOffsetX.get=function(){return this._structArray.float32[this._pos4+7]},n.lineOffsetY.get=function(){return this._structArray.float32[this._pos4+8]},n.writingMode.get=function(){return this._structArray.uint8[this._pos1+36]},n.placedOrientation.get=function(){return this._structArray.uint8[this._pos1+37]},n.placedOrientation.set=function(t){this._structArray.uint8[this._pos1+37]=t},n.hidden.get=function(){return this._structArray.uint8[this._pos1+38]},n.hidden.set=function(t){this._structArray.uint8[this._pos1+38]=t},n.crossTileID.get=function(){return this._structArray.uint32[this._pos4+10]},n.crossTileID.set=function(t){this._structArray.uint32[this._pos4+10]=t},n.associatedIconIndex.get=function(){return this._structArray.int16[this._pos2+22]},Object.defineProperties(e.prototype,n),e}(Mi);$i.prototype.size=48;var to=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new $i(this,t)},e}(ji);Br("PlacedSymbolArray",to);var eo=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={anchorX:{configurable:!0},anchorY:{configurable:!0},rightJustifiedTextSymbolIndex:{configurable:!0},centerJustifiedTextSymbolIndex:{configurable:!0},leftJustifiedTextSymbolIndex:{configurable:!0},verticalPlacedTextSymbolIndex:{configurable:!0},placedIconSymbolIndex:{configurable:!0},verticalPlacedIconSymbolIndex:{configurable:!0},key:{configurable:!0},textBoxStartIndex:{configurable:!0},textBoxEndIndex:{configurable:!0},verticalTextBoxStartIndex:{configurable:!0},verticalTextBoxEndIndex:{configurable:!0},iconBoxStartIndex:{configurable:!0},iconBoxEndIndex:{configurable:!0},verticalIconBoxStartIndex:{configurable:!0},verticalIconBoxEndIndex:{configurable:!0},featureIndex:{configurable:!0},numHorizontalGlyphVertices:{configurable:!0},numVerticalGlyphVertices:{configurable:!0},numIconVertices:{configurable:!0},numVerticalIconVertices:{configurable:!0},useRuntimeCollisionCircles:{configurable:!0},crossTileID:{configurable:!0},textBoxScale:{configurable:!0},textOffset0:{configurable:!0},textOffset1:{configurable:!0},collisionCircleDiameter:{configurable:!0}};return n.anchorX.get=function(){return this._structArray.int16[this._pos2+0]},n.anchorY.get=function(){return this._structArray.int16[this._pos2+1]},n.rightJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+2]},n.centerJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+3]},n.leftJustifiedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+4]},n.verticalPlacedTextSymbolIndex.get=function(){return this._structArray.int16[this._pos2+5]},n.placedIconSymbolIndex.get=function(){return this._structArray.int16[this._pos2+6]},n.verticalPlacedIconSymbolIndex.get=function(){return this._structArray.int16[this._pos2+7]},n.key.get=function(){return this._structArray.uint16[this._pos2+8]},n.textBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+9]},n.textBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+10]},n.verticalTextBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+11]},n.verticalTextBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+12]},n.iconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+13]},n.iconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+14]},n.verticalIconBoxStartIndex.get=function(){return this._structArray.uint16[this._pos2+15]},n.verticalIconBoxEndIndex.get=function(){return this._structArray.uint16[this._pos2+16]},n.featureIndex.get=function(){return this._structArray.uint16[this._pos2+17]},n.numHorizontalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+18]},n.numVerticalGlyphVertices.get=function(){return this._structArray.uint16[this._pos2+19]},n.numIconVertices.get=function(){return this._structArray.uint16[this._pos2+20]},n.numVerticalIconVertices.get=function(){return this._structArray.uint16[this._pos2+21]},n.useRuntimeCollisionCircles.get=function(){return this._structArray.uint16[this._pos2+22]},n.crossTileID.get=function(){return this._structArray.uint32[this._pos4+12]},n.crossTileID.set=function(t){this._structArray.uint32[this._pos4+12]=t},n.textBoxScale.get=function(){return this._structArray.float32[this._pos4+13]},n.textOffset0.get=function(){return this._structArray.float32[this._pos4+14]},n.textOffset1.get=function(){return this._structArray.float32[this._pos4+15]},n.collisionCircleDiameter.get=function(){return this._structArray.float32[this._pos4+16]},Object.defineProperties(e.prototype,n),e}(Mi);eo.prototype.size=68;var no=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new eo(this,t)},e}(Hi);Br("SymbolInstanceArray",no);var ro=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getoffsetX=function(t){return this.float32[1*t+0]},e}(qi);Br("GlyphOffsetArray",ro);var io=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.getx=function(t){return this.int16[3*t+0]},e.prototype.gety=function(t){return this.int16[3*t+1]},e.prototype.gettileUnitDistanceFromAnchor=function(t){return this.int16[3*t+2]},e}(Wi);Br("SymbolLineVertexArray",io);var oo=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={featureIndex:{configurable:!0},sourceLayerIndex:{configurable:!0},bucketIndex:{configurable:!0}};return n.featureIndex.get=function(){return this._structArray.uint32[this._pos4+0]},n.sourceLayerIndex.get=function(){return this._structArray.uint16[this._pos2+2]},n.bucketIndex.get=function(){return this._structArray.uint16[this._pos2+3]},Object.defineProperties(e.prototype,n),e}(Mi);oo.prototype.size=8;var ao=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.get=function(t){return new oo(this,t)},e}(Xi);Br("FeatureIndexArray",ao);var so=Ci([{name:"a_pos",components:2,type:"Int16"}],4).members,lo=function(t){void 0===t&&(t=[]),this.segments=t};function uo(t,e){return 256*(t=c(Math.floor(t),0,255))+c(Math.floor(e),0,255)}lo.prototype.prepareSegment=function(t,e,n,r){var i=this.segments[this.segments.length-1];return t>lo.MAX_VERTEX_ARRAY_LENGTH&&E("Max vertices per segment is "+lo.MAX_VERTEX_ARRAY_LENGTH+": bucket requested "+t),(!i||i.vertexLength+t>lo.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:e.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i},lo.prototype.get=function(){return this.segments},lo.prototype.destroy=function(){for(var t=0,e=this.segments;t>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}})),po=e((function(t){t.exports=function(t,e){for(var n,r=t.length,i=e^r,o=0;r>=4;)n=1540483477*(65535&(n=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}})),fo=ho,mo=po;fo.murmur3=ho,fo.murmur2=mo;var go=function(){this.ids=[],this.positions=[],this.indexed=!1};go.prototype.add=function(t,e,n,r){this.ids.push(vo(t)),this.positions.push(e,n,r)},go.prototype.getPositions=function(t){for(var e=vo(t),n=0,r=this.ids.length-1;n>1;this.ids[i]>=e?r=i:n=i+1}for(var o=[];this.ids[n]===e;)o.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return o},go.serialize=function(t,e){var n=new Float64Array(t.ids),r=new Uint32Array(t.positions);return function t(e,n,r,i){for(;r>1],a=r-1,s=i+1;;){do{a++}while(e[a]o);if(a>=s)break;_o(e,a,s),_o(n,3*a,3*s),_o(n,3*a+1,3*s+1),_o(n,3*a+2,3*s+2)}s-ra.x+1||la.y+1)&&E("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return n}function Go(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Vo(t):[]}}function jo(t,e,n,r,i){t.emplaceBack(2*e+(r+1)/2,2*n+(i+1)/2)}var Ho=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ai,this.indexArray=new Gi,this.segments=new lo,this.programConfigurations=new ko(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function qo(t,e){for(var n=0;n1){if(Yo(t,e))return!0;for(var r=0;r1?n:n.sub(e)._mult(i)._add(e))}function $o(t,e){for(var n,r,i,o=!1,a=0;ae.y!=(i=n[l]).y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(o=!o);return o}function ta(t,e){for(var n=!1,r=0,i=t.length-1;re.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function ea(t,e,n){var r=n[0],i=n[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return!1;var o=S(t,e,n[0]);return o!==S(t,e,n[1])||o!==S(t,e,n[2])||o!==S(t,e,n[3])}function na(t,e,n){var r=e.paint.get(t).value;return"constant"===r.kind?r.value:n.programConfigurations.get(e.id).getMaxValue(t)}function ra(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ia(t,e,n,r,o){if(!e[0]&&!e[1])return t;var a=i.convert(e)._mult(o);"viewport"===n&&a._rotate(-r);for(var s=[],l=0;l=8192||c<0||c>=8192)){var h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),p=h.vertexLength;jo(this.layoutVertexArray,u,c,-1,-1),jo(this.layoutVertexArray,u,c,1,-1),jo(this.layoutVertexArray,u,c,1,1),jo(this.layoutVertexArray,u,c,-1,1),this.indexArray.emplaceBack(p,p+1,p+2),this.indexArray.emplaceBack(p,p+3,p+2),h.vertexLength+=4,h.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,{},r)},Br("CircleBucket",Ho,{omit:["layers"]});var oa=new wi({"circle-sort-key":new vi(Lt.layout_circle["circle-sort-key"])}),aa={paint:new wi({"circle-radius":new vi(Lt.paint_circle["circle-radius"]),"circle-color":new vi(Lt.paint_circle["circle-color"]),"circle-blur":new vi(Lt.paint_circle["circle-blur"]),"circle-opacity":new vi(Lt.paint_circle["circle-opacity"]),"circle-translate":new yi(Lt.paint_circle["circle-translate"]),"circle-translate-anchor":new yi(Lt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new yi(Lt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new yi(Lt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new vi(Lt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new vi(Lt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new vi(Lt.paint_circle["circle-stroke-opacity"])}),layout:oa},sa="undefined"!=typeof Float32Array?Float32Array:Array;function la(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ua(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],m=e[12],g=e[13],y=e[14],v=e[15],_=n[0],x=n[1],b=n[2],w=n[3];return t[0]=_*r+x*s+b*h+w*m,t[1]=_*i+x*l+b*p+w*g,t[2]=_*o+x*u+b*f+w*y,t[3]=_*a+x*c+b*d+w*v,t[4]=(_=n[4])*r+(x=n[5])*s+(b=n[6])*h+(w=n[7])*m,t[5]=_*i+x*l+b*p+w*g,t[6]=_*o+x*u+b*f+w*y,t[7]=_*a+x*c+b*d+w*v,t[8]=(_=n[8])*r+(x=n[9])*s+(b=n[10])*h+(w=n[11])*m,t[9]=_*i+x*l+b*p+w*g,t[10]=_*o+x*u+b*f+w*y,t[11]=_*a+x*c+b*d+w*v,t[12]=(_=n[12])*r+(x=n[13])*s+(b=n[14])*h+(w=n[15])*m,t[13]=_*i+x*l+b*p+w*g,t[14]=_*o+x*u+b*f+w*y,t[15]=_*a+x*c+b*d+w*v,t}Math.hypot||(Math.hypot=function(){for(var t=arguments,e=0,n=arguments.length;n--;)e+=t[n]*t[n];return Math.sqrt(e)});var ca,ha=ua;function pa(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}ca=new sa(3),sa!=Float32Array&&(ca[0]=0,ca[1]=0,ca[2]=0),function(){var t=new sa(4);sa!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var fa=(function(){var t=new sa(2);sa!=Float32Array&&(t[0]=0,t[1]=0)}(),function(t){function e(e){t.call(this,e,aa)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.createBucket=function(t){return new Ho(t)},e.prototype.queryRadius=function(t){var e=t;return na("circle-radius",this,e)+na("circle-stroke-width",this,e)+ra(this.paint.get("circle-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,i,o,a,s){for(var l=ia(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,a),u=this.paint.get("circle-radius").evaluate(e,n)+this.paint.get("circle-stroke-width").evaluate(e,n),c="map"===this.paint.get("circle-pitch-alignment"),h=c?l:function(t,e){return t.map((function(t){return da(t,e)}))}(l,s),p=c?u*a:u,f=0,d=r;ft.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=t.data,s=e.data,l=0;l80*n){r=o=t[0],i=a=t[1];for(var d=n;do&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?1/u:0}return Ra(p,f,n,r,i,u),f}function La(t,e,n,r,i){var o,a;if(i===ts(t,e,n,r)>0)for(o=e;o=e;o-=r)a=Ka(o,t[o],t[o+1],a);return a&&qa(a,a.next)&&(Qa(a),a=a.next),a}function Pa(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!qa(r,r.next)&&0!==Ha(r.prev,r,r.next))r=r.next;else{if(Qa(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Ra(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Ua(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,l,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,o?Na(t,r,i,o):Da(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Qa(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?Ra(t=Oa(Pa(t),e,n),e,n,r,i,o,2):2===a&&ka(t,e,n,r,i,o):Ra(Pa(t),e,n,r,i,o,1);break}}}function Da(t){var e=t.prev,n=t,r=t.next;if(Ha(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Ga(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Ha(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Na(t,e,n,r){var i=t.prev,o=t,a=t.next;if(Ha(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=Ua(i.x=u&&p&&p.z<=c;){if(h!==t.prev&&h!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&Ha(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==t.prev&&p!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Ha(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=u;){if(h!==t.prev&&h!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&Ha(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=c;){if(p!==t.prev&&p!==t.next&&Ga(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Ha(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Oa(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!qa(i,o)&&Wa(i,r,r.next,o)&&Ya(i,o)&&Ya(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Qa(r),Qa(r.next),r=t=o),r=r.next}while(r!==t);return Pa(r)}function ka(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&ja(a,s)){var l=Ja(a,s);return a=Pa(a,a.next),l=Pa(l,l.next),Ra(a,e,n,r,i,o),void Ra(l,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function za(t,e){return t.x-e.x}function Fa(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x=r.x&&r.x>=c&&i!==r.x&&Ga(on.x||r.x===n.x&&Ba(n,r)))&&(n=r,p=l)),r=r.next}while(r!==u);return n}(t,e)){var n=Ja(e,t);Pa(e,e.next),Pa(n,n.next)}}function Ba(t,e){return Ha(t.prev,t,e.prev)<0&&Ha(e.next,t,t.next)<0}function Ua(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Va(t){var e=t,n=t;do{(e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function ja(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Wa(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Ya(t,e)&&Ya(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Ha(t.prev,t,e.prev)||Ha(t,e.prev,e))||qa(t,e)&&Ha(t.prev,t,t.next)>0&&Ha(e.prev,e,e.next)>0)}function Ha(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qa(t,e){return t.x===e.x&&t.y===e.y}function Wa(t,e,n,r){var i=Za(Ha(t,e,n)),o=Za(Ha(t,e,r)),a=Za(Ha(n,r,t)),s=Za(Ha(n,r,e));return i!==o&&a!==s||!(0!==i||!Xa(t,n,e))||!(0!==o||!Xa(t,r,e))||!(0!==a||!Xa(n,t,r))||!(0!==s||!Xa(n,e,r))}function Xa(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Za(t){return t>0?1:t<0?-1:0}function Ya(t,e){return Ha(t.prev,t,t.next)<0?Ha(t,e,t.next)>=0&&Ha(t,t.prev,e)>=0:Ha(t,e,t.prev)<0||Ha(t,t.next,e)<0}function Ja(t,e){var n=new $a(t.i,t.x,t.y),r=new $a(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Ka(t,e,n,r){var i=new $a(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Qa(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function $a(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ts(t,e,n,r){for(var i=0,o=e,a=n-r;or;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-s*u/a+c)),Math.min(i,Math.floor(n+(a-s)*u/a+c)),o)}var h=e[n],p=r,f=i;for(ns(e,r,n),o(e[i],h)>0&&ns(e,r,i);p0;)f--}0===o(e[r],h)?ns(e,r,f):ns(e,++f,i),f<=n&&(r=f+1),n<=f&&(i=f-1)}}(t,e,n||0,r||t.length-1,i||rs)}function ns(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function rs(t,e){return te?1:0}function is(t,e){var n=t.length;if(n<=1)return[t];for(var r,i,o=[],a=0;a1)for(var l=0;l0&&n.holes.push(r+=t[i-1].length)}return n},Ca.default=Ia;var ls=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ai,this.indexArray=new Gi,this.indexArray2=new Zi,this.programConfigurations=new ko(t.layers,t.zoom),this.segments=new lo,this.segments2=new lo,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};ls.prototype.populate=function(t,e,n){this.hasPattern=as("fill",this.layers,e);for(var r=this.layers[0].layout.get("fill-sort-key"),i=!r.isConstant(),o=[],a=0,s=t;a>3}if(o--,1===r||2===r)a+=t.readSVarint(),s+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new i(a,s));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},ds.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;t.pos>3}if(r--,1===n||2===n)(i+=t.readSVarint())s&&(s=i),(o+=t.readSVarint())u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,u]},ds.prototype.toGeoJSON=function(t,e,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*t,s=this.extent*e,l=this.loadGeometry(),u=ds.types[this.type];function c(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}function xs(t,e,n){if(3===t){var r=new ys(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}vs.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 fs(this._pbf,e,this.extent,this._keys,this._values)};var bs={VectorTile:function(t,e){this.layers=t.readFields(xs,{},e)},VectorTileFeature:fs,VectorTileLayer:ys},ws=bs.VectorTileFeature.types,Es=Math.pow(2,13);function Ss(t,e,n,r,i,o,a,s){t.emplaceBack(e,n,2*Math.floor(r*Es)+a,i*Es*2,o*Es*2,Math.round(s))}var Ms=function(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(t){return t.id})),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Pi,this.indexArray=new Gi,this.programConfigurations=new ko(t.layers,t.zoom),this.segments=new lo,this.stateDependentLayerIds=this.layers.filter((function(t){return t.isStateDependent()})).map((function(t){return t.id}))};function Ts(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}Ms.prototype.populate=function(t,e,n){this.features=[],this.hasPattern=as("fill-extrusion",this.layers,e);for(var r=0,i=t;r8192}))||R.every((function(t){return t.y<0}))||R.every((function(t){return t.y>8192}))))for(var m=0,g=0;g=1){var v=d[g-1];if(!Ts(y,v)){h.vertexLength+4>lo.MAX_VERTEX_ARRAY_LENGTH&&(h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));var _=y.sub(v)._perp()._unit(),x=v.dist(y);m+x>32768&&(m=0),Ss(this.layoutVertexArray,y.x,y.y,_.x,_.y,0,0,m),Ss(this.layoutVertexArray,y.x,y.y,_.x,_.y,0,1,m),Ss(this.layoutVertexArray,v.x,v.y,_.x,_.y,0,0,m+=x),Ss(this.layoutVertexArray,v.x,v.y,_.x,_.y,0,1,m);var b=h.vertexLength;this.indexArray.emplaceBack(b,b+2,b+1),this.indexArray.emplaceBack(b+1,b+2,b+3),h.vertexLength+=4,h.primitiveLength+=2}}}}if(h.vertexLength+l>lo.MAX_VERTEX_ARRAY_LENGTH&&(h=this.segments.prepareSegment(l,this.layoutVertexArray,this.indexArray)),"Polygon"===ws[t.type]){for(var w=[],E=[],S=h.vertexLength,M=0,T=s;M=2&&t[l-1].equals(t[l-2]);)l--;for(var u=0;u0;if(E&&y>u){var M=c.dist(f);if(M>2*h){var T=c.sub(c.sub(f)._mult(h/M)._round());this.updateDistance(f,T),this.addCurrentVertex(T,m,0,0,p),f=T}}var C=f&&d,I=C?n:s?"butt":r;if(C&&"round"===I&&(bi&&(I="bevel"),"bevel"===I&&(b>2&&(I="flipbevel"),b100)v=g.mult(-1);else{var A=b*m.add(g).mag()/m.sub(g).mag();v._perp()._mult(A*(S?-1:1))}this.addCurrentVertex(c,v,0,0,p),this.addCurrentVertex(c,v.mult(-1),0,0,p)}else if("bevel"===I||"fakeround"===I){var L=-Math.sqrt(b*b-1),P=S?L:0,R=S?0:L;if(f&&this.addCurrentVertex(c,m,P,R,p),"fakeround"===I)for(var D=Math.round(180*w/Math.PI/20),N=1;N2*h){var U=c.add(d.sub(c)._mult(h/B)._round());this.updateDistance(c,U),this.addCurrentVertex(U,g,0,0,p),c=U}}}}},ks.prototype.addCurrentVertex=function(t,e,n,r,i,o){void 0===o&&(o=!1);var a=e.y*r-e.x,s=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*n,e.y-e.x*n,o,!1,n,i),this.addHalfVertex(t,a,s,o,!0,-r,i),this.distance>Os/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,n,r,i,o))},ks.prototype.addHalfVertex=function(t,e,n,r,i,o,a){var s=.5*(this.lineClips?this.scaledDistance*(Os-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t.x<<1)+(r?1:0),(t.y<<1)+(i?1:0),Math.round(63*e)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1)|(63&s)<<2,s>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);var l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),i?this.e2=l:this.e1=l},ks.prototype.updateScaledDistance=function(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance},ks.prototype.updateDistance=function(t,e){this.distance+=t.dist(e),this.updateScaledDistance()},Br("LineBucket",ks,{omit:["layers","patternFeatures"]});var zs=new wi({"line-cap":new yi(Lt.layout_line["line-cap"]),"line-join":new vi(Lt.layout_line["line-join"]),"line-miter-limit":new yi(Lt.layout_line["line-miter-limit"]),"line-round-limit":new yi(Lt.layout_line["line-round-limit"]),"line-sort-key":new vi(Lt.layout_line["line-sort-key"])}),Fs={paint:new wi({"line-opacity":new vi(Lt.paint_line["line-opacity"]),"line-color":new vi(Lt.paint_line["line-color"]),"line-translate":new yi(Lt.paint_line["line-translate"]),"line-translate-anchor":new yi(Lt.paint_line["line-translate-anchor"]),"line-width":new vi(Lt.paint_line["line-width"]),"line-gap-width":new vi(Lt.paint_line["line-gap-width"]),"line-offset":new vi(Lt.paint_line["line-offset"]),"line-blur":new vi(Lt.paint_line["line-blur"]),"line-dasharray":new xi(Lt.paint_line["line-dasharray"]),"line-pattern":new _i(Lt.paint_line["line-pattern"]),"line-gradient":new bi(Lt.paint_line["line-gradient"])}),layout:zs},Bs=new(function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.possiblyEvaluate=function(e,n){return n=new li(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),t.prototype.possiblyEvaluate.call(this,e,n)},e.prototype.evaluate=function(e,n,r,i){return n=p({},n,{zoom:Math.floor(n.zoom)}),t.prototype.evaluate.call(this,e,n,r,i)},e}(vi))(Fs.paint.properties["line-width"].specification);Bs.useIntegerZoom=!0;var Us=function(t){function e(e){t.call(this,e,Fs),this.gradientVersion=0}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype._handleSpecialPaintPropertyUpdate=function(t){"line-gradient"===t&&(this.stepInterpolant=this._transitionablePaint._values["line-gradient"].value.expression._styleExpression.expression instanceof He,this.gradientVersion=(this.gradientVersion+1)%s)},e.prototype.gradientExpression=function(){return this._transitionablePaint._values["line-gradient"].value.expression},e.prototype.recalculate=function(e,n){t.prototype.recalculate.call(this,e,n),this.paint._values["line-floorwidth"]=Bs.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)},e.prototype.createBucket=function(t){return new ks(t)},e.prototype.queryRadius=function(t){var e=t,n=Vs(na("line-width",this,e),na("line-gap-width",this,e)),r=na("line-offset",this,e);return n/2+Math.abs(r)+ra(this.paint.get("line-translate"))},e.prototype.queryIntersectsFeature=function(t,e,n,r,o,a,s){var l=ia(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,s),u=s/2*Vs(this.paint.get("line-width").evaluate(e,n),this.paint.get("line-gap-width").evaluate(e,n)),c=this.paint.get("line-offset").evaluate(e,n);return c&&(r=function(t,e){for(var n=[],r=new i(0,0),o=0;o=3)for(var o=0;o0?e+2*t:t}var Gs=Ci([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),js=Ci([{name:"a_projected_pos",components:3,type:"Float32"}],4),Hs=(Ci([{name:"a_fade_opacity",components:1,type:"Uint32"}],4),Ci([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}])),qs=(Ci([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]),Ci([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4)),Ws=Ci([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Xs(t,e,n){return t.sections.forEach((function(t){t.text=function(t,e,n){var r=e.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),si.applyArabicShaping&&(t=si.applyArabicShaping(t)),t}(t.text,e,n)})),t}Ci([{name:"triangle",components:3,type:"Uint16"}]),Ci([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Ci([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ci([{type:"Float32",name:"offsetX"}]),Ci([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Zs={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Ys=function(t,e,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,c=-7,h=n?i-1:0,p=n?-1:1,f=t[e+h];for(h+=p,o=f&(1<<-c)-1,f>>=-c,c+=s;c>0;o=256*o+t[e+h],h+=p,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=u}return(f?-1:1)*a*Math.pow(2,o-r)},Js=function(t,e,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,d=r?1:-1,m=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=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(e*l-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[n+f]=255&s,f+=d,s/=256,i-=8);for(a=a<0;t[n+f]=255&a,f+=d,a/=256,u-=8);t[n+f-d]|=128*m},Ks=Qs;function Qs(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Qs.Varint=0,Qs.Fixed64=1,Qs.Bytes=2,Qs.Fixed32=5;var $s="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function tl(t){return t.type===Qs.Bytes?t.readVarint()+t.pos:t.pos+1}function el(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function nl(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function rl(t,e){for(var n=0;n>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function dl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function ml(t,e,n){1===t&&n.readMessage(gl,e)}function gl(t,e,n){if(3===t){var r=n.readMessage(yl,{}),i=r.width,o=r.height,a=r.left,s=r.top,l=r.advance;e.push({id:r.id,bitmap:new _a({width:i+6,height:o+6},r.bitmap),metrics:{width:i,height:o,left:a,top:s,advance:l}})}}function yl(t,e,n){1===t?e.id=n.readVarint():2===t?e.bitmap=n.readBytes():3===t?e.width=n.readVarint():4===t?e.height=n.readVarint():5===t?e.left=n.readSVarint():6===t?e.top=n.readSVarint():7===t&&(e.advance=n.readVarint())}function vl(t){for(var e=0,n=0,r=0,i=t;r=0;p--){var f=a[p];if(!(h.w>f.w||h.h>f.h)){if(h.x=f.x,h.y=f.y,l=Math.max(l,h.y+h.h),s=Math.max(s,h.x+h.w),h.w===f.w&&h.h===f.h){var d=a.pop();p>3,o=this.pos;this.type=7&r,t(i,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=pl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=dl(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=pl(this.buf,this.pos)+4294967296*pl(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=pl(this.buf,this.pos)+4294967296*dl(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=Ys(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Ys(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return el(t,r,e);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return el(t,r,e);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return el(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[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,n){return $s.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){for(var r="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(o=t[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(o=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],s=t[i+3],128==(192&(o=t[i+1]))&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(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!==Qs.Bytes)return t.push(this.readVarint(e));var n=tl(this);for(t=t||[];this.pos127;);else if(e===Qs.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Qs.Fixed32)this.pos+=4;else{if(e!==Qs.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;e268435455||t<0?function(t,e){var n,r;if(t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,n.buf[n.pos]=127&(t>>>=7)}(n,0,e),function(t,e){var n=(7&t)<<4;e.buf[e.pos++]|=n|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,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,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&nl(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),Js(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Js(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 n=0;n=128&&nl(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,Qs.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,rl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,il,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,sl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ol,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,al,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ll,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,ul,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,cl,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,hl,e)},writeBytesField:function(t,e){this.writeTag(t,Qs.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Qs.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Qs.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Qs.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Qs.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Qs.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var _l=function(t,e){var n=e.pixelRatio,r=e.version,i=e.stretchX,o=e.stretchY,a=e.content;this.paddedRect=t,this.pixelRatio=n,this.stretchX=i,this.stretchY=o,this.content=a,this.version=r},xl={tl:{configurable:!0},br:{configurable:!0},tlbr:{configurable:!0},displaySize:{configurable:!0}};xl.tl.get=function(){return[this.paddedRect.x+1,this.paddedRect.y+1]},xl.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]},xl.tlbr.get=function(){return this.tl.concat(this.br)},xl.displaySize.get=function(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]},Object.defineProperties(_l.prototype,xl);var bl=function(t,e){var n={},r={};this.haveRenderCallbacks=[];var i=[];this.addImages(t,n,i),this.addImages(e,r,i);var o=vl(i),a=new xa({width:o.w||1,height:o.h||1});for(var s in t){var l=t[s],u=n[s].paddedRect;xa.copy(l.data,a,{x:0,y:0},{x:u.x+1,y:u.y+1},l.data)}for(var c in e){var h=e[c],p=r[c].paddedRect,f=p.x+1,d=p.y+1,m=h.data.width,g=h.data.height;xa.copy(h.data,a,{x:0,y:0},{x:f,y:d},h.data),xa.copy(h.data,a,{x:0,y:g-1},{x:f,y:d-1},{width:m,height:1}),xa.copy(h.data,a,{x:0,y:0},{x:f,y:d+g},{width:m,height:1}),xa.copy(h.data,a,{x:m-1,y:0},{x:f-1,y:d},{width:1,height:g}),xa.copy(h.data,a,{x:0,y:0},{x:f+m,y:d},{width:1,height:g})}this.image=a,this.iconPositions=n,this.patternPositions=r};bl.prototype.addImages=function(t,e,n){for(var r in t){var i=t[r],o={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(o),e[r]=new _l(o,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}},bl.prototype.patchUpdatedImages=function(t,e){for(var n in t.dispatchRenderCallbacks(this.haveRenderCallbacks),t.updatedImages)this.patchUpdatedImage(this.iconPositions[n],t.getImage(n),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n),e)},bl.prototype.patchUpdatedImage=function(t,e,n){if(t&&e&&t.version!==e.version){t.version=e.version;var r=t.tl;n.update(e.data,void 0,{x:r[0],y:r[1]})}},Br("ImagePosition",_l),Br("ImageAtlas",bl);var wl={horizontal:1,vertical:2,horizontalOnly:3},El=function(){this.scale=1,this.fontStack="",this.imageName=null};El.forText=function(t,e){var n=new El;return n.scale=t||1,n.fontStack=e,n},El.forImage=function(t){var e=new El;return e.imageName=t,e};var Sl=function(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null};function Ml(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m){var g,y=Sl.fromFeature(t,i);h===wl.vertical&&y.verticalizePunctuation();var v=si.processBidirectionalText,_=si.processStyledBidirectionalText;if(v&&1===y.sections.length){g=[];for(var x=0,b=v(y.toString(),Rl(y,u,o,e,r,f,d));x0&&F>M&&(M=F)}else{var B=n[C.fontStack],U=B&&B[A];if(U&&U.rect)R=U.rect,P=U.metrics;else{var V=e[C.fontStack],G=V&&V[A];if(!G)continue;P=G.metrics}L=24*(b-C.scale)}O?(t.verticalizable=!0,S.push({glyph:A,imageName:D,x:p,y:f+L,vertical:O,scale:C.scale,fontStack:C.fontStack,sectionIndex:I,metrics:P,rect:R}),p+=N*C.scale+u):(S.push({glyph:A,imageName:D,x:p,y:f+L,vertical:O,scale:C.scale,fontStack:C.fontStack,sectionIndex:I,metrics:P,rect:R}),p+=P.advance*C.scale+u)}0!==S.length&&(d=Math.max(p-u,d),Nl(S,0,S.length-1,g,M)),p=0;var j=o*b+M;E.lineOffset=Math.max(M,w),f+=j,m=Math.max(j,m),++y}else f+=o,++y}var H,q=f- -17,W=Dl(a),X=W.horizontalAlign,Z=W.verticalAlign;(function(t,e,n,r,i,o,a,s,l){var u,c=(e-n)*i;u=o!==a?-s*r- -17:(-r*l+.5)*a;for(var h=0,p=t;h=0&&r>=t&&Tl[this.text.charCodeAt(r)];r--)n--;this.text=this.text.substring(t,n),this.sectionIndex=this.sectionIndex.slice(t,n)},Sl.prototype.substring=function(t,e){var n=new Sl;return n.text=this.text.substring(t,e),n.sectionIndex=this.sectionIndex.slice(t,e),n.sections=this.sections,n},Sl.prototype.toString=function(){return this.text},Sl.prototype.getMaxScale=function(){var t=this;return this.sectionIndex.reduce((function(e,n){return Math.max(e,t.sections[n].scale)}),0)},Sl.prototype.addTextSection=function(t,e){this.text+=t.text,this.sections.push(El.forText(t.scale,t.fontStack||e));for(var n=this.sections.length-1,r=0;r=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)};var Tl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Cl={};function Il(t,e,n,r,i,o){if(e.imageName){var a=r[e.imageName];return a?a.displaySize[0]*e.scale*24/o+i:0}var s=n[e.fontStack],l=s&&s[t];return l?l.metrics.advance*e.scale+i:0}function Al(t,e,n,r){var i=Math.pow(t-e,2);return r?t=0,h=0,p=0;p-n/2;){if(--a<0)return!1;s-=t[a].dist(o),o=t[a]}s+=t[a].dist(t[a+1]),a++;for(var l=[],u=0;sr;)u-=l.shift().angleDelta;if(u>i)return!1;a++,s+=c.dist(h)}return!0}function Gl(t){for(var e=0,n=0;nu){var d=(u-l)/f,m=qe(h.x,p.x,d),g=qe(h.y,p.y,d),y=new kl(m,g,p.angleTo(h),c);return y._round(),!a||Vl(t,y,s,a,e)?y:void 0}l+=f}}function Wl(t,e,n,r,i,o,a,s,l){var u=jl(r,o,a),c=Hl(r,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&b=0&&w=0&&f+c<=h){var E=new kl(b,w,_,m);E._round(),i&&!Vl(e,E,a,i,o)||d.push(E)}}p+=v}return l||d.length||s||(d=t(e,p/2,r,i,o,a,s,!0,u)),d}(t,p?e/2*s%e:(c/2+2*o)*a*s%e,e,u,n,h,p,!1,l)}function Xl(t,e,n,r,o){for(var a=[],s=0;s=r&&p.x>=r||(h.x>=r?h=new i(r,h.y+(r-h.x)/(p.x-h.x)*(p.y-h.y))._round():p.x>=r&&(p=new i(r,h.y+(r-h.x)/(p.x-h.x)*(p.y-h.y))._round()),h.y>=o&&p.y>=o||(h.y>=o?h=new i(h.x+(o-h.y)/(p.y-h.y)*(p.x-h.x),o)._round():p.y>=o&&(p=new i(h.x+(o-h.y)/(p.y-h.y)*(p.x-h.x),o)._round()),u&&h.equals(u[u.length-1])||a.push(u=[h]),u.push(p)))))}return a}function Zl(t,e,n,r){var o=[],a=t.image,s=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=t.right-t.left,h=t.bottom-t.top,p=a.stretchX||[[0,l]],f=a.stretchY||[[0,u]],d=function(t,e){return t+e[1]-e[0]},m=p.reduce(d,0),g=f.reduce(d,0),y=l-m,v=u-g,_=0,x=m,b=0,w=g,E=0,S=y,M=0,T=v;if(a.content&&r){var C=a.content;_=Yl(p,0,C[0]),b=Yl(f,0,C[1]),x=Yl(p,C[0],C[2]),w=Yl(f,C[1],C[3]),E=C[0]-_,M=C[1]-b,S=C[2]-C[0]-x,T=C[3]-C[1]-w}var I=function(r,o,l,u){var p=Kl(r.stretch-_,x,c,t.left),f=Ql(r.fixed-E,S,r.stretch,m),d=Kl(o.stretch-b,w,h,t.top),y=Ql(o.fixed-M,T,o.stretch,g),v=Kl(l.stretch-_,x,c,t.left),C=Ql(l.fixed-E,S,l.stretch,m),I=Kl(u.stretch-b,w,h,t.top),A=Ql(u.fixed-M,T,u.stretch,g),L=new i(p,d),P=new i(v,d),R=new i(v,I),D=new i(p,I),N=new i(f/s,y/s),O=new i(C/s,A/s),k=e*Math.PI/180;if(k){var z=Math.sin(k),F=Math.cos(k),B=[F,-z,z,F];L._matMult(B),P._matMult(B),D._matMult(B),R._matMult(B)}var U=r.stretch+r.fixed,V=o.stretch+o.fixed;return{tl:L,tr:P,bl:D,br:R,tex:{x:a.paddedRect.x+1+U,y:a.paddedRect.y+1+V,w:l.stretch+l.fixed-U,h:u.stretch+u.fixed-V},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:O,minFontScaleX:S/s/c,minFontScaleY:T/s/h,isSDF:n}};if(r&&(a.stretchX||a.stretchY))for(var A=Jl(p,y,m),L=Jl(f,v,g),P=0;P0&&(d=Math.max(10,d),this.circleDiameter=d)}else{var m=a.top*s-l,g=a.bottom*s+l,y=a.left*s-l,v=a.right*s+l,_=a.collisionPadding;if(_&&(y-=_[0]*s,m-=_[1]*s,v+=_[2]*s,g+=_[3]*s),c){var x=new i(y,m),b=new i(v,m),w=new i(y,g),E=new i(v,g),S=c*Math.PI/180;x._rotate(S),b._rotate(S),w._rotate(S),E._rotate(S),y=Math.min(x.x,b.x,w.x,E.x),v=Math.max(x.x,b.x,w.x,E.x),m=Math.min(x.y,b.y,w.y,E.y),g=Math.max(x.y,b.y,w.y,E.y)}t.emplaceBack(e.x,e.y,y,m,v,g,n,r,o)}this.boxEndIndex=t.length},tu=function(t,e){if(void 0===t&&(t=[]),void 0===e&&(e=eu),this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)};function eu(t,e){return te?1:0}function nu(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=1/0,o=1/0,a=-1/0,s=-1/0,l=t[0],u=0;ua)&&(a=c.x),(!u||c.y>s)&&(s=c.y)}var h=Math.min(a-r,s-o),p=h/2,f=new tu([],ru);if(0===h)return new i(r,o);for(var d=r;dg.d||!g.d)&&(g=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,y)),v.max-g.d<=e||(f.push(new iu(v.p.x-(p=v.h/2),v.p.y-p,p,t)),f.push(new iu(v.p.x+p,v.p.y-p,p,t)),f.push(new iu(v.p.x-p,v.p.y+p,p,t)),f.push(new iu(v.p.x+p,v.p.y+p,p,t)),y+=4)}return n&&(console.log("num probes: "+y),console.log("best distance: "+g.d)),g.p}function ru(t,e){return e.max-t.max}function iu(t,e,n,r){this.p=new i(t,e),this.h=n,this.d=function(t,e){for(var n=!1,r=1/0,i=0;it.y!=c.y>t.y&&t.x<(c.x-u.x)*(t.y-u.y)/(c.y-u.y)+u.x&&(n=!n),r=Math.min(r,Qo(t,u,c))}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}tu.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},tu.prototype.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},tu.prototype.peek=function(){return this.data[0]},tu.prototype._up=function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r},tu.prototype._down=function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=a,t=o}e[t]=i};var ou=Number.POSITIVE_INFINITY;function au(t,e){return e[1]!==ou?function(t,e,n){var r=0,i=0;switch(e=Math.abs(e),n=Math.abs(n),t){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,i]}(t,e[0],e[1]):function(t,e){var n=0,r=0;e<0&&(e=0);var i=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=e;break;case"right":n=-e}return[n,r]}(t,e[0])}function su(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lu(t,e,n,r,o,a,s,l,u,c,h,p,f,d,m){var g=function(t,e,n,r,o,a,s,l){for(var u=r.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=[],h=0,p=e.positionedLines;h32640&&E(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".'):"composite"===y.kind&&((v=[128*d.compositeTextSizes[0].evaluate(s,{},m),128*d.compositeTextSizes[1].evaluate(s,{},m)])[0]>32640||v[1]>32640)&&E(t.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".'),t.addSymbols(t.text,g,v,l,a,s,c,e,u.lineStartIndex,u.lineLength,f,m);for(var _=0,x=h;_=0;a--)if(r.dist(o[a])0)&&("constant"!==o.value.kind||o.value.value.length>0),u="constant"!==s.value.kind||!!s.value.value||Object.keys(s.parameters).length>0,c=i.get("symbol-sort-key");if(this.features=[],l||u){for(var h=e.iconDependencies,p=e.glyphDependencies,f=e.availableImages,d=new li(this.zoom),m=0,g=t;m=0;for(var R=0,D=S.sections;R=0;s--)o[s]={x:e[s].x,y:e[s].y,tileUnitDistanceFromAnchor:i},s>0&&(i+=e[s-1].dist(e[s]));for(var l=0;l0},vu.prototype.hasIconData=function(){return this.icon.segments.get().length>0},vu.prototype.hasDebugData=function(){return this.textCollisionBox&&this.iconCollisionBox},vu.prototype.hasTextCollisionBoxData=function(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0},vu.prototype.hasIconCollisionBoxData=function(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0},vu.prototype.addIndicesForPlacedSymbol=function(t,e){for(var n=t.placedSymbolArray.get(e),r=n.vertexStartIndex+4*n.numGlyphs,i=n.vertexStartIndex;i1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(var n=0,r=this.symbolInstanceIndexes;n=0&&r.indexOf(t)===n&&e.addIndicesForPlacedSymbol(e.text,t)})),i.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,i.verticalPlacedTextSymbolIndex),i.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.placedIconSymbolIndex),i.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,i.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}},Br("SymbolBucket",vu,{omit:["layers","collisionBoxArray","features","compareText"]}),vu.MAX_GLYPHS=65535,vu.addDynamicAttributes=du;var _u=new wi({"symbol-placement":new yi(Lt.layout_symbol["symbol-placement"]),"symbol-spacing":new yi(Lt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new yi(Lt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new vi(Lt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new yi(Lt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new yi(Lt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new yi(Lt.layout_symbol["icon-ignore-placement"]),"icon-optional":new yi(Lt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new yi(Lt.layout_symbol["icon-rotation-alignment"]),"icon-size":new vi(Lt.layout_symbol["icon-size"]),"icon-text-fit":new yi(Lt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new yi(Lt.layout_symbol["icon-text-fit-padding"]),"icon-image":new vi(Lt.layout_symbol["icon-image"]),"icon-rotate":new vi(Lt.layout_symbol["icon-rotate"]),"icon-padding":new yi(Lt.layout_symbol["icon-padding"]),"icon-keep-upright":new yi(Lt.layout_symbol["icon-keep-upright"]),"icon-offset":new vi(Lt.layout_symbol["icon-offset"]),"icon-anchor":new vi(Lt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new yi(Lt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new yi(Lt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new yi(Lt.layout_symbol["text-rotation-alignment"]),"text-field":new vi(Lt.layout_symbol["text-field"]),"text-font":new vi(Lt.layout_symbol["text-font"]),"text-size":new vi(Lt.layout_symbol["text-size"]),"text-max-width":new vi(Lt.layout_symbol["text-max-width"]),"text-line-height":new yi(Lt.layout_symbol["text-line-height"]),"text-letter-spacing":new vi(Lt.layout_symbol["text-letter-spacing"]),"text-justify":new vi(Lt.layout_symbol["text-justify"]),"text-radial-offset":new vi(Lt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new yi(Lt.layout_symbol["text-variable-anchor"]),"text-anchor":new vi(Lt.layout_symbol["text-anchor"]),"text-max-angle":new yi(Lt.layout_symbol["text-max-angle"]),"text-writing-mode":new yi(Lt.layout_symbol["text-writing-mode"]),"text-rotate":new vi(Lt.layout_symbol["text-rotate"]),"text-padding":new yi(Lt.layout_symbol["text-padding"]),"text-keep-upright":new yi(Lt.layout_symbol["text-keep-upright"]),"text-transform":new vi(Lt.layout_symbol["text-transform"]),"text-offset":new vi(Lt.layout_symbol["text-offset"]),"text-allow-overlap":new yi(Lt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new yi(Lt.layout_symbol["text-ignore-placement"]),"text-optional":new yi(Lt.layout_symbol["text-optional"])}),xu={paint:new wi({"icon-opacity":new vi(Lt.paint_symbol["icon-opacity"]),"icon-color":new vi(Lt.paint_symbol["icon-color"]),"icon-halo-color":new vi(Lt.paint_symbol["icon-halo-color"]),"icon-halo-width":new vi(Lt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new vi(Lt.paint_symbol["icon-halo-blur"]),"icon-translate":new yi(Lt.paint_symbol["icon-translate"]),"icon-translate-anchor":new yi(Lt.paint_symbol["icon-translate-anchor"]),"text-opacity":new vi(Lt.paint_symbol["text-opacity"]),"text-color":new vi(Lt.paint_symbol["text-color"],{runtimeType:Gt,getOverride:function(t){return t.textColor},hasOverride:function(t){return!!t.textColor}}),"text-halo-color":new vi(Lt.paint_symbol["text-halo-color"]),"text-halo-width":new vi(Lt.paint_symbol["text-halo-width"]),"text-halo-blur":new vi(Lt.paint_symbol["text-halo-blur"]),"text-translate":new yi(Lt.paint_symbol["text-translate"]),"text-translate-anchor":new yi(Lt.paint_symbol["text-translate-anchor"])}),layout:_u},bu=function(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Ft,this.defaultValue=t};bu.prototype.evaluate=function(t){if(t.formattedSection){var e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default},bu.prototype.eachChild=function(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)},bu.prototype.outputDefined=function(){return!1},bu.prototype.serialize=function(){return null},Br("FormatSectionOverride",bu,{omit:["defaultValue"]});var wu=function(t){function e(e){t.call(this,e,xu)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.recalculate=function(e,n){if(t.prototype.recalculate.call(this,e,n),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){var r=this.layout.get("text-writing-mode");if(r){for(var i=[],o=0,a=r;o",targetMapId:r,sourceMapId:o.mapId})}}},ku.prototype.receive=function(t){var e=t.data,n=e.id;if(n&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[n];var r=this.cancelCallbacks[n];delete this.cancelCallbacks[n],r&&r()}else T()||e.mustQueue?(this.tasks[n]=e,this.taskQueue.push(n),this.invoker.trigger()):this.processTask(n,e)},ku.prototype.process=function(){if(this.taskQueue.length){var t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}},ku.prototype.processTask=function(t,e){var n=this;if(""===e.type){var r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Hr(e.error)):r(null,Hr(e.data)))}else{var i=!1,o=A(this.globalScope)?void 0:[],a=e.hasCallback?function(e,r){i=!0,delete n.cancelCallbacks[t],n.target.postMessage({id:t,type:"",sourceMapId:n.mapId,error:e?jr(e):null,data:jr(r,o)},o)}:function(t){i=!0},s=null,l=Hr(e.data);if(this.parent[e.type])s=this.parent[e.type](e.sourceMapId,l,a);else if(this.parent.getWorkerSource){var u=e.type.split(".");s=this.parent.getWorkerSource(e.sourceMapId,u[0],l.source)[u[1]](l,a)}else a(new Error("Could not find function "+e.type));!i&&s&&s.cancel&&(this.cancelCallbacks[t]=s.cancel)}},ku.prototype.remove=function(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)};var Fu=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};Fu.prototype.setNorthEast=function(t){return this._ne=t instanceof Bu?new Bu(t.lng,t.lat):Bu.convert(t),this},Fu.prototype.setSouthWest=function(t){return this._sw=t instanceof Bu?new Bu(t.lng,t.lat):Bu.convert(t),this},Fu.prototype.extend=function(t){var e,n,r=this._sw,i=this._ne;if(t instanceof Bu)e=t,n=t;else{if(!(t instanceof Fu))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Fu.convert(t)):this.extend(Bu.convert(t)):this;if(n=t._ne,!(e=t._sw)||!n)return this}return r||i?(r.lng=Math.min(e.lng,r.lng),r.lat=Math.min(e.lat,r.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Bu(e.lng,e.lat),this._ne=new Bu(n.lng,n.lat)),this},Fu.prototype.getCenter=function(){return new Bu((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},Fu.prototype.getSouthWest=function(){return this._sw},Fu.prototype.getNorthEast=function(){return this._ne},Fu.prototype.getNorthWest=function(){return new Bu(this.getWest(),this.getNorth())},Fu.prototype.getSouthEast=function(){return new Bu(this.getEast(),this.getSouth())},Fu.prototype.getWest=function(){return this._sw.lng},Fu.prototype.getSouth=function(){return this._sw.lat},Fu.prototype.getEast=function(){return this._ne.lng},Fu.prototype.getNorth=function(){return this._ne.lat},Fu.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},Fu.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},Fu.prototype.isEmpty=function(){return!(this._sw&&this._ne)},Fu.prototype.contains=function(t){var e=Bu.convert(t),n=e.lng,r=e.lat,i=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i},Fu.convert=function(t){return!t||t instanceof Fu?t:new Fu(t)};var Bu=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid LngLat object: ("+t+", "+e+")");if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};Bu.prototype.wrap=function(){return new Bu(h(this.lng,-180,180),this.lat)},Bu.prototype.toArray=function(){return[this.lng,this.lat]},Bu.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},Bu.prototype.distanceTo=function(t){var e=Math.PI/180,n=this.lat*e,r=t.lat*e,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return 6371008.8*Math.acos(Math.min(i,1))},Bu.prototype.toBounds=function(t){void 0===t&&(t=0);var e=360*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new Fu(new Bu(this.lng-n,this.lat-e),new Bu(this.lng+n,this.lat+e))},Bu.convert=function(t){if(t instanceof Bu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Bu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Bu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")};var Uu=2*Math.PI*6371008.8;function Vu(t){return Uu*Math.cos(t*Math.PI/180)}function Gu(t){return(180+t)/360}function ju(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Hu(t,e){return t/Vu(e)}function qu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}var Wu=function(t,e,n){void 0===n&&(n=0),this.x=+t,this.y=+e,this.z=+n};Wu.fromLngLat=function(t,e){void 0===e&&(e=0);var n=Bu.convert(t);return new Wu(Gu(n.lng),ju(n.lat),Hu(e,n.lat))},Wu.prototype.toLngLat=function(){return new Bu(360*this.x-180,qu(this.y))},Wu.prototype.toAltitude=function(){return this.z*Vu(qu(this.y))},Wu.prototype.meterInMercatorCoordinateUnits=function(){return 1/Uu*(t=qu(this.y),1/Math.cos(t*Math.PI/180));var t};var Xu=function(t,e,n){this.z=t,this.x=e,this.y=n,this.key=Ju(0,t,t,e,n)};Xu.prototype.equals=function(t){return this.z===t.z&&this.x===t.x&&this.y===t.y},Xu.prototype.url=function(t,e){var n,r,i,o,a,s=(r=this.y,i=this.z,o=zu(256*(n=this.x),256*(r=Math.pow(2,i)-r-1),i),a=zu(256*(n+1),256*(r+1),i),o[0]+","+o[1]+","+a[0]+","+a[1]),l=function(t,e,n){for(var r,i="",o=t;o>0;o--)i+=(e&(r=1<this.canonical.z?new Yu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Yu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)},Yu.prototype.calculateScaledKey=function(t,e){var n=this.canonical.z-t;return t>this.canonical.z?Ju(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ju(this.wrap*+e,t,t,this.canonical.x>>n,this.canonical.y>>n)},Yu.prototype.isChildOf=function(t){if(t.wrap!==this.wrap)return!1;var e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e},Yu.prototype.children=function(t){if(this.overscaledZ>=t)return[new Yu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var e=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Yu(e,this.wrap,e,n,r),new Yu(e,this.wrap,e,n+1,r),new Yu(e,this.wrap,e,n,r+1),new Yu(e,this.wrap,e,n+1,r+1)]},Yu.prototype.isLessThan=function(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)},Ku.prototype._unpackMapbox=function(t,e,n){return(256*t*256+256*e+n)/10-1e4},Ku.prototype._unpackTerrarium=function(t,e,n){return 256*t+e+n/256-32768},Ku.prototype.getPixels=function(){return new xa({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))},Ku.prototype.backfillBorder=function(t,e,n){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");var r=e*this.dim,i=e*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(e){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}for(var s=-e*this.dim,l=-n*this.dim,u=o;u=0&&c[3]>=0&&s.insert(a,c[0],c[1],c[2],c[3])}},nc.prototype.loadVTLayers=function(){return this.vtLayers||(this.vtLayers=new bs.VectorTile(new Ks(this.rawTileData)).layers,this.sourceLayerCoder=new Qu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers},nc.prototype.query=function(t,e,n,r){var o=this;this.loadVTLayers();for(var a=t.params||{},s=8192/t.tileSize/t.scale,l=sr(a.filter),u=t.queryGeometry,c=t.queryPadding*s,h=ic(u),p=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),f=ic(t.cameraQueryGeometry),d=this.grid3D.query(f.minX-c,f.minY-c,f.maxX+c,f.maxY+c,(function(e,n,r,o){return function(t,e,n,r,o){for(var a=0,s=t;a=l.x&&o>=l.y)return!0}var u=[new i(e,n),new i(e,o),new i(r,o),new i(r,n)];if(t.length>2)for(var c=0,h=u;c=0)return!0;return!1}(o,h)){var f=this.sourceLayerCoder.decode(n),d=this.vtLayers[f].feature(r);if(i.needGeometry){var m=Go(d,!0);if(!i.filter(new li(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!i.filter(new li(this.tileID.overscaledZ),d))return;for(var g=this.getId(d,f),y=0;yr)i=!1;else if(e)if(this.expirationTimelt&&(t.getActor().send("enforceCacheSizeLimit",st),pt=0)},t.clamp=c,t.clearTileCache=function(t){var e=a.caches.delete("mapbox-tiles");t&&e.catch(t).then((function(){return t()}))},t.clipLine=Xl,t.clone=function(t){var e=new sa(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=b,t.clone$2=function(t){var e=new sa(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.collisionCircleLayout=Ws,t.config=B,t.create=function(){var t=new sa(16);return sa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=function(){var t=new sa(9);return sa!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},t.create$2=function(){var t=new sa(4);return sa!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},t.createCommonjsModule=e,t.createExpression=Zn,t.createLayout=Ci,t.createStyleLayer=function(t){return"custom"===t.type?new Cu(t):new Iu[t.type](t)},t.cross=function(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],l=n[2];return t[0]=i*l-o*s,t[1]=o*a-r*l,t[2]=r*s-i*a,t},t.deepEqual=function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(var r=0;r0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},t.number=qe,t.offscreenCanvasSupported=ft,t.ortho=function(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(a+o)*u,t[15]=1,t},t.parseGlyphPBF=function(t){return new Ks(t).readFields(ml,[])},t.pbf=Ks,t.performSymbolLayout=function(t,e,n,r,i,o,a){t.createArrays(),t.tilePixelRatio=8192/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;var s=t.layers[0].layout,l=t.layers[0]._unevaluatedLayout._values,u={};if("composite"===t.textSizeData.kind){var c=t.textSizeData,h=c.maxZoom;u.compositeTextSizes=[l["text-size"].possiblyEvaluate(new li(c.minZoom),a),l["text-size"].possiblyEvaluate(new li(h),a)]}if("composite"===t.iconSizeData.kind){var p=t.iconSizeData,f=p.maxZoom;u.compositeIconSizes=[l["icon-size"].possiblyEvaluate(new li(p.minZoom),a),l["icon-size"].possiblyEvaluate(new li(f),a)]}u.layoutTextSize=l["text-size"].possiblyEvaluate(new li(t.zoom+1),a),u.layoutIconSize=l["icon-size"].possiblyEvaluate(new li(t.zoom+1),a),u.textMaxSize=l["text-size"].possiblyEvaluate(new li(18));for(var d=24*s.get("text-line-height"),m="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement"),g=s.get("text-keep-upright"),y=s.get("text-size"),v=function(){var o=x[_],l=s.get("text-font").evaluate(o,{},a).join(","),c=y.evaluate(o,{},a),h=u.layoutTextSize.evaluate(o,{},a),p=u.layoutIconSize.evaluate(o,{},a),f={horizontal:{},vertical:void 0},v=o.text,b=[0,0];if(v){var w=v.toString(),S=24*s.get("text-letter-spacing").evaluate(o,{},a),M=function(t){for(var e=0,n=t;e=8192||h.y<0||h.y>=8192||function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m,g,y,v,_,x,b,w,S,M){var T,C,I,A,L,P=t.addToLineVertexArray(e,n),R=0,D=0,N=0,O=0,k=-1,z=-1,F={},B=fo(""),U=0,V=0;if(void 0===s._unevaluatedLayout.getValue("text-radial-offset")?(U=(T=s.layout.get("text-offset").evaluate(x,{},S).map((function(t){return 24*t})))[0],V=T[1]):(U=24*s.layout.get("text-radial-offset").evaluate(x,{},S),V=ou),t.allowVerticalPlacement&&r.vertical){var G=s.layout.get("text-rotate").evaluate(x,{},S)+90;A=new $l(l,e,u,c,h,r.vertical,p,f,d,G),a&&(L=new $l(l,e,u,c,h,a,g,y,d,G))}if(i){var j=s.layout.get("icon-rotate").evaluate(x,{}),H="none"!==s.layout.get("icon-text-fit"),q=Zl(i,j,w,H),W=a?Zl(a,j,w,H):void 0;I=new $l(l,e,u,c,h,i,g,y,!1,j),R=4*q.length;var X=t.iconSizeData,Z=null;"source"===X.kind?(Z=[128*s.layout.get("icon-size").evaluate(x,{})])[0]>32640&&E(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".'):"composite"===X.kind&&((Z=[128*b.compositeIconSizes[0].evaluate(x,{},S),128*b.compositeIconSizes[1].evaluate(x,{},S)])[0]>32640||Z[1]>32640)&&E(t.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".'),t.addSymbols(t.icon,q,Z,_,v,x,!1,e,P.lineStartIndex,P.lineLength,-1,S),k=t.icon.placedSymbolArray.length-1,W&&(D=4*W.length,t.addSymbols(t.icon,W,Z,_,v,x,wl.vertical,e,P.lineStartIndex,P.lineLength,-1,S),z=t.icon.placedSymbolArray.length-1)}for(var Y in r.horizontal){var J=r.horizontal[Y];if(!C){B=fo(J.text);var K=s.layout.get("text-rotate").evaluate(x,{},S);C=new $l(l,e,u,c,h,J,p,f,d,K)}var Q=1===J.positionedLines.length;if(N+=lu(t,e,J,o,s,d,x,m,P,r.vertical?wl.horizontal:wl.horizontalOnly,Q?Object.keys(r.horizontal):[Y],F,k,b,S),Q)break}r.vertical&&(O+=lu(t,e,r.vertical,o,s,d,x,m,P,wl.vertical,["vertical"],F,z,b,S));var $=C?C.boxStartIndex:t.collisionBoxArray.length,tt=C?C.boxEndIndex:t.collisionBoxArray.length,et=A?A.boxStartIndex:t.collisionBoxArray.length,nt=A?A.boxEndIndex:t.collisionBoxArray.length,rt=I?I.boxStartIndex:t.collisionBoxArray.length,it=I?I.boxEndIndex:t.collisionBoxArray.length,ot=L?L.boxStartIndex:t.collisionBoxArray.length,at=L?L.boxEndIndex:t.collisionBoxArray.length,st=-1,lt=function(t,e){return t&&t.circleDiameter?Math.max(t.circleDiameter,e):e};st=lt(C,st),st=lt(A,st),st=lt(I,st);var ut=(st=lt(L,st))>-1?1:0;ut&&(st*=M/24),t.glyphOffsetArray.length>=vu.MAX_GLYPHS&&E("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,F.right>=0?F.right:-1,F.center>=0?F.center:-1,F.left>=0?F.left:-1,F.vertical||-1,k,z,B,$,tt,et,nt,rt,it,ot,at,u,N,O,R,D,ut,0,p,U,V,st)}(t,h,s,n,r,i,p,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,y,b,M,l,_,w,T,d,e,o,u,c,a)};if("line"===C)for(var P=0,R=Xl(e.geometry,0,0,8192,8192);P1){var U=ql(B,S,n.vertical||m,r,24,v);U&&L(B,U)}}else if("Polygon"===e.type)for(var V=0,G=is(e.geometry,0);V=I.maxzoom||"none"!==I.visibility&&(a(C,this.zoom,r),(m[I.id]=I.createBucket({index:c.bucketLayerIDs.length,layers:C,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:x,sourceID:this.source})).populate(b,g,this.tileID.canonical),c.bucketLayerIDs.push(C.map((function(t){return t.id}))))}}}var A=t.mapObject(g.glyphDependencies,(function(t){return Object.keys(t).map(Number)}));Object.keys(A).length?o.send("getGlyphs",{uid:this.uid,stacks:A},(function(t,e){h||(h=t,p=e,R.call(l))})):p={};var L=Object.keys(g.iconDependencies);L.length?o.send("getImages",{icons:L,source:this.source,tileID:this.tileID,type:"icons"},(function(t,e){h||(h=t,f=e,R.call(l))})):f={};var P=Object.keys(g.patternDependencies);function R(){if(h)return s(h);if(p&&f&&d){var e=new i(p),n=new t.ImageAtlas(f,d);for(var o in m){var l=m[o];l instanceof t.SymbolBucket?(a(l.layers,this.zoom,r),t.performSymbolLayout(l,p,e.positions,f,n.iconPositions,this.showCollisionBoxes,this.tileID.canonical)):l.hasPattern&&(l instanceof t.LineBucket||l instanceof t.FillBucket||l instanceof t.FillExtrusionBucket)&&(a(l.layers,this.zoom,r),l.addFeatures(g,this.tileID.canonical,n.patternPositions))}this.status="done",s(null,{buckets:t.values(m).filter((function(t){return!t.isEmpty()})),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,imageAtlas:n,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"patterns"},(function(t,e){h||(h=t,d=e,R.call(l))})):d={},R.call(this)};var l=function(t,e,n,r){this.actor=t,this.layerIndex=e,this.availableImages=n,this.loadVectorData=r||s,this.loading={},this.loaded={}};l.prototype.loadTile=function(e,n){var r=this,i=e.uid;this.loading||(this.loading={});var a=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request),s=this.loading[i]=new o(e);s.abort=this.loadVectorData(e,(function(e,o){if(delete r.loading[i],e||!o)return s.status="done",r.loaded[i]=s,n(e);var l=o.rawData,u={};o.expires&&(u.expires=o.expires),o.cacheControl&&(u.cacheControl=o.cacheControl);var c={};if(a){var h=a.finish();h&&(c.resourceTiming=JSON.parse(JSON.stringify(h)))}s.vectorTile=o.vectorTile,s.parse(o.vectorTile,r.layerIndex,r.availableImages,r.actor,(function(e,r){if(e||!r)return n(e);n(null,t.extend({rawTileData:l.slice(0)},r,u,c))})),r.loaded=r.loaded||{},r.loaded[i]=s}))},l.prototype.reloadTile=function(t,e){var n=this,r=this.loaded,i=t.uid,o=this;if(r&&r[i]){var a=r[i];a.showCollisionBoxes=t.showCollisionBoxes;var s=function(t,r){var i=a.reloadCallback;i&&(delete a.reloadCallback,a.parse(a.vectorTile,o.layerIndex,n.availableImages,o.actor,i)),e(t,r)};"parsing"===a.status?a.reloadCallback=s:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}},l.prototype.abortTile=function(t,e){var n=this.loading,r=t.uid;n&&n[r]&&n[r].abort&&(n[r].abort(),delete n[r]),e()},l.prototype.removeTile=function(t,e){var n=this.loaded,r=t.uid;n&&n[r]&&delete n[r],e()};var u=t.window.ImageBitmap,c=function(){this.loaded={}};function h(t,e){if(0!==t.length){p(t[0],e);for(var n=1;n=0!=!!e&&t.reverse()}c.prototype.loadTile=function(e,n){var r=e.uid,i=e.encoding,o=e.rawImageData,a=u&&o instanceof u?this.getImageData(o):o,s=new t.DEMData(r,a,i);this.loaded=this.loaded||{},this.loaded[r]=s,n(null,s)},c.prototype.getImageData=function(e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);var n=this.offscreenCanvasContext.getImageData(-1,-1,e.width+2,e.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:n.width,height:n.height},n.data)},c.prototype.removeTile=function(t){var e=this.loaded,n=t.uid;e&&e[n]&&delete e[n]};var f=t.vectorTile.VectorTileFeature.prototype.toGeoJSON,d=function(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))};d.prototype.loadGeometry=function(){if(1===this._feature.type){for(var e=[],n=0,r=this._feature.geometry;n>31}function I(t,e){for(var n=t.loadGeometry(),r=t.type,i=0,o=0,a=n.length,s=0;s>1;!function t(e,n,r,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);t(e,n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}var p=n[2*r+a],f=i,d=o;for(L(e,n,i,r),n[2*o+a]>p&&L(e,n,i,o);fp;)d--}n[2*i+a]===p?L(e,n,i,d):L(e,n,++d,o),d<=r&&(i=d+1),r<=d&&(o=d-1)}}(e,n,s,i,o,a%2),t(e,n,r,i,s-1,a+1),t(e,n,r,s+1,o,a+1)}}(a,s,r,0,a.length-1,0)};O.prototype.range=function(t,e,n,r){return function(t,e,n,r,i,o,a){for(var s,l,u=[0,t.length-1,0],c=[];u.length;){var h=u.pop(),p=u.pop(),f=u.pop();if(p-f<=a)for(var d=f;d<=p;d++)l=e[2*d+1],(s=e[2*d])>=n&&s<=i&&l>=r&&l<=o&&c.push(t[d]);else{var m=Math.floor((f+p)/2);l=e[2*m+1],(s=e[2*m])>=n&&s<=i&&l>=r&&l<=o&&c.push(t[m]);var g=(h+1)%2;(0===h?n<=s:r<=l)&&(u.push(f),u.push(m-1),u.push(g)),(0===h?i>=s:o>=l)&&(u.push(m+1),u.push(p),u.push(g))}}return c}(this.ids,this.coords,t,e,n,r,this.nodeSize)},O.prototype.within=function(t,e,n){return function(t,e,n,r,i,o){for(var a=[0,t.length-1,0],s=[],l=i*i;a.length;){var u=a.pop(),c=a.pop(),h=a.pop();if(c-h<=o)for(var p=h;p<=c;p++)R(e[2*p],e[2*p+1],n,r)<=l&&s.push(t[p]);else{var f=Math.floor((h+c)/2),d=e[2*f],m=e[2*f+1];R(d,m,n,r)<=l&&s.push(t[f]);var g=(u+1)%2;(0===u?n-i<=d:r-i<=m)&&(a.push(h),a.push(f-1),a.push(g)),(0===u?n+i>=d:r+i>=m)&&(a.push(f+1),a.push(c),a.push(g))}}return s}(this.ids,this.coords,t,e,n,this.nodeSize)};var k={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:function(t){return t}},z=function(t){this.options=H(Object.create(k),t),this.trees=new Array(this.options.maxZoom+1)};function F(t,e,n,r,i){return{x:t,y:e,zoom:1/0,id:n,parentId:-1,numPoints:r,properties:i}}function B(t,e){var n=t.geometry.coordinates,r=n[1];return{x:G(n[0]),y:j(r),zoom:1/0,index:e,parentId:-1}}function U(t){return{type:"Feature",id:t.id,properties:V(t),geometry:{type:"Point",coordinates:[(r=t.x,360*(r-.5)),(e=t.y,n=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(n))/Math.PI-90)]}};var e,n,r}function V(t){var e=t.numPoints,n=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return H(H({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:n})}function G(t){return t/360+.5}function j(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function H(t,e){for(var n in e)t[n]=e[n];return t}function q(t){return t.x}function W(t){return t.y}function X(t,e,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((t-n)*a+(e-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=t-n)*a+(s=e-r)*s}function Z(t,e,n,r){var i={id:void 0===t?null:t,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,n=t.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)Y(t,e);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(a+=r?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u}var c=e.length-3;e[2]=1,function t(e,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,u=e[n],c=e[n+1],h=e[r],p=e[r+1],f=n+3;fa)o=f,a=d;else if(d===a){var m=Math.abs(f-s);mi&&(o-n>3&&t(e,n,o,i),e[o+2]=a,r-o>3&&t(e,o,r,i))}(e,0,c,n),e[c+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function $(t,e,n,r){for(var i=0;i1?1:n}function nt(t,e,n,r,i,o,a,s){if(r/=e,o>=(n/=e)&&a=r)return null;for(var l=[],u=0;u=n&&d=r)){var m=[];if("Point"===p||"MultiPoint"===p)rt(h,m,n,r,i);else if("LineString"===p)it(h,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===p)at(h,m,n,r,i,!1);else if("Polygon"===p)at(h,m,n,r,i,!0);else if("MultiPolygon"===p)for(var g=0;g=n&&a<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function it(t,e,n,r,i,o,a){for(var s,l,u=ot(t),c=0===i?lt:ut,h=t.start,p=0;pn&&(l=c(u,f,d,g,y,n),a&&(u.start=h+s*l)):v>r?_=n&&(l=c(u,f,d,g,y,n),x=!0),_>r&&v<=r&&(l=c(u,f,d,g,y,r),x=!0),!o&&x&&(a&&(u.end=h+s*l),e.push(u),u=ot(t)),a&&(h+=s)}var b=t.length-3;f=t[b],d=t[b+1],m=t[b+2],(v=0===i?f:d)>=n&&v<=r&&st(u,f,d,m),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&st(u,u[0],u[1],u[2]),u.length&&e.push(u)}function ot(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function at(t,e,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function mt(t,e,n,r){var i=e.geometry,o=e.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&e.size<(i?a:r))n.numPoints+=e.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(e[l]),s.push(e[l+1])),n.numPoints++;i&&function(t,e){for(var n=0,r=0,i=t.length,o=i-2;r0===e)for(r=0,i=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var n=[];if("FeatureCollection"===t.type)for(var r=0;r=r;u--){var c=+Date.now();s=this._cluster(s,u),this.trees[u]=new O(s,q,W,o,Float32Array),n&&console.log("z%d: %d clusters in %dms",u,s.length,+Date.now()-c)}return n&&console.timeEnd("total time"),this},z.prototype.getClusters=function(t,e){var n=((t[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,t[1])),i=180===t[2]?180:((t[2]+180)%360+360)%360-180,o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)n=-180,i=180;else if(n>i){var a=this.getClusters([n,r,180,o],e),s=this.getClusters([-180,r,i,o],e);return a.concat(s)}for(var l=this.trees[this._limitZoom(e)],u=[],c=0,h=l.range(G(n),j(o),G(i),j(r));ce&&(p+=m.numPoints||1)}if(p>=o){for(var g=l.x*h,y=l.y*h,v=i&&h>1?this._map(l,!0):null,_=(s<<5)+(e+1)+this.points.length,x=0,b=c;x1)for(var S=0,M=c;S>5},z.prototype._getOriginZoom=function(t){return(t-this.points.length)%32},z.prototype._map=function(t,e){if(t.numPoints)return e?H({},t.properties):t.properties;var n=this.points[t.index].properties,r=this.options.map(n);return e&&r===n?H({},r):r},yt.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},yt.prototype.splitTile=function(t,e,n,r,i,o,a){for(var s=[t,e,n,r],l=this.options,u=l.debug;s.length;){r=s.pop(),n=s.pop(),e=s.pop(),t=s.pop();var c=1<1&&console.time("creation"),p=this.tiles[h]=dt(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+e;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(p.source=t,i){if(e===l.maxZoom||e===i)continue;var d=1<1&&console.time("clipping");var m,g,y,v,_,x,b=.5*l.buffer/l.extent,w=.5-b,E=.5+b,S=1+b;m=g=y=v=null,_=nt(t,c,n-b,n+E,0,p.minX,p.maxX,l),x=nt(t,c,n+w,n+S,0,p.minX,p.maxX,l),t=null,_&&(m=nt(_,c,r-b,r+E,1,p.minY,p.maxY,l),g=nt(_,c,r+w,r+S,1,p.minY,p.maxY,l),_=null),x&&(y=nt(x,c,r-b,r+E,1,p.minY,p.maxY,l),v=nt(x,c,r+w,r+S,1,p.minY,p.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],e+1,2*n,2*r),s.push(g||[],e+1,2*n,2*r+1),s.push(y||[],e+1,2*n+1,2*r),s.push(v||[],e+1,2*n+1,2*r+1)}}},yt.prototype.getTile=function(t,e,n){var r=this.options,i=r.extent,o=r.debug;if(t<0||t>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",t,e,n);for(var l,u=t,c=e,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[vt(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,t,e,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?pt(this.tiles[s],i):null):null};var xt=function(e){function n(t,n,r,i){e.call(this,t,n,r,_t),i&&(this.loadGeoJSON=i)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.loadData=function(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),this._pendingCallback=e,this._pendingLoadDataParams=t,this._state&&"Idle"!==this._state?this._state="NeedsLoadData":(this._state="Coalescing",this._loadData())},n.prototype._loadData=function(){var e=this;if(this._pendingCallback&&this._pendingLoadDataParams){var n=this._pendingCallback,r=this._pendingLoadDataParams;delete this._pendingCallback,delete this._pendingLoadDataParams;var i=!!(r&&r.request&&r.request.collectResourceTiming)&&new t.RequestPerformance(r.request);this.loadGeoJSON(r,(function(o,a){if(o||!a)return n(o);if("object"!=typeof a)return n(new Error("Input data given to '"+r.source+"' is not a valid GeoJSON object."));!function t(e,n){var r,i=e&&e.type;if("FeatureCollection"===i)for(r=0;r=0?0:e.button},n.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};var p=function(e){function n(){e.call(this),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.isLoaded=function(){return this.loaded},n.prototype.setLoaded=function(t){if(this.loaded!==t&&(this.loaded=t,t)){for(var e=0,n=this.requestors;e=0?1.2:1))}function y(t,e,n,r,i,o,a){for(var s=0;s65535)e(new Error("glyphs > 65535 not supported"));else if(o.ranges[s])e(null,{stack:n,id:i,glyph:a});else{var l=o.requests[s];l||(l=o.requests[s]=[],_.loadGlyphRange(n,s,r.url,r.requestManager,(function(t,e){if(e){for(var n in e)r._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=e[+n]);o.ranges[s]=!0}for(var i=0,a=l;i1&&(s=t[++a]);var u=Math.abs(l-s.left),c=Math.abs(l-s.right),h=Math.min(u,c),p=void 0,f=i/n*(r+1);if(s.isDash){var d=r-Math.abs(f);p=Math.sqrt(h*h+d*d)}else p=r-Math.sqrt(h*h+f*f);this.data[o+l]=Math.max(0,Math.min(255,p+128))}},E.prototype.addRegularDash=function(t){for(var e=t.length-1;e>=0;--e){var n=t[e],r=t[e+1];n.zeroLength?t.splice(e,1):r&&r.isDash===n.isDash&&(r.left=n.left,t.splice(e,1))}var i=t[0],o=t[t.length-1];i.isDash===o.isDash&&(i.left=o.left-this.width,o.right=i.right+this.width);for(var a=this.width*this.nextRow,s=0,l=t[s],u=0;u1&&(l=t[++s]);var c=Math.abs(u-l.left),h=Math.abs(u-l.right),p=Math.min(c,h);this.data[a+u]=Math.max(0,Math.min(255,(l.isDash?p:-p)+128))}},E.prototype.addDash=function(e,n){var r=n?7:0,i=2*r+1;if(this.nextRow+i>this.height)return t.warnOnce("LineAtlas out of space"),null;for(var o=0,a=0;a=r&&e.x=i&&e.y0&&(l[new t.OverscaledTileID(e.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+10&&(r.resourceTiming=e._resourceTiming,e._resourceTiming=[]),e.fire(new t.Event("data",r))}}))},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setData=function(e){var n=this;return this._data=e,this.fire(new t.Event("dataloading",{dataType:"source"})),this._updateWorkerData((function(e){if(e)n.fire(new t.ErrorEvent(e));else{var r={dataType:"source",sourceDataType:"content"};n._collectResourceTiming&&n._resourceTiming&&n._resourceTiming.length>0&&(r.resourceTiming=n._resourceTiming,n._resourceTiming=[]),n.fire(new t.Event("data",r))}})),this},n.prototype.getClusterExpansionZoom=function(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this},n.prototype.getClusterChildren=function(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this},n.prototype.getClusterLeaves=function(t,e,n,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:n},r),this},n.prototype._updateWorkerData=function(e){var n=this;this._loaded=!1;var r=t.extend({},this.workerOptions),i=this._data;"string"==typeof i?(r.request=this.map._requestManager.transformRequest(t.browser.resolveURL(i),t.ResourceType.Source),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(i),this.actor.send(this.type+".loadData",r,(function(t,i){n._removed||i&&i.abandoned||(n._loaded=!0,i&&i.resourceTiming&&i.resourceTiming[n.id]&&(n._resourceTiming=i.resourceTiming[n.id].slice(0)),n.actor.send(n.type+".coalesce",{source:r.source},null),e(t))}))},n.prototype.loaded=function(){return this._loaded},n.prototype.loadTile=function(e,n){var r=this,i=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(i,{type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.browser.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(function(t,o){return delete e.request,e.unloadVectorData(),e.aborted?n(null):t?n(t):(e.loadVectorData(o,r.map.painter,"reloadTile"===i),n(null))}))},n.prototype.abortTile=function(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0},n.prototype.unloadTile=function(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})},n.prototype.onRemove=function(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})},n.prototype.serialize=function(){return t.extend({},this._options,{type:this.type,data:this._data})},n.prototype.hasTransition=function(){return!1},n}(t.Evented),P=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),R=function(e){function n(t,n,r,i){e.call(this),this.id=t,this.dispatcher=r,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=n}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(e,n){var r=this;this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),(function(i,o){r._loaded=!0,i?r.fire(new t.ErrorEvent(i)):o&&(r.image=o,e&&(r.coordinates=e),n&&n(),r._finishLoading())}))},n.prototype.loaded=function(){return this._loaded},n.prototype.updateImage=function(t){var e=this;return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(function(){e.texture=null})),this):this},n.prototype._finishLoading=function(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))},n.prototype.onAdd=function(t){this.map=t,this.load()},n.prototype.setCoordinates=function(e){var n=this;this.coordinates=e;var r=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){for(var n=1/0,r=1/0,i=-1/0,o=-1/0,a=0,s=e;an.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError("sources."+this.id,null,"Playback for this video can be set only between the "+n.start(0)+" and "+n.end(0)+"-second mark."))):this.video.currentTime=e}},n.prototype.getVideo=function(){return this.video},n.prototype.onAdd=function(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))},n.prototype.prepare=function(){if(!(0===Object.keys(this.tiles).length||this.video.readyState<2)){var e=this.map.painter.context,n=e.gl;for(var r in this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,P.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){var i=this.tiles[r];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}}},n.prototype.serialize=function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}},n.prototype.hasTransition=function(){return this.video&&!this.video.paused},n}(R),N=function(e){function n(n,r,i,o){e.call(this,n,r,i,o),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((function(t){return!Array.isArray(t)||2!==t.length||t.some((function(t){return"number"!=typeof t}))}))||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError("sources."+n,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.load=function(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},n.prototype.getCanvas=function(){return this.canvas},n.prototype.onAdd=function(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()},n.prototype.onRemove=function(){this.pause()},n.prototype.prepare=function(){var e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),!this._hasInvalidDimensions()&&0!==Object.keys(this.tiles).length){var n=this.map.painter.context,r=n.gl;for(var i in this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,P.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(n,this.canvas,r.RGBA,{premultiply:!0}),this.tiles){var o=this.tiles[i];"loaded"!==o.state&&(o.state="loaded",o.texture=this.texture)}}},n.prototype.serialize=function(){return{type:"canvas",coordinates:this.coordinates}},n.prototype.hasTransition=function(){return this._playing},n.prototype._hasInvalidDimensions=function(){for(var t=0,e=[this.canvas.width,this.canvas.height];tthis.max){var a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this},B.prototype.has=function(t){return t.wrapped().key in this.data},B.prototype.getAndRemove=function(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null},B.prototype._getAndRemoveByKey=function(t){var e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value},B.prototype.getByKey=function(t){var e=this.data[t];return e?e[0].value:null},B.prototype.get=function(t){return this.has(t)?this.data[t.wrapped().key][0].value:null},B.prototype.remove=function(t,e){if(!this.has(t))return this;var n=t.wrapped().key,r=void 0===e?0:this.data[n].indexOf(e),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this},B.prototype.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this},B.prototype.filter=function(t){var e=[];for(var n in this.data)for(var r=0,i=this.data[n];r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}},n.prototype.getTile=function(t){return this.getTileByID(t.key)},n.prototype.getTileByID=function(t){return this._tiles[t]},n.prototype._retainLoadedChildren=function(t,e,n,r){for(var i in this._tiles){var o=this._tiles[i];if(!(r[i]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>n)){for(var a=o.tileID;o&&o.tileID.overscaledZ>e+1;){var s=o.tileID.scaledTo(o.tileID.overscaledZ-1);(o=this._tiles[s.key])&&o.hasData()&&(a=s)}for(var l=a;l.overscaledZ>e;)if(t[(l=l.scaledTo(l.overscaledZ-1)).key]){r[a.key]=a;break}}}},n.prototype.findLoadedParent=function(t,e){if(t.key in this._loadedParentTiles){var n=this._loadedParentTiles[t.key];return n&&n.tileID.overscaledZ>=e?n:null}for(var r=t.overscaledZ-1;r>=e;r--){var i=t.scaledTo(r),o=this._getLoadedTile(i);if(o)return o}},n.prototype._getLoadedTile=function(t){var e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)},n.prototype.updateCacheSize=function(t){var e=Math.ceil(t.width/this._source.tileSize)+1,n=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*n*5),i="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(i)},n.prototype.handleWrapJump=function(t){var e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){var n={};for(var r in this._tiles){var i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+e),n[i.tileID.key]=i}for(var o in this._tiles=n,this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(var a in this._tiles)this._setTileReloadTimer(a,this._tiles[a])}},n.prototype.update=function(e){var r=this;if(this.transform=e,this._sourceLoaded&&!this._paused){var i;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((function(e){return new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)})):(i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}),this._source.hasTile&&(i=i.filter((function(t){return r._source.hasTile(t)})))):i=[];var o=e.coveringZoomLevel(this._source),a=Math.max(o-n.maxOverzooming,this._source.minzoom),s=Math.max(o+n.maxUnderzooming,this._source.minzoom),l=this._updateRetainedTiles(i,o);if(Rt(this._source.type)){for(var u={},c={},h=0,p=Object.keys(l);hthis._source.maxzoom){var g=d.children(this._source.maxzoom)[0],y=this.getTile(g);if(y&&y.hasData()){r[g.key]=g;continue}}else{var v=d.children(this._source.maxzoom);if(r[v[0].key]&&r[v[1].key]&&r[v[2].key]&&r[v[3].key])continue}for(var _=m.wasRequested(),x=d.overscaledZ-1;x>=o;--x){var b=d.scaledTo(x);if(i[b.key])break;if(i[b.key]=!0,!(m=this.getTile(b))&&_&&(m=this._addTile(b)),m&&(r[b.key]=b,_=m.wasRequested(),m.hasData()))break}}}return r},n.prototype._updateLoadedParentTileCache=function(){for(var t in this._loadedParentTiles={},this._tiles){for(var e=[],n=void 0,r=this._tiles[t].tileID;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}e.push(r.key);var i=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(i))break;r=i}for(var o=0,a=e;o0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))},n.prototype.clearTiles=function(){for(var t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(t);this._cache.reset()},n.prototype.tilesIn=function(e,n,r){var i=this,o=[],a=this.transform;if(!a)return o;for(var s=r?a.getCameraQueryGeometry(e):e,l=e.map((function(t){return a.pointCoordinate(t)})),u=s.map((function(t){return a.pointCoordinate(t)})),c=this.getIds(),h=1/0,p=1/0,f=-1/0,d=-1/0,m=0,g=u;m=0&&y[1].y+g>=0){var v=l.map((function(t){return s.getTilePoint(t)})),_=u.map((function(t){return s.getTilePoint(t)}));o.push({tile:r,tileID:s,queryGeometry:v,cameraQueryGeometry:_,scale:m})}}},_=0;_=t.browser.now())return!0}return!1},n.prototype.setFeatureState=function(t,e,n){this._state.updateState(t=t||"_geojsonTileLayer",e,n)},n.prototype.removeFeatureState=function(t,e,n){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,n)},n.prototype.getFeatureState=function(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)},n.prototype.setDependencies=function(t,e,n){var r=this._tiles[t];r&&r.setDependencies(e,n)},n.prototype.reloadTilesForDependencies=function(t,e){for(var n in this._tiles)this._tiles[n].hasDependency(t,e)&&this._reloadTile(n,"reloading");this._cache.filter((function(n){return!n.hasDependency(t,e)}))},n}(t.Evented);function Pt(t,e){var n=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-n||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Rt(t){return"raster"===t||"image"===t||"video"===t}function Dt(){return new t.window.Worker(Yi.workerUrl)}Lt.maxOverzooming=10,Lt.maxUnderzooming=3;var Nt="mapboxgl_preloaded_worker_pool",Ot=function(){this.active={}};Ot.prototype.acquire=function(t){if(!this.workers)for(this.workers=[];this.workers.length0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))};var Jt=function(t,e,n){var r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(t/n),this.yCellCount=Math.ceil(e/n);for(var o=0;o=-e[0]&&n<=e[0]&&r>=-e[1]&&r<=e[1]}function ne(e,n,r,i,o,a,s,l){var u=i?e.textSizeData:e.iconSizeData,c=t.evaluateSizeForZoom(u,r.transform.zoom),h=[256/r.width*2+1,256/r.height*2+1],p=i?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;p.clear();for(var f=e.lineVertexArray,d=i?e.text.placedSymbolArray:e.icon.placedSymbolArray,m=r.transform.width/r.transform.height,g=!1,y=0;yMath.abs(r.x-n.x)*i?{useVertical:!0}:(e===t.WritingMode.vertical?n.yr.x)?{needsFlipping:!0}:null}function oe(e,n,r,i,o,a,s,l,u,c,h,p,f,d){var m,g=n/24,y=e.lineOffsetX*g,v=e.lineOffsetY*g;if(e.numGlyphs>1){var _=e.glyphStartIndex+e.numGlyphs,x=e.lineStartIndex,b=e.lineStartIndex+e.lineLength,w=re(g,l,y,v,r,h,p,e,u,a,f);if(!w)return{notEnoughRoom:!0};var E=$t(w.first.point,s).point,S=$t(w.last.point,s).point;if(i&&!r){var M=ie(e.writingMode,E,S,d);if(M)return M}m=[w.first];for(var T=e.glyphStartIndex+1;T<_-1;T++)m.push(se(g*l.getoffsetX(T),y,v,r,h,p,e.segment,x,b,u,a,f));m.push(w.last)}else{if(i&&!r){var C=$t(p,o).point,I=e.lineStartIndex+e.segment+1,A=new t.Point(u.getx(I),u.gety(I)),L=$t(A,o),P=L.signedDistanceFromCamera>0?L.point:ae(p,A,C,1,o),R=ie(e.writingMode,C,P,d);if(R)return R}var D=se(g*l.getoffsetX(e.glyphStartIndex),y,v,r,h,p,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,u,a,f);if(!D)return{notEnoughRoom:!0};m=[D]}for(var N=0,O=m;N0?1:-1,m=0;i&&(d*=-1,m=Math.PI),d<0&&(m+=Math.PI);for(var g=d>0?l+s:l+s+1,y=o,v=o,_=0,x=0,b=Math.abs(f),w=[];_+x<=b;){if((g+=d)=u)return null;if(v=y,w.push(y),void 0===(y=p[g])){var E=new t.Point(c.getx(g),c.gety(g)),S=$t(E,h);if(S.signedDistanceFromCamera>0)y=p[g]=S.point;else{var M=g-d;y=ae(0===_?a:new t.Point(c.getx(M),c.gety(M)),E,v,b-_+1,h)}}_+=x,x=v.dist(y)}var T=(b-_)/x,C=y.sub(v),I=C.mult(T)._add(v);I._add(C._unit()._perp()._mult(r*d));var A=m+Math.atan2(y.y-v.y,y.x-v.x);return w.push(I),{point:I,angle:A,path:w}}Jt.prototype.keysLength=function(){return this.boxKeys.length+this.circleKeys.length},Jt.prototype.insert=function(t,e,n,r,i){this._forEachCell(e,n,r,i,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(n),this.bboxes.push(r),this.bboxes.push(i)},Jt.prototype.insertCircle=function(t,e,n,r){this._forEachCell(e-r,n-r,e+r,n+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(n),this.circles.push(r)},Jt.prototype._insertBoxCell=function(t,e,n,r,i,o){this.boxCells[i].push(o)},Jt.prototype._insertCircleCell=function(t,e,n,r,i,o){this.circleCells[i].push(o)},Jt.prototype._query=function(t,e,n,r,i,o){if(n<0||t>this.width||r<0||e>this.height)return!i&&[];var a=[];if(t<=0&&e<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(var s=0;s0:a},Jt.prototype._queryCircle=function(t,e,n,r,i){var o=t-n,a=t+n,s=e-n,l=e+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];var u=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,u,{hitTest:r,circle:{x:t,y:e,radius:n},seenUids:{box:{},circle:{}}},i),r?u.length>0:u},Jt.prototype.query=function(t,e,n,r,i){return this._query(t,e,n,r,!1,i)},Jt.prototype.hitTest=function(t,e,n,r,i){return this._query(t,e,n,r,!0,i)},Jt.prototype.hitTestCircle=function(t,e,n,r){return this._queryCircle(t,e,n,!0,r)},Jt.prototype._queryCell=function(t,e,n,r,i,o,a,s){var l=a.seenUids,u=this.boxCells[i];if(null!==u)for(var c=this.bboxes,h=0,p=u;h=c[d+0]&&r>=c[d+1]&&(!s||s(this.boxKeys[f]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[f],x1:c[d],y1:c[d+1],x2:c[d+2],y2:c[d+3]})}}}var m=this.circleCells[i];if(null!==m)for(var g=this.circles,y=0,v=m;ya*a+s*s},Jt.prototype._circleAndRectCollide=function(t,e,n,r,i,o,a){var s=(o-r)/2,l=Math.abs(t-(r+s));if(l>s+n)return!1;var u=(a-i)/2,c=Math.abs(e-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;var h=l-s,p=c-u;return h*h+p*p<=n*n};var le=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ue(t,e){for(var n=0;n=1;P--)L.push(I.path[P]);for(var R=1;R0){for(var k=L[0].clone(),z=L[0].clone(),F=1;F=M.x&&z.x<=T.x&&k.y>=M.y&&z.y<=T.y?[L]:z.xT.x||z.yT.y?[]:t.clipLine([L],M.x,M.y,T.x,T.y)}for(var B=0,U=O;B=this.screenRightBoundary||r<100||e>this.screenBottomBoundary},he.prototype.isInsideGrid=function(t,e,n,r){return n>=0&&t=0&&e0?(this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(m=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:g,width:n,height:r,anchor:t,textBoxScale:i,prevAnchor:m},this.markUsedJustification(p,t,h,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,h),this.placedOrientations[h.crossTileID]=f),{shift:y,placedGlyphBoxes:v}):void 0},be.prototype.placeLayerBucketPart=function(e,n,r){var i=this,o=e.parameters,a=o.bucket,s=o.layout,l=o.posMatrix,u=o.textLabelPlaneMatrix,c=o.labelToScreenMatrix,h=o.textPixelRatio,p=o.holdingForFade,f=o.collisionBoxArray,d=o.partiallyEvaluatedTextSize,m=o.collisionGroup,g=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),_=s.get("icon-allow-overlap"),x="map"===s.get("text-rotation-alignment"),b="map"===s.get("text-pitch-alignment"),w="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order"),S=v&&(_||!a.hasIconData()||y),M=_&&(v||!a.hasTextData()||g);!a.collisionArrays&&f&&a.deserializeCollisionBoxes(f);var T=function(e,o){if(!n[e.crossTileID])if(p)i.placements[e.crossTileID]=new me(!1,!1,!1);else{var f,E=!1,T=!1,C=!0,I=null,A={box:null,offscreen:null},L={box:null,offscreen:null},P=null,R=null,D=0,N=0,O=0;o.textFeatureIndex?D=o.textFeatureIndex:e.useRuntimeCollisionCircles&&(D=e.featureIndex),o.verticalTextFeatureIndex&&(N=o.verticalTextFeatureIndex);var k=o.textBox;if(k){var z=function(n){var r=t.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&i.prevPlacement){var o=i.prevPlacement.placedOrientations[e.crossTileID];o&&(i.placedOrientations[e.crossTileID]=o,i.markUsedOrientation(a,r=o,e))}return r},F=function(n,r){if(a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&o.verticalTextBox)for(var i=0,s=a.writingModes;i0&&(B=B.filter((function(t){return t!==U.anchor}))).unshift(U.anchor)}var V=function(t,n,r){for(var o=t.x2-t.x1,s=t.y2-t.y1,u=e.textBoxScale,c=w&&!_?n:null,p={box:[],offscreen:!1},f=v?2*B.length:B.length,d=0;d=B.length,e,a,r,c);if(g&&(p=g.placedGlyphBoxes)&&p.box&&p.box.length){E=!0,I=g.shift;break}}return p};F((function(){return V(k,o.iconBox,t.WritingMode.horizontal)}),(function(){var n=o.verticalTextBox;return a.allowVerticalPlacement&&!(A&&A.box&&A.box.length)&&e.numVerticalGlyphVertices>0&&n?V(n,o.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null}})),A&&(E=A.box,C=A.offscreen);var G=z(A&&A.box);if(!E&&i.prevPlacement){var j=i.prevPlacement.variableOffsets[e.crossTileID];j&&(i.variableOffsets[e.crossTileID]=j,i.markUsedJustification(a,j.anchor,e,G))}}else{var H=function(t,n){var r=i.collisionIndex.placeCollisionBox(t,v,h,l,m.predicate);return r&&r.box&&r.box.length&&(i.markUsedOrientation(a,n,e),i.placedOrientations[e.crossTileID]=n),r};F((function(){return H(k,t.WritingMode.horizontal)}),(function(){var n=o.verticalTextBox;return a.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&n?H(n,t.WritingMode.vertical):{box:null,offscreen:null}})),z(A&&A.box&&A.box.length)}}if(E=(f=A)&&f.box&&f.box.length>0,C=f&&f.offscreen,e.useRuntimeCollisionCircles){var q=a.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),W=t.evaluateSizeForFeature(a.textSizeData,d,q),X=s.get("text-padding");P=i.collisionIndex.placeCollisionCircles(v,q,a.lineVertexArray,a.glyphOffsetArray,W,l,u,c,r,b,m.predicate,e.collisionCircleDiameter,X),E=v||P.circles.length>0&&!P.collisionDetected,C=C&&P.offscreen}if(o.iconFeatureIndex&&(O=o.iconFeatureIndex),o.iconBox){var Z=function(t){var e=w&&I?xe(t,I.x,I.y,x,b,i.transform.angle):t;return i.collisionIndex.placeCollisionBox(e,_,h,l,m.predicate)};T=L&&L.box&&L.box.length&&o.verticalIconBox?(R=Z(o.verticalIconBox)).box.length>0:(R=Z(o.iconBox)).box.length>0,C=C&&R.offscreen}var Y=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,J=y||0===e.numIconVertices;if(Y||J?J?Y||(T=T&&E):E=T&&E:T=E=T&&E,E&&f&&f.box&&i.collisionIndex.insertCollisionBox(f.box,s.get("text-ignore-placement"),a.bucketInstanceId,L&&L.box&&N?N:D,m.ID),T&&R&&i.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),a.bucketInstanceId,O,m.ID),P&&(E&&i.collisionIndex.insertCollisionCircles(P.circles,s.get("text-ignore-placement"),a.bucketInstanceId,D,m.ID),r)){var K=a.bucketInstanceId,Q=i.collisionCircleArrays[K];void 0===Q&&(Q=i.collisionCircleArrays[K]=new ge);for(var $=0;$=0;--I){var A=C[I];T(a.symbolInstances.get(A),a.collisionArrays[A])}else for(var L=e.symbolInstanceStart;L=0&&(e.text.placedSymbolArray.get(l).crossTileID=o>=0&&l!==o?0:r.crossTileID)}},be.prototype.markUsedOrientation=function(e,n,r){for(var i=n===t.WritingMode.horizontal||n===t.WritingMode.horizontalOnly?n:0,o=n===t.WritingMode.vertical?n:0,a=0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];a0,v=i.placedOrientations[o.crossTileID],_=v===t.WritingMode.vertical,x=v===t.WritingMode.horizontal||v===t.WritingMode.horizontalOnly;if(s>0||l>0){var b=Le(g.text);d(e.text,s,_?Pe:b),d(e.text,l,x?Pe:b);var w=g.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((function(t){t>=0&&(e.text.placedSymbolArray.get(t).hidden=w||_?1:0)})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=w||x?1:0);var E=i.variableOffsets[o.crossTileID];E&&i.markUsedJustification(e,E.anchor,o,v);var S=i.placedOrientations[o.crossTileID];S&&(i.markUsedJustification(e,"left",o,S),i.markUsedOrientation(e,S,o))}if(y){var M=Le(g.icon),T=!(p&&o.verticalPlacedIconSymbolIndex&&_);o.placedIconSymbolIndex>=0&&(d(e.icon,o.numIconVertices,T?M:Pe),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=g.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(d(e.icon,o.numVerticalIconVertices,T?Pe:M),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){var C=e.collisionArrays[r];if(C){var I=new t.Point(0,0);if(C.textBox||C.verticalTextBox){var A=!0;if(u){var L=i.variableOffsets[m];L?(I=_e(L.anchor,L.width,L.height,L.textOffset,L.textBoxScale),c&&I._rotate(h?i.transform.angle:-i.transform.angle)):A=!1}C.textBox&&we(e.textCollisionBox.collisionVertexArray,g.text.placed,!A||_,I.x,I.y),C.verticalTextBox&&we(e.textCollisionBox.collisionVertexArray,g.text.placed,!A||x,I.x,I.y)}var P=Boolean(!x&&C.verticalIconBox);C.iconBox&&we(e.iconCollisionBox.collisionVertexArray,g.icon.placed,P,p?I.x:0,p?I.y:0),C.verticalIconBox&&we(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!P,p?I.x:0,p?I.y:0)}}},g=0;gt},be.prototype.setStale=function(){this.stale=!0};var Ee=Math.pow(2,25),Se=Math.pow(2,24),Me=Math.pow(2,17),Te=Math.pow(2,16),Ce=Math.pow(2,9),Ie=Math.pow(2,8),Ae=Math.pow(2,1);function Le(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;var e=t.placed?1:0,n=Math.floor(127*t.opacity);return n*Ee+e*Se+n*Me+e*Te+n*Ce+e*Ie+n*Ae+e}var Pe=0,Re=function(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]};Re.prototype.continuePlacement=function(t,e,n,r,i){for(var o=this._bucketParts;this._currentTileIndex2};this._currentPlacementIndex>=0;){var s=n[e[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){if(this._inProgressLayer||(this._inProgressLayer=new Re(s)),this._inProgressLayer.continuePlacement(r[s.source],this.placement,this._showCollisionBoxes,s,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0},De.prototype.commit=function(t){return this.placement.commit(t),this.placement};var Ne=512/t.EXTENT/2,Oe=function(t,e,n){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(var r=0;rt.overscaledZ)for(var s in a){var l=a[s];l.tileID.isChildOf(t)&&l.findMatches(e.symbolInstances,t,i)}else{var u=a[t.scaledTo(Number(o)).key];u&&u.findMatches(e.symbolInstances,t,i)}}for(var c=0;c1?"@2x":"",l=t.getJSON(n.transformRequest(n.normalizeSpriteURL(e,s,".json"),t.ResourceType.SpriteJSON),(function(t,e){l=null,a||(a=t,i=e,c())})),u=t.getImage(n.transformRequest(n.normalizeSpriteURL(e,s,".png"),t.ResourceType.SpriteImage),(function(t,e){u=null,a||(a=t,o=e,c())}));function c(){if(a)r(a);else if(i&&o){var e=t.browser.getImageData(o),n={};for(var s in i){var l=i[s],u=l.width,c=l.height,h=l.x,p=l.y,f=l.sdf,d=l.pixelRatio,m=l.stretchX,g=l.stretchY,y=l.content,v=new t.RGBAImage({width:u,height:c});t.RGBAImage.copy(e,v,{x:h,y:p},{x:0,y:0},{width:u,height:c}),n[s]={data:v,pixelRatio:d,sdf:f,stretchX:m,stretchY:g,content:y}}r(null,n)}}return{cancel:function(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}}(e,this.map._requestManager,(function(e,r){if(n._spriteRequest=null,e)n.fire(new t.ErrorEvent(e));else if(r)for(var i in r)n.imageManager.addImage(i,r[i]);n.imageManager.setLoaded(!0),n._availableImages=n.imageManager.listImages(),n.dispatcher.broadcast("setImages",n._availableImages),n.fire(new t.Event("data",{dataType:"style"}))}))},n.prototype._validateLayer=function(e){var n=this.sourceCaches[e.source];if(n){var r=e.sourceLayer;if(r){var i=n.getSource();("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error('Source layer "'+r+'" does not exist on source "'+i.id+'" as specified by style layer "'+e.id+'"')))}}},n.prototype.loaded=function(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(var t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()},n.prototype._serializeLayers=function(t){for(var e=[],n=0,r=t;n0)throw new Error("Unimplemented: "+i.map((function(t){return t.command})).join(", ")+".");return r.forEach((function(t){"setTransition"!==t.command&&n[t.command].apply(n,t.args)})),this.stylesheet=e,!0},n.prototype.addImage=function(e,n){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(e,n),this._afterImageUpdated(e)},n.prototype.updateImage=function(t,e){this.imageManager.updateImage(t,e)},n.prototype.getImage=function(t){return this.imageManager.getImage(t)},n.prototype.removeImage=function(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(e),this._afterImageUpdated(e)},n.prototype._afterImageUpdated=function(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))},n.prototype.listImages=function(){return this._checkLoaded(),this.imageManager.listImages()},n.prototype.addSource=function(e,n,r){var i=this;if(void 0===r&&(r={}),this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error("There is already a source with this ID");if(!n.type)throw new Error("The type property must be defined, but only the following properties were given: "+Object.keys(n).join(", ")+".");if(!(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(t.validateStyle.source,"sources."+e,n,null,r))){this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);var o=this.sourceCaches[e]=new Lt(e,n,this.dispatcher);o.style=this,o.setEventedParent(this,(function(){return{isSourceLoaded:i.loaded(),source:o.serialize(),sourceId:e}})),o.onAdd(this.map),this._changed=!0}},n.prototype.removeSource=function(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(var n in this._layers)if(this._layers[n].source===e)return this.fire(new t.ErrorEvent(new Error('Source "'+e+'" cannot be removed while layer "'+n+'" is using it.')));var r=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],r.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),r.setEventedParent(null),r.clearTiles(),r.onRemove&&r.onRemove(this.map),this._changed=!0},n.prototype.setGeoJSONSourceData=function(t,e){this._checkLoaded(),this.sourceCaches[t].getSource().setData(e),this._changed=!0},n.prototype.getSource=function(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()},n.prototype.addLayer=function(e,n,r){void 0===r&&(r={}),this._checkLoaded();var i=e.id;if(this.getLayer(i))this.fire(new t.ErrorEvent(new Error('Layer with id "'+i+'" already exists on this map')));else{var o;if("custom"===e.type){if(Be(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(i,e.source),e=t.clone$1(e),e=t.extend(e,{source:i})),this._validate(t.validateStyle.layer,"layers."+i,e,{arrayIndex:-1},r))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize()}var a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.')));else{if(this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o,this._removedLayers[i]&&o.source&&"custom"!==o.type){var s=this._removedLayers[i];delete this._removedLayers[i],s.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}},n.prototype.moveLayer=function(e,n){if(this._checkLoaded(),this._changed=!0,this._layers[e]){if(e!==n){var r=this._order.indexOf(e);this._order.splice(r,1);var i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new t.ErrorEvent(new Error('Layer with id "'+n+'" does not exist on this map.'))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be moved.")))},n.prototype.removeLayer=function(e){this._checkLoaded();var n=this._layers[e];if(n){n.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be removed.")))},n.prototype.getLayer=function(t){return this._layers[t]},n.prototype.hasLayer=function(t){return t in this._layers},n.prototype.setLayerZoomRange=function(e,n,r){this._checkLoaded();var i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot have zoom extent.")))},n.prototype.setFilter=function(e,n,r){void 0===r&&(r={}),this._checkLoaded();var i=this.getLayer(e);if(i){if(!t.deepEqual(i.filter,n))return null==n?(i.filter=void 0,void this._updateLayer(i)):void(this._validate(t.validateStyle.filter,"layers."+i.id+".filter",n,null,r)||(i.filter=t.clone$1(n),this._updateLayer(i)))}else this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be filtered.")))},n.prototype.getFilter=function(e){return t.clone$1(this.getLayer(e).filter)},n.prototype.setLayoutProperty=function(e,n,r,i){void 0===i&&(i={}),this._checkLoaded();var o=this.getLayer(e);o?t.deepEqual(o.getLayoutProperty(n),r)||(o.setLayoutProperty(n,r,i),this._updateLayer(o)):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getLayoutProperty=function(e,n){var r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style.")))},n.prototype.setPaintProperty=function(e,n,r,i){void 0===i&&(i={}),this._checkLoaded();var o=this.getLayer(e);o?t.deepEqual(o.getPaintProperty(n),r)||(o.setPaintProperty(n,r,i)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error("The layer '"+e+"' does not exist in the map's style and cannot be styled.")))},n.prototype.getPaintProperty=function(t,e){return this.getLayer(t).getPaintProperty(e)},n.prototype.setFeatureState=function(e,n){this._checkLoaded();var r=e.source,i=e.sourceLayer,o=this.sourceCaches[r];if(void 0!==o){var a=o.getSource().type;"geojson"===a&&i?this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||i?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),o.setFeatureState(i,e.id,n)):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},n.prototype.removeFeatureState=function(e,n){this._checkLoaded();var r=e.source,i=this.sourceCaches[r];if(void 0!==i){var o=i.getSource().type,a="vector"===o?e.sourceLayer:void 0;"vector"!==o||a?n&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):i.removeFeatureState(a,e.id,n):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+r+"' does not exist in the map's style.")))},n.prototype.getFeatureState=function(e){this._checkLoaded();var n=e.source,r=e.sourceLayer,i=this.sourceCaches[n];if(void 0!==i){if("vector"!==i.getSource().type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),i.getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error("The source '"+n+"' does not exist in the map's style.")))},n.prototype.getTransition=function(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)},n.prototype.serialize=function(){return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,(function(t){return t.serialize()})),layers:this._serializeLayers(this._order)},(function(t){return void 0!==t}))},n.prototype._updateLayer=function(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0},n.prototype._flattenAndSortRenderedFeatures=function(t){for(var e=this,n=function(t){return"fill-extrusion"===e._layers[t].type},r={},i=[],o=this._order.length-1;o>=0;o--){var a=this._order[o];if(n(a)){r[a]=o;for(var s=0,l=t;s=0;f--){var d=this._order[f];if(n(d))for(var m=i.length-1;m>=0;m--){var g=i[m].feature;if(r[g.layer.id] 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,0.0,1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),$e=vn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),tn=vn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,0,1);}"),en=vn("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),nn=vn("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),rn=vn("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),on=vn("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),an=vn("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;varying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),sn=vn("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),ln=vn("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),un=vn("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),cn=vn("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_width2=vec2(outset,inset);}"),hn=vn("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_width2=vec2(outset,inset);}"),pn=vn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),fn=vn("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),dn=vn("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),mn=vn("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),0.0,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));}"),gn=vn("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),0.0,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),yn=vn("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,0.0,1.0);gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),0.0,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(1.0,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}");function vn(t,e){var n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),i=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=o?o.concat(i):i,s={};return{fragmentSource:t=t.replace(n,(function(t,e,n,r,i){return s[i]=!0,"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nvarying "+n+" "+r+" "+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"\n#ifdef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n"})),vertexSource:e=e.replace(n,(function(t,e,n,r,i){var o="float"===r?"vec2":"vec4",a=i.match(/color/)?"color":o;return s[i]?"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nuniform lowp float u_"+i+"_t;\nattribute "+n+" "+o+" a_"+i+";\nvarying "+n+" "+r+" "+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"vec4"===a?"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+i+" = a_"+i+";\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+i+" = unpack_mix_"+a+"(a_"+i+", u_"+i+"_t);\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"define"===e?"\n#ifndef HAS_UNIFORM_u_"+i+"\nuniform lowp float u_"+i+"_t;\nattribute "+n+" "+o+" a_"+i+";\n#else\nuniform "+n+" "+r+" u_"+i+";\n#endif\n":"vec4"===a?"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = a_"+i+";\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n":"\n#ifndef HAS_UNIFORM_u_"+i+"\n "+n+" "+r+" "+i+" = unpack_mix_"+a+"(a_"+i+", u_"+i+"_t);\n#else\n "+n+" "+r+" "+i+" = u_"+i+";\n#endif\n"})),staticAttributes:r,staticUniforms:a}}var _n=Object.freeze({__proto__:null,prelude:qe,background:We,backgroundPattern:Xe,circle:Ze,clippingMask:Ye,heatmap:Je,heatmapTexture:Ke,collisionBox:Qe,collisionCircle:$e,debug:tn,fill:en,fillOutline:nn,fillOutlinePattern:rn,fillPattern:on,fillExtrusion:an,fillExtrusionPattern:sn,hillshadePrepare:ln,hillshade:un,line:cn,lineGradient:hn,linePattern:pn,lineSDF:fn,raster:dn,symbolIcon:mn,symbolSDF:gn,symbolTextAndIcon:yn}),xn=function(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null};function bn(t){for(var e=[],n=0;n>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}wn.prototype.draw=function(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m){var g,y=t.gl;if(!this.failedToCreate){for(var v in t.program.set(this.program),t.setDepthMode(n),t.setStencilMode(r),t.setColorMode(i),t.setCullFace(o),this.fixedUniforms)this.fixedUniforms[v].set(a[v]);f&&f.setUniforms(t,this.binderUniforms,h,{zoom:p});for(var _=(g={},g[y.LINES]=2,g[y.TRIANGLES]=3,g[y.LINE_STRIP]=1,g)[e],x=0,b=c.get();x0?1-1/(1.001-a):-a),u_contrast_factor:(o=i.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:jn(i.paint.get("raster-hue-rotate"))};var o,a};function jn(t){t*=Math.PI/180;var e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}var Hn,qn=function(t,e,n,r,i,o,a,s,l,u){var c=i.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:c.width/c.height,u_fade_change:i.options.fadeDuration?i.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:u,u_texture:0}},Wn=function(e,n,r,i,o,a,s,l,u,c,h){var p=o.transform;return t.extend(qn(e,n,r,i,o,a,s,l,u,c),{u_gamma_scale:i?Math.cos(p._pitch)*p.cameraToCenterDistance:1,u_device_pixel_ratio:t.browser.devicePixelRatio,u_is_halo:+h})},Xn=function(e,n,r,i,o,a,s,l,u,c){return t.extend(Wn(e,n,r,i,o,a,s,l,!0,u,!0),{u_texsize_icon:c,u_texture_icon:1})},Zn=function(t,e,n){return{u_matrix:t,u_opacity:e,u_color:n}},Yn=function(e,n,r,i,o,a){return t.extend(function(t,e,n,r){var i=n.imageManager.getPattern(t.from.toString()),o=n.imageManager.getPattern(t.to.toString()),a=n.imageManager.getPixelSize(),s=a.width,l=a.height,u=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,n.transform.tileZoom)/u,h=c*(r.tileID.canonical.x+r.tileID.wrap*u),p=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,l],u_mix:e.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/pe(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,p>>16],u_pixel_coord_lower:[65535&h,65535&p]}}(i,a,r,o),{u_matrix:e,u_opacity:n})},Jn={fillExtrusion:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_lightpos:new t.Uniform3f(e,n.u_lightpos),u_lightintensity:new t.Uniform1f(e,n.u_lightintensity),u_lightcolor:new t.Uniform3f(e,n.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,n.u_vertical_gradient),u_opacity:new t.Uniform1f(e,n.u_opacity)}},fillExtrusionPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_lightpos:new t.Uniform3f(e,n.u_lightpos),u_lightintensity:new t.Uniform1f(e,n.u_lightintensity),u_lightcolor:new t.Uniform3f(e,n.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,n.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,n.u_height_factor),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade),u_opacity:new t.Uniform1f(e,n.u_opacity)}},fill:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},fillPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},fillOutline:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world)}},fillOutlinePattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world),u_image:new t.Uniform1i(e,n.u_image),u_texsize:new t.Uniform2f(e,n.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},circle:function(e,n){return{u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_scale_with_map:new t.Uniform1i(e,n.u_scale_with_map),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_extrude_scale:new t.Uniform2f(e,n.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},collisionBox:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pixels_to_tile_units:new t.Uniform1f(e,n.u_pixels_to_tile_units),u_extrude_scale:new t.Uniform2f(e,n.u_extrude_scale),u_overscale_factor:new t.Uniform1f(e,n.u_overscale_factor)}},collisionCircle:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,n.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,n.u_viewport_size)}},debug:function(e,n){return{u_color:new t.UniformColor(e,n.u_color),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_overlay:new t.Uniform1i(e,n.u_overlay),u_overlay_scale:new t.Uniform1f(e,n.u_overlay_scale)}},clippingMask:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},heatmap:function(e,n){return{u_extrude_scale:new t.Uniform1f(e,n.u_extrude_scale),u_intensity:new t.Uniform1f(e,n.u_intensity),u_matrix:new t.UniformMatrix4f(e,n.u_matrix)}},heatmapTexture:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_world:new t.Uniform2f(e,n.u_world),u_image:new t.Uniform1i(e,n.u_image),u_color_ramp:new t.Uniform1i(e,n.u_color_ramp),u_opacity:new t.Uniform1f(e,n.u_opacity)}},hillshade:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_latrange:new t.Uniform2f(e,n.u_latrange),u_light:new t.Uniform2f(e,n.u_light),u_shadow:new t.UniformColor(e,n.u_shadow),u_highlight:new t.UniformColor(e,n.u_highlight),u_accent:new t.UniformColor(e,n.u_accent)}},hillshadePrepare:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_image:new t.Uniform1i(e,n.u_image),u_dimension:new t.Uniform2f(e,n.u_dimension),u_zoom:new t.Uniform1f(e,n.u_zoom),u_unpack:new t.Uniform4f(e,n.u_unpack)}},line:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels)}},lineGradient:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_image:new t.Uniform1i(e,n.u_image),u_image_height:new t.Uniform1f(e,n.u_image_height)}},linePattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_texsize:new t.Uniform2f(e,n.u_texsize),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_image:new t.Uniform1i(e,n.u_image),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_scale:new t.Uniform3f(e,n.u_scale),u_fade:new t.Uniform1f(e,n.u_fade)}},lineSDF:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_ratio:new t.Uniform1f(e,n.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,n.u_units_to_pixels),u_patternscale_a:new t.Uniform2f(e,n.u_patternscale_a),u_patternscale_b:new t.Uniform2f(e,n.u_patternscale_b),u_sdfgamma:new t.Uniform1f(e,n.u_sdfgamma),u_image:new t.Uniform1i(e,n.u_image),u_tex_y_a:new t.Uniform1f(e,n.u_tex_y_a),u_tex_y_b:new t.Uniform1f(e,n.u_tex_y_b),u_mix:new t.Uniform1f(e,n.u_mix)}},raster:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_tl_parent:new t.Uniform2f(e,n.u_tl_parent),u_scale_parent:new t.Uniform1f(e,n.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,n.u_buffer_scale),u_fade_t:new t.Uniform1f(e,n.u_fade_t),u_opacity:new t.Uniform1f(e,n.u_opacity),u_image0:new t.Uniform1i(e,n.u_image0),u_image1:new t.Uniform1i(e,n.u_image1),u_brightness_low:new t.Uniform1f(e,n.u_brightness_low),u_brightness_high:new t.Uniform1f(e,n.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,n.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,n.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,n.u_spin_weights)}},symbolIcon:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texture:new t.Uniform1i(e,n.u_texture)}},symbolSDF:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texture:new t.Uniform1i(e,n.u_texture),u_gamma_scale:new t.Uniform1f(e,n.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,n.u_is_halo)}},symbolTextAndIcon:function(e,n){return{u_is_size_zoom_constant:new t.Uniform1i(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,n.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,n.u_size_t),u_size:new t.Uniform1f(e,n.u_size),u_camera_to_center_distance:new t.Uniform1f(e,n.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,n.u_pitch),u_rotate_symbol:new t.Uniform1i(e,n.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,n.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,n.u_fade_change),u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,n.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,n.u_coord_matrix),u_is_text:new t.Uniform1i(e,n.u_is_text),u_pitch_with_map:new t.Uniform1i(e,n.u_pitch_with_map),u_texsize:new t.Uniform2f(e,n.u_texsize),u_texsize_icon:new t.Uniform2f(e,n.u_texsize_icon),u_texture:new t.Uniform1i(e,n.u_texture),u_texture_icon:new t.Uniform1i(e,n.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,n.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,n.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,n.u_is_halo)}},background:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_opacity:new t.Uniform1f(e,n.u_opacity),u_color:new t.UniformColor(e,n.u_color)}},backgroundPattern:function(e,n){return{u_matrix:new t.UniformMatrix4f(e,n.u_matrix),u_opacity:new t.Uniform1f(e,n.u_opacity),u_image:new t.Uniform1i(e,n.u_image),u_pattern_tl_a:new t.Uniform2f(e,n.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,n.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,n.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,n.u_pattern_br_b),u_texsize:new t.Uniform2f(e,n.u_texsize),u_mix:new t.Uniform1f(e,n.u_mix),u_pattern_size_a:new t.Uniform2f(e,n.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,n.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,n.u_scale_a),u_scale_b:new t.Uniform1f(e,n.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,n.u_tile_units_to_pixels)}}};function Kn(e,n,r,i,o,a,s){for(var l=e.context,u=l.gl,c=e.useProgram("collisionBox"),h=[],p=0,f=0,d=0;d0){var b=t.create(),w=v;t.mul(b,y.placementInvProjMatrix,e.transform.glCoordMatrix),t.mul(b,b,y.placementViewportMatrix),h.push({circleArray:x,circleOffset:f,transform:w,invTransform:b}),f=p+=x.length/4}_&&c.draw(l,u.LINES,Mt.disabled,Tt.disabled,e.colorModeForRenderPass(),It.disabled,Pn(v,e.transform,g),r.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,null,e.transform.zoom,null,null,_.collisionVertexBuffer)}}if(s&&h.length){var E=e.useProgram("collisionCircle"),S=new t.StructArrayLayout2f1f2i16;S.resize(4*p),S._trim();for(var M=0,T=0,C=h;T=0&&(m[y.associatedIconIndex]={shiftedAnchor:S,angle:M})}else ue(y.numGlyphs,f)}if(h){d.clear();for(var C=e.icon.placedSymbolArray,I=0;I0){var s=t.browser.now(),l=(s-e.timeAdded)/a,u=n?(s-n.timeAdded)/a:-1,c=r.getSource(),h=o.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),p=!n||Math.abs(n.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),f=p&&e.refreshedUponExpiration?1:t.clamp(p?l:1-u,0,1);return e.refreshedUponExpiration&&l>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-f}:{opacity:f,mix:0}}return{opacity:1,mix:0}}var ur=new t.Color(1,0,0,1),cr=new t.Color(0,1,0,1),hr=new t.Color(0,0,1,1),pr=new t.Color(1,0,1,1),fr=new t.Color(0,1,1,1);function dr(t,e,n,r){gr(t,0,e+n/2,t.transform.width,n,r)}function mr(t,e,n,r){gr(t,e-n/2,0,n,t.transform.height,r)}function gr(e,n,r,i,o,a){var s=e.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*t.browser.devicePixelRatio,r*t.browser.devicePixelRatio,i*t.browser.devicePixelRatio,o*t.browser.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}function yr(e,n,r){var i=e.context,o=i.gl,a=r.posMatrix,s=e.useProgram("debug"),l=Mt.disabled,u=Tt.disabled,c=e.colorModeForRenderPass();i.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.draw(i,o.LINE_STRIP,l,u,c,It.disabled,Dn(a,t.Color.red),"$debug",e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);var h=n.getTileByID(r.key).latestRawTileData,p=Math.floor((h&&h.byteLength||0)/1024),f=n.getTile(r).tileSize,d=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5,m=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(m+=" => "+r.overscaledZ),function(t,e){t.initDebugOverlayCanvas();var n=t.debugOverlayCanvas,r=t.context.gl,i=t.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(e,5,5),i.strokeText(e,5,5),t.debugOverlayTexture.update(n),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,m+" "+p+"kb"),s.draw(i,o.TRIANGLES,l,u,Ct.alphaBlended,It.disabled,Dn(a,t.Color.transparent,d),"$debug",e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments)}var vr={symbol:function(e,n,r,i,o){if("translucent"===e.renderPass){var a=Tt.disabled,s=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,n,r,i,o,a,s){for(var l=n.transform,u="map"===o,c="map"===a,h=0,p=e;h256&&this.clearStencil(),n.setColorMode(Ct.disabled),n.setDepthMode(Mt.disabled);var i=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(var o=0,a=e;o256&&this.clearStencil();var t=this.nextStencilID++,e=this.context.gl;return new Tt({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)},_r.prototype.stencilModeForClipping=function(t){var e=this.context.gl;return new Tt({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)},_r.prototype.stencilConfigForOverlap=function(t){var e,n=this.context.gl,r=t.sort((function(t,e){return e.overscaledZ-t.overscaledZ})),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();for(var a={},s=0;s=0;this.currentLayer--){var x=this.style._layers[i[this.currentLayer]],b=o[x.source],w=c[x.source];this._renderTileClippingMasks(x,w),this.renderLayer(this,b,x,w)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer0?e.pop():null},_r.prototype.isPatternMissing=function(t){if(!t)return!1;if(!t.from||!t.to)return!0;var e=this.imageManager.getPattern(t.from.toString()),n=this.imageManager.getPattern(t.to.toString());return!e||!n},_r.prototype.useProgram=function(t,e){this.cache=this.cache||{};var n=""+t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"");return this.cache[n]||(this.cache[n]=new wn(this.context,t,_n[t],e,Jn[t],this._showOverdrawInspector)),this.cache[n]},_r.prototype.setCustomLayerDefaults=function(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()},_r.prototype.setBaseState=function(){var t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)},_r.prototype.initDebugOverlayCanvas=function(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))},_r.prototype.destroy=function(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()};var xr=function(t,e){this.points=t,this.planes=e};xr.fromInvProjectionMatrix=function(e,n,r){var i=Math.pow(2,r),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((function(n){return t.transformMat4([],n,e)})).map((function(e){return t.scale$1([],e,1/e[3]/n*i)})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((function(e){var n=t.sub([],o[e[0]],o[e[1]]),r=t.sub([],o[e[2]],o[e[1]]),i=t.normalize([],t.cross([],n,r)),a=-t.dot(i,o[e[1]]);return i.concat(a)}));return new xr(o,a)};var br=function(e,n){this.min=e,this.max=n,this.center=t.scale$2([],t.add([],this.min,this.max),.5)};br.prototype.quadrant=function(e){for(var n=[e%2==0,e<2],r=t.clone$2(this.min),i=t.clone$2(this.max),o=0;o=0;if(0===a)return 0;a!==n.length&&(r=!1)}if(r)return 2;for(var l=0;l<3;l++){for(var u=Number.MAX_VALUE,c=-Number.MAX_VALUE,h=0;hthis.max[l]-this.min[l])return 0}return 1};var wr=function(t,e,n,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),isNaN(t)||t<0||isNaN(e)||e<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=n,this.right=r};wr.prototype.interpolate=function(e,n,r){return null!=n.top&&null!=e.top&&(this.top=t.number(e.top,n.top,r)),null!=n.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,n.bottom,r)),null!=n.left&&null!=e.left&&(this.left=t.number(e.left,n.left,r)),null!=n.right&&null!=e.right&&(this.right=t.number(e.right,n.right,r)),this},wr.prototype.getCenter=function(e,n){var r=t.clamp((this.left+e-this.right)/2,0,e),i=t.clamp((this.top+n-this.bottom)/2,0,n);return new t.Point(r,i)},wr.prototype.equals=function(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right},wr.prototype.clone=function(){return new wr(this.top,this.bottom,this.left,this.right)},wr.prototype.toJSON=function(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}};var Er=function(e,n,r,i,o){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new wr,this._posMatrixCache={},this._alignedPosMatrixCache={}},Sr={minZoom:{configurable:!0},maxZoom:{configurable:!0},minPitch:{configurable:!0},maxPitch:{configurable:!0},renderWorldCopies:{configurable:!0},worldSize:{configurable:!0},centerOffset:{configurable:!0},size:{configurable:!0},bearing:{configurable:!0},pitch:{configurable:!0},fov:{configurable:!0},zoom:{configurable:!0},center:{configurable:!0},padding:{configurable:!0},centerPoint:{configurable:!0},unmodified:{configurable:!0},point:{configurable:!0}};Er.prototype.clone=function(){var t=new Er(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t},Sr.minZoom.get=function(){return this._minZoom},Sr.minZoom.set=function(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))},Sr.maxZoom.get=function(){return this._maxZoom},Sr.maxZoom.set=function(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))},Sr.minPitch.get=function(){return this._minPitch},Sr.minPitch.set=function(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))},Sr.maxPitch.get=function(){return this._maxPitch},Sr.maxPitch.set=function(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))},Sr.renderWorldCopies.get=function(){return this._renderWorldCopies},Sr.renderWorldCopies.set=function(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t},Sr.worldSize.get=function(){return this.tileSize*this.scale},Sr.centerOffset.get=function(){return this.centerPoint._sub(this.size._div(2))},Sr.size.get=function(){return new t.Point(this.width,this.height)},Sr.bearing.get=function(){return-this.angle/Math.PI*180},Sr.bearing.set=function(e){var n=-t.wrap(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=t.create$2(),t.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))},Sr.pitch.get=function(){return this._pitch/Math.PI*180},Sr.pitch.set=function(e){var n=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())},Sr.fov.get=function(){return this._fov/Math.PI*180},Sr.fov.set=function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())},Sr.zoom.get=function(){return this._zoom},Sr.zoom.set=function(t){var e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())},Sr.center.get=function(){return this._center},Sr.center.set=function(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())},Sr.padding.get=function(){return this._edgeInsets.toJSON()},Sr.padding.set=function(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())},Sr.centerPoint.get=function(){return this._edgeInsets.getCenter(this.width,this.height)},Er.prototype.isPaddingEqual=function(t){return this._edgeInsets.equals(t)},Er.prototype.interpolatePadding=function(t,e,n){this._unmodified=!1,this._edgeInsets.interpolate(t,e,n),this._constrain(),this._calcMatrices()},Er.prototype.coveringZoomLevel=function(t){var e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)},Er.prototype.getVisibleUnwrappedCoordinates=function(e){var n=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies)for(var r=this.pointCoordinate(new t.Point(0,0)),i=this.pointCoordinate(new t.Point(this.width,0)),o=this.pointCoordinate(new t.Point(this.width,this.height)),a=this.pointCoordinate(new t.Point(0,this.height)),s=Math.floor(Math.min(r.x,i.x,o.x,a.x)),l=Math.floor(Math.max(r.x,i.x,o.x,a.x)),u=s-1;u<=l+1;u++)0!==u&&n.push(new t.UnwrappedTileID(u,e));return n},Er.prototype.coveringTiles=function(e){var n=this.coveringZoomLevel(e),r=n;if(void 0!==e.minzoom&&ne.maxzoom&&(n=e.maxzoom);var i=t.MercatorCoordinate.fromLngLat(this.center),o=Math.pow(2,n),a=[o*i.x,o*i.y,0],s=xr.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n),l=e.minzoom||0;this.pitch<=60&&this._edgeInsets.top<.1&&(l=n);var u=function(t){return{aabb:new br([t*o,0,0],[(t+1)*o,o,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}},c=[],h=[],p=n,f=e.reparseOverscaled?r:n;if(this._renderWorldCopies)for(var d=1;d<=3;d++)c.push(u(-d)),c.push(u(d));for(c.push(u(0));c.length>0;){var m=c.pop(),g=m.x,y=m.y,v=m.fullyVisible;if(!v){var _=m.aabb.intersects(s);if(0===_)continue;v=2===_}var x=m.aabb.distanceX(a),b=m.aabb.distanceY(a),w=Math.max(Math.abs(x),Math.abs(b));if(m.zoom===p||w>3+(1<=l)h.push({tileID:new t.OverscaledTileID(m.zoom===p?f:m.zoom,m.wrap,m.zoom,g,y),distanceSq:t.sqrLen([a[0]-.5-g,a[1]-.5-y])});else for(var E=0;E<4;E++){var S=(g<<1)+E%2,M=(y<<1)+(E>>1);c.push({aabb:m.aabb.quadrant(E),zoom:m.zoom+1,x:S,y:M,wrap:m.wrap,fullyVisible:v})}}return h.sort((function(t,e){return t.distanceSq-e.distanceSq})).map((function(t){return t.tileID}))},Er.prototype.resize=function(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()},Sr.unmodified.get=function(){return this._unmodified},Er.prototype.zoomScale=function(t){return Math.pow(2,t)},Er.prototype.scaleZoom=function(t){return Math.log(t)/Math.LN2},Er.prototype.project=function(e){var n=t.clamp(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.Point(t.mercatorXfromLng(e.lng)*this.worldSize,t.mercatorYfromLat(n)*this.worldSize)},Er.prototype.unproject=function(e){return new t.MercatorCoordinate(e.x/this.worldSize,e.y/this.worldSize).toLngLat()},Sr.point.get=function(){return this.project(this.center)},Er.prototype.setLocationAtPoint=function(e,n){var r=this.pointCoordinate(n),i=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(e),a=new t.MercatorCoordinate(o.x-(r.x-i.x),o.y-(r.y-i.y));this.center=this.coordinateLocation(a),this._renderWorldCopies&&(this.center=this.center.wrap())},Er.prototype.locationPoint=function(t){return this.coordinatePoint(this.locationCoordinate(t))},Er.prototype.pointLocation=function(t){return this.coordinateLocation(this.pointCoordinate(t))},Er.prototype.locationCoordinate=function(e){return t.MercatorCoordinate.fromLngLat(e)},Er.prototype.coordinateLocation=function(t){return t.toLngLat()},Er.prototype.pointCoordinate=function(e){var n=[e.x,e.y,0,1],r=[e.x,e.y,1,1];t.transformMat4(n,n,this.pixelMatrixInverse),t.transformMat4(r,r,this.pixelMatrixInverse);var i=n[3],o=r[3],a=n[1]/i,s=r[1]/o,l=n[2]/i,u=r[2]/o,c=l===u?0:(0-l)/(u-l);return new t.MercatorCoordinate(t.number(n[0]/i,r[0]/o,c)/this.worldSize,t.number(a,s,c)/this.worldSize)},Er.prototype.coordinatePoint=function(e){var n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(n,n,this.pixelMatrix),new t.Point(n[0]/n[3],n[1]/n[3])},Er.prototype.getBounds=function(){return(new t.LngLatBounds).extend(this.pointLocation(new t.Point(0,0))).extend(this.pointLocation(new t.Point(this.width,0))).extend(this.pointLocation(new t.Point(this.width,this.height))).extend(this.pointLocation(new t.Point(0,this.height)))},Er.prototype.getMaxBounds=function(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new t.LngLatBounds([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null},Er.prototype.setMaxBounds=function(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])},Er.prototype.calculatePosMatrix=function(e,n){void 0===n&&(n=!1);var r=e.key,i=n?this._alignedPosMatrixCache:this._posMatrixCache;if(i[r])return i[r];var o=e.canonical,a=this.worldSize/this.zoomScale(o.z),s=o.x+Math.pow(2,o.z)*e.wrap,l=t.identity(new Float64Array(16));return t.translate(l,l,[s*a,o.y*a,0]),t.scale(l,l,[a/t.EXTENT,a/t.EXTENT,1]),t.multiply(l,n?this.alignedProjMatrix:this.projMatrix,l),i[r]=new Float32Array(l),i[r]},Er.prototype.customLayerMatrix=function(){return this.mercatorMatrix.slice()},Er.prototype._constrain=function(){if(this.center&&this.width&&this.height&&!this._constraining){this._constraining=!0;var e,n,r,i,o=-90,a=90,s=-180,l=180,u=this.size,c=this._unmodified;if(this.latRange){var h=this.latRange;o=t.mercatorYfromLat(h[1])*this.worldSize,e=(a=t.mercatorYfromLat(h[0])*this.worldSize)-oa&&(i=a-g)}if(this.lngRange){var y=f.x,v=u.x/2;y-vl&&(r=l-v)}void 0===r&&void 0===i||(this.center=this.unproject(new t.Point(void 0!==r?r:f.x,void 0!==i?i:f.y))),this._unmodified=c,this._constraining=!1}},Er.prototype._calcMatrices=function(){if(this.height){var e=this.centerOffset;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height;var n=Math.PI/2+this._pitch,r=this._fov*(.5+e.y/this.height),i=Math.sin(r)*this.cameraToCenterDistance/Math.sin(t.clamp(Math.PI-n-r,.01,Math.PI-.01)),o=this.point,a=o.x,s=o.y,l=1.01*(Math.cos(Math.PI/2-this._pitch)*i+this.cameraToCenterDistance),u=this.height/50,c=new Float64Array(16);t.perspective(c,this._fov,this.width/this.height,u,l),c[8]=2*-e.x/this.width,c[9]=2*e.y/this.height,t.scale(c,c,[1,-1,1]),t.translate(c,c,[0,0,-this.cameraToCenterDistance]),t.rotateX(c,c,this._pitch),t.rotateZ(c,c,this.angle),t.translate(c,c,[-a,-s,0]),this.mercatorMatrix=t.scale([],c,[this.worldSize,this.worldSize,this.worldSize]),t.scale(c,c,[1,1,t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,1]),this.projMatrix=c,this.invProjMatrix=t.invert([],this.projMatrix);var h=this.width%2/2,p=this.height%2/2,f=Math.cos(this.angle),d=Math.sin(this.angle),m=a-Math.round(a)+f*h+d*p,g=s-Math.round(s)+f*p+d*h,y=new Float64Array(c);if(t.translate(y,y,[m>.5?m-1:m,g>.5?g-1:g,0]),this.alignedProjMatrix=y,c=t.create(),t.scale(c,c,[this.width/2,-this.height/2,1]),t.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=t.create(),t.scale(c,c,[1,-1,1]),t.translate(c,c,[-1,-1,0]),t.scale(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),!(c=t.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=c,this._posMatrixCache={},this._alignedPosMatrixCache={}}},Er.prototype.maxPitchScaleFactor=function(){if(!this.pixelMatrixInverse)return 1;var e=this.pointCoordinate(new t.Point(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance},Er.prototype.getCameraPoint=function(){var e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,e))},Er.prototype.getCameraQueryGeometry=function(e){var n=this.getCameraPoint();if(1===e.length)return[e[0],n];for(var r=n.x,i=n.y,o=n.x,a=n.y,s=0,l=e;s=3&&!t.some((function(t){return isNaN(t)}))){var e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},Mr.prototype._updateHashUnthrottled=function(){var e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());try{t.window.history.replaceState(t.window.history.state,null,e)}catch(t){}};var Tr={linearity:.3,easing:t.bezier(0,0,.3,1)},Cr=t.extend({deceleration:2500,maxSpeed:1400},Tr),Ir=t.extend({deceleration:20,maxSpeed:1400},Tr),Ar=t.extend({deceleration:1e3,maxSpeed:360},Tr),Lr=t.extend({deceleration:1e3,maxSpeed:90},Tr),Pr=function(t){this._map=t,this.clear()};function Rr(t,e){(!t.duration||t.duration0&&n-e[0].time>160;)e.shift()},Pr.prototype._onMoveEnd=function(e){if(this._drainInertiaBuffer(),!(this._inertiaBuffer.length<2)){for(var n={zoom:0,bearing:0,pitch:0,pan:new t.Point(0,0),pinchAround:void 0,around:void 0},r=0,i=this._inertiaBuffer;r=this._clickTolerance||this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.dblclick=function(t){return this._firePreventable(new Nr(t.type,this._map,t))},zr.prototype.mouseover=function(t){this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.mouseout=function(t){this._map.fire(new Nr(t.type,this._map,t))},zr.prototype.touchstart=function(t){return this._firePreventable(new Or(t.type,this._map,t))},zr.prototype.touchmove=function(t){this._map.fire(new Or(t.type,this._map,t))},zr.prototype.touchend=function(t){this._map.fire(new Or(t.type,this._map,t))},zr.prototype.touchcancel=function(t){this._map.fire(new Or(t.type,this._map,t))},zr.prototype._firePreventable=function(t){if(this._map.fire(t),t.defaultPrevented)return{}},zr.prototype.isEnabled=function(){return!0},zr.prototype.isActive=function(){return!1},zr.prototype.enable=function(){},zr.prototype.disable=function(){};var Fr=function(t){this._map=t};Fr.prototype.reset=function(){this._delayContextMenu=!1,delete this._contextMenuEvent},Fr.prototype.mousemove=function(t){this._map.fire(new Nr(t.type,this._map,t))},Fr.prototype.mousedown=function(){this._delayContextMenu=!0},Fr.prototype.mouseup=function(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Nr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)},Fr.prototype.contextmenu=function(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new Nr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()},Fr.prototype.isEnabled=function(){return!0},Fr.prototype.isActive=function(){return!1},Fr.prototype.enable=function(){},Fr.prototype.disable=function(){};var Br=function(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1};function Ur(t,e){for(var n={},r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){for(var n=new t.Point(0,0),r=0,i=e;r30)&&(this.aborted=!0)}}},Vr.prototype.touchend=function(t,e,n){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){var r=!this.aborted&&this.centroid;if(this.reset(),r)return r}};var Gr=function(t){this.singleTap=new Vr(t),this.numTaps=t.numTaps,this.reset()};Gr.prototype.reset=function(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()},Gr.prototype.touchstart=function(t,e,n){this.singleTap.touchstart(t,e,n)},Gr.prototype.touchmove=function(t,e,n){this.singleTap.touchmove(t,e,n)},Gr.prototype.touchend=function(t,e,n){var r=this.singleTap.touchend(t,e,n);if(r){var i=t.timeStamp-this.lastTime<500,o=!this.lastTap||this.lastTap.dist(r)<30;if(i&&o||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}};var jr=function(){this._zoomIn=new Gr({numTouches:1,numTaps:2}),this._zoomOut=new Gr({numTouches:2,numTaps:1}),this.reset()};jr.prototype.reset=function(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()},jr.prototype.touchstart=function(t,e,n){this._zoomIn.touchstart(t,e,n),this._zoomOut.touchstart(t,e,n)},jr.prototype.touchmove=function(t,e,n){this._zoomIn.touchmove(t,e,n),this._zoomOut.touchmove(t,e,n)},jr.prototype.touchend=function(t,e,n){var r=this,i=this._zoomIn.touchend(t,e,n),o=this._zoomOut.touchend(t,e,n);return i?(this._active=!0,t.preventDefault(),setTimeout((function(){return r.reset()}),0),{cameraAnimation:function(e){return e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(i)},{originalEvent:t})}}):o?(this._active=!0,t.preventDefault(),setTimeout((function(){return r.reset()}),0),{cameraAnimation:function(e){return e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(o)},{originalEvent:t})}}):void 0},jr.prototype.touchcancel=function(){this.reset()},jr.prototype.enable=function(){this._enabled=!0},jr.prototype.disable=function(){this._enabled=!1,this.reset()},jr.prototype.isEnabled=function(){return this._enabled},jr.prototype.isActive=function(){return this._active};var Hr={0:1,2:2},qr=function(t){this.reset(),this._clickTolerance=t.clickTolerance||1};qr.prototype.reset=function(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton},qr.prototype._correctButton=function(t,e){return!1},qr.prototype._move=function(t,e){return{}},qr.prototype.mousedown=function(t,e){if(!this._lastPoint){var r=n.mouseButton(t);this._correctButton(t,r)&&(this._lastPoint=e,this._eventButton=r)}},qr.prototype.mousemoveWindow=function(t,e){var n=this._lastPoint;if(n)if(t.preventDefault(),function(t,e){var n=Hr[e];return void 0===t.buttons||(t.buttons&n)!==n}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(n)0&&(this._active=!0);var i=Ur(r,n),o=new t.Point(0,0),a=new t.Point(0,0),s=0;for(var l in i){var u=i[l],c=this._touches[l];c&&(o._add(u),a._add(u.sub(c)),s++,i[l]=u)}if(this._touches=i,!(sMath.abs(t.x)}var ri=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.reset=function(){t.prototype.reset.call(this),this._valid=void 0,delete this._firstMove,delete this._lastPoints},e.prototype._start=function(t){this._lastPoints=t,ni(t[0].sub(t[1]))&&(this._valid=!1)},e.prototype._move=function(t,e,n){var r=t[0].sub(this._lastPoints[0]),i=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}},e.prototype.gestureBeginsVertically=function(t,e,n){if(void 0!==this._valid)return this._valid;var r=t.mag()>=2,i=e.mag()>=2;if(r||i){if(!r||!i)return void 0===this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;var o=t.y>0==e.y>0;return ni(t)&&ni(e)&&o}},e}(Jr),ii={panStep:100,bearingStep:15,pitchStep:10},oi=function(){var t=ii;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1};function ai(t){return t*(2-t)}oi.prototype.reset=function(){this._active=!1},oi.prototype.keydown=function(t){var e=this;if(!(t.altKey||t.ctrlKey||t.metaKey)){var n=0,r=0,i=0,o=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),o=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),o=1);break;case 38:t.shiftKey?i=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?i=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:function(s){var l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:ai,zoom:n?Math.round(l)+n*(t.shiftKey?2:1):l,bearing:s.getBearing()+r*e._bearingStep,pitch:s.getPitch()+i*e._pitchStep,offset:[-o*e._panStep,-a*e._panStep],center:s.getCenter()},{originalEvent:t})}}}},oi.prototype.enable=function(){this._enabled=!0},oi.prototype.disable=function(){this._enabled=!1,this.reset()},oi.prototype.isEnabled=function(){return this._enabled},oi.prototype.isActive=function(){return this._active},oi.prototype.disableRotation=function(){this._rotationDisabled=!0},oi.prototype.enableRotation=function(){this._rotationDisabled=!1};var si=function(e,n){this._map=e,this._el=e.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=1/450,t.bindAll(["_onTimeout"],this)};si.prototype.setZoomRate=function(t){this._defaultZoomRate=t},si.prototype.setWheelZoomRate=function(t){this._wheelZoomRate=t},si.prototype.isEnabled=function(){return!!this._enabled},si.prototype.isActive=function(){return!!this._active||void 0!==this._finishTimeout},si.prototype.isZooming=function(){return!!this._zooming},si.prototype.enable=function(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)},si.prototype.disable=function(){this.isEnabled()&&(this._enabled=!1)},si.prototype.wheel=function(e){if(this.isEnabled()){var n=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,r=t.browser.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}},si.prototype._onTimeout=function(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},si.prototype._start=function(e){if(this._delta){this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);var r=n.mousePos(this._el,e);this._around=t.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(r)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}},si.prototype.renderFrame=function(){var e=this;if(this._frameId&&(this._frameId=null,this.isActive())){var n=this._map.transform;if(0!==this._delta){var r="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==i&&(i=1/i);var o="number"==typeof this._targetZoom?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(o*i))),"wheel"===this._type&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}var a,s="number"==typeof this._targetZoom?this._targetZoom:n.zoom,l=this._startZoom,u=this._easing,c=!1;if("wheel"===this._type&&l&&u){var h=Math.min((t.browser.now()-this._lastWheelEventTime)/200,1),p=u(h);a=t.number(l,s,p),h<1?this._frameId||(this._frameId=!0):c=!0}else a=s,c=!0;return this._active=!0,c&&(this._active=!1,this._finishTimeout=setTimeout((function(){e._zooming=!1,e._handler._triggerRenderFrame(),delete e._targetZoom,delete e._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!c,zoomDelta:a-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}},si.prototype._smoothOutEasing=function(e){var n=t.ease;if(this._prevEase){var r=this._prevEase,i=(t.browser.now()-r.start)/r.duration,o=r.easing(i+.01)-r.easing(i),a=.27/Math.sqrt(o*o+1e-4)*.01,s=Math.sqrt(.0729-a*a);n=t.bezier(a,s,.25,1)}return this._prevEase={start:t.browser.now(),duration:e,easing:n},n},si.prototype.reset=function(){this._active=!1};var li=function(t,e){this._clickZoom=t,this._tapZoom=e};li.prototype.enable=function(){this._clickZoom.enable(),this._tapZoom.enable()},li.prototype.disable=function(){this._clickZoom.disable(),this._tapZoom.disable()},li.prototype.isEnabled=function(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()},li.prototype.isActive=function(){return this._clickZoom.isActive()||this._tapZoom.isActive()};var ui=function(){this.reset()};ui.prototype.reset=function(){this._active=!1},ui.prototype.dblclick=function(t,e){return t.preventDefault(),{cameraAnimation:function(n){n.easeTo({duration:300,zoom:n.getZoom()+(t.shiftKey?-1:1),around:n.unproject(e)},{originalEvent:t})}}},ui.prototype.enable=function(){this._enabled=!0},ui.prototype.disable=function(){this._enabled=!1,this.reset()},ui.prototype.isEnabled=function(){return this._enabled},ui.prototype.isActive=function(){return this._active};var ci=function(){this._tap=new Gr({numTouches:1,numTaps:1}),this.reset()};ci.prototype.reset=function(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()},ci.prototype.touchstart=function(t,e,n){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=e[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(t,e,n))},ci.prototype.touchmove=function(t,e,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;var r=e[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(t,e,n)},ci.prototype.touchend=function(t,e,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(t,e,n)&&(this._tapTime=t.timeStamp)},ci.prototype.touchcancel=function(){this.reset()},ci.prototype.enable=function(){this._enabled=!0},ci.prototype.disable=function(){this._enabled=!1,this.reset()},ci.prototype.isEnabled=function(){return this._enabled},ci.prototype.isActive=function(){return this._active};var hi=function(t,e,n){this._el=t,this._mousePan=e,this._touchPan=n};hi.prototype.enable=function(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")},hi.prototype.disable=function(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")},hi.prototype.isEnabled=function(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()},hi.prototype.isActive=function(){return this._mousePan.isActive()||this._touchPan.isActive()};var pi=function(t,e,n){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=n};pi.prototype.enable=function(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()},pi.prototype.disable=function(){this._mouseRotate.disable(),this._mousePitch.disable()},pi.prototype.isEnabled=function(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())},pi.prototype.isActive=function(){return this._mouseRotate.isActive()||this._mousePitch.isActive()};var fi=function(t,e,n,r){this._el=t,this._touchZoom=e,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0};fi.prototype.enable=function(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")},fi.prototype.disable=function(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")},fi.prototype.isEnabled=function(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()},fi.prototype.isActive=function(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()},fi.prototype.disableRotation=function(){this._rotationDisabled=!0,this._touchRotate.disable()},fi.prototype.enableRotation=function(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()};var di=function(t){return t.zoom||t.drag||t.pitch||t.rotate},mi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(t.Event);function gi(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}var yi=function(e,r){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pr(e),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r),t.bindAll(["handleEvent","handleWindowEvent"],this);var i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[t.window,"blur",void 0]];for(var o=0,a=this._listeners;oo?Math.min(2,b):Math.max(.5,b),w=Math.pow(g,1-e),E=i.unproject(_.add(x.mult(e*w)).mult(m));i.setLocationAtPoint(i.renderWorldCopies?E.wrap():E,d)}r._fireMoveEvents(n)}),(function(t){r._afterEase(n,t)}),e),this},n.prototype._prepareEase=function(e,n,r){void 0===r&&(r={}),this._moving=!0,n||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))},n.prototype._fireMoveEvents=function(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))},n.prototype._afterEase=function(e,n){if(!this._easeId||!n||this._easeId!==n){delete this._easeId;var r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),i&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}},n.prototype.flyTo=function(e,n){var r=this;if(!e.essential&&t.browser.prefersReducedMotion){var i=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,n)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);var o=this.transform,a=this.getZoom(),s=this.getBearing(),l=this.getPitch(),u=this.getPadding(),c="zoom"in e?t.clamp(+e.zoom,o.minZoom,o.maxZoom):a,h="bearing"in e?this._normalizeBearing(e.bearing,s):s,p="pitch"in e?+e.pitch:l,f="padding"in e?e.padding:o.padding,d=o.zoomScale(c-a),m=t.Point.convert(e.offset),g=o.centerPoint.add(m),y=o.pointLocation(g),v=t.LngLat.convert(e.center||y);this._normalizeCenter(v);var _=o.project(y),x=o.project(v).sub(_),b=e.curve,w=Math.max(o.width,o.height),E=w/d,S=x.mag();if("minZoom"in e){var M=t.clamp(Math.min(e.minZoom,a,c),o.minZoom,o.maxZoom),T=w/o.zoomScale(M-a);b=Math.sqrt(T/S*2)}var C=b*b;function I(t){var e=(E*E-w*w+(t?-1:1)*C*C*S*S)/(2*(t?E:w)*C*S);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function L(t){return(Math.exp(t)+Math.exp(-t))/2}var P=I(0),R=function(t){return L(P)/L(P+b*t)},D=function(t){return w*((L(P)*(A(e=P+b*t)/L(e))-A(P))/C)/S;var e},N=(I(1)-P)/b;if(Math.abs(S)<1e-6||!isFinite(N)){if(Math.abs(w-E)<1e-6)return this.easeTo(e,n);var O=Ee.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=s!==h,this._pitching=p!==l,this._padding=!o.isPaddingEqual(f),this._prepareEase(n,!1),this._ease((function(e){var i=e*N,d=1/R(i);o.zoom=1===e?c:a+o.scaleZoom(d),r._rotating&&(o.bearing=t.number(s,h,e)),r._pitching&&(o.pitch=t.number(l,p,e)),r._padding&&(o.interpolatePadding(u,f,e),g=o.centerPoint.add(m));var y=1===e?v:o.unproject(_.add(x.mult(D(i))).mult(d));o.setLocationAtPoint(o.renderWorldCopies?y.wrap():y,g),r._fireMoveEvents(n)}),(function(){return r._afterEase(n)}),e),this},n.prototype.isEasing=function(){return!!this._easeFrameId},n.prototype.stop=function(){return this._stop()},n.prototype._stop=function(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){var n=this._onEaseEnd;delete this._onEaseEnd,n.call(this,e)}if(!t){var r=this.handlers;r&&r.stop(!1)}return this},n.prototype._ease=function(e,n,r){!1===r.animate||0===r.duration?(e(1),n()):(this._easeStart=t.browser.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))},n.prototype._renderFrameCallback=function(){var e=Math.min((t.browser.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},n.prototype._normalizeBearing=function(e,n){e=t.wrap(e,-180,180);var r=Math.abs(e-n);return Math.abs(e-360-n)180?-360:n<-180?360:0}},n}(t.Evented),_i=function(e){void 0===e&&(e={}),this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)};_i.prototype.getDefaultPosition=function(){return"bottom-right"},_i.prototype.onAdd=function(t){var e=this.options&&this.options.compact;return this._map=t,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=n.create("button","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.type="button",this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("maplibregl-compact","mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container},_i.prototype.onRemove=function(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0},_i.prototype._setElementTitle=function(t,e){var n=this._map._getUIString("AttributionControl."+e);t.title=n,t.setAttribute("aria-label",n)},_i.prototype._toggleAttribution=function(){this._container.classList.contains("maplibregl-compact-show")||this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","false")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._compactButton.setAttribute("aria-pressed","true"))},_i.prototype._updateEditLink=function(){var e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));var n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){var r=n.reduce((function(t,e,r){return e.value&&(t+=e.key+"="+e.value+(r=0)return!1;return!0}))).join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._editLink=null)}},_i.prototype._updateCompact=function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("maplibregl-compact","mapboxgl-compact"):this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show")};var xi=function(){t.bindAll(["_updateLogo"],this),t.bindAll(["_updateCompact"],this)};xi.prototype.onAdd=function(t){this._map=t,this._container=n.create("div","maplibregl-ctrl mapboxgl-ctrl");var e=n.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container},xi.prototype.onRemove=function(){n.remove(this._container),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)},xi.prototype.getDefaultPosition=function(){return"bottom-left"},xi.prototype._updateLogo=function(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")},xi.prototype._logoRequired=function(){if(this._map.style){var t=this._map.style.sourceCaches;for(var e in t)if(t[e].getSource().mapbox_logo)return!0;return!1}},xi.prototype._updateCompact=function(){var t=this._container.children;if(t.length){var e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("maplibregl-compact","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}};var bi=function(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1};bi.prototype.add=function(t){var e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e},bi.prototype.remove=function(t){for(var e=this._currentlyRunning,n=0,r=e?this._queue.concat(e):this._queue;ne.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>60)throw new Error("maxPitch must be less than or equal to 60");var i=new Er(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies);if(r.call(this,i,e),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._renderTaskQueue=new bi,this._controls=[],this._mapId=t.uniqueId(),this._locale=t.extend({},wi,e.locale),this._clickTolerance=e.clickTolerance,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken),"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error("Container '"+e.container+"' not found.")}else{if(!(e.container instanceof Si))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(function(){return n._update(!1)})),this.on("moveend",(function(){return n._update(!1)})),this.on("zoom",(function(){return n._update(!0)})),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new yi(this,e),this._hash=e.hash&&new Mr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new _i({customAttribution:e.customAttribution})),this.addControl(new xi,e.logoPosition),this.on("style.load",(function(){n.transform.unmodified&&n.jumpTo(n.style.stylesheet)})),this.on("data",(function(e){n._update("style"===e.dataType),n.fire(new t.Event(e.dataType+"data",e))})),this.on("dataloading",(function(e){n.fire(new t.Event(e.dataType+"dataloading",e))}))}r&&(i.__proto__=r),(i.prototype=Object.create(r&&r.prototype)).constructor=i;var o={showTileBoundaries:{configurable:!0},showPadding:{configurable:!0},showCollisionBoxes:{configurable:!0},showOverdrawInspector:{configurable:!0},repaint:{configurable:!0},vertices:{configurable:!0},version:{configurable:!0}};return i.prototype._getMapId=function(){return this._mapId},i.prototype.addControl=function(e,n){if(void 0===n&&(n=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));var r=e.onAdd(this);this._controls.push(e);var i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this},i.prototype.removeControl=function(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));var n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this},i.prototype.hasControl=function(t){return this._controls.indexOf(t)>-1},i.prototype.resize=function(e){var n=this._containerDimensions(),r=n[0],i=n[1];this._resizeCanvas(r,i),this.transform.resize(r,i),this.painter.resize(r,i);var o=!this._moving;return o&&(this.stop(),this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e))),this.fire(new t.Event("resize",e)),o&&this.fire(new t.Event("moveend",e)),this},i.prototype.getBounds=function(){return this.transform.getBounds()},i.prototype.getMaxBounds=function(){return this.transform.getMaxBounds()},i.prototype.setMaxBounds=function(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()},i.prototype.setMinZoom=function(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")},i.prototype.getMaxZoom=function(){return this.transform.maxZoom},i.prototype.setMinPitch=function(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()60)throw new Error("maxPitch must be less than or equal to 60");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")},i.prototype.getMaxPitch=function(){return this.transform.maxPitch},i.prototype.getRenderWorldCopies=function(){return this.transform.renderWorldCopies},i.prototype.setRenderWorldCopies=function(t){return this.transform.renderWorldCopies=t,this._update()},i.prototype.project=function(e){return this.transform.locationPoint(t.LngLat.convert(e))},i.prototype.unproject=function(e){return this.transform.pointLocation(t.Point.convert(e))},i.prototype.isMoving=function(){return this._moving||this.handlers.isMoving()},i.prototype.isZooming=function(){return this._zooming||this.handlers.isZooming()},i.prototype.isRotating=function(){return this._rotating||this.handlers.isRotating()},i.prototype._createDelegatedListener=function(t,e,n){var r,i=this;if("mouseenter"===t||"mouseover"===t){var o=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){var a=i.getLayer(e)?i.queryRenderedFeatures(r.point,{layers:[e]}):[];a.length?o||(o=!0,n.call(i,new Nr(t,i,r.originalEvent,{features:a}))):o=!1},mouseout:function(){o=!1}}}}if("mouseleave"===t||"mouseout"===t){var a=!1;return{layer:e,listener:n,delegates:{mousemove:function(r){(i.getLayer(e)?i.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?a=!0:a&&(a=!1,n.call(i,new Nr(t,i,r.originalEvent)))},mouseout:function(e){a&&(a=!1,n.call(i,new Nr(t,i,e.originalEvent)))}}}}return{layer:e,listener:n,delegates:(r={},r[t]=function(t){var r=i.getLayer(e)?i.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,n.call(i,t),delete t.features)},r)}},i.prototype.on=function(t,e,n){if(void 0===n)return r.prototype.on.call(this,t,e);var i=this._createDelegatedListener(t,e,n);for(var o in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(i),i.delegates)this.on(o,i.delegates[o]);return this},i.prototype.once=function(t,e,n){if(void 0===n)return r.prototype.once.call(this,t,e);var i=this._createDelegatedListener(t,e,n);for(var o in i.delegates)this.once(o,i.delegates[o]);return this},i.prototype.off=function(t,e,n){var i=this;return void 0===n?r.prototype.off.call(this,t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&function(r){for(var o=r[t],a=0;a180;){var s=r.locationPoint(e);if(s.x>=0&&s.y>=0&&s.x<=r.width&&s.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}Pi.prototype.down=function(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),n.disableDrag()},Pi.prototype.move=function(t,e){var n=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&n.setBearing(n.getBearing()+r.bearingDelta),this.mousePitch){var i=this.mousePitch.mousemoveWindow(t,e);i&&i.pitchDelta&&n.setPitch(n.getPitch()+i.pitchDelta)}},Pi.prototype.off=function(){var t=this.element;n.removeEventListener(t,"mousedown",this.mousedown),n.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(t,"touchmove",this.touchmove),n.removeEventListener(t,"touchend",this.touchend),n.removeEventListener(t,"touchcancel",this.reset),this.offTemp()},Pi.prototype.offTemp=function(){n.enableDrag(),n.removeEventListener(t.window,"mousemove",this.mousemove),n.removeEventListener(t.window,"mouseup",this.mouseup)},Pi.prototype.mousedown=function(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:function(){return e.preventDefault()}}),n.mousePos(this.element,e)),n.addEventListener(t.window,"mousemove",this.mousemove),n.addEventListener(t.window,"mouseup",this.mouseup)},Pi.prototype.mousemove=function(t){this.move(t,n.mousePos(this.element,t))},Pi.prototype.mouseup=function(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()},Pi.prototype.touchstart=function(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:function(){return t.preventDefault()}},this._startPos))},Pi.prototype.touchmove=function(t){1!==t.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:function(){return t.preventDefault()}},this._lastPos))},Pi.prototype.touchend=function(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)=n}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))},r.prototype._onUp=function(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"},r.prototype._addDragHandler=function(t){this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},r.prototype.setDraggable=function(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this},r.prototype.isDraggable=function(){return this._draggable},r.prototype.setRotation=function(t){return this._rotation=t||0,this._update(),this},r.prototype.getRotation=function(){return this._rotation},r.prototype.setRotationAlignment=function(t){return this._rotationAlignment=t||"auto",this._update(),this},r.prototype.getRotationAlignment=function(){return this._rotationAlignment},r.prototype.setPitchAlignment=function(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this},r.prototype.getPitchAlignment=function(){return this._pitchAlignment},r}(t.Evented),zi={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Fi=0,Bi=!1,Ui=function(e){function r(n){e.call(this),this.options=t.extend({},zi,n),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.onAdd=function(e){var r;return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),r=this._setupUI,void 0!==Oi?r(Oi):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((function(t){r(Oi="denied"!==t.state)})):r(Oi=!!t.window.navigator.geolocation),this._container},r.prototype.onRemove=function(){void 0!==this._geolocationWatchID&&(t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Fi=0,Bi=!1},r.prototype._isOutOfMapMaxBounds=function(t){var e=this._map.getMaxBounds(),n=t.coords;return e&&(n.longitudee.getEast()||n.latitudee.getNorth())},r.prototype._setErrorState=function(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting")}},r.prototype._onSuccess=function(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}},r.prototype._updateCamera=function(e){var n=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),o=t.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})},r.prototype._updateMarker=function(e){if(e){var n=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},r.prototype._updateCircleRadius=function(){var t=this._map._container.clientHeight/2,e=this._map.unproject([0,t]),n=this._map.unproject([1,t]),r=e.distanceTo(n),i=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=i+"px",this._circleElement.style.height=i+"px"},r.prototype._onZoom=function(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},r.prototype._onError=function(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;var n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&Bi)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}},r.prototype._finish=function(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},r.prototype._setupUI=function(e){var r=this;if(this._container.addEventListener("contextmenu",(function(t){return t.preventDefault()})),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");var i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=i,this._geolocateButton.setAttribute("aria-label",i)}else{var o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=o,this._geolocateButton.setAttribute("aria-label",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new ki(this._dotElement),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ki({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(function(e){e.geolocateSource||"ACTIVE_LOCK"!==r._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(r._watchState="BACKGROUND",r._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),r._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),r.fire(new t.Event("trackuserlocationend")))}))},r.prototype.trigger=function(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Fi--,Bi=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){var e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++Fi>1?(e={maximumAge:6e5,timeout:0},Bi=!0):(e=this.options.positionOptions,Bi=!1),this._geolocationWatchID=t.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else t.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0},r.prototype._clearWatch=function(){t.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)},r}(t.Evented),Vi={maxWidth:100,unit:"metric"},Gi=function(e){this.options=t.extend({},Vi,e),t.bindAll(["_onMove","setUnit"],this)};function ji(t,e,n){var r=n&&n.maxWidth||100,i=t._container.clientHeight/2,o=t.unproject([0,i]),a=t.unproject([r,i]),s=o.distanceTo(a);if(n&&"imperial"===n.unit){var l=3.2808*s;l>5280?Hi(e,r,l/5280,t._getUIString("ScaleControl.Miles")):Hi(e,r,l,t._getUIString("ScaleControl.Feet"))}else n&&"nautical"===n.unit?Hi(e,r,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?Hi(e,r,s/1e3,t._getUIString("ScaleControl.Kilometers")):Hi(e,r,s,t._getUIString("ScaleControl.Meters"))}function Hi(t,e,n,r){var i,o,a,s=(i=n,(o=Math.pow(10,(""+Math.floor(i)).length-1))*(a=(a=i/o)>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(t){var e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(a)));t.style.width=e*(s/n)+"px",t.innerHTML=s+" "+r}Gi.prototype.getDefaultPosition=function(){return"bottom-left"},Gi.prototype._onMove=function(){ji(this._map,this._container,this.options)},Gi.prototype.onAdd=function(t){return this._map=t,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container},Gi.prototype.onRemove=function(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0},Gi.prototype.setUnit=function(t){this.options.unit=t,ji(this._map,this._container,this.options)};var qi=function(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in t.window.document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in t.window.document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in t.window.document&&(this._fullscreenchange="MSFullscreenChange")};qi.prototype.onAdd=function(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer},qi.prototype.onRemove=function(){n.remove(this._controlContainer),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)},qi.prototype._checkFullscreenSupport=function(){return!!(t.window.document.fullscreenEnabled||t.window.document.mozFullScreenEnabled||t.window.document.msFullscreenEnabled||t.window.document.webkitFullscreenEnabled)},qi.prototype._setupUI=function(){var e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",e).setAttribute("aria-hidden",!0),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)},qi.prototype._updateTitle=function(){var t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t},qi.prototype._getTitle=function(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")},qi.prototype._isFullscreen=function(){return this._fullscreen},qi.prototype._changeIcon=function(){(t.window.document.fullscreenElement||t.window.document.mozFullScreenElement||t.window.document.webkitFullscreenElement||t.window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())},qi.prototype._onClickFullscreen=function(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.mozCancelFullScreen?t.window.document.mozCancelFullScreen():t.window.document.msExitFullscreen?t.window.document.msExitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()};var Wi={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Xi=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", "),Zi=function(e){function r(n){e.call(this),this.options=t.extend(Object.create(Wi),n),t.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.addTo=function(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.Event("open")),this},r.prototype.isOpen=function(){return!!this._map},r.prototype.remove=function(){return this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new t.Event("close")),this},r.prototype.getLngLat=function(){return this._lngLat},r.prototype.setLngLat=function(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-track-pointer")),this},r.prototype.trackPointer=function(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this},r.prototype.getElement=function(){return this._container},r.prototype.setText=function(e){return this.setDOMContent(t.window.document.createTextNode(e))},r.prototype.setHTML=function(e){var n,r=t.window.document.createDocumentFragment(),i=t.window.document.createElement("body");for(i.innerHTML=e;n=i.firstChild;)r.appendChild(n);return this.setDOMContent(r)},r.prototype.getMaxWidth=function(){return this._container&&this._container.style.maxWidth},r.prototype.setMaxWidth=function(t){return this.options.maxWidth=t,this._update(),this},r.prototype.setDOMContent=function(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this},r.prototype.addClassName=function(t){this._container&&this._container.classList.add(t)},r.prototype.removeClassName=function(t){this._container&&this._container.classList.remove(t)},r.prototype.setOffset=function(t){return this.options.offset=t,this._update(),this},r.prototype.toggleClassName=function(t){if(this._container)return this._container.classList.toggle(t)},r.prototype._createCloseButton=function(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))},r.prototype._onMouseUp=function(t){this._update(t.point)},r.prototype._onMouseMove=function(t){this._update(t.point)},r.prototype._onDrag=function(t){this._update(t.point)},r.prototype._update=function(e){var r=this;if(this._map&&(this._lngLat||this._trackPointer)&&this._content&&(this._container||(this._container=n.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach((function(t){return r._container.classList.add(t)})),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ri(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||e)){var i=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat),o=this.options.anchor,a=function e(n){if(n){if("number"==typeof n){var r=Math.round(Math.sqrt(.5*Math.pow(n,2)));return{center:new t.Point(0,0),top:new t.Point(0,n),"top-left":new t.Point(r,r),"top-right":new t.Point(-r,r),bottom:new t.Point(0,-n),"bottom-left":new t.Point(r,-r),"bottom-right":new t.Point(-r,-r),left:new t.Point(n,0),right:new t.Point(-n,0)}}if(n instanceof t.Point||Array.isArray(n)){var i=t.Point.convert(n);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.Point.convert(n.center||[0,0]),top:t.Point.convert(n.top||[0,0]),"top-left":t.Point.convert(n["top-left"]||[0,0]),"top-right":t.Point.convert(n["top-right"]||[0,0]),bottom:t.Point.convert(n.bottom||[0,0]),"bottom-left":t.Point.convert(n["bottom-left"]||[0,0]),"bottom-right":t.Point.convert(n["bottom-right"]||[0,0]),left:t.Point.convert(n.left||[0,0]),right:t.Point.convert(n.right||[0,0])}}return e(new t.Point(0,0))}(this.options.offset);if(!o){var s,l=this._container.offsetWidth,u=this._container.offsetHeight;s=i.y+a.bottom.ythis._map.transform.height-u?["bottom"]:[],i.xthis._map.transform.width-l/2&&s.push("right"),o=0===s.length?"bottom":s.join("-")}var c=i.add(a[o]).round();n.setTransform(this._container,Di[o]+" translate("+c.x+"px,"+c.y+"px)"),Ni(this._container,o,"popup")}},r.prototype._focusFirstElement=function(){if(this.options.focusAfterOpen&&this._container){var t=this._container.querySelector(Xi);t&&t.focus()}},r.prototype._onClose=function(){this.remove()},r}(t.Evented),Yi={version:t.version,supported:e,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:Ci,NavigationControl:Li,GeolocateControl:Ui,AttributionControl:_i,ScaleControl:Gi,FullscreenControl:qi,Popup:Zi,Marker:ki,Style:je,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,Evented:t.Evented,config:t.config,prewarm:function(){Ft().acquire(Nt)},clearPrewarmedResources:function(){var t=kt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Nt),kt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Ot.workerCount},set workerCount(t){Ot.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage:function(e){t.clearTileCache(e)},workerUrl:"",addProtocol:function(e,n){t.config.REGISTERED_PROTOCOLS[e]=n},removeProtocol:function(e){delete t.config.REGISTERED_PROTOCOLS[e]}};return Yi}));return n}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).MapboxDraw=e()}(this,(function(){"use strict";var t=function(t,e){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on:function(t,e,r){if(void 0===n[t])throw new Error("Invalid event type: "+t);n[t].push({selector:e,fn:r})},render:function(t){e.store.featureChanged(t)}},i=function(t,i){for(var o=n[t],a=o.length;a--;){var s=o[a];if(s.selector(i)){s.fn.call(r,i)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(r),{render:t.render,stop:function(){t.stop&&t.stop()},trash:function(){t.trash&&(t.trash(),e.store.render())},combineFeatures:function(){t.combineFeatures&&t.combineFeatures()},uncombineFeatures:function(){t.uncombineFeatures&&t.uncombineFeatures()},drag:function(t){i("drag",t)},click:function(t){i("click",t)},mousemove:function(t){i("mousemove",t)},mousedown:function(t){i("mousedown",t)},mouseup:function(t){i("mouseup",t)},mouseout:function(t){i("mouseout",t)},keydown:function(t){i("keydown",t)},keyup:function(t){i("keyup",t)},touchstart:function(t){i("touchstart",t)},touchmove:function(t){i("touchmove",t)},touchend:function(t){i("touchend",t)},tap:function(t){i("tap",t)}}},e=6378137;function n(t){var e=0;if(t&&t.length>0){e+=Math.abs(r(t[0]));for(var n=1;n2){for(l=0;l=Math.pow(2,t)?e(t,n):a};e.rack=function(t,n,r){var i=function(i){var a=0;do{if(a++>10){if(!r)throw new Error("too many ID collisions, use more bits");t+=r}var s=e(t,n)}while(Object.hasOwnProperty.call(o,s));return o[s]=i,s},o=i.hats={};return i.get=function(t){return i.hats[t]},i.set=function(t,e){return i.hats[t]=e,i},i.bits=t||128,i.base=n||16,i}})),H=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||j(),this.type=e.geometry.type};H.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},H.prototype.incomingCoords=function(t){this.setCoordinates(t)},H.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},H.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},H.prototype.setProperty=function(t,e){this.properties[t]=e},H.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:d,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},H.prototype.internal=function(t){var e={id:this.id,meta:T,"meta:type":this.type,active:L,mode:t};if(this.ctx.options.userProperties)for(var n in this.properties)e["user_"+n]=this.properties[n];return{type:d,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var q=function(t,e){H.call(this,t,e)};(q.prototype=Object.create(H.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},q.prototype.updateCoordinate=function(t,e,n){this.coordinates=3===arguments.length?[e,n]:[t,e],this.changed()},q.prototype.getCoordinate=function(){return this.getCoordinates()};var W=function(t,e){H.call(this,t,e)};(W.prototype=Object.create(H.prototype)).isValid=function(){return this.coordinates.length>1},W.prototype.addCoordinate=function(t,e,n){this.changed();var r=parseInt(t,10);this.coordinates.splice(r,0,[e,n])},W.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},W.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1)},W.prototype.updateCoordinate=function(t,e,n){var r=parseInt(t,10);this.coordinates[r]=[e,n],this.changed()};var X=function(t,e){H.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}))};(X.prototype=Object.create(H.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},X.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed()},X.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},X.prototype.addCoordinate=function(t,e,n){this.changed();var r=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[r[0]].splice(r[1],0,[e,n])},X.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];n&&(n.splice(e[1],1),n.length<3&&this.coordinates.splice(e[0],1))},X.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];return JSON.parse(JSON.stringify(n[e[1]]))},X.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},X.prototype.updateCoordinate=function(t,e,n){this.changed();var r=t.split("."),i=parseInt(r[0],10),o=parseInt(r[1],10);void 0===this.coordinates[i]&&(this.coordinates[i]=[]),this.coordinates[i][o]=[e,n]};var Z={MultiPoint:q,MultiLineString:W,MultiPolygon:X},Y=function(t,e,n,r,i){var o=n.split("."),a=parseInt(o[0],10),s=o[1]?o.slice(1).join("."):null;return t[a][e](s,r,i)},J=function(t,e){if(H.call(this,t,e),delete this.coordinates,this.model=Z[e.geometry.type],void 0===this.model)throw new TypeError(e.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(e.geometry.coordinates)};function K(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t}(J.prototype=Object.create(H.prototype))._coordinatesToFeatures=function(t){var e=this,n=this.model.bind(this);return t.map((function(t){return new n(e.ctx,{id:j(),type:d,properties:{},geometry:{coordinates:t,type:e.type.replace("Multi","")}})}))},J.prototype.isValid=function(){return this.features.every((function(t){return t.isValid()}))},J.prototype.setCoordinates=function(t){this.features=this._coordinatesToFeatures(t),this.changed()},J.prototype.getCoordinate=function(t){return Y(this.features,"getCoordinate",t)},J.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===m?t.getCoordinates():t.coordinates}))))},J.prototype.updateCoordinate=function(t,e,n){Y(this.features,"updateCoordinate",t,e,n),this.changed()},J.prototype.addCoordinate=function(t,e,n){Y(this.features,"addCoordinate",t,e,n),this.changed()},J.prototype.removeCoordinate=function(t){Y(this.features,"removeCoordinate",t),this.changed()},J.prototype.getFeatures=function(){return this.features},K.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},K.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,n){return void 0===t[n.feature_id]&&(t[n.feature_id]=!0,e._ctx.store.get(n.feature_id).changed()),t}),{})},K.prototype.getSelected=function(){return this._ctx.store.getSelected()},K.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},K.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},K.prototype.getFeature=function(t){return this._ctx.store.get(t)},K.prototype.select=function(t){return this._ctx.store.select(t)},K.prototype.deselect=function(t){return this._ctx.store.deselect(t)},K.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},K.prototype.addFeature=function(t){return this._ctx.store.add(t)},K.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},K.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},K.prototype.setActionableState=function(t){void 0===t&&(t={});var e={trash:t.trash||!1,combineFeatures:t.combineFeatures||!1,uncombineFeatures:t.uncombineFeatures||!1};return this._ctx.events.actionable(e)},K.prototype.changeMode=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),this._ctx.events.changeMode(t,e,n)},K.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},K.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},K.prototype.featuresAt=function(t,e,n){if(void 0===n&&(n="click"),"click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return k[n](t,e,this._ctx)},K.prototype.newFeature=function(t){var e=t.geometry.type;return e===y?new q(this._ctx,t):e===g?new W(this._ctx,t):e===m?new X(this._ctx,t):new J(this._ctx,t)},K.prototype.isInstanceOf=function(t,e){if(t===y)return e instanceof q;if(t===g)return e instanceof W;if(t===m)return e instanceof X;if("MultiFeature"===t)return e instanceof J;throw new Error("Unknown feature class: "+t)},K.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},K.prototype.onSetup=function(){},K.prototype.onDrag=function(){},K.prototype.onClick=function(){},K.prototype.onMouseMove=function(){},K.prototype.onMouseDown=function(){},K.prototype.onMouseUp=function(){},K.prototype.onMouseOut=function(){},K.prototype.onKeyUp=function(){},K.prototype.onKeyDown=function(){},K.prototype.onTouchStart=function(){},K.prototype.onTouchMove=function(){},K.prototype.onTouchEnd=function(){},K.prototype.onTap=function(){},K.prototype.onStop=function(){},K.prototype.onTrash=function(){},K.prototype.onCombineFeature=function(){},K.prototype.onUncombineFeature=function(){},K.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Q={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},$=Object.keys(Q);function tt(t){return[].concat(t).filter((function(t){return void 0!==t}))}function et(){var t=this;if(!t.ctx.map||void 0===t.ctx.map.getSource(s))return c();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var n=[],r=[];t.isDirty?r=t.getAllIds():(n=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),r=t.sources.hot.filter((function(e){return e.properties.id&&-1===n.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var i=t.sources.cold.length;t.sources.cold=t.isDirty?[]:t.sources.cold.filter((function(t){var e=t.properties.id||t.properties.parent;return-1===n.indexOf(e)}));var o=i!==t.sources.cold.length||r.length>0;function a(n,r){var i=t.get(n).internal(e);t.ctx.events.currentModeRender(i,(function(e){t.sources[r].push(e)}))}if(n.forEach((function(t){return a(t,"hot")})),r.forEach((function(t){return a(t,"cold")})),o&&t.ctx.map.getSource(l).setData({type:v,features:t.sources.cold}),t.ctx.map.getSource(s).setData({type:v,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(S,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return{type:d,properties:{},geometry:{type:y,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var u=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(w,{features:u})}function c(){t.isDirty=!1,t.clearChangedIds()}c(),t.ctx.map.fire(M,{})}function nt(t){var e,n=this;this._features={},this._featureIds=new N,this._selectedFeatureIds=new N,this._selectedCoordinates=[],this._changedFeatureIds=new N,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,et.call(n)})))},this.isDirty=!1}function rt(t,e){var n=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===n.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=n}nt.prototype.createRenderBatch=function(){var t=this,e=this.render,n=0;return this.render=function(){n++},function(){t.render=e,n>0&&t.render()}},nt.prototype.setDirty=function(){return this.isDirty=!0,this},nt.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},nt.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},nt.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},nt.prototype.getAllIds=function(){return this._featureIds.values()},nt.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},nt.prototype.delete=function(t,e){var n=this;return void 0===e&&(e={}),tt(t).forEach((function(t){n._featureIds.has(t)&&(n._featureIds.delete(t),n._selectedFeatureIds.delete(t),e.silent||-1===n._deletedFeaturesToEmit.indexOf(n._features[t])&&n._deletedFeaturesToEmit.push(n._features[t]),delete n._features[t],n.isDirty=!0)})),rt(this,e),this},nt.prototype.get=function(t){return this._features[t]},nt.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},nt.prototype.select=function(t,e){var n=this;return void 0===e&&(e={}),tt(t).forEach((function(t){n._selectedFeatureIds.has(t)||(n._selectedFeatureIds.add(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),this},nt.prototype.deselect=function(t,e){var n=this;return void 0===e&&(e={}),tt(t).forEach((function(t){n._selectedFeatureIds.has(t)&&(n._selectedFeatureIds.delete(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),rt(this,e),this},nt.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},nt.prototype.setSelected=function(t,e){var n=this;return void 0===e&&(e={}),t=tt(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return-1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return!n._selectedFeatureIds.has(t)})),{silent:e.silent}),this},nt.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},nt.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},nt.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},nt.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},nt.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return{coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},nt.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},nt.prototype.setFeatureProperty=function(t,e,n){this.get(t).setProperty(e,n),this.featureChanged(t)},nt.prototype.storeMapConfig=function(){var t=this;P.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled())}))},nt.prototype.restoreMapConfig=function(){var t=this;Object.keys(this._mapInitialConfig).forEach((function(e){t._mapInitialConfig[e]?t.ctx.map[e].enable():t.ctx.map[e].disable()}))},nt.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var it=function(){for(var t=arguments,e={},n=0;n=48&&t<=57)};function u(r,i,o){void 0===o&&(o={}),s.stop();var l=n[r];if(void 0===l)throw new Error(r+" is not valid");a=r;var u=l(e,i);s=t(u,e),o.silent||e.map.fire("draw.modechange",{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){"mapboxgl-canvas"===(t.srcElement||t.target).classList[0]&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?l(t.keyCode)?s.keydown(t):49===t.keyCode&&e.options.controls.point?u(x.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?u(x.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&u(x.DRAW_POLYGON):(t.preventDefault(),s.trash()))},o.keyup=function(t){l(t.keyCode)&&s.keyup(t)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){var n=e.setup,r=e.map,i=e.options,o=e.store;i.styles.some((function(t){return r.getLayer(t.id)}))||(n.addLayers(),o.setDirty(),o.render())}};var c={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){a=e.options.defaultMode,s=t(n[a](e),e)},changeMode:u,actionable:function(t){var n=!1;Object.keys(t).forEach((function(e){if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(n=!0),c[e]=t[e]})),n&&e.map.fire("draw.actionable",{actions:c})},currentModeName:function(){return a},currentModeRender:function(t,e){return s.render(t,e)},fire:function(t,e){o[t]&&o[t](e)},addEventListeners:function(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners:function(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash:function(t){s.trash(t)},combineFeatures:function(){s.combineFeatures()},uncombineFeatures:function(){s.uncombineFeatures()},getMode:function(){return a}}}(e),e.ui=function(t){var e={},n=null,r={mode:null,feature:null,mouse:null},i={mode:null,feature:null,mouse:null};function o(t){i=it(i,t)}function s(){var e,n;if(t.container){var o=[],a=[];at.forEach((function(t){i[t]!==r[t]&&(o.push(t+"-"+r[t]),null!==i[t]&&a.push(t+"-"+i[t]))})),o.length>0&&(e=t.container.classList).remove.apply(e,o),a.length>0&&(n=t.container.classList).add.apply(n,a),r=it(r,i)}}function l(t,e){void 0===e&&(e={});var r=document.createElement("button");return r.className="mapbox-gl-draw_ctrl-draw-btn "+e.className,r.setAttribute("title",e.title),e.container.appendChild(r),r.addEventListener("click",(function(r){if(r.preventDefault(),r.stopPropagation(),r.target===n)return u(),void e.onDeactivate();c(t),e.onActivate()}),!0),r}function u(){n&&(n.classList.remove(a),n=null)}function c(t){u();var r=e[t];r&&r&&"trash"!==t&&(r.classList.add(a),n=r)}return{setActiveButton:c,queueMapClasses:o,updateMapClasses:s,clearMapClasses:function(){o({mode:null,feature:null,mouse:null}),s()},addButtons:function(){var n=t.options.controls,r=document.createElement("div");return r.className="mapboxgl-ctrl-group mapboxgl-ctrl",n?(n[f.LINE]&&(e[f.LINE]=l(f.LINE,{container:r,className:"mapbox-gl-draw_line",title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(x.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),n[f.POLYGON]&&(e[f.POLYGON]=l(f.POLYGON,{container:r,className:"mapbox-gl-draw_polygon",title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(x.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),n[f.POINT]&&(e[f.POINT]=l(f.POINT,{container:r,className:"mapbox-gl-draw_point",title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(x.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),n.trash&&(e.trash=l("trash",{container:r,className:"mapbox-gl-draw_trash",title:"Delete",onActivate:function(){t.events.trash()}})),n.combine_features&&(e.combine_features=l("combineFeatures",{container:r,className:"mapbox-gl-draw_combine",title:"Combine",onActivate:function(){t.events.combineFeatures()}})),n.uncombine_features&&(e.uncombine_features=l("uncombineFeatures",{container:r,className:"mapbox-gl-draw_uncombine",title:"Uncombine",onActivate:function(){t.events.uncombineFeatures()}})),r):r},removeButtons:function(){Object.keys(e).forEach((function(t){var n=e[t];n.parentNode&&n.parentNode.removeChild(n),delete e[t]}))}}}(e),e.container=o.getContainer(),e.store=new nt(e),n=e.ui.addButtons(),e.options.boxSelect&&(o.boxZoom.disable(),o.dragPan.disable(),o.dragPan.enable()),o.loaded()?i.connect():(o.on("load",i.connect),r=setInterval((function(){o.loaded()&&i.connect()}),16)),e.events.start(),n},addLayers:function(){e.map.addSource(l,{data:{type:v,features:[]},type:"geojson"}),e.map.addSource(s,{data:{type:v,features:[]},type:"geojson"}),e.options.styles.forEach((function(t){e.map.addLayer(t)})),e.store.setDirty(!0),e.store.render()},removeLayers:function(){e.options.styles.forEach((function(t){e.map.getLayer(t.id)&&e.map.removeLayer(t.id)})),e.map.getSource(l)&&e.map.removeSource(l),e.map.getSource(s)&&e.map.removeSource(s)}};return e.setup=i,i}function lt(t){return function(e){var n=e.featureTarget;return!!n&&!!n.properties&&n.properties.meta===t}}function ut(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===A&&t.featureTarget.properties.meta===T}function ct(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===L&&t.featureTarget.properties.meta===T}function ht(t){return void 0===t.featureTarget}function pt(t){var e=t.featureTarget;return!!e&&!!e.properties&&e.properties.meta===I}function ft(t){return!!t.originalEvent&&!0===t.originalEvent.shiftKey}function dt(t){return 27===t.keyCode}function mt(t){return 13===t.keyCode}var gt=yt;function yt(t,e){this.x=t,this.y=e}function vt(t,e){var n=e.getBoundingClientRect();return new gt(t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0))}function _t(t,e,n,r){return{type:d,properties:{meta:I,parent:t,coord_path:n,active:r?A:L},geometry:{type:y,coordinates:e}}}function xt(t,e,n){void 0===e&&(e={}),void 0===n&&(n=null);var r,i=t.geometry,o=i.type,a=i.coordinates,s=t.properties&&t.properties.id,l=[];function u(t,n){var r="",i=null;t.forEach((function(t,o){var a=null!=n?n+"."+o:String(o),u=_t(s,t,a,c(a));if(e.midpoints&&i){var h=function(t,e,n){var r=e.geometry.coordinates,i=n.geometry.coordinates;if(r[1]>85||r[1]<-85||i[1]>85||i[1]<-85)return null;var o={lng:(r[0]+i[0])/2,lat:(r[1]+i[1])/2};return{type:d,properties:{meta:C,parent:t,lng:o.lng,lat:o.lat,coord_path:n.properties.coord_path},geometry:{type:y,coordinates:[o.lng,o.lat]}}}(s,i,u);h&&l.push(h)}i=u;var p=JSON.stringify(t);r!==p&&l.push(u),0===o&&(r=p)}))}function c(t){return!!e.selectedPaths&&-1!==e.selectedPaths.indexOf(t)}return o===y?l.push(_t(s,a,n,c(n))):o===m?a.forEach((function(t,e){u(t,null!==n?n+"."+e:String(e))})):o===g?u(a,n):0===o.indexOf(_)&&(r=o.replace(_,""),a.forEach((function(n,i){var o={type:d,properties:t.properties,geometry:{type:r,coordinates:n}};l=l.concat(xt(o,e,i))}))),l}yt.prototype={clone:function(){return new yt(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,n=t.y-this.y;return e*e+n*n},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,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,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),n=Math.sin(t),r=e*this.x-n*this.y,i=n*this.x+e*this.y;return this.x=r,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.x+n*(this.x-e.x)-r*(this.y-e.y),o=e.y+r*(this.x-e.x)+n*(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}},yt.convert=function(t){return t instanceof yt?t:Array.isArray(t)?new yt(t[0],t[1]):t};var bt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()}),0)},wt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()}),0)},Et=function(t){if(!t||!t.type)return null;var e=St[t.type];return e?"geometry"===e?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]}:"feature"===e?{type:"FeatureCollection",features:[t]}:"featurecollection"===e?t:void 0:null},St={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};function Mt(t){switch(t&&t.type||null){case"FeatureCollection":return t.features=t.features.reduce((function(t,e){return t.concat(Mt(e))}),[]),t;case"Feature":return t.geometry?Mt(t.geometry).map((function(e){var n={type:"Feature",properties:JSON.parse(JSON.stringify(t.properties)),geometry:e};return void 0!==t.id&&(n.id=t.id),n})):[t];case"MultiPoint":return t.coordinates.map((function(t){return{type:"Point",coordinates:t}}));case"MultiPolygon":return t.coordinates.map((function(t){return{type:"Polygon",coordinates:t}}));case"MultiLineString":return t.coordinates.map((function(t){return{type:"LineString",coordinates:t}}));case"GeometryCollection":return t.geometries.map(Mt).reduce((function(t,e){return t.concat(e)}),[]);case"Point":case"Polygon":case"LineString":return[t]}}var Tt=G((function(t){var e=t.exports=function(t){return new n(t)};function n(t){this.value=t}function r(t,e,n){var r=[],a=[],c=!0;return function t(h){var p=n?i(h):h,f={},d=!0,m={node:p,node_:h,path:[].concat(r),parent:a[a.length-1],parents:a,key:r.slice(-1)[0],isRoot:0===r.length,level:r.length,circular:null,update:function(t,e){m.isRoot||(m.parent.node[m.key]=t),m.node=t,e&&(d=!1)},delete:function(t){delete m.parent.node[m.key],t&&(d=!1)},remove:function(t){s(m.parent.node)?m.parent.node.splice(m.key,1):delete m.parent.node[m.key],t&&(d=!1)},keys:null,before:function(t){f.before=t},after:function(t){f.after=t},pre:function(t){f.pre=t},post:function(t){f.post=t},stop:function(){c=!1},block:function(){d=!1}};if(!c)return m;function g(){if("object"==typeof m.node&&null!==m.node){m.keys&&m.node_===m.node||(m.keys=o(m.node)),m.isLeaf=0==m.keys.length;for(var t=0;t=e&&this._bbox[3]>=n},It.prototype.intersect=function(t){return this._valid?(e=t instanceof It?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]e[3])):null;var e},It.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var t="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",t)},It.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var At={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},Lt=Object.keys(At),Pt=function(t){return Rt(t).bbox()};function Rt(t){for(var e=Ct(),n=function(t){if(!t)return[];var e=Mt(Et(t)),n=[];return e.features.forEach((function(t){t.geometry&&(n=n.concat(function t(e){return Array.isArray(e)&&e.length&&"number"==typeof e[0]?[e]:e.reduce((function(e,n){return Array.isArray(n)&&Array.isArray(n[0])?e.concat(t(n)):(e.push(n),e)}),[])}(t.geometry.coordinates)))})),n}(t),r=0;rn&&(n=l),ui&&(i=u),ls&&(s=h)}));var l=e;return n+l.lat>85&&(l.lat=85-n),i+l.lat>90&&(l.lat=90-i),r+l.lat<-85&&(l.lat=-85-r),o+l.lat<-90&&(l.lat=-90-o),a+l.lng<=-270&&(l.lng+=360*Math.ceil(Math.abs(l.lng)/360)),s+l.lng>=270&&(l.lng-=360*Math.ceil(Math.abs(l.lng)/360)),l}function Nt(t,e){var n=Dt(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,r=t.getCoordinates(),i=function(t){var e={lng:t[0]+n.lng,lat:t[1]+n.lat};return[e.lng,e.lat]},o=function(t){return t.map((function(t){return i(t)}))};t.type===y?e=i(r):t.type===g||"MultiPoint"===t.type?e=r.map(i):t.type===m||"MultiLineString"===t.type?e=r.map(o):"MultiPolygon"===t.type&&(e=r.map((function(t){return t.map((function(t){return o(t)}))}))),t.incomingCoords(e)}))}var Ot={onSetup:function(t){var e=this,n={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireUpdate:function(){this.map.fire(E,{action:"move",features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(){var t=this,e=this.getSelected(),n=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),r=!1;if(e.length>1){r=!0;var i=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==i&&(r=!1)}))}var o=n.length>0,a=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:o,trash:a})},getUniqueIds:function(t){return t.length?t.map((function(t){return t.properties.id})).filter((function(t){return void 0!==t})).reduce((function(t,e){return t.add(e),t}),new N).values():[]},stopExtendedInteractions:function(t){t.boxSelectElement&&(t.boxSelectElement.parentNode&&t.boxSelectElement.parentNode.removeChild(t.boxSelectElement),t.boxSelectElement=null),this.map.dragPan.enable(),t.boxSelecting=!1,t.canBoxSelect=!1,t.dragMoving=!1,t.canDragMove=!1},onStop:function(){bt(this)},onMouseMove:function(t){return this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return!t.dragMoving||this.fireUpdate()}};Ot.onTap=Ot.onClick=function(t,e){return ht(e)?this.clickAnywhere(t,e):lt(I)(e)?this.clickOnVertex(t,e):function(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.meta===T}(e)?this.clickOnFeature(t,e):void 0},Ot.clickAnywhere=function(t){var e=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(t){return e.doRender(t)}))),bt(this),this.stopExtendedInteractions(t)},Ot.clickOnVertex=function(t,e){this.changeMode(x.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:c})},Ot.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},Ot.clickOnFeature=function(t,e){var n=this;wt(this),this.stopExtendedInteractions(t);var r=ft(e),i=this.getSelectedIds(),o=e.featureTarget.properties.id,a=this.isSelected(o);if(!r&&a&&this.getFeature(o).type!==y)return this.changeMode(x.DIRECT_SELECT,{featureId:o});a&&r?(this.deselect(o),this.updateUIClasses({mouse:h}),1===i.length&&bt(this)):!a&&r?(this.select(o),this.updateUIClasses({mouse:c})):a||r||(i.forEach((function(t){return n.doRender(t)})),this.setSelected(o),this.updateUIClasses({mouse:c})),this.doRender(o)},Ot.onMouseDown=function(t,e){return ut(e)?this.startOnActiveFeature(t,e):this.drawConfig.boxSelect&&function(t){return!!t.originalEvent&&!!t.originalEvent.shiftKey&&0===t.originalEvent.button}(e)?this.startBoxSelect(t,e):void 0},Ot.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=vt(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0},Ot.onTouchStart=function(t,e){if(ut(e))return this.startOnActiveFeature(t,e)},Ot.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},Ot.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:u}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add("mapbox-gl-draw_boxselect"),this.map.getContainer().appendChild(t.boxSelectElement));var n=vt(e.originalEvent,this.map.getContainer()),r=Math.min(t.boxSelectStartLocation.x,n.x),i=Math.max(t.boxSelectStartLocation.x,n.x),o=Math.min(t.boxSelectStartLocation.y,n.y),a=Math.max(t.boxSelectStartLocation.y,n.y),s="translate("+r+"px, "+o+"px)";t.boxSelectElement.style.transform=s,t.boxSelectElement.style.WebkitTransform=s,t.boxSelectElement.style.width=i-r+"px",t.boxSelectElement.style.height=a-o+"px"},Ot.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};Nt(this.getSelected(),n),t.dragMoveLocation=e.lngLat},Ot.onTouchEnd=Ot.onMouseUp=function(t,e){var n=this;if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){var r=[t.boxSelectStartLocation,vt(e.originalEvent,this.map.getContainer())],i=this.featuresAt(null,r,"click"),o=this.getUniqueIds(i).filter((function(t){return!n.isSelected(t)}));o.length&&(this.select(o),o.forEach((function(t){return n.doRender(t)})),this.updateUIClasses({mouse:c}))}this.stopExtendedInteractions(t)},Ot.toDisplayFeatures=function(t,e,n){e.properties.active=this.isSelected(e.properties.id)?A:L,n(e),this.fireActionable(),e.properties.active===A&&e.geometry.type!==y&&xt(e).forEach(n)},Ot.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Ot.onCombineFeatures=function(){var t=this.getSelected();if(!(0===t.length||t.length<2)){for(var e=[],n=[],r=t[0].type.replace("Multi",""),i=0;i1){var a=this.newFeature({type:d,properties:n[0].properties,geometry:{type:"Multi"+r,coordinates:e}});this.addFeature(a),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([a.id]),this.map.fire("draw.combine",{createdFeatures:[a.toGeoJSON()],deletedFeatures:n})}this.fireActionable()}},Ot.onUncombineFeatures=function(){var t=this,e=this.getSelected();if(0!==e.length){for(var n=[],r=[],i=function(i){var o=e[i];t.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach((function(e){t.addFeature(e),e.properties=o.properties,n.push(e.toGeoJSON()),t.select([e.id])})),t.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))},o=0;o1&&this.map.fire("draw.uncombine",{createdFeatures:n,deletedFeatures:r}),this.fireActionable()}};var kt=lt(I),zt=lt(C),Ft={fireUpdate:function(){this.map.fire(E,{action:"change_coordinates",features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(t){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:t.selectedCoordPaths.length>0})},startDragging:function(t,e){this.map.dragPan.disable(),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},stopDragging:function(t){this.map.dragPan.enable(),t.dragMoving=!1,t.canDragMove=!1,t.dragMoveLocation=null},onVertex:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties,r=t.selectedCoordPaths.indexOf(n.coord_path);ft(e)||-1!==r?ft(e)&&-1===r&&t.selectedCoordPaths.push(n.coord_path):t.selectedCoordPaths=[n.coord_path];var i=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(i)},onMidpoint:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties;t.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),t.selectedCoordPaths=[n.coord_path]},pathsToCoordinates:function(t,e){return e.map((function(e){return{feature_id:t,coord_path:e}}))},onFeature:function(t,e){0===t.selectedCoordPaths.length?this.startDragging(t,e):this.stopDragging(t)},dragFeature:function(t,e,n){Nt(this.getSelected(),n),t.dragMoveLocation=e.lngLat},dragVertex:function(t,e,n){for(var r=t.selectedCoordPaths.map((function(e){return t.feature.getCoordinate(e)})),i=Dt(r.map((function(t){return{type:d,properties:{},geometry:{type:y,coordinates:t}}})),n),o=0;o0?this.dragVertex(t,e,n):this.dragFeature(t,e,n),t.dragMoveLocation=e.lngLat}},Ft.onClick=function(t,e){return ht(e)?this.clickNoTarget(t,e):ut(e)?this.clickActiveFeature(t,e):ct(e)?this.clickInactive(t,e):void this.stopDragging(t)},Ft.onTap=function(t,e){return ht(e)?this.clickNoTarget(t,e):ut(e)?this.clickActiveFeature(t,e):ct(e)?this.clickInactive(t,e):void 0},Ft.onTouchEnd=Ft.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t)};var Bt={};function Ut(t,e){return!!t.lngLat&&t.lngLat.lng===e[0]&&t.lngLat.lat===e[1]}Bt.onSetup=function(){var t=this.newFeature({type:d,properties:{},geometry:{type:y,coordinates:[]}});return this.addFeature(t),this.clearSelectedFeatures(),this.updateUIClasses({mouse:u}),this.activateUIButton(f.POINT),this.setActionableState({trash:!0}),{point:t}},Bt.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)},Bt.onTap=Bt.onClick=function(t,e){this.updateUIClasses({mouse:c}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(b,{features:[t.point.toGeoJSON()]}),this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.point.id]})},Bt.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0})},Bt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.point.id;if(e.properties.active=r?A:L,!r)return n(e)},Bt.onTrash=Bt.stopDrawingAndRemove,Bt.onKeyUp=function(t,e){if(dt(e)||mt(e))return this.stopDrawingAndRemove(t,e)};var Vt={onSetup:function(){var t=this.newFeature({type:d,properties:{},geometry:{type:m,coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),wt(this),this.updateUIClasses({mouse:u}),this.activateUIButton(f.POLYGON),this.setActionableState({trash:!0}),{polygon:t,currentVertexPosition:0}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Ut(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:u}),t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),t.currentVertexPosition++,t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)},clickOnVertex:function(t){return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),pt(e)&&this.updateUIClasses({mouse:h})}};Vt.onTap=Vt.onClick=function(t,e){return pt(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},Vt.onKeyUp=function(t,e){dt(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)):mt(e)&&this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},Vt.onStop=function(t){this.updateUIClasses({mouse:p}),bt(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate("0."+t.currentVertexPosition),t.polygon.isValid()?this.map.fire(b,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT,{},{silent:!0})))},Vt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.polygon.id;if(e.properties.active=r?A:L,!r)return n(e);if(0!==e.geometry.coordinates.length){var i=e.geometry.coordinates[0].length;if(!(i<3)){if(e.properties.meta=T,n(_t(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1)),i>3){var o=e.geometry.coordinates[0].length-3;n(_t(t.polygon.id,e.geometry.coordinates[0][o],"0."+o,!1))}if(i<=4){var a=[[e.geometry.coordinates[0][0][0],e.geometry.coordinates[0][0][1]],[e.geometry.coordinates[0][1][0],e.geometry.coordinates[0][1][1]]];if(n({type:d,properties:e.properties,geometry:{coordinates:a,type:g}}),3===i)return}return n(e)}}},Vt.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)};var Gt={onSetup:function(t){var e,n,r=(t=t||{}).featureId,i="forward";if(r){if(!(e=this.getFeature(r)))throw new Error("Could not find a feature with the provided featureId");var o=t.from;if(o&&"Feature"===o.type&&o.geometry&&"Point"===o.geometry.type&&(o=o.geometry),o&&"Point"===o.type&&o.coordinates&&2===o.coordinates.length&&(o=o.coordinates),!o||!Array.isArray(o))throw new Error("Please use the `from` property to indicate which point to continue the line from");var a=e.coordinates.length-1;if(e.coordinates[a][0]===o[0]&&e.coordinates[a][1]===o[1])n=a+1,e.addCoordinate.apply(e,[n].concat(e.coordinates[a]));else{if(e.coordinates[0][0]!==o[0]||e.coordinates[0][1]!==o[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");i="backwards",n=0,e.addCoordinate.apply(e,[n].concat(e.coordinates[0]))}}else e=this.newFeature({type:d,properties:{},geometry:{type:g,coordinates:[]}}),n=0,this.addFeature(e);return this.clearSelectedFeatures(),wt(this),this.updateUIClasses({mouse:u}),this.activateUIButton(f.LINE),this.setActionableState({trash:!0}),{line:e,currentVertexPosition:n,direction:i}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Ut(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&Ut(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:u}),t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),"forward"===t.direction?(t.currentVertexPosition++,t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)):t.line.addCoordinate(0,e.lngLat.lng,e.lngLat.lat)},clickOnVertex:function(t){return this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),pt(e)&&this.updateUIClasses({mouse:h})}};Gt.onTap=Gt.onClick=function(t,e){if(pt(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e)},Gt.onKeyUp=function(t,e){mt(e)?this.changeMode(x.SIMPLE_SELECT,{featureIds:[t.line.id]}):dt(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT))},Gt.onStop=function(t){bt(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(""+t.currentVertexPosition),t.line.isValid()?this.map.fire(b,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT,{},{silent:!0})))},Gt.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(x.SIMPLE_SELECT)},Gt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.line.id;if(e.properties.active=r?A:L,!r)return n(e);e.geometry.coordinates.length<2||(e.properties.meta=T,n(_t(t.line.id,e.geometry.coordinates["forward"===t.direction?e.geometry.coordinates.length-2:1],""+("forward"===t.direction?e.geometry.coordinates.length-2:1),!1)),n(e))};var jt={simple_select:Ot,direct_select:Ft,draw_point:Bt,draw_polygon:Vt,draw_line_string:Gt},Ht={defaultMode:x.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}],modes:jt,controls:{},userProperties:!1},qt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Wt={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function Xt(t,e){return t.map((function(t){return t.source?t:it(t,{id:t.id+"."+e,source:"hot"===e?s:l})}))}var Zt=G((function(t,e){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,l={};l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object Boolean]"]=l["[object DataView]"]=l["[object Date]"]=l["[object Error]"]=l["[object Function]"]=l[r]=l["[object Number]"]=l[i]=l["[object RegExp]"]=l[o]=l["[object String]"]=l["[object WeakMap]"]=!1;var u="object"==typeof global&&global&&global.Object===Object&&global,c="object"==typeof self&&self&&self.Object===Object&&self,h=u||c||Function("return this")(),p=e&&!e.nodeType&&e,f=p&&t&&!t.nodeType&&t,d=f&&f.exports===p,m=d&&u.process,g=function(){try{return m&&m.binding&&m.binding("util")}catch(t){}}(),y=g&&g.isTypedArray;function v(t,e){for(var n=-1,r=null==t?0:t.length;++ns))return!1;var u=o.get(t);if(u&&o.get(e))return u==e;var c=-1,h=!0,p=2&n?new it:void 0;for(o.set(t,e),o.set(e,t);++c-1},nt.prototype.set=function(t,e){var n=this.__data__,r=at(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},rt.prototype.clear=function(){this.size=0,this.__data__={hash:new et,map:new(j||nt),string:new et}},rt.prototype.delete=function(t){var e=pt(this,t).delete(t);return this.size-=e?1:0,e},rt.prototype.get=function(t){return pt(this,t).get(t)},rt.prototype.has=function(t){return pt(this,t).has(t)},rt.prototype.set=function(t,e){var n=pt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},it.prototype.add=it.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},it.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.clear=function(){this.__data__=new nt,this.size=0},ot.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ot.prototype.get=function(t){return this.__data__.get(t)},ot.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.set=function(t,e){var n=this.__data__;if(n instanceof nt){var r=n.__data__;if(!j||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new rt(r)}return n.set(t,e),this.size=n.size,this};var dt=B?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}function St(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Mt(t){return null!=t&&"object"==typeof t}var Tt=y?function(t){return function(e){return t(e)}}(y):function(t){return Mt(t)&&Et(t.length)&&!!l[st(t)]};function Ct(t){return null!=(e=t)&&Et(e.length)&&!wt(e)?function(t,e){var n=xt(t),r=!n&&_t(t),i=!n&&!r&&bt(t),o=!n&&!r&&!i&&Tt(t),a=n||r||i||o,s=a?function(t,e){for(var n=-1,r=Array(t);++n0&&(u(this.container.parentElement,"open"),u(this.container,"active")),this.results=t},e.select=function(t){return Array.from(this.container.children).forEach((function(e,n){return n===t?u(e,"active"):c(e,"active")})),this.selected=t,this.results[t]},e.count=function(){return this.results?this.results.length:0},e.clear=function(){for(this.selected=-1;this.container.lastChild;)this.container.removeChild(this.container.lastChild);c(this.container.parentElement,"open"),c(this.container,"active")},t}(),v={position:"topleft",style:"button",showMarker:!0,showPopup:!1,popupFormat:function(t){return""+t.result.label},marker:{icon:e&&e.Icon?new e.Icon.Default:void 0,draggable:!1},maxMarkers:1,maxSuggestions:5,retainZoomLevel:!1,animateZoom:!0,searchLabel:"Enter address",notFoundMessage:"Sorry, that address could not be found.",messageHideDelay:3e3,zoomLevel:18,classNames:{container:"leaflet-bar leaflet-control leaflet-control-geosearch",button:"leaflet-bar-part leaflet-bar-part-single",resetButton:"reset",msgbox:"leaflet-bar message",form:"",input:""},autoComplete:!0,autoCompleteDelay:250,autoClose:!1,keepResult:!1},_={},x=["dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard"],b="Leaflet must be loaded before instantiating the GeoSearch control",w={options:n({},v),classNames:n({},v.classNames),initialize:function(t){var r,i,o,l,u=this;if(!e)throw new Error(b);if(!t.provider)throw new Error("Provider is missing from options");this.options=n({},this.options,{},t),this.classNames=n({},this.classNames,{},t.classNames),this.markers=new e.FeatureGroup,this.classNames.container+=" leaflet-geosearch-"+this.options.style,this.searchElement=new g({searchLabel:this.options.searchLabel,classNames:{container:this.classNames.container,form:this.classNames.form,input:this.classNames.input},handleSubmit:function(t){return u.onSubmit(t)}}),this.button=a("a",this.classNames.button,this.searchElement.container,{title:this.options.searchLabel,href:"#",onClick:function(t){return u.onClick(t)},onDblClick:function(t){return s(t)}}),this.resetButton=a("a",this.classNames.resetButton,this.searchElement.form,{text:"×",href:"#",onClick:function(){return u.clearResults(null,!0)}}),this.options.autoComplete&&(this.resultList=new y({handleClick:function(t){var e=t.result;u.searchElement.input.value=e.label,u.onSubmit({query:e.label,data:e})}}),this.searchElement.form.appendChild(this.resultList.container),this.searchElement.input.addEventListener("keyup",(r=function(t){return u.autoSearch(t)},void 0===(i=this.options.autoCompleteDelay)&&(i=250),void 0===o&&(o=!1),function(){for(var t=arguments.length,e=new Array(t),n=0;ne?0:r);this.searchElement.input.value=i.label}}else{var o=this.resultList.select(this.resultList.selected);this.onSubmit({query:this.searchElement.input.value,data:o})}},clearResults:function(t,e){if(void 0===e&&(e=!1),!t||27===t.keyCode){var n=this.options,r=n.autoComplete;!e&&n.keepResult||(this.searchElement.input.value="",this.markers.clearLayers()),r&&this.resultList.clear()}},autoSearch:function(t){try{var e=this;if(m.indexOf(t.keyCode)>-1)return Promise.resolve();var n=t.target.value,r=e.options.provider,i=function(){if(n.length)return Promise.resolve(r.search({query:n})).then((function(t){t=t.slice(0,e.options.maxSuggestions),e.resultList.render(t)}));e.resultList.clear()}();return Promise.resolve(i&&i.then?i.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},onSubmit:function(t){try{var e=this;return Promise.resolve(e.options.provider.search(t)).then((function(n){n&&n.length>0&&e.showResult(n[0],t)}))}catch(t){return Promise.reject(t)}},showResult:function(t,e){var n=this.options.autoClose,r=Object.keys(this.markers._layers);r.length>=this.options.maxMarkers&&this.markers.removeLayer(r[0]);var i=this.addMarker(t,e);this.centerMap(t),this.map.fireEvent("geosearch/showlocation",{location:t,marker:i}),n&&this.closeResults()},closeResults:function(){var t=this.searchElement.container;t.classList.contains("active")&&c(t,"active"),this.restoreHandlers(),this.clearResults()},addMarker:function(t,n){var r=this,i=this.options,o=i.marker,a=i.showPopup,s=i.popupFormat,l=new e.Marker([t.y,t.x],o),u=t.label;return"function"==typeof s&&(u=s({query:n,result:t})),l.bindPopup(u),this.markers.addLayer(l),a&&l.openPopup(),o.draggable&&l.on("dragend",(function(t){r.map.fireEvent("geosearch/marker/dragend",{location:l.getLatLng(),event:t})})),l},centerMap:function(t){var n=this.options,r=n.retainZoomLevel,i=n.animateZoom,o=t.bounds?new e.LatLngBounds(t.bounds):new e.LatLng(t.y,t.x).toBounds(10),a=o.isValid()?o:this.markers.getBounds();!r&&o.isValid()?this.map.fitBounds(a,{animate:i}):this.map.setView(a.getCenter(),this.getZoom(),{animate:i})},getZoom:function(){var t=this.options,e=t.zoomLevel;return t.retainZoomLevel?this.map.getZoom():e}};function E(){if(!e)throw new Error(b);for(var t=e.Control.extend(w),n=arguments.length,r=new Array(n),i=0;i3)return n.push({message:"position should not have more than 3 elements",level:"message",line:t.__line__||r});if(!l(t,"number"))return n.push({message:"each element in a position must be a number",line:t.__line__||r});if(e&&e.precisionWarning){if(i===o){i+=1;return n.push({message:"truncated warnings: we've encountered coordinate precision warning "+o+" times, no more warnings will be reported",level:"message",line:t.__line__||r})}ia){i+=1;return n.push({message:"precision of coordinates should be reduced",level:"message",line:t.__line__||r})}}))}}function h(t,e,r,i){void 0===i&&void 0!==t.__line__&&(i=t.__line__);if(0===r)return c(t,i);if(1===r&&e)if("LinearRing"===e){if(!Array.isArray(t[t.length-1])){n.push({message:"a number was found where a coordinate array should have been found: this needs to be nested more deeply",line:i});return!0}t.length<4&&n.push({message:"a LinearRing of coordinates needs to have four or more positions",line:i});if(t.length&&(t[t.length-1].length!==t[0].length||!t[t.length-1].every((function(e,n){return t[0][n]===e})))){n.push({message:"the first and last positions in a LinearRing of coordinates must be the same",line:i});return!0}}else if("Line"===e&&t.length<2)return n.push({message:"a line needs to have two or more coordinates to be valid",line:i});if(Array.isArray(t)){return t.map((function(t){return h(t,e,r-1,t.__line__||i)})).some((function(t){return t}))}n.push({message:"a number was found where a coordinate array should have been found: this needs to be nested more deeply",line:i})}function p(t){if(t.crs){"object"==typeof t.crs&&t.crs.properties&&"urn:ogc:def:crs:OGC:1.3:CRS84"===t.crs.properties.name?n.push({message:"old-style crs member is not recommended, this object is equivalent to the default and should be removed",line:t.__line__}):n.push({message:"old-style crs member is not recommended",line:t.__line__})}}function f(t){if(t.bbox){if(Array.isArray(t.bbox)){l(t.bbox,"number")||n.push({message:"each element in a bbox member must be a number",line:t.bbox.__line__});4!==t.bbox.length&&6!==t.bbox.length&&n.push({message:"bbox must contain 4 elements (for 2D) or 6 elements (for 3D)",line:t.bbox.__line__});return n.length}n.push({message:"bbox member must be an array of numbers, but is a "+typeof t.bbox,line:t.__line__})}}function d(t){p(t);f(t);void 0!==t.id&&"string"!=typeof t.id&&"number"!=typeof t.id&&n.push({message:'Feature "id" member must have a string or number value',line:t.__line__});void 0!==t.features&&n.push({message:'Feature object cannot contain a "features" member',line:t.__line__});void 0!==t.coordinates&&n.push({message:'Feature object cannot contain a "coordinates" member',line:t.__line__});"Feature"!==t.type&&n.push({message:"GeoJSON features must have a type=feature member",line:t.__line__});u(t,"properties","object");u(t,"geometry","object")||t.geometry&&s(t.geometry)}var m={Point:function(t){p(t);f(t);!function(t){void 0!==t.properties&&n.push({message:'geometry object cannot contain a "properties" member',line:t.__line__});void 0!==t.geometry&&n.push({message:'geometry object cannot contain a "geometry" member',line:t.__line__});void 0!==t.features&&n.push({message:'geometry object cannot contain a "features" member',line:t.__line__})}(t);u(t,"coordinates","array")||c(t.coordinates)},Feature:d,MultiPoint:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"",1)},LineString:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"Line",1)},MultiLineString:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"Line",2)},FeatureCollection:function(t){p(t);f(t);void 0!==t.properties&&n.push({message:'FeatureCollection object cannot contain a "properties" member',line:t.__line__});void 0!==t.coordinates&&n.push({message:'FeatureCollection object cannot contain a "coordinates" member',line:t.__line__});if(!u(t,"features","array")){if(!l(t.features,"object"))return n.push({message:"Every feature must be an object",line:t.__line__});t.features.forEach(d)}},GeometryCollection:function(t){p(t);f(t);if(!u(t,"geometries","array")){l(t.geometries,"object")||n.push({message:"The geometries array in a GeometryCollection must contain only geometry objects",line:t.__line__});1===t.geometries.length&&n.push({message:"GeometryCollection with a single geometry should be avoided in favor of single part or a single object of multi-part type",line:t.geometries.__line__});t.geometries.forEach((function(e){if(e){"GeometryCollection"===e.type&&n.push({message:"GeometryCollection should avoid nested geometry collections",line:t.geometries.__line__});s(e)}}))}},Polygon:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"LinearRing",2)||r(t,n)},MultiPolygon:function(t){p(t);f(t);u(t,"coordinates","array")||h(t.coordinates,"LinearRing",3)||r(t,n)}},g=Object.keys(m).reduce((function(t,e){t[e.toLowerCase()]=e;return t}),{});if("object"!=typeof t||null==t){n.push({message:"The root of a GeoJSON object must be an object.",line:0});return n}s(t);n.forEach((function(t){({}).hasOwnProperty.call(t,"line")&&void 0===t.line&&delete t.line}));return n}},{"./rhr":2}],2:[function(t,e,n){function r(t){var e=0;if(t.length>2)for(var n,r,i=0;i=0}function i(t){if(t&&t.length>0){if(r(t[0]))return!1;if(!t.slice(1,t.length).every(r))return!1}return!0}e.exports=function(t,e){(function(t){return"Polygon"===t.type?i(t.coordinates):"MultiPolygon"===t.type?t.coordinates.every(i):void 0})(t)||e.push({message:"Polygons and MultiPolygons should follow the right-hand rule",level:"message",line:t.__line__})}},{}],3:[function(t,e,n){},{}],4:[function(t,e,n){(function(r){(function(){var i=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,12],n=[1,13],r=[1,9],i=[1,10],o=[1,11],a=[1,14],s=[1,15],l=[14,18,22,24],u=[18,22],c=[22,24],h={trace:function(){},yy:{},symbols_:{error:2,JSONString:3,STRING:4,JSONNumber:5,NUMBER:6,JSONNullLiteral:7,NULL:8,JSONBooleanLiteral:9,TRUE:10,FALSE:11,JSONText:12,JSONValue:13,EOF:14,JSONObject:15,JSONArray:16,"{":17,"}":18,JSONMemberList:19,JSONMember:20,":":21,",":22,"[":23,"]":24,JSONElementList:25,$accept:0,$end:1},terminals_:{2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},productions_:[0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],performAction:function(t,e,n,r,i,o,a){var s=o.length-1;switch(i){case 1:this.$=t.replace(/\\(\\|")/g,"$1").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\v/g,"\v").replace(/\\f/g,"\f").replace(/\\b/g,"\b");break;case 2:this.$=Number(t);break;case 3:this.$=null;break;case 4:this.$=!0;break;case 5:this.$=!1;break;case 6:return this.$=o[s-1];case 13:this.$={};Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 14:case 19:this.$=o[s-1];Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 15:this.$=[o[s-2],o[s]];break;case 16:this.$={};this.$[o[s][0]]=o[s][1];break;case 17:this.$=o[s-2];if(void 0!==o[s-2][o[s][0]]){this.$.__duplicateProperties__||Object.defineProperty(this.$,"__duplicateProperties__",{value:[],enumerable:!1});this.$.__duplicateProperties__.push(o[s][0])}o[s-2][o[s][0]]=o[s][1];break;case 18:this.$=[];Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 20:this.$=[o[s]];break;case 21:this.$=o[s-2];o[s-2].push(o[s])}},table:[{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,12:1,13:2,15:7,16:8,17:a,23:s},{1:[3]},{14:[1,16]},t(l,[2,7]),t(l,[2,8]),t(l,[2,9]),t(l,[2,10]),t(l,[2,11]),t(l,[2,12]),t(l,[2,3]),t(l,[2,4]),t(l,[2,5]),t([14,18,21,22,24],[2,1]),t(l,[2,2]),{3:20,4:e,18:[1,17],19:18,20:19},{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,13:23,15:7,16:8,17:a,23:s,24:[1,21],25:22},{1:[2,6]},t(l,[2,13]),{18:[1,24],22:[1,25]},t(u,[2,16]),{21:[1,26]},t(l,[2,18]),{22:[1,28],24:[1,27]},t(c,[2,20]),t(l,[2,14]),{3:20,4:e,20:29},{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,13:30,15:7,16:8,17:a,23:s},t(l,[2,19]),{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:i,11:o,13:31,15:7,16:8,17:a,23:s},t(u,[2,17]),t(u,[2,15]),t(c,[2,21])],defaultActions:{16:[2,6]},parseError:function(t,e){if(!e.recoverable){function n(t,e){this.message=t;this.hash=e}n.prototype=Error;throw new n(t,e)}this.trace(t)},parse:function(t){var e=this,n=[0],r=[null],i=[],o=this.table,a="",s=0,l=0,u=0,c=i.slice.call(arguments,1),h=Object.create(this.lexer),p={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(p.yy[f]=this.yy[f]);h.setInput(t,p.yy);p.yy.lexer=h;p.yy.parser=this;void 0===h.yylloc&&(h.yylloc={});var d=h.yylloc;i.push(d);var m=h.options&&h.options.ranges;"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,y,v,_,x,b,w,E,S,M=function(){var t;"number"!=typeof(t=h.lex()||1)&&(t=e.symbols_[t]||t);return t},T={};;){v=n[n.length-1];if(this.defaultActions[v])_=this.defaultActions[v];else{null==g&&(g=M());_=o[v]&&o[v][g]}if(void 0===_||!_.length||!_[0]){var C="";S=[];for(b in o[v])this.terminals_[b]&&b>2&&S.push("'"+this.terminals_[b]+"'");C=h.showPosition?"Parse error on line "+(s+1)+":\n"+h.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'");this.parseError(C,{text:h.match,token:this.terminals_[g]||g,line:h.yylineno,loc:d,expected:S})}if(_[0]instanceof Array&&_.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+g);switch(_[0]){case 1:n.push(g);r.push(h.yytext);i.push(h.yylloc);n.push(_[1]);g=null;if(y){g=y;y=null}else{l=h.yyleng;a=h.yytext;s=h.yylineno;d=h.yylloc;u>0&&u--}break;case 2:w=this.productions_[_[1]][1];T.$=r[r.length-w];T._$={first_line:i[i.length-(w||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(w||1)].first_column,last_column:i[i.length-1].last_column};m&&(T._$.range=[i[i.length-(w||1)].range[0],i[i.length-1].range[1]]);if(void 0!==(x=this.performAction.apply(T,[a,l,s,p.yy,_[1],r,i].concat(c))))return x;if(w){n=n.slice(0,-1*w*2);r=r.slice(0,-1*w);i=i.slice(0,-1*w)}n.push(this.productions_[_[1]][0]);r.push(T.$);i.push(T._$);E=o[n[n.length-2]][n[n.length-1]];n.push(E);break;case 3:return!0}}return!0}},p={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){this.yy=e||this.yy||{};this._input=t;this._more=this._backtrack=this.done=!1;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};this.options.ranges&&(this.yylloc.range=[0,0]);this.offset=0;return this},input:function(){var t=this._input[0];this.yytext+=t;this.yyleng++;this.offset++;this.match+=t;this.matched+=t;if(t.match(/(?:\r\n?|\n).*/g)){this.yylineno++;this.yylloc.last_line++}else this.yylloc.last_column++;this.options.ranges&&this.yylloc.range[1]++;this._input=this._input.slice(1);return t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-e);this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);this.matched=this.matched.substr(0,this.matched.length-1);n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e};this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]);this.yyleng=this.yytext.length;return this},more:function(){this._more=!0;return this},reject:function(){if(!this.options.backtrack_lexer)return this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno});this._backtrack=!0;return this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;t.length<20&&(t+=this._input.substr(0,20-t.length));return(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer){i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done};this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))}(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length);this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length};this.yytext+=t[0];this.match+=t[0];this.matches=t;this.yyleng=this.yytext.length;this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]);this._more=!1;this._backtrack=!1;this._input=this._input.slice(t[0].length);this.matched+=t[0];n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]);this.done&&this._input&&(this.done=!1);if(n)return n;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,n,r;if(!this._more){this.yytext="";this.match=""}for(var i=this._currentRules(),o=0;oe[0].length)){e=n;r=o;if(this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:break;case 1:return 6;case 2:e.yytext=e.yytext.substr(1,e.yyleng-2);return 4;case 3:return 17;case 4:return 18;case 5:return 23;case 6:return 24;case 7:return 22;case 8:return 21;case 9:return 10;case 10:return 11;case 11:return 8;case 12:return 14;case 13:return"INVALID"}},rules:[/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt\/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};h.lexer=p;function f(){this.yy={}}f.prototype=h;h.Parser=f;return new f}();if(void 0!==t&&void 0!==n){n.parser=i;n.Parser=i.Parser;n.parse=function(){return i.parse.apply(i,arguments)};n.main=function(e){if(!e[1]){console.log("Usage: "+e[0]+" FILE");r.exit(1)}var i=t("fs").readFileSync(t("path").normalize(e[1]),"utf8");return n.parser.parse(i)};void 0!==e&&t.main===e&&n.main(r.argv.slice(1))}}).call(this)}).call(this,t("_process"))},{_process:6,fs:3,path:5}],5:[function(t,e,n){(function(t){(function(){function e(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];if("."===i)t.splice(r,1);else if(".."===i){t.splice(r,1);n++}else if(n){t.splice(r,1);n--}}if(e)for(;n--;n)t.unshift("..");return t}n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var a=o>=0?arguments[o]:t.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");if(a){n=a+"/"+n;i="/"===a.charAt(0)}}return(i?"/":"")+(n=e(r(n.split("/"),(function(t){return!!t})),!i).join("/"))||"."};n.normalize=function(t){var o=n.isAbsolute(t),a="/"===i(t,-1);(t=e(r(t.split("/"),(function(t){return!!t})),!o).join("/"))||o||(t=".");t&&a&&(t+="/");return(o?"/":"")+t};n.isAbsolute=function(t){return"/"===t.charAt(0)};n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))};n.relative=function(t,e){t=n.resolve(t).substr(1);e=n.resolve(e).substr(1);function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,l=0;l=1;--o)if(47===(e=t.charCodeAt(o))){if(!i){r=o;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"/":t.slice(0,r)};n.basename=function(t,e){var n=function(t){"string"!=typeof t&&(t+="");var e,n=0,r=-1,i=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!i){n=e+1;break}}else if(-1===r){i=!1;r=e+1}return-1===r?"":t.slice(n,r)}(t);e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length));return n};n.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,n=0,r=-1,i=!0,o=0,a=t.length-1;a>=0;--a){var s=t.charCodeAt(a);if(47!==s){if(-1===r){i=!1;r=a+1}46===s?-1===e?e=a:1!==o&&(o=1):-1!==e&&(o=-1)}else if(!i){n=a+1;break}}return-1===e||-1===r||0===o||1===o&&e===r-1&&e===n+1?"":t.slice(e,r)};function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r1)for(var n=1;n>8&255]+it[t>>16&255]+it[t>>24&255]+"-"+it[255&e]+it[e>>8&255]+"-"+it[e>>16&15|64]+it[e>>24&255]+"-"+it[63&n|128]+it[n>>8&255]+"-"+it[n>>16&255]+it[n>>24&255]+it[255&r]+it[r>>8&255]+it[r>>16&255]+it[r>>24&255]).toUpperCase()}function ut(t,e,n){return Math.max(e,Math.min(n,t))}function ct(t,e){return(t%e+e)%e}function ht(t,e,n){return(1-n)*t+n*e}function pt(t){return 0==(t&t-1)&&0!==t}function ft(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function dt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var mt=Object.freeze({__proto__:null,DEG2RAD:at,RAD2DEG:st,generateUUID:lt,clamp:ut,euclideanModulo:ct,mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:ht,damp:function(t,e,n,r){return ht(t,e,1-Math.exp(-n*r))},pingpong:function(t,e=1){return e-Math.abs(ct(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(ot=t%2147483647),((ot=16807*ot%2147483647)-1)/2147483646},degToRad:function(t){return t*at},radToDeg:function(t){return t*st},isPowerOfTwo:pt,ceilPowerOfTwo:ft,floorPowerOfTwo:dt,setQuaternionFromProperEuler:function(t,e,n,r,i){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),u=o((e+r)/2),c=a((e+r)/2),h=o((e-r)/2),p=a((e-r)/2),f=o((r-e)/2),d=a((r-e)/2);switch(i){case"XYX":t.set(s*c,l*h,l*p,s*u);break;case"YZY":t.set(l*p,s*c,l*h,s*u);break;case"ZXZ":t.set(l*h,l*p,s*c,s*u);break;case"XZX":t.set(s*c,l*d,l*f,s*u);break;case"YXY":t.set(l*f,s*c,l*d,s*u);break;case"ZYZ":t.set(l*d,l*f,s*c,s*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}});class gt{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}gt.prototype.isVector2=!0;class yt{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,r,i,o,a,s,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=i,u[5]=s,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],u=n[4],c=n[7],h=n[2],p=n[5],f=n[8],d=r[0],m=r[3],g=r[6],y=r[1],v=r[4],_=r[7],x=r[2],b=r[5],w=r[8];return i[0]=o*d+a*y+s*x,i[3]=o*m+a*v+s*b,i[6]=o*g+a*_+s*w,i[1]=l*d+u*y+c*x,i[4]=l*m+u*v+c*b,i[7]=l*g+u*_+c*w,i[2]=h*d+p*y+f*x,i[5]=h*m+p*v+f*b,i[8]=h*g+p*_+f*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*i*u+n*a*s+r*i*l-r*o*s}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=u*o-a*l,h=a*s-u*i,p=l*i-o*s,f=e*c+n*h+r*p;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const d=1/f;return t[0]=c*d,t[1]=(r*l-u*n)*d,t[2]=(a*n-r*o)*d,t[3]=h*d,t[4]=(u*e-r*s)*d,t[5]=(r*i-a*e)*d,t[6]=p*d,t[7]=(n*s-l*e)*d,t[8]=(o*e-n*i)*d,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,i,o,a){const s=Math.cos(i),l=Math.sin(i);return this.set(n*s,n*l,-n*(s*o+l*a)+o+t,-r*l,r*s,-r*(-l*o+s*a)+a+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),r=this.elements,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],u=r[7];return r[0]=e*i+n*s,r[3]=e*o+n*l,r[6]=e*a+n*u,r[1]=-n*i+e*s,r[4]=-n*o+e*l,r[7]=-n*a+e*u,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let vt;yt.prototype.isMatrix3=!0;class _t{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===vt&&(vt=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),vt.width=t.width,vt.height=t.height;const n=vt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=vt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}}let xt=0;class bt extends rt{constructor(t=bt.DEFAULT_IMAGE,e=bt.DEFAULT_MAPPING,n=1001,r=1001,i=1006,o=1008,a=1023,s=1009,l=1,u=3e3){super(),Object.defineProperty(this,"id",{value:xt++}),this.uuid=lt(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new gt(0,0),this.repeat=new gt(1,1),this.center=new gt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=u,this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const r=this.image;if(void 0===r.uuid&&(r.uuid=lt()),!e&&void 0===t.images[r.uuid]){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t1)switch(this.wrapS){case c:t.x=t.x-Math.floor(t.x);break;case h:t.x=t.x<0?0:1;break;case p:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case c:t.y=t.y-Math.floor(t.y);break;case h:t.y=t.y<0?0:1;break;case p:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function wt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_t.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}bt.DEFAULT_IMAGE=void 0,bt.DEFAULT_MAPPING=r,bt.prototype.isTexture=!0;class Et{constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const o=.01,a=t.elements,s=a[0],l=a[4],u=a[8],c=a[1],h=a[5],p=a[9],f=a[2],d=a[6],m=a[10];if(Math.abs(l-c)a&&t>g?tg?a=0?1:-1,r=1-e*e;if(r>Number.EPSILON){const i=Math.sqrt(r),o=Math.atan2(i,e*n);t=Math.sin(t*o)/i,a=Math.sin(a*o)/i}const i=a*n;if(s=s*t+h*i,l=l*t+p*i,u=u*t+f*i,c=c*t+d*i,t===1-a){const t=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=t,l*=t,u*=t,c*=t}}t[e]=s,t[e+1]=l,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,n,r,i,o){const a=n[r],s=n[r+1],l=n[r+2],u=n[r+3],c=i[o],h=i[o+1],p=i[o+2],f=i[o+3];return t[e]=a*f+u*c+s*p-l*h,t[e+1]=s*f+u*h+l*c-a*p,t[e+2]=l*f+u*p+a*h-s*c,t[e+3]=u*f-a*c-s*h-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,r=t._y,i=t._z,o=t._order,a=Math.cos,s=Math.sin,l=a(n/2),u=a(r/2),c=a(i/2),h=s(n/2),p=s(r/2),f=s(i/2);switch(o){case"XYZ":this._x=h*u*c+l*p*f,this._y=l*p*c-h*u*f,this._z=l*u*f+h*p*c,this._w=l*u*c-h*p*f;break;case"YXZ":this._x=h*u*c+l*p*f,this._y=l*p*c-h*u*f,this._z=l*u*f-h*p*c,this._w=l*u*c+h*p*f;break;case"ZXY":this._x=h*u*c-l*p*f,this._y=l*p*c+h*u*f,this._z=l*u*f+h*p*c,this._w=l*u*c-h*p*f;break;case"ZYX":this._x=h*u*c-l*p*f,this._y=l*p*c+h*u*f,this._z=l*u*f-h*p*c,this._w=l*u*c+h*p*f;break;case"YZX":this._x=h*u*c+l*p*f,this._y=l*p*c+h*u*f,this._z=l*u*f-h*p*c,this._w=l*u*c-h*p*f;break;case"XZY":this._x=h*u*c-l*p*f,this._y=l*p*c-h*u*f,this._z=l*u*f+h*p*c,this._w=l*u*c+h*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],o=e[1],a=e[5],s=e[9],l=e[2],u=e[6],c=e[10],h=n+a+c;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(u-s)*t,this._y=(i-l)*t,this._z=(o-r)*t}else if(n>a&&n>c){const t=2*Math.sqrt(1+n-a-c);this._w=(u-s)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(i+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-n-c);this._w=(i-l)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(s+u)/t}else{const t=2*Math.sqrt(1+c-n-a);this._w=(o-r)/t,this._x=(i+l)/t,this._y=(s+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ut(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,o=t._w,a=e._x,s=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+r*l-i*s,this._y=r*u+o*s+i*a-n*l,this._z=i*u+o*l+n*s-r*a,this._w=o*u-n*a-r*s-i*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,r=this._y,i=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const s=1-a*a;if(s<=Number.EPSILON){const t=1-e;return this._w=t*o+e*this._w,this._x=t*n+e*this._x,this._y=t*r+e*this._y,this._z=t*i+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),u=Math.atan2(l,a),c=Math.sin((1-e)*u)/l,h=Math.sin(e*u)/l;return this._w=o*c+this._w*h,this._x=n*c+this._x*h,this._y=r*c+this._y*h,this._z=i*c+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,n){this.copy(t).slerp(e,n)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Ct.prototype.isQuaternion=!0;class It{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Lt.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Lt.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,a=t.z,s=t.w,l=s*e+o*r-a*n,u=s*n+a*e-i*r,c=s*r+i*n-o*e,h=-i*e-o*n-a*r;return this.x=l*s+h*-i+u*-a-c*-o,this.y=u*s+h*-o+c*-i-l*-a,this.z=c*s+h*-a+l*-o-u*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return At.copy(this).projectOnVector(t),this.sub(At)}reflect(t){return this.sub(At.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ut(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}It.prototype.isVector3=!0;const At=new It,Lt=new Ct;class Pt{constructor(t=new It(1/0,1/0,1/0),e=new It(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=t.length;si&&(i=l),u>o&&(o=u),c>a&&(a=c)}return this.min.set(e,n,r),this.max.set(i,o,a),this}setFromBufferAttribute(t){let e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=t.count;si&&(i=l),u>o&&(o=u),c>a&&(a=c)}return this.min.set(e,n,r),this.max.set(i,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Dt),Dt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Vt),Gt.subVectors(this.max,Vt),Ot.subVectors(t.a,Vt),kt.subVectors(t.b,Vt),zt.subVectors(t.c,Vt),Ft.subVectors(kt,Ot),Bt.subVectors(zt,kt),Ut.subVectors(Ot,zt);let e=[0,-Ft.z,Ft.y,0,-Bt.z,Bt.y,0,-Ut.z,Ut.y,Ft.z,0,-Ft.x,Bt.z,0,-Bt.x,Ut.z,0,-Ut.x,-Ft.y,Ft.x,0,-Bt.y,Bt.x,0,-Ut.y,Ut.x,0];return!!qt(e,Ot,kt,zt,Gt)&&!!qt(e=[1,0,0,0,1,0,0,0,1],Ot,kt,zt,Gt)&&(jt.crossVectors(Ft,Bt),qt(e=[jt.x,jt.y,jt.z],Ot,kt,zt,Gt))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Dt.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Dt).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Rt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Rt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Rt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Rt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Rt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Rt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Rt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Rt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Rt)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Pt.prototype.isBox3=!0;const Rt=[new It,new It,new It,new It,new It,new It,new It,new It],Dt=new It,Nt=new Pt,Ot=new It,kt=new It,zt=new It,Ft=new It,Bt=new It,Ut=new It,Vt=new It,Gt=new It,jt=new It,Ht=new It;function qt(t,e,n,r,i){for(let o=0,a=t.length-3;o<=a;o+=3){Ht.fromArray(t,o);const a=i.x*Math.abs(Ht.x)+i.y*Math.abs(Ht.y)+i.z*Math.abs(Ht.z),s=e.dot(Ht),l=n.dot(Ht),u=r.dot(Ht);if(Math.max(-Math.max(s,l,u),Math.min(s,l,u))>a)return!1}return!0}const Wt=new Pt,Xt=new It,Zt=new It,Yt=new It;class Jt{constructor(t=new It,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Wt.setFromPoints(t).getCenter(n);let r=0;for(let e=0,i=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){Yt.subVectors(t,this.center);const e=Yt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add(Yt.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return Zt.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Xt.copy(t.center).add(Zt)),this.expandByPoint(Xt.copy(t.center).sub(Zt)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Kt=new It,Qt=new It,$t=new It,te=new It,ee=new It,ne=new It,re=new It;class ie{constructor(t=new It,e=new It(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Kt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Kt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Kt.copy(this.direction).multiplyScalar(e).add(this.origin),Kt.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){Qt.copy(t).add(e).multiplyScalar(.5),$t.copy(e).sub(t).normalize(),te.copy(this.origin).sub(Qt);const i=.5*t.distanceTo(e),o=-this.direction.dot($t),a=te.dot(this.direction),s=-te.dot($t),l=te.lengthSq(),u=Math.abs(1-o*o);let c,h,p,f;if(u>0)if(h=o*a-s,f=i*u,(c=o*s-a)>=0)if(h>=-f)if(h<=f){const t=1/u;p=(c*=t)*(c+o*(h*=t)+2*a)+h*(o*c+h+2*s)+l}else h=i,p=-(c=Math.max(0,-(o*h+a)))*c+h*(h+2*s)+l;else h=-i,p=-(c=Math.max(0,-(o*h+a)))*c+h*(h+2*s)+l;else h<=-f?p=-(c=Math.max(0,-(-o*i+a)))*c+(h=c>0?-i:Math.min(Math.max(-i,-s),i))*(h+2*s)+l:h<=f?(c=0,p=(h=Math.min(Math.max(-i,-s),i))*(h+2*s)+l):p=-(c=Math.max(0,-(o*i+a)))*c+(h=c>0?i:Math.min(Math.max(-i,-s),i))*(h+2*s)+l;else h=o>0?-i:i,p=-(c=Math.max(0,-(o*h+a)))*c+h*(h+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(c).add(this.origin),r&&r.copy($t).multiplyScalar(h).add(Qt),p}intersectSphere(t,e){Kt.subVectors(t.center,this.origin);const n=Kt.dot(this.direction),r=Kt.dot(Kt)-n*n,i=t.radius*t.radius;if(r>i)return null;const o=Math.sqrt(i-r),a=n-o,s=n+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,i,o,a,s;const l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(n=(t.min.x-h.x)*l,r=(t.max.x-h.x)*l):(n=(t.max.x-h.x)*l,r=(t.min.x-h.x)*l),u>=0?(i=(t.min.y-h.y)*u,o=(t.max.y-h.y)*u):(i=(t.max.y-h.y)*u,o=(t.min.y-h.y)*u),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o=0?(a=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(a=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s=0?n:r,e)))}intersectsBox(t){return null!==this.intersectBox(t,Kt)}intersectTriangle(t,e,n,r,i){ee.subVectors(e,t),ne.subVectors(n,t),re.crossVectors(ee,ne);let o,a=this.direction.dot(re);if(a>0){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}te.subVectors(this.origin,t);const s=o*this.direction.dot(ne.crossVectors(te,ne));if(s<0)return null;const l=o*this.direction.dot(ee.cross(te));if(l<0)return null;if(s+l>a)return null;const u=-o*te.dot(re);return u<0?null:this.at(u/a,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class oe{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,r,i,o,a,s,l,u,c,h,p,f,d,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new oe).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/ae.setFromMatrixColumn(t,0).length(),i=1/ae.setFromMatrixColumn(t,1).length(),o=1/ae.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),u=Math.cos(i),c=Math.sin(i);if("XYZ"===t.order){const t=o*u,n=o*c,r=a*u,i=a*c;e[0]=s*u,e[4]=-s*c,e[8]=l,e[1]=n+r*l,e[5]=t-i*l,e[9]=-a*s,e[2]=i-t*l,e[6]=r+n*l,e[10]=o*s}else if("YXZ"===t.order){const t=s*u,n=s*c,r=l*u,i=l*c;e[0]=t+i*a,e[4]=r*a-n,e[8]=o*l,e[1]=o*c,e[5]=o*u,e[9]=-a,e[2]=n*a-r,e[6]=i+t*a,e[10]=o*s}else if("ZXY"===t.order){const t=s*u,n=s*c,r=l*u,i=l*c;e[0]=t-i*a,e[4]=-o*c,e[8]=r+n*a,e[1]=n+r*a,e[5]=o*u,e[9]=i-t*a,e[2]=-o*l,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){const t=o*u,n=o*c,r=a*u,i=a*c;e[0]=s*u,e[4]=r*l-n,e[8]=t*l+i,e[1]=s*c,e[5]=i*l+t,e[9]=n*l-r,e[2]=-l,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){const t=o*s,n=o*l,r=a*s,i=a*l;e[0]=s*u,e[4]=i-t*c,e[8]=r*c+n,e[1]=c,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=n*c+r,e[10]=t-i*c}else if("XZY"===t.order){const t=o*s,n=o*l,r=a*s,i=a*l;e[0]=s*u,e[4]=-c,e[8]=l*u,e[1]=t*c+i,e[5]=o*u,e[9]=n*c-r,e[2]=r*c-n,e[6]=a*u,e[10]=i*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(le,t,ue)}lookAt(t,e,n){const r=this.elements;return pe.subVectors(t,e),0===pe.lengthSq()&&(pe.z=1),pe.normalize(),ce.crossVectors(n,pe),0===ce.lengthSq()&&(1===Math.abs(n.z)?pe.x+=1e-4:pe.z+=1e-4,pe.normalize(),ce.crossVectors(n,pe)),ce.normalize(),he.crossVectors(pe,ce),r[0]=ce.x,r[4]=he.x,r[8]=pe.x,r[1]=ce.y,r[5]=he.y,r[9]=pe.y,r[2]=ce.z,r[6]=he.z,r[10]=pe.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],u=n[1],c=n[5],h=n[9],p=n[13],f=n[2],d=n[6],m=n[10],g=n[14],y=n[3],v=n[7],_=n[11],x=n[15],b=r[0],w=r[4],E=r[8],S=r[12],M=r[1],T=r[5],C=r[9],I=r[13],A=r[2],L=r[6],P=r[10],R=r[14],D=r[3],N=r[7],O=r[11],k=r[15];return i[0]=o*b+a*M+s*A+l*D,i[4]=o*w+a*T+s*L+l*N,i[8]=o*E+a*C+s*P+l*O,i[12]=o*S+a*I+s*R+l*k,i[1]=u*b+c*M+h*A+p*D,i[5]=u*w+c*T+h*L+p*N,i[9]=u*E+c*C+h*P+p*O,i[13]=u*S+c*I+h*R+p*k,i[2]=f*b+d*M+m*A+g*D,i[6]=f*w+d*T+m*L+g*N,i[10]=f*E+d*C+m*P+g*O,i[14]=f*S+d*I+m*R+g*k,i[3]=y*b+v*M+_*A+x*D,i[7]=y*w+v*T+_*L+x*N,i[11]=y*E+v*C+_*P+x*O,i[15]=y*S+v*I+_*R+x*k,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],a=t[5],s=t[9],l=t[13],u=t[2],c=t[6],h=t[10],p=t[14];return t[3]*(+i*s*c-r*l*c-i*a*h+n*l*h+r*a*p-n*s*p)+t[7]*(+e*s*p-e*l*h+i*o*h-r*o*p+r*l*u-i*s*u)+t[11]*(+e*l*c-e*a*p-i*o*c+n*o*p+i*a*u-n*l*u)+t[15]*(-r*a*u-e*s*c+e*a*h+r*o*c-n*o*h+n*s*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11],f=t[12],d=t[13],m=t[14],g=t[15],y=c*m*l-d*h*l+d*s*p-a*m*p-c*s*g+a*h*g,v=f*h*l-u*m*l-f*s*p+o*m*p+u*s*g-o*h*g,_=u*d*l-f*c*l+f*a*p-o*d*p-u*a*g+o*c*g,x=f*c*s-u*d*s-f*a*h+o*d*h+u*a*m-o*c*m,b=e*y+n*v+r*_+i*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return t[0]=y*w,t[1]=(d*h*i-c*m*i-d*r*p+n*m*p+c*r*g-n*h*g)*w,t[2]=(a*m*i-d*s*i+d*r*l-n*m*l-a*r*g+n*s*g)*w,t[3]=(c*s*i-a*h*i-c*r*l+n*h*l+a*r*p-n*s*p)*w,t[4]=v*w,t[5]=(u*m*i-f*h*i+f*r*p-e*m*p-u*r*g+e*h*g)*w,t[6]=(f*s*i-o*m*i-f*r*l+e*m*l+o*r*g-e*s*g)*w,t[7]=(o*h*i-u*s*i+u*r*l-e*h*l-o*r*p+e*s*p)*w,t[8]=_*w,t[9]=(f*c*i-u*d*i-f*n*p+e*d*p+u*n*g-e*c*g)*w,t[10]=(o*d*i-f*a*i+f*n*l-e*d*l-o*n*g+e*a*g)*w,t[11]=(u*a*i-o*c*i-u*n*l+e*c*l+o*n*p-e*a*p)*w,t[12]=x*w,t[13]=(u*d*r-f*c*r+f*n*h-e*d*h-u*n*m+e*c*m)*w,t[14]=(f*a*r-o*d*r-f*n*s+e*d*s+o*n*m-e*a*m)*w,t[15]=(o*c*r-u*a*r+u*n*s-e*c*s-o*n*h+e*a*h)*w,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,o=t.x,a=t.y,s=t.z,l=i*o,u=i*a;return this.set(l*o+n,l*a-r*s,l*s+r*a,0,l*a+r*s,u*a+n,u*s-r*o,0,l*s-r*a,u*s+r*o,i*s*s+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,o){return this.set(1,n,i,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,o=e._y,a=e._z,s=e._w,l=i+i,u=o+o,c=a+a,h=i*l,p=i*u,f=i*c,d=o*u,m=o*c,g=a*c,y=s*l,v=s*u,_=s*c,x=n.x,b=n.y,w=n.z;return r[0]=(1-(d+g))*x,r[1]=(p+_)*x,r[2]=(f-v)*x,r[3]=0,r[4]=(p-_)*b,r[5]=(1-(h+g))*b,r[6]=(m+y)*b,r[7]=0,r[8]=(f+v)*w,r[9]=(m-y)*w,r[10]=(1-(h+d))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let i=ae.set(r[0],r[1],r[2]).length();const o=ae.set(r[4],r[5],r[6]).length(),a=ae.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],se.copy(this);const s=1/i,l=1/o,u=1/a;return se.elements[0]*=s,se.elements[1]*=s,se.elements[2]*=s,se.elements[4]*=l,se.elements[5]*=l,se.elements[6]*=l,se.elements[8]*=u,se.elements[9]*=u,se.elements[10]*=u,e.setFromRotationMatrix(se),n.x=i,n.y=o,n.z=a,this}makePerspective(t,e,n,r,i,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,s=2*i/(e-t),l=2*i/(n-r),u=(e+t)/(e-t),c=(n+r)/(n-r),h=-(o+i)/(o-i),p=-2*o*i/(o-i);return a[0]=s,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=h,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,n,r,i,o){const a=this.elements,s=1/(e-t),l=1/(n-r),u=1/(o-i),c=(e+t)*s,h=(n+r)*l,p=(o+i)*u;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-h,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}oe.prototype.isMatrix4=!0;const ae=new It,se=new oe,le=new It(0,0,0),ue=new It(1,1,1),ce=new It,he=new It,pe=new It,fe=new oe,de=new Ct;class me{constructor(t=0,e=0,n=0,r=me.DefaultOrder){this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],u=r[9],c=r[2],h=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(ut(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ut(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(ut(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-ut(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ut(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-ut(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return fe.makeRotationFromQuaternion(t),this.setFromRotationMatrix(fe,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return de.setFromEuler(this),this.setFromQuaternion(de,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new It(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}me.prototype.isEuler=!0,me.DefaultOrder="XYZ",me.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ge{constructor(){this.mask=1}set(t){this.mask=1<1){for(let t=0;t1){for(let t=0;t0){r.children=[];for(let e=0;e0){r.animations=[];for(let e=0;e0&&(n.geometries=e),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u)}return n.object=r,n;function o(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(t,e,n,r,i){Pe.subVectors(r,e),Re.subVectors(n,e),De.subVectors(t,e);const o=Pe.dot(Pe),a=Pe.dot(Re),s=Pe.dot(De),l=Re.dot(Re),u=Re.dot(De),c=o*l-a*a;if(0===c)return i.set(-2,-1,-1);const h=1/c,p=(l*s-a*u)*h,f=(o*u-a*s)*h;return i.set(1-p-f,f,p)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,Ne),Ne.x>=0&&Ne.y>=0&&Ne.x+Ne.y<=1}static getUV(t,e,n,r,i,o,a,s){return this.getBarycoord(t,e,n,r,Ne),s.set(0,0),s.addScaledVector(i,Ne.x),s.addScaledVector(o,Ne.y),s.addScaledVector(a,Ne.z),s}static isFrontFacing(t,e,n,r){return Pe.subVectors(n,e),Re.subVectors(t,e),Pe.cross(Re).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Pe.subVectors(this.c,this.b),Re.subVectors(this.a,this.b),.5*Pe.cross(Re).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ve.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ve.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,r,i){return Ve.getUV(t,this.a,this.b,this.c,e,n,r,i)}containsPoint(t){return Ve.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ve.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,i=this.c;let o,a;Oe.subVectors(r,n),ke.subVectors(i,n),Fe.subVectors(t,n);const s=Oe.dot(Fe),l=ke.dot(Fe);if(s<=0&&l<=0)return e.copy(n);Be.subVectors(t,r);const u=Oe.dot(Be),c=ke.dot(Be);if(u>=0&&c<=u)return e.copy(r);const h=s*c-u*l;if(h<=0&&s>=0&&u<=0)return o=s/(s-u),e.copy(n).addScaledVector(Oe,o);Ue.subVectors(t,i);const p=Oe.dot(Ue),f=ke.dot(Ue);if(f>=0&&p<=f)return e.copy(i);const d=p*l-s*f;if(d<=0&&l>=0&&f<=0)return a=l/(l-f),e.copy(n).addScaledVector(ke,a);const m=u*f-p*c;if(m<=0&&c-u>=0&&p-f>=0)return ze.subVectors(i,r),a=(c-u)/(c-u+(p-f)),e.copy(r).addScaledVector(ze,a);const g=1/(m+d+h);return o=d*g,a=h*g,e.copy(n).addScaledVector(Oe,o).addScaledVector(ke,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Ge=0;class je extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:Ge++}),this.uuid=lt(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=T,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=n,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheenTint&&this.sheenTint.isColor&&(n.sheenTint=this.sheenTint.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularTint&&this.specularTint.isColor&&(n.specularTint=this.specularTint.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(n.specularTintMap=this.specularTintMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationTint&&(n.attenuationTint=this.attenuationTint.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.format!==T&&(n.format=this.format),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){const e=r(t.textures),i=r(t.images);e.length>0&&(n.textures=e),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let r=0;r!==t;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}je.prototype.isMaterial=!0;const He={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},qe={h:0,s:0,l:0},We={h:0,s:0,l:0};function Xe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function Ze(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Ye(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Je{constructor(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,n){return this.r=t,this.g=e,this.b=n,this}setHSL(t,e,n){if(t=ct(t,1),e=ut(e,0,1),n=ut(n,0,1),0===e)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Xe(i,r,t+1/3),this.g=Xe(i,r,t),this.b=Xe(i,r,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const r=n[1],i=n[2];switch(r){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const n=parseFloat(t[1])/360,r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(n,r,i)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=He[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Ze(t.r),this.g=Ze(t.g),this.b=Ze(t.b),this}copyLinearToSRGB(t){return this.r=Ye(t.r),this.g=Ye(t.g),this.b=Ye(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){const e=this.r,n=this.g,r=this.b,i=Math.max(e,n,r),o=Math.min(e,n,r);let a,s;const l=(o+i)/2;if(o===i)a=0,s=0;else{const t=i-o;switch(s=l<=.5?t/(i+o):t/(2-i-o),i){case e:a=(n-r)/t+(ne&&(e=t[n]);return e}const fn={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function dn(t,e){return new fn[t](e)}let mn=0;const gn=new oe,yn=new Le,vn=new It,_n=new Pt,xn=new Pt,bn=new It;class wn extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:mn++}),this.uuid=lt(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(pn(t)>65535?ln:an)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new yt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(t),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return gn.makeRotationFromQuaternion(t),this.applyMatrix4(gn),this}rotateX(t){return gn.makeRotationX(t),this.applyMatrix4(gn),this}rotateY(t){return gn.makeRotationY(t),this.applyMatrix4(gn),this}rotateZ(t){return gn.makeRotationZ(t),this.applyMatrix4(gn),this}translate(t,e,n){return gn.makeTranslation(t,e,n),this.applyMatrix4(gn),this}scale(t,e,n){return gn.makeScale(t,e,n),this.applyMatrix4(gn),this}lookAt(t){return yn.lookAt(t),yn.updateMatrix(),this.applyMatrix4(yn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vn).negate(),this.translate(vn.x,vn.y,vn.z),this}setFromPoints(t){const e=[];for(let n=0,r=t.length;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const r=n[e];t.data.attributes[e]=r.toJSON(t.data)}const r={};let i=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],o=[];for(let e=0,r=n.length;e0&&(r[e]=o,i=!0)}i&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new wn).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const r=t.attributes;for(const t in r){const n=r[t];this.setAttribute(t,n.clone(e))}const i=t.morphAttributes;for(const t in i){const n=[],r=i[t];for(let t=0,i=r.length;t0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Mn.copy(n.boundingSphere),Mn.applyMatrix4(i),!1===t.ray.intersectsSphere(Mn))return;if(En.copy(i).invert(),Sn.copy(t.ray).applyMatrix4(En),null!==n.boundingBox&&!1===Sn.intersectsBox(n.boundingBox))return;let o;if(n.isBufferGeometry){const i=n.index,a=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,u=n.attributes.uv,c=n.attributes.uv2,h=n.groups,p=n.drawRange;if(null!==i)if(Array.isArray(r))for(let n=0,f=h.length;nn.far?null:{distance:u,point:Bn.clone(),object:t}}(t,e,n,r,Tn,Cn,In,Fn);if(f){s&&(On.fromBufferAttribute(s,u),kn.fromBufferAttribute(s,c),zn.fromBufferAttribute(s,h),f.uv=Ve.getUV(Fn,Tn,Cn,In,On,kn,zn,new gt)),l&&(On.fromBufferAttribute(l,u),kn.fromBufferAttribute(l,c),zn.fromBufferAttribute(l,h),f.uv2=Ve.getUV(Fn,Tn,Cn,In,On,kn,zn,new gt));const t={a:u,b:c,c:h,normal:new It,materialIndex:0};Ve.getNormal(Tn,Cn,In,t.normal),f.face=t}return f}Un.prototype.isMesh=!0;class Gn extends wn{constructor(t=1,e=1,n=1,r=1,i=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};const a=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const s=[],l=[],u=[],c=[];let h=0,p=0;function f(t,e,n,r,i,o,f,d,m,g,y){const v=o/m,_=f/g,x=o/2,b=f/2,w=d/2,E=m+1,S=g+1;let M=0,T=0;const C=new It;for(let o=0;o0?1:-1,u.push(C.x,C.y,C.z),c.push(s/m),c.push(1-o/g),M+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}Wn.prototype.isShaderMaterial=!0;class Xn extends Le{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new oe,this.projectionMatrix=new oe,this.projectionMatrixInverse=new oe}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}Xn.prototype.isCamera=!0;class Zn extends Xn{constructor(t=50,e=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*st*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*at*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*st*Math.atan(Math.tan(.5*at*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,r,i,o){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*at*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r;const o=this.view;if(null!==this.view&&this.view.enabled){const t=o.fullWidth,a=o.fullHeight;i+=o.offsetX*r/t,e-=o.offsetY*n/a,r*=o.width/t,n*=o.height/a}const a=this.filmOffset;0!==a&&(i+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}Zn.prototype.isPerspectiveCamera=!0;class Yn extends Le{constructor(t,e,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const r=new Zn(90,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new It(1,0,0)),this.add(r);const i=new Zn(90,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new It(-1,0,0)),this.add(i);const o=new Zn(90,1,t,e);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new It(0,1,0)),this.add(o);const a=new Zn(90,1,t,e);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new It(0,-1,0)),this.add(a);const s=new Zn(90,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new It(0,0,1)),this.add(s);const l=new Zn(90,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new It(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,o,a,s,l]=this.children,u=t.xr.enabled,c=t.getRenderTarget();t.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,i),t.setRenderTarget(n,2),t.render(e,o),t.setRenderTarget(n,3),t.render(e,a),t.setRenderTarget(n,4),t.render(e,s),n.texture.generateMipmaps=h,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(c),t.xr.enabled=u}}class Jn extends bt{constructor(t,e,n,r,o,a,s,l,u,c){super(t=void 0!==t?t:[],e=void 0!==e?e:i,n,r,o,a,s=void 0!==s?s:M,l,u,c),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Jn.prototype.isCubeTexture=!0;class Kn extends St{constructor(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),super(t,t,e),e=e||{},this.texture=new Jn(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=T,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n=new Gn(5,5,5),r=new Wn({name:"CubemapFromEquirect",uniforms:jn({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});r.uniforms.tEquirect.value=e;const i=new Un(n,r),o=e.minFilter;return e.minFilter===v&&(e.minFilter=g),new Yn(1,10,this).update(t,i),e.minFilter=o,i.geometry.dispose(),i.material.dispose(),this}clear(t,e,n,r){const i=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,n,r);t.setRenderTarget(i)}}Kn.prototype.isWebGLCubeRenderTarget=!0;const Qn=new It,$n=new It,tr=new yt;class er{constructor(t=new It(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Qn.subVectors(n,e).cross($n.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const n=t.delta(Qn),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:e.copy(n).multiplyScalar(i).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||tr.getNormalMatrix(t),r=this.coplanarPoint(Qn).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}er.prototype.isPlane=!0;const nr=new Jt,rr=new It;class ir{constructor(t=new er,e=new er,n=new er,r=new er,i=new er,o=new er){this.planes=[t,e,n,r,i,o]}set(t,e,n,r,i,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],p=n[9],f=n[10],d=n[11],m=n[12],g=n[13],y=n[14],v=n[15];return e[0].setComponents(a-r,c-s,d-h,v-m).normalize(),e[1].setComponents(a+r,c+s,d+h,v+m).normalize(),e[2].setComponents(a+i,c+l,d+p,v+g).normalize(),e[3].setComponents(a-i,c-l,d-p,v-g).normalize(),e[4].setComponents(a-o,c-u,d-f,v-y).normalize(),e[5].setComponents(a+o,c+u,d+f,v+y).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),nr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(nr)}intersectsSprite(t){return nr.center.set(0,0,0),nr.radius=.7071067811865476,nr.applyMatrix4(t.matrixWorld),this.intersectsSphere(nr)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,rr.y=r.normal.y>0?t.max.y:t.min.y,rr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(rr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function or(){let t=null,e=!1,n=null,r=null;function i(e,o){n(e,o),r=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==n&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function ar(t,e){const n=e.isWebGL2,r=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),r.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=r.get(e);n&&(t.deleteBuffer(n.buffer),r.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){const t=r.get(e);return void((!t||t.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotVH = saturate( dot( geometry.viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float NoH ) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float NoV, float NoL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( NoL + NoV - NoL * NoV ) ) );\n}\nvec3 BRDF_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in GeometricContext geometry ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularTintFactor = specularTint;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARTINTMAP\n\t\t\tspecularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularTintFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularTintFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenTint = sheenTint;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenTint;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( material.roughness, directLight.direction, geometry, material.sheenTint );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationTint, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = transmission.a;\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationTint;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularTint;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARTINTMAP\n\t\tuniform sampler2D specularTintMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenTint;\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},ur={common:{diffuse:{value:new Je(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new yt},uv2Transform:{value:new yt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new gt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Je(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new yt}},sprite:{diffuse:{value:new Je(16777215)},opacity:{value:1},center:{value:new gt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new yt}}},cr={basic:{uniforms:Hn([ur.common,ur.specularmap,ur.envmap,ur.aomap,ur.lightmap,ur.fog]),vertexShader:lr.meshbasic_vert,fragmentShader:lr.meshbasic_frag},lambert:{uniforms:Hn([ur.common,ur.specularmap,ur.envmap,ur.aomap,ur.lightmap,ur.emissivemap,ur.fog,ur.lights,{emissive:{value:new Je(0)}}]),vertexShader:lr.meshlambert_vert,fragmentShader:lr.meshlambert_frag},phong:{uniforms:Hn([ur.common,ur.specularmap,ur.envmap,ur.aomap,ur.lightmap,ur.emissivemap,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.fog,ur.lights,{emissive:{value:new Je(0)},specular:{value:new Je(1118481)},shininess:{value:30}}]),vertexShader:lr.meshphong_vert,fragmentShader:lr.meshphong_frag},standard:{uniforms:Hn([ur.common,ur.envmap,ur.aomap,ur.lightmap,ur.emissivemap,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.roughnessmap,ur.metalnessmap,ur.fog,ur.lights,{emissive:{value:new Je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lr.meshphysical_vert,fragmentShader:lr.meshphysical_frag},toon:{uniforms:Hn([ur.common,ur.aomap,ur.lightmap,ur.emissivemap,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.gradientmap,ur.fog,ur.lights,{emissive:{value:new Je(0)}}]),vertexShader:lr.meshtoon_vert,fragmentShader:lr.meshtoon_frag},matcap:{uniforms:Hn([ur.common,ur.bumpmap,ur.normalmap,ur.displacementmap,ur.fog,{matcap:{value:null}}]),vertexShader:lr.meshmatcap_vert,fragmentShader:lr.meshmatcap_frag},points:{uniforms:Hn([ur.points,ur.fog]),vertexShader:lr.points_vert,fragmentShader:lr.points_frag},dashed:{uniforms:Hn([ur.common,ur.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lr.linedashed_vert,fragmentShader:lr.linedashed_frag},depth:{uniforms:Hn([ur.common,ur.displacementmap]),vertexShader:lr.depth_vert,fragmentShader:lr.depth_frag},normal:{uniforms:Hn([ur.common,ur.bumpmap,ur.normalmap,ur.displacementmap,{opacity:{value:1}}]),vertexShader:lr.meshnormal_vert,fragmentShader:lr.meshnormal_frag},sprite:{uniforms:Hn([ur.sprite,ur.fog]),vertexShader:lr.sprite_vert,fragmentShader:lr.sprite_frag},background:{uniforms:{uvTransform:{value:new yt},t2D:{value:null}},vertexShader:lr.background_vert,fragmentShader:lr.background_frag},cube:{uniforms:Hn([ur.envmap,{opacity:{value:1}}]),vertexShader:lr.cube_vert,fragmentShader:lr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lr.equirect_vert,fragmentShader:lr.equirect_frag},distanceRGBA:{uniforms:Hn([ur.common,ur.displacementmap,{referencePosition:{value:new It},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lr.distanceRGBA_vert,fragmentShader:lr.distanceRGBA_frag},shadow:{uniforms:Hn([ur.lights,ur.fog,{color:{value:new Je(0)},opacity:{value:1}}]),vertexShader:lr.shadow_vert,fragmentShader:lr.shadow_frag}};function hr(t,e,n,r,i){const o=new Je(0);let a,s,u=0,c=null,h=0,p=null;function f(t,e){n.buffers.color.setClear(t.r,t.g,t.b,e,i)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),f(o,u=e)},getClearAlpha:function(){return u},setClearAlpha:function(t){f(o,u=t)},render:function(n,i){let d=!1,m=!0===i.isScene?i.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,y=g.getSession&&g.getSession();y&&"additive"===y.environmentBlendMode&&(m=null),null===m?f(o,u):m&&m.isColor&&(f(m,1),d=!0),(t.autoClear||d)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===s&&((s=new Un(new Gn(1,1,1),new Wn({name:"BackgroundCubeMaterial",uniforms:jn(cr.cube.uniforms),vertexShader:cr.cube.vertexShader,fragmentShader:cr.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(s)),s.material.uniforms.envMap.value=m,s.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,c===m&&h===m.version&&p===t.toneMapping||(s.material.needsUpdate=!0,c=m,h=m.version,p=t.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null)):m&&m.isTexture&&(void 0===a&&((a=new Un(new sr(2,2),new Wn({name:"BackgroundMaterial",uniforms:jn(cr.background.uniforms),vertexShader:cr.background.vertexShader,fragmentShader:cr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(a)),a.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),c===m&&h===m.version&&p===t.toneMapping||(a.material.needsUpdate=!0,c=m,h=m.version,p=t.toneMapping),n.unshift(a,a.geometry,a.material,0,0,null))}}}function pr(t,e,n,r){const i=t.getParameter(34921),o=r.isWebGL2?null:e.get("OES_vertex_array_object"),a=r.isWebGL2||null!==o,s={},l=p(null);let u=l;function c(e){return r.isWebGL2?t.bindVertexArray(e):o.bindVertexArrayOES(e)}function h(e){return r.isWebGL2?t.deleteVertexArray(e):o.deleteVertexArrayOES(e)}function p(t){const e=[],n=[],r=[];for(let t=0;t=0){let o=l[e];if(void 0===o&&("instanceMatrix"===e&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===e&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const e=o.normalized,a=o.itemSize,l=n.get(o);if(void 0===l)continue;const u=l.buffer,c=l.type,h=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,l=n.stride,p=o.offset;if(n&&n.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=o||e.has("WEBGL_draw_buffers"),u=!0===n.logarithmicDepthBuffer,c=t.getParameter(34930),h=t.getParameter(35660),p=t.getParameter(3379),f=t.getParameter(34076),d=t.getParameter(34921),m=t.getParameter(36347),g=t.getParameter(36348),y=t.getParameter(36349),v=h>0,_=o||e.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:a,logarithmicDepthBuffer:u,maxTextures:c,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:f,maxAttributes:d,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:y,vertexTextures:v,floatFragmentTextures:_,floatVertexTextures:v&&_,maxSamples:o?t.getParameter(36183):0}}function mr(t){const e=this;let n=null,r=0,i=!1,o=!1;const a=new er,s=new yt,l={value:null,needsUpdate:!1};function u(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function c(t,n,r,i){const o=null!==t?t.length:0;let u=null;if(0!==o){if(u=l.value,!0!==i||null===u){const e=r+4*o,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===u||u.length0){const a=t.getRenderTarget(),s=new Kn(o.height/2);return s.fromEquirectangularTexture(t,i),e.set(i,s),t.setRenderTarget(a),i.addEventListener("dispose",r),n(s.texture,i.mapping)}return null}}}return i},dispose:function(){e=new WeakMap}}}cr.physical={uniforms:Hn([cr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new gt(1,1)},clearcoatNormalMap:{value:null},sheenTint:{value:new Je(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new gt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationTint:{value:new Je(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularTint:{value:new Je(1,1,1)},specularTintMap:{value:null}}]),vertexShader:lr.meshphysical_vert,fragmentShader:lr.meshphysical_frag};class yr extends Xn{constructor(t=-1,e=1,n=1,r=-1,i=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=i,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,i,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-t,o=n+t,a=r+e,s=r-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o=(i+=t*this.view.offsetX)+t*this.view.width,s=(a-=e*this.view.offsetY)-e*this.view.height}this.projectionMatrix.makeOrthographic(i,o,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}yr.prototype.isOrthographicCamera=!0;class vr extends Wn{constructor(t){super(t),this.type="RawShaderMaterial"}}vr.prototype.isRawShaderMaterial=!0;const _r=Math.pow(2,8),xr=[.125,.215,.35,.446,.526,.582],br=5+xr.length,wr={[X]:0,[Z]:1,[J]:2,[K]:3,[Q]:4,[$]:5,[Y]:6},Er=new yr,{_lodPlanes:Sr,_sizeLods:Mr,_sigmas:Tr}=function(){const t=[],e=[],n=[];let r=8;for(let i=0;i4?a=xr[i-8+4-1]:0==i&&(a=0),n.push(a);const s=1/(o-1),l=-s/2,u=1+s/2,c=[l,l,u,l,u,u,l,l,u,u,l,u],h=6,p=6,f=3,d=2,m=1,g=new Float32Array(f*p*h),y=new Float32Array(d*p*h),v=new Float32Array(m*p*h);for(let t=0;t2?0:-1,r=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];g.set(r,f*p*t),y.set(c,d*p*t);const i=[t,t,t,t,t,t];v.set(i,m*p*t)}const _=new wn;_.setAttribute("position",new tn(g,f)),_.setAttribute("uv",new tn(y,d)),_.setAttribute("faceIndex",new tn(v,m)),t.push(_),r>4&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}(),Cr=new Je;let Ir=null;const Ar=(1+Math.sqrt(5))/2,Lr=1/Ar,Pr=[new It(1,1,1),new It(-1,1,1),new It(1,1,-1),new It(-1,1,-1),new It(0,Ar,Lr),new It(0,Ar,-Lr),new It(Lr,0,Ar),new It(-Lr,0,Ar),new It(Ar,Lr,0),new It(-Ar,Lr,0)];class Rr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(20),n=new It(0,1,0);return new vr({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){Ir=this._renderer.getRenderTarget();const i=this._allocateTargets();return this._sceneToCubeUV(t,n,r,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=zr(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=kr(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t2?_r:0,_r,_r),s.setRenderTarget(r),f&&s.render(p,i),s.render(t,i)}p.geometry.dispose(),p.material.dispose(),s.toneMapping=c,s.outputEncoding=u,s.autoClear=l,t.background=d}_textureToCubeUV(t,e){const n=this._renderer;t.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=zr()):null==this._equirectShader&&(this._equirectShader=kr());const r=t.isCubeTexture?this._cubemapShader:this._equirectShader,i=new Un(Sr[0],r),o=r.uniforms;o.envMap.value=t,t.isCubeTexture||o.texelSize.value.set(1/t.image.width,1/t.image.height),o.inputEncoding.value=wr[t.encoding],o.outputEncoding.value=wr[e.texture.encoding],Or(e,0,0,3*_r,2*_r),n.setRenderTarget(e),n.render(i,Er)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let e=1;e20&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${d} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<20;++t){const e=t/f,n=Math.exp(-e*e/2);m.push(n),0==t?g+=n:t4?r-8+4:0),3*y,2*y),s.setRenderTarget(e),s.render(u,Er)}}function Dr(t){return void 0!==t&&t.type===_&&(t.encoding===X||t.encoding===Z||t.encoding===Y)}function Nr(t){const e=new St(3*_r,3*_r,t);return e.texture.mapping=l,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Or(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function kr(){const t=new gt(1,1);return new vr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function zr(){return new vr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:wr[3e3]},outputEncoding:{value:wr[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Fr(t){let e=new WeakMap,n=null;function r(t){const n=t.target;n.removeEventListener("dispose",r);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}return{get:function(l){if(l&&l.isTexture&&!1===l.isRenderTargetTexture){const u=l.mapping,c=u===a||u===s,h=u===i||u===o;if(c||h){if(e.has(l))return e.get(l).texture;{const i=l.image;if(c&&i&&i.height>0||h&&i&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(i)){const i=t.getRenderTarget();null===n&&(n=new Rr(t));const o=c?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,o),t.setRenderTarget(i),l.addEventListener("dispose",r),o.texture}return null}}}return l},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Br(t){const e={};function n(n){if(void 0!==e[n])return e[n];let r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,r}return{has:function(t){return null!==n(t)},init:function(t){t.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(t){const e=n(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Ur(t,e,n,r){const i={},o=new WeakMap;function a(t){const s=t.target;null!==s.index&&e.remove(s.index);for(const t in s.attributes)e.remove(s.attributes[t]);s.removeEventListener("dispose",a),delete i[s.id];const l=o.get(s);l&&(e.remove(l),o.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(t){const n=[],r=t.index,i=t.attributes.position;let a=0;if(null!==r){const t=r.array;a=r.version;for(let e=0,r=t.length;e65535?ln:an)(n,1);s.version=a;const l=o.get(t);l&&e.remove(l),o.set(t,s)}return{get:function(t,e){return!0===i[e.id]||(e.addEventListener("dispose",a),i[e.id]=!0,n.memory.geometries++),e},update:function(t){const n=t.attributes;for(const t in n)e.update(n[t],34962);const r=t.morphAttributes;for(const t in r){const n=r[t];for(let t=0,r=n.length;t0)return t;const i=e*n;let o=$r[i];if(void 0===o&&(o=new Float32Array(i),$r[i]=o),0!==e){r.toArray(o,0);for(let r=1,i=0;r!==e;++r)i+=n,t[r].toArray(o,i)}return o}function oi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n/gm;function lo(t){return t.replace(so,uo)}function uo(t,e){const n=lr[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return lo(n)}const co=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,ho=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function po(t){return t.replace(ho,mo).replace(co,fo)}function fo(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),mo(t,e,n,r)}function mo(t,e,n,r){let i="";for(let t=parseInt(e);t0?t.gammaFactor:1,y=n.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(io).join("\n")}(n),v=function(t){const e=[];for(const n in t){const r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(s),_=a.createProgram();let x,b,w=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((x=[v].filter(io).join("\n")).length>0&&(x+="\n"),(b=[y,v].filter(io).join("\n")).length>0&&(b+="\n")):(x=[go(n),"#define SHADER_NAME "+n.shaderName,v,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularTintMap?"#define USE_SPECULARTINTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+p:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(io).join("\n"),b=[y,go(n),"#define SHADER_NAME "+n.shaderName,v,"#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.envMap?"#define "+d:"",n.envMap?"#define "+m:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularTintMap?"#define USE_SPECULARTINTMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheenTint?"#define USE_SHEEN":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+p:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?lr.tonemapping_pars_fragment:"",0!==n.toneMapping?ro("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.format===M?"#define OPAQUE":"",lr.encodings_pars_fragment,n.map?eo("mapTexelToLinear",n.mapEncoding):"",n.matcap?eo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?eo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?eo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.specularTintMap?eo("specularTintMapTexelToLinear",n.specularTintMapEncoding):"",n.lightMap?eo("lightMapTexelToLinear",n.lightMapEncoding):"",no("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(io).join("\n")),c=ao(c=oo(c=lo(c),n),n),h=ao(h=oo(h=lo(h),n),n),c=po(c),h=po(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(w="#version 300 es\n",x=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#define varying in",n.glslVersion===nt?"":"out highp vec4 pc_fragColor;",n.glslVersion===nt?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+b);const E=w+b+h,S=Ki(a,35633,w+x+c),T=Ki(a,35632,E);if(a.attachShader(_,S),a.attachShader(_,T),void 0!==n.index0AttributeName?a.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&a.bindAttribLocation(_,0,"position"),a.linkProgram(_),t.debug.checkShaderErrors){const t=a.getProgramInfoLog(_).trim(),e=a.getShaderInfoLog(S).trim(),n=a.getShaderInfoLog(T).trim();let r=!0,i=!0;if(!1===a.getProgramParameter(_,35714)){r=!1;const e=to(a,S,"vertex"),n=to(a,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(_,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==n||(i=!1);i&&(this.diagnostics={runnable:r,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:n,prefix:b}})}let C,I;return a.deleteShader(S),a.deleteShader(T),this.getUniforms=function(){return void 0===C&&(C=new Ji(a,_)),C},this.getAttributes=function(){return void 0===I&&(I=function(t,e){const n={},r=t.getProgramParameter(e,35721);for(let i=0;i0,L=o.clearcoat>0;return{isWebGL2:c,shaderID:S,shaderName:o.type,vertexShader:T,fragmentShader:C,defines:o.defines,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:m,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:d,outputEncoding:null!==I?v(I.texture):t.outputEncoding,map:!!o.map,mapEncoding:v(o.map),matcap:!!o.matcap,matcapEncoding:v(o.matcap),envMap:!!E,envMapMode:E&&E.mapping,envMapEncoding:v(E),envMapCubeUV:!!E&&(E.mapping===l||E.mapping===u),lightMap:!!o.lightMap,lightMapEncoding:v(o.lightMap),aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,emissiveMapEncoding:v(o.emissiveMap),bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:1===o.normalMapType,tangentSpaceNormalMap:0===o.normalMapType,clearcoat:L,clearcoatMap:L&&!!o.clearcoatMap,clearcoatRoughnessMap:L&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:L&&!!o.clearcoatNormalMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularTintMap:!!o.specularTintMap,specularTintMapEncoding:v(o.specularTintMap),alphaMap:!!o.alphaMap,alphaTest:A,gradientMap:!!o.gradientMap,sheenTint:!!o.sheenTint&&(o.sheenTint.r>0||o.sheenTint.g>0||o.sheenTint.b>0),transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!x.geometry&&!!x.geometry.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!x.geometry&&!!x.geometry.attributes.color&&4===x.geometry.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularTintMap||!o.displacementMap),fog:!!b,useFog:o.fog,fogExp2:b&&b.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===x.isSkinnedMesh&&M>0,maxBones:M,useVertexTexture:p,morphTargets:!!x.geometry&&!!x.geometry.morphAttributes.position,morphNormals:!!x.geometry&&!!x.geometry.morphAttributes.normal,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,format:o.format,dithering:o.dithering,shadowMapEnabled:t.shadowMap.enabled&&y.length>0,shadowMapType:t.shadowMap.type,toneMapping:o.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:2===o.side,flipSided:1===o.side,depthPacking:void 0!==o.depthPacking&&o.depthPacking,index0AttributeName:o.index0AttributeName,extensionDerivatives:o.extensions&&o.extensions.derivatives,extensionFragDepth:o.extensions&&o.extensions.fragDepth,extensionDrawBuffers:o.extensions&&o.extensions.drawBuffers,extensionShaderTextureLOD:o.extensions&&o.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t0?i.push(c):!0===n.transparent?o.push(c):r.push(c)},unshift:function(t,e,n,a,l,u){const c=s(t,e,n,a,l,u);n.transmission>0?i.unshift(c):!0===n.transparent?o.unshift(c):r.unshift(c)},finish:function(){for(let t=n,r=e.length;t1&&r.sort(t||xo),i.length>1&&i.sort(e||bo),o.length>1&&o.sort(e||bo)}}}function Eo(t){let e=new WeakMap;return{get:function(n,r){let i;return!1===e.has(n)?(i=new wo(t),e.set(n,[i])):r>=e.get(n).length?(i=new wo(t),e.get(n).push(i)):i=e.get(n)[r],i},dispose:function(){e=new WeakMap}}}function So(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new It,color:new Je};break;case"SpotLight":n={position:new It,direction:new It,color:new Je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new It,color:new Je,distance:0,decay:0};break;case"HemisphereLight":n={direction:new It,skyColor:new Je,groundColor:new Je};break;case"RectAreaLight":n={color:new Je,position:new It,halfWidth:new It,halfHeight:new It}}return t[e.id]=n,n}}}let Mo=0;function To(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function Co(t,e){const n=new So,r=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)i.probe.push(new It);const o=new It,a=new oe,s=new oe;return{setup:function(o,a){let s=0,l=0,u=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let c=0,h=0,p=0,f=0,d=0,m=0,g=0,y=0;o.sort(To);const v=!0!==a?Math.PI:1;for(let t=0,e=o.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=ur.LTC_FLOAT_1,i.rectAreaLTC2=ur.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=ur.LTC_HALF_1,i.rectAreaLTC2=ur.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=u;const _=i.hash;_.directionalLength===c&&_.pointLength===h&&_.spotLength===p&&_.rectAreaLength===f&&_.hemiLength===d&&_.numDirectionalShadows===m&&_.numPointShadows===g&&_.numSpotShadows===y||(i.directional.length=c,i.spot.length=p,i.rectArea.length=f,i.point.length=h,i.hemi.length=d,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=y,_.directionalLength=c,_.pointLength=h,_.spotLength=p,_.rectAreaLength=f,_.hemiLength=d,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=y,i.version=Mo++)},setupView:function(t,e){let n=0,r=0,l=0,u=0,c=0;const h=e.matrixWorldInverse;for(let e=0,p=t.length;e=n.get(r).length?(o=new Io(t,e),n.get(r).push(o)):o=n.get(r)[i],o},dispose:function(){n=new WeakMap}}}class Lo extends je{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}Lo.prototype.isMeshDepthMaterial=!0;class Po extends je{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new It,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Ro(t,e,n){let r=new ir;const i=new gt,o=new gt,a=new Et,s=new Lo({depthPacking:3201}),l=new Po,u={},c=n.maxTextureSize,h={0:1,1:0,2:2},p=new Wn({uniforms:{shadow_pass:{value:null},resolution:{value:new gt},radius:{value:4},samples:{value:8}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nuniform float samples;\n#include \nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),d=p.clone();d.defines.HORIZONTAL_PASS=1;const m=new wn;m.setAttribute("position",new tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Un(m,p),v=this;function _(n,r){const i=e.update(y);p.uniforms.shadow_pass.value=n.map.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,p.uniforms.samples.value=n.blurSamples,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(r,null,i,p,y,null),d.uniforms.shadow_pass.value=n.mapPass.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,d.uniforms.samples.value=n.blurSamples,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(r,null,i,d,y,null)}function x(e,n,r,i,o,a,c){let p=null;const f=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(p=void 0!==f?f:!0===i.isPointLight?l:s,t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0){const t=p.uuid,e=r.uuid;let n=u[t];void 0===n&&(n={},u[t]=n);let i=n[e];void 0===i&&(i=p.clone(),n[e]=i),p=i}return p.visible=r.visible,p.wireframe=r.wireframe,p.side=3===c?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:h[r.side],p.alphaMap=r.alphaMap,p.alphaTest=r.alphaTest,p.clipShadows=r.clipShadows,p.clippingPlanes=r.clippingPlanes,p.clipIntersection=r.clipIntersection,p.displacementMap=r.displacementMap,p.displacementScale=r.displacementScale,p.displacementBias=r.displacementBias,p.wireframeLinewidth=r.wireframeLinewidth,p.linewidth=r.linewidth,!0===i.isPointLight&&!0===p.isMeshDistanceMaterial&&(p.referencePosition.setFromMatrixPosition(i.matrixWorld),p.nearDistance=o,p.farDistance=a),p}function b(n,i,o,a,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const r=e.update(n),i=n.material;if(Array.isArray(i)){const e=r.groups;for(let l=0,u=e.length;lc||i.y>c)&&(i.x>c&&(o.x=Math.floor(c/d.x),i.x=o.x*d.x,h.mapSize.x=o.x),i.y>c&&(o.y=Math.floor(c/d.y),i.y=o.y*d.y,h.mapSize.y=o.y)),null===h.map&&!h.isPointLightShadow&&3===this.type){const t={minFilter:g,magFilter:g,format:T};h.map=new St(i.x,i.y,t),h.map.texture.name=u.name+".shadowMap",h.mapPass=new St(i.x,i.y,t),h.camera.updateProjectionMatrix()}if(null===h.map){const t={minFilter:f,magFilter:f,format:T};h.map=new St(i.x,i.y,t),h.map.texture.name=u.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const m=h.getViewportCount();for(let t=0;t=1):-1!==A.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),C=I>=2);let L=null,P={};const R=t.getParameter(3088),D=t.getParameter(2978),N=(new Et).fromArray(R),O=(new Et).fromArray(D);function k(e,n,r){const i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;er||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const r=e?dt:Math.floor,o=r(i*t.width),a=r(i*t.height);void 0===P&&(P=D(o,a));const s=n?D(o,a):P;return s.width=o,s.height=a,s.getContext("2d").drawImage(t,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+a+")."),s}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function O(t){return pt(t.width)&&pt(t.height)}function k(t,e){return t.generateMipmaps&&e&&t.minFilter!==f&&t.minFilter!==g}function z(e,n,i,o,a=1){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log2(Math.max(i,o,a))}function F(n,r,i){if(!1===s)return r;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=r;return 6403===r&&(5126===i&&(o=33326),5131===i&&(o=33325),5121===i&&(o=33321)),6407===r&&(5126===i&&(o=34837),5131===i&&(o=34843),5121===i&&(o=32849)),6408===r&&(5126===i&&(o=34836),5131===i&&(o=34842),5121===i&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||e.get("EXT_color_buffer_float"),o}function B(t){return t===f||t===d||t===m?9728:9729}function U(e){const n=e.target;n.removeEventListener("dispose",U),function(e){const n=r.get(e);void 0!==n.__webglInit&&(t.deleteTexture(n.__webglTexture),r.remove(e))}(n),n.isVideoTexture&&L.delete(n),a.memory.textures--}function V(e){const n=e.target;n.removeEventListener("dispose",V),function(e){const n=e.texture,i=r.get(e),o=r.get(n);if(e){if(void 0!==o.__webglTexture&&(t.deleteTexture(o.__webglTexture),a.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,i=n.length;e0&&i.__version!==t.version){const n=t.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void Y(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function H(e,i){const a=r.get(e);e.version>0&&a.__version!==e.version?function(e,r,i){if(6!==r.image.length)return;Z(e,r),n.activeTexture(33984+i),n.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const a=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),l=r.image[0]&&r.image[0].isDataTexture,c=[];for(let t=0;t<6;t++)c[t]=a||l?l?r.image[t].image:r.image[t]:N(r.image[t],!1,!0,u);const h=c[0],p=O(h)||s,f=o.convert(r.format),d=o.convert(r.type),m=F(r.internalFormat,f,d);let g;if(X(34067,r,p),a){for(let t=0;t<6;t++){g=c[t].mipmaps;for(let e=0;e1||r.get(o).__currentAnisotropy)&&(t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function Z(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",U),e.__webglTexture=t.createTexture(),a.memory.textures++)}function Y(e,r,i){let a=3553;r.isDataTexture2DArray&&(a=35866),r.isDataTexture3D&&(a=32879),Z(e,r),n.activeTexture(33984+i),n.bindTexture(a,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!s&&(t.wrapS!==h||t.wrapT!==h||t.minFilter!==f&&t.minFilter!==g)}(r)&&!1===O(r.image),u=N(r.image,l,!1,_),c=O(u)||s,p=o.convert(r.format);let d,m=o.convert(r.type),y=F(r.internalFormat,p,m);X(a,r,c);const v=r.mipmaps;if(r.isDepthTexture)y=6402,s?y=r.type===w?36012:r.type===b?33190:r.type===S?35056:33189:r.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===C&&6402===y&&r.type!==x&&r.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=x,m=o.convert(r.type)),r.format===I&&6402===y&&(y=34041,r.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=S,m=o.convert(r.type))),n.texImage2D(3553,0,y,u.width,u.height,0,p,m,null);else if(r.isDataTexture)if(v.length>0&&c){for(let t=0,e=v.length;t0&&c){for(let t=0,e=v.length;t=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),G+=1,t},this.resetTextureUnits=function(){G=0},this.setTexture2D=j,this.setTexture2DArray=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?Y(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?Y(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=H,this.setupRenderTarget=function(e){const l=e.texture,u=r.get(e),c=r.get(l);e.addEventListener("dispose",V),!0!==e.isWebGLMultipleRenderTargets&&(c.__webglTexture=t.createTexture(),c.__version=l.version,a.memory.textures++);const h=!0===e.isWebGLCubeRenderTarget,p=!0===e.isWebGLMultipleRenderTargets,f=!0===e.isWebGLMultisampleRenderTarget,d=l.isDataTexture3D||l.isDataTexture2DArray,m=O(e)||s;if(!s||l.format!==M||l.type!==w&&l.type!==E||(l.format=T,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){u.__webglFramebuffer=[];for(let e=0;e<6;e++)u.__webglFramebuffer[e]=t.createFramebuffer()}else if(u.__webglFramebuffer=t.createFramebuffer(),p)if(i.drawBuffers){const n=e.texture;for(let e=0,i=n.length;es+u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=s-u&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==s&&t.gripSpace&&null!==(i=e.getPose(t.gripSpace,n))&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1);return null!==a&&(a.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==o),this}}class Uo extends rt{constructor(t,e){super();const n=this,r=t.state;let i=null,o=1,a=null,s="local-floor",l=null,u=null,c=null,h=null,p=null,f=!1,d=null,m=null,g=null,y=null,v=null,_=null;const x=[],b=new Map,w=new Zn;w.layers.enable(1),w.viewport=new Et;const E=new Zn;E.layers.enable(2),E.viewport=new Et;const S=[w,E],M=new ko;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;function I(t){const e=b.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function A(){b.forEach((function(t,e){t.disconnect(e)})),b.clear(),T=null,C=null,r.bindXRFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),c&&e.deleteFramebuffer(c),d&&e.deleteFramebuffer(d),m&&e.deleteRenderbuffer(m),g&&e.deleteRenderbuffer(g),c=null,d=null,m=null,g=null,p=null,h=null,u=null,i=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function L(t){const e=i.inputSources;for(let t=0;t0&&(e.alphaTest.value=n.alphaTest);const r=t.get(n).envMap;if(r){e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.ior.value=n.ior,e.refractionRatio.value=n.refractionRatio;const i=t.get(r).__maxMipLevel;void 0!==i&&(e.maxMipLevel.value=i)}let i,o;n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?i=n.map:n.specularMap?i=n.specularMap:n.displacementMap?i=n.displacementMap:n.normalMap?i=n.normalMap:n.bumpMap?i=n.bumpMap:n.roughnessMap?i=n.roughnessMap:n.metalnessMap?i=n.metalnessMap:n.alphaMap?i=n.alphaMap:n.emissiveMap?i=n.emissiveMap:n.clearcoatMap?i=n.clearcoatMap:n.clearcoatNormalMap?i=n.clearcoatNormalMap:n.clearcoatRoughnessMap?i=n.clearcoatRoughnessMap:n.specularIntensityMap?i=n.specularIntensityMap:n.specularTintMap?i=n.specularTintMap:n.transmissionMap?i=n.transmissionMap:n.thicknessMap&&(i=n.thicknessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),n.aoMap?o=n.aoMap:n.lightMap&&(o=n.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uv2Transform.value.copy(o.matrix))}function n(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap),n.bumpMap&&(e.bumpMap.value=n.bumpMap,e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias),t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,r,i,o,a){r.isMeshBasicMaterial?e(t,r):r.isMeshLambertMaterial?(e(t,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,r)):r.isMeshToonMaterial?(e(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshPhongMaterial?(e(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshStandardMaterial?(e(t,r),r.isMeshPhysicalMaterial?function(t,e,r){n(t,e),t.ior.value=e.ior,e.sheenTint&&t.sheenTint.value.copy(e.sheenTint),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate())),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=r.texture,t.transmissionSamplerSize.value.set(r.width,r.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationTint.value.copy(e.attenuationTint)),t.specularIntensity.value=e.specularIntensity,t.specularTint.value.copy(e.specularTint),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap),e.specularTintMap&&(t.specularTintMap.value=e.specularTintMap)}(t,r,a):n(t,r)):r.isMeshMatcapMaterial?(e(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDepthMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDistanceMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,r)):r.isMeshNormalMaterial?(e(t,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){let i;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?i=e.map:e.alphaMap&&(i=e.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,r,i,o):r.isSpriteMaterial?function(t,e){let n;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?n=e.map:e.alphaMap&&(n=e.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Go(t={}){const e=void 0!==t.canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,u=void 0!==t.powerPreference?t.powerPreference:"default",c=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let p=null,d=null;const m=[],g=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=X,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const y=this;let x=!1,b=0,S=0,M=null,C=-1,I=null;const A=new Et,L=new Et;let P=null,R=e.width,D=e.height,N=1,O=null,k=null;const z=new Et(0,0,R,D),F=new Et(0,0,R,D);let B=!1;const U=[],V=new ir;let G=!1,j=!1,H=null;const q=new oe,W=new It,Z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return null===M?N:1}let J,K,Q,$,tt,et,nt,rt,it,ot,at,st,lt,ut,ct,ht,pt,ft,dt,mt,gt,yt,vt,_t=n;function xt(t,n){for(let r=0;r0&&function(t,e,n){if(null===H){const t=!0===a&&!0===K.isWebGL2;H=new(t?Tt:St)(1024,1024,{generateMipmaps:!0,type:null!==yt.convert(E)?E:_,minFilter:v,magFilter:f,wrapS:h,wrapT:h})}const r=y.getRenderTarget();y.setRenderTarget(H),y.clear();const i=y.toneMapping;y.toneMapping=0,Ot(t,e,n),y.toneMapping=i,et.updateMultisampleRenderTarget(H),et.updateRenderTargetMipmap(H),y.setRenderTarget(r)}(i,e,n),r&&Q.viewport(A.copy(r)),i.length>0&&Ot(i,e,n),o.length>0&&Ot(o,e,n),s.length>0&&Ot(s,e,n)}function Ot(t,e,n){const r=!0===e.isScene?e.overrideMaterial:null;for(let i=0,o=t.length;i0?g[g.length-1]:null,m.pop(),p=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return M},this.setRenderTarget=function(t,e=0,n=0){M=t,b=e,S=n,t&&void 0===tt.get(t).__webglFramebuffer&&et.setupRenderTarget(t);let r=null,i=!1,o=!1;if(t){const n=t.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(o=!0);const a=tt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=a[e],i=!0):r=t.isWebGLMultisampleRenderTarget?tt.get(t).__webglMultisampledFramebuffer:a,A.copy(t.viewport),L.copy(t.scissor),P=t.scissorTest}else A.copy(z).multiplyScalar(N).floor(),L.copy(F).multiplyScalar(N).floor(),P=B;if(Q.bindFramebuffer(36160,r)&&K.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const n=t.texture;if(U.length!==n.length||36064!==U[0]){for(let t=0,e=n.length;t=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&_t.readPixels(e,n,r,i,yt.convert(s),yt.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==M?tt.get(M).__webglFramebuffer:null;Q.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),o=Math.floor(e.image.height*r);let a=yt.convert(e.format);K.isWebGL2&&(6407===a&&(a=32849),6408===a&&(a=32856)),et.setTexture2D(e,0),_t.copyTexImage2D(3553,n,a,t.x,t.y,i,o,0),Q.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r=0){const i=e.image.width,o=e.image.height,a=yt.convert(n.format),s=yt.convert(n.type);et.setTexture2D(n,0),_t.pixelStorei(37440,n.flipY),_t.pixelStorei(37441,n.premultiplyAlpha),_t.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?_t.texSubImage2D(3553,r,t.x,t.y,i,o,a,s,e.image.data):e.isCompressedTexture?_t.compressedTexSubImage2D(3553,r,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):_t.texSubImage2D(3553,r,t.x,t.y,a,s,e.image),0===r&&n.generateMipmaps&&_t.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,r,i=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,s=t.max.z-t.min.z+1,l=yt.convert(r.format),u=yt.convert(r.type);let c;if(r.isDataTexture3D)et.setTexture3D(r,0),c=32879;else{if(!r.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");et.setTexture2DArray(r,0),c=35866}_t.pixelStorei(37440,r.flipY),_t.pixelStorei(37441,r.premultiplyAlpha),_t.pixelStorei(3317,r.unpackAlignment);const h=_t.getParameter(3314),p=_t.getParameter(32878),f=_t.getParameter(3316),d=_t.getParameter(3315),m=_t.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;_t.pixelStorei(3314,g.width),_t.pixelStorei(32878,g.height),_t.pixelStorei(3316,t.min.x),_t.pixelStorei(3315,t.min.y),_t.pixelStorei(32877,t.min.z),n.isDataTexture||n.isDataTexture3D?_t.texSubImage3D(c,i,e.x,e.y,e.z,o,a,s,l,u,g.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_t.compressedTexSubImage3D(c,i,e.x,e.y,e.z,o,a,s,l,g.data)):_t.texSubImage3D(c,i,e.x,e.y,e.z,o,a,s,l,u,g),_t.pixelStorei(3314,h),_t.pixelStorei(32878,p),_t.pixelStorei(3316,f),_t.pixelStorei(3315,d),_t.pixelStorei(32877,m),0===i&&r.generateMipmaps&&_t.generateMipmap(c),Q.unbindTexture()},this.initTexture=function(t){et.setTexture2D(t,0),Q.unbindTexture()},this.resetState=function(){b=0,S=0,M=null,Q.reset(),vt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class jo extends Go{}jo.prototype.isWebGL1Renderer=!0;class Ho{constructor(t,e=25e-5){this.name="",this.color=new Je(t),this.density=e}clone(){return new Ho(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ho.prototype.isFogExp2=!0;class qo{constructor(t,e=1,n=1e3){this.name="",this.color=new Je(t),this.near=e,this.far=n}clone(){return new qo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}qo.prototype.isFog=!0;class Wo extends Le{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}Wo.prototype.isScene=!0;class Xo{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=tt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=lt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,i=this.stride;rt.far||e.push({distance:s,point:Qo.clone(),uv:Ve.getUV(Qo,ia,oa,aa,sa,la,ua,new gt),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function ha(t,e,n,r,i,o){ea.subVectors(t,n).addScalar(.5).multiply(r),void 0!==i?(na.x=o*ea.x-i*ea.y,na.y=i*ea.x+o*ea.y):na.copy(ea),t.copy(e),t.x+=na.x,t.y+=na.y,t.applyMatrix4(ra)}ca.prototype.isSprite=!0;const pa=new It,fa=new It;class da extends Le{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t0){let n,r;for(n=1,r=e.length;n0){pa.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(pa);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){pa.setFromMatrixPosition(t.matrixWorld),fa.setFromMatrixPosition(this.matrixWorld);const n=pa.distanceTo(fa)/t.zoom;let r,i;for(e[0].object.visible=!0,r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(this._currentLevel=r-1;rs)continue;h.applyMatrix4(this.matrixWorld);const p=t.ray.origin.distanceTo(h);pt.far||e.push({distance:p,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count)-1;ns)continue;h.applyMatrix4(this.matrixWorld);const r=t.ray.origin.distanceTo(h);rt.far||e.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Fa.prototype.isLine=!0;const Ba=new It,Ua=new It;class Va extends Fa{constructor(t,e){super(t,e),this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,r=e.count;t0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Ya(t,e,n,r,i,o,a){const s=qa.distanceSqToPoint(t);if(si.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:e,face:null,object:a})}}Za.prototype.isPoints=!0;class Ja extends bt{constructor(t,e,n,r,i,o,a,s,l){super(t,e,n,r,i,o,a,s,l),this.format=void 0!==a?a:M,this.minFilter=void 0!==o?o:g,this.magFilter=void 0!==i?i:g,this.generateMipmaps=!1;const u=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){u.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;0=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Ja.prototype.isVideoTexture=!0;class Ka extends bt{constructor(t,e,n,r,i,o,a,s,l,u,c,h){super(null,o,a,s,l,u,r,i,c,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}Ka.prototype.isCompressedTexture=!0;class Qa extends bt{constructor(t,e,n,r,i,o,a,s,l){super(t,e,n,r,i,o,a,s,l),this.needsUpdate=!0}}Qa.prototype.isCanvasTexture=!0;class $a extends bt{constructor(t,e,n,r,i,o,a,s,l,u){if((u=void 0!==u?u:C)!==C&&u!==I)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&u===C&&(n=x),void 0===n&&u===I&&(n=S),super(null,r,i,o,a,s,u,n,l),this.image={width:t,height:e},this.magFilter=void 0!==a?a:f,this.minFilter=void 0!==s?s:f,this.flipY=!1,this.generateMipmaps=!1}}$a.prototype.isDepthTexture=!0;class ts extends wn{constructor(t=1,e=8,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const i=[],o=[],a=[],s=[],l=new It,u=new gt;o.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let i=0,c=3;i<=e;i++,c+=3){const h=n+i/e*r;l.x=t*Math.cos(h),l.y=t*Math.sin(h),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[c]/t+1)/2,u.y=(o[c+1]/t+1)/2,s.push(u.x,u.y)}for(let t=1;t<=e;t++)i.push(t,t+1,0);this.setIndex(i),this.setAttribute("position",new cn(o,3)),this.setAttribute("normal",new cn(a,3)),this.setAttribute("uv",new cn(s,2))}static fromJSON(t){return new ts(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class es extends wn{constructor(t=1,e=1,n=1,r=8,i=1,o=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:a,thetaLength:s};const l=this;r=Math.floor(r),i=Math.floor(i);const u=[],c=[],h=[],p=[];let f=0;const d=[],m=n/2;let g=0;function y(n){const i=f,o=new gt,d=new It;let y=0;const v=!0===n?t:e,_=!0===n?1:-1;for(let t=1;t<=r;t++)c.push(0,m*_,0),h.push(0,_,0),p.push(.5,.5),f++;const x=f;for(let t=0;t<=r;t++){const e=t/r*s+a,n=Math.cos(e),i=Math.sin(e);d.x=v*i,d.y=m*_,d.z=v*n,c.push(d.x,d.y,d.z),h.push(0,_,0),o.x=.5*n+.5,o.y=.5*i*_+.5,p.push(o.x,o.y),f++}for(let t=0;t0&&y(!0),e>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new cn(c,3)),this.setAttribute("normal",new cn(h,3)),this.setAttribute("uv",new cn(p,2))}static fromJSON(t){return new es(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ns extends es{constructor(t=1,e=1,n=8,r=1,i=!1,o=0,a=2*Math.PI){super(0,t,e,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}static fromJSON(t){return new ns(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class rs extends wn{constructor(t,e,n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:r};const i=[],o=[];function a(t,e,n,r){const i=r+1,o=[];for(let r=0;r<=i;r++){o[r]=[];const a=t.clone().lerp(n,r/i),s=e.clone().lerp(n,r/i),l=i-r;for(let t=0;t<=l;t++)o[r][t]=0===t&&r===i?a:a.clone().lerp(s,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),r<.2&&(o[t+4]+=1))}}()}(),this.setAttribute("position",new cn(i,3)),this.setAttribute("normal",new cn(i.slice(),3)),this.setAttribute("uv",new cn(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new rs(t.vertices,t.indices,t.radius,t.details)}}class is extends rs{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new is(t.radius,t.detail)}}const os=new It,as=new It,ss=new It,ls=new Ve;class us extends wn{constructor(t,e){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1,!0===t.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const n=Math.pow(10,4),r=Math.cos(at*e),i=t.getIndex(),o=t.getAttribute("position"),a=i?i.count:o.count,s=[0,0,0],l=["a","b","c"],u=new Array(3),c={},h=[];for(let t=0;t0)){l=r;break}l=r-1}if(n[r=l]===o)return r/(i-1);const u=n[r];return(r+(o-u)/(n[r+1]-u))/(i-1)}getTangent(t,e){let n=t-1e-4,r=t+1e-4;n<0&&(n=0),r>1&&(r=1);const i=this.getPoint(n),o=this.getPoint(r),a=e||(i.isVector2?new gt:new It);return a.copy(o).sub(i).normalize(),a}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new It,r=[],i=[],o=[],a=new It,s=new oe;for(let e=0;e<=t;e++){const n=e/t;r[e]=this.getTangentAt(n,new It),r[e].normalize()}i[0]=new It,o[0]=new It;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),c=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),h<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),o[0].crossVectors(r[0],i[0]);for(let e=1;e<=t;e++){if(i[e]=i[e-1].clone(),o[e]=o[e-1].clone(),a.crossVectors(r[e-1],r[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ut(r[e-1].dot(r[e]),-1,1));i[e].applyMatrix4(s.makeRotationAxis(a,t))}o[e].crossVectors(r[e],i[e])}if(!0===e){let e=Math.acos(ut(i[0].dot(i[t]),-1,1));e/=t,r[0].dot(a.crossVectors(i[0],i[t]))>0&&(e=-e);for(let n=1;n<=t;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],e*n)),o[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class hs extends cs{constructor(t=0,e=0,n=1,r=1,i=0,o=2*Math.PI,a=!1,s=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s}getPoint(t,e){const n=e||new gt,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const o=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===u&&l===i-1&&(l=i-2,u=1),this.closed||l>0?a=r[(l-1)%i]:(ds.subVectors(r[0],r[1]).add(r[0]),a=ds);const c=r[l%i],h=r[(l+1)%i];if(this.closed||l+2r.length-2?r.length-1:o+1],c=r[o>r.length-3?r.length-1:o+2];return n.set(_s(a,s.x,l.x,u.x,c.x),_s(a,s.y,l.y,u.y,c.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e0)for(o=e;o=e;o-=r)a=Ks(o,t[o],t[o+1],a);return a&&qs(a,a.next)&&(Qs(a),a=a.next),a}function Ps(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!qs(r,r.next)&&0!==Hs(r.prev,r,r.next))r=r.next;else{if(Qs(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Rs(t,e,n,r,i,o,a){if(!t)return;!a&&o&&function(t,e,n,r){let i=t;do{null===i.z&&(i.z=Us(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n,r,i,o,a,s,l,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);let s,l,u=t;for(;t.prev!==t.next;)if(s=t.prev,l=t.next,o?Ns(t,r,i,o):Ds(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Qs(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?Rs(t=Os(Ps(t),e,n),e,n,r,i,o,2):2===a&&ks(t,e,n,r,i,o):Rs(Ps(t),e,n,r,i,o,1);break}}function Ds(t){const e=t.prev,n=t,r=t.next;if(Hs(e,n,r)>=0)return!1;let i=t.next.next;for(;i!==t.prev;){if(Gs(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Hs(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Ns(t,e,n,r){const i=t.prev,o=t,a=t.next;if(Hs(i,o,a)>=0)return!1;const s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,c=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=Us(s,l,e,n,r),p=Us(u,c,e,n,r);let f=t.prevZ,d=t.nextZ;for(;f&&f.z>=h&&d&&d.z<=p;){if(f!==t.prev&&f!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Hs(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==t.prev&&d!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Hs(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&Hs(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&Gs(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Hs(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function Os(t,e,n){let r=t;do{const i=r.prev,o=r.next.next;!qs(i,o)&&Ws(i,r,r.next,o)&&Ys(i,o)&&Ys(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Qs(r),Qs(r.next),r=t=o),r=r.next}while(r!==t);return Ps(r)}function ks(t,e,n,r,i,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&js(a,t)){let s=Js(a,t);return a=Ps(a,a.next),s=Ps(s,s.next),Rs(a,e,n,r,i,o),void Rs(s,e,n,r,i,o)}t=t.next}a=a.next}while(a!==t)}function zs(t,e){return t.x-e.x}function Fs(t,e){if(e=function(t,e){let n=e;const r=t.x,i=t.y;let o,a=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const t=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>a){if(a=t,t===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x=n.x&&n.x>=l&&r!==n.x&&Gs(io.x||n.x===o.x&&Bs(o,n)))&&(o=n,h=c)),n=n.next}while(n!==s);return o}(t,e)){const n=Js(e,t);Ps(e,e.next),Ps(n,n.next)}}function Bs(t,e){return Hs(t.prev,t,e.prev)<0&&Hs(e.next,t,t.next)<0}function Us(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Vs(t){let e=t,n=t;do{(e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function js(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Ws(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Ys(t,e)&&Ys(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(Hs(t.prev,t,e.prev)||Hs(t,e.prev,e))||qs(t,e)&&Hs(t.prev,t,t.next)>0&&Hs(e.prev,e,e.next)>0)}function Hs(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function qs(t,e){return t.x===e.x&&t.y===e.y}function Ws(t,e,n,r){const i=Zs(Hs(t,e,n)),o=Zs(Hs(t,e,r)),a=Zs(Hs(n,r,t)),s=Zs(Hs(n,r,e));return i!==o&&a!==s||!(0!==i||!Xs(t,n,e))||!(0!==o||!Xs(t,r,e))||!(0!==a||!Xs(n,t,r))||!(0!==s||!Xs(n,e,r))}function Xs(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Zs(t){return t>0?1:t<0?-1:0}function Ys(t,e){return Hs(t.prev,t,t.next)<0?Hs(t,e,t.next)>=0&&Hs(t,t.prev,e)>=0:Hs(t,e,t.prev)<0||Hs(t,t.next,e)<0}function Js(t,e){const n=new $s(t.i,t.x,t.y),r=new $s(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Ks(t,e,n,r){const i=new $s(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Qs(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function $s(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class tl{static area(t){const e=t.length;let n=0;for(let r=e-1,i=0;i80*n){s=u=t[0],l=c=t[1];for(let e=n;eu&&(u=h),p>c&&(c=p);f=0!==(f=Math.max(u-s,c-l))?1/f:0}return Rs(o,a,n,s,l,f),a}(n,r);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function nl(t,e){for(let n=0;nNumber.EPSILON){const h=Math.sqrt(c),p=Math.sqrt(l*l+u*u),f=e.x-s/h,d=e.y+a/h,m=((n.x-u/p-f)*u-(n.y+l/p-d)*l)/(a*u-s*l),g=(r=f+a*m-t.x)*r+(i=d+s*m-t.y)*i;if(g<=2)return new gt(r,i);o=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(s)===Math.sign(u)&&(t=!0),t?(r=-s,i=a,o=Math.sqrt(c)):(r=a,i=s,o=Math.sqrt(c/2))}return new gt(r/o,i/o)}const P=[];for(let t=0,e=T.length,n=e-1,r=t+1;t=0;t--){const e=t/f,n=c*Math.cos(e*Math.PI/2),r=h*Math.sin(e*Math.PI/2)+p;for(let t=0,e=T.length;t=0;){const r=n;let i=n-1;i<0&&(i=t.length-1);for(let t=0,n=s+2*f;t=0?(t(r-s,f,c),h.subVectors(u,c)):(t(r+s,f,c),h.subVectors(c,u)),f-s>=0?(t(r,f-s,c),p.subVectors(u,c)):(t(r,f+s,c),p.subVectors(c,u)),l.crossVectors(h,p).normalize(),o.push(l.x,l.y,l.z),a.push(r,f)}}for(let t=0;t0)&&p.push(e,i,l),(t!==n-1||s0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.sheenTint.copy(t.sheenTint),this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationTint.copy(t.attenuationTint),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularTint.copy(t.specularTint),this.specularTintMap=t.specularTintMap,this}}wl.prototype.isMeshPhysicalMaterial=!0;class El extends je{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new Je(16777215),this.specular=new Je(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this}}El.prototype.isMeshPhongMaterial=!0;class Sl extends je{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Je(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Sl.prototype.isMeshToonMaterial=!0;class Ml extends je{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}Ml.prototype.isMeshNormalMaterial=!0;class Tl extends je{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new Je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this}}Tl.prototype.isMeshLambertMaterial=!0;class Cl extends je{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Je(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this}}Cl.prototype.isMeshMatcapMaterial=!0;class Il extends Ra{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}Il.prototype.isLineDashedMaterial=!0;var Al=Object.freeze({__proto__:null,ShadowMaterial:xl,SpriteMaterial:Jo,RawShaderMaterial:vr,ShaderMaterial:Wn,PointsMaterial:ja,MeshPhysicalMaterial:wl,MeshStandardMaterial:bl,MeshPhongMaterial:El,MeshToonMaterial:Sl,MeshNormalMaterial:Ml,MeshLambertMaterial:Tl,MeshDepthMaterial:Lo,MeshDistanceMaterial:Po,MeshBasicMaterial:Ke,MeshMatcapMaterial:Cl,LineDashedMaterial:Il,LineBasicMaterial:Ra,Material:je});const Ll={arraySlice:function(t,e,n){return Ll.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){const r=t.length,i=new t.constructor(r);for(let o=0,a=0;a!==r;++o){const r=n[o]*e;for(let n=0;n!==e;++n)i[a++]=t[r+n]}return i},flattenJSON:function(t,e,n,r){let i=1,o=t[0];for(;void 0!==o&&void 0===o[r];)o=t[i++];if(void 0===o)return;let a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(e.push(o.time),n.push.apply(n,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(e.push(o.time),a.toArray(n,n.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(e.push(o.time),n.push(a)),o=t[i++]}while(void 0!==o)},subclip:function(t,e,n,r,i=30){const o=t.clone();o.name=e;const a=[];for(let t=0;t=r)){l.push(e.times[t]);for(let n=0;no.tracks[t].times[0]&&(s=o.tracks[t].times[0]);for(let t=0;t=r.times[h]){const t=h*l+s,e=t+l-s;p=Ll.arraySlice(r.values,t,e)}else{const t=r.createInterpolant(),e=s,n=l-s;t.evaluate(o),p=Ll.arraySlice(t.resultBuffer,e,n)}"quaternion"===i&&(new Ct).fromArray(p).normalize().conjugate().toArray(p);const f=a.times.length;for(let t=0;t=i)break t;{const a=e[1];t=(i=e[--n-1]))break e}o=n,n=0}}for(;n>>1;te;)--o;if(++o,0!==i||o!==r){i>=o&&(i=(o=Math.max(o,1))-1);const t=this.getValueSize();this.times=Ll.arraySlice(n,i,o),this.values=Ll.arraySlice(this.values,i*t,o*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let e=0;e!==i;e++){const r=n[e];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,r),t=!1;break}if(null!==o&&o>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,r,o),t=!1;break}o=r}if(void 0!==r&&Ll.isTypedArray(r))for(let e=0,n=r.length;e!==n;++e){const n=r[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=Ll.arraySlice(this.times),e=Ll.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===V,i=t.length-1;let o=1;for(let a=1;a0){t[o]=t[i];for(let t=i*n,r=o*n,a=0;a!==n;++a)e[r+a]=e[t+a];++o}return o!==t.length?(this.times=Ll.arraySlice(t,0,o),this.values=Ll.arraySlice(e,0,o*n)):(this.times=t,this.values=e),this}clone(){const t=Ll.arraySlice(this.times,0),e=Ll.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Ol.prototype.TimeBufferType=Float32Array,Ol.prototype.ValueBufferType=Float32Array,Ol.prototype.DefaultInterpolation=U;class kl extends Ol{}kl.prototype.ValueTypeName="bool",kl.prototype.ValueBufferType=Array,kl.prototype.DefaultInterpolation=B,kl.prototype.InterpolantFactoryMethodLinear=void 0,kl.prototype.InterpolantFactoryMethodSmooth=void 0;class zl extends Ol{}zl.prototype.ValueTypeName="color";class Fl extends Ol{}Fl.prototype.ValueTypeName="number";class Bl extends Pl{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-e)/(r-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Ct.slerpFlat(i,0,o,l-a,o,l,s);return i}}class Ul extends Ol{InterpolantFactoryMethodLinear(t){return new Bl(this.times,this.values,this.getValueSize(),t)}}Ul.prototype.ValueTypeName="quaternion",Ul.prototype.DefaultInterpolation=U,Ul.prototype.InterpolantFactoryMethodSmooth=void 0;class Vl extends Ol{}Vl.prototype.ValueTypeName="string",Vl.prototype.ValueBufferType=Array,Vl.prototype.DefaultInterpolation=B,Vl.prototype.InterpolantFactoryMethodLinear=void 0,Vl.prototype.InterpolantFactoryMethodSmooth=void 0;class Gl extends Ol{}Gl.prototype.ValueTypeName="vector";class jl{constructor(t,e=-1,n,r=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=lt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,r=1/(t.fps||1);for(let t=0,i=n.length;t!==i;++t)e.push(Hl(n[t]).scale(r));const i=new this(t.name,t.duration,e,t.blendMode);return i.uuid=t.uuid,i}static toJSON(t){const e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,r=n.length;t!==r;++t)e.push(Ol.toJSON(n[t]));return r}static CreateFromMorphTargetSequence(t,e,n,r){const i=e.length,o=[];for(let t=0;t1){const t=o[1];let e=r[t];e||(r[t]=e=[]),e.push(n)}}const o=[];for(const t in r)o.push(this.CreateFromMorphTargetSequence(t,r[t],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,r,i){if(0!==n.length){const o=[],a=[];Ll.flattenJSON(n,o,a,r),0!==o.length&&i.push(new t(e,o,a))}},r=[],i=t.name||"default",o=t.fps||30,a=t.blendMode;let s=t.length||-1;const l=t.hierarchy||[];for(let t=0;t0||0===t.search(/^data\:image\/jpeg/);i.format=r?M:T,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}class eu extends cs{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ss(e,t))}getPoint(t){const e=t*this.getLength(),n=this.getCurveLengths();let r=0;for(;r=e){const t=n[r]-e,i=this.curves[r],o=i.getLength(),a=0===o?0:1-t/o;return i.getPointAt(a)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,r=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class ru extends nu{constructor(t){super(t),this.uuid=lt(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n0:r.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const i=t.uniforms[e];switch(r.uniforms[e]={},i.type){case"t":r.uniforms[e].value=n(i.value);break;case"c":r.uniforms[e].value=(new Je).setHex(i.value);break;case"v2":r.uniforms[e].value=(new gt).fromArray(i.value);break;case"v3":r.uniforms[e].value=(new It).fromArray(i.value);break;case"v4":r.uniforms[e].value=(new Et).fromArray(i.value);break;case"m3":r.uniforms[e].value=(new yt).fromArray(i.value);break;case"m4":r.uniforms[e].value=(new oe).fromArray(i.value);break;default:r.uniforms[e].value=i.value}}if(void 0!==t.defines&&(r.defines=t.defines),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)r.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=n(t.map)),void 0!==t.matcap&&(r.matcap=n(t.matcap)),void 0!==t.alphaMap&&(r.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(r.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),r.normalScale=(new gt).fromArray(e)}return void 0!==t.displacementMap&&(r.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(r.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularTintMap&&(r.specularTintMap=n(t.specularTintMap)),void 0!==t.envMap&&(r.envMap=n(t.envMap)),void 0!==t.envMapIntensity&&(r.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(r.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(r.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(r.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(r.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(r.clearcoatNormalScale=(new gt).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(r.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(r.thicknessMap=n(t.thicknessMap)),r}setTextures(t){return this.textures=t,this}}class Su{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,r=t.length;nNumber.EPSILON){if(l<0&&(n=e[o],s=-s,a=e[i],l=-l),t.ya.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-s*(t.y-n.y);if(0===e)return!0;if(e<0)continue;r=!r}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return r}const i=tl.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return n(o);let a,s,l;const u=[];if(1===o.length)return s=o[0],(l=new ru).curves=s.curves,u.push(l),u;let c=!i(o[0].getPoints());c=t?!c:c;const h=[],p=[];let f,d,m=[],g=0;p[g]=void 0,m[g]=[];for(let e=0,n=o.length;e1){let t=!1;const e=[];for(let t=0,e=p.length;t0&&(t||(m=h))}for(let t=0,e=p.length;t0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let t=e,i=e+e;t!==i;++t)if(n[t]!==n[t+e]){a.setValue(n,r);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let t=n,i=r;t!==i;++t)e[t]=e[r+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let r=0;r!==i;++r)t[e+r]=t[n+r]}_slerp(t,e,n,r){Ct.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,i){const o=this._workIndex*i;Ct.multiplyQuaternionsFlat(t,o,t,e,t,n),Ct.slerpFlat(t,e,t,e,t,o,r)}_lerp(t,e,n,r,i){const o=1-r;for(let a=0;a!==i;++a){const i=e+a;t[i]=t[i]*o+t[n+a]*r}}_lerpAdditive(t,e,n,r,i){for(let o=0;o!==i;++o){const i=e+o;t[i]=t[i]+t[n+o]*r}}}const tc=new RegExp("[\\[\\]\\.:\\/]","g"),ec="[^\\[\\]\\.:\\/]",nc="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",rc=/((?:WC+[\/:])*)/.source.replace("WC",ec),ic=/(WCOD+)?/.source.replace("WCOD",nc),oc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ec),ac=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ec),sc=new RegExp("^"+rc+ic+oc+ac+"$"),lc=["material","materials","bones"];class uc{constructor(t,e,n){this.path=e,this.parsedPath=n||uc.parseTrackName(e),this.node=uc.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new uc.Composite(t,e,n):new uc(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(tc,"")}static parseTrackName(t){const e=sc.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const t=n.nodeName.substring(r+1);-1!==lc.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let r=0;r=i){const o=i++,u=t[o];e[u.uuid]=l,t[l]=u,e[s]=o,t[o]=a;for(let t=0,e=r;t!==e;++t){const e=n[t],r=e[o],i=e[l];e[l]=r,e[o]=i}}}this.nCachedObjects_=i}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_,o=t.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=e[s];if(void 0!==l)if(delete e[s],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=r;t!==e;++t){const e=n[t];e[l]=e[i],e.pop()}}}this.nCachedObjects_=i}subscribe_(t,e){const n=this._bindingsIndicesByPath;let r=n[t];const i=this._bindings;if(void 0!==r)return i[r];const o=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,u=this.nCachedObjects_,c=new Array(l);r=i.length,n[t]=r,o.push(t),a.push(e),i.push(c);for(let n=u,r=s.length;n!==r;++n){const r=s[n];c[n]=new uc(r,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const r=this._paths,i=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];e[t[a]]=n,o[n]=s,o.pop(),i[n]=i[a],i.pop(),r[n]=r[a],r.pop()}}}cc.prototype.isAnimationObjectGroup=!0;class hc{constructor(t,e,n=null,r=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=r;const i=e.tracks,o=i.length,a=new Array(o),s={endingStart:G,endingEnd:G};for(let t=0;t!==o;++t){const e=i[t].createInterpolant(null);a[t]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,r=t._clip.duration,i=r/n,o=n/r;t.warp(1,i,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const r=this._mixer,i=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=i,s[1]=i+n,l[0]=t/o,l[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,r){if(!this.enabled)return void this._updateWeight(t);const i=this._startTime;if(null!==i){const r=(t-i)*n;if(r<0||0===n)return;this._startTime=null,e=n*r}e*=this._updateTimeScale(t);const o=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===W)for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(o),e[n].accumulateAdditive(a);else for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(o),e[n].accumulate(r,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let r=this.time+t,i=this._loopCount;const o=2202===n;if(0===t)return-1===i?r:o&&1==(1&i)?e-r:r;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(r>=e)r=e;else{if(!(r<0)){this.time=r;break t}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),r>=e||r<0){const n=Math.floor(r/e);r-=e*n,i+=Math.abs(n);const a=this.repetitions-i;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?e:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(o&&1==(1&i))return e-r}return r}_setEndings(t,e,n){const r=this._interpolantSettings;n?(r.endingStart=j,r.endingEnd=j):(r.endingStart=t?this.zeroSlopeAtStart?j:G:H,r.endingEnd=e?this.zeroSlopeAtEnd?j:G:H)}_scheduleFading(t,e,n){const r=this._mixer,i=r.time;let o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=n,this}}class pc extends rt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,o=t._propertyBindings,a=t._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let u=l[s];void 0===u&&(u={},l[s]=u);for(let t=0;t!==i;++t){const i=r[t],l=i.name;let c=u[l];if(void 0!==c)o[t]=c;else{if(void 0!==(c=o[t])){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,s,l));continue}const r=e&&e._propertyBindings[t].binding.parsedPath;++(c=new $u(uc.create(n,l,r),i.ValueTypeName,i.getValueSize())).referenceCount,this._addInactiveBinding(c,s,l),o[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,r=this.time+=t,i=Math.sign(t),o=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(r,t,i,o);const a=this._bindings,s=this._nActiveBindings;for(let t=0;t!==s;++t)a[t].apply(o);return this}setTime(t){this.time=0;for(let t=0;tthis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return vc.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}_c.prototype.isBox2=!0;const xc=new It,bc=new It;class wc{constructor(t=new It,e=new It){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){xc.subVectors(t,this.start),bc.subVectors(this.end,this.start);const n=bc.dot(bc);let r=bc.dot(xc)/n;return e&&(r=ut(r,0,1)),r}closestPointToPoint(t,e,n){const r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}class Ec extends Le{constructor(t){super(),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}}Ec.prototype.isImmediateRenderObject=!0;const Sc=new It,Mc=new It,Tc=new oe,Cc=new oe;class Ic extends Va{constructor(t){const e=function t(e){const n=[];e&&e.isBone&&n.push(e);for(let r=0;r.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Vc.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Vc,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}},t.Audio=Xu,t.AudioAnalyser=Qu,t.AudioContext=Ou,t.AudioListener=class extends Le{constructor(){super(),this.type="AudioListener",this.context=Ou.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Vu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ju,Hu,qu),Wu.set(0,0,-1).applyQuaternion(Hu),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ju.x,t),e.positionY.linearRampToValueAtTime(ju.y,t),e.positionZ.linearRampToValueAtTime(ju.z,t),e.forwardX.linearRampToValueAtTime(Wu.x,t),e.forwardY.linearRampToValueAtTime(Wu.y,t),e.forwardZ.linearRampToValueAtTime(Wu.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(ju.x,ju.y,ju.z),e.setOrientation(Wu.x,Wu.y,Wu.z,n.x,n.y,n.z)}},t.AudioLoader=ku,t.AxesHelper=Hc,t.AxisHelper=function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Hc(t)},t.BackSide=1,t.BasicDepthPacking=3200,t.BasicShadowMap=0,t.BinaryTextureLoader=function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new $l(t)},t.Bone=ba,t.BooleanKeyframeTrack=kl,t.BoundingBoxHelper=function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Uc(t,e)},t.Box2=_c,t.Box3=Pt,t.Box3Helper=class extends Va{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new wn;r.setIndex(new tn(n,1)),r.setAttribute("position",new cn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new Ra({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},t.BoxBufferGeometry=Gn,t.BoxGeometry=Gn,t.BoxHelper=Uc,t.BufferAttribute=tn,t.BufferGeometry=wn,t.BufferGeometryLoader=Tu,t.ByteType=1010,t.Cache=ql,t.Camera=Xn,t.CameraHelper=class extends Va{constructor(t){const e=new wn,n=new Ra({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],o={},a=new Je(16755200),s=new Je(16711680),l=new Je(43775),u=new Je(16777215),c=new Je(3355443);function h(t,e,n){p(t,n),p(e,n)}function p(t,e){r.push(0,0,0),i.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(r.length/3-1)}h("n1","n2",a),h("n2","n4",a),h("n4","n3",a),h("n3","n1",a),h("f1","f2",a),h("f2","f4",a),h("f4","f3",a),h("f3","f1",a),h("n1","f1",a),h("n2","f2",a),h("n3","f3",a),h("n4","f4",a),h("p","n1",s),h("p","n2",s),h("p","n3",s),h("p","n4",s),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",u),h("p","c",c),h("cn1","cn2",c),h("cn3","cn4",c),h("cf1","cf2",c),h("cf3","cf4",c),e.setAttribute("position",new cn(r,3)),e.setAttribute("color",new cn(i,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const t=this.geometry,e=this.pointMap;zc.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Fc("c",e,t,zc,0,0,-1),Fc("t",e,t,zc,0,0,1),Fc("n1",e,t,zc,-1,-1,-1),Fc("n2",e,t,zc,1,-1,-1),Fc("n3",e,t,zc,-1,1,-1),Fc("n4",e,t,zc,1,1,-1),Fc("f1",e,t,zc,-1,-1,1),Fc("f2",e,t,zc,1,-1,1),Fc("f3",e,t,zc,-1,1,1),Fc("f4",e,t,zc,1,1,1),Fc("u1",e,t,zc,.7,1.1,-1),Fc("u2",e,t,zc,-.7,1.1,-1),Fc("u3",e,t,zc,0,2,-1),Fc("cf1",e,t,zc,-1,0,1),Fc("cf2",e,t,zc,1,0,1),Fc("cf3",e,t,zc,0,-1,1),Fc("cf4",e,t,zc,0,1,1),Fc("cn1",e,t,zc,-1,0,-1),Fc("cn2",e,t,zc,1,0,-1),Fc("cn3",e,t,zc,0,-1,-1),Fc("cn4",e,t,zc,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},t.CanvasTexture=Qa,t.CatmullRomCurve3=vs,t.CineonToneMapping=3,t.CircleBufferGeometry=ts,t.CircleGeometry=ts,t.ClampToEdgeWrapping=h,t.Clock=Vu,t.Color=Je,t.ColorKeyframeTrack=zl,t.CompressedTexture=Ka,t.CompressedTextureLoader=class extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=[],a=new Ka,s=new Jl(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function u(u){s.load(t[u],(function(t){const n=i.parse(t,!0);o[u]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(l+=1)&&(1===n.mipmapCount&&(a.minFilter=g),a.image=o,a.format=n.format,a.needsUpdate=!0,e&&e(a))}),n,r)}if(Array.isArray(t))for(let e=0,n=t.length;e>16&32768,r=e>>12&2047;const i=e>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&e):i<113?n|=((r|=2048)>>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)}},t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=Xl,t.DepthFormat=C,t.DepthStencilFormat=I,t.DepthTexture=$a,t.DirectionalLight=vu,t.DirectionalLightHelper=class extends Le{constructor(t,e,n){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===e&&(e=1);let r=new wn;r.setAttribute("position",new cn([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const i=new Ra({fog:!1,toneMapped:!1});this.lightPlane=new Fa(r,i),this.add(this.lightPlane),(r=new wn).setAttribute("position",new cn([0,0,0,0,0,1],3)),this.targetLine=new Fa(r,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Dc.setFromMatrixPosition(this.light.matrixWorld),Nc.setFromMatrixPosition(this.light.target.matrixWorld),Oc.subVectors(Nc,Dc),this.lightPlane.lookAt(Nc),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Nc),this.targetLine.scale.z=Oc.length()}},t.DiscreteInterpolant=Nl,t.DodecahedronBufferGeometry=is,t.DodecahedronGeometry=is,t.DoubleSide=2,t.DstAlphaFactor=206,t.DstColorFactor=208,t.DynamicBufferAttribute=function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new tn(t,e).setUsage(et)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=et,t.DynamicReadUsage=35049,t.EdgesGeometry=us,t.EdgesHelper=function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Va(new us(t.geometry),new Ra({color:void 0!==e?e:16777215}))},t.EllipseCurve=hs,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=a,t.EquirectangularRefractionMapping=s,t.Euler=me,t.EventDispatcher=rt,t.ExtrudeBufferGeometry=rl,t.ExtrudeGeometry=rl,t.FaceColors=1,t.FileLoader=Jl,t.FlatShading=1,t.Float16BufferAttribute=un,t.Float32Attribute=function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new cn(t,e)},t.Float32BufferAttribute=cn,t.Float64Attribute=function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new hn(t,e)},t.Float64BufferAttribute=hn,t.FloatType=w,t.Fog=qo,t.FogExp2=Ho,t.Font=Ru,t.FontLoader=class extends Zl{constructor(t){super(t)}load(t,e,n,r){const i=this,o=new Jl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(i.withCredentials),o.load(t,(function(t){let n;try{n=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}const r=i.parse(n);e&&e(r)}),n,r)}parse(t){return new Ru(t)}},t.FrontSide=0,t.Frustum=ir,t.GLBufferAttribute=mc,t.GLSL1="100",t.GLSL3=nt,t.GammaEncoding=Y,t.GreaterDepth=6,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=Rc,t.Group=zo,t.HalfFloatType=E,t.HemisphereLight=ou,t.HemisphereLightHelper=class extends Le{constructor(t,e,n){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new sl(e);r.rotateY(.5*Math.PI),this.material=new Ke({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=r.getAttribute("position"),o=new Float32Array(3*i.count);r.setAttribute("color",new tn(o,3)),this.add(new Un(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");Lc.copy(this.light.color),Pc.copy(this.light.groundColor);for(let t=0,n=e.count;t0){const n=new Wl(e);(i=new Kl(n)).setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e0){(r=new Kl(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,r=t.length;e90))return t;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(t){if(t.constructor===Array){for(const e of t)if(!this.Coords(e))return void console.error("Each coordinate in a line must be a valid Coords type");return t}console.error("Line must be an array")},Rotation:function(t){if(t.constructor===Number)t={z:t};else{if(t.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const e of Object.keys(t)){if(!["x","y","z"].includes(e))return void console.error("Rotation parameters must be x, y, or z");if(t[e].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return t},Scale:function(t){if(t.constructor===Number)t={x:t,y:t,z:t};else{if(t.constructor!==Object)return void console.error("Scale must be an object or a number");for(const e of Object.keys(t)){if(!["x","y","z"].includes(e))return void console.error("Scale parameters must be x, y, or z");if(t[e].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return t}},l=l=u;var c={},h={prettyPrintMatrix:function(t){for(var e=0;e<4;e++){var n=[t[e],t[e+4],t[e+8],t[e+12]];console.log(n.map((function(t){return t.toFixed(4)})))}},makePerspectiveMatrix:function(t,e,n,i){var o=new r.Matrix4,a=1/Math.tan(t/2),s=1/(n-i),l=[a/e,0,0,0,0,a,0,0,0,0,(i+n)*s,-1,0,0,2*i*n*s,0];return o.elements=l,o},makeOrthographicMatrix:function(t,e,n,i,o,a){var s=new r.Matrix4;const l=1/(e-t),u=1/(n-i),c=1/(a-o);var h=[2*l,0,0,0,0,2*u,0,0,0,0,-1*c,0,-(e+t)*l,-(n+i)*u,-o*c,1];return s.elements=h,s},radify:function(t){function e(t){return t=t||0,2*Math.PI*t/360}return"object"==typeof t?t.length>0?t.map((function(t){return e(t)})):[e(t.x),e(t.y),e(t.z)]:e(t)},degreeify:function(t){function e(t){return 360*(t=t||0)/(2*Math.PI)}return"object"==typeof t?[e(t.x),e(t.y),e(t.z)]:e(t)},projectToWorld:function(t){var e=[-i.MERCATOR_A*i.DEG2RAD*t[0]*i.PROJECTION_WORLD_SIZE,-i.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*i.DEG2RAD*t[1]))*i.PROJECTION_WORLD_SIZE];if(t[2]){var n=this.projectedUnitsPerMeter(t[1]);e.push(t[2]*n)}else e.push(0);return new r.Vector3(e[0],e[1],e[2])},projectedUnitsPerMeter:function(t){return Math.abs(i.WORLD_SIZE/Math.cos(i.DEG2RAD*t)/i.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(t){return i.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180)},mercatorZfromAltitude:function(t,e){return t/this._circumferenceAtLatitude(e)},_scaleVerticesToMeters:function(t,e){for(var n=this.projectedUnitsPerMeter(t[1]),r=(this.projectToWorld(t),0);r{let{width:n,color:i}=e,o=(new r.BufferGeometry).setFromPoints(t.getPoints(100)),a=new r.LineBasicMaterial({color:i,linewidth:n});return new r.Line(o,a)},curvesToLines:t=>{var e=[16711680,2031360,2490623];return t.map(((t,n)=>curveToLine(t,{width:3,color:e[n]||"purple"})))},_validate:function(t,e){t=t||{};var n={};h.extend(n,t);for(let r of Object.keys(e))if(void 0===t[r]){if(null===e[r])return void console.error(r+" is required");n[r]=e[r]}else n[r]=t[r];return n},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};c=c=h;var p={};function f(t,e,n){this.map=t,this.camera=e,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=n||new r.Group,this.world.position.x=this.world.position.y=i.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new r.Matrix4).makeTranslation(i.WORLD_SIZE/2,-i.WORLD_SIZE/2,0),worldSizeRatio:i.TILE_SIZE/i.WORLD_SIZE,worldSize:i.TILE_SIZE*this.map.transform.scale};let o=this;this.map.on("move",(function(){o.updateCamera()})).on("resize",(function(){o.setupCamera()})),this.setupCamera()}f.prototype={setupCamera:function(){const t=this.map.transform;this.camera.aspect=t.width/t.height,this.halfFov=t._fov/2,this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height;const e=t._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-e,this.updateCamera()},updateCamera:function(t){if(!this.camera)return void console.log("nocamera");const e=this.map.transform;this.camera.aspect=e.width/e.height;const n=e.centerOffset||new r.Vector3;let i=0,o=0;this.halfFov=e._fov/2;const a=Math.PI/2+e._pitch,s=Math.cos(Math.PI/2-e._pitch);this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*e.height;let l=1;const u=this.worldSize();if(this.map.tb.mapboxVersion>=2){l=this.mercatorZfromAltitude(1,e.center.lat)*u;const t=e._fov*(.5+e.centerOffset.y/e.height),n=e.elevation?e.elevation.getMinElevationBelowMSL()*l:0,r=(e._camera.position[2]*u-n)/Math.cos(e._pitch);o=s*(Math.sin(t)*r/Math.sin(c.clamp(Math.PI-a-t,.01,Math.PI-.01)))+r;const h=r*(1/e._horizonShift);i=Math.min(1.01*o,h)}else i=1.01*(o=s*(Math.sin(this.halfFov)*this.cameraToCenterDistance/Math.sin(Math.PI-a-this.halfFov))+this.cameraToCenterDistance);this.cameraTranslateZ=(new r.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const h=e.height/50,p=Math.max(h*s,h),d=e.height,m=e.width;this.camera instanceof r.OrthographicCamera?this.camera.projectionMatrix=c.makeOrthographicMatrix(m/-2,m/2,d/2,d/-2,p,i):this.camera.projectionMatrix=c.makePerspectiveMatrix(e._fov,m/d,p,i),this.camera.projectionMatrix.elements[8]=2*-n.x/e.width,this.camera.projectionMatrix.elements[9]=2*n.y/e.height;let g=this.calcCameraMatrix(e._pitch,e.angle);e.elevation&&(g.elements[14]=e._camera.position[2]*u),this.camera.matrixWorld.copy(g);let y=e.scale*this.state.worldSizeRatio,v=new r.Matrix4,_=new r.Matrix4,x=new r.Matrix4;v.makeScale(y,y,y);let b=e.x||e.point.x,w=e.y||e.point.y;_.makeTranslation(-b,w,0),x.makeRotationZ(Math.PI),this.world.matrix=(new r.Matrix4).premultiply(x).premultiply(this.state.translateCenter).premultiply(v).premultiply(_),this.map.fire("CameraSynced",{detail:{nearZ:p,farZ:i,pitch:e._pitch,angle:e.angle,furthestDistance:o,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:f}})},worldSize(){let t=this.map.transform;return t.tileSize*t.scale},worldSizeFromZoom(){let t=this.map.transform;return Math.pow(2,t.zoom)*t.tileSize},mercatorZfromAltitude(t,e){return t/this.circumferenceAtLatitude(e)},mercatorZfromZoom(){return this.cameraToCenterDistance/this.worldSizeFromZoom()},circumferenceAtLatitude:t=>i.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180),calcCameraMatrix(t,e,n){const i=this.map.transform,o=void 0===t?i._pitch:t,a=void 0===e?i.angle:e,s=void 0===n?this.cameraTranslateZ:n;return(new r.Matrix4).premultiply(s).premultiply((new r.Matrix4).makeRotationX(o)).premultiply((new r.Matrix4).makeRotationZ(a))},updateCameraState(){let t=this.map.transform;if(!t.height)return;const e=t._camera.forward(),n=t.cameraToCenterDistance,r=t.point,i=(t._cameraZoom?t._cameraZoom:t._zoom,this.mercatorZfromZoom(t)-this.mercatorZfromAltitude(t._centerAltitude,t.center.lat)),o=t.cameraToCenterDistance/i;return[r.x/this.worldSize()-e[0]*n/o,r.y/this.worldSize()-e[1]*n/o,this.mercatorZfromAltitude(t._centerAltitude,t._center.lat)+-e[2]*n/o]},getWorldToCamera(t,e){let n=this.map.transform;const i=new r.Matrix4,o=new r.Matrix4,a=n._camera._orientation,s=n._camera.position,l=new r.Vector3(s[0],s[1],s[2]),u=new r.Quaternion;u.set(a[0],a[1],a[2],a[3]);const c=u.conjugate();return l.multiplyScalar(-t),o.makeTranslation(l.x,l.y,l.z),i.makeRotationFromQuaternion(c).premultiply(o),i.elements[1]*=-1,i.elements[5]*=-1,i.elements[9]*=-1,i.elements[13]*=-1,i.elements[8]*=e,i.elements[9]*=e,i.elements[10]*=e,i.elements[11]*=e,i},translate(t,e,n){let r,i,o,a,s,l,u,c,h,p,f,d,m=n[0]||n.x,g=n[1]||n.y,y=n[2]||n.z;return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*y+e[12],t[13]=e[1]*m+e[5]*g+e[9]*y+e[13],t[14]=e[2]*m+e[6]*g+e[10]*y+e[14],t[15]=e[3]*m+e[7]*g+e[11]*y+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=r*m+s*g+h*y+e[12],t[13]=i*m+l*g+p*y+e[13],t[14]=o*m+u*g+f*y+e[14],t[15]=a*m+c*g+d*y+e[15]),t}},p=p=f;var d={};!function(){"use strict";var t=Math.PI,e=Math.sin,n=Math.cos,r=Math.tan,i=Math.asin,o=Math.atan2,a=Math.acos,s=t/180;function l(t){return t.valueOf()/864e5-.5+2440588}function u(t){return new Date(864e5*(t+.5-2440588))}function c(t){return l(t)-2451545}var h=23.4397*s;function p(t,i){return o(e(t)*n(h)-r(i)*e(h),n(t))}function f(t,r){return i(e(r)*n(h)+n(r)*e(h)*e(t))}function m(t,i,a){return o(e(t),n(t)*e(i)-r(a)*n(i))}function g(t,r,o){return i(e(r)*e(o)+n(r)*n(o)*n(t))}function y(t,e){return s*(280.16+360.9856235*t)-e}function v(t){return s*(357.5291+.98560028*t)}function _(n){return n+s*(1.9148*e(n)+.02*e(2*n)+3e-4*e(3*n))+102.9372*s+t}function x(t){var e=_(v(t));return{dec:f(e,0),ra:p(e,0)}}var b={getPosition:function(t,e,n){var r=s*-n,i=s*e,o=c(t),a=x(o),l=y(o,r)-a.ra;return{azimuth:m(l,i,a.dec),altitude:g(l,i,a.dec)}},toJulian:function(t){return l(t)}},w=b.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];b.addTime=function(t,e,n){w.push([t,e,n])};function E(e,n,r){return 9e-4+(e+n)/(2*t)+r}function S(t,n,r){return 2451545+t+.0053*e(n)-.0069*e(2*r)}function M(t,r,i,o,s,l,u){return S(E(function(t,r,i){return a((e(t)-e(r)*e(i))/(n(r)*n(i)))}(t,i,o),r,s),l,u)}function T(t){var r=s*(134.963+13.064993*t),i=s*(93.272+13.22935*t),o=s*(218.316+13.176396*t)+6.289*s*e(r),a=5.128*s*e(i),l=385001-20905*n(r);return{ra:p(o,a),dec:f(o,a),dist:l}}function C(t,e){return new Date(t.valueOf()+864e5*e/24)}b.getTimes=function(e,n,r,i){var o,a,l,h,p,d=s*-r,m=s*n,g=function(t){return-2.076*Math.sqrt(t)/60}(i=i||0),y=function(e,n){return Math.round(e-9e-4-n/(2*t))}(c(e),d),x=E(0,d,y),b=v(x),T=_(b),C=f(T,0),I=S(x,b,T),A={solarNoon:u(I),nadir:u(I-.5)};for(o=0,a=w.length;o=0&&(g=p-(v=Math.sqrt(d)/(2*Math.abs(c))),y=p+v,Math.abs(g)<=1&&m++,Math.abs(y)<=1&&m++,g<-1&&(g=y)),1===m?x<0?l=w+g:u=w+g:2===m&&(l=w+(f<0?y:g),u=w+(f<0?g:y)),!l||!u);w+=2)x=a;var E={};return l&&(E.rise=C(i,l)),u&&(E.set=C(i,u)),l||u||(E[f>0?"alwaysUp":"alwaysDown"]=!0),E},d=d=b}();var m={},g={material:"MeshBasicMaterial",color:"black",opacity:1};m=m=function(t){var e;function n(){return new r[g.material]({color:g.color})}return t?((e=(t=c._validate(t,g)).material&&t.material.isMaterial?t.material:t.material||t.color||t.opacity?new r[t.material]({color:t.color,transparent:t.opacity<1}):n()).opacity=t.opacity,t.side&&(e.side=t.side)):e=n(),e};var y={};function v(t){this.map=t,this.enrolledObjects=[],this.previousFrameTime}v.prototype={unenroll:function(t){this.enrolledObjects.splice(this.enrolledObjects.indexOf(t),1)},enroll:function(t){if(t.clock=new r.Clock,t.hasDefaultAnimation=!1,t.defaultAction,t.actions=[],t.mixer,t.animations&&t.animations.length>0){t.hasDefaultAnimation=!0;let n=t.userData.defaultAnimation?t.userData.defaultAnimation:0;t.mixer=new r.AnimationMixer(t),e(n)}function e(e){for(let n=0;nt.animations.length&&console.log("The animation index "+e+" doesn't exist for this object");let r=t.animations[n],i=t.mixer.clipAction(r);t.actions.push(i),e===n?(t.defaultAction=i,i.setEffectiveWeight(1)):i.setEffectiveWeight(0),i.play()}}let n=!1;Object.defineProperty(t,"isPlaying",{get:()=>n,set(e){n!=e&&(n=e,t.dispatchEvent({type:"IsPlayingChanged",detail:t}))}}),this.enrolledObjects.push(t),t.animationQueue=[],t.set=function(e){if(e.duration>0){let n={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};c.extend(e,n);let i=e.coords,o=e.rotation,a=e.scale||e.scaleX||e.scaleY||e.scaleZ;if(o){let n=t.rotation;e.startRotation=[n.x,n.y,n.z],e.endState.rotation=c.types.rotation(e.rotation,e.startRotation),e.rotationPerMs=e.endState.rotation.map((function(t,n){return(t-e.startRotation[n])/e.duration}))}if(a){let n=t.scale;e.startScale=[n.x,n.y,n.z],e.endState.scale=c.types.scale(e.scale,e.startScale),e.scalePerMs=e.endState.scale.map((function(t,n){return(t-e.startScale[n])/e.duration}))}i&&(e.pathCurve=new r.CatmullRomCurve3(c.lnglatsToWorld([t.coordinates,e.coords])));let s={type:"set",parameters:e};this.animationQueue.push(s),tb.map.repaint=!0}else this.stop(),e.rotation=c.radify(e.rotation),this._setObject(e);return this},t.animationMethod=null,t.stop=function(e){return t.mixer&&(t.isPlaying=!1,cancelAnimationFrame(t.animationMethod)),this.animationQueue=[],this},t.followPath=function(t,e){let n={type:"followPath",parameters:c._validate(t,_.followPath)};return c.extend(n.parameters,{pathCurve:new r.CatmullRomCurve3(c.lnglatsToWorld(t.path)),start:Date.now(),expiration:Date.now()+n.parameters.duration,cb:e}),this.animationQueue.push(n),tb.map.repaint=!0,this},t._setObject=function(e){t.setScale();let n=e.position,i=e.rotation,o=e.scale,a=e.worldCoordinates,s=e.quaternion,l=e.translate,u=e.worldTranslate;if(n){this.coordinates=n;let t=c.projectToWorld(n);this.position.copy(t)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let t=c.projectToWorld(l);this.position.copy(t),e.position=this.coordinates}if(u){this.translateX(u.x),this.translateY(u.y),this.translateZ(u.z);let t=c.unprojectFromWorld(this.position);this.coordinates=e.position=t}if(i&&(this.rotation.set(i[0],i[1],i[2]),e.rotation=new r.Vector3(i[0],i[1],i[2])),o&&(this.scale.set(o[0],o[1],o[2]),e.scale=this.scale),s&&(this.quaternion.setFromAxisAngle(s[0],s[1]),e.rotation=s[0].multiplyScalar(s[1])),a){this.position.copy(a);let t=c.unprojectFromWorld(a);this.coordinates=e.position=t}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let h={type:"ObjectChanged",detail:{object:this,action:{position:e.position,rotation:e.rotation,scale:e.scale}}};this.dispatchEvent(h)},t.playDefault=function(e){if(t.mixer&&t.hasDefaultAnimation){let n={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};c.extend(e,n),t.mixer.timeScale=e.speed||1;let r={type:"playDefault",parameters:e};return this.animationQueue.push(r),tb.map.repaint=!0,this}},t.playAnimation=function(n){t.mixer&&(n.animation&&e(n.animation),t.playDefault(n))},t.pauseAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.paused=!0}))},t.unPauseAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.paused=!1}))},t.deactivateAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.stop()}))},t.activateAllActions=function(){t.mixer&&t.actions.forEach((function(t){t.play()}))},t.idle=function(){return t.mixer&&t.mixer.update(.01),tb.map.repaint=!0,this}},update:function(t){if(void 0===this.previousFrameTime&&(this.previousFrameTime=t),!this.enrolledObjects)return!1;for(let e=this.enrolledObjects.length-1;e>=0;e--){let n=this.enrolledObjects[e];if(n.animationQueue&&0!==n.animationQueue.length)for(let e=n.animationQueue.length-1;e>=0;e--){let i=n.animationQueue[e];if(!i)continue;let o=i.parameters;if(!o.expiration)return n.animationQueue.splice(e,1),void(n.animationQueue[e]&&(n.animationQueue[e].parameters.start=t));if(t>=o.expiration)o.expiration=!1,"playDefault"===i.type?n.stop():(o.endState&&n._setObject(o.endState),void 0!==o.cb&&o.cb());else{let e=(t-o.start)/o.duration;if("set"===i.type){let t={};o.pathCurve&&(t.worldCoordinates=o.pathCurve.getPoint(e)),o.rotationPerMs&&(t.rotation=o.startRotation.map((function(t,n){return t+o.rotationPerMs[n]*e*o.duration}))),o.scalePerMs&&(t.scale=o.startScale.map((function(t,n){return t+o.scalePerMs[n]*e*o.duration}))),n._setObject(t)}if("followPath"===i.type){let t={worldCoordinates:o.pathCurve.getPointAt(e)};if(o.trackHeading){let n=o.pathCurve.getTangentAt(e).normalize(),i=new r.Vector3(0,0,0),a=new r.Vector3(0,1,0);i.crossVectors(a,n).normalize();let s=Math.acos(a.dot(n));t.quaternion=[i,s]}n._setObject(t)}"playDefault"===i.type&&(n.activateAllActions(),n.isPlaying=!0,n.animationMethod=requestAnimationFrame(this.update),n.mixer.update(n.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=t}};const _={followPath:{path:null,duration:1e3,trackHeading:!0}};y=y=v;var x={};!function(){class t extends r.Object3D{constructor(t){super(),this.element=t||document.createElement("div"),this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.alwaysVisible=!1,Object.defineProperty(this,"layer",{get(){return this.parent&&this.parent.parent?this.parent.parent.layer:null}}),this.dispose=function(){this.remove(),this.element=null},this.remove=function(){this.element instanceof Element&&null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)},this.addEventListener("removed",(function(){this.remove()}))}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this}}t.prototype.isCSS2DObject=!0;const e=new r.Vector3,n=new r.Matrix4,i=new r.Matrix4,o=new r.Vector3,a=new r.Vector3;r.CSS2DObject=t,r.CSS2DRenderer=class{constructor(){const t=this;let r,s,l,u;const c={objects:new WeakMap,list:new Map};this.cacheList=c.list;const h=document.createElement("div");h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:r,height:s}},this.render=function(r,s){!0===r.autoUpdate&&r.updateMatrixWorld(),null===s.parent&&s.updateMatrixWorld(),n.copy(s.matrixWorldInverse),i.multiplyMatrices(s.projectionMatrix,n),function n(r,s,p){if(r.isCSS2DObject)if(r.visible){r.onBeforeRender(t,s,p),e.setFromMatrixPosition(r.matrixWorld),e.applyMatrix4(i);const n=r.element;var f;f=/apple/i.test(navigator.vendor)?"translate(-50%,-50%) translate("+Math.round(e.x*l+l)+"px,"+Math.round(-e.y*u+u)+"px)":"translate(-50%,-50%) translate("+(e.x*l+l)+"px,"+(-e.y*u+u)+"px)",n.style.WebkitTransform=f,n.style.MozTransform=f,n.style.oTransform=f,n.style.transform=f,n.style.display=r.visible&&e.z>=-1&&e.z<=1?"":"none";const g={distanceToCameraSquared:(d=p,m=r,o.setFromMatrixPosition(d.matrixWorld),a.setFromMatrixPosition(m.matrixWorld),o.distanceToSquared(a))};c.objects.set({key:r.uuid},g),c.list.set(r.uuid,r),n.parentNode!==h&&h.appendChild(n),r.onAfterRender(t,s,p)}else c.objects.delete({key:r.uuid}),c.list.delete(r.uuid),r.remove();var d,m;for(let t=0,e=r.children.length;tt.getObjectByName("model")}),Object.defineProperty(t,"animations",{get(){const e=t.model;return e?e.animations:null}}),n.animationManager.enroll(t),t.setCoords=function(e){return t.userData.topMargin&&t.userData.feature&&(e[2]+=((t.userData.feature.properties.height||0)-(t.userData.feature.properties.base_height||t.userData.feature.properties.min_height||0))*(t.userData.topMargin||0)),t.coordinates=e,t.set({position:e}),t},t.setTranslate=function(e){return t.set({translate:e}),t},t.setRotation=function(e){"number"==typeof e&&(e={z:e});var n={x:c.radify(e.x)||t.rotation.x,y:c.radify(e.y)||t.rotation.y,z:c.radify(e.z)||t.rotation.z};t._setObject({rotation:[n.x,n.y,n.z]})},t.calculateAdjustedPosition=function(e,n,r){let i=e.slice(),o=c.unprojectFromWorld(t.modelSize);return r?(i[0]-=0!=n.x?o[0]/n.x:0,i[1]-=0!=n.y?o[1]/n.y:0,i[2]-=0!=n.z?o[2]/n.z:0):(i[0]+=0!=n.x?o[0]/n.x:0,i[1]+=0!=n.y?o[1]/n.y:0,i[2]+=0!=n.z?o[2]/n.z:0),i},t.setRotationAxis=function(e){"number"==typeof e&&(e={z:e});let n=t.modelBox(),i=new w.Vector3(n.max.x,n.max.y,n.min.z);0!=e.x&&r(t,i,new w.Vector3(0,0,1),e.x),0!=e.y&&r(t,i,new w.Vector3(0,0,1),e.y),0!=e.z&&r(t,i,new w.Vector3(0,0,1),e.z)},Object.defineProperty(t,"scaleGroup",{get:()=>t.getObjectByName("scaleGroup")}),Object.defineProperty(t,"boxGroup",{get:()=>t.getObjectByName("boxGroup")}),Object.defineProperty(t,"boundingBox",{get:()=>t.getObjectByName("boxModel")}),Object.defineProperty(t,"boundingBoxShadow",{get:()=>t.getObjectByName("boxShadow")}),t.drawBoundingBox=function(){let e=t.box3(),n=new w.Group;n.name="boxGroup",n.updateMatrixWorld(!0);let r=new w.Box3Helper(e,E.prototype._defaults.colors.yellow);r.name="boxModel",n.add(r),r.layers.disable(0);let i=e.clone();i.max.z=i.min.z;let o=new w.Box3Helper(i,E.prototype._defaults.colors.black);o.name="boxShadow",n.add(o),o.layers.disable(0),n.visible=!1,t.scaleGroup.add(n),t.setBoundingBoxShadowFloor()},t.setBoundingBoxShadowFloor=function(){if(t.boundingBoxShadow){let e=-t.modelHeight,n=t.rotation,r=t.boundingBoxShadow;r.box.max.z=r.box.min.z=e,r.rotation.y=n.y,r.rotation.x=-n.x}},t.setAnchor=function(e){const n=t.box3(),r=n.getCenter(new w.Vector3);switch(t.none={x:0,y:0,z:0},t.center={x:r.x,y:r.y,z:n.min.z},t.bottom={x:r.x,y:n.max.y,z:n.min.z},t.bottomLeft={x:n.max.x,y:n.max.y,z:n.min.z},t.bottomRight={x:n.min.x,y:n.max.y,z:n.min.z},t.top={x:r.x,y:n.min.y,z:n.min.z},t.topLeft={x:n.max.x,y:n.min.y,z:n.min.z},t.topRight={x:n.min.x,y:n.min.y,z:n.min.z},t.left={x:n.max.x,y:r.y,z:n.min.z},t.right={x:n.min.x,y:r.y,z:n.min.z},e){case"center":t.anchor=t.center;break;case"top":t.anchor=t.top;break;case"top-left":t.anchor=t.topLeft;break;case"top-right":t.anchor=t.topRight;break;case"left":t.anchor=t.left;break;case"right":t.anchor=t.right;break;case"bottom":t.anchor=t.bottom;break;case"bottom-left":default:t.anchor=t.bottomLeft;break;case"bottom-right":t.anchor=t.bottomRight;break;case"auto":case"none":t.anchor=t.none}t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)},t.setCenter=function(e){if(e&&(0!=e.x||0!=e.y||0!=e.z)){let n=t.getSize();t.anchor={x:t.anchor.x-n.x*e.x,y:t.anchor.y-n.y*e.y,z:t.anchor.z-n.z*e.z},t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)}},Object.defineProperty(t,"label",{get:()=>t.getObjectByName("label")}),Object.defineProperty(t,"tooltip",{get:()=>t.getObjectByName("tooltip")}),Object.defineProperty(t,"help",{get:()=>t.getObjectByName("help")});let o=!1;Object.defineProperty(t,"hidden",{get:()=>o,set(e){o!=e&&(o=e,t.visibility=!o)}}),Object.defineProperty(t,"visibility",{get:()=>t.visible,set(e){let n=e;if("visible"==e||1==e)n=!0,t.label&&(t.label.visible=n);else{if("none"!=e&&0!=e)return;n=!1,t.label&&t.label.alwaysVisible&&(t.label.visible=n),t.tooltip&&(t.tooltip.visible=n)}if(t.visible!=n){if(t.hidden&&n)return;t.visible=n,t.model&&t.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(n&&t.raycasted?e.layers.enable(0):e.layers.disable(0)),"LineSegments"==e.type&&e.layers.disableAll()}))}}}),t.addLabel=function(e,n,r,i){e&&t.drawLabelHTML(e,n,r,i)},t.removeLabel=function(){t.removeCSS2D("label")},t.drawLabelHTML=function(e,r=!1,i=t.anchor,o=.5){let a=n.drawLabelHTML(e,E.prototype._defaults.label.cssClass),s=t.addCSS2D(a,"label",i,o);return s.alwaysVisible=r,s.visible=r,s},t.addTooltip=function(e,n,r,i=!0,o=1){let a=t.addHelp(e,"tooltip",n,r,o);a.visible=!1,a.custom=i},t.removeTooltip=function(){t.removeCSS2D("tooltip")},t.addHelp=function(e,r="help",i=!1,o=t.anchor,a=0){let s=n.drawTooltip(e,i),l=t.addCSS2D(s,r,o,a);return l.visible=!0,l},t.removeHelp=function(){t.removeCSS2D("help")},t.addCSS2D=function(e,n,r=t.anchor,i=1){if(e){const o=t.box3(),a=o.getSize(new w.Vector3);let s={x:o.max.x,y:o.max.y,z:o.min.z};t.removeCSS2D(n);let l=new x.CSS2DObject(e);return l.name=n,l.position.set(.5*-a.x-t.model.position.x-r.x+s.x,.5*-a.y-t.model.position.y-r.y+s.y,a.z*i),l.visible=!1,t.scaleGroup.add(l),l}},t.removeCSS2D=function(e){let n=t.getObjectByName(e);if(n){n.dispose();let e=t.scaleGroup.children;e.splice(e.indexOf(n),1)}},Object.defineProperty(t,"shadowPlane",{get:()=>t.getObjectByName("shadowPlane")});let a=!1;Object.defineProperty(t,"castShadow",{get:()=>a,set(e){if(t.model&&a!==e){if(t.model.traverse((function(t){t.isMesh&&(t.castShadow=!0)})),e){const n=t.modelSize,r=[n.x,n.y,n.z,t.modelHeight],i=10*Math.max(...r),o=new w.PlaneBufferGeometry(i,i),a=new w.ShadowMaterial;a.opacity=.5;let s=new w.Mesh(o,a);s.name="shadowPlane",s.layers.enable(1),s.layers.disable(0),s.receiveShadow=e,t.add(s)}else t.traverse((function(e){e.isMesh&&e.material instanceof w.ShadowMaterial&&t.remove(e)}));a=e}}}),t.setReceiveShadowFloor=function(){if(t.castShadow){let e=t.shadowPlane,n=e.position,r=e.rotation;if(n.z=-t.modelHeight,r.y=t.rotation.y,r.x=-t.rotation.x,"meters"===t.userData.units){const r=t.modelSize,i=[r.x,r.y,r.z,-n.z],o=10*Math.max(...i)/e.geometry.parameters.width;e.scale.set(o,o,o)}}};let s=!1;Object.defineProperty(t,"receiveShadow",{get:()=>s,set(e){t.model&&s!==e&&(t.model.traverse((function(t){t.isMesh&&(t.receiveShadow=!0)})),s=e)}});let l=!1;Object.defineProperty(t,"wireframe",{get:()=>l,set(e){t.model&&l!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let n=[];Array.isArray(t.material)?n=t.material:n.push(t.material);let r=n[0];e?(t.userData.materials=r,t.material=r.clone(),t.material.wireframe=t.material.transparent=e,t.material.opacity=.3):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null),e?(t.layers.disable(0),t.layers.enable(1)):(t.layers.disable(1),t.layers.enable(0))}"LineSegments"==t.type&&t.layers.disableAll()})),l=e,t.dispatchEvent({type:"Wireframed",detail:t}))}});let u=null;Object.defineProperty(t,"color",{get:()=>u,set(e){t.model&&u!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let n=[];Array.isArray(t.material)?n=t.material:n.push(t.material);let r=n[0];e?(t.userData.materials=r,t.material=new w.MeshStandardMaterial,t.material.color.setHex(e)):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null)}})),u=e)}});let h=!1;Object.defineProperty(t,"selected",{get:()=>h,set(e){e?(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.boxGroup&&(t.boundingBox.material=E.prototype._defaults.materials.boxSelectedMaterial,t.boundingBox.parent.visible=!0,t.boundingBox.layers.enable(1),t.boundingBoxShadow.layers.enable(1)),t.label&&!t.label.alwaysVisible&&(t.label.visible=!0)):(t.boxGroup&&t.remove(t.boxGroup),t.label&&!t.label.alwaysVisible&&(t.label.visible=!1),t.removeHelp()),t.tooltip&&(t.tooltip.visible=e),h!=e&&(h=e,t.dispatchEvent({type:"SelectedChange",detail:t}))}});let p=!0;Object.defineProperty(t,"raycasted",{get:()=>p,set(e){t.model&&p!==e&&(t.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(e?(t.layers.disable(1),t.layers.enable(0)):(t.layers.disable(0),t.layers.enable(1)))})),p=e)}});let f=!1;Object.defineProperty(t,"over",{get:()=>f,set(e){e?(t.selected||(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.userData.tooltip&&!t.tooltip&&t.addTooltip(t.uuid,!0,t.anchor,!1),t.boxGroup&&(t.boundingBox.material=E.prototype._defaults.materials.boxOverMaterial,t.boundingBox.parent.visible=!0,t.boundingBox.layers.enable(1),t.boundingBoxShadow.layers.enable(1))),t.label&&!t.label.alwaysVisible&&(t.label.visible=!0),t.dispatchEvent({type:"ObjectMouseOver",detail:t})):(t.selected||(t.boxGroup&&(t.remove(t.boxGroup),t.tooltip&&!t.tooltip.custom&&t.removeTooltip()),t.label&&!t.label.alwaysVisible&&(t.label.visible=!1)),t.dispatchEvent({type:"ObjectMouseOut",detail:t})),t.tooltip&&(t.tooltip.visible=e||t.selected),f=e}}),t.box3=function(){let e;if(t.updateMatrix(),t.updateMatrixWorld(!0,!0),t.model){let n=t.clone(!0),r=t.model.clone();if(e=(new w.Box3).setFromObject(r),t.parent){let i=new w.Matrix4,o=new w.Matrix4;t.matrix.extractRotation(i),o.copy(i).invert(),n.setRotationFromMatrix(o),e=(new w.Box3).setFromObject(r)}}return e},t.modelBox=function(){return t.box3()},t.getSize=function(){return t.box3().getSize(new w.Vector3(0,0,0))};let d=!1;Object.defineProperty(t,"modelSize",{get:()=>d=t.getSize(),set(t){d!=t&&(d=t)}}),Object.defineProperty(t,"modelHeight",{get(){let e=t.coordinates[2]||0;return"scene"===t.userData.units&&(e*=t.unitsPerMeter/t.scale.x),e}}),Object.defineProperty(t,"unitsPerMeter",{get:()=>Number(c.projectedUnitsPerMeter(t.coordinates[1]).toFixed(7))}),Object.defineProperty(t,"fixedZoom",{get:()=>t.userData.fixedZoom,set(e){t.userData.fixedZoom!==e&&(t.userData.fixedZoom=e,t.userData.units=e?"scene":"meters")}}),t.setFixedZoom=function(e){if(null!=t.fixedZoom&&0!=t.fixedZoom){e||(e=t.userData.mapScale);let r=(n=t.fixedZoom,Math.pow(2,n));if(r>e){let n=r/e;t.scale.set(n,n,n)}else t.scale.set(1,1,1)}var n},t.setScale=function(e){if("scene"!=t.userData.units){let e=t.unitsPerMeter;t.scale.set(e,e,e)}else t.fixedZoom?(e&&(t.userData.mapScale=e),t.setFixedZoom(t.userData.mapScale)):t.scale.set(1,1,1)},t.setObjectScale=function(e){t.setScale(e),t.setBoundingBoxShadowFloor(),t.setReceiveShadowFloor()}}t.add=function(e){return t.scaleGroup.add(e),e.position.z=t.coordinates[2]?-t.coordinates[2]:0,e},t.remove=function(e){e&&(e.traverse((t=>{if(t.geometry&&t.geometry.dispose(),t.material)if(t.material.isMaterial)i(t.material);else for(const e of t.material)i(e);t.dispose&&t.dispose()})),t.scaleGroup.remove(e),tb.map.repaint=!0)},t.duplicate=function(e){let r=t.clone(!0);if(r.getObjectByName("model").animations=t.animations,r.userData.feature&&(e&&e.feature&&(r.userData.feature=e.feature),r.userData.feature.properties.uuid=r.uuid),n._addMethods(r),!e||c.equal(e.scale,t.userData.scale))return r.copyAnchor(t),r;{r.userData=e,r.userData.isGeoGroup=!0,r.remove(r.boxGroup);const t=c.types.rotation(e.rotation,[0,0,0]),n=c.types.scale(e.scale,[1,1,1]);return r.model.position.set(0,0,0),r.model.rotation.set(t[0],t[1],t[2]),r.model.scale.set(n[0],n[1],n[2]),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r}},t.copyAnchor=function(e){t.anchor=e.anchor,t.none={x:0,y:0,z:0},t.center=e.center,t.bottom=e.bottom,t.bottomLeft=e.bottomLeft,t.bottomRight=e.bottomRight,t.top=e.top,t.topLeft=e.topLeft,t.topRight=e.topRight,t.left=e.left,t.right=e.right},t.dispose=function(){E.prototype.unenroll(t),t.traverse((t=>{if((!t.parent||"world"!=t.parent.name)&&"threeboxObject"!==t.name){if(t.geometry&&t.geometry.dispose(),t.material)if(t.material.isMaterial)i(t.material);else for(const e of t.material)i(e);t.dispose&&t.dispose()}})),t.children=[]};const i=t=>{t.dispose();for(const e of Object.keys(t)){const n=t[e];n&&"object"==typeof n&&"minFilter"in n&&n.dispose()}let e=t;(e.map||e.alphaMap||e.aoMap||e.bumpMap||e.displacementMap||e.emissiveMap||e.envMap||e.lightMap||e.metalnessMap||e.normalMap||e.roughnessMap)&&(e.map&&e.map.dispose(),e.alphaMap&&e.alphaMap.dispose(),e.aoMap&&e.aoMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.displacementMap&&e.displacementMap.dispose(),e.emissiveMap&&e.emissiveMap.dispose(),e.envMap&&e.envMap.dispose(),e.lightMap&&e.lightMap.dispose(),e.metalnessMap&&e.metalnessMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.roughnessMap&&e.roughnessMap.dispose())};return t},_makeGroup:function(t,e){let n=new w.Group;n.name="scaleGroup",n.add(t);var r=new w.Group;if(r.userData=e||{},r.userData.isGeoGroup=!0,r.userData.feature&&(r.userData.feature.properties.uuid=r.uuid),n.length)for(o of n)r.add(o);else r.add(n);return r.name="threeboxObject",r},animationManager:new y,drawTooltip:function(t,e=!1){if(t){let n;if(e){let e=document.createElement("div");e.className="mapboxgl-popup-content";let r=document.createElement("strong");r.innerHTML=t,e.appendChild(r);let i=document.createElement("div");i.className="mapboxgl-popup-tip";let o=document.createElement("div");o.className="marker mapboxgl-popup-anchor-bottom",o.appendChild(i),o.appendChild(e),(n=document.createElement("div")).className+="label3D",n.appendChild(o)}else(n=document.createElement("span")).className=this._defaults.tooltip.cssClass,n.innerHTML=t;return n}},drawLabelHTML:function(t,e){let n=document.createElement("div");return n.className+=e,n.innerHTML="string"==typeof t?t:t.outerHTML,n},_defaults:{colors:{red:new w.Color(16711680),yellow:new w.Color(16776960),green:new w.Color(65280),black:new w.Color(0)},materials:{boxNormalMaterial:new w.LineBasicMaterial({color:new w.Color(16711680)}),boxOverMaterial:new w.LineBasicMaterial({color:new w.Color(16776960)}),boxSelectedMaterial:new w.LineBasicMaterial({color:new w.Color(65280)})},line:{geometry:null,color:"black",width:1,opacity:1},label:{htmlElement:null,cssClass:" label3D",alwaysVisible:!1,topMargin:-.5},tooltip:{text:"",cssClass:"toolTip text-xs",mapboxStyle:!1,topMargin:0},sphere:{position:[0,0,0],radius:1,sides:20,units:"scene",material:"MeshBasicMaterial",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},tube:{geometry:null,radius:1,sides:6,units:"scene",material:"MeshBasicMaterial",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0},loadObj:{type:null,obj:null,units:"scene",scale:1,rotation:0,defaultAnimation:0,anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0,clone:!0},Object3D:{obj:null,units:"scene",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},extrusion:{coordinates:[[[]]],geometryOptions:{},height:100,materials:new w.MeshPhongMaterial({color:6684672,side:w.DoubleSide}),scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},b=b=E;var S={};S=S=function(t){let e=(t=c._validate(t,b.prototype._defaults.Object3D)).obj;const n=c.types.rotation(t.rotation,[0,0,0]),r=c.types.scale(t.scale,[1,1,1]);e.rotation.set(n[0],n[1],n[2]),e.scale.set(r[0],r[1],r[2]),e.name="model";let i=b.prototype._makeGroup(e,t);return t.obj.name="model",b.prototype._addMethods(i),i.setAnchor(t.anchor),i.setCenter(t.adjustment),i.raycasted=t.raycasted,i.visibility=!0,i};var M={};M=M=function(t){t=c._validate(t,b.prototype._defaults.sphere);let e=new r.SphereBufferGeometry(t.radius,t.sides,t.sides),n=m(t),i=new r.Mesh(e,n);return new S({obj:i,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})};var T={};function C(t){t=c._validate(t,b.prototype._defaults.extrusion);let e=C.prototype.buildShape(t.coordinates),n=C.prototype.buildGeometry(e,t.geometryOptions),i=new r.Mesh(n,t.materials);return t.obj=i,new S(t)}C.prototype={buildShape:function(t){if(t[0]instanceof(r.Vector2||r.Vector3))return new r.Shape(t);let e=new r.Shape;for(let n=0;n0?e[e.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(t){const e={index:"number"==typeof t?t:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return e.clone=this.clone.bind(e),e}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(t){const e=this.currentMaterial();if(e&&-1===e.groupEnd&&(e.groupEnd=this.geometry.vertices.length/3,e.groupCount=e.groupEnd-e.groupStart,e.inherited=!1),t&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return t&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),e}},n&&n.name&&"function"==typeof n.clone){const t=n.clone(0);t.inherited=!0,this.object.materials.push(t)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(t,e){const n=parseInt(t,10);return 3*(n>=0?n-1:n+e/3)},parseNormalIndex:function(t,e){const n=parseInt(t,10);return 3*(n>=0?n-1:n+e/3)},parseUVIndex:function(t,e){const n=parseInt(t,10);return 2*(n>=0?n-1:n+e/2)},addVertex:function(t,e,n){const r=this.vertices,i=this.object.geometry.vertices;i.push(r[t+0],r[t+1],r[t+2]),i.push(r[e+0],r[e+1],r[e+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){const e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,n){const r=this.normals,i=this.object.geometry.normals;i.push(r[t+0],r[t+1],r[t+2]),i.push(r[e+0],r[e+1],r[e+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(t,e,n){const r=this.vertices,i=this.object.geometry.normals;o.fromArray(r,t),a.fromArray(r,e),s.fromArray(r,n),u.subVectors(s,a),l.subVectors(o,a),u.cross(l),u.normalize(),i.push(u.x,u.y,u.z),i.push(u.x,u.y,u.z),i.push(u.x,u.y,u.z)},addColor:function(t,e,n){const r=this.colors,i=this.object.geometry.colors;void 0!==r[t]&&i.push(r[t+0],r[t+1],r[t+2]),void 0!==r[e]&&i.push(r[e+0],r[e+1],r[e+2]),void 0!==r[n]&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(t,e,n){const r=this.uvs,i=this.object.geometry.uvs;i.push(r[t+0],r[t+1]),i.push(r[e+0],r[e+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){const t=this.object.geometry.uvs;t.push(0,0),t.push(0,0),t.push(0,0)},addUVLine:function(t){const e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,n,r,i,o,a,s,l){const u=this.vertices.length;let c=this.parseVertexIndex(t,u),h=this.parseVertexIndex(e,u),p=this.parseVertexIndex(n,u);if(this.addVertex(c,h,p),this.addColor(c,h,p),void 0!==a&&""!==a){const t=this.normals.length;c=this.parseNormalIndex(a,t),h=this.parseNormalIndex(s,t),p=this.parseNormalIndex(l,t),this.addNormal(c,h,p)}else this.addFaceNormal(c,h,p);if(void 0!==r&&""!==r){const t=this.uvs.length;c=this.parseUVIndex(r,t),h=this.parseUVIndex(i,t),p=this.parseUVIndex(o,t),this.addUV(c,h,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(t){this.object.geometry.type="Points";const e=this.vertices.length;for(let n=0,r=t.length;n=7?a.colors.push(parseFloat(t[4]),parseFloat(t[5]),parseFloat(t[6])):a.colors.push(void 0,void 0,void 0);break;case"vn":a.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));break;case"vt":a.uvs.push(parseFloat(t[1]),parseFloat(t[2]))}}else if("f"===u){const t=l.substr(1).trim().split(/\s+/),e=[];for(let n=0,r=t.length;n0){const t=r.split("/");e.push(t)}}const n=e[0];for(let t=1,r=e.length-1;t1){const t=p[1].trim().toLowerCase();a.object.smooth="0"!==t&&"off"!==t}else a.object.smooth=!0;const t=a.object.currentMaterial();t&&(t.smooth=a.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}a.finalize();const d=new r.Group;if(d.materialLibraries=[].concat(a.materialLibraries),1==!(1===a.objects.length&&0===a.objects[0].geometry.vertices.length))for(let t=0,e=a.objects.length;t0&&u.setAttribute("normal",new r.Float32BufferAttribute(n.normals,3)),n.colors.length>0&&(l=!0,u.setAttribute("color",new r.Float32BufferAttribute(n.colors,3))),!0===n.hasUVIndices&&u.setAttribute("uv",new r.Float32BufferAttribute(n.uvs,2));const c=[];for(let t=0,e=i.length;t1){for(let t=0,e=i.length;t0){const t=new r.PointsMaterial({size:1,sizeAttenuation:!1}),e=new r.BufferGeometry;e.setAttribute("position",new r.Float32BufferAttribute(a.vertices,3)),a.colors.length>0&&void 0!==a.colors[0]&&(e.setAttribute("color",new r.Float32BufferAttribute(a.colors,3)),t.vertexColors=!0);const n=new r.Points(e,t);d.add(n)}return d}}}(),L=L=r.OBJLoader;var P={};!function(){class t{constructor(t="",e={}){this.baseUrl=t,this.options=e,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:r.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:r.RepeatWrapping}setCrossOrigin(t){return this.crossOrigin=t,this}setManager(t){this.manager=t}setMaterials(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(t){if(!this.options)return t;const e={};for(const n in t){const r=t[n],i={};e[n]=i;for(const t in r){let e=!0,n=r[t];const o=t.toLowerCase();switch(o){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(e=!1)}e&&(i[o]=n)}}return e}preload(){for(const t in this.materialsInfo)this.create(t)}getIndex(t){return this.nameLookup[t]}getAsArray(){let t=0;for(const e in this.materialsInfo)this.materialsArray[t]=this.create(e),this.nameLookup[e]=t,t++;return this.materialsArray}create(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]}createMaterial_(t){const e=this,n=this.materialsInfo[t],i={name:t,side:this.side};function o(t,n){if(i[t])return;const r=e.getTextureParams(n,i),o=e.loadTexture((a=e.baseUrl,"string"!=typeof(s=r.url)||""===s?"":/^https?:\/\//i.test(s)?s:a+s));var a,s;o.repeat.copy(r.scale),o.offset.copy(r.offset),o.wrapS=e.wrap,o.wrapT=e.wrap,i[t]=o}for(const t in n){const e=n[t];let a;if(""!==e)switch(t.toLowerCase()){case"kd":i.color=(new r.Color).fromArray(e);break;case"ks":i.specular=(new r.Color).fromArray(e);break;case"ke":i.emissive=(new r.Color).fromArray(e);break;case"map_kd":o("map",e);break;case"map_ks":o("specularMap",e);break;case"map_ke":o("emissiveMap",e);break;case"norm":o("normalMap",e);break;case"map_bump":case"bump":o("bumpMap",e);break;case"map_d":o("alphaMap",e),i.transparent=!0;break;case"ns":i.shininess=parseFloat(e);break;case"d":(a=parseFloat(e))<1&&(i.opacity=a,i.transparent=!0);break;case"tr":a=parseFloat(e),this.options&&this.options.invertTrProperty&&(a=1-a),a>0&&(i.opacity=1-a,i.transparent=!0)}}return this.materials[t]=new r.MeshPhongMaterial(i),this.materials[t]}getTextureParams(t,e){const n={scale:new r.Vector2(1,1),offset:new r.Vector2(0,0)},i=t.split(/\s+/);let o;return(o=i.indexOf("-bm"))>=0&&(e.bumpScale=parseFloat(i[o+1]),i.splice(o,2)),(o=i.indexOf("-s"))>=0&&(n.scale.set(parseFloat(i[o+1]),parseFloat(i[o+2])),i.splice(o,4)),(o=i.indexOf("-o"))>=0&&(n.offset.set(parseFloat(i[o+1]),parseFloat(i[o+2])),i.splice(o,4)),n.url=i.join(" ").trim(),n}loadTexture(t,e,n,i,o){const a=void 0!==this.manager?this.manager:r.DefaultLoadingManager;let s=a.getHandler(t);null===s&&(s=new r.TextureLoader(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);const l=s.load(t,n,i,o);return void 0!==e&&(l.mapping=e),l}}r.MTLLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===this.path?r.LoaderUtils.extractUrlBase(t||""):this.path,s=new r.FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}setMaterialOptions(t){return this.materialOptions=t,this}parse(e,n){const r=e.split("\n");let i={};const o=/\s+/,a={};for(let t=0;t=0?e.substring(0,n):e;s=s.toLowerCase();let l=n>=0?e.substring(n+1):"";if(l=l.trim(),"newmtl"===s)i={name:l},a[l]=i;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){const t=l.split(o,3);i[s]=[parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2])]}else i[s]=l}const s=new t(this.resourcePath||n,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}}}(),P=P=r.MTLLoader;var R,D,N={},O=N={};function k(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function F(t){if(R===setTimeout)return setTimeout(t,0);if((R===k||!R)&&setTimeout)return R=setTimeout,setTimeout(t,0);try{return R(t,0)}catch(e){try{return R.call(null,t,0)}catch(e){return R.call(this,t,0)}}}!function(){try{R="function"==typeof setTimeout?setTimeout:k}catch(t){R=k}try{D="function"==typeof clearTimeout?clearTimeout:z}catch(t){D=z}}();var B,U=[],V=!1,G=-1;function j(){V&&B&&(V=!1,B.length?U=B.concat(U):G=-1,U.length&&H())}function H(){if(!V){var t=F(j);V=!0;for(var e=U.length;e;){for(B=U,U=[];++G1)for(var n=1;n>>1|(21845&y)<<1;g[y]=((65280&(v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4))>>>8|(255&v)<<8)>>>1}var _=function(t,e,n){for(var r=t.length,o=0,a=new i(e);o>>u]=c}else for(s=new i(r),o=0;o>>15-t[o]);return s},x=new r(288);for(y=0;y<144;++y)x[y]=8;for(y=144;y<256;++y)x[y]=9;for(y=256;y<280;++y)x[y]=7;for(y=280;y<288;++y)x[y]=8;var b=new r(32);for(y=0;y<32;++y)b[y]=5;var w=_(x,9,0),E=_(x,9,1),S=_(b,5,0),M=_(b,5,1),T=function(t){for(var e=t[0],n=1;ne&&(e=t[n]);return e},C=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},I=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},A=function(t){return(t/8|0)+(7&t&&1)},L=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var a=new(t instanceof i?i:t instanceof o?o:r)(n-e);return a.set(t.subarray(e,n)),a},P=function(t,e,n){var i=t.length;if(!i||n&&!n.l&&i<5)return e||new r(0);var o=!e||n,u=!n||n.i;n||(n={}),e||(e=new r(3*i));var c=function(t){var n=e.length;if(t>n){var i=new r(Math.max(2*n,t));i.set(e),e=i}},p=n.f||0,f=n.p||0,m=n.b||0,g=n.l,y=n.d,v=n.m,x=n.n,b=8*i;do{if(!g){n.f=p=C(t,f,1);var w=C(t,f+1,3);if(f+=3,!w){var S=t[(V=A(f)+4)-4]|t[V-3]<<8,P=V+S;if(P>i){if(u)throw"unexpected EOF";break}o&&c(m+S),e.set(t.subarray(V,P),m),n.b=m+=S,n.p=f=8*P;continue}if(1==w)g=E,y=M,v=9,x=5;else{if(2!=w)throw"invalid block type";var R=C(t,f,31)+257,D=C(t,f+10,15)+4,N=R+C(t,f+5,31)+1;f+=14;for(var O=new r(N),k=new r(19),z=0;zb)break;var U=_(k,F,1);for(z=0;z>>4)<16)O[z++]=V;else{var j=0,H=0;for(16==V?(H=3+C(t,f,3),f+=2,j=O[z-1]):17==V?(H=3+C(t,f,7),f+=3):18==V&&(H=11+C(t,f,127),f+=7);H--;)O[z++]=j}}var q=O.subarray(0,R),W=O.subarray(R);v=T(q),x=T(W),g=_(q,v,1),y=_(W,x,1)}if(f>b)throw"unexpected EOF"}o&&c(m+131072);for(var X=(1<>>4;if((f+=15&j)>b)throw"unexpected EOF";if(!j)throw"invalid length/literal";if(J<256)e[m++]=J;else{if(256==J){g=null;break}var K=J-254;J>264&&(K=C(t,f,(1<<(tt=a[z=J-257]))-1)+h[z],f+=tt);var Q=y[I(t,f)&Z],$=Q>>>4;if(!Q)throw"invalid distance";if(f+=15&Q,W=d[$],$>3){var tt=s[$];W+=I(t,f)&(1<b)throw"unexpected EOF";o&&c(m+131072);for(var et=m+K;m>>8},D=function(t,e,n){var r=e/8|0;t[r]|=n<<=7&e,t[r+1]|=n>>>8,t[r+2]|=n>>>16},N=function(t,e){for(var n=[],o=0;od&&(d=s[o].s);var m=new i(d+1),g=O(n[p-1],m,0);if(g>e){o=0;var y=0,v=g-e,_=1<e))break;y+=_-(1<>>=v;y>0;){var b=s[o].s;m[b]=0&&y;--o){var w=s[o].s;m[w]==e&&(--m[w],++y)}g=e}return[new r(m),g]},O=function(t,e,n){return-1==t.s?Math.max(O(t.l,e,n+1),O(t.r,e,n+1)):e[t.s]=n},k=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new i(++e),r=0,o=t[0],a=1,s=function(t){n[r++]=t},l=1;l<=e;++l)if(t[l]==o&&l!=e)++a;else{if(!o&&a>2){for(;a>138;a-=138)s(32754);a>2&&(s(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(s(o),--a;a>6;a-=6)s(8304);a>2&&(s(a-3<<5|8208),a=0)}for(;a--;)s(o);a=1,o=t[l]}return[n.subarray(0,r),e]},z=function(t,e){for(var n=0,r=0;r>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var o=0;o4&&!V[l[j-1]];--j);var H,q,W,X,Z=f+5<<3,Y=z(o,x)+z(u,b)+c,J=z(o,g)+z(u,E)+c+14+3*j+z(O,V)+(2*O[16]+3*O[17]+7*O[18]);if(Z<=Y&&Z<=J)return F(e,d,t.subarray(p,p+f));if(R(e,d,1+(J15&&(R(e,d,tt[B]>>>5&127),d+=tt[B]>>>12)}}else H=w,q=x,W=S,X=b;for(B=0;B255){var et;D(e,d,H[257+(et=r[B]>>>18&31)]),d+=q[et+257],et>7&&(R(e,d,r[B]>>>23&31),d+=a[et]);var nt=31&r[B];D(e,d,W[nt]),d+=X[nt],nt>3&&(D(e,d,r[B]>>>5&8191),d+=s[nt])}else D(e,d,H[r[B]]),d+=q[r[B]];return D(e,d,H[256]),d+q[256]},U=new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),V=new r(0),G=function(t,e,n,l,u,c){var h=t.length,f=new r(l+h+5*(1+Math.ceil(h/7e3))+u),d=f.subarray(l,f.length-u),g=0;if(!e||h<8)for(var y=0;y<=h;y+=65535){var v=y+65535;v>>13,b=8191&_,w=(1<7e3||O>24576)&&q>423){g=B(t,d,0,I,P,R,N,O,z,y-z,g),O=D=N=0,z=y;for(var W=0;W<286;++W)P[W]=0;for(W=0;W<30;++W)R[W]=0}var X=2,Z=0,Y=b,J=j-H&32767;if(q>2&&G==C(y-J))for(var K=Math.min(x,q)-1,Q=Math.min(32767,y),$=Math.min(258,q);J<=Q&&--Y&&j!=H;){if(t[y+X]==t[y+X-J]){for(var tt=0;tt<$&&t[y+tt]==t[y+tt-J];++tt);if(tt>X){if(X=tt,Z=J,tt>K)break;var et=Math.min(J,tt-2),nt=0;for(W=0;Wnt&&(nt=it,H=rt)}}}J+=(j=H)-(H=E[j])+32768&32767}if(Z){I[O++]=268435456|p[X]<<18|m[Z];var ot=31&p[X],at=31&m[Z];N+=a[ot]+s[at],++P[257+ot],++R[at],k=y+X,++D}else I[O++]=t[y],++P[t[y]]}}g=B(t,d,c,I,P,R,N,O,z,y-z,g),!c&&7&g&&(g=F(d,g+1,V))}return L(f,0,l+A(g)+u)},j=function(){for(var t=new o(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),H=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r>>8;t=n},d:function(){return~t}}},q=function(){var t=1,e=0;return{p:function(n){for(var r=t,i=e,o=n.length,a=0;a!=o;){for(var s=Math.min(a+2655,o);a>16),i=(65535&i)+15*(i>>16)}t=r,e=i},d:function(){return((t%=65521)>>>8<<16|(255&(e%=65521))<<8|e>>>8)+2*((255&t)<<23)}}},W=function(t,e,n,r,i){return G(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!i)},Z=function(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n},Y=function(t,e,n){for(var r=t(),i=""+t,o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a>>=8},dt=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&ft(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},mt=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var e=t[3],n=10;4&e&&(n+=t[10]|2+(t[11]<<8));for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[n++]);return n+(2&e)},gt=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16)+2*(t[e-1]<<23)},yt=function(t){return 10+(t.filename&&t.filename.length+1||0)},vt=function(t,e){var n=e.level,r=0==n?0:n<6?1:9==n?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},_t=function(t){if(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"};function xt(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var bt=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(W(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=e,this.p(t,e||!1)},t}();e.Deflate=bt;var wt=function(t,e){ut([tt,function(){return[lt,bt]}],this,xt.call(this,t,e),(function(t){var e=new bt(t.data);onmessage=lt(e)}),6)};function Et(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt],(function(t){return ot(St(t.data[0],t.data[1]))}),0,n)}function St(t,e){return W(t,e||{},0,0)}e.AsyncDeflate=wt,e.deflate=Et,e.deflateSync=St;var Mt=function(){function t(t){this.s={},this.p=new r(0),this.ondata=t}return t.prototype.e=function(t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var e=this.p.length,n=new r(e+t.length);n.set(this.p),n.set(t,e),this.p=n},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=P(this.p,this.o,this.s);this.ondata(L(n,e,this.s.b),this.d),this.o=L(n,this.s.b-32768),this.s.b=this.o.length,this.p=L(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}();e.Inflate=Mt;var Tt=function(t){this.ondata=t,ut([$,function(){return[lt,Mt]}],this,0,(function(){var t=new Mt;onmessage=lt(t)}),7)};function Ct(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[$],(function(t){return ot(It(t.data[0],at(t.data[1])))}),1,n)}function It(t,e){return P(t,e)}e.AsyncInflate=Tt,e.inflate=Ct,e.inflateSync=It;var At=function(){function t(t,e){this.c=H(),this.l=0,this.v=1,bt.call(this,t,e)}return t.prototype.push=function(t,e){bt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=W(t,this.o,this.v&&yt(this.o),e&&8,!e);this.v&&(dt(n,this.o),this.v=0),e&&(ft(n,n.length-8,this.c.d()),ft(n,n.length-4,this.l)),this.ondata(n,e)},t}();e.Gzip=At,e.Compress=At;var Lt=function(t,e){ut([tt,et,function(){return[lt,bt,At]}],this,xt.call(this,t,e),(function(t){var e=new At(t.data);onmessage=lt(e)}),8)};function Pt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt,et,function(){return[Rt]}],(function(t){return ot(Rt(t.data[0],t.data[1]))}),2,n)}function Rt(t,e){e||(e={});var n=H(),r=t.length;n.p(t);var i=W(t,e,yt(e),8),o=i.length;return dt(i,e),ft(i,o-8,n.d()),ft(i,o-4,r),i}e.AsyncGzip=Lt,e.AsyncCompress=Lt,e.gzip=Pt,e.compress=Pt,e.gzipSync=Rt,e.compressSync=Rt;var Dt=function(){function t(t){this.v=1,Mt.call(this,t)}return t.prototype.push=function(t,e){if(Mt.prototype.e.call(this,t),this.v){var n=this.p.length>3?mt(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}if(e){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Mt.prototype.c.call(this,e)},t}();e.Gunzip=Dt;var Nt=function(t){this.ondata=t,ut([$,nt,function(){return[lt,Mt,Dt]}],this,0,(function(){var t=new Dt;onmessage=lt(t)}),9)};function Ot(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[$,nt,function(){return[kt]}],(function(t){return ot(kt(t.data[0]))}),3,n)}function kt(t,e){return P(t.subarray(mt(t),-8),e||new r(gt(t)))}e.AsyncGunzip=Nt,e.gunzip=Ot,e.gunzipSync=kt;var zt=function(){function t(t,e){this.c=q(),this.v=1,bt.call(this,t,e)}return t.prototype.push=function(t,e){bt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=W(t,this.o,this.v&&2,e&&4,!e);this.v&&(vt(n,this.o),this.v=0),e&&ft(n,n.length-4,this.c.d()),this.ondata(n,e)},t}();e.Zlib=zt;function Ft(t,e){e||(e={});var n=q();n.p(t);var r=W(t,e,2,4);return vt(r,e),ft(r,r.length-4,n.d()),r}e.AsyncZlib=function(t,e){ut([tt,rt,function(){return[lt,bt,zt]}],this,xt.call(this,t,e),(function(t){var e=new zt(t.data);onmessage=lt(e)}),10)},e.zlib=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[tt,rt,function(){return[Ft]}],(function(t){return ot(Ft(t.data[0],t.data[1]))}),4,n)},e.zlibSync=Ft;var Bt=function(){function t(t){this.v=1,Mt.call(this,t)}return t.prototype.push=function(t,e){if(Mt.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}if(e){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Mt.prototype.c.call(this,e)},t}();e.Unzlib=Bt;var Ut=function(t){this.ondata=t,ut([$,it,function(){return[lt,Mt,Bt]}],this,0,(function(){var t=new Bt;onmessage=lt(t)}),11)};function Vt(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return st(t,e,[$,it,function(){return[Gt]}],(function(t){return ot(Gt(t.data[0],at(t.data[1])))}),5,n)}function Gt(t,e){return P((_t(t),t.subarray(2,-4)),e)}e.AsyncUnzlib=Ut,e.unzlib=Vt,e.unzlibSync=Gt;var jt=function(){function t(t){this.G=Dt,this.I=Mt,this.Z=Bt,this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var i=this,o=function(){i.ondata.apply(i,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(o):new this.Z(o),this.s.push(this.p,e),this.p=null}}},t}();e.Decompress=jt;var Ht=function(){function t(t){this.G=Nt,this.I=Tt,this.Z=Ut,this.ondata=t}return t.prototype.push=function(t,e){jt.prototype.push.call(this,t,e)},t}();e.AsyncDecompress=Ht,e.decompress=function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?Ot(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Ct(t,e,n):Vt(t,e,n)},e.decompressSync=function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?kt(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?It(t,e):Gt(t,e)};var qt=function(t,e,n,i){for(var o in t){var a=t[o],s=e+o;a instanceof r?n[s]=[a,i]:Array.isArray(a)?n[s]=[a[0],Z(i,a[1])]:qt(a,s+"/",n,i)}},Wt="undefined"!=typeof TextEncoder&&new TextEncoder,Xt="undefined"!=typeof TextDecoder&&new TextDecoder,Zt=0;try{Xt.decode(V,{stream:!0}),Zt=1}catch(n){}var Yt=function(t){for(var e="",n=0;;){var r=t[n++],i=(r>127)+(r>223)+(r>239);if(n+i>t.length)return[e,L(t,n-1)];i?3==i?(r=((15&r)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=String.fromCharCode(1&i?(31&r)<<6|63&t[n++]:(15&r)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(r)}},Jt=function(){function t(t){this.ondata=t,Zt?this.t=new TextDecoder:this.p=V}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(e||(e=!1),this.t)return this.ondata(this.t.decode(t,{stream:!e}),e);var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var i=Yt(n),o=i[0],a=i[1];if(e&&a.length)throw"invalid utf-8 data";this.p=a,this.ondata(o,e)},t}();e.DecodeUTF8=Jt;var Kt=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";this.ondata(Qt(t),e||!1)},t}();function Qt(t,e){if(e){for(var n=new r(t.length),i=0;i>1)),s=0,l=function(t){a[s++]=t};for(i=0;ia.length){var u=new r(s+8+(o-i<<1));u.set(a),a=u}var c=t.charCodeAt(i);c<128||e?l(c):c<2048?(l(192|c>>>6),l(128|63&c)):c>55295&&c<57344?(l(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>>18),l(128|c>>>12&63),l(128|c>>>6&63),l(128|63&c)):(l(224|c>>>12),l(128|c>>>6&63),l(128|63&c))}return L(a,0,s)}function $t(t,e){if(e){for(var n="",r=0;r65535)throw"extra field too long";e+=r+4}return e},oe=function(t,e,n,r,i,o,a,s){var l=r.length,u=n.extra,c=s&&s.length,h=ie(u);ft(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(null==o&&8),t[e++]=i&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var p=new Date(null==n.mtime?Date.now():n.mtime),f=p.getFullYear()-1980;if(f<0||f>119)throw"date not in range 1980-2099";if(ft(t,e,2*(f<<24)|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,null!=o&&(ft(t,e,n.crc),ft(t,e+4,o),ft(t,e+8,n.size)),ft(t,e+12,l),ft(t,e+14,h),e+=16,null!=a&&(ft(t,e,c),ft(t,e+6,n.attrs),ft(t,e+10,a),e+=14),t.set(r,e),e+=l,h)for(var d in u){var m=u[d],g=m.length;ft(t,e,+d),ft(t,e+2,g),t.set(m,e+4),e+=4+g}return c&&(t.set(s,e),e+=c),e},ae=function(t,e,n,r,i){ft(t,e,101010256),ft(t,e+8,n),ft(t,e+10,n),ft(t,e+12,r),ft(t,e+16,i)},se=function(){function t(t){this.filename=t,this.c=H(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}();e.ZipPassThrough=se;var le=function(){function t(t,e){var n=this;e||(e={}),se.call(this,t),this.d=new bt(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=te(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){se.prototype.push.call(this,t,e)},t}();e.ZipDeflate=le;var ue=function(){function t(t,e){var n=this;e||(e={}),se.call(this,t),this.d=new wt(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=te(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){se.prototype.push.call(this,t,e)},t}();e.AsyncZipDeflate=ue;var ce=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(2&this.d)throw"stream finished";var n=Qt(t.filename),i=n.length,o=t.comment,a=o&&Qt(o),s=i!=t.filename.length||a&&o.length!=a.length,l=i+ie(t.extra)+30;if(i>65535)throw"filename too long";var u=new r(l);oe(u,0,t,n,s);var c=[u],h=function(){for(var t=0,n=c;t65535&&S("filename too long",null),E)if(g<16e4)try{S(null,St(u,d))}catch(t){S(t,null)}else h.push(Et(u,d,S));else S(null,u)},m=0;m65535)throw"filename too long";var y=h?St(u,c):u,v=y.length,_=H();_.p(u),i.push(Z(c,{size:u.length,crc:_.d(),c:y,f:S,m:d,u:p!=s.length||d&&f.length!=m,o:o,compression:h})),o+=30+p+g+v,a+=76+2*(p+g)+(m||0)+v}for(var x=new r(a+22),b=o,w=a-o,E=0;E0){var i=Math.min(this.c,t.length),o=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(o,!this.c):this.k[0].push(o),(t=t.subarray(i)).length)return this.push(t,e)}else{var a=0,s=0,l=void 0,u=void 0;this.p.length?t.length?((u=new r(this.p.length+t.length)).set(this.p),u.set(t,this.p.length)):u=this.p:u=t;for(var c=u.length,h=this.c,p=h&&this.d,f=function(){var t,e=ht(u,s);if(67324752==e){a=1,l=s,d.d=null,d.c=0;var r=ct(u,s+6),i=ct(u,s+8),o=2048&r,p=8&r,f=ct(u,s+26),m=ct(u,s+28);if(c>s+30+f+m){var g=[];d.k.unshift(g),a=2;var y=ht(u,s+18),v=ht(u,s+22),_=$t(u.subarray(s+30,s+=30+f),!o);4294967295==y?(t=p?[-2]:re(u,s),y=t[0],v=t[1]):p&&(y=-1),s+=m,d.c=y;var x={name:_,compression:i,start:function(){if(!x.ondata)throw"no callback";if(y){var t=n.o[i];if(!t)throw"unknown compression type "+i;var e=y<0?new t(_):new t(_,y,v);e.ondata=function(t,e,n){x.ondata(t,e,n)};for(var r=0,o=g;r=0&&(x.size=y,x.originalSize=v),d.onfile(x)}return"break"}if(h){if(134695760==e)return l=s+=12+(-2==h&&8),a=2,d.c=0,"break";if(33639248==e)return l=s-=4,a=2,d.c=0,"break"}},d=this;s65558)return void e("invalid zip file",null);var s=ct(t,a+8);s||e(null,{});var l=s,u=ht(t,a+16),c=4294967295==u;if(c){if(a=ht(t,a-12),101075792!=ht(t,a))return void e("invalid zip file",null);l=s=ht(t,a+32),u=ht(t,a+48)}for(var h=function(a){var l=ne(t,u,c),h=l[0],p=l[1],f=l[2],d=l[3],m=l[4],g=ee(t,l[5]);u=m;var y=function(t,n){t?(i(),e(t,null)):(o[d]=n,--s||e(null,o))};if(h)if(8==h){var v=t.subarray(g,g+p);if(p<32e4)try{y(null,It(v,new r(f)))}catch(t){y(t,null)}else n.push(Ct(v,{size:f},y))}else y("unknown compression type "+h,null);else y(null,L(t,g,g+p))},p=0;p65558)throw"invalid zip file";var i=ct(t,n+8);if(!i)return{};var o=ht(t,n+16),a=4294967295==o;if(a){if(n=ht(t,n-12),101075792!=ht(t,n))throw"invalid zip file";i=ht(t,n+32),o=ht(t,n+48)}for(var s=0;s0,o="string"==typeof i.Content&&""!==i.Content;if(e||o){const e=this.parseImage(r[t]);n[i.RelativeFilename||i.Filename]=e}}}}for(const t in e){const r=e[t];void 0!==n[r]?e[t]=n[r]:e[t]=e[t].split("\\").pop()}return e}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof e)return"data:"+i+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:i}))}}parseTextures(e){const n=new Map;if("Texture"in t.Objects){const r=t.Objects.Texture;for(const t in r){const i=this.parseTexture(r[t],e);n.set(parseInt(t),i)}}return n}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const i=t.WrapModeU,o=t.WrapModeV,a=void 0!==i?i.value:0,s=void 0!==o?o.value:0;if(n.wrapS=0===a?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=0===s?r.RepeatWrapping:r.ClampToEdgeWrapping,"Scaling"in t){const e=t.Scaling.value;n.repeat.x=e[0],n.repeat.y=e[1]}return n}loadTexture(t,n){let i;const o=this.textureLoader.path,a=e.get(t.id).children;let s;void 0!==a&&a.length>0&&void 0!==n[a[0].ID]&&(0!==(i=n[a[0].ID]).indexOf("blob:")&&0!==i.indexOf("data:")||this.textureLoader.setPath(void 0));const l=t.FileName.slice(-3).toLowerCase();if("tga"===l){const e=this.manager.getHandler(".tga");null===e?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new r.Texture):(e.setPath(this.textureLoader.path),s=e.load(i))}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new r.Texture):s=this.textureLoader.load(i);return this.textureLoader.setPath(o),s}parseMaterials(e){const n=new Map;if("Material"in t.Objects){const r=t.Objects.Material;for(const t in r){const i=this.parseMaterial(r[t],e);null!==i&&n.set(parseInt(t),i)}}return n}parseMaterial(t,n){const i=t.id,o=t.attrName;let a=t.ShadingModel;if("object"==typeof a&&(a=a.value),!e.has(i))return null;const s=this.parseParameters(t,n,i);let l;switch(a.toLowerCase()){case"phong":l=new r.MeshPhongMaterial;break;case"lambert":l=new r.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',a),l=new r.MeshPhongMaterial}return l.setValues(s),l.name=o,l}parseParameters(t,n,i){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=(new r.Color).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(o.color=(new r.Color).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=(new r.Color).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(o.emissive=(new r.Color).fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(o.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(o.opacity=parseFloat(t.Opacity.value)),o.opacity<1&&(o.transparent=!0),t.ReflectionFactor&&(o.reflectivity=t.ReflectionFactor.value),t.Shininess&&(o.shininess=t.Shininess.value),t.Specular?o.specular=(new r.Color).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(o.specular=(new r.Color).fromArray(t.SpecularColor.value));const a=this;return e.get(i).children.forEach((function(t){const e=t.relationship;switch(e){case"Bump":o.bumpMap=a.getTexture(n,t.ID);break;case"Maya|TEX_ao_map":o.aoMap=a.getTexture(n,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=a.getTexture(n,t.ID),void 0!==o.map&&(o.map.encoding=r.sRGBEncoding);break;case"DisplacementColor":o.displacementMap=a.getTexture(n,t.ID);break;case"EmissiveColor":o.emissiveMap=a.getTexture(n,t.ID),void 0!==o.emissiveMap&&(o.emissiveMap.encoding=r.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=a.getTexture(n,t.ID);break;case"ReflectionColor":o.envMap=a.getTexture(n,t.ID),void 0!==o.envMap&&(o.envMap.mapping=r.EquirectangularReflectionMapping,o.envMap.encoding=r.sRGBEncoding);break;case"SpecularColor":o.specularMap=a.getTexture(n,t.ID),void 0!==o.specularMap&&(o.specularMap.encoding=r.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=a.getTexture(n,t.ID),o.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",e)}})),o}getTexture(n,r){return"LayeredTexture"in t.Objects&&r in t.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),r=e.get(r).children[0].ID),n.get(r)}parseDeformers(){const n={},r={};if("Deformer"in t.Objects){const i=t.Objects.Deformer;for(const t in i){const o=i[t],a=e.get(parseInt(t));if("Skin"===o.attrType){const e=this.parseSkeleton(a,i);e.ID=t,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=a.parents[0].ID,n[t]=e}else if("BlendShape"===o.attrType){const e={id:t};e.rawTargets=this.parseMorphTargets(a,i),e.id=t,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),r[t]=e}}}return{skeletons:n,morphTargets:r}}parseSkeleton(t,e){const n=[];return t.children.forEach((function(t){const i=e[t.ID];if("Cluster"!==i.attrType)return;const o={ID:t.ID,indices:[],weights:[],transformLink:(new r.Matrix4).fromArray(i.TransformLink.a)};"Indexes"in i&&(o.indices=i.Indexes.a,o.weights=i.Weights.a),n.push(o)})),{rawBones:n,bones:[]}}parseMorphTargets(t,n){const r=[];for(let i=0;i1?a=s:s.length>0?a=s[0]:(a=new r.MeshPhongMaterial({color:13421772}),s.push(a)),"color"in o.attributes&&s.forEach((function(t){t.vertexColors=!0})),o.FBX_Deformer?(i=new r.SkinnedMesh(o,a)).normalizeSkinWeights():i=new r.Mesh(o,a),i}createCurve(t,e){const n=t.children.reduce((function(t,n){return e.has(n.ID)&&(t=e.get(n.ID)),t}),null),i=new r.LineBasicMaterial({color:3342591,linewidth:1});return new r.Line(n,i)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?v(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(i,o){"LookAtProperty"in o&&e.get(i.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const o=t.Objects.Model[e.ID];if("Lcl_Translation"in o){const t=o.Lcl_Translation.value;void 0!==i.target?(i.target.position.fromArray(t),n.add(i.target)):i.lookAt((new r.Vector3).fromArray(t))}}}))}bindSkeleton(t,n,i){const o=this.parsePoseNodes();for(const a in t){const s=t[a];e.get(parseInt(s.ID)).parents.forEach((function(t){if(n.has(t.ID)){const n=t.ID;e.get(n).parents.forEach((function(t){i.has(t.ID)&&i.get(t.ID).bind(new r.Skeleton(s.bones),o[t.ID])}))}}))}}parsePoseNodes(){const e={};if("Pose"in t.Objects){const n=t.Objects.Pose;for(const t in n)if("BindPose"===n[t].attrType){const i=n[t].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new r.Matrix4).fromArray(t.Matrix.a)})):e[i.Node]=(new r.Matrix4).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in t&&"AmbientColor"in t.GlobalSettings){const e=t.GlobalSettings.AmbientColor.value,i=e[0],o=e[1],a=e[2];if(0!==i||0!==o||0!==a){const t=new r.Color(i,o,a);n.add(new r.AmbientLight(t,1))}}}}class o{parse(n){const r=new Map;if("Geometry"in t.Objects){const i=t.Objects.Geometry;for(const t in i){const o=e.get(parseInt(t)),a=this.parseGeometry(o,i[t],n);r.set(parseInt(t),a)}}return r}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(e,n,r){const i=r.skeletons,o=[],a=e.parents.map((function(e){return t.Objects.Model[e.ID]}));if(0===a.length)return;const s=e.children.reduce((function(t,e){return void 0!==i[e.ID]&&(t=i[e.ID]),t}),null);e.children.forEach((function(t){void 0!==r.morphTargets[t.ID]&&o.push(r.morphTargets[t.ID])}));const l=a[0],u={};"RotationOrder"in l&&(u.eulerOrder=v(l.RotationOrder.value)),"InheritType"in l&&(u.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(u.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(u.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(u.scale=l.GeometricScaling.value);const c=y(u);return this.genGeometry(n,s,o,c)}genGeometry(t,e,n,i){const o=new r.BufferGeometry;t.attrName&&(o.name=t.attrName);const a=this.parseGeoNode(t,e),s=this.genBuffers(a),l=new r.Float32BufferAttribute(s.vertex,3);if(l.applyMatrix4(i),o.setAttribute("position",l),s.colors.length>0&&o.setAttribute("color",new r.Float32BufferAttribute(s.colors,3)),e&&(o.setAttribute("skinIndex",new r.Uint16BufferAttribute(s.weightsIndices,4)),o.setAttribute("skinWeight",new r.Float32BufferAttribute(s.vertexWeights,4)),o.FBX_Deformer=e),s.normal.length>0){const t=(new r.Matrix3).getNormalMatrix(i),e=new r.Float32BufferAttribute(s.normal,3);e.applyNormalMatrix(t),o.setAttribute("normal",e)}if(s.uvs.forEach((function(t,e){let n="uv"+(e+1).toString();0===e&&(n="uv"),o.setAttribute(n,new r.Float32BufferAttribute(s.uvs[e],2))})),a.material&&"AllSame"!==a.material.mappingType){let t=s.materialIndex[0],e=0;if(s.materialIndex.forEach((function(n,r){n!==t&&(o.addGroup(e,r-e,t),t=n,e=r)})),o.groups.length>0){const e=o.groups[o.groups.length-1],n=e.start+e.count;n!==s.materialIndex.length&&o.addGroup(n,s.materialIndex.length-n,t)}0===o.groups.length&&o.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(o,t,n,i),o}parseGeoNode(t,e){const n={};if(n.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],n.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return n.weightTable={},null!==e&&(n.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:e,weight:t.weights[i]})}))}))),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,o=[],a=[],s=[],l=[],u=[],c=[];const h=this;return t.vertexIndices.forEach((function(p,f){let m,g=!1;p<0&&(p^=-1,g=!0);let y=[],v=[];if(o.push(3*p,3*p+1,3*p+2),t.color){const e=d(f,n,p,t.color);s.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[p]&&t.weightTable[p].forEach((function(t){v.push(t.weight),y.push(t.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(n,r){let i=n,o=y[r];e.forEach((function(e,n,r){if(i>e){r[n]=i,i=e;const a=t[n];t[n]=o,o=a}}))})),y=t,v=e}for(;v.length<4;)v.push(0),y.push(0);for(let t=0;t<4;++t)u.push(v[t]),c.push(y[t])}if(t.normal){const e=d(f,n,p,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(m=d(f,n,p,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=d(f,n,p,t);void 0===l[e]&&(l[e]=[]),l[e].push(r[0]),l[e].push(r[1])})),r++,g&&(h.genFace(e,t,o,m,a,s,l,u,c,r),n++,r=0,o=[],a=[],s=[],l=[],u=[],c=[])})),e}genFace(t,e,n,r,i,o,a,s,l,u){for(let c=2;c1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=n.get(o[0].ID);i[t]={name:r[t].attrName,layer:a}}return i}addClip(t){let e=[];const n=this;return t.layer.forEach((function(t){e=e.concat(n.generateTracks(t))})),new r.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new r.Vector3,i=new r.Quaternion,o=new r.Vector3;if(t.transform&&t.transform.decompose(n,i,o),n=n.toArray(),i=(new r.Euler).setFromQuaternion(i,t.eulerOrder).toArray(),o=o.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const r=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");void 0!==r&&e.push(r)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const n=this.generateRotationTrack(t.modelName,t.R.curves,i,t.preRotation,t.postRotation,t.eulerOrder);void 0!==n&&e.push(n)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const n=this.generateVectorTrack(t.modelName,t.S.curves,o,"scale");void 0!==n&&e.push(n)}if(void 0!==t.DeformPercent){const n=this.generateMorphTrack(t);void 0!==n&&e.push(n)}return e}generateVectorTrack(t,e,n,i){const o=this.getTimesForAllAxes(e),a=this.getKeyframeTrackValues(o,e,n);return new r.VectorKeyframeTrack(t+"."+i,o,a)}generateRotationTrack(t,e,n,i,o,a){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(r.MathUtils.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(r.MathUtils.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(r.MathUtils.degToRad));const s=this.getTimesForAllAxes(e),l=this.getKeyframeTrackValues(s,e,n);void 0!==i&&((i=i.map(r.MathUtils.degToRad)).push(a),i=(new r.Euler).fromArray(i),i=(new r.Quaternion).setFromEuler(i)),void 0!==o&&((o=o.map(r.MathUtils.degToRad)).push(a),o=(new r.Euler).fromArray(o),o=(new r.Quaternion).setFromEuler(o).invert());const u=new r.Quaternion,c=new r.Euler,h=[];for(let t=0;t1){let t=1,n=e[0];for(let r=1;r=180){const o=i/180,a=r/o;let s=n+a;const l=t.times[e-1],u=(t.times[e]-l)/o;let c=l+u;const h=[],p=[];for(;c1&&(n=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:n,type:r}}parseNodeProperty(t,e,n){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),i=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===r){const t=i.split(",").slice(1),e=parseInt(t[0]),n=parseInt(t[1]);let a=i.split(",").slice(3);r="connections",function(t,e){for(let n=0,r=t.length,i=e.length;n=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},r=e>=7500?t.getUint64():t.getUint32(),i=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const o=t.getUint8(),a=t.getString(o);if(0===r)return null;const s=[];for(let e=0;e0?s[0]:"",u=s.length>1?s[1]:"",c=s.length>2?s[2]:"";for(n.singleProperty=1===i&&t.getOffset()===r;r>t.getOffset();){const r=this.parseNode(t,e);null!==r&&this.parseSubNode(a,n,r)}return n.propertyList=s,"number"==typeof l&&(n.id=l),""!==u&&(n.attrName=u),""!==c&&(n.attrType=c),""!==a&&(n.name=a),n}parseSubNode(t,e,n){if(!0===n.singleProperty){const t=n.propertyList[0];Array.isArray(t)?(e[n.name]=n,n.a=t):e[n.name]=t}else if("Connections"===t&&"C"===n.name){const t=[];n.propertyList.forEach((function(e,n){0!==n&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===n.name)Object.keys(n).forEach((function(t){e[t]=n[t]}));else if("Properties70"===t&&"P"===n.name){let t=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],o=n.propertyList[3];let a;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),a="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],e[t]={type:r,type2:i,flag:o,value:a}}else void 0===e[n.name]?"number"==typeof n.id?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:"PoseNode"===n.name?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):void 0===e[n.name][n.id]&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),i=t.getUint32(),o=t.getUint32();if(0===i)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}void 0===X&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=X.unzlibSync(new Uint8Array(t.getArrayBuffer(o))),s=new u(a.buffer);switch(e){case"b":case"c":return s.getBooleanArray(r);case"d":return s.getFloat64Array(r);case"f":return s.getFloat32Array(r);case"i":return s.getInt32Array(r);case"l":return s.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class u{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(t){const e=[];for(let n=0;n=0&&(e=e.slice(0,n)),r.LoaderUtils.decodeText(new Uint8Array(e))}}class c{add(t,e){this[t]=e}}function h(t){const e=t.match(/FBXVersion: (\d+)/);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function p(t){return t/46186158e3}const f=[];function d(t,e,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=t;break;case"ByPolygon":i=e;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const o=i*r.dataSize,a=o+r.dataSize;return function(t,e,n,r){for(let i=n,o=0;i=e.length&&e===x(t,0,e.length)}(e))t=(new l).parse(e);else{const n=x(e);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(e){const r=t[e-1];return t=t.slice(n+e),n++,r}for(let t=0;t=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,o,a)}}class g{constructor(t){this.parser=t,this.name="EXT_texture_webp",this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,i=r.textures[t];if(!i.extensions||!i.extensions[e])return null;const o=i.extensions[e],a=r.images[o.source];let s=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(s=t)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(t,a,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class y{constructor(t){this.name="EXT_meshopt_compression",this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],r=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(e){const n=t.byteOffset||0,r=t.byteLength||0,o=t.count,a=t.byteStride,s=new ArrayBuffer(o*a),l=new Uint8Array(e[0],n,r);return i.decodeGltfBuffer(new Uint8Array(s),o,a,l,t.mode,t.filter),s}))}return null}}class v{constructor(t){this.name=e,this.content=null,this.body=null;const n=new DataView(t,0,12);if(this.header={magic:r.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},"glTF"!==this.header.magic)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,o=new DataView(t,12);let a=0;for(;a",e).replace("#include ",n).replace("#include ",i).replace("#include ",o).replace("#include ",a)},Object.defineProperties(this,{specular:{get:function(){return s.specular.value},set:function(t){s.specular.value=t}},specularMap:{get:function(){return s.specularMap.value},set:function(t){s.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(t){s.glossiness.value=t}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(t){s.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class w{constructor(){this.name=i,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return b}extendParams(t,e,n){const i=e.extensions[this.name];t.color=new r.Color(1,1,1),t.opacity=1;const o=[];if(Array.isArray(i.diffuseFactor)){const e=i.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==i.diffuseTexture&&o.push(n.assignTexture(t,"map",i.diffuseTexture)),t.emissive=new r.Color(0,0,0),t.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,t.specular=new r.Color(1,1,1),Array.isArray(i.specularFactor)&&t.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const e=i.specularGlossinessTexture;o.push(n.assignTexture(t,"glossinessMap",e)),o.push(n.assignTexture(t,"specularMap",e))}return Promise.all(o)}createMaterial(t){const e=new b(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=r.TangentSpaceNormalMap,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class E{constructor(){this.name=s}}class S extends r.Interpolant{constructor(t,e,n,r){super(t,e,n,r)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r*3+r;for(let t=0;t!==r;t++)e[t]=n[i+t];return e}}S.prototype.beforeStart_=S.prototype.copySampleValue_,S.prototype.afterEnd_=S.prototype.copySampleValue_,S.prototype.interpolate_=function(t,e,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,u=r-e,c=(n-e)/u,h=c*c,p=h*c,f=t*l,d=f-l,m=-2*p+3*h,g=p-h,y=1-m,v=g-h+c;for(let t=0;t!==a;t++){const e=o[d+t+a],n=o[d+t+s]*u,r=o[f+t+a],l=o[f+t]*u;i[t]=y*e+v*n+m*r+g*l}return i};const M=new r.Quaternion;class T extends S{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return M.fromArray(i).normalize().toArray(i),i}}const C={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},I={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipmapNearestFilter,9985:r.LinearMipmapNearestFilter,9986:r.NearestMipmapLinearFilter,9987:r.LinearMipmapLinearFilter},A={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},L={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},P={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},R={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},D={CUBICSPLINE:void 0,LINEAR:r.InterpolateLinear,STEP:r.InterpolateDiscrete};function N(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}function O(t,e,n){for(const r in n.extensions)void 0===t[r]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=n.extensions[r])}function k(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function z(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,r=e.weights.length;n=2&&d.setY(e,h[t*a+1]),a>=3&&d.setZ(e,h[t*a+2]),a>=4&&d.setW(e,h[t*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return d}))}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t],i=e.images[r.source];let o=this.textureLoader;if(i.uri){const t=n.manager.getHandler(i.uri);null!==t&&(o=t)}return this.loadTextureImage(t,i,o)}loadTextureImage(t,e,n){const i=this,o=this.json,a=this.options,s=o.textures[t],l=(e.uri||e.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const u=self.URL||self.webkitURL;let c=e.uri||"",h=!1,p=!0;const f=c.search(/\.jpe?g($|\?)/i)>0||0===c.search(/^data\:image\/jpeg/);if(("image/jpeg"===e.mimeType||f)&&(p=!1),void 0!==e.bufferView)c=i.getDependency("bufferView",e.bufferView).then((function(t){if("image/png"===e.mimeType){const e=new DataView(t,25,1).getUint8(0,!1);p=6===e||4===e||3===e}h=!0;const n=new Blob([t],{type:e.mimeType});return c=u.createObjectURL(n)}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const d=Promise.resolve(c).then((function(t){return new Promise((function(e,i){let o=e;!0===n.isImageBitmapLoader&&(o=function(t){const n=new r.Texture(t);n.needsUpdate=!0,e(n)}),n.load(N(t,a.path),o,void 0,i)}))})).then((function(e){!0===h&&u.revokeObjectURL(c),e.flipY=!1,s.name&&(e.name=s.name),p||(e.format=r.RGBFormat);const n=(o.samplers||{})[s.sampler]||{};return e.magFilter=I[n.magFilter]||r.LinearFilter,e.minFilter=I[n.minFilter]||r.LinearMipmapLinearFilter,e.wrapS=A[n.wrapS]||r.RepeatWrapping,e.wrapT=A[n.wrapT]||r.RepeatWrapping,i.associations.set(e,{type:"textures",index:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",c),null}));return this.textureCache[l]=d,d}assignTexture(t,e,n){const r=this;return this.getDependency("texture",n.index).then((function(i){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===e&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+e+" not yet supported."),r.extensions[a]){const t=void 0!==n.extensions?n.extensions[a]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[a].extendTexture(i,t),r.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0!==e.attributes.tangent,o=void 0!==e.attributes.color,a=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new r.PointsMaterial,r.Material.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new r.LineBasicMaterial,r.Material.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(i||o||a){let t="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),i&&(t+="vertex-tangents:"),o&&(t+="vertex-colors:"),a&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),o&&(e.vertexColors=!0),a&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n}getMaterialType(){return r.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,a=this.extensions,s=n.materials[t];let l;const u={},c=s.extensions||{},h=[];if(c[i]){const t=a[i];l=t.getMaterialType(),h.push(t.extendParams(u,s,e))}else if(c[o]){const t=a[o];l=t.getMaterialType(),h.push(t.extendParams(u,s,e))}else{const n=s.pbrMetallicRoughness||{};if(u.color=new r.Color(1,1,1),u.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;u.color.fromArray(t),u.opacity=t[3]}void 0!==n.baseColorTexture&&h.push(e.assignTexture(u,"map",n.baseColorTexture)),u.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,u.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(h.push(e.assignTexture(u,"metalnessMap",n.metallicRoughnessTexture)),h.push(e.assignTexture(u,"roughnessMap",n.metallicRoughnessTexture))),l=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),h.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,u)}))))}!0===s.doubleSided&&(u.side=r.DoubleSide);const p=s.alphaMode||"OPAQUE";return"BLEND"===p?(u.transparent=!0,u.depthWrite=!1):(u.format=r.RGBFormat,u.transparent=!1,"MASK"===p&&(u.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&l!==r.MeshBasicMaterial&&(h.push(e.assignTexture(u,"normalMap",s.normalTexture)),u.normalScale=new r.Vector2(1,-1),void 0!==s.normalTexture.scale&&u.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&l!==r.MeshBasicMaterial&&(h.push(e.assignTexture(u,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(u.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&l!==r.MeshBasicMaterial&&(u.emissive=(new r.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&l!==r.MeshBasicMaterial&&h.push(e.assignTexture(u,"emissiveMap",s.emissiveTexture)),Promise.all(h).then((function(){let n;return n=l===b?a[i].createMaterial(u):new l(u),s.name&&(n.name=s.name),n.map&&(n.map.encoding=r.sRGBEncoding),n.emissiveMap&&(n.emissiveMap.encoding=r.sRGBEncoding),k(n,s),e.associations.set(n,{type:"materials",index:t}),s.extensions&&O(a,n,s),n}))}createUniqueName(t){const e=r.PropertyBinding.sanitizeNodeName(t||"");let n=e;for(let t=1;this.nodeNamesUsed[n];++t)n=e+"_"+t;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const e=this,i=this.extensions,o=this.primitiveCache;function a(t){return i[n].decodePrimitive(t,e).then((function(n){return j(n,t,e)}))}const s=[];for(let i=0,l=t.length;i0&&z(p,o),p.name=e.createUniqueName(o.name||"mesh_"+t),k(p,o),h.extensions&&O(i,p,h),e.assignFinalMaterial(p),u.push(p)}if(1===u.length)return u[0];const c=new r.Group;for(let t=0,e=u.length;t1?new r.Group:1===e.length?e[0]:new r.Object3D)!==e[0])for(let t=0,n=e.length;t=2.0 are supported.")));const g=new V(m,{path:l||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});g.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===d[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}g.setExtensions(f),g.setPlugins(d),g.parse(c,h)}}}(),Y=Y=r.GLTFLoader;var J={};r.ColladaLoader=class extends r.Loader{constructor(t){super(t)}load(t,e,n,i){const o=this,a=""===o.path?r.LoaderUtils.extractUrlBase(t):o.path,s=new r.FileLoader(o.manager);s.setPath(o.path),s.setRequestHeader(o.requestHeader),s.setWithCredentials(o.withCredentials),s.load(t,(function(n){try{e(o.parse(n,a))}catch(e){i?i(e):console.error(e),o.manager.itemError(t)}}),n,i)}parse(t,e){function n(t,e){const n=[],r=t.childNodes;for(let t=0,i=r.length;t0&&e.push(new r.VectorKeyframeTrack(i+".position",o,a)),s.length>0&&e.push(new r.QuaternionKeyframeTrack(i+".quaternion",o,s)),l.length>0&&e.push(new r.VectorKeyframeTrack(i+".scale",o,l)),e}function E(t,e,n){let r,i,o,a=!0;for(i=0,o=t.length;i=0;){const r=t[e];if(null!==r.value[n])return r;e--}return null}function M(t,e,n){for(;e>>0));if("tga"===(n=n.toLowerCase()))e=qt;else e=Ht;return e}(i);if(void 0!==e){const n=e.load(i),o=t.extra;if(void 0!==o&&void 0!==o.technique&&!1===l(o.technique)){const t=o.technique;n.wrapS=t.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,n.wrapT=t.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,n.offset.set(t.offsetU||0,t.offsetV||0),n.repeat.set(t.repeatU||1,t.repeatV||1)}else n.wrapS=r.RepeatWrapping,n.wrapT=r.RepeatWrapping;return n}return console.warn("THREE.ColladaLoader: THREE.Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}a.name=t.name||"";const u=i.parameters;for(const t in u){const e=u[t];switch(t){case"diffuse":e.color&&a.color.fromArray(e.color),e.texture&&(a.map=s(e.texture));break;case"specular":e.color&&a.specular&&a.specular.fromArray(e.color),e.texture&&(a.specularMap=s(e.texture));break;case"bump":e.texture&&(a.normalMap=s(e.texture));break;case"ambient":e.texture&&(a.lightMap=s(e.texture));break;case"shininess":e.float&&a.shininess&&(a.shininess=e.float);break;case"emission":e.color&&a.emissive&&a.emissive.fromArray(e.color),e.texture&&(a.emissiveMap=s(e.texture))}}let c=u.transparent,h=u.transparency;if(void 0===h&&c&&(h={float:1}),void 0===c&&h&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&h)if(c.data.texture)a.transparent=!0;else{const t=c.data.color;switch(c.opaque){case"A_ONE":a.opacity=t[3]*h.float;break;case"RGB_ZERO":a.opacity=1-t[0]*h.float;break;case"A_ZERO":a.opacity=1-t[3]*h.float;break;case"RGB_ONE":a.opacity=t[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',c.opaque)}a.opacity<1&&(a.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(a.side=r.DoubleSide),a}function Y(t){return f(Yt.materials[t],Z)}function J(t){for(let e=0;e0?n+o:n;e.inputs[l]={id:t,offset:i},e.stride=Math.max(e.stride,i+1),"TEXCOORD"===n&&(e.hasUV=!0);break;case"vcount":e.vcount=a(r.textContent);break;case"p":e.p=a(r.textContent)}}return e}function lt(t){let e=0;for(let n=0,r=t.length;n0&&e0&&p.setAttribute("position",new r.Float32BufferAttribute(o.array,o.stride)),a.array.length>0&&p.setAttribute("normal",new r.Float32BufferAttribute(a.array,a.stride)),u.array.length>0&&p.setAttribute("color",new r.Float32BufferAttribute(u.array,u.stride)),s.array.length>0&&p.setAttribute("uv",new r.Float32BufferAttribute(s.array,s.stride)),l.array.length>0&&p.setAttribute("uv2",new r.Float32BufferAttribute(l.array,l.stride)),c.length>0&&p.setAttribute("skinIndex",new r.Float32BufferAttribute(c,4)),h.length>0&&p.setAttribute("skinWeight",new r.Float32BufferAttribute(h,4)),i.data=p,i.type=t[0].type,i.materialKeys=f,i}function ht(t,e,n,r){const i=t.p,o=t.stride,a=t.vcount;function s(t){let e=i[t+n]*u;const o=e+u;for(;e4)for(let e=1,r=n-2;e<=r;e++){const n=t+o*e,r=t+o*(e+1);s(t+0*o),s(n),s(r)}t+=o*n}}else for(let t=0,e=i.length;t=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}function yt(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;ni.limits.max||e{let i=[];switch(t.type){case"mtl":r=r.children[0];break;case"gltf":case"glb":case"dae":i=r.animations,r=r.scene;break;case"fbx":i=r.animations}r.animations=i;const o=c.types.rotation(t.rotation,[0,0,0]),a=c.types.scale(t.scale,[1,1,1]);r.rotation.set(o[0],o[1],o[2]),r.scale.set(a[0],a[1],a[2]),t.normalize&&r.traverse((function(t){if(t.isMesh){let e;"MeshStandardMaterial"==t.material.type?(t.material.metalness&&(t.material.metalness*=.1),t.material.glossiness&&(t.material.glossiness*=.25),e=new THREE.Color(12,12,12)):"MeshPhongMaterial"==t.material.type&&(t.material.shininess=.1,e=new THREE.Color(20,20,20)),t.material.specular&&t.material.specular.isColor&&(t.material.specular=e)}})),r.name="model";let s=b.prototype._makeGroup(r,t);b.prototype._addMethods(s),s.setAnchor(t.anchor),s.setCenter(t.adjustment),s.raycasted=t.raycasted,n(s),e(s),s.setFixedZoom(t.mapScale),s.idle()}),(()=>null),(e=>{console.error("Could not load model file: "+t.obj+" \n "+e.stack),n("Error loading the model")}))}),(()=>null),(t=>{console.warn("No material file found "+t.stack)}))};var rt={};function it(t){t=c._validate(t,b.prototype._defaults.line);var e=c.lnglatsToWorld(t.geometry),n=c.normalizeVertices(e),i=c.flattenVectors(n.vertices),o=new r.LineGeometry;o.setPositions(i);let a=new r.LineMaterial({color:t.color,linewidth:t.width,dashed:!1,opacity:t.opacity});return a.resolution.set(window.innerWidth,window.innerHeight),a.isMaterial=!0,a.transparent=!0,a.depthWrite=!1,(it=new r.Line2(o,a)).position.copy(n.position),it.computeLineDistances(),it}rt=rt=it,function(){const t=new r.Box3,e=new r.Vector3;class n extends r.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new r.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new r.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new r.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new r.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new r.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new r.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new r.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new r.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new r.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;if(!e.isGeometry)return e.isBufferGeometry&&this.setPositions(e.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.")}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new r.Box3);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;void 0!==e&&void 0!==n&&(this.boundingBox.setFromBufferAttribute(e),t.setFromBufferAttribute(n),this.boundingBox.union(t))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new r.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(void 0!==t&&void 0!==n){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let o=0,a=t.count;o\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\tworldStart = start.xyz;\n\t\t\tworldEnd = end.xyz;\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( position.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( position.y < 0.5 ) ? start : end;\n\t\t\t\tworldPos.xyz += offset;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segements overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\t\tvarying vec4 worldPos;\n\t\tvarying vec3 worldStart;\n\t\tvarying vec3 worldEnd;\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};class t extends r.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:r.UniformsUtils.clone(r.ShaderLib.line.uniforms),vertexShader:r.ShaderLib.line.vertexShader,fragmentShader:r.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return Boolean("USE_DASH"in this.defines)},set(t){Boolean(t)!==Boolean("USE_DASH"in this.defines)&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return Boolean("ALPHA_TO_COVERAGE"in this.defines)},set:function(t){Boolean(t)!==Boolean("ALPHA_TO_COVERAGE"in this.defines)&&(this.needsUpdate=!0),!0===t?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}t.prototype.isLineMaterial=!0,r.LineMaterial=t}(),function(){const t=new r.Vector3,e=new r.Vector3,n=new r.Vector4,i=new r.Vector4,o=new r.Vector4,a=new r.Vector3,s=new r.Matrix4,l=new r.Line3,u=new r.Vector3,c=new r.Box3,h=new r.Sphere,p=new r.Vector4;class f extends r.Mesh{constructor(t=new r.LineSegmentsGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="LineSegments2"}computeLineDistances(){const n=this.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=new Float32Array(2*i.count);for(let n=0,r=0,s=i.count;nS&&i.z>S)continue;if(n.z>S){const t=n.z-i.z,e=(n.z-S)/t;n.lerp(i,e)}else if(i.z>S){const t=i.z-n.z,e=(i.z-S)/t;i.lerp(n,e)}n.applyMatrix4(g),i.applyMatrix4(g),n.multiplyScalar(1/n.w),i.multiplyScalar(1/i.w),n.x*=x.x/2,n.y*=x.y/2,i.x*=x.x/2,i.y*=x.y/2,l.start.copy(n),l.start.z=0,l.end.copy(i),l.end.z=0;const o=l.closestPointToPointParameter(a,!0);l.at(o,u);const c=r.MathUtils.lerp(n.z,i.z,o),h=c>=-1&&c<=1,p=a.distanceTo(u)<.5*b;if(h&&p){l.start.fromBufferAttribute(w,t),l.end.fromBufferAttribute(E,t),l.start.applyMatrix4(y),l.end.applyMatrix4(y);const n=new r.Vector3,i=new r.Vector3;d.distanceSqToSegment(l.start,l.end,i,n),e.push({point:i,pointOnLine:n,distance:d.origin.distanceTo(i),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}}f.prototype.LineSegments2=!0,r.LineSegments2=f}(),function(){class t extends r.LineSegments2{constructor(t=new r.LineGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Line2"}}t.prototype.isLine2=!0,r.Line2=t}(),function(){const t=new r.Vector3,e=new r.Vector3;class n extends r.Mesh{constructor(t=new r.LineSegmentsGeometry,e=new r.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Wireframe"}computeLineDistances(){const n=this.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=new Float32Array(2*i.count);for(let n=0,r=0,s=i.count;n{n.push(new r.Vector3(t[0],t[1],t[2]))}));const i=new r.CatmullRomCurve3(n);let o=new r.TubeGeometry(i,n.length,t.radius,t.sides,!1),a=m(t),s=new r.Mesh(o,a);return new S({obj:s,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})};var at={};at=at=function(t){this.map=t,this.renderer=new x.CSS2DRenderer,this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.domElement.style.position="absolute",this.renderer.domElement.id="labelCanvas",this.renderer.domElement.style.top=0,this.renderer.domElement.style.zIndex="0",this.map.getCanvasContainer().appendChild(this.renderer.domElement),this.scene,this.camera,this.dispose=function(){this.map.getCanvasContainer().removeChild(this.renderer.domElement),this.renderer.domElement.remove(),this.renderer={}},this.setSize=function(t,e){this.renderer.setSize(t,e)},this.map.on("resize",function(){this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight)}.bind(this)),this.state={reset:function(){}},this.render=async function(t,e){return this.scene=t,this.camera=e,new Promise((n=>{n(this.renderer.render(t,e))}))},this.toggleLabels=async function(t,e){return new Promise((n=>{n(this.setVisibility(t,e,this.scene,this.camera,this.renderer))}))},this.setVisibility=function(t,e,n,r,i){this.renderer.cacheList.forEach((function(o){o.visible!=e&&o.layer===t&&(e&&o.alwaysVisible||!e)&&(o.visible=e,i.renderObject(o,n,r))}))}};var st={};st=st=class{constructor(t,e){this.id=t.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=t.buildingsLayerId,this.minAltitude=t.minAltitude||.1,this.tb=e}onAdd(t,e){this.map=t;const n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,"\n\t\t\tuniform mat4 u_matrix;\n\t\t\tuniform float u_height_factor;\n\t\t\tuniform float u_altitude;\n\t\t\tuniform float u_azimuth;\n\t\t\tattribute vec2 a_pos;\n\t\t\tattribute vec4 a_normal_ed;\n\t\t\tattribute lowp vec2 a_base;\n\t\t\tattribute lowp vec2 a_height;\n\t\t\tvoid main() {\n\t\t\t\tfloat base = max(0.0, a_base.x);\n\t\t\t\tfloat height = max(0.0, a_height.x);\n\t\t\t\tfloat t = mod(a_normal_ed.x, 2.0);\n\t\t\t\tvec4 pos = vec4(a_pos, t > 0.0 ? height : base, 1);\n\t\t\t\tfloat len = pos.z * u_height_factor / tan(u_altitude);\n\t\t\t\tpos.x += cos(u_azimuth) * len;\n\t\t\t\tpos.y += sin(u_azimuth) * len;\n\t\t\t\tpos.z = 0.0;\n\t\t\t\tgl_Position = u_matrix * pos;\n\t\t\t}\n\t\t\t"),e.compileShader(n);const r=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(r,"\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.7);\n\t\t\t}\n\t\t\t"),e.compileShader(r),this.program=e.createProgram(),e.attachShader(this.program,n),e.attachShader(this.program,r),e.linkProgram(this.program),e.validateProgram(this.program),this.uMatrix=e.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=e.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=e.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=e.getUniformLocation(this.program,"u_azimuth"),this.aPos=e.getAttribLocation(this.program,"a_pos"),this.aNormal=e.getAttribLocation(this.program,"a_normal_ed"),this.aBase=e.getAttribLocation(this.program,"a_base"),this.aHeight=e.getAttribLocation(this.program,"a_height")}render(t,e){t.useProgram(this.program);const n=this.map.style.sourceCaches.composite,r=n.getVisibleCoordinates().reverse(),i=this.map.getLayer(this.buildingsLayerId),o=this.map.painter.context,{lng:a,lat:s}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[a,s]);t.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),t.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.getExtension("EXT_blend_minmax"),t.disable(t.DEPTH_TEST);for(const e of r){const r=n.getTile(e),a=r.getBucket(i);if(!a)continue;const[s,l]=a.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;t.uniformMatrix4fv(this.uMatrix,!1,e.posMatrix),t.uniform1f(this.uHeightFactor,Math.pow(2,e.overscaledZ)/r.tileSize/8);for(const e of a.segments.get()){const n=o.currentNumAttributes||0,r=2;for(let e=r;e{this.tb.setObjectsScale()})),this.tb.options.sky&&(this.tb.sky=!0),this.tb.options.terrain&&(this.tb.terrain=!0),["satellite","mapbox-mapbox-satellite","satelliteLayer"].forEach((t=>{this.getLayer(t)&&(this.tb.terrainLayerName=t)}))})),this.map.on("load",(function(){let e;this.selectedObject,this.selectedFeature,this.draggedObject,this.overedObject,this.overedFeature;let n,r=this.getCanvasContainer();this.getCanvasContainer().style.cursor=this.tb.defaultCursor;let i,o,a,s,l=[];function u(t){var e=r.getBoundingClientRect();return{x:t.originalEvent.clientX-e.left-r.clientLeft,y:t.originalEvent.clientY-e.top-r.clientTop}}this.unselectObject=function(){this.selectedObject.selected=!1,this.selectedObject=null},this.outObject=function(){this.overedObject.over=!1,this.overedObject=null},this.unselectFeature=function(t){void 0!==t.id&&(this.setFeatureState({source:t.source,sourceLayer:t.sourceLayer,id:t.id},{select:!1}),this.removeTooltip(t),(t=this.queryRenderedFeatures({layers:[t.layer.id],filter:["==",["id"],t.id]})[0])&&this.fire("SelectedFeatureChange",{detail:t}),this.selectedFeature=null)},this.selectFeature=function(t){this.selectedFeature=t,this.setFeatureState({source:this.selectedFeature.source,sourceLayer:this.selectedFeature.sourceLayer,id:this.selectedFeature.id},{select:!0}),this.selectedFeature=this.queryRenderedFeatures({layers:[this.selectedFeature.layer.id],filter:["==",["id"],this.selectedFeature.id]})[0],this.addTooltip(this.selectedFeature),this.fire("SelectedFeatureChange",{detail:this.selectedFeature})},this.outFeature=function(e){this.overedFeature&&void 0!==this.overedFeature&&this.overedFeature.id!=e&&(t.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!1}),this.removeTooltip(this.overedFeature),this.overedFeature=null)},this.addTooltip=function(t){if(!this.tb.enableTooltips)return;let e=this.tb.getFeatureCenter(t),n=this.tb.tooltip({text:t.properties.name||t.id||t.type,mapboxStyle:!0,feature:t});n.setCoords(e),this.tb.add(n,t.layer.id),t.tooltip=n,t.tooltip.tooltip.visible=!0},this.removeTooltip=function(t){t.tooltip&&(t.tooltip.visibility=!1,this.tb.remove(t.tooltip),t.tooltip=null)},t.onContextMenu=function(t){alert("contextMenu")},this.onClick=function(e){let n,r=[];if(t.tb.enableSelectingObjects&&(r=this.tb.queryRenderedFeatures(e.point)),n="object"==typeof r[0]){let t=ut.prototype.findParent3DObject(r[0]);if(t){if(this.selectedFeature&&this.unselectFeature(this.selectedFeature),this.selectedObject){if(this.selectedObject.uuid!=t.uuid)this.selectedObject.selected=!1,t.selected=!0,this.selectedObject=t;else if(this.selectedObject.uuid==t.uuid)return void this.unselectObject()}else this.selectedObject=t,this.selectedObject.selected=!0;this.selectedObject.dispatchEvent({type:"Wireframed",detail:this.selectedObject}),this.selectedObject.dispatchEvent({type:"IsPlayingChanged",detail:this.selectedObject}),this.repaint=!0,e.preventDefault()}}else{let n=[];if(t.tb.enableSelectingFeatures&&(n=this.queryRenderedFeatures(e.point)),n.length>0&&"fill-extrusion"==n[0].layer.type&&void 0!==n[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=n[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(n[0]);else if(this.selectedFeature.id==n[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(n[0])}},this.onMouseMove=function(r){let l,c=u(r);if(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,r.originalEvent.altKey&&this.draggedObject){if(!t.tb.enableRotatingObjects)return;e="rotate",this.getCanvasContainer().style.cursor="move",Math.min(n.x,c.x),Math.max(n.x,c.x),Math.min(n.y,c.y),Math.max(n.y,c.y);let r={x:0,y:0,z:Math.round(s[2]+~~((c.x-n.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(r),void this.draggedObject.addHelp("rot: "+r.z+"°")}if(r.originalEvent.shiftKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="translate",this.getCanvasContainer().style.cursor="move";let n=r.lngLat,a=[Number((n.lng+i).toFixed(this.tb.gridStep)),Number((n.lat+o).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(a),void this.draggedObject.addHelp("lng: "+a[0]+"°, lat: "+a[1]+"°")}if(r.originalEvent.ctrlKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="altitude",this.getCanvasContainer().style.cursor="move";let n=r.point.y*this.tb.altitudeStep,i=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-n-a).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(i),void this.draggedObject.addHelp("alt: "+i[2]+"m")}let h=[];if(t.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(r.point)),l="object"==typeof h[0]){let t=ut.prototype.findParent3DObject(h[0]);t&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&t.uuid==this.selectedObject.uuid?this.selectedObject&&t.uuid==this.selectedObject.uuid&&(t.over=!0,this.overedObject=t):(this.overedObject&&this.overedObject.uuid!=t.uuid&&this.outObject(),t.over=!0,this.overedObject=t),this.repaint=!0,r.preventDefault())}else{this.overedObject&&this.outObject();let e=[];t.tb.enableSelectingFeatures&&(e=this.queryRenderedFeatures(r.point)),e.length>0&&(this.outFeature(e[0]),"fill-extrusion"==e[0].layer.type&&void 0!==e[0].id&&(this.selectedFeature&&this.selectedFeature.id==e[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=e[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=t.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(e){(e.originalEvent.shiftKey||e.originalEvent.altKey||e.originalEvent.ctrlKey)&&0===e.originalEvent.button&&this.selectedObject&&(t.tb.enableDraggingObjects||t.tb.enableRotatingObjects)&&(e.preventDefault(),t.getCanvasContainer().style.cursor="move",t.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,n=u(e),l=this.draggedObject.coordinates,s=c.degreeify(this.draggedObject.rotation),i=l[0]-e.lngLat.lng,o=l[1]-e.lngLat.lat,a=-this.draggedObject.modelHeight-e.point.y*this.tb.altitudeStep)},this.onMouseUp=function(t){this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.off("mouseup",this.onMouseUp),this.off("mouseout",this.onMouseUp),this.dragPan.enable(),this.draggedObject&&(this.draggedObject.dispatchEvent({type:"ObjectDragged",detail:{draggedObject:this.draggedObject,draggedAction:e}}),this.draggedObject.removeHelp(),this.draggedObject=null,e=null)},this.onMouseOut=function(t){if(this.overedFeature){let e=this.queryRenderedFeatures(t.point);e.length>0&&this.overedFeature.id!=e[0].id&&(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,this.outFeature(e[0]))}},this.onZoom=function(t){this.tb.zoomLayers.forEach((t=>{this.tb.toggleLayer(t)})),this.tb.setObjectsScale()};let h=!1,p=!1;this.on("click",this.onClick),this.on("mousemove",this.onMouseMove),this.on("mouseout",this.onMouseOut),this.on("mousedown",this.onMouseDown),this.on("zoom",this.onZoom),this.on("zoomend",this.onZoom),document.addEventListener("keydown",function(t){17!==t.which&&91!==t.which||(h=!0),16===t.which&&(p=!0);let e=this.selectedObject;if(p&&83===t.which&&e){let t=c.toDecimal;if(e.help)e.removeHelp();else{let n=e.modelSize,r=1;"meters"!==e.userData.units&&((r=c.projectedUnitsPerMeter(e.coordinates[1]))||(r=1),r=t(r,7)),e.addHelp("size(m): "+t(n.x/r,3)+" W, "+t(n.y/r,3)+" L, "+t(n.z/r,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(t){17!=t.which&&91!=t.which||(h=!1),16===t.which&&(p=!1)}.bind(this))}))},get sky(){return this.options.sky},set sky(t){t?this.createSkyLayer():this.removeLayer(this.skyLayerName),this.options.sky=t},get terrain(){return this.options.terrain},set terrain(t){if(this.terrainLayerName="",t)this.createTerrainLayer();else{if(this.mapboxVersion<2)return void console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0");this.map.getTerrain()&&(this.map.setTerrain(null),this.map.removeSource(this.terrainSourceName))}this.options.terrain=t},get fov(){return this.options.fov},set fov(t){this.camera instanceof r.PerspectiveCamera&&this.options.fov!==t&&(this.map.transform.fov=t,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=t)},get orthographic(){return this.options.orthographic},set orthographic(t){const e=this.map.getCanvas().clientHeight,n=this.map.getCanvas().clientWidth;t?(this.map.transform.fov=0,this.camera=new r.OrthographicCamera(n/-2,n/2,e/2,e/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new r.PerspectiveCamera(this.map.transform.fov,n/e,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new p(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=t},createSkyLayer:function(){if(this.mapboxVersion<2)return console.warn("Sky layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.sky=!1);this.map.getLayer(this.skyLayerName)||(this.map.addLayer({id:this.skyLayerName,type:"sky",paint:{"sky-opacity":["interpolate",["linear"],["zoom"],0,0,5,.3,8,1],"sky-type":"atmosphere","sky-atmosphere-sun":this.getSunSky(this.lightDateTime),"sky-atmosphere-sun-intensity":10}}),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()})))},createTerrainLayer:function(){if(this.mapboxVersion<2)return console.warn("Terrain layer are only supported by Mapbox-gl-js > v2.0"),void(this.options.terrain=!1);this.map.getTerrain()||(this.map.addSource(this.terrainSourceName,{type:"raster-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1",tileSize:512,maxzoom:14}),this.map.setTerrain({source:this.terrainSourceName,exaggeration:this.terrainExaggeration}),this.map.once("idle",(()=>{this.cameraSync.updateCamera(),this.repaint()})))},sphere:function(t){return this.setDefaultView(t,this.options),M(t,this.world)},line:rt,label:I,tooltip:A,tube:function(t){return this.setDefaultView(t,this.options),ot(t,this.world)},extrusion:function(t){return this.setDefaultView(t,this.options),T(t)},Object3D:function(t){return this.setDefaultView(t,this.options),S(t)},loadObj:async function(t,e){if(this.setDefaultView(t,this.options),!1===t.clone)return new Promise((async n=>{K(t,e,(async t=>{n(t)}))}));{let n=this.objectsCache.get(t.obj);n?n.promise.then((n=>{e(n.duplicate(t))})).catch((e=>{this.objectsCache.delete(t.obj),console.error("Could not load model file: "+t.obj)})):this.objectsCache.set(t.obj,{promise:new Promise((async(n,r)=>{K(t,e,(async t=>{t.duplicate?n(t.duplicate()):r(t)}))}))})}},material:function(t){return m(t)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:c,SunCalc:d,Constants:i,projectToWorld:function(t){return this.utils.projectToWorld(t)},unprojectFromWorld:function(t){return this.utils.unprojectFromWorld(t)},projectedUnitsPerMeter:function(t){return this.utils.projectedUnitsPerMeter(t)},getFeatureCenter:function(t,e,n){return c.getFeatureCenter(t,e,n)},getObjectHeightOnFloor:function(t,e,n){return c.getObjectHeightOnFloor(t,e,n)},queryRenderedFeatures:function(t){let e=new r.Vector2;return e.x=t.x/this.map.transform.width*2-1,e.y=1-t.y/this.map.transform.height*2,this.raycaster.setFromCamera(e,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(t){var e;return t.object.traverseAncestors((function(t){t.parent&&"Group"==t.parent.type&&t.userData.obj&&(e=t)})),e},setLayoutProperty:function(t,e,n){this.map.setLayoutProperty(t,e,n),null!=n&&"visibility"===e&&this.world.children.filter((e=>e.layer===t)).forEach((t=>{t.visibility=n}))},setLayerZoomRange:function(t,e,n){this.map.getLayer(t)&&(this.map.setLayerZoomRange(t,e,n),this.zoomLayers.includes(t)||this.zoomLayers.push(t),this.toggleLayer(t))},setLayerHeigthProperty:function(t,e){let n=this.map.getLayer(t);if(n)if("fill-extrusion"==n.type){let t=this.map.getStyle().sources[n.source].data;t.features.forEach((function(t){t.properties.level=e})),this.map.getSource(n.source).setData(t)}else"custom"==n.type&&this.world.children.forEach((function(n){let r=n.userData.feature;if(r&&r.layer===t){let t=this.tb.getFeatureCenter(r,n,e);n.setCoords(t)}}))},setObjectsScale:function(){this.world.children.filter((t=>null!=t.fixedZoom)).forEach((t=>{t.setObjectScale(this.map.transform.scale)}))},setStyle:function(t,e){this.clear().then((()=>{this.map.setStyle(t,e)}))},toggleLayer:function(t,e=!0){let n=this.map.getLayer(t);if(n){if(!e)return void this.toggle(n.id,!1);let t=this.map.getZoom();if(n.minzoom&&t=n.maxzoom)return void this.toggle(n.id,!1);this.toggle(n.id,!0)}},toggle:function(t,e){this.setLayoutProperty(t,"visibility",e?"visible":"none"),this.labelRenderer.toggleLabels(t,e)},update:function(){this.map.repaint&&(this.map.repaint=!1);var t=Date.now();this.objects.animationManager.update(t),this.updateLightHelper(),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this.labelRenderer.render(this.scene,this.camera),!1===this.options.passiveRendering&&this.map.triggerRepaint()},add:function(t,e,n){if(!this.enableTooltips&&t.tooltip&&(t.tooltip.visibility=!1),this.world.add(t),e){t.layer=e,t.source=n;let r=this.map.getLayer(e);if(r){let e=r.visibility,n=void 0===e;t.visibility=!(!n&&"visible"!==e)}}},removeByName:function(t){let e=this.world.getObjectByName(t);e&&this.remove(e)},remove:function(t){this.map.selectedObject&&t.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&t.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),t.dispose&&t.dispose(),this.world.remove(t),t=null},clear:async function(t=null,e=!1){return new Promise(((n,r)=>{let i=[];this.world.children.forEach((function(t){i.push(t)}));for(let e=0;e{t.promise.then((t=>{t.dispose(),t=null}))})),n("clear")}))},removeLayer:function(t){this.clear(t,!0).then((()=>{this.map.removeLayer(t)}))},getSunPosition:function(t,e){return d.getPosition(t||Date.now(),e[1],e[0])},getSunTimes:function(t,e){return d.getTimes(t,e[1],e[0],e[2]?e[2]:0)},setBuildingShadows:function(t){if(this.map.getLayer(t.buildingsLayerId)){let e=new st(t,this);this.map.addLayer(e,t.buildingsLayerId)}else console.warn("The layer '"+t.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(t=new Date,e){if(!this.lights.dirLight||!this.options.realSunlight)return void console.warn("To use setSunlight it's required to set realSunlight : true in Threebox initial options.");var n=new Date(t.getTime());if(e?e.lng&&e.lat?this.mapCenter=e:this.mapCenter={lng:e[0],lat:e[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===n.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=n,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(n,[this.mapCenter.lng,this.mapCenter.lat]);let r=this.sunPosition.altitude,o=Math.PI+this.sunPosition.azimuth,a=i.WORLD_SIZE/2,s=Math.sin(r),l=Math.cos(r),u=Math.cos(o)*l,c=Math.sin(o)*l;this.lights.dirLight.position.set(c,u,s),this.lights.dirLight.position.multiplyScalar(a),this.lights.dirLight.intensity=Math.max(s,0),this.lights.hemiLight.intensity=Math.max(1*s,.1),this.lights.dirLight.updateMatrixWorld(),this.updateLightHelper(),this.map.loaded()&&(this.updateSunGround(this.sunPosition),this.map.setLight({anchor:"map",position:[3,180+180*this.sunPosition.azimuth/Math.PI,90-180*this.sunPosition.altitude/Math.PI],intensity:Math.cos(this.sunPosition.altitude),color:`hsl(40, ${50*Math.cos(this.sunPosition.altitude)}%, ${Math.max(20,20+96*Math.sin(this.sunPosition.altitude))}%)`},{duration:0}),this.sky&&this.updateSunSky(this.getSunSky(n,this.sunPosition)))},getSunSky:function(t,e){if(!e){var n=this.map.getCenter();e=this.getSunPosition(t||Date.now(),[n.lng,n.lat])}return[180+180*e.azimuth/Math.PI,90-180*e.altitude/Math.PI]},updateSunSky:function(t){this.sky&&this.map.setPaintProperty(this.skyLayerName,"sky-atmosphere-sun",t)},updateSunGround:function(t){""!=this.terrainLayerName&&this.map.setPaintProperty(this.terrainLayerName,"raster-opacity",Math.max(Math.min(1,4*t.altitude),.25))},updateLightHelper:function(){this.lights.dirLightHelper&&(this.lights.dirLightHelper.position.setFromMatrixPosition(this.lights.dirLight.matrixWorld),this.lights.dirLightHelper.updateMatrix(),this.lights.dirLightHelper.update())},dispose:async function(){return console.log(this.memory()),new Promise((t=>{t(this.clear(null,!0).then((t=>(this.map.remove(),this.map={},this.scene.remove(this.world),this.world.children=[],this.world=null,this.objectsCache.clear(),this.labelRenderer.dispose(),console.log(this.memory()),this.renderer.dispose(),t))))}))},defaultLights:function(){this.lights.ambientLight=new r.AmbientLight(new r.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new r.DirectionalLight(new r.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new r.DirectionalLight(new r.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(t=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new r.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),t&&(this.lights.dirLightHelper=new r.DirectionalLightHelper(this.lights.dirLight,5),this.scene.add(this.lights.dirLightHelper)),this.lights.dirLight.castShadow=!0,this.lights.dirLight.shadow.radius=2,this.lights.dirLight.shadow.mapSize.width=8192,this.lights.dirLight.shadow.mapSize.height=8192,this.lights.dirLight.shadow.camera.top=this.lights.dirLight.shadow.camera.right=1e3,this.lights.dirLight.shadow.camera.bottom=this.lights.dirLight.shadow.camera.left=-1e3,this.lights.dirLight.shadow.camera.near=1,this.lights.dirLight.shadow.camera.visible=!0,this.lights.dirLight.shadow.camera.far=4e8,this.lights.hemiLight=new r.HemisphereLight(new r.Color(16777215),new r.Color(16777215),.6),this.lights.hemiLight.color.setHSL(.661,.96,.12),this.lights.hemiLight.groundColor.setHSL(.11,.96,.14),this.lights.hemiLight.position.set(0,0,50),this.scene.add(this.lights.hemiLight),this.setSunlight(),this.map.once("idle",(()=>{this.setSunlight(),this.repaint()}))},setDefaultView:function(t,e){t.bbox=(t.bbox||null==t.bbox)&&e.enableSelectingObjects,t.tooltip=(t.tooltip||null==t.tooltip)&&e.enableTooltips,t.mapScale=this.map.transform.scale},memory:function(){return this.renderer.info.memory},programs:function(){return this.renderer.info.programs.length},version:"2.2.6"};var ct={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,multiLayer:!1,orthographic:!1,fov:i.FOV_DEGREES,sky:!1,terrain:!1};lt=lt=ut,window.Threebox=lt,window.THREE=r}();!function(t){var e=!1,n=!1,r=!1;function i(e){let n=function(){let t=[0,0] ;return t}(),r=function(){let t=2; ;return t}();if(t(".mapster-map-submission-frontend").length){n=t(".mapster-front-submission-options").data("center");r=t(".mapster-front-submission-options").data("zoom")}let i={container:e,style:{version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{"raster-tiles":{type:"raster",tiles:["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"],tileSize:256,attribution:'© OpenStreetMap contributors'}},layers:[{id:"simple-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22}]},center:n,zoom:r} let o=new maplibregl.Map(i);o.on("load",(()=>{o.resize();C();if(S().features.length>0){var t=turf.bbox(S());o.fitBounds(t,{padding:20,maxZoom:13,duration:0})}}));return o}function o(){if("location"===E()){"circle"===g()&&n.addLayer({id:"feature",type:"circle",source:"feature"});if("label"===g()||"marker"===g()){n.addLayer({id:"feature",type:"symbol",source:"feature"});"marker"===g()&&s()}}"line"===E()&&n.addLayer({id:"feature",type:"line",source:"feature"});"polygon"===E()&&"fill"===y()&&n.addLayer({id:"feature",type:"fill",source:"feature"});"polygon"===E()&&"fill-extrusion"===y()&&n.addLayer({id:"feature",type:"fill-extrusion",source:"feature"});c()}function a(){r&&r.remove()}function s(){if("location"===E()&&"marker"===g()){a();if(S().features.length>0){var t=v().marker,e=new maplibregl.Marker(t).setLngLat(S().features[0].geometry.coordinates);e.addTo(n);r=e}}}function l(){t('.acf-field[data-name="polygon_style"]').length&&t(document).on("change",'.acf-field[data-name="polygon_style"] :input',(function(){!function(){n.getLayer("feature")&&n.removeLayer("feature");o();h()}();c()}))}function u(){t('.acf-field[data-name="location_style"]').length&&t(document).on("change",'.acf-field[data-name="location_style"] :input',(function(){!function(){a();n.getLayer("feature")&&n.removeLayer("feature");o();h()}();c()}))}function c(){var t=v();if("location"===E()&&"marker"===g())s();else if("location"===E()&&"marker"!==g()&&"3d-model"!==g()||"line"===E()||"polygon"===E()){for(var e in t.paint)n.setPaintProperty("feature",`${_()}${e}`,t.paint[e]);for(var e in t.layout)n.setLayoutProperty("feature",`${_()}${e}`,t.layout[e])}else"location"===E()&&"3d-model"===g()&&x()}function h(){var e=v();for(var n in e)for(var r in e[n])t(document).on("change",`.acf-field[data-name="${r}"] :input`,(function(){c()}));if("line"===E()){["dashed_line","dash_length","gap_length"].forEach((e=>{t(document).on("change",`.acf-field[data-name="${e}"] :input`,(function(){c()}))}))}if("location"===E()&&"label"===g()){["label_on","icon_on","icon-image","icon-translate-x","icon-translate-y","text-translate-x","text-translate-y"].forEach((e=>{t(document).on("change",`.acf-field[data-name="${e}"] :input`,(function(){c()}))}))} }function p(){let e=!1;t(document).on("click",".open-multigeom",(function(){t(".open-multigeom-a").trigger("click");if(!e){"line"===E()?t("#draw-single-line").show():"polygon"===E()&&t("#draw-single-polygon").show();!function(e){ }(i(b().attr("id")+"-multi"));e=!0}}))}function f(r){e=r;n=i(b().attr("id"));!function(){jQuery(document).on("click",".mapster-edit-full-width",(()=>{if("flex"===jQuery(".mapster-map-container").css("display")){jQuery(".mapster-map-container").css("display","block");jQuery(".mapster-map-container > div").css("width","100%");jQuery(".mapster-map-container > div").css("marginBottom","15px");jQuery(".mapster-edit-full-width").text("Collapse Map");n.resize()}else{jQuery(".mapster-map-container").css("display","flex");jQuery(".mapster-map-container > div").css("width","50%");jQuery(".mapster-map-container > div").css("marginBottom","0px");jQuery(".mapster-edit-full-width").text("Expand Map");n.resize()}}));let t=!1;jQuery(document).on("click",".mapster-simplify-shape",(()=>{if(jQuery(".mapster-simplify-shape-slider").length){jQuery(".mapster-simplify-shape").html("Simplify Shape");jQuery(".mapster-simplify-container").remove();d(t)}else{jQuery(".mapster-simplify-shape").html("Cancel Simplify Shape");jQuery(".mapster-map-container > div:first-child").append('\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t');t=S()}}));jQuery(document).on("input",".mapster-simplify-shape-slider",(function(){let e=jQuery(this).val();d(turf.simplify(t,{tolerance:parseInt(e)/100}))}));jQuery(document).on("click",".mapster-download-geojson",(()=>{var t=document.createElement("a"),e=new Blob(["\ufeff",JSON.stringify(S())]),n=URL.createObjectURL(e);t.href=n;t.download="geojson-download.json";document.getElementById("acf-form-data").appendChild(t);t.click();document.getElementById("acf-form-data").removeChild(t)}));jQuery(document).on("click",".mapster-image-base",(()=>{ }))}();!function(){var e=M(),r=new MapboxDraw({displayControlsDefault:!1,controls:{point:e.pointAllowed,line_string:e.lineStringAllowed,polygon:e.polygonAllowed,trash:!0}});n.addControl(r,"top-left");n.on("draw.create",(e=>{var i=S();M().multipleAllowed?i.features.push(e.features[0]):i.features=[e.features[0]];n.setLayoutProperty("feature","visibility","visible");t("#finish-drawing div").fadeOut();r.deleteAll();d(i)}));n.on("draw.delete",(t=>{var e=S();e.features=[];n.setLayoutProperty("feature","visibility","visible");d(e)}));n.on("draw.update",(t=>{var e=S();e.features=[t.features[0]];d(e)}));n.on("load",(()=>{t(document).on("click","#draw-point",(()=>{n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();r.changeMode("draw_point")}));t(document).on("click","#draw-linestring",(()=>{n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();r.changeMode("draw_line_string")}));t(document).on("click","#edit-linestring",(()=>{if(S().features[0]){n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();var e=r.add(S());r.changeMode("direct_select",{featureId:e[0]})}}));t(document).on("click","#draw-polygon",(()=>{n.setLayoutProperty("feature","visibility","none");r.changeMode("draw_polygon")}));t(document).on("click","#edit-polygon",(()=>{if(S().features[0]){n.setLayoutProperty("feature","visibility","none");t("#finish-drawing div").fadeIn();var e=r.add(S());r.changeMode("direct_select",{featureId:e[0]})}}));t(document).on("click","#finish-drawing div",(()=>{var e=S(),i=r.getAll(),o=e.features.findIndex((t=>t.id===i.features[0].id));o>-1&&(e.features[o]=i.features[0]);n.setLayoutProperty("feature","visibility","visible");t("#finish-drawing div").fadeOut();r.deleteAll();d(e)}));t(document).on("click","#draw-delete",(()=>{r.deleteAll();n.setLayoutProperty("feature","visibility","none");d({type:"FeatureCollection",features:[]})}))}))}();!function(){"location"===E()&&T();v();n.on("load",(()=>{n.addSource("feature",{type:"geojson",data:S()});o()}))}();h();!function(){if(t("#mapster-map-geosearch").length){const e=new GeoSearch.OpenStreetMapProvider;t(document).on("click","#mapster-get-results",(async function(){var n=t("#mapster-map-geosearch").val();if(n.length>2){const o=await e.search({query:n});var i=r(o);t("#mapster-geocoder-results").empty().append(i)}else t("#mapster-geocoder-results").empty()}));t(document).on("keyup","#mapster-map-geosearch",(function(){t("#mapster-map-geosearch").val().length<=2&&t("#mapster-geocoder-results").empty()}));t(document).on("click","#mapster-geocoder-results li",(function(){var e=t(this).data("bounds");d({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:t(this).data("center")}}]});n.fitBounds(e.map((t=>t.slice().reverse())),{padding:20});t("#mapster-geocoder-results").empty()}));const r=t=>{var e="";t.slice(0,5).forEach((t=>{e+=`
  • ${t.label}
  • `}));return e}}if(t("#mapster-geocoder-mapbox").length){const e=t("#mapster-geocoder-mapbox").data("access_token"),r=new MapboxGeocoder({accessToken:e,mapboxgl:maplibregl,marker:!1});r.on("result",(t=>{d({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:t.result.center}}]})}));document.getElementById("mapster-geocoder-mapbox").appendChild(r.onAdd(n))}}();p();"line"!==E()&&"polygon"!==E()||function(){t("#mapster-map-upload").change((function(t){e(t)}));const e=async t=>{const e=await new Response(t.target.files[0]).json();n(e)},n=e=>{if(e){const r=geojsonhint.hint(e);if(0===r.length){if(n=e.features.find((e=>t("#mapster-map-upload").data("type").indexOf(e.geometry.type)>-1))){if(window.confirm("Are you sure you want to upload this geoJSON? It will overwrite all existing features.")){n.id||(n.id=parseInt(Math.random()*Math.random()*1e7));d({type:"FeatureCollection",features:[n]})}}else window.alert("Please double-check that your geoJSON has the right geometry type for this post.")}else{var n;if(n=e.features.find((e=>t("#mapster-map-upload").data("type").indexOf(e.geometry.type)>-1))){if(window.confirm("There was an error with your upload: "+JSON.stringify(r)+". Are you sure you want to upload this geoJSON? It will overwrite all existing features.")){n.id||(n.id=parseInt(Math.random()*Math.random()*1e7));d({type:"FeatureCollection",features:[n]})}}else window.alert("GeoJSON error: "+JSON.stringify(r))}}else window.alert("Please upload a file.")}}();if("location"===E()){u();t(document).on("click","#set-manual-point",(function(){let e=t("#mapster-map-point-longitude").val(),n=t("#mapster-map-point-latitude").val();d({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Point",coordinates:[parseFloat(e),parseFloat(n)]}}]})}))}"polygon"===E()&&l()}function d(e){!function(t){t.features.forEach((t=>{t.geometry.coordinates=t.geometry.coordinates.map(m)}))}(e);!function(e){t(`#mapster-map-geojson-${w()}`).attr("value",JSON.stringify(e))}(e);n.getSource("feature").setData(e);s();if("location"===E()){T();"3d-model"===g()&&x()}}function m(t){return isNaN(t)?t.map(m):Math.round(1e8*t)/1e8}function g(){return t(".mapster-map-submission-frontend").length?"marker":t('.acf-field[data-name="location_style"]').find("select").val()}function y(){return t('.acf-field[data-name="polygon_style"]').find("select").val()}function v(){if("location"===E()&&"circle"===g()){var e=t('.acf-field[data-name="circle"] .acf-field[data-name="color"]').find(":input").val(),r=t('.acf-field[data-name="circle"] .acf-field[data-name="opacity"]').find(":input").val(),i=t('.acf-field[data-name="circle"] .acf-field[data-name="radius"]').find(":input").val(),o=t('.acf-field[data-name="circle"] .acf-field[data-name="stroke-width"]').find(":input").val(),a=t('.acf-field[data-name="circle"] .acf-field[data-name="stroke-color"]').find(":input").val(),s=t('.acf-field[data-name="circle"] .acf-field[data-name="stroke-opacity"]').find(":input").val();return{paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,radius:""!==i?parseFloat(i):5,"stroke-width":""!==o?parseFloat(o):0,"stroke-color":""!==a?a:"#FFF","stroke-opacity":""!==s?parseFloat(s)/100:1}}}if("location"===E()&&"marker"===g()){e=t('.acf-field[data-name="marker"] .acf-field[data-name="color"]').find(":input").val();var l=t('.acf-field[data-name="marker"] .acf-field[data-name="scale"]').find(":input").val(),u=t('.acf-field[data-name="marker"] .acf-field[data-name="rotation"]').find(":input").val(),c=t('.acf-field[data-name="marker"] .acf-field[data-name="anchor"]').find(":input").val();return{marker:{color:""!==e?e:"#000",scale:""!==l?parseFloat(l)/100:1,rotation:""!==u?parseFloat(u):0,anchor:""!==c?c:"center"}}}if("location"===E()&&"label"===g()){var h=t('.acf-field[data-name="label"] .acf-field[data-name="label_on"]').find(":input").is(":checked"),p=t('.acf-field[data-name="label"] .acf-field[data-name="text-field"]').find(":input").val(),f=t('.acf-field[data-name="label"] .acf-field[data-name="text-font"]').find(":input").val(),d=t('.acf-field[data-name="label"] .acf-field[data-name="text-size"]').find(":input").val(),m=t('.acf-field[data-name="label"] .acf-field[data-name="text-color"]').find(":input").val(),v=t('.acf-field[data-name="label"] .acf-field[data-name="text-opacity"]').find(":input").val(),_=t('.acf-field[data-name="label"] .acf-field[data-name="text-rotate"]').find(":input").val(),x=t('.acf-field[data-name="label"] .acf-field[data-name="text-translate-x"]').find(":input").val(),b=t('.acf-field[data-name="label"] .acf-field[data-name="text-translate-y"]').find(":input").val(),w=t('.acf-field[data-name="label"] .acf-field[data-name="text-halo-width"]').find(":input").val(),S=t('.acf-field[data-name="label"] .acf-field[data-name="text-halo-color"]').find(":input").val(),M=t('.acf-field[data-name="label"] .acf-field[data-name="text-halo-blur"]').find(":input").val(),T=t('.acf-field[data-name="icon"] .acf-field[data-name="icon_on"]').find(":input").is(":checked"),C=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-image"] img').attr("src"),I=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-size"]').find(":input").val(),A=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-opacity"]').find(":input").val(),L=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-rotate"]').find(":input").val(),P=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-translate-x"]').find(":input").val(),R=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-translate-y"]').find(":input").val(),D=t('.acf-field[data-name="icon"] .acf-field[data-name="icon-anchor"]').find(":input").val();""!==C&&function(t,e){t||e();"https:"===window.location.protocol&&t.indexOf("http://")>-1&&(t=t.replace("http","https"));n.loadImage(t,((t,r)=>{if(n.loaded()){n.hasImage("icon-image-location")?n.updateImage("icon-image-location",r):n.addImage("icon-image-location",r);e()}else n.once("idle",(()=>{n.hasImage("icon-image-location")?n.updateImage("icon-image-location",r):n.addImage("icon-image-location",r);e()}))}))}(C,(()=>{n.setLayoutProperty("feature","icon-image","icon-image-location")}));const e={layout:{"text-field":""!==p?p:"","text-font":[f],"text-rotate":""!==_?parseFloat(_):0,"text-size":""!==d?parseFloat(d):16,"icon-size":""!==I?parseFloat(I)/100:1,"icon-rotate":""!==L?parseFloat(L):0,"icon-anchor":""!==D?D:"center","icon-offset":""!==P&&""!==R?[parseFloat(P),parseFloat(R)]:[0,0],"text-offset":""!==x&&""!==b?[parseFloat(x),parseFloat(b)]:[0,0]},paint:{"text-color":""!==m?m:"#000000","text-halo-width":""!==w?parseFloat(w):1,"text-halo-color":""!==S?S:"#FFFFFF","text-halo-blur":""!==M?parseFloat(M)/100:.5,"text-opacity":""!==v?parseFloat(v)/100:1,"icon-opacity":""!==A?parseFloat(A)/100:1}};h||(e.layout["text-size"]=0);T||(e.layout["icon-size"]=0);return e}if("line"===E()){e=t('.acf-field[data-name="color"]').find(":input").val(),r=t('.acf-field[data-name="opacity"]').find(":input").val();var N=t('.acf-field[data-name="width"]').find(":input").val(),O=t('.acf-field[data-name="dashed_line"]').find(":input").is(":checked"),k=t('.acf-field[data-name="dash_length"]').find(":input").val(),z=t('.acf-field[data-name="gap_length"]').find(":input").val();const n={paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,width:""!==N?parseFloat(N):5}};n.paint.dasharray=O?""!==k&&""!==z?[parseFloat(k),parseFloat(z)]:[1,1]:[1,0];return n}if("polygon"===E()&&"fill"===y()){e=t('.acf-field[data-name="color"]').find("input").val(),r=t('.acf-field[data-name="opacity"]').find("input").val();var F=t('.acf-field[data-name="outline-color"]').find("input").val();return{paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,"outline-color":""!==F?F:"rgba(0, 0, 0, 0)"}}}if("polygon"===E()&&"fill-extrusion"===y()){e=t('.acf-field[data-name="color"]').find("input").val(),r=t('.acf-field[data-name="opacity"]').find("input").val();var B=t('.acf-field[data-name="base"]').find("input").val(),U=t('.acf-field[data-name="height"]').find("input").val();return{paint:{color:""!==e?e:"#000",opacity:""!==r?parseFloat(r)/100:1,base:""!==B?parseFloat(B):0,height:""!==U?parseFloat(U):0}}}}function _(){return"location"===E()&&"circle"===g()?"circle-":"location"===E()&&"label"===g()?"":"line"===E()?"line-":"polygon"===E()&&"fill"===y()?"fill-":"polygon"===E()&&"fill-extrusion"===y()?"fill-extrusion-":void 0}function x(){ }function b(){return t(e).find(".mapster-map")}function w(){return b().attr("id").replace("mapster-map-","")}function E(){if(t(".mapster-map-submission-frontend").length){let e=1===t(".mapster-submission-map").data("linestring")?"line":"";e=1===t(".mapster-submission-map").data("point")?"location":e;e=1===t(".mapster-submission-map").data("polygon")?"polygon":e;return e}var e=t("body").attr("class").split(/\s+/).find((t=>t.indexOf("post-type-mapster-wp-")>-1)).replace("post-type-mapster-wp-","");return e="user-sub"===e?"location":e}function S(){var e=t(`#mapster-map-geojson-${w()}`).val();if(e&&""!==e){return JSON.parse(e)}return{type:"FeatureCollection",features:[]}}function M(){return{pointAllowed:1===b().data("point"),lineStringAllowed:1===b().data("linestring"),polygonAllowed:1===b().data("polygon"),multipleAllowed:1===b().data("multiple")}}function T(){if(S().features[0]){var e=S().features[0].geometry.coordinates;t("#mapster-map-point-longitude").val(e[0]);t("#mapster-map-point-latitude").val(e[1])}else{t("#mapster-map-point-longitude").val("");t("#mapster-map-point-latitude").val("")}}function C(){ }if(void 0!==acf.add_action){acf.add_action("ready_field/type=mapster-map",f);acf.add_action("append_field/type=mapster-map",f);acf.add_action("show_field/type=mapster-map",f)}else t(document).on("acf/setup_fields",(function(e,n){t(n).find('.field[data-field_type="mapster-map"]').each((function(){f(t(this))}))}))}(jQuery);