@zwishing/emap 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -2
- package/README.md +68 -8
- package/dist/emap.js +2 -2
- package/dist/emap.mjs +1 -5
- package/dist/index.d.ts +2 -2
- package/dist/map/types.d.ts +5 -0
- package/dist/mapshaper-vendor.js +1 -1
- package/dist/mapshaper-vendor.mjs +1 -0
- package/dist/source/topology-source.d.ts +14 -0
- package/dist/ui/basemap-control.d.ts +2 -1
- package/package.json +17 -8
- package/style.css.d.ts +2 -0
package/dist/emap.mjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import t from"mapshaper";function e(t,e){return e.forEach(function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(function(i){if("default"!==i&&!(i in t)){var r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return e[i]}})}})}),Object.freeze(t)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),i}var n={exports:{}},s=r(Object.freeze({__proto__:null,default:{}}));function o(t,e){for(var i=0,r=t.length-1;r>=0;r--){var n=t[r];"."===n?t.splice(r,1):".."===n?(t.splice(r,1),i++):i&&(t.splice(r,1),i--)}if(e)for(;i--;i)t.unshift("..");return t}var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,l=function(t){return a.exec(t).slice(1)};function c(){for(var t="",e=!1,i=arguments.length-1;i>=-1&&!e;i--){var r=i>=0?arguments[i]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(t=r+"/"+t,e="/"===r.charAt(0))}return(e?"/":"")+(t=o(y(t.split("/"),function(t){return!!t}),!e).join("/"))||"."}function h(t){var e=u(t),i="/"===x(t,-1);return(t=o(y(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&i&&(t+="/"),(e?"/":"")+t}function u(t){return"/"===t.charAt(0)}function p(){return h(y(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function d(t,e){function i(t){for(var e=0;e<t.length&&""===t[e];e++);for(var i=t.length-1;i>=0&&""===t[i];i--);return e>i?[]:t.slice(e,i-e+1)}t=c(t).substr(1),e=c(e).substr(1);for(var r=i(t.split("/")),n=i(e.split("/")),s=Math.min(r.length,n.length),o=s,a=0;a<s;a++)if(r[a]!==n[a]){o=a;break}var l=[];for(a=o;a<r.length;a++)l.push("..");return(l=l.concat(n.slice(o))).join("/")}function f(t){var e=l(t),i=e[0],r=e[1];return i||r?(r&&(r=r.substr(0,r.length-1)),i+r):"."}function m(t,e){var i=l(t)[2];return e&&i.substr(-1*e.length)===e&&(i=i.substr(0,i.length-e.length)),i}function _(t){return l(t)[3]}var g={extname:_,basename:m,dirname:f,sep:"/",delimiter:":",relative:d,join:p,isAbsolute:u,normalize:h,resolve:c};function y(t,e){if(t.filter)return t.filter(e);for(var i=[],r=0;r<t.length;r++)e(t[r],r,t)&&i.push(t[r]);return i}var v,x="b"==="ab".substr(-1)?function(t,e,i){return t.substr(e,i)}:function(t,e,i){return e<0&&(e=t.length+e),t.substr(e,i)},b=r(Object.freeze({__proto__:null,basename:m,default:g,delimiter:":",dirname:f,extname:_,isAbsolute:u,join:p,normalize:h,relative:d,resolve:c,sep:"/"}));v=n,function(){var t=Math.abs,e=Math.floor,i=Math.sin,r=Math.cos,n=Math.tan,o=Math.asin,a=Math.acos,l=Math.atan,c=Math.atan2,h=Math.sqrt,u=Math.pow,p=Math.exp,d=Math.log,f=Math.hypot,m=Math.sinh,_=Math.cosh,g=Math.min,y=Math.max,x=1/0,w=Math.PI,S=57.29577951308232,T=.017453292519943295,C=6378137,M=.0066943799901413165,E=w/4,A=w/2,I=1.5*w,P=2*w,D=2/w,k=-45,z=-47,R=1e-10,L={last_errno:0,debug_level:0,logger:null},F=["no arguments in initialization list","no options found in 'init' file","invalid init= string","projection not named","unknown projection id","effective eccentricity = 1","unknown unit conversion id","invalid boolean param argument","unknown elliptical parameter name","reciprocal flattening (1/f) = 0","|radius reference latitude| > 90","squared eccentricity < 0","major axis or radius = 0 or not given","latitude or longitude exceeded limits","invalid x or y","improperly formed DMS value","non-convergent inverse meridional dist","non-convergent inverse phi2","acos/asin: |arg| >1+1e-14","tolerance condition error","conic lat_1 = -lat_2","lat_1 >= 90","lat_1 = 0","lat_ts >= 90","no distance between control points","projection not selected to be rotated","W <= 0 or M <= 0","lsat not in 1-5 range","path not in range","h <= 0","k <= 0","lat_0 = 0 or 90 or alpha = 90","lat_1=lat_2 or lat_1=0 or lat_2=90","elliptical usage required","invalid UTM zone number","arg(s) out of range for Tcheby eval","failed to find projection to be rotated","failed to load datum shift file","both n & m must be spec'd and > 0","n <= 0, n > 1 or not specified","lat_1 or lat_2 not specified","|lat_1| == |lat_2|","lat_0 is pi/2 from mean lat","unparseable coordinate system definition","geocentric transformation missing z or ellps","unknown prime meridian conversion id","illegal axis orientation combination","point not within available datum shift grids","invalid sweep axis, choose x or y","invalid value for h","point outside of projection domain"];function B(){var t=L.last_errno;t&&(t>0||!function(t){return O.indexOf(t)>-1}(t))&&G(t)}var O=[-14,-15,-17,-18,-19,-20,-27,-48];function N(t){L.last_errno=t}function V(){N(-20)}function j(){N(-20)}function q(t){G(t)}function G(t){N(t),U()}function U(t,e){var i;throw e||(e={}),e.code||(e.code=L.last_errno||0),t||(i=e.code,t=F[~i]||"unknown error"),L.last_errno=0,new $(t,e)}function $(t,e){var i=new Error(t);return i.name="ProjError",Object.keys(e).forEach(function(t){i[t]=e[t]}),i}function Z(t){return W(t)*T}function W(t){var e=/(-?[0-9.]+)d?([0-9.]*)'?([0-9.]*)"?([nsew]?)$/i.exec(t),i=NaN;return e&&(i=+(e[1]||"0")+ +(e[2]||"0")/60+ +(e[3]||"0")/3600,/[ws]/i.test(e[4])&&(i=-i)),isNaN(i)&&G(-16),i}function H(t){return X(t)}function X(t){return parseFloat(t)}function Y(t,e){var i,r,n=e[0],s=t[e.substr(1)],o=void 0!==s;return"t"==n?i=o:o?(r=s.param,s.used=!0,"i"==n?i=parseInt(r):"d"==n?i=H(r):"r"==n?i=Z(r):"s"==n?i=String(r):"b"==n&&("T"==r||"t"==r||!0===r?i=!0:("F"==r||"f"==r||N(-8),i=!1))):i={i:0,b:!1,d:0,r:0,s:""}[n],void 0===i&&U("invalid request to pj_param, fatal"),i}function K(t){for(var e,i=/\+([a-z][a-z0-9_]*(?:=[^\s]*)?)/gi,r={};e=i.exec(t);)J(r,e[1]);return r}function J(t,e){var i,r,n=e.split("=");1==n.length?(i=e,r=!0):(i=n[0],r=e.substr(n[0].length+1)),t[i]={used:!1,param:r}}var Q={};function tt(t,e,i,r){Q[e]={init:t,name:i,description:r}}function et(t){return!t||t.is_latlong}function it(t){var e=!1,i="";return"datum"in t.params?(e=!0,i+=nt(t,"datum")):"R"in t.params?i+=nt(t,"R"):"ellps"in t.params?i+=nt(t,"ellps"):"a"in t.params?(i+=nt(t,"a"),"b"in t.params?i+=nt(t,"b"):"es"in t.params?i+=nt(t,"es"):"f"in t.params?i+=nt(t,"f"):i+=" +es="+t.es):q(-13),e||(i+=nt(t,"towgs84"),i+=nt(t,"nadgrids")),i+=nt(t,"R_A"),i+=nt(t,"R_V"),i+=nt(t,"R_a"),i+=nt(t,"R_lat_a"),i+=nt(t,"R_lat_g"),i+=nt(t,"pm")}function rt(t){var e="datum,ellps,a,b,es,rf,f,towgs84,nadgrids,R,R_A,R_V,R_a,R_lat_a,R_lat_g,pm,init,no_defs".split(","),i="";return Object.keys(t.params).forEach(function(r){-1==e.indexOf(r)&&(i+=nt(t,r))}),(i+=it(t)).trim()}function nt(t,e){var i="";return e in t.params&&(i=" +"+e,!0!==t.params[e].param&&(i+="="+Y(t.params,"s"+e))),i}var st=[["WGS84","towgs84=0,0,0","WGS84","WGS_1984"],["GGRS87","towgs84=-199.87,74.79,246.62","GRS80","Greek_Geodetic_Reference_System_1987"],["NAD83","towgs84=0,0,0","GRS80","North_American_Datum_1983"],["NAD27","nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat","clrk66","North_American_Datum_1927"],["potsdam","towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7","bessel","Potsdam Rauenberg 1950 DHDN"],["carthage","towgs84=-263.0,6.0,431.0","clrk80ign","Carthage 1934 Tunisia"],["hermannskogel","towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232","bessel","Hermannskogel"],["ire65","towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15","mod_airy","Ireland 1965"],["nzgd49","towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993","intl","New Zealand Geodetic Datum 1949"],["OSGB36","towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894","airy","OSGB 1936"],[null,null,null,null]],ot=[["greenwich","0dE"],["lisbon","9d07'54.862\"W"],["paris","2d20'14.025\"E"],["bogota","74d04'51.3\"W"],["madrid","3d41'16.58\"W"],["rome","12d27'8.4\"E"],["bern","7d26'22.5\"E"],["jakarta","106d48'27.79\"E"],["ferro","17d40'W"],["brussels","4d22'4.71\"E"],["stockholm","18d3'29.8\"E"],["athens","23d42'58.815\"E"],["oslo","10d43'22.5\"E"],[null,null]];function at(t){var e=st.reduce(function(e,i){return i[0]===t?i:e},null);return e?{id:e[0],defn:e[1],ellipse_id:e[2],name:e[3]}:null}var lt=[["MERIT","a=6378137.0","rf=298.257","MERIT 1983"],["SGS85","a=6378136.0","rf=298.257","Soviet Geodetic System 85"],["GRS80","a=6378137.0","rf=298.257222101","GRS 1980(IUGG, 1980)"],["IAU76","a=6378140.0","rf=298.257","IAU 1976"],["airy","a=6377563.396","b=6356256.910","Airy 1830"],["APL4.9","a=6378137.0","rf=298.25","Appl. Physics. 1965"],["NWL9D","a=6378145.0","rf=298.25","Naval Weapons Lab., 1965"],["mod_airy","a=6377340.189","b=6356034.446","Modified Airy"],["andrae","a=6377104.43","rf=300.0","Andrae 1876 (Den., Iclnd.)"],["aust_SA","a=6378160.0","rf=298.25","Australian Natl & S. Amer. 1969"],["GRS67","a=6378160.0","rf=298.2471674270","GRS 67(IUGG 1967)"],["bessel","a=6377397.155","rf=299.1528128","Bessel 1841"],["bess_nam","a=6377483.865","rf=299.1528128","Bessel 1841 (Namibia)"],["clrk66","a=6378206.4","b=6356583.8","Clarke 1866"],["clrk80","a=6378249.145","rf=293.4663","Clarke 1880 mod."],["clrk80ign","a=6378249.2","rf=293.4660212936269","Clarke 1880 (IGN)."],["CPM","a=6375738.7","rf=334.29","Comm. des Poids et Mesures 1799"],["delmbr","a=6376428","rf=311.5","Delambre 1810 (Belgium)"],["engelis","a=6378136.05","rf=298.2566","Engelis 1985"],["evrst30","a=6377276.345","rf=300.8017","Everest 1830"],["evrst48","a=6377304.063","rf=300.8017","Everest 1948"],["evrst56","a=6377301.243","rf=300.8017","Everest 1956"],["evrst69","a=6377295.664","rf=300.8017","Everest 1969"],["evrstSS","a=6377298.556","rf=300.8017","Everest (Sabah & Sarawak)"],["fschr60","a=6378166","rf=298.3","Fischer (Mercury Datum) 1960"],["fschr60m","a=6378155","rf=298.3","Modified Fischer 1960"],["fschr68","a=6378150","rf=298.3","Fischer 1968"],["helmert","a=6378200","rf=298.3","Helmert 1906"],["hough","a=6378270.0","rf=297","Hough"],["intl","a=6378388.0","rf=297","International 1909 (Hayford)"],["krass","a=6378245.0","rf=298.3","Krasovsky 1940"],["kaula","a=6378163","rf=298.24","Kaula 1961"],["lerch","a=6378139","rf=298.257","Lerch 1979"],["mprts","a=6397300","rf=191","Maupertius 1738"],["new_intl","a=6378157.5","b=6356772.2","New International 1967"],["plessis","a=6376523","b=6355863","Plessis 1817 (France)"],["SEasia","a=6378155.0","b=6356773.3205","Southeast Asia"],["walbeck","a=6376896.0","b=6355834.8467","Walbeck"],["WGS60","a=6378165.0","rf=298.3","WGS 60"],["WGS66","a=6378145.0","rf=298.25","WGS 66"],["WGS72","a=6378135.0","rf=298.26","WGS 72"],["WGS84","a=6378137.0","rf=298.257223563","WGS 84"],["sphere","a=6370997.0","b=6370997.0","Normal Sphere (r=6370997)"],[null,null,null,null]];function ct(t){var e=lt.reduce(function(e,i){return i[0]===t?i:e},null);return e?{id:e[0],major:e[1],ell:e[2],name:e[3]}:null}var ht=[["km","1000","Kilometer"],["m","1","Meter"],["dm","1/10","Decimeter"],["cm","1/100","Centimeter"],["mm","1/1000","Millimeter"],["kmi","1852.0","International Nautical Mile"],["in","0.0254","International Inch"],["ft","0.3048","International Foot"],["yd","0.9144","International Yard"],["mi","1609.344","International Statute Mile"],["fath","1.8288","International Fathom"],["ch","20.1168","International Chain"],["link","0.201168","International Link"],["us-in","1/39.37","U.S. Surveyor's Inch"],["us-ft","0.304800609601219","U.S. Surveyor's Foot"],["us-yd","0.914401828803658","U.S. Surveyor's Yard"],["us-ch","20.11684023368047","U.S. Surveyor's Chain"],["us-mi","1609.347218694437","U.S. Surveyor's Statute Mile"],["ind-yd","0.91439523","Indian Yard"],["ind-ft","0.30479841","Indian Foot"],["ind-ch","20.11669506","Indian Chain"],[null,null,null]];function ut(t){var e=ht.reduce(function(e,i){return t===i[0]?i:e},null);return e?{id:e[0],to_meter:e[1],name:e[2]}:null}var pt={},dt={};function ft(t){return dt[t]||null}function mt(t){var e,i,r,n,o,a,l,c,h=t.split(":"),u=h[0],p=h[1];return p&&u||q(-3),(e=ft(u=u.toLowerCase()))||(i=u,n=s,a=(o=b).join(o.dirname("/Users/zhang/code/emap/node_modules/mproj/dist"),"../nad"),l=o.join(a,i.toUpperCase()),c=o.join(a,i.toLowerCase()),n.existsSync(l)?r=n.readFileSync(l,"utf8"):n.existsSync(c)?r=n.readFileSync(c,"utf8"):U("unable to read from 'init' file named "+i),e=r,dt[u]=e),e?function(t,e){var i,r,n="",s="";return(i=t.indexOf("<"+e+">"))>-1&&((r=t.lastIndexOf("#",i))>-1&&(s=t.substring(r+1,i).trim(),/\n/.test(s)&&(s="")),n=(n=(n=" "+(n=(n=(n=(n=(n=t.substr(i+e.length+2)).substr(0,n.indexOf("<"))).replace(/#.*/g,"")).replace(/[\s]+/g," ")).replace(/\+title=[^+]*[^ +]/g,function(t){return t.replace(/ /g,"\t")}))).replace(/ (?=[a-z])/gi," +")).replace(/\t/g," ").trim()),n?{opts:n,comment:s}:null}(e,p):null}function _t(e){var r,n,s=K(e),o={params:s,is_latlong:!1,is_geocent:!1,is_long_wrap_set:!1,long_wrap_center:0,axis:"enu",gridlist:null,gridlist_count:0,vgridlist_geoid:null,vgridlist_geoid_count:0};return Object.keys(s).length||q(-1),Y(s,"tinit")&&function(t,e){var i=pt[e.toLowerCase()]||null;i||function(t,e){pt[t.toLowerCase()]=e}(e,i=mt(e)),i||q(-2),gt(t,i.opts)}(s,Y(s,"sinit")),(r=Y(s,"sproj"))||q(-4),(n=Q[r])||q(-5),Y(s,"bno_defs")||function(t){gt(t,"+ellps=WGS84")}(o.params),function(t){var e,i,r,n,s=484813681109536e-20,o=t.datum_params=[0,0,0,0,0,0,0];t.datum_type=0,(e=Y(t.params,"sdatum"))&&((i=at(e))||q(-9),i.ellipse_id&&J(t.params,"ellps="+i.ellipse_id),i.defn&&J(t.params,i.defn)),(r=Y(t.params,"snadgrids"))&&"@null"!=r&&U("+nadgrids is not implemented"),Y(t.params,"scatalog")&&U("+catalog is not implemented"),(n=Y(t.params,"stowgs84"))&&(n.split(",").forEach(function(t,e){o[e]=H(t)||0}),0!=o[3]||0!=o[4]||0!=o[5]||0!=o[6]?(t.datum_type=2,o[3]*=s,o[4]*=s,o[5]*=s,o[6]=o[6]/1e6+1):t.datum_type=1)}(o),function(e){var r,n,s,o,a,l=.16666666666666666,c=e.params,u=0,p=0;Y(c,"tR")?u=Y(c,"dR"):((r=Y(c,"sellps"))&&((n=ct(r))||q(-9),J(c,n.major),J(c,n.ell)),u=Y(c,"da"),Y(c,"tes")?p=Y(c,"des"):Y(c,"te")?p=(s=Y(c,"de"))*s:Y(c,"trf")?((s=Y(c,"drf"))||q(-10),p=(s=1/s)*(2-s)):Y(c,"tf")?p=(s=Y(c,"df"))*(2-s):Y(c,"tb")&&(p=1-(o=Y(c,"db"))*o/(u*u)),o||(o=u*h(1-p)),Y(c,"bR_A")?(u*=1-p*(l+p*(.04722222222222222+.022156084656084655*p)),p=0):Y(c,"bR_V")?u*=1-p*(l+p*(.06944444444444445+.04243827160493827*p)):Y(c,"bR_a")?(u=.5*(u+o),p=0):Y(c,"bR_g")?(u=h(u*o),p=0):Y(c,"bR_h")?(u+o===0&&q(-20),u=2*u*o/(u+o),p=0):(a=Y(c,"tR_lat_a")||Y(c,"tR_lat_g"))&&(s=i(Y(c,a?"rR_lat_a":"rR_lat_g")),t(s)>A&&q(-11),s=1-p*s*s,u*=a?.5*(1-p+s)/(s*h(s)):h(1-p)/s,p=0)),p<0&&q(-12),u<=0&&q(-13),e.es=p,e.a=u}(o),o.a_orig=o.a,o.es_orig=o.es,o.e=h(o.es),o.ra=1/o.a,o.one_es=1-o.es,o.one_es||q(-6),o.rone_es=1/o.one_es,function(t){return 1==t.datum_type&&t.datum_params[0]==t.datum_params[1]==t.datum_params[2]===0&&6378137==t.a&&Math.abs(t.es-.00669437999)<5e-11}(o)&&(o.datum_type=4),o.geoc=!!o.es&&Y(s,"bgeoc"),o.over=Y(s,"bover"),o.has_geoid_vgrids=Y(s,"tgeoidgrids"),o.has_geoid_vgrids&&Y(s,"sgeoidgrids"),o.is_long_wrap_set=Y(s,"tlon_wrap"),o.is_long_wrap_set&&(o.long_wrap_center=Y(s,"rlon_wrap"),t(o.long_wrap_center)<10*P==0&&q(-14)),Y(s,"saxis")&&function(t){var e="ewnsud",i=Y(t.params,"saxis");3!=i.length&&q(z),-1!=e.indexOf(i[0])&&-1!=e.indexOf(i[1])&&-1!=e.indexOf(i[2])||q(z),t.axis=i}(o),o.lam0=Y(s,"rlon_0"),o.phi0=Y(s,"rlat_0"),o.x0=Y(s,"dx_0"),o.y0=Y(s,"dy_0"),Y(s,"tk_0")?o.k0=Y(s,"dk_0"):Y(s,"tk")?o.k0=Y(s,"dk"):o.k0=1,o.k0<=0&&q(-31),function(t){var e,i,r,n=t.params;(e=Y(n,"sunits"))&&((r=ut(e))||q(-7),i=r.to_meter),i||(i=Y(n,"sto_meter"))?(t.to_meter=yt(i),t.fr_meter=1/t.to_meter):t.to_meter=t.fr_meter=1,i=null,(e=Y(n,"svunits"))&&((r=ut(e))||q(-7),i=r.to_meter),i||Y(n,"svto_meter")?(t.vto_meter=yt(i),t.vfr_meter=1/t.vto_meter):(t.vto_meter=t.to_meter,t.vfr_meter=t.fr_meter)}(o),function(t){var e,i,r,n=t.params;(e=Y(n,"spm"))?(i=function(t){var e=ot.reduce(function(e,i){return i[0]===t?i:e},null);return e?{id:e[0],definition:e[1]}:null}(e),r=Z(i?i.definition:e),isNaN(r)&&q(-46),t.from_greenwich=r):t.from_greenwich=0}(o),n.init(o),o}function gt(t,e){var i=K(e),r=["datum","ellps","a","b","rf","f"].reduce(function(e,i){return e||i in t},!1);Object.keys(i).forEach(function(e){e in t||"ellps"==e&&r||(t[e]=i[e])})}function yt(t){var e=t.split("/"),i=X(e[0]);return e.length>1&&(i/=X(e[1])),i}function vt(t,e){var i=0,r=t*t,n=e*e;return t<=0&&(i|=4),e<=0&&(i|=8),t<e&&(i|=16),i?null:{a:t,b:e,a2:r,b2:n,e2:(r-n)/r,ep2:(r-n)/n}}function xt(t,e,n,s,o){var a,l,c,u,p=0,d=n[e],f=s[e],m=o[e];return f<-A&&f>-1.001*A?f=-A:f>A&&f<1.001*A?f=A:(f<-A||f>A)&&(p|=1),p||(d>w&&(d-=2*w),l=i(f),u=r(f),c=l*l,a=t.a/h(1-t.e2*c),n[e]=(a+m)*u*r(d),s[e]=(a+m)*u*i(d),o[e]=(a*(1-t.e2)+m)*l),p}function bt(e,i,r,n,s){var o,a,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C=1e-12,M=r[i],E=n[i],I=s[i];if(p=h(M*M+E*E),d=h(M*M+E*E+I*I),p/e.a<C){if(a=0,d/e.a<C)return r[i]=0,n[i]=A,s[i]=-e.b,0}else a=c(E,M);f=I/d,m=p/d,_=1/h(1-e.e2*(2-e.e2)*m*m),v=m*(1-e.e2)*_,x=f*_,T=0;do{T++,u=p*v+I*x-(g=e.a/h(1-e.e2*x*x))*(1-e.e2*x*x),y=e.e2*g/(g+u),S=(w=f*(_=1/h(1-y*(2-y)*m*m)))*v-(b=m*(1-y)*_)*x,v=b,x=w}while(S*S>1e-24&&T<30);o=l(w/t(b)),r[i]=a,n[i]=o,s[i]=u}function wt(t,e,i){var r=i.length>2,n=[i[0]],s=[i[1]],o=[r?i[2]:0];t.is_latlong&&(n[0]*=T,s[0]*=T),L.last_errno=0,St(t,e,n,s,o),(L.last_errno||n[0]==x)&&U(null,{point:i}),e.is_latlong&&(n[0]*=S,s[0]*=S),i[0]=n[0],i[1]=s[0],r&&(i[2]=o[0])}function St(t,e,i,r,n){var s,o,a=i.length,l={},c={};if("enu"!=t.axis&&Tt(t.axis,!1,i,r,n),1!=t.vto_meter&&n)for(s=0;s<a;s++)n[s]*=t.vto_meter;if(t.is_geocent){if(n||q(k),1!=t.to_meter)for(s=0;s<a;s++)i[s]!=x&&(i[s]*=t.to_meter,r[s]*=t.to_meter);Ct(t.a_orig,t.es_orig,i,r,n)}else if(!t.is_latlong)if(t.inv3d||t.inv||U("source projection not invertible"),t.inv3d)U("inverse 3d transformations not supported");else for(s=0;s<a;s++)c.x=i[s],c.y=r[s],o=It(c,t),i[s]=o.lam,r[s]=o.phi,B();if(0!==t.from_greenwich)for(s=0;s<a;s++)i[s]!=x&&(i[s]+=t.from_greenwich);if(t.has_geoid_vgrids&&n&&U("vgrid transformation not supported"),function(t,e,i,r,n){var s,o,a,l,c=i.length;0!=t.datum_type&&0!=e.datum_type&&(function(t,e){return t.datum_type==e.datum_type&&(!(t.a_orig!=e.a_orig||Math.abs(t.es_orig-e.es_orig)>5e-11)&&(1==t.datum_type?t.datum_params[0]==e.datum_params[0]&&t.datum_params[1]==e.datum_params[1]&&t.datum_params[2]==e.datum_params[2]:2==t.datum_type?t.datum_params[0]==e.datum_params[0]&&t.datum_params[1]==e.datum_params[1]&&t.datum_params[2]==e.datum_params[2]&&t.datum_params[3]==e.datum_params[3]&&t.datum_params[4]==e.datum_params[4]&&t.datum_params[5]==e.datum_params[5]&&t.datum_params[6]==e.datum_params[6]:3!=t.datum_type||Y(t.params,"snadgrids")==Y(e.params,"snadgrids")))}(t,e)||(s=t.a_orig,o=t.es_orig,a=e.a_orig,l=e.es_orig,n||(n=new Float64Array(c)),3==t.datum_type&&(U("gridshift not implemented"),s=C,o=M),3==e.datum_type&&(a=C,l=M),o==l&&s==a&&1!=t.datum_type&&2!=t.datum_type&&1!=e.datum_type&&2!=e.datum_type||(Mt(s,o,i,r,n),1!=t.datum_type&&2!=t.datum_type||function(t,e,i,r){var n,s,o,a,l,c,h,u,p=e.length,d=t.datum_params,f=d[0],m=d[1],_=d[2];if(1==t.datum_type)for(u=0;u<p;u++)e[u]!=x&&(e[u]+=f,i[u]+=m,r[u]+=_);else if(2==t.datum_type)for(a=d[3],l=d[4],c=d[5],h=d[6],u=0;u<p;u++)e[u]!=x&&(n=h*(e[u]-c*i[u]+l*r[u])+f,s=h*(c*e[u]+i[u]-a*r[u])+m,o=h*(-l*e[u]+a*i[u]+r[u])+_,e[u]=n,i[u]=s,r[u]=o)}(t,i,r,n),1!=e.datum_type&&2!=e.datum_type||function(t,e,i,r){var n,s,o,a,l,c,h,u,p=e.length,d=t.datum_params,f=d[0],m=d[1],_=d[2];if(1==t.datum_type)for(u=0;u<p;u++)e[u]!=x&&(e[u]-=f,i[u]-=m,r[u]-=_);else if(2==t.datum_type)for(a=d[3],l=d[4],c=d[5],h=d[6],u=0;u<p;u++)e[u]!=x&&(n=(e[u]-f)/h,s=(i[u]-m)/h,o=(r[u]-_)/h,e[u]=n+c*s-l*o,i[u]=-c*n+s+a*o,r[u]=l*n-a*s+o)}(e,i,r,n),Ct(a,l,i,r,n),3==e.datum_type&&pj_apply_gridshift_2(e,1,i,r,n))))}(t,e,i,r,n),e.has_geoid_vgrids&&n&&U("vgrid transformation not supported"),0!==e.from_greenwich)for(s=0;s<a;s++)i[s]!=x&&(i[s]-=e.from_greenwich);if(e.is_geocent){if(n||q(k),Mt(e.a_orig,e.es_orig,i,r,n),1!=e.fr_meter)for(s=0;s<a;s++)i[s]!=x&&(i[s]*=e.fr_meter,r[s]*=e.fr_meter)}else if(e.is_latlong){if(e.is_latlong&&e.is_long_wrap_set)for(s=0;s<a;s++)if(i[s]!=x){for(;i[s]<e.long_wrap_center-w;)i[s]+=P;for(;i[s]>e.long_wrap_center+w;)i[s]-=P}}else if(e.fwd3d)U("3d transformation not supported");else for(s=0;s<a;s++)l.lam=i[s],l.phi=r[s],o=At(l,e),i[s]=o.x,r[s]=o.y,B();if(1!=e.vto_meter&&n)for(s=0;s<a;s++)n[s]*=e.vfr_meter;return"enu"!=e.axis&&Tt(e.axis,!0,i,r,n),1==a?L.last_errno:0}function Tt(t,e,i,r,n){var s,o,a,l,c,h,u=i.length,p=0;if(e){for(a=0;a<u;a++)if(s=i[a],o=r[a],s!=x)for(n&&(p=n[a]),l=0;l<3;l++)if(2!=l||n)switch(h=0==l?i:1==l?r:n,t[l]){case"e":h[a]=s;break;case"w":h[a]=-s;break;case"n":h[a]=o;break;case"s":h[a]=-o;break;case"u":h[a]=p;break;case"d":h[a]=-p;break;default:q(z)}}else for(a=0;a<u;a++)if(s=i[a],o=r[a],s!=x)for(n&&(p=n[a]),l=0;l<3;l++)switch(c=0==l?s:1==l?o:p,t[l]){case"e":i[a]=c;break;case"w":i[a]=-c;break;case"n":r[a]=c;break;case"s":r[a]=-c;break;case"u":n&&(n[a]=c);break;case"d":n&&(n[a]=-c);break;default:q(z)}}function Ct(t,e,i,r,n){var s,o,a=i.length;for((o=vt(t,0==e?t:t*h(1-e)))||q(k),s=0;s<a;s++)i[s]!=x&&bt(o,s,i,r,n)}function Mt(t,e,i,r,n){var s,o,a=i.length;for((o=vt(t,0===e?t:t*h(1-e)))||q(k),s=0;s<a;s++)i[s]!=x&&xt(o,s,i,r,n)&&(i[s]=r[s]=x)}function Et(i){var r=6.283185307179586,n=3.141592653589793;return t(i)>3.14159265359&&(i+=n,i-=r*e(i/r),i-=n),i}function At(e,i){var r={x:0,y:0},s=t(e.phi)-A;return s<=1e-12&&t(e.lam)<=10?(L.last_errno=0,t(s)<=1e-12?e.phi=e.phi<0?-A:A:i.geoc&&(e.phi=l(i.rone_es*n(e.phi))),e.lam-=i.lam0,i.over||(e.lam=Et(e.lam)),i.fwd?(i.fwd(e,r),r.x=i.fr_meter*(i.a*r.x+i.x0),r.y=i.fr_meter*(i.a*r.y+i.y0)):r.x=r.y=x):N(-14),!L.last_errno&&isFinite(r.x)&&isFinite(r.y)||(r.x=r.y=x),r}function It(e,i){var r={lam:0,phi:0};return e.x<x&&e.y<x?(L.last_errno=0,i.inv?(e.x=(e.x*i.to_meter-i.x0)*i.ra,e.y=(e.y*i.to_meter-i.y0)*i.ra,i.inv(e,r),r.lam+=i.lam0,i.over||(r.lam=Et(r.lam)),i.geoc&&t(t(r.phi)-A)>1e-12&&(r.phi=l(i.one_es*n(r.phi)))):r.lam=r.phi=x):N(-15),!L.last_errno&&isFinite(r.lam)&&isFinite(r.phi)||(r.lam=r.phi=x),r}function Pt(t,i,r,n){var s,o,a;for((t<0||t>=9)&&(t=3),s=1,a=0;a<t;a++)s*=10;return o=3600*s,function(a){var l,c,h,u,p="",d="",f="";return a===x||isNaN(a)?"":(a<0?(a=-a,(h=n||"")||(p="-")):h=r||"",c=(a=e(a*o+.5))/s%60,l=(a=e(a/(60*s)))%60,u=e(a/60)+"d",f=c.toFixed(t),f=(c=parseFloat(f))?(i?f:String(c))+'"':"",(c||l)&&2==(d=String(l)+"'").length&&i&&(d="0"+d),p+u+d+f+h)}}function Dt(t,e,i){var r,n,s,o,a,l;return"string"!=typeof t?ki:("string"!=typeof e?(n="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",s=t,r=e):(n=t,s=e,r=i),l=kt(o=_t(n),a=_t(s)),r?l(r):{forward:l,inverse:kt(a,o)})}function kt(t,e){return function(i){var r=Array.isArray(i);return i=r?i.concat():[i.x,i.y],wt(t,e,i),r||(i={x:i[0],y:i[1]}),i}}function zt(t){var e=t.proj in Q?Q[t.proj].name:"",i=rt(t),r=Jt(t);return{PROJCS:{NAME:e?r.NAME+" / "+e:"unnamed",GEOGCS:r,PROJECTION:"custom_proj4",PARAMETER:[],UNIT:Zt(t),EXTENSION:["PROJ4",i+" +wktext"]}}}function Rt(t){var e=t.EXTENSION;return e&&"PROJ4"==e[0]?(e[1]||"").replace(" +wktext",""):null}Dt.WGS84="+proj=longlat +datum=WGS84",Dt.toPoint=function(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e};var Lt=[],Ft=[];function Bt(t){return"string"==typeof t}function Ot(t){var e=Vt(t,Ft);return e||(e=function(t){return Rt(t)?Rt:null}(t)),e||Ut("unsupported WKT definition: "+(t.NAME||"[unknown]")),e}function Nt(t){var e=Vt(t,Lt);return e||(e=zt),e||Ut("unsupported projection: "+function(t){return jt(t)||"[unknown]"}(t)),e}function Vt(t,e){for(var i=0;i<e.length;i++)if((0,e[i][0])(t))return e[i][1];return null}function jt(t){return Y(t.params,"sproj")}function qt(t){return t.replace(/[-_ \/]+/g,"_").toLowerCase()}function Gt(t){var e;return Array.isArray(t)?e=t:t&&t.length>0&&(e=t.split(",")),e}function Ut(t){throw new Error(t)}function $t(t){return{to_meter:t.UNIT[1]}}function Zt(t){return["Meter",t.to_meter||1]}function Wt(t,e){var i,r,n=t.DATUM,s=n.SPHEROID,o=function(t){var e,i={northamerican1983:"NAD83",newzealand1949:"nzgd49"},r=Ht(t.NAME);if(r in i)return i[r];for(var n=0;n<st.length&&Ht((e=st[n])[3])!=r&&Ht(e[0])!=r;n++);return e?e[0]:null}(n),a=function(t){var e,i={international1924:"intl"},r=Ht(t[0]);if(r in i)return i[r];if(/^grs1980/.test(r))return"GRS80";if("sphere"==r)return null;for(var n=0;n<lt.length&&Ht((e=lt[n])[3])!=r&&Ht(e[0])!=r;n++);return e?e[0]:null}(s),l=e&&e.aux_sphere,c=s[1],h=s[2];return Xt(t.UNIT,"degree"),l?i="+a="+s[1]:o?i="+datum="+o:a?i="+ellps="+a:(i="+a="+c,h>0&&(i+=" +rf="+h)),!n.TOWGS84||l||o||(i+=" +towgs84="+n.TOWGS84.join(",")),((r=t.PRIMEM?t.PRIMEM[1]:0)>0||r<0)&&(i+=" +pm="+r),i}function Ht(t){return(t||"").replace(/^(GCS|D)_/i,"").replace(/[ _]/g,"").toLowerCase()}function Xt(t,e){t&&t[0].toLowerCase()!=e&&Ut("unexpected geographic units: "+geogcs.UNIT[0])}function Yt(t){return function(){return"+proj="+t}}function Kt(t){return function(e){var i,r;return[t.PROJECTION(e),t.PARAMETER(e),t.GEOGCS?t.GEOGCS(e):Wt(e.GEOGCS),(i=$t(e),r="",1!=i.to_meter&&(r="+to_meter="+i.to_meter),r),"+no_defs"].filter(function(t){return!!t}).join(" ")}}function Jt(t){return{NAME:ee(t),DATUM:Qt(t),PRIMEM:["Greenwich",0],UNIT:["degree",.017453292519943295]}}function Qt(t){var e={NAME:re(t),SPHEROID:te(t)},i=Y(t.params,"stowgs84");return/[1-9]/.test(i)&&(e.TOWGS84=i),e}function te(t){var e;return e=Y(t.params,"trf")?Y(t.params,"drf"):t.es?1/(1-Math.sqrt(1-t.es)):0,[ie(t),t.a,e]}function ee(t){var e;return et(t)&&(e=le(t)),e||(e=ne(t),e=/^[a-z]+$/.test(e)?e[0].toUpperCase()+e.substr(1):e.toUpperCase()),e||"UNK"}function ie(t){var e=ct(function(t){var e=ne(t),i=e?at(e):null;return(i?i.ellipse_id:Y(t.params,"sellps"))||""}(t));return e?e.name:"Unknown ellipsoid"}function re(t){var e=at(ne(t));return e&&e.name||"Unknown datum"}function ne(t){return Y(t.params,"sdatum")}function se(t){return Nt(t)(t)}function oe(t,e){return ae({PROJECTION:t,PARAMETER:De(e)})}function ae(t){return function(e){var i={GEOGCS:t.GEOGCS&&t.GEOGCS(e)||Jt(e),PROJECTION:Bt(t.PROJECTION)?t.PROJECTION:t.PROJECTION(e),PARAMETER:t.PARAMETER(e),UNIT:Zt(e)};return i.NAME=t.NAME&&t.NAME(e,i)||function(t,e){var i=le(t);return i||e.GEOGCS.NAME+" / "+e.PROJECTION}(e,i),{PROJCS:i}}}function le(t){var e;return Y(t.params,"tinit")&&(e=mt(Y(t.params,"sinit"))),e?e.comment:""}function ce(t,e,i){var r=ue(e),n=function(t,e){return Kt({PROJECTION:Yt(t),PARAMETER:Pe(e)})}(t,i);de(r,n)}function he(t,e,i){fe(pe(t),oe(e,i))}function ue(t){var e=Gt(t).map(qt);return function(t){var i=t.PROJECTION[0];return e.indexOf(qt(i))>-1}}function pe(t){return function(e){var i=jt(e);return i&&i==t}}function de(t,e){"function"!=typeof t&&Ut("Missing WKT parser test"),"function"!=typeof e&&Ut("Missing WKT parse function"),Ft.push([t,e])}function fe(t,e){"function"!=typeof t&&Ut("Missing WKT maker test"),"function"!=typeof e&&Ut("Missing WKT maker function"),Lt.push([t,e])}de(function(t){return me.test(qt(t.NAME))},function(t){return Kt({PROJECTION:Yt("utm"),PARAMETER:function(t){var e=me.exec(qt(t.NAME)),i="+zone="+e[1];return"s"==e[2].toLowerCase()&&(i+=" +south"),i}})(t)}),de(function(t){return _e.test(qt(t.NAME))},function(t){return Kt({PROJECTION:Yt("ups"),PARAMETER:function(t){var e=_e.exec(qt(t.NAME));return"south"==e[1].toLowerCase()?"+south":""}})(t)}),fe(pe("utm"),function(t){return ae({NAME:ge,PROJECTION:function(){return"Transverse_Mercator"},PARAMETER:ve})(t)}),fe(pe("ups"),function(t){return ae({NAME:ye,PROJECTION:function(){return"Polar_Stereographic"},PARAMETER:xe})(t)});var me=/UTM_zone_([0-9]{1,2})(N|S)/i,_e=/UPS_(North|South)/i;function ge(t,e){return e.GEOGCS.NAME+" / UTM zone "+Y(t.params,"szone")+(Y(t.params,"tsouth")?"S":"N")}function ye(t,e){return e.GEOGCS.NAME+" / UPS "+(Y(t.params,"tsouth")?"South":"North")}function ve(t){return[["latitude_of_origin",0],["central_meridian",180*t.lam0/w],["scale_factor",t.k0],["false_easting",t.x0],["false_northing",t.y0]]}function xe(t){return[["latitude_of_origin",-90],["central_meridian",0],["scale_factor",.994],["false_easting",2e6],["false_northing",2e6]]}function be(t){return Y(t.params,"tlat_ts")&&0!=Y(t.params,"dlat_ts")}function we(t){return 0===t.es&&6378137==t.a}de(ue("Mercator_2SP,Mercator_1SP,Mercator,Mercator_Auxiliary_Sphere"),Kt({GEOGCS:function(t){var e=function(t){return/(Web_Mercator|Pseudo_Mercator)/i.test(qt(t.NAME))}(t)?{aux_sphere:!0}:null;return Wt(t.GEOGCS,e)},PROJECTION:Yt("merc"),PARAMETER:function(t){return Pe(function(t){var e=Ae(t,"standard_parallel_1");return e&&0!=e[1]}(t)?"lat_ts,lat_0b":"lat_tsb,lat_ts")(t)}})),fe(pe("merc"),ae({GEOGCS:function(t){return we(t)?Jt(_t("+proj=longlat +datum=WGS84")):null},PROJECTION:function(t){return be(t)?"Mercator_2SP":"Mercator_1SP"},PARAMETER:function(t){return De(be(t)?"lat_ts,lat_0b":"lat_tsb")(t)},NAME:function(t){return we(t)?"WGS 84 / Pseudo-Mercator":null}}));var Se=[["x_0","false_easting","m"],["y_0","false_northing","m"],["k_0","scale_factor","f"],["lat_0","latitude_of_center"],["lon_0","central_meridian"]],Te={lat_0b:["lat_0","latitude_of_origin"],lat_0c:["lat_0",null],lat_0d:["lat_0","standard_parallel_1"],lat_1:["lat_1","standard_parallel_1"],lat_1b:["lat_1","latitude_of_point_1"],lat_1c:["lat_1","latitude_of_origin"],lat_2:["lat_2","standard_parallel_2"],lat_2b:["lat_2","latitude_of_point_2"],lat_ts:["lat_ts","standard_parallel_1"],lat_tsb:["lat_ts","latitude_of_origin"],lonc:["lonc","central_meridian"],lon_1:["lon_1","longitude_of_point_1"],lon_2:["lon_2","longitude_of_point_2"],alpha:["alpha","azimuth"],gamma:["gamma","rectified_grid_angle"],h:["h","height","f"]},Ce={longitude_of_center:"central_meridian",latitude_of_origin:"latitude_of_center",latitude_of_center:"latitude_of_origin",longitude_of_1st_point:"longitude_of_point_1",longitude_of_2nd_point:"longitude_of_point_2",latitude_of_1st_point:"latitude_of_point_1",latitude_of_2nd_point:"latitude_of_point_2",k:"k_0"};function Me(t,e,i){for(var r=0;r<i.length;r++)if(i[r][e]===t)return i[r];return null}function Ee(t,e,i){var r=null;return!(r=Me(t=t.toLowerCase(),e,i))&&t in Ce&&(r=Me(Ce[t],e,i)),r}function Ae(t,e){for(var i,r=t.PARAMETER||[],n=0;n<r.length;n++)if(e===(i=r[n][0].toLowerCase())||e===Ce[i])return r[n];return null}function Ie(t){var e=null;return t&&(e=Gt(t).reduce(function(t,e){var i=Te[e];return i||Ut("missing parameter rule: "+e),t.push(i),t},[])),(e||[]).concat(Se)}function Pe(t){return function(e){var i=[],r=Ie(t),n=$t(e);return(e.PARAMETER||[]).forEach(function(t){var e,s,o=Ee(t[0],1,r);o?(e=function(t,e,i){var r=t[0];if("m"==t[2]&&(e*=i.to_meter),!("x_0,y_0,lat_0,lon_0".indexOf(r)>-1&&0===e||"k_0"==r&&1==e))return"+"+r+"="+e}(o,t[1],n),e&&i.push(e)):(s="unhandled parameter: "+t[0],console.error("[wkt] "+s))}),i.join(" ")}}function De(t){return function(e){var i=[],r=Ie(t);return Object.keys(e.params).forEach(function(t){var n,s=Ee(t,0,r);s&&s[1]&&(n=Y(e.params,"s"+t),i.push(function(t,e,i){var r,n=t[2];return r="m"==n?parseFloat(e)/i:"f"==n?parseFloat(e):W(e),[t[1],r]}(s,n,e.to_meter)))}),i}}function ke(t){return!("lat_1"in t.params&&"lat_2"in t.params)}function ze(t){return"omerc"==jt(t)&&("alpha"in t.params||"gamma"in t.params)}function Re(t){return ze(t)&&("no_uoff"in t.params||"no_off"in t.params)}function Le(t){return Y(t.params,"tlat_ts")}function Fe(t){var e=JSON.stringify(Oe(t));return e=(e=e.replace(/\["([A-Z0-9]+)",/g,"$1[")).replace(/"(EAST|NORTH|SOUTH|WEST)"/g,"$1")}function Be(t){return"NAME,PROJCS,GEOGCS,GEOCCS,DATUM,SPHEROID,PRIMEM,PROJECTION,PARAMETER,UNIT,AXIS".indexOf(t)+1||999}function Oe(t,e){var i,r=[];return e=e||0,function(t){return Object.keys(t).sort(function(t,e){return Be(t)-Be(e)})}(t).forEach(function(n){var s=t[n];!function(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}(s)?"NAME"==n?r.push(Bt(s)?s:s[0]):"PARAMETER"==n||"AXIS"==n?s.forEach(function(t){r.push([n].concat(t))}):Bt(s)?r.push([n,s]):Array.isArray(s)?r.push([n].concat(s)):((i={})[n]=s,Ut("Incorrectly formatted WKT element: "+JSON.stringify(i))):r.push([n].concat(Oe(s,e+1)))}),0===e&&1==r.length&&(r=r[0]),r}function Ne(t){var e={};return Ve(t).forEach(function(t){qe(t,e)}),e}function Ve(t){var e;t="["+(t=(t=(t=je(t)).replace(/([A-Z0-9]+)\[(?![^"]*[^\[,"]")/g,'["$1",')).replace(/, *([a-zA-Z]+) *(?=[,\]])/g,',"$1"'))+"]";try{e=JSON.parse(t)}catch(t){Ut("unparsable WKT format")}return e}function je(t){var e=0;return t.replace(/"+/g,function(t){var i=e%2==0;return e+=t.length,'"'==t||'""'==t&&i?t:i?'"'+t.substring(1).replace(/""/g,'\\"'):t.replace(/""/g,'\\"')})}function qe(t,e){var i,r=t[0];if("GEOGCS"==r||"GEOCCS"==r||"PROJCS"==r||"DATUM"==r||"VERTCS"==r)for(e[r]={NAME:t[1]},i=2;i<t.length;i++){if(!Array.isArray(t[i]))throw Ut("WKT parse error");qe(t[i],e[r])}else"AXIS"==r||"PARAMETER"==r?(r in e==0&&(e[r]=[]),e[r].push(t.slice(1))):e[r]=t.slice(1);return e}de(ue("Lambert_Conformal_Conic,Lambert_Conformal_Conic_1SP,Lambert_Conformal_Conic_2SP"),Kt({PROJECTION:Yt("lcc"),PARAMETER:function(t){return Pe(function(t){return!Ae(t,"standard_parallel_2")}(t)?"lat_1c":"lat_0b,lat_1,lat_2")(t)}})),fe(pe("lcc"),ae({PROJECTION:function(t){return ke(t)?"Lambert_Conformal_Conic_1SP":"Lambert_Conformal_Conic_2SP"},PARAMETER:function(t){return De(ke(t)?"lat_1c,lat_0c":"lat_0b,lat_1,lat_2")(t)}})),de(ue("Hotine_Oblique_Mercator,Hotine_Oblique_Mercator_Azimuth_Natural_Origin"),Kt({PROJECTION:Yt("omerc"),PARAMETER:function(t){return Pe("alpha,gamma,lonc")(t)+" +no_uoff"}})),fe(Re,oe("Hotine_Oblique_Mercator","alpha,gamma,lonc")),ce("omerc","Oblique_Mercator,Hotine_Oblique_Mercator_Azimuth_Center","alpha,gamma,lonc"),fe(function(t){return ze(t)&&!Re(t)},oe("Oblique_Mercator","alpha,gamma,lonc")),ce("omerc","Hotine_Oblique_Mercator_Two_Point_Natural_Origin","lat_1b,lat_2b,lon_1,lon_2"),fe(function(t){return"omerc"==jt(t)&&"lat_2"in t.params&&"lon_2"in t.params},oe("Hotine_Oblique_Mercator_Two_Point_Natural_Origin","lat_1b,lat_2b,lon_1,lon_2")),de(ue("Stereographic,Polar_Stereographic,Stereographic_North_Pole,Stereographic_South_Pole"),Kt({PROJECTION:Yt("stere"),PARAMETER:function(t){var e=Pe("lat_ts,lat_tsb")(t),i=/lat_ts=([^ ]+)/.exec(e);return i&&-1==e.indexOf("lat_0=")&&(e="+lat_0="+(parseFloat(i[1])<0?-90:90)+" "+e),e}})),fe(pe("stere"),ae({PROJECTION:function(t){return Le(t)?"Polar_Stereographic":"Stereographic"},PARAMETER:function(t){return Le(t)?De("lat_tsb,lat_0c")(t):De("lat_0b")(t)}})),he("vandg","VanDerGrinten"),de(ue("VanDerGrinten,Van_der_Grinten_I"),Kt({PROJECTION:Yt("vandg"),PARAMETER:function(t){var e=Pe("")(t);return e&&(e+=" "),e+"+R_A"}})),[["aitoff","Aitoff","lat1"],["aea","Albers_Conic_Equal_Area,Albers","lat_1,lat_2"],["aeqd","Azimuthal_Equidistant"],["bonne","Bonne","lat_1"],["cass","Cassini_Soldner,Cassini"],["cea","Cylindrical_Equal_Area","lat_ts"],["eck1","Eckert_I"],["eck2","Eckert_II"],["eck3","Eckert_III"],["eck4","Eckert_IV"],["eck5","Eckert_V"],["eck6","Eckert_VI"],["eqdc","Equidistant_Conic","lat_1,lat_2"],["eqc","Plate_Carree,Equirectangular,Equidistant_Cylindrical","lat_ts"],["gall","Gall_Stereographic"],["gnom","Gnomonic"],["laea","Lambert_Azimuthal_Equal_Area"],["loxim","Loximuthal","lat_1"],["mill","Miller_Cylindrical"],["moll","Mollweide"],["nsper","Vertical_Near_Side_Perspective","h"],["nzmg","New_Zealand_Map_Grid","lat_0b"],["ortho","Orthographic","lat_0b"],["poly","Polyconic"],["robin","Robinson"],["sinu","Sinusoidal"],["sterea","Oblique_Stereographic,Double_Stereographic"],["tmerc","Transverse_Mercator,Gauss_Kruger","lat_0b"],["tpeqd","Two_Point_Equidistant","lat_1b,lat_2b,lon_1,lon_2"],["wag1","Wagner_I"],["wag2","Wagner_II"],["wag3","Wagner_III","lat_ts"],["wag4","Wagner_IV"],["wag5","Wagner_V"],["wag6","Wagner_VI"],["wag7","Wagner_VII"],["wink1","Winkel_I","lat_ts"],["wink2","Winkel_II"],["wintri","Winkel_Tripel","lat_1"]].forEach(function(t){var e=t[2]||null;ce(t[0],t[1],e),he(t[0],t[1].split(",")[0],e)});var Ge,Ue,$e={};function Ze(t,e,i){var r;return e>=1e-7?i*(t/(1-(r=e*t)*r)-.5/e*d((1-r)/(1+r))):t+t}function We(t,e,i){return e/h(1-i*t*t)}function He(e,n,s){var a,l,u,p,m,_,g,y,v,b,w,S,T,C;e.fwd=function(t,n){var s,o=t.lam;(s=u-(g?l*Ze(i(t.phi),e.e,e.one_es):m*i(t.phi)))<0&&V(),s=p*h(s),n.x=s*i(o*=l),n.y=_-s*r(o)},e.inv=function(n,s){var h=n.x,y=_-n.y,v=f(h,y);0!=v?(l<0&&(v=-v,h=-h,y=-y),s.phi=v/p,g?(s.phi=(u-s.phi*s.phi)/l,t(a-t(s.phi))>1e-7?(s.phi=function(e,n,s){var a,l,c,h,u,p,f=15,m=1e-7,_=1e-10;if(a=o(.5*e),n<m)return a;p=f;do{a+=u=.5*(h=1-(c=n*(l=i(a)))*c)*h/r(a)*(e/s-l/h+.5/n*d((1-c)/(1+c)))}while(t(u)>_&&--p);return p?a:x}(s.phi,e.e,e.one_es))==x&&j():s.phi=s.phi<0?-A:A):t(s.phi=(u-s.phi*s.phi)/m)<=1?s.phi=o(s.phi):s.phi=s.phi<0?-A:A,s.lam=c(h,y)/l):(s.lam=0,s.phi=l>0?A:-A)},t(n+s)<R&&G(-21),l=v=i(n),y=r(n),b=t(n-s)>=R,(g=e.es>0)?(Xe(e.es),C=We(v,y,e.es),T=Ze(v,e.e,e.one_es),b&&(S=We(v=i(s),y=r(s),e.es),w=Ze(v,e.e,e.one_es),l=(C*C-S*S)/(w-T)),a=1-.5*e.one_es*d((1-e.e)/(1+e.e))/e.e,_=(p=1/l)*h((u=C*C+l*T)-l*Ze(i(e.phi0),e.e,e.one_es))):(b&&(l=.5*(l+i(s))),_=(p=1/l)*h((u=y*y+(m=l+l)*v)-m*i(e.phi0)))}function Xe(t){var e,i=.046875,r=.01953125,n=.01068115234375,s=[];return s[0]=1-t*(.25+t*(i+t*(r+t*n))),s[1]=t*(.75-t*(i+t*(r+t*n))),s[2]=(e=t*t)*(.46875-t*(.013020833333333334+.007120768229166667*t)),s[3]=(e*=t)*(.3645833333333333-.005696614583333333*t),s[4]=e*t*.3076171875,s}function Ye(t,e,i,r){return i*=e,e*=e,r[0]*t-i*(r[1]+e*(r[2]+e*(r[3]+e*r[4])))}function Ke(e,n,s){var o,a,l,c=1/(1-n);l=e;for(var u=10;u>0;--u)if(a=1-n*(o=i(l))*o,l-=a=(Ye(l,o,r(l),s)-e)*(a*h(a))*c,t(a)<1e-11)return l;return N(L),l}function Je(e){var i=t(e);return i>=1?(i>1.00000000000001&&N(-19),e<0?-A:A):o(e)}function Qe(e){var i=t(e);return i>=1?(i>1.00000000000001&&N(-19),e<0?w:0):a(e)}function ti(t){return t<=0?0:h(t)}function ei(e,i){return t(e)<1e-50&&t(i)<1e-50?0:c(e,i)}function ii(e){var n=e.opaque||{mode:0};e.inv=function(e,s){var o,l,c,h,p,d,f,m,_,g,y,v,x,b,S,T,C,M=1e-12,E=0;if(t(e.x)<M&&t(e.y)<M)return s.phi=0,void(s.lam=0);s.phi=e.y,s.lam=e.x;do{o=0;do{for(v=i(.5*s.lam),S=r(.5*s.lam),x=i(s.phi),c=1-(l=(b=r(s.phi))*S)*l,h=2*(l=a(l)/u(c,1.5))*c*b*v,p=l*c*x,d=2*(v*S*x*b/c-l*x*v),f=b*b*v*v/c+l*b*S*x*x,m=x*x*S/c+l*v*v*b,_=.5*(x*b*v/c-l*x*b*b*v*S),n.mode&&(h=.5*(h+s.lam*n.cosphi1),p=.5*(p+s.phi),d*=.5,f=.5*(f+n.cosphi1),m=.5*(m+1),_*=.5),h-=e.x,y=((p-=e.y)*d-h*m)/(g=d*_-m*f),g=(h*_-p*f)/g;y>w;)y-=w;for(;y<-w;)y+=w;s.phi-=g,s.lam-=y}while((t(g)>M||t(y)>M)&&o++<10);s.phi>A&&(s.phi-=2*(s.phi-A)),s.phi<-A&&(s.phi-=2*(s.phi+A)),t(t(s.phi)-A)<M&&!n.mode&&(s.lam=0),(l=a(r(s.phi)*r(c=.5*s.lam)))?(T=2*l*r(s.phi)*i(c)*(C=1/i(l)),C*=l*i(s.phi)):T=C=0,n.mode&&(T=.5*(T+s.lam*n.cosphi1),C=.5*(C+s.phi))}while((t(e.x-T)>M||t(e.y-C)>M)&&E++<20)},e.fwd=function(t,e){var s,o;(o=a(r(t.phi)*r(s=.5*t.lam)))?(e.x=2*o*r(t.phi)*i(s)*(e.y=1/i(o)),e.y*=o*i(t.phi)):e.x=e.y=0,n.mode&&(e.x=.5*(e.x+t.lam*n.cosphi1),e.y=.5*(e.y+t.phi))},e.es=0}function ri(e,r,n){e.es=0,e.fwd=function(e,s){var o,a,l=2.4674011002723395;s.y=r?A*i(e.phi):e.phi,(o=t(e.lam))>=1e-10?(n&&o>=A?s.x=h(l-e.phi*e.phi+1e-10)+o-A:(a=.5*(l/o+o),s.x=o-a+h(a*a-s.y*s.y)),e.lam<0&&(s.x=-s.x)):s.x=0}}function ni(t){var e,i=[];return i[0]=.3333333333333333*t,e=t*t,i[0]+=.17222222222222222*e,i[1]=.06388888888888888*e,e*=t,i[0]+=.10257936507936508*e,i[1]+=.0664021164021164*e,i[2]=.01677689594356261*e,i}function si(t,e){var r=t+t;return t+e[0]*i(r)+e[1]*i(r+r)+e[2]*i(r+r+r)}function oi(t,e){t.es=0,t.fwd=function(t,i){i.y=e.C_y*t.phi,i.x=e.C_x*t.lam*(e.A+ti(1-e.B*t.phi*t.phi))},t.inv=function(t,i){i.phi=t.y/e.C_y,i.lam=t.x/(e.C_x*(e.A+ti(1-e.B*i.phi*i.phi)))}}function ai(e){var s,o,a,u,p,g,y=[],v=[],b=[],w=[];function S(t,e){for(var n,s=2*r(2*e),o=t.length-1,a=t[o],l=0;--o>=0;)n=s*a-l+t[o],l=a,a=n;return e+n*i(2*e)}function T(t,e,n){for(var s,o,a=i(e),l=r(e),c=m(n),h=_(n),u=2*l*h,p=-2*a*c,d=t.length-1,f=t[d],g=0,y=0,v=0;--d>=0;)s=y,o=g,f=u*(y=f)-s-p*(g=v)+t[d],v=p*y-o+u*g;return[(u=a*h)*f-(p=l*c)*v,u*v+p*f]}e.es<=0&&G(-34),p=u=(a=e.es/(1+h(1-e.es)))/(2-a),y[0]=u*(2+u*(-2/3+u*(u*(116/45+u*(26/45+u*(-2854/675)))-2))),v[0]=u*(u*(2/3+u*(4/3+u*(-82/45+u*(32/45+u*(4642/4725)))))-2),p*=u,y[1]=p*(7/3+u*(u*(-227/45+u*(2704/315+u*(2323/945)))-1.6)),v[1]=p*(5/3+u*(-16/15+u*(-13/9+u*(904/315+u*(-1522/945))))),p*=u,y[2]=p*(56/15+u*(-136/35+u*(-1262/105+u*(73814/2835)))),v[2]=p*(-26/15+u*(34/21+u*(1.6+u*(-12686/2835)))),p*=u,y[3]=p*(4279/630+u*(-332/35+u*(-399572/14175))),v[3]=p*(1237/630+u*(u*(-24832/14175)-2.4)),p*=u,y[4]=p*(4174/315+u*(-144838/6237)),v[4]=p*(-734/315+u*(109598/31185)),p*=u,y[5]=p*(601676/22275),v[5]=p*(444337/155925),p=u*u,s=e.k0/(1+u)*(1+p*(1/4+p*(1/64+p/256))),b[0]=u*(u*(2/3+u*(-37/96+u*(1/360+u*(81/512+u*(-96199/604800)))))-.5),w[0]=u*(.5+u*(-2/3+u*(5/16+u*(41/180+u*(-127/288+u*(7891/37800)))))),b[1]=p*(-1/48+u*(-1/15+u*(437/1440+u*(-46/105+u*(1118711/3870720))))),w[1]=p*(13/48+u*(u*(557/1440+u*(281/630+u*(-1983433/1935360)))-.6)),p*=u,b[2]=p*(-17/480+u*(37/840+u*(209/4480+u*(-5569/90720)))),w[2]=p*(61/240+u*(-103/140+u*(15061/26880+u*(167603/181440)))),p*=u,b[3]=p*(-4397/161280+u*(11/504+u*(830251/7257600))),w[3]=p*(49561/161280+u*(-179/168+u*(6601661/7257600))),p*=u,b[4]=p*(-4583/161280+u*(108847/3991680)),w[4]=p*(34729/80640+u*(-3418889/1995840)),p*=u,b[5]=p*(-20648693/638668800),w[5]=.6650675310896665*p,g=S(v,e.phi0),o=-s*(g+function(t,e){for(var n,s=2*r(e),o=t.length-1,a=t[o],l=0;--o>=0;)n=s*a-l+t[o],l=a,a=n;return i(e)*n}(w,2*g)),e.fwd=function(e,a){var l,h,u,p,m,_=e.phi,g=e.lam;_=S(v,_),l=i(_),h=r(_),p=i(g),u=r(g),_=c(l,u*h),g=c(p*h,f(l,h*u)),g=function(e){var i=t(e);return i=function(t){var e=1+t,i=e-1;return 0===i?t:t*d(e)/i}(i*(1+i/(f(1,i)+1))),e<0?-i:i}(n(g)),m=T(w,2*_,2*g),_+=m[0],g+=m[1],t(g)<=2.623395162778?(a.y=s*_+o,a.x=s*g):a.x=a.y=x},e.inv=function(e,n){var a,h,u,p,d,_=e.y,g=e.x;_=(_-o)/s,t(g/=s)<=2.623395162778?(_+=(d=T(b,2*_,2*g))[0],g+=d[1],g=l(m(g)),a=i(_),h=r(_),p=i(g),u=r(g),g=c(p,u*h),_=c(a*u,f(p,u*h)),n.phi=S(y,_),n.lam=g):n.phi=n.lam=x}}function li(e){var n;e.es?(n=Xe(e.es),e.fwd=function(t,s){var o,a;s.y=Ye(t.phi,o=i(t.phi),a=r(t.phi),n),s.x=t.lam*a/h(1-e.es*o*o)},e.inv=function(s,o){var a=t(o.phi=Ke(s.y,e.es,n));a<A?(a=i(o.phi),o.lam=s.x*h(1-e.es*a*a)/r(o.phi)):a-R<A?o.lam=0:j()}):ci(e,0,1)}function ci(e,n,s){var o,a;o=(a=h((n+1)/s))/(n+1),e.es=0,e.fwd=function(e,l){var c,h,u;if(n){for(c=s*i(e.phi),u=8;u&&(e.phi-=h=(n*e.phi+i(e.phi)-c)/(n+r(e.phi)),!(t(h)<1e-7));--u);u||V()}else e.phi=1!=s?Je(s*i(e.phi)):e.phi;l.x=o*e.lam*(n+r(e.phi)),l.y=a*e.phi},e.inv=function(t,e){t.y/=a,e.phi=n?Je((n*t.y+i(t.y))/s):1!=s?Je(i(t.y)/s):t.y,e.lam=t.x/(o*(n+r(t.y)))}}function hi(t){pi(t,ui(0,A))}function ui(t,e){var r=i(e),n=e+e,s=h(P*r/(n+i(n)));return{C_x:2*s/w,C_y:s/r,C_p:n+i(n)}}function pi(e,n){e.fwd=function(e,s){var o,a,l;for(o=n.C_p*i(e.phi),l=10;l&&(e.phi-=a=(e.phi+i(e.phi)-o)/(1+r(e.phi)),!(t(a)<1e-7));--l);l?e.phi*=.5:e.phi=e.phi<0?-A:A,s.x=n.C_x*e.lam*r(e.phi),s.y=n.C_y*i(e.phi)},e.inv=function(e,s){s.phi=Je(e.y/n.C_y),s.lam=e.x/(n.C_x*r(s.phi)),t(s.lam)-w<R?(s.phi+=s.phi,s.phi=Je((s.phi+i(s.phi))/n.C_p)):s.lam=s.phi=x},e.es=0}function di(r,n){var s,a,l,c,p,d=[[0,-1],[1,0]],f=[[-1,0],[0,-1]],m=[[0,1],[-1,0]],_=[[[1,0],[0,1]],d,f,m,m,f,d],v=1e-15;function b(r,n){var s=r.lam,a=r.phi,l=o(2/3);if(t(a)<=l)n.x=s,n.y=3*w/8*i(a);else{var c,u=h(3*(1-t(i(a)))),p=e(2*s/w+2);p>=4&&(p=3),c=-3*E+A*p,n.x=c+(s-c)*u,n.y=T(a)*E*(2-u)}}function S(i,r){var n=i.x,s=i.y,a=E;if(t(s)<=a)r.lam=n,r.phi=o(8*s/(3*w));else if(t(s)<A){var l,c,h=e(2*n/w+2);h>=4&&(h=3),l=-3*E+A*h,c=2-4*t(s)/w,r.lam=l+(n-l)/c,r.phi=T(s)*o(1-u(c,2)/3)}else r.lam=-w,r.phi=T(s)*A}function T(t){return t>0?1:t<0?-1:0}function C(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case-1:return 4;case-2:return 5;case-3:return 6}return 0}function M(t,e){return function(t,e,i){var r,n,s,o,a,l=0,c=t.length;for(a=0;a<c;a++)if(e==t[a][0]&&i==t[a][1])return!0;for(r=t[0][0],n=t[0][1],a=1;a<c;a++)s=t[a%c][0],o=t[a%c][1],i>g(n,o)&&i<=y(n,o)&&e<=y(r,s)&&n!=o&&(r==s||e<=(i-n)*(s-r)/(o-n)+r)&&l++,r=s,n=o;return l%2!=0}(p,t,e)}function I(e,r,n){if(n)return si(r,c);var s=Ze(i(r),e.e,1-e.es)/l;return t(s)>1&&(s=T(s)),o(s)}function P(t,e,i,r){var n,s,o,a,l,c,h=0,u=function(t,e,i,r,n){var s,o={};if(o.x=t,o.y=e,n){if(e>E)o.region="north",o.x=-3*E+i*A,o.y=A,t-=i*A;else{if(!(e<-E))return o.region="equatorial",o.cn=0,o;o.region="south",o.x=-3*E+r*A,o.y=-A,t-=r*A}"north"==o.region?o.cn=e>=-t-E-v&&e<t+5*E-v?(i+1)%4:e>-t-E+v&&e>=t+5*E-v?(i+2)%4:e<=-t-E+v&&e>t+5*E+v?(i+3)%4:i:"south"==o.region&&(o.cn=e<=t+E+v&&e>-t-5*E+v?(r+1)%4:e<t+E-v&&e<=-t-5*E+v?(r+2)%4:e>=t+E-v&&e<-t-5*E-v?(r+3)%4:r)}else{if(e>E)o.region="north",s=A;else{if(!(e<-E))return o.region="equatorial",o.cn=0,o;o.region="south",s=-A}t<-A?(o.cn=0,o.x=-3*E,o.y=s):t>=-A&&t<0?(o.cn=1,o.x=-E,o.y=s):t>=0&&t<A?(o.cn=2,o.x=E,o.y=s):(o.cn=3,o.x=3*E,o.y=s)}return o}(t.x,t.y,e,i,r);if("equatorial"==u.region)return t.x=u.x,void(t.y=u.y);n=[t.x,t.y],s=[u.x,u.y],r?"north"==u.region?(h=e,c=_[C(-1*(u.cn-h))]):(h=i,c=_[C(u.cn-h)]):"north"==u.region?(h=e,c=_[C(u.cn-h)]):(h=i,c=_[C(-1*(u.cn-h))]),a=function(t,e){return[t[0]-e[0],t[1]-e[1]]}(n,s),l=function(t,e){var i,r,n=[0,0];for(i=0;i<2;i++)for(r=0;r<2;r++)n[i]+=t[i][r]*e[r];return n}(c,a),o=function(t,e){return[t[0]+e[0],t[1]+e[1]]}(l,[-3*E+(r?u.cn:0)*A,A]),t.x=o[0],t.y=o[1]}n?(s=Y(r.params,"inorth_square"),a=Y(r.params,"isouth_square"),(s<0||s>3)&&G(-47),(a<0||a>3)&&G(-47),p=[[-w-v,E+v],[s*A-w-v,E+v],[s*A-w-v,3*E+v],[(s+1)*A-w+v,3*E+v],[(s+1)*A-w+v,E+v],[w+v,E+v],[w+v,-E-v],[(a+1)*A-w+v,-E-v],[(a+1)*A-w+v,-3*E-v],[a*A-w-v,-3*E-v],[a*A-w-v,-E-v],[-w-v,-E-v]],0!=r.es?(c=ni(r.es),l=Ze(1,r.e,r.one_es),r.a=r.a*h(.5*l),r.ra=1/r.a,r.fwd=function(t,e){return t.phi=I(r,t.phi,0),b(t,e),P(e,s,a,0)},r.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void N(-15);P(t,s,a,1),S(t,e),e.phi=I(r,e.phi,1)}):(r.fwd=function(t,e){b(t,e),P(e,s,a,0)},r.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void N(-15);P(t,s,a,1),S(t,e)})):(p=[[-w-v,E],[-3*E,A+v],[-A,E+v],[-E,A+v],[0,E+v],[E,A+v],[A,E+v],[3*E,A+v],[w+v,E],[w+v,-E],[3*E,-A-v],[A,-E-v],[E,-A-v],[0,-E-v],[-E,-A-v],[-A,-E-v],[-3*E,-A-v],[-w-v,-E]],0!=r.es?(c=ni(r.es),l=Ze(1,r.e,r.one_es),r.a=r.a*h(.5*l),r.ra=1/r.a,r.fwd=function(t,e){t.phi=I(r,t.phi,0),b(t,e)},r.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void N(-15);S(t,e),e.phi=I(r,e.phi,1)}):(r.fwd=function(t,e){b(t,e)},r.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void N(-15);S(t,e)}))}function fi(t){t.x0=0,t.y0=0,t.is_latlong=!0,t.fwd=function(e,i){i.x=e.lam/t.a,i.y=e.phi/t.a},t.inv=function(e,i){i.lam=e.x*t.a,i.phi=e.y*t.a}}function mi(t,e,i){return e*=i,n(.5*(A-t))/u((1-e)/(1+e),.5*i)}function _i(e,r){var n,s,o=.5*r,a=A-2*l(e),c=15;do{n=r*i(a),a+=s=A-2*l(e*u((1-n)/(1+n),o))-a}while(t(s)>1e-10&&--c);return c<=0&&N(-18),a}function gi(t,e){var i,r,n,s=e.length-1;for(r=e[s][0],n=e[s][1];--s>=0;)i=r,r=e[s][0]+t.r*i-t.i*n,n=e[s][1]+t.r*n+t.i*i;return{r:t.r*r-t.i*n,i:t.r*n+t.i*r}}function yi(t,e,i){var r,n,s,o,a,l=!0,c=e.length-1;for(n=o=e[c][0],r=s=e[c][1];--c>=0;)l?l=!1:(o=n+t.r*(a=o)-t.i*s,s=r+t.r*s+t.i*a),n=e[c][0]+t.r*(a=n)-t.i*r,r=e[c][1]+t.r*r+t.i*a;return i.r=n+t.r*o-t.i*s,i.i=r+t.r*s+t.i*o,{r:t.r*n-t.i*r,i:t.r*r+t.i*n}}function vi(e,s){var o,a,h,p,d=1e-12;0!=e.es?(o=e.e*i(e.phi0),a=2*l(n(.5*(A+e.phi0))*u((1-o)/(1+o),.5*e.e))-A):a=e.phi0,p=i(a),h=r(a),e.inv=function(o,a){var m,_,g,y,v,b,w,S={},T={},C={},M=0,E=0,I=0,P=0;for(S.r=o.x,S.i=o.y,m=20;m&&((_=yi(S,s,T)).r-=o.x,_.i-=o.y,g=T.r*T.r+T.i*T.i,C.r=-(_.r*T.r+_.i*T.i)/g,C.i=-(_.i*T.r-_.r*T.i)/g,S.r+=C.r,S.i+=C.i,!(t(C.r)+t(C.i)<=d));--m);if(m){if(M=f(S.r,S.i),y=2*l(.5*M),E=i(y),I=r(y),a.lam=e.lam0,t(M)<=d)return a.lam=0,void(a.phi=e.phi0);for(P=v=Je(I*p+S.i*E*h/M),m=20;m&&(b=e.e*i(P),P+=w=2*l(n(.5*(A+v))*u((1+b)/(1-b),.5*e.e))-A-P,!(t(w)<=d));--m);}m?(a.phi=P,a.lam=c(S.r*E,M*h*I-S.i*p*E)):a.lam=a.phi=x},e.fwd=function(t,o){var a,c,d,f,m,_,g,y={};a=i(t.lam),c=r(t.lam),d=e.e*i(t.phi),f=2*l(n(.5*(A+t.phi))*u((1-d)/(1+d),.5*e.e))-A,m=i(f),_=r(f),g=2/(1+p*m+h*_*c),y.r=g*_*a,y.i=g*(h*m-p*_*c),y=gi(y,s),o.x=y.r,o.y=y.i}}function xi(e,n,s,a){var l,u,p,d,m,_,g,y,v,x,b,w,S=!isNaN(s)&&!isNaN(a);n<=0&&G(-30),S&&(v=r(a),x=i(a),w=r(s),b=i(s)),t(t(e.phi0)-A)<R?l=e.phi0<0?1:0:t(e.phi0)<R?l=2:(l=3,u=i(e.phi0),p=r(e.phi0)),_=n/e.a,m=1/(d=1+_),g=(d+1)*(y=1/_),e.fwd=function(t,e){var n,s,o,a,c;switch(o=i(t.phi),s=r(t.phi),n=r(t.lam),l){case 3:e.y=u*o+p*s*n;break;case 2:e.y=s*n;break;case 1:e.y=-o;break;case 0:e.y=o}switch(e.y<m&&V(),e.y=_/(d-e.y),e.x=e.y*s*i(t.lam),l){case 3:e.y*=p*o-u*s*n;break;case 2:e.y*=o;break;case 0:n=-n;case 1:e.y*=s*n}S&&(c=1/((a=e.y*v+e.x*x)*b*y+w),e.x=(e.x*v-e.y*x)*w*c,e.y=a*c)},e.inv=function(r,n){var s,a,m,y,T,C;if(S&&(C=1/(_-r.y*b),y=_*r.x*C,T=_*r.y*w*C,r.x=y*v+T*x,r.y=T*v-y*x),s=f(r.x,r.y),(m=1-s*s*g)<0&&j(),m=(d-h(m))/(_/s+s/_),a=h(1-m*m),t(s)<=R)n.lam=0,n.phi=e.phi0;else{switch(l){case 3:n.phi=o(a*u+r.y*m*p/s),r.y=(a-u*i(n.phi))*s,r.x*=m*p;break;case 2:n.phi=o(r.y*m/s),r.y=a*s,r.x*=m;break;case 0:n.phi=o(a),r.y=-r.y;break;case 1:n.phi=-o(a)}n.lam=c(r.x,r.y)}},e.es=0}function bi(t,e){var i=.79788456,r=.1013211836*(e?2:4);t.es=0,t.fwd=function(t,e){e.x=i*t.lam*(1-r*t.phi*t.phi),e.y=i*t.phi},t.inv=function(t,e){e.phi=t.y/i,e.lam=t.x/(i*(1-r*e.phi*e.phi))}}function wi(t,e,n){t.es=0,t.fwd=function(t,s){t.phi=Je(.883883476*i(t.phi)),s.x=e*t.lam*r(t.phi),s.x/=r(t.phi*=.333333333333333),s.y=n*i(t.phi)},t.inv=function(t,s){s.phi=Je(t.y/n),s.lam=t.x*r(s.phi)/e,s.phi*=3,s.lam/=r(s.phi),s.phi=Je(1.13137085*i(s.phi))}}function Si(t,e){var i=e?1.5:2,r=e?.5:1,n=1.01346,s=1.2158542;t.es=0,t.fwd=function(t,e){e.x=n*t.lam*(i-r*h(1+s*t.phi*t.phi)),e.y=n*t.phi},t.inv=function(t,e){e.phi=t.y/n,e.lam=t.x/(n*(i-r*h(1+s*e.phi*e.phi)))}}function Ti(e,r){var n,s,o,a,l,c=1.732050807568877;r?(o=.44329,a=.80404,n=6,s=5.61125,l=3):(o=1.01346,a=.9191,n=4,s=2.147143718212938,l=2),e.es=0,e.fwd=function(e,r){var u,p,f,m;for(u=s*i(e.phi),e.phi*=1.10265779,m=10;m&&(p=h(1+e.phi*e.phi),e.phi-=f=((n-p)*e.phi-d(e.phi+p)-u)/(n-2*p),!(t(f)<1e-10));--m);m||(e.phi=u<0?-c:c),r.x=o*e.lam*(l-h(1+e.phi*e.phi)),r.y=a*e.phi},e.inv=function(t,e){var i;e.phi=t.y/a,i=h(1+e.phi*e.phi),e.lam=t.x/(o*(l-i)),e.phi=Je(((n-i)*e.phi-d(e.phi+i))/s)}}function Ci(e){return function(s){!function(e,s){var o,a,u,p,d,m,_,g,y,v,x=1e-10;switch(Y(e.params,"tlat_1")&&Y(e.params,"tlat_2")?(u=Y(e.params,"rlat_1"),p=Y(e.params,"rlat_2"),g=.5*(p+u),(t(o=.5*(p-u))<x||t(g)<x)&&G(-42)):G(-41),s){case"TISSOT":d=i(g),a=r(o),_=h(((m=d/a+a/d)-2*i(e.phi0))/d);break;case"MURD1":m=i(o)/(o*n(g))+g,_=m-e.phi0,d=i(g);break;case"MURD2":m=(a=h(r(o)))/n(g),_=m+n(g-e.phi0),d=i(g)*a;break;case"MURD3":m=o/(n(g)*n(o))+g,_=m-e.phi0,d=i(g)*i(o)*n(o)/(o*o);break;case"EULER":d=i(g)*i(o)/o,m=(o*=.5)/(n(o)*n(g))+g,_=m-e.phi0;break;case"PCONIC":d=i(g),v=r(o),y=1/n(g),t(o=e.phi0-g)-x>=A&&G(-43),_=v*(y-n(o));break;case"VITK1":d=(a=n(o))*i(g)/o,m=o/(a*n(g))+g,_=m-e.phi0}function b(t,e){var o;switch(s){case"MURD2":o=m+n(g-t.phi);break;case"PCONIC":o=v*(y-n(t.phi-g));break;default:o=m-t.phi}e.x=o*i(t.lam*=d),e.y=_-o*r(t.lam)}function w(t,e){var i;switch(i=f(t.x,t.y=_-t.y),d<0&&(i=-i,t.x=-t.x,t.y=-t.y),e.lam=c(t.x,t.y)/d,s){case"PCONIC":e.phi=l(y-i/v)+g;break;case"MURD2":e.phi=g-l(i-m);break;default:e.phi=m-i}}e.inv=w,e.fwd=b,e.es=0}(s,e)}}function Mi(e,s){var a,p,d,m,_,g,y,v,x=1e-10;if(v=t((p=t(e.phi0))-A)<x?e.phi0<0?0:1:p>x?2:3,s=t(s),e.es){switch(v){case 1:case 0:t(s-A)<x?y=2*e.k0/h(u(1+e.e,1+e.e)*u(1-e.e,1-e.e)):(y=r(s)/mi(s,p=i(s),e.e),p*=e.e,y/=h(1-p*p));break;case 3:case 2:p=i(e.phi0),a=2*l(b(e.phi0,p,e.e))-A,p*=e.e,y=2*e.k0*r(e.phi0)/h(1-p*p),_=i(a),g=r(a)}e.fwd=function(t,n){var s,o,a,c,h,u=0,p=0;switch(s=r(t.lam),o=i(t.lam),h=i(t.phi),(2==v||3==v)&&(u=i(a=2*l(b(t.phi,h,e.e))-A),p=r(a)),v){case 2:c=y/(g*(1+_*u+g*p*s)),n.y=c*(g*u-_*p*s),n.x=c*p;break;case 3:c=y/(1+p*s),n.y=c*u,n.x=c*p;break;case 0:t.phi=-t.phi,s=-s,h=-h;case 1:n.x=y*mi(t.phi,h,e.e),n.y=-n.x*s}n.x=n.x*o},e.inv=function(s,a){a.phi;var h,p,d,m,x=0,b=0,w=0,S=0;switch(d=f(s.x,s.y),v){case 2:case 3:h=r(x=2*c(d*g,y)),p=i(x),b=o(0==d?h*_:h*_+s.y*p*g/d),x=n(.5*(A+b)),s.x*=p,s.y=d*g*h-s.y*_*p,S=A,w=.5*e.e;break;case 1:s.y=-s.y;case 0:b=A-2*l(x=-d/y),S=-A,w=-.5*e.e}for(m=0;m<8;m++,b=a.phi)if(p=e.e*i(b),a.phi=2*l(x*u((1+p)/(1-p),w))-S,t(b-a.phi)<1e-10)return 0==v&&(a.phi=-a.phi),void(a.lam=0==s.x&&0==s.y?0:c(s.x,s.y));j()}}else{switch(v){case 2:d=i(e.phi0),m=r(e.phi0);case 3:y=2*e.k0;break;case 0:case 1:y=t(s-A)>=x?r(s)/n(E-.5*s):2*e.k0}e.fwd=function(e,s){var o=e.phi,a=i(o),l=r(o),c=r(e.lam),h=i(e.lam);switch(v){case 3:case 2:s.y=3==v?1+l*c:1+d*a+m*l*c,s.y<=x&&V(),s.x=(s.y=y/s.y)*l*h,s.y*=3==v?a:m*a-d*l*c;break;case 1:c=-c,o=-o;case 0:t(o-A)<1e-8&&V(),s.x=h*(s.y=y*n(E+.5*o)),s.y*=c}},e.inv=function(n,s){var a,h,u,p;switch(u=i(a=2*l((h=f(n.x,n.y))/y)),p=r(a),s.lam=0,v){case 3:t(h)<=x?s.phi=0:s.phi=o(n.y*u/h),0==p&&0==n.x||(s.lam=c(n.x*u,p*h));break;case 2:t(h)<=x?s.phi=e.phi0:s.phi=o(p*d+n.y*u*m/h),0==(a=p-d*i(s.phi))&&0==n.x||(s.lam=c(n.x*u*m,a*h));break;case 1:n.y=-n.y;case 0:t(h)<=x?s.phi=e.phi0:s.phi=o(0==v?-p:p),s.lam=0==n.x&&0==n.y?0:c(n.x,n.y)}}}function b(t,e,i){return e*=i,n(.5*(A+t))*u((1-e)/(1+e),.5*i)}}function Ei(t,e){return u((1-t)/(1+t),e)}function Ai(t,e,s,o){var a=s/e,c=e,h=1/s;t.inv=function(t,e){var i;t.y/=c,i=r(e.phi=o?l(t.y):Je(t.y)),e.phi/=h,e.lam=t.x/(a*r(e.phi)),o?e.lam/=i*i:e.lam*=i},t.fwd=function(t,e){var s;e.x=a*t.lam*r(t.phi),e.y=c,t.phi*=h,s=r(t.phi),o?(e.x*=s*s,e.y*=n(t.phi)):(e.x/=s,e.y*=i(t.phi))},t.es=0}function Ii(e){var n,s,l,u=1e-10,f=.5,m=.16666666666666666,_=.08333333333333333,g=.05,y=.03333333333333333,v=.023809523809523808,x=.017857142857142856;e.es?((l=Xe(e.es))||e_error_0(),s=Ye(e.phi0,i(e.phi0),r(e.phi0),l),n=e.es/(1-e.es),e.fwd=function(o,a){var c,p,d,f,b,w;o.lam<-A||o.lam>A?N(-14):(c=i(o.phi),p=r(o.phi),d=t(p)>u?c/p:0,d*=d,f=p*o.lam,b=f*f,f/=h(1-e.es*c*c),w=n*p*p,a.x=e.k0*f*(1+m*b*(1-d+w+g*b*(5+d*(d-18)+w*(14-58*d)+v*b*(61+d*(d*(179-d)-479))))),a.y=e.k0*(Ye(o.phi,c,p,l)-s+c*f*o.lam*.5*(1+_*b*(5-d+w*(9+4*w)+y*b*(61+d*(d-58)+w*(270-330*d)+x*b*(1385+d*(d*(543-d)-3111)))))))},e.inv=function(o,a){var c,u,p,d,b,w,S;a.phi=Ke(s+o.y/e.k0,e.es,l),t(a.phi)>=A?(a.phi=o.y<0?-A:A,a.lam=0):(w=i(a.phi),p=r(a.phi),S=t(p)>1e-10?w/p:0,c=n*p*p,d=o.x*h(u=1-e.es*w*w)/e.k0,u*=S,S*=S,b=d*d,a.phi-=u*b/(1-e.es)*f*(1-b*_*(5+S*(3-9*c)+c*(1-4*c)-b*y*(61+S*(90-252*c+45*S)+46*c-b*x*(1385+S*(3633+S*(4095+1575*S)))))),a.lam=d*(1-b*m*(1+2*S+c-b*g*(5+S*(28+24*S+8*c)+6*c-b*v*(61+S*(662+S*(1320+720*S))))))/p)}):(n=e.k0,s=.5*n,e.fwd=function(o,l){var c,p;o.lam<-A||o.lam>A?N(-14):(p=r(o.phi),c=p*i(o.lam),t(t(c)-1)<=u&&V(),l.x=s*d((1+c)/(1-c)),l.y=p*r(o.lam)/h(1-c*c),(c=t(l.y))>=1?c-1>u?V():l.y=0:l.y=a(l.y),o.phi<0&&(l.y=-l.y),l.y=n*(l.y-e.phi0))},e.inv=function(t,i){var s=p(t.x/n),a=.5*(s-1/s);s=r(e.phi0+t.y/n),i.phi=o(h((1-s*s)/(1+a*a))),t.y<0&&-i.phi+e.phi0<0&&(i.phi=-i.phi),i.lam=a||s?c(a,s):0})}function Pi(t,e){var n=.8773826753,s=1.139753528477/e;t.es=0,t.fwd=function(t,o){var a=Je(e*i(t.phi));o.x=n*t.lam*r(a),o.y=s*a},t.inv=function(t,o){t.y/=s,o.phi=Je(i(t.y)/e),o.lam=t.x/(n*r(t.y))}}function Di(e,i){e.fwd=function(e,r){var n,s,o,a;o=t(D*e.phi),a=(a=1-o*o)<0?0:h(a),t(e.lam)<1e-10?(r.x=0,r.y=w*(e.phi<0?-o:o)/(1+a)):(s=.5*t(w/e.lam-e.lam/w),i?(n=o/(1+a),r.x=w*(h(s*s+1-n*n)-s),r.y=w*n):(n=(a*h(1+s*s)-s*a*a)/(1+s*s*o*o),r.x=w*n,r.y=w*h(1-n*(n+2*s)+1e-10)),e.lam<0&&(r.x=-r.x),e.phi<0&&(r.y=-r.y))},e.es=0}$e.Constants={},$e.Math={},$e.Accumulator={},(Ge=$e.Constants).WGS84={a:6378137,f:1/298.257223563},Ge.version={major:1,minor:48,patch:0},Ge.version_string="1.48",(Ue=$e.Math).digits=53,Ue.epsilon=Math.pow(.5,Ue.digits-1),Ue.degree=Math.PI/180,Ue.sq=function(t){return t*t},Ue.hypot=function(t,e){var i,r;return t=Math.abs(t),e=Math.abs(e),i=Math.max(t,e),r=Math.min(t,e)/(i||1),i*Math.sqrt(1+r*r)},Ue.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},Ue.log1p=function(t){var e=1+t,i=e-1;return 0===i?t:t*Math.log(e)/i},Ue.atanh=function(t){var e=Math.abs(t);return e=Ue.log1p(2*e/(1-e))/2,t<0?-e:e},Ue.copysign=function(t,e){return Math.abs(t)*(e<0||0===e&&1/e<0?-1:1)},Ue.sum=function(t,e){var i=t+e,r=i-e,n=i-r;return{s:i,t:-((r-=t)+(n-=e))}},Ue.polyval=function(t,e,i,r){for(var n=t<0?0:e[i++];--t>=0;)n=n*r+e[i++];return n},Ue.AngRound=function(t){if(0===t)return t;var e=1/16,i=Math.abs(t);return i=i<e?e-(e-i):i,t<0?-i:i},Ue.AngNormalize=function(t){return(t%=360)<=-180?t+360:t<=180?t:t-360},Ue.LatFix=function(t){return Math.abs(t)>90?Number.NaN:t},Ue.AngDiff=function(t,e){var i=Ue.sum(Ue.AngNormalize(-t),Ue.AngNormalize(e)),r=Ue.AngNormalize(i.s),n=i.t;return Ue.sum(180===r&&n>0?-180:r,n)},Ue.sincosd=function(t){var e,i,r,n,s,o;switch(e=t%360,e-=90*(i=Math.floor(e/90+.5)),e*=this.degree,r=Math.sin(e),n=Math.cos(e),3&i){case 0:s=r,o=n;break;case 1:s=n,o=-r;break;case 2:s=-r,o=-n;break;default:s=-n,o=r}return t&&(s+=0,o+=0),{s:s,c:o}},Ue.atan2d=function(t,e){var i,r,n=0;switch(Math.abs(t)>Math.abs(e)&&(i=e,e=t,t=i,n=2),e<0&&(e=-e,++n),r=Math.atan2(t,e)/this.degree,n){case 1:r=(t>=0?180:-180)-r;break;case 2:r=90-r;break;case 3:r=-90+r}return r},function(t,e){t.Accumulator=function(t){this.Set(t)},t.Accumulator.prototype.Set=function(e){e||(e=0),e.constructor===t.Accumulator?(this._s=e._s,this._t=e._t):(this._s=e,this._t=0)},t.Accumulator.prototype.Add=function(t){var i=e.sum(t,this._t),r=e.sum(i.s,this._s);i=i.t,this._s=r.s,this._t=r.t,0===this._s?this._s=i:this._t+=i},t.Accumulator.prototype.Sum=function(e){var i;return e?((i=new t.Accumulator(this)).Add(e),i._s):this._s},t.Accumulator.prototype.Negate=function(){this._s*=-1,this._t*=-1}}($e.Accumulator,$e.Math),$e.Geodesic={},$e.GeodesicLine={},$e.PolygonArea={},function(t,e,i,r,n){var s,o,a,l,c,h,u,p,d,f,m,_=20+r.digits+10,g=r.epsilon,y=200*g,v=Math.sqrt(g),x=g*y,b=1e3*v;t.tiny_=Math.sqrt(Number.MIN_VALUE),t.nC1_=6,t.nC1p_=6,t.nC2_=6,t.nC3_=6,t.nC4_=6,s=t.nC3_*(t.nC3_-1)/2,o=t.nC4_*(t.nC4_+1)/2,t.CAP_C1=1,t.CAP_C1p=2,t.CAP_C2=4,t.CAP_C3=8,t.CAP_C4=16,t.NONE=0,t.ARC=64,t.LATITUDE=128,t.LONGITUDE=256|t.CAP_C3,t.AZIMUTH=512,t.DISTANCE=1024|t.CAP_C1,t.STANDARD=t.LATITUDE|t.LONGITUDE|t.AZIMUTH|t.DISTANCE,t.DISTANCE_IN=2048|t.CAP_C1|t.CAP_C1p,t.REDUCEDLENGTH=4096|t.CAP_C1|t.CAP_C2,t.GEODESICSCALE=8192|t.CAP_C1|t.CAP_C2,t.AREA=16384|t.CAP_C4,t.ALL=32671,t.LONG_UNROLL=32768,t.OUT_MASK=32640|t.LONG_UNROLL,t.SinCosSeries=function(t,e,i,r){var n=r.length,s=n-(t?1:0),o=2*(i-e)*(i+e),a=1&s?r[--n]:0,l=0;for(s=Math.floor(s/2);s--;)a=o*(l=o*a-l+r[--n])-a+r[--n];return t?2*e*i*a:i*(a-l)},a=function(t,e){var i,n,s,o,a,l,c,h,u,p,d,f,m=r.sq(t),_=r.sq(e),g=(m+_-1)/6;return 0===_&&g<=0?i=0:(l=g,(a=(n=m*_/4)*(n+2*(o=g*(s=r.sq(g)))))>=0?(c=n+o,c+=c<0?-Math.sqrt(a):Math.sqrt(a),l+=(h=r.cbrt(c))+(0!==h?s/h:0)):(u=Math.atan2(Math.sqrt(-a),-(n+o)),l+=2*g*Math.cos(u/3)),p=Math.sqrt(r.sq(l)+_),f=((d=l<0?_/(p-l):l+p)-_)/(2*p),i=d/(Math.sqrt(d+r.sq(f))+f)),i},l=[1,4,64,0,256],t.A1m1f=function(t){var e=Math.floor(3);return(r.polyval(e,l,0,r.sq(t))/l[e+1]+t)/(1-t)},c=[-1,6,-16,32,-9,64,-128,2048,9,-16,768,3,-5,512,-7,1280,-7,2048],t.C1f=function(e,i){var n,s,o=r.sq(e),a=e,l=0;for(n=1;n<=t.nC1_;++n)s=Math.floor((t.nC1_-n)/2),i[n]=a*r.polyval(s,c,l,o)/c[l+s+1],l+=s+2,a*=e},h=[205,-432,768,1536,4005,-4736,3840,12288,-225,116,384,-7173,2695,7680,3467,7680,38081,61440],t.C1pf=function(e,i){var n,s,o=r.sq(e),a=e,l=0;for(n=1;n<=t.nC1p_;++n)s=Math.floor((t.nC1p_-n)/2),i[n]=a*r.polyval(s,h,l,o)/h[l+s+1],l+=s+2,a*=e},u=[-11,-28,-192,0,256],t.A2m1f=function(t){var e=Math.floor(3);return(r.polyval(e,u,0,r.sq(t))/u[e+1]-t)/(1+t)},p=[1,2,16,32,35,64,384,2048,15,80,768,7,35,512,63,1280,77,2048],t.C2f=function(e,i){var n,s,o=r.sq(e),a=e,l=0;for(n=1;n<=t.nC2_;++n)s=Math.floor((t.nC2_-n)/2),i[n]=a*r.polyval(s,p,l,o)/p[l+s+1],l+=s+2,a*=e},t.Geodesic=function(t,e){if(this.a=t,this.f=e,this._f1=1-this.f,this._e2=this.f*(2-this.f),this._ep2=this._e2/r.sq(this._f1),this._n=this.f/(2-this.f),this._b=this.a*this._f1,this._c2=(r.sq(this.a)+r.sq(this._b)*(0===this._e2?1:(this._e2>0?r.atanh(Math.sqrt(this._e2)):Math.atan(Math.sqrt(-this._e2)))/Math.sqrt(Math.abs(this._e2))))/2,this._etol2=.1*v/Math.sqrt(Math.max(.001,Math.abs(this.f))*Math.min(1,1-this.f/2)/2),!(isFinite(this.a)&&this.a>0))throw new Error("Equatorial radius is not positive");if(!(isFinite(this._b)&&this._b>0))throw new Error("Polar semi-axis is not positive");this._A3x=new Array(6),this._C3x=new Array(s),this._C4x=new Array(o),this.A3coeff(),this.C3coeff(),this.C4coeff()},d=[-3,128,-2,-3,64,-1,-3,-1,16,3,-1,-2,8,1,-1,2,1,1],t.Geodesic.prototype.A3coeff=function(){var t,e,i=0,n=0;for(t=5;t>=0;--t)e=Math.min(6-t-1,t),this._A3x[n++]=r.polyval(e,d,i,this._n)/d[i+e+1],i+=e+2},f=[3,128,2,5,128,-1,3,3,64,-1,0,1,8,-1,1,4,5,256,1,3,128,-3,-2,3,64,1,-3,2,32,7,512,-10,9,384,5,-9,5,192,7,512,-14,7,512,21,2560],t.Geodesic.prototype.C3coeff=function(){var e,i,n,s=0,o=0;for(e=1;e<t.nC3_;++e)for(i=t.nC3_-1;i>=e;--i)n=Math.min(t.nC3_-i-1,i),this._C3x[o++]=r.polyval(n,f,s,this._n)/f[s+n+1],s+=n+2},m=[97,15015,1088,156,45045,-224,-4784,1573,45045,-10656,14144,-4576,-858,45045,64,624,-4576,6864,-3003,15015,100,208,572,3432,-12012,30030,45045,1,9009,-2944,468,135135,5792,1040,-1287,135135,5952,-11648,9152,-2574,135135,-64,-624,4576,-6864,3003,135135,8,10725,1856,-936,225225,-8448,4992,-1144,225225,-1440,4160,-4576,1716,225225,-136,63063,1024,-208,105105,3584,-3328,1144,315315,-128,135135,-2560,832,405405,128,99099],t.Geodesic.prototype.C4coeff=function(){var e,i,n,s=0,o=0;for(e=0;e<t.nC4_;++e)for(i=t.nC4_-1;i>=e;--i)n=t.nC4_-i-1,this._C4x[o++]=r.polyval(n,m,s,this._n)/m[s+n+1],s+=n+2},t.Geodesic.prototype.A3f=function(t){return r.polyval(5,this._A3x,0,t)},t.Geodesic.prototype.C3f=function(e,i){var n,s,o=1,a=0;for(n=1;n<t.nC3_;++n)s=t.nC3_-n-1,o*=e,i[n]=o*r.polyval(s,this._C3x,a,e),a+=s+1},t.Geodesic.prototype.C4f=function(e,i){var n,s,o=1,a=0;for(n=0;n<t.nC4_;++n)s=t.nC4_-n-1,i[n]=o*r.polyval(s,this._C4x,a,e),a+=s+1,o*=e},t.Geodesic.prototype.Lengths=function(e,i,r,n,s,o,a,l,c,h,u,p,d){var f,m,_,g,y={},v=0,x=0,b=0,w=0;if((u&=t.OUT_MASK)&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&(b=t.A1m1f(e),t.C1f(e,p),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(w=t.A2m1f(e),t.C2f(e,d),v=b-w,w=1+w),b=1+b),u&t.DISTANCE)f=t.SinCosSeries(!0,o,a,p)-t.SinCosSeries(!0,r,n,p),y.s12b=b*(i+f),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(x=v*i+(b*f-w*(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,r,n,d))));else if(u&(t.REDUCEDLENGTH|t.GEODESICSCALE)){for(m=1;m<=t.nC2_;++m)d[m]=b*p[m]-w*d[m];x=v*i+(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,r,n,d))}return u&t.REDUCEDLENGTH&&(y.m0=v,y.m12b=l*(n*o)-s*(r*a)-n*a*x),u&t.GEODESICSCALE&&(_=n*a+r*o,g=this._ep2*(c-h)*(c+h)/(s+l),y.M12=_+(g*o-a*x)*r/s,y.M21=_-(g*r-n*x)*o/l),y},t.Geodesic.prototype.InverseStart=function(e,i,n,s,o,l,c,h,u,p,d){var f,m,_,g,v,x,w,S,T,C,M,E,A,I,P,D,k,z,R,L,F={},B=s*i-o*e,O=o*i+s*e;return F.sig12=-1,f=s*i,f+=o*e,(m=O>=0&&B<.5&&o*c<.5)?(g=r.sq(e+s),g/=g+r.sq(i+o),F.dnm=Math.sqrt(1+this._ep2*g),_=c/(this._f1*F.dnm),v=Math.sin(_),x=Math.cos(_)):(v=h,x=u),F.salp1=o*v,F.calp1=x>=0?B+o*e*r.sq(v)/(1+x):f-o*e*r.sq(v)/(1-x),S=r.hypot(F.salp1,F.calp1),T=e*s+i*o*x,m&&S<this._etol2?(F.salp2=i*v,F.calp2=B-i*s*(x>=0?r.sq(v)/(1+x):1-x),w=r.hypot(F.salp2,F.calp2),F.salp2/=w,F.calp2/=w,F.sig12=Math.atan2(S,T)):Math.abs(this._n)>.1||T>=0||S>=6*Math.abs(this._n)*Math.PI*r.sq(i)||(L=Math.atan2(-h,-u),this.f>=0?(I=(A=r.sq(e)*this._ep2)/(2*(1+Math.sqrt(1+A))+A),C=L/(E=this.f*i*this.A3f(I)*Math.PI),M=f/(E*i)):(P=o*i-s*e,D=Math.atan2(f,P),M=c/(E=((C=(k=this.Lengths(this._n,Math.PI+D,e,-i,n,s,o,l,i,o,t.REDUCEDLENGTH,p,d)).m12b/(i*o*k.m0*Math.PI)-1)<-.01?f/C:-this.f*r.sq(i)*Math.PI)/i)),M>-y&&C>-1-b?this.f>=0?(F.salp1=Math.min(1,-C),F.calp1=-Math.sqrt(1-r.sq(F.salp1))):(F.calp1=Math.max(C>-y?0:-1,C),F.salp1=Math.sqrt(1-r.sq(F.calp1))):(z=a(C,M),R=E*(this.f>=0?-C*z/(1+z):-M*(1+z)/z),v=Math.sin(R),x=-Math.cos(R),F.salp1=o*v,F.calp1=f-o*e*r.sq(v)/(1-x))),F.salp1<=0?(F.salp1=1,F.calp1=0):(w=r.hypot(F.salp1,F.calp1),F.salp1/=w,F.calp1/=w),F},t.Geodesic.prototype.Lambda12=function(e,i,n,s,o,a,l,c,h,u,p,d,f,m){var _,g,y,v,x,b,w,S,T,C,M,E,A,I={};return 0===e&&0===c&&(c=-t.tiny_),g=l*i,y=r.hypot(c,l*e),I.ssig1=e,v=g*e,I.csig1=x=c*i,_=r.hypot(I.ssig1,I.csig1),I.ssig1/=_,I.csig1/=_,I.salp2=o!==i?g/o:l,I.calp2=o!==i||Math.abs(s)!==-e?Math.sqrt(r.sq(c*i)+(i<-e?(o-i)*(i+o):(e-s)*(e+s)))/o:Math.abs(c),I.ssig2=s,b=g*s,I.csig2=w=I.calp2*o,_=r.hypot(I.ssig2,I.csig2),I.ssig2/=_,I.csig2/=_,I.sig12=Math.atan2(Math.max(0,I.csig1*I.ssig2-I.ssig1*I.csig2),I.csig1*I.csig2+I.ssig1*I.ssig2),S=Math.max(0,x*b-v*w),T=x*w+v*b,M=Math.atan2(S*u-T*h,T*u+S*h),E=r.sq(y)*this._ep2,I.eps=E/(2*(1+Math.sqrt(1+E))+E),this.C3f(I.eps,m),C=t.SinCosSeries(!0,I.ssig2,I.csig2,m)-t.SinCosSeries(!0,I.ssig1,I.csig1,m),I.domg12=-this.f*this.A3f(I.eps)*g*(I.sig12+C),I.lam12=M+I.domg12,p&&(0===I.calp2?I.dlam12=-2*this._f1*n/e:(A=this.Lengths(I.eps,I.sig12,I.ssig1,I.csig1,n,I.ssig2,I.csig2,a,i,o,t.REDUCEDLENGTH,d,f),I.dlam12=A.m12b,I.dlam12*=this._f1/(I.calp2*o))),I},t.Geodesic.prototype.Inverse=function(e,i,n,s,o){var a,l;return o||(o=t.STANDARD),o===t.LONG_UNROLL&&(o|=t.STANDARD),o&=t.OUT_MASK,l=(a=this.InverseInt(e,i,n,s,o)).vals,o&t.AZIMUTH&&(l.azi1=r.atan2d(a.salp1,a.calp1),l.azi2=r.atan2d(a.salp2,a.calp2)),l},t.Geodesic.prototype.InverseInt=function(e,i,n,s,o){var a,l,c,h,u,p,d,f,m,y,v,b,w,S,T,C,M,E,A,I,P,D,k,z,R,L,F,B,O,N,V,j,q,G,U,$,Z,W,H,X,Y,K,J,Q,tt,et,it,rt,nt,st,ot,at,lt,ct,ht,ut,pt,dt,ft,mt,_t,gt,yt,vt,xt,bt={};if(bt.lat1=e=r.LatFix(e),bt.lat2=n=r.LatFix(n),e=r.AngRound(e),n=r.AngRound(n),l=(a=r.AngDiff(i,s)).t,a=a.s,o&t.LONG_UNROLL?(bt.lon1=i,bt.lon2=i+a+l):(bt.lon1=r.AngNormalize(i),bt.lon2=r.AngNormalize(s)),a=(c=a>=0?1:-1)*r.AngRound(a),l=r.AngRound(180-a-c*l),T=a*r.degree,C=(h=r.sincosd(a>90?l:a)).s,M=(a>90?-1:1)*h.c,(u=Math.abs(e)<Math.abs(n)?-1:1)<0&&(c*=-1,h=e,e=n,n=h),e*=p=e<0?1:-1,n*=p,h=r.sincosd(e),d=this._f1*h.s,f=h.c,d/=h=r.hypot(d,f),f/=h,f=Math.max(t.tiny_,f),h=r.sincosd(n),m=this._f1*h.s,y=h.c,m/=h=r.hypot(m,y),y/=h,y=Math.max(t.tiny_,y),f<-d?y===f&&(m=m<0?d:-d):Math.abs(m)===-d&&(y=f),w=Math.sqrt(1+this._ep2*r.sq(d)),S=Math.sqrt(1+this._ep2*r.sq(m)),k=new Array(t.nC1_+1),z=new Array(t.nC2_+1),R=new Array(t.nC3_),(L=-90===e||0===C)&&(I=C,D=0,B=d,O=(A=M)*f,N=m,V=(P=1)*y,E=Math.atan2(Math.max(0,O*N-B*V),O*V+B*N),v=(F=this.Lengths(this._n,E,B,O,w,N,V,S,f,y,o|t.DISTANCE|t.REDUCEDLENGTH,k,z)).s12b,b=F.m12b,0!==(o&t.GEODESICSCALE)&&(bt.M12=F.M12,bt.M21=F.M21),E<1||b>=0?(E<3*t.tiny_&&(E=b=v=0),b*=this._b,v*=this._b,bt.a12=E/r.degree):L=!1),pt=2,!L&&0===d&&(this.f<=0||l>=180*this.f))A=P=0,I=D=1,v=this.a*T,E=q=T/this._f1,b=this._b*Math.sin(E),o&t.GEODESICSCALE&&(bt.M12=bt.M21=Math.cos(E)),bt.a12=a/this._f1;else if(!L)if(E=(F=this.InverseStart(d,f,w,m,y,S,T,C,M,k,z)).sig12,I=F.salp1,A=F.calp1,E>=0)D=F.salp2,P=F.calp2,G=F.dnm,v=E*this._b*G,b=r.sq(G)*this._b*Math.sin(E/G),o&t.GEODESICSCALE&&(bt.M12=bt.M21=Math.cos(E/G)),bt.a12=E/r.degree,q=T/(this._f1*G);else{for(U=0,$=t.tiny_,Z=1,W=t.tiny_,H=-1,X=!1,Y=!1;U<_&&(K=(F=this.Lambda12(d,f,w,m,y,S,I,A,C,M,U<20,k,z,R)).lam12,D=F.salp2,P=F.calp2,E=F.sig12,B=F.ssig1,O=F.csig1,N=F.ssig2,V=F.csig2,j=F.eps,ft=F.domg12,J=F.dlam12,!Y&&Math.abs(K)>=(X?8:1)*g);++U)K>0&&(U<20||A/I>H/W)?(W=I,H=A):K<0&&(U<20||A/I<Z/$)&&($=I,Z=A),U<20&&J>0&&(Q=-K/J,tt=Math.sin(Q),(it=I*(et=Math.cos(Q))+A*tt)>0&&Math.abs(Q)<Math.PI)?(A=A*et-I*tt,I=it,I/=h=r.hypot(I,A),A/=h,X=Math.abs(K)<=16*g):(I=($+W)/2,A=(Z+H)/2,I/=h=r.hypot(I,A),A/=h,X=!1,Y=Math.abs($-I)+(Z-A)<x||Math.abs(I-W)+(A-H)<x);rt=o|(o&(t.REDUCEDLENGTH|t.GEODESICSCALE)?t.DISTANCE:t.NONE),v=(F=this.Lengths(j,E,B,O,w,N,V,S,f,y,rt,k,z)).s12b,b=F.m12b,0!==(o&t.GEODESICSCALE)&&(bt.M12=F.M12,bt.M21=F.M21),b*=this._b,v*=this._b,bt.a12=E/r.degree,o&t.AREA&&(vt=Math.sin(ft),pt=C*(xt=Math.cos(ft))-M*vt,dt=M*xt+C*vt)}return o&t.DISTANCE&&(bt.s12=0+v),o&t.REDUCEDLENGTH&&(bt.m12=0+b),o&t.AREA&&(nt=I*f,0!==(st=r.hypot(A,I*d))&&0!==nt?(B=d,O=A*f,N=m,V=P*y,j=(at=r.sq(st)*this._ep2)/(2*(1+Math.sqrt(1+at))+at),lt=r.sq(this.a)*st*nt*this._e2,B/=h=r.hypot(B,O),O/=h,N/=h=r.hypot(N,V),V/=h,ct=new Array(t.nC4_),this.C4f(j,ct),ht=t.SinCosSeries(!1,B,O,ct),ut=t.SinCosSeries(!1,N,V,ct),bt.S12=lt*(ut-ht)):bt.S12=0,!L&&pt>1&&(pt=Math.sin(q),dt=Math.cos(q)),!L&&dt>-.7071&&m-d<1.75?(ft=1+dt,mt=1+f,_t=1+y,ot=2*Math.atan2(pt*(d*_t+m*mt),ft*(d*m+mt*_t))):(yt=P*A+D*I,0===(gt=D*A-P*I)&&yt<0&&(gt=t.tiny_*A,yt=-1),ot=Math.atan2(gt,yt)),bt.S12+=this._c2*ot,bt.S12*=u*c*p,bt.S12+=0),u<0&&(h=I,I=D,D=h,h=A,A=P,P=h,o&t.GEODESICSCALE&&(h=bt.M12,bt.M12=bt.M21,bt.M21=h)),{vals:bt,salp1:I*=u*c,calp1:A*=u*p,salp2:D*=u*c,calp2:P*=u*p}},t.Geodesic.prototype.GenDirect=function(i,r,n,s,o,a){return a?a===t.LONG_UNROLL&&(a|=t.STANDARD):a=t.STANDARD,s||(a|=t.DISTANCE_IN),new e.GeodesicLine(this,i,r,n,a).GenPosition(s,o,a)},t.Geodesic.prototype.Direct=function(t,e,i,r,n){return this.GenDirect(t,e,i,!1,r,n)},t.Geodesic.prototype.ArcDirect=function(t,e,i,r,n){return this.GenDirect(t,e,i,!0,r,n)},t.Geodesic.prototype.Line=function(t,i,r,n){return new e.GeodesicLine(this,t,i,r,n)},t.Geodesic.prototype.DirectLine=function(t,e,i,r,n){return this.GenDirectLine(t,e,i,!1,r,n)},t.Geodesic.prototype.ArcDirectLine=function(t,e,i,r,n){return this.GenDirectLine(t,e,i,!0,r,n)},t.Geodesic.prototype.GenDirectLine=function(i,r,n,s,o,a){var l;return a||(a=t.STANDARD|t.DISTANCE_IN),s||(a|=t.DISTANCE_IN),(l=new e.GeodesicLine(this,i,r,n,a)).GenSetDistance(s,o),l},t.Geodesic.prototype.InverseLine=function(i,n,s,o,a){var l,c,h;return a||(a=t.STANDARD|t.DISTANCE_IN),l=this.InverseInt(i,n,s,o,t.ARC),h=r.atan2d(l.salp1,l.calp1),a&t.OUT_MASK&t.DISTANCE_IN&&(a|=t.DISTANCE),(c=new e.GeodesicLine(this,i,n,h,a,l.salp1,l.calp1)).SetArc(l.vals.a12),c},t.Geodesic.prototype.Polygon=function(t){return new i.PolygonArea(this,t)},t.WGS84=new t.Geodesic(n.WGS84.a,n.WGS84.f)}($e.Geodesic,$e.GeodesicLine,$e.PolygonArea,$e.Math,$e.Constants),function(t,e,i){e.GeodesicLine=function(e,r,n,s,o,a,l){var c,h,u,p,d,f;o||(o=t.STANDARD|t.DISTANCE_IN),this.a=e.a,this.f=e.f,this._b=e._b,this._c2=e._c2,this._f1=e._f1,this.caps=o|t.LATITUDE|t.AZIMUTH|t.LONG_UNROLL,this.lat1=i.LatFix(r),this.lon1=n,void 0===a||void 0===l?(this.azi1=i.AngNormalize(s),c=i.sincosd(i.AngRound(this.azi1)),this.salp1=c.s,this.calp1=c.c):(this.azi1=s,this.salp1=a,this.calp1=l),c=i.sincosd(i.AngRound(this.lat1)),u=this._f1*c.s,h=c.c,u/=c=i.hypot(u,h),h/=c,h=Math.max(t.tiny_,h),this._dn1=Math.sqrt(1+e._ep2*i.sq(u)),this._salp0=this.salp1*h,this._calp0=i.hypot(this.calp1,this.salp1*u),this._ssig1=u,this._somg1=this._salp0*u,this._csig1=this._comg1=0!==u||0!==this.calp1?h*this.calp1:1,c=i.hypot(this._ssig1,this._csig1),this._ssig1/=c,this._csig1/=c,this._k2=i.sq(this._calp0)*e._ep2,p=this._k2/(2*(1+Math.sqrt(1+this._k2))+this._k2),this.caps&t.CAP_C1&&(this._A1m1=t.A1m1f(p),this._C1a=new Array(t.nC1_+1),t.C1f(p,this._C1a),this._B11=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C1a),d=Math.sin(this._B11),f=Math.cos(this._B11),this._stau1=this._ssig1*f+this._csig1*d,this._ctau1=this._csig1*f-this._ssig1*d),this.caps&t.CAP_C1p&&(this._C1pa=new Array(t.nC1p_+1),t.C1pf(p,this._C1pa)),this.caps&t.CAP_C2&&(this._A2m1=t.A2m1f(p),this._C2a=new Array(t.nC2_+1),t.C2f(p,this._C2a),this._B21=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C2a)),this.caps&t.CAP_C3&&(this._C3a=new Array(t.nC3_),e.C3f(p,this._C3a),this._A3c=-this.f*this._salp0*e.A3f(p),this._B31=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C3a)),this.caps&t.CAP_C4&&(this._C4a=new Array(t.nC4_),e.C4f(p,this._C4a),this._A4=i.sq(this.a)*this._calp0*this._salp0*e._e2,this._B41=t.SinCosSeries(!1,this._ssig1,this._csig1,this._C4a)),this.a13=this.s13=Number.NaN},e.GeodesicLine.prototype.GenPosition=function(e,r,n){var s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C,M,E,A,I,P,D={};return n?n===t.LONG_UNROLL&&(n|=t.STANDARD):n=t.STANDARD,n&=this.caps&t.OUT_MASK,D.lat1=this.lat1,D.azi1=this.azi1,D.lon1=n&t.LONG_UNROLL?this.lon1:i.AngNormalize(this.lon1),e?D.a12=r:D.s12=r,e||this.caps&t.DISTANCE_IN&t.OUT_MASK?(l=0,c=0,e?(s=r*i.degree,o=(E=i.sincosd(r)).s,a=E.c):(p=r/(this._b*(1+this._A1m1)),d=Math.sin(p),f=Math.cos(p),s=p-((l=-t.SinCosSeries(!0,this._stau1*f+this._ctau1*d,this._ctau1*f-this._stau1*d,this._C1pa))-this._B11),o=Math.sin(s),a=Math.cos(s),Math.abs(this.f)>.01&&(h=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,l=t.SinCosSeries(!0,h,u,this._C1a),s-=((1+this._A1m1)*(s+(l-this._B11))-r/this._b)/Math.sqrt(1+this._k2*i.sq(h)),o=Math.sin(s),a=Math.cos(s))),h=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,S=Math.sqrt(1+this._k2*i.sq(h)),n&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&((e||Math.abs(this.f)>.01)&&(l=t.SinCosSeries(!0,h,u,this._C1a)),c=(1+this._A1m1)*(l-this._B11)),g=this._calp0*h,0===(y=i.hypot(this._salp0,this._calp0*u))&&(y=u=t.tiny_),b=this._salp0,w=this._calp0*u,e&&n&t.DISTANCE&&(D.s12=this._b*((1+this._A1m1)*s+c)),n&t.LONGITUDE&&(v=this._salp0*h,x=u,_=i.copysign(1,this._salp0),m=((n&t.LONG_UNROLL?_*(s-(Math.atan2(h,u)-Math.atan2(this._ssig1,this._csig1))+(Math.atan2(_*v,x)-Math.atan2(_*this._somg1,this._comg1))):Math.atan2(v*this._comg1-x*this._somg1,x*this._comg1+v*this._somg1))+this._A3c*(s+(t.SinCosSeries(!0,h,u,this._C3a)-this._B31)))/i.degree,D.lon2=n&t.LONG_UNROLL?this.lon1+m:i.AngNormalize(i.AngNormalize(this.lon1)+i.AngNormalize(m))),n&t.LATITUDE&&(D.lat2=i.atan2d(g,this._f1*y)),n&t.AZIMUTH&&(D.azi2=i.atan2d(b,w)),n&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(T=t.SinCosSeries(!0,h,u,this._C2a),C=(1+this._A2m1)*(T-this._B21),M=(this._A1m1-this._A2m1)*s+(c-C),n&t.REDUCEDLENGTH&&(D.m12=this._b*(S*(this._csig1*h)-this._dn1*(this._ssig1*u)-this._csig1*u*M)),n&t.GEODESICSCALE&&(E=this._k2*(h-this._ssig1)*(h+this._ssig1)/(this._dn1+S),D.M12=a+(E*h-u*M)*this._ssig1/this._dn1,D.M21=a-(E*this._ssig1-this._csig1*M)*h/S)),n&t.AREA&&(A=t.SinCosSeries(!1,h,u,this._C4a),0===this._calp0||0===this._salp0?(I=b*this.calp1-w*this.salp1,P=w*this.calp1+b*this.salp1):(I=this._calp0*this._salp0*(a<=0?this._csig1*(1-a)+o*this._ssig1:o*(this._csig1*o/(1+a)+this._ssig1)),P=i.sq(this._salp0)+i.sq(this._calp0)*this._csig1*u),D.S12=this._c2*Math.atan2(I,P)+this._A4*(A-this._B41)),e||(D.a12=s/i.degree),D):(D.a12=Number.NaN,D)},e.GeodesicLine.prototype.Position=function(t,e){return this.GenPosition(!1,t,e)},e.GeodesicLine.prototype.ArcPosition=function(t,e){return this.GenPosition(!0,t,e)},e.GeodesicLine.prototype.GenSetDistance=function(t,e){t?this.SetArc(e):this.SetDistance(e)},e.GeodesicLine.prototype.SetDistance=function(e){var i;this.s13=e,i=this.GenPosition(!1,this.s13,t.ARC),this.a13=0+i.a12},e.GeodesicLine.prototype.SetArc=function(e){var i;this.a13=e,i=this.GenPosition(!0,this.a13,t.DISTANCE),this.s13=0+i.s12}}($e.Geodesic,$e.GeodesicLine,$e.Math),function(t,e,i,r){var n,s;n=function(t,e){var r;return t=i.AngNormalize(t),e=i.AngNormalize(e),r=i.AngDiff(t,e).s,t<=0&&e>0&&r>0?1:e<=0&&t>0&&r<0?-1:0},s=function(t,e){return((e%=720)>=0&&e<360||e<-360?0:1)-((t%=720)>=0&&t<360||t<-360?0:1)},t.PolygonArea=function(t,i){this._geod=t,this.a=this._geod.a,this.f=this._geod.f,this._area0=4*Math.PI*t._c2,this.polyline=i||!1,this._mask=e.LATITUDE|e.LONGITUDE|e.DISTANCE|(this.polyline?e.NONE:e.AREA|e.LONG_UNROLL),this.polyline||(this._areasum=new r.Accumulator(0)),this._perimetersum=new r.Accumulator(0),this.Clear()},t.PolygonArea.prototype.Clear=function(){this.num=0,this._crossings=0,this.polyline||this._areasum.Set(0),this._perimetersum.Set(0),this._lat0=this._lon0=this.lat=this.lon=Number.NaN},t.PolygonArea.prototype.AddPoint=function(t,e){var i;0===this.num?(this._lat0=this.lat=t,this._lon0=this.lon=e):(i=this._geod.Inverse(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(i.s12),this.polyline||(this._areasum.Add(i.S12),this._crossings+=n(this.lon,e)),this.lat=t,this.lon=e),++this.num},t.PolygonArea.prototype.AddEdge=function(t,e){var i;this.num&&(i=this._geod.Direct(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(e),this.polyline||(this._areasum.Add(i.S12),this._crossings+=s(this.lon,i.lon2)),this.lat=i.lat2,this.lon=i.lon2),++this.num},t.PolygonArea.prototype.Compute=function(t,e){var i,s,o={number:this.num};return this.num<2?(o.perimeter=0,this.polyline||(o.area=0),o):this.polyline?(o.perimeter=this._perimetersum.Sum(),o):(i=this._geod.Inverse(this.lat,this.lon,this._lat0,this._lon0,this._mask),o.perimeter=this._perimetersum.Sum(i.s12),(s=new r.Accumulator(this._areasum)).Add(i.S12),1&this._crossings+n(this.lon,this._lon0)&&s.Add((s.Sum()<0?1:-1)*this._area0/2),t||s.Negate(),e?s.Sum()>this._area0/2?s.Add(-this._area0):s.Sum()<=-this._area0/2&&s.Add(+this._area0):(s.Sum()>=this._area0||s<0)&&s.Add(-this._area0),o.area=s.Sum(),o)},t.PolygonArea.prototype.TestPoint=function(t,e,i,r){var s,o,a,l,c={number:this.num+1};if(0===this.num)return c.perimeter=0,this.polyline||(c.area=0),c;for(c.perimeter=this._perimetersum.Sum(),o=this.polyline?0:this._areasum.Sum(),a=this._crossings,l=0;l<(this.polyline?1:2);++l)s=this._geod.Inverse(0===l?this.lat:t,0===l?this.lon:e,0!==l?this._lat0:t,0!==l?this._lon0:e,this._mask),c.perimeter+=s.s12,this.polyline||(o+=s.S12,a+=n(0===l?this.lon:e,0!==l?this._lon0:e));return this.polyline||(1&a&&(o+=(o<0?1:-1)*this._area0/2),i||(o*=-1),r?o>this._area0/2?o-=this._area0:o<=-this._area0/2&&(o+=this._area0):o>=this._area0?o-=this._area0:o<0&&(o+=this._area0),c.area=o),c},t.PolygonArea.prototype.TestEdge=function(t,e,i,r){var o,a,l,c={number:this.num?this.num+1:0};return 0===this.num||(c.perimeter=this._perimetersum.Sum()+e,this.polyline||(a=this._areasum.Sum(),l=this._crossings,a+=(o=this._geod.Direct(this.lat,this.lon,t,e,this._mask)).S12,l+=s(this.lon,o.lon2),o=this._geod.Inverse(o.lat2,o.lon2,this._lat0,this._lon0,this._mask),c.perimeter+=o.s12,a+=o.S12,1&(l+=n(o.lon2,this._lon0))&&(a+=(a<0?1:-1)*this._area0/2),i||(a*=-1),r?a>this._area0/2?a-=this._area0:a<=-this._area0/2&&(a+=this._area0):a>=this._area0?a-=this._area0:a<0&&(a+=this._area0),c.area=a)),c}}($e.PolygonArea,$e.Geodesic,$e.Math,$e.Accumulator),tt(function(t){var e=Y(t.params,"rlat_1"),i=Y(t.params,"rlat_2");He(t,e,i)},"aea","Albers Equal Area","Conic Sph&Ell\nlat_1= lat_2="),tt(function(t){var e=Y(t.params,"rlat_1"),i=Y(t.params,"bsouth")?-A:A;He(t,e,i)},"leac","Lambert Equal Area Conic","Conic, Sph&Ell\nlat_1= south"),tt(function(e){var s,o,l,u,p,d,m,_=1e-10;if(e.phi0=Y(e.params,"rlat_0"),t(t(e.phi0)-A)<_?(p=e.phi0<0?1:0,s=e.phi0<0?-1:1,o=0):t(e.phi0)<_?(p=2,s=0,o=1):(p=3,s=i(e.phi0),o=r(e.phi0)),e.es)if(m=new $e.Geodesic.Geodesic(e.a,e.es/(1+h(e.one_es))),d=Xe(e.es),Y(e.params,"bguam"))l=Ye(e.phi0,s,o,d),e.inv=function(t,s){var o,a,c;for(o=.5*t.x*t.x,s.phi=e.phi0,c=0;c<3;++c)a=e.e*i(s.phi),s.phi=Ke(l+t.y-o*n(s.phi)*(a=h(1-a*a)),e.es,d);s.lam=t.x*a/r(s.phi)},e.fwd=function(t,n){var s,o,a;s=r(t.phi),o=i(t.phi),a=1/h(1-e.es*o*o),n.x=t.lam*s*a,n.y=Ye(t.phi,o,s,d)-l+.5*t.lam*t.lam*s*o*a};else{switch(p){case 0:u=Ye(A,1,0,d);break;case 1:u=Ye(-A,-1,0,d);break;case 2:case 3:e.inv=y,e.fwd=g,h(1-e.es*s*s),e.e,h(e.one_es)}e.inv=y,e.fwd=g}else e.inv=function(t,n){var a,l,h,u=t.x,d=t.y;if((l=f(u,d))>w)l-_>w&&j(),l=w;else if(l<_)return n.phi=e.phi0,void(n.lam=0);3==p||2==p?(h=i(l),a=r(l),2==p?(n.phi=Je(d*h/l),u*=h,d=a*l):(n.phi=Je(a*s+d*h*o/l),d=(a-s*i(n.phi))*l,u*=h*o),n.lam=0==d?0:c(u,d)):0==p?(n.phi=A-l,n.lam=c(u,-d)):(n.phi=l-A,n.lam=c(u,d))},e.fwd=function(e,n){var l,c,h;switch(h=i(e.phi),c=r(e.phi),l=r(e.lam),p){case 2:case 3:n.y=2==p?c*l:s*h+o*c*l,t(t(n.y)-1)<1e-14?n.y<0?V():n.x=n.y=0:(n.y=a(n.y),n.y/=i(n.y),n.x=n.y*c*i(e.lam),n.y*=2==p?h:o*h-s*c*l);break;case 0:e.phi=-e.phi,l=-l;case 1:t(e.phi-A)<_&&V(),n.x=(n.y=A+e.phi)*i(e.lam),n.y*=l}};function g(n,s){var o,a,l,c,h,f,g,y,v,x,b;switch(o=r(n.lam),a=r(n.phi),l=i(n.phi),p){case 0:o=-o;case 1:s.x=(c=t(u-Ye(n.phi,l,a,d)))*i(n.lam),s.y=c*o;break;case 2:case 3:if(t(n.lam)<_&&t(n.phi-e.phi0)<_){s.x=s.y=0;break}y=e.phi0/T,g=e.lam0/T,x=n.phi/T,v=(n.lam+e.lam0)/T,h=(b=m.Inverse(y,g,x,v,m.AZIMUTH)).azi1*T,f=b.s12,s.x=f*i(h)/e.a,s.y=f*r(h)/e.a}}function y(t,i){var r,n,s,o,a,l,g,y;if((r=f(t.x,t.y))<_)return i.phi=e.phi0,i.lam=0,i;3==p||2==p?(o=t.x*e.a,a=t.y*e.a,l=e.phi0/T,g=e.lam0/T,n=c(o,a)/T,s=h(o*o+a*a),y=m.Direct(l,g,n,s,m.STANDARD),i.phi=y.lat2*T,i.lam=y.lon2*T,i.lam-=e.lam0):(i.phi=Ke(0==p?u-r:u+r,e.es,d),i.lam=c(t.x,0==p?-t.y:t.y))}},"aeqd","Azimuthal Equidistant","Azi, Sph&Ell\nlat_0 guam"),tt(function(e){var s,o,a,l,c,h,u=1e-10;e.es=0,e.fwd=function(e,h){var p,f,m,_,g,y,v,x;switch(p=i(e.lam),f=r(e.lam),l){case 2:case 3:_=i(e.phi),x=(m=r(e.phi))*f,3==l&&(x=s*_+o*x),!c&&x<-u&&V(),v=t(y=1-x)>u?-d(g=.5*(1+x))/y-a/g:.5-a,h.x=v*m*p,h.y=3==l?v*(o*_-s*m*f):v*_;break;case 1:case 0:e.phi=t(p_halfpi-e.phi),!c&&e.phi-u>A&&V(),(e.phi*=.5)>u?(g=n(e.phi),v=-2*(d(r(e.phi))/g+g*a),h.x=v*p,h.y=v*f,0==l&&(h.y=-h.y)):h.x=h.y=0}},c=Y(e.params,"bno_cut"),h=.5*(A-Y(e.params,"rlat_b")),t(h)<u?a=-.5:(a=1/n(h),a*=a*d(r(h))),t(t(e.phi0)-A)<u?e.phi0<0?(p_halfpi=-A,l=1):(p_halfpi=A,l=0):t(e.phi0)<u?l=2:(l=3,s=i(e.phi0),o=r(e.phi0))},"airy","Airy","Misc Sph, no inv.\nno_cut lat_b="),tt(function(t){var e=t.opaque={mode:1};Y(t.params,"tlat_1")?0===(e.cosphi1=r(Y(t.params,"rlat_1")))&&G(-22):e.cosphi1=.6366197723675814,ii(t)},"wintri","Winkel Tripel","Misc Sph\nlat_1"),tt(ii,"aitoff","Aitoff","Misc Sph"),tt(function(t){t.fwd=function(t,e){var s,o,a,l,c,u,p,d=4/3,f=t.lam;s=n(.5*t.phi),a=1+(o=h(1-s*s))*r(f*=.5),l=i(f)*o/a,u=s/a,e.x=d*l*(3+(c=l*l)-3*(p=u*u)),e.y=d*u*(3+3*c-p)},t.es=0},"august","August Epicycloidal","Misc Sph, no inv."),tt(function(t){ri(t,!1,!1)},"apian","Apian Globular I","Misc Sph, no inv."),tt(function(t){ri(t,!1,!0)},"ortel","Ortelius Oval","Misc Sph, no inv."),tt(function(t){ri(t,!0,!1)},"bacon","Bacon Globular","Misc Sph, no inv."),tt(function(t){var e,n,s,a;t.es=0,t.fwd=function(t,l){var u,p,d,f,m,_;return t.lam+=-16.5*T,p=r(t.phi),d=r(t.lam)*p,f=i(t.lam)*p,_=(m=i(t.phi))*e+d*n,t.lam=c(f*s-_*a,d*e-m*n),_=_*s+f*a,t.phi=o(_),t.lam=Et(t.lam),t.lam+t.phi<-1.4&&(u=(t.lam-t.phi+1.6)*(t.lam+t.phi+1.4)/8,t.lam+=u,t.phi-=.8*u*i(t.phi+w/2)),p=r(t.phi),u=h(2/(1+p*r(t.lam/2))),l.x=1.68*u*p*i(t.lam/2),l.y=u*i(t.phi),u=(1-r(t.lam*t.phi))/12,l.y<0&&(l.x*=1+u),l.y>0&&(l.y*=1+u/1.5*l.x*l.x),l},t.lam0=0,t.phi0=-42*T,e=r(t.phi0),n=i(t.phi0),s=1,a=0},"bertin1953","Bertin 1953","Misc., Sph., NoInv."),tt(function(e){var n=h(2);e.fwd=function(e,s){var o,a,l,c;if(o=e.phi,t(t(e.phi)-A)<1e-7)s.x=0;else{for(l=i(o)*w,c=20;c&&(o-=a=(o+i(o)-l)/(1+r(o)),!(t(a)<1e-7));--c);o*=.5,s.x=2.00276*e.lam/(1/r(e.phi)+1.11072/r(o))}s.y=.49931*(e.phi+n*i(o))},e.es=0},"boggs","Boggs Eumorphic","PCyl., no inv., Sph."),tt(function(e){var s,o,a,l,u,p,d=1e-10;s=Y(e.params,"rlat_1"),t(s)<d&&G(-23),e.es?(u=Xe(e.es),l=Ye(s,a=i(s),p=r(s),u),a=p/(h(1-e.es*a*a)*a),e.inv=function(n,s){var o,p;p=f(n.x,n.y=a-n.y),s.phi=Ke(a+l-p,e.es,u),(o=t(s.phi))<A?(o=i(s.phi),s.lam=p*c(n.x,n.y)*h(1-e.es*o*o)/r(s.phi)):t(o-A)<=d?s.lam=0:j()},e.fwd=function(t,n){var s,o,c;s=a+l-Ye(t.phi,o=i(t.phi),c=r(t.phi),u),o=c*t.lam/(s*h(1-e.es*o*o)),n.x=s*i(o),n.y=a-s*r(o)}):(o=t(s)+d>=A?0:1/n(s),e.inv=function(e,i){var n=f(e.x,e.y=o-e.y);i.phi=o+s-n,t(i.phi)>A&&j(),t(t(i.phi)-A)<=d?i.lam=0:i.lam=n*c(e.x,e.y)/r(i.phi)},e.fwd=function(e,n){var a,l;l=o+s-e.phi,t(l)>d?(n.x=l*i(a=e.lam*r(e.phi)/l),n.y=o-l*r(a)):n.x=n.y=0})},"bonne","Bonne (Werner lat_1=90)","Conic Sph&Ell\nlat_1="),tt(function(t){var e,s,a=.16666666666666666,l=.008333333333333333,u=.041666666666666664,p=.06666666666666667;t.es?(s=Xe(t.es),e=Ye(t.phi0,i(t.phi0),r(t.phi0),s),t.fwd=function(o,c){var p,d,f,m,_,g;c.y=Ye(o.phi,p=i(o.phi),m=r(o.phi),s),p=1/h(1-t.es*p*p),g=n(o.phi),d=g*g,f=o.lam*m,m*=t.es*m/(1-t.es),_=f*f,c.x=p*f*(1-_*d*(a-(8-d+8*m)*_*l)),c.y-=e-p*g*_*(.5+(5-d+6*m)*_*u)},t.inv=function(o,a){var l,c,d,f,m,_,g;g=Ke(e+o.y,t.es,s),_=n(g),c=_*_,l=i(g),d=1/(1-t.es*l*l),l=h(d),d*=(1-t.es)*l,f=o.x/l,m=f*f,a.phi=g-l*_/d*m*(.5-(1+3*c)*m*u),a.lam=f*(1+c*m*((1+3*c)*m*p-.3333333333333333))/r(g)}):(t.fwd=function(e,s){s.x=o(r(e.phi)*i(e.lam)),s.y=c(n(e.phi),r(e.lam))-t.phi0},t.inv=function(e,s){var a=e.y+t.phi0;s.phi=o(i(a)*r(e.x)),s.lam=c(n(e.x),r(a))})},"cass","Cassini","Cyl, Sph&Ell"),tt(function(e){var n,s,a=0;Y(e.params,"tlat_ts")&&(e.k0=r(a=Y(e.params,"rlat_ts")),e.k0<0&&G(-24)),e.es?(a=i(a),e.k0/=h(1-e.es*a*a),e.e=h(e.es),(s=ni(e.es))||e_error_0(),n=Ze(1,e.e,e.one_es),e.fwd=function(t,r){r.x=e.k0*t.lam,r.y=.5*Ze(i(t.phi),e.e,e.one_es)/e.k0},e.inv=function(t,i){i.phi=si(o(2*t.y*e.k0/n),s),i.lam=t.x/e.k0}):(e.fwd=function(t,r){r.x=e.k0*t.lam,r.y=i(t.phi)/e.k0},e.inv=function(i,r){var n,s=i.x,a=i.y;(n=t(a*=e.k0))-R<=1?(r.phi=n>=1?a<0?-A:A:o(a),r.lam=s/e.k0):j()})},"cea","Equal Area Cylindrical","Cyl, Sph&Ell\nlat_ts="),tt(function(e){var n,s,o,a,l,u,p,d=1/3,f=[];for(u=0;u<3;++u)f[u]={p:{}},f[u].phi=Y(e.params,"rlat_"+(u+1)),f[u].lam=Y(e.params,"rlon_"+(u+1)),f[u].lam=Et(f[u].lam-e.lam0),f[u].cosphi=r(f[u].phi),f[u].sinphi=i(f[u].phi);for(u=0;u<3;++u)p=2==u?0:u+1,f[u].v=m(f[p].phi-f[u].phi,f[u].cosphi,f[u].sinphi,f[p].cosphi,f[p].sinphi,f[p].lam-f[u].lam),f[u].v.r||G(-25);function m(e,n,s,o,a,l){var u,p,d,f={};return u=r(l),t(e)>1||t(l)>1?f.r=Qe(cs1*a+n*o*u):(p=i(.5*e),d=i(.5*l),f.r=2*Je(h(p*p+n*o*d*d))),t(f.r)>1e-9?f.Az=c(o*i(l),n*a-s*o*u):f.r=f.Az=0,f}function _(t,e,i){return Qe(.5*(t*t+e*e-i*i)/(t*e))}o=_(f[0].v.r,f[2].v.r,f[1].v.r),a=_(f[0].v.r,f[1].v.r,f[2].v.r),l=w-o,s=2*(f[0].p.y=f[1].p.y=f[2].v.r*i(o)),f[2].p.y=0,f[0].p.x=-(f[1].p.x=.5*f[0].v.r),n=f[2].p.x=f[0].p.x+f[2].v.r*r(o),e.es=0,e.fwd=function(t,e){var o,c,h,u,p,g,y,v=[];for(o=i(t.phi),c=r(t.phi),u=0;u<3&&(v[u]=m(t.phi-f[u].phi,f[u].cosphi,f[u].sinphi,c,o,t.lam-f[u].lam),v[u].r);++u)v[u].Az=Et(v[u].Az-f[u].v.Az);if(u<3)g=f[u].p.x,y=f[u].p.y;else{for(g=n,y=s,u=0;u<3;++u)p=2==u?0:u+1,h=_(f[u].v.r,v[u].r,v[p].r),v[u].Az<0&&(h=-h),u?1==u?(h=a-h,g-=v[u].r*r(h),y-=v[u].r*i(h)):(h=l-h,g+=v[u].r*r(h),y+=v[u].r*i(h)):(g+=v[u].r*r(h),y-=v[u].r*i(h));g*=d,y*=d}e.x=g,e.y=y}},"chamb","Chamberlin Trimetric","Misc Sph, no inv.\nlat_1= lon_1= lat_2= lon_2= lat_3= lon_3="),tt(function(t){var e=1/3;t.inv=function(t,i){i.phi=3*o(.32573500793527993*t.y),i.lam=1.0233267079464885*t.x/(2*r((i.phi+i.phi)*e)-1)},t.fwd=function(t,n){t.phi*=e,n.x=.9772050238058398*t.lam*(2*r(t.phi+t.phi)-1),n.y=3.0699801238394655*i(t.phi)},t.es=0},"crast","Craster Parabolic (Putnins P4)","PCyl., Sph."),tt(function(t){var e=.5253,n=.7264,s=1/Math.sqrt(e*n),a=.9701,l=d(22*T),c=f(0),u=i(l),p=r(l);function d(t){return o(n*i(t)+.4188*h(e*n))}function f(t){return e*t}Y(t.params,"tlon_0")||(t.lam0=11.023*T),t.es=0,t.fwd=function(t,e){var n=d(t.phi),o=f(t.lam),m=i(n),_=r(n),g=i(o-c),y=r(o-c),v=h(2/(1+i(l)*m+p*_*y));e.x=s*v*_*g*a,e.y=s*v*(p*m-u*_*y)/a}},"cupola","Cupola","PCyl., Sph., NoInv."),tt(function(e){e.fwd=function(e,i){var n=t(e.lam);i.y=e.phi,i.x=e.lam,i.x*=r((.95+n*(n*n*.0016666666666666666-.08333333333333333))*(e.phi*(.9+.03*e.phi*e.phi*e.phi*e.phi)))},e.es=0},"denoy","Denoyer Semi-Elliptical","PCyl, Sph., no inv."),tt(function(e){var i=.9213177319235613,r=.3183098861837907;e.es=0,e.fwd=function(e,n){n.x=i*e.lam*(1-r*t(e.phi)),n.y=i*e.phi},e.inv=function(e,n){n.phi=e.y/i,n.lam=e.x/(i*(1-r*t(n.phi)))}},"eck1","Eckert I","PCyl Sph"),tt(function(e){var r=.46065886596178063,n=1.4472025091165353;e.es=0,e.fwd=function(e,s){s.x=r*e.lam*(s.y=h(4-3*i(t(e.phi)))),s.y=n*(2-s.y),e.phi<0&&(s.y=-s.y)},e.inv=function(e,i){i.lam=e.x/(r*(i.phi=2-t(e.y)/n)),i.phi=.3333333333333333*(4-i.phi*i.phi),t(i.phi)>=1?t(i.phi)>1.0000001?j():i.phi=i.phi<0?-A:A:i.phi=o(i.phi),e.y<0&&(i.phi=-i.phi)}},"eck2","Eckert II","PCyl Sph"),tt(function(t){oi(t,{C_x:.4222382003157712,C_y:.8444764006315424,A:1,B:.4052847345693511})},"eck3","Eckert III","PCyl Sph"),tt(function(t){oi(t,{C_x:.94745,C_y:.94745,A:0,B:.3039635509270133})},"wag6","Wagner VI","PCyl Sph"),tt(function(t){oi(t,{C_x:.8660254037844,C_y:1,A:0,B:.3039635509270133})},"kav7","Kavraisky VII","PCyl Sph"),tt(function(t){oi(t,{C_x:1.8949,C_y:.94745,A:-.5,B:.3039635509270133})},"putp1","Putnins P1","PCyl Sph"),tt(function(e){var n=.4222382003157712,s=1.3265004281770023,o=3.5707963267948966;e.es=0,e.fwd=function(e,a){var l,c,h,u,p;for(l=o*i(e.phi),c=e.phi*e.phi,e.phi*=.895168+c*(.0218849+.00826809*c),p=6;p&&(u=r(e.phi),h=i(e.phi),e.phi-=c=(e.phi+h*(u+2)-l)/(1+u*(u+2)-h*h),!(t(c)<1e-7));--p);p?(a.x=n*e.lam*(1+r(e.phi)),a.y=s*i(e.phi)):(a.x=n*e.lam,a.y=e.phi<0?-s:s)},e.inv=function(t,e){var a;e.phi=Je(t.y/s),e.lam=t.x/(n*(1+(a=r(e.phi)))),e.phi=Je((e.phi+i(e.phi)*(a+2))/o)}},"eck4","Eckert IV","PCyl Sph"),tt(function(t){t.es=0,t.fwd=function(t,e){e.x=.4410127717245515*(1+r(t.phi))*t.lam,e.y=.882025543449103*t.phi},t.inv=function(t,e){e.lam=2.267508027238226*t.x/(1+r(e.phi=1.133754013619113*t.y))}},"eck5","Eckert V","PCyl Sph"),tt(function(t){var e=r(Y(t.params,"rlat_ts"));e<=0&&G(-24),t.es=0,t.fwd=function(i,r){r.x=e*i.lam,r.y=i.phi-t.phi0},t.inv=function(i,r){r.lam=i.x/e,r.phi=i.y+t.phi0}},"eqc","Equidistant Cylindrical (Plate Caree)","Cyl, Sph\nlat_ts=[, lat_0=0]"),tt(function(e){var n,s,o,a,l,h,u,p,d,m,_,g,y;n=Y(e.params,"rlat_1"),s=Y(e.params,"rlat_2"),t(n+s)<R&&G(-21),(u=Xe(e.es))||e_error_0(),o=m=i(n),d=r(n),_=t(n-s)>=R,(p=e.es>0)?(y=We(m,d,e.es),g=Ye(n,m,d,u),_&&(m=i(s),d=r(s),o=(y-We(m,d,e.es))/(Ye(s,m,d,u)-g)),l=(h=g+y/o)-Ye(e.phi0,i(e.phi0),r(e.phi0),u)):(_&&(o=(d-r(s))/(s-n)),h=n+r(n)/o,l=h-e.phi0),e.fwd=function(t,e){a=h-(p?Ye(t.phi,i(t.phi),r(t.phi),u):t.phi),e.x=a*i(t.lam*=o),e.y=l-a*r(t.lam)},e.inv=function(t,i){0!=(a=f(t.x,t.y=l-t.y))?(o<0&&(a=-a,t.x=-t.x,t.y=-t.y),i.phi=h-a,p&&(i.phi=Ke(i.phi,e.es,u)),i.lam=c(t.x,t.y)/o):(i.lam=0,i.phi=o>0?A:-A)}},"eqdc","Equidistant Conic","Conic, Sph&Ell\nlat_1= lat_2="),tt(function(t){var e=1.340264,i=-.081106,r=893e-6,n=.003796,s=Math.sqrt(3)/2;t.es=0,t.fwd=function(t,o){var a=Math.asin(s*Math.sin(t.phi)),l=a*a,c=l*l*l;o.x=t.lam*Math.cos(a)/(s*(e+3*i*l+c*(7*r+9*n*l))),o.y=a*(e+i*l+c*(r+n*l))},t.inv=function(t,o){var a,l,c,h,u=t.y;for(h=0;h<12&&(u-=c=(u*(e+i*(a=u*u)+(l=a*a*a)*(r+n*a))-t.y)/(e+3*i*a+l*(7*r+9*n*a)),!(Math.abs(c)<1e-9));++h);l=(a=u*u)*a*a,o.lam=s*t.x*(e+3*i*a+l*(7*r+9*n*a))/Math.cos(u),o.phi=Math.asin(Math.sin(u)/s)}},"eqearth","Equal Earth","PCyl., Sph."),tt(ai,"etmerc","Extended Transverse Mercator","Cyl, Sph\nlat_ts=(0)\nlat_0=(0)"),tt(function(t){t.fwd=function(t,e){e.x=.7071067811865476*t.lam,e.y=1.7071067811865475*n(.5*t.phi)},t.inv=function(t,e){e.lam=1.4142135623730951*t.x,e.phi=2*l(.585786437626905*t.y)},t.es=0},"gall","Gall (Gall Stereographic)","Cyl, Sph"),tt(function(t){t.is_geocent=!0,t.x0=0,t.y0=0,t.fwd=function(t,e){e.x=t.lam,e.y=t.phi},t.inv=function(t,e){e.phi=t.y,e.lam=t.x}},"geocent","Geocentric",""),tt(function(t){var e,s,o,a,u,p,d,m=Y(t.params,"dh"),_=Y(t.params,"ssweep");_?"x"==_?d=1:"y"==_?d=0:G(-49):d=0,((u=m/t.a)<=0||u>1e10)&&G(-50),p=(a=1+u)*a-1,0!=t.es?(e=h(t.one_es),s=t.one_es,o=t.rone_es,t.inv=function(t,i){var s,m,_,g,y,v;s=-1,d?(_=n(t.y/u),m=n(t.x/u)*f(1,_)):(m=n(t.x/u),_=n(t.y/u)*f(1,m));var x=(y=2*a*s)*y-4*(g=m*m+(g=_/e)*g+s*s)*p;x<0&&G(-51),v=(-y-h(x))/(2*g),s=a+v*s,m*=v,_*=v,i.lam=c(m,s),i.phi=l(_*r(i.lam)/s),i.phi=l(o*n(i.phi))},t.fwd=function(t,c){var h,p,m,_,g;t.phi=l(s*n(t.phi)),h=e/f(e*r(t.phi),i(t.phi)),p=h*r(t.lam)*r(t.phi),m=h*i(t.lam)*r(t.phi),_=h*i(t.phi),(a-p)*p-m*m-_*_*o<0&&G(-51),g=a-p,d?(c.x=u*l(m/f(_,g)),c.y=u*l(_/g)):(c.x=u*l(m/g),c.y=u*l(_/f(m,g)))}):(e=s=o=1,t.inv=function(t,e){var i,s,o,f,m,_;i=-1,d?(o=n(t.y/u),s=n(t.x/u)*h(1+o*o)):(s=n(t.x/u),o=n(t.y/u)*h(1+s*s));var g=(m=2*a*i)*m-4*(f=s*s+o*o+i*i)*p;g<0&&G(-51),_=(-m-h(g))/(2*f),i=a+_*i,s*=_,o*=_,e.lam=c(s,i),e.phi=l(o*r(e.lam)/i)},t.fwd=function(t,e){var n=r(t.phi),s=r(t.lam)*n,o=i(t.lam)*n,c=i(t.phi);n=a-s,d?(e.x=u*l(o/f(c,n)),e.y=u*l(c/n)):(e.x=u*l(o/n),e.y=u*l(c/f(o,n)))})},"geos","Geostationary Satellite View","Azi, Sph&Ell"),tt(function(t){var e=a(Y(t.params,"tlat_1")?Y(t.params,"rlat_1"):0),s=i(e),o=r(e);function a(t){return Je(n(.5*t))}t.fwd=function(t,e){var n=.5*t.lam,l=a(t.phi),c=i(l),h=r(l),u=r(n);s*c+o*h*u>=0?(e.x=h*i(n),e.y=o*c-s*h*u):V()},t.es=0},"gilbert","Gilbert Two World Perspective","PCyl., Sph., NoInv.\nlat_1="),tt(function(t){t.fwd=function(t,e){var i=t.phi*t.phi;e.y=t.phi*(1+.08333333333333333*i),e.x=t.lam*(1-.162388*i),i=t.lam*t.lam,e.x*=.87-952426e-9*i*i},t.es=0},"gins8","Ginsburg VIII (TsNIIGAiK)","PCyl, Sph., no inv."),tt(function(t){Y(t.params,"tn"),Y(t.params,"tm")?ci(t,Y(t.params,"dm"),Y(t.params,"dn")):G(-99)},"gn_sinu","General Sinusoidal Series","PCyl, Sph.\nm= n="),tt(li,"sinu","Sinusoidal (Sanson-Flamsteed)","PCyl, Sph&Ell"),tt(function(t){ci(t,1,2.5707963267948966)},"eck6","Eckert VI","PCyl, Sph.\nm= n="),tt(function(t){ci(t,.5,1.7853981633974483)},"mbtfps","McBryde-Thomas Flat-Polar Sinusoidal","PCyl, Sph."),tt(function(e){var n,s,a=1e-10;t(t(e.phi0)-A)<a?s=e.phi0<0?1:0:t(e.phi0)<a?s=2:(s=3,sinph0=i(e.phi0),n=r(e.phi0)),e.inv=function(r,u){var p,d,m,_=r.x,g=r.y;if(p=f(_,g),m=i(u.phi=l(p)),d=h(1-m*m),t(p)<=a)u.phi=e.phi0,u.lam=0;else{switch(s){case 3:u.phi=d*sinph0+g*m*n/p,t(u.phi)>=1?u.phi=u.phi>0?A:-A:u.phi=o(u.phi),g=(d-sinph0*i(u.phi))*p,_*=m*n;break;case 2:u.phi=g*m/p,t(u.phi)>=1?u.phi=u.phi>0?A:-A:u.phi=o(u.phi),g=d*p,_*=m;break;case 1:u.phi-=A;break;case 0:u.phi=A-u.phi,g=-g}u.lam=c(_,g)}},e.fwd=function(t,e){var o,l,c;switch(c=i(t.phi),l=r(t.phi),o=r(t.lam),s){case 2:e.y=l*o;break;case 3:e.y=sinph0*c+n*l*o;break;case 1:e.y=-c;break;case 0:e.y=c}switch(e.y<=a&&V(),e.x=(e.y=1/e.y)*l*i(t.lam),s){case 2:e.y*=c;break;case 3:e.y*=n*c-sinph0*l*o;break;case 0:o=-o;case 1:e.y*=l*o}},e.es=0},"gnom","Gnomonic","Azi, Sph."),tt(hi,"moll","Mollweide","PCyl Sph"),tt(function(t){pi(t,ui(0,w/3))},"wag4","Wagner IV","PCyl Sph"),tt(function(t){pi(t,{C_x:.90977,C_y:1.65014,C_p:3.00896})},"wag5","Wagner V","PCyl Sph"),tt(function(e){var i,r,n,s,o=.0528,a=.7109307819790236;e.es=0,li(e),i=e.fwd,r=e.inv,hi(e),n=e.fwd,s=e.inv,e.fwd=function(e,r){t(e.phi)<a?i(e,r):(n(e,r),r.y-=e.phi>0?o:-o)},e.inv=function(e,i){t(e.y)<=a?r(e,i):(e.y+=e.y>0?o:-o,s(e,i))}},"goode","Goode Homolosine","PCyl, Sph."),tt(function(e){var n,s,o;e.inv=function(e,i){var r=h(1-.25*n*n*e.x*e.x-.25*e.y*e.y);t(2*r*r-1)<1e-10?(i.lam=x,i.phi=x,pj_errno=-14):(i.lam=ei(n*e.x*r,2*r*r-1)/n,i.phi=Je(r*e.y))},e.fwd=function(t,e){var a,l;l=h(2/(1+(a=r(t.phi))*r(t.lam*=n))),e.x=s*l*a*i(t.lam),e.y=o*l*i(t.phi)},e.es=0,Y(e.params,"tW")?(n=t(Y(e.params,"dW")))<=0&&G(-27):n=.5,Y(e.params,"tM")?(s=t(Y(e.params,"dM")))<=0&&G(-27):s=1,o=1/s,s/=n},"hammer","Hammer & Eckert-Greifendorff","Misc Sph,\nW= M="),tt(function(e){var n=1.000001;e.inv=function(e,s){var a=e.y*(e.y<0?.5179951515653813:.5686373742600607);t(a)>1?t(a)>n?j():a=a>0?A:-A:a=o(a),s.lam=1.1764705882352942*e.x/r(a),a+=a,s.phi=(a+i(a))*(e.y<0?.4102345310814193:.3736990601468637),t(s.phi)>1?t(s.phi)>n?j():s.phi=s.phi>0?A:-A:s.phi=o(s.phi)},e.fwd=function(e,n){var s,o,a;for(o=i(e.phi)*(e.phi<0?2.43763:2.67595),a=20;a&&(e.phi-=s=(e.phi+i(e.phi)-o)/(1+r(e.phi)),!(t(s)<1e-7));--a);n.x=.85*e.lam*r(e.phi*=.5),n.y=i(e.phi)*(e.phi<0?1.93052:1.75859)},e.es=0},"hatano","Hatano Asymmetrical Equal Area","PCyl., Sph."),tt(di,"healpix","HEALPix","Sph., Ellps."),tt(function(t){di(t,!0)},"rhealpix","rHEALPix","Sph., Ellps.\nnorth_square= south_square="),tt(function(e){var n,s=i(.5),l=o(s),u=2*h(w/(n=w+4*l*2)),p=.5*u*(2+h(3));e.es=0,e.fwd=function(e,s){var o,a,d=1-i(e.phi);if(d&&d<2){var f,m,_,g,y,v=A-e.phi,x=25;do{m=i(v),_=r(v),y=l+c(m,2-_),v-=f=(v-1*l-2*m+(g=5-4*_)*y-.5*d*n)/(4*m*y)}while(t(f)>1e-12&&--x>0);o=u*h(g),a=e.lam*y/w}else o=u*(1+d),a=e.lam*l/w;s.x=o*i(a),s.y=p-o*r(a)},e.inv=function(t,e){var r=t.x,s=t.y,d=r*r+(s-=p)*s,f=(5-d/(u*u))/4,m=a(f),_=i(m),g=l+c(_,2-f);e.lam=o(r/h(d))*w/g,e.phi=o(1-2*(m-1*l-2*_+(5-4*f)*g)/n)}},"hill","Hill Eucyclic","PCyl., Sph."),tt(function(e){var s,a,p,d,f,m,_,g,y,v=.785398163397448,x=1.37008346281555;e.a=6377397.155,e.e=h(e.es=.006674372230614),Y(e.params,"tlat_0")||(e.phi0=.863937979737193),Y(e.params,"tlon_0")||(e.lam0=.4334234309119251),Y(e.params,"tk")||(e.k0=.9999),y=1,Y(e.params,"tczech")||(y=-1),d=h(1+e.es*u(r(e.phi0),4)/(1-e.es)),s=o(i(e.phi0)/d),p=u((1+e.e*i(e.phi0))/(1-e.e*i(e.phi0)),d*e.e/2),f=n(s/2+v)/u(n(e.phi0/2+v),d)*p,a=h(1-e.es)/(1-e.es*u(i(e.phi0),2)),m=i(x),_=e.k0*a/n(x),g=.5286277629901559,e.inv=function(s,a){var p,b,w,S,T,C,M,E;M=s.x,s.x=s.y,s.y=M,s.x*=y,s.y*=y,T=h(s.x*s.x+s.y*s.y),S=c(s.y,s.x)/i(x),w=2*(l(u(_/T,1/m)*n(x/2+v))-v),p=o(r(g)*i(w)-i(g)*r(w)*r(S)),b=o(r(w)*i(S)/r(p)),a.lam=e.lam0-b/d,C=p,E=0;do{a.phi=2*(l(u(f,-1/d)*u(n(p/2+v),1/d)*u((1+e.e*i(C))/(1-e.e*i(C)),e.e/2))-v),t(C-a.phi)<1e-15&&(E=1),C=a.phi}while(0===E);a.lam-=e.lam0},e.fwd=function(t,s){var a,c,h,p,b,w,S;a=u((1+e.e*i(t.phi))/(1-e.e*i(t.phi)),d*e.e/2),c=2*(l(f*u(n(t.phi/2+v),d)/a)-v),h=-t.lam*d,p=o(r(g)*i(c)+i(g)*r(c)*r(h)),b=o(r(c)*i(h)/r(p)),w=m*b,S=_*u(n(x/2+v),m)/u(n(p/2+v),m),s.y=S*r(w),s.x=S*i(w),s.y*=y,s.x*=y}},"krovak","Krovak","PCyl., Ellps."),tt(function(e){var n,s,a,l,u,p,d,m,_,g,y,v=1e-10;if(g=t(e.phi0),_=t(g-A)<v?e.phi0<0?1:0:t(g)<v?2:3,e.es){switch(e.e=h(e.es),u=Ze(1,e.e,e.one_es),e.es,m=ni(e.es),_){case 0:case 1:p=1;break;case 2:p=1/(d=h(.5*u)),a=1,l=.5*u;break;case 3:d=h(.5*u),y=i(e.phi0),n=Ze(y,e.e,e.one_es)/u,s=h(1-n*n),p=r(e.phi0)/(h(1-e.es*y*y)*d*s),l=(a=d)/p,a*=p}e.inv=function(t,a){var l,h,g,y,x=0;switch(_){case 2:case 3:if(t.x/=p,t.y*=p,(y=f(t.x,t.y))<v)return a.lam=0,a.phi=e.phi0,a;h=2*o(.5*y/d),l=r(h),h=i(h),t.x*=h,3==_?(x=l*n+t.y*h*s/y,t.y=y*s*l-t.y*n*h):(x=t.y*h/y,t.y=y*l);break;case 0:t.y=-t.y;case 1:if(!(g=t.x*t.x+t.y*t.y))return a.lam=0,a.phi=e.phi0,a;x=1-g/u,1==_&&(x=-x)}return a.lam=c(t.x,t.y),a.phi=si(o(x),m),a},e.fwd=function(o,c){var p,d,f,m,g=0,y=0,x=0;switch(p=r(o.lam),d=i(o.lam),f=i(o.phi),m=Ze(f,e.e,e.one_es),(3==_||2==_)&&(y=h(1-(g=m/u)*g)),_){case 3:x=1+n*g+s*y*p;break;case 2:x=1+y*p;break;case 0:x=A+o.phi,m=u-m;break;case 1:x=o.phi-A,m=u+m}switch(t(x)<v&&V(),_){case 3:case 2:3==_?(x=h(2/x),c.y=l*x*(s*g-n*y*p)):(x=h(2/(1+y*p)),c.y=x*g*l),c.x=a*x*y*d;break;case 0:case 1:m>=0?(x=h(m),c.x=x*d,c.y=p*(1==_?x:-x)):c.x=c.y=0}}}else 3==_&&(n=i(e.phi0),s=r(e.phi0)),e.inv=function(a,l){var h,u=0,p=0;switch(h=f(a.x,a.y),(l.phi=.5*h)>1&&j(),l.phi=2*o(l.phi),(3==_||2==_)&&(p=i(l.phi),u=r(l.phi)),_){case 2:l.phi=t(h)<=v?0:o(a.y*p/h),a.x*=p,a.y=u*h;break;case 3:l.phi=t(h)<=v?e.phi0:o(u*n+a.y*p*s/h),a.x*=p*s,a.y=(u-i(l.phi)*n)*h;break;case 0:a.y=-a.y,l.phi=A-l.phi;break;case 1:l.phi-=A}l.lam=0!=a.y||2!=_&&3!=_?c(a.x,a.y):0},e.fwd=function(o,a){var l,c,u;switch(u=i(o.phi),c=r(o.phi),l=r(o.lam),_){case 2:case 3:a.y=2==_?1+c*l:1+n*u+s*c*l,a.y<=v&&V(),a.y=h(2/a.y),a.x=a.y*c*i(o.lam),a.y*=2==_?u:s*u-n*c*l;break;case 0:l=-l;case 1:t(o.phi+e.phi0)<v&&V(),a.y=E-.5*o.phi,a.y=2*(1==_?r(a.y):i(a.y)),a.x=a.y*i(o.lam),a.y*=l}}},"laea","Lambert Azimuthal Equal Area","Azi, Sph&Ell"),tt(fi,"lonlat","Lat/long (Geodetic)",""),tt(fi,"longlat","Lat/long (Geodetic alias)",""),tt(fi,"latlon","Lat/long (Geodetic alias)",""),tt(fi,"latlong","Lat/long (Geodetic alias)",""),tt(function(e){var s,o,a,p,m,_,g,y,v,b,w,S=1e-10;e.inv=function(t,i){var r,n=t.x,s=t.y;n/=e.k0,s/=e.k0,0!=(r=f(n,s=g-s))?(_<0&&(r=-r,n=-n,s=-s),v?(i.phi=_i(u(r/y,1/_),e.e),i.phi==x&&j()):i.phi=2*l(u(y/r,1/_))-A,i.lam=c(n,s)/_):(i.lam=0,i.phi=_>0?A:-A)},e.fwd=function(s,o){var a,l=s.lam;t(t(s.phi)-A)<S?(s.phi*_<=0&&V(),a=0):a=y*(v?u(mi(s.phi,i(s.phi),e.e),_):u(n(E+.5*s.phi),-_)),l*=_,o.x=e.k0*(a*i(l)),o.y=e.k0*(g-a*r(l))},p=Y(e.params,"rlat_1"),Y(e.params,"tlat_2")?m=Y(e.params,"rlat_2"):(m=p,Y(e.params,"tlat_0")||(e.phi0=p)),t(p+m)<S&&G(-21),_=o=i(p),s=r(p),a=t(p-m)>=S,(v=0!=e.es)?(e.e=h(e.es),w=We(o,s,e.es),b=mi(p,o,e.e),a&&(o=i(m),_=d(w/We(o,r(m),e.es)),_/=d(b/mi(m,o,e.e))),y=g=w*u(b,-_)/_,g*=t(t(e.phi0)-A)<S?0:u(mi(e.phi0,i(e.phi0),e.e),_)):(a&&(_=d(s/r(m))/d(n(E+.5*m)/n(E+.5*p))),y=s*u(n(E+.5*p),_)/_,g=t(t(e.phi0)-A)<S?0:y*u(n(E+.5*e.phi0),-_))},"lcc","Lambert Conformal Conic","Conic, Sph&Ell\nlat_1= and lat_2= or lat_0="),tt(function(e){var i,s,o,a=1e-8;i=Y(e.params,"rlat_1"),s=r(i),o=n(E+.5*i),s<a&&G(-22),e.fwd=function(e,r){r.y=e.phi-i,t(r.y)<a?r.x=e.lam*s:(r.x=E+.5*e.phi,t(r.x)<a||t(t(r.x)-A)<a?r.x=0:r.x=e.lam*r.y/d(n(r.x)/o))},e.inv=function(e,r){r.phi=e.y+i,t(e.y)<a?r.lam=e.x/s:(r.lam=E+.5*r.phi,t(r.lam)<a||t(t(r.lam)-A)<a?r.lam=0:r.lam=e.x*d(n(r.lam)/o)/e.y)},e.es=0},"loxim","Loximuthal","PCyl Sph"),tt(function(e){var n=.9525793444156804,s=.9258200997725514,a=3.401680257083045,l=2/3,c=1/3,h=1.0000001;e.fwd=function(t,e){t.phi=o(n*i(t.phi)),e.x=s*t.lam*(2*r(l*t.phi)-1),e.y=a*i(c*t.phi)},e.inv=function(e,c){c.phi=e.y/a,t(c.phi)>=1?t(c.phi)>h?j():c.phi=c.phi<0?-A:A:c.phi=o(c.phi),c.lam=e.x/(s*(2*r(l*(c.phi*=3))-1)),t(c.phi=i(c.phi)/n)>=1?t(c.phi)>h?j():c.phi=c.phi<0?-A:A:c.phi=o(c.phi)},e.es=0},"mbt_fpp","McBride-Thomas Flat-Polar Parabolic","Cyl., Sph."),tt(function(e){var n=1.000001;e.fwd=function(e,n){var s,o,a;for(o=1.7071067811865475*i(e.phi),a=20;a&&(e.phi-=s=(i(.5*e.phi)+i(e.phi)-o)/(.5*r(.5*e.phi)+r(e.phi)),!(t(s)<1e-7));--a);n.x=.3124597141037825*e.lam*(1+2*r(e.phi)/r(.5*e.phi)),n.y=1.874758284622695*i(.5*e.phi)},e.inv=function(e,s){var a;s.phi=.533402096794177*e.y,t(s.phi)>1?t(s.phi)>n?j():s.phi<0?(a=-1,s.phi=-w):(a=1,s.phi=w):s.phi=2*o(a=s.phi),s.lam=3.2004125807650623*e.x/(1+2*r(s.phi)/r(.5*s.phi)),s.phi=.585786437626905*(a+i(s.phi)),t(s.phi)>1?t(s.phi)>n?j():s.phi=s.phi<0?-A:A:s.phi=o(s.phi)},e.es=0},"mbt_fpq","McBryde-Thomas Flat-Polar Quartic","Cyl., Sph."),tt(function(e){var n=.45503,s=1.36509,o=1.41546,a=.22248,l=1.44492,c=1/3;e.fwd=function(e,h){var u,p,d,f;for(u=o*i(e.phi),f=10;f&&(d=e.phi/s,e.phi-=p=(n*i(d)+i(e.phi)-u)/(c*r(d)+r(e.phi)),!(t(p)<1e-7));--f);d=e.phi/s,h.x=a*e.lam*(1+3*r(e.phi)/r(d)),h.y=l*i(d)},e.inv=function(t,e){var c;e.phi=s*(c=Je(t.y/l)),e.lam=t.x/(a*(1+3*r(e.phi)/r(c))),e.phi=Je((n*i(c)+i(e.phi))/o)},e.es=0},"mbt_fps","McBryde-Thomas Flat-Pole Sine (No. 2)","Cyl., Sph."),tt(function(e){var s=1e-10,o=0,a=Y(e.params,"tlat_ts");a&&(o=Y(e.params,"rlat_ts"))>=A&&G(-24),e.es?(a&&(e.k0=We(i(o),r(o),e.es)),e.inv=function(t,i){i.phi=_i(p(-t.y/e.k0),e.e),i.phi===x&&j(),i.lam=t.x/e.k0},e.fwd=function(r,n){t(t(r.phi)-A)<=s&&V(),n.x=e.k0*r.lam,n.y=-e.k0*d(mi(r.phi,i(r.phi),e.e))}):(e.inv=function(t,i){i.phi=A-2*l(p(-t.y/e.k0)),i.lam=t.x/e.k0},e.fwd=function(i,r){t(t(i.phi)-A)<=s&&V(),r.x=e.k0*i.lam,r.y=e.k0*d(n(E+.5*i.phi))})},"merc","Mercator","Cyl, Sph&Ell\nlat_ts="),tt(function(e){e.k0=1,e.inv=function(t,i){i.phi=A-2*l(p(-t.y/e.k0)),i.lam=t.x/e.k0},e.fwd=function(i,r){t(t(i.phi)-A)<=R&&V(),r.x=e.k0*i.lam,r.y=e.k0*d(n(E+.5*i.phi))}},"webmerc","Web Mercator / Pseudo Mercator","Cyl, Ell"),tt(function(t){t.fwd=function(t,e){e.x=t.lam,e.y=1.25*d(n(E+.4*t.phi))},t.inv=function(t,e){e.lam=t.x,e.phi=2.5*(l(p(.8*t.y))-E)},t.es=0},"mill","Miller Cylindrical","Cyl, Sph"),tt(function(t){t.lam0=20*T,t.phi0=18*T,t.es=0,vi(t,[[.9245,0],[0,0],[.01943,0]])},"mil_os","Miller Oblated Stereographic","Azi(mod)"),tt(function(t){t.lam0=-165*T,t.phi0=-10*T,t.es=0,vi(t,[[.721316,0],[0,0],[-.0088162,-.00617325]])},"lee_os","Lee Oblated Stereographic","Azi(mod)"),tt(function(t){t.lam0=-96*T,t.phi0=39*T,t.es=0,t.a=6370997,vi(t,[[.98879,0],[0,0],[-.050909,0],[0,0],[.075528,0]])},"gs48","Mod Stereographic of 48 U.S.","Azi(mod)"),tt(function(t){var e;t.lam0=-152*T,t.phi0=64*T,0!=t.es?(e=[[.9945303,0],[.0052083,-.0027404],[.0072721,.0048181],[-.0151089,-.1932526],[.0642675,-.1381226],[.3582802,-.2884586]],t.a=6378206.4,t.e=h(t.es=.00676866)):(e=[[.9972523,0],[.0052513,-.0041175],[.0074606,.0048125],[-.0153783,-.1968253],[.0636871,-.1408027],[.3660976,-.2937382]],t.a=6370997),vi(t,e)},"alsk","Mod Stereographic of Alaska","Azi(mod)"),tt(function(t){var e;t.lam0=-120*T,t.phi0=45*T,0!=t.es?(e=[[.9827497,0],[.0210669,.0053804],[-.1031415,-.0571664],[-.0323337,-.0322847],[.0502303,.1211983],[.0251805,.0895678],[-.0012315,-.1416121],[.0072202,-.1317091],[-.0194029,.0759677],[-.0210072,.0834037]],t.a=6378206.4,t.e=h(t.es=.00676866)):(e=[[.984299,0],[.0211642,.0037608],[-.1036018,-.0575102],[-.0329095,-.0320119],[.0499471,.1223335],[.026046,.0899805],[7388e-7,-.1435792],[.0075848,-.1334108],[-.0216473,.0776645],[-.0225161,.0853673]],t.a=6370997),vi(t,e)},"gs50","Mod Stereographic of 50 U.S.","Azi(mod)"),tt(function(e){var i=.8707,r=-.131979,n=-.013791,s=.003971,o=-.001529,a=1.007226,l=.015085,c=-.044475,h=.028874,u=-.005916,p=a,d=3*l,f=7*c,m=9*h,_=11*u,g=.8707*.52*w;e.es=0,e.fwd=function(t,e){var p,d;d=(p=t.phi*t.phi)*p,e.x=t.lam*(i+p*(r+p*(n+d*p*(s+p*o)))),e.y=t.phi*(a+p*(l+d*(c+h*p+u*d)))},e.inv=function(e,y){var v,x,b,w,S=e.x,T=e.y;for(T>g?T=g:T<-g&&(T=-g),v=T;v-=x=(v*(a+(b=v*v)*(l+(w=b*b)*(c+h*b+u*w)))-T)/(p+b*(d+w*(f+m*b+_*w))),!(t(x)<1e-11););y.phi=v,b=v*v,y.lam=S/(i+b*(r+b*(n+b*b*b*(s+b*o))))}},"natearth","Natural Earth","PCyl., Sph."),tt(function(e){var i=.84719,r=-.13063,n=-.04515,s=.05494,o=-.02326,a=.00331,l=1.01183,c=-.02625,h=.01926,u=-.00396,p=l,d=9*c,f=.45334622460635143*w;e.es=0,e.fwd=function(t,e){var p,d,f;f=(p=t.phi*t.phi)*(d=p*p),e.x=t.lam*(i+r*p+f*f*(n+s*p+o*d+a*f)),e.y=t.phi*(l+d*d*(c+h*p+u*d))},e.inv=function(e,m){var _,g,y,v,x,b=e.x,w=e.y;for(w>f?w=f:w<-f&&(w=-f),_=w;_-=g=(_*(l+(v=(y=_*_)*y)*v*(c+h*y+u*v))-w)/(p+v*v*(d+.21186*y+-.05148*v)),!(t(g)<1e-11););m.phi=_,x=(y=_*_)*(v=y*y),m.lam=b/(i+r*y+x*x*(n+s*y+o*v+a*x))}},"natearth2","Natural Earth 2","PCyl., Sph."),tt(function(e){e.inv=function(t,e){e.lam=2*t.x/(1+r(t.y)),e.phi=Je(.5*(t.y+i(t.y)))},e.fwd=function(e,n){var s,o,a;for(s=2*i(e.phi),o=e.phi*e.phi,e.phi*=1.00371+o*(-.011412*o-.0935382),a=10;a&&(e.phi-=o=(e.phi+i(e.phi)-s)/(1+r(e.phi)),!(t(o)<1e-7));--a);n.x=.5*e.lam*(1+r(e.phi)),n.y=e.phi},e.es=0},"nell","Nell","PCyl., Sph."),tt(function(e){e.es=0,e.fwd=function(t,e){e.x=.5*t.lam*(1+r(t.phi)),e.y=2*(t.phi-n(.5*t.phi))},e.inv=function(e,i){var s,o,a,l;for(a=.5*e.y,l=9;l>0&&(o=r(.5*i.phi),i.phi-=s=(i.phi-n(i.phi/2)-a)/(1-.5/(o*o)),!(t(s)<1e-7));--l);l?i.lam=2*e.x/(1+r(i.phi)):(i.phi=a<0?-A:A,i.lam=2*e.x)}},"nell_h","Nell-Hammer","PCyl., Sph."),tt(function(e){e.es=0,e.fwd=function(e,n){var s=1e-10;if(t(e.lam)<s)n.x=0,n.y=e.phi;else if(t(e.phi)<s)n.x=e.lam,n.y=0;else if(t(t(e.lam)-A)<s)n.x=e.lam*r(e.phi),n.y=A*i(e.phi);else if(t(t(e.phi)-A)<s)n.x=0,n.y=e.phi;else{var o=A/e.lam-e.lam/A,a=e.phi/A,l=i(e.phi),c=(1-a*a)/(l-a),u=o/c,p=(o*l/c-.5*o)/(1+(u*=u)),d=(l/u+.5*c)/(1+1/u);n.x=r(e.phi),n.x=h(p*p+n.x*n.x/(1+u)),n.x=A*(p+(e.lam<0?-n.x:n.x)),n.y=h(d*d-(l*l/u+c*l-1)/(1+1/u)),n.y=A*(d+(e.phi<0?n.y:-n.y))}}},"nicol","Nicolosi Globular","Misc Sph, no inv"),tt(function(t){xi(t,Y(t.params,"dh"))},"nsper","Near-sided perspective","Azi, Sph\nh="),tt(function(t){var e=Y(t.params,"dtilt")*T,i=Y(t.params,"dazi")*T,r=Y(t.params,"dh");xi(t,r,e,i)},"tpers","Tilted perspective","Azi, Sph\ntilt= azi= h="),tt(function(e){var i=[[.7557853228,0],[.249204646,.003371507],[-.001541739,.04105856],[-.10162907,.01727609],[-.26623489,-.36249218],[-.6870983,-1.1651967]],r=[1.5627014243,.5185406398,-.03333098,-.1052906,-.0368594,.007317,.0122,.00394,-.0013],n=[.6399175073,-.1358797613,.063294409,-.02526853,.0117879,-.0055161,.0026906,-.001333,67e-5,-34e-5];e.ra=1/(e.a=6378388),e.lam0=173*T,e.phi0=-41*T,e.x0=251e4,e.y0=6023150,e.inv=function(n,s){var o,a,l,c,h,u,p={r:n.y,i:n.x},d={};for(o=20;o>0&&((h=yi(p,i,d)).r-=n.y,h.i-=n.x,u=d.r*d.r+d.i*d.i,p.r+=l=-(h.r*d.r+h.i*d.i)/u,p.i+=c=-(h.i*d.r-h.r*d.i)/u,!(t(l)+t(c)<=1e-10));--o);if(o>0){for(s.lam=p.i,a=r.length-1,s.phi=r[a],--a;a>=0;--a)s.phi=r[a]+p.r*s.phi;s.phi=e.phi0+p.r*s.phi*.484813681109536}else s.lam=s.phi=x},e.fwd=function(t,r){var s=n.length-1,o={r:n[s]},a=2.0626480624709638*(t.phi-e.phi0);for(--s;s>=0;--s)o.r=n[s]+a*o.r;o.r*=a,o.i=t.lam,o=gi(o,i),r.x=o.i,r.y=o.r}},"nzmg","New Zealand Map Grid","fixed Earth"),tt(function(e){var s,o,a,h,u,p,d,f,m,_,g,y,v,b,w,C=1e-10;s=Y(e.params,"so_proj"),o=Q[s],s||G(-26),o&&"ob_tran"!=s||G(-37),e.es=0,a={},Object.keys(e).forEach(function(t){a[t]=e[t]}),o.init(a),a.is_latlong&&1==e.to_meter&&(e.to_meter=T,e.fr_meter=S),Y(e.params,"to_alpha")?(f=Y(e.params,"ro_lon_c"),m=Y(e.params,"ro_lat_c"),_=Y(e.params,"ro_alpha"),t(t(m)-A)<=C&&G(-32),h=f+ei(-r(_),-i(_)*i(m)),d=Je(r(m)*i(_))):Y(e.params,"to_lat_p")?(h=Y(e.params,"ro_lon_p"),d=Y(e.params,"ro_lat_p")):(g=Y(e.params,"ro_lon_1"),v=Y(e.params,"ro_lat_1"),y=Y(e.params,"ro_lon_2"),b=Y(e.params,"ro_lat_2"),(t(v-b)<=C||(w=t(v))<=C||t(w-A)<=C||t(t(b)-A)<=C)&&G(-33),h=c(r(v)*i(b)*r(g)-i(v)*r(b)*r(y),i(v)*r(b)*i(y)-r(v)*i(b)*i(g)),d=l(-r(h-g)/n(v))),t(d)>C?(u=r(d),p=i(d),e.fwd=function(t,e){var n,s,o;n=r(t.lam),s=i(t.phi),o=r(t.phi),t.lam=Et(ei(o*i(t.lam),p*o*n+u*s)+h),t.phi=Je(p*s-u*o*n),a.fwd(t,e)},e.inv=a.inv?function(t,e){var n,s,o;a.inv(t,e),e.lam!=x&&(n=r(e.lam-=h),s=i(e.phi),o=r(e.phi),e.phi=Je(p*s+u*o*n),e.lam=ei(o*i(e.lam),p*o*n-u*s))}:null):(e.fwd=function(t,e){var n,s;n=r(t.phi),s=r(t.lam),t.lam=Et(ei(n*i(t.lam),i(t.phi))+h),t.phi=Je(-n*s),a.fwd(t,e)},e.inv=a.inv?function(t,e){var n,s;a.inv(t,e),e.lam!=x&&(n=r(e.phi),s=e.lam-h,e.lam=ei(n*i(s),-i(e.phi)),e.phi=Je(n*r(s)))}:null)},"ob_tran","General Oblique Transformation","Misc Sph\no_proj= plus parameters for projection\no_lat_p= o_lon_p= (new pole) or\no_alpha= o_lon_c= o_lat_c= or\no_lon_1= o_lat_1= o_lon_2= o_lat_2="),tt(function(t){var e,s,a,u,p,d,f,m,_,g,y;f=1/t.k0,m=t.k0,Y(t.params,"talpha")?(d=Y(t.params,"ralpha"),p=Y(t.params,"rlonc"),y=l(-r(d)/(-i(0)*i(d)))+p,_=o(r(0)*i(d))):(e=Y(t.params,"rlat_1"),s=Y(t.params,"rlat_2"),a=Y(t.params,"rlon_1"),u=Y(t.params,"rlon_2"),y=c(r(e)*i(s)*r(a)-i(e)*r(s)*r(u),i(e)*r(s)*i(u)-r(e)*i(s)*i(a)),a==-A&&(y=-y),_=l(-r(y-a)/n(e))),t.lam0=y+A,g=r(_),_=i(_),y=i(y),t.es=0,t.fwd=function(t,e){var s;e.y=i(t.lam),s=r(t.lam),e.x=l((n(t.phi)*g+_*e.y)/s),s<0&&(e.x+=w),e.x*=m,e.y=f*(_*i(t.phi)-g*r(t.phi)*e.y)},t.inv=function(t,e){var n,s;t.y/=f,t.x/=m,n=h(1-t.y*t.y),e.phi=o(t.y*_+n*g*(s=i(t.x))),e.lam=c(n*_*s-t.y*g,n*r(t.x))}},"ocea","Oblique Cylindrical Equal Area","Cyl, Sph lonc= alpha= or\nlat_1= lat_2= lon_1= lon_2="),tt(function(e){var s,a,f,m,_,g,y,v,b,S,T,C,M,I,D,k,z,L,F,B,O,N,q,U,$,Z,W,H=1e-7,X=0,K=0,J=0,Q=0,tt=0,et=0,it=0,rt=0;W=Y(e.params,"tno_rot"),0!=(C=Y(e.params,"talpha"))&&(it=Y(e.params,"ralpha")),0!=(M=Y(e.params,"tgamma"))&&(X=Y(e.params,"rgamma")),C||M?(K=Y(e.params,"rlonc"),(rt=Y(e.params,"tno_off")||Y(e.params,"tno_uoff"))&&(Y(e.params,"sno_uoff"),Y(e.params,"sno_off"))):(J=Y(e.params,"rlon_1"),tt=Y(e.params,"rlat_1"),Q=Y(e.params,"rlon_2"),et=Y(e.params,"rlat_2"),(t(tt-et)<=H||(s=t(tt))<=H||t(s-A)<=H||t(t(e.phi0)-A)<=H||t(t(et)-A)<=H)&&G(-33)),a=h(e.one_es),t(e.phi0)>R?(v=i(e.phi0),f=r(e.phi0),s=1-e.es*v*v,D=f*f,D=h(1+e.es*D*D/e.one_es),I=D*e.k0*a/s,(_=(m=D*a/(f*h(s)))*m-1)<=0?_=0:(_=h(_),e.phi0<0&&(_=-_)),k=_+=m,k*=u(mi(e.phi0,v,e.e),D)):(D=1/a,I=e.k0,k=m=_=1),C||M?(C?(T=o(i(it)/m),M||(X=it)):it=o(m*i(T=X)),e.lam0=K-o(.5*(_-1/_)*n(T))/D):(g=u(mi(tt,i(tt),e.e),D),y=u(mi(et,i(et),e.e),D),_=k/g,b=(y-g)/(y+g),S=((S=k*k)-y*g)/(S+y*g),(s=J-Q)<-w?Q-=P:s>w&&(Q+=P),e.lam0=Et(.5*(J+Q)-l(S*n(.5*D*(J-Q))/b)/D),T=l(2*i(D*Et(J-e.lam0))/(_-1/_)),X=it=o(m*i(T))),B=i(T),O=r(T),N=i(X),q=r(X),L=1/(z=I*(F=1/D)),rt?Z=0:(Z=t(z*l(h(m*m-1)/r(it))),e.phi0<0&&(Z=-Z)),U=z*d(n(E-(_=.5*T))),$=z*d(n(E+_)),e.fwd=function(n,s){var o,a,l,h,p,f,m,_;t(t(n.phi)-A)>R?(o=.5*((p=k/u(mi(n.phi,i(n.phi),e.e),D))-(f=1/p)),a=.5*(p+f),h=i(D*n.lam),t(t(l=(o*B-h*O)/a)-1)<R&&V(),_=.5*z*d((1-l)/(1+l)),f=r(D*n.lam),m=t(f)<H?I*n.lam:z*c(o*O+h*B,f)):(_=n.phi>0?U:$,m=z*n.phi),W?(s.x=m,s.y=_):(m-=Z,s.x=_*q+m*N,s.y=m*q-_*N)},e.inv=function(n,s){var o,a,l,d,f,m,_;W?(a=n.y,o=n.x):(a=n.x*q-n.y*N,o=n.y*q+n.x*N+Z),d=.5*((l=p(-L*a))-1/l),f=.5*(l+1/l),m=i(L*o),t(t(_=(m*O+d*B)/f)-1)<R?(s.lam=0,s.phi=_<0?-A:A):(s.phi=k/h((1+_)/(1-_)),(s.phi=_i(u(s.phi,1/D),e.e))==x&&j(),s.lam=-F*c(d*O-m*B,r(L*o)))}},"omerc","Oblique Mercator","Cyl, Sph&Ell no_rot\nalpha= [gamma=] [no_off] lonc= or\nlon_1= lat_1= lon_2= lat_2="),tt(function(e){var n=1e-10,s={};t(t(e.phi0)-A)<=n?s.mode=e.phi0<0?1:0:t(e.phi0)>n?(s.mode=3,s.sinph0=i(e.phi0),s.cosph0=r(e.phi0)):s.mode=2,e.fwd=function(o,a){var l,c,h;switch(c=r(o.phi),l=r(o.lam),s.mode){case 2:c*l<-1e-10&&V(),a.y=i(o.phi);break;case 3:s.sinph0*(h=i(o.phi))+s.cosph0*c*l<-1e-10&&V(),a.y=s.cosph0*h-s.sinph0*c*l;break;case 0:l=-l;case 1:t(o.phi-e.phi0)-n>A&&V(),a.y=c*l}a.x=c*i(o.lam)},e.inv=function(i,r){var l,u,p;if((p=l=f(i.x,i.y))>1&&(p-1>n&&j(),p=1),u=h(1-p*p),t(l)<=n)r.phi=e.phi0,r.lam=0;else{switch(s.mode){case 0:i.y=-i.y,r.phi=a(p);break;case 1:r.phi=-a(p);break;case 2:case 3:2==s.mode?(r.phi=i.y*p/l,i.x*=p,i.y=u*l):(r.phi=u*s.sinph0+i.y*p*s.cosph0/l,i.y=(u-s.sinph0*r.phi)*l,i.x*=p*s.cosph0),t(r.phi)>=1?r.phi=r.phi<0?-A:A:r.phi=o(r.phi)}r.lam=0!=i.y||3!=s.mode&&2!=s.mode?c(i.x,i.y):0==i.x?0:i.x<0?-A:A}},e.es=0},"ortho","Orthographic","Azi, Sph."),tt(function(e){var i=1.0148,r=.23185,n=-.14499,s=.02406,o=i,a=5*r,l=7*n,c=908571831.7;e.es=0,e.fwd=function(t,e){var o=t.phi*t.phi;e.x=t.lam,e.y=t.phi*(i+o*o*(r+o*(n+s*o)))},e.inv=function(e,h){var u,p,d,f;for(u=e.y,e.y>c?e.y=c:e.y<-c&&(e.y=-c),f=100;f&&(u-=p=(u*(i+(d=u*u)*d*(r+d*(n+s*d)))-e.y)/(o+d*d*(a+d*(l+.21654*d))),!(t(p)<1e-11));--f);h.phi=u,h.lam=e.x}},"patterson","Patterson Cylindrical","Cyl., Sph."),tt(function(e){var s,a,l=1e-10,c=1e-12;e.es?(a=Xe(e.es),s=Ye(e.phi0,i(e.phi0),r(e.phi0),a),e.fwd=function(n,o){var c,h,u;t(n.phi)<=l?(o.x=n.lam,o.y=-s):(h=i(n.phi),c=t(u=r(n.phi))>l?We(h,u,e.es)/h:0,o.x=c*i(n.lam*=h),o.y=Ye(n.phi,h,u,a)-s+c*(1-r(n.lam)))},e.inv=function(u,p){var d,f,m,_,g,y,v,x,b,w,S=u.x,T=u.y;if(t(T+=s)<=l)p.lam=S,p.phi=0;else{for(d=T*T+S*S,p.phi=T,w=20;w>0&&(g=(m=i(p.phi))*(_=r(p.phi)),t(_)<c&&j(),f=m*(x=h(1-e.es*m*m))/_,v=(y=Ye(p.phi,m,_,a))*y+d,x=e.one_es/(x*x*x),p.phi+=b=(y+y+f*v-2*T*(f*y+1))/(e.es*g*(v-2*T*y)/f+2*(T-y)*(f*x-1/g)-x-x),!(t(b)<=c));--w);w||j(),f=i(p.phi),p.lam=o(S*n(p.phi)*h(1-e.es*f*f))/i(p.phi)}}):(s=-e.phi0,e.fwd=function(o,a){var c,h;t(o.phi)<=l?(a.x=o.lam,a.y=s):(c=1/n(o.phi),a.x=i(h=o.lam*i(o.phi))*c,a.y=o.phi-e.phi0+c*(1-r(h)))},e.inv=function(r,s){var a,c,h,u;if(t(r.y=e.phi0+r.y)<=l)s.lam=r.x,s.phi=0;else{s.phi=r.y,a=r.x*r.x+r.y*r.y,u=10;do{h=n(s.phi),s.phi-=c=(r.y*(s.phi*h+1)-s.phi-.5*(s.phi*s.phi+a)*h)/((s.phi-r.y)/h-1)}while(t(c)>1e-10&&--u);u||j(),s.lam=o(r.x*n(s.phi))/i(s.phi)}})},"poly","Polyconic (American)","Conic, Sph&Ell"),tt(function(e){var n=1.8949,s=1.71848,o=.6141848493043784,a=1.0471975511965976;e.es=0,e.fwd=function(e,l){var c,h,u,p,d;for(c=o*i(e.phi),u=e.phi*e.phi,e.phi*=.615709+u*(.00909953+.0046292*u),d=10;d&&(h=r(e.phi),u=i(e.phi),e.phi-=p=(e.phi+u*(h-1)-c)/(1+h*(h-1)-u*u),!(t(p)<1e-10));--d);d||(e.phi=e.phi<0?-a:a),l.x=n*e.lam*(r(e.phi)-.5),l.y=s*i(e.phi)},e.inv=function(t,e){var a;e.phi=Je(t.y/s),e.lam=t.x/(n*((a=r(e.phi))-.5)),e.phi=Je((e.phi+i(e.phi)*(a-1))/o)}},"putp2","Putnins P2","PCyl., Sph."),tt(bi,"putp3","Putnins P3","PCyl., Sph."),tt(function(t){bi(t,!0)},"putp3p","Putnins P3'","PCyl., Sph."),tt(function(t){wi(t,.874038744,3.883251825)},"putp4p","Putnins P4'","PCyl., Sph."),tt(function(t){wi(t,1,4.442882938)},"weren","Werenskiold I","PCyl., Sph."),tt(Si,"putp5","Putnins P5","PCyl., Sph."),tt(function(t){Si(t,!0)},"putp5p","Putnins P5'","PCyl., Sph."),tt(Ti,"putp6","Putnins P6","PCyl., Sph."),tt(function(t){Ti(t,!0)},"putp6p","Putnins P6'","PCyl., Sph."),tt(function(e){var s,o,u,p;function d(e,i,r){var n,s;return e<1e-10?(n=0,s=0):(s=c(i,r),t(s)<=E?n=0:s>E&&s<=A+E?(n=1,s-=A):s>A+E||s<=-(A+E)?(n=2,s=s>=0?s-w:s+w):(n=3,s+=A)),{area:n,theta:s}}function f(t,e){var i=t+e;return i<-w?i+=P:i>+w&&(i-=P),i}s=e.phi0>=A-E/2?4:e.phi0<=-(A-E/2)?5:t(e.lam0)<=E?0:t(e.lam0)<=A+E?e.lam0>0?1:3:2,0!==e.es&&(e.a,e.a,o=e.a*h(1-e.es),u=1-(e.a-o)/e.a,p=u*u),e.fwd=function(t,o){var c,u,m,_,g,y,v,x,b,S,T,C,M,P;c=0!==e.es?l(p*n(t.phi)):t.phi,u=t.lam,4==s?(_=A-c,u>=E&&u<=A+E?(v=0,m=u-A):u>A+E||u<=-(A+E)?(v=1,m=u>0?u-w:u+w):u>-(A+E)&&u<=-E?(v=2,m=u+A):(v=3,m=u)):5==s?(_=A+c,u>=E&&u<=A+E?(v=0,m=-u+A):u<E&&u>=-E?(v=1,m=-u):u<-E&&u>=-(A+E)?(v=2,m=-u-A):(v=3,m=u>0?-u+w:-u-w)):(1==s?u=f(u,+A):2==s?u=f(u,+w):3==s&&(u=f(u,-A)),T=i(c),C=r(c),M=i(u),x=C*r(u),b=C*M,S=T,0==s?P=d(_=a(x),S,b):1==s?P=d(_=a(b),S,-x):2==s?P=d(_=a(-x),S,-b):3==s?P=d(_=a(-b),S,x):(_=0,P={area:0,theta:0}),m=P.theta,v=P.area),y=l(12/w*(m+a(i(m)*r(E))-A)),g=h((1-r(_))/(r(y)*r(y))/(1-r(l(1/r(m))))),1==v?y+=A:2==v?y+=w:3==v&&(y+=I),o.x=g*r(y),o.y=g*i(y)},e.inv=function(d,m){var _,g,y,v,x,b,S,T,C,M,E,I,P;if(g=l(h(d.x*d.x+d.y*d.y)),_=c(d.y,d.x),d.x>=0&&d.x>=t(d.y)?M=0:d.y>=0&&d.y>=t(d.x)?(M=1,_-=A):d.x<0&&-d.x>=t(d.y)?(M=2,_=_<0?_+w:_-w):(M=3,_+=A),C=w/12*n(_),x=i(C)/(r(C)-1/h(2)),b=l(x),(S=1-(y=r(_))*y*(v=n(g))*v*(1-r(l(1/r(b)))))<-1?S=-1:S>1&&(S=1),4==s)T=a(S),m.phi=A-T,m.lam=0==M?b+A:1==M?b<0?b+w:b-w:2==M?b-A:b;else if(5==s)T=a(S),m.phi=T-A,m.lam=0==M?-b+A:1==M?-b:2==M?-b-A:b<0?-b-w:-b+w;else{var D,k,z;C=(D=S)*D,k=(C+=(z=C>=1?0:h(1-C)*i(b))*z)>=1?0:h(1-C),1==M?(C=k,k=-z,z=C):2==M?(k=-k,z=-z):3==M&&(C=k,k=z,z=-C),1==s?(C=D,D=-k,k=C):2==s?(D=-D,k=-k):3==s&&(C=D,D=k,k=-C),m.phi=a(-z)-A,m.lam=c(k,D),1==s?m.lam=f(m.lam,-A):2==s?m.lam=f(m.lam,-w):3==s&&(m.lam=f(m.lam,+A))}0!==e.es&&(E=m.phi<0?1:0,I=n(m.phi),P=o/h(I*I+p),m.phi=l(h(e.a*e.a-P*P)/(u*P)),E&&(m.phi=-m.phi))}},"qsc","Quadrilateralized Spherical Cube","Azi, Sph."),tt(function(i){var r=c([[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]]),n=c([[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]]),s=.8487,o=1.3523;function a(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))}function l(t,e){return t[1]+e*(t[2]+t[2]+3*e*t[3])}function c(t){return t.map(function(t){return new Float32Array(t)})}i.es=0,i.fwd=function(i,l){var c,h;(c=e(11.459155902616464*(h=t(i.phi))))<0&&V(),c>=18&&(c=17),h=S*(h-.08726646259971647*c),l.x=a(r[c],h)*s*i.lam,l.y=a(n[c],h)*o,i.phi<0&&(l.y=-l.y)},i.inv=function(i,c){var h,u,p,d;if(c.lam=i.x/s,c.phi=t(i.y/o),c.phi>=1)c.phi>1.000001?j():(c.phi=i.y<0?-A:A,c.lam/=r[18][0]);else{if((d=e(18*c.phi))<0||d>=18)return j();for(;;)if(n[d][0]>c.phi)--d;else{if(!(n[d+1][0]<=c.phi))break;++d}for(p=new Float32Array(n[d]),h=5*(c.phi-p[0])/(n[d+1][0]-p[0]),p[0]-=c.phi;h-=u=a(p,h)/l(p,h),!(t(u)<1e-8););c.phi=(5*d+h)*T,i.y<0&&(c.phi=-c.phi),c.lam/=a(r[d],h)}}},"robin","Robinson","PCyl., Sph."),tt(Ci("EULER"),"euler","Euler","Conic, Sph\nlat_1= and lat_2="),tt(Ci("MURD1"),"murd1","Murdoch I","Conic, Sph\nlat_1= and lat_2="),tt(Ci("MURD2"),"murd2","Murdoch II","Conic, Sph\nlat_1= and lat_2="),tt(Ci("MURD3"),"murd3","Murdoch III","Conic, Sph\nlat_1= and lat_2="),tt(Ci("PCONIC"),"pconic","Perspective Conic","Conic, Sph\nlat_1= and lat_2="),tt(Ci("TISSOT"),"tissot","Tissot","Conic, Sph\nlat_1= and lat_2="),tt(Ci("VITK1"),"vitk1","Vitkovsky I","Conic, Sph\nlat_1= and lat_2="),tt(function(e){var s,o,a,c,u,f,m,_,g;a=.5*e.e,m=r(e.phi0),m*=m,o=h(1+e.es*m*m*e.rone_es),g=i(e.phi0),u=r(_=Je(f=g/o)),g*=e.e,s=d(n(E+.5*_))-o*(d(n(E+.5*e.phi0))-a*d((1+g)/(1-g))),c=e.k0*h(e.one_es)/(1-g*g),e.inv=function(h,m){var _,g,y,v,x,b,w,S,T;for(y=2*(l(p(h.y/c))-E),v=h.x/c,x=r(y),_=Je(u*i(y)+f*x*r(v)),g=Je(x*i(v)/r(_)),w=(s-d(n(E+.5*_)))/o,T=6;T&&(b=e.e*i(_),_-=S=(w+d(n(E+.5*_))-a*d((1+b)/(1-b)))*(1-b*b)*r(_)*e.rone_es,!(t(S)<1e-10));--T);T?(m.phi=_,m.lam=g/o):j()},e.fwd=function(t,h){var m,_,g,y,v,x;v=e.e*i(t.phi),m=2*l(p(o*(d(n(E+.5*t.phi))-a*d((1+v)/(1-v)))+s))-A,_=o*t.lam,x=r(m),g=Je(u*i(m)-f*x*r(_)),y=Je(x*i(_)/r(g)),h.x=c*y,h.y=c*d(n(E+.5*g))}},"somerc","Swiss. Obl. Mercator","Cyl, Ell\nFor CH1903"),tt(function(t){var e=Y(t.params,"tlat_ts")?Y(t.params,"rlat_ts"):A;Mi(t,e)},"stere","Stereographic","Azi, Sph&Ell\nlat_ts="),tt(function(t){t.phi0=Y(t.params,"bsouth")?-A:A,t.k0=.994,t.x0=2e6,t.y0=2e6,t.lam0=0,t.es||G(-34),Mi(t,A)},"ups","Universal Polar Stereographic","Azi, Sph&Ell\nsouth"),tt(function(e){var s,a,p,d,m,_,g,y,v,x=(s=e.e,a=e.phi0,p=s*s,d=i(a),m=r(a),_=h(1-p)/(1-p*d*d),g=h(1+p*m*m*m*m/(1-p)),y=o(d/g),v=.5*g*s,{e:s,K:n(.5*y+E)/(u(n(.5*a+E),g)*Ei(s*d,v)),C:g,chi:y,ratexp:v,rc:_}),b=x.chi,w=2*x.rc,S=i(b),T=r(b);e.fwd=function(t,s){var o,a,c,h;t=function(t,e){return{phi:2*l(e.K*u(n(.5*t.phi+E),e.C)*Ei(e.e*i(t.phi),e.ratexp))-A,lam:e.C*t.lam}}(t,x),a=i(t.phi),o=r(t.phi),c=r(t.lam),h=e.k0*w/(1+S*a+T*o*c),s.x=h*o*i(t.lam),s.y=h*(T*a-S*o*c)},e.inv=function(s,a){var h,p,d,m,_=s.x/e.k0,g=s.y/e.k0;(h=f(_,g))?(p=2*c(h,w),d=i(p),m=r(p),a.phi=o(m*S+g*d*T/h),a.lam=c(_*d,h*T*m-g*S*d)):(a.phi=b,a.lam=0),function(e,r){e.phi;var s,o,a=u(n(.5*e.phi+E)/r.K,1/r.C);for(e.lam/=r.C,s=20;s>0&&(o=2*l(a*Ei(r.e*i(e.phi),-.5*r.e))-A,!(t(o-e.phi)<1e-14));--s)e.phi=o;s||N(-17)}(a,x)}},"sterea","Oblique Stereographic Alternative","Azimuthal, Sph&Ell"),tt(function(t){Ai(t,1.50488,1.35439,!1)},"kav5","Kavraisky V","PCyl., Sph."),tt(function(t){Ai(t,2,2,!1)},"qua_aut","Quartic Authalic","PCyl., Sph."),tt(function(t){Ai(t,2,2,!0)},"fouc","Foucaut","PCyl., Sph."),tt(function(t){Ai(t,1.48875,1.36509,!1)},"mbt_s","McBryde-Thomas Flat-Polar Sine (No. 1)","PCyl., Sph."),tt(function(t){t.es=0,t.fwd=function(e,s){s.x=r(e.phi)*i(e.lam)/t.k0,s.y=t.k0*(c(n(e.phi),r(e.lam))-t.phi0)},t.inv=function(e,n){var s;e.y=e.y/t.k0+t.phi0,e.x*=t.k0,s=h(1-e.x*e.x),n.phi=o(s*i(e.y)),n.lam=c(e.x,s*r(e.y))}},"tcea","Transverse Cylindrical Equal Area","Cyl, Sph"),tt(function(t){t.es=0,t.fwd=function(t,e){var r=n(t.phi/2),s=i(E*r);e.x=t.lam*(.74482-.34588*s*s),e.y=1.70711*r},t.inv=function(t,e){var r=t.y/1.70711,n=i(E*r);e.lam=t.x/(.74482-.34588*n*n),e.phi=2*l(r)}},"times","Times","Cyl, Sph"),tt(function(e){Y(e.params,"bapprox")?Ii(e):function(e){if(0===e.es)return Ii(e);ai(e);var i=e.fwd,r=e.inv;Ii(e);var n=e.fwd,s=e.inv;e.fwd=function(e,r){t(e.lam)>3*T?i(e,r):n(e,r)},e.inv=function(e,i){t(e.x)>.053-.022*e.y*e.y?r(e,i):s(e,i)}}(e)},"tmerc","Transverse Mercator","Cyl, Sph&Ell"),tt(function(t){var i;t.es||G(-34),t.y0=Y(t.params,"bsouth")?1e7:0,t.x0=5e5,Y(t.params,"tzone")?(i=Y(t.params,"izone"))>0&&i<=60?--i:G(-35):(i=e(30*(Et(t.lam0)+w)/w))<0?i=0:i>=60&&(i=59),t.lam0=(i+.5)*w/30-w,t.k0=.9996,t.phi0=0,ai(t)},"utm","Universal Transverse Mercator (UTM)","Cyl, Sph\nzone= south"),tt(function(t){var e,s,o,a,l,h,u,p,d,m,_,g,y,v,x,b,w,S,T,C,M,E,I;C=Y(t.params,"rlat_1"),S=Y(t.params,"rlon_1"),M=Y(t.params,"rlat_2"),T=Y(t.params,"rlon_2"),C==M&&S==T&&G(-25),t.lam0=Et(.5*(S+T)),m=Et(T-S),e=r(C),o=r(M),s=i(C),a=i(M),h=e*a,u=s*o,l=e*o*i(m),d=Qe(s*a+e*o*r(m)),_=.5*d,E=c(o*i(m),e*a-s*o*r(m)),v=r(I=Je(e*i(E))),x=i(I),b=Et(c(e*r(E),s)-_),m*=.5,w=A-c(i(E)*s,r(E))-m,g=n(_),y=.5/i(_),p=.5/d,d*=d,t.fwd=function(t,n){var c,f,_,g,y,v,x;v=i(t.phi),x=r(t.phi),f=Qe(s*v+e*x*r(g=t.lam+m)),_=Qe(a*v+o*x*r(y=t.lam-m)),f*=f,_*=_,n.x=p*(c=f-_),c=d-c,n.y=p*ti(4*d*_-c*c),l*v-x*(h*i(g)-u*i(y))<0&&(n.y=-n.y)},t.inv=function(t,e){var n,s,o,a,l,h;o=(n=r(f(t.y,t.x+_)))+(s=r(f(t.y,t.x-_))),a=n-s,e.lam=-c(a,o*g),e.phi=Qe(f(g*o,a)*y),t.y<0&&(e.phi=-e.phi),h=i(e.phi),l=r(e.phi),e.phi=Je(x*h+v*l*(o=r(e.lam-=b))),e.lam=c(l*i(e.lam),x*l*o-v*h)+w},t.es=0},"tpeqd","Two Point Equidistant","Misc Sph\nlat_1= lon_1= lat_2= lon_2="),tt(function(t){var e,n,s,o,a,l;(o=Y(t.params,"dn"))>0&&o<=1==0&&G(-40),s=Y(t.params,"dq")/3,a=Y(t.params,"ralpha"),l=o*i(a),e=r(a)/h(1-l*l),n=1/(e*o),t.fwd=function(t,a){var l=t.phi=Je(o*i(t.phi));a.x=e*t.lam*r(t.phi),l*=l,a.y=t.phi*(1+l*s)*n},t.es=0},"urm5","Urmaev V","PCyl., Sph., no inv.\nn= q= alpha="),tt(function(t){var e=Y(t.params,"dn");(e<=0||e>1)&&G(-40),Pi(t,e)},"urmfps","Urmaev Flat-Polar Sinusoidal","PCyl, Sph.\nn="),tt(function(t){Pi(t,.8660254037844386)},"wag1","Wagner I (Kavraisky VI)","PCyl, Sph."),tt(function(e){var i=1e-10,s=.3333333333333333,l=9.869604401089358,c=19.739208802178716,u=4.934802200544679;e.fwd=function(e,r){var s,a,l,c,u;(u=t(e.phi/A))-i>1&&V(),u>1&&(u=1),t(e.phi)<=i?(r.x=e.lam,r.y=0):t(e.lam)<=i||t(u-1)<i?(r.x=0,r.y=w*n(.5*o(u)),e.phi<0&&(r.y=-r.y)):(a=(s=.5*t(w/e.lam-e.lam/w))*s,l=h(1-u*u),c=(l/=u+l-1)*l,u=l*(2/u-1),u*=u,r.x=l-u,l=u+a,r.x=w*(s*r.x+h(a*r.x*r.x-l*(c-u)))/l,e.lam<0&&(r.x=-r.x),r.y=t(r.x/w),r.y=1-r.y*(r.y+2*s),r.y<-i&&V(),r.y<0?r.y=0:r.y=h(r.y)*(e.phi<0?-w:w))},e.inv=function(e,n){var o,p,d,f,m,_,g,y,v,x,b,S,T;if(S=e.x*e.x,(b=t(e.y))<i)return n.phi=0,o=S*S+c*(S+u),n.lam=t(e.x)<=i?0:.5*(S-l+h(o))/e.x,n;T=e.y*e.y,f=(d=-w*b*((y=S+T)+l))+l*(y-3*T),p=w*b,v=2*h(-s*(_=d/(m=(g=y*y)+P*(b*y+w*(T+w*(b+A))))-s*(f/=m)*f)),(o=t(x=3*(x=.07407407407407407*f*f*f+(p*p-s*f*d)/m)/(_*v)))-i<=1?(x=o>1?x>0?0:w:a(x),n.phi=w*(v*r(x*s+4.188790204786391)-s*f),e.y<0&&(n.phi=-n.phi),o=g+c*(S-T+u),n.lam=t(e.x)<=i?0:.5*(y-l+(o<=0?0:h(o)))/e.x):j()}},"vandg","van der Grinten (I)","Misc Sph"),tt(function(t){Di(t,!1)},"vandg2","van der Grinten II","Misc Sph, no inv."),tt(function(t){Di(t,!0)},"vandg3","van der Grinten III","Misc Sph, no inv."),tt(function(e){e.es=0,e.fwd=function(e,i){var r,n,s,o,a,l,c,u,p=1e-10;t(e.phi)<p?(i.x=e.lam,i.y=0):t(e.lam)<p||t(t(e.phi)-A)<p?(i.x=0,i.y=e.phi):(l=(o=.5*((s=t(D*e.phi))*(8-s*(2+(a=s*s)))-5)/(a*(s-1)))*o,c=D*e.lam,c=h((c+=1/c)*c-4),t(e.lam)-A<0&&(c=-c),r=s+o,r=(c*((r*=r)+l-1)+2*h(r*(a+l*(u=c*c)-1)+(1-a)*(a*((n=s+3*o)*n+4*l)+l*(12*s*o+4*l))))/(4*r+u),i.x=A*r,i.y=A*h(1+c*t(r)-r*r),e.lam<0&&(i.x=-i.x),e.phi<0&&(i.y=-i.y))}},"vandg4","van der Grinten IV","Misc Sph, no inv."),tt(function(t){var e=.92483,n=1.38725,s=.88022,o=.8855;t.fwd=function(t,a){t.phi=Je(s*i(o*t.phi)),a.x=e*t.lam*r(t.phi),a.y=n*t.phi},t.inv=function(t,a){a.phi=t.y/n,a.lam=t.x/(e*r(a.phi)),a.phi=Je(i(a.phi)/s)/o}},"wag2","Wagner II","PCyl., Sph."),tt(function(t){var e=.6666666666666666,i=Y(t.params,"rlat_ts"),n=r(i)/r(2*i/3);t.es=0,t.fwd=function(t,i){i.x=n*t.lam*r(e*t.phi),i.y=t.phi},t.inv=function(t,i){i.phi=t.y,i.lam=t.x/(n*r(e*i.phi))}},"wag3","Wagner III","PCyl., Sph.\nlat_ts="),tt(function(t){t.es=0,t.fwd=function(t,e){var n,s,a;n=o(e.y=.9063077870366499*i(t.phi)),e.x=2.66723*(s=r(n))*i(t.lam/=3),e.y*=1.24104*(a=1/h(.5*(1+s*r(t.lam)))),e.x*=a}},"wag7","Wagner VII","Misc Sph, no inv."),tt(function(t){var e=r(Y(t.params,"rlat_ts"));t.fwd=function(t,i){i.x=.5*t.lam*(e+r(t.phi)),i.y=t.phi},t.inv=function(t,i){i.phi=t.y,i.lam=2*t.x/(e+r(i.phi))},t.es=0},"wink1","Winkel I","PCyl., Sph.\nlat_ts="),tt(function(e){var n=r(Y(e.params,"rlat_1"));e.fwd=function(e,s){var o,a,l,c=e.phi;for(s.y=c*D,o=w*i(c),c*=1.8,l=10;l&&(c-=a=(c+i(c)-o)/(1+r(c)),!(t(a)<1e-7));--l);l?c*=.5:c=c<0?-A:A,s.x=.5*e.lam*(r(c)+n),s.y=E*(i(c)+s.y)},e.inv=null,e.es=0},"wink2","Winkel II","PCyl., Sph., no inv.\nlat_1=");var ki=Dt;ki.pj_init=_t,ki.pj_fwd=At,ki.pj_inv=It,ki.pj_transform=St,ki.pj_add=tt,ki.pj_fwd_deg=function(t,e){return At({lam:t.lam*T,phi:t.phi*T},e)},ki.pj_inv_deg=function(t,e){var i=It(t,e);return{lam:i.lam*S,phi:i.phi*S}},ki.pj_transform_point=wt,ki.internal={dmstod:W,dmstor:Z,get_rtodms:function(t,e,i,r){var n=Pt(t,e,i,r);return function(t){return n(t*S)}},get_dtodms:Pt,get_proj_defn:rt,pj_latlong_from_proj:function(t){return _t("+proj=latlong"+it(t))},pj_get_params:K,pj_datums:st,pj_list:Q,pj_ellps:lt,pj_units:ht,pj_read_init_opts:mt,find_datum:at,DEG_TO_RAD:T,RAD_TO_DEG:S,wkt_parse:Ne,wkt_unpack:Ve,convert_wkt_quotes:je,wkt_to_proj4:function(t){var e,i,r=Ne(t);return r.PROJCS?e=Ot(i=r.PROJCS)(i):r.GEOGCS?e="+proj=longlat "+Wt(r.GEOGCS):r.GEOCCS?Ut("geocentric coordinates are not supported"):Ut("missing a supported WKT CS type"),e},wkt_from_proj4:function(t){return t.length&&(t=_t(t)),Fe(et(t)?{GEOGCS:Jt(t)}:se(t))},wkt_make_projcs:se,wkt_get_geogcs_name:ee,wkt_stringify:Fe,mproj_insert_libcache:function(t,e){dt[t]=e},mproj_search_libcache:ft,GeographicLib:$e},v.exports=ki}();var w=n.exports,S=e({__proto__:null,default:i(w)},[w]);class T{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(t,e){let i=this.length++;for(;i>0;){const t=i-1>>1,r=this.values[t];if(e>=r)break;this.ids[i]=this.ids[t],this.values[i]=r,i=t}this.ids[i]=t,this.values[i]=e}pop(){if(0===this.length)return;const t=this.ids,e=this.values,i=t[0],r=--this.length;if(r>0){const i=t[r],n=e[r];let s=0;const o=r>>1;for(;s<o;){const i=1+(s<<1),o=i+1,a=i+(+(o<r)&+(e[o]<e[i]));if(e[a]>=n)break;t[s]=t[a],e[s]=e[a],s=a}t[s]=i,e[s]=n}return i}peek(){return this.length>0?this.ids[0]:void 0}peekValue(){return this.length>0?this.values[0]:void 0}shrink(){this.ids.length=this.values.length=this.length}}const C=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class M{static from(t,e=0){if(e%8!=0)throw new Error("byteOffset must be 8-byte aligned.");if(!t||void 0===t.byteLength||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[i,r]=new Uint8Array(t,e+0,2);if(251!==i)throw new Error("Data does not appear to be in a Flatbush format.");const n=r>>4;if(3!==n)throw new Error(`Got v${n} data when expected v3.`);const s=C[15&r];if(!s)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,e+2,1),[a]=new Uint32Array(t,e+4,1);return new M(a,o,s,void 0,t,e)}constructor(t,e=16,i=Float64Array,r=ArrayBuffer,n,s=0){if(void 0===t)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.byteOffset=s;let o=t,a=o;this._levelBounds=[4*o];do{o=Math.ceil(o/this.nodeSize),a+=o,this._levelBounds.push(4*a)}while(1!==o);this.ArrayType=i,this.IndexArrayType=a<16384?Uint16Array:Uint32Array;const l=C.indexOf(i),c=4*a*i.BYTES_PER_ELEMENT;if(l<0)throw new Error(`Unexpected typed array class: ${i}.`);if(n)this.data=n,this._boxes=new i(n,s+8,4*a),this._indices=new this.IndexArrayType(n,s+8+c,a),this._pos=4*a,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1];else{const n=this.data=new r(8+c+a*this.IndexArrayType.BYTES_PER_ELEMENT);this._boxes=new i(n,8,4*a),this._indices=new this.IndexArrayType(n,8+c,a),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(n,0,2).set([251,48+l]),new Uint16Array(n,2,1)[0]=e,new Uint32Array(n,4,1)[0]=t}this._queue=new T}add(t,e,i=t,r=e){const n=this._pos>>2,s=this._boxes;return this._indices[n]=n,s[this._pos++]=t,s[this._pos++]=e,s[this._pos++]=i,s[this._pos++]=r,t<this.minX&&(this.minX=t),e<this.minY&&(this.minY=e),i>this.maxX&&(this.maxX=i),r>this.maxY&&(this.maxY=r),n}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);const t=this._boxes;if(this.numItems<=this.nodeSize)return t[this._pos++]=this.minX,t[this._pos++]=this.minY,t[this._pos++]=this.maxX,void(t[this._pos++]=this.maxY);const e=this.maxX-this.minX||1,i=this.maxY-this.minY||1,r=new Uint32Array(this.numItems);for(let n=0,s=0;n<this.numItems;n++){const o=t[s++],a=t[s++],l=t[s++],c=t[s++],h=Math.floor(65535*((o+l)/2-this.minX)/e),u=Math.floor(65535*((a+c)/2-this.minY)/i);r[n]=P(h,u)}A(r,t,this._indices,0,this.numItems-1,this.nodeSize);for(let e=0,i=0;e<this._levelBounds.length-1;e++){const r=this._levelBounds[e];for(;i<r;){const e=i;let n=t[i++],s=t[i++],o=t[i++],a=t[i++];for(let e=1;e<this.nodeSize&&i<r;e++)n=Math.min(n,t[i++]),s=Math.min(s,t[i++]),o=Math.max(o,t[i++]),a=Math.max(a,t[i++]);this._indices[this._pos>>2]=e,t[this._pos++]=n,t[this._pos++]=s,t[this._pos++]=o,t[this._pos++]=a}}}search(t,e,i,r,n){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let s=this._boxes.length-4;const o=[],a=[];for(;void 0!==s;){const l=Math.min(s+4*this.nodeSize,E(s,this._levelBounds));for(let c=s;c<l;c+=4){const l=this._boxes[c];if(i<l)continue;const h=this._boxes[c+1];if(r<h)continue;const u=this._boxes[c+2];if(t>u)continue;const p=this._boxes[c+3];if(e>p)continue;const d=0|this._indices[c>>2];s>=4*this.numItems?o.push(d):(void 0===n||n(d,l,h,u,p))&&a.push(d)}s=o.pop()}return a}neighbors(t,e,i=1/0,r=1/0,n){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let s=this._boxes.length-4;const o=this._queue,a=[],l=r*r;t:for(;void 0!==s;){const r=Math.min(s+4*this.nodeSize,E(s,this._levelBounds));for(let i=s;i<r;i+=4){const r=0|this._indices[i>>2],a=this._boxes[i],c=this._boxes[i+1],h=this._boxes[i+2],u=this._boxes[i+3],p=t<a?a-t:t>h?t-h:0,d=e<c?c-e:e>u?e-u:0,f=p*p+d*d;f>l||(s>=4*this.numItems?o.push(r<<1,f):(void 0===n||n(r))&&o.push(1+(r<<1),f))}for(;o.length&&1&o.peek();){if(o.peekValue()>l)break t;if(a.push(o.pop()>>1),a.length===i)break t}s=o.length?o.pop()>>1:void 0}return o.clear(),a}}function E(t,e){let i=0,r=e.length-1;for(;i<r;){const n=i+r>>1;e[n]>t?r=n:i=n+1}return e[i]}function A(t,e,i,r,n,s){if(Math.floor(r/s)>=Math.floor(n/s))return;const o=t[r],a=t[r+n>>1],l=t[n];let c=l;const h=Math.max(o,a);l>h?c=h:h===o?c=Math.max(a,l):h===a&&(c=Math.max(o,l));let u=r-1,p=n+1;for(;;){do{u++}while(t[u]<c);do{p--}while(t[p]>c);if(u>=p)break;I(t,e,i,u,p)}A(t,e,i,r,p,s),A(t,e,i,p+1,n,s)}function I(t,e,i,r,n){const s=t[r];t[r]=t[n],t[n]=s;const o=4*r,a=4*n,l=e[o],c=e[o+1],h=e[o+2],u=e[o+3];e[o]=e[a],e[o+1]=e[a+1],e[o+2]=e[a+2],e[o+3]=e[a+3],e[a]=l,e[a+1]=c,e[a+2]=h,e[a+3]=u;const p=i[r];i[r]=i[n],i[n]=p}function P(t,e){let i=t^e,r=65535^i,n=65535^(t|e),s=t&(65535^e),o=i|r>>1,a=i>>1^i,l=n>>1^r&s>>1^n,c=i&n>>1^s>>1^s;i=o,r=a,n=l,s=c,o=i&i>>2^r&r>>2,a=i&r>>2^r&(i^r)>>2,l^=i&n>>2^r&s>>2,c^=r&n>>2^(i^r)&s>>2,i=o,r=a,n=l,s=c,o=i&i>>4^r&r>>4,a=i&r>>4^r&(i^r)>>4,l^=i&n>>4^r&s>>4,c^=r&n>>4^(i^r)&s>>4,i=o,r=a,n=l,s=c,l^=i&n>>8^r&s>>8,c^=r&n>>8^(i^r)&s>>8,i=l^l>>1,r=c^c>>1;let h=t^e,u=r|65535^(h|i);return h=16711935&(h|h<<8),h=252645135&(h|h<<4),h=858993459&(h|h<<2),h=1431655765&(h|h<<1),u=16711935&(u|u<<8),u=252645135&(u|u<<4),u=858993459&(u|u<<2),u=1431655765&(u|u<<1),(u<<1|h)>>>0}const D=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class k{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=D[15&i];if(!n)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new k(o,s,n,t)}constructor(t,e=64,i=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const n=D.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return z(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=o){for(let o=u;o<=h;o++){const a=s[2*o],c=s[2*o+1];a>=t&&a<=i&&c>=e&&c<=r&&l.push(n[o])}continue}const p=u+h>>1,d=s[2*p],f=s[2*p+1];d>=t&&d<=i&&f>=e&&f<=r&&l.push(n[p]),(0===c?t<=d:e<=f)&&(a.push(u),a.push(p-1),a.push(1-c)),(0===c?i>=d:r>=f)&&(a.push(p+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:s}=this,o=[0,r.length-1,0],a=[],l=i*i;for(;o.length;){const c=o.pop()||0,h=o.pop()||0,u=o.pop()||0;if(h-u<=s){for(let i=u;i<=h;i++)B(n[2*i],n[2*i+1],t,e)<=l&&a.push(r[i]);continue}const p=u+h>>1,d=n[2*p],f=n[2*p+1];B(d,f,t,e)<=l&&a.push(r[p]),(0===c?t-i<=d:e-i<=f)&&(o.push(u),o.push(p-1),o.push(1-c)),(0===c?t+i>=d:e+i>=f)&&(o.push(p+1),o.push(h),o.push(1-c))}return a}}function z(t,e,i,r,n,s){if(n-r<=i)return;const o=r+n>>1;R(t,e,o,r,n,s),z(t,e,i,r,o-1,1-s),z(t,e,i,o+1,n,1-s)}function R(t,e,i,r,n,s){for(;n>r;){if(n-r>600){const o=n-r+1,a=i-r+1,l=Math.log(o),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(o-c)/o)*(a-o/2<0?-1:1);R(t,e,i,Math.max(r,Math.floor(i-a*c/o+h)),Math.min(n,Math.floor(i+(o-a)*c/o+h)),s)}const o=e[2*i+s];let a=r,l=n;for(L(t,e,r,i),e[2*n+s]>o&&L(t,e,r,n);a<l;){for(L(t,e,a,l),a++,l--;e[2*a+s]<o;)a++;for(;e[2*l+s]>o;)l--}e[2*r+s]===o?L(t,e,r,l):(l++,L(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function L(t,e,i,r){F(t,i,r),F(e,2*i,2*r),F(e,2*i+1,2*r+1)}function F(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function B(t,e,i,r){const n=t-i,s=e-r;return n*n+s*s}var O={exports:{}};!function(t){var e,i,r,n;(n={}).Constants={},n.Math={},n.Accumulator={},(e=n.Constants).WGS84={a:6378137,f:1/298.257223563},e.version={major:2,minor:2,patch:0},e.version_string="2.2.0",(i=n.Math).digits=53,i.epsilon=Math.pow(.5,i.digits-1),i.degree=Math.PI/180,i.sq=function(t){return t*t},i.hypot=function(t,e){return Math.sqrt(t*t+e*e)},i.cbrt=Math.cbrt||function(t){var e=Math.pow(Math.abs(t),1/3);return t>0?e:t<0?-e:t},i.log1p=Math.log1p||function(t){var e=1+t,i=e-1;return 0===i?t:t*Math.log(e)/i},i.atanh=Math.atanh||function(t){var e=Math.abs(t);return e=i.log1p(2*e/(1-e))/2,t>0?e:t<0?-e:t},i.copysign=function(t,e){return Math.abs(t)*(e<0||0===e&&1/e<0?-1:1)},i.sum=function(t,e){var i=t+e,r=i-e,n=i-r;return r-=t,{s:i,t:i?0-(r+(n-=e)):i}},i.polyval=function(t,e,i,r){for(var n=t<0?0:e[i++];--t>=0;)n=n*r+e[i++];return n},i.AngRound=function(t){var e=1/16,r=Math.abs(t);return r=r<e?e-(e-r):r,i.copysign(r,t)},i.remainder=function(t,e){return(t%=e)<-e/2?t+e:t<e/2?t:t-e},i.AngNormalize=function(t){var e=i.remainder(t,360);return 180===Math.abs(e)?i.copysign(180,t):e},i.LatFix=function(t){return Math.abs(t)>90?NaN:t},i.AngDiff=function(t,e){var r,n,s=i.sum(i.remainder(-t,360),i.remainder(e,360));return r=(s=i.sum(i.remainder(s.s,360),s.t)).s,n=s.t,0!==r&&180!==Math.abs(r)||(r=i.copysign(r,0===n?e-t:-n)),{d:r,e:n}},i.sincosd=function(t){var e,r,n,s,o,a,l;switch(e=t%360,r=(e-=90*(n=Math.round(e/90)))*this.degree,s=Math.sin(r),o=Math.cos(r),45===Math.abs(e)?(o=Math.sqrt(.5),s=i.copysign(o,r)):30===Math.abs(e)&&(o=Math.sqrt(.75),s=i.copysign(.5,r)),3&n){case 0:a=s,l=o;break;case 1:a=o,l=-s;break;case 2:a=-s,l=-o;break;default:a=-o,l=s}return l+=0,0===a&&(a=i.copysign(a,t)),{s:a,c:l}},i.sincosde=function(t,e){var r,n,s,o,a,l,c;switch(r=t%360,s=Math.round(r/90),n=(r=i.AngRound(r-90*s+e))*this.degree,o=Math.sin(n),a=Math.cos(n),45===Math.abs(r)?(a=Math.sqrt(.5),o=i.copysign(a,n)):30===Math.abs(r)&&(a=Math.sqrt(.75),o=i.copysign(.5,n)),3&s){case 0:l=o,c=a;break;case 1:l=a,c=-o;break;case 2:l=-o,c=-a;break;default:l=-a,c=o}return c+=0,0===l&&(l=i.copysign(l,t+e)),{s:l,c:c}},i.atan2d=function(t,e){var r,n=0;switch(Math.abs(t)>Math.abs(e)&&([t,e]=[e,t],n=2),i.copysign(1,e)<0&&(e=-e,++n),r=Math.atan2(t,e)/this.degree,n){case 1:r=i.copysign(180,t)-r;break;case 2:r=90-r;break;case 3:r=-90+r}return r},function(t,e){t.Accumulator=function(t){this.Set(t)},t.Accumulator.prototype.Set=function(e){e||(e=0),e.constructor===t.Accumulator?(this._s=e._s,this._t=e._t):(this._s=e,this._t=0)},t.Accumulator.prototype.Add=function(t){var i=e.sum(t,this._t),r=e.sum(i.s,this._s);i=i.t,this._s=r.s,this._t=r.t,0===this._s?this._s=i:this._t+=i},t.Accumulator.prototype.Sum=function(e){var i;return e?((i=new t.Accumulator(this)).Add(e),i._s):this._s},t.Accumulator.prototype.Negate=function(){this._s*=-1,this._t*=-1},t.Accumulator.prototype.Remainder=function(t){this._s=e.remainder(this._s,t),this.Add(0)}}(n.Accumulator,n.Math),n.Geodesic={},n.GeodesicLine={},n.PolygonArea={},function(t,e,i,r,n){var s,o,a,l,c,h,u,p,d,f,m,_=20+r.digits+10,g=r.epsilon,y=200*g,v=Math.sqrt(g),x=g,b=1e3*v;t.tiny_=Math.sqrt(Number.MIN_VALUE/Number.EPSILON),t.nC1_=6,t.nC1p_=6,t.nC2_=6,t.nC3_=6,t.nC4_=6,s=t.nC3_*(t.nC3_-1)/2,o=t.nC4_*(t.nC4_+1)/2,t.CAP_C1=1,t.CAP_C1p=2,t.CAP_C2=4,t.CAP_C3=8,t.CAP_C4=16,t.NONE=0,t.ARC=64,t.LATITUDE=128,t.LONGITUDE=256|t.CAP_C3,t.AZIMUTH=512,t.DISTANCE=1024|t.CAP_C1,t.STANDARD=t.LATITUDE|t.LONGITUDE|t.AZIMUTH|t.DISTANCE,t.DISTANCE_IN=2048|t.CAP_C1|t.CAP_C1p,t.REDUCEDLENGTH=4096|t.CAP_C1|t.CAP_C2,t.GEODESICSCALE=8192|t.CAP_C1|t.CAP_C2,t.AREA=16384|t.CAP_C4,t.ALL=32671,t.LONG_UNROLL=32768,t.OUT_MASK=32640|t.LONG_UNROLL,t.SinCosSeries=function(t,e,i,r){var n=r.length,s=n-(t?1:0),o=2*(i-e)*(i+e),a=1&s?r[--n]:0,l=0;for(s=Math.floor(s/2);s--;)a=o*(l=o*a-l+r[--n])-a+r[--n];return t?2*e*i*a:i*(a-l)},a=function(t,e){var i,n,s,o,a,l,c,h,u,p,d,f,m=r.sq(t),_=r.sq(e),g=(m+_-1)/6;return 0===_&&g<=0?i=0:(l=g,(a=(n=m*_/4)*(n+2*(o=g*(s=r.sq(g)))))>=0?(c=n+o,c+=c<0?-Math.sqrt(a):Math.sqrt(a),l+=(h=r.cbrt(c))+(0!==h?s/h:0)):(u=Math.atan2(Math.sqrt(-a),-(n+o)),l+=2*g*Math.cos(u/3)),p=Math.sqrt(r.sq(l)+_),f=((d=l<0?_/(p-l):l+p)-_)/(2*p),i=d/(Math.sqrt(d+r.sq(f))+f)),i},l=[1,4,64,0,256],t.A1m1f=function(t){var e=Math.floor(3);return(r.polyval(e,l,0,r.sq(t))/l[e+1]+t)/(1-t)},c=[-1,6,-16,32,-9,64,-128,2048,9,-16,768,3,-5,512,-7,1280,-7,2048],t.C1f=function(e,i){var n,s,o=r.sq(e),a=e,l=0;for(n=1;n<=t.nC1_;++n)s=Math.floor((t.nC1_-n)/2),i[n]=a*r.polyval(s,c,l,o)/c[l+s+1],l+=s+2,a*=e},h=[205,-432,768,1536,4005,-4736,3840,12288,-225,116,384,-7173,2695,7680,3467,7680,38081,61440],t.C1pf=function(e,i){var n,s,o=r.sq(e),a=e,l=0;for(n=1;n<=t.nC1p_;++n)s=Math.floor((t.nC1p_-n)/2),i[n]=a*r.polyval(s,h,l,o)/h[l+s+1],l+=s+2,a*=e},u=[-11,-28,-192,0,256],t.A2m1f=function(t){var e=Math.floor(3);return(r.polyval(e,u,0,r.sq(t))/u[e+1]-t)/(1+t)},p=[1,2,16,32,35,64,384,2048,15,80,768,7,35,512,63,1280,77,2048],t.C2f=function(e,i){var n,s,o=r.sq(e),a=e,l=0;for(n=1;n<=t.nC2_;++n)s=Math.floor((t.nC2_-n)/2),i[n]=a*r.polyval(s,p,l,o)/p[l+s+1],l+=s+2,a*=e},t.Geodesic=function(t,e){if(this.a=t,this.f=e,this._f1=1-this.f,this._e2=this.f*(2-this.f),this._ep2=this._e2/r.sq(this._f1),this._n=this.f/(2-this.f),this._b=this.a*this._f1,this._c2=(r.sq(this.a)+r.sq(this._b)*(0===this._e2?1:(this._e2>0?r.atanh(Math.sqrt(this._e2)):Math.atan(Math.sqrt(-this._e2)))/Math.sqrt(Math.abs(this._e2))))/2,this._etol2=.1*v/Math.sqrt(Math.max(.001,Math.abs(this.f))*Math.min(1,1-this.f/2)/2),!(isFinite(this.a)&&this.a>0))throw new Error("Equatorial radius is not positive");if(!(isFinite(this._b)&&this._b>0))throw new Error("Polar semi-axis is not positive");this._A3x=new Array(6),this._C3x=new Array(s),this._C4x=new Array(o),this.A3coeff(),this.C3coeff(),this.C4coeff()},d=[-3,128,-2,-3,64,-1,-3,-1,16,3,-1,-2,8,1,-1,2,1,1],t.Geodesic.prototype.A3coeff=function(){var t,e,i=0,n=0;for(t=5;t>=0;--t)e=Math.min(6-t-1,t),this._A3x[n++]=r.polyval(e,d,i,this._n)/d[i+e+1],i+=e+2},f=[3,128,2,5,128,-1,3,3,64,-1,0,1,8,-1,1,4,5,256,1,3,128,-3,-2,3,64,1,-3,2,32,7,512,-10,9,384,5,-9,5,192,7,512,-14,7,512,21,2560],t.Geodesic.prototype.C3coeff=function(){var e,i,n,s=0,o=0;for(e=1;e<t.nC3_;++e)for(i=t.nC3_-1;i>=e;--i)n=Math.min(t.nC3_-i-1,i),this._C3x[o++]=r.polyval(n,f,s,this._n)/f[s+n+1],s+=n+2},m=[97,15015,1088,156,45045,-224,-4784,1573,45045,-10656,14144,-4576,-858,45045,64,624,-4576,6864,-3003,15015,100,208,572,3432,-12012,30030,45045,1,9009,-2944,468,135135,5792,1040,-1287,135135,5952,-11648,9152,-2574,135135,-64,-624,4576,-6864,3003,135135,8,10725,1856,-936,225225,-8448,4992,-1144,225225,-1440,4160,-4576,1716,225225,-136,63063,1024,-208,105105,3584,-3328,1144,315315,-128,135135,-2560,832,405405,128,99099],t.Geodesic.prototype.C4coeff=function(){var e,i,n,s=0,o=0;for(e=0;e<t.nC4_;++e)for(i=t.nC4_-1;i>=e;--i)n=t.nC4_-i-1,this._C4x[o++]=r.polyval(n,m,s,this._n)/m[s+n+1],s+=n+2},t.Geodesic.prototype.A3f=function(t){return r.polyval(5,this._A3x,0,t)},t.Geodesic.prototype.C3f=function(e,i){var n,s,o=1,a=0;for(n=1;n<t.nC3_;++n)s=t.nC3_-n-1,o*=e,i[n]=o*r.polyval(s,this._C3x,a,e),a+=s+1},t.Geodesic.prototype.C4f=function(e,i){var n,s,o=1,a=0;for(n=0;n<t.nC4_;++n)s=t.nC4_-n-1,i[n]=o*r.polyval(s,this._C4x,a,e),a+=s+1,o*=e},t.Geodesic.prototype.Lengths=function(e,i,r,n,s,o,a,l,c,h,u,p,d){var f,m,_,g,y={},v=0,x=0,b=0,w=0;if((u&=t.OUT_MASK)&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&(b=t.A1m1f(e),t.C1f(e,p),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(w=t.A2m1f(e),t.C2f(e,d),v=b-w,w=1+w),b=1+b),u&t.DISTANCE)f=t.SinCosSeries(!0,o,a,p)-t.SinCosSeries(!0,r,n,p),y.s12b=b*(i+f),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(x=v*i+(b*f-w*(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,r,n,d))));else if(u&(t.REDUCEDLENGTH|t.GEODESICSCALE)){for(m=1;m<=t.nC2_;++m)d[m]=b*p[m]-w*d[m];x=v*i+(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,r,n,d))}return u&t.REDUCEDLENGTH?(y.m0=v,y.m12b=l*(n*o)-s*(r*a)-n*a*x):y.m12b=NaN,u&t.GEODESICSCALE&&(_=n*a+r*o,g=this._ep2*(c-h)*(c+h)/(s+l),y.M12=_+(g*o-a*x)*r/s,y.M21=_-(g*r-n*x)*o/l),y},t.Geodesic.prototype.InverseStart=function(e,i,n,s,o,l,c,h,u,p,d){var f,m,_,g,v,x,w,S,T,C,M,E,A,I,P,D,k,z,R,L,F={},B=s*i-o*e,O=o*i+s*e;return F.sig12=-1,f=s*i,f+=o*e,(m=O>=0&&B<.5&&o*c<.5)?(g=r.sq(e+s),g/=g+r.sq(i+o),F.dnm=Math.sqrt(1+this._ep2*g),_=c/(this._f1*F.dnm),v=Math.sin(_),x=Math.cos(_)):(v=h,x=u),F.salp1=o*v,F.calp1=x>=0?B+o*e*r.sq(v)/(1+x):f-o*e*r.sq(v)/(1-x),S=r.hypot(F.salp1,F.calp1),T=e*s+i*o*x,m&&S<this._etol2?(F.salp2=i*v,F.calp2=B-i*s*(x>=0?r.sq(v)/(1+x):1-x),w=r.hypot(F.salp2,F.calp2),F.salp2/=w,F.calp2/=w,F.sig12=Math.atan2(S,T)):Math.abs(this._n)>.1||T>=0||S>=6*Math.abs(this._n)*Math.PI*r.sq(i)||(L=Math.atan2(-h,-u),this.f>=0?(I=(A=r.sq(e)*this._ep2)/(2*(1+Math.sqrt(1+A))+A),C=L/(E=this.f*i*this.A3f(I)*Math.PI),M=f/(E*i)):(P=o*i-s*e,D=Math.atan2(f,P),M=c/(E=((C=(k=this.Lengths(this._n,Math.PI+D,e,-i,n,s,o,l,i,o,t.REDUCEDLENGTH,p,d)).m12b/(i*o*k.m0*Math.PI)-1)<-.01?f/C:-this.f*r.sq(i)*Math.PI)/i)),M>-y&&C>-1-b?this.f>=0?(F.salp1=Math.min(1,-C),F.calp1=-Math.sqrt(1-r.sq(F.salp1))):(F.calp1=Math.max(C>-y?0:-1,C),F.salp1=Math.sqrt(1-r.sq(F.calp1))):(z=a(C,M),R=E*(this.f>=0?-C*z/(1+z):-M*(1+z)/z),v=Math.sin(R),x=-Math.cos(R),F.salp1=o*v,F.calp1=f-o*e*r.sq(v)/(1-x))),F.salp1<=0?(F.salp1=1,F.calp1=0):(w=r.hypot(F.salp1,F.calp1),F.salp1/=w,F.calp1/=w),F},t.Geodesic.prototype.Lambda12=function(e,i,n,s,o,a,l,c,h,u,p,d,f,m){var _,g,y,v,x,b,w,S,T,C,M,E,A,I={};return 0===e&&0===c&&(c=-t.tiny_),g=l*i,y=r.hypot(c,l*e),I.ssig1=e,v=g*e,I.csig1=x=c*i,_=r.hypot(I.ssig1,I.csig1),I.ssig1/=_,I.csig1/=_,I.salp2=o!==i?g/o:l,I.calp2=o!==i||Math.abs(s)!==-e?Math.sqrt(r.sq(c*i)+(i<-e?(o-i)*(i+o):(e-s)*(e+s)))/o:Math.abs(c),I.ssig2=s,b=g*s,I.csig2=w=I.calp2*o,_=r.hypot(I.ssig2,I.csig2),I.ssig2/=_,I.csig2/=_,I.sig12=Math.atan2(Math.max(0,I.csig1*I.ssig2-I.ssig1*I.csig2),I.csig1*I.csig2+I.ssig1*I.ssig2),S=Math.max(0,x*b-v*w),T=x*w+v*b,M=Math.atan2(S*u-T*h,T*u+S*h),E=r.sq(y)*this._ep2,I.eps=E/(2*(1+Math.sqrt(1+E))+E),this.C3f(I.eps,m),C=t.SinCosSeries(!0,I.ssig2,I.csig2,m)-t.SinCosSeries(!0,I.ssig1,I.csig1,m),I.domg12=-this.f*this.A3f(I.eps)*g*(I.sig12+C),I.lam12=M+I.domg12,p&&(0===I.calp2?I.dlam12=-2*this._f1*n/e:(A=this.Lengths(I.eps,I.sig12,I.ssig1,I.csig1,n,I.ssig2,I.csig2,a,i,o,t.REDUCEDLENGTH,d,f),I.dlam12=A.m12b,I.dlam12*=this._f1/(I.calp2*o))),I},t.Geodesic.prototype.Inverse=function(e,i,n,s,o){var a,l;return o||(o=t.STANDARD),o===t.LONG_UNROLL&&(o|=t.STANDARD),o&=t.OUT_MASK,l=(a=this.InverseInt(e,i,n,s,o)).vals,o&t.AZIMUTH&&(l.azi1=r.atan2d(a.salp1,a.calp1),l.azi2=r.atan2d(a.salp2,a.calp2)),l},t.Geodesic.prototype.InverseInt=function(e,i,n,s,o){var a,l,c,h,u,p,d,f,m,y,b,w,S,T,C,M,E,A,I,P,D,k,z,R,L,F,B,O,N,V,j,q,G,U,$,Z,W,H,X,Y,K,J,Q,tt,et,it,rt,nt,st,ot,at,lt,ct,ht,ut,pt,dt,ft,mt,_t,gt,yt,vt,xt,bt,wt={};if(wt.lat1=e=r.LatFix(e),wt.lat2=n=r.LatFix(n),e=r.AngRound(e),n=r.AngRound(n),l=(a=r.AngDiff(i,s)).e,a=a.d,o&t.LONG_UNROLL?(wt.lon1=i,wt.lon2=i+a+l):(wt.lon1=r.AngNormalize(i),wt.lon2=r.AngNormalize(s)),l*=c=r.copysign(1,a),C=(a*=c)*r.degree,M=(h=r.sincosde(a,l)).s,E=h.c,l=180-a-l,(u=Math.abs(e)<Math.abs(n)||isNaN(n)?-1:1)<0&&(c*=-1,[n,e]=[e,n]),e*=p=r.copysign(1,-e),n*=p,h=r.sincosd(e),d=this._f1*h.s,f=h.c,d/=h=r.hypot(d,f),f/=h,f=Math.max(t.tiny_,f),h=r.sincosd(n),m=this._f1*h.s,y=h.c,m/=h=r.hypot(m,y),y/=h,y=Math.max(t.tiny_,y),f<-d?y===f&&(m=r.copysign(d,m)):Math.abs(m)===-d&&(y=f),S=Math.sqrt(1+this._ep2*r.sq(d)),T=Math.sqrt(1+this._ep2*r.sq(m)),z=new Array(t.nC1_+1),R=new Array(t.nC2_+1),L=new Array(t.nC3_),(F=-90===e||0===M)&&(P=M,k=0,O=d,N=(I=E)*f,V=m,j=(D=1)*y,A=Math.atan2(Math.max(0,N*V-O*j),N*j+O*V),b=(B=this.Lengths(this._n,A,O,N,S,V,j,T,f,y,o|t.DISTANCE|t.REDUCEDLENGTH,z,R)).s12b,w=B.m12b,o&t.GEODESICSCALE&&(wt.M12=B.M12,wt.M21=B.M21),A<v||w>=0?((A<3*t.tiny_||A<g&&(b<0||w<0))&&(A=w=b=0),w*=this._b,b*=this._b,wt.a12=A/r.degree):F=!1),dt=2,!F&&0===d&&(this.f<=0||l>=180*this.f))I=D=0,P=k=1,b=this.a*C,A=G=C/this._f1,w=this._b*Math.sin(A),o&t.GEODESICSCALE&&(wt.M12=wt.M21=Math.cos(A)),wt.a12=a/this._f1;else if(!F)if(A=(B=this.InverseStart(d,f,S,m,y,T,C,M,E,z,R)).sig12,P=B.salp1,I=B.calp1,A>=0)k=B.salp2,D=B.calp2,U=B.dnm,b=A*this._b*U,w=r.sq(U)*this._b*Math.sin(A/U),o&t.GEODESICSCALE&&(wt.M12=wt.M21=Math.cos(A/U)),wt.a12=A/r.degree,G=C/(this._f1*U);else{for($=0,Z=t.tiny_,W=1,H=t.tiny_,X=-1,Y=!1,K=!1;J=(B=this.Lambda12(d,f,S,m,y,T,P,I,M,E,$<20,z,R,L)).lam12,k=B.salp2,D=B.calp2,A=B.sig12,O=B.ssig1,N=B.csig1,V=B.ssig2,j=B.csig2,q=B.eps,mt=B.domg12,Q=B.dlam12,!K&&Math.abs(J)>=(Y?8:1)*g&&$!=_;++$)J>0&&($<20||I/P>X/H)?(H=P,X=I):J<0&&($<20||I/P<W/Z)&&(Z=P,W=I),$<20&&Q>0&&(tt=-J/Q,Math.abs(tt)<Math.PI&&(et=Math.sin(tt),(rt=P*(it=Math.cos(tt))+I*et)>0))?(I=I*it-P*et,P=rt,P/=h=r.hypot(P,I),I/=h,Y=Math.abs(J)<=16*g):(P=(Z+H)/2,I=(W+X)/2,P/=h=r.hypot(P,I),I/=h,Y=!1,K=Math.abs(Z-P)+(W-I)<x||Math.abs(P-H)+(I-X)<x);nt=o|(o&(t.REDUCEDLENGTH|t.GEODESICSCALE)?t.DISTANCE:t.NONE),b=(B=this.Lengths(q,A,O,N,S,V,j,T,f,y,nt,z,R)).s12b,w=B.m12b,o&t.GEODESICSCALE&&(wt.M12=B.M12,wt.M21=B.M21),w*=this._b,b*=this._b,wt.a12=A/r.degree,o&t.AREA&&(xt=Math.sin(mt),dt=M*(bt=Math.cos(mt))-E*xt,ft=E*bt+M*xt)}return o&t.DISTANCE&&(wt.s12=0+b),o&t.REDUCEDLENGTH&&(wt.m12=0+w),o&t.AREA&&(st=P*f,0!==(ot=r.hypot(I,P*d))&&0!==st?(O=d,N=I*f,V=m,j=D*y,q=(lt=r.sq(ot)*this._ep2)/(2*(1+Math.sqrt(1+lt))+lt),ct=r.sq(this.a)*ot*st*this._e2,O/=h=r.hypot(O,N),N/=h,V/=h=r.hypot(V,j),j/=h,ht=new Array(t.nC4_),this.C4f(q,ht),ut=t.SinCosSeries(!1,O,N,ht),pt=t.SinCosSeries(!1,V,j,ht),wt.S12=ct*(pt-ut)):wt.S12=0,F||2!=dt||(dt=Math.sin(G),ft=Math.cos(G)),!F&&ft>-.7071&&m-d<1.75?(mt=1+ft,_t=1+f,gt=1+y,at=2*Math.atan2(dt*(d*gt+m*_t),mt*(d*m+_t*gt))):(vt=D*I+k*P,0===(yt=k*I-D*P)&&vt<0&&(yt=t.tiny_*I,vt=-1),at=Math.atan2(yt,vt)),wt.S12+=this._c2*at,wt.S12*=u*c*p,wt.S12+=0),u<0&&([k,P]=[P,k],[D,I]=[I,D],o&t.GEODESICSCALE&&([wt.M21,wt.M12]=[wt.M12,wt.M21])),{vals:wt,salp1:P*=u*c,calp1:I*=u*p,salp2:k*=u*c,calp2:D*=u*p}},t.Geodesic.prototype.GenDirect=function(i,r,n,s,o,a){return a?a===t.LONG_UNROLL&&(a|=t.STANDARD):a=t.STANDARD,s||(a|=t.DISTANCE_IN),new e.GeodesicLine(this,i,r,n,a).GenPosition(s,o,a)},t.Geodesic.prototype.Direct=function(t,e,i,r,n){return this.GenDirect(t,e,i,!1,r,n)},t.Geodesic.prototype.ArcDirect=function(t,e,i,r,n){return this.GenDirect(t,e,i,!0,r,n)},t.Geodesic.prototype.Line=function(t,i,r,n){return new e.GeodesicLine(this,t,i,r,n)},t.Geodesic.prototype.DirectLine=function(t,e,i,r,n){return this.GenDirectLine(t,e,i,!1,r,n)},t.Geodesic.prototype.ArcDirectLine=function(t,e,i,r,n){return this.GenDirectLine(t,e,i,!0,r,n)},t.Geodesic.prototype.GenDirectLine=function(i,r,n,s,o,a){var l;return a||(a=t.STANDARD|t.DISTANCE_IN),s||(a|=t.DISTANCE_IN),(l=new e.GeodesicLine(this,i,r,n,a)).GenSetDistance(s,o),l},t.Geodesic.prototype.InverseLine=function(i,n,s,o,a){var l,c,h;return a||(a=t.STANDARD|t.DISTANCE_IN),l=this.InverseInt(i,n,s,o,t.ARC),h=r.atan2d(l.salp1,l.calp1),a&t.OUT_MASK&t.DISTANCE_IN&&(a|=t.DISTANCE),(c=new e.GeodesicLine(this,i,n,h,a,l.salp1,l.calp1)).SetArc(l.vals.a12),c},t.Geodesic.prototype.Polygon=function(t){return new i.PolygonArea(this,t)},t.WGS84=new t.Geodesic(n.WGS84.a,n.WGS84.f)}(n.Geodesic,n.GeodesicLine,n.PolygonArea,n.Math,n.Constants),function(t,e,i){e.GeodesicLine=function(e,r,n,s,o,a,l){var c,h,u,p,d,f;o||(o=t.STANDARD|t.DISTANCE_IN),this.a=e.a,this.f=e.f,this._b=e._b,this._c2=e._c2,this._f1=e._f1,this.caps=o|t.LATITUDE|t.AZIMUTH|t.LONG_UNROLL,this.lat1=i.LatFix(r),this.lon1=n,void 0===a||void 0===l?(this.azi1=i.AngNormalize(s),c=i.sincosd(i.AngRound(this.azi1)),this.salp1=c.s,this.calp1=c.c):(this.azi1=s,this.salp1=a,this.calp1=l),c=i.sincosd(i.AngRound(this.lat1)),u=this._f1*c.s,h=c.c,u/=c=i.hypot(u,h),h/=c,h=Math.max(t.tiny_,h),this._dn1=Math.sqrt(1+e._ep2*i.sq(u)),this._salp0=this.salp1*h,this._calp0=i.hypot(this.calp1,this.salp1*u),this._ssig1=u,this._somg1=this._salp0*u,this._csig1=this._comg1=0!==u||0!==this.calp1?h*this.calp1:1,c=i.hypot(this._ssig1,this._csig1),this._ssig1/=c,this._csig1/=c,this._k2=i.sq(this._calp0)*e._ep2,p=this._k2/(2*(1+Math.sqrt(1+this._k2))+this._k2),this.caps&t.CAP_C1&&(this._A1m1=t.A1m1f(p),this._C1a=new Array(t.nC1_+1),t.C1f(p,this._C1a),this._B11=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C1a),d=Math.sin(this._B11),f=Math.cos(this._B11),this._stau1=this._ssig1*f+this._csig1*d,this._ctau1=this._csig1*f-this._ssig1*d),this.caps&t.CAP_C1p&&(this._C1pa=new Array(t.nC1p_+1),t.C1pf(p,this._C1pa)),this.caps&t.CAP_C2&&(this._A2m1=t.A2m1f(p),this._C2a=new Array(t.nC2_+1),t.C2f(p,this._C2a),this._B21=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C2a)),this.caps&t.CAP_C3&&(this._C3a=new Array(t.nC3_),e.C3f(p,this._C3a),this._A3c=-this.f*this._salp0*e.A3f(p),this._B31=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C3a)),this.caps&t.CAP_C4&&(this._C4a=new Array(t.nC4_),e.C4f(p,this._C4a),this._A4=i.sq(this.a)*this._calp0*this._salp0*e._e2,this._B41=t.SinCosSeries(!1,this._ssig1,this._csig1,this._C4a)),this.a13=this.s13=NaN},e.GeodesicLine.prototype.GenPosition=function(e,r,n){var s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C,M,E,A,I,P,D={};return n?n===t.LONG_UNROLL&&(n|=t.STANDARD):n=t.STANDARD,n&=this.caps&t.OUT_MASK,D.lat1=this.lat1,D.azi1=this.azi1,D.lon1=n&t.LONG_UNROLL?this.lon1:i.AngNormalize(this.lon1),e?D.a12=r:D.s12=r,e||this.caps&t.DISTANCE_IN&t.OUT_MASK?(l=0,c=0,e?(s=r*i.degree,o=(E=i.sincosd(r)).s,a=E.c):(p=r/(this._b*(1+this._A1m1)),d=Math.sin(p),f=Math.cos(p),s=p-((l=-t.SinCosSeries(!0,this._stau1*f+this._ctau1*d,this._ctau1*f-this._stau1*d,this._C1pa))-this._B11),o=Math.sin(s),a=Math.cos(s),Math.abs(this.f)>.01&&(h=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,l=t.SinCosSeries(!0,h,u,this._C1a),s-=((1+this._A1m1)*(s+(l-this._B11))-r/this._b)/Math.sqrt(1+this._k2*i.sq(h)),o=Math.sin(s),a=Math.cos(s))),h=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,S=Math.sqrt(1+this._k2*i.sq(h)),n&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&((e||Math.abs(this.f)>.01)&&(l=t.SinCosSeries(!0,h,u,this._C1a)),c=(1+this._A1m1)*(l-this._B11)),g=this._calp0*h,0===(y=i.hypot(this._salp0,this._calp0*u))&&(y=u=t.tiny_),b=this._salp0,w=this._calp0*u,e&&n&t.DISTANCE&&(D.s12=this._b*((1+this._A1m1)*s+c)),n&t.LONGITUDE&&(v=this._salp0*h,x=u,_=i.copysign(1,this._salp0),m=((n&t.LONG_UNROLL?_*(s-(Math.atan2(h,u)-Math.atan2(this._ssig1,this._csig1))+(Math.atan2(_*v,x)-Math.atan2(_*this._somg1,this._comg1))):Math.atan2(v*this._comg1-x*this._somg1,x*this._comg1+v*this._somg1))+this._A3c*(s+(t.SinCosSeries(!0,h,u,this._C3a)-this._B31)))/i.degree,D.lon2=n&t.LONG_UNROLL?this.lon1+m:i.AngNormalize(i.AngNormalize(this.lon1)+i.AngNormalize(m))),n&t.LATITUDE&&(D.lat2=i.atan2d(g,this._f1*y)),n&t.AZIMUTH&&(D.azi2=i.atan2d(b,w)),n&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(T=t.SinCosSeries(!0,h,u,this._C2a),C=(1+this._A2m1)*(T-this._B21),M=(this._A1m1-this._A2m1)*s+(c-C),n&t.REDUCEDLENGTH&&(D.m12=this._b*(S*(this._csig1*h)-this._dn1*(this._ssig1*u)-this._csig1*u*M)),n&t.GEODESICSCALE&&(E=this._k2*(h-this._ssig1)*(h+this._ssig1)/(this._dn1+S),D.M12=a+(E*h-u*M)*this._ssig1/this._dn1,D.M21=a-(E*this._ssig1-this._csig1*M)*h/S)),n&t.AREA&&(A=t.SinCosSeries(!1,h,u,this._C4a),0===this._calp0||0===this._salp0?(I=b*this.calp1-w*this.salp1,P=w*this.calp1+b*this.salp1):(I=this._calp0*this._salp0*(a<=0?this._csig1*(1-a)+o*this._ssig1:o*(this._csig1*o/(1+a)+this._ssig1)),P=i.sq(this._salp0)+i.sq(this._calp0)*this._csig1*u),D.S12=this._c2*Math.atan2(I,P)+this._A4*(A-this._B41)),e||(D.a12=s/i.degree),D):(D.a12=NaN,D)},e.GeodesicLine.prototype.Position=function(t,e){return this.GenPosition(!1,t,e)},e.GeodesicLine.prototype.ArcPosition=function(t,e){return this.GenPosition(!0,t,e)},e.GeodesicLine.prototype.GenSetDistance=function(t,e){t?this.SetArc(e):this.SetDistance(e)},e.GeodesicLine.prototype.SetDistance=function(e){var i;this.s13=e,i=this.GenPosition(!1,this.s13,t.ARC),this.a13=0+i.a12},e.GeodesicLine.prototype.SetArc=function(e){var i;this.a13=e,i=this.GenPosition(!0,this.a13,t.DISTANCE),this.s13=0+i.s12}}(n.Geodesic,n.GeodesicLine,n.Math),function(t,e,i,r){var n,s,o,a;n=function(t,e){var r=i.AngDiff(t,e).d;return t=i.AngNormalize(t),e=i.AngNormalize(e),r>0&&(t<0&&e>=0||t>0&&0===e)?1:r<0&&t>=0&&e<0?-1:0},s=function(t,e){return(0<=(e%=720)&&e<360||e<-360?0:1)-(0<=(t%=720)&&t<360||t<-360?0:1)},o=function(t,e,i,r,n){return t.Remainder(e),1&i&&t.Add((t.Sum()<0?1:-1)*e/2),r||t.Negate(),n?t.Sum()>e/2?t.Add(-e):t.Sum()<=-e/2&&t.Add(+e):t.Sum()>=e?t.Add(-e):t.Sum()<0&&t.Add(+e),0+t.Sum()},a=function(t,e,r,n,s){return t=i.remainder(t,e),1&r&&(t+=(t<0?1:-1)*e/2),n||(t*=-1),s?t>e/2?t-=e:t<=-e/2&&(t+=e):t>=e?t-=e:t<0&&(t+=e),0+t},t.PolygonArea=function(t,i){this._geod=t,this.a=this._geod.a,this.f=this._geod.f,this._area0=4*Math.PI*t._c2,this.polyline=i||!1,this._mask=e.LATITUDE|e.LONGITUDE|e.DISTANCE|(this.polyline?e.NONE:e.AREA|e.LONG_UNROLL),this.polyline||(this._areasum=new r.Accumulator(0)),this._perimetersum=new r.Accumulator(0),this.Clear()},t.PolygonArea.prototype.Clear=function(){this.num=0,this._crossings=0,this.polyline||this._areasum.Set(0),this._perimetersum.Set(0),this._lat0=this._lon0=this.lat=this.lon=NaN},t.PolygonArea.prototype.AddPoint=function(t,e){var i;0===this.num?(this._lat0=this.lat=t,this._lon0=this.lon=e):(i=this._geod.Inverse(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(i.s12),this.polyline||(this._areasum.Add(i.S12),this._crossings+=n(this.lon,e)),this.lat=t,this.lon=e),++this.num},t.PolygonArea.prototype.AddEdge=function(t,e){var i;this.num&&(i=this._geod.Direct(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(e),this.polyline||(this._areasum.Add(i.S12),this._crossings+=s(this.lon,i.lon2)),this.lat=i.lat2,this.lon=i.lon2),++this.num},t.PolygonArea.prototype.Compute=function(t,e){var i,s,a={number:this.num};return this.num<2?(a.perimeter=0,this.polyline||(a.area=0),a):this.polyline?(a.perimeter=this._perimetersum.Sum(),a):(i=this._geod.Inverse(this.lat,this.lon,this._lat0,this._lon0,this._mask),a.perimeter=this._perimetersum.Sum(i.s12),(s=new r.Accumulator(this._areasum)).Add(i.S12),a.area=o(s,this._area0,this._crossings+n(this.lon,this._lon0),t,e),a)},t.PolygonArea.prototype.TestPoint=function(t,e,i,r){var s,o,l,c,h={number:this.num+1};if(0===this.num)return h.perimeter=0,this.polyline||(h.area=0),h;for(h.perimeter=this._perimetersum.Sum(),o=this.polyline?0:this._areasum.Sum(),l=this._crossings,c=0;c<(this.polyline?1:2);++c)s=this._geod.Inverse(0===c?this.lat:t,0===c?this.lon:e,0!==c?this._lat0:t,0!==c?this._lon0:e,this._mask),h.perimeter+=s.s12,this.polyline||(o+=s.S12,l+=n(0===c?this.lon:e,0!==c?this._lon0:e));return this.polyline||(h.area=a(o,this._area0,l,i,r)),h},t.PolygonArea.prototype.TestEdge=function(t,e,i,r){var o,l,c,h={number:this.num?this.num+1:0};return 0===this.num||(h.perimeter=this._perimetersum.Sum()+e,this.polyline||(l=this._areasum.Sum(),c=this._crossings,l+=(o=this._geod.Direct(this.lat,this.lon,t,e,this._mask)).S12,c+=s(this.lon,o.lon2),c+=n(o.lon2,this._lon0),o=this._geod.Inverse(o.lat2,o.lon2,this._lat0,this._lon0,this._mask),h.perimeter+=o.s12,l+=o.S12,h.area=a(l,this._area0,c,i,r))),h}}(n.PolygonArea,n.Geodesic,n.Math,n.Accumulator),r=n,t.exports?t.exports=r:window.geodesic=r}(O);var N=O.exports,V=e({__proto__:null,default:i(N)},[N]);const j=globalThis;"undefined"==typeof window&&(j.window=j.window||{},j.window.document||(j.window.document={}));const q=j.window.modules=j.window.modules||{};q.mproj=S,q.flatbush=M,q.kdbush=k,q["geographiclib-geodesic"]=V;class G{_listeners={};on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}once(t,e){const i=r=>{this.off(t,i),e(r)};return this.on(t,i)}off(t,e){return this._listeners[t]?(this._listeners[t]=this._listeners[t].filter(t=>t!==e),this):this}fire(t,e){if(!this._listeners[t])return this;const i={type:t,...e};return this._listeners[t].forEach(t=>t(i)),this}}class U{mx;my;bx;by;constructor(t=1,e=1,i=0,r=0){this.mx=t,this.my=e,this.bx=i,this.by=r}static fromBounds(t,e,i=!1){const r=e.width/t.width||1,n=(i?-e.height/t.height:e.height/t.height)||1,s=e.xmin-r*t.xmin,o=i?e.ymax-n*t.ymin:e.ymin-n*t.ymin;return new U(r,n,s,o)}project(t,e){return[t*this.mx+this.bx,e*this.my+this.by]}unproject(t,e){return[(t-this.bx)/this.mx,(e-this.by)/this.my]}translate(t,e){this.bx+=t,this.by+=e}scale(t,e,i){this.bx=e*(1-t)+this.bx*t,this.by=i*(1-t)+this.by*t,this.mx*=t,this.my*=t}clone(){return new U(this.mx,this.my,this.bx,this.by)}}class ${xmin;ymin;xmax;ymax;constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.xmin=t,this.ymin=e,this.xmax=i,this.ymax=r}static fromArray(t){return new $(t[0],t[1],t[2],t[3])}get width(){return this.xmax-this.xmin}get height(){return this.ymax-this.ymin}get centerX(){return.5*(this.xmin+this.xmax)}get centerY(){return.5*(this.ymin+this.ymax)}hasBounds(){return this.xmin<=this.xmax&&this.ymin<=this.ymax}clone(){return new $(this.xmin,this.ymin,this.xmax,this.ymax)}mergePoint(t,e){t<this.xmin&&(this.xmin=t),t>this.xmax&&(this.xmax=t),e<this.ymin&&(this.ymin=e),e>this.ymax&&(this.ymax=e)}merge(t){t.hasBounds()&&(t.xmin<this.xmin&&(this.xmin=t.xmin),t.xmax>this.xmax&&(this.xmax=t.xmax),t.ymin<this.ymin&&(this.ymin=t.ymin),t.ymax>this.ymax&&(this.ymax=t.ymax))}fillOut(t,e=.5,i=.5){const r=this.width,n=this.height;let s;return r/n<t?(s=n*t-r,this.xmin-=(1-e)*s,this.xmax+=e*s):(s=r/t-n,this.ymin-=(1-i)*s,this.ymax+=i*s),this}scale(t){const e=this.centerX,i=this.centerY,r=this.width*t,n=this.height*t;this.xmin=e-r/2,this.xmax=e+r/2,this.ymin=i-n/2,this.ymax=i+n/2}}class Z extends G{_running=!1;_busy=!1;_tickTime=0;_startTime=0;_duration=1/0;constructor(){super()}start(t){const e=Date.now();this._duration=t||1/0,this._startTime=e,this._running=!0,this._busy||this._startTick(e)}stop(){this._running=!1}_startTick(t){this._busy=!0,this._tickTime=t,("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,25))(()=>this._onTick())}_onTick(){const t=Date.now(),e=t-this._startTime,i=Math.min((e+10)/this._duration,1),r=i>=1;this._running?(r&&(this._running=!1),this.fire("tick",{elapsed:e,pct:i,done:r,time:t,tickTime:t-this._tickTime}),this._busy=!1,this._running&&this._startTick(t)):this._busy=!1}}class W extends G{_timer=new Z;_startValue=0;_endValue=0;_ease;constructor(t){super(),this._ease=t||null,this._timer.on("tick",t=>this._onTick(t))}start(t,e,i){this._startValue=t,this._endValue=e,this._timer.start(i||500)}stop(){this._timer.stop()}_onTick(t){const e=this._ease?this._ease(t.pct):t.pct,i=this._endValue*e+this._startValue*(1-e);this.fire("change",{value:i})}static sineInOut(t){return.5-Math.cos(t*Math.PI)/2}static quadraticOut(t){return 1-Math.pow(1-t,2)}}const H=18485274.7;class X{_transform=new U;_extent=new $;_width=0;_height=0;_initialMX=0;_initialExtent=null;_zoomTween=new W(W.sineInOut);_zoomFocus=[0,0];_animatingTransform=null;onViewChange=null;_crs="EPSG:4326";setCRS(t){this._crs=t}get transform(){return this._transform}get extent(){return this._extent}get width(){return this._width}get height(){return this._height}get initialMX(){return this._initialMX}updateSize(t,e){this._width=t,this._height=e}setExtent(t){this._extent=t.clone(),this._initialExtent||(this._initialExtent=t.clone()),this._updateTransform()}reset(){this._initialExtent&&this.setExtent(this._initialExtent)}clearInitialState(){this._initialExtent=null,this._initialMX=0}_updateTransform(){if(!this._extent.hasBounds())return;const t=this._width/this._height,e=this._extent.clone().fillOut(t),i=new $(0,0,this._width,this._height);this._transform=U.fromBounds(e,i,!0),0===this._initialMX&&(this._initialMX=Math.abs(this._transform.mx),this._initialExtent=e)}pan(t,e){this._transform.translate(t,e),this._applyConstraints()}cancelZoomAnimation(){this._zoomTween.stop(),this._animatingTransform=null}applyWheelZoom(t,e,i,r){const n=1+.12*e,s=t>0?n:1/n;this._transform.scale(s,i,r),this._applyConstraints()}zoomIn(){this._zoomTo(1.15)}zoomOut(){this._zoomTo(1/1.15)}_zoomTo(t){const e=[this._width/2,this._height/2],i=Math.abs(this._transform.mx),r=i*t;this._zoomFocus=e,this._animatingTransform=this._transform.clone(),this._zoomTween.start(i,r,200)}initZoomTween(){this._zoomTween.on("change",t=>{if(!this._animatingTransform)return;const e=t.value/this._animatingTransform.mx,i=this._animatingTransform.clone();i.scale(e,this._zoomFocus[0],this._zoomFocus[1]),this._transform=i,this.onViewChange?.(),t.done&&(this._animatingTransform=null)})}project(t,e){return this._transform.project(t,e)}unproject(t,e){return this._transform.unproject(t,e)}getLineScale(){if(0===this._initialMX)return 1;const t=Math.abs(this._transform.mx)/this._initialMX;let e=1;return t<.5?e*=Math.pow(t+.5,.35):t>30&&(e*=Math.pow(t-29,.065)),e}getArcFilter(t){const e=.1*(1/Math.abs(this._transform.mx)),i=this._initialMX>0?Math.abs(this._transform.mx)/this._initialMX:1,r=i<1?e*i:e,n=this._getViewBounds();return e=>!t.arcIsSmaller?.(e,r)&&!(n&&t.arcIntersectsBBox&&!t.arcIntersectsBBox(e,n))}getViewBounds(){return this._getViewBounds()}_getViewBounds(){if(!this._transform||0===this._width)return null;const t=this._transform,e=-t.bx/t.mx,i=(this._width-t.bx)/t.mx,r=-t.by/t.my,n=(this._height-t.by)/t.my;return[Math.min(e,i),Math.min(r,n),Math.max(e,i),Math.max(r,n)]}_applyConstraints(){const t=this._transform;let e=Math.abs(t.mx);const i=this._getMinMX(),r=this._getMaxMX();(this._crs.toLowerCase().includes("3857")||this._crs.toLowerCase().includes("webmercator"))&&e<i&&(e=i),e>r&&(e=r);const n=t.my>0?e:-e,s=this._getStrictBounds(),o=(this._width/2-t.bx)/t.mx;let a=(this._height/2-t.by)/t.my;if(s){const t=this._height/(2*e),i=s.ymax-t,r=s.ymin+t;r>i?a=(s.ymin+s.ymax)/2:a>i?a=i:a<r&&(a=r)}const l=this._width/2-o*e,c=this._height/2-a*n;this._transform=new U(e,n,l,c)}_getMaxMX(){if(!this._initialExtent)return 1/0;const t=this._initialExtent,e=(...t)=>Math.max(...t.map(Math.abs)),i=e(t.xmin,t.xmax,t.centerX),r=e(t.ymin,t.ymax,t.centerY),n=t.width/this._width/(1e-16*i),s=t.height/this._height/(1e-16*r);return Math.max(n,s)}_getStrictBounds(){const t=this._crs.toLowerCase();return"epsg:3857"===t||"webmercator"===t?new $(-1/0,-18485274.7,1/0,H):null}_getMinMX(){const t=this._crs.toLowerCase();let e;if("epsg:3857"===t||"webmercator"===t)e=36970549.4;else{if("epsg:4326"!==t&&"wgs84"!==t)return.01*this._initialMX;e=180}return this._height/e}}class Y{snapVertices(e,i,r){t.internal.snapVerticesToPoint(e,i,r)}insertVertex(e,i,r){t.internal.insertVertex(e,i,r)}deleteVertex(e,i){t.internal.deleteVertex(e,i)}appendEmptyArc(e){t.internal.appendEmptyArc(e)}appendVertex(e,i){t.internal.appendVertex(e,i)}deleteLastArc(e){t.internal.deleteLastArc(e)}findNearestVertices(e,i,r){return t.internal.findNearestVertices(e,i,r)}findArcIdFromVertexId(e,i){return t.internal.findArcIdFromVertexId(e,i)}vertexIsArcEndpoint(e,i){return t.internal.vertexIsArcEndpoint(e,i)}forEachSegmentInShape(e,i,r){t.internal.forEachSegmentInShape(e,i,r)}findClosestPointOnSeg(e,i,r,n,s,o,a){return t.internal.findClosestPointOnSeg(e,i,r,n,s,o,a)}addIntersectionCuts(e,i){t.internal.addIntersectionCuts(e,i)}findSegmentIntersections(e,i){return t.internal.findSegmentIntersections(e,i)}getIntersectionLayer(e,i,r){return t.internal.getIntersectionLayer(e,i,r)}getAvgSegment(e){return t.internal.getAvgSegment(e)}simplifyArcsFast(e,i){return t.internal.simplifyArcsFast(e,i)}layerHasGeometry(e){return t.internal.layerHasGeometry(e)}getLayerBounds(e,i){const r=t.internal.getLayerBounds(e,i);return r?{xmin:r.xmin,ymin:r.ymin,xmax:r.xmax,ymax:r.ymax}:{xmin:NaN,ymin:NaN,xmax:NaN,ymax:NaN}}getDatasetBounds(e){const i=t.internal.getDatasetBounds(e);return{xmin:i.xmin,ymin:i.ymin,xmax:i.xmax,ymax:i.ymax}}exportDatasetsToPack(e,i){return t.internal.exportDatasetsToPack(e,i??{})}restoreSessionData(e){return t.internal.restoreSessionData(e)}pack(e){return t.internal.pack(e)}unpackSessionData(e){return t.internal.unpackSessionData(e)}exportPackedDatasets(e,i){return t.internal.exportPackedDatasets(e,i??{})}exportFileContent(e,i){return t.internal.exportFileContent(e,i)}copyDataset(e){return t.internal.copyDataset(e)}runImport(e,i){const r=t.internal.parseCommands(e);return r.length>0&&"i"===r[0].name&&(r[0].options.input=i),new Promise((e,i)=>{t.internal.runParsedCommands(r,new t.internal.Job,(t,r)=>{if(t)return void i(t);const n=r.catalog.getDefaultTargets();0!==n.length?e(n[0].dataset):i(new Error("No layers found in dataset"))})})}runOnDataset(e,i,r){return new Promise((n,s)=>{const o=new t.internal.Job;o.catalog.addDataset(i);const a=t.internal.parseCommands(e);if(r)for(const t of a)t.options&&(t.options.input=r);t.internal.runParsedCommands(a,o,(t,e)=>{if(t)return void s(t);const i=e.catalog.getDefaultTargets();0!==i.length?n(i[0].dataset):s(new Error("mapshaper command completed but produced no default target"))})})}runOnDatasetParsed(e,i,r){return new Promise((n,s)=>{const o=new t.internal.Job;if(o.catalog.addDataset(i),r)for(const t of e)t.options&&(t.options.input=r);t.internal.runParsedCommands(e,o,(t,e)=>{if(t)return void s(t);const i=e.catalog.getDefaultTargets();0!==i.length?n(i[0].dataset):s(new Error("mapshaper command completed but produced no default target"))})})}}let K=null;function J(){return K??(K=new Y)}function Q(t){K=t}const tt=6378137;class et{_crs="EPSG:4326";get crs(){return this._crs}setCRS(t){this._crs=t}getCenter(t,e){const i=this._crs.toLowerCase();return"epsg:3857"===i||"webmercator"===i?this._webMercatorToLatLng(t,e):[t,e]}getZoom(t){const e=this._crs.toLowerCase();return"epsg:3857"===e||"webmercator"===e?Math.log2(40075016.6855*t/512):0}async reproject(t,e){for(const i of e.values())i.reproject&&await i.reproject(t);this._crs=t;const i=J(),r=new $;for(const t of e.values()){const e=t.getDataset();if(e?.layers)for(const t of e.layers)if(i.layerHasGeometry(t)){const n=i.getLayerBounds(t,e.arcs);n&&r.merge(new $(n.xmin,n.ymin,n.xmax,n.ymax))}}return r.hasBounds()&&r.scale(1.07),r}_webMercatorToLatLng(t,e){const i=180/Math.PI;return[t/tt*i,i*(.5*Math.PI-2*Math.atan(Math.exp(-e/tt)))]}}function it(t,e){return t?.name?String(t.name):t?.id?String(t.id):`layer-${e}`}function rt(t){return t&&Array.isArray(t)?"number"==typeof t[0]?[t]:Array.isArray(t[0])?t:[]:[]}class nt{_canvas;_ctx;_transform=new U;_pixelRatio=window.devicePixelRatio||1;constructor(t){this._canvas=t;const e=t.getContext("2d");if(!e)throw new Error("Failed to get 2D context");this._ctx=e}setTransform(t){this._transform=t}setPixelRatio(t){this._pixelRatio=t}drawPaths(t,e,i){if(0===e.width)return;const r=this._ctx;r.strokeStyle=e.color||"#333",r.lineWidth=(e.width??1)*this._pixelRatio,r.lineCap="round",r.lineJoin="round";let n=0;r.beginPath(),t.forEach(t=>{t&&t.forEach(t=>{t.forEach(t=>{n>0&&n%25==0&&(r.stroke(),r.beginPath());const e=i.getArcIter(t);this.drawPathSnapping(e,r),n++})})}),r.stroke()}drawArcs(t,e,i){if(0===e.width)return;const r=this._ctx,n=t.size();r.strokeStyle=e.color||"#333",r.lineWidth=(e.width??1)*this._pixelRatio,r.lineCap="round",r.lineJoin="round";let s=0;r.beginPath();for(let e=0;e<n;e++){if(i&&!i(e))continue;s>0&&s%25==0&&(r.stroke(),r.beginPath());const n=t.getArcIter(e);this.drawPathSnapping(n,r),s++}r.stroke()}drawPathSnapping(t,e){const i=this._transform.mx*this._pixelRatio,r=this._transform.my*this._pixelRatio,n=this._transform.bx*this._pixelRatio,s=this._transform.by*this._pixelRatio;let o,a,l,c,h=0;if(t.hasNext()){for(o=2*(t.x*i+n)|0,a=2*(t.y*r+s)|0,e.moveTo(o/2,a/2);t.hasNext();)l=o,c=a,o=2*(t.x*i+n)|0,a=2*(t.y*r+s)|0,o===l&&a===c||(e.lineTo(o/2,a/2),h++);0===h&&e.lineTo(o/2+.1,a/2)}}drawPoints(t,e){const i=this._ctx,r=this._pixelRatio,n=this._transform.mx*r,s=this._transform.my*r,o=this._transform.bx*r,a=this._transform.by*r,l=(Number(e?.radius)||4)*r,c=e?.color||"#333",h=!1!==e?.fill;i.beginPath(),i.fillStyle=c,i.strokeStyle=c,t.forEach(t=>{if(!t)return;rt(t).forEach(t=>{const e=t[0]*n+o,r=t[1]*s+a;i.moveTo(e+l,r),i.arc(e,r,l,0,2*Math.PI)})}),h?i.fill():i.stroke()}drawVertexDots(t,e,i={}){const r=this._ctx,n=this._pixelRatio,s=this._transform.mx*n,o=this._transform.my*n,a=this._transform.bx*n,l=this._transform.by*n,c=i.dotColor||"#333",h=(i.dotRadius||3)*n,u=i.hoverColor||"#cc6acc",p=(i.hoverRadius||6)*n,d=i.hoverVertex;let f=null;d&&(f=[d[0]*s+a,d[1]*o+l]),r.fillStyle=c,r.beginPath(),t.forEach(t=>{t&&t.forEach(t=>{t.forEach(t=>{const i=t>=0?t:~t,n=e.getArcIter(i);for(;n.hasNext();){const t=n.x*s+a,e=n.y*o+l;f&&Math.abs(t-f[0])<1&&Math.abs(e-f[1])<1||(r.moveTo(t+h,e),r.arc(t,e,h,0,2*Math.PI))}})})}),r.fill(),f&&(r.fillStyle=u,r.beginPath(),"interpolated"===i.hoverType?r.rect(f[0]-p,f[1]-p,2*p,2*p):r.arc(f[0],f[1],p,0,2*Math.PI),r.fill())}drawPolygonFill(t,e,i,r,n){if(!e.getShapeIter)return;const s=this._ctx,o=this._pixelRatio,a=this._transform.mx*o,l=this._transform.my*o,c=this._transform.bx*o,h=this._transform.by*o;s.fillStyle=i;const u="number"==typeof n&&1!==n,p=s.globalAlpha;u&&(s.globalAlpha=p*Math.max(0,Math.min(1,n)));let d=0;s.beginPath();for(let i=0;i<t.length;i++){const n=t[i];if(!n)continue;let o=!0;if(r){o=!1;for(const t of n){for(const e of t){if(r(e>=0?e:~e)){o=!0;break}}if(o)break}}if(o){d>0&&d>=100&&(s.fill("evenodd"),s.beginPath(),d=0);for(const t of n){const i=e.getShapeIter(t);if(!i.hasNext())continue;let r,n,o=2*(i.x*a+c)|0,u=2*(i.y*l+h)|0;for(s.moveTo(o/2,u/2);i.hasNext();)r=o,n=u,o=2*(i.x*a+c)|0,u=2*(i.y*l+h)|0,o===r&&u===n||s.lineTo(o/2,u/2);s.closePath()}d++}}d>0&&s.fill("evenodd"),u&&(s.globalAlpha=p)}drawDrawingOverlay(t){const e=this._ctx,i=this._pixelRatio,r=this._transform.mx*i,n=this._transform.my*i,s=this._transform.bx*i,o=this._transform.by*i,a=t.drawColor||"#0078ff",l=t.vertices,c=t.cursorCoord,h=t=>[t[0]*r+s,t[1]*n+o];if(l.length>0){e.strokeStyle=a,e.lineWidth=2*i,e.lineJoin="round",e.lineCap="round",e.setLineDash([]),e.beginPath();const t=h(l[0]);e.moveTo(t[0],t[1]);for(let t=1;t<l.length;t++){const i=h(l[t]);e.lineTo(i[0],i[1])}e.stroke()}if(l.length>0&&c){const r=h(l[l.length-1]),n=h(c);if(e.strokeStyle=a,e.lineWidth=1.5*i,e.setLineDash([6*i,4*i]),e.beginPath(),e.moveTo(r[0],r[1]),e.lineTo(n[0],n[1]),"polygon"===t.geometryType&&l.length>=2){const t=h(l[0]);e.moveTo(n[0],n[1]),e.lineTo(t[0],t[1])}e.stroke(),e.setLineDash([])}if(l.length>0){const t=4*i;e.fillStyle=a,e.beginPath();for(const i of l){const r=h(i);e.moveTo(r[0]+t,r[1]),e.arc(r[0],r[1],t,0,2*Math.PI)}e.fill()}if(t.snapCoord){const r=h(t.snapCoord),n=7*i;e.strokeStyle="#ff4444",e.lineWidth=2*i,e.beginPath(),"edge"===t.snapKind?e.rect(r[0]-n,r[1]-n,2*n,2*n):e.arc(r[0],r[1],n,0,2*Math.PI),e.stroke()}}clear(){this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){const i=this._pixelRatio;this._canvas.width=t*i,this._canvas.height=e*i,this._canvas.style.width=t+"px",this._canvas.style.height=e+"px"}}class st{_painter;constructor(t){this._painter=t}render(t,e,i){"vertex"===t&&e?this._renderVertexOverlay(e):"draw"===t&&i&&this._painter.drawDrawingOverlay(i)}_renderVertexOverlay(t){const e=t.arcs;"polygon"===t.geometryType&&t.polygonFill&&this._painter.drawPolygonFill(t.shapes,e,t.polygonFill),this._painter.drawVertexDots(t.shapes,e,{dotColor:"#333",dotRadius:3,hoverVertex:t.hoverVertex,hoverType:t.hoverType??"vertex",hoverColor:"#cc6acc",hoverRadius:6})}}class ot{opts;label;invalidatesPriorCommands=!0;constructor(t){this.opts=t,this.label=t.label}do(){this.opts.source.setDataset(this.opts.after)}undo(){this.opts.source.setDataset(this.opts.before)}}const at=Object.freeze({ok:!0,value:void 0});function lt(t){return{ok:!0,value:t}}const ct=Object.freeze({notFound:(t,e)=>({ok:!1,error:{kind:"not-found",what:t,id:e}}),validation:(t,e)=>({ok:!1,error:{kind:"validation",field:t,reason:e}}),expressionDisabled:t=>({ok:!1,error:{kind:"expression-disabled",operation:t}}),mapshaper:(t,e)=>({ok:!1,error:{kind:"mapshaper",cause:t,...e??{}}}),hostRemoved:()=>({ok:!1,error:{kind:"host-removed"}})}),ht=new Set(["rename-fields","rename-layers","sort","sort-features","filter-fields","drop","target","uniq","unique-features"]),ut=new Set(["buffer","clean","dissolve","mosaic","union","snap","check-geometry","simplify"]);function pt(t){const e=[],i=/(?:^|\s)-([a-z][a-z-]*)/gi;let r;for(;null!==(r=i.exec(t));)e.push(r[1].toLowerCase());return e}function dt(t,e,i,r){if(!1===i)return!1;if(!0===i)return!0;if(0===t.length)return e>=r;if(t.every(t=>ht.has(t)))return!1;return e>=(t.some(t=>ut.has(t))?Math.floor(.5*r):r)}const ft={clip:"shape-count",erase:"shape-count",dissolve:"shape-count",explode:"shape-count",filter:"shape-count","filter-geom":"shape-count","filter-islands":"shape-count","filter-slivers":"shape-count","merge-layers":"shape-count",mosaic:"shape-count",union:"shape-count",divide:"shape-count",points:"shape-count",lines:"shape-count",polygons:"shape-count",innerlines:"shape-count",split:"shape-count","split-layer":"shape-count",uniq:"shape-count",buffer:"shape-count",drop:"shape-count","intersection-points":"shape-count",clean:"topology-only",snap:"topology-only",simplify:"topology-only","rebuild-topology":"topology-only",each:"attribute-only",join:"attribute-only","rename-fields":"attribute-only","rename-layers":"attribute-only","filter-fields":"attribute-only","data-fill":"attribute-only",sort:"attribute-only",proj:"crs-only",project:"crs-only",affine:"crs-only"};function mt(t){let e="attribute-only",i=!1;for(const r of t){if("target"===r)continue;const t=ft[r];if(void 0===t)return"unknown";i=!0,e=gt(e,t)}return i?e:"unknown"}const _t={"attribute-only":0,"crs-only":1,"topology-only":2,"shape-count":3,unknown:3};function gt(t,e){return _t[t]>=_t[e]?t:e}async function yt(t,e,i,r,n){if(t._removed)return ct.hostRemoved();const s=t._sources.get(e);if(!s)return ct.notFound("source",e);const o=s.getDataset();if(!o)return ct.notFound("source",e);const a=J().copyDataset(o);let l,c=!1;if(t._workerPool){const e=o.arcs?.getPointCount?.()??0,r=function(t,e,i,r){return!1!==i&&(!0===i||dt(pt(t),e,i,r))}(i,e,t._workerMode,t._workerThreshold),n=t._workerRouting;c=n?n({cmd:i,heads:pt(i),vertexCount:e,mode:t._workerMode,threshold:t._workerThreshold,defaultDecision:r}):r}try{l=c?await async function(t,e,i,r,n){if(!t._workerPool)throw new Error("_runViaWorker: worker pool not available");const s=t._workerPool.reserveId(),o=e.arcs?.getPointCount?.()??0,a="undefined"!=typeof performance?performance.now():Date.now();t.fire("workerjobstart",{id:s,cmd:i,label:r,datasetVertexCount:o});try{const r=await J().exportDatasetsToPack([e],{compact:!1}),o=bt(r),l=t._workerPool.dispatchWithId(s,i,r,n,o),c=await l,h=await J().restoreSessionData(c);if(!h.datasets||0===h.datasets.length)throw new Error("worker: no dataset in response");const u=("undefined"!=typeof performance?performance.now():Date.now())-a;return t.fire("workerjobend",{id:s,ok:!0,durationMs:u}),h.datasets[0]}catch(e){const i=("undefined"!=typeof performance?performance.now():Date.now())-a;throw t.fire("workerjobend",{id:s,ok:!1,durationMs:i,errorMessage:e?.message??String(e)}),e}}(t,o,i,r,n):await J().runOnDataset(i,o,n)}catch(e){return t._removed?ct.hostRemoved():(t.fire("error",{error:e}),ct.mapshaper(e,{cmd:i,operation:r}))}return t._removed?ct.hostRemoved():xt(t,e,a,l,r,function(t){return mt(pt(t))}(i))}async function vt(t,e,i,r,n){if(t._removed)return ct.hostRemoved();const s=t._sources.get(e);if(!s)return ct.notFound("source",e);const o=s.getDataset();if(!o)return ct.notFound("source",e);const a=J().copyDataset(o),l=i.map(t=>t.name);let c,h=!1;if(t._workerPool){const e=o.arcs?.getPointCount?.()??0,i=dt(l,e,t._workerMode,t._workerThreshold),r=t._workerRouting;h=r?r({cmd:l.map(t=>`-${t}`).join(" "),heads:l,vertexCount:e,mode:t._workerMode,threshold:t._workerThreshold,defaultDecision:i}):i}try{c=h?await async function(t,e,i,r,n){if(!t._workerPool)throw new Error("_runViaWorkerParsed: worker pool not available");const s=t._workerPool.reserveId(),o=e.arcs?.getPointCount?.()??0,a="undefined"!=typeof performance?performance.now():Date.now(),l=i.map(t=>`-${t.name}`).join(" ");t.fire("workerjobstart",{id:s,cmd:l,label:r,datasetVertexCount:o});try{const r=await J().exportDatasetsToPack([e],{compact:!1}),o=bt(r),l=t._workerPool.dispatchWithId(s,i,r,n,o),c=await l,h=await J().restoreSessionData(c);if(!h.datasets||0===h.datasets.length)throw new Error("worker: no dataset in response");const u=("undefined"!=typeof performance?performance.now():Date.now())-a;return t.fire("workerjobend",{id:s,ok:!0,durationMs:u}),h.datasets[0]}catch(e){const i=("undefined"!=typeof performance?performance.now():Date.now())-a;throw t.fire("workerjobend",{id:s,ok:!1,durationMs:i,errorMessage:e?.message??String(e)}),e}}(t,o,i,r,n):await J().runOnDatasetParsed(i,o,n)}catch(e){return t._removed?ct.hostRemoved():(t.fire("error",{error:e}),ct.mapshaper(e,{operation:r}))}return t._removed?ct.hostRemoved():xt(t,e,a,c,r,mt(l))}function xt(t,e,i,r,n,s="unknown"){const o=t._sources.get(e);return o?(t._activeTransaction&&t._activeTransaction._captureFirstTouch(e,i),o.setDataset(r),t._history.push(new ot({source:o,before:i,after:r,label:n})),t._history.isCapturing()||t._fireHistoryChange(),function(t){return"shape-count"===t||"topology-only"===t||"unknown"===t}(s)&&t._fireSelectionChange(t._selection.clear()),t._scheduleRender(),at):ct.notFound("source",e)}function bt(t){const e=[],i=new Set,r=t=>{if(t&&"object"==typeof t){if(t instanceof Uint8Array){const r=t.buffer;return void(r instanceof ArrayBuffer&&!i.has(r)&&(i.add(r),e.push(r)))}if(t instanceof ArrayBuffer)i.has(t)||(i.add(t),e.push(t));else if(Array.isArray(t))for(const e of t)r(e);else for(const e of Object.keys(t))r(t[e])}};return r(t),e}function wt(t,e){for(let i=0;i<t.length;i++){const r=t[i];if(r){if(it(r,i)===e)return r;if(r.name===e)return r;if(r.id===e)return r}}return null}class St{_sources;constructor(t){this._sources=t}resolve(t,e){const i=this._sources.get(t);return i?wt(i.getLayers(),e):null}resolveInLayers(t,e){return wt(t,e)}}async function Tt(t,e,i){const r=t.host._sources.get(e.source);if(!r)return ct.notFound("source",e.source);const n=r.getDataset();if(!n)return ct.notFound("source",e.source);if(!wt(n.layers,e.target))return ct.notFound("layer",e.target);const s="string"==typeof e.mask&&e.mask.length>0;if(s===Array.isArray(e.bbox))return ct.validation(s?"mask":"bbox","must supply exactly one of `mask` or `bbox`");if(s){if(!wt(n.layers,e.mask))return ct.notFound("mask",e.mask)}else{const t=e.bbox;if(4!==t.length||!t.every(t=>Number.isFinite(t)))return ct.validation("bbox","must be [xmin, ymin, xmax, ymax] of finite numbers");if(t[0]>=t[2]||t[1]>=t[3])return ct.validation("bbox","must satisfy xmin<xmax and ymin<ymax")}const o=s?{source:e.mask}:{bbox:e.bbox};e.cleanup&&(o.cleanup=!0),e.removeSlivers&&(o.remove_slivers=!0);const a="clip"===i?"Clip":"Erase";return t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:i,options:o}],`${a} ${e.target}`)}const Ct="__emap_merge";async function Mt(t){const e=t.host._selection.getAll();if(0===e.length)return ct.validation("selection","selection is empty");const i=e[0].source,r=e[0].layer;for(const t of e)if(t.source!==i||t.layer!==r)return ct.validation("selection","selection spans multiple sources or layers");const n=t.host.layers.resolve(i,r);if(!n)return ct.notFound("layer",r);if(!function(t,e){const i=t.data?.getRecords?.();if(!i||0===i.length)return!1;const r=new Set(e);for(let t=0;t<i.length;t++){const e=i[t]??{};e[Ct]=r.has(t)?"M":`k_${t}`,i[t]=e}return!0}(n,e.map(t=>t.id).slice().sort((t,e)=>t-e)))return ct.validation("layer","layer has no data table; cannot stamp discriminator");const s=function(t,e){const i={fields:[Ct]},r=e.data?.getFields?.();if(r&&r.length>0){const t=r.filter(t=>t!==Ct&&!t.includes(","));t.length>0&&(i.copy_fields=t)}return[{name:"target",options:{target:t}},{name:"dissolve",options:i},{name:"filter-fields",options:{fields:[Ct],invert:!0}}]}(r,n),o=`Merge ${e.length} feature${e.length>1?"s":""}`,a=await t.runDatasetCommandParsed(i,s,o);return a.ok||function(t){const e=t.data?.getRecords?.();if(!e)return;for(const t of e)t&&Ct in t&&delete t[Ct]}(n),a}const Et=new Set(["left","right","outer","inner"]),At=new Set(["flat","round"]),It=/^-?\d+(\.\d+)?$/;function Pt(t){return"number"==typeof t&&Number.isInteger(t)&&t>0}async function Dt(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);const n=wt(r.layers,e.target);if(!n)return ct.notFound("layer",e.target);if("number"==typeof e.radius){if(!Number.isFinite(e.radius)||e.radius<=0)return ct.validation("radius","must be a positive finite number")}else{if("string"!=typeof e.radius||0===e.radius.trim().length)return ct.validation("radius","must be a positive number or non-empty expression");if(It.test(e.radius)&&Number(e.radius)<=0)return ct.validation("radius","numeric string must be a positive number")}if("string"==typeof e.radius&&!t.host._allowExpressionEvaluation([e.radius],"bufferLayer"))return ct.expressionDisabled("bufferLayer");if(void 0!==e.vertices&&!Pt(e.vertices))return ct.validation("vertices","must be a positive integer");if(void 0!==e.arcQuality&&!Pt(e.arcQuality))return ct.validation("arcQuality","must be a positive integer");if(void 0!==e.sliceLength&&!Pt(e.sliceLength))return ct.validation("sliceLength","must be a positive integer");if(void 0!==e.backtrack&&!Pt(e.backtrack))return ct.validation("backtrack","must be a positive integer");if(void 0!==e.tolerance&&!("number"==typeof(s=e.tolerance)&&Number.isFinite(s)&&s>0))return ct.validation("tolerance","must be a positive finite number");var s;if(void 0!==e.type&&!Et.has(e.type))return ct.validation("type","must be one of: left, right, outer, inner");if(void 0!==e.capStyle&&!At.has(e.capStyle))return ct.validation("capStyle","must be one of: flat, round");void 0!==e.type&&"polygon"===n.geometry_type&&console.warn(`bufferLayer: type="${e.type}" is intended for polyline layers; applying to polygon layer "${e.target}" may produce unexpected output.`);const o={radius:String(e.radius)};void 0!==e.capStyle&&(o.cap_style=e.capStyle),void 0!==e.vertices&&(o.vertices=e.vertices),void 0!==e.arcQuality&&(o.arc_quality=e.arcQuality),void 0!==e.tolerance&&(o.tolerance=e.tolerance),void 0!==e.type&&(o.type=e.type),!0===e.planar&&(o.planar=!0),!0===e.v2&&(o.v2=!0),void 0!==e.sliceLength&&(o.slice_length=e.sliceLength),void 0!==e.backtrack&&(o.backtrack=e.backtrack);const a=[{name:"target",options:{target:e.target}},{name:"buffer",options:o}];return t.runDatasetCommandParsed(e.source,a,`Buffer ${e.target}`)}class kt{_emap;constructor(t){this._emap=t}get _ctx(){return{host:this._emap,runDatasetCommand:(t,e,i,r)=>yt(this._emap,t,e,i,r),runDatasetCommandParsed:(t,e,i,r)=>vt(this._emap,t,e,i,r),applyDatasetReplace:(t,e,i,r)=>xt(this._emap,t,e,i,r)}}clipLayer(t){return async function(t,e){return Tt(t,e,"clip")}(this._ctx,t)}eraseLayer(t){return async function(t,e){return Tt(t,e,"erase")}(this._ctx,t)}dissolveLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=Array.isArray(e.fields)&&e.fields.length>0;if(void 0!==e.field&&n)return ct.validation("field","`field` and `fields` are mutually exclusive");if(void 0!==e.field&&("string"!=typeof e.field||e.field.includes(",")))return ct.validation("field","field name must be a string without `,`");if(!t.host._allowExpressionEvaluation([e.calc,e.where],"dissolveLayer"))return ct.expressionDisabled("dissolveLayer");const s={};if(e.field)s.fields=[e.field];else if(n){const t=e.fields.filter(t=>"string"==typeof t&&!t.includes(","));t.length>0&&(s.fields=t)}const o=t=>Array.isArray(t)?t.filter(t=>"string"==typeof t&&!t.includes(",")):[],a=o(e.sumFields);a.length>0&&(s.sum_fields=a);const l=o(e.copyFields);return l.length>0&&(s.copy_fields=l),e.calc&&e.calc.trim()&&(s.calc=e.calc),e.where&&e.where.trim()&&(s.where=e.where),e.multipart&&(s.multipart=!0),e.name&&e.name.trim()&&(s.name=e.name),e.noReplace&&(s.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"dissolve",options:s}],`Dissolve ${e.target}`)}(this._ctx,t)}bufferLayer(t){return Dt(this._ctx,t)}applyExpression(t){return async function(t,e){if(!e.expression||!e.expression.trim())return ct.validation("expression","must be a non-empty expression");const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.expression,e.where],"applyExpression"))return ct.expressionDisabled("applyExpression");const n={expression:e.expression};return e.where&&e.where.trim()&&(n.where=e.where),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"each",options:n}],`Update ${e.target}`)}(this._ctx,t)}filterFeatures(t){return async function(t,e){const i=!(!e.expression||!e.expression.trim());if(!i&&!e.removeEmpty)return ct.validation("expression","must supply `expression` or `removeEmpty: true`");const r=t.host._sources.get(e.source);if(!r)return ct.notFound("source",e.source);const n=r.getDataset();if(!n)return ct.notFound("source",e.source);if(!wt(n.layers,e.target))return ct.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.expression],"filterFeatures"))return ct.expressionDisabled("filterFeatures");const s={};return i&&(s.expression=e.expression),e.invert&&(s.invert=!0),e.removeEmpty&&(s.remove_empty=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter",options:s}],`Filter ${e.target}`)}(this._ctx,t)}filterIslands(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n="number"==typeof e.minArea&&Number.isFinite(e.minArea),s="number"==typeof e.minVertices&&Number.isInteger(e.minVertices)&&e.minVertices>0;if(!n&&!s)return ct.validation("minArea","must supply at least one of `minArea` or `minVertices`");if(n&&e.minArea<0)return ct.validation("minArea","must be non-negative");const o={};return n&&(o.min_area=String(e.minArea)),s&&(o.min_vertices=e.minVertices),e.removeEmpty&&(o.remove_empty=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-islands",options:o}],`Filter islands ${e.target}`)}(this._ctx,t)}filterSlivers(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if("number"!=typeof e.minArea||!Number.isFinite(e.minArea)||e.minArea<=0)return ct.validation("minArea","must be a positive finite number");const n={min_area:String(e.minArea)};return e.weighted&&(n.weighted=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-slivers",options:n}],`Filter slivers ${e.target}`)}(this._ctx,t)}filterGeom(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=e.bbox;return Array.isArray(n)&&4===n.length&&n.every(t=>Number.isFinite(t))?n[0]>=n[2]||n[1]>=n[3]?ct.validation("bbox","must satisfy xmin<xmax and ymin<ymax"):t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-geom",options:{bbox:[n[0],n[1],n[2],n[3]]}}],`Filter geom ${e.target}`):ct.validation("bbox","must be [xmin, ymin, xmax, ymax] of finite numbers")}(this._ctx,t)}explodeLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();return r?wt(r.layers,e.target)?t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"explode",options:{}}],`Explode ${e.target}`):ct.notFound("layer",e.target):ct.notFound("source",e.source)}(this._ctx,t)}innerlinesLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.where],"innerlinesLayer"))return ct.expressionDisabled("innerlinesLayer");const n={};return e.where&&e.where.trim()&&(n.where=e.where),e.name&&e.name.trim()&&(n.name=e.name),e.noReplace&&(n.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"innerlines",options:n}],`Innerlines ${e.target}`)}(this._ctx,t)}snapLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n={};return"number"==typeof e.interval&&(n.interval=String(e.interval)),e.endpoints&&(n.endpoints=!0),"number"==typeof e.precision&&(n.precision=e.precision),e.fixGeometry&&(n.fix_geometry=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"snap",options:n}],`Snap ${e.target}`)}(this._ctx,t)}cleanLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=t=>void 0===t||"number"==typeof t&&Number.isFinite(t)&&t>=0;if(!n(e.gapFillArea))return ct.validation("gapFillArea","must be a finite non-negative number");if(!n(e.sliverControl))return ct.validation("sliverControl","must be a finite non-negative number");if(!n(e.snapInterval))return ct.validation("snapInterval","must be a finite non-negative number");if(void 0!==e.overlapRule){const t=["min-id","max-id","min-area","max-area"];if(!t.includes(e.overlapRule))return ct.validation("overlapRule",`must be one of ${t.join(", ")}`)}const s={};return void 0!==e.gapFillArea&&(s.gap_fill_area=String(e.gapFillArea)),void 0!==e.sliverControl&&(s.sliver_control=e.sliverControl),void 0!==e.snapInterval&&(s.snap_interval=String(e.snapInterval)),e.noSnap&&(s.no_snap=!0),e.allowOverlaps&&(s.allow_overlaps=!0),void 0!==e.overlapRule&&(s.overlap_rule=e.overlapRule),e.allowEmpty&&(s.allow_empty=!0),e.rewind&&(s.rewind=!0),e.onlyArcs&&(s.only_arcs=!0),e.noArcDissolve&&(s.no_arc_dissolve=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"clean",options:s}],`Clean ${e.target}`)}(this._ctx,t)}mosaicLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.calc],"mosaicLayer"))return ct.expressionDisabled("mosaicLayer");const n={};return"number"==typeof e.snapInterval&&(n.snap_interval=String(e.snapInterval)),e.noSnap&&(n.no_snap=!0),e.noReplace&&(n.no_replace=!0),e.name&&e.name.trim()&&(n.name=e.name),e.calc&&e.calc.trim()&&(n.calc=e.calc),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"mosaic",options:n}],`Mosaic ${e.target}`)}(this._ctx,t)}unionLayers(t){return async function(t,e){if(!e.targets||e.targets.length<2)return ct.validation("targets","must supply at least 2 target layers");const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);for(const t of e.targets){if("string"!=typeof t||t.includes(","))return ct.validation("targets",`target name must not contain ',': ${String(t)}`);if(!wt(r.layers,t))return ct.notFound("layer",t)}const n=e.targets.join(","),s={};if(e.fields&&e.fields.length>0){const t=e.fields.filter(t=>!t.includes(","));t.length>0&&(s.fields=t)}return e.name&&e.name.trim()&&(s.name=e.name),e.noReplace&&(s.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:n}},{name:"union",options:s}],`Union ${n}`)}(this._ctx,t)}divideLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);const n=wt(r.layers,e.target);if(!n)return ct.notFound("layer",e.target);if("polyline"!==n.geometry_type)return ct.validation("target",`expected polyline layer, got ${n.geometry_type??"unknown"}`);const s=wt(r.layers,e.divider);if(!s)return ct.notFound("divider",e.divider);if("polygon"!==s.geometry_type)return ct.validation("divider",`expected polygon layer, got ${s.geometry_type??"unknown"}`);const o={source:e.divider};if(e.fields&&e.fields.length>0){const t=e.fields.filter(t=>!t.includes(","));t.length>0&&(o.fields=t)}return e.force&&(o.force=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"divide",options:o}],`Divide ${e.target}`)}(this._ctx,t)}pointsLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);const n=wt(r.layers,e.target);if(!n)return ct.notFound("layer",e.target);const s=n.geometry_type;switch(e.type){case"centroid":case"inner":if("polygon"!==s)return ct.validation("type",`${e.type} requires polygon target, got ${s??"unknown"}`);break;case"midpoints":case"interpolated":if("polyline"!==s)return ct.validation("type",`${e.type} requires polyline target, got ${s??"unknown"}`);break;case"vertices":case"endpoints":if("polygon"!==s&&"polyline"!==s)return ct.validation("type",`${e.type} requires polygon/polyline target, got ${s??"unknown"}`);break;default:return ct.validation("type",`unknown type: ${String(e.type)}`)}if("interpolated"===e.type&&!("number"==typeof e.interval&&e.interval>0))return ct.validation("interval","interpolated points require a positive interval");const o={[e.type]:!0};return"interpolated"===e.type&&(o.interval=String(e.interval)),e.name&&e.name.trim()&&(o.name=e.name),e.noReplace&&(o.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"points",options:o}],`Points ${e.target}`)}(this._ctx,t)}linesLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);const n=wt(r.layers,e.target);if(!n)return ct.notFound("layer",e.target);if("polygon"!==n.geometry_type)return ct.validation("target",`expected polygon layer, got ${n.geometry_type??"unknown"}`);const s={},o=e.fields?.filter(t=>"string"==typeof t&&!t.includes(","));return o&&o.length>0&&(s.fields=o),e.name&&e.name.trim()&&(s.name=e.name),e.noReplace&&(s.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"lines",options:s}],`Lines ${e.target}`)}(this._ctx,t)}polygonsLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);const n=wt(r.layers,e.target);if(!n)return ct.notFound("layer",e.target);if("polyline"!==n.geometry_type)return ct.validation("target",`expected polyline layer, got ${n.geometry_type??"unknown"}`);const s={};return"number"==typeof e.gapTolerance&&e.gapTolerance>0&&(s.gap_tolerance=String(e.gapTolerance)),e.fromRings&&(s.from_rings=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"polygons",options:s}],`Polygons ${e.target}`)}(this._ctx,t)}simplifyLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(void 0!==e.target&&!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(1!==[void 0!==e.percentage,void 0!==e.interval,void 0!==e.resolution].filter(Boolean).length)return ct.validation("threshold","must supply exactly one of percentage, interval, resolution");const n={};if(void 0!==e.percentage){const t=e.percentage;if(!Number.isFinite(t)||t<0||t>100)return ct.validation("percentage","must be a finite number in [0, 100]");n.percentage=`${t}%`}else if(void 0!==e.interval){const t=e.interval;if(!Number.isFinite(t)||t<=0)return ct.validation("interval","must be a positive finite number");n.interval=String(t)}else{const t=e.resolution;if(!/^\d+x\d+$/.test(t))return ct.validation("resolution","must match `WIDTHxHEIGHT` (digits)");n.resolution=t}if(void 0!==e.weighting&&void 0!==e.method&&"weighted"!==e.method)return ct.validation("weighting",`weighting only applies to method='weighted', not ${e.method}`);e.method&&(n.method=e.method),"number"==typeof e.weighting&&Number.isFinite(e.weighting)&&(n.weighting=e.weighting),e.planar&&(n.planar=!0),e.keepShapes&&(n.keep_shapes=!0),e.lockBox&&(n.lock_box=!0),e.noRepair&&(n.no_repair=!0);const s=[];e.target&&s.push({name:"target",options:{target:e.target}}),s.push({name:"simplify",options:n});const o=`Simplify ${e.target??e.source}`;return t.runDatasetCommandParsed(e.source,s,o)}(this._ctx,t)}projectLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(void 0!==e.target&&!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=(e.crs??"").trim();if(0===n.length)return ct.validation("crs","must be a non-empty CRS string");const s={crs:n};e.init&&e.init.trim()&&(s.init=e.init),e.densify&&(s.densify=!0);const o=[];e.target&&o.push({name:"target",options:{target:e.target}}),o.push({name:"proj",options:s});const a=`Project ${e.target??e.source}`;return t.runDatasetCommandParsed(e.source,o,a)}(this._ctx,t)}affineLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(void 0!==e.target&&!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=Array.isArray(e.shift),s="number"==typeof e.rotate&&0!==e.rotate,o=void 0!==e.scale&&("number"==typeof e.scale?1!==e.scale:Array.isArray(e.scale));if(!n&&!s&&!o)return ct.validation("shift","must supply at least one of `shift`, `rotate`, or `scale`");if(n){const t=e.shift;if(2!==t.length||!t.every(t=>Number.isFinite(t)))return ct.validation("shift","must be [dx, dy] of finite numbers")}if(s&&!Number.isFinite(e.rotate))return ct.validation("rotate","must be a finite number (degrees)");if(o&&Array.isArray(e.scale)){const t=e.scale;if(2!==t.length||!t.every(t=>Number.isFinite(t)&&0!==t))return ct.validation("scale","must be [sx, sy] of nonzero finite numbers")}else if(o&&"number"==typeof e.scale&&(!Number.isFinite(e.scale)||0===e.scale))return ct.validation("scale","must be a nonzero finite number");if(!(void 0===e.anchor||Array.isArray(e.anchor)&&2===e.anchor.length&&e.anchor.every(t=>Number.isFinite(t))))return ct.validation("anchor","must be [x, y] of finite numbers");if(!t.host._allowExpressionEvaluation([e.where],"affineLayer"))return ct.expressionDisabled("affineLayer");const a={};n&&(a.shift=[String(e.shift[0]),String(e.shift[1])]),s&&(a.rotate=e.rotate),o&&(a.scale=(e.scale,e.scale)),e.anchor&&(a.anchor=[e.anchor[0],e.anchor[1]]),e.where&&e.where.trim()&&(a.where=e.where);const l=[];e.target&&l.push({name:"target",options:{target:e.target}}),l.push({name:"affine",options:a});const c=`Affine ${e.target??e.source}`;return t.runDatasetCommandParsed(e.source,l,c)}(this._ctx,t)}renameLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=(e.name??"").trim();if(0===n.length)return ct.validation("name","must be a non-empty string");if(n.includes(","))return ct.validation("name","must not contain `,`");if(n!==e.target&&r.layers.some(t=>(t?.name??"")===n))return ct.validation("name",`another layer already named '${n}'`);return t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"rename-layers",options:{names:[n]}}],`Rename ${e.target} → ${n}`)}(this._ctx,t)}mergeLayers(t){return async function(t,e){if(!e.targets||e.targets.length<2)return ct.validation("targets","must supply at least 2 target layers");const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);for(const t of e.targets)if("string"!=typeof t||t.includes(","))return ct.validation("targets",`target name must not contain ',': ${String(t)}`);const n=e.targets.map(t=>wt(r.layers,t));for(let t=0;t<n.length;t++)if(!n[t])return ct.notFound("layer",e.targets[t]);if(!e.force){const t=n[0]?.geometry_type;if(!n.every(e=>e?.geometry_type===t))return ct.validation("targets","targets have mixed geometry types; pass `force: true` to merge anyway")}const s=e.targets.join(","),o={};return e.name&&e.name.trim()&&(o.name=e.name),e.force&&(o.force=!0),e.flatten&&(o.flatten=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:s}},{name:"merge-layers",options:o}],`Merge ${s}`)}(this._ctx,t)}splitLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=(e.expression??"").trim();if(0===n.length)return ct.validation("expression","must be a non-empty expression");if(!t.host._allowExpressionEvaluation([n],"splitLayer"))return ct.expressionDisabled("splitLayer");const s={expression:n};return e.noReplace&&(s.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"split",options:s}],`Split ${e.target}`)}(this._ctx,t)}dropLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();return r?wt(r.layers,e.target)?t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"drop",options:{}}],`Drop ${e.target}`):ct.notFound("layer",e.target):ct.notFound("source",e.source)}(this._ctx,t)}sortFeatures(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=(e.expression??"").trim();if(0===n.length)return ct.validation("expression","must be a non-empty expression");if(!t.host._allowExpressionEvaluation([n],"sortFeatures"))return ct.expressionDisabled("sortFeatures");const s={expression:n};return e.descending&&(s.descending=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"sort",options:s}],`Sort ${e.target}`)}(this._ctx,t)}uniqueFeatures(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);const n=(e.expression??"").trim();if(0===n.length)return ct.validation("expression","must be a non-empty expression");if(!t.host._allowExpressionEvaluation([n],"uniqueFeatures"))return ct.expressionDisabled("uniqueFeatures");if(void 0!==e.maxCount&&!("number"==typeof e.maxCount&&e.maxCount>0))return ct.validation("maxCount","must be a positive number");const s={expression:n};return void 0!==e.maxCount&&(s.max_count=e.maxCount),e.invert&&(s.invert=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"uniq",options:s}],`Uniq ${e.target}`)}(this._ctx,t)}filterFields(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!Array.isArray(e.fields)||0===e.fields.length)return ct.validation("fields","must be a non-empty array");for(const t of e.fields){if("string"!=typeof t||0===t.trim().length)return ct.validation("fields",`field name must be a non-empty string: ${String(t)}`);if(t.includes(","))return ct.validation("fields",`field name must not contain ',': ${t}`)}const n={fields:e.fields.slice()};return e.invert&&(n.invert=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-fields",options:n}],`Filter fields ${e.target}`)}(this._ctx,t)}renameFields(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!e.mapping||"object"!=typeof e.mapping)return ct.validation("mapping","must be an object of { oldName: newName }");const n=Object.entries(e.mapping);if(0===n.length)return ct.validation("mapping","must contain at least one rename pair");const s=[];for(const[t,e]of n){const i=(t??"").trim(),r=(e??"").trim();if(0===i.length||0===r.length)return ct.validation("mapping",`field names must be non-empty: ${t}=${e}`);if(i.includes(",")||i.includes("=")||r.includes(",")||r.includes("="))return ct.validation("mapping",`field names must not contain ',' or '=': ${t}=${e}`);s.push(`${i}=${r}`)}return t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"rename-fields",options:{fields:s}}],`Rename fields ${e.target}`)}(this._ctx,t)}joinTable(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!Array.isArray(e.keys)||2!==e.keys.length)return ct.validation("keys","must be a 2-element [targetKey, sourceKey] array");const[n,s]=e.keys.map(t=>"string"==typeof t?t.trim():"");if(0===n.length||0===s.length)return ct.validation("keys","both keys must be non-empty strings");if(n.includes(",")||s.includes(","))return ct.validation("keys","keys must not contain `,`");let o,a;const l=e.data;if(!l||"object"!=typeof l)return ct.validation("data","must be { csv } | { json } | { layer }");if("layer"in l&&"string"==typeof l.layer&&l.layer.trim().length>0)o=l.layer.trim();else if("csv"in l&&("string"==typeof l.csv||l.csv instanceof Uint8Array)){const t=".emap-join.csv";o=t,a={[t]:l.csv}}else{if(!("json"in l)||void 0===l.json)return ct.validation("data","must contain one of `csv`, `json`, or `layer`");{const t=".emap-join.json";let e;e="string"==typeof l.json||l.json instanceof Uint8Array?l.json:JSON.stringify(l.json),o=t,a={[t]:e}}}if(!t.host._allowExpressionEvaluation([e.where,e.calc],"joinTable"))return ct.expressionDisabled("joinTable");const c={source:o,keys:[n,s]};if(e.fields&&e.fields.length>0){const t=e.fields.filter(t=>"string"==typeof t&&!t.includes(","));t.length>0&&(c.fields=t)}return e.prefix&&e.prefix.length>0&&(c.prefix=e.prefix),e.where&&e.where.trim().length>0&&(c.where=e.where),e.calc&&e.calc.trim().length>0&&(c.calc=e.calc),e.unjoined&&(c.unjoined=!0),e.unmatched&&(c.unmatched=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"join",options:c}],`Join ${e.target}`,a)}(this._ctx,t)}dataFill(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!wt(r.layers,e.target))return ct.notFound("layer",e.target);if("string"!=typeof e.field||0===e.field.trim().length)return ct.validation("field","must be a non-empty string");if(e.field.includes(",")||e.field.includes("="))return ct.validation("field","must not contain `,` or `=`");if(void 0!==e.weightField){if("string"!=typeof e.weightField||0===e.weightField.trim().length)return ct.validation("weightField","must be a non-empty string when supplied");if(e.weightField.includes(",")||e.weightField.includes("="))return ct.validation("weightField","must not contain `,` or `=`")}const n={field:e.field};return e.weightField&&(n.weight_field=e.weightField),e.contiguous&&(n.contiguous=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"data-fill",options:n}],`Data fill ${e.target}.${e.field}`)}(this._ctx,t)}rebuildTopology(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(!r.arcs)return at;const n=J(),s=n.copyDataset(r),o=n.copyDataset(r);try{n.addIntersectionCuts(o,{snap_interval:e.snapInterval,no_snap:e.noSnap,rebuild_topology:e.rebuildTopology})}catch(e){return t.host.fire("error",{error:e}),ct.mapshaper(e,{operation:"rebuildTopology"})}return t.applyDatasetReplace(e.source,s,o,"Rebuild topology")}(this._ctx,t)}checkGeometry(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);if(void 0!==e.target&&!wt(r.layers,e.target))return ct.notFound("layer",e.target);if(!r.arcs)return lt({ok:!0,intersections:[],intersectionCount:0});const n={};void 0!==e.tolerance&&(n.tolerance=e.tolerance);const s=J().findSegmentIntersections(r.arcs,n).map(t=>({x:t.x,y:t.y}));return lt({ok:0===s.length,intersections:s,intersectionCount:s.length})}(this._ctx,t)}intersectionPointsLayer(t){return async function(t,e){const i=t.host._sources.get(e.source);if(!i)return ct.notFound("source",e.source);const r=i.getDataset();if(!r)return ct.notFound("source",e.source);const n=wt(r.layers,e.target);if(!n)return ct.notFound("layer",e.target);if("polygon"!==n.geometry_type&&"polyline"!==n.geometry_type)return ct.validation("target",`expected polygon/polyline target, got ${n.geometry_type??"unknown"}`);if(!r.arcs)return ct.validation("source","source has no arcs");const s=e.name&&e.name.trim()||`${e.target}-intersections`;if(r.layers.some(t=>t?.name===s))return ct.validation("name",`another layer already named '${s}'`);if(void 0!==e.tolerance&&("number"!=typeof e.tolerance||!Number.isFinite(e.tolerance)||e.tolerance<=0))return ct.validation("tolerance","must be a positive finite number");const o={};void 0!==e.tolerance&&(o.tolerance=e.tolerance);const a=J(),l=a.copyDataset(r),c=a.copyDataset(r);let h;try{const t=a.findSegmentIntersections(c.arcs,o),i=wt(c.layers,e.target);if(!i)throw new Error("intersectionPointsLayer: target lost in copyDataset");h=a.getIntersectionLayer(t,i,c.arcs),h.name=s,c.layers.push(h)}catch(e){return t.host.fire("error",{error:e}),ct.mapshaper(e,{operation:"intersectionPointsLayer"})}return t.applyDatasetReplace(e.source,l,c,`Intersection points ${e.target}`)}(this._ctx,t)}mergeSelected(){return Mt(this._ctx)}}class zt{children;label;constructor(t,e){this.children=t,this.label=e}do(){for(const t of this.children)t.do()}undo(){for(let t=this.children.length-1;t>=0;t--)this.children[t].undo()}}function Rt(t){return"polygon"===t.geometry_type||"polyline"===t.geometry_type}function Lt(t){return"point"===t.geometry_type}function Ft(t){t&&(t.editVersion=(t.editVersion??0)+1)}class Bt{opts;label;_mergeAt=Date.now();constructor(t){this.opts=t;const e=t.arcIds.length+t.pointFeatures.length;this.label=`Translate ${e} feature${1===e?"":"s"}`}do(){this._apply(this.opts.dx,this.opts.dy)}undo(){this._apply(-this.opts.dx,-this.opts.dy)}mergeable(t){if(!(t instanceof Bt))return!1;if(t.opts.source!==this.opts.source)return!1;if(Date.now()-t._mergeAt>500)return!1;const e=t.opts.arcIds,i=this.opts.arcIds;if(e.length!==i.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==i[t])return!1;const r=t.opts.pointFeatures,n=this.opts.pointFeatures;if(r.length!==n.length)return!1;for(let t=0;t<r.length;t++){if(r[t].featureId!==n[t].featureId)return!1;if(r[t].layer!==n[t].layer)return!1}return!0}merge(t){t instanceof Bt&&(this.opts.dx+=t.opts.dx,this.opts.dy+=t.opts.dy,this._mergeAt=Date.now())}_apply(t,e){const{arcs:i,arcIds:r,pointFeatures:n,source:s}=this.opts;if(i&&r.length>0){const n=i.getVertexData?.();if(n){const{xx:s,yy:o,ii:a,nn:l}=n;for(const n of r){const r=a[n],c=l[n];for(let i=r;i<r+c;i++)s[i]+=t,o[i]+=e;i.updateArcBounds?.(n)}}}for(const i of n){const r=i.layer.shapes?.[i.featureId];if(r)for(const i of rt(r))i&&i.length>=2&&(i[0]+=t,i[1]+=e)}s.markDisplayArcsDirty?.(),Ft(s.getDataset?.())}}class Ot{opts;label;constructor(t){this.opts=t;const e=t.arcIds.length+t.pointFeatures.length;this.label=t.label??`Transform ${e} feature${1===e?"":"s"}`}do(){this._apply(this.opts.matrix)}undo(){this._apply(Gt(this.opts.matrix))}_apply(t){const{arcs:e,arcIds:i,pointFeatures:r,source:n}=this.opts;if(e&&i.length>0){const r=e.getVertexData?.();if(r){const{xx:n,yy:s,ii:o,nn:a}=r;for(const r of i){const i=o[r],l=a[r];for(let e=i;e<i+l;e++){const i=n[e],r=s[e];n[e]=t.a*i+t.c*r+t.tx,s[e]=t.b*i+t.d*r+t.ty}e.updateArcBounds?.(r)}}}for(const e of r){const i=e.layer.shapes?.[e.featureId];if(i)for(const e of rt(i))if(e&&e.length>=2){const i=e[0],r=e[1];e[0]=t.a*i+t.c*r+t.tx,e[1]=t.b*i+t.d*r+t.ty}}n.markDisplayArcsDirty?.(),Ft(n.getDataset?.())}}function Nt(t,e=0,i=0){const r=Math.cos(t),n=Math.sin(t);return{a:r,b:n,c:-n,d:r,tx:e-r*e+n*i,ty:i-n*e-r*i}}function Vt(t,e,i=0,r=0){return{a:t,b:0,c:0,d:e,tx:i-t*i,ty:r-e*r}}function jt(t,e){return{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,tx:t.a*e.tx+t.c*e.ty+t.tx,ty:t.b*e.tx+t.d*e.ty+t.ty}}const qt={a:1,b:0,c:0,d:1,tx:0,ty:0};function Gt(t){const e=t.a*t.d-t.b*t.c;if(0===e)throw new Error("FeatureAffineCommand: matrix is singular (det=0)");const i=t.d/e,r=-t.b/e,n=-t.c/e,s=t.a/e;return{a:i,b:r,c:n,d:s,tx:-(i*t.tx+n*t.ty),ty:-(r*t.tx+s*t.ty)}}class Ut{opts;label;constructor(t){this.opts=t,this.label=`Split ${t.appendedArcs.length} shared arc${1===t.appendedArcs.length?"":"s"}`}do(){const t=this.opts.source.getArcs();if(t){!function(t,e){const i=t.getVertexData?.();if(!i)return;const{xx:r,yy:n,zz:s,nn:o}=i,a=!!s&&e.every(t=>t.zz);let l=0;for(const t of e)l+=t.xx.length;const c=new Float64Array(r.length+l),h=new Float64Array(n.length+l),u=a?new Float64Array(s.length+l):null;c.set(r),h.set(n),u&&s&&u.set(s);let p=r.length;for(const t of e)c.set(t.xx,p),h.set(t.yy,p),u&&t.zz&&u.set(t.zz,p),p+=t.xx.length;const d=new Int32Array(o.length+e.length);d.set(o);for(let t=0;t<e.length;t++)d[o.length+t]=e[t].xx.length;t.updateVertexData(d,c,h,u)}(t,this.opts.appendedArcs);for(const t of this.opts.remaps)t.layer.shapes[t.featureId]=Wt(t.newShape);this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}undo(){const t=this.opts.source.getArcs();if(t){!function(t,e){const i=t.getVertexData?.();if(!i)return;const{xx:r,yy:n,zz:s,nn:o}=i;if(o.length===e)return;if(e>o.length)return;let a=0;for(let t=0;t<e;t++)a+=o[t];const l=new Int32Array(e);l.set(o.subarray(0,e));const c=new Float64Array(r.subarray(0,a)),h=new Float64Array(n.subarray(0,a)),u=s?new Float64Array(s.subarray(0,a)):null;t.updateVertexData(l,c,h,u)}(t,this.opts.originalArcCount);for(const t of this.opts.remaps)t.layer.shapes[t.featureId]=Wt(t.originalShape);this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}}function $t(t,e,i){const r=t.getArcs();if(!r)return null;const n=r.size();if(0===n||0===e.length)return null;const s=new Uint32Array(n),o=new Uint32Array(n),a=new Set;for(const t of e)a.add(Zt(t.layer,t.featureId));for(const t of i){if(!t.shapes)continue;if(!Rt(t))continue;const e=t.shapes;for(let i=0;i<e.length;i++){const r=e[i];if(!r)continue;const l=a.has(Zt(t,i));for(const t of r)if(Array.isArray(t))for(const e of t){if("number"!=typeof e)continue;const t=e>=0?e:~e;t<0||t>=n||(l?s[t]++:o[t]++)}}}const l=[];for(let t=0;t<n;t++)s[t]>0&&o[t]>0&&l.push(t);if(0===l.length)return null;const c=new globalThis.Map;for(let t=0;t<l.length;t++)c.set(l[t],n+t);const h=r.getVertexData?.();if(!h)return null;const{xx:u,yy:p,zz:d,ii:f,nn:m}=h,_=l.map(t=>{const e=f[t],i=m[t];return{xx:new Float64Array(u.subarray(e,e+i)),yy:new Float64Array(p.subarray(e,e+i)),zz:d?new Float64Array(d.subarray(e,e+i)):null}}),g=[];for(const t of e){if(!Rt(t.layer))continue;const e=t.layer.shapes?.[t.featureId];if(!e)continue;let i=!1;const r=e.map(t=>t.map(t=>{const e=t>=0?t:~t,r=c.get(e);return void 0===r?t:(i=!0,t>=0?r:~r)}));i&&g.push({layer:t.layer,featureId:t.featureId,originalShape:Wt(e),newShape:r})}return 0===g.length?null:{source:t,remaps:g,appendedArcs:_,originalArcCount:n}}function Zt(t,e){return`${t.name??""}#${e}`}function Wt(t){return t.map(t=>t.slice())}class Ht{_emap;constructor(t){this._emap=t}translateSelected(t,e){if(0===t&&0===e)return ct.validation("offset","dx and dy are both 0 (no-op)");const i=this._emap._selection.getAll();if(0===i.length)return ct.validation("selection","selection is empty");const r=new globalThis.Map;for(const t of i){const e=this._emap.layers.resolve(t.source,t.layer);if(!e?.shapes)continue;const i=e.shapes[t.id];if(!i)continue;let n=r.get(t.source);if(n||(n={arcIdSet:new Set,pointFeatures:[]},r.set(t.source,n)),"point"===e.geometry_type)n.pointFeatures.push({layer:e,featureId:t.id});else{const t=i;for(const e of t)if(Array.isArray(e))for(const t of e)"number"==typeof t&&n.arcIdSet.add(t>=0?t:~t)}}if(0===r.size)return ct.validation("selection","no resolvable layers in selection");const n=[],s=[];for(const[i,o]of r){const r=this._emap._sources.get(i);if(!r)continue;if(0===o.arcIdSet.size&&0===o.pointFeatures.length)continue;const a=new Bt({source:r,arcs:r.getArcs(),dx:t,dy:e,arcIds:Array.from(o.arcIdSet),pointFeatures:o.pointFeatures});a.do(),n.push(a),s.push(i)}if(0===n.length)return ct.validation("selection","every resolved layer was empty");const o=1===n.length?n[0]:new zt(n,`Translate ${i.length} features`);return this._emap._history.push(o),this._emap._fireHistoryChange(),this._emap._clearSpatialIndexesForSources(s),this._emap._scheduleRender(),at}_buildSelectionBuckets(t){const e=this._emap._selection.getAll();if(0===e.length)return null;const i=new globalThis.Map;for(const t of e){const e=this._emap.layers.resolve(t.source,t.layer);if(!e?.shapes)continue;if(!e.shapes[t.id])continue;const r=this._emap._sources.get(t.source);if(!r)continue;let n=i.get(t.source);n||(n={sourceId:t.source,source:r,arcIds:[],pointFeatures:[],pathFeatures:[]},i.set(t.source,n)),"point"===e.geometry_type?n.pointFeatures.push({layer:e,featureId:t.id}):n.pathFeatures.push({layer:e,featureId:t.id})}if(0===i.size)return null;const r=[];if(t)for(const t of i.values()){if(0===t.pathFeatures.length)continue;const e=$t(t.source,t.pathFeatures,t.source.getLayers());if(!e)continue;const i=new Ut(e);i.do(),r.push(i),this._emap._invalidateShapeCachesForSources([t.sourceId])}for(const t of i.values()){const e=new Set;for(const i of t.pathFeatures){const r=i.layer.shapes?.[i.featureId];if(r)for(const i of r)if(Array.isArray(i))for(const r of i){if("number"!=typeof r)continue;const i=r>=0?r:~r;e.has(i)||(e.add(i),t.arcIds.push(i))}}}return{buckets:Array.from(i.values()).map(t=>({sourceId:t.sourceId,source:t.source,arcIds:t.arcIds,pointFeatures:t.pointFeatures})),splitCmds:r}}beginTranslateSession(t){const e=this._buildSelectionBuckets(!1!==t?.splitSharedArcs);if(!e)return null;const{buckets:i,splitCmds:r}=e;let n=0,s=0,o=!1;const a=(t,e)=>{for(const r of i)0===r.arcIds.length&&0===r.pointFeatures.length||new Bt({source:r.source,arcs:r.source.getArcs(),dx:t,dy:e,arcIds:r.arcIds,pointFeatures:r.pointFeatures}).do()};return{move:(t,e)=>{o||0===t&&0===e||(a(t,e),n+=t,s+=e,this._emap._scheduleRender())},commit:()=>{if(o)return!1;o=!0;if(!!(0===n&&0===s)){for(let t=r.length-1;t>=0;t--)r[t].undo();return r.length>0&&this._emap._scheduleRender(),!1}const t=i.map(t=>new Bt({source:t.source,arcs:t.source.getArcs(),dx:n,dy:s,arcIds:t.arcIds,pointFeatures:t.pointFeatures})),e=i.reduce((t,e)=>t+e.arcIds.length+e.pointFeatures.length,0),a=[...r,...t],l=1===a.length?a[0]:new zt(a,`Translate ${e} features`);return this._emap._history.push(l),this._emap._fireHistoryChange(),this._emap._invalidateShapeCachesForSources(i.map(t=>t.sourceId)),this._emap._scheduleRender(),!0},cancel:()=>{if(!o){o=!0,0===n&&0===s||a(-n,-s);for(let t=r.length-1;t>=0;t--)r[t].undo();n=0,s=0,r.length>0&&this._emap._invalidateShapeCachesForSources(i.map(t=>t.sourceId)),this._emap._scheduleRender()}},getAccumulated:()=>[n,s]}}beginAffineSession(t,e){const i=this._buildSelectionBuckets(!1!==e?.splitSharedArcs);if(!i)return null;const{buckets:r,splitCmds:n}=i;let s,o;if(t)[s,o]=t;else{const t=new globalThis.Map;for(const e of r)t.set(e.sourceId,{arcIdSet:new Set(e.arcIds),pointFeatures:e.pointFeatures});const e=this._computeSelectionCentroid(t);if(!e){for(let t=n.length-1;t>=0;t--)n[t].undo();return null}[s,o]=e}if(!Number.isFinite(s)||!Number.isFinite(o)){for(let t=n.length-1;t>=0;t--)n[t].undo();return null}const a=[s,o];let l={...qt},c=!1;const h=t=>1===t.a&&0===t.b&&0===t.c&&1===t.d&&0===t.tx&&0===t.ty,u=t=>{for(const e of r)0===e.arcIds.length&&0===e.pointFeatures.length||new Ot({source:e.source,arcs:e.source.getArcs(),matrix:t,arcIds:e.arcIds,pointFeatures:e.pointFeatures}).do()};return{origin:a,applyDelta:t=>{c||h(t)||(u(t),l=jt(t,l),this._emap._scheduleRender())},commit:t=>{if(c)return!1;if(c=!0,h(l)){for(let t=n.length-1;t>=0;t--)n[t].undo();return n.length>0&&this._emap._scheduleRender(),!1}const e=r.reduce((t,e)=>t+e.arcIds.length+e.pointFeatures.length,0),i=r.map(e=>new Ot({source:e.source,arcs:e.source.getArcs(),matrix:l,arcIds:e.arcIds,pointFeatures:e.pointFeatures,label:t})),s=[...n,...i],o=1===s.length?s[0]:new zt(s,t??`Transform ${e} feature${1===e?"":"s"}`);return this._emap._history.push(o),this._emap._fireHistoryChange(),this._emap._invalidateShapeCachesForSources(r.map(t=>t.sourceId)),this._emap._scheduleRender(),!0},cancel:()=>{if(!c){c=!0,h(l)||u(Gt(l));for(let t=n.length-1;t>=0;t--)n[t].undo();l={...qt},n.length>0&&this._emap._invalidateShapeCachesForSources(r.map(t=>t.sourceId)),this._emap._scheduleRender()}},getCumulative:()=>({...l})}}rotateSelected(t,e){if(0===t)return ct.validation("angleDegrees","angle is 0 (no-op)");const i=t*Math.PI/180;return this._applyAffineToSelection((t,e)=>Nt(i,t,e),e,t=>`Rotate ${t} feature${1===t?"":"s"}`)}scaleSelected(t,e,i){const r=t,n=e??t;return 1===r&&1===n?ct.validation("scale","sx and sy are both 1 (no-op)"):this._applyAffineToSelection((t,e)=>Vt(r,n,t,e),i,t=>`Scale ${t} feature${1===t?"":"s"}`)}_applyAffineToSelection(t,e,i){const r=this._emap._selection.getAll();if(0===r.length)return ct.validation("selection","selection is empty");const n=new globalThis.Map;for(const t of r){const e=this._emap.layers.resolve(t.source,t.layer);if(!e?.shapes)continue;const i=e.shapes[t.id];if(!i)continue;let r=n.get(t.source);if(r||(r={arcIdSet:new Set,pointFeatures:[]},n.set(t.source,r)),"point"===e.geometry_type)r.pointFeatures.push({layer:e,featureId:t.id});else{const t=i;for(const e of t)if(Array.isArray(e))for(const t of e)"number"==typeof t&&r.arcIdSet.add(t>=0?t:~t)}}if(0===n.size)return ct.validation("selection","no resolvable layers in selection");let s,o;if(e)s=e[0],o=e[1];else{const t=this._computeSelectionCentroid(n);if(!t)return ct.validation("origin","no vertices in selection; cannot compute centroid");[s,o]=t}if(!Number.isFinite(s)||!Number.isFinite(o))return ct.validation("origin","computed origin is not finite");const a=t(s,o),l=[],c=[];for(const[t,e]of n){const i=this._emap._sources.get(t);if(!i)continue;if(0===e.arcIdSet.size&&0===e.pointFeatures.length)continue;const r=new Ot({source:i,arcs:i.getArcs(),matrix:a,arcIds:Array.from(e.arcIdSet),pointFeatures:e.pointFeatures});r.do(),l.push(r),c.push(t)}if(0===l.length)return ct.validation("selection","every resolved layer was empty");const h=1===l.length?l[0]:new zt(l,i(r.length));return this._emap._history.push(h),this._emap._fireHistoryChange(),this._emap._clearSpatialIndexesForSources(c),this._emap._scheduleRender(),at}_computeSelectionCentroid(t){let e=1/0,i=1/0,r=-1/0,n=-1/0,s=!1;for(const[o,a]of t){const t=this._emap._sources.get(o);if(!t)continue;const l=t.getArcs(),c=l?.getVertexData?.();if(c&&a.arcIdSet.size>0){const{xx:t,yy:o,ii:l,nn:h}=c;for(const c of a.arcIdSet){const a=l[c],u=h[c];for(let l=a;l<a+u;l++){const a=t[l],c=o[l];a<e&&(e=a),a>r&&(r=a),c<i&&(i=c),c>n&&(n=c),s=!0}}}for(const t of a.pointFeatures){const o=t.layer.shapes?.[t.featureId];if(o)for(const t of rt(o)){if(!t||t.length<2)continue;const o=t[0],a=t[1];o<e&&(e=o),o>r&&(r=o),a<i&&(i=a),a>n&&(n=a),s=!0}}}return s?[(e+r)/2,(i+n)/2]:null}}class Xt{opts;label;constructor(t){this.opts=t,this.label=t.label??"Edit properties"}do(){Yt(this.opts.layer,this.opts.featureId,this.opts.prev,this.opts.next)}undo(){Yt(this.opts.layer,this.opts.featureId,this.opts.next,this.opts.prev)}}function Yt(t,e,i,r){const n=t.data?.getRecords?.(),s=n?.[e];if(s){for(const t of Object.keys(r))s[t]=r[t];for(const t of Object.keys(i))t in r||delete s[t]}}class Kt{opts;label;_addedIndices=[];constructor(t){this.opts=t,this.label=`Add field ${t.field}`}do(){const t=this.opts.layer.data?.getRecords?.();if(!t)return;const e=this.opts.defaultValue??null;this._addedIndices=[];for(let i=0;i<t.length;i++)t[i]&&!(this.opts.field in t[i])&&(t[i][this.opts.field]=e,this._addedIndices.push(i))}undo(){const t=this.opts.layer.data?.getRecords?.();if(t){for(const e of this._addedIndices)delete t[e]?.[this.opts.field];this._addedIndices=[]}}}class Jt{opts;label;_snapshot=new globalThis.Map;constructor(t){this.opts=t,this.label=`Remove field ${t.field}`}do(){const t=this.opts.layer.data?.getRecords?.();if(t){this._snapshot.clear();for(let e=0;e<t.length;e++){const i=t[e];i&&this.opts.field in i&&(this._snapshot.set(e,i[this.opts.field]),delete i[this.opts.field])}}}undo(){const t=this.opts.layer.data?.getRecords?.();if(t)for(const[e,i]of this._snapshot){const r=t[e];r&&(r[this.opts.field]=i)}}}class Qt{opts;label;constructor(t){this.opts=t,this.label=`Rename field ${t.from} → ${t.to}`}do(){te(this.opts.layer,this.opts.from,this.opts.to)}undo(){te(this.opts.layer,this.opts.to,this.opts.from)}}function te(t,e,i){const r=t.data?.getRecords?.();if(r)for(const t of r)t&&e in t&&(t[i]=t[e],delete t[e])}class ee{_emap;constructor(t){this._emap=t}setFeatureProperty(t,e,i){return this.setFeatureProperties(t,{[e]:i})}setFeatureProperties(t,e){const i=this._emap.layers.resolve(t.source,t.layer);if(!i)return ct.notFound("layer",t.layer);const r=i.data?.getRecords?.(),n=r?.[t.id];if(!n)return ct.notFound("field",`record#${t.id}`);const s={},o={};for(const t of Object.keys(e)){const i=t in n,r=i?n[t]:void 0,a=e[t];(void 0!==a||i)&&(void 0!==a&&i&&n[t]===a||(i&&(s[t]=r),void 0!==a&&(o[t]=a)))}if(0===Object.keys(s).length&&0===Object.keys(o).length)return ct.validation("props","no-op: every requested value already matches the record");const a=new Xt({layer:i,featureId:t.id,prev:s,next:o});return a.do(),this._emap._history.push(a),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}addField(t){const e=this._emap.layers.resolve(t.source,t.target);if(!e)return ct.notFound("layer",t.target);if(!e.data)return ct.validation("target","layer has no data table");const i=new Kt({layer:e,field:t.field,defaultValue:t.defaultValue});return i.do(),this._emap._history.push(i),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}removeField(t){const e=this._emap.layers.resolve(t.source,t.target);if(!e)return ct.notFound("layer",t.target);if(!e.data)return ct.validation("target","layer has no data table");const i=new Jt({layer:e,field:t.field});return i.do(),this._emap._history.push(i),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}renameField(t){const e=this._emap.layers.resolve(t.source,t.target);if(!e)return ct.notFound("layer",t.target);if(!e.data)return ct.validation("target","layer has no data table");const i=e.data.getRecords?.();if(!i)return ct.validation("target","data table has no records");if(t.from===t.to)return ct.validation("to","`from` and `to` are identical");for(const e of i)if(e&&t.from in e&&t.to in e)return ct.validation("to",`would overwrite existing '${t.to}' on at least one record`);const r=new Qt({layer:e,from:t.from,to:t.to});return r.do(),this._emap._history.push(r),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}}class ie{_onChange;_mode="none";_vertex=null;_draw=null;constructor(t){this._onChange=t}get mode(){return this._mode}get vertex(){return this._vertex}get draw(){return this._draw}setMode(t){if(t===this._mode)return;const e=this._mode;this._mode=t,"vertex"!==t&&(this._vertex=null),"draw"!==t&&(this._draw=null),this._fire(e)}setVertex(t){this._vertex!==t&&(this._vertex=t,this._fire(this._mode))}clearVertex(){null!==this._vertex&&(this._vertex=null,this._fire(this._mode))}setDraw(t){this._draw!==t&&(this._draw=t,this._fire(this._mode))}clearDraw(){null!==this._draw&&(this._draw=null,this._fire(this._mode))}_fire(t){this._onChange({current:{mode:this._mode,vertex:this._vertex,draw:this._draw},previousMode:t,modeChanged:t!==this._mode})}}var re={},ne=Uint8Array,se=Uint16Array,oe=Int32Array,ae=new ne([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),le=new ne([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ce=new ne([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),he=function(t,e){for(var i=new se(31),r=0;r<31;++r)i[r]=e+=1<<t[r-1];var n=new oe(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return{b:i,r:n}},ue=he(ae,2),pe=ue.b,de=ue.r;pe[28]=258,de[258]=28;for(var fe=he(le,0),me=fe.b,_e=fe.r,ge=new se(32768),ye=0;ye<32768;++ye){var ve=(43690&ye)>>1|(21845&ye)<<1;ve=(61680&(ve=(52428&ve)>>2|(13107&ve)<<2))>>4|(3855&ve)<<4,ge[ye]=((65280&ve)>>8|(255&ve)<<8)>>1}var xe=function(t,e,i){for(var r=t.length,n=0,s=new se(e);n<r;++n)t[n]&&++s[t[n]-1];var o,a=new se(e);for(n=1;n<e;++n)a[n]=a[n-1]+s[n-1]<<1;if(i){o=new se(1<<e);var l=15-e;for(n=0;n<r;++n)if(t[n])for(var c=n<<4|t[n],h=e-t[n],u=a[t[n]-1]++<<h,p=u|(1<<h)-1;u<=p;++u)o[ge[u]>>l]=c}else for(o=new se(r),n=0;n<r;++n)t[n]&&(o[n]=ge[a[t[n]-1]++]>>15-t[n]);return o},be=new ne(288);for(ye=0;ye<144;++ye)be[ye]=8;for(ye=144;ye<256;++ye)be[ye]=9;for(ye=256;ye<280;++ye)be[ye]=7;for(ye=280;ye<288;++ye)be[ye]=8;var we=new ne(32);for(ye=0;ye<32;++ye)we[ye]=5;var Se=xe(be,9,0),Te=xe(be,9,1),Ce=xe(we,5,0),Me=xe(we,5,1),Ee=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},Ae=function(t,e,i){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&i},Ie=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&e)},Pe=function(t){return(t+7)/8|0},De=function(t,e,i){return(null==e||e<0)&&(e=0),(null==i||i>t.length)&&(i=t.length),new ne(t.subarray(e,i))},ke=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ze=function(t,e,i){var r=new Error(e||ke[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,ze),!i)throw r;return r},Re=function(t,e,i,r){var n=t.length,s=r?r.length:0;if(!n||e.f&&!e.l)return i||new ne(0);var o=!i,a=o||2!=e.i,l=e.i;o&&(i=new ne(3*n));var c=function(t){var e=i.length;if(t>e){var r=new ne(Math.max(2*e,t));r.set(i),i=r}},h=e.f||0,u=e.p||0,p=e.b||0,d=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!d){h=Ae(t,u,1);var y=Ae(t,u+1,3);if(u+=3,!y){var v=t[(P=Pe(u)+4)-4]|t[P-3]<<8,x=P+v;if(x>n){l&&ze(0);break}a&&c(p+v),i.set(t.subarray(P,x),p),e.b=p+=v,e.p=u=8*x,e.f=h;continue}if(1==y)d=Te,f=Me,m=9,_=5;else if(2==y){var b=Ae(t,u,31)+257,w=Ae(t,u+10,15)+4,S=b+Ae(t,u+5,31)+1;u+=14;for(var T=new ne(S),C=new ne(19),M=0;M<w;++M)C[ce[M]]=Ae(t,u+3*M,7);u+=3*w;var E=Ee(C),A=(1<<E)-1,I=xe(C,E,1);for(M=0;M<S;){var P,D=I[Ae(t,u,A)];if(u+=15&D,(P=D>>4)<16)T[M++]=P;else{var k=0,z=0;for(16==P?(z=3+Ae(t,u,3),u+=2,k=T[M-1]):17==P?(z=3+Ae(t,u,7),u+=3):18==P&&(z=11+Ae(t,u,127),u+=7);z--;)T[M++]=k}}var R=T.subarray(0,b),L=T.subarray(b);m=Ee(R),_=Ee(L),d=xe(R,m,1),f=xe(L,_,1)}else ze(1);if(u>g){l&&ze(0);break}}a&&c(p+131072);for(var F=(1<<m)-1,B=(1<<_)-1,O=u;;O=u){var N=(k=d[Ie(t,u)&F])>>4;if((u+=15&k)>g){l&&ze(0);break}if(k||ze(2),N<256)i[p++]=N;else{if(256==N){O=u,d=null;break}var V=N-254;if(N>264){var j=ae[M=N-257];V=Ae(t,u,(1<<j)-1)+pe[M],u+=j}var q=f[Ie(t,u)&B],G=q>>4;q||ze(3),u+=15&q;L=me[G];if(G>3){j=le[G];L+=Ie(t,u)&(1<<j)-1,u+=j}if(u>g){l&&ze(0);break}a&&c(p+131072);var U=p+V;if(p<L){var $=s-L,Z=Math.min(L,U);for($+p<0&&ze(3);p<Z;++p)i[p]=r[$+p]}for(;p<U;++p)i[p]=i[p-L]}}e.l=d,e.p=O,e.b=p,e.f=h,d&&(h=1,e.m=m,e.d=f,e.n=_)}while(!h);return p!=i.length&&o?De(i,0,p):i.subarray(0,p)},Le=function(t,e,i){i<<=7&e;var r=e/8|0;t[r]|=i,t[r+1]|=i>>8},Fe=function(t,e,i){i<<=7&e;var r=e/8|0;t[r]|=i,t[r+1]|=i>>8,t[r+2]|=i>>16},Be=function(t,e){for(var i=[],r=0;r<t.length;++r)t[r]&&i.push({s:r,f:t[r]});var n=i.length,s=i.slice();if(!n)return{t:Ue,l:0};if(1==n){var o=new ne(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(t,e){return t.f-e.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,h=1,u=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=n-1;)a=i[i[c].f<i[u].f?c++:u++],l=i[c!=h&&i[c].f<i[u].f?c++:u++],i[h++]={s:-1,f:a.f+l.f,l:a,r:l};var p=s[0].s;for(r=1;r<n;++r)s[r].s>p&&(p=s[r].s);var d=new se(p+1),f=Oe(i[h-1],d,0);if(f>e){r=0;var m=0,_=f-e,g=1<<_;for(s.sort(function(t,e){return d[e.s]-d[t.s]||t.f-e.f});r<n;++r){var y=s[r].s;if(!(d[y]>e))break;m+=g-(1<<f-d[y]),d[y]=e}for(m>>=_;m>0;){var v=s[r].s;d[v]<e?m-=1<<e-d[v]++-1:++r}for(;r>=0&&m;--r){var x=s[r].s;d[x]==e&&(--d[x],++m)}f=e}return{t:new ne(d),l:f}},Oe=function(t,e,i){return-1==t.s?Math.max(Oe(t.l,e,i+1),Oe(t.r,e,i+1)):e[t.s]=i},Ne=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new se(++e),r=0,n=t[0],s=1,o=function(t){i[r++]=t},a=1;a<=e;++a)if(t[a]==n&&a!=e)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=t[a]}return{c:i.subarray(0,r),n:e}},Ve=function(t,e){for(var i=0,r=0;r<e.length;++r)i+=t[r]*e[r];return i},je=function(t,e,i){var r=i.length,n=Pe(e+2);t[n]=255&r,t[n+1]=r>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var s=0;s<r;++s)t[n+s+4]=i[s];return 8*(n+4+r)},qe=function(t,e,i,r,n,s,o,a,l,c,h){Le(e,h++,i),++n[256];for(var u=Be(n,15),p=u.t,d=u.l,f=Be(s,15),m=f.t,_=f.l,g=Ne(p),y=g.c,v=g.n,x=Ne(m),b=x.c,w=x.n,S=new se(19),T=0;T<y.length;++T)++S[31&y[T]];for(T=0;T<b.length;++T)++S[31&b[T]];for(var C=Be(S,7),M=C.t,E=C.l,A=19;A>4&&!M[ce[A-1]];--A);var I,P,D,k,z=c+5<<3,R=Ve(n,be)+Ve(s,we)+o,L=Ve(n,p)+Ve(s,m)+o+14+3*A+Ve(S,M)+2*S[16]+3*S[17]+7*S[18];if(l>=0&&z<=R&&z<=L)return je(e,h,t.subarray(l,l+c));if(Le(e,h,1+(L<R)),h+=2,L<R){I=xe(p,d,0),P=p,D=xe(m,_,0),k=m;var F=xe(M,E,0);Le(e,h,v-257),Le(e,h+5,w-1),Le(e,h+10,A-4),h+=14;for(T=0;T<A;++T)Le(e,h+3*T,M[ce[T]]);h+=3*A;for(var B=[y,b],O=0;O<2;++O){var N=B[O];for(T=0;T<N.length;++T){var V=31&N[T];Le(e,h,F[V]),h+=M[V],V>15&&(Le(e,h,N[T]>>5&127),h+=N[T]>>12)}}}else I=Se,P=be,D=Ce,k=we;for(T=0;T<a;++T){var j=r[T];if(j>255){Fe(e,h,I[(V=j>>18&31)+257]),h+=P[V+257],V>7&&(Le(e,h,j>>23&31),h+=ae[V]);var q=31&j;Fe(e,h,D[q]),h+=k[q],q>3&&(Fe(e,h,j>>5&8191),h+=le[q])}else Fe(e,h,I[j]),h+=P[j]}return Fe(e,h,I[256]),h+P[256]},Ge=new oe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ue=new ne(0),$e=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,r=9;--r;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),Ze=function(){var t=-1;return{p:function(e){for(var i=t,r=0;r<e.length;++r)i=$e[255&i^e[r]]^i>>>8;t=i},d:function(){return~t}}},We=function(t,e,i,r,n){if(!n&&(n={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),o=new ne(s.length+t.length);o.set(s),o.set(t,s.length),t=o,n.w=s.length}return function(t,e,i,r,n,s){var o=s.z||t.length,a=new ne(r+o+5*(1+Math.ceil(o/7e3))+n),l=a.subarray(r,a.length-n),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=Ge[e-1],p=u>>13,d=8191&u,f=(1<<i)-1,m=s.p||new se(32768),_=s.h||new se(f+1),g=Math.ceil(i/3),y=2*g,v=function(e){return(t[e]^t[e+1]<<g^t[e+2]<<y)&f},x=new oe(25e3),b=new se(288),w=new se(32),S=0,T=0,C=s.i||0,M=0,E=s.w||0,A=0;C+2<o;++C){var I=v(C),P=32767&C,D=_[I];if(m[P]=D,_[I]=P,E<=C){var k=o-C;if((S>7e3||M>24576)&&(k>423||!c)){h=qe(t,l,0,x,b,w,T,M,A,C-A,h),M=S=T=0,A=C;for(var z=0;z<286;++z)b[z]=0;for(z=0;z<30;++z)w[z]=0}var R=2,L=0,F=d,B=P-D&32767;if(k>2&&I==v(C-B))for(var O=Math.min(p,k)-1,N=Math.min(32767,C),V=Math.min(258,k);B<=N&&--F&&P!=D;){if(t[C+R]==t[C+R-B]){for(var j=0;j<V&&t[C+j]==t[C+j-B];++j);if(j>R){if(R=j,L=B,j>O)break;var q=Math.min(B,j-2),G=0;for(z=0;z<q;++z){var U=C-B+z&32767,$=U-m[U]&32767;$>G&&(G=$,D=U)}}}B+=(P=D)-(D=m[P])&32767}if(L){x[M++]=268435456|de[R]<<18|_e[L];var Z=31&de[R],W=31&_e[L];T+=ae[Z]+le[W],++b[257+Z],++w[W],E=C+R,++S}else x[M++]=t[C],++b[t[C]]}}for(C=Math.max(C,E);C<o;++C)x[M++]=t[C],++b[t[C]];h=qe(t,l,c,x,b,w,T,M,A,C-A,h),c||(s.r=7&h|l[h/8|0]<<3,h-=7,s.h=_,s.p=m,s.i=C,s.w=E)}else{for(C=s.w||0;C<o+c;C+=65535){var H=C+65535;H>=o&&(l[h/8|0]=c,H=o),h=je(l,h+1,t.subarray(C,H))}s.i=o}return De(a,0,r+Pe(h)+n)}(t,null==e.level?6:e.level,null==e.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,i,r,n)},He=function(t,e){var i={};for(var r in t)i[r]=t[r];for(var r in e)i[r]=e[r];return i},Xe=function(t,e,i){for(var r=t(),n=t.toString(),s=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<r.length;++o){var a=r[o],l=s[o];if("function"==typeof a){e+=";"+l+"=";var c=a.toString();if(a.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;e+=c.slice(h,c.indexOf("(",h))}else for(var u in e+=c,a.prototype)e+=";"+l+".prototype."+u+"="+a.prototype[u].toString();else e+=c}else i[l]=a}return e},Ye=[],Ke=function(t,e,i,r){if(!Ye[i]){for(var n="",s={},o=t.length-1,a=0;a<o;++a)n=Xe(t[a],n,s);Ye[i]={c:Xe(t[o],n,s),e:s}}var l=He({},Ye[i].e);return function(t,e,i,r,n){var s=new Worker(re[e]||(re[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return s.onmessage=function(t){var e=t.data,i=e.$e$;if(i){var r=new Error(i[0]);r.code=i[1],r.stack=i[2],n(r,null)}else n(null,e)},s.postMessage(i,r),s}(Ye[i].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",i,l,function(t){var e=[];for(var i in t)t[i].buffer&&e.push((t[i]=new t[i].constructor(t[i])).buffer);return e}(l),r)},Je=function(){return[ne,se,oe,ae,le,ce,pe,me,Te,Me,ge,ke,xe,Ee,Ae,Ie,Pe,De,ze,Re,ai,Qe,ti]},Qe=function(t){return postMessage(t,[t.buffer])},ti=function(t){return t&&{out:t.size&&new ne(t.size),dictionary:t.dictionary}},ei=function(t,e){return t[e]|t[e+1]<<8},ii=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},ri=function(t,e){return ii(t,e)+4294967296*ii(t,e+4)},ni=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function si(t,e){return We(t,e||{},0,0)}function oi(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&ze(7),function(t,e,i,r,n,s){var o=Ke(i,r,n,function(t,e){o.terminate(),s(t,e)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}}(t,e,[Je],function(t){return Qe(ai(t.data[0],ti(t.data[1])))},1,i)}function ai(t,e){return Re(t,{i:2},e&&e.out,e&&e.dictionary)}var li=function(t,e,i,r){for(var n in t){var s=t[n],o=e+n,a=r;Array.isArray(s)&&(a=He(r,s[1]),s=s[0]),s instanceof ne?i[o]=[s,a]:(i[o+="/"]=[new ne(0),a],li(s,o,i,r))}},ci="undefined"!=typeof TextEncoder&&new TextEncoder,hi="undefined"!=typeof TextDecoder&&new TextDecoder;try{hi.decode(Ue,{stream:!0})}catch(t){}function ui(t,e){if(ci)return ci.encode(t);for(var i=t.length,r=new ne(t.length+(t.length>>1)),n=0,s=function(t){r[n++]=t},o=0;o<i;++o){if(n+5>r.length){var a=new ne(n+8+(i-o<<1));a.set(r),r=a}var l=t.charCodeAt(o);l<128||e?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return De(r,0,n)}function pi(t,e){if(e){for(var i="",r=0;r<t.length;r+=16384)i+=String.fromCharCode.apply(null,t.subarray(r,r+16384));return i}if(hi)return hi.decode(t);var n=function(t){for(var e="",i=0;;){var r=t[i++],n=(r>127)+(r>223)+(r>239);if(i+n>t.length)return{s:e,r:De(t,i-1)};n?3==n?(r=((15&r)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=1&n?String.fromCharCode((31&r)<<6|63&t[i++]):String.fromCharCode((15&r)<<12|(63&t[i++])<<6|63&t[i++]):e+=String.fromCharCode(r)}}(t),s=n.s;return(i=n.r).length&&ze(8),s}var di=function(t,e){for(;1!=ei(t,e);e+=4+ei(t,e+2));return[ri(t,e+12),ri(t,e+4),ri(t,e+20)]},fi=function(t){var e=0;if(t)for(var i in t){var r=t[i].length;r>65535&&ze(9),e+=r+4}return e},mi=function(t,e,i,r,n,s,o,a){var l=r.length,c=i.extra,h=a&&a.length,u=fi(c);ni(t,e,null!=o?33639248:67324752),e+=4,null!=o&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(s<0&&8),t[e++]=n&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var p=new Date(null==i.mtime?Date.now():i.mtime),d=p.getFullYear()-1980;if((d<0||d>119)&&ze(10),ni(t,e,d<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,-1!=s&&(ni(t,e,i.crc),ni(t,e+4,s<0?-s-2:s),ni(t,e+8,i.size)),ni(t,e+12,l),ni(t,e+14,u),e+=16,null!=o&&(ni(t,e,h),ni(t,e+6,i.attrs),ni(t,e+10,o),e+=14),t.set(r,e),e+=l,u)for(var f in c){var m=c[f],_=m.length;ni(t,e,+f),ni(t,e+2,_),t.set(m,e+4),e+=4+_}return h&&(t.set(a,e),e+=h),e};function _i(t,e){e||(e={});var i={},r=[];li(t,"",i,e);var n=0,s=0;for(var o in i){var a=i[o],l=a[0],c=a[1],h=0==c.level?0:8,u=(S=ui(o)).length,p=c.comment,d=p&&ui(p),f=d&&d.length,m=fi(c.extra);u>65535&&ze(11);var _=h?si(l,c):l,g=_.length,y=Ze();y.p(l),r.push(He(c,{size:l.length,crc:y.d(),c:_,f:S,m:d,u:u!=o.length||d&&p.length!=f,o:n,compression:h})),n+=30+u+m+g,s+=76+2*(u+m)+(f||0)+g}for(var v=new ne(s+22),x=n,b=s-n,w=0;w<r.length;++w){var S=r[w];mi(v,S.o,S,S.f,S.u,S.c.length);var T=30+S.f.length+fi(S.extra);v.set(S.c,S.o+T),mi(v,n,S,S.f,S.u,S.c.length,S.o,S.m),n+=16+T+(S.m?S.m.length:0)}return function(t,e,i,r,n){ni(t,e,101010256),ni(t,e+8,i),ni(t,e+10,i),ni(t,e+12,r),ni(t,e+16,n)}(v,n,r.length,b,x),v}var gi="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()};function yi(t,e,i){i||(i=e,e={}),"function"!=typeof i&&ze(7);var r=[],n=function(){for(var t=0;t<r.length;++t)r[t]()},s={},o=function(t,e){gi(function(){i(t,e)})};gi(function(){o=i});for(var a=t.length-22;101010256!=ii(t,a);--a)if(!a||t.length-a>65558)return o(ze(13,0,1),null),n;var l=ei(t,a+8);if(l){var c=l,h=ii(t,a+16),u=4294967295==h||65535==c;if(u){var p=ii(t,a-12);(u=101075792==ii(t,p))&&(c=l=ii(t,p+32),h=ii(t,p+48))}for(var d=e&&e.filter,f=function(e){var i=function(t,e,i){var r=ei(t,e+28),n=pi(t.subarray(e+46,e+46+r),!(2048&ei(t,e+8))),s=e+46+r,o=ii(t,e+20),a=i&&4294967295==o?di(t,s):[o,ii(t,e+24),ii(t,e+42)],l=a[0],c=a[1],h=a[2];return[ei(t,e+10),l,c,n,s+ei(t,e+30)+ei(t,e+32),h]}(t,h,u),a=i[0],c=i[1],p=i[2],f=i[3],m=i[4],_=i[5],g=function(t,e){return e+30+ei(t,e+26)+ei(t,e+28)}(t,_);h=m;var y=function(t,e){t?(n(),o(t,null)):(e&&(s[f]=e),--l||o(null,s))};if(!d||d({name:f,size:c,originalSize:p,compression:a}))if(a)if(8==a){var v=t.subarray(g,g+c);if(p<524288||c>.8*p)try{y(null,ai(v,{out:new ne(p)}))}catch(t){y(t,null)}else r.push(oi(v,{size:p},y))}else y(ze(14,"unknown compression type "+a,1),null);else y(null,De(t,g,g+c));else y(null,null)},m=0;m<c;++m)f()}else o(null,{});return n}const vi=5e5;class xi{_unfilteredArcs;_filteredArcs=null;_filteredSegLen=0;_dirty=!1;constructor(t){this._unfilteredArcs=t;(t.getPointCount?.()??0)>vi&&this._initFilteredArcs()}markDirty(){this._dirty=!0}_initFilteredArcs(){const t=this._unfilteredArcs,e=t.getVertexData?.();if(e?.zz){const e=.08,i=Math.ceil((t.getPointCount?.()??0)/vi),r=t.getRetainedInterval?.()??0,n=t.getThresholdByPct?.(e,i)??0;this._filteredArcs=t.setRetainedInterval?.(n)?.getFilteredCopy?.()??null,t.setRetainedInterval?.(r),this._filteredArcs&&(this._filteredSegLen=J().getAvgSegment(this._filteredArcs))}else{const e=J();this._filteredSegLen=4*e.getAvgSegment(t),this._filteredArcs=e.simplifyArcsFast(t,this._filteredSegLen)}}getScaledArcs(t){const e=null!==this._filteredArcs&&t>1.5*this._filteredSegLen;if(this._filteredArcs){(this._filteredArcs.size()!==this._unfilteredArcs.size()||this._dirty&&e)&&(this._initFilteredArcs(),this._dirty=!1)}else if(this._dirty){(this._unfilteredArcs.getPointCount?.()??0)>vi&&this._initFilteredArcs(),this._dirty=!1}this._filteredArcs&&this._filteredArcs.setRetainedInterval?.(this._unfilteredArcs.getRetainedInterval?.()??0);return this._filteredArcs&&t>1.5*this._filteredSegLen?this._filteredArcs:this._unfilteredArcs}getArcs(){return this._unfilteredArcs}hasLOD(){return null!==this._filteredArcs}}class bi{_adapter;constructor(t=J()){this._adapter=t}async runImport(t,e){return this._adapter.runImport(t,e)}}let wi=null;const Si="EPSG:4326";function Ti(t){if(!t)return Si;const e=t.info;if(!e)return Si;if(e.crs_string)return Ci(e.crs_string);if(e.prj){const t=Mi(e.prj);if(t)return t}if(e.crs){if(e.crs.is_latlong)return"EPSG:4326";if("merc"===e.crs.projName&&6378137===e.crs.a)return"EPSG:3857"}return Si}function Ci(t){const e=t.toLowerCase();return"wgs84"===e||e.includes("4326")?"EPSG:4326":e.includes("3857")||"webmercator"===e?"EPSG:3857":(/^epsg:\d+$/i.test(t),t.toUpperCase())}function Mi(t){const e=t.match(/AUTHORITY\["EPSG"\s*,\s*"(\d+)"\]/i);return e?`EPSG:${e[1]}`:/Mercator.*WGS.*84.*Pseudo/i.test(t)||/WGS.*84.*Pseudo.*Mercator/i.test(t)||/Web_Mercator/i.test(t)?"EPSG:3857":/DATUM\["WGS_1984"/i.test(t)&&/GEOGCS/i.test(t)?"EPSG:4326":null}const Ei={geojson:"application/geo+json",topojson:"application/json",shapefile:"application/zip",msx:"application/octet-stream"};function Ai(t){return"string"==typeof t?(new TextEncoder).encode(t):t instanceof Uint8Array?t:new Uint8Array(t)}const Ii={maxBytes:209715200,maxEntries:5e3,maxRatio:100};class Pi extends G{id;type="topology";_dataset;_displayArcs=null;_options;_data;_loadVersion=0;_abortController=null;_simplifyFloor=0;_runner;getSimplifyFloor(){return this._simplifyFloor}constructor(t,e){super(),this.id=t,this._options=e||{},this._data=this._options.data,this._runner=this._options.mapshaperRunner??wi??(wi=new bi),this._data&&this._updateData()}static async fromUrl(t,e,i){const r=new Pi(t,i);return await new Promise((t,i)=>{let n,s;const o=()=>{r.off("data",n),r.off("error",s)};n=()=>{o(),t()},s=t=>{o(),i(t?.error??t)},r.on("data",n),r.on("error",s),r.setData(e)}),r}setData(t){return this._loadVersion++,this._abortController?.abort(),this._abortController=null,this._data=t,this._updateData(),this}async _updateData(){if(!this._data)return;const t=this._loadVersion,e=new AbortController;this._abortController=e,this.fire("dataloading");try{const i={},r=[];if(Array.isArray(this._data)){if(0===this._data.length)throw new Error("setData received an empty array; nothing to import");for(const t of this._data)if(this._isZipFile(t.filename)){const e=await this._extractZip(t.content),n=this._findPrimaryFile(e);if(!n)throw new Error(`No importable file found in zip archive: ${t.filename}`);for(const[t,r]of Object.entries(e))i[t]=r;r.push(n)}else i[t.filename]=t.content,r.push(t.filename)}else{let t;if("string"==typeof this._data){const i=this._data,r=await fetch(i,{signal:e.signal});if(!r.ok)throw new Error(`Failed to fetch ${i}: HTTP ${r.status}`);const n=await r.arrayBuffer(),s=new Uint8Array(n);let o=new URL(i).pathname.split("/").pop()||"";if(!this._hasSupportedExtension(o)){const t=r.headers.get("Content-Type")||"";o=this._filenameFromContentType(t,o)}o||(o="data.json"),t={filename:o,content:s}}else t=this._data;if(this._isZipFile(t.filename)){const e=await this._extractZip(t.content),n=this._findPrimaryFile(e);if(!n)throw new Error("No importable file found in zip archive");for(const[t,r]of Object.entries(e))i[t]=r;r.push(n)}else i[t.filename]=t.content,r.push(t.filename)}const n=`-i ${r.map(t=>`"${t.replace(/"/g,'\\"')}"`).join(" ")}`,s=await this._runner.runImport(n,i);if(t!==this._loadVersion)return;this._dataset=s,this._dataset?.arcs&&(this._displayArcs=new xi(this._dataset.arcs)),this._simplifyFloor=this._dataset?.arcs?.getRetainedInterval?.()??0,this.fire("data",{reason:"load"})}catch(e){if(t!==this._loadVersion)return;if("AbortError"===e?.name)return;this.fire("error",{error:e})}}_hasSupportedExtension(t){return/\.(json|geojson|topojson|zip|shp|kml|msx)$/i.test(t)}_filenameFromContentType(t,e){return(e||"data")+({"application/json":".json","application/geo+json":".geojson","application/vnd.geo+json":".geojson","application/topojson+json":".topojson","application/zip":".zip","application/x-zip-compressed":".zip","application/octet-stream":".zip","application/vnd.google-earth.kml+xml":".kml","text/plain":".json"}[t.toLowerCase().split(";")[0].trim()]||".json")}getDataset(){return this._dataset}getCRS(){return Ti(this._dataset)}async reproject(t){if(!this._dataset)return;this._dataset?.arcs?.setRetainedInterval&&this._dataset.arcs.setRetainedInterval(0),this._dataset.info&&(delete this._dataset.info.crs_string,delete this._dataset.info.prj,delete this._dataset.info.wkt1);const e=`-proj ${t}`,i=await J().runOnDataset(e,this._dataset);this._dataset=i,this._dataset?.arcs&&(this._displayArcs=new xi(this._dataset.arcs))}getExtent(){if(!this._dataset)return new $;const t=J().getDatasetBounds(this._dataset);return new $(t.xmin,t.ymin,t.xmax,t.ymax)}getArcs(){return this._dataset?.arcs}getDisplayArcs(){return this._displayArcs}markDisplayArcsDirty(){this._displayArcs?.markDirty()}refreshDisplayArcs(){this._dataset?.arcs&&(this._displayArcs=new xi(this._dataset.arcs))}setDataset(t){this._dataset=t,t.arcs?this._displayArcs=new xi(t.arcs):this._displayArcs=null,this._simplifyFloor=t.arcs?.getRetainedInterval?.()??0,this.fire("data",{reason:"replace"})}async export(t){if(!this._dataset)throw new Error("TopologySource has no dataset to export");const e=this._dataset.arcs,i=e?.getRetainedInterval?.()??0;i&&e?.setRetainedInterval&&e.setRetainedInterval(0);try{const e=J(),i="msx"===t.format?await e.exportPackedDatasets([this._dataset],{compact:!0}):e.exportFileContent(this._dataset,{format:t.format});return this._filesToBlob(i,t.format)}finally{i&&e?.setRetainedInterval&&e.setRetainedInterval(i)}}_filesToBlob(t,e){if(0===t.length)throw new Error(`mapshaper produced no output for format=${e}`);if("shapefile"===e){const e={};for(const i of t)e[i.filename]=Ai(i.content);const i=_i(e);return new Blob([i],{type:Ei.shapefile})}return new Blob([t[0].content],{type:Ei[e]})}getLayers(){return this._dataset?.layers||[]}_isZipFile(t){return/\.zip$/i.test(t)}async _extractZip(t){const e={...Ii,...this._options.zipLimits};let i=0,r=0;const n=await new Promise((n,s)=>{yi(t,{filter:n=>{if(r++,r>e.maxEntries)throw new Error(`ZIP extraction limit exceeded: ${r} entries > maxEntries ${e.maxEntries}`);if(i+=n.originalSize,i>e.maxBytes)throw new Error(`ZIP extraction limit exceeded: uncompressed total ${i} > maxBytes ${e.maxBytes}`);if(t.byteLength>0){const r=i/t.byteLength;if(r>e.maxRatio)throw new Error(`ZIP extraction limit exceeded: ratio ${r.toFixed(1)} > maxRatio ${e.maxRatio}`)}return!(/^__MACOSX/.test(n.name)||n.name.split("/").pop()?.startsWith("."))}},(t,e)=>{t?s(t):n(e)})}),s={};for(const t of Object.keys(n)){const e=n[t],i=t.split("/").pop()||t;this._isTextFile(i)?s[i]=pi(e):s[i]=e}return s}_isTextFile(t){return/\.(prj|cpg|csv|json|geojson|kml|txt)$/i.test(t)}_findPrimaryFile(t){const e=Object.keys(t),i=[".shp",".geojson",".json",".kml",".topojson"];for(const t of i){const i=e.find(e=>e.toLowerCase().endsWith(t));if(i)return i}return e.find(t=>!this._isAuxiliaryFile(t))||""}_isAuxiliaryFile(t){return/\.(prj|shx|dbf)$/i.test(t)}}function Di(t){const e=[];return function(i){e.push(i),e.length>t&&e.shift();return e.reduce((t,e)=>t+e,0)/e.length}}class ki extends G{_element;_active=!1;_timer=new Z;_sustainInterval=150;_fadeDelay=70;_eventTime=0;_getAverageRate=Di(10);_getWheelDirection=function(){let t=0,e=null;return function(i,r){const n=i>0?1:i<0?-1:0;(!e||r-t>300)&&(e=Di(3)),t=r;const s=e(n)||n;return s>0?1:s<0?-1:0}}();_wheelDirection=0;_mouseX=0;_mouseY=0;_wheelHandler=t=>this._handleWheel(t);constructor(t){super(),this._element=t,this._timer.on("tick",t=>this._onTick(t)),this._element.addEventListener("wheel",this._wheelHandler,{passive:!1})}destroy(){this._element.removeEventListener("wheel",this._wheelHandler),this._timer.stop()}_updateSustainInterval(t){this._fadeDelay=t+50,this._sustainInterval=this._fadeDelay+80}_handleWheel(t){const e=Date.now();if(this._wheelDirection=this._getWheelDirection(-t.deltaY,e),0===this._wheelDirection)return;t.preventDefault();const i=this._element.getBoundingClientRect();this._mouseX=t.clientX-i.left,this._mouseY=t.clientY-i.top,this._active?this._updateSustainInterval(this._getAverageRate(e-this._eventTime)):(this._active=!0,this.fire("mousewheelstart")),this._eventTime=e,this._timer.start(this._sustainInterval)}_onTick(t){const e=t.time-this._eventTime;let i=t.tickTime/25,r=0;e>this._fadeDelay&&(r=Math.min(1,(e-this._fadeDelay)/(this._sustainInterval-this._fadeDelay))),t.done?(this._active=!1,this.fire("mousewheelend")):(r>0&&(i*=W.quadraticOut(1-r)),this.fire("mousewheel",{direction:this._wheelDirection,multiplier:i,x:this._mouseX,y:this._mouseY}))}}class zi extends G{_element;_isDragging=!1;_lastMousePos=[0,0];_enabled=!0;_onMouseDownBound;_onMouseMoveBound;_onMouseUpBound;constructor(t){super(),this._element=t,this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this),t.addEventListener("mousedown",this._onMouseDownBound),window.addEventListener("mousemove",this._onMouseMoveBound),window.addEventListener("mouseup",this._onMouseUpBound)}setEnabled(t){this._enabled=t,!t&&this._isDragging&&(this._isDragging=!1,this.fire("panend"))}isEnabled(){return this._enabled}isDragging(){return this._isDragging}destroy(){this._element.removeEventListener("mousedown",this._onMouseDownBound),window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound)}_onMouseDown(t){this._enabled&&(t.shiftKey||(this._isDragging=!0,this._lastMousePos=[t.clientX,t.clientY],this.fire("panstart")))}_onMouseMove(t){if(!this._isDragging)return;const e=t.clientX-this._lastMousePos[0],i=t.clientY-this._lastMousePos[1];this._lastMousePos=[t.clientX,t.clientY],this.fire("pan",{dx:e,dy:i})}_onMouseUp(){this._isDragging&&(this._isDragging=!1,this.fire("panend"))}}class Ri{_workerUrl;_WorkerCtor;_slots;_pending=new Map;_nextId=1;_rrCursor=0;_destroyed=!1;constructor(t){this._workerUrl=t.workerUrl,this._WorkerCtor=t.WorkerCtor??globalThis.Worker;const e=Math.max(1,Math.floor(t.poolSize??1));this._slots=Array.from({length:e},()=>({worker:null,epoch:0,pendingCount:0}))}run(t,e,i){return this.runWithId(t,e,i).promise}runWithId(t,e,i){const r=this.reserveId();return{id:r,promise:this.dispatchWithId(r,t,e,i)}}reserveId(){return this._nextId++}dispatchWithId(t,e,i,r,n){if(this._destroyed)return Promise.reject(new Error("MapshaperWorkerPool: destroyed"));const s=this._pickWorker();let o;try{o=this._ensureWorker(s)}catch(t){return Promise.reject(t)}const a=this._slots[s],l=a.epoch;return a.pendingCount++,new Promise((a,c)=>{this._pending.set(t,{resolve:a,reject:c,workerIndex:s,epoch:l});const h={id:t,type:"run",packed:i};"string"==typeof e?h.cmd=e:h.commands=e,r&&(h.inputFiles=r),n&&n.length>0?o.postMessage(h,n):o.postMessage(h)})}destroy(){this._destroyed||(this._destroyed=!0,this._terminateAll(new Error("MapshaperWorkerPool: destroyed")))}cancelAll(){this._destroyed||this._terminateAll(new Error("MapshaperWorkerPool: cancelled"))}isWorkerSpawned(){return this._slots.some(t=>null!==t.worker)}get poolSize(){return this._slots.length}_pickWorker(){let t=0,e=1/0,i=!1;const r=this._slots.length;for(let n=0;n<r;n++){const s=(this._rrCursor+n)%r,o=this._slots[s],a=null!==o.worker;(o.pendingCount<e||o.pendingCount===e&&a&&!i)&&(t=s,e=o.pendingCount,i=a)}return this._rrCursor=(t+1)%r,t}_terminateAll(t){for(const t of this._slots)t.worker&&(t.worker.terminate(),t.worker=null),t.epoch++,t.pendingCount=0;for(const{reject:e}of this._pending.values())e(t);this._pending.clear()}_ensureWorker(t){const e=this._slots[t];if(e.worker)return e.worker;if(!this._WorkerCtor)throw new Error("MapshaperWorkerPool: Worker constructor not available in this environment");const i=new this._WorkerCtor(this._workerUrl);return i.onmessage=e=>this._onMessage(t,e.data),i.onerror=e=>this._onWorkerError(t,e),e.worker=i,i}_onMessage(t,e){if(!e||"number"!=typeof e.id)return;const i=this._pending.get(e.id);if(!i)return;const r=this._slots[t];i.workerIndex===t&&i.epoch===r.epoch&&(this._pending.delete(e.id),r.pendingCount=Math.max(0,r.pendingCount-1),"ok"===e.type?i.resolve(e.packed):i.reject(new Error(e.message||"mapshaper worker error")))}_onWorkerError(t,e){const i=new Error(`mapshaper worker error: ${e.message||"unknown"}`),r=this._slots[t];r.worker&&(r.worker.terminate(),r.worker=null),r.epoch++,r.pendingCount=0;const n=[];for(const[e,i]of this._pending)i.workerIndex===t&&n.push(e);for(const t of n){const e=this._pending.get(t);this._pending.delete(t),e?.reject(i)}}}class Li{_sources;_getTransform;_getSize;_getInitialMX;_indexCache=new globalThis.Map;constructor(t,e,i,r){this._sources=t,this._getTransform=e,this._getSize=i,this._getInitialMX=r}prebuild(t){if(void 0!==t){const e=this._sources.get(t);return void(e&&this._prebuildSource(t,e))}for(const[t,e]of this._sources)this._prebuildSource(t,e)}clear(t){if(void 0===t)return void this._indexCache.clear();const e=`${t}|`,i=[];for(const t of this._indexCache.keys())t.startsWith(e)&&i.push(t);for(const t of i)this._indexCache.delete(t)}_prebuildSource(t,e){if("topology"!==e.type)return;const i=e.getLayers(),r=e.getArcs(),n=e.getDataset?.();for(let e=0;e<i.length;e++)this._getOrBuildIndex(t,e,i[e],r,n)}_getOrBuildIndex(t,e,i,r,n){const s=i?.shapes;if(!s||0===s.length)return null;const o=r?.size?.()??0,a=n?.editVersion??0,l=`${t}|${e}|${s.length}|${o}|${a}`,c=this._indexCache.get(l);if(void 0!==c)return c;const h=`${t}|${e}|`,u=[];for(const t of this._indexCache.keys())t!==l&&t.startsWith(h)&&u.push(t);for(const t of u)this._indexCache.delete(t);const p="point"===i.geometry_type,d=new M(s.length),f=[];for(let t=0;t<s.length;t++){const e=s[t];if(!e){d.add(0,0,0,0);continue}let i=1/0,n=1/0,o=-1/0,a=-1/0;if(p)for(const t of rt(e))!t||t.length<2||(t[0]<i&&(i=t[0]),t[0]>o&&(o=t[0]),t[1]<n&&(n=t[1]),t[1]>a&&(a=t[1]));else if(r?.getSimpleShapeBbox){const t=e;for(let e=0;e<t.length;e++)r.getSimpleShapeBbox(t[e],f),f[0]<i&&(i=f[0]),f[1]<n&&(n=f[1]),f[2]>o&&(o=f[2]),f[3]>a&&(a=f[3])}i!==1/0?d.add(i,n,o,a):d.add(0,0,0,0)}d.finish();const m={index:d,shapeCount:s.length};return this._indexCache.set(l,m),m}query(t,e,i){const{width:r,height:n}=this._getSize(),s=Array.isArray(t),o=s?t:[[0,0],[r,n]],a=e||(s?{}:t)||{};if(Array.isArray(o)&&"number"==typeof o[0]){const t=o;return this._queryFeaturesAtPoint(t,a,i)}const l=o;return this._queryFeaturesInBBox(l,a,i)}_layerMatchesFilter(t,e,i){if(!i||0===i.length)return!0;const r=it(t,e);return!!i.includes(r)||(!(!t?.name||!i.includes(t.name))||!(!t?.id||!i.includes(t.id)))}_unproject(t,e){return this._getTransform().unproject(t,e)}_getHitBuffer(t){return t/Math.abs(this._getTransform().mx||1)}_getZoomAdjustedHitBuffer(t,e){const i=this._getTransform(),r=this._getInitialMX(),n=Math.abs(i.mx)/(r||Math.abs(i.mx)||1);return n<1&&(t*=n),e>0&&t<e&&(t=e),this._getHitBuffer(t)}_findHitCandidates(t,e,i,r,n,s,o,a){const l=[],c={},h=[],u=i.shapes;if(!u)return l;const p=this._getOrBuildIndex(t,e,i,r,a),d=p?p.index.search(n-o,s-o,n+o,s+o):null,f=null!==d?d.length:u.length;for(let t=0;t<f;t++){const e=null!==d?d[t]:t,i=u[e];if(i)for(let t=0;t<i.length;t++){const a=i[t];if(r.getSimpleShapeBbox(a,h),n+o<h[0]||n-o>h[2]||s+o<h[1]||s-o>h[3])continue;let u=c[e];u||(u=c[e]={shape:[],id:e,dist:0},l.push(u)),u.shape.push(a)}}return l}_sortByDistance(e,i,r,n){const s=t.geom;for(const t of r)t.info=s.getPointToShapeInfo(e,i,t.shape,n),t.dist=t.info.distance;r.sort((t,e)=>t.dist-e.dist)}_pickNearestCandidates(t,e,i){const r=[];let n=0;for(let s=0;s<t.length;s++){const o=t[s];if(!(o.dist<i))break;if(0===s)n=o.dist;else if(o.dist-n>e)break;r.push(o)}return r}_pointTest(e,i,r,n,s,o){const a=t.geom,l=Math.abs(this._getTransform().mx||1);let c=-1,h=1/0,u=25;const p=r.shapes;if(!p)return[];const d=u/(l||1),f=this._getOrBuildIndex(e,i,r,void 0,o),m=f?f.index.search(n-d,s-d,n+d,s+d):null,_=null!==m?m.length:p.length;for(let t=0;t<_;t++){const e=null!==m?m[t]:t,i=p[e];if(i)for(const t of rt(i)){if(!t)continue;const i=a.distance2D(n,s,t[0],t[1])*l;i>u||(i<u&&u>2&&(u=Math.max(2,i)),i<h&&(h=i,c=e))}}return-1===c?[]:[c]}_polylineTest(t,e,i,r,n,s,o,a){const l=this._getZoomAdjustedHitBuffer(15,2),c=o>=0?o:.05,h=this._getZoomAdjustedHitBuffer(c,0);let u=this._findHitCandidates(t,e,i,r,n,s,l,a);return this._sortByDistance(n,s,u,r),u=this._pickNearestCandidates(u,h,l),u.length?[u[0].id]:[]}_polygonTest(e,i,r,n,s,o,a){const l=t.geom,c=this._getZoomAdjustedHitBuffer(10,1),h=this._findHitCandidates(e,i,r,n,s,o,c,a);let u=[];for(const t of h)l.testPointInPolygon(s,o,t.shape,n)&&u.push(t);return h.length>0&&0===u.length?(this._sortByDistance(s,o,h,n),u=this._pickNearestCandidates(h,0,c)):u.length>1&&this._sortByDistance(s,o,u,n),u.length?[u[0].id]:[]}_polygonVertexTest(t,e,i,r,n,s,o){const a=this._polygonTest(t,e,i,r,n,s,o),l=this._polylineTest(t,e,i,r,n,s,5,o);return a.length?a:l}_queryFeaturesAtPoint(t,e,i){const r=this._getTransform(),n=[],[s,o]=this._unproject(t[0],t[1]),a=1/Math.abs(r.mx||1);for(const[t,r]of this._sources){const l=r.getLayers(),c=r.getDisplayArcs(),h=c?c.getScaledArcs(a):r.getArcs(),u=r.getDataset?.();for(let r=0;r<l.length;r++){const a=l[r];if(!a?.shapes)continue;if(!this._layerMatchesFilter(a,r,e.layers))continue;const c=it(a,r);if(i&&!i.has(`${t}:${c}`))continue;const p=a.geometry_type;let d=[];if("point"===p?d=this._pointTest(t,r,a,s,o,u):"polyline"===p&&h?d=this._polylineTest(t,r,a,h,s,o,-1,u):"polygon"===p&&h&&(d=this._polygonVertexTest(t,r,a,h,s,o,u)),0!==d.length)for(const e of d){const i=a.data,r=i?.getRecordAt?.(e)??i?.getRecords?.()?.[e]??{};n.push({id:e,source:t,layer:c,geometryType:p||"unknown",properties:{...r}})}}}return n}_queryFeaturesInBBox(t,e,i){const r=this._getTransform(),n=[],[s,o]=t,a=this._unproject(s[0],s[1]),l=this._unproject(o[0],o[1]),c=Math.min(a[0],l[0]),h=Math.min(a[1],l[1]),u=Math.max(a[0],l[0]),p=Math.max(a[1],l[1]),d=1/Math.abs(r.mx||1);for(const[t,r]of this._sources){const s=r.getLayers(),o=r.getDisplayArcs(),a=o?o.getScaledArcs(d):r.getArcs(),l=r.getDataset?.();for(let r=0;r<s.length;r++){const o=s[r];if(!o?.shapes)continue;if(!this._layerMatchesFilter(o,r,e.layers))continue;const d=it(o,r);if(i&&!i.has(`${t}:${d}`))continue;const f=o.geometry_type,m=o.data,_=[],g=this._getOrBuildIndex(t,r,o,a,l),y=g?g.index.search(c,h,u,p):null,v=null!==y?y.length:o.shapes.length;for(let e=0;e<v;e++){const i=null!==y?y[e]:e,r=o.shapes[i];if(!r)continue;let s=!1;if("point"===f)s=rt(r).some(t=>t[0]>=c&&t[0]<=u&&t[1]>=h&&t[1]<=p);else if(a){const t=r;for(let e=0;e<t.length;e++)if(a.getSimpleShapeBbox(t[e],_),!(u<_[0]||c>_[2]||p<_[1]||h>_[3])){s=!0;break}}if(!s)continue;const l=m?.getRecordAt?.(i)??m?.getRecords?.()?.[i]??{};n.push({id:i,source:t,layer:d,geometryType:f||"unknown",properties:{...l}})}}}return n}}class Fi{_host;constructor(t){this._host=t}get(t){const e=this._host.layers.resolve(t.source,t.layer);if(!e)return null;if(!Number.isInteger(t.id)||t.id<0)return null;const i=e.shapes??null;if(!i||t.id>=i.length)return null;const r=i[t.id],n=e.data?.getRecords?.()??[];return{ref:t,geometry:r,properties:Object.freeze({...n[t.id]??{}})}}*iter(t,e){const i=this._host.layers.resolve(t,e);if(!i||!i.shapes)return;const r=i.shapes,n=i.data?.getRecords?.()??[];for(let i=0;i<r.length;i++)yield{ref:{source:t,layer:e,id:i},geometry:r[i],properties:Object.freeze({...n[i]??{}})}}count(t,e){const i=this._host.layers.resolve(t,e);return i?.shapes?.length??0}}class Bi{_all=new globalThis.Set;get size(){return this._all.size}register(t){return this._all.add(t),()=>{this._all.delete(t)}}unregisterAll(){this._all.clear()}async runFor(t,e,i){if(0===this._all.size)return[];const r=[];for(const e of this._all)e.phase===t&&r.push(e);if(0===r.length)return[];const n=await Promise.allSettled(r.map(t=>t.run(e,i))),s=[];for(let t=0;t<r.length;t++){const e=r[t],i=n[t];let o;o="fulfilled"===i.status?i.value:{ok:!1,issues:[{severity:"error",message:`validator '${e.name}' threw: ${i.reason instanceof Error?i.reason.message:String(i.reason)}`}]},s.push({validator:e.name,report:o})}return s}}class Oi{_highlighted=new globalThis.Map;_highlightStyle={color:"#ff7a00",width:2.2,radius:6,fill:!0};get size(){return this._highlighted.size}setHighlightedFeatures(t,e){this._highlighted.clear(),e&&(this._highlightStyle={...this._highlightStyle,...e});for(const e of t){const t=this._highlighted.get(e.source)||new globalThis.Map,i=t.get(e.layer)||new Set;i.add(e.id),t.set(e.layer,i),this._highlighted.set(e.source,t)}}clearHighlightedFeatures(){return 0!==this._highlighted.size&&(this._highlighted.clear(),!0)}setHighlightStyle(t){return this._highlightStyle={...this._highlightStyle,...t},this._highlighted.size>0}renderHighlights(t,e,i,r,n){if(0===this._highlighted.size)return;const s=this._highlightStyle.color||"#ff7a00",o=(this._highlightStyle.width??2.2)*r,a=this._highlightStyle.radius??6,l=!1!==this._highlightStyle.fill,c=1/Math.abs(i.mx||1);for(const[i,r]of e){const e=this._highlighted.get(i);if(!e)continue;const h=r.getLayers(),u=r.getDisplayArcs(),p=u?u.getScaledArcs(c):r.getArcs();for(let r=0;r<h.length;r++){const c=h[r];if(!c?.shapes)continue;const u=it(c,r);if(n&&!n.has(`${i}:${u}`))continue;const d=e.get(u);if(!d||0===d.size)continue;const f=[];for(const t of d){const e=c.shapes[t];e&&f.push(e)}0!==f.length&&("point"===c.geometry_type?t.drawPoints(f,{color:s,radius:a,fill:l}):p&&t.drawPaths(f,{color:s,width:o},p))}}}}class Ni{_byKey=new globalThis.Map;_size=0;get size(){return this._size}has(t){return this._byKey.get(t.source)?.get(t.layer)?.has(t.id)??!1}getAll(){const t=[];for(const[e,i]of this._byKey)for(const[r,n]of i)for(const i of n)t.push({source:e,layer:r,id:i});return t}getByLayer(t,e){const i=this._byKey.get(t)?.get(e);return i?Array.from(i):[]}clear(){if(0===this._size)return{added:[],removed:[],changed:!1};const t=this.getAll();return this._byKey.clear(),this._size=0,{added:[],removed:t,changed:!0}}apply(t,e){const i=Gi(t);if("replace"===e){const t=this._refSetSnapshot();this._byKey.clear(),this._size=0;for(const t of i)this._addOne(t);return qi(t,this._refSetSnapshot())}const r=[],n=[];if("add"===e)for(const t of i)this._addOne(t)&&r.push(t);else for(const t of i)this.has(t)?this._removeOne(t)&&n.push(t):this._addOne(t)&&r.push(t);return{added:r,removed:n,changed:r.length>0||n.length>0}}remove(t){const e=[];for(const i of Gi(t))this._removeOne(i)&&e.push(i);return{added:[],removed:e,changed:e.length>0}}snapshot(){return this._refSetSnapshot()}restore(t){const e=this._refSetSnapshot();this._byKey.clear(),this._size=0;for(const e of t)this._addOne(ji(e));return qi(e,t)}_addOne(t){let e=this._byKey.get(t.source);e||(e=new globalThis.Map,this._byKey.set(t.source,e));let i=e.get(t.layer);return i||(i=new Set,e.set(t.layer,i)),!i.has(t.id)&&(i.add(t.id),this._size++,!0)}_removeOne(t){const e=this._byKey.get(t.source),i=e?.get(t.layer);return!!i?.has(t.id)&&(i.delete(t.id),this._size--,0===i.size&&(e.delete(t.layer),0===e.size&&this._byKey.delete(t.source)),!0)}_refSetSnapshot(){const t=new Set;for(const[e,i]of this._byKey)for(const[r,n]of i)for(const i of n)t.add(Vi(e,r,i));return t}}function Vi(t,e,i){return JSON.stringify([t,e,i])}function ji(t){const[e,i,r]=JSON.parse(t);return{source:e,layer:i,id:r}}function qi(t,e){const i=[],r=[];for(const r of e)t.has(r)||i.push(ji(r));for(const i of t)e.has(i)||r.push(ji(i));return{added:i,removed:r,changed:i.length>0||r.length>0}}function Gi(t){const e=new Set,i=[];for(const r of t){const t=Vi(r.source,r.layer,r.id);e.has(t)||(e.add(t),i.push(r))}return i}class Ui{_undoStack=[];_redoStack=[];_maxSize;_lastSkippedStale=!1;_captureBuffer=null;constructor(t={}){if(this._maxSize=t.maxSize??200,this._maxSize<1)throw new Error("EditHistory: maxSize must be >= 1")}push(t){if(this._captureBuffer)return void this._captureBuffer.push(t);const e=this._undoStack[this._undoStack.length-1];if(e&&!e.stale&&e.merge&&t.mergeable?.(e))return e.merge(t),void(this._redoStack.length=0);if(t.invalidatesPriorCommands){for(const t of this._undoStack)t.stale=!0;this._redoStack.length=0}this._undoStack.push(t),this._redoStack.length=0,this._undoStack.length>this._maxSize&&this._undoStack.shift()}beginCapture(){if(this._captureBuffer)throw new Error("EditHistory: nested capture not supported");this._captureBuffer=[]}endCapture(){const t=this._captureBuffer;return this._captureBuffer=null,t??[]}isCapturing(){return null!==this._captureBuffer}undo(){const t=this._undoStack.pop();return t?(t.stale?this._lastSkippedStale=!0:(t.undo(),this._lastSkippedStale=!1),this._redoStack.push(t),t):null}redo(){const t=this._redoStack.pop();return t?(t.stale?this._lastSkippedStale=!0:(t.do(),this._lastSkippedStale=!1),this._undoStack.push(t),t):null}clear(){this._undoStack.length=0,this._redoStack.length=0,this._lastSkippedStale=!1}canUndo(){return this._undoStack.length>0}canRedo(){return this._redoStack.length>0}size(){return this._undoStack.length}snapshot(){const t=this._undoStack[this._undoStack.length-1];let e=0;for(const t of this._undoStack)t.stale&&e++;const i={canUndo:this._undoStack.length>0,canRedo:this._redoStack.length>0,label:t?.label,staleCount:e,topIsStale:!!t?.stale};return this._lastSkippedStale&&(i.skippedStale=!0),i}}class $i{_host;_datasetSnapshots=new globalThis.Map;_selectionSnapshot;_closed=!1;constructor(t){if(t._activeTransaction)throw new Error("Transaction: another transaction is already active");this._host=t,this._selectionSnapshot=t._selection.snapshot(),t._history.beginCapture(),t._activeTransaction=this}_captureFirstTouch(t,e){this._datasetSnapshots.has(t)||this._datasetSnapshots.set(t,e)}get isOpen(){return!this._closed}async commit(t){this._end();const e=this._host._history.endCapture();if(0===e.length)return at;const i=new zt(e,t);return this._host._history.push(i),this._host._fireHistoryChange(),at}rollback(){this._end(),this._host._history.endCapture();for(const[t,e]of this._datasetSnapshots){const i=this._host._sources.get(t);i&&i.setDataset(e)}const t=this._host._selection.restore(this._selectionSnapshot);t.changed&&this._host._fireSelectionChange(t),this._host._fireHistoryChange(),this._host._scheduleRender()}_end(){if(this._closed)throw new Error("Transaction: already committed or rolled back");this._closed=!0,this._host._activeTransaction=null}}class Zi{opts;label="Delete feature";constructor(t){this.opts=t}do(){const{layer:t,featureId:e}=this.opts;if(!t.shapes)return;t.shapes.splice(e,1);const i=t.data?.getRecords?.();i?.splice(e,1)}undo(){const{layer:t,featureId:e,shape:i,record:r}=this.opts;if(t.shapes||(t.shapes=[]),t.shapes.splice(e,0,i),null!==r){const i=t.data?.getRecords?.();i?.splice(e,0,r)}}}class Wi{opts;label;constructor(t){this.opts=t,this.label=`Delete ${t.snapshots.length} feature${1===t.snapshots.length?"":"s"}`}do(){const{layer:t,snapshots:e}=this.opts;if(!t.shapes||0===e.length)return;const i=new Set;for(const t of e)i.add(t.id);const r=t.shapes,n=new Array(r.length-i.size);let s=0;for(let t=0;t<r.length;t++)i.has(t)||(n[s++]=r[t]);t.shapes=n;const o=t.data?.getRecords?.();if(o){let t=0;for(let e=0;e<o.length;e++)i.has(e)||(o[t++]=o[e]);o.length=t}}undo(){const{layer:t,snapshots:e}=this.opts;t.shapes||(t.shapes=[]);const i=[...e].sort((t,e)=>t.id-e.id),r=t.data?.getRecords?.();for(const e of i)t.shapes.splice(e.id,0,e.shape),r&&null!==e.record&&r.splice(e.id,0,e.record)}}function Hi(t,e){const i=t||{};return{color:i["line-color"]||i["fill-color"]||"#333",width:(i["line-width"]??.8)*e}}function Xi(t){const e=t||{};return{color:e["circle-color"]||"#333",radius:e["circle-radius"]??4,fill:!1!==e["circle-fill"]}}class Yi extends G{_container;_canvasContainer;_canvas;_painter;_editOverlay;_viewport=new X;_projection=new et;_sources=new globalThis.Map;_layersCache;get layers(){return this._layersCache??(this._layersCache=new St(this._sources))}_sourceListeners=new globalThis.Map;_layers=[];_effectiveLayersCache=[];_defaultLayersDirty=!0;_layerArcFlagsCache=new globalThis.Map;_mouseWheel;_dragPan;_pendingRender=0;_rafId=0;_controlContainers=new globalThis.Map;_controls=[];_highlightManager=new Oi;_featureQuery;features;_selection=new Ni;_history=new Ui;_activeTransaction=null;_validators=new Bi;get validators(){return this._validators}_historyShortcutUnbind=null;_ops;_editSession;_attributes;get ops(){return this._ops??(this._ops=new kt(this))}get editSession(){return this._editSession??(this._editSession=new Ht(this))}get attributes(){return this._attributes??(this._attributes=new ee(this))}_editState=new ie(t=>{t.modeChanged&&(this._dragPan?.setEnabled("none"===t.current.mode),this.fire("editmodechange",{mode:t.current.mode})),this._scheduleRender()});_workerPool=null;_workerMode=!1;_workerThreshold=5e4;_workerRouting;_expressionPolicy="disabled";constructor(t){if(super(),"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container #${t.container} not found`);this._container=e}else this._container=t.container;this._canvasContainer=this._createCanvasContainer(),this._container.appendChild(this._canvasContainer),this._canvas=document.createElement("canvas"),this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0",this._canvasContainer.appendChild(this._canvas),this._painter=new nt(this._canvas),this._painter.setPixelRatio(window.devicePixelRatio||1),this._editOverlay=new st(this._painter),this._updateSize(),this._viewport.onViewChange=()=>this.fire("move"),this._viewport.initZoomTween(),this._mouseWheel=new ki(this._canvasContainer),this._dragPan=new zi(this._canvasContainer),this._featureQuery=new Li(this._sources,()=>this._viewport.transform,()=>({width:this._viewport.width,height:this._viewport.height}),()=>this._viewport.initialMX),this.features=new Fi(this),this._attachEventListeners(),this.on("move",()=>this._scheduleRender()),this.on("resize",()=>this._scheduleRender()),this.on("reset",()=>this.reset()),this.on("historychange",()=>this._runAfterCommitValidators()),this._expressionPolicy=t.expressionPolicy??"disabled",this._workerMode=t.useWorker??!1,"number"==typeof t.workerThreshold&&t.workerThreshold>=0&&(this._workerThreshold=t.workerThreshold),this._workerRouting=t.workerRouting,(!1!==this._workerMode||t.workerPool)&&(t.workerPool?this._workerPool=t.workerPool:this._workerPool=new Ri({workerUrl:t.workerUrl??"emap-worker.js",poolSize:t.workerPoolSize}))}cancelWorkerJobs(){this._workerPool?.cancelAll()}setExpressionPolicy(t){this._expressionPolicy=t}getExpressionPolicy(){return this._expressionPolicy??"disabled"}_allowExpressionEvaluation(t,e){return!t.some(t=>"string"==typeof t&&t.trim().length>0)||"trusted"===this.getExpressionPolicy()||(this.fire("error",{error:new Error(`${e}: expression evaluation is disabled`)}),!1)}getCanvasContainer(){return this._canvasContainer}getEditMode(){return this._editState.mode}setEditMode(t){this._editState.setMode(t)}setEditVertexState(t){this._editState.setVertex(t)}clearEditVertexState(){this._editState.clearVertex()}setEditDrawState(t){this._editState.setDraw(t)}clearEditDrawState(){this._editState.clearDraw()}_attachEventListeners(){this._dragPan.on("pan",t=>{this._viewport.pan(t.dx,t.dy),this.fire("move")}),this._dragPan.on("panstart",()=>{this._viewport.cancelZoomAnimation()}),this._mouseWheel.on("mousewheel",t=>{this._viewport.applyWheelZoom(t.direction,t.multiplier,t.x,t.y),this.fire("move")})}_createCanvasContainer(){const t=document.createElement("div");t.style.position="relative",t.style.width="100%",t.style.height="100%",t.style.overflow="hidden",t.className="emap-canvas-container";const e=["top-left","top-right","bottom-left","bottom-right"];for(const i of e){const e=document.createElement("div");e.className=`emap-ctrl-${i}`,e.style.position="absolute",e.style.pointerEvents="none",e.style.zIndex="10";const[r,n]=i.split("-");e.style[r]="10px",e.style[n]="10px",e.style.display="flex",e.style.flexDirection="column",e.style.gap="8px";const s=t=>t.stopPropagation();for(const t of["click","mousedown","mouseup","dblclick","contextmenu"])e.addEventListener(t,s);e.addEventListener("wheel",s,{passive:!0}),t.appendChild(e),this._controlContainers.set(i,e)}return t}_updateSize(){const t=this._container.clientWidth,e=this._container.clientHeight;this._viewport.updateSize(t,e),this._painter.resize(t,e)}addSource(t,e){this._sources.set(t,e);const i=i=>{if(1===this._sources.size&&e.getCRS){const t=e.getCRS();t&&this._projection.crs!==t&&(this._projection.setCRS(t),this._viewport.setCRS(t),this.fire("crschange"))}this.fire("data",{sourceId:t,...i}),this._defaultLayersDirty=!0,this._layerArcFlagsCache.clear(),this._scheduleRender()};this._sourceListeners.set(t,i),e.on("data",i),e.getDataset&&e.getDataset()&&i({type:"data"})}removeSource(t){const e=this._sources.get(t);if(e){const i=this._sourceListeners.get(t);i&&(e.off("data",i),this._sourceListeners.delete(t)),this._sources.delete(t),this._defaultLayersDirty=!0,this._layerArcFlagsCache.delete(t);for(const e of this._layerArcFlagsCache.keys())e.startsWith(`${t}:`)&&this._layerArcFlagsCache.delete(e);this._scheduleRender()}}getSource(t){return this._sources.get(t)}async exportSnapshot(t={}){const e=!1!==t.compact,i=[],r=[];for(const[t,e]of this._sources){if("topology"!==e.type)continue;const n=e.getDataset?.();n&&(i.push(t),r.push(n))}const n=J(),s=await n.exportDatasetsToPack(r,{compact:e});s.emap={version:1,sources:i.map(t=>({id:t}))};const o=n.pack(s);return new Blob([o],{type:"application/octet-stream"})}async loadSnapshot(t,e={}){const i=!1!==e.replace,r=e.idPrefix??"",n=e.defaultIds??[];let s;if(t instanceof Uint8Array)s=t;else if(t instanceof ArrayBuffer)s=new Uint8Array(t);else{if(!("undefined"!=typeof Blob&&t instanceof Blob))throw new Error("loadSnapshot: input must be Blob, Uint8Array, or ArrayBuffer");s=new Uint8Array(await t.arrayBuffer())}if(!function(t){if(!t||0===t.length)return!1;const e=t[0];return e>=128&&e<=143||222===e||223===e}(s))throw new Error("loadSnapshot: input does not look like a mapshaper .msx snapshot (expected msgpack map marker as the first byte)");const o=await J().unpackSessionData(s),a=o.datasets??[],l=o.emap,c=l?.sources?.map(t=>t?.id).filter(t=>"string"==typeof t)??[],h=a.map((t,e)=>{const i=c[e],s=n[e]??`snapshot-${e}`;return r+(i??s)});if(!i)for(const t of h)if(this._sources.has(t))throw new Error(`loadSnapshot: source "${t}" already exists (pass { replace: true } to overwrite)`);this._history.clear(),this._fireSelectionChange(this._selection.clear()),this.fire("historychange");const u=[];for(let t=0;t<a.length;t++){const e=h[t];i&&this._sources.has(e)&&this.removeSource(e);const r=new Pi(e);r.setDataset(a[t]),this.addSource(e,r),u.push(e)}return u}addLayer(t,e){if(!this._sources.has(t.source))throw new Error(`Source "${t.source}" not found`);if(this._layers.some(e=>e.id===t.id))throw new Error(`Layer "${t.id}" already exists`);if(e){const i=this._layers.findIndex(t=>t.id===e);if(-1===i)throw new Error(`Layer "${e}" not found`);this._layers.splice(i,0,{...t})}else this._layers.push({...t});this._defaultLayersDirty=!0,this._scheduleRender()}removeLayer(t){const e=this._layers.findIndex(e=>e.id===t);-1!==e&&(this._layers.splice(e,1),this._defaultLayersDirty=!0,this._scheduleRender())}getLayer(t){return this._layers.find(e=>e.id===t)}getLayers(){return[...this._layers]}setLayerVisibility(t,e){const i=this._layers.find(e=>e.id===t);i&&(i.layout||(i.layout={}),i.layout.visibility=e,this._scheduleRender())}setPaintProperty(t,e,i){const r=this._layers.find(e=>e.id===t);r&&(r.paint||(r.paint={}),r.paint[e]=i,this._scheduleRender())}moveLayer(t,e){const i=this._layers.findIndex(e=>e.id===t);if(-1===i)return;const[r]=this._layers.splice(i,1);if(e){const t=this._layers.findIndex(t=>t.id===e);-1===t?this._layers.push(r):this._layers.splice(t,0,r)}else this._layers.push(r);this._defaultLayersDirty=!0,this._scheduleRender()}_getEffectiveLayers(){if(this._layers.length>0)return this._layers;if(!this._defaultLayersDirty)return this._effectiveLayersCache;const t=[];for(const[e,i]of this._sources){const r=i.getLayers();if(0===r.length)t.push({id:`${e}:default`,type:"line",source:e,paint:{"line-color":"#333","line-width":.8}});else for(let i=0;i<r.length;i++){const n=r[i],s=it(n,i),o=n.geometry_type;t.push({id:`${e}:${s}`,type:"point"===o?"circle":"line",source:e,"source-layer":s,paint:"point"===o?{"circle-color":"#333","circle-radius":4}:{"line-color":"#333","line-width":.8}})}}return this._effectiveLayersCache=t,this._defaultLayersDirty=!1,t}_resolveSourceLayer(t,e){const i=t.getLayers();if(!i.length)return null;if(!e)return i[0];for(let t=0;t<i.length;t++){if(it(i[t],t)===e)return i[t]}return null}_getLayerArcFlags(t,e,i){if(!t||!t.shapes||!e)return null;let r=this._layerArcFlagsCache.get(i);if(r)return r;const n=e.size();r=new Uint8Array(n);const s=t.shapes;for(const t of s)if(t)for(const e of t)for(const t of e){r[t>=0?t:~t]=1}return this._layerArcFlagsCache.set(i,r),r}_getVisibleLayerKeys(){const t=new Set,e=this._getEffectiveLayers();for(const i of e){if("none"===i.layout?.visibility)continue;const e=this._sources.get(i.source);if(!e)continue;const r=this._resolveSourceLayer(e,i["source-layer"]);if(r){const n=e.getLayers().indexOf(r),s=it(r,n>=0?n:0);t.add(`${i.source}:${s}`)}}return t}getPainter(){return this._painter}getCRS(){return this._projection.crs}setCRS(t){this._projection.setCRS(t),this._viewport.setCRS(t),this.fire("crschange")}async reproject(t){if(this._projection.crs===t)return;const e=await this._projection.reproject(t,this._sources);this._viewport.setCRS(t),this._viewport.clearInitialState(),e.hasBounds()&&this.setExtent(e),this.fire("crschange"),this.fire("data",{reason:"reproject"})}getCenter(){const t=this._viewport.transform,e=(this._viewport.width/2-t.bx)/t.mx,i=(this._viewport.height/2-t.by)/t.my;return this._projection.getCenter(e,i)}getZoom(){return this._projection.getZoom(Math.abs(this._viewport.transform.mx))}getTransform(){return this._viewport.transform}getExtent(){return this._viewport.extent}setExtent(t){this._viewport.setExtent(t),this.fire("move")}reset(){this._viewport.reset()}addControl(t,e="top-left"){const i=t.onAdd(this);i.style.pointerEvents="auto",this._controlContainers.get(e)?.appendChild(i),this._controls.push(t)}removeControl(t){t.onRemove(this);const e=this._controls.indexOf(t);-1!==e&&this._controls.splice(e,1)}zoomIn(){this._viewport.zoomIn()}zoomOut(){this._viewport.zoomOut()}_scheduleRender(){this._removed||(this._pendingRender++,0===this._rafId&&(this._rafId=requestAnimationFrame(()=>this._doRender())))}_doRender(){this._rafId=0,this._pendingRender>0&&(this._pendingRender=0,this.render())}render(){const t=this._viewport.transform;this._painter.setTransform(t),this._painter.clear();const e=this._viewport.getLineScale(),i=1/Math.abs(t.mx);this._renderLayers(i,e),this._renderHighlight(t,e),this._editOverlay.render(this._editState.mode,this._editState.vertex,this._editState.draw)}_renderLayers(t,e){const i=this._getEffectiveLayers();for(const r of i){if("none"===r.layout?.visibility)continue;const i=this._sources.get(r.source);if(!i)continue;const n=i.getDisplayArcs(),s=n?n.getScaledArcs(t):i.getArcs();if(s&&s.setRetainedInterval&&("function"!=typeof s.isFlat||!s.isFlat())){const e=i.getSimplifyFloor?.()??0;s.setRetainedInterval(Math.max(e,.5*t))}const o=this._resolveSourceLayer(i,r["source-layer"]),a=`${r.source}:${r["source-layer"]||"default"}`;if("line"===r.type&&s)this._renderLineLayer(r,o,s,a,e);else if("fill"===r.type&&s&&o?.shapes)this._renderFillLayer(r,o,s,a,e);else if("circle"===r.type&&o?.shapes){const t=Xi(r.paint);this._painter.drawPoints(o.shapes,t)}}}_renderLineLayer(t,e,i,r,n){const s=Hi(t.paint,n);if(e?.shapes){const t=this._getLayerArcFlags(e,i,r),n=this._combineArcFilters(t,this._viewport.getArcFilter(i));this._painter.drawArcs(i,s,n)}else this._painter.drawArcs(i,s,this._viewport.getArcFilter(i))}_renderFillLayer(t,e,i,r,n){const s=t.paint,o=s?.["fill-color"]||"rgba(200, 200, 200, 0.4)",a=s?.["fill-opacity"],l=this._viewport.getArcFilter(i);this._painter.drawPolygonFill(e.shapes,i,o,l,a);const c=Hi(t.paint,n),h=this._getLayerArcFlags(e,i,r);this._painter.drawArcs(i,c,this._combineArcFilters(h,l))}_combineArcFilters(t,e){return t&&e?i=>1===t[i]&&e(i):t?e=>1===t[e]:e}_renderHighlight(t,e){const i=this._getVisibleLayerKeys();this._highlightManager.renderHighlights(this._painter,this._sources,t,e,i)}project(t,e){return this._viewport.project(t,e)}unproject(t,e){return this._viewport.unproject(t,e)}resize(){this._updateSize(),this._viewport.setExtent(this._viewport.extent),this.fire("resize")}queryFeatures(t,e){const i=this._getVisibleLayerKeys();return this._featureQuery.query(t,e,i)}prebuildSpatialIndex(t){this._featureQuery.prebuild(t)}clearSpatialIndex(t){this._featureQuery.clear(t)}_clearSpatialIndexesForSources(t){for(const e of t)this._featureQuery?.clear(e)}setHighlightedFeatures(t,e){this._highlightManager.setHighlightedFeatures(t,e),this._scheduleRender()}clearHighlightedFeatures(){this._highlightManager.clearHighlightedFeatures()&&this._scheduleRender()}setHighlightStyle(t){this._highlightManager.setHighlightStyle(t)&&this._scheduleRender()}select(t,e){const i=e?.mode??"replace",r=this._selection.apply(t,i);this._fireSelectionChange(r)}deselect(t){const e=this._selection.remove(t);this._fireSelectionChange(e)}clearSelection(){const t=this._selection.clear();this._fireSelectionChange(t)}getSelection(){return this._selection.getAll()}isSelected(t){return this._selection.has(t)}_fireSelectionChange(t){t.changed&&this.fire("selectionchange",{selected:this._selection.getAll(),added:t.added,removed:t.removed})}deleteSelected(){const t=this._selection.getAll();if(0===t.length)return!1;const e=new globalThis.Map;for(const i of t){let t=e.get(i.source);t||(t=new globalThis.Map,e.set(i.source,t));const r=t.get(i.layer)??[];r.push(i.id),t.set(i.layer,r)}const i=[];let r=0;for(const[t,n]of e){const e=this._sources.get(t);if(!e)continue;const s=e.getLayers();for(const[t,e]of n){let n=null;for(let e=0;e<s.length;e++)if(it(s[e],e)===t){n=s[e];break}if(!n?.shapes)continue;const o=n.data?.getRecords?.(),a=[],l=new Set;for(const t of e){if(l.has(t))continue;l.add(t);const e=n.shapes[t];if(void 0===e)continue;const i=o?o[t]:null;a.push({id:t,shape:e,record:i??null})}if(0===a.length)continue;const c=new Wi({layer:n,snapshots:a});c.do(),i.push(c),r+=a.length}}if(0===i.length)return!1;const n=new zt(i,`Delete ${r} feature${r>1?"s":""}`);return this._history.push(n),this._fireHistoryChange(),this._invalidateShapeCachesForSources(e.keys()),this._fireSelectionChange(this._selection.clear()),this._scheduleRender(),!0}_invalidateShapeCachesForSources(t){for(const e of t){const t=`${e}:`;for(const e of this._layerArcFlagsCache.keys())e.startsWith(t)&&this._layerArcFlagsCache.delete(e);this._featureQuery?.clear(e)}}pushCommand(t){this._history.push(t),this._fireHistoryChange()}undo(){return!!this._history.undo()&&(this._fireHistoryChange(),this._invalidateAllShapeCaches(),this._scheduleRender(),!0)}redo(){return!!this._history.redo()&&(this._fireHistoryChange(),this._invalidateAllShapeCaches(),this._scheduleRender(),!0)}_invalidateAllShapeCaches(){this._layerArcFlagsCache.clear();for(const t of this._sources.keys())this._featureQuery?.clear(t)}canUndo(){return this._history.canUndo()}canRedo(){return this._history.canRedo()}clearHistory(){const t=this._history.canUndo()||this._history.canRedo();this._history.clear(),t&&this._fireHistoryChange()}beginTransaction(){return new $i(this)}bindHistoryShortcuts(t){this._historyShortcutUnbind?.();const e=t??this._canvasContainer;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1");const i=t=>{if(!(t.ctrlKey||t.metaKey))return;const e="z"===t.key||"Z"===t.key,i="y"===t.key||"Y"===t.key;e&&!t.shiftKey?(t.preventDefault(),this.undo()):(e&&t.shiftKey||i)&&(t.preventDefault(),this.redo())};e.addEventListener("keydown",i);const r=()=>{e.removeEventListener("keydown",i),this._historyShortcutUnbind===r&&(this._historyShortcutUnbind=null)};return this._historyShortcutUnbind=r,r}_fireHistoryChange(){const t=this._history.snapshot();this.fire("historychange",t)}_runAfterCommitValidators(){if(0===this._validators.size)return;const t={label:this._history.snapshot().label??""};this._validators.runFor("after-commit",this,t).then(e=>{if(this._removed)return;const i=e.filter(t=>!t.report.ok);i.length>0&&this.fire("validationfailed",{results:i,label:t.label})})}_resolveLayer(t,e){return this.layers.resolve(t,e)}remove(){if(this._removed)return;this._removed=!0,0!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=0),this._pendingRender=0,this._dragPan.destroy(),this._mouseWheel.destroy(),this._historyShortcutUnbind?.(),this._historyShortcutUnbind=null,this._workerPool&&(this._workerPool.cancelAll(),this._workerPool.destroy(),this._workerPool=null);for(const[t,e]of this._sourceListeners){const i=this._sources.get(t);i?.off("data",e)}this._sourceListeners.clear();for(const t of this._sources.keys())this._featureQuery?.clear(t);this._layerArcFlagsCache.clear(),this._sources.clear();const t=this._controls??[];for(const e of[...t])try{e.onRemove(this)}catch(t){this.fire("error",{error:t})}t.length=0,this._controlContainers?.clear(),this._editState?.setMode("none"),this._container&&this._canvasContainer&&this._container.removeChild(this._canvasContainer)}_removed=!1}function Ki(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\0/g,"\\0")}"`}const Ji=/^[A-Za-z0-9_\-:.一-鿿][A-Za-z0-9_\-:. 一-鿿]*$/,Qi=/^[A-Za-z0-9_\-.一-鿿][A-Za-z0-9_\-. 一-鿿]*$/;function tr(t){return"string"==typeof t&&t.length>0&&Ji.test(t)}function er(t){return"string"==typeof t&&t.length>0&&Qi.test(t)}function ir(t){for(const e of t)if(!er(e))return"string"==typeof e?e:String(e);return null}function rr(t={}){const e=t.severity??"error";return{name:"topology",phase:"after-commit",async run(i){const r=J(),n=t.sources??Array.from(i._sources.keys()),s=[];for(const o of n){const n=i._sources.get(o)?.getDataset();if(!n||!n.arcs)continue;const a={};void 0!==t.tolerance&&(a.tolerance=t.tolerance);const l=r.findSegmentIntersections(n.arcs,a);l.length>0&&s.push({severity:e,message:`${o}: ${l.length} self-intersection${1===l.length?"":"s"}`})}return{ok:0===s.length,issues:s}}}}class nr{opts;label="Move vertex";_mergeAt=Date.now();constructor(t){this.opts=t}do(){(this.opts.adapter??J()).snapVertices(this.opts.vertexIds,this.opts.to,this.opts.arcs),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}undo(){(this.opts.adapter??J()).snapVertices(this.opts.vertexIds,this.opts.from,this.opts.arcs),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}mergeable(t){if(!(t instanceof nr))return!1;if(t.opts.source!==this.opts.source)return!1;if(Date.now()-t._mergeAt>500)return!1;const e=t.opts.vertexIds,i=this.opts.vertexIds;if(e.length!==i.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==i[t])return!1;return!0}merge(t){t instanceof nr&&(this.opts.to=t.opts.to,this._mergeAt=Date.now())}}class sr{opts;label="Insert vertex";constructor(t){this.opts=t}do(){(this.opts.adapter??J()).insertVertex(this.opts.arcs,this.opts.insertionId,this.opts.point),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}undo(){(this.opts.adapter??J()).deleteVertex(this.opts.arcs,this.opts.insertionId),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}class or{opts;label="Delete vertex";constructor(t){this.opts=t}do(){(this.opts.adapter??J()).deleteVertex(this.opts.arcs,this.opts.vertexIndex),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}undo(){(this.opts.adapter??J()).insertVertex(this.opts.arcs,this.opts.vertexIndex,this.opts.coords),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}class ar{opts;label;constructor(t){this.opts=t,this.label=`Draw ${t.geometryType}`}do(){const t=this.opts,e=t.adapter??J();if("point"!==t.geometryType){if(!t.arcs||!t.arcVertices)throw new Error("FeatureCreateCommand: path features require arcs and arcVertices");e.appendEmptyArc(t.arcs);for(const i of t.arcVertices)e.appendVertex(t.arcs,i)}if(t.layer.shapes||(t.layer.shapes=[]),t.layer.shapes.push(t.appendedShape),null!==t.appendedRecord){const e=t.layer.data?.getRecords?.();e?.push(t.appendedRecord)}t.source.markDisplayArcsDirty?.(),Ft(t.source.getDataset?.())}undo(){const t=this.opts,e=t.adapter??J();if(t.layer.shapes?.pop(),null!==t.appendedRecord){const e=t.layer.data?.getRecords?.();e?.pop()}"point"!==t.geometryType&&t.arcs&&e.deleteLastArc(t.arcs),t.source.markDisplayArcsDirty?.(),Ft(t.source.getDataset?.())}}class lr{_map=null;_container=null;_options;constructor(t={}){this._options={showZoom:!0,showHome:!0,...t}}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className=`emap-ctrl emap-ctrl-group ${this._options.className||""}`,this._options.showZoom&&(this._createButton("zoom-in","+","Zoom In",()=>{this._map?.zoomIn()}),this._createButton("zoom-out","-","Zoom Out",()=>{this._map?.zoomOut()})),this._options.showHome&&this._createButton("home","⌂","Reset View",()=>{this._map?.fire("reset")}),this._container}_createButton(t,e,i,r){const n=document.createElement("button");n.className=`emap-ctrl-${t}`,n.type="button",n.title=i;const s=document.createElement("span");s.className="emap-ctrl-icon",s.textContent=e,n.appendChild(s),n.addEventListener("click",r),this._container?.appendChild(n)}onRemove(){this._container&&this._container.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null}}class cr{_map=null;_container=null;_options;_mousePosEl=null;_epsgEl=null;_onMouseMoveBound;_onUpdateEPSGBound;_rafPending=!1;constructor(t={}){this._options={showMousePos:!0,showEPSG:!0,alignment:"left",...t},this._onMouseMoveBound=this._onMouseMove.bind(this),this._onUpdateEPSGBound=this._updateEPSG.bind(this)}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className=`emap-ctrl emap-status-ctrl emap-align-${this._options.alignment} ${this._options.className||""}`,this._options.showMousePos&&(this._mousePosEl=document.createElement("span"),this._mousePosEl.className="emap-status-mousepos",this._container.appendChild(this._mousePosEl)),this._options.showEPSG&&(this._epsgEl=document.createElement("span"),this._epsgEl.className="emap-status-epsg",this._container.appendChild(this._epsgEl),this._updateEPSG()),this._map.on("crschange",this._onUpdateEPSGBound),this._map.getCanvasContainer().addEventListener("mousemove",this._onMouseMoveBound),this._container}_onMouseMove(t){if(!this._map||!this._mousePosEl||!this._options.showMousePos)return;if(this._rafPending)return;this._rafPending=!0;const e=t.clientX,i=t.clientY;requestAnimationFrame(()=>{if(this._rafPending=!1,!this._map||!this._mousePosEl)return;const t=this._map.getCanvasContainer().getBoundingClientRect(),r=e-t.left,n=i-t.top,[s,o]=this._map.unproject(r,n);this._mousePosEl.textContent=` ${s.toFixed(4)}, ${o.toFixed(4)}`})}_updateEPSG(){if(!this._map||!this._epsgEl)return;const t=this._map.getCRS();this._epsgEl.textContent=` | ${t}`}onRemove(){this._map&&(this._map.getCanvasContainer().removeEventListener("mousemove",this._onMouseMoveBound),this._map.off("crschange",this._onUpdateEPSGBound)),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null}}var hr={exports:{}};
|
|
2
|
-
/**
|
|
3
|
-
* MapLibre GL JS
|
|
4
|
-
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.17.0/LICENSE.txt
|
|
5
|
-
*/hr.exports=function(){var t={},e={};function i(i,r,n){if(e[i]=n,"index"===i){var s="var sharedModule = {}; ("+e.shared+")(sharedModule); ("+e.worker+")(sharedModule);",o={};return e.shared(o),e.index(t,o),"undefined"!=typeof window&&t.setWorkerUrl(window.URL.createObjectURL(new Blob([s],{type:"text/javascript"}))),t}}return i("shared",["exports"],function(t){function e(t,e,i,r){return new(i||(i=Promise))(function(n,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})}function i(t,e){this.x=t,this.y=e}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,s;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){const e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){const 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(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){const t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){const e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround(t,e){const i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(t){if(t instanceof i)return t;if(Array.isArray(t))return new i(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new i(+t.x,+t.y);throw new Error("Expected [x, y] or {x, y} point format")};var o=function(){if(s)return n;function t(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}return s=1,n=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=n/s}var o=0,a=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},n}(),a=r(o);let l,c;function h(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function u(){if(null==c&&(c=!1,h())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<t*t;i++){const r=4*i;e.fillStyle=`rgb(${r},${r+1},${r+2})`,e.fillRect(i%t,Math.floor(i/t),1,1)}const i=e.getImageData(0,0,t,t).data;for(let e=0;e<t*t*4;e++)if(e%4!=3&&i[e]!==e){c=!0;break}}}return c||!1}var p=1e-6,d="undefined"!=typeof Float32Array?Float32Array:Array;function f(){var t=new d(9);return d!=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}function m(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 _(){var t=new d(3);return d!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function g(t){var e=t[0],i=t[1],r=t[2];return Math.sqrt(e*e+i*i+r*r)}function y(t,e,i){var r=new d(3);return r[0]=t,r[1]=e,r[2]=i,r}function v(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function x(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function b(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[0],a=i[1],l=i[2];return t[0]=n*l-s*a,t[1]=s*o-r*l,t[2]=r*a-n*o,t}var w,S=g;function T(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*s+i[12]*o,t[1]=i[1]*r+i[5]*n+i[9]*s+i[13]*o,t[2]=i[2]*r+i[6]*n+i[10]*s+i[14]*o,t[3]=i[3]*r+i[7]*n+i[11]*s+i[15]*o,t}function C(){var t=new d(4);return d!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function M(t,e,i,r){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",s=Math.PI/360;e*=s,r*=s,i*=s;var o=Math.sin(e),a=Math.cos(e),l=Math.sin(i),c=Math.cos(i),h=Math.sin(r),u=Math.cos(r);switch(n){case"xyz":t[0]=o*c*u+a*l*h,t[1]=a*l*u-o*c*h,t[2]=a*c*h+o*l*u,t[3]=a*c*u-o*l*h;break;case"xzy":t[0]=o*c*u-a*l*h,t[1]=a*l*u-o*c*h,t[2]=a*c*h+o*l*u,t[3]=a*c*u+o*l*h;break;case"yxz":t[0]=o*c*u+a*l*h,t[1]=a*l*u-o*c*h,t[2]=a*c*h-o*l*u,t[3]=a*c*u+o*l*h;break;case"yzx":t[0]=o*c*u+a*l*h,t[1]=a*l*u+o*c*h,t[2]=a*c*h-o*l*u,t[3]=a*c*u-o*l*h;break;case"zxy":t[0]=o*c*u-a*l*h,t[1]=a*l*u+o*c*h,t[2]=a*c*h+o*l*u,t[3]=a*c*u-o*l*h;break;case"zyx":t[0]=o*c*u-a*l*h,t[1]=a*l*u+o*c*h,t[2]=a*c*h-o*l*u,t[3]=a*c*u+o*l*h;break;default:throw new Error("Unknown angle order "+n)}return t}function E(){var t=new d(2);return d!=Float32Array&&(t[0]=0,t[1]=0),t}function A(t,e){var i=new d(2);return i[0]=t,i[1]=e,i}_(),w=new d(4),d!=Float32Array&&(w[0]=0,w[1]=0,w[2]=0,w[3]=0),_(),y(1,0,0),y(0,1,0),C(),C(),f(),E();const I=8192;function P(t,e,i){return e*(I/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function D(t,e){return(t%e+e)%e}function k(t,e,i){return t*(1-i)+e*i}function z(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function R(t,e,i,r){const n=new a(t,e,i,r);return t=>n.solve(t)}const L=R(.25,.1,.25,1);function F(t,e,i){return Math.min(i,Math.max(e,t))}function B(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function O(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let N=1;function V(t,e,i){const r={};for(const i in t)r[i]=e.call(this,t[i],i,t);return r}function j(t,e,i){const r={};for(const i in t)e.call(this,t[i],i,t)&&(r[i]=t[i]);return r}function q(t){return Array.isArray(t)?t.map(q):"object"==typeof t&&t?V(t,q):t}const G={};function U(t){G[t]||("undefined"!=typeof console&&console.warn(t),G[t]=!0)}function $(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function Z(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let W=null;function H(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const X="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Y(t,i,r,n,s){return e(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const o=null==e?void 0:e.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw new Error(`Unrecognized format ${o}`);const a=o.startsWith("BGR"),l=new Uint8ClampedArray(n*s*4);if(yield e.copyTo(l,function(t,e,i,r,n){const s=4*Math.max(-e,0),o=(Math.max(0,i)-i)*r*4+s,a=4*r,l=Math.max(0,e),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,i+n)-c},layout:[{offset:o,stride:a}]}}(t,i,r,n,s)),a)for(let t=0;t<l.length;t+=4){const e=l[t];l[t]=l[t+2],l[t+2]=e}return l}finally{e.close()}})}let K,J;function Q(t,e,i,r){return t.addEventListener(e,i,r),{unsubscribe:()=>{t.removeEventListener(e,i,r)}}}function tt(t){return t*Math.PI/180}function et(t){return t/Math.PI*180}const it={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},rt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},nt="AbortError";class st extends Error{constructor(t=nt){super(t instanceof Error?t.message:t),this.name=nt,t instanceof Error&&t.stack&&(this.stack=t.stack)}}function ot(t){return t.name===nt}const at={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function lt(t){return at.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ct="global-dispatcher";class ht extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}}const ut=()=>Z(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,pt=function(t,i){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=lt(t.url);if(e)return e(t,i);if(Z(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ct},i)}if(!(/^file:/.test(r=t.url)||/^file:/.test(ut())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,i){return e(this,void 0,void 0,function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:ut(),signal:i.signal});let r,n;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{r=yield fetch(e)}catch(e){if(ot(e))throw e;throw new ht(0,e.message,t.url,new Blob)}if(!r.ok){const e=yield r.blob();throw new ht(r.status,r.statusText,t.url,e)}n="arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text();const s=yield n;return i.signal.throwIfAborted(),{data:s,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires")}})}(t,i);if(Z(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ct},i)}var r;return function(t,e){return new Promise((i,r)=>{var n;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(n=t.headers)||void 0===n?void 0:n.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{r(new Error(s.statusText))},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response)}catch(t){return void r(t)}i({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")})}else{const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});r(new ht(s.status,s.statusText,t.url,e))}},e.signal.addEventListener("abort",()=>{s.abort(),r(new st(e.signal.reason))}),s.send(t.body)})}(t,i)};function dt(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return!0;const e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function ft(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function mt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class _t{constructor(t,e={}){O(this,e),this.type=t}}class gt extends _t{constructor(t,e={}){super("error",O({error:t},e))}}class yt{on(t,e){return this._listeners=this._listeners||{},ft(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return mt(t,e,this._listeners),mt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ft(t,e,this._oneTimeListeners),this):new Promise(e=>this.once(t,e))}fire(t,e){"string"==typeof t&&(t=new _t(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)mt(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(O(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof gt&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var vt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},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},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{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:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},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:{},"color-relief":{},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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},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:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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:{},"viewport-glyph":{},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-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},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:"expression_name",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}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","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","feature"]},"property-type":"cross-faded-data-driven"},"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:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,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:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",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"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},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"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const xt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function bt(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return xt.forEach(t=>{t in e&&(i[t]=e[t])}),i}function wt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!wt(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!wt(t[i],e[i]))return!1;return!0}return t===e}function St(t,e){t.push(e)}function Tt(t,e,i){St(i,{command:"addSource",args:[t,e[t]]})}function Ct(t,e,i){St(e,{command:"removeSource",args:[t]}),i[t]=!0}function Mt(t,e,i,r){Ct(t,i,r),Tt(t,e,i)}function Et(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!wt(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!wt(t[i][r],e[i][r]))return!1;return!0}function At(t,e,i,r,n,s){t=t||{},e=e||{};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(wt(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&!Object.prototype.hasOwnProperty.call(t,o)&&(wt(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}))}function It(t){return t.id}function Pt(t,e){return t[e.id]=e,t}class Dt{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function kt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class zt extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class Rt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Rt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Lt={kind:"null"},Ft={kind:"number"},Bt={kind:"string"},Ot={kind:"boolean"},Nt={kind:"color"},Vt={kind:"projectionDefinition"},jt={kind:"object"},qt={kind:"value"},Gt={kind:"collator"},Ut={kind:"formatted"},$t={kind:"padding"},Zt={kind:"colorArray"},Wt={kind:"numberArray"},Ht={kind:"resolvedImage"},Xt={kind:"variableAnchorOffsetCollection"};function Yt(t,e){return{kind:"array",itemType:t,N:e}}function Kt(t){if("array"===t.kind){const e=Kt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Jt=[Lt,Ft,Bt,Ot,Nt,Vt,Ut,jt,Yt(qt),$t,Wt,Zt,Ht,Xt];function Qt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Qt(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(const t of Jt)if(!Qt(t,e))return null}return`Expected ${Kt(t)} but found ${Kt(e)} instead.`}function te(t,e){return e.some(e=>e.kind===t.kind)}function ee(t,e){return e.some(e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t)}function ie(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const re=.96422,ne=.82521,se=4/29,oe=6/29,ae=3*oe*oe,le=oe*oe*oe,ce=Math.PI/180,he=180/Math.PI;function ue(t){return(t%=360)<0&&(t+=360),t}function pe([t,e,i,r]){let n,s;const o=fe((.2225045*(t=de(t))+.7168786*(e=de(e))+.0606169*(i=de(i)))/1);t===e&&e===i?n=s=o:(n=fe((.4360747*t+.3850649*e+.1430804*i)/re),s=fe((.0139322*t+.0971045*e+.7141733*i)/ne));const a=116*o-16;return[a<0?0:a,500*(n-o),200*(o-s),r]}function de(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function fe(t){return t>le?Math.pow(t,1/3):t/ae+se}function me([t,e,i,r]){let n=(t+16)/116,s=isNaN(e)?n:n+e/500,o=isNaN(i)?n:n-i/200;return n=1*ge(n),s=re*ge(s),o=ne*ge(o),[_e(3.1338561*s-1.6168667*n-.4906146*o),_e(-.9787684*s+1.9161415*n+.033454*o),_e(.0719453*s-.2289914*n+1.4052427*o),r]}function _e(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ge(t){return t>oe?t*t*t:ae*(t-se)}const ye=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function ve(t,e){return ye(t,e)?t[e]:void 0}function xe(t){return parseInt(t.padEnd(2,t),16)/255}function be(t,e){return we(e?t/100:t,0,1)}function we(t,e,i){return Math.min(Math.max(e,t),i)}function Se(t){return!t.some(Number.isNaN)}const Te={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ce(t,e,i){return t+i*(e-t)}function Me(t,e,i){return t.map((t,r)=>Ce(t,e[r],i))}class Ee{constructor(t,e,i,r=1,n=!0){this.r=t,this.g=e,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static parse(t){if(t instanceof Ee)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=ve(Te,t);if(e){const[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let i=1;return[xe(t.slice(i,i+=e)),xe(t.slice(i,i+=e)),xe(t.slice(i,i+=e)),xe(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,i,r,n,s,o,a,l,c,h,u,p]=e,d=[n||" ",a||" ",h].join("");if(" "===d||" /"===d||",,"===d||",,,"===d){const t=[r,o,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[we(+i/e,0,1),we(+s/e,0,1),we(+l/e,0,1),u?be(+u,p):1];if(Se(t))return t}}return}}const i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[t,e,r,n,s,o,a,l,c]=i,h=[r||" ",s||" ",a].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const t=[+e,we(+n,0,100),we(+o,0,100),l?be(+l,c):1];if(Se(t))return function([t,e,i,r]){function n(r){const n=(r+t/30)%12,s=e*Math.min(i,1-i);return i-s*Math.max(-1,Math.min(n-3,9-n,1))}return t=ue(t),e/=100,i/=100,[n(0),n(8),n(4),r]}(t)}}}(t);return e?new Ee(...e,!1):void 0}get rgb(){const{r:t,g:e,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[t/n,e/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,i,r,n]=pe(t),s=Math.sqrt(i*i+r*r);return[Math.round(1e4*s)?ue(Math.atan2(r,i)*he):NaN,s,e,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",pe(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map(t=>Math.round(255*t)).join(",")},${r})`}static interpolate(t,e,i,r="rgb"){switch(r){case"rgb":{const[r,n,s,o]=Me(t.rgb,e.rgb,i);return new Ee(r,n,s,o,!1)}case"hcl":{const[r,n,s,o]=t.hcl,[a,l,c,h]=e.hcl;let u,p;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?u=NaN:(u=a,1!==s&&0!==s||(p=l)):(u=r,1!==c&&0!==c||(p=n));else{let t=a-r;a>r&&t>180?t-=360:a<r&&r-a>180&&(t+=360),u=r+i*t}const[d,f,m,_]=function([t,e,i,r]){return t=isNaN(t)?0:t*ce,me([i,Math.cos(t)*e,Math.sin(t)*e,r])}([u,null!=p?p:Ce(n,l,i),Ce(s,c,i),Ce(o,h,i)]);return new Ee(d,f,m,_,!1)}case"lab":{const[r,n,s,o]=me(Me(t.lab,e.lab,i));return new Ee(r,n,s,o,!1)}}}}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);class Ae{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ie=["bottom","center","top"];class Pe{constructor(t,e,i,r,n,s){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=s}}class De{constructor(t){this.sections=t}static fromString(t){return new De([new Pe(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(t=>0!==t.text.length||t.image&&0!==t.image.name.length)}static factory(t){return t instanceof De?t:De.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map(t=>t.text).join("")}}class ke{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ke)return t;if("number"==typeof t)return new ke([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new ke(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){return new ke(Me(t.values,e.values,i))}}class ze{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ze)return t;if("number"==typeof t)return new ze([t]);if(Array.isArray(t)){for(const e of t)if("number"!=typeof e)return;return new ze(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){return new ze(Me(t.values,e.values,i))}}class Re{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Re)return t;if("string"==typeof t){const e=Ee.parse(t);if(!e)return;return new Re([e])}if(!Array.isArray(t))return;const e=[];for(const i of t){if("string"!=typeof i)return;const t=Ee.parse(i);if(!t)return;e.push(t)}return new Re(e)}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i,r="rgb"){const n=[];if(t.values.length!=e.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${e.values.length}), cannot interpolate.`);for(let s=0;s<t.values.length;s++)n.push(Ee.interpolate(t.values[s],e.values[s],i,r));return new Re(n)}}class Le extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}}const Fe=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Be{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Be)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){const i=t[e],r=t[e+1];if("string"!=typeof i||!Fe.has(i))return;if(!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new Be(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){const r=t.values,n=e.values;if(r.length!==n.length)throw new Le(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const s=[];for(let t=0;t<r.length;t+=2){if(r[t]!==n[t])throw new Le(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${r[t]}, to[${t}]: ${n[t]}`);s.push(r[t]);const[e,o]=r[t+1],[a,l]=n[t+1];s.push([Ce(e,a,i),Ce(o,l,i)])}return new Be(s)}}class Oe{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Oe({name:t,available:!1}):null}}class Ne{constructor(t,e,i){this.from=t,this.to=e,this.transition=i}static interpolate(t,e,i){return new Ne(t,e,i)}static parse(t){return t instanceof Ne?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new Ne(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new Ne(t.from,t.to,t.transition):"string"==typeof t?new Ne(t,t,1):void 0}}function Ve(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function je(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ne||t instanceof Ee||t instanceof Ae||t instanceof De||t instanceof ke||t instanceof ze||t instanceof Re||t instanceof Be||t instanceof Oe)return!0;if(Array.isArray(t)){for(const e of t)if(!je(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!je(t[e]))return!1;return!0}return!1}function qe(t){if(null===t)return Lt;if("string"==typeof t)return Bt;if("boolean"==typeof t)return Ot;if("number"==typeof t)return Ft;if(t instanceof Ee)return Nt;if(t instanceof Ne)return Vt;if(t instanceof Ae)return Gt;if(t instanceof De)return Ut;if(t instanceof ke)return $t;if(t instanceof ze)return Wt;if(t instanceof Re)return Zt;if(t instanceof Be)return Xt;if(t instanceof Oe)return Ht;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=qe(e);if(i){if(i===t)continue;i=qt;break}i=t}return Yt(i||qt,e)}return jt}function Ge(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Ee||t instanceof Ne||t instanceof De||t instanceof ke||t instanceof ze||t instanceof Re||t instanceof Be||t instanceof Oe?t.toString():JSON.stringify(t)}class Ue{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!je(t[1]))return e.error("invalid value");const i=t[1];let r=qe(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Ue(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const $e={string:Bt,number:Ft,boolean:Ot,object:jt};class Ze{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,s;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in $e)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=$e[i],r++}else n=qt;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);s=t[2],r++}i=Yt(n,s)}else{if(!$e[n])throw new Error(`Types doesn't contain name = ${n}`);i=$e[n]}const s=[];for(;r<t.length;r++){const i=e.parse(t[r],r,qt);if(!i)return null;s.push(i)}return new Ze(i,s)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Qt(this.type,qe(i)))return i;if(e===this.args.length-1)throw new Le(`Expected value to be of type ${Kt(this.type)}, but found ${Kt(qe(i))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const We={"to-boolean":Ot,"to-color":Nt,"to-number":Ft,"to-string":Bt};class He{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(!We[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=We[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,qt);if(!r)return null;n.push(r)}return new He(r,n)}evaluate(t){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(t));case"color":{let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof Ee)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Ve(e[0],e[1],e[2],e[3]),!i))return new Ee(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Le(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const i of this.args){e=i.evaluate(t);const r=ke.parse(e);if(r)return r}throw new Le(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"numberArray":{let e;for(const i of this.args){e=i.evaluate(t);const r=ze.parse(e);if(r)return r}throw new Le(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"colorArray":{let e;for(const i of this.args){e=i.evaluate(t);const r=Re.parse(e);if(r)return r}throw new Le(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const i of this.args){e=i.evaluate(t);const r=Be.parse(e);if(r)return r}throw new Le(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Le(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return De.fromString(Ge(this.args[0].evaluate(t)));case"resolvedImage":return Oe.fromString(Ge(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return Ge(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const Xe=["Unknown","Point","LineString","Polygon"];class Ye{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Xe[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=Ee.parse(t),this._parseColorCache.set(t,e)),e}}class Ke{constructor(t,e,i=[],r,n=new Rt,s=[]){this.registry=t,this.path=i,this.key=i.map(t=>`[${t}]`).join(""),this.scope=n,this.errors=s,this.expectedType=r,this._isConstant=e}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new Ze(e,[t]):"coerce"===i?new He(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", []].');const 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;const n=this.registry[r];if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(n.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(n.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(n.kind)||"colorArray"===t.kind&&["value","string","array"].includes(n.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(n.kind))r=i(r,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Ue)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const e=new Ye;try{r=new Ue(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}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.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new Ke(this.registry,this._isConstant,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map(t=>`[${t}]`).join("")}`;this.errors.push(new zt(i,t))}checkSubtype(t,e){const i=Qt(t,e);return i&&this.error(i),i}}class Je{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const s=e.parse(t[r+1],r+1);if(!s)return null;i.push([n,s])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Je(i,r):null}outputDefined(){return this.result.outputDefined()}}class Qe{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Qe(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class ti{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Ft),r=e.parse(t[2],2,Yt(e.expectedType||qt));return i&&r?new ti(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new Le(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new Le(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Le(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ei{constructor(t,e){this.type=Ot,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,qt),r=e.parse(t[2],2,qt);return i&&r?te(i.type,[Ot,Bt,Ft,Lt,qt])?new ei(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Kt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!ee(e,["boolean","string","number","null"]))throw new Le(`Expected first argument to be of type boolean, string, number or null, but found ${Kt(qe(e))} instead.`);if(!ee(i,["string","array"]))throw new Le(`Expected second argument to be of type array or string, but found ${Kt(qe(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class ii{constructor(t,e,i){this.type=Ft,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,qt),r=e.parse(t[2],2,qt);if(!i||!r)return null;if(!te(i.type,[Ot,Bt,Ft,Lt,qt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Kt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Ft);return n?new ii(i,r,n):null}return new ii(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!ee(e,["boolean","string","number","null"]))throw new Le(`Expected first argument to be of type boolean, string, number or null, but found ${Kt(qe(e))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(t)),ee(i,["string"])){const t=i.indexOf(e,r);return-1===t?-1:[...i.slice(0,t)].length}if(ee(i,["array"]))return i.indexOf(e,r);throw new Le(`Expected second argument to be of type array or string, but found ${Kt(qe(i))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class ri{constructor(t,e,i,r,n,s){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=s}static parse(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.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},s=[];for(let o=2;o<t.length-1;o+=2){let a=t[o];const l=t[o+1];Array.isArray(a)||(a=[a]);const c=e.concat(o);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,qe(t)))return null}else i=qe(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=s.length}const h=e.parse(l,o,r);if(!h)return null;r=r||h.type,s.push(h)}const o=e.parse(t[1],1,qt);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(i,o.type)?null:new ri(i,r,o,n,s,a):null}evaluate(t){const e=this.input.evaluate(t);return(qe(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}}class ni{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const s=e.parse(t[n],n,Ot);if(!s)return null;const o=e.parse(t[n+1],n+1,i);if(!o)return null;r.push([s,o]),i=i||o.type}const n=e.parse(t[t.length-1],t.length-1,i);if(!n)return null;if(!i)throw new Error("Can't infer output type");return new ni(i,r,n)}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every(([t,e])=>e.outputDefined())&&this.otherwise.outputDefined()}}class si{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,qt),r=e.parse(t[2],2,Ft);if(!i||!r)return null;if(!te(i.type,[Yt(qt),Bt,qt]))return e.error(`Expected first argument to be of type array or string, but found ${Kt(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,Ft);return n?new si(i.type,i,r,n):null}return new si(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);let r;if(this.endIndex&&(r=this.endIndex.evaluate(t)),ee(e,["string"]))return[...e].slice(i,r).join("");if(ee(e,["array"]))return e.slice(i,r);throw new Le(`Expected first argument to be of type array or string, but found ${Kt(qe(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function oi(t,e){const i=t.length-1;let r,n,s=0,o=i,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),r=t[a],n=t[a+1],r<=e){if(a===i||e<n)return a;s=a+1}else{if(!(r>e))throw new Le("Input is not a number.");o=a-1}return 0}class ai{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){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.");const i=e.parse(t[1],1,Ft);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const s=1===i?-1/0:t[i],o=t[i+1],a=i,l=i+1;if("number"!=typeof s)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(o,l,n);if(!c)return null;n=n||c.type,r.push([s,c])}return new ai(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[oi(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function li(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ci,hi,ui=function(){if(hi)return ci;function t(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}return hi=1,ci=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var n=this.sampleCurveX(i)-t;if(Math.abs(n)<e)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=n/s}var o=0,a=1;for(i=t,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-t)<e));r++)t>n?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},ci}(),pi=li(ui);class di{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,r){let n=0;if("exponential"===t.name)n=fi(e,t.base,i,r);else if("linear"===t.name)n=fi(e,1,i,r);else if("cubic-bezier"===t.name){const s=t.controlPoints;n=new pi(s[0],s[1],s[2],s[3]).solve(fi(e,1,i,r))}return n}static parse(t,e){let[i,r,n,...s]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some(t=>"number"!=typeof t||t<0||t>1))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}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(n=e.parse(n,2,Ft),!n)return null;const o=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||e.expectedType==Zt?e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType):a=Nt;for(let t=0;t<s.length;t+=2){const i=s[t],r=s[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(o.length&&o[o.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,o.push([i,c])}return ie(a,Ft)||ie(a,Vt)||ie(a,Nt)||ie(a,$t)||ie(a,Wt)||ie(a,Zt)||ie(a,Xt)||ie(a,Yt(Ft))?new di(a,i,r,n,o):e.error(`Type ${Kt(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const s=oi(e,r),o=di.interpolationFactor(this.interpolation,r,e[s],e[s+1]),a=i[s].evaluate(t),l=i[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Ce(a,l,o);case"color":return Ee.interpolate(a,l,o);case"padding":return ke.interpolate(a,l,o);case"colorArray":return Re.interpolate(a,l,o);case"numberArray":return ze.interpolate(a,l,o);case"variableAnchorOffsetCollection":return Be.interpolate(a,l,o);case"array":return Me(a,l,o);case"projectionDefinition":return Ne.interpolate(a,l,o)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ee.interpolate(a,l,o,"hcl");case"colorArray":return Re.interpolate(a,l,o,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ee.interpolate(a,l,o,"lab");case"colorArray":return Re.interpolate(a,l,o,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function fi(t,e,i,r){const n=r-i,s=t-i;return 0===n?0:1===e?s/n:(Math.pow(e,s)-1)/(Math.pow(e,n)-1)}const mi={color:Ee.interpolate,number:Ce,padding:ke.interpolate,numberArray:ze.interpolate,colorArray:Re.interpolate,variableAnchorOffsetCollection:Be.interpolate,array:Me};class _i{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}if(!i)throw new Error("No output type");const s=r&&n.some(t=>Qt(r,t.type));return new _i(s?qt:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof Oe&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function gi(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function yi(t,e,i,r){return 0===r.compare(e,i)}function vi(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=Ot,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let s=e.parse(t[1],1,qt);if(!s)return null;if(!gi(i,s.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Kt(s.type)}'.`);let o=e.parse(t[2],2,qt);if(!o)return null;if(!gi(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Kt(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Kt(s.type)}' and '${Kt(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Ze(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Ze(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Gt),!a)return null}return new n(s,o,a)}evaluate(n){const s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=qe(s),i=qe(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Le(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=qe(s),i=qe(o);if("string"!==t.kind||"string"!==i.kind)return e(n,s,o)}return this.collator?i(n,s,o,this.collator.evaluate(n)):e(n,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const xi=vi("==",function(t,e,i){return e===i},yi),bi=vi("!=",function(t,e,i){return e!==i},function(t,e,i,r){return!yi(0,e,i,r)}),wi=vi("<",function(t,e,i){return e<i},function(t,e,i,r){return r.compare(e,i)<0}),Si=vi(">",function(t,e,i){return e>i},function(t,e,i,r){return r.compare(e,i)>0}),Ti=vi("<=",function(t,e,i){return e<=i},function(t,e,i,r){return r.compare(e,i)<=0}),Ci=vi(">=",function(t,e,i){return e>=i},function(t,e,i,r){return r.compare(e,i)>=0});class Mi{constructor(t,e,i){this.type=Gt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Ot);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Ot);if(!n)return null;let s=null;return i.locale&&(s=e.parse(i.locale,1,Bt),!s)?null:new Mi(r,n,s)}evaluate(t){return new Ae(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class Ei{constructor(t,e,i,r,n){this.type=Bt,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Ft);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,Bt),!n))return null;let s=null;if(r.currency&&(s=e.parse(r.currency,1,Bt),!s))return null;let o=null;if(r["min-fraction-digits"]&&(o=e.parse(r["min-fraction-digits"],1,Ft),!o))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,Ft),!a)?null:new Ei(i,n,s,o,a)}evaluate(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))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ai{constructor(t){this.type=Ut,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const s=t[i];if(n&&"object"==typeof s&&!Array.isArray(s)){n=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Ft),!t))return null;let i=null;if(s["text-font"]&&(i=e.parse(s["text-font"],1,Yt(Bt)),!i))return null;let o=null;if(s["text-color"]&&(o=e.parse(s["text-color"],1,Nt),!o))return null;let a=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!Ie.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(a=e.parse(s["vertical-align"],1,Bt),!a)return null}const l=r[r.length-1];l.scale=t,l.font=i,l.textColor=o,l.verticalAlign=a}else{const s=e.parse(t[i],1,qt);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ai(r)}evaluate(t){return new De(this.sections.map(e=>{const i=e.content.evaluate(t);return qe(i)===Ht?new Pe("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new Pe(Ge(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}}class Ii{constructor(t){this.type=Ht,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Bt);return i?new Ii(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Oe.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class Pi{constructor(t){this.type=Ft,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Kt(i.type)} instead.`):new Pi(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new Le(`Expected value to be of type string or array, but found ${Kt(qe(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Di=8192;function ki(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*Di),Math.round(r*n*Di)]}function zi(t,e){const i=Math.pow(2,e.z);return[(n=(t[0]/Di+e.x)/i,360*n-180),(r=(t[1]/Di+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n}function Ri(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Li(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Fi(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],s=t[0]-i[0],o=t[1]-i[1];return r*o-s*n==0&&r*s<=0&&n*o<=0}function Bi(t,e,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-n[1]*s[0]&&!(!Gi(t,e,i,r)||!Gi(i,r,t,e));var n,s}function Oi(t,e,i){for(const r of i)for(let i=0;i<r.length-1;++i)if(Bi(t,e,r[i],r[i+1]))return!0;return!1}function Ni(t,e,i=!1){let r=!1;for(const a of e)for(let e=0;e<a.length-1;e++){if(Fi(t,a[e],a[e+1]))return i;(s=a[e])[1]>(n=t)[1]!=(o=a[e+1])[1]>n[1]&&n[0]<(o[0]-s[0])*(n[1]-s[1])/(o[1]-s[1])+s[0]&&(r=!r)}var n,s,o;return r}function Vi(t,e){for(const i of e)if(Ni(t,i))return!0;return!1}function ji(t,e){for(const i of t)if(!Ni(i,e))return!1;for(let i=0;i<t.length-1;++i)if(Oi(t[i],t[i+1],e))return!1;return!0}function qi(t,e){for(const i of e)if(ji(t,i))return!0;return!1}function Gi(t,e,i,r){const n=r[0]-i[0],s=r[1]-i[1],o=(t[0]-i[0])*s-n*(t[1]-i[1]),a=(e[0]-i[0])*s-n*(e[1]-i[1]);return o>0&&a<0||o<0&&a>0}function Ui(t,e,i){const r=[];for(let n=0;n<t.length;n++){const s=[];for(let r=0;r<t[n].length;r++){const o=ki(t[n][r],i);Ri(e,o),s.push(o)}r.push(s)}return r}function $i(t,e,i){const r=[];for(let n=0;n<t.length;n++){const s=Ui(t[n],e,i);r.push(s)}return r}function Zi(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}Ri(e,t)}function Wi(t,e,i,r){const n=Math.pow(2,r.z)*Di,s=[r.x*Di,r.y*Di],o=[];for(const r of t)for(const t of r){const r=[t.x+s[0],t.y+s[1]];Zi(r,e,i,n),o.push(r)}return o}function Hi(t,e,i,r){const n=Math.pow(2,r.z)*Di,s=[r.x*Di,r.y*Di],o=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+s[0],r.y+s[1]];Ri(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=n/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const r of t)Zi(r,e,i,n)}var a;return o}class Xi{constructor(t,e){this.type=Ot,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(je(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const i of e.features){const{type:e,coordinates:r}=i.geometry;"Polygon"===e&&t.push(r),"MultiPolygon"===e&&t.push(...r)}if(t.length)return new Xi(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Xi(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Xi(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const s=Ui(e.coordinates,r,n),o=Wi(t.geometry(),i,r,n);if(!Li(i,r))return!1;for(const t of o)if(!Ni(t,s))return!1}if("MultiPolygon"===e.type){const s=$i(e.coordinates,r,n),o=Wi(t.geometry(),i,r,n);if(!Li(i,r))return!1;for(const t of o)if(!Vi(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const s=Ui(e.coordinates,r,n),o=Hi(t.geometry(),i,r,n);if(!Li(i,r))return!1;for(const t of o)if(!ji(t,s))return!1}if("MultiPolygon"===e.type){const s=$i(e.coordinates,r,n),o=Hi(t.geometry(),i,r,n);if(!Li(i,r))return!1;for(const t of o)if(!qi(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Yi=class{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,s=e[n];if(i(r,s)>=0)break;e[t]=s,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1);const s=r+1;if(s<this.length&&i(e[s],e[r])<0&&(r=s),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}};function Ki(t,e,i=0,r=t.length-1,n=Qi){for(;r>i;){if(r-i>600){const s=r-i+1,o=e-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Ki(t,e,Math.max(i,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),n)}const s=t[e];let o=i,a=r;for(Ji(t,i,e),n(t[r],s)>0&&Ji(t,i,r);o<a;){for(Ji(t,o,a),o++,a--;n(t[o],s)<0;)o++;for(;n(t[a],s)>0;)a--}0===n(t[i],s)?Ji(t,i,a):(a++,Ji(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Ji(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function Qi(t,e){return t<e?-1:t>e?1:0}function tr(t,e){if(t.length<=1)return[t];const i=[];let r,n;for(const e of t){const t=ir(e);0!==t&&(e.area=Math.abs(t),void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e]):r.push(e))}if(r&&i.push(r),e>1)for(let t=0;t<i.length;t++)i[t].length<=e||(Ki(i[t],e,1,i[t].length-1,er),i[t]=i[t].slice(0,e));return i}function er(t,e){return e.area-t.area}function ir(t){let e=0;for(let i,r,n=0,s=t.length,o=s-1;n<s;o=n++)i=t[n],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}const rr=1/298.257223563,nr=rr*(2-rr),sr=Math.PI/180;class or{constructor(t){const e=6378.137*sr*1e3,i=Math.cos(t*sr),r=1/(1-nr*(1-i*i)),n=Math.sqrt(r);this.kx=e*n*i,this.ky=e*n*r*(1-nr)}distance(t,e){const i=this.wrap(t[0]-e[0])*this.kx,r=(t[1]-e[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(t,e){let i,r,n,s,o=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],c=t[a][1],h=this.wrap(t[a+1][0]-l)*this.kx,u=(t[a+1][1]-c)*this.ky,p=0;0===h&&0===u||(p=(this.wrap(e[0]-l)*this.kx*h+(e[1]-c)*this.ky*u)/(h*h+u*u),p>1?(l=t[a+1][0],c=t[a+1][1]):p>0&&(l+=h/this.kx*p,c+=u/this.ky*p)),h=this.wrap(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const d=h*h+u*u;d<o&&(o=d,i=l,r=c,n=a,s=p)}return{point:[i,r],index:n,t:Math.max(0,Math.min(1,s))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function ar(t,e){return e[0]-t[0]}function lr(t){return t[1]-t[0]+1}function cr(t,e){return t[1]>=t[0]&&t[1]<e}function hr(t,e){if(t[0]>t[1])return[null,null];const i=lr(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];const r=Math.floor(i/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function ur(t,e){if(!cr(e,t.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)Ri(i,t[r]);return i}function pr(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)for(const t of i)Ri(e,t);return e}function dr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function fr(t,e,i){if(!dr(t)||!dr(e))return NaN;let r=0,n=0;return t[2]<e[0]&&(r=e[0]-t[2]),t[0]>e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(n=t[1]-e[3]),t[3]<e[1]&&(n=e[1]-t[3]),i.distance([0,0],[r,n])}function mr(t,e,i){const r=i.pointOnLine(e,t);return i.distance(t,r.point)}function _r(t,e,i,r,n){const s=Math.min(mr(t,[i,r],n),mr(e,[i,r],n)),o=Math.min(mr(i,[t,e],n),mr(r,[t,e],n));return Math.min(s,o)}function gr(t,e,i,r,n){if(!cr(e,t.length)||!cr(r,i.length))return 1/0;let s=1/0;for(let o=e[0];o<e[1];++o){const e=t[o],a=t[o+1];for(let t=r[0];t<r[1];++t){const r=i[t],o=i[t+1];if(Bi(e,a,r,o))return 0;s=Math.min(s,_r(e,a,r,o,n))}}return s}function yr(t,e,i,r,n){if(!cr(e,t.length)||!cr(r,i.length))return NaN;let s=1/0;for(let o=e[0];o<=e[1];++o)for(let e=r[0];e<=r[1];++e)if(s=Math.min(s,n.distance(t[o],i[e])),0===s)return s;return s}function vr(t,e,i){if(Ni(t,e,!0))return 0;let r=1/0;for(const n of e){const e=n[0],s=n[n.length-1];if(e!==s&&(r=Math.min(r,mr(t,[s,e],i)),0===r))return r;const o=i.pointOnLine(n,t);if(r=Math.min(r,i.distance(t,o.point)),0===r)return r}return r}function xr(t,e,i,r){if(!cr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(Ni(t[r],i,!0))return 0;let n=1/0;for(let s=e[0];s<e[1];++s){const e=t[s],o=t[s+1];for(const t of i)for(let i=0,s=t.length,a=s-1;i<s;a=i++){const s=t[a],l=t[i];if(Bi(e,o,s,l))return 0;n=Math.min(n,_r(e,o,s,l,r))}}return n}function br(t,e){for(const i of t)for(const t of i)if(Ni(t,e,!0))return!0;return!1}function wr(t,e,i,r=1/0){const n=pr(t),s=pr(e);if(r!==1/0&&fr(n,s,i)>=r)return r;if(Li(n,s)){if(br(t,e))return 0}else if(br(e,t))return 0;let o=1/0;for(const r of t)for(let t=0,n=r.length,s=n-1;t<n;s=t++){const n=r[s],a=r[t];for(const t of e)for(let e=0,r=t.length,s=r-1;e<r;s=e++){const r=t[s],l=t[e];if(Bi(n,a,r,l))return 0;o=Math.min(o,_r(n,a,r,l,i))}}return o}function Sr(t,e,i,r,n,s){if(!s)return;const o=fr(ur(r,s),n,i);o<e&&t.push([o,s,[0,0]])}function Tr(t,e,i,r,n,s,o){if(!s||!o)return;const a=fr(ur(r,s),ur(n,o),i);a<e&&t.push([a,s,o])}function Cr(t,e,i,r,n=1/0){let s=Math.min(r.distance(t[0],i[0][0]),n);if(0===s)return s;const o=new Yi([[0,[0,t.length-1],[0,0]]],ar),a=pr(i);for(;o.length>0;){const n=o.pop();if(n[0]>=s)continue;const l=n[1],c=e?50:100;if(lr(l)<=c){if(!cr(l,t.length))return NaN;if(e){const e=xr(t,l,i,r);if(isNaN(e)||0===e)return e;s=Math.min(s,e)}else for(let e=l[0];e<=l[1];++e){const n=vr(t[e],i,r);if(s=Math.min(s,n),0===s)return 0}}else{const i=hr(l,e);Sr(o,s,r,t,a,i[0]),Sr(o,s,r,t,a,i[1])}}return s}function Mr(t,e,i,r,n,s=1/0){let o=Math.min(s,n.distance(t[0],i[0]));if(0===o)return o;const a=new Yi([[0,[0,t.length-1],[0,i.length-1]]],ar);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],c=s[2],h=e?50:100,u=r?50:100;if(lr(l)<=h&&lr(c)<=u){if(!cr(l,t.length)&&cr(c,i.length))return NaN;let s;if(e&&r)s=gr(t,l,i,c,n),o=Math.min(o,s);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(s=mr(i[t],e,n),o=Math.min(o,s),0===o)return o}else if(!e&&r){const e=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(s=mr(t[i],e,n),o=Math.min(o,s),0===o)return o}else s=yr(t,l,i,c,n),o=Math.min(o,s)}else{const s=hr(l,e),h=hr(c,r);Tr(a,o,n,t,i,s[0],h[0]),Tr(a,o,n,t,i,s[0],h[1]),Tr(a,o,n,t,i,s[1],h[0]),Tr(a,o,n,t,i,s[1],h[1])}}return o}function Er(t){return"MultiPolygon"===t.type?t.coordinates.map(t=>({type:"Polygon",coordinates:t})):"MultiLineString"===t.type?t.coordinates.map(t=>({type:"LineString",coordinates:t})):"MultiPoint"===t.type?t.coordinates.map(t=>({type:"Point",coordinates:t})):[t]}class Ar{constructor(t,e){this.type=Ft,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(je(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new Ar(e,e.features.map(t=>Er(t.geometry)).flat());if("Feature"===e.type)return new Ar(e,Er(e.geometry));if("type"in e&&"coordinates"in e)return new Ar(e,Er(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map(e=>zi([e.x,e.y],t.canonical));if(0===i.length)return NaN;const n=new or(r[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,Mr(r,!1,[t.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,Mr(r,!1,t.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Cr(r,!1,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map(e=>zi([e.x,e.y],t.canonical));if(0===i.length)return NaN;const n=new or(r[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,Mr(r,!0,[t.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,Mr(r,!0,t.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Cr(r,!0,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const i=t.geometry();if(0===i.length||0===i[0].length)return NaN;const r=tr(i,0).map(e=>e.map(e=>e.map(e=>zi([e.x,e.y],t.canonical)))),n=new or(r[0][0][0][1]);let s=1/0;for(const t of e)for(const e of r){switch(t.type){case"Point":s=Math.min(s,Cr([t.coordinates],!1,e,n,s));break;case"LineString":s=Math.min(s,Cr(t.coordinates,!0,e,n,s));break;case"Polygon":s=Math.min(s,wr(e,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Ir{constructor(t){this.type=qt,this.key=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=t[1];return null==i?e.error("Global state property must be defined."):"string"!=typeof i?e.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Ir(i)}evaluate(t){var e;const i=null===(e=t.globals)||void 0===e?void 0:e.globalState;return i&&0!==Object.keys(i).length?ve(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Pr={"==":xi,"!=":bi,">":Si,"<":wi,">=":Ci,"<=":Ti,array:Ze,at:ti,boolean:Ze,case:ni,coalesce:_i,collator:Mi,format:Ai,image:Ii,in:ei,"index-of":ii,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Pi,let:Je,literal:Ue,match:ri,number:Ze,"number-format":Ei,object:Ze,slice:si,step:ai,string:Ze,"to-boolean":He,"to-color":He,"to-number":He,"to-string":He,var:Qe,within:Xi,distance:Ar,"global-state":Ir};class Dr{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const i=t[0],r=Dr.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=s.filter(([e])=>!Array.isArray(e)||e.length===t.length-1);let a=null;for(const[r,s]of o){a=new Ke(e.registry,Fr,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,s=a.parse(i,1+o.length,n);if(!s){l=!0;break}o.push(s)}if(!l)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=o[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new Dr(i,n,s,o)}}if(1===o.length)e.errors.push(...a.errors);else{const i=(o.length?o:s).map(([t])=>{return e=t,Array.isArray(e)?`(${e.map(Kt).join(", ")})`:`(${Kt(e.type)}...)`;var e}).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(Kt(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){Dr.definitions=e;for(const i in e)t[i]=Dr}}function kr(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const s=n?n.evaluate(t):1,o=Ve(e,i,r,s);if(o)throw new Le(o);return new Ee(e/255,i/255,r/255,s,!1)}function zr(t,e){return t in e}function Rr(t,e){const i=e[t];return void 0===i?null:i}function Lr(t){return{type:t}}function Fr(t){if(t instanceof Qe)return Fr(t.boundExpression);if(t instanceof Dr&&"error"===t.name)return!1;if(t instanceof Mi)return!1;if(t instanceof Xi)return!1;if(t instanceof Ar)return!1;if(t instanceof Ir)return!1;const e=t instanceof He||t instanceof Ze;let i=!0;return t.eachChild(t=>{i=e?i&&Fr(t):i&&t instanceof Ue}),!!i&&Br(t)&&Nr(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Br(t){if(t instanceof Dr){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Xi)return!1;if(t instanceof Ar)return!1;let e=!0;return t.eachChild(t=>{e&&!Br(t)&&(e=!1)}),e}function Or(t){if(t instanceof Dr&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild(t=>{e&&!Or(t)&&(e=!1)}),e}function Nr(t,e){if(t instanceof Dr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild(t=>{i&&!Nr(t,e)&&(i=!1)}),i}function Vr(t){return{result:"success",value:t}}function jr(t){return{result:"error",value:t}}function qr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Gr(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Ur(t){return!!t.expression&&t.expression.interpolated}function $r(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Zr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&qe(t)===jt}function Wr(t){return t}function Hr(t,e){const i=t.stops&&"object"==typeof t.stops[0][0],r=i||!(i||void 0!==t.property),n=t.type||(Ur(e)?"exponential":"interval"),s=function(t){switch(t.type){case"color":return Ee.parse;case"padding":return ke.parse;case"numberArray":return ze.parse;case"colorArray":return Re.parse;default:return null}}(e);if(s&&((t=kt({},t)).stops&&(t.stops=t.stops.map(t=>[t[0],s(t[1])])),t.default=s(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==(o=t.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${t.colorSpace}"`);var o;const a=function(t){switch(t){case"exponential":return Jr;case"interval":return Kr;case"categorical":return Yr;case"identity":return Qr;default:throw new Error(`Unknown function type "${t}"`)}}(n);let l,c;if("categorical"===n){l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];c=typeof t.stops[0][0]}if(i){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],s=n[0].zoom;void 0===i[s]&&(i[s]={zoom:s,type:t.type,property:t.property,default:t.default,stops:[]},r.push(s)),i[s].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,Hr(i[t],e)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:di.interpolationFactor.bind(void 0,s),zoomStops:n.map(t=>t[0]),evaluate:({zoom:i},r)=>Jr({stops:n,base:t.base},e,i).evaluate(i,r)}}if(r){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map(t=>t[0]),evaluate:({zoom:i})=>a(t,e,i,l,c)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?Xr(t.default,e.default):a(t,e,n,l,c)}}}function Xr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Yr(t,e,i,r,n){return Xr(typeof i===n?r[i]:void 0,t.default,e.default)}function Kr(t,e,i){if("number"!==$r(i))return Xr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=oi(t.stops.map(t=>t[0]),i);return t.stops[n][1]}function Jr(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==$r(i))return Xr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const s=oi(t.stops.map(t=>t[0]),i),o=function(t,e,i,r){const n=r-i,s=t-i;return 0===n?0:1===e?s/n:(Math.pow(e,s)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1],c=mi[e.type]||Wr;return"function"==typeof a.evaluate?{evaluate(...e){const i=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return c(i,r,o,t.colorSpace)}}:c(a,l,o,t.colorSpace)}function Qr(t,e,i){switch(e.type){case"color":i=Ee.parse(i);break;case"formatted":i=De.fromString(i.toString());break;case"resolvedImage":i=Oe.fromString(i.toString());break;case"padding":i=ke.parse(i);break;case"colorArray":i=Re.parse(i);break;case"numberArray":i=ze.parse(i);break;default:$r(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return Xr(i,t.default,e.default)}Dr.register(Pr,{error:[{kind:"error"},[Bt],(t,[e])=>{throw new Le(e.evaluate(t))}],typeof:[Bt,[qt],(t,[e])=>Kt(qe(e.evaluate(t)))],"to-rgba":[Yt(Ft,4),[Nt],(t,[e])=>{const[i,r,n,s]=e.evaluate(t).rgb;return[255*i,255*r,255*n,s]}],rgb:[Nt,[Ft,Ft,Ft],kr],rgba:[Nt,[Ft,Ft,Ft,Ft],kr],has:{type:Ot,overloads:[[[Bt],(t,[e])=>zr(e.evaluate(t),t.properties())],[[Bt,jt],(t,[e,i])=>zr(e.evaluate(t),i.evaluate(t))]]},get:{type:qt,overloads:[[[Bt],(t,[e])=>Rr(e.evaluate(t),t.properties())],[[Bt,jt],(t,[e,i])=>Rr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[qt,[Bt],(t,[e])=>Rr(e.evaluate(t),t.featureState||{})],properties:[jt,[],t=>t.properties()],"geometry-type":[Bt,[],t=>t.geometryType()],id:[qt,[],t=>t.id()],zoom:[Ft,[],t=>t.globals.zoom],"heatmap-density":[Ft,[],t=>t.globals.heatmapDensity||0],elevation:[Ft,[],t=>t.globals.elevation||0],"line-progress":[Ft,[],t=>t.globals.lineProgress||0],accumulated:[qt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Ft,Lr(Ft),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[Ft,Lr(Ft),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:Ft,overloads:[[[Ft,Ft],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Ft],(t,[e])=>-e.evaluate(t)]]},"/":[Ft,[Ft,Ft],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Ft,[Ft,Ft],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Ft,[],()=>Math.LN2],pi:[Ft,[],()=>Math.PI],e:[Ft,[],()=>Math.E],"^":[Ft,[Ft,Ft],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Ft,[Ft],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Ft,[Ft],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Ft,[Ft],(t,[e])=>Math.log(e.evaluate(t))],log2:[Ft,[Ft],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Ft,[Ft],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Ft,[Ft],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Ft,[Ft],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Ft,[Ft],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Ft,[Ft],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Ft,[Ft],(t,[e])=>Math.atan(e.evaluate(t))],min:[Ft,Lr(Ft),(t,e)=>Math.min(...e.map(e=>e.evaluate(t)))],max:[Ft,Lr(Ft),(t,e)=>Math.max(...e.map(e=>e.evaluate(t)))],abs:[Ft,[Ft],(t,[e])=>Math.abs(e.evaluate(t))],round:[Ft,[Ft],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ft,[Ft],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Ft,[Ft],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Ot,[Bt,qt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Ot,[qt],(t,[e])=>t.id()===e.value],"filter-type-==":[Ot,[Bt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Ot,[Bt,qt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Ot,[qt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Ot,[Bt,qt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Ot,[qt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Ot,[Bt,qt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Ot,[qt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Ot,[Bt,qt],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Ot,[qt],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Ot,[qt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Ot,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Ot,[Yt(Bt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Ot,[Yt(qt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Ot,[Bt,Yt(qt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Ot,[Bt,Yt(qt)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Ot,overloads:[[[Ot,Ot],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Lr(Ot),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Ot,overloads:[[[Ot,Ot],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Lr(Ot),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Ot,[Ot],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Ot,[Bt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Bt,[Bt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Bt,[Bt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Bt,Lr(qt),(t,e)=>e.map(e=>Ge(e.evaluate(t))).join("")],"resolved-locale":[Bt,[Gt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class tn{constructor(t,e,i){this.expression=t,this._warningHistory={},this._evaluator=new Ye,this._defaultValue=e?function(t){if("color"===t.type&&Zr(t.default))return new Ee(0,0,0,0);switch(t.type){case"color":return Ee.parse(t.default)||null;case"padding":return ke.parse(t.default)||null;case"numberArray":return ze.parse(t.default)||null;case"colorArray":return Re.parse(t.default)||null;case"variableAnchorOffsetCollection":return Be.parse(t.default)||null;case"projectionDefinition":return Ne.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this._globalState=i}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=hn(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,s){this._globalState&&(t=hn(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Le(`Expected value to be one of ${Object.keys(this._enumValues).map(t=>JSON.stringify(t)).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function en(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Pr}function rn(t,e,i){const r=new Ke(Pr,Fr,[],e?function(t){const e={color:Nt,string:Bt,number:Ft,enum:Bt,boolean:Ot,formatted:Ut,padding:$t,numberArray:Wt,colorArray:Zt,projectionDefinition:Vt,resolvedImage:Ht,variableAnchorOffsetCollection:Xt};return"array"===t.type?Yt(e[t.value]||qt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Vr(new tn(n,e,i)):jr(r.errors)}class nn{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Or(e.expression),this.globalStateRefs=cn(e.expression),this._globalState=i}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=hn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._globalState&&(t=hn(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,n,s)}}class sn{constructor(t,e,i,r,n){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Or(e.expression),this.globalStateRefs=cn(e.expression),this.interpolationType=r,this._globalState=n}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=hn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._globalState&&(t=hn(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,n,s)}interpolationFactor(t,e,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,t,e,i):0}}function on(t,e,i){const r=rn(t,e,i);if("error"===r.result)return r;const n=r.value.expression,s=Br(n);if(!s&&!qr(e))return jr([new zt("","data expressions not supported")]);const o=Nr(n,["zoom"]);if(!o&&!Gr(e))return jr([new zt("","zoom expressions not supported")]);const a=ln(n);return a||o?a instanceof zt?jr([a]):a instanceof di&&!Ur(e)?jr([new zt("",'"interpolate" expressions cannot be used with this property')]):Vr(a?new sn(s?"camera":"composite",r.value,a.labels,a instanceof di?a.interpolation:void 0,i):new nn(s?"constant":"source",r.value,i)):jr([new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class an{constructor(t,e){this._parameters=t,this._specification=e,kt(this,Hr(this._parameters,this._specification))}static deserialize(t){return new an(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ln(t){let e=null;if(t instanceof Je)e=ln(t.result);else if(t instanceof _i){for(const i of t.args)if(e=ln(i),e)break}else(t instanceof ai||t instanceof di)&&t.input instanceof Dr&&"zoom"===t.input.name&&(e=t);return e instanceof zt||t.eachChild(t=>{const i=ln(t);i instanceof zt?e=i:!e&&i?e=new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new zt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function cn(t,e=new Set){return t instanceof Ir&&e.add(t.key),t.eachChild(t=>{cn(t,e)}),e}function hn(t,e){const{zoom:i,heatmapDensity:r,elevation:n,lineProgress:s,isSupportedScript:o,accumulated:a}=null!=t?t:{};return{zoom:i,heatmapDensity:r,elevation:n,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:e}}function un(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=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(const e of t.slice(1))if(!un(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const pn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function dn(t,e){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};un(t)||(t=_n(t));const i=rn(t,pn,e);if("error"===i.result)throw new Error(i.value.map(t=>`${t.key}: ${t.message}`).join(", "));return{filter:(t,e,r)=>i.value.evaluate(t,e,{},r),needGeometry:mn(t),getGlobalStateRefs:()=>cn(i.value.expression)}}function fn(t,e){return t<e?-1:t>e?1:0}function mn(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(mn(t[e]))return!0;return!1}function _n(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?gn(t[1],t[2],"=="):"!="===e?xn(gn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?gn(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(_n))):"all"===e?["all"].concat(t.slice(1).map(_n)):"none"===e?["all"].concat(t.slice(1).map(_n).map(xn)):"in"===e?yn(t[1],t.slice(2)):"!in"===e?xn(yn(t[1],t.slice(2))):"has"===e?vn(t[1]):"!has"!==e||xn(vn(t[1]));var i}function gn(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function yn(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(t=>typeof t!=typeof e[0])?["filter-in-large",t,["literal",e.sort(fn)]]:["filter-in-small",t,["literal",e]]}}function vn(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function xn(t){return["!",t]}function bn(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const i of t)e+=`${bn(i)},`;return`${e}]`}const i=Object.keys(t).sort();let r="{";for(let e=0;e<i.length;e++)r+=`${JSON.stringify(i[e])}:${bn(t[i[e]])},`;return`${r}}`}function wn(t){let e="";for(const i of xt)e+=`/${bn(t[i])}`;return e}function Sn(t){const e=t.value;return e?[new Dt(t.key,e,"constants have been deprecated as of v8")]:[]}function Tn(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Cn(t){if(Array.isArray(t))return t.map(Cn);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Cn(t[i]);return e}return Tn(t)}function Mn(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,o=t.styleSpec,a=t.validateSpec;let l=[];const c=$r(i);if("object"!==c)return[new Dt(e,i,`object expected, ${c} found`)];for(const t in i){const c=t.split(".")[0],h=ve(r,c)||r["*"];let u;if(ve(n,c))u=n[c];else if(ve(r,c)){if(void 0===i[t])continue;u=a}else if(n["*"])u=n["*"];else{if(!r["*"]){l.push(new Dt(e,i[t],`unknown property "${t}"`));continue}u=a}l=l.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:h,style:s,styleSpec:o,object:i,objectKey:t,validateSpec:a},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&l.push(new Dt(e,i,`missing required property "${t}"`));return l}function En(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==$r(e))return[new Dt(s,e,`array expected, ${$r(e)} found`)];if(i.length&&e.length!==i.length)return[new Dt(s,e,`array length ${i.length} expected, length ${e.length} found`)];let a={type:i.value,values:i.values};n.$version<7&&(a.function=i.function),"object"===$r(i.value)&&(a=i.value);let l=[];for(let i=0;i<e.length;i++)l=l.concat(o({array:e,arrayIndex:i,value:e[i],valueSpec:a,validateSpec:t.validateSpec,style:r,styleSpec:n,key:`${s}[${i}]`}));return l}function An(t){const e=t.key,i=t.value,r=t.valueSpec;let n=$r(i);return"number"===n&&i!=i&&(n="NaN"),"number"!==n?[new Dt(e,i,`number expected, ${n} found`)]:"minimum"in r&&i<r.minimum?[new Dt(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new Dt(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function In(t){const e=t.valueSpec,i=Tn(t.value.type);let r,n,s,o={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===$r(t.value.stops)&&"array"===$r(t.value.stops[0])&&"object"===$r(t.value.stops[0][0]),h=Mn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new Dt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(En({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===$r(r)&&0===r.length&&e.push(new Dt(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&h.push(new Dt(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new Dt(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Ur(t.valueSpec)&&h.push(new Dt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!qr(t.valueSpec)?h.push(new Dt(t.key,t.value,"property functions not supported")):a&&!Gr(t.valueSpec)&&h.push(new Dt(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new Dt(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,a=t.key;if("array"!==$r(r))return[new Dt(a,r,`array expected, ${$r(r)} found`)];if(2!==r.length)return[new Dt(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==$r(r[0]))return[new Dt(a,r,`object expected, ${$r(r[0])} found`)];if(void 0===r[0].zoom)return[new Dt(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Dt(a,r,"object stop key must have value")];if(s&&s>Tn(r[0].zoom))return[new Dt(a,r[0].zoom,"stop zoom values must appear in ascending order")];Tn(r[0].zoom)!==s&&(s=Tn(r[0].zoom),n=void 0,o={}),i=i.concat(Mn({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:An,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:r[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return en(Cn(r[1]))?i.concat([new Dt(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(t.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const a=$r(t.value),l=Tn(t.value),c=null!==t.value?t.value:s;if(r){if(a!==r)return[new Dt(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Dt(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return qr(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(t.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new Dt(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in o?[new Dt(t.key,c,"stop domain values must be unique")]:(o[l]=!0,[])):[new Dt(t.key,c,`integer expected, found ${l}`)]}}function Pn(t){const e=("property"===t.expressionContext?on:rn)(Cn(t.value),t.valueSpec);if("error"===e.result)return e.value.map(e=>new Dt(`${t.key}${e.key}`,t.value,e.message));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new Dt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Or(i))return[new Dt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Or(i))return[new Dt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Nr(i,["zoom","feature-state"]))return[new Dt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Br(i))return[new Dt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Dn(t){const e=t.key,i=t.value,r=$r(i);return"string"!==r?[new Dt(e,i,`color expected, ${r} found`)]:Ee.parse(String(i))?[]:[new Dt(e,i,`color expected, "${i}" found`)]}function kn(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Tn(i))&&n.push(new Dt(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Tn(i))&&n.push(new Dt(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function zn(t){return un(Cn(t.value))?Pn(kt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Rn(t)}function Rn(t){const e=t.value,i=t.key;if("array"!==$r(e))return[new Dt(i,e,`array expected, ${$r(e)} found`)];const r=t.styleSpec;let n,s=[];if(e.length<1)return[new Dt(i,e,"filter array must have at least 1 element")];switch(s=s.concat(kn({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),Tn(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Tn(e[1])&&s.push(new Dt(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new Dt(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=$r(e[1]),"string"!==n&&s.push(new Dt(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let o=2;o<e.length;o++)n=$r(e[o]),"$type"===Tn(e[1])?s=s.concat(kn({key:`${i}[${o}]`,value:e[o],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&s.push(new Dt(`${i}[${o}]`,e[o],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)s=s.concat(Rn({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=$r(e[1]),2!==e.length?s.push(new Dt(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&s.push(new Dt(`${i}[1]`,e[1],`string expected, ${n} found`))}return s}function Ln(t,e){const i=t.key,r=t.validateSpec,n=t.style,s=t.styleSpec,o=t.value,a=t.objectKey,l=s[`${e}_${t.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if("paint"===e&&c&&l[c[1]]&&l[c[1]].transition)return r({key:i,value:o,valueSpec:s.transition,style:n,styleSpec:s});const h=t.valueSpec||l[a];if(!h)return[new Dt(i,o,`unknown property "${a}"`)];let u;if("string"===$r(o)&&qr(h)&&!h.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new Dt(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const p=[];return"symbol"===t.layerType&&"text-font"===a&&Zr(Cn(o))&&"identity"===Tn(o.type)&&p.push(new Dt(i,o,'"text-font" does not support identity functions')),p.concat(r({key:t.key,value:o,valueSpec:h,style:n,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function Fn(t){return Ln(t,"paint")}function Bn(t){return Ln(t,"layout")}function On(t){let e=[];const i=t.value,r=t.key,n=t.style,s=t.styleSpec;if("object"!==$r(i))return[new Dt(r,i,`object expected, ${$r(i)} found`)];i.type||i.ref||e.push(new Dt(r,i,'either "type" or "ref" is required'));let o=Tn(i.type);const a=Tn(i.ref);if(i.id){const s=Tn(i.id);for(let o=0;o<t.arrayIndex;o++){const t=n.layers[o];Tn(t.id)===s&&e.push(new Dt(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach(t=>{t in i&&e.push(new Dt(r,i[t],`"${t}" is prohibited for ref layers`))}),n.layers.forEach(e=>{Tn(e.id)===a&&(t=e)}),t?t.ref?e.push(new Dt(r,i.ref,"ref cannot reference another ref layer")):o=Tn(t.type):e.push(new Dt(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(i.source){const t=n.sources&&n.sources[i.source],s=t&&Tn(t.type);t?"vector"===s&&"raster"===o?e.push(new Dt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o||"raster-dem"!==s&&"color-relief"===o?e.push(new Dt(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?e.push(new Dt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==s||i["source-layer"]?"raster-dem"===s&&"hillshade"!==o&&"color-relief"!==o?e.push(new Dt(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==o||!i.paint||!i.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new Dt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Dt(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Dt(r,i.source,`source "${i.source}" not found`))}else e.push(new Dt(r,i,'missing required property "source"'));return e=e.concat(Mn({key:r,value:i,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:zn,layout:t=>Mn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Bn(kt({layerType:o},t))}}),paint:t=>Mn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Fn(kt({layerType:o},t))}})}})),e}function Nn(t){const e=t.value,i=t.key,r=$r(e);return"string"!==r?[new Dt(i,e,`string expected, ${r} found`)]:[]}const Vn={promoteId:function({key:t,value:e}){if("string"===$r(e))return Nn({key:t,value:e});{const i=[];for(const r in e)i.push(...Nn({key:`${t}.${r}`,value:e[r]}));return i}}};function jn(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style,s=t.validateSpec;if(!e.type)return[new Dt(i,e,'"type" is required')];const o=Tn(e.type);let a;switch(o){case"vector":case"raster":return a=Mn({key:i,value:e,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Vn,validateSpec:s}),a;case"raster-dem":return a=function(t){var e;const i=null!==(e=t.sourceName)&&void 0!==e?e:"",r=t.value,n=t.styleSpec,s=n.source_raster_dem,o=t.style;let a=[];const l=$r(r);if(void 0===r)return a;if("object"!==l)return a.push(new Dt("source_raster_dem",r,`object expected, ${l} found`)),a;const c="custom"===Tn(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in r)!c&&h.includes(e)?a.push(new Dt(e,r[e],`In "${i}": "${e}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):s[e]?a=a.concat(t.validateSpec({key:e,value:r[e],valueSpec:s[e],validateSpec:t.validateSpec,style:o,styleSpec:n})):a.push(new Dt(e,r[e],`unknown property "${e}"`));return a}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:s}),a;case"geojson":if(a=Mn({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:s,objectElementValidators:Vn}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],s="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...Pn({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),a.push(...Pn({key:`${i}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return a;case"video":return Mn({key:i,value:e,valueSpec:r.source_video,style:n,validateSpec:s,styleSpec:r});case"image":return Mn({key:i,value:e,valueSpec:r.source_image,style:n,validateSpec:s,styleSpec:r});case"canvas":return[new Dt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return kn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function qn(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let s=[];const o=$r(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new Dt("light",e,`object expected, ${o} found`)]),s;for(const o in e){const a=o.match(/^(.*)-transition$/);s=s.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:i.transition,validateSpec:t.validateSpec,style:n,styleSpec:i}):r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new Dt(o,e[o],`unknown property "${o}"`)])}return s}function Gn(t){const e=t.value,i=t.styleSpec,r=i.sky,n=t.style,s=$r(e);if(void 0===e)return[];if("object"!==s)return[new Dt("sky",e,`object expected, ${s} found`)];let o=[];for(const s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],style:n,styleSpec:i}):[new Dt(s,e[s],`unknown property "${s}"`)]);return o}function Un(t){const e=t.value,i=t.styleSpec,r=i.terrain,n=t.style;let s=[];const o=$r(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new Dt("terrain",e,`object expected, ${o} found`)]),s;for(const o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new Dt(o,e[o],`unknown property "${o}"`)]);return s}function $n(t){let e=[];const i=t.value,r=t.key;if(Array.isArray(i)){const n=[],s=[];for(const o in i)i[o].id&&n.includes(i[o].id)&&e.push(new Dt(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),n.push(i[o].id),i[o].url&&s.includes(i[o].url)&&e.push(new Dt(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),s.push(i[o].url),e=e.concat(Mn({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Nn({key:r,value:i})}function Zn(t){return Boolean(t)&&t.constructor===Object}function Wn(t){return Zn(t.value)?[]:[new Dt(t.key,t.value,`object expected, ${$r(t.value)} found`)]}const Hn={"*":()=>[],array:En,boolean:function(t){const e=t.value,i=t.key,r=$r(e);return"boolean"!==r?[new Dt(i,e,`boolean expected, ${r} found`)]:[]},number:An,color:Dn,constants:Sn,enum:kn,filter:zn,function:In,layer:On,object:Mn,source:jn,light:qn,sky:Gn,terrain:Un,projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,n=t.style,s=$r(e);if(void 0===e)return[];if("object"!==s)return[new Dt("projection",e,`object expected, ${s} found`)];let o=[];for(const s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],style:n,styleSpec:i}):[new Dt(s,e[s],`unknown property "${s}"`)]);return o},projectionDefinition:function(t){const e=t.key;let i=t.value;i=i instanceof String?i.valueOf():i;const r=$r(i);return"array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(i)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(i)?["array","string"].includes(r)?[]:[new Dt(e,i,`projection expected, invalid type "${r}" found`)]:[new Dt(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Nn,formatted:function(t){return 0===Nn(t).length?[]:Pn(t)},resolvedImage:function(t){return 0===Nn(t).length?[]:Pn(t)},padding:function(t){const e=t.key,i=t.value;if("array"===$r(i)){if(i.length<1||i.length>4)return[new Dt(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let n=[];for(let s=0;s<i.length;s++)n=n.concat(t.validateSpec({key:`${e}[${s}]`,value:i[s],validateSpec:t.validateSpec,valueSpec:r}));return n}return An({key:e,value:i,valueSpec:{}})},numberArray:function(t){const e=t.key,i=t.value;if("array"===$r(i)){const r={type:"number"};if(i.length<1)return[new Dt(e,i,"array length at least 1 expected, length 0 found")];let n=[];for(let s=0;s<i.length;s++)n=n.concat(t.validateSpec({key:`${e}[${s}]`,value:i[s],validateSpec:t.validateSpec,valueSpec:r}));return n}return An({key:e,value:i,valueSpec:{}})},colorArray:function(t){const e=t.key,i=t.value;if("array"===$r(i)){if(i.length<1)return[new Dt(e,i,"array length at least 1 expected, length 0 found")];let t=[];for(let r=0;r<i.length;r++)t=t.concat(Dn({key:`${e}[${r}]`,value:i[r]}));return t}return Dn({key:e,value:i})},variableAnchorOffsetCollection:function(t){const e=t.key,i=t.value,r=$r(i),n=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new Dt(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let s=[];for(let r=0;r<i.length;r+=2)s=s.concat(kn({key:`${e}[${r}]`,value:i[r],valueSpec:n.layout_symbol["text-anchor"]})),s=s.concat(En({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:n}));return s},sprite:$n,state:Wn,fontFaces:function(t){const e=t.key,i=t.value,r=t.validateSpec,n=t.styleSpec,s=t.style;if(!Zn(i))return[new Dt(e,i,`object expected, ${$r(i)} found`)];const o=[];for(const t in i){const a=i[t],l=$r(a);if("string"===l)o.push(...Nn({key:`${e}.${t}`,value:a}));else if("array"===l){const i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[l,c]of a.entries())o.push(...Mn({key:`${e}.${t}[${l}]`,value:c,valueSpec:i,styleSpec:n,style:s,validateSpec:r}))}else o.push(new Dt(`${e}.${t}`,a,`string or array expected, ${l} found`))}return o}};function Xn(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=Xn,i.expression&&Zr(Tn(e))?In(t):i.expression&&en(Cn(e))?Pn(t):i.type&&Hn[i.type]?Hn[i.type](t):Mn(kt({},t,{valueSpec:i.type?r[i.type]:i}))}function Yn(t){const e=t.value,i=t.key,r=Nn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new Dt(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new Dt(i,e,'"glyphs" url must include a "{range}" token'))),r}function Kn(t,e=vt){let i=[];return i=i.concat(Xn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Xn,objectElementValidators:{glyphs:Yn,"*":()=>[]}})),t.constants&&(i=i.concat(Sn({key:"constants",value:t.constants}))),Qn(i)}function Jn(t){return function(e){return t(Object.assign({},e,{validateSpec:Xn}))}}function Qn(t){return[].concat(t).sort((t,e)=>t.line-e.line)}function ts(t){return function(...e){return Qn(t.apply(this,e))}}Kn.source=ts(Jn(jn)),Kn.sprite=ts(Jn($n)),Kn.glyphs=ts(Jn(Yn)),Kn.light=ts(Jn(qn)),Kn.sky=ts(Jn(Gn)),Kn.terrain=ts(Jn(Un)),Kn.state=ts(Jn(Wn)),Kn.layer=ts(Jn(On)),Kn.filter=ts(Jn(zn)),Kn.paintProperty=ts(Jn(Fn)),Kn.layoutProperty=ts(Jn(Bn));const es={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class is{constructor(t,e){this._globalState=e,this.setValue(t)}evaluate(){var t;return null!==(t=this._literalValue)&&void 0!==t?t:this._compiledValue.evaluate({})}setValue(t){if(null==t||"visible"===t||"none"===t)return this._literalValue="none"===t?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const e=rn(t,es,this._globalState);if("error"===e.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(e.value.map(t=>`${t.key}: ${t.message}`).join(", "));this._literalValue=void 0,this._compiledValue=e.value,this._globalStateRefs=cn(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const rs=vt,ns=Kn,ss=ns.light,os=ns.sky,as=ns.paintProperty,ls=ns.layoutProperty;function cs(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new gt(new Error(r.message))),i=!0;return i}class hs{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(let t=0;t<this.d*this.d;t++){const e=n[3+t],i=n[3+t+1];r.push(e===i?null:n.subarray(e,i))}const s=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],s),this.bboxes=n.subarray(s),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const n=i/e*t;this.min=-n,this.max=t+n}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,n,s){this.cells[n].push(s)}query(t,e,i,r,n){const s=this.min,o=this.max;if(t<=s&&e<=s&&o<=i&&o<=r&&!n)return Array.prototype.slice.call(this.keys);{const s=[];return this._forEachCell(t,e,i,r,this._queryCell,s,{},n),s}}_queryCell(t,e,i,r,n,s,o,a){const l=this.cells[n];if(null!==l){const n=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===o[u]){const l=4*u;(a?a(c[l+0],c[l+1],c[l+2],c[l+3]):t<=c[l+2]&&e<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(o[u]=!0,s.push(n[u])):o[u]=!1}}}}_forEachCell(t,e,i,r,n,s,o,a){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++){const c=this.d*l+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&n.call(this,t,e,i,r,c,s,o,a))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t<this.cells.length;t++)i+=this.cells[t].length;const r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=e;for(let e=0;e<t.length;e++){const i=t[e];r[3+e]=n,r.set(i,n),n+=i.length}return r[3+t.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+t.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new hs(t.buffer)}}const us={};function ps(t,e,i={}){if(us[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),us[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}ps("Object",Object),ps("Set",Set),ps("TransferableGridIndex",hs),ps("Color",Ee),ps("Error",Error),ps("AJAXError",ht),ps("ResolvedImage",Oe),ps("StylePropertyFunction",an),ps("StyleExpression",tn,{omit:["_evaluator"]}),ps("ZoomDependentExpression",sn),ps("ZoomConstantExpression",nn),ps("CompoundExpression",Dr,{omit:["_evaluate"]});for(const t in Pr)Pr[t]._classRegistryKey||ps(`Expression_${t}`,Pr[t]);function ds(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function fs(t){return t.$name||t.constructor._classRegistryKey}function ms(t){return!function(t){if(null===t||"object"!=typeof t)return!1;const e=fs(t);return!(!e||"Object"===e)}(t)&&(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||t instanceof Blob||t instanceof Error||ds(t)||H(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function _s(t,e){if(ms(t))return(ds(t)||H(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(_s(r,e));return i}if("object"!=typeof t)throw new Error("can't serialize object of type "+typeof t);const i=fs(t);if(!i)throw new Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!us[i])throw new Error(`${i} is not registered.`);const{klass:r}=us[i],n=r.serialize?r.serialize(t,e):{};if(r.serialize){if(e&&n===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in t){if(!t.hasOwnProperty(r))continue;if(us[i].omit.indexOf(r)>=0)continue;const s=t[r];n[r]=us[i].shallow.indexOf(r)>=0?s:_s(s,e)}t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}function gs(t){if(ms(t))return t;if(Array.isArray(t))return t.map(gs);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=fs(t)||"Object";if(!us[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=us[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const n=t[i];r[i]=us[e].shallow.indexOf(i)>=0?n:gs(n)}return r}class ys{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}function vs(t){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function xs(t){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function bs(t){return/\s/u.test(String.fromCodePoint(t))}function ws(t){for(const e of t)if(xs(e.codePointAt(0)))return!0;return!1}function Ss(t){for(const e of t)if(!Ms(e.codePointAt(0)))return!1;return!0}function Ts(t){const e=t.map(t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}}).filter(t=>t);return new RegExp(e.join("|"),"u")}const Cs=Ts(["Arab","Dupl","Mong","Ougr","Syrc"]);function Ms(t){return!Cs.test(String.fromCodePoint(t))}function Es(t){return!(xs(t)||(e=t,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e}const As=Ts(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Is(t){return As.test(String.fromCodePoint(t))}function Ps(t,e){return!(!e&&Is(t)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(t)))}function Ds(t){for(const e of t)if(Is(e.codePointAt(0)))return!0;return!1}const ks=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(ks.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,i){return e(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,r=new Promise(t=>{this.loadScriptResolve=t});i(e);const n=new Promise(t=>setTimeout(()=>t(),this.TIMEOUT));if(yield Promise.race([r,n]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)})}};class zs{constructor(t,e){this.isSupportedScript=Rs,this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new ys,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ys,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}function Rs(t){return function(t,e){for(const i of t)if(!Ps(i.codePointAt(0),e))return!1;return!0}(t,"loaded"===ks.getRTLTextPluginStatus())}const Ls="-transition";class Fs{constructor(t,e,i){this.property=t,this.value=e,this.expression=function(t,e,i){if(Zr(t))return new an(t,e);if(en(t)){const r=on(t,e,i);if("error"===r.result)throw new Error(r.value.map(t=>`${t.key}: ${t.message}`).join(", "));return r.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=Ee.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==e.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?i=Be.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(i=Ne.parse(t)):i=Re.parse(t):i=ze.parse(t):i=ke.parse(t),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Bs{constructor(t,e){this.property=t,this.value=new Fs(t,void 0,e)}transitioned(t,e){return new Ns(this.property,this.value,e,O({},t.transition,this.transition),t.now)}untransitioned(){return new Ns(this.property,this.value,null,{},0)}}class Os{constructor(t,e){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=e}getValue(t){return q(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Bs(this._values[t].property,this._globalState)),this._values[t].value=new Fs(this._values[t].property,null===e?void 0:q(e),this._globalState)}getTransition(t){return q(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Bs(this._values[t].property,this._globalState)),this._values[t].transition=q(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}${Ls}`]=r)}return t}transitioned(t,e){const i=new Vs(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new Vs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ns{constructor(t,e,i,r,n){this.property=t,this.value=e,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),s=this.prior;if(s){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return s.possiblyEvaluate(t,e,i);{const o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,e,i),n,z(o))}}return n}}class Vs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new Gs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class js{constructor(t,e){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=e}hasValue(t){return void 0!==this._values[t].value}getValue(t){return q(this._values[t].value)}setValue(t,e){this._values[t]=new Fs(this._values[t].property,null===e?void 0:q(e),this._globalState)}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new Gs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}}class qs{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class Gs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Us{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const r=mi[this.specification.type];return r?r(t,e,i):t}}class $s{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new qs(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new qs(this,{kind:"constant",value:void 0},t.parameters);const r=mi[this.specification.type];if(r){const n=r(t.value.value,e.value.value,i);return new qs(this,{kind:"constant",value:n},t.parameters)}return t}evaluate(t,e,i,r,n,s){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,s)}}class Zs extends $s{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new qs(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),s="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,o=this._calculate(s,s,s,e);return new qs(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new qs(this,{kind:"constant",value:i},e)}return new qs(this,t.expression,e)}evaluate(t,e,i,r,n,s){if("source"===t.kind){const o=t.evaluate(e,i,r,n,s);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Ws{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new zs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new zs(Math.floor(e.zoom),e)),t.expression.evaluate(new zs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Hs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Xs{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new Fs(i,void 0,void 0),n=this.defaultTransitionablePropertyValues[e]=new Bs(i,void 0);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}ps("DataDrivenProperty",$s),ps("DataConstantProperty",Us),ps("CrossFadedDataDrivenProperty",Zs),ps("CrossFadedProperty",Ws),ps("ColorRampProperty",Hs);class Ys extends yt{constructor(t,e,i){if(super(),this.id=t.id,this.type=t.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(t,e){return new is(t,e)}(this.visibility,i),"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=dn(t.filter,i)),e.layout&&(this._unevaluatedLayout=new js(e.layout,i)),e.paint)){this._transitionablePaint=new Os(e.paint,i);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Gs(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=dn(t,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;for(const e of this._visibilityExpression.getGlobalStateRefs())t.add(e);if(this._unevaluatedLayout)for(const e in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[e];for(const e of i.getGlobalStateRefs())t.add(e)}for(const e of this._featureFilter.getGlobalStateRefs())t.add(e);return t}getPaintAffectingGlobalStateRefs(){var t;const e=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const r=this._transitionablePaint._values[i].value;for(const n of r.getGlobalStateRefs()){const s=null!==(t=e.get(n))&&void 0!==t?t:[];s.push({name:i,value:r.value}),e.set(n,s)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,e,i={}){if(null==e||!this._validate(ls,`layers.${this.id}.layout.${t}`,t,e,i))return"visibility"===t?(this.visibility=e,this._visibilityExpression.setValue(e),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(t,e)}getPaintProperty(t){return t.endsWith(Ls)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(as,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(Ls))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,s,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t=this.minzoom,e=!1){return!!(this.minzoom&&t<(e?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(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)}serialize(){const 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),j(t,(t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&cs(this,t.call(ns,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:vt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof qs&&qr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}let Ks;var Js={get paint(){return Ks=Ks||new Xs({"raster-opacity":new Us(vt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Us(vt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Us(vt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Us(vt.paint_raster["raster-brightness-max"]),"raster-saturation":new Us(vt.paint_raster["raster-saturation"]),"raster-contrast":new Us(vt.paint_raster["raster-contrast"]),"raster-resampling":new Us(vt.paint_raster["raster-resampling"]),"raster-fade-duration":new Us(vt.paint_raster["raster-fade-duration"])})}};class Qs extends Ys{constructor(t,e){super(t,Js,e)}}const to={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class eo{constructor(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}}class io{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function ro(t,e=1){let i=0,r=0;return{members:t.map(t=>{const n=to[t.type].BYTES_PER_ELEMENT,s=i=no(i,Math.max(e,n)),o=t.components||1;return r=Math.max(r,n),i+=n*o,{name:t.name,type:t.type,components:o,offset:s}}),size:no(i,Math.max(r,e)),alignment:e}}function no(t,e){return Math.ceil(t/e)*e}class so extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}so.prototype.bytesPerElement=4,ps("StructArrayLayout2i4",so);class oo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}oo.prototype.bytesPerElement=6,ps("StructArrayLayout3i6",oo);class ao extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,t}}ao.prototype.bytesPerElement=8,ps("StructArrayLayout4i8",ao);class lo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,t}}lo.prototype.bytesPerElement=12,ps("StructArrayLayout2i4i12",lo);class co extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){const a=4*t,l=8*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=s,this.uint8[l+7]=o,t}}co.prototype.bytesPerElement=8,ps("StructArrayLayout2i4ub8",co);class ho extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}ho.prototype.bytesPerElement=8,ps("StructArrayLayout2f8",ho);class uo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,s,o,a,l,c)}emplace(t,e,i,r,n,s,o,a,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=s,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}uo.prototype.bytesPerElement=20,ps("StructArrayLayout10ui20",uo);class po extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,s,o,a)}emplace(t,e,i,r,n,s,o,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=s,this.uint16[c+5]=o,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}po.prototype.bytesPerElement=16,ps("StructArrayLayout8ui16",po);class fo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,c,h,u){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,n,s,o,a,l,c,h,u)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=s,this.uint16[d+5]=o,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=h,this.int16[d+10]=u,this.int16[d+11]=p,t}}fo.prototype.bytesPerElement=24,ps("StructArrayLayout4i4ui4i24",fo);class mo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}mo.prototype.bytesPerElement=12,ps("StructArrayLayout3f12",mo);class _o extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}_o.prototype.bytesPerElement=4,ps("StructArrayLayout1ul4",_o);class go extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,n,s,o,a,l)}emplace(t,e,i,r,n,s,o,a,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=s,this.int16[h+5]=o,this.uint32[u+3]=a,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}go.prototype.bytesPerElement=20,ps("StructArrayLayout6i1ul2ui20",go);class yo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,t}}yo.prototype.bytesPerElement=12,ps("StructArrayLayout2i2i2i12",yo);class vo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n)}emplace(t,e,i,r,n,s){const o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[a+6]=n,this.int16[a+7]=s,t}}vo.prototype.bytesPerElement=16,ps("StructArrayLayout2f1f2i16",vo);class xo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){const a=16*t,l=4*t,c=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[c+6]=s,this.int16[c+7]=o,t}}xo.prototype.bytesPerElement=16,ps("StructArrayLayout2ub2f2i16",xo);class bo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}bo.prototype.bytesPerElement=6,ps("StructArrayLayout3ui6",bo);class wo extends io{_refreshViews(){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)}emplaceBack(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g){const y=24*t,v=12*t,x=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=n,this.uint32[v+2]=s,this.uint32[v+3]=o,this.uint32[v+4]=a,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[v+7]=u,this.float32[v+8]=p,this.uint8[x+36]=d,this.uint8[x+37]=f,this.uint8[x+38]=m,this.uint32[v+10]=_,this.int16[y+22]=g,t}}wo.prototype.bytesPerElement=48,ps("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",wo);class So extends io{_refreshViews(){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)}emplaceBack(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C,M,E){const A=this.length;return this.resize(A+1),this.emplace(A,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C,M,E)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C,M,E,A){const I=32*t,P=16*t;return this.int16[I+0]=e,this.int16[I+1]=i,this.int16[I+2]=r,this.int16[I+3]=n,this.int16[I+4]=s,this.int16[I+5]=o,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=h,this.uint16[I+10]=u,this.uint16[I+11]=p,this.uint16[I+12]=d,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=_,this.uint16[I+16]=g,this.uint16[I+17]=y,this.uint16[I+18]=v,this.uint16[I+19]=x,this.uint16[I+20]=b,this.uint16[I+21]=w,this.uint16[I+22]=S,this.uint32[P+12]=T,this.float32[P+13]=C,this.float32[P+14]=M,this.uint16[I+30]=E,this.uint16[I+31]=A,t}}So.prototype.bytesPerElement=64,ps("StructArrayLayout8i15ui1ul2f2ui64",So);class To extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}To.prototype.bytesPerElement=4,ps("StructArrayLayout1f4",To);class Co extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[6*t+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}Co.prototype.bytesPerElement=12,ps("StructArrayLayout1ui2f12",Co);class Mo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=4*t;return this.uint32[2*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,t}}Mo.prototype.bytesPerElement=8,ps("StructArrayLayout1ul2ui8",Mo);class Eo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Eo.prototype.bytesPerElement=4,ps("StructArrayLayout2ui4",Eo);class Ao extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Ao.prototype.bytesPerElement=2,ps("StructArrayLayout1ui2",Ao);class Io extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,t}}Io.prototype.bytesPerElement=16,ps("StructArrayLayout4f16",Io);class Po extends eo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Po.prototype.size=20;class Do extends go{get(t){return new Po(this,t)}}ps("CollisionBoxArray",Do);class ko extends eo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}ko.prototype.size=48;class zo extends wo{get(t){return new ko(this,t)}}ps("PlacedSymbolArray",zo);class Ro extends eo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ro.prototype.size=64;class Lo extends So{get(t){return new Ro(this,t)}}ps("SymbolInstanceArray",Lo);class Fo extends To{getoffsetX(t){return this.float32[1*t+0]}}ps("GlyphOffsetArray",Fo);class Bo extends oo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ps("SymbolLineVertexArray",Bo);class Oo extends eo{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Oo.prototype.size=12;class No extends Co{get(t){return new Oo(this,t)}}ps("TextAnchorOffsetArray",No);class Vo extends eo{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Vo.prototype.size=8;class jo extends Mo{get(t){return new Vo(this,t)}}ps("FeatureIndexArray",jo);class qo extends so{}class Go extends so{}class Uo extends so{}class $o extends lo{}class Zo extends co{}class Wo extends ho{}class Ho extends uo{}class Xo extends po{}class Yo extends fo{}class Ko extends mo{}class Jo extends _o{}class Qo extends yo{}class ta extends xo{}class ea extends bo{}class ia extends Eo{}const ra=ro([{name:"a_pos",components:2,type:"Int16"}],4),{members:na}=ra;class sa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,e,i,r){const n=this.segments[this.segments.length-1];return t>sa.MAX_VERTEX_ARRAY_LENGTH&&U(`Max vertices per segment is ${sa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${sa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+t>sa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r?this.createNewSegment(e,i,r):n}createNewSegment(t,e,i){const r={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(t,e,i){return this.prepareSegment(0,t,e,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new sa([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function oa(t,e){return 256*(t=F(Math.floor(t),0,255))+F(Math.floor(e),0,255)}sa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ps("SegmentVector",sa);const aa=ro([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),la=ro([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var ca,ha,ua,pa={exports:{}},da={exports:{}},fa={exports:{}},ma=function(){if(ua)return pa.exports;ua=1;var t=(ca||(ca=1,da.exports=function(t,e){var i,r,n,s,o,a,l,c;for(r=t.length-(i=3&t.length),n=e,o=3432918353,a=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(s=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),da.exports),e=(ha||(ha=1,fa.exports=function(t,e){for(var i,r=t.length,n=e^r,s=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++s;switch(r){case 3:n^=(255&t.charCodeAt(s+2))<<16;case 2:n^=(255&t.charCodeAt(s+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(s)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),fa.exports);return pa.exports=t,pa.exports.murmur3=t,pa.exports.murmur2=e,pa.exports}(),_a=r(ma);class ga{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(ya(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ya(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return va(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new ga;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ya(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:_a(String(t))}function va(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let s=i-1,o=r+1;for(;;){do{s++}while(t[s]<n);do{o--}while(t[o]>n);if(s>=o)break;xa(t,s,o),xa(e,3*s,3*o),xa(e,3*s+1,3*o+1),xa(e,3*s+2,3*o+2)}o-i<r-o?(va(t,e,i,o),i=o+1):(va(t,e,o+1,r),r=o)}}function xa(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}ps("FeaturePositionMap",ga);class ba{constructor(t,e){this.gl=t.gl,this.location=e}}class wa extends ba{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Sa extends ba{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Ta extends ba{constructor(t,e){super(t,e),this.current=Ee.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Ca=new Float32Array(16);function Ma(t){return[oa(255*t.r,255*t.g),oa(255*t.b,255*t.a)]}class Ea{constructor(t,e,i){this.value=t,this.uniformNames=e.map(t=>`u_${t}`),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Ta(t,e):new wa(t,e)}}class Aa{constructor(t,e){this.uniformNames=e.map(t=>`u_${t}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,e){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,e.y,e.height,e.width]}setUniform(t,e,i,r){let n=null;"u_pattern_to"===r?n=this.patternTo:"u_pattern_from"===r?n=this.patternFrom:"u_dasharray_to"===r?n=this.dashTo:"u_dasharray_from"===r?n=this.dashFrom:"u_pixel_ratio_to"===r?n=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(n=this.pixelRatioFrom),null!==n&&t.set(n)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)||"u_dasharray_"===i.substr(0,12)?new Sa(t,e):new wa(t,e)}}class Ia{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map(t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(t,e,i){const r=this.paintVertexArray.length,n=this.expression.evaluate(new zs(0,i),e,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(r,t,n)}updatePaintArray(t,e,i,r,n){const s=this.expression.evaluate(new zs(0,n),i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=Ma(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Pa{constructor(t,e,i,r,n,s){this.expression=t,this.uniformNames=e.map(t=>`u_${t}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map(t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(t,e,i){const r=this.expression.evaluate(new zs(this.zoom,i),e,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new zs(this.zoom+1,i),e,{},i.canonical,[],i.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,r,n)}updatePaintArray(t,e,i,r,n){const s=this.expression.evaluate(new zs(this.zoom,n),i,r),o=this.expression.evaluate(new zs(this.zoom+1,n),i,r);this._setPaintValue(t,e,s,o)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=Ma(i),s=Ma(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],s[0],s[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=F(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new wa(t,e)}}class Da{constructor(t,e,i,r,n,s){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=s,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,this.getPositionIds(e),i)}updatePaintArray(t,e,i,r,n){this._setPaintValues(t,e,this.getPositionIds(i),n)}_setPaintValues(t,e,i,r){const n=this.getPositions(r);if(!n||!i)return;const s=n[i.min],o=n[i.mid],a=n[i.max];if(s&&o&&a)for(let i=t;i<e;i++)this.emplace(this.zoomInPaintVertexArray,i,o,s),this.emplace(this.zoomOutPaintVertexArray,i,o,a)}upload(t){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const e=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,e,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,e,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ka extends Da{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns&&t.patterns[this.layerId]}getVertexAttributes(){return aa.members}emplace(t,e,i,r){t.emplace(e,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}}class za extends Da{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes&&t.dashes[this.layerId]}getVertexAttributes(){return la.members}emplace(t,e,i,r){t.emplace(e,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}}class Ra{constructor(t,e,i){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const s=t.paint.get(n);if(!(s instanceof qs&&qr(s.property.specification)))continue;const o=Fa(n,t.type),a=s.value,l=s.property.specification.type,c=s.property.useIntegerZoom,h=s.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===a.kind)this.binders[n]=u?new Aa(a.value,o):new Ea(a.value,o,l),r.push(`/u_${n}`);else if("source"===a.kind||u){const i=Ba(n,l,"source");this.binders[n]=u?"line-dasharray"===n?new za(a,l,c,e,i,t.id):new ka(a,l,c,e,i,t.id):new Ia(a,o,l,i),r.push(`/a_${n}`)}else{const t=Ba(n,l,"composite");this.binders[n]=new Pa(a,o,l,c,e,t),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Ia||e instanceof Pa?e.maxValue:0}populatePaintArrays(t,e,i){for(const r in this.binders){const n=this.binders[r];(n instanceof Ia||n instanceof Pa||n instanceof Da)&&n.populatePaintArray(t,e,i)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof Aa&&r.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof Aa&&r.setConstantDashPositions(t,e)}}updatePaintArrays(t,e,i,r,n){let s=!1;for(const o in t){const a=e.getPositions(o);for(const e of a){const a=i.feature(e.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof Ia||l instanceof Pa||l instanceof Da)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(e.start,e.end,a,t[o],n),s=!0}}}}return s}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Ea||i instanceof Aa)&&t.push(...i.uniformNames.map(t=>`#define HAS_UNIFORM_${t}`))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Ia||i instanceof Pa)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name);else if(i instanceof Da){const e=i.getVertexAttributes();for(const i of e)t.push(i.name)}}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Ea||i instanceof Aa||i instanceof Pa)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Ea||n instanceof Aa||n instanceof Pa)for(const s of n.uniformNames)if(e[s]){const o=n.getBinding(t,e[s],s);i.push({name:s,property:r,binding:o})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:s}of e)this.binders[n].setUniform(s,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof Da){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Ia||i instanceof Pa)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof Ia||i instanceof Pa||i instanceof Da)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Ia||e instanceof Pa||e instanceof Da)&&e.destroy()}}}class La{constructor(t,e,i=()=>!0){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new Ra(r,e,i);this.needsUpload=!1,this._featureMap=new ga,this._bufferOffset=0}populatePaintArrays(t,e,i,r){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function Fa(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function Ba(t,e,i){const r={color:{source:ho,composite:Io},number:{source:To,composite:ho}},n=function(t){return{"line-pattern":{source:Ho,composite:Ho},"fill-pattern":{source:Ho,composite:Ho},"fill-extrusion-pattern":{source:Ho,composite:Ho},"line-dasharray":{source:Xo,composite:Xo}}[t]}(t);return n&&n[i]||r[e][i]}ps("ConstantBinder",Ea),ps("CrossFadedConstantBinder",Aa),ps("SourceExpressionBinder",Ia),ps("CrossFadedPatternBinder",ka),ps("CrossFadedDasharrayBinder",za),ps("CompositeExpressionBinder",Pa),ps("ProgramConfiguration",Ra,{omit:["_buffers"]}),ps("ProgramConfigurationSet",La);const Oa=Math.pow(2,14)-1,Na=-Oa-1;function Va(t){const e=I/t.extent,i=t.loadGeometry();for(let t=0;t<i.length;t++){const r=i[t];for(let t=0;t<r.length;t++){const i=r[t],n=Math.round(i.x*e),s=Math.round(i.y*e);i.x=F(n,Na,Oa),i.y=F(s,Na,Oa),(n<i.x||n>i.x+1||s<i.y||s>i.y+1)&&U("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function ja(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Va(t):[]}}const qa=-32768;function Ga(t,e,i,r,n){t.emplaceBack(qa+8*e+r,qa+8*i+n)}class Ua{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Go,this.indexArray=new ea,this.segments=new sa,this.programConfigurations=new La(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,e,i){const r=this.layers[0],n=[];let s=null,o=!1,a="heatmap"===r.type;if("circle"===r.type){const t=r;s=t.layout.get("circle-sort-key"),o=!s.isConstant(),a=a||"map"===t.paint.get("circle-pitch-alignment")}const l=a?e.subdivisionGranularity.circle:1;for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ja(e,t);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),c,i))continue;const h=o?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Va(e),patterns:{},sortKey:h};n.push(u)}o&&n.sort((t,e)=>t.sortKey-e.sortKey);for(const r of n){const{geometry:n,index:s,sourceLayerIndex:o}=r,a=t[s].feature;this.addFeature(r,n,s,i,l),e.featureIndex.insert(a,n,s,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,na),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r,n=1){let s;switch(n){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}const o=s.length;for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=I||r<0||r>=I)continue;const n=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),a=n.vertexLength;for(let t=0;t<o;t++)for(let e=0;e<o;e++)Ga(this.layoutVertexArray,i,r,s[e],s[t]);for(let t=0;t<o-1;t++)for(let e=0;e<o-1;e++){const i=a+t*o+e,r=a+(t+1)*o+e;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}n.vertexLength+=o*o,n.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:{},canonical:r})}}function $a(t,e){for(let i=0;i<t.length;i++)if(tl(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(tl(t,e[i]))return!0;return!!Xa(t,e)}function Za(t,e,i){return!!tl(t,e)||!!Ka(e,t,i)}function Wa(t,e){if(1===t.length)return Qa(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(tl(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(Qa(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Xa(t,e[i]))return!0;return!1}function Ha(t,e,i){if(t.length>1){if(Xa(t,e))return!0;for(let r=0;r<e.length;r++)if(Ka(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(Ka(t[r],e,i))return!0;return!1}function Xa(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(Ya(r,n,e[t],e[t+1]))return!0}return!1}function Ya(t,e,i,r){return $(t,i,r)!==$(e,i,r)&&$(t,e,i)!==$(t,e,r)}function Ka(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(Ja(t,e[i-1],e[i])<r)return!0;return!1}function Ja(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function Qa(t,e){let i,r,n,s=!1;for(let o=0;o<t.length;o++){i=t[o];for(let t=0,o=i.length-1;t<i.length;o=t++)r=i[t],n=i[o],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(s=!s)}return s}function tl(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const s=t[r],o=t[n];s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(i=!i)}return i}function el(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const s=$(t,e,i[0]);return s!==$(t,e,i[1])||s!==$(t,e,i[2])||s!==$(t,e,i[3])}function il(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function rl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function nl(t,e,r,n,s){if(!e[0]&&!e[1])return t;const o=i.convert(e)._mult(s);"viewport"===r&&o._rotate(-n);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(o));return a}function sl(t){const e=[];for(let i=0;i<t.length;i++){const r=t[i],n=e.at(-1);(0===i||n&&!r.equals(n))&&e.push(r)}return e}function ol({queryGeometry:t,size:e},i){return Za(t,i,e)}function al({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){return Za(t,s,e*(i.projectTileCoordinates(s.x,s.y,r,n).signedDistanceFromCamera/i.cameraToCenterDistance))}function ll({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){const o=i.projectTileCoordinates(s.x,s.y,r,n).signedDistanceFromCamera,a=e*(i.cameraToCenterDistance/o);return Za(t,ul(s,i,r,n),a)}function cl({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){return Za(t,ul(s,i,r,n),e)}function hl({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n,pitchAlignment:s="map",pitchScale:o="map"},a){const l="map"===s?"map"===o?ol:al:"map"===o?ll:cl,c={queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n};for(const t of a)for(const e of t)if(l(c,e))return!0;return!1}function ul(t,e,r,n){const s=e.projectTileCoordinates(t.x,t.y,r,n).point;return new i((.5*s.x+.5)*e.width,(.5*-s.y+.5)*e.height)}let pl,dl;ps("CircleBucket",Ua,{omit:["layers"]});var fl={get paint(){return dl=dl||new Xs({"circle-radius":new $s(vt.paint_circle["circle-radius"]),"circle-color":new $s(vt.paint_circle["circle-color"]),"circle-blur":new $s(vt.paint_circle["circle-blur"]),"circle-opacity":new $s(vt.paint_circle["circle-opacity"]),"circle-translate":new Us(vt.paint_circle["circle-translate"]),"circle-translate-anchor":new Us(vt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Us(vt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Us(vt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new $s(vt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new $s(vt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new $s(vt.paint_circle["circle-stroke-opacity"])})},get layout(){return pl=pl||new Xs({"circle-sort-key":new $s(vt.layout_circle["circle-sort-key"])})}};class ml extends Ys{constructor(t,e){super(t,fl,e)}createBucket(t){return new Ua(t)}queryRadius(t){const e=t;return il("circle-radius",this,e)+il("circle-stroke-width",this,e)+rl(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){const l=nl(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,s),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h=this.paint.get("circle-pitch-scale"),u=this.paint.get("circle-pitch-alignment");let p,d;return"map"===u?(p=l,d=c*s):(p=function(t,e,i,r){return t.map(t=>ul(t,e,i,r))}(l,n,o,a),d=c),hl({queryGeometry:p,size:d,transform:n,unwrappedTileID:o,getElevation:a,pitchAlignment:u,pitchScale:h},r)}}class _l extends Ua{}let gl;ps("HeatmapBucket",_l,{omit:["layers"]});var yl={get paint(){return gl=gl||new Xs({"heatmap-radius":new $s(vt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new $s(vt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Us(vt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Hs(vt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Us(vt.paint_heatmap["heatmap-opacity"])})}};function vl(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${n.length} but got: ${e*i*r}`)}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function xl(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const n=vl({},{width:e,height:i},r);bl(t,n,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=n.data}function bl(t,e,i,r,n,s){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=e.data;if(o===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*s,h=((r.y+l)*e.width+r.x)*s;for(let t=0;t<n.width*s;t++)a[h+t]=o[c+t]}return e}class wl{constructor(t,e){vl(this,t,1,e)}resize(t){xl(this,t,1)}clone(){return new wl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){bl(t,e,i,r,n,1)}}class Sl{constructor(t,e){vl(this,t,4,e)}resize(t){xl(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Sl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){bl(t,e,i,r,n,4)}setPixel(t,e,i){const r=4*(t*this.width+e);this.data[r+0]=Math.round(255*i.r/i.a),this.data[r+1]=Math.round(255*i.g/i.a),this.data[r+2]=Math.round(255*i.b/i.a),this.data[r+3]=Math.round(255*i.a)}}function Tl(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new Sl({width:i,height:r});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const s=(r,s,o)=>{e[t.evaluationKey]=o;const a=t.expression.evaluate(e);n.setPixel(r/4/i,s/4,a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,o=0;r<i;r++,o+=4){const a=r/(i-1),{start:l,end:c}=t.clips[e];s(n,o,l*(1-a)+c*a)}else for(let t=0,e=0;t<i;t++,e+=4)s(0,e,t/(i-1));return n}ps("AlphaImage",wl),ps("RGBAImage",Sl);const Cl="big-fb";class Ml extends Ys{createBucket(t){return new _l(t)}constructor(t,e){super(t,yl,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Tl({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Cl)&&this.heatmapFbos.delete(Cl)}queryRadius(t){return il("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){return hl({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(e,i)*s,transform:n,unwrappedTileID:o,getElevation:a},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}}let El;var Al={get paint(){return El=El||new Xs({"hillshade-illumination-direction":new Us(vt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Us(vt.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Us(vt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Us(vt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Us(vt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Us(vt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Us(vt.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Us(vt.paint_hillshade["hillshade-method"])})}};class Il extends Ys{constructor(t,e){super(t,Al,e),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,e=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values;const n=Math.max(t.length,e.length,i.length,r.length);t=t.concat(Array(n-t.length).fill(t.at(-1))),e=e.concat(Array(n-e.length).fill(e.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1)));const s=e.map(tt);return{directionRadians:t.map(tt),altitudeRadians:s,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}}let Pl;var Dl={get paint(){return Pl=Pl||new Xs({"color-relief-opacity":new Us(vt["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Hs(vt["paint_color-relief"]["color-relief-color"])})}};class kl{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:n}=t,s=!(this.size&&this.size[0]===r&&this.size[1]===n||i),{context:o}=this,{gl:a}=o;if(this.useMipmap=Boolean(e&&e.useMipmap),a.bindTexture(a.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!e||!1!==e.premultiply)),s)this.size=[r,n],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||H(t)?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,t):a.texImage2D(a.TEXTURE_2D,0,this.format,r,n,0,this.format,a.UNSIGNED_BYTE,t.data);else{const{x:e,y:s}=i||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||H(t)?a.texSubImage2D(a.TEXTURE_2D,0,e,s,a.RGBA,a.UNSIGNED_BYTE,t):a.texSubImage2D(a.TEXTURE_2D,0,e,s,r,n,a.RGBA,a.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&a.generateMipmap(a.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(t,e,i){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),i!==n.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=n.LINEAR),t!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class zl{constructor(t,e,i,r=1,n=1,s=1,o=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i))return void U(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const a=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=r,this.greenFactor=n,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;t<a;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(a,t)]=this.data[this._idx(a-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,a)]=this.data[this._idx(t,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<a;t++)for(let e=0;e<a;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),r=4*this._idx(t,e);return this.unpack(i[r],i[r+1],i[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);return(e+1)*this.stride+(t+1)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}pack(t){return Rl(t,this.getUnpackVector())}getPixels(){return new Sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:s=o-1;break;case 1:o=s+1}const a=-e*this.dim,l=-i*this.dim;for(let e=s;e<o;e++)for(let i=r;i<n;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+a,e+l)]}}function Rl(t,e){const i=e[0],r=e[1],n=e[2],s=e[3],o=Math.min(i,r,n),a=Math.round((t+s)/o);return{r:Math.floor(a*o/i)%256,g:Math.floor(a*o/r)%256,b:Math.floor(a*o/n)%256}}ps("DEMData",zl);class Ll extends Ys{constructor(t,e){super(t,Dl,e)}_createColorRamp(t){const e={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof nn&&i._styleExpression.expression instanceof di){this.colorRampExpression=i;const t=i._styleExpression.expression;e.elevationStops=t.labels,e.colorStops=[];for(const i of e.elevationStops)e.colorStops.push(t.evaluate({globals:{elevation:i}}))}if(e.elevationStops.length<1&&(e.elevationStops=[0],e.colorStops=[Ee.transparent]),e.elevationStops.length<2&&(e.elevationStops.push(e.elevationStops[0]+1),e.colorStops.push(e.colorStops[0])),e.elevationStops.length<=t)return e;const r={elevationStops:[],colorStops:[]},n=(e.elevationStops.length-1)/(t-1);for(let t=0;t<e.elevationStops.length-.5;t+=n)r.elevationStops.push(e.elevationStops[Math.round(t)]),r.colorStops.push(e.colorStops[Math.round(t)]);return U(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${e.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,e,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const r=this._createColorRamp(e),n=new Sl({width:r.colorStops.length,height:1}),s=new Sl({width:r.colorStops.length,height:1});for(let t=0;t<r.elevationStops.length;t++){const e=Rl(r.elevationStops[t],i);s.setPixel(0,t,new Ee(e.r/255,e.g/255,e.b/255,1)),n.setPixel(0,t,r.colorStops[t])}return this.colorRampTextures={elevationTexture:new kl(t,s,t.gl.RGBA),colorTexture:new kl(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Fl=ro([{name:"a_pos",components:2,type:"Int16"}],4),{members:Bl}=Fl;function Ol(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);const s=e.constantOr(null);s&&(n=!0,r[s.to]=!0,r[s.from]=!0)}return n}function Nl(t,e,i,r,n){const{zoom:s}=r,o=n.patternDependencies;for(const r of e){const e=r.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:s-1},i,{},n.availableImages),a=e.evaluate({zoom:s},i,{},n.availableImages),l=e.evaluate({zoom:s+1},i,{},n.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,i.patterns[r.id]={min:t,mid:a,max:l}}}return i}function Vl(t,e,i,r,n){let s;if(n===function(t,e,i,r){let n=0;for(let s=e,o=i-r;s<i;s+=r)n+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return n}(t,e,i,r)>0)for(let n=e;n<i;n+=r)s=lc(n/r|0,t[n],t[n+1],s);else for(let n=i-r;n>=e;n-=r)s=lc(n/r|0,t[n],t[n+1],s);return s&&ic(s,s.next)&&(cc(s),s=s.next),s}function jl(t,e){if(!t)return t;e||(e=t);let i,r=t;do{if(i=!1,r.steiner||!ic(r,r.next)&&0!==ec(r.prev,r,r.next))r=r.next;else{if(cc(r),r=e=r.prev,r===r.next)break;i=!0}}while(i||r!==e);return e}function ql(t,e,i,r,n,s,o){if(!t)return;!o&&s&&function(t,e,i,r){let n=t;do{0===n.z&&(n.z=Yl(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let e,i=1;do{let r,n=t;t=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let l=i;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||n.z<=o.z)?(r=n,n=n.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=o}s.nextZ=null,i*=2}while(e>1)}(n)}(t,r,n,s);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(s?Ul(t,r,n,s):Gl(t))e.push(l.i,t.i,c.i),cc(t),t=c.next,a=c.next;else if((t=c)===a){o?1===o?ql(t=$l(jl(t),e),e,i,r,n,s,2):2===o&&Zl(t,e,i,r,n,s):ql(jl(t),e,i,r,n,s,1);break}}}function Gl(t){const e=t.prev,i=t,r=t.next;if(ec(e,i,r)>=0)return!1;const n=e.x,s=i.x,o=r.x,a=e.y,l=i.y,c=r.y,h=Math.min(n,s,o),u=Math.min(a,l,c),p=Math.max(n,s,o),d=Math.max(a,l,c);let f=r.next;for(;f!==e;){if(f.x>=h&&f.x<=p&&f.y>=u&&f.y<=d&&Ql(n,a,s,l,o,c,f.x,f.y)&&ec(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ul(t,e,i,r){const n=t.prev,s=t,o=t.next;if(ec(n,s,o)>=0)return!1;const a=n.x,l=s.x,c=o.x,h=n.y,u=s.y,p=o.y,d=Math.min(a,l,c),f=Math.min(h,u,p),m=Math.max(a,l,c),_=Math.max(h,u,p),g=Yl(d,f,e,i,r),y=Yl(m,_,e,i,r);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z<=y;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==o&&Ql(a,h,l,u,c,p,v.x,v.y)&&ec(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==o&&Ql(a,h,l,u,c,p,x.x,x.y)&&ec(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==o&&Ql(a,h,l,u,c,p,v.x,v.y)&&ec(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==o&&Ql(a,h,l,u,c,p,x.x,x.y)&&ec(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function $l(t,e){let i=t;do{const r=i.prev,n=i.next.next;!ic(r,n)&&rc(r,i,i.next,n)&&oc(r,n)&&oc(n,r)&&(e.push(r.i,i.i,n.i),cc(i),cc(i.next),i=t=n),i=i.next}while(i!==t);return jl(i)}function Zl(t,e,i,r,n,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&tc(o,t)){let a=ac(o,t);return o=jl(o,o.next),a=jl(a,a.next),ql(o,e,i,r,n,s,0),void ql(a,e,i,r,n,s,0)}t=t.next}o=o.next}while(o!==t)}function Wl(t,e){let i=t.x-e.x;return 0===i&&(i=t.y-e.y,0===i)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function Hl(t,e){const i=function(t,e){let i=e;const r=t.x,n=t.y;let s,o=-1/0;if(ic(t,i))return i;do{if(ic(t,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=r&&t>o&&(o=t,s=i.x<i.next.x?i:i.next,t===r))return s}i=i.next}while(i!==e);if(!s)return null;const a=s,l=s.x,c=s.y;let h=1/0;i=s;do{if(r>=i.x&&i.x>=l&&r!==i.x&&Jl(n<c?r:o,n,l,c,n<c?o:r,n,i.x,i.y)){const e=Math.abs(n-i.y)/(r-i.x);oc(i,t)&&(e<h||e===h&&(i.x>s.x||i.x===s.x&&Xl(s,i)))&&(s=i,h=e)}i=i.next}while(i!==a);return s}(t,e);if(!i)return e;const r=ac(i,t);return jl(r,r.next),jl(i,i.next)}function Xl(t,e){return ec(t.prev,t,e.prev)<0&&ec(e.next,t,t.next)<0}function Yl(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Kl(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Jl(t,e,i,r,n,s,o,a){return(n-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(s-a)>=(n-o)*(r-a)}function Ql(t,e,i,r,n,s,o,a){return!(t===o&&e===a)&&Jl(t,e,i,r,n,s,o,a)}function tc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&rc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(oc(t,e)&&oc(e,t)&&function(t,e){let i=t,r=!1;const n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(ec(t.prev,t,e.prev)||ec(t,e.prev,e))||ic(t,e)&&ec(t.prev,t,t.next)>0&&ec(e.prev,e,e.next)>0)}function ec(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function ic(t,e){return t.x===e.x&&t.y===e.y}function rc(t,e,i,r){const n=sc(ec(t,e,i)),s=sc(ec(t,e,r)),o=sc(ec(i,r,t)),a=sc(ec(i,r,e));return n!==s&&o!==a||!(0!==n||!nc(t,i,e))||!(0!==s||!nc(t,r,e))||!(0!==o||!nc(i,t,r))||!(0!==a||!nc(i,e,r))}function nc(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function sc(t){return t>0?1:t<0?-1:0}function oc(t,e){return ec(t.prev,t,t.next)<0?ec(t,e,t.next)>=0&&ec(t,t.prev,e)>=0:ec(t,e,t.prev)<0||ec(t,t.next,e)<0}function ac(t,e){const i=hc(t.i,t.x,t.y),r=hc(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function lc(t,e,i,r){const n=hc(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function cc(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 hc(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class uc{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class pc{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}pc.noSubdivision=new pc({fill:new uc(0,0),line:new uc(0,0),tile:new uc(0,0),stencil:new uc(0,0),circle:1}),ps("SubdivisionGranularityExpression",uc),ps("SubdivisionGranularitySetting",pc);const dc=-32768,fc=32767;class mc{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=I/t,this._canonical=e}_getKey(t,e){return(t+=32768)<<16|e+32768}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(t),r=0|Math.round(e),n=this._getKey(i,r);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,s),this._vertexBuffer.push(i,r),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const i=[];for(let r=0;r<e.length;r+=3){const n=e[r],s=e[r+1],o=e[r+2],a=t[2*n],l=t[2*n+1];(t[2*s]-a)*(t[2*o+1]-l)-(t[2*s+1]-l)*(t[2*o]-a)>0?(i.push(n),i.push(o),i.push(s)):(i.push(n),i.push(s),i.push(o))}return i}(this._vertexBuffer,t);const e=[],i=t.length;for(let r=0;r<i;r+=3){const i=[t[r+0],t[r+1],t[r+2]],n=[this._vertexBuffer[2*t[r+0]+0],this._vertexBuffer[2*t[r+0]+1],this._vertexBuffer[2*t[r+1]+0],this._vertexBuffer[2*t[r+1]+1],this._vertexBuffer[2*t[r+2]+0],this._vertexBuffer[2*t[r+2]+1]];let s=1/0,o=1/0,a=-1/0,l=-1/0;for(let t=0;t<3;t++){const e=n[2*t],i=n[2*t+1];s=Math.min(s,e),a=Math.max(a,e),o=Math.min(o,i),l=Math.max(l,i)}if(s===a||o===l)continue;const c=Math.floor(s/this._granularityCellSize),h=Math.ceil(a/this._granularityCellSize),u=Math.floor(o/this._granularityCellSize),p=Math.ceil(l/this._granularityCellSize);if(c!==h||u!==p)for(let t=u;t<p;t++){const r=this._scanlineGenerateVertexRingForCellRow(t,n,i);yc(this._vertexBuffer,r,e)}else e.push(...i)}return e}_scanlineGenerateVertexRingForCellRow(t,e,i){const r=t*this._granularityCellSize,n=r+this._granularityCellSize,s=[];for(let t=0;t<3;t++){const o=e[2*t],a=e[2*t+1],l=e[2*(t+1)%6],c=e[(2*(t+1)+1)%6],h=e[2*(t+2)%6],u=e[(2*(t+2)+1)%6],p=l-o,d=c-a,f=0===p,m=0===d,_=(r-a)/d,g=(n-a)/d,y=Math.min(_,g),v=Math.max(_,g);if(!m&&(y>=1||v<=0)||m&&(a<r||a>n)){c>=r&&c<=n&&s.push(i[(t+1)%3]);continue}!m&&y>0&&s.push(this._vertexToIndex(o+p*y,a+d*y));const x=o+p*Math.max(y,0),b=o+p*Math.min(v,1);f||this._generateIntraEdgeVertices(s,o,a,l,c,x,b),!m&&v<1&&s.push(this._vertexToIndex(o+p*v,a+d*v)),(m||c>=r&&c<=n)&&s.push(i[(t+1)%3]),!m&&(c<=r||c>=n)&&this._generateInterEdgeVertices(s,o,a,l,c,h,u,b,r,n)}return s}_generateIntraEdgeVertices(t,e,i,r,n,s,o){const a=r-e,l=n-i,c=0===l,h=c?Math.min(e,r):Math.min(s,o),u=c?Math.max(e,r):Math.max(s,o),p=Math.floor(h/this._granularityCellSize)+1,d=Math.ceil(u/this._granularityCellSize)-1;if(c?e<r:s<o)for(let r=p;r<=d;r++){const n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}else for(let r=d;r>=p;r--){const n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}}_generateInterEdgeVertices(t,e,i,r,n,s,o,a,l,c){const h=n-i,u=s-r,p=o-n,d=(l-n)/p,f=(c-n)/p,m=Math.min(d,f),_=Math.max(d,f),g=r+u*m;let y=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,x=a<g;const b=0===p;if(b&&(o===l||o===c))return;if(b||m>=1||_<=0){const t=i-o,r=s+(e-s)*Math.min((l-o)/t,(c-o)/t);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,x=a<r}const w=h>0?c:l;if(x)for(let e=y;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,w));else for(let e=v;e>=y;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,w))}_generateOutline(t){const e=[];for(const i of t){const t=gc(i,this._granularity,!0),r=this._pointArrayToIndices(t),n=[];for(let t=1;t<r.length;t++)n.push(r[t-1]),n.push(r[t]);e.push(n)}return e}_handlePoles(t){let e=!1,i=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(e||i)&&this._fillPoles(t,e,i)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){const i=t[e+1];i===dc&&(t[e+1]=-32767),i===fc&&(t[e+1]=32766)}}_generatePoleQuad(t,e,i,r,n,s){r>n!=(s===dc)?(t.push(e),t.push(i),t.push(this._vertexToIndex(r,s)),t.push(i),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(r,s))):(t.push(i),t.push(e),t.push(this._vertexToIndex(r,s)),t.push(this._vertexToIndex(n,s)),t.push(i),t.push(this._vertexToIndex(r,s)))}_fillPoles(t,e,i){const r=this._vertexBuffer,n=I,s=t.length;for(let o=2;o<s;o+=3){const s=t[o-2],a=t[o-1],l=t[o],c=r[2*s],h=r[2*s+1],u=r[2*a],p=r[2*a+1],d=r[2*l],f=r[2*l+1];e&&(0===h&&0===p&&this._generatePoleQuad(t,s,a,c,u,dc),0===p&&0===f&&this._generatePoleQuad(t,a,l,u,d,dc),0===f&&0===h&&this._generatePoleQuad(t,l,s,d,c,dc)),i&&(h===n&&p===n&&this._generatePoleQuad(t,s,a,c,u,fc),p===n&&f===n&&this._generatePoleQuad(t,a,l,u,d,fc),f===n&&h===n&&this._generatePoleQuad(t,l,s,d,c,fc))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:r}=function(t){const e=[],i=[];for(const r of t)if(0!==r.length){r!==t[0]&&e.push(i.length/2);for(let t=0;t<r.length;t++)i.push(r[t].x),i.push(r[t].y)}return{flattened:i,holeIndices:e}}(t);let n;this._initializeVertices(i);try{const t=function(t,e,i=2){const r=e&&e.length,n=r?e[0]*i:t.length;let s=Vl(t,0,n,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=function(t,e,i,r){const n=[];for(let i=0,s=e.length;i<s;i++){const o=Vl(t,e[i]*r,i<s-1?e[i+1]*r:t.length,r,!1);o===o.next&&(o.steiner=!0),n.push(Kl(o))}n.sort(Wl);for(let t=0;t<n.length;t++)i=Hl(n[t],i);return i}(t,e,s,i)),t.length>80*i){a=t[0],l=t[1];let e=a,r=l;for(let s=i;s<n;s+=i){const i=t[s],n=t[s+1];i<a&&(a=i),n<l&&(l=n),i>e&&(e=i),n>r&&(r=n)}c=Math.max(e-a,r-l),c=0!==c?32767/c:0}return ql(s,o,i,a,l,c,0),o}(i,r),e=this._convertIndices(i,t);n=this._subdivideTrianglesScanline(e)}catch(t){console.error(t)}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(n),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:s}}_convertIndices(t,e){const i=[];for(let r=0;r<e.length;r++)i.push(this._vertexToIndex(t[2*e[r]],t[2*e[r]+1]));return i}_pointArrayToIndices(t){const e=[];for(let i=0;i<t.length;i++){const r=t[i];e.push(this._vertexToIndex(r.x,r.y))}return e}}function _c(t,e,i,r=!0){return new mc(i,e).subdividePolygonInternal(t,r)}function gc(t,e,r=!1){if(!t||t.length<1)return[];if(t.length<2)return[];const n=t[0],s=t[t.length-1],o=r&&(n.x!==s.x||n.y!==s.y);if(e<2)return o?[...t,t[0]]:[...t];const a=Math.floor(I/e),l=[];l.push(new i(t[0].x,t[0].y));const c=t.length,h=o?c:c-1;for(let e=0;e<h;e++){const r=t[e],n=e<c-1?t[e+1]:t[0],s=r.x,o=r.y,h=n.x,u=n.y,p=s!==h,d=o!==u;if(!p&&!d)continue;const f=h-s,m=u-o,_=Math.abs(f),g=Math.abs(m);let y=s,v=o;for(;;){const t=f>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,e=m>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(y-t),n=Math.abs(v-e),s=Math.abs(y-h),o=Math.abs(v-u),c=p?r/_:Number.POSITIVE_INFINITY,x=d?n/g:Number.POSITIVE_INFINITY;if((s<=r||!p)&&(o<=n||!d))break;if(c<x&&p||!d){y=t,v+=m*c;const e=new i(y,Math.round(v));l[l.length-1].x===e.x&&l[l.length-1].y===e.y||l.push(e)}else{y+=f*x,v=e;const t=new i(Math.round(y),v);l[l.length-1].x===t.x&&l[l.length-1].y===t.y||l.push(t)}}const x=new i(h,u);l[l.length-1].x===x.x&&l[l.length-1].y===x.y||l.push(x)}return l}function yc(t,e,i){if(0===e.length)throw new Error("Subdivision vertex ring is empty.");let r=0,n=t[2*e[0]];for(let i=1;i<e.length;i++){const s=t[2*e[i]];s<n&&(n=s,r=i)}const s=e.length;let o=r,a=(o+1)%s;for(;;){const r=o-1>=0?o-1:s-1,n=(a+1)%s,l=t[2*e[r]],c=t[2*e[n]],h=t[2*e[o]],u=t[2*e[o]+1],p=t[2*e[a]+1];let d=!1;if(l<c)d=!0;else if(l>c)d=!1;else{const i=p-u,s=-(t[2*e[a]]-h),o=u<p?1:-1;((l-h)*i+(t[2*e[r]+1]-u)*s)*o>((c-h)*i+(t[2*e[n]+1]-u)*s)*o&&(d=!0)}if(d){const t=e[r],n=e[o],l=e[a];t!==n&&t!==l&&n!==l&&i.push(l,n,t),o--,o<0&&(o=s-1)}else{const t=e[n],r=e[o],l=e[a];t!==r&&t!==l&&r!==l&&i.push(l,r,t),a++,a>=s&&(a=0)}if(r===n)break}}function vc(t,e,i,r,n,s,o,a,l){const c=n.length/2,h=o&&a&&l;if(c<sa.MAX_VERTEX_ARRAY_LENGTH){const u=e.prepareSegment(c,i,r),p=u.vertexLength;for(let t=0;t<s.length;t+=3)r.emplaceBack(p+s[t],p+s[t+1],p+s[t+2]);let d,f;u.vertexLength+=c,u.primitiveLength+=s.length/3,h&&(f=o.prepareSegment(c,i,a),d=f.vertexLength,f.vertexLength+=c);for(let e=0;e<n.length;e+=2)t(n[e],n[e+1]);if(h)for(let t=0;t<l.length;t++){const e=l[t];for(let t=1;t<e.length;t+=2)a.emplaceBack(d+e[t-1],d+e[t]);f.primitiveLength+=e.length/2}}else!function(t,e,i,r,n,s){const o=[];for(let t=0;t<r.length/2;t++)o.push(-1);const a={count:0};let l=0,c=t.getOrCreateLatestSegment(e,i),h=c.vertexLength;for(let u=2;u<n.length;u+=3){const p=n[u-2],d=n[u-1],f=n[u];let m=o[p]<l,_=o[d]<l,g=o[f]<l;c.vertexLength+((m?1:0)+(_?1:0)+(g?1:0))>sa.MAX_VERTEX_ARRAY_LENGTH&&(c=t.createNewSegment(e,i),l=a.count,m=!0,_=!0,g=!0,h=0);const y=xc(o,r,s,a,p,m,c),v=xc(o,r,s,a,d,_,c),x=xc(o,r,s,a,f,g,c);i.emplaceBack(h+y-l,h+v-l,h+x-l),c.primitiveLength++}}(e,i,r,n,s,t),h&&function(t,e,i,r,n,s){const o=[];for(let t=0;t<r.length/2;t++)o.push(-1);const a={count:0};let l=0,c=t.getOrCreateLatestSegment(e,i),h=c.vertexLength;for(let u=0;u<n.length;u++){const p=n[u];for(let d=1;d<n[u].length;d+=2){const n=p[d-1],u=p[d];let f=o[n]<l,m=o[u]<l;c.vertexLength+((f?1:0)+(m?1:0))>sa.MAX_VERTEX_ARRAY_LENGTH&&(c=t.createNewSegment(e,i),l=a.count,f=!0,m=!0,h=0);const _=xc(o,r,s,a,n,f,c),g=xc(o,r,s,a,u,m,c);i.emplaceBack(h+_-l,h+g-l),c.primitiveLength++}}}(o,i,a,n,l,t),e.forceNewSegmentOnNextPrepare(),null==o||o.forceNewSegmentOnNextPrepare()}function xc(t,e,i,r,n,s,o){if(s){const s=r.count;return i(e[2*n],e[2*n+1]),t[n]=r.count,r.count++,o.vertexLength++,s}return t[n]}class bc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Uo,this.indexArray=new ea,this.indexArray2=new ia,this.programConfigurations=new La(t.layers,t.zoom),this.segments=new sa,this.segments2=new sa,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,e,i){this.hasDependencies=Ol("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=ja(o,t);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,e.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Va(o),patterns:{},sortKey:u};s.push(p)}n&&s.sort((t,e)=>t.sortKey-e.sortKey);for(const r of s){const{geometry:n,index:s,sourceLayerIndex:o}=r;if(this.hasDependencies){const t=Nl("fill",this.layers,r,{zoom:this.zoom},e);this.patternFeatures.push(t)}else this.addFeature(r,n,s,i,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,n,s,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}addFeatures(t,e,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Bl),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,n,s){for(const t of tr(e,500)){const e=_c(t,r,s.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;vc((t,e)=>{i.emplaceBack(t,e)},this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:r})}}let wc,Sc;ps("FillBucket",bc,{omit:["layers","patternFeatures"]});var Tc={get paint(){return Sc=Sc||new Xs({"fill-antialias":new Us(vt.paint_fill["fill-antialias"]),"fill-opacity":new $s(vt.paint_fill["fill-opacity"]),"fill-color":new $s(vt.paint_fill["fill-color"]),"fill-outline-color":new $s(vt.paint_fill["fill-outline-color"]),"fill-translate":new Us(vt.paint_fill["fill-translate"]),"fill-translate-anchor":new Us(vt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Zs(vt.paint_fill["fill-pattern"])})},get layout(){return wc=wc||new Xs({"fill-sort-key":new $s(vt.layout_fill["fill-sort-key"])})}};class Cc extends Ys{constructor(t,e){super(t,Tc,e)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new bc(t)}queryRadius(){return rl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return Wa(nl(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}}const Mc=ro([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ec=ro([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ac}=Mc;class Ic{constructor(t,e,i,r,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n,t.readFields(Pc,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos,r=[];let n,s=1,o=0,a=0,l=0;for(;t.pos<e;){if(o<=0){const e=t.readVarint();s=7&e,o=e>>3}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&(n&&r.push(n),n=[]),n&&n.push(new i(a,l));else{if(7!==s)throw new Error(`unknown command ${s}`);n&&n.push(n[0].clone())}}return n&&r.push(n),r}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let i=1,r=0,n=0,s=0,o=1/0,a=-1/0,l=1/0,c=-1/0;for(;t.pos<e;){if(r<=0){const e=t.readVarint();i=7&e,r=e>>3}if(r--,1===i||2===i)n+=t.readSVarint(),s+=t.readSVarint(),n<o&&(o=n),n>a&&(a=n),s<l&&(l=s),s>c&&(c=s);else if(7!==i)throw new Error(`unknown command ${i}`)}return[o,l,a,c]}toGeoJSON(t,e,i){const r=this.extent*Math.pow(2,i),n=this.extent*t,s=this.extent*e,o=this.loadGeometry();function a(t){return[360*(t.x+n)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+s)/r)*Math.PI))-90]}function l(t){return t.map(a)}let c;if(1===this.type){const t=[];for(const e of o)t.push(e[0]);const e=l(t);c=1===t.length?{type:"Point",coordinates:e[0]}:{type:"MultiPoint",coordinates:e}}else if(2===this.type){const t=o.map(l);c=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}else{if(3!==this.type)throw new Error("unknown feature type");{const t=Dc(o),e=[];for(const i of t)e.push(i.map(l));c=1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}}const h={type:"Feature",geometry:c,properties:this.properties};return null!=this.id&&(h.id=this.id),h}}function Pc(t,e,i){1===t?e.id=i.readVarint():2===t?function(t,e){const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=e._keys[t.readVarint()],r=e._values[t.readVarint()];e.properties[i]=r}}(i,e):3===t?e.type=i.readVarint():4===t&&(e._geometry=i.pos)}function Dc(t){const e=t.length;if(e<=1)return[t];const i=[];let r,n;for(let s=0;s<e;s++){const e=kc(t[s]);0!==e&&(void 0===n&&(n=e<0),n===e<0?(r&&i.push(r),r=[t[s]]):r&&r.push(t[s]))}return r&&i.push(r),i}function kc(t){let e=0;for(let i,r,n=0,s=t.length,o=s-1;n<s;o=n++)i=t[n],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}Ic.types=["Unknown","Point","LineString","Polygon"];class zc{constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Rc,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new Ic(this._pbf,e,this.extent,this._keys,this._values)}}function Rc(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}if(null==e)throw new Error("unknown feature value");return e}(i))}class Lc{constructor(t,e){this.layers=t.readFields(Fc,{},e)}}function Fc(t,e,i){if(3===t){const t=new zc(i,i.readVarint()+i.pos);t.length&&(e[t.name]=t)}}const Bc=Math.pow(2,13);function Oc(t,e,i,r,n,s,o,a){t.emplaceBack(e,i,2*Math.floor(r*Bc)+o,n*Bc*2,s*Bc*2,Math.round(a))}class Nc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new $o,this.centroidVertexArray=new qo,this.indexArray=new ea,this.programConfigurations=new La(t.layers,t.zoom),this.segments=new sa,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,e,i){this.features=[],this.hasDependencies=Ol("fill-extrusion",this.layers,e);for(const{feature:r,id:n,index:s,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,a=ja(r,t);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:o,index:s,geometry:t?a.geometry:Va(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Nl("fill-extrusion",this.layers,l,{zoom:this.zoom},e)):this.addFeature(l,l.geometry,s,i,{},e.subdivisionGranularity),e.featureIndex.insert(r,l.geometry,s,o,this.index,!0)}}addFeatures(t,e,i){for(const r of this.features){const{geometry:n}=r;this.addFeature(r,n,r.index,e,i,t.subdivisionGranularity)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ac),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ec.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,n,s){for(const i of tr(e,500)){const e={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(e,r,t,i,s);const o=this.layoutVertexArray.length-n,a=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t<o;t++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:r})}processPolygon(t,e,i,r,n){if(r.length<1)return;if(qc(r[0]))return;for(const e of r)0!==e.length&&Vc(t,e);const s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(e.z),a="Polygon"===Ic.types[i.type];for(const t of r){if(0===t.length)continue;if(qc(t))continue;const e=gc(t,o,a);this._generateSideFaces(e,s)}if(!a)return;const l=_c(r,e,o,!1),c=this.layoutVertexArray;vc((t,e)=>{Oc(c,t,e,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let i=0;for(let r=1;r<t.length;r++){const n=t[r],s=t[r-1];if(jc(n,s))continue;e.segment.vertexLength+4>sa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const o=n.sub(s)._perp()._unit(),a=s.dist(n);i+a>32768&&(i=0),Oc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),Oc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i),i+=a,Oc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),Oc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}}function Vc(t,e){for(let i=0;i<e.length;i++){const r=e[i];i===e.length-1&&e[0].x===r.x&&e[0].y===r.y||(t.x+=r.x,t.y+=r.y,t.sampleCount++)}}function jc(t,e){return t.x===e.x&&(t.x<0||t.x>I)||t.y===e.y&&(t.y<0||t.y>I)}function qc(t){return t.every(t=>t.x<0)||t.every(t=>t.x>I)||t.every(t=>t.y<0)||t.every(t=>t.y>I)}let Gc;ps("FillExtrusionBucket",Nc,{omit:["layers","features"]});var Uc={get paint(){return Gc=Gc||new Xs({"fill-extrusion-opacity":new Us(vt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new $s(vt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Us(vt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Us(vt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Zs(vt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new $s(vt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new $s(vt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Us(vt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class $c extends Ys{constructor(t,e){super(t,Uc,e)}createBucket(t){return new Nc(t)}queryRadius(){return rl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:s,pixelsToTileUnits:o,pixelPosMatrix:a}){const l=nl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-s.bearingInRadians,o),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),u=function(t,e){const r=[];for(const n of t){const t=[n.x,n.y,0,1];T(t,t,e),r.push(new i(t[0]/t[3],t[1]/t[3]))}return r}(l,a),p=function(t,e,r,n){const s=[],o=[],a=n[8]*e,l=n[9]*e,c=n[10]*e,h=n[11]*e,u=n[8]*r,p=n[9]*r,d=n[10]*r,f=n[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x,o=s.y,m=n[0]*e+n[4]*o+n[12],_=n[1]*e+n[5]*o+n[13],g=n[2]*e+n[6]*o+n[14],y=n[3]*e+n[7]*o+n[15],v=g+c,x=y+h,b=m+u,w=_+p,S=g+d,T=y+f,C=new i((m+a)/x,(_+l)/x);C.z=v/x,t.push(C);const M=new i(b/T,w/T);M.z=S/T,r.push(M)}s.push(t),o.push(r)}return[s,o]}(n,h,c,a);return function(t,e,i){let r=1/0;Wa(i,e)&&(r=Wc(i,e[0]));for(let n=0;n<e.length;n++){const s=e[n],o=t[n];for(let t=0;t<s.length-1;t++){const e=s[t],n=[e,s[t+1],o[t+1],o[t],e];$a(i,n)&&(r=Math.min(r,Wc(i,n)))}}return r!==1/0&&r}(p[0],p[1],u)}}function Zc(t,e){return t.x*e.x+t.y*e.y}function Wc(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const s=e[i],o=t[0],a=n.sub(r),l=s.sub(r),c=o.sub(r),h=Zc(a,a),u=Zc(a,l),p=Zc(l,l),d=Zc(c,a),f=Zc(c,l),m=h*p-u*u,_=(p*d-u*f)/m,g=(h*f-u*d)/m,y=r.z*(1-_-g)+n.z*_+s.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}const Hc=ro([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Xc}=Hc,Yc=ro([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Kc}=Yc,Jc=Math.cos(Math.PI/180*37.5),Qc=Math.pow(2,14)/.5;class th{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(t=>{this.gradients[t.id]={}}),this.layoutVertexArray=new Zo,this.layoutVertexArray2=new Wo,this.indexArray=new ea,this.programConfigurations=new La(t.layers,t.zoom),this.segments=new sa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id)}populate(t,e,i){this.hasDependencies=Ol("line",this.layers,e)||this.hasLineDasharray(this.layers);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ja(e,t);if(!this.layers[0]._featureFilter.filter(new zs(this.zoom),c,i))continue;const h=n?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Va(e),patterns:{},dashes:{},sortKey:h};s.push(u)}n&&s.sort((t,e)=>t.sortKey-e.sortKey);for(const r of s){const{geometry:n,index:s,sourceLayerIndex:o}=r;this.hasDependencies?(Ol("line",this.layers,e)?Nl("line",this.layers,r,{zoom:this.zoom},e):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,e),this.patternFeatures.push(r)):this.addFeature(r,n,s,i,{},{},e.subdivisionGranularity),e.featureIndex.insert(t[s].feature,n,s,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures(t,e,i,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,i,r,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Kc)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Xc),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n,s,o){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap"),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,l,c,h,u,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,dashPositions:s,canonical:r})}addLine(t,e,i,r,n,s,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=gc(t,o?a.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const l="Polygon"===Ic.types[e.type];let c=t.length;for(;c>=2&&t[c-1].equals(t[c-2]);)c--;let h=0;for(;h<c-1&&t[h].equals(t[h+1]);)h++;if(c<(l?3:2))return;"bevel"===i&&(n=1.05);const u=this.overscaling<=16?122880/(512*this.overscaling):0,p=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let d,f,m,_,g;this.e1=this.e2=-1,l&&(d=t[c-2],g=t[h].sub(d)._unit()._perp());for(let e=h;e<c;e++){if(m=e===c-1?l?t[h+1]:void 0:t[e+1],m&&t[e].equals(m))continue;g&&(_=g),d&&(f=d),d=t[e],g=m?m.sub(d)._unit()._perp():_,_=_||g;let o=_.add(g);0===o.x&&0===o.y||o._unit();const a=_.x*g.x+_.y*g.y,y=o.x*g.x+o.y*g.y,v=0!==y?1/y:1/0,x=2*Math.sqrt(2-2*y),b=y<Jc&&f&&m,w=_.x*g.y-_.y*g.x>0;if(b&&e>h){const t=d.dist(f);if(t>2*u){const e=d.sub(d.sub(f)._mult(u/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,_,0,0,p),f=e}}const S=f&&m;let T=S?i:l?"butt":r;if(S&&"round"===T&&(v<s?T="miter":v<=2&&(T="fakeround")),"miter"===T&&v>n&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v<n&&(T="miter")),f&&this.updateDistance(f,d),"miter"===T)o._mult(v),this.addCurrentVertex(d,o,0,0,p);else if("flipbevel"===T){if(v>100)o=g.mult(-1);else{const t=v*_.add(g).mag()/_.sub(g).mag();o._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(d,o,0,0,p),this.addCurrentVertex(d,o.mult(-1),0,0,p)}else if("bevel"===T||"fakeround"===T){const t=-Math.sqrt(v*v-1),e=w?t:0,i=w?0:t;if(f&&this.addCurrentVertex(d,_,e,i,p),"fakeround"===T){const t=Math.round(180*x/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*t*t+(.848013+a*(.215638*a-1.06021)))}const r=g.sub(_)._mult(i)._add(_)._unit()._mult(w?-1:1);this.addHalfVertex(d,r.x,r.y,!1,w,0,p)}}m&&this.addCurrentVertex(d,g,-e,-i,p)}else if("butt"===T)this.addCurrentVertex(d,o,0,0,p);else if("square"===T){const t=f?1:-1;this.addCurrentVertex(d,o,t,t,p)}else"round"===T&&(f&&(this.addCurrentVertex(d,_,0,0,p),this.addCurrentVertex(d,_,1,1,p,!0)),m&&(this.addCurrentVertex(d,g,-1,-1,p,!0),this.addCurrentVertex(d,g,0,0,p)));if(b&&e<c-1){const t=d.dist(m);if(t>2*u){const e=d.add(m.sub(d)._mult(u/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,g,0,0,p),d=e}}}}addCurrentVertex(t,e,i,r,n,s=!1){const o=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,s,!1,i,n),this.addHalfVertex(t,o,a,s,!0,-r,n),this.distance>Qc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,n,s))}addHalfVertex({x:t,y:e},i,r,n,s,o,a){const l=.5*(this.lineClips?this.scaledDistance*(Qc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(s?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),s?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}hasLineDasharray(t){for(const e of t){const t=e.paint.get("line-dasharray");if(t&&!t.isConstant())return!0}return!1}addLineDashDependencies(t,e,i,r){for(const n of t){const t=n.paint.get("line-dasharray");if(!t||"constant"===t.value.kind)continue;const s="round"===n.layout.get("line-cap"),o={dasharray:t.value.evaluate({zoom:i-1},e,{}),round:s},a={dasharray:t.value.evaluate({zoom:i},e,{}),round:s},l={dasharray:t.value.evaluate({zoom:i+1},e,{}),round:s},c=`${o.dasharray.join(",")},${o.round}`,h=`${a.dasharray.join(",")},${a.round}`,u=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[c]=o,r.dashDependencies[h]=a,r.dashDependencies[u]=l,e.dashes[n.id]={min:c,mid:h,max:u}}}}let eh,ih;ps("LineBucket",th,{omit:["layers","patternFeatures"]});var rh={get paint(){return ih=ih||new Xs({"line-opacity":new $s(vt.paint_line["line-opacity"]),"line-color":new $s(vt.paint_line["line-color"]),"line-translate":new Us(vt.paint_line["line-translate"]),"line-translate-anchor":new Us(vt.paint_line["line-translate-anchor"]),"line-width":new $s(vt.paint_line["line-width"]),"line-gap-width":new $s(vt.paint_line["line-gap-width"]),"line-offset":new $s(vt.paint_line["line-offset"]),"line-blur":new $s(vt.paint_line["line-blur"]),"line-dasharray":new Zs(vt.paint_line["line-dasharray"]),"line-pattern":new Zs(vt.paint_line["line-pattern"]),"line-gradient":new Hs(vt.paint_line["line-gradient"])})},get layout(){return eh=eh||new Xs({"line-cap":new Us(vt.layout_line["line-cap"]),"line-join":new $s(vt.layout_line["line-join"]),"line-miter-limit":new Us(vt.layout_line["line-miter-limit"]),"line-round-limit":new Us(vt.layout_line["line-round-limit"]),"line-sort-key":new $s(vt.layout_line["line-sort-key"])})}};class nh extends $s{possiblyEvaluate(t,e){return e=new zs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=O({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}let sh;class oh extends Ys{constructor(t,e){super(t,rh,e),this.gradientVersion=0,sh||(sh=new nh(rh.paint.properties["line-width"].specification),sh.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof ai,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=sh.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new th(t)}queryRadius(t){const e=t,i=ah(il("line-width",this,e),il("line-gap-width",this,e)),r=il("line-offset",this,e);return i/2+Math.abs(r)+rl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:s,pixelsToTileUnits:o}){const a=nl(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-s.bearingInRadians,o),l=o/2*ah(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),c=this.paint.get("line-offset").evaluate(e,r);return c&&(n=function(t,e){const r=[];for(let n=0;n<t.length;n++){const s=sl(t[n]),o=[];for(let t=0;t<s.length;t++){const r=s[t],n=s[t-1],a=s[t+1],l=0===t?new i(0,0):r.sub(n)._unit()._perp(),c=t===s.length-1?new i(0,0):a.sub(r)._unit()._perp(),h=l._add(c)._unit(),u=h.x*c.x+h.y*c.y;0!==u&&h._mult(1/u),o.push(h._mult(e)._add(r))}r.push(o)}return r}(n,c*o)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(tl(t,n[e]))return!0;if(Ha(t,n,i))return!0}return!1}(a,n,l)}isTileClipped(){return!0}}function ah(t,e){return e>0?e+2*t:t}const lh=ro([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ch=ro([{name:"a_projected_pos",components:3,type:"Float32"}],4);ro([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const hh=ro([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ro([{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"}]);const uh=ro([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),ph=ro([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function dh(t,e,i){return t.sections.forEach(t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),ks.applyArabicShaping&&(t=ks.applyArabicShaping(t)),t}(t.text,e,i)}),t}ro([{name:"triangle",components:3,type:"Uint16"}]),ro([{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"}]),ro([{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",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),ro([{type:"Float32",name:"offsetX"}]),ro([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ro([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var fh=24;const mh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},_h={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},gh={40:!0};function yh(t,e,i,r,n,s){if("fontStack"in e){const r=i[e.fontStack],s=r&&r[t];return s?s.metrics.advance*e.scale+n:0}{const t=r[e.imageName];return t?t.displaySize[0]*e.scale*fh/s+n:0}}function vh(t,e,i,r){const n=Math.pow(t-e,2);return r?t<e?n/2:2*n:n+Math.abs(i)*i}function xh(t,e,i){let r=0;return 10===t&&(r-=1e4),i&&(r+=150),40!==t&&65288!==t||(r+=50),41!==e&&65289!==e||(r+=50),r}function bh(t,e,i,r,n,s){let o=null,a=vh(e,i,n,s);for(const t of r){const r=vh(e-t.x,i,n,s)+t.badness;r<=a&&(o=t,a=r)}return{index:t,x:e,priorBreak:o,badness:a}}function wh(t){return t?wh(t.priorBreak).concat(t.index):[]}class Sh{constructor(t="",e=[],i=[]){this.text=t,this.sections=e,this.sectionIndex=i,this.imageSectionID=null}static fromFeature(t,e){const i=new Sh;for(let r=0;r<t.sections.length;r++){const n=t.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,e)}return i}length(){return[...this.text].length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=function(t){let e="",i={premature:!0,value:void 0};const r=t[Symbol.iterator]();let n=r.next();const s=t[Symbol.iterator]();s.next();let o=s.next();for(;!n.done;)e+=!o.done&&Es(o.value.codePointAt(0))&&!mh[o.value]||!i.premature&&Es(i.value.codePointAt(0))&&!mh[i.value]||!mh[n.value]?n.value:mh[n.value],i={value:n.value,premature:!1},n=r.next(),o=s.next();return e}(this.text)}hasZeroWidthSpaces(){return this.text.includes("")}trim(){const t=this.text.match(/^\s*/),e=t?t[0].length:0,i=this.text.match(/\S\s*$/),r=i?i[0].length-1:0;this.text=this.text.substring(e,this.text.length-r),this.sectionIndex=this.sectionIndex.slice(e,this.sectionIndex.length-r)}substring(t,e){const i=[...this.text].slice(t,e).join(""),r=this.sectionIndex.slice(t,e);return new Sh(i,this.sections,r)}toCodeUnitIndex(t){return[...this.text].slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,e)=>Math.max(t,this.sections[e].scale),0)}getMaxImageSize(t){let e=0,i=0;for(let r=0;r<this.length();r++){const n=this.getSection(r);if("imageName"in n){const r=t[n.imageName];if(!r)continue;const s=r.displaySize;e=Math.max(e,s[0]),i=Math.max(i,s[1])}}return{maxImageWidth:e,maxImageHeight:i}}addTextSection(t,e){this.text+=t.text,this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||e});const i=this.sections.length-1;this.sectionIndex.push(...[...t.text].map(()=>i))}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void U("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:e}),this.sectionIndex.push(this.sections.length-1)):U("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,e,i,r,n){const s=[],o=this.determineAverageLineWidth(t,e,i,r,n),a=this.hasZeroWidthSpaces();let l=0,c=0;const h=this.text[Symbol.iterator]();let u=h.next();const p=this.text[Symbol.iterator]();p.next();let d=p.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!u.done;){const e=this.getSection(c),_=u.value.codePointAt(0);if(bs(_)||(l+=yh(_,e,i,r,t,n)),!d.done){const t=vs(_),i=d.value.codePointAt(0);(_h[_]||t||"imageName"in e||!m.done&&gh[i])&&s.push(bh(c+1,l,o,s,xh(_,i,t&&a),!1))}c++,u=h.next(),d=p.next(),m=f.next()}return wh(bh(this.length(),l,o,s,0,!0))}determineAverageLineWidth(t,e,i,r,n){let s=0,o=0;for(const e of this.text){const a=this.getSection(o);s+=yh(e.codePointAt(0),a,i,r,t,n),o++}return s/Math.max(1,Math.ceil(s/e))}}const Th=4294967296,Ch=1/Th,Mh="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Eh{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,i=this.length){for(;this.pos<i;){const i=this.readVarint(),r=i>>3,n=this.pos;this.type=7&i,t(r,e,this),this.pos===n&&this.skip(i)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Th;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Th;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let i,r;return r=e[this.pos++],i=127&r,r<128?i:(r=e[this.pos++],i|=(127&r)<<7,r<128?i:(r=e[this.pos++],i|=(127&r)<<14,r<128?i:(r=e[this.pos++],i|=(127&r)<<21,r<128?i:(r=e[this.pos],i|=(15&r)<<28,function(t,e,i){const r=i.buf;let n,s;if(s=r[i.pos++],n=(112&s)>>4,s<128)return Ah(t,n,e);if(s=r[i.pos++],n|=(127&s)<<3,s<128)return Ah(t,n,e);if(s=r[i.pos++],n|=(127&s)<<10,s<128)return Ah(t,n,e);if(s=r[i.pos++],n|=(127&s)<<17,s<128)return Ah(t,n,e);if(s=r[i.pos++],n|=(127&s)<<24,s<128)return Ah(t,n,e);if(s=r[i.pos++],n|=(1&s)<<31,s<128)return Ah(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Mh?Mh.decode(this.buf.subarray(e,t)):function(t,e,i){let r="",n=e;for(;n<i;){const e=t[n];let s,o,a,l=null,c=e>239?4:e>223?3:e>191?2:1;if(n+c>i)break;1===c?e<128&&(l=e):2===c?(s=t[n+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===c?(s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Ch),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Ch),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(t,e){let i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(i=~(-t%4294967296),r=~(-t/4294967296),4294967295^i?i=i+1|0:(i=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,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){const i=(7&t)<<4;e.buf[e.pos++]|=i|((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(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,i){for(let r,n,s=0;s<e.length;s++){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!n){r>56319||s+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);const i=this.pos-e;i>=128&&Ih(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let i=0;i<e;i++)this.buf[this.pos++]=t[i]}writeRawMessage(t,e){this.pos++;const i=this.pos;t(e,this);const r=this.pos-i;r>=128&&Ih(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(t,e,i){this.writeTag(t,2),this.writeRawMessage(e,i)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Ph,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Dh,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Rh,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,kh,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,zh,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,Lh,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Fh,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Bh,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Oh,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function Ah(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Ih(t,e,i){const r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(let e=i.pos-1;e>=t;e--)i.buf[e+r]=i.buf[e]}function Ph(t,e){for(let i=0;i<t.length;i++)e.writeVarint(t[i])}function Dh(t,e){for(let i=0;i<t.length;i++)e.writeSVarint(t[i])}function kh(t,e){for(let i=0;i<t.length;i++)e.writeFloat(t[i])}function zh(t,e){for(let i=0;i<t.length;i++)e.writeDouble(t[i])}function Rh(t,e){for(let i=0;i<t.length;i++)e.writeBoolean(t[i])}function Lh(t,e){for(let i=0;i<t.length;i++)e.writeFixed32(t[i])}function Fh(t,e){for(let i=0;i<t.length;i++)e.writeSFixed32(t[i])}function Bh(t,e){for(let i=0;i<t.length;i++)e.writeFixed64(t[i])}function Oh(t,e){for(let i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Nh(t,e,i){1===t&&i.readMessage(Vh,e)}function Vh(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:s,left:o,top:a,advance:l}=i.readMessage(jh,{});e.push({id:t,bitmap:new wl({width:n+6,height:s+6},r),metrics:{width:n,height:s,left:o,top:a,advance:l}})}}function jh(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function qh(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort((t,e)=>e.h-t.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,s=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,s=Math.max(s,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();e&&t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:s,fill:e/(n*s)||0}}class Gh{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:s,textFitWidth:o,textFitHeight:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=s,this.version=i,this.textFitWidth=o,this.textFitHeight=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Uh{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:s,h:o}=qh(n),a=new Sl({width:s||1,height:o||1});for(const e in t){const r=t[e],n=i[e].paddedRect;Sl.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,s=n.x+1,o=n.y+1,l=i.data.width,c=i.data.height;Sl.copy(i.data,a,{x:0,y:0},{x:s,y:o},i.data),Sl.copy(i.data,a,{x:0,y:c-1},{x:s,y:o-1},{width:l,height:1}),Sl.copy(i.data,a,{x:0,y:0},{x:s,y:o+c},{width:l,height:1}),Sl.copy(i.data,a,{x:l-1,y:0},{x:s-1,y:o},{width:1,height:c}),Sl.copy(i.data,a,{x:0,y:0},{x:s+l,y:o},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],s={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(s),e[r]=new Gh(s,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}}var $h;function Zh(e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=Sh.fromFeature(e,s);let g;p===t.az.vertical&&_.verticalizePunctuation();let y=_.determineLineBreaks(h,o,i,n,f);const{processBidirectionalText:v,processStyledBidirectionalText:x}=ks;if(v&&1===_.sections.length){g=[],y=y.map(t=>_.toCodeUnitIndex(t));const t=v(_.toString(),y);for(const e of t){const t=[...e].map(()=>0);g.push(new Sh(e,_.sections,t))}}else if(x){g=[],y=y.map(t=>_.toCodeUnitIndex(t));let t=0;const e=[];for(const i of _.text)e.push(...Array(i.length).fill(_.sectionIndex[t])),t++;const i=x(_.text,e,y);for(const t of i){const e=[];let i="";for(const r of t[0])e.push(t[1][i.length]),i+=r;g.push(new Sh(t[0],_.sections,e))}}else g=function(t,e){const i=[];let r=0;for(const n of e)i.push(t.substring(r,n)),r=n;return r<t.length()&&i.push(t.substring(r,t.length())),i}(_,y);const b=[],w={positionedLines:b,text:_.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:p,iconsInText:!1,verticalizable:!1};return function(t,e,i,r,n,s,o,a,l,c,h,u){let p=0,d=0,f=0,m=0;const _="right"===a?1:"left"===a?0:.5,g=fh/u;let y=0;for(const o of n){o.trim();const n=o.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};t.positionedLines[y]=a;const u=a.positionedGlyphs;let v=0;if(!o.length()){d+=s,++y;continue}const x=Hh(r,o,g);let b=0;for(const s of o.text){const a=o.getSection(b),f=s.codePointAt(0),m=Yh(l,h,f),_={glyph:f,imageName:null,x:p,y:d+-17,vertical:m,scale:1,fontStack:"",sectionIndex:o.getSectionIndex(b),metrics:null,rect:null};let y;if("fontStack"in a){if(y=Kh(a,f,m,x,e,i),!y)continue;_.fontStack=a.fontStack}else{if(t.iconsInText=!0,a.scale*=g,y=Jh(a,m,n,x,r),!y)continue;v=Math.max(v,y.imageOffset),_.imageName=a.imageName}const{rect:w,metrics:S,baselineOffset:T}=y;_.y+=T,_.scale=a.scale,_.metrics=S,_.rect=w,u.push(_),m?(t.verticalizable=!0,p+=("imageName"in a?S.advance:fh)*a.scale+c):p+=S.advance*a.scale+c,b++}0!==u.length&&(f=Math.max(p-c,f),Qh(u,0,u.length-1,_)),p=0,a.lineOffset=Math.max(v,(n-1)*fh);const w=s*n+v;d+=w,m=Math.max(w,m),++y}const{horizontalAlign:v,verticalAlign:x}=Wh(o);(function(t,e,i,r,n,s,o,a,l){const c=(e-i)*n;let h=0;h=s!==o?-a*r- -17:-r*l*o+.5*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(t.positionedLines,_,v,x,f,m,s,d,n.length),t.top+=-x*d,t.bottom=t.top+d,t.left+=-v*f,t.right=t.left+f}(w,i,r,n,g,a,l,c,p,h,d,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(b)&&w}function Wh(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Hh(t,e,i){const r=e.getMaxScale()*fh,{maxImageWidth:n,maxImageHeight:s}=e.getMaxImageSize(t),o=Math.max(r,s*i);return{verticalLineContentWidth:Math.max(r,n*i),horizontalLineContentHeight:o}}function Xh(t){switch(t){case"top":return 0;case"center":return.5;default:return 1}}function Yh(e,i,r){return!(e===t.az.horizontal||!i&&!xs(r)||i&&(bs(r)||(n=r,/\p{sc=Arab}/u.test(String.fromCodePoint(n)))));var n}function Kh(t,e,i,r,n,s){const o=s[t.fontStack],a=function(t,e,i,r){if(t&&t.rect)return t;const n=e[i.fontStack],s=n&&n[r];return s?{rect:null,metrics:s.metrics}:null}(o&&o[e],n,t,e);if(null===a)return null;let l;if(i)l=r.verticalLineContentWidth-t.scale*fh;else{const e=Xh(t.verticalAlign);l=(r.horizontalLineContentHeight-t.scale*fh)*e}return{rect:a.rect,metrics:a.metrics,baselineOffset:l}}function Jh(t,e,i,r,n){const s=n[t.imageName];if(!s)return null;const o=s.paddedRect,a=s.displaySize,l={width:a[0],height:a[1],left:1,top:-3,advance:e?a[1]:a[0]};let c;if(e)c=r.verticalLineContentWidth-a[1]*t.scale;else{const e=Xh(t.verticalAlign);c=(r.horizontalLineContentHeight-a[1]*t.scale)*e}return{rect:o,metrics:l,baselineOffset:c,imageOffset:(e?a[0]:a[1])*t.scale-fh*i}}function Qh(t,e,i,r){if(0===r)return;const n=t[i],s=(t[i].x+n.metrics.advance*n.scale)*r;for(let r=e;r<=i;r++)t[r].x-=s}function tu(t,e,i){const{horizontalAlign:r,verticalAlign:n}=Wh(i),s=e[0]-t.displaySize[0]*r,o=e[1]-t.displaySize[1]*n;return{image:t,top:o,bottom:o+t.displaySize[1],left:s,right:s+t.displaySize[0]}}function eu(t){var e,i;let r=t.left,n=t.top,s=t.right-r,o=t.bottom-n;const a=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",l=null!==(i=t.image.textFitHeight)&&void 0!==i?i:"stretchOrShrink",c=(t.image.content[2]-t.image.content[0])/(t.image.content[3]-t.image.content[1]);if("proportional"===l){if("stretchOnly"===a&&s/o<c||"proportional"===a){const t=Math.ceil(o*c);r*=t/s,s=t}}else if("proportional"===a&&"stretchOnly"===l&&0!==c&&s/o>c){const t=Math.ceil(s/c);n*=t/o,o=t}return{x1:r,y1:n,x2:r+s,y2:n+o}}function iu(t,e,i,r,n,s){const o=t.image;let a;if(o.content){const t=o.content,e=o.pixelRatio||1;a=[t[0]/e,t[1]/e,o.displaySize[0]-t[2]/e,o.displaySize[1]-t[3]/e]}const l=e.left*s,c=e.right*s;let h,u,p,d;"width"===i||"both"===i?(d=n[0]+l-r[3],u=n[0]+c+r[1]):(d=n[0]+(l+c-o.displaySize[0])/2,u=d+o.displaySize[0]);const f=e.top*s,m=e.bottom*s;return"height"===i||"both"===i?(h=n[1]+f-r[0],p=n[1]+m+r[2]):(h=n[1]+(f+m-o.displaySize[1])/2,p=h+o.displaySize[1]),{image:o,top:h,right:u,bottom:p,left:d,collisionPadding:a}}ps("ImagePosition",Gh),ps("ImageAtlas",Uh),t.az=void 0,($h=t.az||(t.az={}))[$h.none=0]="none",$h[$h.horizontal=1]="horizontal",$h[$h.vertical=2]="vertical",$h[$h.horizontalOnly=3]="horizontalOnly";const ru=128,nu=32640;function su(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new zs(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let s=n;for(;s<e.length&&e[s]<t+1;)s++;s=Math.min(e.length-1,s);const o=e[n],a=e[s];return"composite"===i.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:o,maxZoom:a,minSize:i.evaluate(new zs(o)),maxSize:i.evaluate(new zs(a)),interpolationType:r}}}function ou(t,e,i){let r="never";const n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}const au=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lu(t,e,i,r,n,s,o,a,l,c,h,u,p){const d=a?Math.min(nu,Math.round(a[0])):0,f=a?Math.min(nu,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*n),s,o,(d<<1)+(l?1:0),f,16*c,16*h,256*u,256*p)}function cu(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function hu(t){for(const e of t.sections)if(Ds(e.text))return!0;return!1}class uu{constructor(t){this.layoutVertexArray=new Yo,this.indexArray=new ea,this.programConfigurations=t,this.segments=new sa,this.dynamicLayoutVertexArray=new Ko,this.opacityVertexArray=new Jo,this.hasVisibleVertices=!1,this.placedSymbolArray=new zo}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lh.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,ch.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,au,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ps("SymbolBuffers",uu);class pu{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new sa,this.collisionVertexArray=new ta}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,hh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ps("CollisionBuffers",pu);class du{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=su(this.zoom,i["text-size"]),this.iconSizeData=su(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),s=r.get("symbol-z-order");this.canOverlap="never"!==ou(r,"text-overlap","text-allow-overlap")||"never"!==ou(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map(e=>t.az[e])),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.sourceID=e.sourceID}createArrays(){this.text=new uu(new La(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new uu(new La(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new Fo,this.lineVertexArray=new Bo,this.symbolInstances=new Lo,this.textAnchorOffsets=new No}calculateGlyphDependencies(t,e,i,r,n){for(const s of t)if(e[s.codePointAt(0)]=!0,(i||r)&&n){const t=mh[s];t&&(e[t.codePointAt(0)]=!0)}}populate(e,i,r){const n=this.layers[0],s=n.layout,o=s.get("text-font"),a=s.get("text-field"),l=s.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof De&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=s.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const p=i.iconDependencies,d=i.glyphDependencies,f=i.availableImages,m=new zs(this.zoom);for(const{feature:i,id:a,index:l,sourceLayerIndex:_}of e){const e=n._featureFilter.needGeometry,g=ja(i,e);if(!n._featureFilter.filter(m,g,r))continue;let y,v;if(e||(g.geometry=Va(i)),c){const t=n.getValueAndResolveTokens("text-field",g,r,f),e=De.factory(t),i=this.hasRTLText=this.hasRTLText||hu(e);(!i||"unavailable"===ks.getRTLTextPluginStatus()||i&&ks.isParsed())&&(y=dh(e,n,g))}if(h){const t=n.getValueAndResolveTokens("icon-image",g,r,f);v=t instanceof Oe?t:Oe.fromString(t)}if(!y&&!v)continue;const x=this.sortFeaturesByKey?u.evaluate(g,{},r):void 0;if(this.features.push({id:a,text:y,icon:v,index:l,sourceLayerIndex:_,geometry:g.geometry,properties:i.properties,type:Ic.types[i.type],sortKey:x}),v&&(p[v.name]=!0),y){const e=o.evaluate(g,{},r).join(","),i="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.az.vertical)>=0;for(const t of y.sections)if(t.image)p[t.image.name]=!0;else{const r=ws(y.toString()),n=t.fontStack||e,s=d[n]=d[n]||{};this.calculateGlyphDependencies(t.text,s,i,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function s(e){r.push(t[e]),n++}function o(t,e,n){const s=i[t];return delete i[t],i[e]=s,r[s].geometry[0].pop(),r[s].geometry[0]=r[s].geometry[0].concat(n[0]),s}function a(t,i,n){const s=e[i];return delete e[i],e[t]=s,r[s].geometry[0].shift(),r[s].geometry[0]=n[0].concat(r[s].geometry[0]),s}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,p=h.text?h.text.toString():null;if(!p){s(c);continue}const d=l(p,u),f=l(p,u,!0);if(d in i&&f in e&&i[d]!==e[f]){const t=a(d,f,u),n=o(d,f,r[t].geometry);delete e[d],delete i[f],i[l(p,r[n].geometry,!0)]=n,r[t].geometry=null}else d in i?o(d,f,u):f in e?a(d,f,u):(s(c),e[d]=n-1,i[f]=n-1)}return r.filter(t=>t.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((t,e)=>t.sortKey-e.sortKey)}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const n={};for(let r=t.segment+1;r<e.length;r++)n[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)n[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=n[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,i,r,n,s,o,a,l,c,h,u,p){const d=e.indexArray,f=e.layoutVertexArray,m=e.segments.prepareSegment(4*i.length,f,d,this.canOverlap?o.sortKey:void 0),_=this.glyphOffsetArray.length,g=m.vertexLength,y=this.allowVerticalPlacement&&a===t.az.vertical?Math.PI/2:0,v=o.text&&o.text.sections;for(let t=0;t<i.length;t++){const{tl:n,tr:s,bl:a,br:c,tex:h,pixelOffsetTL:u,pixelOffsetBR:_,minFontScaleX:g,minFontScaleY:x,glyphOffset:b,isSDF:w,sectionIndex:S}=i[t],T=m.vertexLength,C=b[1];lu(f,l.x,l.y,n.x,C+n.y,h.x,h.y,r,w,u.x,u.y,g,x),lu(f,l.x,l.y,s.x,C+s.y,h.x+h.w,h.y,r,w,_.x,u.y,g,x),lu(f,l.x,l.y,a.x,C+a.y,h.x,h.y+h.h,r,w,u.x,_.y,g,x),lu(f,l.x,l.y,c.x,C+c.y,h.x+h.w,h.y+h.h,r,w,_.x,_.y,g,x),cu(e.dynamicLayoutVertexArray,l,y),d.emplaceBack(T,T+2,T+1),d.emplaceBack(T+1,T+2,T+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),t!==i.length-1&&S===i[t+1].sectionIndex||e.programConfigurations.populatePaintArrays(f.length,o,o.index,{imagePositions:{},canonical:p,formattedSection:v&&v[S]})}e.placedSymbolArray.emplaceBack(l.x,l.y,_,this.glyphOffsetArray.length-_,g,c,h,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],a,0,!1,0,u)}_addCollisionDebugVertex(t,e,i,r,n,s){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,n,Math.round(s.x),Math.round(s.y))}addCollisionDebugVertices(t,e,r,n,s,o,a){const l=s.segments.prepareSegment(4,s.layoutVertexArray,s.indexArray),c=l.vertexLength,h=s.layoutVertexArray,u=s.collisionVertexArray,p=a.anchorX,d=a.anchorY;this._addCollisionDebugVertex(h,u,o,p,d,new i(t,e)),this._addCollisionDebugVertex(h,u,o,p,d,new i(r,e)),this._addCollisionDebugVertex(h,u,o,p,d,new i(r,n)),this._addCollisionDebugVertex(h,u,o,p,d,new i(t,n)),l.vertexLength+=4;const f=s.indexArray;f.emplaceBack(c,c+1),f.emplaceBack(c+1,c+2),f.emplaceBack(c+2,c+3),f.emplaceBack(c+3,c),l.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let n=t;n<e;n++){const t=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new pu(Qo,uh.members,ia),this.iconCollisionBox=new pu(Qo,uh.members,ia);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,r,n,s,o,a,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let e=s;e<o;e++){const i=t.get(e);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<l;e++){const i=t.get(e);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+2,e+1),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],s=[];for(let t=0;t<this.symbolInstances.length;++t){s.push(t);const o=this.symbolInstances.get(t);r.push(0|Math.round(e*o.anchorX+i*o.anchorY)),n.push(o.featureIndex)}return s.sort((t,e)=>r[t]-r[e]||n[e]-n[t]),s}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||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(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let fu,mu;ps("SymbolBucket",du,{omit:["layers","collisionBoxArray","features","compareText"]}),du.MAX_GLYPHS=65535,du.addDynamicAttributes=cu;var _u={get paint(){return mu=mu||new Xs({"icon-opacity":new $s(vt.paint_symbol["icon-opacity"]),"icon-color":new $s(vt.paint_symbol["icon-color"]),"icon-halo-color":new $s(vt.paint_symbol["icon-halo-color"]),"icon-halo-width":new $s(vt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new $s(vt.paint_symbol["icon-halo-blur"]),"icon-translate":new Us(vt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Us(vt.paint_symbol["icon-translate-anchor"]),"text-opacity":new $s(vt.paint_symbol["text-opacity"]),"text-color":new $s(vt.paint_symbol["text-color"],{runtimeType:Nt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new $s(vt.paint_symbol["text-halo-color"]),"text-halo-width":new $s(vt.paint_symbol["text-halo-width"]),"text-halo-blur":new $s(vt.paint_symbol["text-halo-blur"]),"text-translate":new Us(vt.paint_symbol["text-translate"]),"text-translate-anchor":new Us(vt.paint_symbol["text-translate-anchor"])})},get layout(){return fu=fu||new Xs({"symbol-placement":new Us(vt.layout_symbol["symbol-placement"]),"symbol-spacing":new Us(vt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Us(vt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new $s(vt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Us(vt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Us(vt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Us(vt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Us(vt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Us(vt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Us(vt.layout_symbol["icon-rotation-alignment"]),"icon-size":new $s(vt.layout_symbol["icon-size"]),"icon-text-fit":new Us(vt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Us(vt.layout_symbol["icon-text-fit-padding"]),"icon-image":new $s(vt.layout_symbol["icon-image"]),"icon-rotate":new $s(vt.layout_symbol["icon-rotate"]),"icon-padding":new $s(vt.layout_symbol["icon-padding"]),"icon-keep-upright":new Us(vt.layout_symbol["icon-keep-upright"]),"icon-offset":new $s(vt.layout_symbol["icon-offset"]),"icon-anchor":new $s(vt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Us(vt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Us(vt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Us(vt.layout_symbol["text-rotation-alignment"]),"text-field":new $s(vt.layout_symbol["text-field"]),"text-font":new $s(vt.layout_symbol["text-font"]),"text-size":new $s(vt.layout_symbol["text-size"]),"text-max-width":new $s(vt.layout_symbol["text-max-width"]),"text-line-height":new Us(vt.layout_symbol["text-line-height"]),"text-letter-spacing":new $s(vt.layout_symbol["text-letter-spacing"]),"text-justify":new $s(vt.layout_symbol["text-justify"]),"text-radial-offset":new $s(vt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Us(vt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new $s(vt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new $s(vt.layout_symbol["text-anchor"]),"text-max-angle":new Us(vt.layout_symbol["text-max-angle"]),"text-writing-mode":new Us(vt.layout_symbol["text-writing-mode"]),"text-rotate":new $s(vt.layout_symbol["text-rotate"]),"text-padding":new Us(vt.layout_symbol["text-padding"]),"text-keep-upright":new Us(vt.layout_symbol["text-keep-upright"]),"text-transform":new $s(vt.layout_symbol["text-transform"]),"text-offset":new $s(vt.layout_symbol["text-offset"]),"text-allow-overlap":new Us(vt.layout_symbol["text-allow-overlap"]),"text-overlap":new Us(vt.layout_symbol["text-overlap"]),"text-ignore-placement":new Us(vt.layout_symbol["text-ignore-placement"]),"text-optional":new Us(vt.layout_symbol["text-optional"])})}};class gu{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Lt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const 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}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ps("FormatSectionOverride",gu,{omit:["defaultValue"]});class yu extends Ys{constructor(t,e){super(t,_u,e)}recalculate(t,e){if(super.recalculate(t,e),"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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"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")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||en(s.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,(e,i)=>t&&i in t?String(t[i]):"")}(e.properties,n)}createBucket(t){return new du(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of _u.paint.overridableProperties){if(!yu.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new gu(e),r=new tn(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new nn("source",r):new sn("composite",r,e.value.zoomStops),this.paint._values[t]=new qs(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&yu.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=_u.paint.properties[e];let n=!1;const s=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof De)s(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const t=e=>{n||(e instanceof Ue&&qe(e.value)===Ut?s(e.value.sections):e instanceof Ai?s(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}}let vu;var xu={get paint(){return vu=vu||new Xs({"background-color":new Us(vt.paint_background["background-color"]),"background-pattern":new Ws(vt.paint_background["background-pattern"]),"background-opacity":new Us(vt.paint_background["background-opacity"])})}};class bu extends Ys{constructor(t,e){super(t,xu,e)}}class wu extends Ys{constructor(t,e){super(t,{},e),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Su{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Tu={once:!0},Cu=6371008.8;class Mu{constructor(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")}wrap(){return new Mu(B(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Cu*Math.acos(Math.min(n,1))}static convert(t){if(t instanceof Mu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Mu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Mu(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: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Eu=2*Math.PI*Cu;function Au(t){return Eu*Math.cos(t*Math.PI/180)}function Iu(t){return(180+t)/360}function Pu(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Du(t,e){return t/Au(e)}function ku(t){return 360*t-180}function zu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Ru(t,e){return t*Au(zu(e))}class Lu{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Mu.convert(t);return new Lu(Iu(i.lng),Pu(i.lat),Du(e,i.lat))}toLngLat(){return new Mu(ku(this.x),zu(this.y))}toAltitude(){return Ru(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Eu*(t=zu(this.y),1/Math.cos(t*Math.PI/180));var t}}function Fu(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Bu{constructor(t,e,i){if(!function(t,e,i){return!(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,i))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=Vu(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(s=this.y,o=this.z,a=Fu(256*(n=this.x),256*(s=Math.pow(2,o)-s-1),o),l=Fu(256*(n+1),256*(s+1),o),a[0]+","+a[1]+","+l[0]+","+l[1]);var n,s,o,a,l;const c=function(t,e,i){let r,n="";for(let s=t;s>0;s--)r=1<<s-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new i((t.x*e-this.x)*I,(t.y*e-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ou{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Vu(t,e.z,e.z,e.x,e.y)}}class Nu{constructor(t,e,i,r,n){if(this.terrainRttPosMatrix32f=null,t<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Bu(i,+r,+n),this.key=Vu(e,t,i,r,n)}clone(){return new Nu(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Nu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Nu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?Vu(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Vu(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;if(this.overscaledZ-t.overscaledZ<=0)return!1;if(0===t.overscaledZ)return this.overscaledZ>0;const e=this.canonical.z-t.canonical.z;return!(e<0)&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Nu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Nu(e,this.wrap,e,i,r),new Nu(e,this.wrap,e,i+1,r),new Nu(e,this.wrap,e,i,r+1),new Nu(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Nu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Nu(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Ou(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Lu(t.x-this.wrap,t.y))}}function Vu(t,e,i,r,n){(t*=2)<0&&(t=-1*t-1);const s=1<<i;return(s*s*t+s*n+r).toString(36)+i.toString(36)+e.toString(36)}function ju(t,e){return e?t.properties[e]:t.id}function qu(t,e){const i={id:t.id};if(e.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(const i of e.removeProperties){const e=t.addOrUpdateProperties.findIndex(t=>t.key===i);e>-1&&t.addOrUpdateProperties.splice(e,1)}return(t.removeAllProperties||e.removeAllProperties)&&(i.removeAllProperties=!0),(t.removeProperties||e.removeProperties)&&(i.removeProperties=[...t.removeProperties||[],...e.removeProperties||[]]),(t.addOrUpdateProperties||e.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...t.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(t.newGeometry||e.newGeometry)&&(i.newGeometry=e.newGeometry||t.newGeometry),i}function Gu(t){var e,i;if(!t)return{};const r={};return r.removeAll=t.removeAll,r.remove=new Set(t.remove||[]),r.add=new Map(null===(e=t.add)||void 0===e?void 0:e.map(t=>[t.id,t])),r.update=new Map(null===(i=t.update)||void 0===i?void 0:i.map(t=>[t.id,t])),r}ps("CanonicalTileID",Bu),ps("OverscaledTileID",Nu,{omit:["terrainRttPosMatrix32f"]});class Uu{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){const e=new Uu;return e.extend(t(new i(this.minX,this.minY))),e.extend(t(new i(this.maxX,this.minY))),e.extend(t(new i(this.minX,this.maxY))),e.extend(t(new i(this.maxX,this.maxY))),e}static fromPoints(t){const e=new Uu;for(const i of t)e.extend(i);return e}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}}class $u{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Zu{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,this._x=i,this._y=r,this._z=e,this.properties=t.properties,this.id=n}projectPoint(t,e,i,r){return[360*(t.x+e)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+i)/r)*Math.PI))-90]}projectLine(t,e,i,r){return t.map(t=>this.projectPoint(t,e,i,r))}get geometry(){if(this._geometry)return this._geometry;const t=this._vectorTileFeature,e=t.extent*Math.pow(2,this._z),i=t.extent*this._x,r=t.extent*this._y,n=t.loadGeometry();switch(t.type){case 1:{const t=[];for(const e of n)t.push(e[0]);const s=this.projectLine(t,i,r,e);this._geometry=1===t.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{const t=n.map(t=>this.projectLine(t,i,r,e));this._geometry=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t};break}case 3:{const t=Dc(n),s=[];for(const n of t)s.push(n.map(t=>this.projectLine(t,i,r,e)));this._geometry=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw new Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&"_x"!==e&&"_y"!==e&&"_z"!==e&&(t[e]=this[e]);return t}}class Wu{_name;dataBuffer;nullabilityBuffer;_size;constructor(t,e,i){this._name=t,this.dataBuffer=e,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(t){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(t)?null:this.getValueFromBuffer(t)}has(t){return this.nullabilityBuffer&&this.nullabilityBuffer.get(t)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Hu extends Wu{}class Xu extends Hu{getValueFromBuffer(t){return this.dataBuffer[t]}}class Yu extends Hu{getValueFromBuffer(t){return this.dataBuffer[t]}}class Ku extends Wu{delta;constructor(t,e,i,r){super(t,e,r),this.delta=i}}class Ju extends Ku{constructor(t,e,i,r){super(t,Int32Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}}class Qu extends Wu{constructor(t,e,i){super(t,Int32Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}}class tp{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(t,e,i,r,n=4096){this._name=t,this._geometryVector=e,this._idVector=i,this._propertyVectors=r,this._extent=n}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(t){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(t=>[t.name,t]))),this.propertyVectorsMap.get(t)}*[Symbol.iterator](){const t=this.geometryVector[Symbol.iterator]();let e=0;for(;e<this.numFeatures;){let i;this.idVector&&(i=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(e)):this.idVector.getValue(e));const r=t?.next().value,n={};for(const t of this.propertyVectors){if(!t)continue;const i=t.name,r=t.getValue(e);null!==r&&(n[i]=r)}e++,yield{id:i,geometry:r,properties:n}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const t=[],e=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;this.idVector&&(r=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(i)):this.idVector.getValue(i));const n={coordinates:e[i],type:this.geometryVector.geometryType(i)},s={};for(const t of this.propertyVectors){if(!t)continue;const e=t.name,r=t.getValue(i);null!==r&&(s[e]=r)}t.push({id:r,geometry:n,properties:s})}return t}containsMaxSaveIntegerValues(t){return t instanceof Xu||t instanceof Qu&&t instanceof Ju||t instanceof Yu}}class ep{value;constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}increment(){return this.value++}add(t){this.value+=t}}var ip,rp,np,sp,op,ap,lp,cp,hp,up;function pp(t,e,i){const r=new Int32Array(i);let n=0,s=e.get();for(let e=0;e<r.length;e++){let e=t[s++],i=127&e;e<128||(e=t[s++],i|=(127&e)<<7,e<128||(e=t[s++],i|=(127&e)<<14,e<128||(e=t[s++],i|=(127&e)<<21,e<128||(e=t[s++],i|=(15&e)<<28)))),r[n++]=i}return e.set(s),r}function dp(t,e,i){const r=new BigInt64Array(i);for(let i=0;i<r.length;i++)r[i]=yp(t,e);return r}function fp(t,e){let i,r;return r=t[e.get()],e.increment(),i=127&r,r<128?i:(r=t[e.get()],e.increment(),i|=(127&r)<<7,r<128?i:(r=t[e.get()],e.increment(),i|=(127&r)<<14,r<128?i:(r=t[e.get()],e.increment(),i|=(127&r)<<21,r<128?i:(r=t[e.get()],i|=(15&r)<<28,function(t,e,i){let r,n;if(n=e[i.get()],i.increment(),r=(112&n)>>4,n<128)return 4294967296*r+(t>>>0);if(n=e[i.get()],i.increment(),r|=(127&n)<<3,n<128)return 4294967296*r+(t>>>0);if(n=e[i.get()],i.increment(),r|=(127&n)<<10,n<128)return 4294967296*r+(t>>>0);if(n=e[i.get()],i.increment(),r|=(127&n)<<17,n<128)return 4294967296*r+(t>>>0);if(n=e[i.get()],i.increment(),r|=(127&n)<<24,n<128)return 4294967296*r+(t>>>0);if(n=e[i.get()],i.increment(),r|=(1&n)<<31,n<128)return 4294967296*r+(t>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,t,e)))))}function mp(t,e,i,r){throw new Error("FastPFor is not implemented yet.")}function _p(t){return t>>>1^-(1&t)}function gp(t){return t>>1n^-(1n&t)}function yp(t,e){let i=0n,r=0,n=e.get();for(;n<t.length;){const e=t[n++];if(i|=BigInt(127&e)<<BigInt(r),!(128&e))break;if(r+=7,r>=64)throw new Error("Varint too long")}return e.set(n),i}function vp(t,e,i){const r=new Int32Array(i);let n=0;for(let i=0;i<e;i++){const s=t[i];r.fill(t[i+e],n,n+s),n+=s}return r}function xp(t,e,i){const r=new BigInt64Array(i);let n=0;for(let i=0;i<e;i++){const s=Number(t[i]);r.fill(t[i+e],n,n+s),n+=s}return r}function bp(t,e,i){const r=new Float64Array(i);let n=0;for(let i=0;i<e;i++){const s=t[i];r.fill(t[i+e],n,n+s),n+=s}return r}function wp(t){const e=t.length/4*4;let i=1;if(e>=4)for(let r=t[0];i<e-4;i+=4)r=t[i]+=r,r=t[i+1]+=r,r=t[i+2]+=r,r=t[i+3]+=r;for(;i!=t.length;)t[i]+=t[i-1],++i}function Sp(t){t[0]=t[0]>>>1^-(1&t[0]),t[1]=t[1]>>>1^-(1&t[1]);const e=t.length/4*4;let i=2;if(e>=4)for(;i<e-4;i+=4){const e=t[i],r=t[i+1],n=t[i+2],s=t[i+3];t[i]=(e>>>1^-(1&e))+t[i-2],t[i+1]=(r>>>1^-(1&r))+t[i-1],t[i+2]=(n>>>1^-(1&n))+t[i],t[i+3]=(s>>>1^-(1&s))+t[i+1]}for(;i!=t.length;i+=2)t[i]=(t[i]>>>1^-(1&t[i]))+t[i-2],t[i+1]=(t[i+1]>>>1^-(1&t[i+1]))+t[i-1]}!function(t){t.NONE="NONE",t.DELTA="DELTA",t.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",t.RLE="RLE",t.MORTON="MORTON",t.PDE="PDE"}(ip||(ip={})),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT",t.ALP="ALP"}(rp||(rp={})),function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"}(np||(np={}));class Tp{_dictionaryType;_offsetType;_lengthType;constructor(t,e,i){this._dictionaryType=t,this._offsetType=e,this._lengthType=i}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Cp(t,e){const i=function(t,e){const i=t[e.get()],r=Object.values(np)[i>>4];let n=null;switch(r){case np.DATA:n=new Tp(Object.values(sp)[15&i]);break;case np.OFFSET:n=new Tp(null,Object.values(op)[15&i]);break;case np.LENGTH:n=new Tp(null,null,Object.values(ap)[15&i])}e.increment();const s=t[e.get()],o=Object.values(ip)[s>>5],a=Object.values(ip)[s>>2&7],l=Object.values(rp)[3&s];e.increment();const c=pp(t,e,2),h=c[0];return{physicalStreamType:r,logicalStreamType:n,logicalLevelTechnique1:o,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:h,byteLength:c[1],decompressedCount:h}}(t,e);return i.logicalLevelTechnique1===ip.MORTON?function(t,e,i){const r=pp(e,i,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:t.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(i,t,e):ip.RLE!==i.logicalLevelTechnique1&&ip.RLE!==i.logicalLevelTechnique2||rp.NONE===i.physicalLevelTechnique?i:function(t,e,i){const r=pp(e,i,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(i,t,e)}!function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"}(sp||(sp={})),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"}(op||(op={})),function(t){t.VAR_BINARY="VAR_BINARY",t.GEOMETRIES="GEOMETRIES",t.PARTS="PARTS",t.RINGS="RINGS",t.TRIANGLES="TRIANGLES",t.SYMBOL="SYMBOL",t.DICTIONARY="DICTIONARY"}(ap||(ap={})),function(t){t[t.FLAT=0]="FLAT",t[t.CONST=1]="CONST",t[t.SEQUENCE=2]="SEQUENCE",t[t.DICTIONARY=3]="DICTIONARY",t[t.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(lp||(lp={}));class Mp{values;_size;constructor(t,e){this.values=t,this._size=e}get(t){const e=Math.floor(t/8);return 1==(this.values[e]>>t%8&1)}set(t,e){const i=Math.floor(t/8);this.values[i]=this.values[i]|(e?1:0)<<t%8}getInt(t){const e=Math.floor(t/8);return this.values[e]>>t%8&1}size(){return this._size}getBuffer(){return this.values}}function Ep(t,e,i,r,n){return function(t,e,i){switch(e.logicalLevelTechnique1){case ip.DELTA:return e.logicalLevelTechnique2===ip.RLE?function(t,e,i){const r=new Int32Array(i);let n=0,s=0;for(let i=0;i<e;i++){const o=t[i],a=_p(t[i+e]);for(let t=0;t<o;t++)s+=a,r[n++]=s}return r}(t,e.runs,e.numRleValues):(function(t){t[0]=t[0]>>>1^-(1&t[0]);const e=t.length/4*4;let i=1;if(e>=4)for(;i<e-4;i+=4){const e=t[i],r=t[i+1],n=t[i+2],s=t[i+3];t[i]=(e>>>1^-(1&e))+t[i-1],t[i+1]=(r>>>1^-(1&r))+t[i],t[i+2]=(n>>>1^-(1&n))+t[i+1],t[i+3]=(s>>>1^-(1&s))+t[i+2]}for(;i!=t.length;++i)t[i]=(t[i]>>>1^-(1&t[i]))+t[i-1]}(t),t);case ip.RLE:return function(t,e,i){return i?function(t,e,i){const r=new Int32Array(i);let n=0;for(let i=0;i<e;i++){const s=t[i];let o=t[i+e];o=o>>>1^-(1&o),r.fill(o,n,n+s),n+=s}return r}(t,e.runs,e.numRleValues):vp(t,e.runs,e.numRleValues)}(t,e,i);case ip.MORTON:return wp(t),t;case ip.COMPONENTWISE_DELTA:return Sp(t),t;case ip.NONE:return i&&function(t){for(let e=0;e<t.length;e++){const i=t[e];t[e]=i>>>1^-(1&i)}}(t),t;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(Ip(t,e,i),i,r)}function Ap(t,e,i){return function(t,e){if(e.logicalLevelTechnique1===ip.DELTA&&e.logicalLevelTechnique2===ip.NONE){const e=function(t){const e=new Int32Array(t.length+1);e[0]=0,e[1]=_p(t[0]);let i=e[1],r=2;for(;r!=e.length;++r){const n=t[r-1];i+=n>>>1^-(1&n),e[r]=e[r-1]+i}return e}(t);return e}if(e.logicalLevelTechnique1===ip.RLE&&e.logicalLevelTechnique2===ip.NONE){const i=function(t,e,i){const r=new Int32Array(i+1);r[0]=0;let n=1,s=r[0];for(let i=0;i<e;i++){const o=t[i],a=t[i+e];for(let t=n;t<n+o;t++)r[t]=a+s,s=r[t];n+=o}return r}(t,e.runs,e.numRleValues);return i}if(e.logicalLevelTechnique1===ip.NONE&&e.logicalLevelTechnique2===ip.NONE){!function(t){let e=0;for(let i=0;i<t.length;i++)t[i]+=e,e=t[i]}(t);const i=new Int32Array(e.numValues+1);return i[0]=0,i.set(t,1),i}if(e.logicalLevelTechnique1===ip.DELTA&&e.logicalLevelTechnique2===ip.RLE){const i=function(t,e,i){const r=new Int32Array(i+1);r[0]=0;let n=1,s=r[0];for(let i=0;i<e;i++){const o=t[i];let a=t[i+e];a=a>>>1^-(1&a);for(let t=n;t<n+o;t++)r[t]=a+s,s=r[t];n+=o}return r}(t,e.runs,e.numRleValues);return wp(i),i}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Ip(t,e,i),i)}function Ip(t,e,i){const r=i.physicalLevelTechnique;if(r===rp.FAST_PFOR)return mp();if(r===rp.VARINT)return pp(t,e,i.numValues);if(r===rp.NONE){const r=e.get();e.add(i.byteLength);const n=t.subarray(r,e.get());return new Int32Array(n)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}function Pp(t,e,i,r){const n=Ip(t,e,i);if(1===n.length){const t=n[0];return r?_p(t):t}return r?function(t){return _p(t[1])}(n):function(t){return t[1]}(n)}function Dp(t,e,i){return function(t){if(2==t.length){const e=_p(t[1]);return[e,e]}return[_p(t[2]),_p(t[3])]}(Ip(t,e,i))}function kp(t,e,i){return function(t){if(2==t.length){const e=gp(t[1]);return[e,e]}return[gp(t[2]),gp(t[3])]}(dp(t,e,i.numValues))}function zp(t,e,i,r){return function(t,e,i){switch(e.logicalLevelTechnique1){case ip.DELTA:return e.logicalLevelTechnique2===ip.RLE?function(t,e,i){const r=new BigInt64Array(i);let n=0,s=0n;for(let i=0;i<e;i++){const o=Number(t[i]),a=gp(t[i+e]);for(let t=0;t<o;t++)s+=a,r[n++]=s}return r}(t,e.runs,e.numRleValues):(function(t){t[0]=t[0]>>1n^-(1n&t[0]);const e=t.length/4*4;let i=1;if(e>=4)for(;i<e-4;i+=4){const e=t[i],r=t[i+1],n=t[i+2],s=t[i+3];t[i]=(e>>1n^-(1n&e))+t[i-1],t[i+1]=(r>>1n^-(1n&r))+t[i],t[i+2]=(n>>1n^-(1n&n))+t[i+1],t[i+3]=(s>>1n^-(1n&s))+t[i+2]}for(;i!=t.length;++i)t[i]=(t[i]>>1n^-(1n&t[i]))+t[i-1]}(t),t);case ip.RLE:return function(t,e,i){return i?function(t,e,i){const r=new BigInt64Array(i);let n=0;for(let i=0;i<e;i++){const s=Number(t[i]);let o=t[i+e];o=o>>1n^-(1n&o),r.fill(o,n,n+s),n+=s}return r}(t,e.runs,e.numRleValues):xp(t,e.runs,e.numRleValues)}(t,e,i);case ip.NONE:return i&&function(t){for(let e=0;e<t.length;e++){const i=t[e];t[e]=i>>1n^-(1n&i)}}(t),t;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(dp(t,e,i.numValues),i,r)}function Rp(t,e,i,r){const n=dp(t,e,i.numValues);if(1===n.length){const t=n[0];return r?gp(t):t}return r?function(t){return gp(t[1])}(n):function(t){return t[1]}(n)}function Lp(t,e,i,r,n){return function(t,e,i,r){switch(e.logicalLevelTechnique1){case ip.DELTA:return e.logicalLevelTechnique2===ip.RLE&&(t=vp(t,e.runs,e.numRleValues)),function(t,e){const i=new Int32Array(t.size());let r=0;t.get(0)?(i[0]=t.get(0)?e[0]>>>1^-(1&e[0]):0,r=1):i[0]=0;let n=1;for(;n!=i.length;++n)i[n]=t.get(n)?i[n-1]+(e[r]>>>1^-(1&e[r++])):i[n-1];return i}(r,t);case ip.RLE:return function(t,e,i,r){const n=e;return i?function(t,e,i){const r=new Int32Array(t.size());let n=0;for(let s=0;s<i;s++){const o=e[s];let a=e[s+i];a=a>>>1^-(1&a);for(let e=n;e<n+o;e++)t.get(e)?r[e]=a:(r[e]=0,n++);n+=o}return r}(r,t,n.runs):function(t,e,i){const r=new Int32Array(t.size());let n=0;for(let s=0;s<i;s++){const o=e[s],a=e[s+i];for(let e=n;e<n+o;e++)t.get(e)?r[e]=a:(r[e]=0,n++);n+=o}return r}(r,t,n.runs)}(t,e,i,r);case ip.MORTON:return wp(t),t;case ip.COMPONENTWISE_DELTA:return Sp(t),t;case ip.NONE:return t=i?function(t,e){const i=new Int32Array(t.size());let r=0,n=0;for(;n!=i.length;++n)if(t.get(n)){const t=e[r++];i[n]=t>>>1^-(1&t)}else i[n]=0;return i}(r,t):function(t,e){const i=new Int32Array(t.size());let r=0,n=0;for(;n!=i.length;++n)i[n]=t.get(n)?e[r++]:0;return i}(r,t),t;default:throw new Error("The specified Logical level technique is not supported")}}(i.physicalLevelTechnique===rp.FAST_PFOR?mp():pp(t,e,i.numValues),i,r,n)}function Fp(t,e,i,r){const n=t.logicalLevelTechnique1;if(n===ip.RLE)return 1===t.runs?lp.CONST:lp.FLAT;const s=e instanceof Mp?e.size():e;if(n===ip.DELTA&&t.logicalLevelTechnique2===ip.RLE){const e=t.runs,n=2;if(t.numRleValues!==s)return lp.FLAT;if(1===e)return lp.SEQUENCE;if(2===e){const e=r.get();let s;if(t.physicalLevelTechnique===rp.VARINT)s=pp(i,r,4);else{const t=r.get();s=new Int32Array(i.buffer,i.byteOffset+t,4)}if(r.set(e),s[2]===n&&s[3]===n)return lp.SEQUENCE}}return 1===t.numValues?lp.CONST:lp.FLAT}class Bp extends Hu{getValueFromBuffer(t){return this.dataBuffer[t]}}class Op extends Ku{constructor(t,e,i,r){super(t,BigInt64Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}}class Np{_geometryOffsets;_partOffsets;_ringOffsets;constructor(t,e,i){this._geometryOffsets=t,this._partOffsets=e,this._ringOffsets=i}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function Vp(t,e,i){return{x:jp(t,e)-i,y:jp(t>>1,e)-i}}function jp(t,e){let i=0;for(let r=0;r<e;r++)i|=(t&1<<2*r)>>r;return i}!function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON",t[t.MULTIPOINT=3]="MULTIPOINT",t[t.MULTILINESTRING=4]="MULTILINESTRING",t[t.MULTIPOLYGON=5]="MULTIPOLYGON"}(cp||(cp={})),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"}(hp||(hp={})),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"}(up||(up={}));class qp{createPoint(t){return[[t]]}createMultiPoint(t){return t.map(t=>[t])}createLineString(t){return[t]}createMultiLineString(t){return t}createPolygon(t,e){return[t].concat(e)}createMultiPolygon(t){return t.flat()}}function Gp(t){const e=new Array(t.numGeometries);let r=1,n=1,s=1,o=0;const a=new qp;let l=0,c=0;const h=t.mortonSettings,u=t.topologyVector,p=u.geometryOffsets,d=u.partOffsets,f=u.ringOffsets,m=t.vertexOffsets,_=t.containsPolygonGeometry(),g=t.vertexBuffer;for(let u=0;u<t.numGeometries;u++){const y=t.geometryType(u);if(y===cp.POINT){if(m&&0!==m.length)if(t.vertexBufferType===up.VEC_2){const t=2*m[c++],r=new i(g[t],g[t+1]);e[o++]=a.createPoint(r)}else{const t=Vp(g[m[c++]],h.numBits,h.coordinateShift),r=new i(t.x,t.y);e[o++]=a.createPoint(r)}else{const t=new i(g[l++],g[l++]);e[o++]=a.createPoint(t)}p&&s++,d&&r++,f&&n++}else if(y===cp.MULTIPOINT){const t=p[s]-p[s-1];s++;const r=new Array(t);if(m&&0!==m.length){for(let e=0;e<t;e++){const t=2*m[c++];r[e]=new i(g[t],g[t+1])}e[o++]=a.createMultiPoint(r)}else{for(let e=0;e<t;e++){const t=g[l++],n=g[l++];r[e]=new i(t,n)}e[o++]=a.createMultiPoint(r)}}else if(y===cp.LINESTRING){let i,u=0;_?(u=f[n]-f[n-1],n++):u=d[r]-d[r-1],r++,m&&0!==m.length?(i=t.vertexBufferType===up.VEC_2?Hp(g,m,c,u,!1):Xp(g,m,c,u,!1,h),c+=u):(i=Wp(g,l,u,!1),l+=2*u),e[o++]=a.createLineString(i),p&&s++}else if(y===cp.POLYGON){const i=d[r]-d[r-1];r++;const u=new Array(i-1);let _=f[n]-f[n-1];if(n++,m&&0!==m.length){const i=t.vertexBufferType===up.VEC_2?$p(g,m,c,_):Zp(g,m,c,_,0,h);c+=_;for(let e=0;e<u.length;e++)_=f[n]-f[n-1],n++,u[e]=t.vertexBufferType===up.VEC_2?$p(g,m,c,_):Zp(g,m,c,_,0,h),c+=_;e[o++]=a.createPolygon(i,u)}else{const t=Up(g,l,_);l+=2*_;for(let t=0;t<u.length;t++)_=f[n]-f[n-1],n++,u[t]=Up(g,l,_),l+=2*_;e[o++]=a.createPolygon(t,u)}p&&s++}else if(y===cp.MULTILINESTRING){const i=p[s]-p[s-1];s++;const u=new Array(i);if(m&&0!==m.length){for(let e=0;e<i;e++){let i=0;_?(i=f[n]-f[n-1],n++):i=d[r]-d[r-1],r++;const s=t.vertexBufferType===up.VEC_2?Hp(g,m,c,i,!1):Xp(g,m,c,i,!1,h);u[e]=s,c+=i}e[o++]=a.createMultiLineString(u)}else{for(let t=0;t<i;t++){let e=0;_?(e=f[n]-f[n-1],n++):e=d[r]-d[r-1],r++,u[t]=Wp(g,l,e,!1),l+=2*e}e[o++]=a.createMultiLineString(u)}}else{if(y!==cp.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const i=p[s]-p[s-1];s++;const u=new Array(i);let _=0;if(m&&0!==m.length){for(let e=0;e<i;e++){const i=d[r]-d[r-1];r++;const s=new Array(i-1);_=f[n]-f[n-1],n++;const o=t.vertexBufferType===up.VEC_2?$p(g,m,c,_):Zp(g,m,c,_,0,h);c+=_;for(let e=0;e<s.length;e++)_=f[n]-f[n-1],n++,s[e]=t.vertexBufferType===up.VEC_2?$p(g,m,c,_):Zp(g,m,c,_,0,h),c+=_;u[e]=a.createPolygon(o,s)}e[o++]=a.createMultiPolygon(u)}else{for(let t=0;t<i;t++){const e=d[r]-d[r-1];r++;const i=new Array(e-1);_=f[n]-f[n-1],n++;const s=Up(g,l,_);l+=2*_;for(let t=0;t<i.length;t++){const e=f[n]-f[n-1];n++,i[t]=Up(g,l,e),l+=2*e}u[t]=a.createPolygon(s,i)}e[o++]=a.createMultiPolygon(u)}}}}return e}function Up(t,e,i){return Wp(t,e,i,!0)}function $p(t,e,i,r){return Hp(t,e,i,r,!0)}function Zp(t,e,i,r,n,s){return Xp(t,e,i,r,!0,s)}function Wp(t,e,r,n){const s=new Array(n?r+1:r);for(let n=0;n<2*r;n+=2)s[n/2]=new i(t[e+n],t[e+n+1]);return n&&(s[s.length-1]=s[0]),s}function Hp(t,e,r,n,s){const o=new Array(s?n+1:n);for(let s=0;s<2*n;s+=2){const n=2*e[r+s/2];o[s/2]=new i(t[n],t[n+1])}return s&&(o[o.length-1]=o[0]),o}function Xp(t,e,r,n,s,o){const a=new Array(s?n+1:n);for(let s=0;s<n;s++){const n=Vp(t[e[r+s]],o.numBits,o.coordinateShift);a[s]=new i(n.x,n.y)}return s&&(a[a.length-1]=a[0]),a}class Yp{_vertexBufferType;_topologyVector;_vertexOffsets;_vertexBuffer;_mortonSettings;constructor(t,e,i,r,n){this._vertexBufferType=t,this._topologyVector=e,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=n}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const t=Gp(this);let e=0;for(;e<this.numGeometries;)yield{coordinates:t[e],type:this.geometryType(e)},e++}getSimpleEncodedVertex(t){const e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){const e=Vp(this.vertexBuffer[this.vertexOffsets[t]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[e.x,e.y]}const e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getGeometries(){return Gp(this)}get mortonSettings(){return this._mortonSettings}}class Kp extends Yp{_numGeometries;_geometryType;constructor(t,e,i,r,n,s,o){super(i,r,n,s,o),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===cp.POLYGON||this._geometryType===cp.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class Jp extends Yp{_geometryTypes;constructor(t,e,i,r,n,s){super(t,i,r,n,s),this._geometryTypes=e}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let t=0;t<this.numGeometries;t++)if(this.geometryType(t)===cp.POLYGON||this.geometryType(t)===cp.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class Qp{_triangleOffsets;_indexBuffer;_vertexBuffer;_topologyVector;constructor(t,e,i,r){this._triangleOffsets=t,this._indexBuffer=e,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const t=new Array(this.numGeometries),e=this._topologyVector,r=e.partOffsets,n=e.ringOffsets,s=e.geometryOffsets;let o=0,a=1,l=1,c=1;for(let e=0;e<this.numGeometries;e++)switch(this.geometryType(e)){case cp.POLYGON:{const h=r[a]-r[a-1];a++;const u=[];for(let t=0;t<h;t++){const t=n[l]-n[l-1];l++;const e=[];for(let r=0;r<t;r++){const t=this._vertexBuffer[o++],r=this._vertexBuffer[o++];e.push(new i(t,r))}e.length>0&&e.push(e[0]),u.push(e)}t[e]=u,s&&c++}break;case cp.MULTIPOLYGON:{const h=s[c]-s[c-1];c++;const u=[];for(let t=0;t<h;t++){const t=r[a]-r[a-1];a++;for(let e=0;e<t;e++){const t=n[l]-n[l-1];l++;const e=[];for(let r=0;r<t;r++){const t=this._vertexBuffer[o++],r=this._vertexBuffer[o++];e.push(new i(t,r))}e.length>0&&e.push(e[0]),u.push(e)}}t[e]=u}}return t}[Symbol.iterator](){return null}}function td(t,e,i,r,n,s){return new ed(t,e,i,r,n,s)}class ed extends Qp{_numGeometries;_geometryType;constructor(t,e,i,r,n,s){super(i,r,n,s),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function id(t,e,i,r,n){return new rd(t,e,i,r,n)}class rd extends Qp{_geometryTypes;constructor(t,e,i,r,n){super(e,i,r,n),this._geometryTypes=t}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function nd(t,e,i,r,n){const s=Cp(t,i);let o=null,a=null,l=null,c=null,h=null,u=null,p=null,d=null;if(Fp(s,r,t,i)===lp.CONST){const n=Pp(t,i,s,!1);for(let r=0;r<e-1;r++){const e=Cp(t,i);switch(e.physicalStreamType){case np.LENGTH:switch(e.logicalStreamType.lengthType){case ap.GEOMETRIES:o=Ap(t,i,e);break;case ap.PARTS:a=Ap(t,i,e);break;case ap.RINGS:l=Ap(t,i,e);break;case ap.TRIANGLES:p=Ap(t,i,e)}break;case np.OFFSET:switch(e.logicalStreamType.offsetType){case op.VERTEX:c=Ep(t,i,e,!1);break;case op.INDEX:d=Ep(t,i,e,!1)}break;case np.DATA:sp.VERTEX===e.logicalStreamType.dictionaryType?h=Ep(t,i,e,!0):(u={numBits:e.numBits,coordinateShift:e.coordinateShift},h=Ep(t,i,e,!1))}}return null!==d?null!=o||null!=a?td(r,n,p,d,h,new Np(o,a,l)):td(r,n,p,d,h):null===u?function(t,e,i,r,n){return new Kp(t,e,up.VEC_2,i,r,n)}(r,n,new Np(o,a,l),c,h):function(t,e,i,r,n,s){return new Kp(t,e,up.MORTON,i,r,n,s)}(r,n,new Np(o,a,l),c,h,u)}const f=Ep(t,i,s,!1);for(let r=0;r<e-1;r++){const e=Cp(t,i);switch(e.physicalStreamType){case np.LENGTH:switch(e.logicalStreamType.lengthType){case ap.GEOMETRIES:o=Ep(t,i,e,!1);break;case ap.PARTS:a=Ep(t,i,e,!1);break;case ap.RINGS:l=Ep(t,i,e,!1);break;case ap.TRIANGLES:p=Ap(t,i,e)}break;case np.OFFSET:switch(e.logicalStreamType.offsetType){case op.VERTEX:c=Ep(t,i,e,!1);break;case op.INDEX:d=Ep(t,i,e,!1)}break;case np.DATA:sp.VERTEX===e.logicalStreamType.dictionaryType?h=Ep(t,i,e,!0):(u={numBits:e.numBits,coordinateShift:e.coordinateShift},h=Ep(t,i,e,!1))}}return null!==d&&null===a?id(f,p,d,h):(null!==o?(o=sd(f,o,2),null!==a&&null!==l?(a=od(f,o,a,!1),l=function(t,e,i,r){const n=new Int32Array(i[i.length-1]+1);let s=0;n[0]=s;let o=1,a=1,l=0;for(let c=0;c<t.length;c++){const h=t[c],u=e[c+1]-e[c];if(0!==h&&3!==h)for(let t=0;t<u;t++){const t=i[o]-i[o-1];o++;for(let e=0;e<t;e++)s=n[a++]=s+r[l++]}else for(let t=0;t<u;t++)n[a++]=++s,o++}return n}(f,o,a,l)):null!==a&&(a=function(t,e,i){const r=new Int32Array(e[e.length-1]+1);let n=0;r[0]=n;let s=1,o=0;for(let a=0;a<t.length;a++){const l=t[a],c=e[a+1]-e[a];if(4===l||1===l)for(let t=0;t<c;t++)n=r[s++]=n+i[o++];else for(let t=0;t<c;t++)r[s++]=++n}return r}(f,o,a))):null!==a&&null!==l?(a=sd(f,a,1),l=od(f,a,l,!0)):null!==a&&(a=sd(f,a,0)),null!==d?id(f,p,d,h,new Np(o,a,l)):null===u?function(t,e,i,r){return new Jp(up.VEC_2,t,e,i,r)}(f,new Np(o,a,l),c,h):function(t,e,i,r,n){return new Jp(up.MORTON,t,e,i,r,n)}(f,new Np(o,a,l),c,h,u))}function sd(t,e,i){const r=new Int32Array(t.length+1);let n=0;r[0]=n;let s=0;for(let o=0;o<t.length;o++)n=r[o+1]=n+(t[o]>i?e[s++]:1);return r}function od(t,e,i,r){const n=new Int32Array(e[e.length-1]+1);let s=0;n[0]=s;let o=1,a=0;for(let l=0;l<t.length;l++){const c=t[l],h=e[l+1]-e[l];if(5===c||2===c||r&&(4===c||1===c))for(let t=0;t<h;t++)s=n[o++]=s+i[a++];else for(let t=0;t<h;t++)n[o++]=++s}return n}class ad extends Wu{dataVector;constructor(t,e,i){super(t,e.getBuffer(),i),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}}class ld extends Hu{getValueFromBuffer(t){return this.dataBuffer[t]}}class cd extends Wu{constructor(t,e,i){super(t,BigInt64Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}}function hd(t,e,i){return ud(t,Math.ceil(e/8),i)}function ud(t,e,i){const r=new Uint8Array(e);let n=0;for(;n<e;){const e=t[i.increment()];if(e<=127){const s=e+3,o=t[i.increment()],a=n+s;r.fill(o,n,a),n=a}else{const s=256-e;for(let e=0;e<s;e++)r[n++]=t[i.increment()]}}return r}const pd=new TextDecoder;function dd(t,e,i){return i-e>=12?pd.decode(t.subarray(e,i)):function(t,e,i){let r="",n=e;for(;n<i;){const e=t[n];let s,o,a,l=null,c=e>239?4:e>223?3:e>191?2:1;if(n+c>i)break;1===c?e<128&&(l=e):2===c?(s=t[n+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===c?(s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(t,e,i)}class fd extends Wu{offsetBuffer;constructor(t,e,i,r){super(t,i,r),this.offsetBuffer=e}}class md extends fd{textEncoder;constructor(t,e,i,r){super(t,e,i,r??e.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(t){return dd(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class _d extends fd{indexBuffer;textEncoder;constructor(t,e,i,r,n){super(t,i,r,n??e.length),this.indexBuffer=e,this.indexBuffer=e,this.textEncoder=new TextEncoder}getValueFromBuffer(t){const e=this.indexBuffer[t];return dd(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class gd extends fd{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(t,e,i,r,n,s,o){super(t,i,r,o),this.indexBuffer=e,this.symbolOffsetBuffer=n,this.symbolTableBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(t){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(t,e,i){const r=[],n=new Array(e.length).fill(0);for(let t=1;t<e.length;t++)n[t]=n[t-1]+e[t-1];for(let s=0;s<i.length;s++)if(255===i[s])r.push(i[++s]);else{const o=e[i[s]],a=n[i[s]];for(let e=0;e<o;e++)r.push(t[a+e])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const e=this.indexBuffer[t];return dd(this.decodedDictionary,this.offsetBuffer[e],this.offsetBuffer[e+1])}offsetToLengthBuffer(t){const e=new Uint32Array(t.length-1);let i=t[0];for(let r=1;r<t.length;r++){const n=t[r];e[r-1]=n-i,i=n}return e}}function yd(t,e,i,r,n,s){return"scalarType"===i.type?function(t,e,i,r,n,s){let o=null,a=0;if(0===t)return null;if(s.nullable){const t=Cp(e,i);a=t.numValues;const r=i.get(),n=hd(e,a,i);i.set(r+t.byteLength),o=new Mp(n,t.numValues)}const l=o??r;switch(n.physicalType){case 4:case 3:return function(t,e,i,r,n){const s=Cp(t,e),o=Fp(s,n,t,e),a=3===r.physicalType;if(o===lp.FLAT){const r=vd(n)?Lp(t,e,s,a,n):Ep(t,e,s,a);return new Xu(i.name,r,n)}if(o===lp.SEQUENCE){const r=Dp(t,e,s);return new Ju(i.name,r[0],r[1],s.numRleValues)}{const r=Pp(t,e,s,a);return new Qu(i.name,r,n)}}(e,i,s,n,l);case 9:return function(t,e,i,r,n){let s=null,o=null,a=null,l=null,c=null,h=null,u=null,p=null;for(let t=0;t<r;t++){const t=Cp(e,i);if(0!==t.byteLength)switch(t.physicalStreamType){case np.PRESENT:{const r=hd(e,t.numValues,i);h=new Mp(r,t.numValues);break}case np.OFFSET:o=null!=n||null!=h?Lp(e,i,t,!1,n??h):Ep(e,i,t,!1);break;case np.LENGTH:{const r=Ap(e,i,t);ap.DICTIONARY===t.logicalStreamType.lengthType?s=r:ap.SYMBOL===t.logicalStreamType.lengthType?l=r:u=r;break}case np.DATA:{const r=e.subarray(i.get(),i.get()+t.byteLength);i.add(t.byteLength);const n=t.logicalStreamType.dictionaryType;sp.FSST===n?c=r:sp.SINGLE===n||sp.SHARED===n?a=r:sp.NONE===n&&(p=r);break}}}return function(t,e,i,r,n,s,o){return e?new gd(t,i,r,n,s,e,o):null}(t,c,o,s,a,l,n??h)??function(t,e,i,r,n){return e?n?new _d(t,i,r,e,n):new _d(t,i,r,e):null}(t,a,o,s,n??h)??function(t,e,i,r,n){if(!e||!i)return null;if(r)return n?new _d(t,r,e,i,n):new _d(t,r,e,i);if(n&&n.size()!==e.length-1){const r=new Int32Array(n.size());let s=0;for(let t=0;t<n.size();t++)r[t]=n.get(t)?s++:0;return new _d(t,r,e,i,n)}return n?new md(t,e,i,n):new md(t,e,i)}(t,u,p,o,n??h)}(s.name,e,i,s.nullable?t-1:t,o);case 0:return function(t,e,i,r,n){const s=Cp(t,e),o=s.numValues,a=e.get(),l=vd(n)?function(t,e,i,r){const n=ud(t,Math.ceil(e/8),i),s=new Mp(n,e),o=r.size(),a=new Mp(new Uint8Array(o),o);let l=0;for(let t=0;t<r.size();t++){const e=!!r.get(t)&&s.get(l++);a.set(t,e)}return a.getBuffer()}(t,o,e,n):hd(t,o,e);e.set(a+s.byteLength);const c=new Mp(l,o);return new ad(i.name,c,n)}(e,i,s,0,l);case 6:case 5:return function(t,e,i,r,n){const s=Cp(t,e),o=Fp(s,r,t,e),a=5===n.physicalType;if(o===lp.FLAT){const n=vd(r)?function(t,e,i,r,n){return function(t,e,i,r){switch(e.logicalLevelTechnique1){case ip.DELTA:return e.logicalLevelTechnique2===ip.RLE&&(t=xp(t,e.runs,e.numRleValues)),function(t,e){const i=new BigInt64Array(t.size());let r=0;t.get(0)?(i[0]=t.get(0)?e[0]>>1n^-(1n&e[0]):0n,r=1):i[0]=0n;let n=1;for(;n!=i.length;++n)i[n]=t.get(n)?i[n-1]+(e[r]>>1n^-(1n&e[r++])):i[n-1];return i}(r,t);case ip.RLE:return function(t,e,i,r){const n=e;return i?function(t,e,i){const r=new BigInt64Array(t.size());let n=0;for(let s=0;s<i;s++){const o=Number(e[s]);let a=e[s+i];a=a>>1n^-(1n&a);for(let e=n;e<n+o;e++)t.get(e)?r[e]=a:(r[e]=0n,n++);n+=o}return r}(r,t,n.runs):function(t,e,i){const r=new BigInt64Array(t.size());let n=0;for(let s=0;s<i;s++){const o=Number(e[s]),a=e[s+i];for(let e=n;e<n+o;e++)t.get(e)?r[e]=a:(r[e]=0n,n++);n+=o}return r}(r,t,n.runs)}(t,e,i,r);case ip.NONE:return t=i?function(t,e){const i=new BigInt64Array(t.size());let r=0,n=0;for(;n!=i.length;++n)if(t.get(n)){const t=e[r++];i[n]=t>>1n^-(1n&t)}else i[n]=0n;return i}(r,t):function(t,e){const i=new BigInt64Array(t.size());let r=0,n=0;for(;n!=i.length;++n)i[n]=t.get(n)?e[r++]:0n;return i}(r,t),t;default:throw new Error("The specified Logical level technique is not supported")}}(dp(t,e,i.numValues),i,r,n)}(t,e,s,a,r):zp(t,e,s,a);return new Bp(i.name,n,r)}if(o===lp.SEQUENCE){const r=kp(t,e,s);return new Op(i.name,r[0],r[1],s.numRleValues)}{const n=Rp(t,e,s,a);return new cd(i.name,n,r)}}(e,i,s,l,n);case 7:return function(t,e,i,r){const n=Cp(t,e),s=vd(r)?function(t,e,i,r){const n=e.get(),s=n+r*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(n,s)).buffer,a=new Float32Array(o);e.set(s);const l=i.size(),c=new Float32Array(l);let h=0;for(let t=0;t<l;t++)c[t]=i.get(t)?a[h++]:0;return c}(t,e,r,n.numValues):function(t,e,i){const r=e.get(),n=r+i*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(t.subarray(r,n)).buffer,o=new Float32Array(s);return e.set(n),o}(t,e,n.numValues);return new ld(i.name,s,r)}(e,i,s,l);case 8:return function(t,e,i,r){const n=Cp(t,e),s=vd(r)?function(t,e,i,r){const n=e.get(),s=n+r*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(n,s)).buffer,a=new Float64Array(o);e.set(s);const l=i.size(),c=new Float64Array(l);let h=0;for(let t=0;t<l;t++)c[t]=i.get(t)?a[h++]:0;return c}(t,e,r,n.numValues):function(t,e,i){const r=e.get(),n=r+i*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(t.subarray(r,n)).buffer,o=new Float64Array(s);return e.set(n),o}(t,e,n.numValues);return new Yu(i.name,s,r)}(e,i,s,l);default:throw new Error(`The specified data type for the field is currently not supported: ${n}`)}}(r,t,e,n,i.scalarType,i):1!=r?null:function(t,e,i,r){let n=null,s=null,o=null,a=null,l=!1;for(;!l;){const i=Cp(t,e);switch(i.physicalStreamType){case np.LENGTH:ap.DICTIONARY===i.logicalStreamType.lengthType?n=Ap(t,e,i):o=Ap(t,e,i);break;case np.DATA:sp.SINGLE===i.logicalStreamType.dictionaryType||sp.SHARED===i.logicalStreamType.dictionaryType?(s=t.subarray(e.get(),e.get()+i.byteLength),l=!0):a=t.subarray(e.get(),e.get()+i.byteLength),e.add(i.byteLength)}}const c=i.complexType.children,h=[];let u=0;for(const l of c){const c=pp(t,e,1)[0];if(0==c)continue;const p=`${i.name}${"default"===l.name?"":":"+l.name}`;if(2!==c||"scalarField"!==l.type||9!==l.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const d=Cp(t,e),f=hd(t,d.numValues,e),m=Cp(t,e),_=m.decompressedCount!==r?Lp(t,e,m,!1,new Mp(f,d.numValues)):Ep(t,e,m,!1);h[u++]=a?new gd(p,_,n,s,o,a,new Mp(f,d.numValues)):new _d(p,_,n,s,new Mp(f,d.numValues))}return h}(t,e,i,n)}function vd(t){return t instanceof Mp}function xd(t){if("id"===t.name)return!1;if("scalarType"===t.type){const e=t.scalarType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===e.type)return!1}else if("complexType"===t.type){const e=t.complexType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}const bd=new TextDecoder;function wd(t,e){const i=pp(t,e,1)[0];if(0===i)return"";const r=e.get(),n=t.subarray(r,r+i);return e.add(i),bd.decode(n)}function Sd(t,e){const i=pp(t,e,1)[0]>>>0,r=!!(4&i),n=!!(2&i),s=pp(t,e,1)[0]>>>0,o={};if(1&i&&(o.nullable=!0),n){const n={};if(r?(n.type="logicalType",n.logicalType=s):(n.type="physicalType",n.physicalType=s),8&i){const i=pp(t,e,1)[0]>>>0;n.children=new Array(i);for(let r=0;r<i;r++)n.children[r]=Sd(t,e)}o.type="complexField",o.complexField=n}else{const t={};r?(t.type="logicalType",t.logicalType=s):(t.type="physicalType",t.physicalType=s),o.type="scalarField",o.scalarField=t}return o}function Td(t,e){const i=pp(t,e,1)[0]>>>0,r=function(t){switch(t){case 0:case 1:case 2:case 3:{const e={};e.nullable=!!(1&t),e.columnScope=0;const i={};return i.physicalType=t>1?6:4,i.type="physicalType",e.scalarType=i,e.type="scalarType",e}case 4:{const t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:0};return t.type="complexType",t.complexType=e,t}case 30:{const t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:1};return t.type="complexType",t.complexType=e,t}default:return function(t){let e=null;switch(t){case 10:case 11:e=0;break;case 12:case 13:e=1;break;case 14:case 15:e=2;break;case 16:case 17:e=3;break;case 18:case 19:e=4;break;case 20:case 21:e=5;break;case 22:case 23:e=6;break;case 24:case 25:e=7;break;case 26:case 27:e=8;break;case 28:case 29:e=9;break;default:return null}const i={};i.nullable=!!(1&t),i.columnScope=0;const r={type:"physicalType"};return r.physicalType=e,i.type="scalarType",i.scalarType=r,i}(t)}}(i);if(!r)throw new Error(`Unsupported column type code: ${i}`);if(function(t){return t>=10}(i)?r.name=wd(t,e):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),function(t){return 30===t}(i)){const i=pp(t,e,1)[0]>>>0,n=r.complexType;n.children=new Array(i);for(let r=0;r<i;r++)n.children[r]=Sd(t,e)}return r}function Cd(t,e){const i={featureTables:[]},r={};r.name=wd(t,e);const n=pp(t,e,1)[0]>>>0,s=pp(t,e,1)[0]>>>0;r.columns=new Array(s);for(let i=0;i<s;i++)r.columns[i]=Td(t,e);return i.featureTables.push(r),[i,n]}function Md(t,e,i,r,n,s,o=!1){const a=e.scalarType.physicalType,l=Fp(n,s,t,i);if(4===a)switch(l){case lp.FLAT:{const e=Ep(t,i,n,!1);return new Xu(r,e,s)}case lp.SEQUENCE:{const e=Dp(t,i,n);return new Ju(r,e[0],e[1],n.numRleValues)}case lp.CONST:{const e=Pp(t,i,n,!1);return new Qu(r,e,s)}}else switch(l){case lp.FLAT:{if(o){const e=function(t,e,i){const r=function(t,e,i){const r=new Float64Array(e);for(let n=0;n<e;n++)r[n]=fp(t,i);return r}(t,i.numValues,e);return function(t,e){switch(e.logicalLevelTechnique1){case ip.DELTA:return e.logicalLevelTechnique2===ip.RLE&&(t=bp(t,e.runs,e.numRleValues)),function(t){t[0]=t[0]%2==1?(t[0]+1)/-2:t[0]/2;const e=t.length/4*4;let i=1;if(e>=4)for(;i<e-4;i+=4){const e=t[i],r=t[i+1],n=t[i+2],s=t[i+3];t[i]=(e%2==1?(e+1)/-2:e/2)+t[i-1],t[i+1]=(r%2==1?(r+1)/-2:r/2)+t[i],t[i+2]=(n%2==1?(n+1)/-2:n/2)+t[i+1],t[i+3]=(s%2==1?(s+1)/-2:s/2)+t[i+2]}for(;i!=t.length;++i)t[i]=(t[i]%2==1?(t[i]+1)/-2:t[i]/2)+t[i-1]}(t),t;case ip.RLE:return function(t,e){return bp(t,e.runs,e.numRleValues)}(t,e);case ip.NONE:return t;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(r,i)}(t,i,n);return new Yu(r,e,s)}const e=zp(t,i,n,!1);return new Bp(r,e,s)}case lp.SEQUENCE:{const e=kp(t,i,n);return new Op(r,e[0],e[1],n.numRleValues)}case lp.CONST:{const e=Rp(t,i,n,!1);return new cd(r,e,s)}}throw new Error("Vector type not supported for id column.")}class Ed{constructor(t,e){var i;switch(this._featureData=t,this.properties=this._featureData.properties||{},null===(i=this._featureData.geometry)||void 0===i?void 0:i.type){case cp.POINT:case cp.MULTIPOINT:this.type=1;break;case cp.LINESTRING:case cp.MULTILINESTRING:this.type=2;break;case cp.POLYGON:case cp.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=e,this.id=Number(this._featureData.id)}loadGeometry(){const t=[];for(const e of this._featureData.geometry.coordinates){const r=[];for(const t of e)r.push(new i(t.x,t.y));t.push(r)}return t}}class Ad{constructor(t){this.features=[],this.featureTable=t,this.name=t.name,this.extent=t.extent,this.version=2,this.features=t.getFeatures(),this.length=this.features.length}feature(t){return new Ed(this.features[t],this.extent)}}class Id{constructor(t){this.layers={};const e=function(t,e,i=!0){const r=new ep(0),n=[];for(;r.get()<t.length;){const e=pp(t,r,1)[0]>>>0,s=r.get()+e;if(s>t.length)throw new Error(`Block overruns tile: ${s} > ${t.length}`);if(1!=pp(t,r,1)[0]>>>0){r.set(s);continue}const o=Cd(t,r),a=o[1],l=o[0].featureTables[0];let c=null,h=null;const u=[];let p=0;for(const e of l.columns){const n=e.name;if("id"===n){let s=null;if(e.nullable){const e=Cp(t,r),i=r.get(),n=hd(t,e.numValues,r);r.set(i+e.byteLength),s=new Mp(n,e.numValues)}const o=Cp(t,r);p=o.decompressedCount,c=Md(t,e,r,n,o,s??p,i)}else if("geometry"===n){const e=pp(t,r,1)[0];if(0===p){const e=r.get();p=Cp(t,r).decompressedCount,r.set(e)}h=nd(t,e,r,p)}else{const i=xd(e)?pp(t,r,1)[0]:1;if(0===i&&"scalarType"===e.type)continue;const n=yd(t,r,e,i,p);if(n)if(Array.isArray(n))for(const t of n)u.push(t);else u.push(n)}}const d=new tp(l.name,h,c,u,a);n.push(d),r.set(s)}return n}(new Uint8Array(t));this.layers=e.reduce((t,e)=>Object.assign(Object.assign({},t),{[e.name]:new Ad(e)}),{})}}class Pd{constructor(t,e){this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},this.extent=e,"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id))}loadGeometry(){const t=[],e=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const r of e){const e=[];for(const t of r)e.push(new i(t[0],t[1]));t.push(e)}return t}}const Dd="_geojsonTileLayer";function kd(t,e){e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let r=0;r<t.length;r++)i.feature=t.feature(r),e.writeMessage(2,zd,i);const r=i.keys;for(const t of r)e.writeStringField(3,t);const n=i.values;for(const t of n)e.writeMessage(4,Od,t)}function zd(t,e){if(!t.feature)return;const i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,Rd,t),e.writeVarintField(3,i.type),e.writeMessage(4,Bd,i)}function Rd(t,e){for(const i in t.feature?.properties){let r=t.feature.properties[i],n=t.keycache[i];if(null==r)continue;void 0===n&&(t.keys.push(i),n=t.keys.length-1,t.keycache[i]=n),e.writeVarint(n),"string"!=typeof r&&"boolean"!=typeof r&&"number"!=typeof r&&(r=JSON.stringify(r));const s=typeof r+":"+r;let o=t.valuecache[s];void 0===o&&(t.values.push(r),o=t.values.length-1,t.valuecache[s]=o),e.writeVarint(o)}}function Ld(t,e){return(e<<3)+(7&t)}function Fd(t){return t<<1^t>>31}function Bd(t,e){const i=t.loadGeometry(),r=t.type;let n=0,s=0;for(const o of i){let i=1;1===r&&(i=o.length),e.writeVarint(Ld(1,i));const a=3===r?o.length-1:o.length;for(let t=0;t<a;t++){1===t&&1!==r&&e.writeVarint(Ld(2,a-1));const i=o[t].x-n,l=o[t].y-s;e.writeVarint(Fd(i)),e.writeVarint(Fd(l)),n+=i,s+=l}3===t.type&&e.writeVarint(Ld(7,1))}}function Od(t,e){const i=typeof t;"string"===i?e.writeStringField(1,t):"boolean"===i?e.writeBooleanField(7,t):"number"===i&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}class Nd{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new hs(I,16,0),this.grid3D=new hs(I,16,0),this.featureIndexArray=new jo,this.promoteId=e}insert(t,e,i,r,n,s){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const a=s?this.grid3D:this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<I&&r[1]<I&&r[2]>=0&&r[3]>=0&&a.insert(o,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Lc(new Eh(this.rawTileData)).layers:new Id(this.rawTileData).layers,this.sourceLayerCoder=new $u(this.vtLayers?Object.keys(this.vtLayers).sort():[Dd])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const s=t.params,o=I/t.tileSize/t.scale,a=dn(s.filter,s.globalState),l=t.queryGeometry,c=t.queryPadding*o,h=Uu.fromPoints(l),u=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),p=Uu.fromPoints(t.cameraQueryGeometry).expandBy(c),d=this.grid3D.query(p.minX,p.minY,p.maxX,p.maxY,(e,r,n,s)=>function(t,e,r,n,s){for(const i of t)if(e<=i.x&&r<=i.y&&n>=i.x&&s>=i.y)return!0;const o=[new i(e,r),new i(e,s),new i(n,s),new i(n,r)];if(t.length>2)for(const e of o)if(tl(t,e))return!0;for(let e=0;e<t.length-1;e++)if(el(t[e],t[e+1],o))return!0;return!1}(t.cameraQueryGeometry,e-c,r-c,n+c,s+c));for(const t of d)u.push(t);u.sort(jd);const f={};let m;for(let i=0;i<u.length;i++){const c=u[i];if(c===m)continue;m=c;const h=this.featureIndexArray.get(c);let p=null;this.loadMatchingFeature(f,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,a,s.layers,s.availableImages,e,r,n,(e,i,r)=>(p||(p=Va(e)),i.queryIntersectsFeature({queryGeometry:l,feature:e,featureState:r,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:o,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return f}loadMatchingFeature(t,e,i,r,n,s,o,a,l,c,h){const u=this.bucketLayerIDs[e];if(s&&!u.some(t=>s.has(t)))return;const p=this.sourceLayerCoder.decode(i),d=this.vtLayers[p].feature(r);if(n.needGeometry){const t=ja(d,!0);if(!n.filter(new zs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new zs(this.tileID.overscaledZ),d))return;const f=this.getId(d,p);for(let e=0;e<u.length;e++){const i=u[e];if(s&&!s.has(i))continue;const n=a[i];if(!n)continue;let p={};f&&c&&(p=c.getState(n.sourceLayer||Dd,f));const m=O({},l[i]);m.paint=Vd(m.paint,n.paint,d,p,o),m.layout=Vd(m.layout,n.layout,d,p,o);const _=!h||h(d,n,p);if(!_)continue;const g=new Zu(d,this.z,this.x,this.y,f);g.layer=m;let y=t[i];void 0===y&&(y=t[i]=[]),y.push({featureIndex:r,feature:g,intersectionZ:_})}}lookupSymbolFeatures(t,e,i,r,n,s,o,a){const l={};this.loadVTLayers();const c=dn(n.filterSpec,n.globalState);for(const n of t)this.loadMatchingFeature(l,i,r,n,c,s,o,a,e);return l}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){var i;let r=t.id;return this.promoteId&&(r=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof r&&(r=Number(r)),void 0===r&&(null===(i=t.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(r=Number(t.properties.cluster_id))),r}}function Vd(t,e,i,r,n){return V(t,(t,s)=>{const o=e instanceof Gs?e.get(s):null;return o&&o.evaluate?o.evaluate(i,r,n):o})}function jd(t,e){return e-t}function qd(t,e,r,n,s){const o=[];for(let a=0;a<t.length;a++){const l=t[a];let c;for(let t=0;t<l.length-1;t++){let a=l[t],h=l[t+1];a.x<e&&h.x<e||(a.x<e?a=new i(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x<e&&(h=new i(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y<r&&h.y<r||(a.y<r?a=new i(a.x+(r-a.y)/(h.y-a.y)*(h.x-a.x),r)._round():h.y<r&&(h=new i(a.x+(r-a.y)/(h.y-a.y)*(h.x-a.x),r)._round()),a.x>=n&&h.x>=n||(a.x>=n?a=new i(n,a.y+(n-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x>=n&&(h=new i(n,a.y+(n-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y>=s&&h.y>=s||(a.y>=s?a=new i(a.x+(s-a.y)/(h.y-a.y)*(h.x-a.x),s)._round():h.y>=s&&(h=new i(a.x+(s-a.y)/(h.y-a.y)*(h.x-a.x),s)._round()),c&&a.equals(c[c.length-1])||(c=[a],o.push(c)),c.push(h)))))}}return o}function Gd(t,e,i,r,n){switch(e){case 1:return function(t,e,i,r){const n=[];for(const s of t)for(const t of s){const s=0===r?t.x:t.y;s>=e&&s<=i&&n.push([t])}return n}(t,i,r,n);case 2:return $d(t,i,r,n,!1);case 3:return $d(t,i,r,n,!0)}return[]}function Ud(t,e,r,n,s){const o=0===n?Zd:Wd;let a=[];const l=[];for(let i=0;i<t.length-1;i++){const c=t[i],h=t[i+1],u=0===n?c.x:c.y,p=0===n?h.x:h.y;let d=!1;u<e?p>e&&a.push(o(c,h,e)):u>r?p<r&&a.push(o(c,h,r)):a.push(c),p<e&&u>=e&&(a.push(o(c,h,e)),d=!0),p>r&&u<=r&&(a.push(o(c,h,r)),d=!0),!s&&d&&(l.push(a),a=[])}const c=t.length-1,h=0===n?t[c].x:t[c].y;return h>=e&&h<=r&&a.push(t[c]),s&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function $d(t,e,i,r,n){const s=[];for(const o of t){const t=Ud(o,e,i,r,n);t.length>0&&s.push(...t)}return s}function Zd(t,e,r){return new i(r,t.y+(r-t.x)/(e.x-t.x)*(e.y-t.y))}function Wd(t,e,r){return new i(t.x+(r-t.y)/(e.y-t.y)*(e.x-t.x),r)}ps("FeatureIndex",Nd,{omit:["rawTileData","sourceLayerCoder"]});class Hd extends i{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new Hd(this.x,this.y,this.angle,this.segment)}}function Xd(t,e,i,r,n){if(void 0===e.segment||0===i)return!0;let s=e,o=e.segment+1,a=0;for(;a>-i/2;){if(o--,o<0)return!1;a-=t[o].dist(s),s=t[o]}a+=t[o].dist(t[o+1]),o++;const l=[];let c=0;for(;a<i/2;){const e=t[o],i=t[o+1];if(!i)return!1;let s=t[o-1].angleTo(e)-e.angleTo(i);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:s}),c+=s;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;o++,a+=e.dist(i)}return!0}function Yd(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function Kd(t,e,i){return t?.6*e*i:0}function Jd(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Qd(t,e,i,r,n,s){const o=Kd(i,n,s),a=Jd(i,r)*s;let l=0;const c=Yd(t)/2;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1],s=r.dist(n);if(l+s>c){const h=(c-l)/s,u=mi.number(r.x,n.x,h),p=mi.number(r.y,n.y,h),d=new Hd(u,p,n.angleTo(r),i);return d._round(),!o||Xd(t,d,a,o,e)?d:void 0}l+=s}}function tf(t,e,i,r,n,s,o,a,l){const c=Kd(r,s,o),h=Jd(r,n),u=h*o,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u<e/4&&(e=u+e/4),ef(t,p?e/2*a%e:(h/2+2*s)*o*a%e,e,c,i,u,p,!1,l)}function ef(t,e,i,r,n,s,o,a,l){const c=s/2,h=Yd(t);let u=0,p=e-i,d=[];for(let e=0;e<t.length-1;e++){const o=t[e],a=t[e+1],f=o.dist(a),m=a.angleTo(o);for(;p+i<u+f;){p+=i;const _=(p-u)/f,g=mi.number(o.x,a.x,_),y=mi.number(o.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&p-c>=0&&p+c<=h){const i=new Hd(g,y,m,e);i._round(),r&&!Xd(t,i,s,r,n)||d.push(i)}}u+=f}return a||d.length||o||(d=ef(t,u/2,i,r,n,s,o,!0,l)),d}function rf(t,e,r,n){const s=[],o=t.image,a=o.pixelRatio,l=o.paddedRect.w-2,c=o.paddedRect.h-2;let h={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const u=o.stretchX||[[0,l]],p=o.stretchY||[[0,c]],d=(t,e)=>t+e[1]-e[0],f=u.reduce(d,0),m=p.reduce(d,0),_=l-f,g=c-m;let y=0,v=f,x=0,b=m,w=0,S=_,T=0,C=g;if(o.content&&n){const e=o.content,i=e[2]-e[0],r=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(h=eu(t)),y=nf(u,0,e[0]),x=nf(p,0,e[1]),v=nf(u,e[0],e[2]),b=nf(p,e[1],e[3]),w=e[0]-y,T=e[1]-x,S=i-v,C=r-b}const M=h.x1,E=h.y1,A=h.x2-M,I=h.y2-E,P=(t,n,s,l)=>{const c=of(t.stretch-y,v,A,M),h=af(t.fixed-w,S,t.stretch,f),u=of(n.stretch-x,b,I,E),p=af(n.fixed-T,C,n.stretch,m),d=of(s.stretch-y,v,A,M),_=af(s.fixed-w,S,s.stretch,f),g=of(l.stretch-x,b,I,E),P=af(l.fixed-T,C,l.stretch,m),D=new i(c,u),k=new i(d,u),z=new i(d,g),R=new i(c,g),L=new i(h/a,p/a),F=new i(_/a,P/a),B=e*Math.PI/180;if(B){const t=Math.sin(B),e=Math.cos(B),i=[e,-t,t,e];D._matMult(i),k._matMult(i),R._matMult(i),z._matMult(i)}const O=t.stretch+t.fixed,N=n.stretch+n.fixed;return{tl:D,tr:k,bl:R,br:z,tex:{x:o.paddedRect.x+1+O,y:o.paddedRect.y+1+N,w:s.stretch+s.fixed-O,h:l.stretch+l.fixed-N},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:F,minFontScaleX:S/a/A,minFontScaleY:C/a/I,isSDF:r}};if(n&&(o.stretchX||o.stretchY)){const t=sf(u,_,f),e=sf(p,g,m);for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)s.push(P(r,e[t],n,e[t+1]))}}else s.push(P({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return s}function nf(t,e,i){let r=0;for(const n of t)r+=Math.max(e,Math.min(i,n[1]))-Math.max(e,Math.min(i,n[0]));return r}function sf(t,e,i){const r=[{fixed:-1,stretch:0}];for(const[e,i]of t){const t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return r.push({fixed:e+1,stretch:i}),r}function of(t,e,i,r){return t/e*i+r}function af(t,e,i,r){return t-e*i/r}ps("Anchor",Hd);class lf{constructor(t,e,r,n,s,o,a,l,c,h){var u;if(this.boxStartIndex=t.length,c){let t=o.top,e=o.bottom;const i=o.collisionPadding;i&&(t-=i[1],e+=i[3]);let r=e-t;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{const c=(null===(u=o.image)||void 0===u?void 0:u.content)&&(o.image.textFitWidth||o.image.textFitHeight)?eu(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const p=o.collisionPadding;if(p&&(c.x1-=p[0]*a,c.y1-=p[1]*a,c.x2+=p[2]*a,c.y2+=p[3]*a),h){const t=new i(c.x1,c.y1),e=new i(c.x2,c.y1),r=new i(c.x1,c.y2),n=new i(c.x2,c.y2),s=h*Math.PI/180;t._rotate(s),e._rotate(s),r._rotate(s),n._rotate(s),c.x1=Math.min(t.x,e.x,r.x,n.x),c.x2=Math.max(t.x,e.x,r.x,n.x),c.y1=Math.min(t.y,e.y,r.y,n.y),c.y2=Math.max(t.y,e.y,r.y,n.y)}t.emplaceBack(e.x,e.y,c.x1,c.y1,c.x2,c.y2,r,n,s)}this.boxEndIndex=t.length}}class cf{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,s=e[n];if(i(r,s)>=0)break;e[t]=s,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1);const s=r+1;if(s<this.length&&i(e[s],e[r])<0&&(r=s),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}}function hf(t,e=1,r=!1){const n=Uu.fromPoints(t[0]),s=Math.min(n.width(),n.height());let o=s/2;const a=new cf([],uf),{minX:l,minY:c,maxX:h,maxY:u}=n;if(0===s)return new i(l,c);for(let e=l;e<h;e+=s)for(let i=c;i<u;i+=s)a.push(new pf(e+o,i+o,o,t));let p=function(t){let e=0,i=0,r=0;const n=t[0];for(let t=0,s=n.length,o=s-1;t<s;o=t++){const s=n[t],a=n[o],l=s.x*a.y-a.x*s.y;i+=(s.x+a.x)*l,r+=(s.y+a.y)*l,e+=3*l}return new pf(i/e,r/e,0,t)}(t),d=a.length;for(;a.length;){const i=a.pop();(i.d>p.d||!p.d)&&(p=i,r&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,d)),i.max-p.d<=e||(o=i.h/2,a.push(new pf(i.p.x-o,i.p.y-o,o,t)),a.push(new pf(i.p.x+o,i.p.y-o,o,t)),a.push(new pf(i.p.x-o,i.p.y+o,o,t)),a.push(new pf(i.p.x+o,i.p.y+o,o,t)),d+=4)}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function uf(t,e){return e.max-t.max}function pf(t,e,r,n){this.p=new i(t,e),this.h=r,this.d=function(t,e){let i=!1,r=1/0;for(let n=0;n<e.length;n++){const s=e[n];for(let e=0,n=s.length,o=n-1;e<n;o=e++){const n=s[e],a=s[o];n.y>t.y!=a.y>t.y&&t.x<(a.x-n.x)*(t.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Ja(t,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}var df;t.aP=void 0,(df=t.aP||(t.aP={}))[df.center=1]="center",df[df.left=2]="left",df[df.right=3]="right",df[df.top=4]="top",df[df.bottom=5]="bottom",df[df["top-left"]=6]="top-left",df[df["top-right"]=7]="top-right",df[df["bottom-left"]=8]="bottom-left",df[df["bottom-right"]=9]="bottom-right";const ff=Number.POSITIVE_INFINITY;function mf(t,e){return e[1]!==ff?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}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,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Math.SQRT2;switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function _f(t,e,i){var r;const n=t.layout,s=null===(r=n.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(e,{},i);if(s){const t=s.values,e=[];for(let i=0;i<t.length;i+=2){const r=e[i]=t[i],n=t[i+1].map(t=>t*fh);r.startsWith("top")?n[1]-=7:r.startsWith("bottom")&&(n[1]+=7),e[i+1]=n}return new Be(e)}const o=n.get("text-variable-anchor");if(o){let r;r=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[n.get("text-radial-offset").evaluate(e,{},i)*fh,ff]:n.get("text-offset").evaluate(e,{},i).map(t=>t*fh);const s=[];for(const t of o)s.push(t,mf(t,r));return new Be(s)}return null}function gf(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 yf(e,i,r,n,s,o,a,l,c,h,u,p){let d=o.textMaxSize.evaluate(i,{});void 0===d&&(d=a);const f=e.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},u),_=xf(r.horizontal),g=a/24,y=e.tilePixelRatio*g,v=e.tilePixelRatio*d/24,x=e.tilePixelRatio*l,b=e.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*e.tilePixelRatio,S=function(t,e,i,r=1){const n=t.get("icon-padding").evaluate(e,{},i),s=n&&n.values;return[s[0]*r,s[1]*r,s[2]*r,s[3]*r]}(f,i,u,e.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,C="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),M="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),E=f.get("symbol-placement"),A=b/2,P=f.get("icon-text-fit");let D;n&&"none"!==P&&(e.allowVerticalPlacement&&r.vertical&&(D=iu(n,r.vertical,P,f.get("icon-text-fit-padding"),m,g)),_&&(n=iu(n,_,P,f.get("icon-text-fit-padding"),m,g)));const k=u?p.line.getGranularityForZoomLevel(u.z):1,z=(l,p)=>{p.x<0||p.x>=I||p.y<0||p.y>=I||function(e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x,b,w,S,T,C){const M=e.addToLineVertexArray(i,r);let E,A,I,P,D=0,k=0,z=0,R=0,L=-1,F=-1;const B={};let O=_a("");if(e.allowVerticalPlacement&&n.vertical){const t=l.layout.get("text-rotate").evaluate(b,{},T)+90;I=new lf(c,i,h,u,p,n.vertical,d,f,m,t),a&&(P=new lf(c,i,h,u,p,a,g,y,m,t))}if(s){const r=l.layout.get("icon-rotate").evaluate(b,{}),n="none"!==l.layout.get("icon-text-fit"),o=rf(s,r,S,n),d=a?rf(a,r,S,n):void 0;A=new lf(c,i,h,u,p,s,g,y,!1,r),D=4*o.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[ru*l.layout.get("icon-size").evaluate(b,{})],m[0]>nu&&U(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[ru*w.compositeIconSizes[0].evaluate(b,{},T),ru*w.compositeIconSizes[1].evaluate(b,{},T)],(m[0]>nu||m[1]>nu)&&U(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,o,m,x,v,b,t.az.none,i,M.lineStartIndex,M.lineLength,-1,T),L=e.icon.placedSymbolArray.length-1,d&&(k=4*d.length,e.addSymbols(e.icon,d,m,x,v,b,t.az.vertical,i,M.lineStartIndex,M.lineLength,-1,T),F=e.icon.placedSymbolArray.length-1)}const N=Object.keys(n.horizontal);for(const r of N){const s=n.horizontal[r];if(!E){O=_a(s.text);const t=l.layout.get("text-rotate").evaluate(b,{},T);E=new lf(c,i,h,u,p,s,d,f,m,t)}const a=1===s.positionedLines.length;if(z+=vf(e,i,s,o,l,m,b,_,M,n.vertical?t.az.horizontal:t.az.horizontalOnly,a?N:[r],B,L,w,T),a)break}n.vertical&&(R+=vf(e,i,n.vertical,o,l,m,b,_,M,t.az.vertical,["vertical"],B,F,w,T));const V=E?E.boxStartIndex:e.collisionBoxArray.length,j=E?E.boxEndIndex:e.collisionBoxArray.length,q=I?I.boxStartIndex:e.collisionBoxArray.length,G=I?I.boxEndIndex:e.collisionBoxArray.length,$=A?A.boxStartIndex:e.collisionBoxArray.length,Z=A?A.boxEndIndex:e.collisionBoxArray.length,W=P?P.boxStartIndex:e.collisionBoxArray.length,H=P?P.boxEndIndex:e.collisionBoxArray.length;let X=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=Y(E,X),X=Y(I,X),X=Y(A,X),X=Y(P,X);const K=X>-1?1:0;K&&(X*=C/fh),e.glyphOffsetArray.length>=du.MAX_GLYPHS&&U("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const J=_f(l,b,T),[Q,tt]=function(e,i){const r=e.length,n=null==i?void 0:i.values;if((null==n?void 0:n.length)>0)for(let i=0;i<n.length;i+=2){const r=n[i+1];e.emplaceBack(t.aP[n[i]],r[0],r[1])}return[r,e.length]}(e.textAnchorOffsets,J);e.symbolInstances.emplaceBack(i.x,i.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,L,F,O,V,j,q,G,$,Z,W,H,h,z,R,D,k,K,0,d,X,Q,tt)}(e,p,l,r,n,s,D,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,y,[w,w,w,w],C,c,x,S,M,m,i,o,h,u,a)};if("line"===E)for(const t of qd(i.geometry,0,0,I,I)){const i=gc(t,k),s=tf(i,b,T,r.vertical||_,n,24,v,e.overscaling,I);for(const t of s)_&&bf(e,_.text,A,t)||z(i,t)}else if("line-center"===E){for(const t of i.geometry)if(t.length>1){const e=gc(t,k),i=Qd(e,T,r.vertical||_,n,24,v);i&&z(e,i)}}else if("Polygon"===i.type)for(const t of tr(i.geometry,0)){const e=hf(t,16);z(gc(t[0],k,!0),new Hd(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry){const e=gc(t,k);z(e,new Hd(e[0].x,e[0].y,0))}else if("Point"===i.type)for(const t of i.geometry)for(const e of t)z([e],new Hd(e.x,e.y,0))}function vf(t,e,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=function(t,e,r,n,s,o,a,l){const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const o=n.rect||{};let u=4,p=!0,d=1,f=0;const m=(s||l)&&n.vertical,_=n.metrics.advance*n.scale/2;if(l&&e.verticalizable&&(f=t.lineOffset/2-(n.imageName?-(fh-n.metrics.width*n.scale)/2:(n.scale-1)*fh)),n.imageName){const t=a[n.imageName];p=t.sdf,d=t.pixelRatio,u=1/d}const g=s?[n.x+_,n.y]:[0,0];let y=s?[0,0]:[n.x+_+r[0],n.y+r[1]-f],v=[0,0];m&&(v=y,y=[0,0]);const x=n.metrics.isDoubleResolution?2:1,b=(n.metrics.left-u)*n.scale-_+y[0],w=(-n.metrics.top-u)*n.scale+y[1],S=b+o.w/x*n.scale/d,T=w+o.h/x*n.scale/d,C=new i(b,w),M=new i(S,w),E=new i(b,T),A=new i(S,T);if(m){const t=new i(-_,_- -17),e=-Math.PI/2,r=12-_,s=new i(22-r,-(n.imageName?r:0)),o=new i(...v);C._rotateAround(e,t)._add(s)._add(o),M._rotateAround(e,t)._add(s)._add(o),E._rotateAround(e,t)._add(s)._add(o),A._rotateAround(e,t)._add(s)._add(o)}if(c){const t=Math.sin(c),e=Math.cos(c),i=[e,-t,t,e];C._matMult(i),M._matMult(i),E._matMult(i),A._matMult(i)}const I=new i(0,0),P=new i(0,0);h.push({tl:C,tr:M,bl:E,br:A,tex:o,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:I,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0})}return h}(0,r,l,s,o,a,n,t.allowVerticalPlacement),g=t.textSizeData;let y=null;"source"===g.kind?(y=[ru*s.layout.get("text-size").evaluate(a,{})],y[0]>nu&&U(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===g.kind&&(y=[ru*f.compositeTextSizes[0].evaluate(a,{},m),ru*f.compositeTextSizes[1].evaluate(a,{},m)],(y[0]>nu||y[1]>nu)&&U(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,_,y,l,o,a,h,e,c.lineStartIndex,c.lineLength,d,m);for(const e of u)p[e]=t.text.placedSymbolArray.length-1;return 4*_.length}function xf(t){for(const e in t)return t[e];return null}function bf(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}const wf=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Sf{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=wf[15&i];if(!n)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new Sf(o,s,n,t)}constructor(t,e=64,i=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const n=wf.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Tf(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=o){for(let o=u;o<=h;o++){const a=s[2*o],c=s[2*o+1];a>=t&&a<=i&&c>=e&&c<=r&&l.push(n[o])}continue}const p=u+h>>1,d=s[2*p],f=s[2*p+1];d>=t&&d<=i&&f>=e&&f<=r&&l.push(n[p]),(0===c?t<=d:e<=f)&&(a.push(u),a.push(p-1),a.push(1-c)),(0===c?i>=d:r>=f)&&(a.push(p+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:s}=this,o=[0,r.length-1,0],a=[],l=i*i;for(;o.length;){const c=o.pop()||0,h=o.pop()||0,u=o.pop()||0;if(h-u<=s){for(let i=u;i<=h;i++)Af(n[2*i],n[2*i+1],t,e)<=l&&a.push(r[i]);continue}const p=u+h>>1,d=n[2*p],f=n[2*p+1];Af(d,f,t,e)<=l&&a.push(r[p]),(0===c?t-i<=d:e-i<=f)&&(o.push(u),o.push(p-1),o.push(1-c)),(0===c?t+i>=d:e+i>=f)&&(o.push(p+1),o.push(h),o.push(1-c))}return a}}function Tf(t,e,i,r,n,s){if(n-r<=i)return;const o=r+n>>1;Cf(t,e,o,r,n,s),Tf(t,e,i,r,o-1,1-s),Tf(t,e,i,o+1,n,1-s)}function Cf(t,e,i,r,n,s){for(;n>r;){if(n-r>600){const o=n-r+1,a=i-r+1,l=Math.log(o),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(o-c)/o)*(a-o/2<0?-1:1);Cf(t,e,i,Math.max(r,Math.floor(i-a*c/o+h)),Math.min(n,Math.floor(i+(o-a)*c/o+h)),s)}const o=e[2*i+s];let a=r,l=n;for(Mf(t,e,r,i),e[2*n+s]>o&&Mf(t,e,r,n);a<l;){for(Mf(t,e,a,l),a++,l--;e[2*a+s]<o;)a++;for(;e[2*l+s]>o;)l--}e[2*r+s]===o?Mf(t,e,r,l):(l++,Mf(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Mf(t,e,i,r){Ef(t,i,r),Ef(e,2*i,2*r),Ef(e,2*i+1,2*r+1)}function Ef(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function Af(t,e,i,r){const n=t-i,s=e-r;return n*n+s*s}var If;t.cI=void 0,(If=t.cI||(t.cI={})).create="create",If.load="load",If.fullLoad="fullLoad";let Pf=null,Df=[];const kf=1e3/60,zf="loadTime",Rf="fullLoadTime",Lf={mark(t){performance.mark(t)},frame(t){const e=t;null!=Pf&&Df.push(e-Pf),Pf=e},clearMetrics(){Pf=null,Df=[],performance.clearMeasures(zf),performance.clearMeasures(Rf);for(const e in t.cI)performance.clearMarks(t.cI[e])},getPerformanceMetrics(){performance.measure(zf,t.cI.create,t.cI.load),performance.measure(Rf,t.cI.create,t.cI.fullLoad);const e=performance.getEntriesByName(zf)[0].duration,i=performance.getEntriesByName(Rf)[0].duration,r=Df.length,n=1/(Df.reduce((t,e)=>t+e,0)/r/1e3),s=Df.filter(t=>t>kf).reduce((t,e)=>t+(e-kf)/kf,0);return{loadTime:e,fullLoadTime:i,fps:n,percentDroppedFrames:s/(r+s)*100,totalFrames:r}}};t.$=h,t.A=d,t.B=cs,t.C=ns,t.D=Us,t.E=yt,t.F=function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}},t.G=mi,t.H=zs,t.I=Gh,t.J=os,t.K=function(t){if(null==W){const e=t.navigator?t.navigator.userAgent:null;W=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return W},t.L=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Su(()=>this.process()),this.subscription=Q(this.target,"message",t=>this.receive(t),!1),this.globalScope=Z(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}unregisterMessageHandler(t){delete this.messageHandlers[t]}sendAsync(t,e){return new Promise((i,r)=>{const n=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?Q(e.signal,"abort",()=>{null==s||s.unsubscribe(),delete this.resolveRejects[n];const e={id:n,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e)},Tu):null;this.resolveRejects[n]={resolve:t=>{null==s||s.unsubscribe(),i(t)},reject:t=>{null==s||s.unsubscribe(),r(t)}};const o=[],a=Object.assign(Object.assign({},t),{id:n,sourceMapId:this.mapId,origin:location.origin,data:_s(t.data,o)});this.target.postMessage(a,{transfer:o})})}receive(t){const e=t.data,i=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[i];const t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(Z(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,i){return e(this,void 0,void 0,function*(){if("<response>"===i.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(i.error?e.reject(gs(i.error)):e.resolve(gs(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=gs(i.data),r=new AbortController;this.abortControllers[t]=r;try{const n=yield this.messageHandlers[i.type](i.sourceMapId,e,r);this.completeTask(t,null,n)}catch(e){this.completeTask(t,e)}})}completeTask(t,e,i){const r=[];delete this.abortControllers[t];const n={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?_s(e):null,data:_s(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},t.M=ct,t.N=function(){var t=new d(16);return d!=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.O=function(t,e,i){var r,n,s,o,a,l,c,h,u,p,d,f,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],f=e[11],t[0]=r=e[0],t[1]=n,t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=r*m+a*_+u*g+e[12],t[13]=n*m+l*_+p*g+e[13],t[14]=s*m+c*_+d*g+e[14],t[15]=o*m+h*_+f*g+e[15]),t},t.P=i,t.Q=function(t,e,i){var r=i[0],n=i[1],s=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.R=Sl,t.S=function(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=i[0],x=i[1],b=i[2],w=i[3];return t[0]=v*r+x*a+b*u+w*m,t[1]=v*n+x*l+b*p+w*_,t[2]=v*s+x*c+b*d+w*g,t[3]=v*o+x*h+b*f+w*y,t[4]=(v=i[4])*r+(x=i[5])*a+(b=i[6])*u+(w=i[7])*m,t[5]=v*n+x*l+b*p+w*_,t[6]=v*s+x*c+b*d+w*g,t[7]=v*o+x*h+b*f+w*y,t[8]=(v=i[8])*r+(x=i[9])*a+(b=i[10])*u+(w=i[11])*m,t[9]=v*n+x*l+b*p+w*_,t[10]=v*s+x*c+b*d+w*g,t[11]=v*o+x*h+b*f+w*y,t[12]=(v=i[12])*r+(x=i[13])*a+(b=i[14])*u+(w=i[15])*m,t[13]=v*n+x*l+b*p+w*_,t[14]=v*s+x*c+b*d+w*g,t[15]=v*o+x*h+b*f+w*y,t},t.T=kl,t.U=function(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i},t.V=Mu,t.W=B,t.X=Pu,t.Y=Iu,t.Z=ot,t._=e,t.a=st,t.a$=x,t.a0=u,t.a1=Y,t.a2=Nu,t.a3=ku,t.a4=zu,t.a5=I,t.a6=function(t,e,i){if(!t)return e||{};if(!e)return t||{};const r=Gu(t),n=Gu(e);!function(t,e){e.removeAll&&(t.add.clear(),t.update.clear(),t.remove.clear(),e.remove.clear());for(const i of e.remove)t.add.delete(i),t.update.delete(i);for(const[i,r]of e.update){const n=t.update.get(i);n&&(e.update.set(i,qu(n,r)),t.update.delete(i))}}(r,n);const s={};if((r.removeAll||n.removeAll)&&(s.removeAll=!0),s.remove=new Set([...r.remove,...n.remove]),s.add=new Map([...r.add,...n.add]),s.update=new Map([...r.update,...n.update]),s.remove.size&&s.add.size)for(const t of s.add.keys())s.remove.delete(t);return function(t){const e={};return t.removeAll&&(e.removeAll=t.removeAll),t.remove&&(e.remove=Array.from(t.remove)),t.add&&(e.add=Array.from(t.add.values())),t.update&&(e.update=Array.from(t.update.values())),e}(s)},t.a7=function(t,e){const i=new Map;if(null==t)return i;if(null==t.type)return i;if("Feature"===t.type){const r=ju(t,e);if(null==r)return;return i.set(r,t),i}if("FeatureCollection"===t.type){const r=new Set;for(const n of t.features){const t=ju(n,e);if(null==t)return;if(r.has(t))return;r.add(t),i.set(t,n)}return i}},t.a8=function(t,e,i){var r,n;const s=[];if(e.removeAll)t.clear();else if(e.remove)for(const i of e.remove){const e=t.get(i);e&&(s.push(e.geometry),t.delete(i))}if(e.add)for(const r of e.add){const e=ju(r,i);if(null==e)continue;const n=t.get(e);n&&s.push(n.geometry),s.push(r.geometry),t.set(e,r)}if(e.update)for(const i of e.update){const e=t.get(i.id);if(!e)continue;const o=!!i.newGeometry,a=i.removeAllProperties||(null===(r=i.removeProperties)||void 0===r?void 0:r.length)>0||(null===(n=i.addOrUpdateProperties)||void 0===n?void 0:n.length)>0;if(!o&&!a)continue;s.push(e.geometry);const l=Object.assign({},e);if(t.set(i.id,l),o&&(s.push(i.newGeometry),l.geometry=i.newGeometry),a){if(l.properties=i.removeAllProperties?{}:Object.assign({},l.properties||{}),i.removeProperties)for(const t of i.removeProperties)delete l.properties[t];if(i.addOrUpdateProperties)for(const{key:t,value:e}of i.addOrUpdateProperties)l.properties[t]=e}}return s},t.a9=Lu,t.aA=function(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/ru:"composite"===t.kind?mi.number(r/ru,n/ru,i):e},t.aB=function(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*o,v=i*l-n*o,x=i*c-s*o,b=r*l-n*a,w=r*c-s*a,S=n*c-s*l,T=h*m-u*f,C=h*_-p*f,M=h*g-d*f,E=u*_-p*m,A=u*g-d*m,I=p*g-d*_,P=y*I-v*A+x*E+b*M-w*C+S*T;return P?(t[0]=(a*I-l*A+c*E)*(P=1/P),t[1]=(n*A-r*I-s*E)*P,t[2]=(m*S-_*w+g*b)*P,t[3]=(p*w-u*S-d*b)*P,t[4]=(l*M-o*I-c*C)*P,t[5]=(i*I-n*M+s*C)*P,t[6]=(_*x-f*S-g*v)*P,t[7]=(h*S-p*x+d*v)*P,t[8]=(o*A-a*M+c*T)*P,t[9]=(r*M-i*A-s*T)*P,t[10]=(f*w-m*x+g*y)*P,t[11]=(u*x-h*w-d*y)*P,t[12]=(a*C-o*E-l*T)*P,t[13]=(i*E-r*C+n*T)*P,t[14]=(m*v-f*b-_*y)*P,t[15]=(h*b-u*v+p*y)*P,t):null},t.aC=E,t.aD=function(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)},t.aE=function(t){return t[0]=0,t[1]=0,t},t.aF=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},t.aG=cu,t.aH=T,t.aI=function(t,e,r,n){const s=e.y-t.y,o=e.x-t.x,a=n.y-r.y,l=n.x-r.x,c=a*o-l*s;if(0===c)return null;const h=(l*(t.y-r.y)-a*(t.x-r.x))/c;return new i(t.x+h*o,t.y+h*s)},t.aJ=qd,t.aK=$a,t.aL=function(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);return[e,i,r,n]},t.aM=fh,t.aN=P,t.aO=function(t,e,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];const s=n?"map"===r?-t.bearingInRadians:0:"viewport"===r?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[n?i[0]:P(e,i[0],t.zoom),n?i[1]:P(e,i[1],t.zoom)]},t.aQ=ou,t.aR=gf,t.aS=Wh,t.aT=Sf,t.aU=ro,t.aV=pc,t.aW=qo,t.aX=sa,t.aY=ea,t.aZ=et,t.a_=Ru,t.aa=Uu,t.ab=25,t.ac=Bu,t.ad=t=>{const e=window.document.createElement("video");return e.muted=!0,new Promise(i=>{e.onloadstart=()=>{i(e)};for(const i of t){const t=window.document.createElement("source");dt(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}})},t.ae=Dt,t.af=function(){return N++},t.ag=Do,t.ah=du,t.ai=Dd,t.aj=dn,t.ak=ja,t.al=Zu,t.am=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(t,i,r,n)=>{const s=r||n;return e[i]=!s||s.toLowerCase(),""}),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e},t.an=F,t.ao=85.051129,t.ap=tt,t.aq=function(t){return Math.pow(2,t)},t.ar=m,t.as=Du,t.at=function(t){return Math.log(t)/Math.LN2},t.au=function(t){var e=t[0],i=t[1];return e*e+i*i},t.av=function(t){if(!t.length)return new Set;const e=Math.max(...t.map(t=>t.canonical.z));let i=1/0,r=-1/0,n=1/0,s=-1/0;const o=[];for(const a of t){const{x:t,y:l,z:c}=a.canonical,h=Math.pow(2,e-c),u=t*h,p=l*h;o.push({id:a,x:u,y:p}),u<i&&(i=u),u>r&&(r=u),p<n&&(n=p),p>s&&(s=p)}const a=new Set;for(const t of o)t.x!==i&&t.x!==r&&t.y!==n&&t.y!==s||a.add(t.id);return a},t.aw=function(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x},t.ax=class{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout(()=>{this.remove(t,n)},i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const 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}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}},t.ay=function(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:s,maxZoom:o}=t,a=n?F(di.interpolationFactor(n,e,s,o),0,1):0;"camera"===t.kind?r=mi.number(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}},t.b=H,t.b$=Ta,t.b0=v,t.b1=function(t){var e=new d(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.b2=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t},t.b3=function(t,e){var i=e[0],r=e[1],n=e[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.b4=b,t.b5=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.b6=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t},t.b7=g,t.b8=function(t,e,i){const r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2];return 0===r?null:(-(t[0]*i[0]+t[1]*i[1]+t[2]*i[2])-i[3])/r},t.b9=S,t.bA=function(){return new Float64Array(3)},t.bB=M,t.bC=function(t,e,i){var r=i[0],n=i[1],s=i[2],o=i[3],a=e[0],l=e[1],c=e[2],h=n*c-s*l,u=s*a-r*c,p=r*l-n*a;return t[0]=a+o*(h+=h)+n*(p+=p)-s*(u+=u),t[1]=l+o*u+s*h-r*p,t[2]=c+o*p+r*u-n*h,t},t.bD=function(t,e,i){const r=(n=[t[0],t[1],t[2],e[0],e[1],e[2],i[0],i[1],i[2]])[0]*((h=n[8])*(o=n[4])-(a=n[5])*(c=n[7]))+n[1]*(-h*(s=n[3])+a*(l=n[6]))+n[2]*(c*s-o*l);var n,s,o,a,l,c,h;if(0===r)return null;const u=b([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),p=b([],[i[0],i[1],i[2]],[t[0],t[1],t[2]]),d=b([],[t[0],t[1],t[2]],[e[0],e[1],e[2]]),f=x([],u,-t[3]);return v(f,f,x([],p,-e[3])),v(f,f,x([],d,-i[3])),x(f,f,1/r),f},t.bE=Cu,t.bF=function(){return new Float64Array(4)},t.bG=function(t,e,i,r){var n=[],s=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],s[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),s[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),s[2]=n[2],t[0]=s[0]+i[0],t[1]=s[1]+i[1],t[2]=s[2]+i[2],t},t.bH=function(t,e,i,r){var n=[],s=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],s[0]=n[0],s[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),s[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),t[0]=s[0]+i[0],t[1]=s[1]+i[1],t[2]=s[2]+i[2],t},t.bI=function(t,e,i,r){var n=[],s=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],s[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),s[1]=n[1],s[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),t[0]=s[0]+i[0],t[1]=s[1]+i[1],t[2]=s[2]+i[2],t},t.bJ=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n-c*r,t[1]=o*n-h*r,t[2]=a*n-u*r,t[3]=l*n-p*r,t[8]=s*r+c*n,t[9]=o*r+h*n,t[10]=a*r+u*n,t[11]=l*r+p*n,t},t.bK=function(t,e){const i=D(t,360),r=D(e,360),n=r-i,s=r>i?n-360:n+360;return Math.abs(n)<Math.abs(s)?n:s},t.bL=function(t){return t[0]=0,t[1]=0,t[2]=0,t},t.bM=function(t,e,i,r){const n=Math.sqrt(t*t+e*e),s=Math.sqrt(i*i+r*r);t/=n,e/=n,i/=s,r/=s;const o=Math.acos(t*i+e*r);return-e*i+t*r>0?o:-o},t.bN=function(t,e){const i=D(t,2*Math.PI),r=D(e,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))},t.bO=function(){const t={},e=vt.$version;for(const i in vt.$root){const r=vt.$root[i];if(r.required){let n=null;n="version"===i?e:"array"===r.type?[]:{},null!=n&&(t[i]=n)}}return t},t.bP=ut,t.bQ=ys,t.bR=function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],i[r]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(e).length!==Object.keys(i).length)return!1;for(const r in e)if(!t(e[r],i[r]))return!1;return!0}return e===i},t.bS=function(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=bt(t[i],e[t[i].ref]));return t},t.bT=function(t,e){if("custom"===t.type)return new wu(t,e);switch(t.type){case"background":return new bu(t,e);case"circle":return new ml(t,e);case"color-relief":return new Ll(t,e);case"fill":return new Cc(t,e);case"fill-extrusion":return new $c(t,e);case"heatmap":return new Ml(t,e);case"hillshade":return new Il(t,e);case"line":return new oh(t,e);case"raster":return new Qs(t,e);case"symbol":return new yu(t,e)}},t.bU=t=>"raster"===t.type,t.bV=q,t.bW=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!wt(t.version,e.version))return[{command:"setStyle",args:[e]}];wt(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),wt(t.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),wt(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),wt(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),wt(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),wt(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),wt(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),wt(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),wt(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),wt(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),wt(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),wt(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),wt(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),wt(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const r={},n=[];!function(t,e,i,r){let n;for(n in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)||Ct(n,i,r));for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)?wt(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&Et(t,e,n)?St(i,{command:"setGeoJSONSourceData",args:[n,e[n].data]}):Mt(n,e,i,r)):Tt(n,e,i))}(t.sources,e.sources,n,r);const s=[];t.layers&&t.layers.forEach(t=>{"source"in t&&r[t.source]?i.push({command:"removeLayer",args:[t.id]}):s.push(t)}),i=i.concat(n),function(t,e,i){e=e||[];const r=(t=t||[]).map(It),n=e.map(It),s=t.reduce(Pt,{}),o=e.reduce(Pt,{}),a=r.slice(),l=Object.create(null);let c,h,u,p,d;for(let t=0,e=0;t<r.length;t++)c=r[t],Object.prototype.hasOwnProperty.call(o,c)?e++:(St(i,{command:"removeLayer",args:[c]}),a.splice(a.indexOf(c,e),1));for(let t=0,e=0;t<n.length;t++)c=n[n.length-1-t],a[a.length-1-t]!==c&&(Object.prototype.hasOwnProperty.call(s,c)?(St(i,{command:"removeLayer",args:[c]}),a.splice(a.lastIndexOf(c,a.length-e),1)):e++,p=a[a.length-t],St(i,{command:"addLayer",args:[o[c],p]}),a.splice(a.length-t,0,c),l[c]=!0);for(let t=0;t<n.length;t++)if(c=n[t],h=s[c],u=o[c],!l[c]&&!wt(h,u))if(wt(h.source,u.source)&&wt(h["source-layer"],u["source-layer"])&&wt(h.type,u.type)){for(d in At(h.layout,u.layout,i,c,null,"setLayoutProperty"),At(h.paint,u.paint,i,c,null,"setPaintProperty"),wt(h.filter,u.filter)||St(i,{command:"setFilter",args:[c,u.filter]}),wt(h.minzoom,u.minzoom)&&wt(h.maxzoom,u.maxzoom)||St(i,{command:"setLayerZoomRange",args:[c,u.minzoom,u.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,d)&&"layout"!==d&&"paint"!==d&&"filter"!==d&&"metadata"!==d&&"minzoom"!==d&&"maxzoom"!==d&&(0===d.indexOf("paint.")?At(h[d],u[d],i,c,d.slice(6),"setPaintProperty"):wt(h[d],u[d])||St(i,{command:"setLayerProperty",args:[c,d,u[d]]}));for(d in u)Object.prototype.hasOwnProperty.call(u,d)&&!Object.prototype.hasOwnProperty.call(h,d)&&"layout"!==d&&"paint"!==d&&"filter"!==d&&"metadata"!==d&&"minzoom"!==d&&"maxzoom"!==d&&(0===d.indexOf("paint.")?At(h[d],u[d],i,c,d.slice(6),"setPaintProperty"):wt(h[d],u[d])||St(i,{command:"setLayerProperty",args:[c,d,u[d]]}))}else St(i,{command:"removeLayer",args:[c]}),p=a[a.lastIndexOf(c)+1],St(i,{command:"addLayer",args:[u,p]})}(s,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:"setStyle",args:[e]}]}return i},t.bX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.bY=V,t.bZ=j,t.b_=class extends ba{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.ba=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t},t.bb=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bc=Ou,t.bd=Vu,t.be=function(t,e,i,r,n){var s=1/Math.tan(e/2);if(t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0){var o=1/(r-n);t[10]=(n+r)*o,t[14]=2*n*r*o}else t[10]=-1,t[14]=-2*r;return t},t.bf=function(t){var e=new d(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.bg=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],c=e[4],h=e[5],u=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n+c*r,t[1]=o*n+h*r,t[2]=a*n+u*r,t[3]=l*n+p*r,t[4]=c*n-s*r,t[5]=h*n-o*r,t[6]=u*n-a*r,t[7]=p*n-l*r,t},t.bh=function(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[4],o=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*n+c*r,t[5]=o*n+h*r,t[6]=a*n+u*r,t[7]=l*n+p*r,t[8]=c*n-s*r,t[9]=h*n-o*r,t[10]=u*n-a*r,t[11]=p*n-l*r,t},t.bi=function(){const t=new Float32Array(16);return m(t),t},t.bj=function(){const t=new Float64Array(16);return m(t),t},t.bk=function(){return new Float64Array(16)},t.bl=function(t,e,i){const r=new Float64Array(4);return M(r,t,e-90,i),r},t.bm=function(t,e,i,r){var n,s,o,a,l,c=e[0],h=e[1],u=e[2],d=e[3],f=i[0],m=i[1],_=i[2],g=i[3];return(s=c*f+h*m+u*_+d*g)<0&&(s=-s,f=-f,m=-m,_=-_,g=-g),1-s>p?(n=Math.acos(s),o=Math.sin(n),a=Math.sin((1-r)*n)/o,l=Math.sin(r*n)/o):(a=1-r,l=r),t[0]=a*c+l*f,t[1]=a*h+l*m,t[2]=a*u+l*_,t[3]=a*d+l*g,t},t.bn=function(t){const e=new Float64Array(9);var i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,v;u=(n=(r=t)[0])*(l=n+n),p=(s=r[1])*l,f=(o=r[2])*l,m=o*(c=s+s),g=(a=r[3])*l,y=a*c,v=a*(h=o+o),(i=e)[0]=1-(d=s*c)-(_=o*h),i[3]=p-v,i[6]=f+y,i[1]=p+v,i[4]=1-u-_,i[7]=m-g,i[2]=f-y,i[5]=m+g,i[8]=1-u-d;const x=et(-Math.asin(F(e[2],-1,1)));let b,w;return Math.hypot(e[5],e[8])<.001?(b=0,w=-et(Math.atan2(e[3],e[4]))):(b=et(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),w=et(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:b,pitch:x+90,bearing:w}},t.bo=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.bp=Ee,t.bq=wa,t.br=dc,t.bs=fc,t.bt=uc,t.bu=k,t.bv=z,t.bw=Ne,t.bx=function(t,e,i,r,n){return k(r,n,F((t-e)/(i-e),0,1))},t.by=function(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t},t.bz=D,t.c=at,t.c$=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.c0=class extends ba{constructor(t,e){super(t,e),this.current=Ca}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.c1=Sa,t.c2=class extends ba{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.c3=class extends ba{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.c4=f,t.c5=function(t,e){var i=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.c6=function(t,e,i){var r=e[0],n=e[1],s=e[2];return t[0]=r*i[0]+n*i[3]+s*i[6],t[1]=r*i[1]+n*i[4]+s*i[7],t[2]=r*i[2]+n*i[5]+s*i[8],t},t.c7=function(t,e,i,r,n,s,o){var a=1/(e-i),l=1/(r-n),c=1/(s-o);return t[0]=-2*a,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*c,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(o+s)*c,t[15]=1,t},t.c8=class extends ba{constructor(t,e){super(t,e),this.current=new Array}set(t){if(t!=this.current){this.current=t;const e=new Float32Array(4*t.length);for(let i=0;i<t.length;i++)e[4*i]=t[i].r,e[4*i+1]=t[i].g,e[4*i+2]=t[i].b,e[4*i+3]=t[i].a;this.gl.uniform4fv(this.location,e)}}},t.c9=class extends ba{constructor(t,e){super(t,e),this.current=new Array}set(t){if(t!=this.current){this.current=t;const e=new Float32Array(t);this.gl.uniform1fv(this.location,e)}}},t.cA=function(t,e){var i;if(!rt[e])return!1;const r=null==t?void 0:t.target,n=(null===(i=null==r?void 0:r.ownerDocument)||void 0===i?void 0:i.defaultView)||window;return t instanceof n.MouseEvent||t instanceof n.WheelEvent},t.cB=function(t,e){return it[e]&&"touches"in t},t.cC=function(t){return it[t]||rt[t]},t.cD=function(t,e,i){var r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t},t.cE=function(t,e){const{x:i,y:r}=Lu.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)},t.cF=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cG=class extends oo{},t.cH=Lf,t.cJ=ht,t.cK=function(t,e){at.REGISTERED_PROTOCOLS[t]=e},t.cL=function(t){delete at.REGISTERED_PROTOCOLS[t]},t.cM=function(t,e){const i={};for(let r=0;r<t.length;r++){const n=e&&e[t[r].id]||wn(t[r]);e&&(e[t[r].id]=n);let s=i[n];s||(s=i[n]=[]),s.push(t[r])}const r=[];for(const t in i)r.push(i[t]);return r},t.cN=ps,t.cO=$u,t.cP=Nd,t.cQ=Uh,t.cR=function(e){var i;e.bucket.createArrays(),e.bucket.tilePixelRatio=I/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const r=e.bucket.layers[0],n=r.layout,s=r._unevaluatedLayout._values,o={layoutIconSize:s["icon-size"].possiblyEvaluate(new zs(e.bucket.zoom+1),e.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new zs(e.bucket.zoom+1),e.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new zs(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.textSizeData;o.compositeTextSizes=[s["text-size"].possiblyEvaluate(new zs(t),e.canonical),s["text-size"].possiblyEvaluate(new zs(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;o.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new zs(t),e.canonical),s["icon-size"].possiblyEvaluate(new zs(i),e.canonical)]}const a=n.get("text-line-height")*fh,l="viewport"!==n.get("text-rotation-alignment")&&"point"!==n.get("symbol-placement"),c=n.get("text-keep-upright"),h=n.get("text-size");for(const s of e.bucket.features){const u=n.get("text-font").evaluate(s,{},e.canonical).join(","),p=h.evaluate(s,{},e.canonical),d=o.layoutTextSize.evaluate(s,{},e.canonical),f=o.layoutIconSize.evaluate(s,{},e.canonical),m={horizontal:{},vertical:void 0},_=s.text;let g,y=[0,0];if(_){const i=_.toString(),o=n.get("text-letter-spacing").evaluate(s,{},e.canonical)*fh,h=Ss(i)?o:0,f=n.get("text-anchor").evaluate(s,{},e.canonical),g=_f(r,s,e.canonical);if(!g){const t=n.get("text-radial-offset").evaluate(s,{},e.canonical);y=t?mf(f,[t*fh,ff]):n.get("text-offset").evaluate(s,{},e.canonical).map(t=>t*fh)}let v=l?"center":n.get("text-justify").evaluate(s,{},e.canonical);const x="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(s,{},e.canonical)*fh:1/0,b=()=>{e.bucket.allowVerticalPlacement&&ws(i)&&(m.vertical=Zh(_,e.glyphMap,e.glyphPositions,e.imagePositions,u,x,a,f,"left",h,y,t.az.vertical,!0,d,p))};if(!l&&g){const i=new Set;if("auto"===v)for(let t=0;t<g.values.length;t+=2)i.add(gf(g.values[t]));else i.add(v);let r=!1;for(const n of i)if(!m.horizontal[n])if(r)m.horizontal[n]=m.horizontal[0];else{const i=Zh(_,e.glyphMap,e.glyphPositions,e.imagePositions,u,x,a,"center",n,h,y,t.az.horizontal,!1,d,p);i&&(m.horizontal[n]=i,r=1===i.positionedLines.length)}b()}else{"auto"===v&&(v=gf(f));const r=Zh(_,e.glyphMap,e.glyphPositions,e.imagePositions,u,x,a,f,v,h,y,t.az.horizontal,!1,d,p);r&&(m.horizontal[v]=r),b(),ws(i)&&l&&c&&(m.vertical=Zh(_,e.glyphMap,e.glyphPositions,e.imagePositions,u,x,a,f,v,h,y,t.az.vertical,!1,d,p))}}let v=!1;if(s.icon&&s.icon.name){const t=e.imageMap[s.icon.name];t&&(g=tu(e.imagePositions[s.icon.name],n.get("icon-offset").evaluate(s,{},e.canonical),n.get("icon-anchor").evaluate(s,{},e.canonical)),v=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=v:e.bucket.sdfIcons!==v&&U("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.bucket.pixelRatio||0!==n.get("icon-rotate").constantOr(1))&&(e.bucket.iconsNeedLinear=!0))}const x=xf(m.horizontal)||m.vertical;(i=e.bucket).iconsInText||(i.iconsInText=!!x&&x.iconsInText),(x||g)&&yf(e.bucket,s,m,g,e.imageMap,o,d,f,y,v,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()},t.cS=bc,t.cT=Nc,t.cU=th,t.cV=function(t){const e=new Eh;return function(t,e){for(const i in t.layers)e.writeMessage(3,kd,t.layers[i])}(t,e),e.finish()},t.cW=function(t,e,i,r,n,s){let o=Gd(t,e,i,n,0);return o=Gd(o,e,r,s,1),o},t.cX=class{constructor(t){this.maxEntries=t,this.map=new Map}get(t){const e=this.map.get(t);return void 0!==e&&(this.map.delete(t),this.map.set(t,e)),e}set(t,e){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxEntries){const t=this.map.keys().next().value;this.map.delete(t)}this.map.set(t,e)}clear(){this.map.clear()}},t.cY=Lc,t.cZ=Eh,t.c_=Id,t.ca=class extends vo{},t.cb=ph,t.cc=class extends bo{},t.cd=Cl,t.ce=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.cf=Tl,t.cg=function(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[3]*r+i[7]*n+i[11]*s+i[15];return t[0]=(i[0]*r+i[4]*n+i[8]*s+i[12])/(o=o||1),t[1]=(i[1]*r+i[5]*n+i[9]*s+i[13])/o,t[2]=(i[2]*r+i[6]*n+i[10]*s+i[14])/o,t},t.ch=class extends ao{},t.ci=class extends Ao{},t.cj=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.ck=function(t,e){var i=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],v=e[0],x=e[1],b=e[2],w=e[3],S=e[4],T=e[5],C=e[6],M=e[7],E=e[8],A=e[9],I=e[10],P=e[11],D=e[12],k=e[13],z=e[14],R=e[15];return Math.abs(i-v)<=p*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(r-x)<=p*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-b)<=p*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(s-w)<=p*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(o-S)<=p*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(a-T)<=p*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-C)<=p*Math.max(1,Math.abs(l),Math.abs(C))&&Math.abs(c-M)<=p*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(h-E)<=p*Math.max(1,Math.abs(h),Math.abs(E))&&Math.abs(u-A)<=p*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-I)<=p*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(f-P)<=p*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(m-D)<=p*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(_-k)<=p*Math.max(1,Math.abs(_),Math.abs(k))&&Math.abs(g-z)<=p*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(y-R)<=p*Math.max(1,Math.abs(y),Math.abs(R))},t.cl=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.cm=t=>"symbol"===t.type,t.cn=t=>"circle"===t.type,t.co=t=>"heatmap"===t.type,t.cp=t=>"line"===t.type,t.cq=t=>"fill"===t.type,t.cr=t=>"fill-extrusion"===t.type,t.cs=t=>"hillshade"===t.type,t.ct=t=>"color-relief"===t.type,t.cu=t=>"background"===t.type,t.cv=t=>"custom"===t.type,t.cw=R,t.cx=function(t,e,i){if(e<=0)return t;const r=1/e;return void 0===i||Math.abs(i)<1e-10?Math.round(t*r)/r:(i>0?Math.ceil(t*r-1e-9):Math.floor(t*r+1e-10))/r},t.cy=function(t,e,i){const r=A(e.x-i.x,e.y-i.y),n=A(t.x-i.x,t.y-i.y);var s,o;return et(Math.atan2(r[0]*n[1]-r[1]*n[0],(s=r)[0]*(o=n)[0]+s[1]*o[1]))},t.cz=L,t.d=dt,t.d0=function(t,i,r,n,s){return e(this,void 0,void 0,function*(){if(u())try{return yield Y(t,i,r,n,s)}catch(t){}return function(t,e,i,r,n){const s=t.width,o=t.height;K&&J||(K=new OffscreenCanvas(s,o),J=K.getContext("2d",{willReadFrequently:!0})),K.width=s,K.height=o,J.drawImage(t,0,0,s,o);const a=J.getImageData(e,i,r,n);return J.clearRect(0,0,s,o),a.data}(t,i,r,n,s)})},t.d1=zl,t.d2=r,t.d3=class{constructor(t,e){this.layers={[Dd]:this},this.name=Dd,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=t.length,this.features=t}feature(t){return new Pd(this.features[t],this.extent)}},t.d4=rn,t.d5=ks,t.e=O,t.f=t=>e(void 0,void 0,void 0,function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),t.g=lt,t.h=t=>new Promise((e,i)=>{const r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=X})},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):X}),t.i=Z,t.j=(t,e)=>pt(O(t,{type:"json"}),e),t.k=gt,t.l=_t,t.m=pt,t.n=(t,e)=>pt(O(t,{type:"arrayBuffer"}),e),t.o=function(t){return new Eh(t).readFields(Nh,[])},t.p=qh,t.q=function(t){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))},t.r=wl,t.s=Q,t.t=Xs,t.u=vt,t.v=rs,t.w=U,t.x=Os,t.y=ss,t.z=Ls}),i("worker",["./shared"],function(t){class e{constructor(t,e){this.keyCache={},t&&this.replace(t,e)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.bT(i,r);e._featureFilter=t.aj(e.filter,r),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=t.cM(Object.values(this._layerConfigs),this.keyCache);for(const e of n){const i=e.map(t=>this._layers[t.id]),r=i[0];if(r.isHidden())continue;const n=r.source||"";let s=this.familiesBySource[n];s||(s=this.familiesBySource[n]={});const o=r.sourceLayer||t.ai;let a=s[o];a||(a=s[o]=[]),a.push(i)}}}class i{constructor(e){const i={},r=[];for(const t in e){const n=e[t],s=i[t]={};for(const t in n){const e=n[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};r.push(i),s[t]={rect:i,metrics:e.metrics}}}const{w:n,h:s}=t.p(r),o=new t.r({width:n||1,height:s||1});for(const r in e){const n=e[r];for(const e in n){const s=n[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=i[r][e].rect;t.r.copy(s.bitmap,o,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap)}}this.image=o,this.positions=i}}t.cN("GlyphAtlas",i);class r{constructor(e){this.tileID=new t.a2(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}parse(e,r,s,o,a){return t._(this,void 0,void 0,function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.ag;const l=new t.cO(Object.keys(e.layers).sort()),c=new t.cP(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:s,subdivisionGranularity:a},p=r.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const o=l.encode(i),a=[];for(let t=0;t<r.length;t++){const e=r.feature(t),n=c.getId(e,i);a.push({feature:e,id:n,index:t,sourceLayerIndex:o})}for(const e of p[i]){const i=e[0];i.source!==this.source&&t.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.isHidden(this.zoom,!0)||(n(e,this.zoom,s),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(a,u,this.tileID.canonical),c.bucketLayerIDs.push(e.map(t=>t.id)))}}const d=t.bY(u.glyphDependencies,t=>Object.keys(t).map(Number));this.inFlightDependencies.forEach(t=>null==t?void 0:t.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(d).length){const t=new AbortController;this.inFlightDependencies.push(t),f=o.sendAsync({type:"GG",data:{stacks:d,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const m=Object.keys(u.iconDependencies);let _=Promise.resolve({});if(m.length){const t=new AbortController;this.inFlightDependencies.push(t),_=o.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},t)}const g=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(g.length){const t=new AbortController;this.inFlightDependencies.push(t),y=o.sendAsync({type:"GI",data:{icons:g,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const v=u.dashDependencies;let x=Promise.resolve({});if(Object.keys(v).length){const t=new AbortController;this.inFlightDependencies.push(t),x=o.sendAsync({type:"GDA",data:{dashes:v}},t)}const[b,w,S,T]=yield Promise.all([f,_,y,x]),C=new i(b),M=new t.cQ(w,S);for(const e in h){const i=h[e];i instanceof t.ah?(n(i.layers,this.zoom,s),t.cR({bucket:i,glyphMap:b,glyphPositions:C.positions,imageMap:w,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):i.hasDependencies&&(i instanceof t.cS||i instanceof t.cT||i instanceof t.cU)&&(n(i.layers,this.zoom,s),i.addFeatures(u,this.tileID.canonical,M.patternPositions,T))}return this.status="done",{buckets:Object.values(h).filter(t=>!t.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:C.image,imageAtlas:M,dashPositions:T,glyphMap:this.returnDependencies?b:null,iconMap:this.returnDependencies?w:null,glyphPositions:this.returnDependencies?C.positions:null}})}}function n(e,i,r){const n=new t.H(i);for(const t of e)t.recalculate(n,r)}class s{constructor(t,e,i,r,n){this.type=t,this.properties=i||{},this.extent=n,this.pointsArray=e,this.id=r}loadGeometry(){return this.pointsArray.map(e=>e.map(e=>new t.P(e.x,e.y)))}}class o{constructor(t,e,i){this.version=2,this._myFeatures=t,this.name=e,this.length=t.length,this.extent=i}feature(t){return this._myFeatures[t]}}class a{constructor(){this.layers={}}addLayer(t){this.layers[t.name]=t}}function l(e){let i=t.cV(e);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:e,rawData:i.buffer}}function c(e,i,r){const{extent:n}=e,a=Math.pow(2,r.z-i.z),l=(r.x-i.x*a)*n,c=(r.y-i.y*a)*n,h=[];for(let i=0;i<e.length;i++){const r=e.feature(i);let o=r.loadGeometry();for(const t of o)for(const e of t)e.x=e.x*a-l,e.y=e.y*a-c;const u=128;o=t.cW(o,r.type,-u,-u,n+u,n+u),0!==o.length&&h.push(new s(r.type,o,r.properties,r.id,n))}return new o(h,e.name,n)}class h{constructor(e,i,r){this.actor=e,this.layerIndex=i,this.availableImages=r,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new t.cX(1e3)}loadVectorTile(e,i){return t._(this,void 0,void 0,function*(){const r=yield t.n(e.request,i);try{return{vectorTile:"mlt"!==e.encoding?new t.cY(new t.cZ(r.data)):new t.c_(r.data),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires}}catch(t){const i=new Uint8Array(r.data);let n=`Unable to parse the tile at ${e.request.url}, `;throw n+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.message}`,new Error(n)}})}loadTile(e){return t._(this,void 0,void 0,function*(){const{uid:i,overzoomParameters:n}=e;n&&(e.request=n.overzoomRequest);const s=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.c$(e.request),o=new r(e);this.loading[i]=o;const a=new AbortController;o.abort=a;try{const r=yield this.loadVectorTile(e,a);if(delete this.loading[i],!r)return null;if(n){const t=this._getOverzoomTile(e,r.vectorTile);r.rawData=t.rawData,r.vectorTile=t.vectorTile}const l=r.rawData,c={};r.expires&&(c.expires=r.expires),r.cacheControl&&(c.cacheControl=r.cacheControl);const h={};if(s){const t=s.finish();t&&(h.resourceTiming=JSON.parse(JSON.stringify(t)))}o.vectorTile=r.vectorTile;const u=o.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);this.loaded[i]=o,this.fetching[i]={rawTileData:l,cacheControl:c,resourceTiming:h};try{const i=yield u;return t.e({rawTileData:l.slice(0),encoding:e.encoding},i,c,h)}finally{delete this.fetching[i]}}catch(t){throw delete this.loading[i],o.status="done",this.loaded[i]=o,t}})}_getOverzoomTile(t,e){const{tileID:i,source:r,overzoomParameters:n}=t,{maxZoomTileID:s}=n,o=`${s.key}_${i.key}`,h=this.overzoomedTileResultCache.get(o);if(h)return h;const u=new a,p=this.layerIndex.familiesBySource[r];for(const t in p){const r=e.layers[t];if(!r)continue;const n=c(r,s,i.canonical);n.length>0&&u.addLayer(n)}const d=l(u);return this.overzoomedTileResultCache.set(o,d),d}reloadTile(e){return t._(this,void 0,void 0,function*(){const i=e.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[i];if(r.showCollisionBoxes=e.showCollisionBoxes,"parsing"===r.status){const n=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity);let s;if(this.fetching[i]){const{rawTileData:r,cacheControl:o,resourceTiming:a}=this.fetching[i];delete this.fetching[i],s=t.e({rawTileData:r.slice(0),encoding:e.encoding},n,o,a)}else s=n;return s}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,e.subdivisionGranularity)})}abortTile(e){return t._(this,void 0,void 0,function*(){const t=this.loading,i=e.uid;t&&t[i]&&t[i].abort&&(t[i].abort.abort(),delete t[i])})}removeTile(e){return t._(this,void 0,void 0,function*(){this.loaded&&this.loaded[e.uid]&&delete this.loaded[e.uid]})}}class u{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,function*(){const{uid:i,encoding:r,rawImageData:n,redFactor:s,greenFactor:o,blueFactor:a,baseShift:l}=e,c=n.width+2,h=n.height+2,u=t.b(n)?new t.R({width:c,height:h},yield t.d0(n,-1,-1,c,h)):n,p=new t.d1(i,u,r,s,o,a,l);return this.loaded=this.loaded||{},this.loaded[i]=p,p})}removeTile(t){const e=this.loaded,i=t.uid;e&&e[i]&&delete e[i]}}var p,d,f=function(){if(d)return p;function t(t,i){if(0!==t.length){e(t[0],i);for(var r=1;r<t.length;r++)e(t[r],!i)}}function e(t,e){for(var i=0,r=0,n=0,s=t.length,o=s-1;n<s;o=n++){var a=(t[n][0]-t[o][0])*(t[o][1]+t[n][1]),l=i+a;r+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!e&&t.reverse()}return d=1,p=function e(i,r){var n,s=i&&i.type;if("FeatureCollection"===s)for(n=0;n<i.features.length;n++)e(i.features[n],r);else if("GeometryCollection"===s)for(n=0;n<i.geometries.length;n++)e(i.geometries[n],r);else if("Feature"===s)e(i.geometry,r);else if("Polygon"===s)t(i.coordinates,r);else if("MultiPolygon"===s)for(n=0;n<i.coordinates.length;n++)t(i.coordinates[n],r);return i}}(),m=t.d2(f);const _={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},g=Math.fround||(y=new Float32Array(1),t=>(y[0]=+t,y[0]));var y;class v{constructor(t){this.options=Object.assign(Object.create(_),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:r}=this.options;e&&console.time("total time");const n=`prepare ${t.length} points`;e&&console.time(n),this.points=t;const s=[];for(let e=0;e<t.length;e++){const i=t[e];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,o=g(w(r)),a=g(S(n));s.push(o,a,1/0,e,-1,1),this.options.reduce&&s.push(0)}let o=this.trees[r+1]=this._createTree(s);e&&console.timeEnd(n);for(let t=r;t>=i;t--){const i=+Date.now();o=this.trees[t]=this._createTree(this._cluster(o,t)),e&&console.log("z%d: %d clusters in %dms",t,o.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=180===t[2]?180:((t[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,n=180;else if(i>n){const t=this.getClusters([i,r,180,s],e),o=this.getClusters([-180,r,n,s],e);return t.concat(o)}const o=this.trees[this._limitZoom(e)],a=o.range(w(i),S(s),w(n),S(r)),l=o.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?x(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const s=n.data;if(e*this.stride>=s.length)throw new Error(r);const o=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(s[e*this.stride],s[e*this.stride+1],o),l=[];for(const e of a){const i=e*this.stride;s[i+4]===t&&l.push(s[i+5]>1?x(s,i,this.clusterProps):this.points[s[i+3]])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:s,radius:o}=this.options,a=o/s,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((e-a)/n,l,(e+1+a)/n,c),r.data,e,i,n,h),0===e&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,h),e===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const s=this.getChildren(e);for(const e of s){const s=e.properties;if(s&&s.cluster?n+s.point_count<=r?n+=s.point_count:n=this._appendLeaves(t,s.cluster_id,i,r,n):n<r?n++:t.push(e),t.length===i)break}return n}_createTree(e){const i=new t.aT(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)i.add(e[t],e[t+1]);return i.finish(),i.data=e,i}_addTileFeatures(t,e,i,r,n,s){for(const o of t){const t=o*this.stride,a=e[t+5]>1;let l,c,h;if(a)l=b(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=w(r),h=S(n)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let p;p=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==p&&(u.id=p),s.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:r,reduce:n,minPoints:s}=this.options,o=i/(r*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;i<a.length;i+=c){if(a[i+2]<=e)continue;a[i+2]=e;const r=a[i],h=a[i+1],u=t.within(a[i],a[i+1],o),p=a[i+5];let d=p;for(const t of u){const i=t*c;a[i+2]>e&&(d+=a[i+5])}if(d>p&&d>=s){let t,s=r*p,o=h*p,f=-1;const m=(i/c<<5)+(e+1)+this.points.length;for(const r of u){const l=r*c;if(a[l+2]<=e)continue;a[l+2]=e;const h=a[l+5];s+=a[l]*h,o+=a[l+1]*h,a[l+4]=m,n&&(t||(t=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(t)),n(t,this._map(a,l)))}a[i+4]=m,l.push(s/d,o/d,1/0,m,-1,d),n&&l.push(f)}else{for(let t=0;t<c;t++)l.push(a[i+t]);if(d>1)for(const t of u){const i=t*c;if(!(a[i+2]<=e)){a[i+2]=e;for(let t=0;t<c;t++)l.push(a[i+t])}}}}return l}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const r=this.clusterProps[t[e+6]];return i?Object.assign({},r):r}const r=this.points[t[e+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function x(t,e,i){return{type:"Feature",id:t[e+3],properties:b(t,e,i),geometry:{type:"Point",coordinates:[(r=t[e],360*(r-.5)),T(t[e+1])]}};var r}function b(t,e,i){const r=t[e+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,s=t[e+6],o=-1===s?{}:Object.assign({},i[s]);return Object.assign(o,{cluster:!0,cluster_id:t[e+3],point_count:r,point_count_abbreviated:n})}function w(t){return t/360+.5}function S(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function T(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function C(t,e,i,r){let n=r;const s=e+(i-e>>1);let o,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let r=e+3;r<i;r+=3){const e=M(t[r],t[r+1],l,c,h,u);if(e>n)o=r,n=e;else if(e===n){const t=Math.abs(r-s);t<a&&(o=r,a=t)}}n>r&&(o-e>3&&C(t,e,o,r),t[o+2]=n,i-o>3&&C(t,o,i,r))}function M(t,e,i,r,n,s){let o=n-i,a=s-r;if(0!==o||0!==a){const l=((t-i)*o+(e-r)*a)/(o*o+a*a);l>1?(i=n,r=s):l>0&&(i+=o*l,r+=a*l)}return o=t-i,a=e-r,o*o+a*a}function E(t,e,i,r){const n={type:e,geom:i},s={id:null==t?null:t,type:n.type,geometry:n.geom,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(n.type){case"Point":case"MultiPoint":case"LineString":A(s,n.geom);break;case"Polygon":A(s,n.geom[0]);break;case"MultiLineString":for(const t of n.geom)A(s,t);break;case"MultiPolygon":for(const t of n.geom)A(s,t[0])}return s}function A(t,e){for(let i=0;i<e.length;i+=3)t.minX=Math.min(t.minX,e[i]),t.minY=Math.min(t.minY,e[i+1]),t.maxX=Math.max(t.maxX,e[i]),t.maxY=Math.max(t.maxY,e[i+1])}function I(t,e){const i=[];switch(t.type){case"FeatureCollection":for(let r=0;r<t.features.length;r++)P(i,t.features[r],e,r);break;case"Feature":P(i,t,e);break;default:P(i,{geometry:t,properties:void 0},e)}return i}function P(t,e,i,r){if(!e.geometry)return;if("GeometryCollection"===e.geometry.type){for(const n of e.geometry.geometries)P(t,{id:e.id,geometry:n,properties:e.properties},i,r);return}const n=e.geometry.coordinates;if(!n?.length)return;const s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);let o=e.id;switch(i.promoteId?o=e.properties?.[i.promoteId]:i.generateId&&(o=r||0),e.geometry.type){case"Point":{const i=[];return D(e.geometry.coordinates,i),void t.push(E(o,e.geometry.type,i,e.properties))}case"MultiPoint":{const i=[];for(const t of e.geometry.coordinates)D(t,i);return void t.push(E(o,e.geometry.type,i,e.properties))}case"LineString":{const i=[];return k(e.geometry.coordinates,i,s,!1),void t.push(E(o,e.geometry.type,i,e.properties))}case"MultiLineString":{if(i.lineMetrics){for(const i of e.geometry.coordinates){const r=[];k(i,r,s,!1),t.push(E(o,"LineString",r,e.properties))}return}const r=[];return z(e.geometry.coordinates,r,s,!1),void t.push(E(o,e.geometry.type,r,e.properties))}case"Polygon":{const i=[];return z(e.geometry.coordinates,i,s,!0),void t.push(E(o,e.geometry.type,i,e.properties))}case"MultiPolygon":{const i=[];for(const t of e.geometry.coordinates){const e=[];z(t,e,s,!0),i.push(e)}return void t.push(E(o,e.geometry.type,i,e.properties))}default:throw new Error("Input data is not a valid GeoJSON object.")}}function D(t,e){e.push(R(t[0]),L(t[1]),0)}function k(t,e,i,r){let n,s,o=0;for(let i=0;i<t.length;i++){const a=R(t[i][0]),l=L(t[i][1]);e.push(a,l,0),i>0&&(o+=r?(n*l-a*s)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-s,2))),n=a,s=l}const a=e.length-3;e[2]=1,i>0&&C(e,0,a,i),e[a+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function z(t,e,i,r){for(let n=0;n<t.length;n++){const s=[];k(t[n],s,i,r),e.push(s)}}function R(t){return t/360+.5}function L(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function F(t,e,i,r,n,s,o,a){if(r/=e,s>=(i/=e)&&o<r)return t;if(o<i||s>=r)return null;const l=[];for(const e of t){const t=0===n?e.minX:e.minY,s=0===n?e.maxX:e.maxY;if(t>=i&&s<r)l.push(e);else if(!(s<i||t>=r))switch(e.type){case"Point":case"MultiPoint":{const t=[];if(B(e.geometry,t,i,r,n),!t.length)continue;l.push(E(e.id,3===t.length?"Point":"MultiPoint",t,e.tags));continue}case"LineString":{const t=[];if(O(e.geometry,t,i,r,n,!1,a.lineMetrics),!t.length)continue;if(a.lineMetrics){for(const i of t)l.push(E(e.id,e.type,i,e.tags));continue}if(t.length>1){l.push(E(e.id,"MultiLineString",t,e.tags));continue}l.push(E(e.id,e.type,t[0],e.tags));continue}case"MultiLineString":{const t=[];if(V(e.geometry,t,i,r,n,!1),!t.length)continue;if(1===t.length){l.push(E(e.id,"LineString",t[0],e.tags));continue}l.push(E(e.id,e.type,t,e.tags));continue}case"Polygon":{const t=[];if(V(e.geometry,t,i,r,n,!0),!t.length)continue;l.push(E(e.id,e.type,t,e.tags));continue}case"MultiPolygon":{const t=[];for(const s of e.geometry){const e=[];V(s,e,i,r,n,!0),e.length&&t.push(e)}if(!t.length)continue;l.push(E(e.id,e.type,t,e.tags));continue}}}return l.length?l:null}function B(t,e,i,r,n){for(let s=0;s<t.length;s+=3){const o=t[s+n];o>=i&&o<=r&&j(e,t[s],t[s+1],t[s+2])}}function O(t,e,i,r,n,s,o){let a=N(t);const l=0===n?q:G;let c,h,u=t.start;for(let p=0;p<t.length-3;p+=3){const d=t[p],f=t[p+1],m=t[p+2],_=t[p+3],g=t[p+4],y=0===n?d:f,v=0===n?_:g;let x=!1;o&&(c=Math.sqrt(Math.pow(d-_,2)+Math.pow(f-g,2))),y<i?v>i&&(h=l(a,d,f,_,g,i),o&&(a.start=u+c*h)):y>r?v<r&&(h=l(a,d,f,_,g,r),o&&(a.start=u+c*h)):j(a,d,f,m),v<i&&y>=i&&(h=l(a,d,f,_,g,i),x=!0),v>r&&y<=r&&(h=l(a,d,f,_,g,r),x=!0),!s&&x&&(o&&(a.end=u+c*h),e.push(a),a=N(t)),o&&(u+=c)}let p=t.length-3;const d=t[p],f=t[p+1],m=0===n?d:f;m>=i&&m<=r&&j(a,d,f,t[p+2]),p=a.length-3,s&&p>=3&&(a[p]!==a[0]||a[p+1]!==a[1])&&j(a,a[0],a[1],a[2]),a.length&&e.push(a)}function N(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function V(t,e,i,r,n,s){for(const o of t)O(o,e,i,r,n,s,!1)}function j(t,e,i,r){t.push(e,i,r)}function q(t,e,i,r,n,s){const o=(s-e)/(r-e);return j(t,s,i+(n-i)*o,1),o}function G(t,e,i,r,n,s){const o=(s-i)/(n-i);return j(t,e+(r-e)*o,s,1),o}function U(t,e){const i=e.buffer/e.extent;let r=t;const n=F(t,1,-1-i,i,0,-1,2,e),s=F(t,1,1-i,2+i,0,-1,2,e);return n||s?(r=F(t,1,-i,1+i,0,-1,2,e)||[],n&&(r=$(n,1).concat(r)),s&&(r=r.concat($(s,-1))),r):r}function $(t,e){const i=[];for(const r of t)switch(r.type){case"Point":case"MultiPoint":case"LineString":{const t=Z(r.geometry,e);i.push(E(r.id,r.type,t,r.tags));continue}case"MultiLineString":case"Polygon":{const t=[];for(const i of r.geometry)t.push(Z(i,e));i.push(E(r.id,r.type,t,r.tags));continue}case"MultiPolygon":{const t=[];for(const i of r.geometry){const r=[];for(const t of i)r.push(Z(t,e));t.push(r)}i.push(E(r.id,r.type,t,r.tags));continue}}return i}function Z(t,e){const i=[];i.size=t.size,void 0!==t.start&&(i.start=t.start,i.end=t.end);for(let r=0;r<t.length;r+=3)i.push(t[r]+e,t[r+1],t[r+2]);return i}function W(t,e){if(t.transformed)return t;const i=1<<t.z,r=t.x,n=t.y;for(const s of t.features){if(1===s.type){const t=[];for(let o=0;o<s.geometry.length;o+=2)t.push(H(s.geometry[o],s.geometry[o+1],e,i,r,n));s.geometry=t;continue}const t=[];for(const o of s.geometry){const s=[];for(let t=0;t<o.length;t+=2)s.push(H(o[t],o[t+1],e,i,r,n));t.push(s)}s.geometry=t}return t.transformed=!0,t}function H(t,e,i,r,n,s){return[Math.round(i*(t*r-n)),Math.round(i*(e*r-s))]}function X(t,e,i,r,n){const s=e===n.maxZoom?0:n.tolerance/((1<<e)*n.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:i,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const e of t)Y(o,e,s,n);return o}function Y(t,e,i,r){t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY);let n,s=e.tags||null;switch(e.type){case"Point":case"MultiPoint":{const i=[];for(let r=0;r<e.geometry.length;r+=3)i.push(e.geometry[r],e.geometry[r+1]),t.numPoints++,t.numSimplified++;if(!i.length)return;n={type:1,tags:s,geometry:i};break}case"LineString":{const o=[];if(K(o,e.geometry,t,i,!1,!1),!o.length)return;if(r.lineMetrics){s={};for(const t in e.tags)s[t]=e.tags[t];s.mapbox_clip_start=e.geometry.start/e.geometry.size,s.mapbox_clip_end=e.geometry.end/e.geometry.size}n={type:2,tags:s,geometry:o};break}case"MultiLineString":case"Polygon":{const r=[];for(let n=0;n<e.geometry.length;n++)K(r,e.geometry[n],t,i,"Polygon"===e.type,0===n);if(!r.length)return;n={type:"Polygon"===e.type?3:2,tags:s,geometry:r};break}case"MultiPolygon":{const r=[];for(let n=0;n<e.geometry.length;n++){const s=e.geometry[n];for(let e=0;e<s.length;e++)K(r,s[e],t,i,!0,0===e)}if(!r.length)return;n={type:3,tags:s,geometry:r};break}}null!==e.id&&(n.id=e.id),t.features.push(n)}function K(t,e,i,r,n,s){const o=r*r;if(r>0&&e.size<(n?o:r))return void(i.numPoints+=e.length/3);const a=[];for(let t=0;t<e.length;t+=3)(0===r||e[t+2]>o)&&(i.numSimplified++,a.push(e[t],e[t+1])),i.numPoints++;n&&function(t,e){let i=0;for(let e=0,r=t.length,n=r-2;e<r;n=e,e+=2)i+=(t[e]-t[n])*(t[e+1]+t[n+1]);if(i>0===e)for(let e=0,i=t.length;e<i/2;e+=2){const r=t[e],n=t[e+1];t[e]=t[i-2-e],t[e+1]=t[i-1-e],t[i-2-e]=r,t[i-1-e]=n}}(a,s),t.push(a)}function J(t,e,i){const r=!!e.newGeometry,n=e.removeAllProperties||e.removeProperties?.length>0||e.addOrUpdateProperties?.length>0;if(r){let r=I({type:"FeatureCollection",features:[{type:"Feature",id:t.id,geometry:e.newGeometry,properties:n?Q(t.tags,e):t.tags}]},i);return r=U(r,i),r[0]}if(n){const i={...t};return i.tags=Q(i.tags,e),i}return null}function Q(t,e){if(e.removeAllProperties)return{};const i={...t||{}};if(e.removeProperties)for(const t of e.removeProperties)delete i[t];if(e.addOrUpdateProperties)for(const{key:t,value:r}of e.addOrUpdateProperties)i[t]=r;return i}const tt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,debug:0};class et{options;tiles;tileCoords;stats={};total=0;source;constructor(t,e){const i=(e=this.options=Object.assign({},tt,e)).debug;if(i&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)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.");let r=I(t,e);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=U(r,e),r.length&&this.splitTile(r,0,0,0),e.updateable&&(this.source=r),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,i,r,n,s,o){const a=[t,e,i,r],l=this.options,c=l.debug;for(;a.length;){r=a.pop(),i=a.pop(),e=a.pop(),t=a.pop();const h=1<<e,u=it(e,i,r);let p=this.tiles[u];if(!p&&(c>1&&console.time("creation"),p=this.tiles[u]=X(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r,id:u}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(p.source=t,null==n){if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===n)continue;if(null!=n){const t=n-e;if(i!==s>>t||r!==o>>t)continue}}if(p.source=null,!t.length)continue;c>1&&console.time("clipping");const d=.5*l.buffer/l.extent,f=.5-d,m=.5+d,_=1+d;let g=null,y=null,v=null,x=null;const b=F(t,h,i-d,i+m,0,p.minX,p.maxX,l),w=F(t,h,i+f,i+_,0,p.minX,p.maxX,l);b&&(g=F(b,h,r-d,r+m,1,p.minY,p.maxY,l),y=F(b,h,r+f,r+_,1,p.minY,p.maxY,l)),w&&(v=F(w,h,r-d,r+m,1,p.minY,p.maxY,l),x=F(w,h,r+f,r+_,1,p.minY,p.maxY,l)),c>1&&console.timeEnd("clipping"),a.push(g||[],e+1,2*i,2*r),a.push(y||[],e+1,2*i,2*r+1),a.push(v||[],e+1,2*i+1,2*r),a.push(x||[],e+1,2*i+1,2*r+1)}}getTile(t,e,i){t=+t,e=+e,i=+i;const r=this.options,{extent:n,debug:s}=r;if(t<0||t>24)return null;const o=1<<t,a=it(t,e=e+o&o-1,i);if(this.tiles[a])return W(this.tiles[a],n);s>1&&console.log("drilling down to z%d-%d-%d",t,e,i);let l,c=t,h=e,u=i;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[it(c,h,u)];return l?.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,h,u),console.time("drilling down")),this.splitTile(l.source,c,h,u,t,e,i),s>1&&console.timeEnd("drilling down"),this.tiles[a]?W(this.tiles[a],n):null):null}invalidateTiles(t){const e=this.options,{debug:i}=e;let r=1/0,n=-1/0,s=1/0,o=-1/0;for(const e of t)r=Math.min(r,e.minX),n=Math.max(n,e.maxX),s=Math.min(s,e.minY),o=Math.max(o,e.maxY);const a=e.buffer/e.extent,l=new Set;for(const e in this.tiles){const c=this.tiles[e],h=1<<c.z,u=(c.x-a)/h,p=(c.x+1+a)/h,d=(c.y-a)/h,f=(c.y+1+a)/h;if(n<u||r>=p||o<d||s>=f)continue;let m=!1;for(const e of t)if(e.maxX>=u&&e.minX<p&&e.maxY>=d&&e.minY<f){m=!0;break}if(m){if(i){i>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c.z,c.x,c.y,c.numFeatures,c.numPoints,c.numSimplified);const t=`z${c.z}`;this.stats[t]=(this.stats[t]||0)-1,this.total--}delete this.tiles[e],l.add(e)}}l.size&&(this.tileCoords=this.tileCoords.filter(t=>!l.has(t.id)))}updateData(t){const e=this.options,i=e.debug;if(!e.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");const{affected:r,source:n}=function(t,e,i){const r=function(t){return t?{removeAll:t.removeAll,remove:new Set(t.remove||[]),add:new Map(t.add?.map(t=>[t.id,t])),update:new Map(t.update?.map(t=>[t.id,t]))}:{remove:new Set,add:new Map,update:new Map}}(e);let n=[];if(r.removeAll&&(n=t,t=[]),r.remove.size||r.add.size){const e=[];for(const i of t){const{id:t}=i;(r.remove.has(t)||r.add.has(t))&&e.push(i)}if(e.length){n.push(...e);const i=new Set(e.map(t=>t.id));t=t.filter(t=>!i.has(t.id))}if(r.add.size){let e=I({type:"FeatureCollection",features:Array.from(r.add.values())},i);e=U(e,i),n.push(...e),t.push(...e)}}if(r.update.size)for(const[e,s]of r.update){const r=t.findIndex(t=>t.id===e);if(-1===r)continue;const o=t[r],a=J(o,s,i);a&&(n.push(o,a),t[r]=a)}return{affected:n,source:t}}(this.source,t,e);if(!r.length)return;this.source=n,i>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(r),i>1&&console.timeEnd("invalidating");const[s,o,a]=[0,0,0],l=X(this.source,s,o,a,this.options);l.source=this.source;const c=it(s,o,a);if(this.tiles[c]=l,this.tileCoords.push({z:s,x:o,y:a,id:c}),i){const t=`z${s}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}}}function it(t,e,i){return 32*((1<<t)*i+e)+t}class rt extends h{constructor(t,e,i,r=nt){super(t,e,i),this._dataUpdateable=new Map,this._createGeoJSONIndex=r}loadVectorTile(e,i){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);return r?l(new t.d3(r.features,{version:2,extent:t.a5})):null})}loadData(e){return t._(this,void 0,void 0,function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const r=this._startPerformance(e);this._pendingRequest=new AbortController;try{(!this._pendingData||e.request||e.data||e.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(e,this._pendingRequest));const t=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(t,e),this.loaded={};const i={};return e.request&&(i.data=t),this._finishPerformance(r,e,i),i}catch(e){if(delete this._pendingRequest,t.Z(e))return{abandoned:!0};throw e}})}_startPerformance(e){var i;if(null===(i=null==e?void 0:e.request)||void 0===i?void 0:i.collectResourceTiming)return new t.c$(e.request)}_finishPerformance(t,e,i){if(!t)return;const r=t.finish();r&&(i.resourceTiming={},i.resourceTiming[e.source]=JSON.parse(JSON.stringify(r)))}getData(){return t._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(t){const e=this.loaded;return e&&e[t.uid]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,i){return t._(this,void 0,void 0,function*(){let t;if(e.request?t=yield this.loadGeoJSONFromUrl(e.request,e.promoteId,i):e.data?t=this._loadGeoJSONFromObject(e.data,e.promoteId):e.dataDiff&&(t=this._loadGeoJSONFromDiff(e.dataDiff,e.promoteId,e.source)),delete this._pendingRequest,"object"!=typeof t)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);return m(t,!0),e.filter&&(t=this._filterGeoJSON(t,e.filter)),t})}loadGeoJSONFromUrl(e,i,r){return t._(this,void 0,void 0,function*(){const n=yield t.j(e,r);return this._dataUpdateable=t.a7(n.data,i),n.data})}_loadGeoJSONFromObject(e,i){return this._dataUpdateable=t.a7(e,i),e}_loadGeoJSONFromDiff(e,i,r){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${r}`);t.a8(this._dataUpdateable,e,i);const n=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(n)}_filterGeoJSON(e,i){const r=t.d4(i,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw new Error(r.value.map(t=>`${t.key}: ${t.message}`).join(", "));const n=e.features.filter(t=>r.value.evaluate({zoom:0},t));return this._toFeatureCollection(n)}_toFeatureCollection(t){return{type:"FeatureCollection",features:t}}removeSource(e){return t._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset)}}function nt(e,i){return i.cluster?new v(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},n={},s={accumulated:null,zoom:0},o={properties:null},a=Object.keys(i);for(const e of a){const[s,o]=i[e],a=t.d4(o),l=t.d4("string"==typeof s?[s,["accumulated"],["get",e]]:s);r[e]=a.value,n[e]=l.value}return e.map=t=>{o.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(s,o);return e},e.reduce=(t,e)=>{o.properties=e;for(const e of a)s.accumulated=t[e],t[e]=n[e].evaluate(s,o)},e}(i)).load(e.features):function(t,e){return new et(t,e)}(e,i.geojsonVtOptions)}class st{constructor(e){this.self=e,this.actor=new t.L(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(t,e)=>{if(this.externalWorkerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.externalWorkerSourceTypes[t]=e},this.self.addProtocol=t.cK,this.self.removeProtocol=t.cL,this.self.registerRTLTextPlugin=e=>{t.d5.setMethods(e)},this.actor.registerMessageHandler("LDT",(t,e)=>this._getDEMWorkerSource(t,e.source).loadTile(e)),this.actor.registerMessageHandler("RDT",(e,i)=>t._(this,void 0,void 0,function*(){this._getDEMWorkerSource(e,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(e,i)=>t._(this,void 0,void 0,function*(){return this._getWorkerSource(e,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(e,i)=>t._(this,void 0,void 0,function*(){return this._getWorkerSource(e,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(e,i)=>t._(this,void 0,void 0,function*(){return this._getWorkerSource(e,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(t,e)=>this._getWorkerSource(t,e.type,e.source).loadData(e)),this.actor.registerMessageHandler("GD",(t,e)=>this._getWorkerSource(t,e.type,e.source).getData()),this.actor.registerMessageHandler("LT",(t,e)=>this._getWorkerSource(t,e.type,e.source).loadTile(e)),this.actor.registerMessageHandler("RT",(t,e)=>this._getWorkerSource(t,e.type,e.source).reloadTile(e)),this.actor.registerMessageHandler("AT",(t,e)=>this._getWorkerSource(t,e.type,e.source).abortTile(e)),this.actor.registerMessageHandler("RMT",(t,e)=>this._getWorkerSource(t,e.type,e.source).removeTile(e)),this.actor.registerMessageHandler("RS",(e,i)=>t._(this,void 0,void 0,function*(){if(!this.workerSources[e]||!this.workerSources[e][i.type]||!this.workerSources[e][i.type][i.source])return;const t=this.workerSources[e][i.type][i.source];delete this.workerSources[e][i.type][i.source],void 0!==t.removeSource&&t.removeSource(i)})),this.actor.registerMessageHandler("RM",e=>t._(this,void 0,void 0,function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)})),this.actor.registerMessageHandler("SR",(e,i)=>t._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(t,e)=>this._syncRTLPluginState(t,e)),this.actor.registerMessageHandler("IS",(e,i)=>t._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(t,e)=>this._setImages(t,e)),this.actor.registerMessageHandler("UL",(e,i)=>t._(this,void 0,void 0,function*(){this._getLayerIndex(e).update(i.layers,i.removedIds,this._getGlobalState(e))})),this.actor.registerMessageHandler("UGS",(e,i)=>t._(this,void 0,void 0,function*(){const t=this._getGlobalState(e);for(const e in i)t[e]=i[e]})),this.actor.registerMessageHandler("SL",(e,i)=>t._(this,void 0,void 0,function*(){this._getLayerIndex(e).replace(i,this._getGlobalState(e))}))}_getGlobalState(t){let e=this.globalStates.get(t);return e||(e={},this.globalStates.set(t,e)),e}_setImages(e,i){return t._(this,void 0,void 0,function*(){this.availableImages[e]=i;for(const t in this.workerSources[e]){const r=this.workerSources[e][t];for(const t in r)r[t].availableImages=i}})}_syncRTLPluginState(e,i){return t._(this,void 0,void 0,function*(){return yield t.d5.syncState(i,this.self.importScripts)})}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let i=this.layerIndexes[t];return i||(i=this.layerIndexes[t]=new e),i}_getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const r={sendAsync:(e,i)=>(e.targetMapId=t,this.actor.sendAsync(e,i))};switch(e){case"vector":this.workerSources[t][e][i]=new h(r,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][i]=new rt(r,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][i]=new this.externalWorkerSourceTypes[e](r,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][i]}_getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new u),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new st(self)),st}),i("index",["exports","./shared"],function(t,e){var i="5.17.0";function r(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let n,s,o;const a={frame(t,i,r,n){const s=n||window,o=s.requestAnimationFrame(t=>{a(),i(t)}),{unsubscribe:a}=e.s(t.signal,"abort",()=>{a(),s.cancelAnimationFrame(o),r(new e.a(t.signal.reason))},!1)},frameAsync(t,e){return new Promise((i,r)=>{this.frame(t,i,r,e)})},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(n||(n=document.createElement("a")),n.href=t,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==o?o:!!matchMedia&&(null==s&&(s=matchMedia("(prefers-reduced-motion: reduce)")),s.matches)},set prefersReducedMotion(t){o=t}},l=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}class h{static testProp(t){if(!h.docStyle)return t[0];for(let e=0;e<t.length;e++)if(t[e]in h.docStyle)return t[e];return t[0]}static create(t,e,i){const r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){h.docStyle&&h.selectProp&&(h.userSelect=h.docStyle[h.selectProp],h.docStyle[h.selectProp]="none")}static enableDrag(){h.docStyle&&h.selectProp&&(h.docStyle[h.selectProp]=h.userSelect)}static setTransform(t,e){t.style[h.transformProp]=e}static addEventListener(t,e,i,r={}){t.addEventListener(e,i,"passive"in r?r:r.capture)}static removeEventListener(t,e,i,r={}){t.removeEventListener(e,i,"passive"in r?r:r.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",h.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",h.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",h.suppressClickInternal,!0)},0)}static getScale(t){const e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,i,r){const n=i.boundingClientRect;return new e.P((r.clientX-n.left)/i.x-t.clientLeft,(r.clientY-n.top)/i.y-t.clientTop)}static mousePos(t,e){const i=h.getScale(t);return h.getPoint(t,i,e)}static touchPos(t,e){const i=[],r=h.getScale(t);for(let n=0;n<e.length;n++)i.push(h.getPoint(t,r,e[n]));return i}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const e=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),i=e.querySelectorAll("script");for(const t of i)t.remove();return h.clean(e),e.innerHTML}static isPossiblyDangerous(t,e){const i=e.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!i.includes("javascript:")&&!i.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const e=t.children;for(const t of e)h.removeAttributes(t),h.clean(t)}static removeAttributes(t){for(const{name:e,value:i}of t.attributes)h.isPossiblyDangerous(e,i)&&t.removeAttribute(e)}}h.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,h.selectProp=h.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),h.transformProp=h.testProp(["transform","WebkitTransform"]);const u={supported:!1,testSupport:function(t){!f&&d&&(m?_(t):p=t)}};let p,d,f=!1,m=!1;function _(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,d),t.isContextLost())return;u.supported=!0}catch(t){}t.deleteTexture(e),f=!0}var g;"undefined"!=typeof document&&(d=document.createElement("img"),d.onload=()=>{p&&_(p),p=null,m=!0},d.onerror=()=>{f=!0,p=null},d.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let i,r,n,s;t.resetRequestQueue=()=>{i=[],r=0,n=0,s={}},t.addThrottleControl=t=>{const e=n++;return s[e]=t,e},t.removeThrottleControl=t=>{delete s[t],a()},t.getImage=(t,r,n=!0)=>new Promise((s,o)=>{u.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"}),i.push({abortController:r,requestParameters:t,supportImageRefresh:n,state:"queued",onError:t=>{o(t)},onSuccess:t=>{s(t)}}),a()});const o=t=>e._(this,void 0,void 0,function*(){t.state="running";const{requestParameters:i,supportImageRefresh:n,onError:s,onSuccess:o,abortController:c}=t,h=!1===n&&!e.i(self)&&!e.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((t,e)=>t&&"accept"===e,!0));r++;const u=h?l(i,c):e.m(i,c);try{const i=yield u;delete t.abortController,t.state="completed",i.data instanceof HTMLImageElement||e.b(i.data)?o(i):i.data&&o({data:yield(p=i.data,"function"==typeof createImageBitmap?e.f(p):e.h(p)),cacheControl:i.cacheControl,expires:i.expires})}catch(e){delete t.abortController,s(e)}finally{r--,a()}var p}),a=()=>{const t=(()=>{for(const t of Object.keys(s))if(s[t]())return!0;return!1})()?e.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=r;e<t&&i.length>0;e++){const t=i.shift();t.abortController.signal.aborted?e--:o(t)}},l=(t,i)=>new Promise((r,n)=>{const s=new Image,o=t.url,a=t.credentials;a&&"include"===a?s.crossOrigin="use-credentials":(a&&"same-origin"===a||!e.d(o))&&(s.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{s.src="",n(new e.a(i.signal.reason))}),s.fetchPriority="high",s.onload=()=>{s.onerror=s.onload=null,r({data:s})},s.onerror=()=>{s.onerror=s.onload=null,i.signal.aborted||n(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},s.src=o})}(g||(g={})),g.resetRequestQueue();class y{constructor(t){this._transformRequestFn=null!=t?t:null}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function v(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:r,url:n}of t){const t=`${r}${n}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:r,url:n}))}}return e}function x(t,e,i){try{const r=new URL(t);return r.pathname+=`${e}${i}`,r.toString()}catch(e){throw new Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function b(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class w extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const i=this.images[t];if(i&&!i.data&&i.spriteData){const t=i.spriteData;i.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,i){let r=!0;const n=i.data||i.spriteData;return this._validateStretch(i.stretchX,n&&n.width)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,n&&n.height)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.k(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){if(!t)return!0;if(4!==t.length)return!1;const i=e.spriteData,r=i&&i.width||e.data.width,n=i&&i.height||e.data.height;return!(t[0]<0||r<t[0]||t[1]<0||n<t[1]||t[2]<0||r<t[2]||t[3]<0||n<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,e,i=!0){const r=this.getImage(t);if(i&&(r.data.width!==e.data.width||r.data.height!==e.data.height))throw new Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${e.data.width}x${e.data.height}).`);e.version=r.version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise((e,i)=>{let r=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(r=!1);this.isLoaded()||r?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})})}_getImagesForIds(t){const i={};for(const r of t){let t=this.getImage(r);t||(this.fire(new e.l("styleimagemissing",{id:r})),t=this.getImage(r)),t?i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const i=this.patterns[t],r=this.getImage(t);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new e.I(i,r);this.patterns[t]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const i=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new e.T(t,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:r}=e.p(t),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],r=i.x+1,s=i.y+1,o=this.getImage(t).data,a=o.width,l=o.height;e.R.copy(o,n,{x:0,y:0},{x:r,y:s},{width:a,height:l}),e.R.copy(o,n,{x:0,y:l-1},{x:r,y:s-1},{width:a,height:1}),e.R.copy(o,n,{x:0,y:0},{x:r,y:s+l},{width:a,height:1}),e.R.copy(o,n,{x:a-1,y:0},{x:r-1,y:s},{width:1,height:l}),e.R.copy(o,n,{x:0,y:0},{x:r+a,y:s},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const i of t){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const t=this.getImage(i);t||e.w(`Image with ID: "${i}" was not found`),b(t)&&this.updateImage(i,t)}}cloneImages(){const t={};for(const e in this.images){const i=this.images[e];t[e]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return t}}const S=1e20;function T(t,e,i,r,n,s,o,a,l){for(let c=e;c<e+r;c++)C(t,i*s+c,s,n,o,a,l);for(let c=i;c<i+n;c++)C(t,c*s+e,1,r,o,a,l)}function C(t,e,i,r,n,s,o){s[0]=0,o[0]=-S,o[1]=S,n[0]=t[e];for(let a=1,l=0,c=0;a<r;a++){n[a]=t[e+a*i];const r=a*a;do{const t=s[l];c=(n[a]-n[t]+r-t*t)/(a-t)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=S}for(let a=0,l=0;a<r;a++){for(;o[l+1]<a;)l++;const r=s[l],c=a-r;t[e+a*i]=n[r]+c*c}}const M=e.v.layout_symbol["text-font"].default.join(",");class E{constructor(t,e,i){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={},this.lang=i}setURL(t){this.url=t}getGlyphs(t){return e._(this,void 0,void 0,function*(){const e=[];for(const i in t)for(const r of t[i])e.push(this._getAndCacheGlyphsPromise(i,r));const i=yield Promise.all(e),r={};for(const{stack:t,id:e,glyph:n}of i)r[t]||(r[t]={}),r[t][e]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};return r})}_getAndCacheGlyphsPromise(t,i){return e._(this,void 0,void 0,function*(){let e=this.entries[t];e||(e=this.entries[t]={glyphs:{},requests:{},ranges:{}});let r=e.glyphs[i];return void 0!==r?{stack:t,id:i,glyph:r}:!this.url||this._charUsesLocalIdeographFontFamily(i)?(r=e.glyphs[i]=this._drawGlyph(e,t,i),{stack:t,id:i,glyph:r}):yield this._downloadAndCacheRangePromise(t,i)})}_downloadAndCacheRangePromise(t,i){return e._(this,void 0,void 0,function*(){const e=this.entries[t],r=Math.floor(i/256);if(e.ranges[r])return{stack:t,id:i,glyph:null};if(!e.requests[r]){const i=E.loadGlyphRange(t,r,this.url,this.requestManager);e.requests[r]=i}try{const n=yield e.requests[r];for(const t in n)e.glyphs[+t]=n[+t];return e.ranges[r]=!0,{stack:t,id:i,glyph:n[i]||null}}catch(n){const s=e.glyphs[i]=this._drawGlyph(e,t,i);return this._warnOnMissingGlyphRange(s,r,i,n),{stack:t,id:i,glyph:s}}})}_warnOnMissingGlyphRange(t,i,r,n){const s=256*i,o=s+255,a=r.toString(16).padStart(4,"0").toUpperCase();e.w(`Unable to load glyph range ${i}, ${s}-${o}. Rendering codepoint U+${a} locally instead. ${n}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&e.q(t)}_drawGlyph(t,i,r){const n=i===M&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(r),s=n?"ideographTinySDF":"tinySDF";t[s]||(t[s]=this._createTinySDF(n?this.localIdeographFontFamily:i));const o=t[s].draw(String.fromCodePoint(r)),a=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(r));return{id:r,bitmap:new e.r({width:o.width||60,height:o.height||60},o.data),metrics:{width:a?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:a?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const e=t?t.split(","):[];e.push("sans-serif");const i=e.map(t=>/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`).join(",");return new E.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(e[0]),fontStyle:this._fontStyle(e[0]),lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){const e={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[r,n]of Object.entries(e))new RegExp(`\\b${r}\\b`,"i").test(t)&&(i=`${n}`);return i}destroy(){for(const t in this.entries){const e=this.entries[t];e.tinySDF&&(e.tinySDF=null),e.ideographTinySDF&&(e.ideographTinySDF=null),e.glyphs={},e.requests={},e.ranges={}}this.entries={}}}E.loadGlyphRange=function(t,i,r,n){return e._(this,void 0,void 0,function*(){const s=256*i,o=s+255,a=n.transformRequest(r.replace("{fontstack}",t).replace("{range}",`${s}-${o}`),"Glyphs"),l=yield e.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${s}-${o}`);const c={};for(const t of e.o(l.data))c[t.id]=t;return c})},E.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=e,this.cutoff=r,this.radius=i,this.lang=a;const l=this.size=t+4*e,c=this._createCanvas(l),h=this.ctx=c.getContext("2d",{willReadFrequently:!0});h.font=`${o} ${s} ${t}px ${n}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:s}=this.ctx.measureText(t),o=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-n))),l=Math.min(this.size-this.buffer,o+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:o,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(t,m,m+o);const y=f.getImageData(m,m,a,l);g.fill(S,0,u),_.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const i=y.data[4*(t*a+e)+3]/255;if(0===i)continue;const r=(t+m)*c+e+m;if(1===i)g[r]=0,_[r]=S;else{const t=.5-i;g[r]=t>0?t*t:0,_[r]=t<0?t*t:0}}T(g,0,0,c,h,c,this.f,this.v,this.z),T(_,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(g[t])-Math.sqrt(_[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return d}};class A{constructor(){this.specification=e.u.light.position}possiblyEvaluate(t,i){return e.F(t.expression.evaluate(i))}interpolate(t,i,r){return{x:e.G.number(t.x,i.x,r),y:e.G.number(t.y,i.y,r),z:e.G.number(t.z,i.z,r)}}}let I;class P extends e.E{constructor(t){super(),I=I||new e.t({anchor:new e.D(e.u.light.anchor),position:new A,color:new e.D(e.u.light.color),intensity:new e.D(e.u.light.intensity)}),this._transitionable=new e.x(I,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i={}){if(!this._validate(e.y,t,i))for(const i in t){const r=t[i];i.endsWith(e.z)?this._transitionable.setTransition(i.slice(0,-e.z.length),r):this._transitionable.setValue(i,r)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(!r||!1!==r.validate)&&e.B(this,t.call(e.C,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.u}))}}const D=new e.t({"sky-color":new e.D(e.u.sky["sky-color"]),"horizon-color":new e.D(e.u.sky["horizon-color"]),"fog-color":new e.D(e.u.sky["fog-color"]),"fog-ground-blend":new e.D(e.u.sky["fog-ground-blend"]),"horizon-fog-blend":new e.D(e.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new e.D(e.u.sky["sky-horizon-blend"]),"atmosphere-blend":new e.D(e.u.sky["atmosphere-blend"])});class k extends e.E{constructor(t){super(),this._transitionable=new e.x(D,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.H(0))}setSky(t,i={}){if(!this._validate(e.J,t,i)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const i in t){const r=t[i];i.endsWith(e.z)?this._transitionable.setTransition(i.slice(0,-e.z.length),r):this._transitionable.setValue(i,r)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r={}){return!1!==(null==r?void 0:r.validate)&&e.B(this,t.call(e.C,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.u})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class z{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){const i=t.join(",")+String(e);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(t,e)),this.dashEntry[i]}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,s=t[0]*i,o=!0;r.push({left:n,right:s,isDash:o,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){o=!o;const l=t[e];n=a*i,a+=l,s=a*i,r.push({left:n,right:s,isDash:o,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let s=0,o=t[s];for(let a=0;a<this.width;a++){a/o.right>1&&(o=t[++s]);const l=Math.abs(a-o.left),c=Math.abs(a-o.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(o.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let n=0,s=t[n];for(let e=0;e<this.width;e++){e/s.right>1&&(s=t[++n]);const i=Math.abs(e-s.left),o=Math.abs(e-s.right),a=Math.min(i,o);this.data[r+e]=Math.max(0,Math.min(255,(s.isDash?a:-a)+128))}}addDash(t,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return e.w("LineAtlas out of space"),null;let s=0;for(let e=0;e<t.length;e++)s+=t[e];if(0!==s){const e=this.width/s,n=this.getDashRanges(t,this.width,e);i?this.addRoundDash(n,e,r):this.addRegularDash(n)}const o={y:this.nextRow+r,height:2*r,width:s};return this.nextRow+=n,this.dirty=!0,o}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}const R="maplibre_preloaded_worker_pool";class L{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<L.workerCount;)this.workers.push(new Worker(e.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach(t=>{t.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[R]}numActive(){return Object.keys(this.active).length}}const F=Math.floor(a.hardwareConcurrency/2);let B,O;function N(){return B||(B=new L),B}L.workerCount=e.K(globalThis)?Math.max(Math.min(F,3),1):1;class V{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let t=0;t<r.length;t++){const n=new e.L(r[t],i);n.name=`Worker ${t}`,this.actors.push(n)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,e){const i=[];for(const r of this.actors)i.push(r.sendAsync({type:t,data:e}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach(t=>{t.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const i of this.actors)i.registerMessageHandler(t,e)}unregisterMessageHandler(t){for(const e of this.actors)e.unregisterMessageHandler(t)}}function j(){return O||(O=new V(N(),e.M),O.registerMessageHandler("GR",(t,i,r)=>e.m(i,r))),O}function q(t,i){const r=e.N();return e.O(r,r,[1,1,0]),e.Q(r,r,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?e.S(r,r,t.calculatePosMatrix(i.toUnwrapped())):r}function G(t,e,i,r,n,s,o){var a;const l=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(null!==(a=null==n?void 0:n.layers)&&void 0!==a?a:null,e,t.id),c=s.maxPitchScaleFactor(),h=t.tilesIn(r,c,l);h.sort(U);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,n,s,c,q(s,r.tileID),o?(t,e)=>o(r.tileID,t,e):void 0)});return function(t,e){for(const i in t)for(const r of t[i])$(r,e);return t}(function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,s=i[n]=i[n]||{};for(const i in t){const r=t[i],n=s[i]=s[i]||{},o=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,o.push(t))}}return e}(u),t)}function U(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function $(t,e){const i=t.feature,r=e.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}function Z(t,i,r,n){return e._(this,void 0,void 0,function*(){let s=t;if(t.url?s=(yield e.j(i.transformRequest(t.url,"Source"),r)).data:yield a.frameAsync(r,n),!s)return null;const o=e.U(e.e(s,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in s&&s.vector_layers&&(o.vectorLayerIds=s.vector_layers.map(t=>t.id)),o})}class W{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof e.V?new e.V(t.lng,t.lat):e.V.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.V?new e.V(t.lng,t.lat):e.V.convert(t),this}extend(t){const i=this._sw,r=this._ne;let n,s;if(t instanceof e.V)n=t,s=t;else{if(!(t instanceof W))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(W.convert(t)):this.extend(e.V.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.V.convert(t)):this;if(n=t._sw,s=t._ne,!n||!s)return this}return i||r?(i.lng=Math.min(n.lng,i.lng),i.lat=Math.min(n.lat,i.lat),r.lng=Math.max(s.lng,r.lng),r.lat=Math.max(s.lat,r.lat)):(this._sw=new e.V(n.lng,n.lat),this._ne=new e.V(s.lng,s.lat)),this}getCenter(){return new e.V((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new e.V(this.getWest(),this.getNorth())}getSouthEast(){return new e.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:i,lat:r}=e.V.convert(t);let n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}intersects(t){if(!((t=W.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(t.getEast()-t.getWest());if(i>=360||r>=360)return!0;const n=e.W(this.getWest(),-180,180),s=e.W(this.getEast(),-180,180),o=e.W(t.getWest(),-180,180),a=e.W(t.getEast(),-180,180),l=n>=s,c=o>=a;return!(!l||!c)||(l?a>=n||o<=s:c?s>=o||n<=a:o<=s&&a>=n)}static convert(t){return t instanceof W?t:t?new W(t):t}static fromLngLat(t,i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*t.lat);return new W(new e.V(t.lng-n,t.lat-r),new e.V(t.lng+n,t.lat+r))}adjustAntiMeridian(){const t=new e.V(this._sw.lng,this._sw.lat),i=new e.V(this._ne.lng,this._ne.lat);return new W(t,t.lng>i.lng?new e.V(i.lng+360,i.lat):i)}}class H{constructor(t,e,i){this.bounds=W.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),r=Math.floor(e.Y(this.bounds.getWest())*i),n=Math.floor(e.X(this.bounds.getNorth())*i),s=Math.ceil(e.Y(this.bounds.getEast())*i),o=Math.ceil(e.X(this.bounds.getSouth())*i);return t.x>=r&&t.x<s&&t.y>=n&&t.y<o}}class X extends e.E{constructor(t,i,r,n){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.e(this,e.U(i,["url","scheme","tileSize","promoteId","encoding"])),this._options=e.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n)}load(){return e._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield Z(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),t&&(e.e(this,t),t.bounds&&(this.tileBounds=new H(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,e.Z(t)||this.fire(new e.k(t))}})}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(t)};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise((e,i)=>{t.reloadPromise={resolve:e,reject:i}})}else t.actor=this.dispatcher.getActor(),r="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:r,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e)}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}})}_getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const e=t.tileID.scaledTo(this.maxzoom).canonical,i=e.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:e,overzoomRequest:this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))})}unloadTile(t){return e._(this,void 0,void 0,function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Y extends e.E{constructor(t,i,r,n){super(),this.id=t,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.U(i,["url","scheme","tileSize"]))}load(){return e._(this,arguments,void 0,function*(t=!1){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield Z(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(e.e(this,i),i.bounds&&(this.tileBounds=new H(i.bounds,this.minzoom,this.maxzoom)),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,e.Z(t)||this.fire(new e.k(t))}})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const r=yield g.getImage(this.map._requestManager.transformRequest(i,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(r&&r.data){this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&t.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const i=this.map.painter.context,n=i.gl,s=r.data;t.texture=this.map.painter.getTileTexture(s.width),t.texture?t.texture.update(s,{useMipmap:!0}):(t.texture=new e.T(i,s,n.RGBA,{useMipmap:!0}),t.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}})}abortTile(t){return e._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)})}unloadTile(t){return e._(this,void 0,void 0,function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)})}hasTransition(){return!1}}class K extends Y{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(t){return e._(this,void 0,void 0,function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const i=yield g.getImage(r,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const n=e.b(r)&&e.$()?r:yield this.readImageNow(r),s={type:this.type,uid:t.uid,source:this.id,rawImageData:n,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:s});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}})}readImageNow(t){return e._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&e.a0()){const i=t.width+2,r=t.height+2;try{return new e.R({width:i,height:r},yield e.a1(t,-1,-1,i,r))}catch(t){}}return a.getImageData(t,1)})}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,s=0===i.x?t.wrap-1:t.wrap,o=(i.x+1+r)%r,a=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.a2(t.overscaledZ,s,i.z,n,i.y).key]={backfilled:!1},l[new e.a2(t.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},i.y>0&&(l[new e.a2(t.overscaledZ,s,i.z,n,i.y-1).key]={backfilled:!1},l[new e.a2(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.a2(t.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new e.a2(t.overscaledZ,s,i.z,n,i.y+1).key]={backfilled:!1},l[new e.a2(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.a2(t.overscaledZ,a,i.z,o,i.y+1).key]={backfilled:!1}),l}unloadTile(t){return e._(this,void 0,void 0,function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))})}}function J(t){return"GeometryCollection"===t.type?t.geometries.map(t=>t.coordinates).flat(1/0):t.coordinates.flat(1/0)}function Q(t){const e=new W;let i;switch(t.type){case"FeatureCollection":i=t.features.map(t=>J(t.geometry)).flat(1/0);break;case"Feature":i=J(t.geometry);break;default:i=J(t)}if(0==i.length)return e;for(let t=0;t<i.length-1;t+=2)e.extend([i[t],i[t+1]]);return e}class tt extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:i.data},this.actor=r.getActor(),this.setEventedParent(n),this._data="string"==typeof i.data?{url:i.data}:{geojson:i.data},this._options=e.e({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&e.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=e.e({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:e.a5,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(i.clusterMaxZoom),minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.a5,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions),"string"==typeof this.promoteId&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(t){return t*(e.a5/this.tileSize)}_getClusterMaxZoom(t){const i=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||void 0===t||e.w(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${i}"`),i}load(){return e._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(t){this.map=t,this.load()}setData(t,e){this._data="string"==typeof t?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t};const i=this._updateWorkerData();return e?i:this}updateData(t,i){this._pendingWorkerUpdate.diff=e.a6(this._pendingWorkerUpdate.diff,t);const r=this._updateWorkerData();return i?r:this}getData(){return e._(this,void 0,void 0,function*(){const t=e.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})})}getBounds(){return e._(this,void 0,void 0,function*(){return Q(yield this.getData())})}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,void 0!==t.clusterRadius&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,e,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:e,offset:i}})}_updateWorkerData(){return e._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void e.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:t,diff:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(t,i);void 0!==t?this._pendingWorkerUpdate.data=void 0:i&&(this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,yield this._dispatchWorkerUpdate(r)})}_getLoadGeoJSONParameters(t,i){const r=e.e({type:this.type},this.workerOptions);return"string"==typeof t?(r.request=this.map._requestManager.transformRequest(a.resolveURL(t),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r):void 0!==t?(r.data=t,r):i?(r.dataDiff=i,r):r}_dispatchWorkerUpdate(t){return e._(this,void 0,void 0,function*(){this._isUpdatingWorker=!0,this.fire(new e.l("dataloading",{dataType:"source"}));try{const i=yield this.actor.sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||i.abandoned)return void this.fire(new e.l("dataabort",{dataType:"source"}));i.data&&(this._data={geojson:i.data});const r=this._applyDiffToSource(t.dataDiff),n=this._getShouldReloadTileOptions(r),s={dataType:"source"};this._applyResourceTiming(s,i),this.fire(new e.l("data",Object.assign(Object.assign({},s),{sourceDataType:"metadata"}))),this.fire(new e.l("data",Object.assign(Object.assign({},s),{sourceDataType:"content",shouldReloadTileOptions:n})))}catch(t){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new e.l("dataabort",{dataType:"source"}));this.fire(new e.k(t))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyResourceTiming(t,i){var r;if(!this._collectResourceTiming)return;const n=null===(r=i.resourceTiming)||void 0===r?void 0:r[this.id];if(!n)return;const s=n.slice(0);(null==s?void 0:s.length)&&e.e(t,{resourceTiming:s})}_applyDiffToSource(t){if(!t)return;const i="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const t=e.a7(this._data.geojson,i);if(!t)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;const r=e.a8(this._data.updateable,t,i);return t.removeAll||this._options.cluster?void 0:r}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map(t=>Q(t))}}shouldReloadTile(t,{affectedBounds:i}){if("loading"===t.state)return!0;if("unloaded"===t.state)return!1;const{buffer:r,extent:n}=this.workerOptions.geojsonVtOptions,s=function({x:t,y:i,z:r},n=0){const s=e.a3((t-n)/Math.pow(2,r)),o=e.a4((i+1+n)/Math.pow(2,r)),a=e.a3((t+1+n)/Math.pow(2,r)),l=e.a4((i-n)/Math.pow(2,r));return new W([s,o],[a,l])}(t.tileID.canonical,r/n);for(const t of i)if(s.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(t){return e._(this,void 0,void 0,function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const r=yield this.actor.sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(r,this.map.painter,"RT"===e)})}abortTile(t){return e._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0})}unloadTile(t){return e._(this,void 0,void 0,function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class et extends e.E{constructor(t,e,i,r){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t){return e._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new e.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield g.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,e.Z(t)||this.fire(new e.k(t))}})}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const i=t.map(e.a9.fromLngLat);var r;return this.tileID=function(t){const i=e.aa.fromPoints(t),r=i.width(),n=i.height(),s=Math.max(r,n),o=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),a=Math.pow(2,o);return new e.ac(o,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(t=>this.tileID.getTilePoint(t)._round()),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new e.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture||(this.texture=new e.T(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){const{minX:i,minY:r,maxX:n,maxY:s}=e.aa.fromPoints(t),o={};for(let t=0;t<=e.ab;t++){const e=Math.pow(2,t),a=Math.floor(i*e),l=Math.floor(r*e),c=Math.floor(n*e),h=Math.floor(s*e),u=(a%e+e)%e,p=c%e,d=Math.floor(a/e),f=Math.floor(c/e);o[t]={minWrap:d,maxWrap:f,minTileXWrapped:u,maxTileXWrapped:p,minTileY:l,maxTileY:h}}return o}}class it extends et{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.ad(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.k(t))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.k(new e.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class rt extends et{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(t=>!Array.isArray(t)||2!==t.length||t.some(t=>"number"!=typeof t))||this.fire(new e.k(new e.ae(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.k(new e.ae(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.k(new e.ae(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.k(new e.ae(`sources.${t}`,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 e.k(new e.ae(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return e._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.k(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())})}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new e.T(i,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const nt={},st=t=>{switch(t){case"geojson":return tt;case"image":return et;case"raster":return Y;case"raster-dem":return K;case"vector":return X;case"video":return it;case"canvas":return rt}return nt[t]},ot="RTLPluginLoaded";class at extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch(t=>{throw this.status="error",t})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return e._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.l(ot))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let lt=null;function ct(){return lt||(lt=new at),lt}var ht,ut;!function(t){t[t.Base=0]="Base",t[t.Parent=1]="Parent"}(ht||(ht={})),function(t){t[t.Departing=0]="Departing",t[t.Incoming=1]="Incoming"}(ut||(ut={}));class pt{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=e.af(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:e,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=e,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,i,r){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map(t=>e.getLayer(t)).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(e=>t.filter(t=>t.id===e)[0]));for(const e of t)i[e.id]=r}}return i}(t.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.ah){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.ah&&i.hasRTLText){this.hasRTLText=!0,ct().lazyLoad();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new e.ag}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const i=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new e.T(t,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,s,o,a,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:s,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:o,queryPadding:this.queryPadding*l,getElevation:h},t,e,i):{}}querySourceFeatures(t,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),s=i&&i.sourceLayer?i.sourceLayer:"",o=n[e.ai]||n[s];if(!o)return;const a=e.aj(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<o.length;i++){const n=o.feature(i);if(a.needGeometry){const t=e.ak(n,!0);if(!a.filter(new e.H(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.H(this.tileID.overscaledZ),n))continue;const p=r.getId(n,s),d=new e.al(n,l,c,h,p);d.tile=u,t.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.am(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let e=!1;if(this.expirationTime>t)e=!1;else if(i)if(this.expirationTime<i)e=!0;else{const r=this.expirationTime-i;r?this.expirationTime=t+Math.max(r,3e4):e=!0}else e=!0;e?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,i){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length)return;const r=this.latestFeatureIndex.loadVTLayers();for(const n in this.buckets){if(!i.style.hasLayer(n))continue;const s=this.buckets[n],o=s.layers[0].sourceLayer||e.ai,a=r[o],l=t[o];if(!a||!l||0===Object.keys(l).length)continue;s.update(l,a,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const c=i&&i.style&&i.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(s)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<c()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=c()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}}class dt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,i,r){const n=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.e(this.stateChanges[t][n],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])r[e]||(this.deletedStates[t][n][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,i){const r=String(i),n=e.e({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return{};for(const t in e)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,i){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),e.e(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[t]=i}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e]}r[t]=r[t]||{},e.e(r[t],i)}this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length&&t.setFeatureState(r,i)}}const ft=89.25;function mt(t,i){const r=e.an(i.lat,-e.ao,e.ao);return new e.P(e.Y(i.lng)*t,e.X(r)*t)}function _t(t,i){return new e.a9(i.x/t,i.y/t).toLngLat()}function gt(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(e.ap(90-t.pitch)),Math.tan(e.ap(ft-t.pitch)))}function yt(t,i){const r=t.canonical,n=i/e.aq(r.z),s=r.x+Math.pow(2,r.z)*t.wrap,o=e.ar(new Float64Array(16));return e.O(o,o,[s*n,r.y*n,0]),e.Q(o,o,[n/e.a5,n/e.a5,1]),o}function vt(t,i,r,n,s){const o=e.a9.fromLngLat(t,i),a=s*e.as(1,t.lat),{x:l,y:c,z:h}=xt(r,n);return new e.a9(o.x+a*-l,o.y+a*-c,o.z+a*-h)}function xt(t,i){const r=e.ap(t),n=e.ap(i),s=Math.cos(-r),o=Math.sin(r);return{x:o*Math.sin(n),y:-o*Math.cos(n),z:s}}function bt(t,e,i){const r=e.intersectsFrustum(t);if(!i||0===r)return r;const n=e.intersectsPlane(i);return 0===n?0:2===r&&2===n?2:1}function wt(t,e,i){let r=0;const n=(i-e)/10;for(let s=0;s<10;s++)r+=n*Math.pow(Math.cos(e+(s+.5)/10*(i-e)),t);return r}function St(t,i){return function(r,n,s,o,a){const l=2*((t-1)/e.at(Math.cos(e.ap(ft-a))/Math.cos(e.ap(ft)))-1),c=Math.acos(s/o),h=2*wt(l-1,0,e.ap(a/2)),u=Math.min(e.ap(ft),c+e.ap(a/2)),p=wt(l-1,Math.min(u,c-e.ap(a/2)),u),d=Math.atan(n/s),f=Math.hypot(n,s);let m=r;return m+=e.at(o/f/Math.max(.5,Math.cos(e.ap(a/2)))),m+=l*e.at(Math.cos(d))/2,m-=e.at(Math.max(1,p/h/i))/2,m}}const Tt=St(9.314,3);function Ct(t,i){const r=(i.roundZoom?Math.round:Math.floor)(t.zoom+e.at(t.tileSize/i.tileSize));return Math.max(0,r)}function Mt(t,i){const r=t.getCameraFrustum(),n=t.getClippingPlane(),s=t.screenPointToMercatorCoordinate(t.getCameraPoint()),o=e.a9.fromLngLat(t.center,t.elevation);s.z=o.z+Math.cos(t.pitchInRadians)*t.cameraToCenterDistance/t.worldSize;const a=t.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(t,i),c=Ct(t,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:t.maxZoom,p=Math.min(Math.max(0,c),u),d=Math.pow(2,p),f=[d*s.x,d*s.y,0],m=[d*o.x,d*o.y,0],_=Math.hypot(o.x-s.x,o.y-s.y),g=Math.abs(o.z-s.z),y=Math.hypot(_,g),v=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),x=[],b=[];if(t.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)x.push(v(-t)),x.push(v(t));for(x.push(v(0));x.length>0;){const d=x.pop(),_=d.x,v=d.y;let w=d.fullyVisible;const S={x:_,y:v,z:d.zoom},T=a.getTileBoundingVolume(S,d.wrap,t.elevation,i);if(!w){const t=bt(r,T,n);if(0===t)continue;w=2===t}const C=a.distanceToTile2d(s.x,s.y,S,T);let M=c;l&&(M=(i.calculateTileZoom||Tt)(t.zoom+e.at(t.tileSize/i.tileSize),C,g,y,t.fov)),M=(i.roundZoom?Math.round:Math.floor)(M),M=Math.max(0,M);const E=Math.min(M,u);if(d.wrap=a.getWrap(o,S,d.wrap),d.zoom>=E){if(d.zoom<h)continue;const t=p-d.zoom,r=f[0]-.5-(_<<t),n=f[1]-.5-(v<<t),s=i.reparseOverscaled?Math.max(d.zoom,M):d.zoom;b.push({tileID:new e.a2(d.zoom===u?s:d.zoom,d.wrap,d.zoom,_,v),distanceSq:e.au([m[0]-.5-_,m[1]-.5-v]),tileDistanceToCamera:Math.sqrt(r*r+n*n)})}else for(let t=0;t<4;t++)x.push({zoom:d.zoom+1,x:(_<<1)+t%2,y:(v<<1)+(t>>1),wrap:d.wrap,fullyVisible:w})}return b.sort((t,e)=>t.distanceSq-e.distanceSq).map(t=>t.tileID)}const Et=e.aa.fromPoints([new e.P(0,0),new e.P(e.a5,e.a5)]);function At(t){return"raster"===t||"image"===t||"video"===t}function It(t,e,i,r,n,s,o){if(!e.hasData())return!1;const{tileID:a,fadingRole:l,fadingDirection:c,fadingParentID:h}=e;if(l===ht.Base&&c===ut.Incoming&&h)return i[h.key]=h,!0;const u=Math.max(a.overscaledZ-n,s);for(let n=a.overscaledZ-1;n>=u;n--){const s=a.scaledTo(n),l=t.getLoadedTile(s);if(l)return e.setCrossFadeLogic({fadingRole:ht.Base,fadingDirection:ut.Incoming,fadingParentID:l.tileID,fadeEndTime:r+o}),l.setCrossFadeLogic({fadingRole:ht.Parent,fadingDirection:ut.Departing,fadeEndTime:r+o}),i[s.key]=s,!0}return!1}function Pt(t,e,i,r,n,s){if(!e.hasData())return!1;const o=e.tileID.children(n);let a=Dt(t,e,o,i,r,n,s);if(a)return!0;for(const l of o)Dt(t,e,l.children(n),i,r,n,s)&&(a=!0);return a}function Dt(t,e,i,r,n,s,o){if(i[0].overscaledZ>=s)return!1;let a=!1;for(const s of i){const i=t.getLoadedTile(s);if(!i)continue;const{fadingRole:l,fadingDirection:c,fadingParentID:h}=i;l===ht.Base&&c===ut.Departing&&h||(i.setCrossFadeLogic({fadingRole:ht.Base,fadingDirection:ut.Departing,fadingParentID:e.tileID,fadeEndTime:n+o}),e.setCrossFadeLogic({fadingRole:ht.Parent,fadingDirection:ut.Incoming,fadeEndTime:n+o})),r[s.key]=s,a=!0}return a}function kt(t,e,i,r){const n=t.tileID;return!!t.selfFading||!t.hasData()&&!!e.has(n)&&(t.setSelfFadeLogic(i+r),!0)}function zt(t,e){var i;t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let r=e.tileID.canonical.x-t.tileID.canonical.x;const n=e.tileID.canonical.y-t.tileID.canonical.y,s=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===r&&0===n||Math.abs(n)>1||(Math.abs(r)>1&&(1===Math.abs(r+s)?r+=s:1===Math.abs(r-s)&&(r-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),(null===(i=t.neighboringTiles)||void 0===i?void 0:i[o])&&(t.neighboringTiles[o].backfilled=!0)))}class Rt{constructor(){this._tiles={}}handleWrapJump(t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e}setFeatureState(t,e){for(const i in this._tiles)this._tiles[i].setFeatureState(t,e)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map(t=>t.tileID).sort(e.aw).map(t=>t.key):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,e){this._tiles[t]=e}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){const e=this.getTileById(t.key);return(null==e?void 0:e.hasData())?e:null}isIdRenderable(t,e=!1){var i;return null===(i=this.getTileById(t))||void 0===i?void 0:i.isRenderable(e)}getRenderableIds(t=0,i){const r=[];for(const t of this.getAllIds())this.isIdRenderable(t,i)&&r.push(this.getTileById(t));return i?r.sort((i,r)=>{const n=i.tileID,s=r.tileID,o=new e.P(n.canonical.x,n.canonical.y)._rotate(-t),a=new e.P(s.canonical.x,s.canonical.y)._rotate(-t);return n.overscaledZ-s.overscaledZ||a.y-o.y||a.x-o.x}).map(t=>t.tileID.key):r.map(t=>t.tileID).sort(e.aw).map(t=>t.key)}}class Lt extends e.E{constructor(t,i,r){super(),this.id=t,this.dispatcher=r,this.on("data",t=>this._dataHandler(t)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((t,e,i,r)=>{const n=new(st(e.type))(t,e,i,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return n})(t,i,r,this),this._inViewTiles=new Rt,this._outOfViewCache=new e.ax(0,t=>this._unloadTile(t)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new dt,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){for(const t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t),this._inViewTiles=new Rt}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,i,r){return e._(this,void 0,void 0,function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,i,r)}catch(i){t.state="errored",404!==i.status?this._source.fire(new e.k(i,{tile:t})):this.update(this.transform,this.terrain)}})}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.l("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const e of this._inViewTiles.getAllTiles())e.upload(t),e.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var e;return this._inViewTiles.getRenderableIds(null===(e=this.transform)||void 0===e?void 0:e.bearingInRadians,t)}hasRenderableParent(t){const e=t.overscaledZ-1;if(e>=this._source.minzoom){const i=this.getLoadedTile(t.scaledTo(e));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(t,e=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const i of this._inViewTiles.getAllIds()){const r=this._inViewTiles.getTileById(i);e&&!this._source.shouldReloadTile(r,e)||(t?this._reloadTile(i,"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}_reloadTile(t,i){return e._(this,void 0,void 0,function*(){const e=this._inViewTiles.getTileById(t);e&&("loading"!==e.state&&(e.state=i),yield this._loadTile(e,t,i))})}_tileLoaded(t,i,r){t.timeAdded=c(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this.getSource().type&&t.dem&&function(t,e){var i,r;const n=e.getRenderableIds();for(const s of n){if(!t.neighboringTiles||!t.neighboringTiles[s])continue;const n=e.getTileById(s);t.neighboringTiles[s].backfilled||zt(t,n),(null===(r=null===(i=n.neighboringTiles)||void 0===i?void 0:i[t.tileID.key])||void 0===r?void 0:r.backfilled)||zt(n,t)}}(t,this._inViewTiles),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.l("data",{dataType:"source",tile:t,coord:t.tileID}))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,e){const i=this._getLoadedDescendents(e),r=new Set;for(const n of e){const e=i[n.key];if(!(null==e?void 0:e.length)){r.add(n);continue}const s=n.overscaledZ+Lt.maxOverzooming,o=e.filter(t=>t.tileID.overscaledZ<=s);if(!o.length){r.add(n);continue}const a=Math.min(...o.map(t=>t.tileID.overscaledZ)),l=o.filter(t=>t.tileID.overscaledZ===a).map(t=>t.tileID);for(const e of l)t[e.key]=e;this._areDescendentsComplete(l,a,n.overscaledZ)||r.add(n)}return r}_getLoadedDescendents(t){var e;const i={};for(const r of this._inViewTiles.getAllTiles().filter(t=>t.hasData()))for(const n of t)r.tileID.isChildOf(n)&&(i[e=n.key]||(i[e]=[])).push(r);return i}_areDescendentsComplete(t,e,i){return 1===t.length&&t[0].isOverscaled()?t[0].overscaledZ===e:Math.pow(4,e-i)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const i=Math.ceil(t.width/this._source.tileSize)+1,r=Math.ceil(t.height/this._source.tileSize)+1,n=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?e.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._outOfViewCache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);this._prevLng=t,e&&(this._inViewTiles.handleWrapJump(e),this._resetTileReloadTimers())}update(t,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.a2(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)):(r=Mt(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?t.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter(t=>this._source.hasTile(t)))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new e.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const s=Ct(t,this._source),o=this._updateRetainedTiles(r,s),a=At(this._source.type);a&&this._rasterFadeDuration>0&&!i&&function(t,i,r,n,s,o,a){const l=c(),h=e.av(i);for(const e of i){const i=t.getTileById(e.key);i.fadingDirection!==ut.Departing&&0!==i.fadeOpacity||i.resetFadeLogic(),It(t,i,r,l,n,s,a)||Pt(t,i,r,l,o,a)||kt(i,h,l,a)||i.resetFadeLogic()}}(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),a?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(t){for(const e of this._inViewTiles.getAllIds())t[e]||this._removeTile(e)}_cleanUpVectorTiles(t){for(const e of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(e);t[e]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(e):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(e)}}_addTerrainIdealTiles(t){const e=[];for(const i of t)if(i.canonical.z>this._source.minzoom){const t=i.scaledTo(i.canonical.z-1);e.push(t);const r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));e.push(r)}return t.concat(e)}releaseSymbolFadeTiles(){for(const t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var i;const r=new Set;for(const e of t)this._addTile(e).hasData()||r.add(e);const n=t.reduce((t,e)=>(t[e.key]=e,t),{}),s=this._retainLoadedChildren(n,r),o={},a=Math.max(e-Lt.maxUnderzooming,this._source.minzoom);for(const t of s){let e=this._inViewTiles.getTileById(t.key),r=null==e?void 0:e.wasRequested();for(let s=t.overscaledZ-1;s>=a;--s){const a=t.scaledTo(s);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&r&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||r)&&(n[a.key]=a),r=e.wasRequested(),t)break}}}return n}_addTile(t){let i=this._inViewTiles.getTileById(t.key);if(i)return i;i=this._outOfViewCache.getAndRemove(t),i&&(i.resetFadeLogic(),this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null));const r=i;return i||(i=new pt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state)),i.uses++,this._inViewTiles.setTile(t.key,i),r||this._source.fire(new e.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){this._clearTileReloadTimer(t);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},i))}_clearTileReloadTimer(t){const e=this._timers[t];e&&(clearTimeout(e),delete this._timers[t])}_resetTileReloadTimers(){for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t of this._inViewTiles.getAllIds()){const e=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,e)}}refreshTiles(t){for(const e of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(e);(this._inViewTiles.isIdRenderable(e)||"errored"==i.state)&&t.some(t=>t.equals(i.tileID.canonical))&&this._reloadTile(e,"expired")}}_removeTile(t){const e=this._inViewTiles.getTileById(t);e&&(e.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._outOfViewCache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){"source"===t.dataType&&("metadata"!==t.sourceDataType?"content"===t.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,i,r){const n=[],s=this.transform;if(!s)return n;const o=s.getCoveringTilesDetailsProvider().allowWorldCopies(),a=r?s.getCameraQueryGeometry(t):t,l=t=>s.screenPointToMercatorCoordinate(t,this.terrain),c=this.transformBbox(t,l,!o),h=this.transformBbox(a,l,!o),u=this.getIds(),p=e.aa.fromPoints(h);for(let t=0;t<u.length;t++){const r=this._inViewTiles.getTileById(u[t]);if(r.holdingForSymbolFade())continue;const a=o?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],l=Math.pow(2,s.zoom-r.tileID.overscaledZ),d=i*r.queryPadding*e.a5/r.tileSize/l;for(const t of a){const i=p.map(i=>t.getTilePoint(new e.a9(i.x,i.y)));if(i.expandBy(d),i.intersects(Et)){const e=c.map(e=>t.getTilePoint(e)),i=h.map(e=>t.getTilePoint(e));n.push({tile:r,tileID:o?t:t.unwrapTo(0),queryGeometry:e,cameraQueryGeometry:i,scale:l})}}}return n}transformBbox(t,i,r){let n=t.map(i);if(r){const r=e.aa.fromPoints(t);r.shrinkBy(.001*Math.min(r.width(),r.height()));const s=r.map(i);e.aa.fromPoints(n).covers(s)||(n=n.map(t=>t.x>.5?new e.a9(t.x-1,t.y,t.z):t))}return n}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map(t=>this._inViewTiles.getTileById(t).tileID);return this.transform&&this.transform.populateCache(e),e}hasTransition(){return!!this._source.hasTransition()||!(!At(this._source.type)||!function(t,e){if(e<=0)return!1;const i=c();for(const e of t.getAllTiles())if(e.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,i,r){this._state.updateState(t=t||e.ai,i,r)}removeFeatureState(t,i,r){this._state.removeFeatureState(t=t||e.ai,i,r)}getFeatureState(t,i){return this._state.getState(t=t||e.ai,i)}setDependencies(t,e,i){const r=this._inViewTiles.getTileById(t);r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(t,e)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(t,e))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}}Lt.maxUnderzooming=10,Lt.maxOverzooming=3;class Ft{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.an(t,0,1);let i=1,r=this._distances[i];const n=t*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const s=i-1,o=this._distances[s],a=r-o,l=a>0?(n-o)/a:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}function Bt(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class Ot{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,s){this.boxCells[n].push(s)}_insertCircleCell(t,e,i,r,n,s){this.circleCells[n].push(s)}_query(t,e,i,r,n,s,o){if(i<0||t>this.width||r<0||e>this.height)return[];const a=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)a.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];a.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,a,{hitTest:n,overlapMode:s,seenUids:{box:{},circle:{}}},o);return a}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,n,s){return this._query(t,e,i,r,!0,n,s).length>0}hitTestCircle(t,e,i,r,n){const s=t-i,o=t+i,a=e-i,l=e+i;if(o<0||s>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(s,a,o,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(t,e,i,r,n,s,o,a){const{seenUids:l,hitTest:c,overlapMode:h}=o,u=this.boxCells[n];if(null!==u){const n=this.bboxes;for(const o of u)if(!l.box[o]){l.box[o]=!0;const u=4*o,p=this.boxKeys[o];if(t<=n[u+2]&&e<=n[u+3]&&i>=n[u+0]&&r>=n[u+1]&&(!a||a(p))&&(!c||!Bt(h,p.overlapMode))&&(s.push({key:p,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const p=this.circleCells[n];if(null!==p){const n=this.circles;for(const o of p)if(!l.circle[o]){l.circle[o]=!0;const u=3*o,p=this.circleKeys[o];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],t,e,i,r)&&(!a||a(p))&&(!c||!Bt(h,p.overlapMode))){const t=n[u],e=n[u+1],i=n[u+2];if(s.push({key:p,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,n,s,o,a){const{circle:l,seenUids:c,overlapMode:h}=o,u=this.boxCells[n];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(r))&&!Bt(h,r.overlapMode))return s.push(!0),!0}}const p=this.circleCells[n];if(null!==p){const t=this.circles;for(const e of p)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!Bt(h,r.overlapMode))return s.push(!0),!0}}}_forEachCell(t,e,i,r,n,s,o,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+p,s,o,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,n,s){const o=r-t,a=n-e,l=i+s;return l*l>o*o+a*a}_circleAndRectCollide(t,e,i,r,n,s,o){const a=(s-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(o-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,p=h-c;return u*u+p*p<=i*i}}function Nt(t,i,n){const s=e.N();if(!t){const{vecSouth:t,vecEast:e}=jt(i),n=r();n[0]=e[0],n[1]=e[1],n[2]=t[0],n[3]=t[1],o=n,(p=(l=(a=n)[0])*(u=a[3])-(h=a[2])*(c=a[1]))&&(o[0]=u*(p=1/p),o[1]=-c*p,o[2]=-h*p,o[3]=l*p),s[0]=n[0],s[1]=n[1],s[4]=n[2],s[5]=n[3]}var o,a,l,c,h,u,p;return e.Q(s,s,[1/n,1/n,1]),s}function Vt(t,i,r,n){if(t){const t=e.N();if(!i){const{vecSouth:e,vecEast:i}=jt(r);t[0]=i[0],t[1]=i[1],t[4]=e[0],t[5]=e[1]}return e.Q(t,t,[n,n,1]),t}return r.pixelsToClipSpaceMatrix}function jt(t){const i=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),n=Math.cos(t.pitchInRadians),s=Math.cos(t.bearingInRadians),o=Math.sin(t.bearingInRadians),a=e.aC();a[0]=-s*n*r-o*i,a[1]=-o*n*r+s*i;const l=e.aD(a);l<1e-9?e.aE(a):e.aF(a,a,1/l);const c=e.aC();c[0]=s*n*i-o*r,c[1]=o*n*i+s*r;const h=e.aD(c);return h<1e-9?e.aE(c):e.aF(c,c,1/h),{vecEast:c,vecSouth:a}}function qt(t,i,r,n){let s;n?(s=[t,i,n(t,i),1],e.aH(s,s,r)):(s=[t,i,0,1],se(s,s,r));const o=s[3];return{point:new e.P(s[0]/o,s[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}function Gt(t,e){return.5+t/e*.5}function Ut(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function $t(t,i,r,n,s,o,a,l,c,h,u,p,d){const f=r?t.textSizeData:t.iconSizeData,m=e.ay(f,i.transform.zoom),_=[256/i.width*2+1,256/i.height*2+1],g=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();const y=t.lineVertexArray,v=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=i.transform.width/i.transform.height;let b=!1;for(let r=0;r<v.length;r++){const w=v.get(r);if(w.hidden||w.writingMode===e.az.vertical&&!b){ne(w.numGlyphs,g);continue}b=!1;const S=new e.P(w.anchorX,w.anchorY),T={getElevation:d,pitchedLabelPlaneMatrix:n,lineVertexArray:y,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:S,unwrappedTileID:c,width:h,height:u,translation:p},C=Qt(w.anchorX,w.anchorY,T);if(!Ut(C.point,_)){ne(w.numGlyphs,g);continue}const M=Gt(i.transform.cameraToCenterDistance,C.signedDistanceFromCamera),E=e.aA(f,m,w),A=o?E*i.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,c)/M:E*M,I=Ht({projectionContext:T,pitchedLabelPlaneMatrixInverse:s,symbol:w,fontSize:A,flip:!1,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:l});b=I.useVertical,(I.notEnoughRoom||b||I.needsFlipping&&Ht({projectionContext:T,pitchedLabelPlaneMatrixInverse:s,symbol:w,fontSize:A,flip:!0,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:x,rotateToLine:l}).notEnoughRoom)&&ne(w.numGlyphs,g)}r?t.text.dynamicLayoutVertexBuffer.updateData(g):t.icon.dynamicLayoutVertexBuffer.updateData(g)}function Zt(t,e,i,r,n,s,o,a){const l=s.glyphStartIndex+s.numGlyphs,c=s.lineStartIndex,h=s.lineStartIndex+s.lineLength,u=e.getoffsetX(s.glyphStartIndex),p=e.getoffsetX(l-1),d=ie(t*u,i,r,n,s.segment,c,h,a,o);if(!d)return null;const f=ie(t*p,i,r,n,s.segment,c,h,a,o);return f?a.projectionCache.anyProjectionOccluded?null:{first:d,last:f}:null}function Wt(t,i,r,n){return t===e.az.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:(t===e.az.vertical?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function Ht(t){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:s,flip:o,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=t,p=s/24,d=n.lineOffsetX*p,f=n.lineOffsetY*p;let m;if(n.numGlyphs>1){const t=n.glyphStartIndex+n.numGlyphs,e=n.lineStartIndex,s=n.lineStartIndex+n.lineLength,c=Zt(p,l,d,f,o,n,u,i);if(!c)return{notEnoughRoom:!0};const _=Jt(c.first.point.x,c.first.point.y,i,r),g=Jt(c.last.point.x,c.last.point.y,i,r);if(a&&!o){const t=Wt(n.writingMode,_,g,h);if(t)return t}m=[c.first];for(let r=n.glyphStartIndex+1;r<t-1;r++){const t=ie(p*l.getoffsetX(r),d,f,o,n.segment,e,s,i,u);if(!t)return{notEnoughRoom:!0};m.push(t)}m.push(c.last)}else{if(a&&!o){const t=Kt(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,s=n.lineStartIndex+n.segment+1,o=new e.P(i.lineVertexArray.getx(s),i.lineVertexArray.gety(s)),a=Kt(o.x,o.y,i),l=a.signedDistanceFromCamera>0?a.point:Xt(i.tileAnchorPoint,o,t,1,i),c=Jt(t.x,t.y,i,r),u=Jt(l.x,l.y,i,r),p=Wt(n.writingMode,c,u,h);if(p)return p}const t=ie(p*l.getoffsetX(n.glyphStartIndex),d,f,o,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,u);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[t]}for(const t of m)e.aG(c,t.point,t.angle);return{}}function Xt(t,e,i,r,n){const s=t.add(t.sub(e)._unit()),o=Kt(s.x,s.y,n).point,a=i.sub(o);return i.add(a._mult(r/a.mag()))}function Yt(t,i,r){const n=i.projectionCache;if(n.projections[t])return n.projections[t];const s=new e.P(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),o=Kt(s.x,s.y,i);if(o.signedDistanceFromCamera>0)return n.projections[t]=o.point,n.anyProjectionOccluded=n.anyProjectionOccluded||o.isOccluded,o.point;const a=t-r.direction;return Xt(0===r.distanceFromAnchor?i.tileAnchorPoint:new e.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),s,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Kt(t,e,i){const r=t+i.translation[0],n=e+i.translation[1];let s;return i.pitchWithMap?(s=qt(r,n,i.pitchedLabelPlaneMatrix,i.getElevation),s.isOccluded=!1):(s=i.transform.projectTileCoordinates(r,n,i.unwrappedTileID,i.getElevation),s.point.x=(.5*s.point.x+.5)*i.width,s.point.y=(.5*-s.point.y+.5)*i.height),s}function Jt(t,i,r,n){if(r.pitchWithMap){const s=[t,i,0,1];return e.aH(s,s,n),r.transform.projectTileCoordinates(s[0]/s[3],s[1]/s[3],r.unwrappedTileID,r.getElevation).point}return{x:t/r.width*2-1,y:1-i/r.height*2}}function Qt(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,i.getElevation)}function te(t,e,i){return t._unit()._perp()._mult(e*i)}function ee(t,i,r,n,s,o,a,l,c){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const h=r.add(i);if(t+c.direction<n||t+c.direction>=s)return l.projectionCache.offsets[t]=h,h;const u=Yt(t+c.direction,l,c),p=te(u.sub(r),a,c.direction),d=r.add(p),f=u.add(p);return l.projectionCache.offsets[t]=e.aI(o,h,d,f)||h,l.projectionCache.offsets[t]}function ie(t,e,i,r,n,s,o,a,l){const c=r?t-e:t+e;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let p,d=h>0?s+n:s+n+1;a.projectionCache.cachedAnchorPoint?p=a.projectionCache.cachedAnchorPoint:(p=Kt(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=p);let f,m,_=p,g=p,y=0,v=0;const x=Math.abs(c),b=[];let w;for(;y+v<=x;){if(d+=h,d<s||d>=o)return null;y+=v,g=_,m=f;const t={absOffsetX:x,direction:h,distanceFromAnchor:y,previousVertex:g};if(_=Yt(d,a,t),0===i)b.push(g),w=_.sub(g);else{let e;const r=_.sub(g);e=0===r.mag()?te(Yt(d+h,a,t).sub(_),i,h):te(r,i,h),m||(m=g.add(e)),f=ee(d,e,_,s,o,m,i,a,t),b.push(m),w=f.sub(m)}v=w.mag()}const S=w._mult((x-y)/v)._add(m||g),T=u+Math.atan2(_.y-g.y,_.x-g.x);return b.push(S),{point:S,angle:l?T:0,path:b}}const re=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ne(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(re,3*t)}}function se(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const oe=100;class ae{constructor(t,e=new Ot(t.width+200,t.height+200,25),i=new Ot(t.width+200,t.height+200,25)){this.transform=t,this.grid=e,this.ignoredGrid=i,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+oe,this.screenBottomBoundary=t.height+oe,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,r,n,s,o,a,l,c,h,u){const p=this.projectAndGetPerspectiveRatio(t.anchorPointX+a[0],t.anchorPointY+a[1],n,c,u),d=i*p.perspectiveRatio;let f;if(s||o)f=this._projectCollisionBox(t,d,r,n,s,o,a,p,c,h,u);else{const e=p.x+(h?h.x*d:0),i=p.y+(h?h.y*d:0);f={allPointsOccluded:!1,box:[e+t.x1*d,i+t.y1*d,e+t.x2*d,i+t.y2*d]}}const[m,_,g,y]=f.box,v=s?f.allPointsOccluded:p.isOccluded;let x=v;return x||(x=p.perspectiveRatio<this.perspectiveRatioCutoff),x||(x=!this.isInsideGrid(m,_,g,y)),x||"always"!==e&&this.grid.hitTest(m,_,g,y,e,l)?{box:[m,_,g,y],placeable:!1,offscreen:!1,occluded:v}:{box:[m,_,g,y],placeable:!0,offscreen:this.isOffscreen(m,_,g,y),occluded:v}}placeCollisionCircles(t,i,r,n,s,o,a,l,c,h,u,p,d,f){const m=[],_=new e.P(i.anchorX,i.anchorY),g=this.getPerspectiveRatio(_.x,_.y,o,f),y=(c?s*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,o)/g:s*g)/e.aM,v={getElevation:f,pitchedLabelPlaneMatrix:a,lineVertexArray:r,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:_,unwrappedTileID:o,width:this.transform.width,height:this.transform.height,translation:d},x=Zt(y,n,i.lineOffsetX*y,i.lineOffsetY*y,!1,i,!1,v);let b=!1,w=!1,S=!0;if(x){const i=.5*u*g+p,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),s=new Ft,o=x.first,a=x.last;let d=[];for(let t=o.path.length-1;t>=1;t--)d.push(o.path[t]);for(let t=1;t<a.path.length;t++)d.push(a.path[t]);const f=2.5*i;if(c){const t=this.projectPathToScreenSpace(d,v);d=t.some(t=>t.signedDistanceFromCamera<=0)?[]:t.map(t=>t.point)}let _=[];if(d.length>0){const t=d[0].clone(),i=d[0].clone();for(let e=1;e<d.length;e++)t.x=Math.min(t.x,d[e].x),t.y=Math.min(t.y,d[e].y),i.x=Math.max(i.x,d[e].x),i.y=Math.max(i.y,d[e].y);_=t.x>=r.x&&i.x<=n.x&&t.y>=r.y&&i.y<=n.y?[d]:i.x<r.x||t.x>n.x||i.y<r.y||t.y>n.y?[]:e.aJ([d],r.x,r.y,n.x,n.y)}for(const e of _){s.reset(e,.25*i);let r=0;r=s.length<=.5*i?1:Math.ceil(s.paddedLength/f)+1;for(let e=0;e<r;e++){const n=e/Math.max(r-1,1),o=s.lerp(n),a=o.x+oe,c=o.y+oe;m.push(a,c,i,0);const u=a-i,p=c-i,d=a+i,f=c+i;if(S=S&&this.isOffscreen(u,p,d,f),w=w||this.isInsideGrid(u,p,d,f),"always"!==t&&this.grid.hitTestCircle(a,c,i,t,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||g<this.perspectiveRatioCutoff?[]:m,offscreen:S,collisionDetected:b}}projectPathToScreenSpace(t,i){const r=function(t,i){const r=e.N();return e.aB(r,i.pitchedLabelPlaneMatrix),t.map(t=>{const e=qt(t.x,t.y,r,i.getElevation),n=i.transform.projectTileCoordinates(e.point.x,e.point.y,i.unwrappedTileID,i.getElevation);return n.point.x=(.5*n.point.x+.5)*i.width,n.point.y=(.5*-n.point.y+.5)*i.height,n})}(t,i);return function(t){let e=0,i=0,r=0,n=0;for(let s=0;s<t.length;s++)t[s].isOccluded?(r=s+1,n=0):(n++,n>i&&(i=n,e=r));return t.slice(e,e+i)}(r)}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],r=new e.aa;for(const n of t){const t=new e.P(n.x+oe,n.y+oe);r.extend(t),i.push(t)}const{minX:n,minY:s,maxX:o,maxY:a}=r,l=this.grid.query(n,s,o,a).concat(this.ignoredGrid.query(n,s,o,a)),c={},h={};for(const t of l){const r=t.key;if(void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]={}),c[r.bucketInstanceId][r.featureIndex])continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.aK(i,n)&&(c[r.bucketInstanceId][r.featureIndex]=!0,void 0===h[r.bucketInstanceId]&&(h[r.bucketInstanceId]=[]),h[r.bucketInstanceId].push(r.featureIndex))}return h}insertCollisionBox(t,e,i,r,n,s){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:s,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n,s){const o=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:s,overlapMode:e};for(let e=0;e<t.length;e+=4)o.insertCircle(a,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,i,r,n,s){if(s){let r;n?(r=[t,i,n(t,i),1],e.aH(r,r,s)):(r=[t,i,0,1],se(r,r,s));const o=r[3];return{x:(r[0]/o+1)/2*this.transform.width+oe,y:(-r[1]/o+1)/2*this.transform.height+oe,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{const e=this.transform.projectTileCoordinates(t,i,r,n);return{x:(e.point.x+1)/2*this.transform.width+oe,y:(1-e.point.y)/2*this.transform.height+oe,perspectiveRatio:.5+this.transform.cameraToCenterDistance/e.signedDistanceFromCamera*.5,isOccluded:e.isOccluded,signedDistanceFromCamera:e.signedDistanceFromCamera}}}getPerspectiveRatio(t,e,i,r){const n=this.transform.projectTileCoordinates(t,e,i,r);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(t,e,i,r){return i<oe||t>=this.screenRightBoundary||r<oe||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=e.ar([]);return e.O(t,t,[-100,-100,0]),t}_projectCollisionBox(t,i,r,n,s,o,a,l,c,h,u){let p=1,d=0,f=0,m=1;const _=t.anchorPointX+a[0],g=t.anchorPointY+a[1];if(o&&!s){const t=this.projectAndGetPerspectiveRatio(_+1,g,n,c,u),e=t.x-l.x,i=Math.atan((t.y-l.y)/e)+(e<0?Math.PI:0),r=Math.sin(i),s=Math.cos(i);p=s,d=r,f=-r,m=s}else if(!o&&s){const t=jt(this.transform);p=t.vecEast[0],d=t.vecEast[1],f=t.vecSouth[0],m=t.vecSouth[1]}let y=l.x,v=l.y,x=i;s&&(y=_,v=g,x=Math.pow(2,-(this.transform.zoom-r.overscaledZ)),x*=this.transform.getPitchedTextCorrection(_,g,n),h||(x*=e.an(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),h&&(y+=p*h.x*x+f*h.y*x,v+=d*h.x*x+m*h.y*x);const b=t.x1*x,w=t.x2*x,S=(b+w)/2,T=t.y1*x,C=t.y2*x,M=(T+C)/2,E=[{offsetX:b,offsetY:T},{offsetX:S,offsetY:T},{offsetX:w,offsetY:T},{offsetX:w,offsetY:M},{offsetX:w,offsetY:C},{offsetX:S,offsetY:C},{offsetX:b,offsetY:C},{offsetX:b,offsetY:M}];let A=[];for(const{offsetX:t,offsetY:i}of E)A.push(new e.P(y+p*t+f*i,v+d*t+m*i));let I=!1;if(s){const t=A.map(t=>this.projectAndGetPerspectiveRatio(t.x,t.y,n,c,u));I=t.some(t=>!t.isOccluded),A=t.map(t=>new e.P(t.x,t.y))}else I=!0;return{box:e.aL(A),allPointsOccluded:!I}}}class le{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class ce{constructor(t,e,i,r,n){this.text=new le(t?t.text:null,e,i,n),this.icon=new le(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class he{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class ue{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class pe{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function de(t,i,r,n,s){const{horizontalAlign:o,verticalAlign:a}=e.aS(t);return new e.P(-(o-.5)*i+n[0]*s,-(a-.5)*r+n[1]*s)}class fe{constructor(t,e,i,r,n){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new ae(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new pe(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(i,r)=>e.getElevation(t,i,r):null}getBucketParts(t,i,r,n){const s=r.getBucket(i),o=r.latestFeatureIndex;if(!s||!o||i.id!==s.layerIds[0])return;const a=r.collisionBoxArray,l=s.layers[0].layout,c=s.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/e.a5,p=r.tileID.toUnwrapped(),d="map"===l.get("text-rotation-alignment"),f=e.aN(r,1,this.transform.zoom),m=e.aO(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),_=e.aO(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=Nt(d,this.transform,f);this.retainedQueryData[s.bucketInstanceId]=new ue(s.bucketInstanceId,o,s.sourceLayerIndex,s.index,r.tileID);const y={bucket:s,layout:l,translationText:m,translationIcon:_,unwrappedTileID:p,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:e.ay(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(n)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:y})}attemptAnchorPlacement(t,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,v,x){const b=e.aP[t.textAnchor],w=[t.textOffset0,t.textOffset1],S=de(b,r,n,w,s),T=this.collisionIndex.placeCollisionBox(i,p,l,c,h,a,o,_,u.predicate,v,S,x);if((!y||this.collisionIndex.placeCollisionBox(y,p,l,c,h,a,o,g,u.predicate,v,S,x).placeable)&&T.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[d.crossTileID]&&this.prevPlacement.placements[d.crossTileID]&&this.prevPlacement.placements[d.crossTileID].text&&(t=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:w,width:r,height:n,anchor:b,textBoxScale:s,prevAnchor:t},this.markUsedJustification(f,b,d,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,d),this.placedOrientations[d.crossTileID]=m),{shift:S,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,r){const{bucket:n,layout:s,translationText:o,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:p,partiallyEvaluatedTextSize:d,collisionGroup:f}=t.parameters,m=s.get("text-optional"),_=s.get("icon-optional"),g=e.aQ(s,"text-overlap","text-allow-overlap"),y="always"===g,v=e.aQ(s,"icon-overlap","icon-allow-overlap"),x="always"===v,b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),S="none"!==s.get("icon-text-fit"),T="viewport-y"===s.get("symbol-z-order"),C=y&&(x||!n.hasIconData()||_),M=x&&(y||!n.hasTextData()||m);!n.collisionArrays&&p&&n.deserializeCollisionBoxes(p);const E=this.retainedQueryData[n.bucketInstanceId].tileID,A=this._getTerrainElevationFunc(E),I=this.transform.getFastPathSimpleProjectionMatrix(E),P=(t,p,x)=>{var T,P;if(i[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new he(!1,!1,!1));let D=!1,k=!1,z=!0,R=null,L={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,N=null,V=0,j=0,q=0;p.textFeatureIndex?V=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(V=t.featureIndex),p.verticalTextFeatureIndex&&(j=p.verticalTextFeatureIndex);const G=p.textBox;if(G){const i=i=>{let r=e.az.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,r=e,this.markUsedOrientation(n,r,t))}return r},s=(i,r)=>{if(n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&p.verticalTextBox){for(const t of n.writingModes)if(t===e.az.vertical?(L=r(),F=L):L=i(),L&&L.placeable)break}else L=i()},c=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===c){const r=(e,i)=>{const r=this.collisionIndex.placeCollisionBox(e,g,h,E,l,w,b,o,f.predicate,A,void 0,I);return r&&r.placeable&&(this.markUsedOrientation(n,i,t),this.placedOrientations[t.crossTileID]=i),r};s(()=>r(G,e.az.horizontal),()=>{const i=p.verticalTextBox;return n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?r(i,e.az.vertical):{box:null,offscreen:null}}),i(L&&L.placeable)}else{let d=e.aP[null===(P=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[t.crossTileID])||void 0===P?void 0:P.anchor];const m=(e,i,s)=>{const p=e.x2-e.x1,m=e.y2-e.y1,_=t.textBoxScale,y=S&&"never"===v?i:null;let x=null,T="never"===g?1:2,C="never";d&&T++;for(let i=0;i<T;i++){for(let i=c;i<u;i++){const r=n.textAnchorOffsets.get(i);if(d&&r.textAnchor!==d)continue;const c=this.attemptAnchorPlacement(r,e,p,m,_,b,w,h,E,l,f,C,t,n,s,o,a,y,A);if(c&&(x=c.placedGlyphBoxes,x&&x.placeable))return D=!0,R=c.shift,x}d?d=null:C=g}return r&&!x&&(x={box:this.collisionIndex.placeCollisionBox(G,"always",h,E,l,w,b,o,f.predicate,A,void 0,I).box,offscreen:!1,placeable:!1,occluded:!1}),x};s(()=>m(G,p.iconBox,e.az.horizontal),()=>{const i=p.verticalTextBox;return n.allowVerticalPlacement&&(!L||!L.placeable)&&t.numVerticalGlyphVertices>0&&i?m(i,p.verticalIconBox,e.az.vertical):{box:null,occluded:!0,offscreen:null}}),L&&(D=L.placeable,z=L.offscreen);const _=i(L&&L.placeable);if(!D&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(n,e.anchor,t,_))}}}if(B=L,D=B&&B.placeable,z=B&&B.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){const i=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),a=e.aA(n.textSizeData,d,i),h=s.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,n.lineVertexArray,n.glyphOffsetArray,a,l,c,r,w,f.predicate,t.collisionCircleDiameter,h,o,A),O.circles.length&&O.collisionDetected&&!r&&e.w("Collisions detected, but collision boxes are not shown"),D=y||O.circles.length>0&&!O.collisionDetected,z=z&&O.offscreen}if(p.iconFeatureIndex&&(q=p.iconFeatureIndex),p.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,v,h,E,l,w,b,a,f.predicate,A,S&&R?R:void 0,I);F&&F.placeable&&p.verticalIconBox?(N=t(p.verticalIconBox),k=N.placeable):(N=t(p.iconBox),k=N.placeable),z=z&&N.offscreen}const U=m||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,$=_||0===t.numIconVertices;U||$?$?U||(k=k&&D):D=k&&D:k=D=k&&D;const Z=k&&N.placeable;if(D&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,s.get("text-ignore-placement"),n.bucketInstanceId,F&&F.placeable&&j?j:V,f.ID),Z&&this.collisionIndex.insertCollisionBox(N.box,v,s.get("icon-ignore-placement"),n.bucketInstanceId,q,f.ID),O&&D&&this.collisionIndex.insertCollisionCircles(O.circles,g,s.get("text-ignore-placement"),n.bucketInstanceId,V,f.ID),r&&this.storeCollisionData(n.bucketInstanceId,x,p,B,N,O),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===n.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new he((D||C)&&!(null==B?void 0:B.occluded),(k||M)&&!(null==N?void 0:N.occluded),z||n.justReloaded),i[t.crossTileID]=!0};if(T){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=n.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=e.length-1;t>=0;--t){const i=e[t];P(n.symbolInstances.get(i),n.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)P(n.symbolInstances.get(e),n.collisionArrays[e],e);n.justReloaded=!1}storeCollisionData(t,e,i,r,n,s){if(i.textBox||i.iconBox){let s,o;this.collisionBoxArrays.has(t)?s=this.collisionBoxArrays.get(t):(s=new Map,this.collisionBoxArrays.set(t,s)),s.has(e)?o=s.get(e):(o={text:null,icon:null},s.set(e,o)),i.textBox&&(o.text=r.box),i.iconBox&&(o.icon=n.box)}if(s){let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=[]);for(let t=0;t<s.circles.length;t+=4)e.push(s.circles[t+0]-oe),e.push(s.circles[t+1]-oe),e.push(s.circles[t+2]),e.push(s.collisionDetected?1:0)}}markUsedJustification(t,i,r,n){let s;s=n===e.az.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[e.aR(i)];const o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const e of o)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=s>=0&&e!==s?0:r.crossTileID)}markUsedOrientation(t,i,r){const n=i===e.az.horizontal||i===e.az.horizontalOnly?i:0,s=i===e.az.vertical?i:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const e of o)t.text.placedSymbolArray.get(e).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=s)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},s=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],s=n[t];s?(this.opacities[t]=new ce(s,r,e.text,e.icon),i=i||e.text!==s.text.placed||e.icon!==s.icon.placed):(this.opacities[t]=new ce(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new ce(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in s)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=s[t]);for(const t in o)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=o[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(t,i,r,n){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const s=t.layers[0],o=s.layout,a=new ce(null,0,!1,!1,!0),l=o.get("text-allow-overlap"),c=o.get("icon-allow-overlap"),h=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===o.get("text-rotation-alignment"),p="map"===o.get("text-pitch-alignment"),d="none"!==o.get("icon-text-fit"),f=new ce(null,0,l&&(c||!t.hasIconData()||o.get("icon-optional")),c&&(l||!t.hasTextData()||o.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const m=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i);t.hasVisibleVertices=t.hasVisibleVertices||i!==Te},_=this.collisionBoxArrays.get(t.bucketInstanceId);for(let i=0;i<t.symbolInstances.length;i++){const n=t.symbolInstances.get(i),{numHorizontalGlyphVertices:s,numVerticalGlyphVertices:o,crossTileID:l}=n;let c=this.opacities[l];r[l]?c=a:c||(c=f,this.opacities[l]=c),r[l]=!0;const g=n.numIconVertices>0,y=this.placedOrientations[n.crossTileID],v=y===e.az.vertical,x=y===e.az.horizontal||y===e.az.horizontalOnly;if(s>0||o>0){const e=Se(c.text);m(t.text,s,v?Te:e),m(t.text,o,x?Te:e);const i=c.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach(e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||v?1:0)}),n.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(t,r.anchor,n,y);const a=this.placedOrientations[n.crossTileID];a&&(this.markUsedJustification(t,"left",n,a),this.markUsedOrientation(t,a,n))}if(g){const e=Se(c.icon),i=!(d&&n.verticalPlacedIconSymbolIndex&&v);n.placedIconSymbolIndex>=0&&(m(t.icon,n.numIconVertices,i?e:Te),t.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=c.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,n.numVerticalIconVertices,i?Te:e),t.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const b=_&&_.has(i)?_.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.P(0,0);if(r.textBox||r.verticalTextBox){let e=!0;if(h){const t=this.variableOffsets[l];t?(i=de(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(p?-this.transform.bearingInRadians:this.transform.bearingInRadians)):e=!1}if(r.textBox||r.verticalTextBox){let n;r.textBox&&(n=v),r.verticalTextBox&&(n=x),me(t.textCollisionBox.collisionVertexArray,c.text.placed,!e||n,b.text,i.x,i.y)}}if(r.iconBox||r.verticalIconBox){const e=Boolean(!x&&r.verticalIconBox);let n;r.iconBox&&(n=e),r.verticalIconBox&&(n=!e),me(t.iconCollisionBox.collisionVertexArray,c.icon.placed,n,b.icon,d?i.x:0,d?i.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function me(t,e,i,r,n,s){r&&0!==r.length||(r=[0,0,0,0]);const o=r[0]-oe,a=r[1]-oe,l=r[2]-oe,c=r[3]-oe;t.emplaceBack(e?1:0,i?1:0,n||0,s||0,o,a),t.emplaceBack(e?1:0,i?1:0,n||0,s||0,l,a),t.emplaceBack(e?1:0,i?1:0,n||0,s||0,l,c),t.emplaceBack(e?1:0,i?1:0,n||0,s||0,o,c)}const _e=Math.pow(2,25),ge=Math.pow(2,24),ye=Math.pow(2,17),ve=Math.pow(2,16),xe=Math.pow(2,9),be=Math.pow(2,8),we=Math.pow(2,1);function Se(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*_e+e*ge+i*ye+e*ve+i*xe+e*be+i*we+e}const Te=0;class Ce{constructor(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=[]}continuePlacement(t,e,i,r,n){const s=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(s,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort((t,e)=>t.sortKey-e.sortKey));this._currentPartIndex<s.length;)if(e.placeLayerBucketPart(s[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}}class Me{constructor(t,e,i,r,n,s,o,a){this.placement=new fe(t,e,s,o,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=c(),n=()=>!this._forceFullPlacement&&c()-r>2;for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new Ce(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Ee=512/e.a5/2;class Ae{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};const n=new Map;for(let t=0;t<i.length;t++){const e=i.get(t),r=e.key,s=n.get(r);s?s.push(e):n.set(r,[e])}for(const[t,i]of n){const r={positions:i.map(t=>({x:Math.floor(t.anchorX*Ee),y:Math.floor(t.anchorY*Ee)})),crossTileIDs:i.map(t=>t.crossTileID)};if(r.positions.length>128){const t=new e.aT(r.positions.length,16,Uint16Array);for(const{x:e,y:i}of r.positions)t.add(e,i);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,i){const{x:r,y:n,z:s}=this.tileID.canonical,{x:o,y:a,z:l}=i.canonical,c=Ee/Math.pow(2,l-s),h=(a*e.a5+t.anchorY)*c,u=n*e.a5*Ee;return{x:Math.floor((o*e.a5+t.anchorX)*c-r*e.a5*Ee),y:Math.floor(h-u)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const s=t.get(n);if(s.crossTileID)continue;const o=this._symbolsByKey[s.key];if(!o)continue;const a=this.getScaledCoordinates(s,e);if(o.index){const t=o.index.range(a.x-r,a.y-r,a.x+r,a.y+r).sort();for(const e of t){const t=o.crossTileIDs[e];if(!i[t]){i[t]=!0,s.crossTileID=t;break}}}else if(o.positions)for(let t=0;t<o.positions.length;t++){const e=o.positions[t],n=o.crossTileIDs[t];if(Math.abs(e.x-a.x)<=r&&Math.abs(e.y-a.y)<=r&&!i[n]){i[n]=!0,s.crossTileID=n;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:t})=>t)}}class Ie{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Pe{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const s=n[i];s.tileID.isChildOf(t)&&s.findMatches(e.symbolInstances,t,r)}else{const s=n[t.scaledTo(Number(i)).key];s&&s.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ae(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i of e.getCrossTileIDsLists())for(const e of i)delete this.usedCrossTileIDs[t][e]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class De{constructor(){this.layerIndexes={},this.crossTileIDs=new Ie,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Pe);let n=!1;const s={};r.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(n=!0),s[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(s)&&(n=!0),n}pruneUnusedLayers(t){const e={};t.forEach(t=>{e[t]=!0});for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}var ke="void main() {fragColor=vec4(1.0);}";const ze={prelude:Re("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Re("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Re("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Re("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Re("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Re("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Re(ke,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Re("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Re("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Re("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Re("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {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;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Re("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Re("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Re(ke,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Re("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Re("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Re("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Re("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out 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=projectTile(a_pos+u_fill_translate,a_pos);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);}"),fillExtrusion:Re("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout 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;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat 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;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=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;}"),fillExtrusionPattern:Re("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out 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;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*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;}"),hillshadePrepare:Re("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;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))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out 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;}"),hillshade:Re("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Re("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Re("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\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=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Re("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Re("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\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\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\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\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\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\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Re("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\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\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\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\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\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\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_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;float texel_height=1.0/u_image_height;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Re("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in 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=texture(u_image0,v_pos0);vec4 color1=texture(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Re("uniform sampler2D u_texture;in vec2 v_tex;in 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;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;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;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Re("#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;in vec2 v_data0;in 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 inner_edge=(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);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;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_translation;uniform float u_pitched_scale;out vec2 v_data0;out 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Re("#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;in vec4 v_data0;in 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;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in 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_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;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out 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;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,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);}"),terrain:Re("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Re("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Re("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Re("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Re("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Re("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Re(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/in ([\w]+) ([\w]+)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=s?s.concat(n):n,a={};return{fragmentSource:t=t.replace(i,(t,e,i,r,n)=>(a[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`)),vertexSource:e=e.replace(i,(t,e,i,r,n)=>{const s="float"===r?"vec2":"vec4",o=n.match(/color/)?"color":s;return a[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`}),staticAttributes:r,staticUniforms:o}}class Le{constructor(t,e,i){this.vertexBuffer=t,this.indexBuffer=e,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Fe=e.aU([{name:"a_pos",type:"Int16",components:2}]);const Be="#define PROJECTION_MERCATOR",Oe="mercator";class Ne{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Oe}get shaderDefine(){return Be}get shaderPreludeCode(){return ze.projectionMercator}get vertexShaderPreludeCode(){return ze.projectionMercator.vertexSource}get subdivisionGranularity(){return e.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,i,r,n,s){if(this._cachedMesh)return this._cachedMesh;const o=new e.aW;o.emplaceBack(0,0),o.emplaceBack(e.a5,0),o.emplaceBack(0,e.a5),o.emplaceBack(e.a5,e.a5);const a=t.createVertexBuffer(o,Fe.members),l=e.aX.simpleSegment(0,0,4,2),c=new e.aY;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=t.createIndexBuffer(c);return this._cachedMesh=new Le(a,h,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Ve{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<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=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.G.number(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.G.number(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.G.number(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.G.number(t.right,i.right,r)),this}getCenter(t,i){const r=e.an((this.left+t-this.right)/2,0,t),n=e.an((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Ve(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function je(t,e){if(!t.renderWorldCopies||t.lngRange)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}function qe(t){return Math.max(0,Math.floor(t))}class Ge{constructor(t,i){var r;this.applyConstrain=(t,e)=>null!==this._constrainOverride?this._constrainOverride(t,e):this._callbacks.defaultConstrain(t,e),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(r=null==i?void 0:i.constrainOverride)&&void 0!==r?r:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new e.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=qe(this._zoom),this._scale=e.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ve,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,i,r){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=qe(this._zoom),this._scale=e.aq(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new Ve(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!r&&t.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){void 0===t&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const i=e.W(t,-180,180)*Math.PI/180;var n,s,o,a,l,c,h,u,p;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),n=this._rotationMatrix,o=-this._bearingInRadians,a=(s=this._rotationMatrix)[0],l=s[1],c=s[2],h=s[3],u=Math.sin(o),p=Math.cos(o),n[0]=a*p+c*u,n[1]=l*p+h*u,n[2]=a*-u+c*p,n[3]=l*-u+h*p)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const i=e.an(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const e=t/180*Math.PI;this._rollInRadians!==e&&(this._unmodified=!1,this._rollInRadians=e,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return e.aZ(this._fovInRadians)}setFov(t){t=e.an(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=e.ap(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const i=this.applyConstrain(this._center,t).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=e.aq(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,e){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=e,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this.constrainInternal(),this._calcMatrices()}resize(t,e,i=!0){this._width=t,this._height=e,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new W([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-e.ao,e.ao])}getCameraQueryGeometry(t,i){if(1===i.length)return[i[0],t];{const{minX:r,minY:n,maxX:s,maxY:o}=e.aa.fromPoints(i).extend(t);return[new e.P(r,n),new e.P(s,n),new e.P(s,o),new e.P(r,o),new e.P(r,n)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(e),this.setZoom(i),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=e.ar(new Float64Array(16));e.Q(t,t,[this._width/2,-this._height/2,1]),e.O(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=e.ar(new Float64Array(16)),e.Q(t,t,[1,-1,1]),e.O(t,t,[-1,-1,0]),e.Q(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,i,r,n){const s=void 0!==r?r:this.bearing,o=n=void 0!==n?n:this.pitch,{distanceToCenter:a,clampedElevation:l}=this._distanceToCenterFromAltElevationPitch(i,this.elevation,o),{x:c,y:h}=xt(o,s),u=e.a9.fromLngLat(t,i);let p,d,f=e.a_(1,u.y),m=0;do{if(m+=1,m>10)break;d=a/f,p=new e.a9(u.x+c*d,u.y+h*d),f=1/p.meterInMercatorCoordinateUnits()}while(Math.abs(a-d*f)>1e-12);return{center:p.toLngLat(),elevation:l,zoom:e.at(this.height/2/Math.tan(this.fovInRadians/2)/d/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const i=1/this.worldSize,r=e.as(1,this.center.lat)*this.worldSize,n=e.a9.fromLngLat(this.center,this.elevation),s=n.x/i,o=n.y/i,a=n.z/i,l=this.pitch,c=this.bearing,{x:h,y:u,z:p}=xt(l,c),d=this.cameraToCenterDistance,f=s+d*-h,m=o+d*-u,_=a+d*p,{distanceToCenter:g,clampedElevation:y}=this._distanceToCenterFromAltElevationPitch(_/r,t,l),v=g*r,x=new e.a9((f+h*v)*i,(m+u*v)*i,0).toLngLat(),b=e.as(1,x.lat),w=e.at(this.height/2/Math.tan(this.fovInRadians/2)/g/b/this.tileSize);this._elevation=y,this._center=x,this.setZoom(w)}_distanceToCenterFromAltElevationPitch(t,i,r){const n=-Math.cos(e.ap(r)),s=t-i;let o,a=i;return n*s>=0||Math.abs(n)<.1?(o=1e4,a=t+o*n):o=-s/n,{distanceToCenter:o,clampedElevation:a}}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=e.as(1,this.center.lat)*this.worldSize;return vt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const i=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/i,t.canonical.y/i,1/i/e.a5,1/i/e.a5]}}class Ue{constructor(t,i){this.min=t,this.max=i,this.center=e.a$([],e.b0([],this.min,this.max),.5)}quadrant(t){const i=[t%2==0,t<2],r=e.b1(this.min),n=e.b1(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],n[t]=i[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new Ue(r,n)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let e=!0;for(let i=0;i<t.planes.length;i++){const r=this.intersectsPlane(t.planes[i]);if(0===r)return 0;1===r&&(e=!1)}return e?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let e=t[3],i=t[3];for(let r=0;r<3;r++)t[r]>0?(e+=t[r]*this.min[r],i+=t[r]*this.max[r]):(i+=t[r]*this.min[r],e+=t[r]*this.max[r]);return e>=0?2:i<0?0:1}}class $e{distanceToTile2d(t,e,i,r){const n=r.distanceX([t,e]),s=r.distanceY([t,e]);return Math.hypot(n,s)}getWrap(t,e,i){return i}getTileBoundingVolume(t,i,r,n){var s,o;let a=0,l=0;if(null==n?void 0:n.terrain){const c=new e.a2(t.z,i,t.z,t.x,t.y),h=n.terrain.getMinMaxElevation(c);a=null!==(s=h.minElevation)&&void 0!==s?s:Math.min(0,r),l=null!==(o=h.maxElevation)&&void 0!==o?o:Math.max(0,r)}const c=1<<t.z;return new Ue([i+t.x/c,t.y/c,a],[i+(t.x+1)/c,(t.y+1)/c,l])}allowVariableZoom(t,i){const r=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,n=e.an(78.5-r/2,0,60);return!!i.terrain||t.pitch>n}allowWorldCopies(){return!0}prepareNextFrame(){}}class Ze{constructor(t,e,i){this.points=t,this.planes=e,this.aabb=i}static fromInvProjectionMatrix(t,i=1,r=0,n,s){const o=s?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,r),l=[[-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(r=>function(t,i,r,n){const s=e.aH([],t,i),o=1/s[3]/r*n;return e.b6(s,s,[o,o,1/s[3],o])}(r,t,i,a));n&&function(t,i,r,n){const s=n?4:0,o=n?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const r=e.b2([],t[i+o],t[i+s]),n=e.b7(r);e.a$(r,r,1/n),l.push(n),c.push(r)}for(let i=0;i<4;i++){const n=e.b8(t[i+s],c[i],r);a=null!==n&&n>=0?Math.max(a,n):Math.max(a,l[i])}const h=function(t,i){const r=e.b2([],t[i[0]],t[i[1]]),n=e.b2([],t[i[2]],t[i[1]]),s=[0,0,0,0];return e.b3(s,e.b4([],r,n)),s[3]=-e.b5(s,t[i[0]]),s}(t,i),u=function(t,i){const r=e.b9(t),n=e.ba([],t,1/r),s=e.b2([],i,e.a$([],n,e.b5(i,n))),o=e.b9(s);if(o>0){const t=Math.sqrt(1-n[3]*n[3]),r=e.a$([],n,-n[3]),a=e.b0([],r,e.a$([],s,t/o));return e.bb(i,a)}return null}(r,h);if(null!==u){const t=u/e.b5(c[0],h);a=Math.min(a,t)}for(let e=0;e<4;e++){const i=Math.min(a,l[e]);t[e+o]=[t[e+s][0]+c[e][0]*i,t[e+s][1]+c[e][1]*i,t[e+s][2]+c[e][2]*i,1]}}(l,o[0],n,s);const c=o.map(t=>{const i=e.b2([],l[t[0]],l[t[1]]),r=e.b2([],l[t[2]],l[t[1]]),n=e.b3([],e.b4([],i,r)),s=-e.b5(n,l[t[1]]);return n.concat(s)}),h=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],u=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const t of l)for(let e=0;e<3;e++)h[e]=Math.min(h[e],t[e]),u[e]=Math.max(u[e],t[e]);return new Ze(l,c,new Ue(h,u))}}class We{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t,e){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(t,i)=>{i=e.an(+i,this.minZoom,this.maxZoom);const r={center:new e.V(t.lng,t.lat),zoom:i};let n=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===n){const t=180-1e-10;n=[-t,t]}const s=this.tileSize*e.aq(r.zoom);let o=0,a=s,l=0,c=s,h=0,u=0;const{x:p,y:d}=this.size;if(this._helper._latRange){const t=this._helper._latRange;o=e.X(t[1])*s,a=e.X(t[0])*s,a-o<d&&(h=d/(a-o))}n&&(l=e.W(e.Y(n[0])*s,0,s),c=e.W(e.Y(n[1])*s,0,s),c<l&&(c+=s),c-l<p&&(u=p/(c-l)));const{x:f,y:m}=mt(s,t);let _,g;const y=Math.max(u||0,h||0);if(y){const t=new e.P(u?(c+l)/2:f,h?(a+o)/2:m);return r.center=_t(s,t).wrap(),r.zoom+=e.at(y),r}if(this._helper._latRange){const t=d/2;m-t<o&&(g=o+t),m+t>a&&(g=a-t)}if(n){const t=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=e.W(f,t-s/2,t+s/2));const r=p/2;i-r<l&&(_=l+r),i+r>c&&(_=c-r)}if(void 0!==_||void 0!==g){const t=new e.P(null!=_?_:f,null!=g?g:m);r.center=_t(s,t).wrap()}return r},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Ge({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new $e}clone(){const t=new We;return t.apply(this,!1),t}apply(t,e,i){this._helper.apply(t,e,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const i=[new e.bc(0,t)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new e.P(0,0)),n=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,0)),s=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new e.P(0,this._helper._height)),a=Math.floor(Math.min(r.x,n.x,s.x,o.x)),l=Math.floor(Math.max(r.x,n.x,s.x,o.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new e.bc(r,t))}return i}getCameraFrustum(){return Ze.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const e=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLatZoom(e,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,i){const r=e.as(this.elevation,this.center.lat),n=this.screenPointToMercatorCoordinateAtZ(i,r),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=e.a9.fromLngLat(t),a=new e.a9(o.x-(n.x-s.x),o.y-(n.y-s.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){return i?this.coordinatePoint(e.a9.fromLngLat(t),i.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(e.a9.fromLngLat(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,i){const r=i||0,n=[t.x,t.y,0,1],s=[t.x,t.y,1,1];e.aH(n,n,this._pixelMatrixInverse),e.aH(s,s,this._pixelMatrixInverse);const o=n[3],a=s[3],l=n[1]/o,c=s[1]/a,h=n[2]/o,u=s[2]/a,p=h===u?0:(r-h)/(u-h);return new e.a9(e.G.number(n[0]/o,s[0]/a,p)/this.worldSize,e.G.number(l,c,p)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){const n=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.aH(n,n,r),new e.P(n[0]/n[3],n[1]/n[3])}getBounds(){const t=Math.max(0,this._helper._height/2-gt(this));return(new W).extend(this.screenPointToLocation(new e.P(0,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new e.P(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=e.pointCoordinate(t):t.y>this.height/2-gt(this)}calculatePosMatrix(t,i=!1,r){var n;const s=null!==(n=t.key)&&void 0!==n?n:e.bd(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),o=i?this._alignedPosMatrixCache:this._posMatrixCache;if(o.has(s)){const t=o.get(s);return r?t.f32:t.f64}const a=yt(t,this.worldSize);e.S(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return o.set(s,l),r?l.f32:l.f64}calculateFogMatrix(t){const i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const n=yt(t,this.worldSize);return e.S(n,this._fogMatrix,n),r.set(i,new Float32Array(n)),r.get(i)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}_calculateNearFarZIfNeeded(t,i,r){if(!this._helper.autoCalculateNearFarZ)return;const n=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),s=t-n*this._helper._pixelPerMeter/Math.cos(i),o=n<0?s:t,a=Math.PI/2+this.pitchInRadians,l=e.ap(this.fov)*(Math.abs(Math.cos(e.ap(this.roll)))*this.height+Math.abs(Math.sin(e.ap(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*o/Math.sin(e.an(Math.PI-a-l,.01,Math.PI-.01)),h=gt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),p=e.ap(.75),d=u>p?2*u*(.5+r.y/(2*h)):p,f=Math.sin(d)*o/Math.sin(e.an(Math.PI-a-d,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,i=mt(this.worldSize,this.center),r=i.x,n=i.y;this._helper._pixelPerMeter=e.as(1,this.center.lat)*this.worldSize;const s=e.ap(Math.min(this.pitch,ft)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));let a;this._calculateNearFarZIfNeeded(o,s,t),a=new Float64Array(16),e.be(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),e.aB(this._invProjMatrix,a),a[8]=2*-t.x/this._helper._width,a[9]=2*t.y/this._helper._height,this._projectionMatrix=e.bf(a),e.Q(a,a,[1,-1,1]),e.O(a,a,[0,0,-this._helper.cameraToCenterDistance]),e.bg(a,a,-this.rollInRadians),e.bh(a,a,this.pitchInRadians),e.bg(a,a,-this.bearingInRadians),e.O(a,a,[-r,-n,0]),this._mercatorMatrix=e.Q([],a,[this.worldSize,this.worldSize,this.worldSize]),e.Q(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=e.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),e.O(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=e.aB([],a);const l=[0,0,-1,1];e.aH(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),e.be(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,e.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),e.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),e.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),e.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),e.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),e.O(this._fogMatrix,this._fogMatrix,[-r,-n,0]),e.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),e.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=e.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),d=r-Math.round(r)+u*c+p*h,f=n-Math.round(n)+u*h+p*c,m=new Float64Array(a);if(e.O(m,m,[d>.5?d-1:d,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=e.aB(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.aH(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=e.as(1,this.center.lat)*this.worldSize;return vt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,i){const r=e.a9.fromLngLat(t),n=[r.x*this.worldSize,r.y*this.worldSize,i,1];return e.aH(n,n,this._viewProjMatrix),n[2]/n[3]}getProjectionData(t){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:n}=t,s=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&n?i.terrainRttPosMatrix32f:o||e.bi(),{mainMatrix:a,tileMercatorCoords:s,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return e.b1(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,i,r,n){const s=this.calculatePosMatrix(r);let o;n?(o=[t,i,n(t,i),1],e.aH(o,o,s)):(o=[t,i,0,1],se(o,o,s));const a=o[3];return{point:new e.P(o[0]/a,o[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(t){for(const e of t)this.calculatePosMatrix(e)}getMatrixForModel(t,i){const r=e.a9.fromLngLat(t,i),n=r.meterInMercatorCoordinateUnits(),s=e.bj();return e.O(s,s,[r.x,r.y,r.z]),e.bg(s,s,Math.PI),e.bh(s,s,Math.PI/2),e.Q(s,s,[-n,n,n]),s}getProjectionDataForCustomLayer(t=!0){const i=new e.a2(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),n=yt(i,this.worldSize);e.S(n,this._viewProjMatrix,n),r.tileMercatorCoords=[0,0,1,1];const s=[e.a5,e.a5,this.worldSize/this._helper.pixelsPerMeter],o=e.bk();return e.Q(o,n,s),r.fallbackMatrix=o,r.mainMatrix=o,r}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function He(){e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Xe(t){if(t.useSlerp)if(t.k<1){const i=e.bl(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),r=e.bl(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),n=new Float64Array(4);e.bm(n,i,r,t.k);const s=e.bn(n);t.tr.setRoll(s.roll),t.tr.setPitch(s.pitch),t.tr.setBearing(s.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(e.G.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(e.G.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(e.G.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Ye(t,i,r,n,s){const o=s.padding,a=mt(s.worldSize,r.getNorthWest()),l=mt(s.worldSize,r.getNorthEast()),c=mt(s.worldSize,r.getSouthEast()),h=mt(s.worldSize,r.getSouthWest()),u=e.ap(-n),p=a.rotate(u),d=l.rotate(u),f=c.rotate(u),m=h.rotate(u),_=new e.P(Math.max(p.x,d.x,m.x,f.x),Math.max(p.y,d.y,m.y,f.y)),g=new e.P(Math.min(p.x,d.x,m.x,f.x),Math.min(p.y,d.y,m.y,f.y)),y=_.sub(g),v=(s.width-(o.left+o.right+i.left+i.right))/y.x,x=(s.height-(o.top+o.bottom+i.top+i.bottom))/y.y;if(x<0||v<0)return void He();const b=Math.min(e.at(s.scale*Math.min(v,x)),t.maxZoom),w=e.P.convert(t.offset),S=new e.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(e.ap(n)),T=w.add(S).mult(s.scale/e.aq(b));return{center:_t(s.worldSize,a.add(c).div(2).sub(T)),zoom:b,bearing:n}}class Ke{get useGlobeControls(){return!1}handlePanInertia(t,e){const i=t.mag(),r=Math.abs(gt(e));return{easingOffset:t.mult(Math.min(.75*r/i,1)),easingCenter:e.center}}handleMapControlsRollPitchBearingZoom(t,e){t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta),t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta)}handleMapControlsPan(t,e,i){t.around.distSqr(e.centerPoint)<.01||e.setLocationAtPoint(i,t.around)}cameraForBoxAndBearing(t,e,i,r,n){return Ye(t,e,i,r,n)}handleJumpToCenterZoom(t,i){t.zoom!==(void 0!==i.zoom?+i.zoom:t.zoom)&&t.setZoom(+i.zoom),void 0!==i.center&&t.setCenter(e.V.convert(i.center))}handleEaseTo(t,i){const r=t.zoom,n=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},a=void 0!==i.zoom,l=!t.isPaddingEqual(i.padding);let c=!1;const h=a?+i.zoom:t.zoom;let u=t.centerPoint.add(i.offsetAsPoint);const p=t.screenPointToLocation(u),{center:d,zoom:f}=t.applyConstrain(e.V.convert(i.center||p),null!=h?h:r);je(t,d);const m=mt(t.worldSize,p),_=mt(t.worldSize,d).sub(m),g=e.aq(f-r);return c=f!==r,{easeFunc:a=>{if(c&&t.setZoom(e.G.number(r,f,a)),e.bo(s,o)||Xe({startEulerAngles:s,endEulerAngles:o,tr:t,k:a,useSlerp:s.roll!=o.roll}),l&&(t.interpolatePadding(n,i.padding,a),u=t.centerPoint.add(i.offsetAsPoint)),i.around)t.setLocationAtPoint(i.around,i.aroundPoint);else{const i=e.aq(t.zoom-r),n=f>r?Math.min(2,g):Math.max(.5,g),s=Math.pow(n,1-a),o=_t(t.worldSize,m.add(_.mult(a*s)).mult(i));t.setLocationAtPoint(t.renderWorldCopies?o.wrap():o,u)}},isZooming:c,elevationCenter:d}}handleFlyTo(t,i){const r=void 0!==i.zoom,n=t.zoom,s=t.applyConstrain(e.V.convert(i.center||i.locationAtOffset),r?+i.zoom:n),o=s.center,a=s.zoom;je(t,o);const l=mt(t.worldSize,i.locationAtOffset),c=mt(t.worldSize,o).sub(l),h=c.mag(),u=e.aq(a-n);let p;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,n,a),s=t.applyConstrain(o,r).zoom;p=e.aq(s-n)}return{easeFunc:(i,r,s,h)=>{t.setZoom(1===i?a:n+e.at(r));const u=1===i?o:_t(t.worldSize,l.add(c.mult(s)).mult(r));t.setLocationAtPoint(t.renderWorldCopies?u.wrap():u,h)},scaleOfZoom:u,targetCenter:o,scaleOfMinZoom:p,pixelPathLength:h}}}class Je{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}Je.Replace=[1,0],Je.disabled=new Je(Je.Replace,e.bp.transparent,[!1,!1,!1,!1]),Je.unblended=new Je(Je.Replace,e.bp.transparent,[!0,!0,!0,!0]),Je.alphaBlended=new Je([1,771],e.bp.transparent,[!0,!0,!0,!0]);const Qe=2305;class ti{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}ti.disabled=new ti(!1,1029,Qe),ti.backCCW=new ti(!0,1029,Qe),ti.frontCCW=new ti(!0,1028,Qe);class ei{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}ei.ReadOnly=!1,ei.ReadWrite=!0,ei.disabled=new ei(519,ei.ReadOnly,[0,1]);const ii=7680;class ri{constructor(t,e,i,r,n,s){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=s}}ri.disabled=new ri({func:519,mask:0},0,0,ii,ii,ii);const ni=new WeakMap;function si(t){var e;if(ni.has(t))return ni.get(t);{const i=null===(e=t.getParameter(t.VERSION))||void 0===e?void 0:e.startsWith("WebGL 2.0");return ni.set(t,i),i}}class oi{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const i=t.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const n=new e.aW;n.emplaceBack(-1,-1),n.emplaceBack(2,-1),n.emplaceBack(-1,2);const s=new e.aY;s.emplaceBack(0,1,2),this._fullscreenTriangle=new Le(i.createVertexBuffer(n,Fe.members),i.createIndexBuffer(s),e.aX.simpleSegment(0,0,n.length,s.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),si(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,e){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,e),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,e=t.gl;t.activeTexture.set(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,i){const r=this._cachedRenderContext.context,n=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:e.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,n.TRIANGLES,ei.disabled,ri.disabled,Je.unblended,ti.disabled,((t,e)=>({u_input:t,u_output_expected:e}))(t,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&si(n)){n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.readBuffer(n.COLOR_ATTACHMENT0),n.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null);const t=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);n.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:t}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&si(t)){const i=t.clientWaitSync(this._readbackQueue.sync,0,0);if(i===t.WAIT_FAILED)return e.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=oi._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let e=0;return e+=t[0]/256,e+=t[1]/65536,e+=t[2]/16777216,t[3]<127&&(e=-e),e/128}}const ai=e.a5/128;function li(t,i){const r=void 0!==t.granularity?Math.max(t.granularity,1):1,n=r+(t.generateBorders?2:0),s=r+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),o=n+1,a=s+1,l=t.generateBorders?-1:0,c=t.generateBorders||t.extendToNorthPole?-1:0,h=r+(t.generateBorders?1:0),u=r+(t.generateBorders||t.extendToSouthPole?1:0),p=o*a,d=n*s*6,f=o*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,_=new Int16Array(2*p);let g=0;for(let i=c;i<=u;i++)for(let n=l;n<=h;n++){let s=n/r*e.a5;-1===n&&(s=-ai),n===r+1&&(s=e.a5+ai);let o=i/r*e.a5;-1===i&&(o=t.extendToNorthPole?e.br:-ai),i===r+1&&(o=t.extendToSouthPole?e.bs:e.a5+ai),_[g++]=s,_[g++]=o}const y=m?new Uint32Array(d):new Uint16Array(d);let v=0;for(let t=0;t<s;t++)for(let e=0;e<n;e++){const i=e+1+t*o,r=e+(t+1)*o,n=e+1+(t+1)*o;y[v++]=e+t*o,y[v++]=r,y[v++]=i,y[v++]=i,y[v++]=r,y[v++]=n}return{vertices:_.buffer.slice(0),indices:y.buffer.slice(0),uses32bitIndices:m}}const ci=new e.aV({fill:new e.bt(128,2),line:new e.bt(512,0),tile:new e.bt(128,32),stencil:new e.bt(128,1),circle:3});class hi{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return ze.projectionGlobe}get vertexShaderPreludeCode(){return ze.projectionMercator.vertexSource}get subdivisionGranularity(){return ci}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new oi(t));const i=e.X(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,n=this._errorMeasurement.updateErrorLoop(i,r),s=c();n!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=n,this._errorMeasurementLastChangeTime=s);const o=Math.min(Math.max((s-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=e.bu(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,e.bv(o))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,e,i,r,n){const s=("stencil"===n?ci.stencil:ci.tile).getGranularityForZoomLevel(e.z);return this._getMesh(t,{granularity:s,generateBorders:i,extendToNorthPole:0===e.y&&r,extendToSouthPole:e.y===(1<<e.z)-1&&r})}_getMesh(t,i){const r=this._getMeshKey(i);if(r in this._tileMeshCache)return this._tileMeshCache[r];const n=function(t,i){const r=li(i,"16bit"),n=e.aW.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),s=e.aY.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Le(t.createVertexBuffer(n,Fe.members),t.createIndexBuffer(s),e.aX.simpleSegment(0,0,n.length,s.length))}(t,i);return this._tileMeshCache[r]=n,n}recalculate(t){}hasTransition(){const t=c();let e=!1;return e=e||(t-this._errorMeasurementLastChangeTime)/1e3<.7,e=e||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,e}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const ui=new e.t({type:new e.D(e.u.projection.type)});class pi extends e.E{constructor(t){super(),this._transitionable=new e.x(ui,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.H(0)),this._mercatorProjection=new Ne,this._verticalPerspectiveProjection=new hi}get transitionState(){const t=this.properties.get("type");if("string"==typeof t&&"mercator"===t)return 0;if("string"==typeof t&&"vertical-perspective"===t)return 1;if(t instanceof e.bw){if("vertical-perspective"===t.from&&"mercator"===t.to)return 1-t.transition;if("mercator"===t.from&&"vertical-perspective"===t.to)return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,e,i,r,n){return this.currentProjection.getMeshFromTileID(t,e,i,r,n)}setProjection(t){this._transitionable.setValue("type",(null==t?void 0:t.type)||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function di(t){const e=_i(t.worldSize,t.center.lat);return 2*Math.PI*e}function fi(t,i,r,n,s){const o=1/(1<<s),a=i/e.a5*o+n*o,l=e.bz((t/e.a5*o+r*o)*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-a*Math.PI*2))-.5*Math.PI,h=Math.cos(c),u=new Float64Array(3);return u[0]=Math.sin(l)*h,u[1]=Math.sin(c),u[2]=Math.cos(l)*h,u}function mi(t){return function(t,e){const i=Math.cos(e),r=new Float64Array(3);return r[0]=Math.sin(t)*i,r[1]=Math.sin(e),r[2]=Math.cos(t)*i,r}(t.lng*Math.PI/180,t.lat*Math.PI/180)}function _i(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function gi(t){const i=Math.asin(t[1])/Math.PI*180,r=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(r>1e-6){const n=t[0]/r,s=Math.acos(t[2]/r),o=(n>0?s:-s)/Math.PI*180;return new e.V(e.W(o,-180,180),i)}return new e.V(0,i)}function yi(t){return Math.cos(t*Math.PI/180)}function vi(t,i){const r=yi(t),n=yi(i);return e.at(n/r)}function xi(t,i){const r=t.rotate(i.bearingInRadians),n=i.zoom+vi(i.center.lat,0),s=e.bu(1/yi(i.center.lat),1/yi(Math.min(Math.abs(i.center.lat),60)),e.bx(n,7,3,0,1)),o=360/di({worldSize:i.worldSize,center:{lat:i.center.lat}});return new e.V(i.center.lng-r.x*o*s,e.an(i.center.lat+r.y*o,-e.ao,e.ao))}function bi(t){const e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function wi(t,i,r,n){const s=t.lat+r*n;if(Math.abs(r)>1){const o=(Math.sign(t.lat+r)!==Math.sign(t.lat)?-Math.abs(t.lat):Math.abs(t.lat))*Math.PI/180,a=Math.abs(t.lat+r)*Math.PI/180,l=bi(o+n*(a-o)),c=bi(o),h=bi(a);return new e.V(t.lng+i*((l-c)/(h-c)),s)}return new e.V(t.lng+i*n,s)}class Si{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,e,i,r){const n=`${t.z}_${t.x}_${t.y}_${(null==r?void 0:r.terrain)?"t":""}`,s=this._cache.get(n);if(s)return s;const o=this._cachePrevious.get(n);if(o)return this._cache.set(n,o),o;const a=this._boundingVolumeFactory(t,e,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}}class Ti{constructor(t,e,i,r){this.min=i,this.max=r,this.points=t,this.planes=e}static fromAabb(t,e){const i=[];for(let r=0;r<8;r++)i.push([1&~r?t[0]:e[0],1==(r>>1&1)?e[1]:t[1],1==(r>>2&1)?e[2]:t[2]]);return new Ti(i,[[-1,0,0,e[0]],[1,0,0,-t[0]],[0,-1,0,e[1]],[0,1,0,-t[1]],[0,0,-1,e[2]],[0,0,1,-t[2]]],t,e)}static fromCenterSizeAngles(t,i,r){const n=e.bB([],r[0],r[1],r[2]),s=e.bC([],[i[0],0,0],n),o=e.bC([],[0,i[1],0],n),a=e.bC([],[0,0,i[2]],n),l=[...t],c=[...t];for(let e=0;e<8;e++)for(let i=0;i<3;i++){const r=t[i]+s[i]*(1&~e?-1:1)+o[i]*(1==(e>>1&1)?1:-1)+a[i]*(1==(e>>2&1)?1:-1);l[i]=Math.min(l[i],r),c[i]=Math.max(c[i],r)}const h=[];for(let i=0;i<8;i++){const r=[...t];e.b0(r,r,e.a$([],s,1&~i?-1:1)),e.b0(r,r,e.a$([],o,1==(i>>1&1)?1:-1)),e.b0(r,r,e.a$([],a,1==(i>>2&1)?1:-1)),h.push(r)}return new Ti(h,[[...s,-e.b5(s,h[0])],[...o,-e.b5(o,h[0])],[...a,-e.b5(a,h[0])],[-s[0],-s[1],-s[2],-e.b5(s,h[7])],[-o[0],-o[1],-o[2],-e.b5(o,h[7])],[-a[0],-a[1],-a[2],-e.b5(a,h[7])]],l,c)}intersectsFrustum(t){let e=!0;const i=this.points.length,r=this.planes.length,n=t.planes.length,s=t.points.length;for(let r=0;r<n;r++){const n=t.planes[r];let s=0;for(let t=0;t<i;t++){const e=this.points[t];n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]>=0&&s++}if(0===s)return 0;s<i&&(e=!1)}if(e)return 2;for(let e=0;e<r;e++){const i=this.planes[e];let r=0;for(let e=0;e<s;e++){const n=t.points[e];i[0]*n[0]+i[1]*n[1]+i[2]*n[2]+i[3]>=0&&r++}if(0===r)return 0}return 1}intersectsPlane(t){const e=this.points.length;let i=0;for(let r=0;r<e;r++){const e=this.points[r];t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0&&i++}return i===e?2:0===i?0:1}}function Ci(t,e,i){const r=t-e;return r<0?-r:Math.max(0,r-i)}function Mi(t,e,i,r,n){const s=t-i;let o;return o=s<0?Math.min(-s,1+s-n):s>1?Math.min(Math.max(s-n,0),1-s):0,Math.max(o,Ci(e,r,n))}class Ei{constructor(){this._boundingVolumeCache=new Si(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,e,i,r){const n=1<<i.z,s=1/n,o=i.x/n,a=i.y/n;let l=2;return l=Math.min(l,Mi(t,e,o,a,s)),l=Math.min(l,Mi(t,e,o+.5,-a-s,s)),l=Math.min(l,Mi(t,e,o+.5,2-a-s,s)),l}getWrap(t,e,i){const r=1<<e.z,n=1/r,s=e.x/r,o=Ci(t.x,s,n),a=Ci(t.x,s-1,n),l=Ci(t.x,s+1,n),c=Math.min(o,a,l);return c===l?1:c===a?-1:0}allowVariableZoom(t,e){return Ct(t,e)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,e,i,r){return this._boundingVolumeCache.getTileBoundingVolume(t,e,i,r)}_computeTileBoundingVolume(t,i,r,n){var s,o;let a=0,l=0;if(null==n?void 0:n.terrain){const c=new e.a2(t.z,i,t.z,t.x,t.y),h=n.terrain.getMinMaxElevation(c);a=null!==(s=h.minElevation)&&void 0!==s?s:Math.min(0,r),l=null!==(o=h.maxElevation)&&void 0!==o?o:Math.max(0,r)}if(a/=e.bE,l/=e.bE,a+=1,l+=1,t.z<=0)return Ti.fromAabb([-l,-l,-l],[l,l,l]);if(1===t.z)return Ti.fromAabb([0===t.x?-l:0,0===t.y?0:-l,-l],[0===t.x?0:l,0===t.y?l:0,l]);{const i=[fi(0,0,t.x,t.y,t.z),fi(e.a5,0,t.x,t.y,t.z),fi(e.a5,e.a5,t.x,t.y,t.z),fi(0,e.a5,t.x,t.y,t.z)],r=[];for(const t of i)r.push(e.a$([],t,l));if(l!==a)for(const t of i)r.push(e.a$([],t,a));0===t.y&&r.push([0,1,0]),t.y===(1<<t.z)-1&&r.push([0,-1,0]);const n=[1,1,1],s=[-1,-1,-1];for(const t of r)for(let e=0;e<3;e++)n[e]=Math.min(n[e],t[e]),s[e]=Math.max(s[e],t[e]);const o=fi(e.a5/2,e.a5/2,t.x,t.y,t.z),c=e.b4([],[0,1,0],o);e.b3(c,c);const h=e.b4([],o,c);e.b3(h,h);const u=e.b4([],i[2],i[1]);e.b3(u,u);const p=e.b4([],i[0],i[3]);e.b3(p,p),r.push(e.a$([],o,l)),t.y>=(1<<t.z)/2&&r.push(e.a$([],fi(e.a5/2,0,t.x,t.y,t.z),l)),t.y<(1<<t.z)/2&&r.push(e.a$([],fi(e.a5/2,e.a5,t.x,t.y,t.z),l));const d=Ai(o,r),f=Ai(h,r),m=[-o[0],-o[1],-o[2],d.max],_=[o[0],o[1],o[2],-d.min],g=[-h[0],-h[1],-h[2],f.max],y=[h[0],h[1],h[2],-f.min],v=[...u,0],x=[...p,0],b=[];return 0===t.y?b.push(e.bD(x,v,m),e.bD(x,v,_)):b.push(e.bD(g,v,m),e.bD(g,v,_),e.bD(g,x,m),e.bD(g,x,_)),t.y===(1<<t.z)-1?b.push(e.bD(x,v,m),e.bD(x,v,_)):b.push(e.bD(y,v,m),e.bD(y,v,_),e.bD(y,x,m),e.bD(y,x,_)),new Ti(b,[m,_,g,y,v,x],n,s)}}}function Ai(t,i){let r=1/0,n=-1/0;for(const s of i){const i=e.b5(t,s);r=Math.min(r,i),n=Math.max(n,i)}return{min:r,max:n}}class Ii{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e){this._helper.resize(t,e)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t){this._cachedClippingPlane=e.bF(),this._projectionMatrix=e.bj(),this._globeViewProjMatrix32f=e.bi(),this._globeViewProjMatrixNoCorrection=e.bj(),this._globeViewProjMatrixNoCorrectionInverted=e.bj(),this._globeProjMatrixInverted=e.bj(),this._cameraPosition=e.bA(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(t,i)=>{const r=e.an(t.lat,-e.ao,e.ao),n=e.an(+i,this.minZoom+vi(0,r),this.maxZoom);return{center:new e.V(t.lng,r),zoom:n}},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Ge({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new Ei}clone(){const t=new Ii;return t.apply(this,!1),t}apply(t,e,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(t,e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=e.bA();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:e,applyGlobeMatrix:i}=t,r=this._helper.getMercatorTileCoordinates(e);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const i=this.pitchInRadians,r=this.cameraToCenterDistance/t,n=Math.sin(i)*r,s=Math.cos(i)*r+1,o=1/Math.sqrt(n*n+s*s)*1;let a=-n,l=s;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const h=[0,a,l];e.bG(h,h,[0,0,0],-this.bearingInRadians),e.bH(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),e.bI(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/e.b7(h);return e.a$(h,h,u),[...h,-o*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(mi(t))}transformLightDirection(t){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,n=Math.cos(r),s=[Math.sin(i)*n,Math.sin(r),Math.cos(i)*n],o=[s[2],0,-s[0]],a=[0,0,0];e.b4(a,o,s),e.b3(o,o),e.b3(a,a);const l=[0,0,0];return e.b3(l,[o[0]*t[0]+a[0]*t[1]+s[0]*t[2],o[1]*t[0]+a[1]*t[1]+s[1]*t[2],o[2]*t[0]+a[2]*t[1]+s[2]*t[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,i,r){const n=function(t,i,r){const n=1/(1<<r.z);return new e.a9(t/e.a5*n+r.x*n,i/e.a5*n+r.y*n)}(t,i,r.canonical),s=(o=n.y,[e.bz(n.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(s[1])}projectTileCoordinates(t,i,r,n){const s=r.canonical,o=fi(t,i,s.x,s.y,s.z),a=1+(n?n(t,i):0)/e.bE,l=[o[0]*a,o[1]*a,o[2]*a,1];e.aH(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,h=c[0]*o[0]+c[1]*o[1]+c[2]*o[2]+c[3]<0;return{point:new e.P(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=_i(this.worldSize,this.center.lat),i=e.bk(),r=e.bk();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),e.be(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const n=this.centerOffset;i[8]=2*-n.x/this._helper._width,i[9]=2*n.y/this._helper._height,this._projectionMatrix=e.bf(i),this._globeProjMatrixInverted=e.bk(),e.aB(this._globeProjMatrixInverted,i),e.O(i,i,[0,0,-this.cameraToCenterDistance]),e.bg(i,i,this.rollInRadians),e.bh(i,i,-this.pitchInRadians),e.bg(i,i,this.bearingInRadians),e.O(i,i,[0,0,-t]);const s=e.bA();s[0]=t,s[1]=t,s[2]=t,e.bh(r,i,this.center.lat*Math.PI/180),e.bJ(r,r,-this.center.lng*Math.PI/180),e.Q(r,r,s),this._globeViewProjMatrixNoCorrection=r,e.bh(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),e.bJ(i,i,-this.center.lng*Math.PI/180),e.Q(i,i,s),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=e.bk(),e.aB(this._globeViewProjMatrixNoCorrectionInverted,r);const o=e.bA();this._cameraPosition=e.bA(),this._cameraPosition[2]=this.cameraToCenterDistance/t,e.bG(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),e.bH(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),e.bG(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),e.b0(this._cameraPosition,this._cameraPosition,[0,0,1]),e.bH(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),e.bI(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const a=e.bf(this._globeViewProjMatrixNoCorrectionInverted);e.Q(a,a,[1,1,-1]),this._cachedFrustum=Ze.fromInvProjectionMatrix(a,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){e.w("calculateFogMatrix is not supported on globe projection.");const i=e.bk();return e.ar(i),i}getVisibleUnwrappedCoordinates(t){return[new e.bc(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&e.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const r=mi(t);e.a$(r,r,1+i/e.bE);const n=e.bF();return e.aH(n,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),n[2]/n[3]}populateCache(t){}getBounds(){const t=.5*this.width,i=.5*this.height,r=[new e.P(0,0),new e.P(t,0),new e.P(this.width,0),new e.P(this.width,i),new e.P(this.width,this.height),new e.P(t,this.height),new e.P(0,this.height),new e.P(0,i)],n=[];for(const t of r)n.push(this.unprojectScreenPoint(t));let s=0,o=0,a=0,l=0;const c=this.center;for(const t of n){const i=e.bK(c.lng,t.lng),r=e.bK(c.lat,t.lat);i<o&&(o=i),i>s&&(s=i),r<l&&(l=r),r>a&&(a=r)}const h=[c.lng+o,c.lat+l,c.lng+s,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new W(h)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,i){const r=mi(this.unprojectScreenPoint(i)),n=mi(t),s=e.bA();e.bL(s);const o=e.bA();e.bI(o,r,s,-this.center.lng*Math.PI/180),e.bH(o,o,s,this.center.lat*Math.PI/180);const a=n[0]*n[0]+n[2]*n[2],l=o[0]*o[0];if(a<l)return;const c=Math.sqrt(a-l),h=-c,u=e.bM(n[0],n[2],o[0],c),p=e.bM(n[0],n[2],o[0],h),d=e.bA();e.bI(d,n,s,-u);const f=e.bM(d[1],d[2],o[1],o[2]),m=e.bA();e.bI(m,n,s,-p);const _=e.bM(m[1],m[2],o[1],o[2]),g=.5*Math.PI,y=f>=-g&&f<=g,v=_>=-g&&_<=g;let x,b;if(y&&v){const t=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;e.bN(u,t)+e.bN(f,i)<e.bN(p,t)+e.bN(_,i)?(x=u,b=f):(x=p,b=_)}else if(y)x=u,b=f;else{if(!v)return;x=p,b=_}const w=x/Math.PI*180,S=b/Math.PI*180,T=this.center.lat;this.setCenter(new e.V(w,e.an(S,-90,90))),this.setZoom(this.zoom+vi(T,this.center.lat))}locationToScreenPoint(t,i){const r=mi(t);if(i){const n=i.getElevationForLngLatZoom(t,this._helper._tileZoom);e.a$(r,r,1+n/e.bE)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){const i=e.bF();return e.aH(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new e.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){const e=i.pointCoordinate(t);if(e)return e}return e.a9.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(t,e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(t){const i=e.bF();i[0]=t.x/this.width*2-1,i[1]=-1*(t.y/this.height*2-1),i[2]=1,i[3]=1,e.aH(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const r=e.bA();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];const n=e.bA();return e.b3(n,r),n}isSurfacePointVisible(t){const e=this._cachedClippingPlane;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const i=e.bF();return e.aH(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(t,i){const r=e.b5(t,i),n=e.bA(),s=e.bA();e.a$(s,i,r),e.b2(n,t,s);const o=1-e.b5(n,n);if(o<0)return null;const a=e.b5(t,t)-1,l=-r+(r<0?1:-1)*Math.sqrt(o),c=a/l,h=l;return{tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(t){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(t),n=this.rayPlanetIntersection(i,r);if(n){const t=e.bA();e.b0(t,i,[r[0]*n.tMin,r[1]*n.tMin,r[2]*n.tMin]);const s=e.bA();return e.b3(s,t),gi(s)}const s=this._cachedClippingPlane,o=s[0]*r[0]+s[1]*r[1]+s[2]*r[2],a=-e.bb(s,i)/o,l=e.bA();if(a>0)e.b0(l,i,[r[0]*a,r[1]*a,r[2]*a]);else{const t=e.bA();e.b0(t,i,[2*r[0],2*r[1],2*r[2]]);const n=e.bb(this._cachedClippingPlane,t);e.b2(l,t,[this._cachedClippingPlane[0]*n,this._cachedClippingPlane[1]*n,this._cachedClippingPlane[2]*n])}const c=function(t){const i=e.bA();return i[0]=t[0]*-t[3],i[1]=t[1]*-t[3],i[2]=t[2]*-t[3],{center:i,radius:Math.sqrt(1-t[3]*t[3])}}(s);return gi(function(t,i,r){const n=e.bA();e.b2(n,r,t);const s=e.bA();return e.by(s,t,n,i/e.b9(n)),s}(c.center,c.radius,l))}getMatrixForModel(t,i){const r=e.V.convert(t),n=1/e.bE,s=e.bj();return e.bJ(s,s,r.lng/180*Math.PI),e.bh(s,s,-r.lat/180*Math.PI),e.O(s,s,[0,0,1+i/e.bE]),e.bh(s,s,.5*Math.PI),e.Q(s,s,[n,n,n]),s}getProjectionDataForCustomLayer(t=!0){const i=this.getProjectionData({overscaledTileID:new e.a2(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}}class Pi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){return this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t,e){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(t,e)=>this.currentTransform.defaultConstrain(t,e),this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Ge({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._globeness=1,this._mercatorTransform=new We,this._verticalPerspectiveTransform=new Ii}clone(){const t=new Pi;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,e){this._helper.apply(t,e),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const e=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:e.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:e.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return e.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return e.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,r){const n=this._mercatorTransform.getPitchedTextCorrection(t,i,r),s=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r);return e.bu(n,s,this._globeness)}projectTileCoordinates(t,e,i,r){return this.currentTransform.projectTileCoordinates(t,e,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,e){return this.currentTransform.lngLatToCameraDepth(t,e)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,e){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,e),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,e),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,e){return this.currentTransform.locationToScreenPoint(t,e)}screenPointToMercatorCoordinate(t,e){return this.currentTransform.screenPointToMercatorCoordinate(t,e)}screenPointToLocation(t,e){return this.currentTransform.screenPointToLocation(t,e)}isPointOnMapSurface(t,e){return this.currentTransform.isPointOnMapSurface(t,e)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,e){return this.currentTransform.getMatrixForModel(t,e)}getProjectionDataForCustomLayer(t=!0){const e=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return e;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=e.mainMatrix,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class Di{get useGlobeControls(){return!0}handlePanInertia(t,i){const r=xi(t,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new e.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){const r=t.around,n=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);const s=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);const o=i.zoom-s;if(0===o)return;const a=e.bK(i.center.lng,n.lng),l=a/(Math.abs(a/180)+1),c=e.bK(i.center.lat,n.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,p=-1*e.b5(u,h),d=e.bA();e.b0(d,u,[h[0]*p,h[1]*p,h[2]*p]);const f=e.b7(d)-1,m=Math.exp(.5*-Math.max(f-.3,0)),_=_i(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=e.bx(_,.9,.5,1,.25),y=(1-e.aq(-o))*Math.min(m,g),v=i.center.lat,x=i.zoom,b=new e.V(i.center.lng+l*y,e.an(i.center.lat+c*y,-e.ao,e.ao));i.setLocationAtPoint(n,r);const w=i.center,S=e.bx(Math.abs(a),45,85,0,1),T=e.bx(_,.75,.35,0,1),C=Math.pow(Math.max(S,T),.25),M=e.bK(w.lng,b.lng),E=e.bK(w.lat,b.lat);i.setCenter(new e.V(w.lng+M*C,w.lat+E*C).wrap()),i.setZoom(x+vi(v,i.center.lat))}handleMapControlsPan(t,e,i){if(!t.panDelta)return;const r=e.center.lat,n=e.zoom;e.setCenter(xi(t.panDelta,e).wrap()),e.setZoom(n+vi(r,e.center.lat))}cameraForBoxAndBearing(t,i,r,n,s){const o=Ye(t,i,r,n,s),a=i.left/s.width*2-1,l=(s.width-i.right)/s.width*2-1,c=i.top/s.height*-2+1,h=(s.height-i.bottom)/s.height*-2+1,u=e.bK(r.getWest(),r.getEast())<0,p=u?r.getEast():r.getWest(),d=u?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),_=p+.5*e.bK(p,d),g=f+.5*e.bK(f,m),y=s.clone();y.setCenter(o.center),y.setBearing(o.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(o.zoom);const v=y.modelViewProjectionMatrix,x=[mi(r.getNorthWest()),mi(r.getNorthEast()),mi(r.getSouthWest()),mi(r.getSouthEast()),mi(new e.V(d,g)),mi(new e.V(p,g)),mi(new e.V(_,f)),mi(new e.V(_,m))],b=mi(o.center);let w=Number.POSITIVE_INFINITY;for(const t of x)a<0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(t,b,v,"x",a))),l>0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(t,b,v,"x",l))),c>0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(t,b,v,"y",c))),h<0&&(w=Di.getLesserNonNegativeNonNull(w,Di.solveVectorScale(t,b,v,"y",h)));if(Number.isFinite(w)&&0!==w)return o.zoom=y.zoom+e.at(w),o;He()}handleJumpToCenterZoom(t,i){const r=t.center.lat,n=t.applyConstrain(i.center?e.V.convert(i.center):t.center,t.zoom).center;t.setCenter(n.wrap());const s=void 0!==i.zoom?+i.zoom:t.zoom+vi(r,n.lat);t.zoom!==s&&t.setZoom(s)}handleEaseTo(t,i){const r=t.zoom,n=t.center,s=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},a={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},l=void 0!==i.zoom,c=!t.isPaddingEqual(i.padding);let h=!1;const u=i.center?e.V.convert(i.center):n,p=t.applyConstrain(u,r).center;je(t,p);const d=t.clone();d.setCenter(p),d.setZoom(l?+i.zoom:r+vi(n.lat,u.lat)),d.setBearing(i.bearing);const f=new e.P(e.an(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.an(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));d.setLocationAtPoint(p,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?d.center:p,_=l?+i.zoom:r+vi(n.lat,m.lat),g=r+vi(n.lat,0),y=_+vi(m.lat,0),v=e.bK(n.lng,m.lng),x=e.bK(n.lat,m.lat),b=e.aq(y-g);return h=_!==r,{easeFunc:r=>{if(e.bo(o,a)||Xe({startEulerAngles:o,endEulerAngles:a,tr:t,k:r,useSlerp:o.roll!=a.roll}),c&&t.interpolatePadding(s,i.padding,r),i.around)e.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{const e=y>g?Math.min(2,b):Math.max(.5,b),i=Math.pow(e,1-r),s=wi(n,v,x,r*i);t.setCenter(s.wrap())}if(h){const i=e.G.number(g,y,r)+vi(0,t.center.lat);t.setZoom(i)}},isZooming:h,elevationCenter:m}}handleFlyTo(t,i){const r=void 0!==i.zoom,n=t.center,s=t.zoom,o=t.padding,a=!t.isPaddingEqual(i.padding),l=t.applyConstrain(e.V.convert(i.center||i.locationAtOffset),s).center,c=r?+i.zoom:t.zoom+vi(t.center.lat,l.lat),h=t.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new e.P(e.an(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.an(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(l,u);const p=h.center;je(t,p);const d=function(t,i,r){const n=mi(i),s=mi(r),o=e.b5(n,s),a=Math.acos(o),l=di(t);return a/(2*Math.PI)*l}(t,n,p),f=s+vi(n.lat,0),m=c+vi(p.lat,0),_=e.aq(m-f);let g;if("number"==typeof i.minZoom){const r=+i.minZoom+vi(p.lat,0),n=Math.min(r,f,m)+vi(0,p.lat),s=t.applyConstrain(p,n).zoom+vi(p.lat,0);g=e.aq(s-f)}const y=e.bK(n.lng,p.lng),v=e.bK(n.lat,p.lat);return{easeFunc:(r,s,l,h)=>{const u=wi(n,y,v,l);a&&t.interpolatePadding(o,i.padding,r);const d=1===r?p:u;t.setCenter(d.wrap());const m=f+e.at(s);t.setZoom(1===r?c:m+vi(0,d.lat))},scaleOfZoom:_,targetCenter:p,scaleOfMinZoom:g,pixelPathLength:d}}static solveVectorScale(t,e,i,r,n){const s="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],o=[i[3],i[7],i[11],i[15]],a=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],l=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],c=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],h=e[0]*o[0]+e[1]*o[1]+e[2]*o[2];return c+n*l===a+n*h||o[3]*(a-c)+s[3]*(h-l)+a*h==c*l?null:(c+s[3]-n*h-n*o[3])/(c-a-n*h+n*l)}static getLesserNonNegativeNonNull(t,e){return null!==e&&e>=0&&e<t?e:t}}class ki{constructor(t){this._globe=t,this._mercatorCameraHelper=new Ke,this._verticalPerspectiveCameraHelper=new Di}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,e){return this.currentHelper.handlePanInertia(t,e)}handleMapControlsRollPitchBearingZoom(t,e){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,e)}handleMapControlsPan(t,e,i){this.currentHelper.handleMapControlsPan(t,e,i)}cameraForBoxAndBearing(t,e,i,r,n){return this.currentHelper.cameraForBoxAndBearing(t,e,i,r,n)}handleJumpToCenterZoom(t,e){this.currentHelper.handleJumpToCenterZoom(t,e)}handleEaseTo(t,e){return this.currentHelper.handleEaseTo(t,e)}handleFlyTo(t,e){return this.currentHelper.handleFlyTo(t,e)}}const zi=(t,i)=>e.B(t,i&&i.filter(t=>"source.canvas"!==t.identifier)),Ri=e.bO();class Li extends e.E{constructor(t,i={}){var r,n;super(),this._rtlPluginLoaded=()=>{for(const t in this.tileManagers){const e=this.tileManagers[t].getSource().type;"vector"!==e&&"geojson"!==e||this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new V(N(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",(t,e)=>this.getGlyphs(t,e)),this.dispatcher.registerMessageHandler("GI",(t,e)=>this.getImages(t,e)),this.dispatcher.registerMessageHandler("GDA",(t,e)=>this.getDashes(t,e)),this.imageManager=new w,this.imageManager.setEventedParent(this);const s=(null===(r=t._container)||void 0===r?void 0:r.lang)||"undefined"!=typeof document&&(null===(n=document.documentElement)||void 0===n?void 0:n.lang)||void 0;this.glyphManager=new E(t._requestManager,i.localIdeographFontFamily,s),this.lineAtlas=new z(256,512),this.crossTileSymbolIndex=new De,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",e.bP()),ct().on(ot,this._rtlPluginLoaded),this.on("data",t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.tileManagers[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}})}_setInitialValues(){var t;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new e.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(t=this.crossTileSymbolIndex)||void 0===t?void 0:t.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,i){var r,n,s;this._checkLoaded();const o=null===i?null!==(s=null===(n=null===(r=this.stylesheet.state)||void 0===r?void 0:r[t])||void 0===n?void 0:n.default)&&void 0!==s?s:null:i;if(e.bR(o,this._globalState[t]))return this;this._globalState[t]=o,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();const i=[];for(const r in t)!e.bR(this._globalState[r],t[r].default)&&(i.push(r),this._globalState[r]=t[r].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(t){if(0===t.length)return;const e=new Set,i={};for(const r of t){i[r]=this._globalState[r];for(const t in this._layers){const i=this._layers[t],n=i.getLayoutAffectingGlobalStateRefs(),s=i.getPaintAffectingGlobalStateRefs(),o=i.getVisibilityAffectingGlobalStateRefs();if(n.has(r)&&e.add(i.source),s.has(r))for(const{name:t,value:e}of s.get(r))this._updatePaintProperty(i,t,e);(null==o?void 0:o.has(r))&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(const t in this.tileManagers)e.has(t)&&(this._reloadSource(t),this._changed=!0)}loadURL(t,i={},r){this.fire(new e.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const n=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const s=this._loadStyleRequest;e.j(n,this._loadStyleRequest).then(t=>{this._loadStyleRequest=null,this._load(t.data,i,r)}).catch(t=>{this._loadStyleRequest=null,t&&!s.signal.aborted&&this.fire(new e.k(t))})}loadJSON(t,i={},r){this.fire(new e.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,r)}).catch(()=>{})}loadEmpty(){this.fire(new e.l("dataloading",{dataType:"style"})),this._load(Ri,{validate:!1})}_load(t,i,r){var n,s;let o=i.transformStyle?i.transformStyle(r,t):t;if(!i.validate||!zi(this,e.C(o))){o=Object.assign({},o),this._loaded=!0,this.stylesheet=o;for(const t in o.sources)this.addSource(t,o.sources[t],{validate:!1});o.sprite?this._loadSprite(o.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(o.glyphs),this._createLayers(),this.light=new P(this.stylesheet.light),this._setProjectionInternal((null===(n=this.stylesheet.projection)||void 0===n?void 0:n.type)||"mercator"),this.sky=new k(this.stylesheet.sky),this.map.setTerrain(null!==(s=this.stylesheet.terrain)&&void 0!==s?s:null),this.fire(new e.l("data",{dataType:"style"})),this.fire(new e.l("style.load"))}}_createLayers(){var t,i,r;const n=e.bS(this.stylesheet.layers);this.setGlobalState(null!==(t=this.stylesheet.state)&&void 0!==t?t:null),this.dispatcher.broadcast("SL",n),this._order=n.map(t=>t.id),this._layers={},this._serializedLayers=null;for(const t of n){const n=e.bT(t,this._globalState);if(n.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=n,e.bU(n)&&this.tileManagers[n.source]){const e=null!==(r=null===(i=t.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==r?r:n.paint.get("raster-fade-duration");this.tileManagers[n.source].setRasterFadeDuration(e)}}}_loadSprite(t,i=!1,r=void 0){this.imageManager.setLoaded(!1);const n=new AbortController;let s;this._spriteRequest=n,function(t,i,r,n){return e._(this,void 0,void 0,function*(){const s=v(t),o=r>1?"@2x":"",l={},c={};for(const{id:t,url:r}of s){const s=i.transformRequest(x(r,o,".json"),"SpriteJSON");l[t]=e.j(s,n);const a=i.transformRequest(x(r,o,".png"),"SpriteImage");c[t]=g.getImage(a,n)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(t,i){return e._(this,void 0,void 0,function*(){const e={};for(const r in t){e[r]={};const n=a.getImageCanvasContext((yield i[r]).data),s=(yield t[r]).data;for(const t in s){const{width:i,height:o,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:p,content:d,textFitWidth:f,textFitHeight:m}=s[t];e[r][t]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:p,content:d,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:o,x:a,y:l,context:n}}}}return e})}(l,c)})}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const r=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter(e=>!(e in t)):[];for(const t of r)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const r in t[e]){const n="default"===e?r:`${e}:${r}`;this._spritesImagesIds[e].push(n),n in this.imageManager.images?this.imageManager.updateImage(n,t[e][r],!1):this.imageManager.addImage(n,t[e][r]),i&&(this._changedImages[n]=!0)}}}).catch(t=>{this._spriteRequest=null,s=t,n.signal.aborted||this.fire(new e.k(s))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"})),r&&r(s)})}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}_validateLayer(t){const i=this.tileManagers[t.source];if(!i)return;const r=t.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.k(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t,i=!1){const r=this._serializedAllLayers();if(!t||0===t.length)return Object.values(i?e.bV(r):r);const n=[];for(const s of t)if(r[s]){const t=i?e.bV(r[s]):r[s];n.push(t)}return n}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){var t,e,i;if(null===(t=this.light)||void 0===t?void 0:t.hasTransition())return!0;if(null===(e=this.sky)||void 0===e?void 0:e.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const i=this._changed;if(i){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const r={};for(const t in this.tileManagers){const e=this.tileManagers[t];r[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const t in r){const i=this.tileManagers[t];!!r[t]!=!!i.used&&i.fire(new e.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,i&&this.fire(new e.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,i={}){var r;this._checkLoaded();const n=this.serialize();if(t=i.transformStyle?i.transformStyle(n,t):t,(null===(r=i.validate)||void 0===r||r)&&zi(this,e.C(t)))return!1;(t=e.bV(t)).layers=e.bS(t.layers);const s=e.bW(n,t),o=this._getOperationsToPerform(s);if(o.unimplemented.length>0)throw new Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(const t of o.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new e.l("style.load",{style:this})),!0}_getOperationsToPerform(t){const e=[],i=[];for(const r of t)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":e.push(()=>this.addLayer.apply(this,r.args));break;case"removeLayer":e.push(()=>this.removeLayer.apply(this,r.args));break;case"setPaintProperty":e.push(()=>this.setPaintProperty.apply(this,r.args));break;case"setLayoutProperty":e.push(()=>this.setLayoutProperty.apply(this,r.args));break;case"setFilter":e.push(()=>this.setFilter.apply(this,r.args));break;case"addSource":e.push(()=>this.addSource.apply(this,r.args));break;case"removeSource":e.push(()=>this.removeSource.apply(this,r.args));break;case"setLayerZoomRange":e.push(()=>this.setLayerZoomRange.apply(this,r.args));break;case"setLight":e.push(()=>this.setLight.apply(this,r.args));break;case"setGeoJSONSourceData":e.push(()=>this.setGeoJSONSourceData.apply(this,r.args));break;case"setGlyphs":e.push(()=>this.setGlyphs.apply(this,r.args));break;case"setSprite":e.push(()=>this.setSprite.apply(this,r.args));break;case"setTerrain":e.push(()=>this.map.setTerrain.apply(this,r.args));break;case"setSky":e.push(()=>this.setSky.apply(this,r.args));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":e.push(()=>this.setGlobalState.apply(this,r.args));break;case"setTransition":e.push(()=>{});break;default:i.push(r.command)}return{operations:e,unimplemented:i}}addImage(t,i){if(this.getImage(t))return this.fire(new e.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.tileManagers[t])throw new Error(`Source "${t}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.C.source,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.tileManagers[t]=new Lt(t,i,this.dispatcher);n.style=this,n.setEventedParent(this,()=>({isSourceLoaded:n.loaded(),source:n.serialize(),sourceId:t})),n.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.tileManagers[t])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.k(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],i.fire(new e.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.tileManagers[t])throw new Error(`There is no source with this ID=${t}`);const i=this.tileManagers[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.tileManagers[t]&&this.tileManagers[t].getSource()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this.getLayer(n))return void this.fire(new e.k(new Error(`Layer "${n}" already exists on this map.`)));let s;if("custom"===t.type){if(zi(this,e.bX(t)))return;s=e.bT(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(n,t.source),t=e.bV(t),t=e.e(t,{source:n})),this._validate(e.C.layer,`layers.${n}`,t,{arrayIndex:-1},r))return;s=e.bT(t,this._globalState),this._validateLayer(s),s.setEventedParent(this,{layer:{id:n}})}const o=i?this._order.indexOf(i):this._order.length;if(i&&-1===o)this.fire(new e.k(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(o,0,n),this._layerOrderChanged=!0,this._layers[n]=s,this._removedLayers[n]&&s.source&&"custom"!==s.type){const t=this._removedLayers[n];delete this._removedLayers[n],t.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.tileManagers[s.source].pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map)}}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new e.k(new Error(`Cannot move layer "${t}" before non-existing layer "${i}".`))):(this._order.splice(n,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.k(new Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,r){this._checkLoaded();const n=this.getLayer(t);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new e.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,i,r={}){this._checkLoaded();const n=this.getLayer(t);if(n){if(!e.bR(n.filter,i))return null==i?(n.setFilter(void 0),void this._updateLayer(n)):void(this._validate(e.C.filter,`layers.${n.id}.filter`,i,null,r)||(n.setFilter(e.bV(i)),this._updateLayer(n)))}else this.fire(new e.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.bV(this.getLayer(t).filter)}setLayoutProperty(t,i,r,n={}){this._checkLoaded();const s=this.getLayer(t);s?e.bR(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,n),this._updateLayer(s)):this.fire(new e.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,i){const r=this.getLayer(t);if(r)return r.getLayoutProperty(i);this.fire(new e.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,i,r,n={}){this._checkLoaded();const s=this.getLayer(t);s?e.bR(s.getPaintProperty(i),r)||this._updatePaintProperty(s,i,r,n):this.fire(new e.k(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,i,r,n={}){t.setPaintProperty(i,r,n)&&this._updateLayer(t),e.bU(t)&&"raster-fade-duration"===i&&this.tileManagers[t.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,i){this._checkLoaded();const r=t.source,n=t.sourceLayer,s=this.tileManagers[r];if(void 0===s)return void this.fire(new e.k(new Error(`The source '${r}' does not exist in the map's style.`)));const o=s.getSource().type;"geojson"===o&&n?this.fire(new e.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||n?(void 0===t.id&&this.fire(new e.k(new Error("The feature id parameter must be provided."))),s.setFeatureState(n,t.id,i)):this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,i){this._checkLoaded();const r=t.source,n=this.tileManagers[r];if(void 0===n)return void this.fire(new e.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=n.getSource().type,o="vector"===s?t.sourceLayer:void 0;"vector"!==s||o?i&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.k(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(o,t.id,i):this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this.tileManagers[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===t.id&&this.fire(new e.k(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,t.id)):void this.fire(new e.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.bY(this.tileManagers,t=>t.serialize()),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,n=this.stylesheet;return e.bZ({version:n.version,name:n.name,metadata:n.metadata,light:n.light,sky:n.sky,center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,sprite:n.sprite,glyphs:n.glyphs,transition:n.transition,projection:n.projection,sources:t,layers:i,terrain:r},t=>void 0!==t)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.tileManagers[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const s=this._order[n];if(e(s)){i[s]=n;for(const e of t){const t=e[s];if(t)for(const e of t)r.push(e)}}}r.sort((t,e)=>e.intersectionZ-t.intersectionZ);const n=[];for(let s=this._order.length-1;s>=0;s--){const o=this._order[s];if(e(o))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<s)break;n.push(e),r.pop()}else for(const e of t){const t=e[o];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(t,i,r){i&&i.filter&&this._validate(e.C.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new e.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const s=[];i.availableImages=this._availableImages;const o=this._serializedAllLayers(),a=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l=Object.assign(Object.assign({},i),{layers:a,globalState:this._globalState});for(const e in this.tileManagers)i.layers&&!n[e]||s.push(G(this.tileManagers[e],this._layers,o,t,l,r,this.map.terrain?(t,e,i)=>this.map.terrain.getElevation(t,e,i):void 0));return this.placement&&s.push(function(t,e,i,r,n,s,o){const a={},l=s.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(o[t]);c.sort(U);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,{filterSpec:n.filter,globalState:n.globalState},n.layers,n.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],n=r[t];n.sort((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex});for(const t of n)e.push(t)}}return function(t,e,i){for(const r in t)for(const n of t[r])$(n,i[e[r].source]);return t}(a,t,i)}(this._layers,o,this.tileManagers,t,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(t,i){(null==i?void 0:i.filter)&&this._validate(e.C.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.tileManagers[t];return r?function(t,e){const i=t.getRenderableIds().map(e=>t.getTileByID(e)),r=[],n={};for(let t=0;t<i.length;t++){const s=i[t],o=s.tileID.canonical.key;n[o]||(n[o]=!0,s.querySourceFeatures(r,e))}return r}(r,i?Object.assign(Object.assign({},i),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e.bR(t[i],r[i])){n=!0;break}if(!n)return;const s={now:c(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,i),this.light.updateTransitions(s)}getProjection(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,this._setProjectionInternal(t.type)}getSky(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.sky}setSky(t,i={}){this._checkLoaded();const r=this.getSky();let n=!1;if(!t&&!r)return;if(t&&!r)n=!0;else if(!t&&r)n=!0;else for(const i in t)if(!e.bR(t[i],r[i])){n=!0;break}if(!n)return;const s={now:c(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,i),this.sky.updateTransitions(s)}_setProjectionInternal(t){const i=function(t,i){const r={constrainOverride:i};if(Array.isArray(t)){const e=new pi({type:t});return{projection:e,transform:new Pi(r),cameraHelper:new ki(e)}}switch(t){case"mercator":return{projection:new Ne,transform:new We(r),cameraHelper:new Ke};case"globe":{const t=new pi({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:t,transform:new Pi(r),cameraHelper:new ki(t)}}case"vertical-perspective":return{projection:new hi,transform:new Ii(r),cameraHelper:new Di};default:return e.w(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Ne,transform:new We(r),cameraHelper:new Ke}}}(t,this.map.transformConstrain);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const t in this.tileManagers)this.tileManagers[t].reload()}_validate(t,i,r,n,s={}){return(!s||!1!==s.validate)&&zi(this,t.call(e.C,e.e({key:i,style:this.serialize(),value:r,styleSpec:e.u},n)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),ct().off(ot,this._rtlPluginLoaded);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.tileManagers){const e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(const e in this.tileManagers)this.tileManagers[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,e,i,r,n=!1){let s=!1,o=!1;const a={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!a[i.source]){const t=this.tileManagers[i.source];a[i.source]=t.getRenderableIds(!0).map(e=>t.getTileByID(e)).sort((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1))}const r=this.crossTileSymbolIndex.addLayer(i,a[i.source],t.center.lng);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((n=n||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),t.zoom))&&(this.pauseablePlacement=new Me(t,this.map.terrain,this._order,n,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),o=!0),s&&this.pauseablePlacement.placement.setStale()),o||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,i){return e._(this,void 0,void 0,function*(){const t=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const e=this.tileManagers[i.source];return e&&e.setDependencies(i.tileID.key,i.type,i.icons),t})}getGlyphs(t,i){return e._(this,void 0,void 0,function*(){const t=yield this.glyphManager.getGlyphs(i.stacks),e=this.tileManagers[i.source];return e&&e.setDependencies(i.tileID.key,i.type,[""]),t})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(e.C.glyphs,"glyphs",t,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getDashes(t,i){return e._(this,void 0,void 0,function*(){const t={};for(const[e,r]of Object.entries(i.dashes))t[e]=this.lineAtlas.getDash(r.dasharray,r.round);return t})}addSprite(t,i,r={},n){this._checkLoaded();const s=[{id:t,url:i}],o=[...v(this.stylesheet.sprite),...s];this._validate(e.C.sprite,"sprite",o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(s,!0,n))}removeSprite(t){this._checkLoaded();const i=v(this.stylesheet.sprite);if(i.find(e=>e.id===t)){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;i.splice(i.findIndex(e=>e.id===t),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.l("data",{dataType:"style"}))}else this.fire(new e.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return v(this.stylesheet.sprite)}setSprite(t,i={},r){this._checkLoaded(),t&&this._validate(e.C.sprite,"sprite",t,null,i)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const t in this.tileManagers){const e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const t in this._layers){const e=this._layers[t];e.setEventedParent(null),e.onRemove&&e.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Fi=e.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Bi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,s,o,a,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(c=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==s||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,r,n,s,o,a,l):(t.bindVertexArray.set(this.vao),o&&o.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind())}freshBind(t,e,i,r,n,s,o,a){const l=t.numAttributes,c=this.context,h=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=s,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=a,e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);s&&s.enableAttributes(h,t),o&&o.enableAttributes(h,t),a&&a.enableAttributes(h,t),e.bind(),e.setVertexAttribPointers(h,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(h,t,n);s&&(s.bind(),s.setVertexAttribPointers(h,t,n)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,t,n)),a&&(a.bind(),a.setVertexAttribPointers(h,t,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Oi=(t,i,r,n,s)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):e.bp.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:s?0:r?r.calculateFogBlendOpacity(n):0,u_horizon_color:r?r.properties.get("horizon-color"):e.bp.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:s?1:0}),Ni={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Vi(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class ji{constructor(t,i,r,n,s,o,a,l,c=[]){const h=t.gl;this.program=h.createProgram();const u=Vi(i.staticAttributes),p=r?r.getBinderAttributes():[],d=u.concat(p),f=ze.prelude.staticUniforms?Vi(ze.prelude.staticUniforms):[],m=a.staticUniforms?Vi(a.staticUniforms):[],_=i.staticUniforms?Vi(i.staticUniforms):[],g=r?r.getBinderUniforms():[],y=f.concat(m).concat(_).concat(g),v=[];for(const t of y)v.indexOf(t)<0&&v.push(t);const x=r?r.defines():[];si(h)&&x.unshift("#version 300 es"),s&&x.push("#define OVERDRAW_INSPECTOR;"),o&&x.push("#define TERRAIN3D;"),l&&x.push(l),c&&x.push(...c);let b=x.concat(ze.prelude.fragmentSource,a.fragmentSource,i.fragmentSource).join("\n"),w=x.concat(ze.prelude.vertexSource,a.vertexSource,i.vertexSource).join("\n");si(h)||(b=function(t){return t.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(b),w=function(t){return t.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(w));const S=h.createShader(h.FRAGMENT_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(S,b),h.compileShader(S),!h.getShaderParameter(S,h.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${h.getShaderInfoLog(S)}`);h.attachShader(this.program,S);const T=h.createShader(h.VERTEX_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(T,w),h.compileShader(T),!h.getShaderParameter(T,h.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${h.getShaderInfoLog(T)}`);h.attachShader(this.program,T),this.attributes={};const C={};this.numAttributes=d.length;for(let t=0;t<this.numAttributes;t++)d[t]&&(h.bindAttribLocation(this.program,t,d[t]),this.attributes[d[t]]=t);if(h.linkProgram(this.program),!h.getProgramParameter(this.program,h.LINK_STATUS))throw new Error(`Program failed to link: ${h.getProgramInfoLog(this.program)}`);h.deleteShader(T),h.deleteShader(S);for(let t=0;t<v.length;t++){const e=v[t];if(e&&!C[e]){const t=h.getUniformLocation(this.program,e);t&&(C[e]=t)}}this.fixedUniforms=n(t,C),this.terrainUniforms=((t,i)=>({u_depth:new e.b_(t,i.u_depth),u_terrain:new e.b_(t,i.u_terrain),u_terrain_dim:new e.bq(t,i.u_terrain_dim),u_terrain_matrix:new e.c0(t,i.u_terrain_matrix),u_terrain_unpack:new e.c1(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.bq(t,i.u_terrain_exaggeration)}))(t,C),this.projectionUniforms=((t,i)=>({u_projection_matrix:new e.c0(t,i.u_projection_matrix),u_projection_tile_mercator_coords:new e.c1(t,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new e.c1(t,i.u_projection_clipping_plane),u_projection_transition:new e.bq(t,i.u_projection_transition),u_projection_fallback_matrix:new e.c0(t,i.u_projection_fallback_matrix)}))(t,C),this.binderUniforms=r?r.getUniforms(t,C):[]}draw(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y){const v=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(s),a){t.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,a.depthTexture),t.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,a.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(a[t])}if(l)for(const t in l)this.projectionUniforms[Ni[t]].set(l[t]);if(o)for(const t in this.fixedUniforms)this.fixedUniforms[t].set(o[t]);m&&m.setUniforms(t,this.binderUniforms,d,{zoom:f});let x=0;switch(e){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1}for(const i of p.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new Bi)).bind(t,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,_,g,y),v.drawElements(e,i.primitiveLength*x,v.UNSIGNED_SHORT,i.primitiveOffset*x*2)}}}function qi(t,i,r){const n=1/e.aN(r,1,i.transform.tileZoom),s=Math.pow(2,r.tileID.overscaledZ),o=r.tileSize*Math.pow(2,i.transform.tileZoom)/s,a=o*(r.tileID.canonical.x+r.tileID.wrap*s),l=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[n,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Gi=(t,i,r,n)=>{const s=t.style.light,o=s.properties.get("position"),a=[o.x,o.y,o.z],l=e.c4();"viewport"===s.properties.get("anchor")&&e.c5(l,t.transform.bearingInRadians),e.c6(a,a,l);const c=t.transform.transformLightDirection(a),h=s.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:n}},Ui=(t,i,r,n,s,o,a)=>e.e(Gi(t,i,r,n),qi(o,t,a),{u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8}),$i=(t,i,r,n)=>e.e(qi(i,t,r),{u_fill_translate:n}),Zi=(t,e)=>({u_world:t,u_fill_translate:e}),Wi=(t,i,r,n,s)=>e.e($i(t,i,r,s),{u_world:n}),Hi=(t,i,r,n,s)=>{const o=t.transform;let a,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const t=e.aN(i,1,o.zoom);a=!0,l=[t,t],c=t/(e.a5*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*s}else a=!1,l=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:n}},Xi=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Yi=t=>({u_viewport_size:[t.width,t.height]}),Ki=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),Ji=(t,i,r,n)=>{const s=e.aN(t,1,i)/(e.a5*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*n;return{u_extrude_scale:e.aN(t,1,i),u_intensity:r,u_globe_extrude_scale:s}},Qi=(t,i,r,n)=>{const s=e.N();e.c7(s,0,t.width,t.height,0,0,1);const o=t.context.gl;return{u_matrix:s,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:n,u_opacity:i.paint.get("heatmap-opacity")}},tr=(t,e,i)=>{const r=i.paint.get("hillshade-accent-color");let n;switch(i.paint.get("hillshade-method")){case"basic":n=4;break;case"combined":n=1;break;case"igor":n=2;break;case"multidirectional":n=3;break;default:n=0}const s=i.getIlluminationProperties();for(let e=0;e<s.directionRadians.length;e++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s.directionRadians[e]+=t.transform.bearingInRadians);return{u_image:0,u_latrange:ir(0,e.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:s.altitudeRadians,u_azimuths:s.directionRadians,u_accent:r,u_method:n,u_highlights:s.highlightColor,u_shadows:s.shadowColor}},er=(t,i)=>{const r=i.stride,n=e.N();return e.c7(n,0,e.a5,-e.a5,0,0,1),e.O(n,n,[0,-e.a5,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}};function ir(t,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new e.a9(0,n/r).toLngLat().lat,new e.a9(0,(n+1)/r).toLngLat().lat]}const rr=(t,e,i=0)=>({u_image:0,u_unpack:e.getUnpackVector(),u_dimension:[e.stride,e.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:t.paint.get("color-relief-opacity")}),nr=(t,i,r,n)=>{const s=t.transform;return{u_translation:hr(t,i,r),u_ratio:n/e.aN(i,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},sr=(t,i,r,n,s)=>e.e(nr(t,i,r,n),{u_image:0,u_image_height:s}),or=(t,i,r,n,s)=>{const o=t.transform,a=cr(i,o);return{u_translation:hr(t,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:n/e.aN(i,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},ar=(t,i,r,n,s)=>{const o=cr(i,t.transform);return e.e(nr(t,i,r,n),{u_tileratio:o,u_crossfade_from:s.fromScale,u_crossfade_to:s.toScale,u_image:0,u_mix:s.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},lr=(t,i,r,n,s,o)=>{const a=cr(i,t.transform);return e.e(nr(t,i,r,n),{u_image:0,u_image_height:o,u_tileratio:a,u_crossfade_from:s.fromScale,u_crossfade_to:s.toScale,u_image_dash:1,u_mix:s.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function cr(t,i){return 1/e.aN(t,1,i.tileZoom)}function hr(t,i,r){return e.aO(t.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const ur=(t,e,i,r,n)=>{return{u_tl_parent:t,u_scale_parent:e,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(o=r.paint.get("raster-saturation"),o>0?1-1/(1.001-o):-o),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:pr(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]};var s,o};function pr(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const dr=(t,e,i,r,n,s,o,a,l,c,h,u,p)=>{const d=o.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:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:d.width/d.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:s,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:p}},fr=(t,i,r,n,s,o,a,l,c,h,u,p,d,f)=>{const m=a.transform;return e.e(dr(t,i,r,n,s,o,a,l,c,h,u,p,f),{u_gamma_scale:n?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},mr=(t,i,r,n,s,o,a,l,c,h,u,p,d)=>e.e(fr(t,i,r,n,s,o,a,l,c,h,!0,u,0,d),{u_texsize_icon:p,u_texture_icon:1}),_r=(t,e)=>({u_opacity:t,u_color:e}),gr=(t,i,r,n,s)=>e.e(function(t,i,r,n){const s=r.imageManager.getPattern(t.from.toString()),o=r.imageManager.getPattern(t.to.toString()),{width:a,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,n.tileID.overscaledZ),h=n.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(n.tileID.canonical.x+n.tileID.wrap*c),p=h*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/e.aN(n,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,p>>16],u_pixel_coord_lower:[65535&u,65535&p]}}(r,s,i,n),{u_opacity:t}),yr=(t,e)=>{},vr={fillExtrusion:(t,i)=>({u_lightpos:new e.c2(t,i.u_lightpos),u_lightpos_globe:new e.c2(t,i.u_lightpos_globe),u_lightintensity:new e.bq(t,i.u_lightintensity),u_lightcolor:new e.c2(t,i.u_lightcolor),u_vertical_gradient:new e.bq(t,i.u_vertical_gradient),u_opacity:new e.bq(t,i.u_opacity),u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillExtrusionPattern:(t,i)=>({u_lightpos:new e.c2(t,i.u_lightpos),u_lightpos_globe:new e.c2(t,i.u_lightpos_globe),u_lightintensity:new e.bq(t,i.u_lightintensity),u_lightcolor:new e.c2(t,i.u_lightcolor),u_vertical_gradient:new e.bq(t,i.u_vertical_gradient),u_height_factor:new e.bq(t,i.u_height_factor),u_opacity:new e.bq(t,i.u_opacity),u_fill_translate:new e.c3(t,i.u_fill_translate),u_image:new e.b_(t,i.u_image),u_texsize:new e.c3(t,i.u_texsize),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bq(t,i.u_fade)}),fill:(t,i)=>({u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillPattern:(t,i)=>({u_image:new e.b_(t,i.u_image),u_texsize:new e.c3(t,i.u_texsize),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bq(t,i.u_fade),u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillOutline:(t,i)=>({u_world:new e.c3(t,i.u_world),u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillOutlinePattern:(t,i)=>({u_world:new e.c3(t,i.u_world),u_image:new e.b_(t,i.u_image),u_texsize:new e.c3(t,i.u_texsize),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bq(t,i.u_fade),u_fill_translate:new e.c3(t,i.u_fill_translate)}),circle:(t,i)=>({u_camera_to_center_distance:new e.bq(t,i.u_camera_to_center_distance),u_scale_with_map:new e.b_(t,i.u_scale_with_map),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_extrude_scale:new e.c3(t,i.u_extrude_scale),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_globe_extrude_scale:new e.bq(t,i.u_globe_extrude_scale),u_translate:new e.c3(t,i.u_translate)}),collisionBox:(t,i)=>({u_pixel_extrude_scale:new e.c3(t,i.u_pixel_extrude_scale)}),collisionCircle:(t,i)=>({u_viewport_size:new e.c3(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.b$(t,i.u_color),u_overlay:new e.b_(t,i.u_overlay),u_overlay_scale:new e.bq(t,i.u_overlay_scale)}),depth:yr,clippingMask:yr,heatmap:(t,i)=>({u_extrude_scale:new e.bq(t,i.u_extrude_scale),u_intensity:new e.bq(t,i.u_intensity),u_globe_extrude_scale:new e.bq(t,i.u_globe_extrude_scale)}),heatmapTexture:(t,i)=>({u_matrix:new e.c0(t,i.u_matrix),u_world:new e.c3(t,i.u_world),u_image:new e.b_(t,i.u_image),u_color_ramp:new e.b_(t,i.u_color_ramp),u_opacity:new e.bq(t,i.u_opacity)}),hillshade:(t,i)=>({u_image:new e.b_(t,i.u_image),u_latrange:new e.c3(t,i.u_latrange),u_exaggeration:new e.bq(t,i.u_exaggeration),u_altitudes:new e.c9(t,i.u_altitudes),u_azimuths:new e.c9(t,i.u_azimuths),u_accent:new e.b$(t,i.u_accent),u_method:new e.b_(t,i.u_method),u_shadows:new e.c8(t,i.u_shadows),u_highlights:new e.c8(t,i.u_highlights)}),hillshadePrepare:(t,i)=>({u_matrix:new e.c0(t,i.u_matrix),u_image:new e.b_(t,i.u_image),u_dimension:new e.c3(t,i.u_dimension),u_zoom:new e.bq(t,i.u_zoom),u_unpack:new e.c1(t,i.u_unpack)}),colorRelief:(t,i)=>({u_image:new e.b_(t,i.u_image),u_unpack:new e.c1(t,i.u_unpack),u_dimension:new e.c3(t,i.u_dimension),u_elevation_stops:new e.b_(t,i.u_elevation_stops),u_color_stops:new e.b_(t,i.u_color_stops),u_color_ramp_size:new e.b_(t,i.u_color_ramp_size),u_opacity:new e.bq(t,i.u_opacity)}),line:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bq(t,i.u_ratio),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bq(t,i.u_ratio),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_image:new e.b_(t,i.u_image),u_image_height:new e.bq(t,i.u_image_height)}),linePattern:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_texsize:new e.c3(t,i.u_texsize),u_ratio:new e.bq(t,i.u_ratio),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_image:new e.b_(t,i.u_image),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bq(t,i.u_fade)}),lineSDF:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bq(t,i.u_ratio),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_image:new e.b_(t,i.u_image),u_mix:new e.bq(t,i.u_mix),u_tileratio:new e.bq(t,i.u_tileratio),u_crossfade_from:new e.bq(t,i.u_crossfade_from),u_crossfade_to:new e.bq(t,i.u_crossfade_to),u_lineatlas_width:new e.bq(t,i.u_lineatlas_width),u_lineatlas_height:new e.bq(t,i.u_lineatlas_height)}),lineGradientSDF:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bq(t,i.u_ratio),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_image:new e.b_(t,i.u_image),u_image_height:new e.bq(t,i.u_image_height),u_tileratio:new e.bq(t,i.u_tileratio),u_crossfade_from:new e.bq(t,i.u_crossfade_from),u_crossfade_to:new e.bq(t,i.u_crossfade_to),u_image_dash:new e.b_(t,i.u_image_dash),u_mix:new e.bq(t,i.u_mix),u_lineatlas_width:new e.bq(t,i.u_lineatlas_width),u_lineatlas_height:new e.bq(t,i.u_lineatlas_height)}),raster:(t,i)=>({u_tl_parent:new e.c3(t,i.u_tl_parent),u_scale_parent:new e.bq(t,i.u_scale_parent),u_buffer_scale:new e.bq(t,i.u_buffer_scale),u_fade_t:new e.bq(t,i.u_fade_t),u_opacity:new e.bq(t,i.u_opacity),u_image0:new e.b_(t,i.u_image0),u_image1:new e.b_(t,i.u_image1),u_brightness_low:new e.bq(t,i.u_brightness_low),u_brightness_high:new e.bq(t,i.u_brightness_high),u_saturation_factor:new e.bq(t,i.u_saturation_factor),u_contrast_factor:new e.bq(t,i.u_contrast_factor),u_spin_weights:new e.c2(t,i.u_spin_weights),u_coords_top:new e.c1(t,i.u_coords_top),u_coords_bottom:new e.c1(t,i.u_coords_bottom)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.b_(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.b_(t,i.u_is_size_feature_constant),u_size_t:new e.bq(t,i.u_size_t),u_size:new e.bq(t,i.u_size),u_camera_to_center_distance:new e.bq(t,i.u_camera_to_center_distance),u_pitch:new e.bq(t,i.u_pitch),u_rotate_symbol:new e.b_(t,i.u_rotate_symbol),u_aspect_ratio:new e.bq(t,i.u_aspect_ratio),u_fade_change:new e.bq(t,i.u_fade_change),u_label_plane_matrix:new e.c0(t,i.u_label_plane_matrix),u_coord_matrix:new e.c0(t,i.u_coord_matrix),u_is_text:new e.b_(t,i.u_is_text),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_is_along_line:new e.b_(t,i.u_is_along_line),u_is_variable_anchor:new e.b_(t,i.u_is_variable_anchor),u_texsize:new e.c3(t,i.u_texsize),u_texture:new e.b_(t,i.u_texture),u_translation:new e.c3(t,i.u_translation),u_pitched_scale:new e.bq(t,i.u_pitched_scale)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.b_(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.b_(t,i.u_is_size_feature_constant),u_size_t:new e.bq(t,i.u_size_t),u_size:new e.bq(t,i.u_size),u_camera_to_center_distance:new e.bq(t,i.u_camera_to_center_distance),u_pitch:new e.bq(t,i.u_pitch),u_rotate_symbol:new e.b_(t,i.u_rotate_symbol),u_aspect_ratio:new e.bq(t,i.u_aspect_ratio),u_fade_change:new e.bq(t,i.u_fade_change),u_label_plane_matrix:new e.c0(t,i.u_label_plane_matrix),u_coord_matrix:new e.c0(t,i.u_coord_matrix),u_is_text:new e.b_(t,i.u_is_text),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_is_along_line:new e.b_(t,i.u_is_along_line),u_is_variable_anchor:new e.b_(t,i.u_is_variable_anchor),u_texsize:new e.c3(t,i.u_texsize),u_texture:new e.b_(t,i.u_texture),u_gamma_scale:new e.bq(t,i.u_gamma_scale),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_is_halo:new e.b_(t,i.u_is_halo),u_translation:new e.c3(t,i.u_translation),u_pitched_scale:new e.bq(t,i.u_pitched_scale)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.b_(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.b_(t,i.u_is_size_feature_constant),u_size_t:new e.bq(t,i.u_size_t),u_size:new e.bq(t,i.u_size),u_camera_to_center_distance:new e.bq(t,i.u_camera_to_center_distance),u_pitch:new e.bq(t,i.u_pitch),u_rotate_symbol:new e.b_(t,i.u_rotate_symbol),u_aspect_ratio:new e.bq(t,i.u_aspect_ratio),u_fade_change:new e.bq(t,i.u_fade_change),u_label_plane_matrix:new e.c0(t,i.u_label_plane_matrix),u_coord_matrix:new e.c0(t,i.u_coord_matrix),u_is_text:new e.b_(t,i.u_is_text),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_is_along_line:new e.b_(t,i.u_is_along_line),u_is_variable_anchor:new e.b_(t,i.u_is_variable_anchor),u_texsize:new e.c3(t,i.u_texsize),u_texsize_icon:new e.c3(t,i.u_texsize_icon),u_texture:new e.b_(t,i.u_texture),u_texture_icon:new e.b_(t,i.u_texture_icon),u_gamma_scale:new e.bq(t,i.u_gamma_scale),u_device_pixel_ratio:new e.bq(t,i.u_device_pixel_ratio),u_is_halo:new e.b_(t,i.u_is_halo),u_translation:new e.c3(t,i.u_translation),u_pitched_scale:new e.bq(t,i.u_pitched_scale)}),background:(t,i)=>({u_opacity:new e.bq(t,i.u_opacity),u_color:new e.b$(t,i.u_color)}),backgroundPattern:(t,i)=>({u_opacity:new e.bq(t,i.u_opacity),u_image:new e.b_(t,i.u_image),u_pattern_tl_a:new e.c3(t,i.u_pattern_tl_a),u_pattern_br_a:new e.c3(t,i.u_pattern_br_a),u_pattern_tl_b:new e.c3(t,i.u_pattern_tl_b),u_pattern_br_b:new e.c3(t,i.u_pattern_br_b),u_texsize:new e.c3(t,i.u_texsize),u_mix:new e.bq(t,i.u_mix),u_pattern_size_a:new e.c3(t,i.u_pattern_size_a),u_pattern_size_b:new e.c3(t,i.u_pattern_size_b),u_scale_a:new e.bq(t,i.u_scale_a),u_scale_b:new e.bq(t,i.u_scale_b),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.bq(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_texture:new e.b_(t,i.u_texture),u_ele_delta:new e.bq(t,i.u_ele_delta),u_fog_matrix:new e.c0(t,i.u_fog_matrix),u_fog_color:new e.b$(t,i.u_fog_color),u_fog_ground_blend:new e.bq(t,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.bq(t,i.u_fog_ground_blend_opacity),u_horizon_color:new e.b$(t,i.u_horizon_color),u_horizon_fog_blend:new e.bq(t,i.u_horizon_fog_blend),u_is_globe_mode:new e.bq(t,i.u_is_globe_mode)}),terrainDepth:(t,i)=>({u_ele_delta:new e.bq(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_texture:new e.b_(t,i.u_texture),u_terrain_coords_id:new e.bq(t,i.u_terrain_coords_id),u_ele_delta:new e.bq(t,i.u_ele_delta)}),projectionErrorMeasurement:(t,i)=>({u_input:new e.bq(t,i.u_input),u_output_expected:new e.bq(t,i.u_output_expected)}),atmosphere:(t,i)=>({u_sun_pos:new e.c2(t,i.u_sun_pos),u_atmosphere_blend:new e.bq(t,i.u_atmosphere_blend),u_globe_position:new e.c2(t,i.u_globe_position),u_globe_radius:new e.bq(t,i.u_globe_radius),u_inv_proj_matrix:new e.c0(t,i.u_inv_proj_matrix)}),sky:(t,i)=>({u_sky_color:new e.b$(t,i.u_sky_color),u_horizon_color:new e.b$(t,i.u_horizon_color),u_horizon:new e.c3(t,i.u_horizon),u_horizon_normal:new e.c3(t,i.u_horizon_normal),u_sky_horizon_blend:new e.bq(t,i.u_sky_horizon_blend),u_sky_blend:new e.bq(t,i.u_sky_blend)})};class xr{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const br={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wr{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],s=e.attributes[n.name];void 0!==s&&t.vertexAttribPointer(s,n.components,t[br[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Sr{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Tr extends Sr{getDefault(){return e.bp.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Cr extends Sr{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Mr extends Sr{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Er extends Sr{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Ar extends Sr{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Ir extends Sr{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Pr extends Sr{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Dr extends Sr{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class kr extends Sr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class zr extends Sr{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Rr extends Sr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class Lr extends Sr{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Fr extends Sr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Br extends Sr{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Or extends Sr{getDefault(){return e.bp.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Nr extends Sr{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Vr extends Sr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class jr extends Sr{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class qr extends Sr{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Gr extends Sr{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Ur extends Sr{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class $r extends Sr{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Zr extends Sr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Wr extends Sr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Hr extends Sr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Xr extends Sr{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Yr extends Sr{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Kr extends Sr{getDefault(){return null}set(t){var e;if(t===this.current&&!this.dirty)return;const i=this.gl;si(i)?i.bindVertexArray(t):null===(e=i.getExtension("OES_vertex_array_object"))||void 0===e||e.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Jr extends Sr{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class Qr extends Sr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class tn extends Sr{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class en extends Sr{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class rn extends en{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class nn extends en{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class sn extends en{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const on="Framebuffer is not complete";class an{constructor(t,e,i,r,n){this.context=t,this.width=e,this.height=i;const s=t.gl,o=this.framebuffer=s.createFramebuffer();if(this.colorAttachment=new rn(t,o),r)this.depthAttachment=n?new sn(t,o):new nn(t,o);else if(n)throw new Error("Stencil cannot be set without depth");if(s.checkFramebufferStatus(s.FRAMEBUFFER)!==s.FRAMEBUFFER_COMPLETE)throw new Error(on)}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class ln{constructor(t){var e,i;if(this.gl=t,this.clearColor=new Tr(this),this.clearDepth=new Cr(this),this.clearStencil=new Mr(this),this.colorMask=new Er(this),this.depthMask=new Ar(this),this.stencilMask=new Ir(this),this.stencilFunc=new Pr(this),this.stencilOp=new Dr(this),this.stencilTest=new kr(this),this.depthRange=new zr(this),this.depthTest=new Rr(this),this.depthFunc=new Lr(this),this.blend=new Fr(this),this.blendFunc=new Br(this),this.blendColor=new Or(this),this.blendEquation=new Nr(this),this.cullFace=new Vr(this),this.cullFaceSide=new jr(this),this.frontFace=new qr(this),this.program=new Gr(this),this.activeTexture=new Ur(this),this.viewport=new $r(this),this.bindFramebuffer=new Zr(this),this.bindRenderbuffer=new Wr(this),this.bindTexture=new Hr(this),this.bindVertexBuffer=new Xr(this),this.bindElementBuffer=new Yr(this),this.bindVertexArray=new Kr(this),this.pixelStoreUnpack=new Jr(this),this.pixelStoreUnpackPremultiplyAlpha=new Qr(this),this.pixelStoreUnpackFlipY=new tn(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),si(t)){this.HALF_FLOAT=t.HALF_FLOAT;const r=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(e=t.RGBA16F)&&void 0!==e?e:null==r?void 0:r.RGBA16F_EXT,this.RGB16F=null!==(i=t.RGB16F)&&void 0!==i?i:null==r?void 0:r.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const e=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==e?void 0:e.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new xr(this,t,e)}createVertexBuffer(t,e,i){return new wr(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i,r){return new an(this,t,e,i,r)}clear({color:t,depth:e,stencil:i}){const r=this.gl;let n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){e.bR(t.blendFunction,Je.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return si(this.gl)?this.gl.createVertexArray():null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var e;return si(this.gl)?this.gl.deleteVertexArray(t):null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let cn;function hn(t,i,r,n,s){const o=t.context,a=t.transform,l=o.gl,c=t.useProgram("collisionBox"),h=[];let u=0,p=0;for(let e=0;e<n.length;e++){const d=n[e],f=i.getTile(d).getBucket(r);if(!f)continue;const m=s?f.textCollisionBox:f.iconCollisionBox,_=f.collisionCircleArray;_.length>0&&(h.push({circleArray:_,circleOffset:p,coord:d}),u+=_.length/4,p=u),m&&c.draw(o,l.LINES,ei.disabled,ri.disabled,t.colorModeForRenderPass(),ti.disabled,Xi(t.transform),t.style.map.terrain&&t.style.map.terrain.getTerrainData(d),a.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,t.transform.zoom,null,null,m.collisionVertexBuffer)}if(!s||!h.length)return;const d=t.useProgram("collisionCircle"),f=new e.ca;f.resize(4*u),f._trim();let m=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],s=t.circleArray[i+2],o=t.circleArray[i+3];f.emplace(m++,r,n,s,o,0),f.emplace(m++,r,n,s,o,1),f.emplace(m++,r,n,s,o,2),f.emplace(m++,r,n,s,o,3)}(!cn||cn.length<2*u)&&(cn=function(t){const i=2*t,r=new e.cc;r.resize(i),r._trim();for(let t=0;t<i;t++){const e=6*t;r.uint16[e+0]=4*t+0,r.uint16[e+1]=4*t+1,r.uint16[e+2]=4*t+2,r.uint16[e+3]=4*t+2,r.uint16[e+4]=4*t+3,r.uint16[e+5]=4*t+0}return r}(u));const _=o.createIndexBuffer(cn,!0),g=o.createVertexBuffer(f,e.cb.members,!0);for(const i of h){const n=Yi(t.transform);d.draw(o,l.TRIANGLES,ei.disabled,ri.disabled,t.colorModeForRenderPass(),ti.disabled,n,t.style.map.terrain&&t.style.map.terrain.getTerrainData(i.coord),null,r.id,g,_,e.aX.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}g.destroy(),_.destroy()}const un=e.ar(new Float32Array(16));function pn(t,i,r,n,s,o){const{horizontalAlign:a,verticalAlign:l}=e.aS(t);return new e.P((-(a-.5)*i/s+n[0])*o,(-(l-.5)*r/s+n[1])*o)}function dn(t,i,r,n,s,o){const a=i.tileAnchorPoint.add(new e.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let t=n.mult(o);r||(t=t.rotate(-s));const e=a.add(t);return qt(e.x,e.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(r){const e=Kt(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(t),r=Math.atan(e.y/e.x)+(e.x<0?Math.PI:0);return t.add(n.rotate(r))}return t.add(n)}function fn(t,i,r,n,s,o,a,l,c,h,u,p){const d=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,_={};f.clear();for(let m=0;m<d.length;m++){const g=d.get(m),y=g.hidden||!g.crossTileID||t.allowVerticalPlacement&&!g.placedOrientation?null:n[g.crossTileID];if(y){const n=new e.P(g.anchorX,g.anchorY),d={getElevation:p,width:s.width,height:s.height,pitchedLabelPlaneMatrix:o,pitchWithMap:r,transform:s,tileAnchorPoint:n,translation:h,unwrappedTileID:u},m=r?Qt(n.x,n.y,d):Kt(n.x,n.y,d),v=Gt(s.cameraToCenterDistance,m.signedDistanceFromCamera);let x=e.aA(t.textSizeData,l,g)*v/e.aM;r&&(x*=t.tilePixelRatio/a);const{width:b,height:w,anchor:S,textOffset:T,textBoxScale:C}=y,M=pn(S,b,w,T,C,x),E=s.getPitchedTextCorrection(n.x+h[0],n.y+h[1],u),A=dn(m.point,d,i,M,-s.bearingInRadians,E),I=t.allowVerticalPlacement&&g.placedOrientation===e.az.vertical?Math.PI/2:0;for(let t=0;t<g.numGlyphs;t++)e.aG(f,A,I);c&&g.associatedIconIndex>=0&&(_[g.associatedIconIndex]={shiftedAnchor:A,angle:I})}else ne(g.numGlyphs,f)}if(c){m.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const r=i.get(t);if(r.hidden)ne(r.numGlyphs,m);else{const i=_[t];if(i)for(let t=0;t<r.numGlyphs;t++)e.aG(m,i.shiftedAnchor,i.angle);else ne(r.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(f)}function mn(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function _n(t,i,r,n,s,o,a,l,c,h,u,p,d){const f=t.context,m=f.gl,_=t.transform,g="map"===l,y="map"===c,v="viewport"!==l&&"point"!==r.layout.get("symbol-placement"),x=g&&!y&&!v,b=!r.layout.get("symbol-sort-key").isConstant();let w=!1;const S=t.getDepthModeForSublayer(0,ei.ReadOnly),T=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),C=[],M=_.getCircleRadiusCorrection();for(const l of n){const n=i.getTile(l),c=n.getBucket(r);if(!c)continue;const u=s?c.text:c.icon;if(!u||!u.segments.get().length||!u.hasVisibleVertices)continue;const p=u.programConfigurations.get(r.id),f=s||c.sdfIcons,S=s?c.textSizeData:c.iconSizeData,E=y||0!==_.pitch,A=t.useProgram(mn(f,s,c),p),I=e.ay(S,_.zoom),P=t.style.map.terrain&&t.style.map.terrain.getTerrainData(l);let D,k,z,R,L=[0,0],F=null;if(s)k=n.glyphAtlasTexture,z=m.LINEAR,D=n.glyphAtlasTexture.size,c.iconsInText&&(L=n.imageAtlasTexture.size,F=n.imageAtlasTexture,R=E||t.options.rotating||t.options.zooming||"composite"===S.kind||"camera"===S.kind?m.LINEAR:m.NEAREST);else{const e=1!==r.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;k=n.imageAtlasTexture,z=f||t.options.rotating||t.options.zooming||e||E?m.LINEAR:m.NEAREST,D=n.imageAtlasTexture.size}const B=e.aN(n,1,t.transform.zoom),O=Nt(g,t.transform,B),N=e.N();e.aB(N,O);const V=Vt(y,g,t.transform,B),j=e.aO(_,n,o,a),q=_.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!d,applyTerrainMatrix:!0}),G=T&&c.hasTextData(),U="none"!==r.layout.get("icon-text-fit")&&G&&c.hasIconData();if(v){const e=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(l,e,i):null,i="map"===r.layout.get("text-rotation-alignment");$t(c,t,s,O,N,y,h,i,l.toUnwrapped(),_.width,_.height,j,e)}const $=s&&T||U,Z=v||$?un:y?O:t.transform.clipSpaceToPixelsMatrix,W=f&&0!==r.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let H;H=f?c.iconsInText?mr(S.kind,I,x,y,v,$,t,Z,V,j,D,L,M):fr(S.kind,I,x,y,v,$,t,Z,V,j,s,D,0,M):dr(S.kind,I,x,y,v,$,t,Z,V,j,s,D,M);const X={program:A,buffers:u,uniformValues:H,projectionData:q,atlasTexture:k,atlasTextureIcon:F,atlasInterpolation:z,atlasInterpolationIcon:R,isSDF:f,hasHalo:W};if(b&&c.canOverlap){w=!0;const t=u.segments.get();for(const i of t)C.push({segments:new e.aX([i]),sortKey:i.sortKey,state:X,terrainData:P})}else C.push({segments:u.segments,sortKey:0,state:X,terrainData:P})}w&&C.sort((t,e)=>t.sortKey-e.sortKey);for(const e of C){const i=e.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,gn(i.buffers,e.segments,r,t,i.program,S,u,p,n,i.projectionData,e.terrainData)),n.u_is_halo=0}gn(i.buffers,e.segments,r,t,i.program,S,u,p,i.uniformValues,i.projectionData,e.terrainData)}}function gn(t,e,i,r,n,s,o,a,l,c,h){const u=r.context;n.draw(u,u.gl.TRIANGLES,s,o,a,ti.backCCW,l,h,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function yn(t,i,r,n,s){const o=t.context,a=o.gl,l=ri.disabled,c=new Je([a.ONE,a.ONE],e.bp.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=n.key;let p=r.heatmapFbos.get(u);p||(p=xn(o,i.tileSize,i.tileSize),r.heatmapFbos.set(u,p)),o.bindFramebuffer.set(p.framebuffer),o.viewport.set([0,0,i.tileSize,i.tileSize]),o.clear({color:e.bp.transparent});const d=h.programConfigurations.get(r.id),f=t.useProgram("heatmap",d,!s),m=t.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),_=t.style.map.terrain.getTerrainData(n);f.draw(o,a.TRIANGLES,ei.disabled,l,c,ti.disabled,Ji(i,t.transform.zoom,r.paint.get("heatmap-intensity"),1),_,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,t.transform.zoom,d)}function vn(t,e,i,r,n){const s=t.context,o=s.gl,a=t.transform;s.setColorMode(t.colorModeForRenderPass());const l=bn(s,e),c=i.key,h=e.heatmapFbos.get(c);if(!h)return;s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,h.colorAttachment.get()),s.activeTexture.set(o.TEXTURE1),l.bind(o.LINEAR,o.CLAMP_TO_EDGE);const u=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});t.useProgram("heatmapTexture").draw(s,o.TRIANGLES,ei.disabled,ri.disabled,t.colorModeForRenderPass(),ti.disabled,Qi(t,e,0,1),null,u,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,a.zoom),h.destroy(),e.heatmapFbos.delete(c)}function xn(t,e,i){var r,n;const s=t.gl,o=s.createTexture();s.bindTexture(s.TEXTURE_2D,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR);const a=null!==(r=t.HALF_FLOAT)&&void 0!==r?r:s.UNSIGNED_BYTE,l=null!==(n=t.RGBA16F)&&void 0!==n?n:s.RGBA;s.texImage2D(s.TEXTURE_2D,0,l,e,i,0,s.RGBA,a,null);const c=t.createFramebuffer(e,i,!1,!1);return c.colorAttachment.set(o),c}function bn(t,i){return i.colorRampTexture||(i.colorRampTexture=new e.T(t,i.colorRamp,t.gl.RGBA)),i.colorRampTexture}function wn(t,i,r,n,s,o,a,l){let c=256;if(s.stepInterpolant){const n=i.getSource().maxzoom,s=a.canonical.z===n?Math.ceil(1<<t.transform.maxZoom-a.canonical.z):1;c=e.an(e.ce(o.maxLineLength/e.a5*1024*s),256,r.maxTextureSize)}return l.gradient=e.cf({expression:s.gradientExpression(),evaluationKey:"lineProgress",resolution:c,image:l.gradient||void 0,clips:o.lineClipsArray}),l.texture?l.texture.update(l.gradient):l.texture=new e.T(r,l.gradient,n.RGBA),l.version=s.gradientVersion,l.texture}function Sn(t,e,i,r,n){t.activeTexture.set(e.TEXTURE0),i.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),r.updatePaintBuffers(n)}function Tn(t,e,i,r,n,s){(n||t.lineAtlas.dirty)&&(e.activeTexture.set(i.TEXTURE0),t.lineAtlas.bind(e)),r.updatePaintBuffers(s)}function Cn(t,e,i,r,n,s,o){const a=s.gradients[n.id];let l=a.texture;n.gradientVersion!==a.version&&(l=wn(t,e,i,r,n,s,o,a)),i.activeTexture.set(r.TEXTURE0),l.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Mn(t,e,i,r,n,s,o,a,l){const c=s.gradients[n.id];let h=c.texture;n.gradientVersion!==c.version&&(h=wn(t,e,i,r,n,s,o,c)),i.activeTexture.set(r.TEXTURE0),h.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),t.lineAtlas.bind(i),a.updatePaintBuffers(l)}function En(t,e,i,r,n){if(!i||!r||!r.imageAtlas)return;const s=r.imageAtlas.patternPositions;let o=s[i.to.toString()],a=s[i.from.toString()];if(!o&&a&&(o=a),!a&&o&&(a=o),!o||!a){const t=n.getPaintProperty(e);o=s[t],a=s[t]}o&&a&&t.setConstantPatternPositions(o,a)}function An(t,i,r,n,s,o,a,l){const c=t.context.gl,h="fill-pattern",u=r.paint.get(h),p=u&&u.constantOr(1),d=r.getCrossfadeParameters();let f,m,_,g,y;const v=t.transform,x=r.paint.get("fill-translate"),b=r.paint.get("fill-translate-anchor");a?(m=p&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=p?"fillPattern":"fill",f=c.TRIANGLES);const w=u.constantOr(null);for(const u of n){const n=i.getTile(u);if(p&&!n.patternsLoaded())continue;const S=n.getBucket(r);if(!S)continue;const T=S.programConfigurations.get(r.id),C=t.useProgram(m,T),M=t.style.map.terrain&&t.style.map.terrain.getTerrainData(u);p&&(t.context.activeTexture.set(c.TEXTURE0),n.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),T.updatePaintBuffers(d)),En(T,h,w,n,r);const E=v.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),A=e.aO(v,n,x,b);if(a){g=S.indexBuffer2,y=S.segments2;const e=[c.drawingBufferWidth,c.drawingBufferHeight];_="fillOutlinePattern"===m&&p?Wi(t,d,n,e,A):Zi(e,A)}else g=S.indexBuffer,y=S.segments,_=p?$i(t,d,n,A):{u_fill_translate:A};const I=t.stencilModeForClipping(u);C.draw(t.context,f,s,I,o,ti.backCCW,_,M,E,r.id,S.layoutVertexBuffer,g,y,r.paint,t.transform.zoom,T)}}function In(t,i,r,n,s,o,a,l){const c=t.context,h=c.gl,u="fill-extrusion-pattern",p=r.paint.get(u),d=p.constantOr(1),f=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),_=p.constantOr(null),g=t.transform;for(const p of n){const n=i.getTile(p),y=n.getBucket(r);if(!y)continue;const v=t.style.map.terrain&&t.style.map.terrain.getTerrainData(p),x=y.programConfigurations.get(r.id),b=t.useProgram(d?"fillExtrusionPattern":"fillExtrusion",x);d&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers(f));const w=g.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!l,applyTerrainMatrix:!0});En(x,u,_,n,r);const S=e.aO(g,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),T=r.paint.get("fill-extrusion-vertical-gradient"),C=d?Ui(t,T,m,S,p,f,n):Gi(t,T,m,S);b.draw(c,c.gl.TRIANGLES,s,o,a,ti.backCCW,C,v,w,r.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,r.paint,t.transform.zoom,x,t.style.map.terrain&&y.centroidVertexBuffer)}}function Pn(t,e,i,r,n,s,o,a,l){var c;const h=t.style.projection,u=t.context,p=t.transform,d=u.gl,f=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=t.useProgram("hillshade",null,!1,f),_=!t.options.moving;for(const f of r){const r=e.getTile(f),g=r.fbo;if(!g)continue;const y=h.getMeshFromTileID(u,f.canonical,a,!0,"raster"),v=null===(c=t.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);u.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,g.colorAttachment.get());const x=p.getProjectionData({overscaledTileID:f,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,d.TRIANGLES,s,n[f.overscaledZ],o,ti.backCCW,tr(t,r,i),v,x,i.id,y.vertexBuffer,y.indexBuffer,y.segments)}}function Dn(t,i,r,n,s,o,a,l,c){var h;const u=t.style.projection,p=t.context,d=t.transform,f=p.gl,m=t.useProgram("colorRelief"),_=!t.options.moving;let g=!0,y=0;for(const v of n){const n=i.getTile(v),x=n.dem;if(g){const t=f.getParameter(f.MAX_TEXTURE_SIZE),{elevationTexture:e,colorTexture:i}=r.getColorRampTextures(p,t,x.getUnpackVector());p.activeTexture.set(f.TEXTURE1),e.bind(f.NEAREST,f.CLAMP_TO_EDGE),p.activeTexture.set(f.TEXTURE4),i.bind(f.LINEAR,f.CLAMP_TO_EDGE),g=!1,y=e.size[0]}if(!x||!x.data)continue;const b=x.stride,w=x.getPixels();if(p.activeTexture.set(f.TEXTURE0),p.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(b),n.demTexture){const t=n.demTexture;t.update(w,{premultiply:!1}),t.bind(f.LINEAR,f.CLAMP_TO_EDGE)}else n.demTexture=new e.T(p,w,f.RGBA,{premultiply:!1}),n.demTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const S=u.getMeshFromTileID(p,v.canonical,l,!0,"raster"),T=null===(h=t.style.map.terrain)||void 0===h?void 0:h.getTerrainData(v),C=d.getProjectionData({overscaledTileID:v,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(p,f.TRIANGLES,o,s[v.overscaledZ],a,ti.backCCW,rr(r,n.dem,y),T,C,r.id,S.vertexBuffer,S.indexBuffer,S.segments)}}const kn=[new e.P(0,0),new e.P(e.a5,0),new e.P(e.a5,e.a5),new e.P(0,e.a5)];function zn(t,e,i,r,n,s,o,a,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=t.context,p=u.gl,d=t.useProgram("raster"),f=t.transform,m=t.style.projection,_=t.colorModeForRenderPass(),g=!t.options.moving,y=i.paint.get("raster-opacity"),v=i.paint.get("raster-resampling"),x=i.paint.get("raster-fade-duration"),b=!!t.style.map.terrain;for(const w of r){const r=t.getDepthModeForSublayer(w.overscaledZ-h,1===y?ei.ReadWrite:ei.ReadOnly,p.LESS),S=e.getTile(w),T="nearest"===v?p.NEAREST:p.LINEAR;u.activeTexture.set(p.TEXTURE0),S.texture.bind(T,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(p.TEXTURE1);const{parentTile:C,parentScaleBy:M,parentTopLeft:E,fadeValues:A}=Rn(S,e,x,b);S.fadeOpacity=A.tileOpacity,C?(C.fadeOpacity=A.parentTileOpacity,C.texture.bind(T,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)):S.texture.bind(T,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),S.texture.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&p.texParameterf(p.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const I=t.style.map.terrain&&t.style.map.terrain.getTerrainData(w),P=f.getProjectionData({overscaledTileID:w,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),D=ur(E,M,A.fadeMix,i,a),k=m.getMeshFromTileID(u,w.canonical,s,o,"raster");d.draw(u,p.TRIANGLES,r,n?n[w.overscaledZ]:ri.disabled,_,l?ti.frontCCW:ti.backCCW,D,I,P,i.id,k.vertexBuffer,k.indexBuffer,k.segments)}}function Rn(t,i,r,n){const s={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===r||n)return s;if(t.fadingParentID){const n=i.getLoadedTile(t.fadingParentID);if(!n)return s;const o=Math.pow(2,n.tileID.overscaledZ-t.tileID.overscaledZ),a=[t.tileID.canonical.x*o%1,t.tileID.canonical.y*o%1],l=function(t,i,r){const n=c(),s=(n-i.timeAdded)/r,o=t.fadingDirection===ut.Incoming,a=e.an((n-t.timeAdded)/r,0,1),l=e.an(1-s,0,1),h=o?a:l;return{tileOpacity:h,parentTileOpacity:o?l:a,fadeMix:{opacity:1,mix:1-h}}}(t,n,r);return{parentTile:n,parentScaleBy:o,parentTopLeft:a,fadeValues:l}}if(t.selfFading){const i=function(t,i){const r=(c()-t.timeAdded)/i,n=e.an(r,0,1);return{tileOpacity:n,fadeMix:{opacity:n,mix:0}}}(t,r);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return s}const Ln=new e.bp(1,0,0,1),Fn=new e.bp(0,1,0,1),Bn=new e.bp(0,0,1,1),On=new e.bp(1,0,1,1),Nn=new e.bp(0,1,1,1);function Vn(t,e,i,r){qn(t,0,e+i/2,t.transform.width,i,r)}function jn(t,e,i,r){qn(t,e-i/2,0,i,t.transform.height,r)}function qn(t,e,i,r,n,s){const o=t.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio),o.clear({color:s}),a.disable(a.SCISSOR_TEST)}function Gn(t,i,r){const n=t.context,s=n.gl,o=t.useProgram("debug"),a=ei.disabled,l=ri.disabled,c=t.colorModeForRenderPass(),h="$debug",u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(r);n.activeTexture.set(s.TEXTURE0);const p=i.getTileByID(r.key).latestRawTileData,d=Math.floor((p&&p.byteLength||0)/1024),f=i.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/t.transform.zoom)*.5;let _=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(_+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${_} ${d}kB`);const g=t.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(n,s.TRIANGLES,a,l,Je.alphaBlended,ti.disabled,Ki(e.bp.transparent,m),null,g,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),o.draw(n,s.LINE_STRIP,a,l,c,ti.disabled,Ki(e.bp.red),u,g,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Un(t,e,i,r){const{isRenderingGlobe:n}=r,s=t.context,o=s.gl,a=t.transform,l=t.colorModeForRenderPass(),c=t.getDepthModeFor3D(),h=t.useProgram("terrain");s.bindFramebuffer.set(null),s.viewport.set([0,0,t.width,t.height]);for(const r of i){const i=e.getTerrainMesh(r.tileID),u=t.renderToTexture.getTexture(r),p=e.getTerrainData(r.tileID);s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.texture);const d=e.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=Oi(d,f,t.style.sky,a.pitch,n),_=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(s,o.TRIANGLES,c,ri.disabled,l,ti.backCCW,m,p,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function $n(t,i){if(!i.mesh){const r=new e.aW;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const n=new e.aY;n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),i.mesh=new Le(t.createVertexBuffer(r,Fe.members),t.createIndexBuffer(n),e.aX.simpleSegment(0,0,r.length,n.length))}return i.mesh}class Zn{constructor(t,i){this.context=new ln(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Lt.maxOverzooming+Lt.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new De}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,i=new e.aW;i.emplaceBack(0,0),i.emplaceBack(e.a5,0),i.emplaceBack(0,e.a5),i.emplaceBack(e.a5,e.a5),this.tileExtentBuffer=t.createVertexBuffer(i,Fe.members),this.tileExtentSegments=e.aX.simpleSegment(0,0,4,2);const r=new e.aW;r.emplaceBack(0,0),r.emplaceBack(e.a5,0),r.emplaceBack(0,e.a5),r.emplaceBack(e.a5,e.a5),this.debugBuffer=t.createVertexBuffer(r,Fe.members),this.debugSegments=e.aX.simpleSegment(0,0,4,5);const n=new e.ch;n.emplaceBack(0,0,0,0),n.emplaceBack(e.a5,0,e.a5,0),n.emplaceBack(0,e.a5,0,e.a5),n.emplaceBack(e.a5,e.a5,e.a5,e.a5),this.rasterBoundsBuffer=t.createVertexBuffer(n,Fi.members),this.rasterBoundsSegments=e.aX.simpleSegment(0,0,4,2);const s=new e.aW;s.emplaceBack(0,0),s.emplaceBack(e.a5,0),s.emplaceBack(0,e.a5),s.emplaceBack(e.a5,e.a5),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(s,Fe.members),this.rasterBoundsSegmentsPosOnly=e.aX.simpleSegment(0,0,4,5);const o=new e.aW;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(o,Fe.members),this.viewportSegments=e.aX.simpleSegment(0,0,4,2);const a=new e.ci;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(a);const l=new e.aY;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new ri({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new Le(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=e.N();e.c7(r,0,this.width,this.height,0,0,1),e.Q(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const n={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(t,i.TRIANGLES,ei.disabled,this.stencilClearMode,Je.disabled,ti.disabled,null,null,n,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Je.disabled),r.setDepthMode(ei.disabled);const n={};for(const t of e)n[t.key]=this.nextStencilID++;this._renderTileMasks(n,e,i,!0),this._renderTileMasks(n,e,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(t,e,i,r){const n=this.context,s=n.gl,o=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of e){const e=t[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=o.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),p=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(n,s.TRIANGLES,ei.disabled,new ri({func:s.ALWAYS,mask:0},e,255,s.KEEP,s.KEEP,s.REPLACE),Je.disabled,i?ti.disabled:ti.backCCW,null,h,p,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}_renderTilesDepthBuffer(){const t=this.context,e=t.gl,i=this.style.projection,r=this.transform,n=this.useProgram("depth"),s=this.getDepthModeFor3D(),o=Mt(r,{tileSize:r.tileSize});for(const a of o){const o=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(t,e.TRIANGLES,s,ri.disabled,Je.disabled,ti.backCCW,null,o,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new ri({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new ri({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const e=this.context.gl,i=t.sort((t,e)=>e.overscaledZ-t.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const t={};for(let i=0;i<n;i++)t[i+r]=new ri({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:ri.disabled},i]}stencilConfigForOverlapTwoPass(t){const e=this.context.gl,i=t.sort((t,e)=>e.overscaledZ-t.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){const t={},s={};for(let i=0;i<n;i++)t[i+r]=new ri({func:e.GREATER,mask:255},n+1+i,255,e.KEEP,e.KEEP,e.REPLACE),s[i+r]=new ri({func:e.GREATER,mask:255},1+i,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID=2*n+1,[t,s,i]}return this.nextStencilID=3,[{[r]:new ri({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new ri({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Je([t.CONSTANT_COLOR,t.ONE],new e.bp(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Je.unblended:Je.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return ei.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ei(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new ei(this.context.gl.LEQUAL,ei.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){var r,n;this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(c()),this.imageManager.beginFrame();const s=this.style._order,o=this.style.tileManagers,a={},l={},h={},u={isRenderingToTexture:!1,isRenderingGlobe:(null===(r=t.projection)||void 0===r?void 0:r.transitionState)>0};for(const t in o){const e=o[t];e.used&&e.prepare(this.context),a[t]=e.getVisibleCoordinates(!1),l[t]=a[t].slice().reverse(),h[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<s.length;t++)if(this.style._layers[s[t]].is3D()){this.opaquePassCutoff=t;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const t of s){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=l[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,o[e.source],e,i,u)}if(null===(n=this.style.projection)||void 0===n||n.updateGPUdependent({context:this.context,useProgram:t=>this.useProgram(t)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?e.bp.black:e.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(t,e){const i=t.context,r=i.gl,n=((t,e,i)=>{const r=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),s=gt(e),o=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:[(e.width/2-s*n)*i,(e.height/2+s*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i,u_sky_blend:o}})(e,t.style.map.transform,t.pixelRatio),s=new ei(r.LEQUAL,ei.ReadWrite,[0,1]),o=ri.disabled,a=t.colorModeForRenderPass(),l=t.useProgram("sky"),c=$n(i,e);l.draw(i,r.TRIANGLES,s,o,a,ti.disabled,n,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[s[this.currentLayer]],e=o[t.source],i=a[t.source];this._renderTileClippingMasks(t,i,!1),this.renderLayer(this,e,t,i,u)}this.renderPass="translucent";let p=!1;for(this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const t=this.style._layers[s[this.currentLayer]],e=o[t.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(t,u))continue;this.opaquePassEnabledForLayer()||p||(p=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===t.type?h:l)[t.source];this._renderTileClippingMasks(t,a[t.source],!!this.renderToTexture),this.renderLayer(this,e,t,i,u)}if(u.isRenderingGlobe&&function(t,i,r){const n=t.context,s=n.gl,o=t.useProgram("atmosphere"),a=new ei(s.LEQUAL,ei.ReadOnly,[0,1]),l=t.transform,c=function(t,i){const r=t.properties.get("position"),n=[-r.x,-r.y,-r.z],s=e.ar(new Float64Array(16));return"map"===t.properties.get("anchor")&&(e.bg(s,s,i.rollInRadians),e.bh(s,s,-i.pitchInRadians),e.bg(s,s,i.bearingInRadians),e.bh(s,s,i.center.lat*Math.PI/180),e.bJ(s,s,-i.center.lng*Math.PI/180)),e.cg(n,n,s),n}(r,t.transform),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=i.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;const p=_i(l.worldSize,l.center.lat),d=l.inverseProjectionMatrix,f=new Float64Array(4);f[3]=1,e.aH(f,f,l.modelViewProjectionMatrix),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1,e.aH(f,f,d),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1;const m=((t,e,i,r,n)=>({u_sun_pos:t,u_atmosphere_blend:e,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(c,u,[f[0],f[1],f[2]],p,d),_=$n(n,i);o.draw(n,s.TRIANGLES,a,ri.disabled,Je.alphaBlended,ti.disabled,m,null,null,"atmosphere",_.vertexBuffer,_.indexBuffer,_.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const t=function(t,e){let i=null;const r=Object.values(t._layers).flatMap(i=>i.source&&!i.isHidden(e)?[t.tileManagers[i.source]]:[]),n=r.filter(t=>"vector"===t.getSource().type),s=r.filter(t=>"vector"!==t.getSource().type),o=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};return n.forEach(t=>o(t)),i||s.forEach(t=>o(t)),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let r=0;r<i.length;r++)Gn(t,e,i[r])}(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;Vn(t,t.transform.height-(e.top||0),3,Ln),Vn(t,e.bottom||0,3,Fn),jn(t,e.left||0,3,Bn),jn(t,t.transform.width-(e.right||0),3,On);const i=t.transform.centerPoint;!function(t,e,i,r){qn(t,e-1,i-10,2,20,r),qn(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,Nn)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const i=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix;let n=this.terrainFacilitator.dirty;n||(n=t?!e.cj(i,r):!e.ck(i,r)),n||(n=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),n&&(e.cl(i,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){const r=t.context,n=r.gl,s=t.transform,o=Je.unblended,a=new ei(n.LEQUAL,ei.ReadWrite,[0,1]),l=i.tileManager.getRenderableTiles(),c=t.useProgram("terrainDepth");r.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.bp.transparent,depth:1});for(const t of l){const e=i.getTerrainMesh(t.tileID),l=i.getTerrainData(t.tileID),h=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:i.getMeshFrameDelta(s.zoom)};c.draw(r,n.TRIANGLES,a,ri.disabled,o,ti.backCCW,u,l,h,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain),function(t,i){const r=t.context,n=r.gl,s=t.transform,o=Je.unblended,a=new ei(n.LEQUAL,ei.ReadWrite,[0,1]),l=i.getCoordsTexture(),c=i.tileManager.getRenderableTiles(),h=t.useProgram("terrainCoords");r.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.bp.transparent,depth:1}),i.coordsIndex=[];for(const t of c){const e=i.getTerrainMesh(t.tileID),c=i.getTerrainData(t.tileID);r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,l.texture);const u={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(s.zoom)},p=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(r,n.TRIANGLES,a,ri.disabled,o,ti.backCCW,u,c,p,"terrain",e.vertexBuffer,e.indexBuffer,e.segments),i.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain))}renderLayer(t,i,r,n,s){r.isHidden(this.transform.zoom)||("background"===r.type||"custom"===r.type||(n||[]).length)&&(this.id=r.id,e.cm(r)?function(t,i,r,n,s,o){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:a}=o,l=ri.disabled,c=t.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,r,n,s,o,a,l,c){const h=i.transform,u=i.style.map.terrain,p="map"===s,d="map"===o;for(const s of t){const t=n.getTile(s),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const f=e.ay(o.textSizeData,h.zoom),m=e.aN(t,1,i.transform.zoom),_=Nt(p,i.transform,m),g="none"!==r.layout.get("icon-text-fit")&&o.hasIconData();if(f){const i=Math.pow(2,h.zoom-t.tileID.overscaledZ),r=u?(t,e)=>u.getElevation(s,t,e):null;fn(o,p,d,c,h,_,i,f,g,e.aO(h,t,a,l),s.toUnwrapped(),r)}}}(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),s),0!==r.paint.get("icon-opacity").constantOr(1)&&_n(t,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,a),0!==r.paint.get("text-opacity").constantOr(1)&&_n(t,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(hn(t,i,r,n,!0),hn(t,i,r,n,!1))}(t,i,r,n,this.style.placement.variableOffsets,s):e.cn(r)?function(t,i,r,n,s){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:o}=s,a=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=t.context,p=u.gl,d=t.transform,f=t.getDepthModeForSublayer(0,ei.ReadOnly),m=ri.disabled,_=t.colorModeForRenderPass(),g=[],y=d.getCircleRadiusCorrection();for(let s=0;s<n.length;s++){const a=n[s],l=i.getTile(a),c=l.getBucket(r);if(!c)continue;const u=r.paint.get("circle-translate"),p=r.paint.get("circle-translate-anchor"),f=e.aO(d,l,u,p),m=c.programConfigurations.get(r.id),_=t.useProgram("circle",m),v=c.layoutVertexBuffer,x=c.indexBuffer,b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a),w={programConfiguration:m,program:_,layoutVertexBuffer:v,indexBuffer:x,uniformValues:Hi(t,l,r,f,y),terrainData:b,projectionData:d.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(h){const t=c.segments.get();for(const i of t)g.push({segments:new e.aX([i]),sortKey:i.sortKey,state:w})}else g.push({segments:c.segments,sortKey:0,state:w})}h&&g.sort((t,e)=>t.sortKey-e.sortKey);for(const e of g){const{programConfiguration:i,program:n,layoutVertexBuffer:s,indexBuffer:o,uniformValues:a,terrainData:l,projectionData:c}=e.state;n.draw(u,p.TRIANGLES,f,m,_,ti.backCCW,a,l,c,r.id,s,o,e.segments,r.paint,t.transform.zoom,i)}}(t,i,r,n,s):e.co(r)?function(t,i,r,n,s){if(0===r.paint.get("heatmap-opacity"))return;const o=t.context,{isRenderingToTexture:a,isRenderingGlobe:l}=s;if(t.style.map.terrain){for(const e of n){const n=i.getTile(e);i.hasRenderableParent(e)||("offscreen"===t.renderPass?yn(t,n,r,e,l):"translucent"===t.renderPass&&vn(t,r,e,a,l))}o.viewport.set([0,0,t.width,t.height])}else"offscreen"===t.renderPass?function(t,i,r,n){const s=t.context,o=s.gl,a=t.transform,l=ri.disabled,c=new Je([o.ONE,o.ONE],e.bp.transparent,[!0,!0,!0,!0]);(function(t,i,r){const n=t.gl;t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,i.width/4,i.height/4]);let s=r.heatmapFbos.get(e.cd);s?(n.bindTexture(n.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer)):(s=xn(t,i.width/4,i.height/4),r.heatmapFbos.set(e.cd,s))})(s,t,r),s.clear({color:e.bp.transparent});for(let e=0;e<n.length;e++){const h=n[e];if(i.hasRenderableParent(h))continue;const u=i.getTile(h),p=u.getBucket(r);if(!p)continue;const d=p.programConfigurations.get(r.id),f=t.useProgram("heatmap",d),m=a.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),_=a.getCircleRadiusCorrection();f.draw(s,o.TRIANGLES,ei.disabled,l,c,ti.backCCW,Ji(u,a.zoom,r.paint.get("heatmap-intensity"),_),null,m,r.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,r.paint,a.zoom,d)}s.viewport.set([0,0,t.width,t.height])}(t,i,r,n):"translucent"===t.renderPass&&function(t,i){const r=t.context,n=r.gl;r.setColorMode(t.colorModeForRenderPass());const s=i.heatmapFbos.get(e.cd);s&&(r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,s.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1),bn(r,i).bind(n.LINEAR,n.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(r,n.TRIANGLES,ei.disabled,ri.disabled,t.colorModeForRenderPass(),ti.disabled,Qi(t,i,0,1),null,null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom))}(t,r)}(t,i,r,n,s):e.cp(r)?function(t,e,i,r,n){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:s}=n,o=i.paint.get("line-opacity"),a=i.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const l=t.getDepthModeForSublayer(0,ei.ReadOnly),c=t.colorModeForRenderPass(),h=i.paint.get("line-dasharray"),u=h.constantOr(1),p=i.paint.get("line-pattern"),d=p.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters();let _;_=d?"linePattern":u&&f?"lineGradientSDF":u?"lineSDF":f?"lineGradient":"line";const g=t.context,y=g.gl,v=t.transform;let x=!0;for(const n of r){const r=e.getTile(n);if(d&&!r.patternsLoaded())continue;const o=r.getBucket(i);if(!o)continue;const a=o.programConfigurations.get(i.id),b=t.context.program.get(),w=t.useProgram(_,a),S=x||w.program!==b,T=t.style.map.terrain&&t.style.map.terrain.getTerrainData(n),C=p.constantOr(null),M=h&&h.constantOr(null);if(C&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[C.to.toString()],i=t.patternPositions[C.from.toString()];e&&i&&a.setConstantPatternPositions(e,i)}else if(M){const e="round"===i.layout.get("line-cap"),r=t.lineAtlas.getDash(M.to,e),n=t.lineAtlas.getDash(M.from,e);a.setConstantDashPositions(r,n)}const E=v.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),A=v.getPixelScale();let I;d?(I=or(t,r,i,A,m),Sn(g,y,r,a,m)):u&&f?(I=lr(t,r,i,A,m,o.lineClipsArray.length),Mn(t,e,g,y,i,o,n,a,m)):u?(I=ar(t,r,i,A,m),Tn(t,g,y,a,S,m)):f?(I=sr(t,r,i,A,o.lineClipsArray.length),Cn(t,e,g,y,i,o,n)):I=nr(t,r,i,A);const P=t.stencilModeForClipping(n);w.draw(g,y.TRIANGLES,l,P,c,ti.disabled,I,T,E,i.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,i.paint,t.transform.zoom,a,o.layoutVertexBuffer2),x=!1}}(t,i,r,n,s):e.cq(r)?function(t,i,r,n,s){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const{isRenderingToTexture:l}=s,c=t.colorModeForRenderPass(),h=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===o.constantOr(e.bp.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.getDepthModeForSublayer(1,"opaque"===t.renderPass?ei.ReadWrite:ei.ReadOnly);An(t,i,r,n,e,c,!1,l)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const e=t.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,ei.ReadOnly);An(t,i,r,n,e,c,!0,l)}}(t,i,r,n,s):e.cr(r)?function(t,e,i,r,n){const s=i.paint.get("fill-extrusion-opacity");if(0===s)return;const{isRenderingToTexture:o}=n;if("translucent"===t.renderPass){const n=new ei(t.context.gl.LEQUAL,ei.ReadWrite,t.depthRangeFor3D);if(1!==s||i.paint.get("fill-extrusion-pattern").constantOr(1))In(t,e,i,r,n,ri.disabled,Je.disabled,o),In(t,e,i,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass(),o);else{const s=t.colorModeForRenderPass();In(t,e,i,r,n,ri.disabled,s,o)}}}(t,i,r,n,s):e.cs(r)?function(t,i,r,n,s){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const{isRenderingToTexture:o}=s,a=t.context,l=t.style.projection.useSubdivision,c=t.getDepthModeForSublayer(0,ei.ReadOnly),h=t.colorModeForRenderPass();if("offscreen"===t.renderPass)!function(t,i,r,n,s,o,a){const l=t.context,c=l.gl;for(const h of r){const r=i.getTile(h),u=r.dem;if(!u||!u.data)continue;if(!r.needsHillshadePrepare)continue;const p=u.dim,d=u.stride,f=u.getPixels();if(l.activeTexture.set(c.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||t.getTileTexture(d),r.demTexture){const t=r.demTexture;t.update(f,{premultiply:!1}),t.bind(c.NEAREST,c.CLAMP_TO_EDGE)}else r.demTexture=new e.T(l,f,c.RGBA,{premultiply:!1}),r.demTexture.bind(c.NEAREST,c.CLAMP_TO_EDGE);l.activeTexture.set(c.TEXTURE0);let m=r.fbo;if(!m){const t=new e.T(l,{width:p,height:p,data:null},c.RGBA);t.bind(c.LINEAR,c.CLAMP_TO_EDGE),m=r.fbo=l.createFramebuffer(p,p,!0,!1),m.colorAttachment.set(t.texture)}l.bindFramebuffer.set(m.framebuffer),l.viewport.set([0,0,p,p]),t.useProgram("hillshadePrepare").draw(l,c.TRIANGLES,s,o,a,ti.disabled,er(r.tileID,u),null,null,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),r.needsHillshadePrepare=!1}}(t,i,n,r,c,ri.disabled,h),a.viewport.set([0,0,t.width,t.height]);else if("translucent"===t.renderPass)if(l){const[e,s,a]=t.stencilConfigForOverlapTwoPass(n);Pn(t,i,r,a,e,c,h,!1,o),Pn(t,i,r,a,s,c,h,!0,o)}else{const[e,s]=t.getStencilConfigForOverlapAndUpdateStencilID(n);Pn(t,i,r,s,e,c,h,!1,o)}}(t,i,r,n,s):e.ct(r)?function(t,e,i,r,n){if("translucent"!==t.renderPass)return;if(!r.length)return;const{isRenderingToTexture:s}=n,o=t.style.projection.useSubdivision,a=t.getDepthModeForSublayer(0,ei.ReadOnly),l=t.colorModeForRenderPass();if(o){const[n,o,c]=t.stencilConfigForOverlapTwoPass(r);Dn(t,e,i,c,n,a,l,!1,s),Dn(t,e,i,c,o,a,l,!0,s)}else{const[n,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);Dn(t,e,i,o,n,a,l,!1,s)}}(t,i,r,n,s):e.bU(r)?function(t,e,i,r,n){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const{isRenderingToTexture:s}=n,o=e.getSource(),a=t.style.projection.useSubdivision;if(o instanceof et)zn(t,e,i,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,s);else if(a){const[n,o,a]=t.stencilConfigForOverlapTwoPass(r);zn(t,e,i,a,n,!1,!0,kn,!1,s),zn(t,e,i,a,o,!0,!0,kn,!1,s)}else{const[n,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);zn(t,e,i,o,n,!1,!0,kn,!1,s)}}(t,i,r,n,s):e.cu(r)?function(t,e,i,r,n){const s=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const{isRenderingToTexture:a}=n,l=t.context,c=l.gl,h=t.style.projection,u=t.transform,p=u.tileSize,d=i.paint.get("background-pattern");if(t.isPatternMissing(d))return;const f=!d&&1===s.a&&1===o&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==f)return;const m=ri.disabled,_=t.getDepthModeForSublayer(0,"opaque"===f?ei.ReadWrite:ei.ReadOnly),g=t.colorModeForRenderPass(),y=t.useProgram(d?"backgroundPattern":"background"),v=r||Mt(u,{tileSize:p,terrain:t.style.map.terrain});d&&(l.activeTexture.set(c.TEXTURE0),t.imageManager.bind(t.context));const x=i.getCrossfadeParameters();for(const e of v){const r=u.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),n=d?gr(o,t,d,{tileID:e,tileSize:p},x):_r(o,s),f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e),v=h.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,c.TRIANGLES,_,m,g,ti.backCCW,n,f,r,i.id,v.vertexBuffer,v.indexBuffer,v.segments)}}(t,0,r,n,s):e.cv(r)&&function(t,e,i,r){const{isRenderingGlobe:n}=r,s=t.context,o=i.implementation,a=t.style.projection,l=t.transform,c=l.getProjectionDataForCustomLayer(n),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:c},u=o.renderingMode?o.renderingMode:"2d";if("offscreen"===t.renderPass){const e=o.prerender;e&&(t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),e.call(o,s.gl,h),s.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),s.setStencilMode(ri.disabled);const e="3d"===u?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,ei.ReadOnly);s.setDepthMode(e),o.render(s.gl,h),s.setDirty(),t.setBaseState(),s.bindFramebuffer.set(null)}}(t,0,r,s))}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e,i=!1,r=[]){this.cache=this.cache||{};const n=!!this.style.map.terrain,s=this.style.projection,o=i?ze.projectionMercator:s.shaderPreludeCode,a=i?Be:s.shaderDefine,l=t+(e?e.cacheKey:"")+`/${i?Oe:s.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(n?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||(this.cache[l]=new ji(this.context,ze[t],e,vr[t],this._showOverdrawInspector,n,o,a,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const 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)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var t,e;if(this._tileTextures){for(const t in this._tileTextures){const e=this._tileTextures[t];if(e)for(const t of e)t.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.vertexBuffer)||void 0===t||t.destroy()),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.indexBuffer)||void 0===e||e.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const t in this.cache){const e=this.cache[t];e&&e.program&&this.context.gl.deleteProgram(e.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}function Wn(t,e){let i,r=!1,n=null,s=null;const o=()=>{n=null,r&&(t.apply(s,i),n=setTimeout(o,e),r=!1)};return(...t)=>(r=!0,s=this,i=t,n||o(),n)}class Hn{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(t=>t.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(!this._isValidHash(t))return!1;const 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},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let i=e;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${e}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let n=window.location.href.replace(/(#.+)?$/,r);n=n.replace("&&","&"),window.history.replaceState(window.history.state,null,n)},this._updateHash=Wn(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),s=Math.round(e.lng*n)/n,o=Math.round(e.lat*n)/n,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${s}/${o}/${i}`:`${i}/${o}/${s}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i}).filter(t=>t);return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new e.V(+t[2],+t[1])}catch(t){return!1}const i=+t[0],r=+(t[3]||0),n=+(t[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&n>=this._map.getMinPitch()&&n<=this._map.getMaxPitch()}}const Xn={linearity:.3,easing:e.cw(0,0,.3,1)},Yn=e.e({deceleration:2500,maxSpeed:1400},Xn),Kn=e.e({deceleration:20,maxSpeed:1400},Xn),Jn=e.e({deceleration:1e3,maxSpeed:360},Xn),Qn=e.e({deceleration:1e3,maxSpeed:90},Xn),ts=e.e({deceleration:1e3,maxSpeed:360},Xn);class es{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=c();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,i.roll+=t.rollDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const s=rs(i.pan.mag(),r,e.e({},Yn,t||{})),o=i.pan.mult(s.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(o,this._map.transform);n.center=a.easingCenter,n.offset=a.easingOffset,is(n,s)}if(i.zoom){const t=rs(i.zoom,r,Kn),s=e.cx(this._map.transform.zoom+t.amount,this._map.getZoomSnap(),t.amount);n.zoom=s,is(n,t)}if(i.bearing){const t=rs(i.bearing,r,Jn);n.bearing=this._map.transform.bearing+e.an(t.amount,-179,179),is(n,t)}if(i.pitch){const t=rs(i.pitch,r,Qn);n.pitch=this._map.transform.pitch+t.amount,is(n,t)}if(i.roll){const t=rs(i.roll,r,ts);n.roll=this._map.transform.roll+e.an(t.amount,-179,179),is(n,t)}if(n.zoom||n.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(n,{noMoveStart:!0})}}function is(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function rs(t,i,r){const{maxSpeed:n,linearity:s,deceleration:o}=r,a=e.an(t*s/(i/1e3),-n,n),l=Math.abs(a)/(o*s);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class ns extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,n={}){r=r instanceof MouseEvent?r:new MouseEvent(t,r);const s=h.mousePos(i.getCanvas(),r),o=i.unproject(s);super(t,e.e({point:s,lngLat:o,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class ss extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){const n="touchend"===t?r.changedTouches:r.touches,s=h.touchPos(i.getCanvasContainer(),n),o=s.map(t=>i.unproject(t)),a=s.reduce((t,e,i,r)=>t.add(e.div(r.length)),new e.P(0,0));super(t,{points:s,point:a,lngLats:o,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class os extends e.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class as{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new os(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ns(t.type,this._map,t))}mouseup(t){this._map.fire(new ns(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new ns(t.type,this._map,t))}dblclick(t){return this._firePreventable(new ns(t.type,this._map,t))}mouseover(t){this._map.fire(new ns(t.type,this._map,t))}mouseout(t){this._map.fire(new ns(t.type,this._map,t))}touchstart(t){return this._firePreventable(new ss(t.type,this._map,t))}touchmove(t){this._map.fire(new ss(t.type,this._map,t))}touchend(t){this._map.fire(new ss(t.type,this._map,t))}touchcancel(t){this._map.fire(new ss(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ls{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new ns(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ns("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new ns(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cs{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this._map.terrain)}}class hs{constructor(t,e){this._map=t,this._tr=new cs(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(h.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=h.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),o=Math.min(r.y,i.y),a=Math.max(r.y,i.y);h.setTransform(this._box,`translate(${n}px,${o}px)`),this._box.style.width=s-n+"px",this._box.style.height=a-o+"px"}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const r=this._startPos,n=i;if(this.reset(),h.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.l("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(r,n,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.l(t,{originalEvent:i}))}}function us(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class ps{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=us(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=us(i,e);for(const t in this.touches){const e=r[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class ds{constructor(t){this.singleTap=new ps(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class fs{constructor(t){this._tr=new cs(t),this._zoomIn=new ds({numTouches:1,numTaps:2}),this._zoomOut=new ds({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,i,r){const n=this._zoomIn.touchend(t,i,r),s=this._zoomOut.touchend(t,i,r),o=this._tr;return n?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:e.cx(o.zoom+1,i.getZoomSnap()),around:o.unproject(n)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:e.cx(o.zoom-1,i.getZoomSnap()),around:o.unproject(s)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ms{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.rollDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(e)?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const r=Array.isArray(e)?e[0]:e;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&h.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const _s=0,gs=2,ys={[_s]:1,[gs]:2};class vs{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const e=h.mouseButton(t);this._eventButton=e}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){const i=ys[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return h.mouseButton(t)===this._eventButton}}class xs{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class bs{constructor(t=new vs({checkCorrectEvent:()=>!0}),e=new xs){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=e}_executeRelevantHandler(t,e,i){return t instanceof MouseEvent?e(t):"undefined"!=typeof TouchEvent&&t instanceof TouchEvent?i(t):void 0}startMove(t){this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.startMove(t),t=>this.oneFingerTouchMoveStateManager.startMove(t))}endMove(t){this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.endMove(t),t=>this.oneFingerTouchMoveStateManager.endMove(t))}isValidStartEvent(t){return this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(t){return this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(t){return this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}}const ws=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};class Ss{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active){if(!this._shouldBePrevented(i.length))return t.preventDefault(),this._calculateTransform(t,e,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);const n=us(r,i),s=new e.P(0,0),o=new e.P(0,0);let a=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(s._add(e),o._add(e.sub(i)),a++,n[t]=e)}if(this._touches=n,this._shouldBePrevented(a)||!o.mag())return;const l=o.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:s.div(a),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ts{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[r,n]=this._firstTwoTouches,s=Cs(i,e,r),o=Cs(i,e,n);if(!s||!o)return;const a=this._aroundCenter?null:s.add(o).div(2);return this._move([s,o],a,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,s=Cs(i,e,r),o=Cs(i,e,n);s&&o||(this._active&&h.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Cs(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Ms(t,e){return Math.log(t/e)/Math.LN2}class Es extends Ts{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Ms(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ms(this._distance,i),pinchAround:e}}}function As(t,e){return 180*t.angleWith(e)/Math.PI}class Is extends Ts{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e,i){const r=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:As(this._vector,r),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=As(t,this._startVector);return Math.abs(i)<e}}function Ps(t){return Math.abs(t.y)>Math.abs(t.x)}class Ds extends Ts{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Ps(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=t.y>0==e.y>0;return Ps(t)&&Ps(e)&&s}}const ks={panStep:100,bearingStep:15,pitchStep:10};class zs{constructor(t){this._tr=new cs(t);const e=ks;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let i=0,r=0,n=0,s=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?n=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,n=0),{cameraAnimation:a=>{const l=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:Rs,zoom:i?e.cx(l.zoom+i*(t.shiftKey?2:1),a.getZoomSnap()):l.zoom,bearing:l.bearing+r*this._bearingStep,pitch:l.pitch+n*this._pitchStep,offset:[-s*this._panStep,-o*this._panStep],center:l.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Rs(t){return t*(2-t)}const Ls=4.000244140625,Fs=1/450;class Bs{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new cs(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Fs}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=c(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Ls==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=h.mousePos(this._map.getCanvas(),t),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(e.V.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const e=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=e),"number"==typeof this._targetZoom&&(this._targetZoom+=e)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Ls?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n="number"!=typeof this._targetZoom?t.scale:e.aq(this._targetZoom),s=t.applyConstrain(t.getCameraLngLat(),e.at(n*r)).zoom,o=this._map.getZoomSnap();if("wheel"===this._type&&o>0){const i=e.cx(t.zoom,o);this._targetZoom=e.cx(s,o,s-i)}else this._targetZoom=s;"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?t.zoom:this._targetZoom,r=this._startZoom,n=this._easing;let s,o=!1;if("wheel"===this._type&&r&&n){const t=c()-this._lastWheelEventTime,a=Math.min((t+5)/200,1),l=n(a);s=e.G.number(r,i,l),a<1?this._frameId||(this._frameId=!0):o=!0}else s=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=s,{noInertia:!0,needsRenderFrame:!o,zoomDelta:s-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.cz;if(this._prevEase){const t=this._prevEase,r=(c()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),s=.27/Math.sqrt(n*n+1e-4)*.01,o=Math.sqrt(.0729-s*s);i=e.cw(s,o,.25,1)}return this._prevEase={start:c(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Os{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ns{constructor(t){this._tr=new cs(t),this.reset()}reset(){this._active=!1}dblclick(t,i){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:e.cx(this._tr.zoom+(t.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(i)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vs{constructor(){this._tap=new ds({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const r=e[0],n=t.timeStamp-this._tapTime<500,s=this._tapPoint.dist(r)<30;n&&s?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class js{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class qs{constructor(t,e,i,r){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=e,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Gs{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Us{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=e,this._container.appendChild(r);const n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(h.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,i){this._enabled&&(this._map.fire(new e.l("cooperativegestureprevented",{gestureType:t,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const $s=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;class Zs extends e.l{}function Ws(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}class Hs{get _ownerDocument(){var t;return(null===(t=this._el)||void 0===t?void 0:t.ownerDocument)||document}get _ownerWindow(){var t,e;return(null===(e=null===(t=this._el)||void 0===t?void 0:t.ownerDocument)||void 0===e?void 0:e.defaultView)||window}constructor(t,i){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,i)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},s={},o={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let u;if(this._blockedByActive(o,c,a))l.reset();else if(l[i||t.type]){if(e.cA(t,i||t.type)){const e=h.mousePos(this._map.getCanvas(),t);u=l[i||t.type](t,e)}else if(e.cB(t,i||t.type)){const e=this._getMapTouches(t.touches),r=h.touchPos(this._map.getCanvas(),e);u=l[i||t.type](t,r,e)}else e.cC(i||t.type)||(u=l[i||t.type](t));this.mergeHandlerResult(n,s,u,a,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()}(u||l.isActive())&&(o[a]=l)}const a={};for(const t in this._previousActiveHandlers)o[t]||(a[t]=r);this._previousActiveHandlers=o,(Object.keys(a).length||Ws(n))&&(this._changes.push([n,s,a]),this._triggerRenderFrame()),(Object.keys(o).length||Ws(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=n;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new es(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[t,e,i]of this._listeners)h.addEventListener(t,e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)h.removeEventListener(t,e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new as(i,t));const n=i.boxZoom=new hs(i,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();const s=i.cooperativeGestures=new Us(i,t.cooperativeGestures);this._add("cooperativeGestures",s),t.cooperativeGestures&&s.enable();const o=new fs(i),a=new Ns(i);i.doubleClickZoom=new Os(a,o),this._add("tapZoom",o),this._add("clickZoom",a),t.interactive&&t.doubleClickZoom&&i.doubleClickZoom.enable();const l=new Vs;this._add("tapDragZoom",l);const c=i.touchPitch=new Ds(i);this._add("touchPitch",c),t.interactive&&t.touchPitch&&i.touchPitch.enable(t.touchPitch);const u=()=>i.project(i.getCenter()),p=function({enable:t,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:n=100,rotateDegreesPerPixelMoved:s=.8},o){const a=new vs({checkCorrectEvent:t=>0===h.mouseButton(t)&&t.ctrlKey||2===h.mouseButton(t)&&!t.ctrlKey});return new ms({clickTolerance:i,move:(t,i)=>{const a=o();if(r&&Math.abs(a.y-t.y)>n)return{bearingDelta:e.cy(new e.P(t.x,i.y),i,a)};let l=(i.x-t.x)*s;return r&&i.y<a.y&&(l=-l),{bearingDelta:l}},moveStateManager:a,enable:t,assignEvents:ws})}(t,u),d=function({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5}){const r=new vs({checkCorrectEvent:t=>0===h.mouseButton(t)&&t.ctrlKey||2===h.mouseButton(t)});return new ms({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:ws})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){const n=new vs({checkCorrectEvent:t=>2===h.mouseButton(t)&&t.ctrlKey});return new ms({clickTolerance:e,move:(t,e)=>{const n=r();let s=(e.x-t.x)*i;return e.y<n.y&&(s=-s),{rollDelta:s}},moveStateManager:n,enable:t,assignEvents:ws})}(t,u);i.dragRotate=new qs(t,p,d,f),this._add("mouseRotate",p,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",f,["mousePitch"]),t.interactive&&t.dragRotate&&i.dragRotate.enable();const m=function({enable:t,clickTolerance:e}){const i=new vs({checkCorrectEvent:t=>0===h.mouseButton(t)&&!t.ctrlKey});return new ms({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:ws})}(t),_=new Ss(t,i);i.dragPan=new js(r,m,_),this._add("mousePan",m),this._add("touchPan",_,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&i.dragPan.enable(t.dragPan);const g=new Is,y=new Es;i.touchZoomRotate=new Gs(r,y,g,l),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",y,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&i.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new ls(i));const v=i.scrollZoom=new Bs(i,()=>this._triggerRenderFrame());this._add("scrollZoom",v,["mousePan"]),t.interactive&&t.scrollZoom&&i.scrollZoom.enable(t.scrollZoom);const x=i.keyboard=new zs(i);this._add("keyboard",x),t.interactive&&t.keyboard&&i.keyboard.enable()}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean($s(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,r,n,s){if(!r)return;e.e(t,r);const o={handlerName:n,originalEvent:r.originalEvent||s};void 0!==r.zoomDelta&&(i.zoom=o),void 0!==r.panDelta&&(i.drag=o),void 0!==r.rollDelta&&(i.roll=o),void 0!==r.pitchDelta&&(i.pitch=o),void 0!==r.bearingDelta&&(i.rotate=o)}_applyChanges(){const t={},i={},r={};for(const[n,s,o]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),n.rollDelta&&(t.rollDelta=(t.rollDelta||0)+n.rollDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.e(i,s),e.e(r,o);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,n=r._getTransformForUpdate(),s=r.terrain;if(!(Ws(t)||s&&this._terrainMovement))return this._fireEvents(e,i,!0);r._stop(!0);let{panDelta:o,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:p}=t;void 0!==p&&(u=p),u=u||r.transform.centerPoint,s&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const d={panDelta:o,zoomDelta:a,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const f=u.distSqr(n.centerPoint)<.01?n.center:n.screenPointToLocation(o?u.sub(o):u);this._handleMapControls({terrain:s,tr:n,deltasForHelper:d,preZoomAroundLoc:f,combinedEventsInProgress:e,panDelta:o}),r._applyUpdatedTransform(n),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_handleMapControls({terrain:t,tr:e,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:n,panDelta:s}){const o=this._map.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,e),t)return o.useGlobeControls?(this._terrainMovement||!n.drag&&!n.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void o.handleMapControlsPan(i,e,r)):this._terrainMovement||!n.drag&&!n.zoom?void(n.drag&&this._terrainMovement&&s?e.setCenter(e.screenPointToLocation(e.centerPoint.sub(s))):o.handleMapControlsPan(i,e,r)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void o.handleMapControlsPan(i,e,r));o.handleMapControlsPan(i,e,r)}_fireEvents(t,i,r){const n=$s(this._eventsInProgress),s=$s(t),o={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(o[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&s&&this._fireEvent("movestart",s.originalEvent);for(const t in o)this._fireEvent(t,o[t]);s&&this._fireEvent("move",s.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=i[e]||r,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const h=$s(this._eventsInProgress),u=(n||s)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(t)}if(r&&u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;!t||!t.essential&&a.prefersReducedMotion?(this._map.fire(new e.l("moveend",{originalEvent:c})),i(this._map.getBearing())&&this._map.resetNorth()):(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:c})),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.l(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new Zs("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Xs extends e.E{constructor(t,e,i){super(),this._renderFrameCallback=()=>{const t=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._zoomSnap=i.zoomSnap,this.cameraHelper=e,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(t,e){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=e}getCenter(){return new e.V(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,e){return this.jumpTo({elevation:t},e),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.e({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,r){return this.easeTo(e.e({zoom:t},i),r)}zoomIn(t,i){return this.zoomTo(e.cx(this.getZoom()+1,this._zoomSnap),t,i),this}zoomOut(t,i){return this.zoomTo(e.cx(this.getZoom()-1,this._zoomSnap),t,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,i){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new e.l("movestart",i)).fire(new e.l("move",i)).fire(new e.l("moveend",i))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,r){return this.easeTo(e.e({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,roll:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}getRoll(){return this.transform.roll}setRoll(t,e){return this.jumpTo({roll:t},e),this}cameraForBounds(t,e){t=W.convert(t).adjustAntiMeridian();const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,i,r,n){const s={top:0,bottom:0,right:0,left:0};if("number"==typeof(n=e.e({padding:s,offset:[0,0],maxZoom:this.transform.maxZoom},n)).padding){const t=n.padding;n.padding={top:t,bottom:t,right:t,left:t}}const o=e.e(s,n.padding);n.padding=o;const a=this.transform,l=new W(t,i);return this.cameraHelper.cameraForBoxAndBearing(n,o,l,r,a)}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,i,r,n,s){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(e.P.convert(t)),this.transform.screenPointToLocation(e.P.convert(i)),r,n),n,s)}_fitInternal(t,i,r){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(t,i){this.stop();const r=this._getTransformForUpdate();let n=!1,s=!1,o=!1;const a=r.zoom;this.cameraHelper.handleJumpToCenterZoom(r,t);const l=r.zoom!==a;return"elevation"in t&&r.elevation!==+t.elevation&&r.setElevation(+t.elevation),"bearing"in t&&r.bearing!==+t.bearing&&(n=!0,r.setBearing(+t.bearing)),"pitch"in t&&r.pitch!==+t.pitch&&(s=!0,r.setPitch(+t.pitch)),"roll"in t&&r.roll!==+t.roll&&(o=!0,r.setRoll(+t.roll)),null==t.padding||r.isPaddingEqual(t.padding)||r.setPadding(t.padding),this._applyUpdatedTransform(r),this.fire(new e.l("movestart",i)).fire(new e.l("move",i)),l&&this.fire(new e.l("zoomstart",i)).fire(new e.l("zoom",i)).fire(new e.l("zoomend",i)),n&&this.fire(new e.l("rotatestart",i)).fire(new e.l("rotate",i)).fire(new e.l("rotateend",i)),s&&this.fire(new e.l("pitchstart",i)).fire(new e.l("pitch",i)).fire(new e.l("pitchend",i)),o&&this.fire(new e.l("rollstart",i)).fire(new e.l("roll",i)).fire(new e.l("rollend",i)),this.fire(new e.l("moveend",i))}calculateCameraOptionsFromTo(t,i,r,n=0){const s=e.a9.fromLngLat(t,i),o=e.a9.fromLngLat(r,n),a=o.x-s.x,l=o.y-s.y,c=o.z-s.z,h=Math.hypot(a,l,c);if(0===h)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(a,l),p=e.at(this.transform.cameraToCenterDistance/h/this.transform.tileSize),d=180*Math.atan2(a,-l)/Math.PI;let f=180*Math.acos(u/h)/Math.PI;return f=c<0?90-f:90+f,{center:o.toLngLat(),elevation:n,zoom:p,pitch:f,bearing:d}}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,n){const s=this.transform.calculateCenterFromCameraLngLatAlt(t,e,i,r);return{center:s.center,elevation:s.elevation,zoom:s.zoom,bearing:i,pitch:r,roll:n}}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.cz},t)).animate||!t.essential&&a.prefersReducedMotion)&&(t.duration=0);const r=this._getTransformForUpdate(),n=this.getBearing(),s=r.pitch,o=r.roll,l="bearing"in t?this._normalizeBearing(t.bearing,n):n,c="pitch"in t?+t.pitch:s,h="roll"in t?this._normalizeBearing(t.roll,o):o,u="padding"in t?t.padding:r.padding,p=e.P.convert(t.offset);let d,f;t.around&&(d=e.V.convert(t.around),f=r.locationToScreenPoint(d));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},_=this.cameraHelper.handleEaseTo(r,{bearing:l,pitch:c,roll:h,padding:u,around:d,aroundPoint:f,offsetAsPoint:p,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||n!==l,this._pitching=this._pitching||c!==s,this._rolling=this._rolling||h!==o,this._padding=!r.isPaddingEqual(u),this._zooming=this._zooming||_.isZooming,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,m),this.terrain&&this._prepareElevation(_.elevationCenter),this._ease(e=>{_.easeFunc(e),this.terrain&&!t.freezeElevation&&this._updateElevation(e),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,e)},t),this}_prepareEase(t,i,r={}){this._moving=!0,i||r.moving||this.fire(new e.l("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.l("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.l("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.l("pitchstart",t)),this._rolling&&!r.rolling&&this.fire(new e.l("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.setElevation(e.G.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const e=t.getCameraLngLat(),i=t.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(e,t.zoom):0;if(i<r){const i=this.calculateCameraOptionsFromTo(e,r,t.center,t.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(t){const e=[];if(e.push(t=>this._elevateCameraIfInsideTerrain(t)),this.transformCameraUpdate&&e.push(t=>this.transformCameraUpdate(t)),!e.length)return;const i=t.clone();for(const t of e){const e=i.clone(),{center:r,zoom:n,roll:s,pitch:o,bearing:a,elevation:l}=t(e);r&&e.setCenter(r),void 0!==l&&e.setElevation(l),void 0!==n&&e.setZoom(n),void 0!==s&&e.setRoll(s),void 0!==o&&e.setPitch(o),void 0!==a&&e.setBearing(a),i.apply(e,!1)}this.transform.apply(i,!1)}_fireMoveEvents(t){this.fire(new e.l("move",t)),this._zooming&&this.fire(new e.l("zoom",t)),this._rotating&&this.fire(new e.l("rotate",t)),this._pitching&&this.fire(new e.l("pitch",t)),this._rolling&&this.fire(new e.l("roll",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,n=this._rotating,s=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new e.l("zoomend",t)),n&&this.fire(new e.l("rotateend",t)),s&&this.fire(new e.l("pitchend",t)),o&&this.fire(new e.l("rollend",t)),this.fire(new e.l("moveend",t))}flyTo(t,i){if(!t.essential&&a.prefersReducedMotion){const r=e.U(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(r,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.cz},t);const r=this._getTransformForUpdate(),n=r.bearing,s=r.pitch,o=r.roll,l=r.padding,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,u="roll"in t?this._normalizeBearing(t.roll,o):o,p="padding"in t?t.padding:r.padding,d=e.P.convert(t.offset);let f=r.centerPoint.add(d);const m=r.screenPointToLocation(f),_=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:p,locationAtOffset:m,offsetAsPoint:d,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let g=t.curve;const y=Math.max(r.width,r.height),v=y/_.scaleOfZoom,x=_.pixelPathLength;"number"==typeof _.scaleOfMinZoom&&(g=Math.sqrt(y/_.scaleOfMinZoom/x*2));const b=g*g;function w(t){const e=(v*v-y*y+(t?-1:1)*b*b*x*x)/(2*(t?v:y)*b*x);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function T(t){return(Math.exp(t)+Math.exp(-t))/2}const C=w(!1);let M=function(t){return T(C)/T(C+g*t)},E=function(t){return y*((T(C)*(S(e=C+g*t)/T(e))-S(C))/b)/x;var e},A=(w(!0)-C)/g;if(Math.abs(x)<2e-6||!isFinite(A)){if(Math.abs(y-v)<1e-6)return this.easeTo(t,i);const e=v<y?-1:1;A=Math.abs(Math.log(v/y))/g,E=()=>0,M=t=>Math.exp(e*g*t)}return t.duration="duration"in t?+t.duration:1e3*A/("screenSpeed"in t?+t.screenSpeed/g:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=n!==c,this._pitching=h!==s,this._rolling=u!==o,this._padding=!r.isPaddingEqual(p),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(_.targetCenter),this._ease(a=>{const m=a*A,g=1/M(m),y=E(m);this._rotating&&r.setBearing(e.G.number(n,c,a)),this._pitching&&r.setPitch(e.G.number(s,h,a)),this._rolling&&r.setRoll(e.G.number(o,u,a)),this._padding&&(r.interpolatePadding(l,p,a),f=r.centerPoint.add(d)),_.easeFunc(a,g,y,f),this.terrain&&!t.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){t=e.W(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(e.V.convert(t),this.transform):null}}const Ys={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ks{constructor(t=Ys){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(t=>"string"!=typeof t?"":t)):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.tileManagers;for(const i in e){const r=e[i];if(r.used||r.usedForTerrain){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t=t.filter(t=>String(t).trim()),t.sort((t,e)=>t.length-e.length),t=t.filter((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0});const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=h.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Js{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");const e=h.create("a","maplibregl-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="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Qs{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var to=e.aU([{name:"a_pos3d",type:"Int16",components:3}]);class eo extends e.E{constructor(t){super(),this._lastTilesetChange=c(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(t,i){this.tileManager.update(t,i),this._renderableTilesKeys=[];const r={};for(const n of Mt(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float64Array(16),e.c7(n.terrainRttPosMatrix32f,0,e.a5,e.a5,0,0,1),this._tiles[n.key]=new pt(n,this.tileSize),this._lastTilesetChange=c());for(const t in this._tiles)r[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,e){return e?this._getTerrainCoordsForTileRanges(t,e):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID,s=t.clone(),o=e.bk();if(n.canonical.equals(t.canonical))e.c7(o,0,e.a5,e.a5,0,0,1);else if(n.canonical.isChildOf(t.canonical)){const i=n.canonical.z-t.canonical.z,r=n.canonical.x-(n.canonical.x>>i<<i),s=n.canonical.y-(n.canonical.y>>i<<i),a=e.a5>>i;e.c7(o,0,a,a,0,0,1),e.O(o,o,[-r*a,-s*a,0])}else{if(!t.canonical.isChildOf(n.canonical))continue;{const i=t.canonical.z-n.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i),s=t.canonical.y-(t.canonical.y>>i<<i),a=e.a5>>i;e.c7(o,0,e.a5,e.a5,0,0,1),e.O(o,o,[r*a,s*a,0]),e.Q(o,o,[1/2**i,1/2**i,0])}}s.terrainRttPosMatrix32f=new Float32Array(o),i[r]=s}return i}_getTerrainCoordsForTileRanges(t,i){const r={};for(const n of this._renderableTilesKeys){const s=this._tiles[n].tileID;if(!this._isWithinTileRanges(s,i))continue;const o=t.clone(),a=e.bk();if(s.canonical.z===t.canonical.z){const i=t.canonical.x-s.canonical.x+t.wrap*(1<<t.canonical.z),r=t.canonical.y-s.canonical.y;e.c7(a,0,e.a5,e.a5,0,0,1),e.O(a,a,[i*e.a5,r*e.a5,0])}else if(s.canonical.z>t.canonical.z){const i=s.canonical.z-t.canonical.z,r=s.canonical.x-(s.canonical.x>>i<<i)+t.wrap*(1<<s.canonical.z),n=s.canonical.y-(s.canonical.y>>i<<i),o=t.canonical.x-(s.canonical.x>>i),l=t.canonical.y-(s.canonical.y>>i),c=e.a5>>i;e.c7(a,0,c,c,0,0,1),e.O(a,a,[-r*c+o*e.a5,-n*c+l*e.a5,0])}else{const i=t.canonical.z-s.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i)+t.wrap*(1<<t.canonical.z),n=t.canonical.y-(t.canonical.y>>i<<i),o=(t.canonical.x>>i)-s.canonical.x,l=(t.canonical.y>>i)-s.canonical.y,c=e.a5<<i;e.c7(a,0,c,c,0,0,1),e.O(a,a,[r*e.a5+o*c,n*e.a5+l*c,0])}o.terrainRttPosMatrix32f=new Float32Array(a),r[n]=o}return r}getSourceTile(t,e){const i=this.tileManager._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(r).key);let n=this.findTileInCaches(this._sourceTileCache[t.key]);if(!(null==n?void 0:n.dem)&&e)for(;r>=i.minzoom&&!(null==n?void 0:n.dem);)n=this.findTileInCaches(t.scaledTo(r--).key);return n}findTileInCaches(t){let e=this.tileManager.getTileByID(t);return e||(e=this.tileManager._outOfViewCache.getByKey(t),e)}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,e){const i=e[t.canonical.z];return!!i&&(t.wrap>i.minWrap||t.wrap<i.maxWrap||t.canonical.x>=i.minTileXWrapped&&t.canonical.x<=i.maxTileXWrapped&&t.canonical.y>=i.minTileY&&t.canonical.y<=i.maxTileY)}}class io{constructor(t,e,i){this._meshCache={},this.painter=t,this.tileManager=new eo(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,i,r,n=e.a5){var s;if(!(i>=0&&i<n&&r>=0&&r<n))return 0;const o=this.getTerrainData(t),a=null===(s=o.tile)||void 0===s?void 0:s.dem;if(!a)return 0;const l=e.cD([],[i/n*e.a5,r/n*e.a5],o.u_terrain_matrix),c=[l[0]*a.dim,l[1]*a.dim],h=Math.floor(c[0]),u=Math.floor(c[1]),p=c[0]-h,d=c[1]-u;return a.get(h,u)*(1-p)*(1-d)+a.get(h+1,u)*p*(1-d)+a.get(h,u+1)*(1-p)*d+a.get(h+1,u+1)*p*d}getElevationForLngLatZoom(t,i){if(!e.cE(i,t.wrap()))return 0;const{tileID:r,mercatorX:n,mercatorY:s}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(r,n%e.a5,s%e.a5,e.a5)}getElevationForLngLat(t,e){const i=Mt(e,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let r=0;for(const t of i)t.canonical.z>r&&(r=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,r)}getElevation(t,i,r,n=e.a5){return this.getDEMElevation(t,i,r,n)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const t=this.painter.context,i=new e.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new e.T(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new e.T(t,new e.R({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=e.ar([])}const i=this.tileManager.getSourceTile(t,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){const t=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new e.T(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}const r=i&&i.toString()+i.tileID.key+t.key;if(r&&!this._demMatrixCache[r]){const r=this.tileManager.getSource().maxzoom;let n=t.canonical.z-i.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=r?n=t.canonical.z-r:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=t.canonical.x-(t.canonical.x>>n<<n),o=t.canonical.y-(t.canonical.y>>n<<n),a=e.cF(new Float64Array(16),[1/(e.a5<<n),1/(e.a5<<n),0]);e.O(a,a,[s*e.a5,o*e.a5,0]),this._demMatrixCache[t.key]={matrix:a,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(t){const i=this.painter,r=i.width/devicePixelRatio,n=i.height/devicePixelRatio;return!this._fbo||this._fbo.width===r&&this._fbo.height===n||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new e.T(i.context,{width:r,height:n,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new e.T(i.context,{width:r,height:n,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=i.context.createFramebuffer(r,n,!0,!1),this._fbo.depthAttachment.set(i.context.createRenderbuffer(i.context.gl.DEPTH_COMPONENT16,r,n))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,e+=4)i[e+0]=255&r,i[e+1]=255&t,i[e+2]=r>>8<<4|t>>8,i[e+3]=0;const r=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new e.T(t,r,t.gl.RGBA,{premultiply:!1});return n.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,n=r.gl,s=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),n.readPixels(s,a-o-1,1,1,n.RGBA,n.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.tileManager.getTileByID(h);if(!u)return null;const p=this._coordsTextureSize,d=(1<<u.tileID.canonical.z)*p;return new e.a9((u.tileID.canonical.x*p+l)/d+u.tileID.wrap,(u.tileID.canonical.y*p+c)/d,this.getElevation(u.tileID,l,c,p))}depthAtPoint(t){const e=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/16777216+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(t){var i;const r=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,n=r&&0===t.canonical.y,s=r&&t.canonical.y===(1<<t.canonical.z)-1,o=`m_${n?"n":""}_${s?"s":""}`;if(this._meshCache[o])return this._meshCache[o];const a=this.painter.context,l=new e.cG,c=new e.aY,h=this.meshSize,u=e.a5/h,p=h*h;for(let t=0;t<=h;t++)for(let e=0;e<=h;e++)l.emplaceBack(e*u,t*u,0);for(let t=0;t<p;t+=h+1)for(let e=0;e<h;e++)c.emplaceBack(e+t,h+e+t+1,h+e+t+2),c.emplaceBack(e+t,h+e+t+2,e+t+1);const d=l.length,f=d+(h+1),m=(h+1)*h,_=n?e.br:0,g=n?0:1,y=s?e.bs:e.a5,v=s?0:1;for(let t=0;t<=h;t++)l.emplaceBack(t*u,_,g);for(let t=0;t<=h;t++)l.emplaceBack(t*u,y,v);for(let t=0;t<h;t++)c.emplaceBack(m+t,f+t,f+t+1),c.emplaceBack(m+t,f+t+1,m+t+1),c.emplaceBack(0+t,d+t+1,d+t),c.emplaceBack(0+t,0+t+1,d+t+1);const x=l.length,b=x+2*(h+1);for(const t of[0,1])for(let i=0;i<=h;i++)for(const r of[0,1])l.emplaceBack(t*e.a5,i*u,r);for(let t=0;t<2*h;t+=2)c.emplaceBack(x+t,x+t+1,x+t+3),c.emplaceBack(x+t,x+t+3,x+t+2),c.emplaceBack(b+t,b+t+3,b+t+1),c.emplaceBack(b+t,b+t+2,b+t+3);const w=new Le(a.createVertexBuffer(l,to.members),a.createIndexBuffer(c),e.aX.simpleSegment(0,0,l.length,c.length));return this._meshCache[o]=w,w}getMeshFrameDelta(t){return 2*Math.PI*e.bE/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,i){var r;if(!e.cE(i,t.wrap()))return 0;const{tileID:n}=this._getOverscaledTileIDFromLngLatZoom(t,i);return null!==(r=this.getMinMaxElevation(n).minElevation)&&void 0!==r?r:0}getMinMaxElevation(t){const e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,i){const r=e.a9.fromLngLat(t.wrap()),n=(1<<i)*e.a5,s=r.x*n,o=r.y*n,a=Math.floor(s/e.a5),l=Math.floor(o/e.a5);return{tileID:new e.a2(i,0,i,a,l),mercatorX:s,mercatorY:o}}}class ro{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const i=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),r=new e.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return r.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),i.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),i.colorAttachment.set(r.texture),{id:t,fbo:i,texture:r,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(e=>t.id!==e),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some(t=>!t.inUse)}}const no={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class so{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new ro(t.context,30,e.tileManager.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter(i=>!t._layers[i].isHidden(e)),this._coordsAscending={};for(const e in t.tileManagers){this._coordsAscending[e]={};const i=t.tileManagers[e].getVisibleCoordinates(),r=t.tileManagers[e].getSource(),n=r instanceof et?r.terrainTileRanges:null;for(const t of i){const i=this.terrain.tileManager.getTerrainCoords(t,n);for(const t in i)this._coordsAscending[e][t]||(this._coordsAscending[e][t]=[]),this._coordsAscending[e][t].push(i[t])}}this._coordsAscendingStr={};for(const e of t._order){const i=t._layers[e],r=i.source;if(no[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const t in this._coordsAscending[r])this._coordsAscendingStr[r][t]=this._coordsAscending[r][t].map(t=>t.key).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsAscendingStr){const i=this._coordsAscendingStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t,i){if(t.isHidden(this.painter.transform.zoom))return!1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),n=t.type,s=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(no[n]&&(this._prevType&&no[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(no[this._prevType]||no[n]&&o){this._prevType=n;const t=this._stacks.length-1,i=this._stacks[t]||[];for(const n of this._renderableTiles){if(this.pool.isFull()&&(Un(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(n),n.rtt[t]){const e=this.pool.getObjectForId(n.rtt[t].id);if(e.stamp===n.rtt[t].stamp){this.pool.useObject(e);continue}}const o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),n.rtt[t]={id:o.id,stamp:o.stamp},s.context.bindFramebuffer.set(o.fbo.framebuffer),s.context.clear({color:e.bp.transparent,stencil:0}),s.currentStencilSource=void 0;for(let t=0;t<i.length;t++){const e=s.style._layers[i[t]],a=e.source?this._coordsAscending[e.source][n.tileID.key]:[n.tileID];s.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),s._renderTileClippingMasks(e,a,!0),s.renderLayer(s,s.style.tileManagers[e.source],e,a,r),e.source&&(n.rttCoords[e.source]=this._coordsAscendingStr[e.source][n.tileID.key])}}return Un(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),no[n]}return!1}}const oo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},ao=i,lo={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Ys,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:e.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0},co={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class ho{constructor(t,i,r=!1){this.mousedown=t=>{this.startMove(t,h.mousePos(this.element,t)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,h.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const n=new bs;this._rotatePitchHandler=new ms({clickTolerance:3,move:(t,n)=>{const s=i.getBoundingClientRect(),o=new e.P((s.bottom-s.top)/2,(s.right-s.left)/2);return{bearingDelta:e.cy(new e.P(t.x,n.y),n,o),pitchDelta:r?-.5*(n.y-t.y):void 0}},moveStateManager:n,enable:!0,assignEvents:()=>{}}),this.map=t,h.addEventListener(i,"mousedown",this.mousedown),h.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(i,"touchcancel",this.reset)}startMove(t,e){this._rotatePitchHandler.dragStart(t,e),h.disableDrag()}move(t,e){const i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHandler.dragMove(t,e)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){const t=this.element;h.removeEventListener(t,"mousedown",this.mousedown),h.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}let uo;function po(t,i,r,n=!1){if(n||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==t?void 0:t.wrap();const s=new e.V(t.lng,t.lat);if(t=new e.V(t.lng,t.lat),i){const n=new e.V(t.lng-360,t.lat),s=new e.V(t.lng+360,t.lat),o=r.locationToScreenPoint(t).distSqr(i);r.locationToScreenPoint(n).distSqr(i)<o?t=n:r.locationToScreenPoint(s).distSqr(i)<o&&(t=s)}for(;Math.abs(t.lng-r.center.lng)>180;){const e=r.locationToScreenPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==s.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(t))?t:s}const fo={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function mo(t,e,i){const r=t.classList;for(const t in fo)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}class _o extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{if(!this._map)return;const e=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!e)&&this._map.once("render",this._update),this._lngLat=po(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${fo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),a.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity(t&&"moveend"===t.type)}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.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 e.l("dragstart"))),this.fire(new e.l("drag")))},this._onUp=()=>{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 e.l("dragend")),this._state="inactive"},this._addDragHandler=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))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const i=h.createNS("http://www.w3.org/2000/svg","svg"),r=41,n=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${n}px`),i.setAttributeNS(null,"viewBox",`0 0 ${n} ${r}`);const s=h.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const o=h.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"fill-rule","nonzero");const a=h.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of l){const e=h.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),a.appendChild(e)}const c=h.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const u=h.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(u);const p=h.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"opacity","0.25"),p.setAttributeNS(null,"fill","#000000");const d=h.createNS("http://www.w3.org/2000/svg","path");d.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),p.appendChild(d);const f=h.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const _=h.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#000000"),_.setAttributeNS(null,"opacity","0.25"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962");const g=h.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(_),m.appendChild(g),o.appendChild(a),o.appendChild(c),o.appendChild(p),o.appendChild(f),o.appendChild(m),i.appendChild(o),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),mo(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.V.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var i,r;const n=null===(i=this._map)||void 0===i?void 0:i.terrain,s=this._map.transform.isLocationOccluded(this._lngLat);if(!n||s){const t=s?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==t&&(this._element.style.opacity=t))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,a=o.terrain.depthAtPoint(this._pos),l=o.terrain.getElevationForLngLat(this._lngLat,o.transform);if(o.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/o.transform.pixelsPerMeter,h=Math.sin(o.getPitch()*Math.PI/180)*c,u=o.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),p=o.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&p&&this._popup.remove(),this._element.style.opacity=p?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(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}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return(void 0===this._opacity||void 0===t&&void 0===e)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const go={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let yo=0,vo=!1;const xo={maxWidth:100,unit:"metric"};function bo(t,e,i){const r=i&&i.maxWidth||100,n=t._container.clientHeight/2,s=t._container.clientWidth/2,o=t.unproject([s-r/2,n]),a=t.unproject([s+r/2,n]),l=Math.round(t.project(a).x-t.project(o).x),c=Math.min(r,l,t._container.clientWidth),h=o.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?wo(e,c,i/5280,t._getUIString("ScaleControl.Miles")):wo(e,c,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?wo(e,c,h/1852,t._getUIString("ScaleControl.NauticalMiles")):h>=1e3?wo(e,c,h/1e3,t._getUIString("ScaleControl.Kilometers")):wo(e,c,h,t._getUIString("ScaleControl.Meters"))}function wo(t,e,i,r){const n=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(n/i)+"px",t.innerHTML=`${n} ${r}`}const So={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},To=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Co(t){if(t){if("number"==typeof t){const i=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(i,i),"top-right":new e.P(-i,i),bottom:new e.P(0,-t),"bottom-left":new e.P(i,-i),"bottom-right":new e.P(-i,-i),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const i=e.P.convert(t);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:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return Co(new e.P(0,0))}const Mo=i;t.AJAXError=e.cJ,t.Event=e.l,t.Evented=e.E,t.LngLat=e.V,t.MercatorCoordinate=e.a9,t.Point=e.P,t.addProtocol=e.cK,t.config=e.c,t.removeProtocol=e.cL,t.AttributionControl=Ks,t.BoxZoomHandler=hs,t.CanvasSource=rt,t.CooperativeGesturesHandler=Us,t.DoubleClickZoomHandler=Os,t.DragPanHandler=js,t.DragRotateHandler=qs,t.EdgeInsets=Ve,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},t.GeoJSONSource=tt,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.l("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const i=new e.V(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),s=e.e({bearing:n},this.options.fitBoundsOptions),o=W.fromLngLat(i,r);this._map.fitBounds(o,s,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const i=new e.V(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&vo)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new _o({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _o({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{const i=(null==t?void 0:t[0])instanceof ResizeObserverEntry;t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.l("trackuserlocationend")),this.fire(new e.l("userlocationlostfocus")))})}},this.options=e.e({},go,t)}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return e._(this,arguments,void 0,function*(t=!1){if(void 0!==uo&&!t)return uo;if(void 0===window.navigator.permissions)return uo=!!window.navigator.geolocation,uo;try{const t=yield window.navigator.permissions.query({name:"geolocation"});uo="denied"!==t.state}catch(t){uo=!!window.navigator.geolocation}return uo})}().then(t=>this._finishSetupUI(t)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(),h.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,yo=0,vo=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const t=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&t))return;const e=this._map.project(t),i=this._map.unproject([e.x+100,e.y]),r=t.distanceTo(i)/100,n=2*this._accuracy/r;this._circleElement.style.width=`${n.toFixed(2)}px`,this._circleElement.style.height=`${n.toFixed(2)}px`}trigger(){if(!this._setup)return e.w("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 e.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":yo--,vo=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.l("trackuserlocationstart")),this.fire(new e.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),yo++,yo>1?(t={maximumAge:6e5,timeout:0},vo=!0):(t=this.options.positionOptions,vo=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},t.GlobeControl=class{constructor(){this._toggleProjection=()=>{var t;const e=null===(t=this._map.getProjection())||void 0===t?void 0:t.type;this._map.setProjection("mercator"!==e&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var t;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(t=this._map.getProjection())||void 0===t?void 0:t.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=h.create("button","maplibregl-ctrl-globe",this._container),h.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},t.Hash=Hn,t.ImageSource=et,t.KeyboardHandler=zs,t.LngLatBounds=W,t.LogoControl=Js,t.Map=class extends Xs{get _ownerWindow(){var t,e;return(null===(e=null===(t=this._container)||void 0===t?void 0:t.ownerDocument)||void 0===e?void 0:e.defaultView)||window}constructor(t){var i,r;e.cH.mark(e.cI.create);const n=Object.assign(Object.assign(Object.assign({},lo),t),{canvasContextAttributes:Object.assign(Object.assign({},lo.canvasContextAttributes),t.canvasContextAttributes)});if(null!=n.minZoom&&null!=n.maxZoom&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=n.minPitch&&null!=n.maxPitch&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=n.minPitch&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=n.maxPitch&&n.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const s=new We,o=new Ke;void 0!==n.minZoom&&s.setMinZoom(n.minZoom),void 0!==n.maxZoom&&s.setMaxZoom(n.maxZoom),void 0!==n.minPitch&&s.setMinPitch(n.minPitch),void 0!==n.maxPitch&&s.setMaxPitch(n.maxPitch),void 0!==n.renderWorldCopies&&s.setRenderWorldCopies(n.renderWorldCopies),null!==n.transformConstrain&&s.setConstrainOverride(n.transformConstrain),super(s,o,{bearingSnap:n.bearingSnap,zoomSnap:n.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Qs,this._controls=[],this._mapId=e.af(),this._lostContextStyle={style:null,images:null},this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const t of Object.values(this.style._layers))if("custom"===t.type&&console.warn(`Custom layer with id '${t.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),t._listeners)for(const[e]of Object.entries(t._listeners))console.warn(`Custom layer with id '${t.id}' had event listeners for event '${e}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new e.l("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new e.l("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._zoomSnap=n.zoomSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},oo),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this._zoomLevelsToOverscale=n.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=n.transformCameraUpdate,this.transformConstrain=n.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,void 0!==n.reduceMotion&&(a.prefersReducedMotion=n.reduceMotion),this._imageQueueHandle=g.addThrottleControl(()=>this.isMoving()),this._requestManager=new y(n.transformRequest),this._container=this._resolveContainer(n.container),n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Hs(this,n),this._hash=n.hash&&new Hn("string"==typeof n.hash&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,e.e({},n.fitBoundsOptions,{duration:0}))));const l="string"==typeof n.style||!("globe"===(null===(r=null===(i=n.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,l),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new Ks("boolean"==typeof n.attributionControl?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Js,n.logoPosition),this.on("style.load",()=>{if(l||this._resizeTransform(),this.transform.unmodified){const t=e.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.l(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.l(`${t.dataType}dataloading`,t))}),this.on("dataabort",t=>{this.fire(new e.l("sourcedataabort",t))})}_getMapId(){return this._mapId}setGlobalStateProperty(t,e){return this.style.setGlobalStateProperty(t,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}coveringTiles(t){return Mt(this.transform,t)}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this.transform)),super.calculateCameraOptionsFromTo(t,e,i,r)}resize(t,i=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(i);const r=!this._moving;return r&&(this.stop(),this.fire(new e.l("movestart",t)).fire(new e.l("move",t))),this.fire(new e.l("resize",t)),r&&this.fire(new e.l("moveend",t)),this}_resizeInternal(t=!0){const[e,i]=this._containerDimensions(),r=this._getClampedPixelRatio(e,i);if(this._resizeCanvas(e,i,r),this.painter.resize(e,i,r),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const r=this._getClampedPixelRatio(e,i);this._resizeCanvas(e,i,r),this.painter.resize(e,i,r)}this._resizeTransform(t)}_resizeTransform(t=!0){var e;const[i,r]=this._containerDimensions();this.transform.resize(i,r,t),null===(e=this._requestedCameraState)||void 0===e||e.resize(i,r,t)}_getClampedPixelRatio(t,e){const{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),s=t*n,o=e*n;return Math.min(s>i?i/s:1,o>r?r/o:1)*n}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(W.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom){const i=this.transform.zoom,r=this._getTransformForUpdate();return r.setMinZoom(t),this._applyUpdatedTransform(r),this._update(),i!==this.transform.zoom&&this.fire(new e.l("zoomstart")).fire(new e.l("zoom")).fire(new e.l("zoomend")).fire(new e.l("movestart")).fire(new e.l("move")).fire(new e.l("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom){const i=this.transform.zoom,r=this._getTransformForUpdate();return r.setMaxZoom(t),this._applyUpdatedTransform(r),this._update(),i!==this.transform.zoom&&this.fire(new e.l("zoomstart")).fire(new e.l("zoom")).fire(new e.l("zoomend")).fire(new e.l("movestart")).fire(new e.l("move")).fire(new e.l("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(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){const i=this.transform.pitch,r=this._getTransformForUpdate();return r.setMinPitch(t),this._applyUpdatedTransform(r),this._update(),i!==this.transform.pitch&&this.fire(new e.l("pitchstart")).fire(new e.l("pitch")).fire(new e.l("pitchend")).fire(new e.l("movestart")).fire(new e.l("move")).fire(new e.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>180)throw new Error("maxPitch must be less than or equal to 180");if(t>=this.transform.minPitch){const i=this.transform.pitch,r=this._getTransformForUpdate();return r.setMaxPitch(t),this._applyUpdatedTransform(r),this._update(),i!==this.transform.pitch&&this.fire(new e.l("pitchstart")).fire(new e.l("pitch")).fire(new e.l("pitchend")).fire(new e.l("movestart")).fire(new e.l("move")).fire(new e.l("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this.transform.setConstrainOverride(t),this._update()}project(t){return this.transform.locationToScreenPoint(e.V.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const s=e.filter(t=>this.getLayer(t)),o=0!==s.length?this.queryRenderedFeatures(n.point,{layers:s}):[];o.length?r||(r=!0,i.call(this,new ns(t,this,n.originalEvent,{features:o}))):r=!1};return{layers:e,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{const s=e.filter(t=>this.getLayer(t));(0!==s.length?this.queryRenderedFeatures(n.point,{layers:s}):[]).length?r=!0:r&&(r=!1,i.call(this,new ns(t,this,n.originalEvent)))},s=e=>{r&&(r=!1,i.call(this,new ns(t,this,e.originalEvent)))};return{layers:e,listener:i,delegates:{mousemove:n,mouseout:s}}}{const r=t=>{const r=e.filter(t=>this.getLayer(t)),n=0!==r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layers:e,listener:i,delegates:{[t]:r}}}}_saveDelegatedListener(t,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(e)}_removeDelegatedListener(t,e,i){if(!this._delegatedListeners||!this._delegatedListeners[t])return;const r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){const n=r[t];if(n.listener===i&&n.layers.length===e.length&&n.layers.every(t=>e.includes(t))){for(const t in n.delegates)this.off(t,n.delegates[t]);return void r.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r="string"==typeof e?[e]:e,n=this._createDelegatedListener(t,r,i);this._saveDelegatedListener(t,n);for(const t in n.delegates)this.on(t,n.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,r,i)}}}once(t,e,i){if(void 0===i)return super.once(t,e);const r="string"==typeof e?[e]:e,n=this._createDelegatedListener(t,r,i);for(const e in n.delegates){const s=n.delegates[e];n.delegates[e]=(...e)=>{this._removeDelegatedListener(t,r,i),s(...e)}}this._saveDelegatedListener(t,n);for(const t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,i){if(!this.style)return[];let r;const n=t instanceof e.P||Array.isArray(t),s=n?t:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(n?{}:t)||{},s instanceof e.P||"number"==typeof s[0])r=[e.P.convert(s)];else{const t=e.P.convert(s[0]),i=e.P.convert(s[1]);r=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t]}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return!1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){var i,r;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(t,e));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Li(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,n):this.style.loadJSON(t,e,n),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Li(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){const r=this._requestManager.transformRequest(t,"Style");e.j(r,new AbortController).then(t=>{this._updateDiff(t.data,i)}).catch(t=>{t&&this.fire(new e.k(t))})}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(r){e.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const i=this.style&&this.style.tileManagers[t];if(void 0!==i)return i.loaded();this.fire(new e.k(new Error(`There is no tile manager with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const i=this.style.tileManagers[t.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===r.type&&r.source===t.source&&e.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new io(this.painter,i,t),this.painter.renderToTexture=new so(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=e=>{var i;"style"===e.dataType?this.terrain.tileManager.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=e.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new e.l("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.tileManagers;for(const e of Object.values(t))if(!e.areTilesLoaded())return!1;return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}setSourceTileLodParams(t,e,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=St(Math.max(1,t),Math.max(1,e))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=St(Math.max(1,t),Math.max(1,e));return this._update(!0),this}refreshTiles(t,i){const r=this.style.tileManagers[t];if(!r)throw new Error(`There is no tile manager with ID "${t}", cannot refresh tile`);void 0===i?r.reload(!0):r.refreshTiles(i.map(t=>new e.ac(t.z,t.x,t.y)))}addImage(t,i,r={}){const{pixelRatio:n=1,sdf:s=!1,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:a,data:p}=i,d=i;return this.style.addImage(t,{data:new e.R({width:r,height:a},new Uint8Array(p)),pixelRatio:n,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t),this}}{const{width:r,height:p,data:d}=a.getImageData(i);this.style.addImage(t,{data:new e.R({width:r,height:p},d),pixelRatio:n,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0})}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return this.fire(new e.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||e.b(i)?a.getImageData(i):i,{width:s,height:o,data:l}=n;if(void 0===s||void 0===o)return this.fire(new e.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==r.data.width||o!==r.data.height)return this.fire(new e.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||e.b(i));return r.data.replace(l,c),this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.k(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return g.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,t=>{t||this._update(!0)}),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,t=>{t||this._update(!0)}),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupResizeObserver(){var t;let e=!1;const i=Wn(t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())},50),r=null!==(t=this._ownerWindow.ResizeObserver)&&void 0!==t?t:ResizeObserver;this._resizeObserver=new r(t=>{e?i(t):e=!0}),this._resizeObserver.observe(this._container)}_resolveContainer(t){if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new Error(`Container '${t}' not found.`);return e}if(t instanceof HTMLElement)return t;if(t&&"object"==typeof t&&1===t.nodeType)return t;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=h.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const n=this._controlContainer=h.create("div","maplibregl-control-container",t),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(t=>{s[t]=h.create("div",`maplibregl-ctrl-${t} `,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,t):this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t),!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Zn(i,this.transform),u.testSupport(i)}migrateProjection(t,i){super.migrateProjection(t,i),this.painter.transform=t,this.fire(new e.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){var i,r,n,s,o;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=c();this.style.zoomHistory.update(t,i);const r=new e.H(t,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(h=!0,this._crossFadingFactor=n),this.style.update(r)}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==l;null===(n=this.style.projection)||void 0===n||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState,null===(o=this.style.projection)||void 0===o?void 0:o.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding}),this.fire(new e.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.cH.mark(e.cI.load),this.fire(new e.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const p=this._sourcesDirty||this._styleDirty||this._placementDirty;return p||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.l("idle")),!this._loaded||this._fullyLoaded||p||(this._fullyLoaded=!0,e.cH.mark(e.cI.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),g.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),e.cH.clearMetrics(),this._removed=!0,this.fire(new e.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,t=>{e.cH.frame(t),this._frameRequest=null;try{this._render(t)}catch(t){if(!e.Z(t)&&!function(t){return t.message===on}(t))throw t}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return ao}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}},t.MapMouseEvent=ns,t.MapTouchEvent=ss,t.MapWheelEvent=os,t.Marker=_o,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},co,t),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ho(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=h.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.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),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.l("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=po(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const e=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=Co(this.options.offset);if(!i){const t=this._container.offsetWidth,n=this._container.offsetHeight,s=function(t){var e,i,r,n;return t?{top:null!==(e=t.top)&&void 0!==e?e:0,right:null!==(i=t.right)&&void 0!==i?i:0,bottom:null!==(r=t.bottom)&&void 0!==r?r:0,left:null!==(n=t.left)&&void 0!==n?n:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let o;o=e.y+r.bottom.y<n+s.top?["top"]:e.y>this._map.transform.height-n-s.bottom?["bottom"]:[],e.x<t/2+s.left?o.push("left"):e.x>this._map.transform.width-t/2-s.right&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let n=e.add(r[i]);this.options.subpixelPositioning||(n=n.round()),h.setTransform(this._container,`${fo[i]} translate(${n.x}px,${n.y}px)`),mo(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(So),t)}addTo(t){return this._map&&this.remove(),this._map=t,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"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.V.convert(t),this._pos=null,this._flatPos=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"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=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"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}setPadding(t){this.options.padding=t,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(To);t&&t.focus()}},t.RasterDEMTileSource=K,t.RasterTileSource=Y,t.ScaleControl=class{constructor(t){this._onMove=()=>{bo(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,bo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},xo),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=Bs,t.Style=Li,t.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=Ds,t.TwoFingersTouchRotateHandler=Is,t.TwoFingersTouchZoomHandler=Es,t.TwoFingersTouchZoomRotateHandler=Gs,t.VectorTileSource=X,t.VideoSource=it,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,function*(){if(st(t))throw new Error(`A source type called "${t}" already exists.`);((t,e)=>{nt[t]=e})(t,i)}),t.clearPrewarmedResources=function(){const t=B;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(R),B=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()"))},t.createTileMesh=li,t.getMaxParallelImageRequests=function(){return e.c.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return ct().getRTLTextPluginStatus()},t.getVersion=function(){return Mo},t.getWorkerCount=function(){return L.workerCount},t.getWorkerUrl=function(){return e.c.WORKER_URL},t.importScriptInWorkers=function(t){return j().broadcast("IS",t)},t.isTimeFrozen=function(){return l.isFrozen()},t.now=c,t.prewarm=function(){N().acquire(R)},t.restoreNow=function(){l.restoreNow()},t.setMaxParallelImageRequests=function(t){e.c.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setNow=function(t){l.setNow(t)},t.setRTLTextPlugin=function(t,e){return ct().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){L.workerCount=t},t.setWorkerUrl=function(t){e.c.WORKER_URL=t}}),t}();var ur=hr.exports;!function(t,e){void 0===e&&(e={});var i=e.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}}(".maplibregl-map{-webkit-tap-highlight-color:rgb(0,0,0,0);font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgba(0,0,0,.05)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E\")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E\")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E\")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E\")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E\")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E\")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E\")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E\")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E\")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E\")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E\")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E\")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85) scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85) scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85) scale(.88807)'/%3E%3C/g%3E%3C/svg%3E\");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85) scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85) scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85) scale(.88807)'/%3E%3C/g%3E%3C/svg%3E\")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85) scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85) scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85) scale(.88807)'/%3E%3C/g%3E%3C/svg%3E\")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgba(0,0,0,.05)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:\"\";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:\"\";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999}");const pr=[{name:"OSM",url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png",type:"raster"},{name:"CartoDB Light",url:"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",type:"raster"},{name:"CartoDB Dark",url:"https://basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png",type:"raster"}];class dr{_map=null;_container=null;_basemapContainer=null;_maplibreMap=null;_styles;_activeStyle=null;_isOn=!1;_syncBasemapBound;constructor(t={}){this._styles=t.styles||pr,this._syncBasemapBound=this._syncBasemap.bind(this)}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-basemap-ctrl",this._styles.forEach(t=>{const e=document.createElement("button");e.className="emap-basemap-btn",e.textContent=t.name,e.onclick=()=>this._toggleStyle(t),this._container.appendChild(e)}),this._createBasemapLayer(),this._map.on("move",this._syncBasemapBound),this._container}_createBasemapLayer(){if(!this._map)return;const t=this._map.getCanvasContainer();this._basemapContainer=document.createElement("div"),this._basemapContainer.className="emap-basemap",this._basemapContainer.style.cssText="\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 0;\n display: none;\n ",t.insertBefore(this._basemapContainer,t.firstChild)}_toggleStyle(t){this._activeStyle===t?this._turnOff():this._showBasemap(t),this._updateButtons()}async _showBasemap(t){if(this._activeStyle=t,this._isOn=!0,!this._basemapContainer||!this._map)return;this._basemapContainer.style.display="block";const e=(this._map.getCRS()||"").toLowerCase();"webmercator"!==e&&"epsg:3857"!==e&&this._map.reproject&&await this._map.reproject("webmercator"),this._maplibreMap?(this._maplibreMap.resize(),this._setStyle(t),this._syncBasemap()):await this._initMapLibre(t)}async _initMapLibre(t){if(!this._basemapContainer||!this._map)return;const e=this._createMapLibreStyle(t);this._maplibreMap=new ur.Map({container:this._basemapContainer,style:e,center:this._map.getCenter(),zoom:this._map.getZoom(),interactive:!1,attributionControl:!1,maxPitch:0,renderWorldCopies:!0}),this._maplibreMap.on("load",()=>{this._syncBasemap()})}_setStyle(t){if(!this._maplibreMap)return;const e=this._createMapLibreStyle(t);this._maplibreMap.setStyle(e)}_createMapLibreStyle(t){return"raster"===t.type||t.url.includes("{z}")?{version:8,sources:{"basemap-tiles":{type:"raster",tiles:[t.url],tileSize:512}},layers:[{id:"basemap-layer",type:"raster",source:"basemap-tiles",minzoom:0,maxzoom:22}]}:t.url}_syncBasemap(){if(this._maplibreMap&&this._map&&this._isOn)try{this._maplibreMap.jumpTo({center:this._map.getCenter(),zoom:this._map.getZoom()})}catch(t){console.warn("Sync basemap failed:",t)}}_turnOff(){this._activeStyle=null,this._isOn=!1,this._basemapContainer&&(this._basemapContainer.style.display="none")}_updateButtons(){if(!this._container)return;this._container.querySelectorAll(".emap-basemap-btn").forEach((t,e)=>{const i=this._styles[e]===this._activeStyle;t.classList.toggle("active",i)})}isOn(){return this._isOn}onRemove(){this._map&&this._map.off("move",this._syncBasemapBound),this._maplibreMap&&(this._maplibreMap.remove(),this._maplibreMap=null),this._basemapContainer?.parentNode&&this._basemapContainer.parentNode.removeChild(this._basemapContainer),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null}}class fr{_map=null;_container=null;_btn=null;_active=!1;_polygonFillColor;_hoveredFeature=null;_hoverVertexCoords=null;_hoverVertexIds=[];_hoverType=null;_hoverInsertionId=-1;_dragging=!1;_neighborShapes=[];_dragFromCoords=null;_onMouseMoveBound;_onMouseDownBound;_onMouseUpBound;_onMoveHandlerBound;_onContextMenuBound;constructor(t={}){this._polygonFillColor=void 0!==t.polygonFillColor?t.polygonFillColor:"rgba(0,0,0,0.15)",this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this),this._onMoveHandlerBound=this._onMapMove.bind(this),this._onContextMenuBound=this._onContextMenu.bind(this)}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group",this._btn=document.createElement("button"),this._btn.className="emap-ctrl-edit",this._btn.type="button",this._btn.title="Edit Vertices",this._btn.innerHTML='<span class="emap-ctrl-icon">✏</span>',this._btn.addEventListener("click",()=>this._toggle()),this._container.appendChild(this._btn),this._container}onRemove(){this._deactivate(),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null,this._btn=null}_toggle(){this._active?this._deactivate():this._activate()}_activate(){if(!this._map)return;this._active=!0,this._btn?.classList.add("active"),this._map.setEditMode("vertex");const t=this._map.getCanvasContainer();t.classList.add("emap-edit-active"),t.addEventListener("mousemove",this._onMouseMoveBound),t.addEventListener("mousedown",this._onMouseDownBound),t.addEventListener("contextmenu",this._onContextMenuBound),window.addEventListener("mouseup",this._onMouseUpBound),this._map.on("move",this._onMoveHandlerBound)}_deactivate(){if(!this._map)return;this._active=!1,this._btn?.classList.remove("active"),this._map.setEditMode("none"),this._map.clearEditVertexState(),this._hoveredFeature=null,this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._dragging=!1;const t=this._map.getCanvasContainer();t.classList.remove("emap-edit-active"),t.removeEventListener("mousemove",this._onMouseMoveBound),t.removeEventListener("mousedown",this._onMouseDownBound),t.removeEventListener("contextmenu",this._onContextMenuBound),window.removeEventListener("mouseup",this._onMouseUpBound),this._map.off("move",this._onMoveHandlerBound),this._map.render()}_onMapMove(){this._hoveredFeature&&!this._dragging&&(this._updateEditState(),this._map?.render())}_onContextMenu(t){if(t.preventDefault(),this._dragging)return;if("vertex"!==this._hoverType||0===this._hoverVertexIds.length)return;if(!this._hoveredFeature)return;const e=this._hoverVertexIds[0],i=this._hoveredFeature.arcs;J().vertexIsArcEndpoint(e,i)||this._showContextMenu(t.clientX,t.clientY,()=>{this._deleteHoveredVertex()})}_deleteHoveredVertex(){if(!this._map||!this._hoveredFeature||0===this._hoverVertexIds.length)return;const t=this._hoveredFeature.arcs,e=this._hoverVertexIds[0],i=this._hoveredFeature.source,r=t.getVertex2(e);if(J().deleteVertex(t,e),this._refreshSourceDisplayArcs(i),this._bumpSourceEditVersion(i),r){const n=this._map.getSource(i);n&&this._map.pushCommand(new or({vertexIndex:e,coords:[r[0],r[1]],arcs:t,source:n}))}this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._map.clearEditVertexState(),this._map.render()}_refreshSourceDisplayArcs(t){this._map?.getSource(t)?.refreshDisplayArcs()}_bumpSourceEditVersion(t){const e=this._map?.getSource(t);Ft(e?.getDataset?.()??null)}_showContextMenu(t,e,i){document.getElementById("emap-ctx-menu")?.remove();const r=document.createElement("div");r.id="emap-ctx-menu",Object.assign(r.style,{position:"fixed",left:`${t}px`,top:`${e}px`,background:"#fff",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.18)",padding:"4px 0",zIndex:"9999",minWidth:"120px",font:"13px/1.5 system-ui, sans-serif"});const n=document.createElement("div");n.textContent="删除节点",Object.assign(n.style,{padding:"6px 16px",cursor:"pointer",color:"#d32"}),n.addEventListener("mouseenter",()=>{n.style.background="#f5f5f5"}),n.addEventListener("mouseleave",()=>{n.style.background=""}),n.addEventListener("click",t=>{t.stopPropagation(),r.remove(),document.removeEventListener("click",s),i()}),r.appendChild(n),document.body.appendChild(r);const s=()=>{r.remove(),document.removeEventListener("click",s)};setTimeout(()=>document.addEventListener("click",s),0)}_onMouseMove(t){if(!this._map)return;if(this._dragging)return void this._handleDrag(t);const e=this._map.getCanvasContainer().getBoundingClientRect(),i=t.clientX-e.left,r=t.clientY-e.top,n=this._map.queryFeatures([i,r]);if(0===n.length)return this._hoveredFeature=null,this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._map.clearEditVertexState(),void this._map.render();const s=n[0];if("point"===s.geometryType)return this._hoveredFeature=null,this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._map.clearEditVertexState(),void this._map.render();const o=this._map.getSource(s.source);if(!o)return;const a=o.getLayers(),l=o.getArcs();if(!l)return;let c=null;for(const t of a)if(t.shapes&&t.shapes[s.id]){c=t.shapes[s.id];break}c&&(this._hoveredFeature={source:s.source,layer:s.layer,id:s.id,shape:c,arcs:l,geometryType:s.geometryType,allLayers:a},this._findNearestVertices(c,l,i,r),this._hoverVertexCoords||this._findInterpolatedPoint(c,l,i,r),this._findNeighborShapes(l),this._updateEditState(),this._map.render())}_findNearestVertices(t,e,i,r){if(!this._map)return;const n=this._map.unproject(i,r),s=J().findNearestVertices(n,t,e);if(!s||0===s.length)return this._hoverVertexCoords=null,void(this._hoverVertexIds=[]);const o=e.getVertex2(s[0]);if(!o)return this._hoverVertexCoords=null,void(this._hoverVertexIds=[]);const a=this._map.project(o[0],o[1]);Math.sqrt((a[0]-i)*(a[0]-i)+(a[1]-r)*(a[1]-r))<=10?(this._hoverVertexCoords=[o[0],o[1]],this._hoverVertexIds=s,this._hoverType="vertex",this._hoverInsertionId=-1):(this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1)}_findInterpolatedPoint(t,e,i,r){if(!this._map)return;const n=this._map.unproject(i,r);let s=1/0,o=null;const a=J();if(a.forEachSegmentInShape(t,e,(t,e,i,r)=>{const l=i[t],c=r[t],h=i[e],u=r[e],p=a.findClosestPointOnSeg(n[0],n[1],l,c,h,u,0),d=p[0]-n[0],f=p[1]-n[1],m=Math.sqrt(d*d+f*f);m<s&&(s=m,o={insertionId:(t<e?t:e)+1,point:[p[0],p[1]]})}),!o)return;const l=o,c=this._map.project(l.point[0],l.point[1]);Math.sqrt((c[0]-i)*(c[0]-i)+(c[1]-r)*(c[1]-r))<=10&&(this._hoverVertexCoords=l.point,this._hoverVertexIds=[],this._hoverType="interpolated",this._hoverInsertionId=l.insertionId)}_findNeighborShapes(t){if(this._neighborShapes=[],!this._hoveredFeature||"polygon"!==this._hoveredFeature.geometryType)return;const{ii:e}=t.getVertexData(),i=this._hoveredFeature.id,r=new Set;if(this._hoverVertexIds.length>0)for(const t of this._hoverVertexIds)r.add(J().findArcIdFromVertexId(t,e));else"interpolated"===this._hoverType&&this._hoverInsertionId>0&&r.add(J().findArcIdFromVertexId(this._hoverInsertionId-1,e));if(0===r.size)return;const n=[];for(const t of this._hoveredFeature.allLayers)if(t.shapes)for(let e=0;e<t.shapes.length;e++){if(e===i)continue;const s=t.shapes[e];if(!s)continue;let o=!1;for(const t of s){for(const e of t){const t=e>=0?e:~e;if(r.has(t)){o=!0;break}}if(o)break}o&&n.push(s)}this._neighborShapes=n}_updateEditState(){if(!this._map||!this._hoveredFeature)return;const t=this._hoveredFeature.geometryType,e=this._neighborShapes.length>0?[this._hoveredFeature.shape,...this._neighborShapes]:[this._hoveredFeature.shape];this._map.setEditVertexState({shapes:e,arcs:this._hoveredFeature.arcs,hoverVertex:this._hoverVertexCoords,hoverType:this._hoverType,geometryType:t,polygonFill:"polygon"===t?this._polygonFillColor:null,neighborShapes:this._neighborShapes.length>0?this._neighborShapes:void 0})}_onMouseDown(t){if(this._hoverVertexCoords&&this._hoveredFeature){if(t.preventDefault(),t.stopPropagation(),"interpolated"===this._hoverType&&this._hoverInsertionId>=0){const t=this._hoveredFeature.arcs,e=[this._hoverVertexCoords[0],this._hoverVertexCoords[1]];J().insertVertex(t,this._hoverInsertionId,e),this._hoverVertexIds=[this._hoverInsertionId],this._hoverType="vertex",this._bumpSourceEditVersion(this._hoveredFeature.source),this._pushVertexInsertCommand(this._hoverInsertionId,e)}this._dragFromCoords=this._hoverVertexCoords?[this._hoverVertexCoords[0],this._hoverVertexCoords[1]]:null,this._dragging=!0}}_pushVertexInsertCommand(t,e){if(!this._map||!this._hoveredFeature)return;const i=this._map.getSource(this._hoveredFeature.source);i&&this._map.pushCommand(new sr({insertionId:t,point:e,arcs:this._hoveredFeature.arcs,source:i}))}_handleDrag(t){if(!this._map||!this._hoveredFeature||0===this._hoverVertexIds.length)return;const e=this._map.getCanvasContainer().getBoundingClientRect(),i=t.clientX-e.left,r=t.clientY-e.top,n=this._map.unproject(i,r),s=this._hoveredFeature.arcs;J().snapVertices(this._hoverVertexIds,[n[0],n[1]],s),this._hoverVertexCoords=[n[0],n[1]],this._updateEditState(),this._map.render()}_onMouseUp(t){if(!this._dragging||!this._map||!this._hoveredFeature)return;this._dragging=!1;const e=this._map.getCanvasContainer().getBoundingClientRect(),i=t.clientX-e.left,r=t.clientY-e.top,n=this._map.unproject(i,r),s=this._hoveredFeature.source,o=this._hoveredFeature.arcs;o.transformPoints&&o.transformPoints(function(){}),this._refreshSourceDisplayArcs(s),this._bumpSourceEditVersion(s);const a=this._dragFromCoords;if(a&&(a[0]!==n[0]||a[1]!==n[1])&&this._hoverVertexIds.length>0){const t=this._map.getSource(s);t&&this._map.pushCommand(new nr({vertexIds:[...this._hoverVertexIds],from:[a[0],a[1]],to:[n[0],n[1]],arcs:o,source:t}))}this._dragFromCoords=null,this._map.fire("vertex_moved",{id:this._hoveredFeature.id,source:s,layer:this._hoveredFeature.layer,vertexIndex:this._hoverVertexIds[0]??null,vertexIds:this._hoverVertexIds,coords:n}),this._map.render()}}const mr={polygon:"▢",polyline:"╱",point:"●"},_r={polygon:"Draw Polygon",polyline:"Draw Polyline",point:"Draw Point"};class gr{_options;_map=null;_container=null;_btn=null;_active=!1;_vertices=[];_cursorCoord=null;_snapCoord=null;_snapKind=null;_snapThreshold;_onMouseMoveBound;_onClickBound;_onDblClickBound;_onKeyDownBound;_onMoveHandlerBound;constructor(t){this._options=t,this._snapThreshold=t.snapThreshold??10,this._onMouseMoveBound=this._onMouseMove.bind(this),this._onClickBound=this._onClick.bind(this),this._onDblClickBound=this._onDblClick.bind(this),this._onKeyDownBound=this._onKeyDown.bind(this),this._onMoveHandlerBound=this._onMapMove.bind(this)}onAdd(t){this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group",this._btn=document.createElement("button"),this._btn.className="emap-ctrl-draw",this._btn.type="button",this._btn.title=_r[this._options.type];const e=document.createElement("span");e.className="emap-ctrl-icon";const i=this._options.icon??mr[this._options.type];return"string"==typeof i?e.textContent=i:e.appendChild(i),this._btn.replaceChildren(e),this._btn.addEventListener("click",()=>this._toggle()),this._container.appendChild(this._btn),t.on("editmodechange",t=>{this._active&&"draw"!==t.mode&&this._deactivateQuiet()}),this._container}onRemove(){this._deactivate(),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null,this._btn=null}_toggle(){this._active?this._deactivate():this._activate()}_activate(){if(!this._map)return;this._active=!0,this._btn?.classList.add("active"),this._map.setEditMode("draw");const t=this._map.getCanvasContainer();t.classList.add("emap-draw-active"),t.addEventListener("mousemove",this._onMouseMoveBound),t.addEventListener("click",this._onClickBound),t.addEventListener("dblclick",this._onDblClickBound),window.addEventListener("keydown",this._onKeyDownBound),this._map.on("move",this._onMoveHandlerBound)}_deactivate(){this._clearDrawState(),this._deactivateQuiet(),this._map?.setEditMode("none")}_deactivateQuiet(){if(!this._map)return;this._active=!1,this._btn?.classList.remove("active");const t=this._map.getCanvasContainer();t.classList.remove("emap-draw-active"),t.removeEventListener("mousemove",this._onMouseMoveBound),t.removeEventListener("click",this._onClickBound),t.removeEventListener("dblclick",this._onDblClickBound),window.removeEventListener("keydown",this._onKeyDownBound),this._map.off("move",this._onMoveHandlerBound),this._map.clearEditDrawState(),this._map.render()}_clearDrawState(){this._vertices=[],this._cursorCoord=null,this._snapCoord=null,this._snapKind=null}_onMapMove(){this._vertices.length>0&&(this._updateDrawState(),this._map?.render())}_onMouseMove(t){if(!this._map)return;const e=this._map.getCanvasContainer().getBoundingClientRect(),i=t.clientX-e.left,r=t.clientY-e.top,n=this._map.unproject(i,r);this._cursorCoord=[n[0],n[1]];const s=this._findSnapTarget(i,r);this._snapCoord=s?.coord??null,this._snapKind=s?.kind??null,(this._vertices.length>0||this._snapCoord)&&(this._updateDrawState(),this._map.render())}_onClick(t){if(!this._map)return;const e=this._map.getCanvasContainer().getBoundingClientRect(),i=t.clientX-e.left,r=t.clientY-e.top,n=this._snapCoord?[this._snapCoord[0],this._snapCoord[1]]:this._map.unproject(i,r);if("point"===this._options.type)return this._vertices=[n],void this._commitFeature();if("polygon"===this._options.type&&this._vertices.length>=3){const t=this._vertices[0],e=this._map.project(t[0],t[1]);if(Math.hypot(e[0]-i,e[1]-r)<=12)return void this._commitFeature()}this._vertices.push(n),this._updateDrawState(),this._map.render()}_onDblClick(t){this._map&&(t.preventDefault(),t.stopPropagation(),"point"!==this._options.type&&("polyline"===this._options.type&&this._vertices.length>=2||"polygon"===this._options.type&&this._vertices.length>=3)&&this._commitFeature())}_onKeyDown(t){"Escape"===t.key&&(this._clearDrawState(),this._map?.clearEditDrawState(),this._map?.render())}_findSnapTarget(t,e){if(!this._map)return null;const i=this._map,r=this._options.snapSources??[this._options.source],n=!1!==this._options.snapToVertex,s=!1!==this._options.snapToEdge;let o=this._snapThreshold,a=null,l=null;for(const c of r){const r=i.getSource(c);if(!r)continue;const h=r.getArcs();if(!h?.getVertexData)continue;const u=h.getVertexData();if(!u)continue;const p=u.xx,d=u.yy;if(n)for(let r=0;r<p.length;r++){const n=i.project(p[r],d[r]),s=Math.hypot(n[0]-t,n[1]-e);s<o&&(o=s,a=[p[r],d[r]],l="vertex")}s&&h.forEachSegment&&h.forEachSegment((r,n,s,c)=>{const h=i.project(s[r],c[r]),u=i.project(s[n],c[n]),p=yr([t,e],h,u);p.dist<o&&(o=p.dist,a=i.unproject(p.point[0],p.point[1]),l="edge")})}if(n)for(const r of this._vertices){const n=i.project(r[0],r[1]),s=Math.hypot(n[0]-t,n[1]-e);s<o&&(o=s,a=[r[0],r[1]],l="vertex")}return a?{coord:a,kind:l}:null}_commitFeature(){if(!this._map||0===this._vertices.length)return;const t=this._map.getSource(this._options.source);if(!t)return;const e=t.getDataset();if(!e)return;const i=this._resolveTargetLayer(e.layers);if(!i)return;const r=e.layers.indexOf(i);let n,s,o;if(i.shapes||(i.shapes=[]),"point"===this._options.type)n=[this._vertices[0]],i.shapes.push(n);else{if(s="polygon"===this._options.type?[...this._vertices,this._vertices[0]]:[...this._vertices],o=e.arcs,!o)return;n=[[this._appendArc(o,s)]],i.shapes.push(n)}let a=null;if(i.data){const t=i.data.getRecords?.();t&&(a={},t.push(a))}t.refreshDisplayArcs(),this._map.pushCommand(new ar({geometryType:this._options.type,layer:i,source:t,appendedShape:n,appendedRecord:a,arcVertices:s,arcs:o}));const l=i.shapes.length-1,c=it(i,r>=0?r:0);this._map.fire("feature_created",{id:l,source:this._options.source,layer:c,geometryType:this._options.type,properties:{}}),this._clearDrawState(),this._map.clearEditDrawState(),t.fire("data",{reason:"edit"})}_resolveTargetLayer(t){if(!t.length)return null;if(this._options.sourceLayer)for(let e=0;e<t.length;e++){if(it(t[e],e)===this._options.sourceLayer)return t[e]}const e="polygon"===this._options.type?"polygon":"polyline"===this._options.type?"polyline":"point";for(const i of t)if(i.geometry_type===e)return i;return t[0]}_appendArc(t,e){const i=t.getVertexData(),r=i.xx,n=i.yy,s=i.nn,o=i.zz,a=r.length,l=s.length,c=e.length,h=new Float64Array(a+c),u=new Float64Array(a+c),p=new Int32Array(l+1);h.set(r),u.set(n),p.set(s);for(let t=0;t<c;t++)h[a+t]=e[t][0],u[a+t]=e[t][1];p[l]=c;let d=null;if(o){d=new Float64Array(a+c),d.set(o);for(let t=0;t<c;t++)d[a+t]=1/0}return t.updateVertexData(p,h,u,d),l}_updateDrawState(){this._map&&this._map.setEditDrawState({vertices:[...this._vertices],cursorCoord:this._snapCoord||this._cursorCoord,snapCoord:this._snapCoord,snapKind:this._snapKind,geometryType:this._options.type,drawColor:this._options.drawColor||"#0078ff"})}}function yr(t,e,i){const r=e[0],n=e[1],s=i[0],o=i[1],a=t[0],l=t[1],c=s-r,h=o-n,u=c*c+h*h;if(0===u){const t=a-r,e=l-n;return{point:[r,n],dist:Math.hypot(t,e)}}let p=((a-r)*c+(l-n)*h)/u;p<0?p=0:p>1&&(p=1);const d=r+p*c,f=n+p*h;return{point:[d,f],dist:Math.hypot(a-d,l-f)}}class vr{_container=null;_vertexEditControl;_drawControls=[];_options;constructor(t){this._options=t||{},this._vertexEditControl=new fr,this._options.drawSource&&(this._drawControls=[new gr({source:this._options.drawSource,sourceLayer:this._options.drawSourceLayer,type:"polygon"}),new gr({source:this._options.drawSource,sourceLayer:this._options.drawSourceLayer,type:"polyline"}),new gr({source:this._options.drawSource,sourceLayer:this._options.drawSourceLayer,type:"point"})])}onAdd(t){const e=this._vertexEditControl.onAdd(t);this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group emap-edit-toolbar";const i=e.querySelector("button");i&&this._container.appendChild(i);for(const e of this._drawControls){const i=e.onAdd(t).querySelector("button");i&&this._container.appendChild(i)}return this._container}onRemove(){this._vertexEditControl.onRemove();for(const t of this._drawControls)t.onRemove();this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._container=null}}class xr{_map=null;_container=null;_undoBtn=null;_redoBtn=null;_options;_onHistoryChange=null;constructor(t={}){this._options=t}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className=`emap-ctrl emap-ctrl-group ${this._options.className||""}`.trim(),this._undoBtn=this._createButton("undo","↶",this._options.undoTitle??"Undo (Ctrl+Z)",()=>{this._map?.undo()}),this._redoBtn=this._createButton("redo","↷",this._options.redoTitle??"Redo (Ctrl+Shift+Z)",()=>{this._map?.redo()}),this._setEnabled(t.canUndo(),t.canRedo()),this._onHistoryChange=t=>this._setEnabled(t.canUndo,t.canRedo),t.on("historychange",this._onHistoryChange),this._container}onRemove(){this._map&&this._onHistoryChange&&this._map.off("historychange",this._onHistoryChange),this._onHistoryChange=null,this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null,this._undoBtn=null,this._redoBtn=null}_setEnabled(t,e){this._undoBtn&&(this._undoBtn.disabled=!t),this._redoBtn&&(this._redoBtn.disabled=!e)}_createButton(t,e,i,r){const n=document.createElement("button");n.className=`emap-ctrl-${t}`,n.type="button",n.title=i,n.disabled=!0;const s=document.createElement("span");return s.className="emap-ctrl-icon",s.textContent=e,n.appendChild(s),n.addEventListener("click",r),this._container?.appendChild(n),n}}class br{_options;_dragThreshold;_enabled=!0;_map=null;_container=null;_overlay=null;_canvasContainer=null;_startPx=null;_onMouseDownBound;_onMouseMoveBound;_onMouseUpBound;constructor(t={}){this._options=t,this._dragThreshold=t.dragThreshold??4,this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this)}onAdd(t){this._map=t,this._canvasContainer=t.getCanvasContainer();const e=document.createElement("div");e.className="emap-box-select",e.style.position="absolute",e.style.pointerEvents="none",e.style.display="none",e.style.left="0",e.style.top="0",e.style.width="0",e.style.height="0";const i=this._options.style??{};e.style.border=`${i.strokeWidth??1.5}px solid ${i.stroke??"#0078ff"}`,e.style.background=i.fill??"rgba(0, 120, 255, 0.1)",e.style.boxSizing="border-box",this._canvasContainer.appendChild(e),this._overlay=e,this._canvasContainer.addEventListener("mousedown",this._onMouseDownBound);const r=document.createElement("div");return r.className="emap-ctrl emap-box-select-anchor",r.style.width="0",r.style.height="0",r.style.pointerEvents="none",this._container=r,r}onRemove(){this._canvasContainer&&this._canvasContainer.removeEventListener("mousedown",this._onMouseDownBound),window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound),this._overlay?.parentNode&&this._overlay.parentNode.removeChild(this._overlay),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._canvasContainer=null,this._overlay=null,this._container=null,this._startPx=null}disable(){this._enabled=!1,this._startPx&&this._cancelDrag()}enable(){this._enabled=!0}isEnabled(){return this._enabled}_onMouseDown(t){if(!this._enabled)return;if(!t.shiftKey)return;if(0!==t.button)return;if(!this._canvasContainer||!this._overlay)return;t.preventDefault();const[e,i]=this._eventToContainerPx(t);this._startPx=[e,i],this._overlay.style.left=`${e}px`,this._overlay.style.top=`${i}px`,this._overlay.style.width="0",this._overlay.style.height="0",this._overlay.style.display="block",window.addEventListener("mousemove",this._onMouseMoveBound),window.addEventListener("mouseup",this._onMouseUpBound)}_onMouseMove(t){if(!this._startPx||!this._overlay)return;const[e,i]=this._eventToContainerPx(t),[r,n]=this._startPx,s=Math.min(r,e),o=Math.min(n,i),a=Math.abs(e-r),l=Math.abs(i-n);this._overlay.style.left=`${s}px`,this._overlay.style.top=`${o}px`,this._overlay.style.width=`${a}px`,this._overlay.style.height=`${l}px`}_onMouseUp(t){if(!this._startPx||!this._map||!this._overlay)return void this._cleanupDrag();const[e,i]=this._startPx,[r,n]=this._eventToContainerPx(t),s=r-e,o=n-i,a=Math.hypot(s,o);if(this._overlay.style.display="none",a<this._dragThreshold)return void this._cleanupDrag();const l=Math.min(e,r),c=Math.min(i,n),h=Math.max(e,r),u=Math.max(i,n),p=function(t){const e=new Set,i=[];for(const r of t){const t=`${r.source}|${r.layer}|${r.id}`;e.has(t)||(e.add(t),i.push({source:r.source,layer:r.layer,id:r.id}))}return i}(this._map.queryFeatures([[l,c],[h,u]],this._options.layers?{layers:this._options.layers}:void 0)),d=this._modeFromEvent(t);this._map.select(p,{mode:d}),this._cleanupDrag()}_cancelDrag(){this._overlay&&(this._overlay.style.display="none"),this._cleanupDrag()}_cleanupDrag(){this._startPx=null,window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound)}_eventToContainerPx(t){if(!this._canvasContainer)return[0,0];const e=this._canvasContainer.getBoundingClientRect();return[t.clientX-e.left,t.clientY-e.top]}_modeFromEvent(t){return t.altKey?"toggle":t.ctrlKey||t.metaKey?"add":"replace"}}class wr{_options;_dragThreshold;_enabled=!0;_map=null;_container=null;_svg=null;_polyline=null;_canvasContainer=null;_path=null;_onMouseDownBound;_onMouseMoveBound;_onMouseUpBound;constructor(t={}){this._options=t,this._dragThreshold=t.dragThreshold??4,this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this)}onAdd(t){this._map=t,this._canvasContainer=t.getCanvasContainer();const e="http://www.w3.org/2000/svg",i=document.createElementNS(e,"svg");i.setAttribute("class","emap-lasso-select"),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width="100%",i.style.height="100%",i.style.pointerEvents="none",i.style.display="none";const r=document.createElementNS(e,"polyline"),n=this._options.style??{};r.setAttribute("stroke",n.stroke??"#0078ff"),r.setAttribute("stroke-width",String(n.strokeWidth??1.5)),r.setAttribute("fill",n.fill??"rgba(0, 120, 255, 0.1)"),r.setAttribute("stroke-dasharray",n.strokeDasharray??"4 3"),r.setAttribute("points",""),i.appendChild(r),this._canvasContainer.appendChild(i),this._svg=i,this._polyline=r,this._canvasContainer.addEventListener("mousedown",this._onMouseDownBound);const s=document.createElement("div");return s.className="emap-ctrl emap-lasso-select-anchor",s.style.width="0",s.style.height="0",s.style.pointerEvents="none",this._container=s,s}onRemove(){this._canvasContainer&&this._canvasContainer.removeEventListener("mousedown",this._onMouseDownBound),window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound),this._svg?.parentNode&&this._svg.parentNode.removeChild(this._svg),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._canvasContainer=null,this._svg=null,this._polyline=null,this._container=null,this._path=null}disable(){this._enabled=!1,this._path&&this._cancelDrag()}enable(){this._enabled=!0}isEnabled(){return this._enabled}_onMouseDown(t){if(!this._enabled)return;if(!t.shiftKey)return;if(0!==t.button)return;if(!this._canvasContainer||!this._svg||!this._polyline)return;t.preventDefault();const e=this._eventToContainerPx(t);this._path=[e],this._polyline.setAttribute("points",`${e[0]},${e[1]}`),this._svg.style.display="block",window.addEventListener("mousemove",this._onMouseMoveBound),window.addEventListener("mouseup",this._onMouseUpBound)}_onMouseMove(t){if(!this._path||!this._polyline)return;const e=this._eventToContainerPx(t);this._path.push(e),this._polyline.setAttribute("points",this._path.map(t=>`${t[0]},${t[1]}`).join(" "))}_onMouseUp(t){const e=this._path;if(!e||!this._map||!this._svg)return void this._cleanupDrag();if(this._svg.style.display="none",e.length<3)return void this._cleanupDrag();const i=function(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const[s,o]of t)s<e&&(e=s),o<i&&(i=o),s>r&&(r=s),o>n&&(n=o);return[e,i,r,n]}(e),r=i[2]-i[0],n=i[3]-i[1];if(Math.hypot(r,n)<this._dragThreshold)return void this._cleanupDrag();const s=e.slice();s.push(e[0]);const o=this._map.queryFeatures([[i[0],i[1]],[i[2],i[3]]],this._options.layers?{layers:this._options.layers}:void 0),a=[],l=new Set,c=!1!==this._options.includeIntersecting;for(const t of o){const e=`${t.source}|${t.layer}|${t.id}`;l.has(e)||Tr(this._map,t,s,c)&&(l.add(e),a.push({source:t.source,layer:t.layer,id:t.id}))}const h=function(t){return t.altKey?"toggle":t.ctrlKey||t.metaKey?"add":"replace"}(t);this._map.select(a,{mode:h}),this._cleanupDrag()}_cancelDrag(){this._svg&&(this._svg.style.display="none"),this._cleanupDrag()}_cleanupDrag(){this._path=null,window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound)}_eventToContainerPx(t){if(!this._canvasContainer)return[0,0];const e=this._canvasContainer.getBoundingClientRect();return[t.clientX-e.left,t.clientY-e.top]}}function Sr(t,e){const[i,r]=t;let n=!1;const s=e.length;for(let t=0,o=s-1;t<s;o=t++){const[s,a]=e[t],[l,c]=e[o];a>r!=c>r&&i<(l-s)*(r-a)/(c-a)+s&&(n=!n)}return n}function Tr(t,e,i,r){const n=function(t,e){const i=t.getSource(e.source);if(!i)return null;let r=t.layers?.resolve(e.source,e.layer);if(!r){const t=i.getDataset?.();r=t?.layers.find((t,i)=>it(t,i)===e.layer||t?.name===e.layer||t?.id===e.layer)}if(!r?.shapes)return null;const n=r.shapes?.[e.id];return n?{layer:r,shape:n,arcs:i.getArcs?.()}:null}(t,e);if(!n)return!1;if("point"===n.layer.geometry_type){const e=rt(n.shape);if(0===e.length)return!1;const s=e.map(([e,i])=>t.project(e,i));return r?s.some(t=>Mr(t,i)):s.every(t=>Mr(t,i))}if(!n.arcs)return!1;const s=function(t,e,i){const r=[];for(const n of e){const e=[],s=i.getShapeIter?.(n);if(s)for(;s.hasNext();)e.push(t.project(s.x,s.y));else for(const r of n){const n=r>=0?r:~r,s=i.getArcIter(n);for(;s.hasNext();)e.push(t.project(s.x,s.y))}e.length>0&&r.push(e)}return r}(t,n.shape,n.arcs);if(0===s.length)return!1;const o="polygon"===n.layer.geometry_type;return r?function(t,e,i){for(const r of t){if(r.some(t=>Mr(t,e)))return!0;if(Cr(r,e,i))return!0}return!(!i||!e.some(e=>function(t,e){let i=!1;for(const r of e){if(Er(t,r))return!0;Sr(t,r)&&(i=!i)}return i}(e,t)))}(s,i,o):function(t,e,i){for(const r of t){if(!r.every(t=>Mr(t,e)))return!1;if(Cr(r,e,i))return!1}return!0}(s,i,o)}function Cr(t,e,i){const r=i?Ar(t):t,n=Ar(e);for(let t=0;t<r.length-1;t++){const e=r[t],i=r[t+1];for(let t=0;t<n.length-1;t++){if(Ir(e,i,n[t],n[t+1]))return!0}}return!1}function Mr(t,e){return Er(t,e)||Sr(t,e)}function Er(t,e){const i=Ar(e);for(let e=0;e<i.length-1;e++)if(Pr(t,i[e],i[e+1]))return!0;return!1}function Ar(t){if(t.length<2)return t;const e=t[0],i=t[t.length-1];return r=e,n=i,Math.abs(r[0]-n[0])<=zr&&Math.abs(r[1]-n[1])<=zr?t:[...t,e];var r,n}function Ir(t,e,i,r){const n=Dr(t,e,i),s=Dr(t,e,r),o=Dr(i,r,t),a=Dr(i,r,e);return!(!kr(n)||!Pr(i,t,e))||(!(!kr(s)||!Pr(r,t,e))||(!(!kr(o)||!Pr(t,i,r))||(!(!kr(a)||!Pr(e,i,r))||n>0!=s>0&&o>0!=a>0)))}function Pr(t,e,i){return!!kr(Dr(e,i,t))&&(t[0]>=Math.min(e[0],i[0])-zr&&t[0]<=Math.max(e[0],i[0])+zr&&t[1]>=Math.min(e[1],i[1])-zr&&t[1]<=Math.max(e[1],i[1])+zr)}function Dr(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(e[1]-t[1])*(i[0]-t[0])}function kr(t){return Math.abs(t)<=zr}const zr=1e-9;const Rr=[{value:"",label:"weighted (default)"},{value:"weighted",label:"weighted"},{value:"visvalingam",label:"visvalingam"},{value:"dp",label:"dp (Douglas–Peucker)"}];class Lr{_opts;_map=null;_container=null;_btn=null;_popup=null;_percentageInput=null;_percentageLabel=null;_methodSel=null;_keepShapes=null;_planar=null;_applyBtn=null;_statusEl=null;_onDocClick=null;_onDocKey=null;constructor(t){this._opts=t}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group emap-ctrl-simplify-wrap",this._btn=document.createElement("button"),this._btn.type="button",this._btn.className="emap-ctrl-simplify",this._btn.innerHTML='<span class="emap-ctrl-icon">≈</span>',this._btn.title=this._opts.title??"Simplify geometry",this._btn.onclick=t=>{t.stopPropagation(),this._togglePopup()},this._container.appendChild(this._btn),this._popup=this._buildPopup(),this._container.appendChild(this._popup),this._container}onRemove(){this._teardownDocListeners(),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._container=null,this._btn=null,this._popup=null,this._percentageInput=null,this._percentageLabel=null,this._methodSel=null,this._keepShapes=null,this._planar=null,this._applyBtn=null,this._statusEl=null,this._map=null}_buildPopup(){const t=document.createElement("div");t.className="emap-simplify-popup",t.style.display="none",t.style.cssText+="\n position:absolute; top:36px; left:0; min-width:240px; padding:10px;\n background:#fff; border:1px solid #ccc; border-radius:4px;\n box-shadow:0 2px 8px rgba(0,0,0,.15); font-size:13px;\n z-index:10; color:#222;",t.onclick=t=>t.stopPropagation();const e=this._opts.initialPercentage??10,i=this._opts.initialMethod??"";return t.innerHTML=`\n <div style="margin-bottom:8px;">\n <label style="display:flex; align-items:center; gap:6px;">\n <span>Percentage:</span>\n <input type="range" min="0" max="100" step="0.1" value="${e}" style="flex:1;" />\n <span class="value" style="min-width:48px; text-align:right;">${e}%</span>\n </label>\n </div>\n <div style="margin-bottom:8px;">\n <label style="display:flex; align-items:center; gap:6px;">\n <span>Method:</span>\n <select style="flex:1;">\n ${Rr.map(t=>`<option value="${t.value}"${t.value===i?" selected":""}>${t.label}</option>`).join("")}\n </select>\n </label>\n </div>\n <div style="margin-bottom:8px; display:flex; gap:12px; flex-wrap:wrap;">\n <label><input type="checkbox" data-flag="keep-shapes" checked /> keep-shapes</label>\n <label><input type="checkbox" data-flag="planar" /> planar</label>\n </div>\n <div style="display:flex; gap:6px; align-items:center;">\n <button type="button" class="apply" style="padding:4px 12px;">Apply</button>\n <span class="status" style="opacity:.8; font-size:12px;"></span>\n </div>\n `,this._percentageInput=t.querySelector("input[type=range]"),this._percentageLabel=t.querySelector(".value"),this._methodSel=t.querySelector("select"),this._keepShapes=t.querySelector("input[data-flag=keep-shapes]"),this._planar=t.querySelector("input[data-flag=planar]"),this._applyBtn=t.querySelector("button.apply"),this._statusEl=t.querySelector(".status"),this._percentageInput.oninput=()=>{this._percentageLabel&&this._percentageInput&&(this._percentageLabel.textContent=`${this._percentageInput.value}%`)},this._applyBtn.onclick=()=>this._apply(),t}_togglePopup(){if(!this._popup)return;const t="none"===this._popup.style.display;this._popup.style.display=t?"block":"none",this._btn?.classList.toggle("active",t),t?(this._setupDocListeners(),this._setStatus("")):this._teardownDocListeners()}_setupDocListeners(){this._onDocClick=t=>{this._container&&!this._container.contains(t.target)&&this._togglePopup()},this._onDocKey=t=>{"Escape"===t.key&&this._togglePopup()},document.addEventListener("mousedown",this._onDocClick),document.addEventListener("keydown",this._onDocKey)}_teardownDocListeners(){this._onDocClick&&document.removeEventListener("mousedown",this._onDocClick),this._onDocKey&&document.removeEventListener("keydown",this._onDocKey),this._onDocClick=null,this._onDocKey=null}_setStatus(t){this._statusEl&&(this._statusEl.textContent=t)}async _apply(){if(!this._map||!this._percentageInput||!this._methodSel)return;const t=Number(this._percentageInput.value),e=this._methodSel.value,i={source:this._opts.source,percentage:t};this._opts.target&&(i.target=this._opts.target),e&&(i.method=e),this._keepShapes?.checked&&(i.keepShapes=!0),this._planar?.checked&&(i.planar=!0),this._applyBtn&&(this._applyBtn.disabled=!0),this._setStatus("Running…");try{const e=await this._map.ops.simplifyLayer(i);if(e?.ok)this._setStatus(`Simplified at ${t}%`);else{const t=e?.error,i=t?`${t.kind}${t.field?" field="+t.field:""}`:"unknown";this._setStatus(`Failed: ${i}`)}}catch(t){this._setStatus(`Error: ${t?.message??t}`)}finally{this._applyBtn&&(this._applyBtn.disabled=!1)}}}export{U as AffineTransform,dr as BasemapControl,$ as Bounds,br as BoxSelectControl,Wi as BulkFeatureDeleteCommand,nt as CanvasPainter,zt as CompositeCommand,Si as DEFAULT_CRS,ot as DatasetReplaceCommand,Y as DefaultMapshaperAdapter,zi as DragPanHandler,gr as DrawFeatureControl,Ui as EditHistory,st as EditOverlayRenderer,vr as EditToolbar,Yi as Emap,ct as Err,G as EventDispatcher,Fi as FeatureAccessor,Ot as FeatureAffineCommand,ar as FeatureCreateCommand,Zi as FeatureDeleteCommand,Xt as FeaturePropertyChangeCommand,Li as FeatureQuery,Bt as FeatureTranslateCommand,Kt as FieldAddCommand,Jt as FieldRemoveCommand,Qt as FieldRenameCommand,Oi as HighlightManager,xr as HistoryControl,qt as IDENTITY_MATRIX,wr as LassoSelectControl,Ri as MapshaperWorkerPool,lr as NavigationControl,at as OK,et as Projection,Ni as Selection,Lr as SimplifyControl,Ut as SplitSharedArcsCommand,cr as StatusControl,Pi as TopologySource,$i as Transaction,U as Transform,Bi as ValidatorRegistry,or as VertexDeleteCommand,fr as VertexEditControl,sr as VertexInsertCommand,nr as VertexMoveCommand,X as Viewport,Ft as bumpEditVersion,jt as composeMatrix,Tr as featureMatchesLasso,ir as findInvalidFieldName,J as getDefaultMapshaperAdapter,Mi as inferFromPrj,Gt as invertMatrix,Rt as isPathLayer,Lt as isPointLayer,er as isValidFieldName,tr as isValidLayerName,Ci as normalizeCrsString,lt as okValue,$t as planSharedArcSplit,Sr as pointInPolygon,Ki as quoteCliArg,Ti as resolveDatasetCRS,Xi as resolvePointStyle,Hi as resolveStrokeStyle,Nt as rotateMatrix,Vt as scaleMatrix,Q as setDefaultMapshaperAdapter,rr as topologyValidator};
|
|
1
|
+
import t from"./mapshaper-vendor.mjs";function e(t,e){return e.forEach(function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(function(n){if("default"!==n&&!(n in t)){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})}),Object.freeze(t)}function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}),n}var s={exports:{}},r=i(Object.freeze({__proto__:null,default:{}}));function o(t,e){for(var n=0,i=t.length-1;i>=0;i--){var s=t[i];"."===s?t.splice(i,1):".."===s?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,h=function(t){return a.exec(t).slice(1)};function l(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");i&&(t=i+"/"+t,e="/"===i.charAt(0))}return(e?"/":"")+(t=o(g(t.split("/"),function(t){return!!t}),!e).join("/"))||"."}function c(t){var e=u(t),n="/"===x(t,-1);return(t=o(g(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t}function u(t){return"/"===t.charAt(0)}function p(){return c(g(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function d(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=l(t).substr(1),e=l(e).substr(1);for(var i=n(t.split("/")),s=n(e.split("/")),r=Math.min(i.length,s.length),o=r,a=0;a<r;a++)if(i[a]!==s[a]){o=a;break}var h=[];for(a=o;a<i.length;a++)h.push("..");return(h=h.concat(s.slice(o))).join("/")}function _(t){var e=h(t),n=e[0],i=e[1];return n||i?(i&&(i=i.substr(0,i.length-1)),n+i):"."}function f(t,e){var n=h(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n}function m(t){return h(t)[3]}var y={extname:m,basename:f,dirname:_,sep:"/",delimiter:":",relative:d,join:p,isAbsolute:u,normalize:c,resolve:l};function g(t,e){if(t.filter)return t.filter(e);for(var n=[],i=0;i<t.length;i++)e(t[i],i,t)&&n.push(t[i]);return n}var v,x="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return e<0&&(e=t.length+e),t.substr(e,n)},w=i(Object.freeze({__proto__:null,basename:f,default:y,delimiter:":",dirname:_,extname:m,isAbsolute:u,join:p,normalize:c,relative:d,resolve:l,sep:"/"}));v=s,function(){var t=Math.abs,e=Math.floor,n=Math.sin,i=Math.cos,s=Math.tan,o=Math.asin,a=Math.acos,h=Math.atan,l=Math.atan2,c=Math.sqrt,u=Math.pow,p=Math.exp,d=Math.log,_=Math.hypot,f=Math.sinh,m=Math.cosh,y=Math.min,g=Math.max,x=1/0,b=Math.PI,C=57.29577951308232,S=.017453292519943295,A=6378137,M=.0066943799901413165,E=b/4,k=b/2,D=1.5*b,I=2*b,P=2/b,T=-45,L=-47,N=1e-10,R={last_errno:0,debug_level:0,logger:null},F=["no arguments in initialization list","no options found in 'init' file","invalid init= string","projection not named","unknown projection id","effective eccentricity = 1","unknown unit conversion id","invalid boolean param argument","unknown elliptical parameter name","reciprocal flattening (1/f) = 0","|radius reference latitude| > 90","squared eccentricity < 0","major axis or radius = 0 or not given","latitude or longitude exceeded limits","invalid x or y","improperly formed DMS value","non-convergent inverse meridional dist","non-convergent inverse phi2","acos/asin: |arg| >1+1e-14","tolerance condition error","conic lat_1 = -lat_2","lat_1 >= 90","lat_1 = 0","lat_ts >= 90","no distance between control points","projection not selected to be rotated","W <= 0 or M <= 0","lsat not in 1-5 range","path not in range","h <= 0","k <= 0","lat_0 = 0 or 90 or alpha = 90","lat_1=lat_2 or lat_1=0 or lat_2=90","elliptical usage required","invalid UTM zone number","arg(s) out of range for Tcheby eval","failed to find projection to be rotated","failed to load datum shift file","both n & m must be spec'd and > 0","n <= 0, n > 1 or not specified","lat_1 or lat_2 not specified","|lat_1| == |lat_2|","lat_0 is pi/2 from mean lat","unparseable coordinate system definition","geocentric transformation missing z or ellps","unknown prime meridian conversion id","illegal axis orientation combination","point not within available datum shift grids","invalid sweep axis, choose x or y","invalid value for h","point outside of projection domain"];function G(){var t=R.last_errno;t&&(t>0||!function(t){return O.indexOf(t)>-1}(t))&&j(t)}var O=[-14,-15,-17,-18,-19,-20,-27,-48];function B(t){R.last_errno=t}function z(){B(-20)}function U(){B(-20)}function q(t){j(t)}function j(t){B(t),$()}function $(t,e){var n;throw e||(e={}),e.code||(e.code=R.last_errno||0),t||(n=e.code,t=F[~n]||"unknown error"),R.last_errno=0,new V(t,e)}function V(t,e){var n=new Error(t);return n.name="ProjError",Object.keys(e).forEach(function(t){n[t]=e[t]}),n}function H(t){return W(t)*S}function W(t){var e=/(-?[0-9.]+)d?([0-9.]*)'?([0-9.]*)"?([nsew]?)$/i.exec(t),n=NaN;return e&&(n=+(e[1]||"0")+ +(e[2]||"0")/60+ +(e[3]||"0")/3600,/[ws]/i.test(e[4])&&(n=-n)),isNaN(n)&&j(-16),n}function K(t){return X(t)}function X(t){return parseFloat(t)}function Z(t,e){var n,i,s=e[0],r=t[e.substr(1)],o=void 0!==r;return"t"==s?n=o:o?(i=r.param,r.used=!0,"i"==s?n=parseInt(i):"d"==s?n=K(i):"r"==s?n=H(i):"s"==s?n=String(i):"b"==s&&("T"==i||"t"==i||!0===i?n=!0:("F"==i||"f"==i||B(-8),n=!1))):n={i:0,b:!1,d:0,r:0,s:""}[s],void 0===n&&$("invalid request to pj_param, fatal"),n}function J(t){for(var e,n=/\+([a-z][a-z0-9_]*(?:=[^\s]*)?)/gi,i={};e=n.exec(t);)Y(i,e[1]);return i}function Y(t,e){var n,i,s=e.split("=");1==s.length?(n=e,i=!0):(n=s[0],i=e.substr(s[0].length+1)),t[n]={used:!1,param:i}}var Q={};function tt(t,e,n,i){Q[e]={init:t,name:n,description:i}}function et(t){return!t||t.is_latlong}function nt(t){var e=!1,n="";return"datum"in t.params?(e=!0,n+=st(t,"datum")):"R"in t.params?n+=st(t,"R"):"ellps"in t.params?n+=st(t,"ellps"):"a"in t.params?(n+=st(t,"a"),"b"in t.params?n+=st(t,"b"):"es"in t.params?n+=st(t,"es"):"f"in t.params?n+=st(t,"f"):n+=" +es="+t.es):q(-13),e||(n+=st(t,"towgs84"),n+=st(t,"nadgrids")),n+=st(t,"R_A"),n+=st(t,"R_V"),n+=st(t,"R_a"),n+=st(t,"R_lat_a"),n+=st(t,"R_lat_g"),n+=st(t,"pm")}function it(t){var e="datum,ellps,a,b,es,rf,f,towgs84,nadgrids,R,R_A,R_V,R_a,R_lat_a,R_lat_g,pm,init,no_defs".split(","),n="";return Object.keys(t.params).forEach(function(i){-1==e.indexOf(i)&&(n+=st(t,i))}),(n+=nt(t)).trim()}function st(t,e){var n="";return e in t.params&&(n=" +"+e,!0!==t.params[e].param&&(n+="="+Z(t.params,"s"+e))),n}var rt=[["WGS84","towgs84=0,0,0","WGS84","WGS_1984"],["GGRS87","towgs84=-199.87,74.79,246.62","GRS80","Greek_Geodetic_Reference_System_1987"],["NAD83","towgs84=0,0,0","GRS80","North_American_Datum_1983"],["NAD27","nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat","clrk66","North_American_Datum_1927"],["potsdam","towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7","bessel","Potsdam Rauenberg 1950 DHDN"],["carthage","towgs84=-263.0,6.0,431.0","clrk80ign","Carthage 1934 Tunisia"],["hermannskogel","towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232","bessel","Hermannskogel"],["ire65","towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15","mod_airy","Ireland 1965"],["nzgd49","towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993","intl","New Zealand Geodetic Datum 1949"],["OSGB36","towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894","airy","OSGB 1936"],[null,null,null,null]],ot=[["greenwich","0dE"],["lisbon","9d07'54.862\"W"],["paris","2d20'14.025\"E"],["bogota","74d04'51.3\"W"],["madrid","3d41'16.58\"W"],["rome","12d27'8.4\"E"],["bern","7d26'22.5\"E"],["jakarta","106d48'27.79\"E"],["ferro","17d40'W"],["brussels","4d22'4.71\"E"],["stockholm","18d3'29.8\"E"],["athens","23d42'58.815\"E"],["oslo","10d43'22.5\"E"],[null,null]];function at(t){var e=rt.reduce(function(e,n){return n[0]===t?n:e},null);return e?{id:e[0],defn:e[1],ellipse_id:e[2],name:e[3]}:null}var ht=[["MERIT","a=6378137.0","rf=298.257","MERIT 1983"],["SGS85","a=6378136.0","rf=298.257","Soviet Geodetic System 85"],["GRS80","a=6378137.0","rf=298.257222101","GRS 1980(IUGG, 1980)"],["IAU76","a=6378140.0","rf=298.257","IAU 1976"],["airy","a=6377563.396","b=6356256.910","Airy 1830"],["APL4.9","a=6378137.0","rf=298.25","Appl. Physics. 1965"],["NWL9D","a=6378145.0","rf=298.25","Naval Weapons Lab., 1965"],["mod_airy","a=6377340.189","b=6356034.446","Modified Airy"],["andrae","a=6377104.43","rf=300.0","Andrae 1876 (Den., Iclnd.)"],["aust_SA","a=6378160.0","rf=298.25","Australian Natl & S. Amer. 1969"],["GRS67","a=6378160.0","rf=298.2471674270","GRS 67(IUGG 1967)"],["bessel","a=6377397.155","rf=299.1528128","Bessel 1841"],["bess_nam","a=6377483.865","rf=299.1528128","Bessel 1841 (Namibia)"],["clrk66","a=6378206.4","b=6356583.8","Clarke 1866"],["clrk80","a=6378249.145","rf=293.4663","Clarke 1880 mod."],["clrk80ign","a=6378249.2","rf=293.4660212936269","Clarke 1880 (IGN)."],["CPM","a=6375738.7","rf=334.29","Comm. des Poids et Mesures 1799"],["delmbr","a=6376428","rf=311.5","Delambre 1810 (Belgium)"],["engelis","a=6378136.05","rf=298.2566","Engelis 1985"],["evrst30","a=6377276.345","rf=300.8017","Everest 1830"],["evrst48","a=6377304.063","rf=300.8017","Everest 1948"],["evrst56","a=6377301.243","rf=300.8017","Everest 1956"],["evrst69","a=6377295.664","rf=300.8017","Everest 1969"],["evrstSS","a=6377298.556","rf=300.8017","Everest (Sabah & Sarawak)"],["fschr60","a=6378166","rf=298.3","Fischer (Mercury Datum) 1960"],["fschr60m","a=6378155","rf=298.3","Modified Fischer 1960"],["fschr68","a=6378150","rf=298.3","Fischer 1968"],["helmert","a=6378200","rf=298.3","Helmert 1906"],["hough","a=6378270.0","rf=297","Hough"],["intl","a=6378388.0","rf=297","International 1909 (Hayford)"],["krass","a=6378245.0","rf=298.3","Krasovsky 1940"],["kaula","a=6378163","rf=298.24","Kaula 1961"],["lerch","a=6378139","rf=298.257","Lerch 1979"],["mprts","a=6397300","rf=191","Maupertius 1738"],["new_intl","a=6378157.5","b=6356772.2","New International 1967"],["plessis","a=6376523","b=6355863","Plessis 1817 (France)"],["SEasia","a=6378155.0","b=6356773.3205","Southeast Asia"],["walbeck","a=6376896.0","b=6355834.8467","Walbeck"],["WGS60","a=6378165.0","rf=298.3","WGS 60"],["WGS66","a=6378145.0","rf=298.25","WGS 66"],["WGS72","a=6378135.0","rf=298.26","WGS 72"],["WGS84","a=6378137.0","rf=298.257223563","WGS 84"],["sphere","a=6370997.0","b=6370997.0","Normal Sphere (r=6370997)"],[null,null,null,null]];function lt(t){var e=ht.reduce(function(e,n){return n[0]===t?n:e},null);return e?{id:e[0],major:e[1],ell:e[2],name:e[3]}:null}var ct=[["km","1000","Kilometer"],["m","1","Meter"],["dm","1/10","Decimeter"],["cm","1/100","Centimeter"],["mm","1/1000","Millimeter"],["kmi","1852.0","International Nautical Mile"],["in","0.0254","International Inch"],["ft","0.3048","International Foot"],["yd","0.9144","International Yard"],["mi","1609.344","International Statute Mile"],["fath","1.8288","International Fathom"],["ch","20.1168","International Chain"],["link","0.201168","International Link"],["us-in","1/39.37","U.S. Surveyor's Inch"],["us-ft","0.304800609601219","U.S. Surveyor's Foot"],["us-yd","0.914401828803658","U.S. Surveyor's Yard"],["us-ch","20.11684023368047","U.S. Surveyor's Chain"],["us-mi","1609.347218694437","U.S. Surveyor's Statute Mile"],["ind-yd","0.91439523","Indian Yard"],["ind-ft","0.30479841","Indian Foot"],["ind-ch","20.11669506","Indian Chain"],[null,null,null]];function ut(t){var e=ct.reduce(function(e,n){return t===n[0]?n:e},null);return e?{id:e[0],to_meter:e[1],name:e[2]}:null}var pt={},dt={};function _t(t){return dt[t]||null}function ft(t){var e,n,i,s,o,a,h,l,c=t.split(":"),u=c[0],p=c[1];return p&&u||q(-3),(e=_t(u=u.toLowerCase()))||(n=u,s=r,a=(o=w).join(o.dirname("/Users/zhang/code/emap/node_modules/mproj/dist"),"../nad"),h=o.join(a,n.toUpperCase()),l=o.join(a,n.toLowerCase()),s.existsSync(h)?i=s.readFileSync(h,"utf8"):s.existsSync(l)?i=s.readFileSync(l,"utf8"):$("unable to read from 'init' file named "+n),e=i,dt[u]=e),e?function(t,e){var n,i,s="",r="";return(n=t.indexOf("<"+e+">"))>-1&&((i=t.lastIndexOf("#",n))>-1&&(r=t.substring(i+1,n).trim(),/\n/.test(r)&&(r="")),s=(s=(s=" "+(s=(s=(s=(s=(s=t.substr(n+e.length+2)).substr(0,s.indexOf("<"))).replace(/#.*/g,"")).replace(/[\s]+/g," ")).replace(/\+title=[^+]*[^ +]/g,function(t){return t.replace(/ /g,"\t")}))).replace(/ (?=[a-z])/gi," +")).replace(/\t/g," ").trim()),s?{opts:s,comment:r}:null}(e,p):null}function mt(e){var i,s,r=J(e),o={params:r,is_latlong:!1,is_geocent:!1,is_long_wrap_set:!1,long_wrap_center:0,axis:"enu",gridlist:null,gridlist_count:0,vgridlist_geoid:null,vgridlist_geoid_count:0};return Object.keys(r).length||q(-1),Z(r,"tinit")&&function(t,e){var n=pt[e.toLowerCase()]||null;n||function(t,e){pt[t.toLowerCase()]=e}(e,n=ft(e)),n||q(-2),yt(t,n.opts)}(r,Z(r,"sinit")),(i=Z(r,"sproj"))||q(-4),(s=Q[i])||q(-5),Z(r,"bno_defs")||function(t){yt(t,"+ellps=WGS84")}(o.params),function(t){var e,n,i,s,r=484813681109536e-20,o=t.datum_params=[0,0,0,0,0,0,0];t.datum_type=0,(e=Z(t.params,"sdatum"))&&((n=at(e))||q(-9),n.ellipse_id&&Y(t.params,"ellps="+n.ellipse_id),n.defn&&Y(t.params,n.defn)),(i=Z(t.params,"snadgrids"))&&"@null"!=i&&$("+nadgrids is not implemented"),Z(t.params,"scatalog")&&$("+catalog is not implemented"),(s=Z(t.params,"stowgs84"))&&(s.split(",").forEach(function(t,e){o[e]=K(t)||0}),0!=o[3]||0!=o[4]||0!=o[5]||0!=o[6]?(t.datum_type=2,o[3]*=r,o[4]*=r,o[5]*=r,o[6]=o[6]/1e6+1):t.datum_type=1)}(o),function(e){var i,s,r,o,a,h=.16666666666666666,l=e.params,u=0,p=0;Z(l,"tR")?u=Z(l,"dR"):((i=Z(l,"sellps"))&&((s=lt(i))||q(-9),Y(l,s.major),Y(l,s.ell)),u=Z(l,"da"),Z(l,"tes")?p=Z(l,"des"):Z(l,"te")?p=(r=Z(l,"de"))*r:Z(l,"trf")?((r=Z(l,"drf"))||q(-10),p=(r=1/r)*(2-r)):Z(l,"tf")?p=(r=Z(l,"df"))*(2-r):Z(l,"tb")&&(p=1-(o=Z(l,"db"))*o/(u*u)),o||(o=u*c(1-p)),Z(l,"bR_A")?(u*=1-p*(h+p*(.04722222222222222+.022156084656084655*p)),p=0):Z(l,"bR_V")?u*=1-p*(h+p*(.06944444444444445+.04243827160493827*p)):Z(l,"bR_a")?(u=.5*(u+o),p=0):Z(l,"bR_g")?(u=c(u*o),p=0):Z(l,"bR_h")?(u+o===0&&q(-20),u=2*u*o/(u+o),p=0):(a=Z(l,"tR_lat_a")||Z(l,"tR_lat_g"))&&(r=n(Z(l,a?"rR_lat_a":"rR_lat_g")),t(r)>k&&q(-11),r=1-p*r*r,u*=a?.5*(1-p+r)/(r*c(r)):c(1-p)/r,p=0)),p<0&&q(-12),u<=0&&q(-13),e.es=p,e.a=u}(o),o.a_orig=o.a,o.es_orig=o.es,o.e=c(o.es),o.ra=1/o.a,o.one_es=1-o.es,o.one_es||q(-6),o.rone_es=1/o.one_es,function(t){return 1==t.datum_type&&t.datum_params[0]==t.datum_params[1]==t.datum_params[2]===0&&6378137==t.a&&Math.abs(t.es-.00669437999)<5e-11}(o)&&(o.datum_type=4),o.geoc=!!o.es&&Z(r,"bgeoc"),o.over=Z(r,"bover"),o.has_geoid_vgrids=Z(r,"tgeoidgrids"),o.has_geoid_vgrids&&Z(r,"sgeoidgrids"),o.is_long_wrap_set=Z(r,"tlon_wrap"),o.is_long_wrap_set&&(o.long_wrap_center=Z(r,"rlon_wrap"),t(o.long_wrap_center)<10*I==0&&q(-14)),Z(r,"saxis")&&function(t){var e="ewnsud",n=Z(t.params,"saxis");3!=n.length&&q(L),-1!=e.indexOf(n[0])&&-1!=e.indexOf(n[1])&&-1!=e.indexOf(n[2])||q(L),t.axis=n}(o),o.lam0=Z(r,"rlon_0"),o.phi0=Z(r,"rlat_0"),o.x0=Z(r,"dx_0"),o.y0=Z(r,"dy_0"),Z(r,"tk_0")?o.k0=Z(r,"dk_0"):Z(r,"tk")?o.k0=Z(r,"dk"):o.k0=1,o.k0<=0&&q(-31),function(t){var e,n,i,s=t.params;(e=Z(s,"sunits"))&&((i=ut(e))||q(-7),n=i.to_meter),n||(n=Z(s,"sto_meter"))?(t.to_meter=gt(n),t.fr_meter=1/t.to_meter):t.to_meter=t.fr_meter=1,n=null,(e=Z(s,"svunits"))&&((i=ut(e))||q(-7),n=i.to_meter),n||Z(s,"svto_meter")?(t.vto_meter=gt(n),t.vfr_meter=1/t.vto_meter):(t.vto_meter=t.to_meter,t.vfr_meter=t.fr_meter)}(o),function(t){var e,n,i,s=t.params;(e=Z(s,"spm"))?(n=function(t){var e=ot.reduce(function(e,n){return n[0]===t?n:e},null);return e?{id:e[0],definition:e[1]}:null}(e),i=H(n?n.definition:e),isNaN(i)&&q(-46),t.from_greenwich=i):t.from_greenwich=0}(o),s.init(o),o}function yt(t,e){var n=J(e),i=["datum","ellps","a","b","rf","f"].reduce(function(e,n){return e||n in t},!1);Object.keys(n).forEach(function(e){e in t||"ellps"==e&&i||(t[e]=n[e])})}function gt(t){var e=t.split("/"),n=X(e[0]);return e.length>1&&(n/=X(e[1])),n}function vt(t,e){var n=0,i=t*t,s=e*e;return t<=0&&(n|=4),e<=0&&(n|=8),t<e&&(n|=16),n?null:{a:t,b:e,a2:i,b2:s,e2:(i-s)/i,ep2:(i-s)/s}}function xt(t,e,s,r,o){var a,h,l,u,p=0,d=s[e],_=r[e],f=o[e];return _<-k&&_>-1.001*k?_=-k:_>k&&_<1.001*k?_=k:(_<-k||_>k)&&(p|=1),p||(d>b&&(d-=2*b),h=n(_),u=i(_),l=h*h,a=t.a/c(1-t.e2*l),s[e]=(a+f)*u*i(d),r[e]=(a+f)*u*n(d),o[e]=(a*(1-t.e2)+f)*h),p}function wt(e,n,i,s,r){var o,a,u,p,d,_,f,m,y,g,v,x,w,b,C,S,A=1e-12,M=i[n],E=s[n],D=r[n];if(p=c(M*M+E*E),d=c(M*M+E*E+D*D),p/e.a<A){if(a=0,d/e.a<A)return i[n]=0,s[n]=k,r[n]=-e.b,0}else a=l(E,M);_=D/d,f=p/d,m=1/c(1-e.e2*(2-e.e2)*f*f),v=f*(1-e.e2)*m,x=_*m,S=0;do{S++,u=p*v+D*x-(y=e.a/c(1-e.e2*x*x))*(1-e.e2*x*x),g=e.e2*y/(y+u),C=(b=_*(m=1/c(1-g*(2-g)*f*f)))*v-(w=f*(1-g)*m)*x,v=w,x=b}while(C*C>1e-24&&S<30);o=h(b/t(w)),i[n]=a,s[n]=o,r[n]=u}function bt(t,e,n){var i=n.length>2,s=[n[0]],r=[n[1]],o=[i?n[2]:0];t.is_latlong&&(s[0]*=S,r[0]*=S),R.last_errno=0,Ct(t,e,s,r,o),(R.last_errno||s[0]==x)&&$(null,{point:n}),e.is_latlong&&(s[0]*=C,r[0]*=C),n[0]=s[0],n[1]=r[0],i&&(n[2]=o[0])}function Ct(t,e,n,i,s){var r,o,a=n.length,h={},l={};if("enu"!=t.axis&&St(t.axis,!1,n,i,s),1!=t.vto_meter&&s)for(r=0;r<a;r++)s[r]*=t.vto_meter;if(t.is_geocent){if(s||q(T),1!=t.to_meter)for(r=0;r<a;r++)n[r]!=x&&(n[r]*=t.to_meter,i[r]*=t.to_meter);At(t.a_orig,t.es_orig,n,i,s)}else if(!t.is_latlong)if(t.inv3d||t.inv||$("source projection not invertible"),t.inv3d)$("inverse 3d transformations not supported");else for(r=0;r<a;r++)l.x=n[r],l.y=i[r],o=Dt(l,t),n[r]=o.lam,i[r]=o.phi,G();if(0!==t.from_greenwich)for(r=0;r<a;r++)n[r]!=x&&(n[r]+=t.from_greenwich);if(t.has_geoid_vgrids&&s&&$("vgrid transformation not supported"),function(t,e,n,i,s){var r,o,a,h,l=n.length;0!=t.datum_type&&0!=e.datum_type&&(function(t,e){return t.datum_type==e.datum_type&&(!(t.a_orig!=e.a_orig||Math.abs(t.es_orig-e.es_orig)>5e-11)&&(1==t.datum_type?t.datum_params[0]==e.datum_params[0]&&t.datum_params[1]==e.datum_params[1]&&t.datum_params[2]==e.datum_params[2]:2==t.datum_type?t.datum_params[0]==e.datum_params[0]&&t.datum_params[1]==e.datum_params[1]&&t.datum_params[2]==e.datum_params[2]&&t.datum_params[3]==e.datum_params[3]&&t.datum_params[4]==e.datum_params[4]&&t.datum_params[5]==e.datum_params[5]&&t.datum_params[6]==e.datum_params[6]:3!=t.datum_type||Z(t.params,"snadgrids")==Z(e.params,"snadgrids")))}(t,e)||(r=t.a_orig,o=t.es_orig,a=e.a_orig,h=e.es_orig,s||(s=new Float64Array(l)),3==t.datum_type&&($("gridshift not implemented"),r=A,o=M),3==e.datum_type&&(a=A,h=M),o==h&&r==a&&1!=t.datum_type&&2!=t.datum_type&&1!=e.datum_type&&2!=e.datum_type||(Mt(r,o,n,i,s),1!=t.datum_type&&2!=t.datum_type||function(t,e,n,i){var s,r,o,a,h,l,c,u,p=e.length,d=t.datum_params,_=d[0],f=d[1],m=d[2];if(1==t.datum_type)for(u=0;u<p;u++)e[u]!=x&&(e[u]+=_,n[u]+=f,i[u]+=m);else if(2==t.datum_type)for(a=d[3],h=d[4],l=d[5],c=d[6],u=0;u<p;u++)e[u]!=x&&(s=c*(e[u]-l*n[u]+h*i[u])+_,r=c*(l*e[u]+n[u]-a*i[u])+f,o=c*(-h*e[u]+a*n[u]+i[u])+m,e[u]=s,n[u]=r,i[u]=o)}(t,n,i,s),1!=e.datum_type&&2!=e.datum_type||function(t,e,n,i){var s,r,o,a,h,l,c,u,p=e.length,d=t.datum_params,_=d[0],f=d[1],m=d[2];if(1==t.datum_type)for(u=0;u<p;u++)e[u]!=x&&(e[u]-=_,n[u]-=f,i[u]-=m);else if(2==t.datum_type)for(a=d[3],h=d[4],l=d[5],c=d[6],u=0;u<p;u++)e[u]!=x&&(s=(e[u]-_)/c,r=(n[u]-f)/c,o=(i[u]-m)/c,e[u]=s+l*r-h*o,n[u]=-l*s+r+a*o,i[u]=h*s-a*r+o)}(e,n,i,s),At(a,h,n,i,s),3==e.datum_type&&pj_apply_gridshift_2(e,1,n,i,s))))}(t,e,n,i,s),e.has_geoid_vgrids&&s&&$("vgrid transformation not supported"),0!==e.from_greenwich)for(r=0;r<a;r++)n[r]!=x&&(n[r]-=e.from_greenwich);if(e.is_geocent){if(s||q(T),Mt(e.a_orig,e.es_orig,n,i,s),1!=e.fr_meter)for(r=0;r<a;r++)n[r]!=x&&(n[r]*=e.fr_meter,i[r]*=e.fr_meter)}else if(e.is_latlong){if(e.is_latlong&&e.is_long_wrap_set)for(r=0;r<a;r++)if(n[r]!=x){for(;n[r]<e.long_wrap_center-b;)n[r]+=I;for(;n[r]>e.long_wrap_center+b;)n[r]-=I}}else if(e.fwd3d)$("3d transformation not supported");else for(r=0;r<a;r++)h.lam=n[r],h.phi=i[r],o=kt(h,e),n[r]=o.x,i[r]=o.y,G();if(1!=e.vto_meter&&s)for(r=0;r<a;r++)s[r]*=e.vfr_meter;return"enu"!=e.axis&&St(e.axis,!0,n,i,s),1==a?R.last_errno:0}function St(t,e,n,i,s){var r,o,a,h,l,c,u=n.length,p=0;if(e){for(a=0;a<u;a++)if(r=n[a],o=i[a],r!=x)for(s&&(p=s[a]),h=0;h<3;h++)if(2!=h||s)switch(c=0==h?n:1==h?i:s,t[h]){case"e":c[a]=r;break;case"w":c[a]=-r;break;case"n":c[a]=o;break;case"s":c[a]=-o;break;case"u":c[a]=p;break;case"d":c[a]=-p;break;default:q(L)}}else for(a=0;a<u;a++)if(r=n[a],o=i[a],r!=x)for(s&&(p=s[a]),h=0;h<3;h++)switch(l=0==h?r:1==h?o:p,t[h]){case"e":n[a]=l;break;case"w":n[a]=-l;break;case"n":i[a]=l;break;case"s":i[a]=-l;break;case"u":s&&(s[a]=l);break;case"d":s&&(s[a]=-l);break;default:q(L)}}function At(t,e,n,i,s){var r,o,a=n.length;for((o=vt(t,0==e?t:t*c(1-e)))||q(T),r=0;r<a;r++)n[r]!=x&&wt(o,r,n,i,s)}function Mt(t,e,n,i,s){var r,o,a=n.length;for((o=vt(t,0===e?t:t*c(1-e)))||q(T),r=0;r<a;r++)n[r]!=x&&xt(o,r,n,i,s)&&(n[r]=i[r]=x)}function Et(n){var i=6.283185307179586,s=3.141592653589793;return t(n)>3.14159265359&&(n+=s,n-=i*e(n/i),n-=s),n}function kt(e,n){var i={x:0,y:0},r=t(e.phi)-k;return r<=1e-12&&t(e.lam)<=10?(R.last_errno=0,t(r)<=1e-12?e.phi=e.phi<0?-k:k:n.geoc&&(e.phi=h(n.rone_es*s(e.phi))),e.lam-=n.lam0,n.over||(e.lam=Et(e.lam)),n.fwd?(n.fwd(e,i),i.x=n.fr_meter*(n.a*i.x+n.x0),i.y=n.fr_meter*(n.a*i.y+n.y0)):i.x=i.y=x):B(-14),!R.last_errno&&isFinite(i.x)&&isFinite(i.y)||(i.x=i.y=x),i}function Dt(e,n){var i={lam:0,phi:0};return e.x<x&&e.y<x?(R.last_errno=0,n.inv?(e.x=(e.x*n.to_meter-n.x0)*n.ra,e.y=(e.y*n.to_meter-n.y0)*n.ra,n.inv(e,i),i.lam+=n.lam0,n.over||(i.lam=Et(i.lam)),n.geoc&&t(t(i.phi)-k)>1e-12&&(i.phi=h(n.one_es*s(i.phi)))):i.lam=i.phi=x):B(-15),!R.last_errno&&isFinite(i.lam)&&isFinite(i.phi)||(i.lam=i.phi=x),i}function It(t,n,i,s){var r,o,a;for((t<0||t>=9)&&(t=3),r=1,a=0;a<t;a++)r*=10;return o=3600*r,function(a){var h,l,c,u,p="",d="",_="";return a===x||isNaN(a)?"":(a<0?(a=-a,(c=s||"")||(p="-")):c=i||"",l=(a=e(a*o+.5))/r%60,h=(a=e(a/(60*r)))%60,u=e(a/60)+"d",_=l.toFixed(t),_=(l=parseFloat(_))?(n?_:String(l))+'"':"",(l||h)&&2==(d=String(h)+"'").length&&n&&(d="0"+d),p+u+d+_+c)}}function Pt(t,e,n){var i,s,r,o,a,h;return"string"!=typeof t?Ln:("string"!=typeof e?(s="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",r=t,i=e):(s=t,r=e,i=n),h=Tt(o=mt(s),a=mt(r)),i?h(i):{forward:h,inverse:Tt(a,o)})}function Tt(t,e){return function(n){var i=Array.isArray(n);return n=i?n.concat():[n.x,n.y],bt(t,e,n),i||(n={x:n[0],y:n[1]}),n}}function Lt(t){var e=t.proj in Q?Q[t.proj].name:"",n=it(t),i=Yt(t);return{PROJCS:{NAME:e?i.NAME+" / "+e:"unnamed",GEOGCS:i,PROJECTION:"custom_proj4",PARAMETER:[],UNIT:Ht(t),EXTENSION:["PROJ4",n+" +wktext"]}}}function Nt(t){var e=t.EXTENSION;return e&&"PROJ4"==e[0]?(e[1]||"").replace(" +wktext",""):null}Pt.WGS84="+proj=longlat +datum=WGS84",Pt.toPoint=function(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e};var Rt=[],Ft=[];function Gt(t){return"string"==typeof t}function Ot(t){var e=zt(t,Ft);return e||(e=function(t){return Nt(t)?Nt:null}(t)),e||$t("unsupported WKT definition: "+(t.NAME||"[unknown]")),e}function Bt(t){var e=zt(t,Rt);return e||(e=Lt),e||$t("unsupported projection: "+function(t){return Ut(t)||"[unknown]"}(t)),e}function zt(t,e){for(var n=0;n<e.length;n++)if((0,e[n][0])(t))return e[n][1];return null}function Ut(t){return Z(t.params,"sproj")}function qt(t){return t.replace(/[-_ \/]+/g,"_").toLowerCase()}function jt(t){var e;return Array.isArray(t)?e=t:t&&t.length>0&&(e=t.split(",")),e}function $t(t){throw new Error(t)}function Vt(t){return{to_meter:t.UNIT[1]}}function Ht(t){return["Meter",t.to_meter||1]}function Wt(t,e){var n,i,s=t.DATUM,r=s.SPHEROID,o=function(t){var e,n={northamerican1983:"NAD83",newzealand1949:"nzgd49"},i=Kt(t.NAME);if(i in n)return n[i];for(var s=0;s<rt.length&&Kt((e=rt[s])[3])!=i&&Kt(e[0])!=i;s++);return e?e[0]:null}(s),a=function(t){var e,n={international1924:"intl"},i=Kt(t[0]);if(i in n)return n[i];if(/^grs1980/.test(i))return"GRS80";if("sphere"==i)return null;for(var s=0;s<ht.length&&Kt((e=ht[s])[3])!=i&&Kt(e[0])!=i;s++);return e?e[0]:null}(r),h=e&&e.aux_sphere,l=r[1],c=r[2];return Xt(t.UNIT,"degree"),h?n="+a="+r[1]:o?n="+datum="+o:a?n="+ellps="+a:(n="+a="+l,c>0&&(n+=" +rf="+c)),!s.TOWGS84||h||o||(n+=" +towgs84="+s.TOWGS84.join(",")),((i=t.PRIMEM?t.PRIMEM[1]:0)>0||i<0)&&(n+=" +pm="+i),n}function Kt(t){return(t||"").replace(/^(GCS|D)_/i,"").replace(/[ _]/g,"").toLowerCase()}function Xt(t,e){t&&t[0].toLowerCase()!=e&&$t("unexpected geographic units: "+geogcs.UNIT[0])}function Zt(t){return function(){return"+proj="+t}}function Jt(t){return function(e){var n,i;return[t.PROJECTION(e),t.PARAMETER(e),t.GEOGCS?t.GEOGCS(e):Wt(e.GEOGCS),(n=Vt(e),i="",1!=n.to_meter&&(i="+to_meter="+n.to_meter),i),"+no_defs"].filter(function(t){return!!t}).join(" ")}}function Yt(t){return{NAME:ee(t),DATUM:Qt(t),PRIMEM:["Greenwich",0],UNIT:["degree",.017453292519943295]}}function Qt(t){var e={NAME:ie(t),SPHEROID:te(t)},n=Z(t.params,"stowgs84");return/[1-9]/.test(n)&&(e.TOWGS84=n),e}function te(t){var e;return e=Z(t.params,"trf")?Z(t.params,"drf"):t.es?1/(1-Math.sqrt(1-t.es)):0,[ne(t),t.a,e]}function ee(t){var e;return et(t)&&(e=he(t)),e||(e=se(t),e=/^[a-z]+$/.test(e)?e[0].toUpperCase()+e.substr(1):e.toUpperCase()),e||"UNK"}function ne(t){var e=lt(function(t){var e=se(t),n=e?at(e):null;return(n?n.ellipse_id:Z(t.params,"sellps"))||""}(t));return e?e.name:"Unknown ellipsoid"}function ie(t){var e=at(se(t));return e&&e.name||"Unknown datum"}function se(t){return Z(t.params,"sdatum")}function re(t){return Bt(t)(t)}function oe(t,e){return ae({PROJECTION:t,PARAMETER:Pe(e)})}function ae(t){return function(e){var n={GEOGCS:t.GEOGCS&&t.GEOGCS(e)||Yt(e),PROJECTION:Gt(t.PROJECTION)?t.PROJECTION:t.PROJECTION(e),PARAMETER:t.PARAMETER(e),UNIT:Ht(e)};return n.NAME=t.NAME&&t.NAME(e,n)||function(t,e){var n=he(t);return n||e.GEOGCS.NAME+" / "+e.PROJECTION}(e,n),{PROJCS:n}}}function he(t){var e;return Z(t.params,"tinit")&&(e=ft(Z(t.params,"sinit"))),e?e.comment:""}function le(t,e,n){var i=ue(e),s=function(t,e){return Jt({PROJECTION:Zt(t),PARAMETER:Ie(e)})}(t,n);de(i,s)}function ce(t,e,n){_e(pe(t),oe(e,n))}function ue(t){var e=jt(t).map(qt);return function(t){var n=t.PROJECTION[0];return e.indexOf(qt(n))>-1}}function pe(t){return function(e){var n=Ut(e);return n&&n==t}}function de(t,e){"function"!=typeof t&&$t("Missing WKT parser test"),"function"!=typeof e&&$t("Missing WKT parse function"),Ft.push([t,e])}function _e(t,e){"function"!=typeof t&&$t("Missing WKT maker test"),"function"!=typeof e&&$t("Missing WKT maker function"),Rt.push([t,e])}de(function(t){return fe.test(qt(t.NAME))},function(t){return Jt({PROJECTION:Zt("utm"),PARAMETER:function(t){var e=fe.exec(qt(t.NAME)),n="+zone="+e[1];return"s"==e[2].toLowerCase()&&(n+=" +south"),n}})(t)}),de(function(t){return me.test(qt(t.NAME))},function(t){return Jt({PROJECTION:Zt("ups"),PARAMETER:function(t){var e=me.exec(qt(t.NAME));return"south"==e[1].toLowerCase()?"+south":""}})(t)}),_e(pe("utm"),function(t){return ae({NAME:ye,PROJECTION:function(){return"Transverse_Mercator"},PARAMETER:ve})(t)}),_e(pe("ups"),function(t){return ae({NAME:ge,PROJECTION:function(){return"Polar_Stereographic"},PARAMETER:xe})(t)});var fe=/UTM_zone_([0-9]{1,2})(N|S)/i,me=/UPS_(North|South)/i;function ye(t,e){return e.GEOGCS.NAME+" / UTM zone "+Z(t.params,"szone")+(Z(t.params,"tsouth")?"S":"N")}function ge(t,e){return e.GEOGCS.NAME+" / UPS "+(Z(t.params,"tsouth")?"South":"North")}function ve(t){return[["latitude_of_origin",0],["central_meridian",180*t.lam0/b],["scale_factor",t.k0],["false_easting",t.x0],["false_northing",t.y0]]}function xe(t){return[["latitude_of_origin",-90],["central_meridian",0],["scale_factor",.994],["false_easting",2e6],["false_northing",2e6]]}function we(t){return Z(t.params,"tlat_ts")&&0!=Z(t.params,"dlat_ts")}function be(t){return 0===t.es&&6378137==t.a}de(ue("Mercator_2SP,Mercator_1SP,Mercator,Mercator_Auxiliary_Sphere"),Jt({GEOGCS:function(t){var e=function(t){return/(Web_Mercator|Pseudo_Mercator)/i.test(qt(t.NAME))}(t)?{aux_sphere:!0}:null;return Wt(t.GEOGCS,e)},PROJECTION:Zt("merc"),PARAMETER:function(t){return Ie(function(t){var e=ke(t,"standard_parallel_1");return e&&0!=e[1]}(t)?"lat_ts,lat_0b":"lat_tsb,lat_ts")(t)}})),_e(pe("merc"),ae({GEOGCS:function(t){return be(t)?Yt(mt("+proj=longlat +datum=WGS84")):null},PROJECTION:function(t){return we(t)?"Mercator_2SP":"Mercator_1SP"},PARAMETER:function(t){return Pe(we(t)?"lat_ts,lat_0b":"lat_tsb")(t)},NAME:function(t){return be(t)?"WGS 84 / Pseudo-Mercator":null}}));var Ce=[["x_0","false_easting","m"],["y_0","false_northing","m"],["k_0","scale_factor","f"],["lat_0","latitude_of_center"],["lon_0","central_meridian"]],Se={lat_0b:["lat_0","latitude_of_origin"],lat_0c:["lat_0",null],lat_0d:["lat_0","standard_parallel_1"],lat_1:["lat_1","standard_parallel_1"],lat_1b:["lat_1","latitude_of_point_1"],lat_1c:["lat_1","latitude_of_origin"],lat_2:["lat_2","standard_parallel_2"],lat_2b:["lat_2","latitude_of_point_2"],lat_ts:["lat_ts","standard_parallel_1"],lat_tsb:["lat_ts","latitude_of_origin"],lonc:["lonc","central_meridian"],lon_1:["lon_1","longitude_of_point_1"],lon_2:["lon_2","longitude_of_point_2"],alpha:["alpha","azimuth"],gamma:["gamma","rectified_grid_angle"],h:["h","height","f"]},Ae={longitude_of_center:"central_meridian",latitude_of_origin:"latitude_of_center",latitude_of_center:"latitude_of_origin",longitude_of_1st_point:"longitude_of_point_1",longitude_of_2nd_point:"longitude_of_point_2",latitude_of_1st_point:"latitude_of_point_1",latitude_of_2nd_point:"latitude_of_point_2",k:"k_0"};function Me(t,e,n){for(var i=0;i<n.length;i++)if(n[i][e]===t)return n[i];return null}function Ee(t,e,n){var i=null;return!(i=Me(t=t.toLowerCase(),e,n))&&t in Ae&&(i=Me(Ae[t],e,n)),i}function ke(t,e){for(var n,i=t.PARAMETER||[],s=0;s<i.length;s++)if(e===(n=i[s][0].toLowerCase())||e===Ae[n])return i[s];return null}function De(t){var e=null;return t&&(e=jt(t).reduce(function(t,e){var n=Se[e];return n||$t("missing parameter rule: "+e),t.push(n),t},[])),(e||[]).concat(Ce)}function Ie(t){return function(e){var n=[],i=De(t),s=Vt(e);return(e.PARAMETER||[]).forEach(function(t){var e,r,o=Ee(t[0],1,i);o?(e=function(t,e,n){var i=t[0];if("m"==t[2]&&(e*=n.to_meter),!("x_0,y_0,lat_0,lon_0".indexOf(i)>-1&&0===e||"k_0"==i&&1==e))return"+"+i+"="+e}(o,t[1],s),e&&n.push(e)):(r="unhandled parameter: "+t[0],console.error("[wkt] "+r))}),n.join(" ")}}function Pe(t){return function(e){var n=[],i=De(t);return Object.keys(e.params).forEach(function(t){var s,r=Ee(t,0,i);r&&r[1]&&(s=Z(e.params,"s"+t),n.push(function(t,e,n){var i,s=t[2];return i="m"==s?parseFloat(e)/n:"f"==s?parseFloat(e):W(e),[t[1],i]}(r,s,e.to_meter)))}),n}}function Te(t){return!("lat_1"in t.params&&"lat_2"in t.params)}function Le(t){return"omerc"==Ut(t)&&("alpha"in t.params||"gamma"in t.params)}function Ne(t){return Le(t)&&("no_uoff"in t.params||"no_off"in t.params)}function Re(t){return Z(t.params,"tlat_ts")}function Fe(t){var e=JSON.stringify(Oe(t));return e=(e=e.replace(/\["([A-Z0-9]+)",/g,"$1[")).replace(/"(EAST|NORTH|SOUTH|WEST)"/g,"$1")}function Ge(t){return"NAME,PROJCS,GEOGCS,GEOCCS,DATUM,SPHEROID,PRIMEM,PROJECTION,PARAMETER,UNIT,AXIS".indexOf(t)+1||999}function Oe(t,e){var n,i=[];return e=e||0,function(t){return Object.keys(t).sort(function(t,e){return Ge(t)-Ge(e)})}(t).forEach(function(s){var r=t[s];!function(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}(r)?"NAME"==s?i.push(Gt(r)?r:r[0]):"PARAMETER"==s||"AXIS"==s?r.forEach(function(t){i.push([s].concat(t))}):Gt(r)?i.push([s,r]):Array.isArray(r)?i.push([s].concat(r)):((n={})[s]=r,$t("Incorrectly formatted WKT element: "+JSON.stringify(n))):i.push([s].concat(Oe(r,e+1)))}),0===e&&1==i.length&&(i=i[0]),i}function Be(t){var e={};return ze(t).forEach(function(t){qe(t,e)}),e}function ze(t){var e;t="["+(t=(t=(t=Ue(t)).replace(/([A-Z0-9]+)\[(?![^"]*[^\[,"]")/g,'["$1",')).replace(/, *([a-zA-Z]+) *(?=[,\]])/g,',"$1"'))+"]";try{e=JSON.parse(t)}catch(t){$t("unparsable WKT format")}return e}function Ue(t){var e=0;return t.replace(/"+/g,function(t){var n=e%2==0;return e+=t.length,'"'==t||'""'==t&&n?t:n?'"'+t.substring(1).replace(/""/g,'\\"'):t.replace(/""/g,'\\"')})}function qe(t,e){var n,i=t[0];if("GEOGCS"==i||"GEOCCS"==i||"PROJCS"==i||"DATUM"==i||"VERTCS"==i)for(e[i]={NAME:t[1]},n=2;n<t.length;n++){if(!Array.isArray(t[n]))throw $t("WKT parse error");qe(t[n],e[i])}else"AXIS"==i||"PARAMETER"==i?(i in e==0&&(e[i]=[]),e[i].push(t.slice(1))):e[i]=t.slice(1);return e}de(ue("Lambert_Conformal_Conic,Lambert_Conformal_Conic_1SP,Lambert_Conformal_Conic_2SP"),Jt({PROJECTION:Zt("lcc"),PARAMETER:function(t){return Ie(function(t){return!ke(t,"standard_parallel_2")}(t)?"lat_1c":"lat_0b,lat_1,lat_2")(t)}})),_e(pe("lcc"),ae({PROJECTION:function(t){return Te(t)?"Lambert_Conformal_Conic_1SP":"Lambert_Conformal_Conic_2SP"},PARAMETER:function(t){return Pe(Te(t)?"lat_1c,lat_0c":"lat_0b,lat_1,lat_2")(t)}})),de(ue("Hotine_Oblique_Mercator,Hotine_Oblique_Mercator_Azimuth_Natural_Origin"),Jt({PROJECTION:Zt("omerc"),PARAMETER:function(t){return Ie("alpha,gamma,lonc")(t)+" +no_uoff"}})),_e(Ne,oe("Hotine_Oblique_Mercator","alpha,gamma,lonc")),le("omerc","Oblique_Mercator,Hotine_Oblique_Mercator_Azimuth_Center","alpha,gamma,lonc"),_e(function(t){return Le(t)&&!Ne(t)},oe("Oblique_Mercator","alpha,gamma,lonc")),le("omerc","Hotine_Oblique_Mercator_Two_Point_Natural_Origin","lat_1b,lat_2b,lon_1,lon_2"),_e(function(t){return"omerc"==Ut(t)&&"lat_2"in t.params&&"lon_2"in t.params},oe("Hotine_Oblique_Mercator_Two_Point_Natural_Origin","lat_1b,lat_2b,lon_1,lon_2")),de(ue("Stereographic,Polar_Stereographic,Stereographic_North_Pole,Stereographic_South_Pole"),Jt({PROJECTION:Zt("stere"),PARAMETER:function(t){var e=Ie("lat_ts,lat_tsb")(t),n=/lat_ts=([^ ]+)/.exec(e);return n&&-1==e.indexOf("lat_0=")&&(e="+lat_0="+(parseFloat(n[1])<0?-90:90)+" "+e),e}})),_e(pe("stere"),ae({PROJECTION:function(t){return Re(t)?"Polar_Stereographic":"Stereographic"},PARAMETER:function(t){return Re(t)?Pe("lat_tsb,lat_0c")(t):Pe("lat_0b")(t)}})),ce("vandg","VanDerGrinten"),de(ue("VanDerGrinten,Van_der_Grinten_I"),Jt({PROJECTION:Zt("vandg"),PARAMETER:function(t){var e=Ie("")(t);return e&&(e+=" "),e+"+R_A"}})),[["aitoff","Aitoff","lat1"],["aea","Albers_Conic_Equal_Area,Albers","lat_1,lat_2"],["aeqd","Azimuthal_Equidistant"],["bonne","Bonne","lat_1"],["cass","Cassini_Soldner,Cassini"],["cea","Cylindrical_Equal_Area","lat_ts"],["eck1","Eckert_I"],["eck2","Eckert_II"],["eck3","Eckert_III"],["eck4","Eckert_IV"],["eck5","Eckert_V"],["eck6","Eckert_VI"],["eqdc","Equidistant_Conic","lat_1,lat_2"],["eqc","Plate_Carree,Equirectangular,Equidistant_Cylindrical","lat_ts"],["gall","Gall_Stereographic"],["gnom","Gnomonic"],["laea","Lambert_Azimuthal_Equal_Area"],["loxim","Loximuthal","lat_1"],["mill","Miller_Cylindrical"],["moll","Mollweide"],["nsper","Vertical_Near_Side_Perspective","h"],["nzmg","New_Zealand_Map_Grid","lat_0b"],["ortho","Orthographic","lat_0b"],["poly","Polyconic"],["robin","Robinson"],["sinu","Sinusoidal"],["sterea","Oblique_Stereographic,Double_Stereographic"],["tmerc","Transverse_Mercator,Gauss_Kruger","lat_0b"],["tpeqd","Two_Point_Equidistant","lat_1b,lat_2b,lon_1,lon_2"],["wag1","Wagner_I"],["wag2","Wagner_II"],["wag3","Wagner_III","lat_ts"],["wag4","Wagner_IV"],["wag5","Wagner_V"],["wag6","Wagner_VI"],["wag7","Wagner_VII"],["wink1","Winkel_I","lat_ts"],["wink2","Winkel_II"],["wintri","Winkel_Tripel","lat_1"]].forEach(function(t){var e=t[2]||null;le(t[0],t[1],e),ce(t[0],t[1].split(",")[0],e)});var je,$e,Ve={};function He(t,e,n){var i;return e>=1e-7?n*(t/(1-(i=e*t)*i)-.5/e*d((1-i)/(1+i))):t+t}function We(t,e,n){return e/c(1-n*t*t)}function Ke(e,s,r){var a,h,u,p,f,m,y,g,v,w,b,C,S,A;e.fwd=function(t,s){var r,o=t.lam;(r=u-(y?h*He(n(t.phi),e.e,e.one_es):f*n(t.phi)))<0&&z(),r=p*c(r),s.x=r*n(o*=h),s.y=m-r*i(o)},e.inv=function(s,r){var c=s.x,g=m-s.y,v=_(c,g);0!=v?(h<0&&(v=-v,c=-c,g=-g),r.phi=v/p,y?(r.phi=(u-r.phi*r.phi)/h,t(a-t(r.phi))>1e-7?(r.phi=function(e,s,r){var a,h,l,c,u,p,_=15,f=1e-7,m=1e-10;if(a=o(.5*e),s<f)return a;p=_;do{a+=u=.5*(c=1-(l=s*(h=n(a)))*l)*c/i(a)*(e/r-h/c+.5/s*d((1-l)/(1+l)))}while(t(u)>m&&--p);return p?a:x}(r.phi,e.e,e.one_es))==x&&U():r.phi=r.phi<0?-k:k):t(r.phi=(u-r.phi*r.phi)/f)<=1?r.phi=o(r.phi):r.phi=r.phi<0?-k:k,r.lam=l(c,g)/h):(r.lam=0,r.phi=h>0?k:-k)},t(s+r)<N&&j(-21),h=v=n(s),g=i(s),w=t(s-r)>=N,(y=e.es>0)?(Xe(e.es),A=We(v,g,e.es),S=He(v,e.e,e.one_es),w&&(C=We(v=n(r),g=i(r),e.es),b=He(v,e.e,e.one_es),h=(A*A-C*C)/(b-S)),a=1-.5*e.one_es*d((1-e.e)/(1+e.e))/e.e,m=(p=1/h)*c((u=A*A+h*S)-h*He(n(e.phi0),e.e,e.one_es))):(w&&(h=.5*(h+n(r))),m=(p=1/h)*c((u=g*g+(f=h+h)*v)-f*n(e.phi0)))}function Xe(t){var e,n=.046875,i=.01953125,s=.01068115234375,r=[];return r[0]=1-t*(.25+t*(n+t*(i+t*s))),r[1]=t*(.75-t*(n+t*(i+t*s))),r[2]=(e=t*t)*(.46875-t*(.013020833333333334+.007120768229166667*t)),r[3]=(e*=t)*(.3645833333333333-.005696614583333333*t),r[4]=e*t*.3076171875,r}function Ze(t,e,n,i){return n*=e,e*=e,i[0]*t-n*(i[1]+e*(i[2]+e*(i[3]+e*i[4])))}function Je(e,s,r){var o,a,h,l=1/(1-s);h=e;for(var u=10;u>0;--u)if(a=1-s*(o=n(h))*o,h-=a=(Ze(h,o,i(h),r)-e)*(a*c(a))*l,t(a)<1e-11)return h;return B(R),h}function Ye(e){var n=t(e);return n>=1?(n>1.00000000000001&&B(-19),e<0?-k:k):o(e)}function Qe(e){var n=t(e);return n>=1?(n>1.00000000000001&&B(-19),e<0?b:0):a(e)}function tn(t){return t<=0?0:c(t)}function en(e,n){return t(e)<1e-50&&t(n)<1e-50?0:l(e,n)}function nn(e){var s=e.opaque||{mode:0};e.inv=function(e,r){var o,h,l,c,p,d,_,f,m,y,g,v,x,w,C,S,A,M=1e-12,E=0;if(t(e.x)<M&&t(e.y)<M)return r.phi=0,void(r.lam=0);r.phi=e.y,r.lam=e.x;do{o=0;do{for(v=n(.5*r.lam),C=i(.5*r.lam),x=n(r.phi),l=1-(h=(w=i(r.phi))*C)*h,c=2*(h=a(h)/u(l,1.5))*l*w*v,p=h*l*x,d=2*(v*C*x*w/l-h*x*v),_=w*w*v*v/l+h*w*C*x*x,f=x*x*C/l+h*v*v*w,m=.5*(x*w*v/l-h*x*w*w*v*C),s.mode&&(c=.5*(c+r.lam*s.cosphi1),p=.5*(p+r.phi),d*=.5,_=.5*(_+s.cosphi1),f=.5*(f+1),m*=.5),c-=e.x,g=((p-=e.y)*d-c*f)/(y=d*m-f*_),y=(c*m-p*_)/y;g>b;)g-=b;for(;g<-b;)g+=b;r.phi-=y,r.lam-=g}while((t(y)>M||t(g)>M)&&o++<10);r.phi>k&&(r.phi-=2*(r.phi-k)),r.phi<-k&&(r.phi-=2*(r.phi+k)),t(t(r.phi)-k)<M&&!s.mode&&(r.lam=0),(h=a(i(r.phi)*i(l=.5*r.lam)))?(S=2*h*i(r.phi)*n(l)*(A=1/n(h)),A*=h*n(r.phi)):S=A=0,s.mode&&(S=.5*(S+r.lam*s.cosphi1),A=.5*(A+r.phi))}while((t(e.x-S)>M||t(e.y-A)>M)&&E++<20)},e.fwd=function(t,e){var r,o;(o=a(i(t.phi)*i(r=.5*t.lam)))?(e.x=2*o*i(t.phi)*n(r)*(e.y=1/n(o)),e.y*=o*n(t.phi)):e.x=e.y=0,s.mode&&(e.x=.5*(e.x+t.lam*s.cosphi1),e.y=.5*(e.y+t.phi))},e.es=0}function sn(e,i,s){e.es=0,e.fwd=function(e,r){var o,a,h=2.4674011002723395;r.y=i?k*n(e.phi):e.phi,(o=t(e.lam))>=1e-10?(s&&o>=k?r.x=c(h-e.phi*e.phi+1e-10)+o-k:(a=.5*(h/o+o),r.x=o-a+c(a*a-r.y*r.y)),e.lam<0&&(r.x=-r.x)):r.x=0}}function rn(t){var e,n=[];return n[0]=.3333333333333333*t,e=t*t,n[0]+=.17222222222222222*e,n[1]=.06388888888888888*e,e*=t,n[0]+=.10257936507936508*e,n[1]+=.0664021164021164*e,n[2]=.01677689594356261*e,n}function on(t,e){var i=t+t;return t+e[0]*n(i)+e[1]*n(i+i)+e[2]*n(i+i+i)}function an(t,e){t.es=0,t.fwd=function(t,n){n.y=e.C_y*t.phi,n.x=e.C_x*t.lam*(e.A+tn(1-e.B*t.phi*t.phi))},t.inv=function(t,n){n.phi=t.y/e.C_y,n.lam=t.x/(e.C_x*(e.A+tn(1-e.B*n.phi*n.phi)))}}function hn(e){var r,o,a,u,p,y,g=[],v=[],w=[],b=[];function C(t,e){for(var s,r=2*i(2*e),o=t.length-1,a=t[o],h=0;--o>=0;)s=r*a-h+t[o],h=a,a=s;return e+s*n(2*e)}function S(t,e,s){for(var r,o,a=n(e),h=i(e),l=f(s),c=m(s),u=2*h*c,p=-2*a*l,d=t.length-1,_=t[d],y=0,g=0,v=0;--d>=0;)r=g,o=y,_=u*(g=_)-r-p*(y=v)+t[d],v=p*g-o+u*y;return[(u=a*c)*_-(p=h*l)*v,u*v+p*_]}e.es<=0&&j(-34),p=u=(a=e.es/(1+c(1-e.es)))/(2-a),g[0]=u*(2+u*(-2/3+u*(u*(116/45+u*(26/45+u*(-2854/675)))-2))),v[0]=u*(u*(2/3+u*(4/3+u*(-82/45+u*(32/45+u*(4642/4725)))))-2),p*=u,g[1]=p*(7/3+u*(u*(-227/45+u*(2704/315+u*(2323/945)))-1.6)),v[1]=p*(5/3+u*(-16/15+u*(-13/9+u*(904/315+u*(-1522/945))))),p*=u,g[2]=p*(56/15+u*(-136/35+u*(-1262/105+u*(73814/2835)))),v[2]=p*(-26/15+u*(34/21+u*(1.6+u*(-12686/2835)))),p*=u,g[3]=p*(4279/630+u*(-332/35+u*(-399572/14175))),v[3]=p*(1237/630+u*(u*(-24832/14175)-2.4)),p*=u,g[4]=p*(4174/315+u*(-144838/6237)),v[4]=p*(-734/315+u*(109598/31185)),p*=u,g[5]=p*(601676/22275),v[5]=p*(444337/155925),p=u*u,r=e.k0/(1+u)*(1+p*(1/4+p*(1/64+p/256))),w[0]=u*(u*(2/3+u*(-37/96+u*(1/360+u*(81/512+u*(-96199/604800)))))-.5),b[0]=u*(.5+u*(-2/3+u*(5/16+u*(41/180+u*(-127/288+u*(7891/37800)))))),w[1]=p*(-1/48+u*(-1/15+u*(437/1440+u*(-46/105+u*(1118711/3870720))))),b[1]=p*(13/48+u*(u*(557/1440+u*(281/630+u*(-1983433/1935360)))-.6)),p*=u,w[2]=p*(-17/480+u*(37/840+u*(209/4480+u*(-5569/90720)))),b[2]=p*(61/240+u*(-103/140+u*(15061/26880+u*(167603/181440)))),p*=u,w[3]=p*(-4397/161280+u*(11/504+u*(830251/7257600))),b[3]=p*(49561/161280+u*(-179/168+u*(6601661/7257600))),p*=u,w[4]=p*(-4583/161280+u*(108847/3991680)),b[4]=p*(34729/80640+u*(-3418889/1995840)),p*=u,w[5]=p*(-20648693/638668800),b[5]=.6650675310896665*p,y=C(v,e.phi0),o=-r*(y+function(t,e){for(var s,r=2*i(e),o=t.length-1,a=t[o],h=0;--o>=0;)s=r*a-h+t[o],h=a,a=s;return n(e)*s}(b,2*y)),e.fwd=function(e,a){var h,c,u,p,f,m=e.phi,y=e.lam;m=C(v,m),h=n(m),c=i(m),p=n(y),u=i(y),m=l(h,u*c),y=l(p*c,_(h,c*u)),y=function(e){var n=t(e);return n=function(t){var e=1+t,n=e-1;return 0===n?t:t*d(e)/n}(n*(1+n/(_(1,n)+1))),e<0?-n:n}(s(y)),f=S(b,2*m,2*y),m+=f[0],y+=f[1],t(y)<=2.623395162778?(a.y=r*m+o,a.x=r*y):a.x=a.y=x},e.inv=function(e,s){var a,c,u,p,d,m=e.y,y=e.x;m=(m-o)/r,t(y/=r)<=2.623395162778?(m+=(d=S(w,2*m,2*y))[0],y+=d[1],y=h(f(y)),a=n(m),c=i(m),p=n(y),u=i(y),y=l(p,u*c),m=l(a*u,_(p,u*c)),s.phi=C(g,m),s.lam=y):s.phi=s.lam=x}}function ln(e){var s;e.es?(s=Xe(e.es),e.fwd=function(t,r){var o,a;r.y=Ze(t.phi,o=n(t.phi),a=i(t.phi),s),r.x=t.lam*a/c(1-e.es*o*o)},e.inv=function(r,o){var a=t(o.phi=Je(r.y,e.es,s));a<k?(a=n(o.phi),o.lam=r.x*c(1-e.es*a*a)/i(o.phi)):a-N<k?o.lam=0:U()}):cn(e,0,1)}function cn(e,s,r){var o,a;o=(a=c((s+1)/r))/(s+1),e.es=0,e.fwd=function(e,h){var l,c,u;if(s){for(l=r*n(e.phi),u=8;u&&(e.phi-=c=(s*e.phi+n(e.phi)-l)/(s+i(e.phi)),!(t(c)<1e-7));--u);u||z()}else e.phi=1!=r?Ye(r*n(e.phi)):e.phi;h.x=o*e.lam*(s+i(e.phi)),h.y=a*e.phi},e.inv=function(t,e){t.y/=a,e.phi=s?Ye((s*t.y+n(t.y))/r):1!=r?Ye(n(t.y)/r):t.y,e.lam=t.x/(o*(s+i(t.y)))}}function un(t){dn(t,pn(0,k))}function pn(t,e){var i=n(e),s=e+e,r=c(I*i/(s+n(s)));return{C_x:2*r/b,C_y:r/i,C_p:s+n(s)}}function dn(e,s){e.fwd=function(e,r){var o,a,h;for(o=s.C_p*n(e.phi),h=10;h&&(e.phi-=a=(e.phi+n(e.phi)-o)/(1+i(e.phi)),!(t(a)<1e-7));--h);h?e.phi*=.5:e.phi=e.phi<0?-k:k,r.x=s.C_x*e.lam*i(e.phi),r.y=s.C_y*n(e.phi)},e.inv=function(e,r){r.phi=Ye(e.y/s.C_y),r.lam=e.x/(s.C_x*i(r.phi)),t(r.lam)-b<N?(r.phi+=r.phi,r.phi=Ye((r.phi+n(r.phi))/s.C_p)):r.lam=r.phi=x},e.es=0}function _n(i,s){var r,a,h,l,p,d=[[0,-1],[1,0]],_=[[-1,0],[0,-1]],f=[[0,1],[-1,0]],m=[[[1,0],[0,1]],d,_,f,f,_,d],v=1e-15;function w(i,s){var r=i.lam,a=i.phi,h=o(2/3);if(t(a)<=h)s.x=r,s.y=3*b/8*n(a);else{var l,u=c(3*(1-t(n(a)))),p=e(2*r/b+2);p>=4&&(p=3),l=-3*E+k*p,s.x=l+(r-l)*u,s.y=S(a)*E*(2-u)}}function C(n,i){var s=n.x,r=n.y,a=E;if(t(r)<=a)i.lam=s,i.phi=o(8*r/(3*b));else if(t(r)<k){var h,l,c=e(2*s/b+2);c>=4&&(c=3),h=-3*E+k*c,l=2-4*t(r)/b,i.lam=h+(s-h)/l,i.phi=S(r)*o(1-u(l,2)/3)}else i.lam=-b,i.phi=S(r)*k}function S(t){return t>0?1:t<0?-1:0}function A(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case-1:return 4;case-2:return 5;case-3:return 6}return 0}function M(t,e){return function(t,e,n){var i,s,r,o,a,h=0,l=t.length;for(a=0;a<l;a++)if(e==t[a][0]&&n==t[a][1])return!0;for(i=t[0][0],s=t[0][1],a=1;a<l;a++)r=t[a%l][0],o=t[a%l][1],n>y(s,o)&&n<=g(s,o)&&e<=g(i,r)&&s!=o&&(i==r||e<=(n-s)*(r-i)/(o-s)+i)&&h++,i=r,s=o;return h%2!=0}(p,t,e)}function D(e,i,s){if(s)return on(i,l);var r=He(n(i),e.e,1-e.es)/h;return t(r)>1&&(r=S(r)),o(r)}function I(t,e,n,i){var s,r,o,a,h,l,c=0,u=function(t,e,n,i,s){var r,o={};if(o.x=t,o.y=e,s){if(e>E)o.region="north",o.x=-3*E+n*k,o.y=k,t-=n*k;else{if(!(e<-E))return o.region="equatorial",o.cn=0,o;o.region="south",o.x=-3*E+i*k,o.y=-k,t-=i*k}"north"==o.region?o.cn=e>=-t-E-v&&e<t+5*E-v?(n+1)%4:e>-t-E+v&&e>=t+5*E-v?(n+2)%4:e<=-t-E+v&&e>t+5*E+v?(n+3)%4:n:"south"==o.region&&(o.cn=e<=t+E+v&&e>-t-5*E+v?(i+1)%4:e<t+E-v&&e<=-t-5*E+v?(i+2)%4:e>=t+E-v&&e<-t-5*E-v?(i+3)%4:i)}else{if(e>E)o.region="north",r=k;else{if(!(e<-E))return o.region="equatorial",o.cn=0,o;o.region="south",r=-k}t<-k?(o.cn=0,o.x=-3*E,o.y=r):t>=-k&&t<0?(o.cn=1,o.x=-E,o.y=r):t>=0&&t<k?(o.cn=2,o.x=E,o.y=r):(o.cn=3,o.x=3*E,o.y=r)}return o}(t.x,t.y,e,n,i);if("equatorial"==u.region)return t.x=u.x,void(t.y=u.y);s=[t.x,t.y],r=[u.x,u.y],i?"north"==u.region?(c=e,l=m[A(-1*(u.cn-c))]):(c=n,l=m[A(u.cn-c)]):"north"==u.region?(c=e,l=m[A(u.cn-c)]):(c=n,l=m[A(-1*(u.cn-c))]),a=function(t,e){return[t[0]-e[0],t[1]-e[1]]}(s,r),h=function(t,e){var n,i,s=[0,0];for(n=0;n<2;n++)for(i=0;i<2;i++)s[n]+=t[n][i]*e[i];return s}(l,a),o=function(t,e){return[t[0]+e[0],t[1]+e[1]]}(h,[-3*E+(i?u.cn:0)*k,k]),t.x=o[0],t.y=o[1]}s?(r=Z(i.params,"inorth_square"),a=Z(i.params,"isouth_square"),(r<0||r>3)&&j(-47),(a<0||a>3)&&j(-47),p=[[-b-v,E+v],[r*k-b-v,E+v],[r*k-b-v,3*E+v],[(r+1)*k-b+v,3*E+v],[(r+1)*k-b+v,E+v],[b+v,E+v],[b+v,-E-v],[(a+1)*k-b+v,-E-v],[(a+1)*k-b+v,-3*E-v],[a*k-b-v,-3*E-v],[a*k-b-v,-E-v],[-b-v,-E-v]],0!=i.es?(l=rn(i.es),h=He(1,i.e,i.one_es),i.a=i.a*c(.5*h),i.ra=1/i.a,i.fwd=function(t,e){return t.phi=D(i,t.phi,0),w(t,e),I(e,r,a,0)},i.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void B(-15);I(t,r,a,1),C(t,e),e.phi=D(i,e.phi,1)}):(i.fwd=function(t,e){w(t,e),I(e,r,a,0)},i.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void B(-15);I(t,r,a,1),C(t,e)})):(p=[[-b-v,E],[-3*E,k+v],[-k,E+v],[-E,k+v],[0,E+v],[E,k+v],[k,E+v],[3*E,k+v],[b+v,E],[b+v,-E],[3*E,-k-v],[k,-E-v],[E,-k-v],[0,-E-v],[-E,-k-v],[-k,-E-v],[-3*E,-k-v],[-b-v,-E]],0!=i.es?(l=rn(i.es),h=He(1,i.e,i.one_es),i.a=i.a*c(.5*h),i.ra=1/i.a,i.fwd=function(t,e){t.phi=D(i,t.phi,0),w(t,e)},i.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void B(-15);C(t,e),e.phi=D(i,e.phi,1)}):(i.fwd=function(t,e){w(t,e)},i.inv=function(t,e){if(!M(t.x,t.y))return e.lam=x,e.phi=x,void B(-15);C(t,e)}))}function fn(t){t.x0=0,t.y0=0,t.is_latlong=!0,t.fwd=function(e,n){n.x=e.lam/t.a,n.y=e.phi/t.a},t.inv=function(e,n){n.lam=e.x*t.a,n.phi=e.y*t.a}}function mn(t,e,n){return e*=n,s(.5*(k-t))/u((1-e)/(1+e),.5*n)}function yn(e,i){var s,r,o=.5*i,a=k-2*h(e),l=15;do{s=i*n(a),a+=r=k-2*h(e*u((1-s)/(1+s),o))-a}while(t(r)>1e-10&&--l);return l<=0&&B(-18),a}function gn(t,e){var n,i,s,r=e.length-1;for(i=e[r][0],s=e[r][1];--r>=0;)n=i,i=e[r][0]+t.r*n-t.i*s,s=e[r][1]+t.r*s+t.i*n;return{r:t.r*i-t.i*s,i:t.r*s+t.i*i}}function vn(t,e,n){var i,s,r,o,a,h=!0,l=e.length-1;for(s=o=e[l][0],i=r=e[l][1];--l>=0;)h?h=!1:(o=s+t.r*(a=o)-t.i*r,r=i+t.r*r+t.i*a),s=e[l][0]+t.r*(a=s)-t.i*i,i=e[l][1]+t.r*i+t.i*a;return n.r=s+t.r*o-t.i*r,n.i=i+t.r*r+t.i*o,{r:t.r*s-t.i*i,i:t.r*i+t.i*s}}function xn(e,r){var o,a,c,p,d=1e-12;0!=e.es?(o=e.e*n(e.phi0),a=2*h(s(.5*(k+e.phi0))*u((1-o)/(1+o),.5*e.e))-k):a=e.phi0,p=n(a),c=i(a),e.inv=function(o,a){var f,m,y,g,v,w,b,C={},S={},A={},M=0,E=0,D=0,I=0;for(C.r=o.x,C.i=o.y,f=20;f&&((m=vn(C,r,S)).r-=o.x,m.i-=o.y,y=S.r*S.r+S.i*S.i,A.r=-(m.r*S.r+m.i*S.i)/y,A.i=-(m.i*S.r-m.r*S.i)/y,C.r+=A.r,C.i+=A.i,!(t(A.r)+t(A.i)<=d));--f);if(f){if(M=_(C.r,C.i),g=2*h(.5*M),E=n(g),D=i(g),a.lam=e.lam0,t(M)<=d)return a.lam=0,void(a.phi=e.phi0);for(I=v=Ye(D*p+C.i*E*c/M),f=20;f&&(w=e.e*n(I),I+=b=2*h(s(.5*(k+v))*u((1+w)/(1-w),.5*e.e))-k-I,!(t(b)<=d));--f);}f?(a.phi=I,a.lam=l(C.r*E,M*c*D-C.i*p*E)):a.lam=a.phi=x},e.fwd=function(t,o){var a,l,d,_,f,m,y,g={};a=n(t.lam),l=i(t.lam),d=e.e*n(t.phi),_=2*h(s(.5*(k+t.phi))*u((1-d)/(1+d),.5*e.e))-k,f=n(_),m=i(_),y=2/(1+p*f+c*m*l),g.r=y*m*a,g.i=y*(c*f-p*m*l),g=gn(g,r),o.x=g.r,o.y=g.i}}function wn(e,s,r,a){var h,u,p,d,f,m,y,g,v,x,w,b,C=!isNaN(r)&&!isNaN(a);s<=0&&j(-30),C&&(v=i(a),x=n(a),b=i(r),w=n(r)),t(t(e.phi0)-k)<N?h=e.phi0<0?1:0:t(e.phi0)<N?h=2:(h=3,u=n(e.phi0),p=i(e.phi0)),m=s/e.a,f=1/(d=1+m),y=(d+1)*(g=1/m),e.fwd=function(t,e){var s,r,o,a,l;switch(o=n(t.phi),r=i(t.phi),s=i(t.lam),h){case 3:e.y=u*o+p*r*s;break;case 2:e.y=r*s;break;case 1:e.y=-o;break;case 0:e.y=o}switch(e.y<f&&z(),e.y=m/(d-e.y),e.x=e.y*r*n(t.lam),h){case 3:e.y*=p*o-u*r*s;break;case 2:e.y*=o;break;case 0:s=-s;case 1:e.y*=r*s}C&&(l=1/((a=e.y*v+e.x*x)*w*g+b),e.x=(e.x*v-e.y*x)*b*l,e.y=a*l)},e.inv=function(i,s){var r,a,f,g,S,A;if(C&&(A=1/(m-i.y*w),g=m*i.x*A,S=m*i.y*b*A,i.x=g*v+S*x,i.y=S*v-g*x),r=_(i.x,i.y),(f=1-r*r*y)<0&&U(),f=(d-c(f))/(m/r+r/m),a=c(1-f*f),t(r)<=N)s.lam=0,s.phi=e.phi0;else{switch(h){case 3:s.phi=o(a*u+i.y*f*p/r),i.y=(a-u*n(s.phi))*r,i.x*=f*p;break;case 2:s.phi=o(i.y*f/r),i.y=a*r,i.x*=f;break;case 0:s.phi=o(a),i.y=-i.y;break;case 1:s.phi=-o(a)}s.lam=l(i.x,i.y)}},e.es=0}function bn(t,e){var n=.79788456,i=.1013211836*(e?2:4);t.es=0,t.fwd=function(t,e){e.x=n*t.lam*(1-i*t.phi*t.phi),e.y=n*t.phi},t.inv=function(t,e){e.phi=t.y/n,e.lam=t.x/(n*(1-i*e.phi*e.phi))}}function Cn(t,e,s){t.es=0,t.fwd=function(t,r){t.phi=Ye(.883883476*n(t.phi)),r.x=e*t.lam*i(t.phi),r.x/=i(t.phi*=.333333333333333),r.y=s*n(t.phi)},t.inv=function(t,r){r.phi=Ye(t.y/s),r.lam=t.x*i(r.phi)/e,r.phi*=3,r.lam/=i(r.phi),r.phi=Ye(1.13137085*n(r.phi))}}function Sn(t,e){var n=e?1.5:2,i=e?.5:1,s=1.01346,r=1.2158542;t.es=0,t.fwd=function(t,e){e.x=s*t.lam*(n-i*c(1+r*t.phi*t.phi)),e.y=s*t.phi},t.inv=function(t,e){e.phi=t.y/s,e.lam=t.x/(s*(n-i*c(1+r*e.phi*e.phi)))}}function An(e,i){var s,r,o,a,h,l=1.732050807568877;i?(o=.44329,a=.80404,s=6,r=5.61125,h=3):(o=1.01346,a=.9191,s=4,r=2.147143718212938,h=2),e.es=0,e.fwd=function(e,i){var u,p,_,f;for(u=r*n(e.phi),e.phi*=1.10265779,f=10;f&&(p=c(1+e.phi*e.phi),e.phi-=_=((s-p)*e.phi-d(e.phi+p)-u)/(s-2*p),!(t(_)<1e-10));--f);f||(e.phi=u<0?-l:l),i.x=o*e.lam*(h-c(1+e.phi*e.phi)),i.y=a*e.phi},e.inv=function(t,e){var n;e.phi=t.y/a,n=c(1+e.phi*e.phi),e.lam=t.x/(o*(h-n)),e.phi=Ye(((s-n)*e.phi-d(e.phi+n))/r)}}function Mn(e){return function(r){!function(e,r){var o,a,u,p,d,f,m,y,g,v,x=1e-10;switch(Z(e.params,"tlat_1")&&Z(e.params,"tlat_2")?(u=Z(e.params,"rlat_1"),p=Z(e.params,"rlat_2"),y=.5*(p+u),(t(o=.5*(p-u))<x||t(y)<x)&&j(-42)):j(-41),r){case"TISSOT":d=n(y),a=i(o),m=c(((f=d/a+a/d)-2*n(e.phi0))/d);break;case"MURD1":f=n(o)/(o*s(y))+y,m=f-e.phi0,d=n(y);break;case"MURD2":f=(a=c(i(o)))/s(y),m=f+s(y-e.phi0),d=n(y)*a;break;case"MURD3":f=o/(s(y)*s(o))+y,m=f-e.phi0,d=n(y)*n(o)*s(o)/(o*o);break;case"EULER":d=n(y)*n(o)/o,f=(o*=.5)/(s(o)*s(y))+y,m=f-e.phi0;break;case"PCONIC":d=n(y),v=i(o),g=1/s(y),t(o=e.phi0-y)-x>=k&&j(-43),m=v*(g-s(o));break;case"VITK1":d=(a=s(o))*n(y)/o,f=o/(a*s(y))+y,m=f-e.phi0}function w(t,e){var o;switch(r){case"MURD2":o=f+s(y-t.phi);break;case"PCONIC":o=v*(g-s(t.phi-y));break;default:o=f-t.phi}e.x=o*n(t.lam*=d),e.y=m-o*i(t.lam)}function b(t,e){var n;switch(n=_(t.x,t.y=m-t.y),d<0&&(n=-n,t.x=-t.x,t.y=-t.y),e.lam=l(t.x,t.y)/d,r){case"PCONIC":e.phi=h(g-n/v)+y;break;case"MURD2":e.phi=y-h(n-f);break;default:e.phi=f-n}}e.inv=b,e.fwd=w,e.es=0}(r,e)}}function En(e,r){var a,p,d,f,m,y,g,v,x=1e-10;if(v=t((p=t(e.phi0))-k)<x?e.phi0<0?0:1:p>x?2:3,r=t(r),e.es){switch(v){case 1:case 0:t(r-k)<x?g=2*e.k0/c(u(1+e.e,1+e.e)*u(1-e.e,1-e.e)):(g=i(r)/mn(r,p=n(r),e.e),p*=e.e,g/=c(1-p*p));break;case 3:case 2:p=n(e.phi0),a=2*h(w(e.phi0,p,e.e))-k,p*=e.e,g=2*e.k0*i(e.phi0)/c(1-p*p),m=n(a),y=i(a)}e.fwd=function(t,s){var r,o,a,l,c,u=0,p=0;switch(r=i(t.lam),o=n(t.lam),c=n(t.phi),(2==v||3==v)&&(u=n(a=2*h(w(t.phi,c,e.e))-k),p=i(a)),v){case 2:l=g/(y*(1+m*u+y*p*r)),s.y=l*(y*u-m*p*r),s.x=l*p;break;case 3:l=g/(1+p*r),s.y=l*u,s.x=l*p;break;case 0:t.phi=-t.phi,r=-r,c=-c;case 1:s.x=g*mn(t.phi,c,e.e),s.y=-s.x*r}s.x=s.x*o},e.inv=function(r,a){a.phi;var c,p,d,f,x=0,w=0,b=0,C=0;switch(d=_(r.x,r.y),v){case 2:case 3:c=i(x=2*l(d*y,g)),p=n(x),w=o(0==d?c*m:c*m+r.y*p*y/d),x=s(.5*(k+w)),r.x*=p,r.y=d*y*c-r.y*m*p,C=k,b=.5*e.e;break;case 1:r.y=-r.y;case 0:w=k-2*h(x=-d/g),C=-k,b=-.5*e.e}for(f=0;f<8;f++,w=a.phi)if(p=e.e*n(w),a.phi=2*h(x*u((1+p)/(1-p),b))-C,t(w-a.phi)<1e-10)return 0==v&&(a.phi=-a.phi),void(a.lam=0==r.x&&0==r.y?0:l(r.x,r.y));U()}}else{switch(v){case 2:d=n(e.phi0),f=i(e.phi0);case 3:g=2*e.k0;break;case 0:case 1:g=t(r-k)>=x?i(r)/s(E-.5*r):2*e.k0}e.fwd=function(e,r){var o=e.phi,a=n(o),h=i(o),l=i(e.lam),c=n(e.lam);switch(v){case 3:case 2:r.y=3==v?1+h*l:1+d*a+f*h*l,r.y<=x&&z(),r.x=(r.y=g/r.y)*h*c,r.y*=3==v?a:f*a-d*h*l;break;case 1:l=-l,o=-o;case 0:t(o-k)<1e-8&&z(),r.x=c*(r.y=g*s(E+.5*o)),r.y*=l}},e.inv=function(s,r){var a,c,u,p;switch(u=n(a=2*h((c=_(s.x,s.y))/g)),p=i(a),r.lam=0,v){case 3:t(c)<=x?r.phi=0:r.phi=o(s.y*u/c),0==p&&0==s.x||(r.lam=l(s.x*u,p*c));break;case 2:t(c)<=x?r.phi=e.phi0:r.phi=o(p*d+s.y*u*f/c),0==(a=p-d*n(r.phi))&&0==s.x||(r.lam=l(s.x*u*f,a*c));break;case 1:s.y=-s.y;case 0:t(c)<=x?r.phi=e.phi0:r.phi=o(0==v?-p:p),r.lam=0==s.x&&0==s.y?0:l(s.x,s.y)}}}function w(t,e,n){return e*=n,s(.5*(k+t))*u((1-e)/(1+e),.5*n)}}function kn(t,e){return u((1-t)/(1+t),e)}function Dn(t,e,r,o){var a=r/e,l=e,c=1/r;t.inv=function(t,e){var n;t.y/=l,n=i(e.phi=o?h(t.y):Ye(t.y)),e.phi/=c,e.lam=t.x/(a*i(e.phi)),o?e.lam/=n*n:e.lam*=n},t.fwd=function(t,e){var r;e.x=a*t.lam*i(t.phi),e.y=l,t.phi*=c,r=i(t.phi),o?(e.x*=r*r,e.y*=s(t.phi)):(e.x/=r,e.y*=n(t.phi))},t.es=0}function In(e){var s,r,h,u=1e-10,_=.5,f=.16666666666666666,m=.08333333333333333,y=.05,g=.03333333333333333,v=.023809523809523808,x=.017857142857142856;e.es?((h=Xe(e.es))||e_error_0(),r=Ze(e.phi0,n(e.phi0),i(e.phi0),h),s=e.es/(1-e.es),e.fwd=function(o,a){var l,p,d,_,w,b;o.lam<-k||o.lam>k?B(-14):(l=n(o.phi),p=i(o.phi),d=t(p)>u?l/p:0,d*=d,_=p*o.lam,w=_*_,_/=c(1-e.es*l*l),b=s*p*p,a.x=e.k0*_*(1+f*w*(1-d+b+y*w*(5+d*(d-18)+b*(14-58*d)+v*w*(61+d*(d*(179-d)-479))))),a.y=e.k0*(Ze(o.phi,l,p,h)-r+l*_*o.lam*.5*(1+m*w*(5-d+b*(9+4*b)+g*w*(61+d*(d-58)+b*(270-330*d)+x*w*(1385+d*(d*(543-d)-3111)))))))},e.inv=function(o,a){var l,u,p,d,w,b,C;a.phi=Je(r+o.y/e.k0,e.es,h),t(a.phi)>=k?(a.phi=o.y<0?-k:k,a.lam=0):(b=n(a.phi),p=i(a.phi),C=t(p)>1e-10?b/p:0,l=s*p*p,d=o.x*c(u=1-e.es*b*b)/e.k0,u*=C,C*=C,w=d*d,a.phi-=u*w/(1-e.es)*_*(1-w*m*(5+C*(3-9*l)+l*(1-4*l)-w*g*(61+C*(90-252*l+45*C)+46*l-w*x*(1385+C*(3633+C*(4095+1575*C)))))),a.lam=d*(1-w*f*(1+2*C+l-w*y*(5+C*(28+24*C+8*l)+6*l-w*v*(61+C*(662+C*(1320+720*C))))))/p)}):(s=e.k0,r=.5*s,e.fwd=function(o,h){var l,p;o.lam<-k||o.lam>k?B(-14):(p=i(o.phi),l=p*n(o.lam),t(t(l)-1)<=u&&z(),h.x=r*d((1+l)/(1-l)),h.y=p*i(o.lam)/c(1-l*l),(l=t(h.y))>=1?l-1>u?z():h.y=0:h.y=a(h.y),o.phi<0&&(h.y=-h.y),h.y=s*(h.y-e.phi0))},e.inv=function(t,n){var r=p(t.x/s),a=.5*(r-1/r);r=i(e.phi0+t.y/s),n.phi=o(c((1-r*r)/(1+a*a))),t.y<0&&-n.phi+e.phi0<0&&(n.phi=-n.phi),n.lam=a||r?l(a,r):0})}function Pn(t,e){var s=.8773826753,r=1.139753528477/e;t.es=0,t.fwd=function(t,o){var a=Ye(e*n(t.phi));o.x=s*t.lam*i(a),o.y=r*a},t.inv=function(t,o){t.y/=r,o.phi=Ye(n(t.y)/e),o.lam=t.x/(s*i(t.y))}}function Tn(e,n){e.fwd=function(e,i){var s,r,o,a;o=t(P*e.phi),a=(a=1-o*o)<0?0:c(a),t(e.lam)<1e-10?(i.x=0,i.y=b*(e.phi<0?-o:o)/(1+a)):(r=.5*t(b/e.lam-e.lam/b),n?(s=o/(1+a),i.x=b*(c(r*r+1-s*s)-r),i.y=b*s):(s=(a*c(1+r*r)-r*a*a)/(1+r*r*o*o),i.x=b*s,i.y=b*c(1-s*(s+2*r)+1e-10)),e.lam<0&&(i.x=-i.x),e.phi<0&&(i.y=-i.y))},e.es=0}Ve.Constants={},Ve.Math={},Ve.Accumulator={},(je=Ve.Constants).WGS84={a:6378137,f:1/298.257223563},je.version={major:1,minor:48,patch:0},je.version_string="1.48",($e=Ve.Math).digits=53,$e.epsilon=Math.pow(.5,$e.digits-1),$e.degree=Math.PI/180,$e.sq=function(t){return t*t},$e.hypot=function(t,e){var n,i;return t=Math.abs(t),e=Math.abs(e),n=Math.max(t,e),i=Math.min(t,e)/(n||1),n*Math.sqrt(1+i*i)},$e.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},$e.log1p=function(t){var e=1+t,n=e-1;return 0===n?t:t*Math.log(e)/n},$e.atanh=function(t){var e=Math.abs(t);return e=$e.log1p(2*e/(1-e))/2,t<0?-e:e},$e.copysign=function(t,e){return Math.abs(t)*(e<0||0===e&&1/e<0?-1:1)},$e.sum=function(t,e){var n=t+e,i=n-e,s=n-i;return{s:n,t:-((i-=t)+(s-=e))}},$e.polyval=function(t,e,n,i){for(var s=t<0?0:e[n++];--t>=0;)s=s*i+e[n++];return s},$e.AngRound=function(t){if(0===t)return t;var e=1/16,n=Math.abs(t);return n=n<e?e-(e-n):n,t<0?-n:n},$e.AngNormalize=function(t){return(t%=360)<=-180?t+360:t<=180?t:t-360},$e.LatFix=function(t){return Math.abs(t)>90?Number.NaN:t},$e.AngDiff=function(t,e){var n=$e.sum($e.AngNormalize(-t),$e.AngNormalize(e)),i=$e.AngNormalize(n.s),s=n.t;return $e.sum(180===i&&s>0?-180:i,s)},$e.sincosd=function(t){var e,n,i,s,r,o;switch(e=t%360,e-=90*(n=Math.floor(e/90+.5)),e*=this.degree,i=Math.sin(e),s=Math.cos(e),3&n){case 0:r=i,o=s;break;case 1:r=s,o=-i;break;case 2:r=-i,o=-s;break;default:r=-s,o=i}return t&&(r+=0,o+=0),{s:r,c:o}},$e.atan2d=function(t,e){var n,i,s=0;switch(Math.abs(t)>Math.abs(e)&&(n=e,e=t,t=n,s=2),e<0&&(e=-e,++s),i=Math.atan2(t,e)/this.degree,s){case 1:i=(t>=0?180:-180)-i;break;case 2:i=90-i;break;case 3:i=-90+i}return i},function(t,e){t.Accumulator=function(t){this.Set(t)},t.Accumulator.prototype.Set=function(e){e||(e=0),e.constructor===t.Accumulator?(this._s=e._s,this._t=e._t):(this._s=e,this._t=0)},t.Accumulator.prototype.Add=function(t){var n=e.sum(t,this._t),i=e.sum(n.s,this._s);n=n.t,this._s=i.s,this._t=i.t,0===this._s?this._s=n:this._t+=n},t.Accumulator.prototype.Sum=function(e){var n;return e?((n=new t.Accumulator(this)).Add(e),n._s):this._s},t.Accumulator.prototype.Negate=function(){this._s*=-1,this._t*=-1}}(Ve.Accumulator,Ve.Math),Ve.Geodesic={},Ve.GeodesicLine={},Ve.PolygonArea={},function(t,e,n,i,s){var r,o,a,h,l,c,u,p,d,_,f,m=20+i.digits+10,y=i.epsilon,g=200*y,v=Math.sqrt(y),x=y*g,w=1e3*v;t.tiny_=Math.sqrt(Number.MIN_VALUE),t.nC1_=6,t.nC1p_=6,t.nC2_=6,t.nC3_=6,t.nC4_=6,r=t.nC3_*(t.nC3_-1)/2,o=t.nC4_*(t.nC4_+1)/2,t.CAP_C1=1,t.CAP_C1p=2,t.CAP_C2=4,t.CAP_C3=8,t.CAP_C4=16,t.NONE=0,t.ARC=64,t.LATITUDE=128,t.LONGITUDE=256|t.CAP_C3,t.AZIMUTH=512,t.DISTANCE=1024|t.CAP_C1,t.STANDARD=t.LATITUDE|t.LONGITUDE|t.AZIMUTH|t.DISTANCE,t.DISTANCE_IN=2048|t.CAP_C1|t.CAP_C1p,t.REDUCEDLENGTH=4096|t.CAP_C1|t.CAP_C2,t.GEODESICSCALE=8192|t.CAP_C1|t.CAP_C2,t.AREA=16384|t.CAP_C4,t.ALL=32671,t.LONG_UNROLL=32768,t.OUT_MASK=32640|t.LONG_UNROLL,t.SinCosSeries=function(t,e,n,i){var s=i.length,r=s-(t?1:0),o=2*(n-e)*(n+e),a=1&r?i[--s]:0,h=0;for(r=Math.floor(r/2);r--;)a=o*(h=o*a-h+i[--s])-a+i[--s];return t?2*e*n*a:n*(a-h)},a=function(t,e){var n,s,r,o,a,h,l,c,u,p,d,_,f=i.sq(t),m=i.sq(e),y=(f+m-1)/6;return 0===m&&y<=0?n=0:(h=y,(a=(s=f*m/4)*(s+2*(o=y*(r=i.sq(y)))))>=0?(l=s+o,l+=l<0?-Math.sqrt(a):Math.sqrt(a),h+=(c=i.cbrt(l))+(0!==c?r/c:0)):(u=Math.atan2(Math.sqrt(-a),-(s+o)),h+=2*y*Math.cos(u/3)),p=Math.sqrt(i.sq(h)+m),_=((d=h<0?m/(p-h):h+p)-m)/(2*p),n=d/(Math.sqrt(d+i.sq(_))+_)),n},h=[1,4,64,0,256],t.A1m1f=function(t){var e=Math.floor(3);return(i.polyval(e,h,0,i.sq(t))/h[e+1]+t)/(1-t)},l=[-1,6,-16,32,-9,64,-128,2048,9,-16,768,3,-5,512,-7,1280,-7,2048],t.C1f=function(e,n){var s,r,o=i.sq(e),a=e,h=0;for(s=1;s<=t.nC1_;++s)r=Math.floor((t.nC1_-s)/2),n[s]=a*i.polyval(r,l,h,o)/l[h+r+1],h+=r+2,a*=e},c=[205,-432,768,1536,4005,-4736,3840,12288,-225,116,384,-7173,2695,7680,3467,7680,38081,61440],t.C1pf=function(e,n){var s,r,o=i.sq(e),a=e,h=0;for(s=1;s<=t.nC1p_;++s)r=Math.floor((t.nC1p_-s)/2),n[s]=a*i.polyval(r,c,h,o)/c[h+r+1],h+=r+2,a*=e},u=[-11,-28,-192,0,256],t.A2m1f=function(t){var e=Math.floor(3);return(i.polyval(e,u,0,i.sq(t))/u[e+1]-t)/(1+t)},p=[1,2,16,32,35,64,384,2048,15,80,768,7,35,512,63,1280,77,2048],t.C2f=function(e,n){var s,r,o=i.sq(e),a=e,h=0;for(s=1;s<=t.nC2_;++s)r=Math.floor((t.nC2_-s)/2),n[s]=a*i.polyval(r,p,h,o)/p[h+r+1],h+=r+2,a*=e},t.Geodesic=function(t,e){if(this.a=t,this.f=e,this._f1=1-this.f,this._e2=this.f*(2-this.f),this._ep2=this._e2/i.sq(this._f1),this._n=this.f/(2-this.f),this._b=this.a*this._f1,this._c2=(i.sq(this.a)+i.sq(this._b)*(0===this._e2?1:(this._e2>0?i.atanh(Math.sqrt(this._e2)):Math.atan(Math.sqrt(-this._e2)))/Math.sqrt(Math.abs(this._e2))))/2,this._etol2=.1*v/Math.sqrt(Math.max(.001,Math.abs(this.f))*Math.min(1,1-this.f/2)/2),!(isFinite(this.a)&&this.a>0))throw new Error("Equatorial radius is not positive");if(!(isFinite(this._b)&&this._b>0))throw new Error("Polar semi-axis is not positive");this._A3x=new Array(6),this._C3x=new Array(r),this._C4x=new Array(o),this.A3coeff(),this.C3coeff(),this.C4coeff()},d=[-3,128,-2,-3,64,-1,-3,-1,16,3,-1,-2,8,1,-1,2,1,1],t.Geodesic.prototype.A3coeff=function(){var t,e,n=0,s=0;for(t=5;t>=0;--t)e=Math.min(6-t-1,t),this._A3x[s++]=i.polyval(e,d,n,this._n)/d[n+e+1],n+=e+2},_=[3,128,2,5,128,-1,3,3,64,-1,0,1,8,-1,1,4,5,256,1,3,128,-3,-2,3,64,1,-3,2,32,7,512,-10,9,384,5,-9,5,192,7,512,-14,7,512,21,2560],t.Geodesic.prototype.C3coeff=function(){var e,n,s,r=0,o=0;for(e=1;e<t.nC3_;++e)for(n=t.nC3_-1;n>=e;--n)s=Math.min(t.nC3_-n-1,n),this._C3x[o++]=i.polyval(s,_,r,this._n)/_[r+s+1],r+=s+2},f=[97,15015,1088,156,45045,-224,-4784,1573,45045,-10656,14144,-4576,-858,45045,64,624,-4576,6864,-3003,15015,100,208,572,3432,-12012,30030,45045,1,9009,-2944,468,135135,5792,1040,-1287,135135,5952,-11648,9152,-2574,135135,-64,-624,4576,-6864,3003,135135,8,10725,1856,-936,225225,-8448,4992,-1144,225225,-1440,4160,-4576,1716,225225,-136,63063,1024,-208,105105,3584,-3328,1144,315315,-128,135135,-2560,832,405405,128,99099],t.Geodesic.prototype.C4coeff=function(){var e,n,s,r=0,o=0;for(e=0;e<t.nC4_;++e)for(n=t.nC4_-1;n>=e;--n)s=t.nC4_-n-1,this._C4x[o++]=i.polyval(s,f,r,this._n)/f[r+s+1],r+=s+2},t.Geodesic.prototype.A3f=function(t){return i.polyval(5,this._A3x,0,t)},t.Geodesic.prototype.C3f=function(e,n){var s,r,o=1,a=0;for(s=1;s<t.nC3_;++s)r=t.nC3_-s-1,o*=e,n[s]=o*i.polyval(r,this._C3x,a,e),a+=r+1},t.Geodesic.prototype.C4f=function(e,n){var s,r,o=1,a=0;for(s=0;s<t.nC4_;++s)r=t.nC4_-s-1,n[s]=o*i.polyval(r,this._C4x,a,e),a+=r+1,o*=e},t.Geodesic.prototype.Lengths=function(e,n,i,s,r,o,a,h,l,c,u,p,d){var _,f,m,y,g={},v=0,x=0,w=0,b=0;if((u&=t.OUT_MASK)&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&(w=t.A1m1f(e),t.C1f(e,p),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(b=t.A2m1f(e),t.C2f(e,d),v=w-b,b=1+b),w=1+w),u&t.DISTANCE)_=t.SinCosSeries(!0,o,a,p)-t.SinCosSeries(!0,i,s,p),g.s12b=w*(n+_),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(x=v*n+(w*_-b*(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,i,s,d))));else if(u&(t.REDUCEDLENGTH|t.GEODESICSCALE)){for(f=1;f<=t.nC2_;++f)d[f]=w*p[f]-b*d[f];x=v*n+(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,i,s,d))}return u&t.REDUCEDLENGTH&&(g.m0=v,g.m12b=h*(s*o)-r*(i*a)-s*a*x),u&t.GEODESICSCALE&&(m=s*a+i*o,y=this._ep2*(l-c)*(l+c)/(r+h),g.M12=m+(y*o-a*x)*i/r,g.M21=m-(y*i-s*x)*o/h),g},t.Geodesic.prototype.InverseStart=function(e,n,s,r,o,h,l,c,u,p,d){var _,f,m,y,v,x,b,C,S,A,M,E,k,D,I,P,T,L,N,R,F={},G=r*n-o*e,O=o*n+r*e;return F.sig12=-1,_=r*n,_+=o*e,(f=O>=0&&G<.5&&o*l<.5)?(y=i.sq(e+r),y/=y+i.sq(n+o),F.dnm=Math.sqrt(1+this._ep2*y),m=l/(this._f1*F.dnm),v=Math.sin(m),x=Math.cos(m)):(v=c,x=u),F.salp1=o*v,F.calp1=x>=0?G+o*e*i.sq(v)/(1+x):_-o*e*i.sq(v)/(1-x),C=i.hypot(F.salp1,F.calp1),S=e*r+n*o*x,f&&C<this._etol2?(F.salp2=n*v,F.calp2=G-n*r*(x>=0?i.sq(v)/(1+x):1-x),b=i.hypot(F.salp2,F.calp2),F.salp2/=b,F.calp2/=b,F.sig12=Math.atan2(C,S)):Math.abs(this._n)>.1||S>=0||C>=6*Math.abs(this._n)*Math.PI*i.sq(n)||(R=Math.atan2(-c,-u),this.f>=0?(D=(k=i.sq(e)*this._ep2)/(2*(1+Math.sqrt(1+k))+k),A=R/(E=this.f*n*this.A3f(D)*Math.PI),M=_/(E*n)):(I=o*n-r*e,P=Math.atan2(_,I),M=l/(E=((A=(T=this.Lengths(this._n,Math.PI+P,e,-n,s,r,o,h,n,o,t.REDUCEDLENGTH,p,d)).m12b/(n*o*T.m0*Math.PI)-1)<-.01?_/A:-this.f*i.sq(n)*Math.PI)/n)),M>-g&&A>-1-w?this.f>=0?(F.salp1=Math.min(1,-A),F.calp1=-Math.sqrt(1-i.sq(F.salp1))):(F.calp1=Math.max(A>-g?0:-1,A),F.salp1=Math.sqrt(1-i.sq(F.calp1))):(L=a(A,M),N=E*(this.f>=0?-A*L/(1+L):-M*(1+L)/L),v=Math.sin(N),x=-Math.cos(N),F.salp1=o*v,F.calp1=_-o*e*i.sq(v)/(1-x))),F.salp1<=0?(F.salp1=1,F.calp1=0):(b=i.hypot(F.salp1,F.calp1),F.salp1/=b,F.calp1/=b),F},t.Geodesic.prototype.Lambda12=function(e,n,s,r,o,a,h,l,c,u,p,d,_,f){var m,y,g,v,x,w,b,C,S,A,M,E,k,D={};return 0===e&&0===l&&(l=-t.tiny_),y=h*n,g=i.hypot(l,h*e),D.ssig1=e,v=y*e,D.csig1=x=l*n,m=i.hypot(D.ssig1,D.csig1),D.ssig1/=m,D.csig1/=m,D.salp2=o!==n?y/o:h,D.calp2=o!==n||Math.abs(r)!==-e?Math.sqrt(i.sq(l*n)+(n<-e?(o-n)*(n+o):(e-r)*(e+r)))/o:Math.abs(l),D.ssig2=r,w=y*r,D.csig2=b=D.calp2*o,m=i.hypot(D.ssig2,D.csig2),D.ssig2/=m,D.csig2/=m,D.sig12=Math.atan2(Math.max(0,D.csig1*D.ssig2-D.ssig1*D.csig2),D.csig1*D.csig2+D.ssig1*D.ssig2),C=Math.max(0,x*w-v*b),S=x*b+v*w,M=Math.atan2(C*u-S*c,S*u+C*c),E=i.sq(g)*this._ep2,D.eps=E/(2*(1+Math.sqrt(1+E))+E),this.C3f(D.eps,f),A=t.SinCosSeries(!0,D.ssig2,D.csig2,f)-t.SinCosSeries(!0,D.ssig1,D.csig1,f),D.domg12=-this.f*this.A3f(D.eps)*y*(D.sig12+A),D.lam12=M+D.domg12,p&&(0===D.calp2?D.dlam12=-2*this._f1*s/e:(k=this.Lengths(D.eps,D.sig12,D.ssig1,D.csig1,s,D.ssig2,D.csig2,a,n,o,t.REDUCEDLENGTH,d,_),D.dlam12=k.m12b,D.dlam12*=this._f1/(D.calp2*o))),D},t.Geodesic.prototype.Inverse=function(e,n,s,r,o){var a,h;return o||(o=t.STANDARD),o===t.LONG_UNROLL&&(o|=t.STANDARD),o&=t.OUT_MASK,h=(a=this.InverseInt(e,n,s,r,o)).vals,o&t.AZIMUTH&&(h.azi1=i.atan2d(a.salp1,a.calp1),h.azi2=i.atan2d(a.salp2,a.calp2)),h},t.Geodesic.prototype.InverseInt=function(e,n,s,r,o){var a,h,l,c,u,p,d,_,f,g,v,w,b,C,S,A,M,E,k,D,I,P,T,L,N,R,F,G,O,B,z,U,q,j,$,V,H,W,K,X,Z,J,Y,Q,tt,et,nt,it,st,rt,ot,at,ht,lt,ct,ut,pt,dt,_t,ft,mt,yt,gt,vt,xt,wt={};if(wt.lat1=e=i.LatFix(e),wt.lat2=s=i.LatFix(s),e=i.AngRound(e),s=i.AngRound(s),h=(a=i.AngDiff(n,r)).t,a=a.s,o&t.LONG_UNROLL?(wt.lon1=n,wt.lon2=n+a+h):(wt.lon1=i.AngNormalize(n),wt.lon2=i.AngNormalize(r)),a=(l=a>=0?1:-1)*i.AngRound(a),h=i.AngRound(180-a-l*h),S=a*i.degree,A=(c=i.sincosd(a>90?h:a)).s,M=(a>90?-1:1)*c.c,(u=Math.abs(e)<Math.abs(s)?-1:1)<0&&(l*=-1,c=e,e=s,s=c),e*=p=e<0?1:-1,s*=p,c=i.sincosd(e),d=this._f1*c.s,_=c.c,d/=c=i.hypot(d,_),_/=c,_=Math.max(t.tiny_,_),c=i.sincosd(s),f=this._f1*c.s,g=c.c,f/=c=i.hypot(f,g),g/=c,g=Math.max(t.tiny_,g),_<-d?g===_&&(f=f<0?d:-d):Math.abs(f)===-d&&(g=_),b=Math.sqrt(1+this._ep2*i.sq(d)),C=Math.sqrt(1+this._ep2*i.sq(f)),T=new Array(t.nC1_+1),L=new Array(t.nC2_+1),N=new Array(t.nC3_),(R=-90===e||0===A)&&(D=A,P=0,G=d,O=(k=M)*_,B=f,z=(I=1)*g,E=Math.atan2(Math.max(0,O*B-G*z),O*z+G*B),v=(F=this.Lengths(this._n,E,G,O,b,B,z,C,_,g,o|t.DISTANCE|t.REDUCEDLENGTH,T,L)).s12b,w=F.m12b,0!==(o&t.GEODESICSCALE)&&(wt.M12=F.M12,wt.M21=F.M21),E<1||w>=0?(E<3*t.tiny_&&(E=w=v=0),w*=this._b,v*=this._b,wt.a12=E/i.degree):R=!1),pt=2,!R&&0===d&&(this.f<=0||h>=180*this.f))k=I=0,D=P=1,v=this.a*S,E=q=S/this._f1,w=this._b*Math.sin(E),o&t.GEODESICSCALE&&(wt.M12=wt.M21=Math.cos(E)),wt.a12=a/this._f1;else if(!R)if(E=(F=this.InverseStart(d,_,b,f,g,C,S,A,M,T,L)).sig12,D=F.salp1,k=F.calp1,E>=0)P=F.salp2,I=F.calp2,j=F.dnm,v=E*this._b*j,w=i.sq(j)*this._b*Math.sin(E/j),o&t.GEODESICSCALE&&(wt.M12=wt.M21=Math.cos(E/j)),wt.a12=E/i.degree,q=S/(this._f1*j);else{for($=0,V=t.tiny_,H=1,W=t.tiny_,K=-1,X=!1,Z=!1;$<m&&(J=(F=this.Lambda12(d,_,b,f,g,C,D,k,A,M,$<20,T,L,N)).lam12,P=F.salp2,I=F.calp2,E=F.sig12,G=F.ssig1,O=F.csig1,B=F.ssig2,z=F.csig2,U=F.eps,_t=F.domg12,Y=F.dlam12,!Z&&Math.abs(J)>=(X?8:1)*y);++$)J>0&&($<20||k/D>K/W)?(W=D,K=k):J<0&&($<20||k/D<H/V)&&(V=D,H=k),$<20&&Y>0&&(Q=-J/Y,tt=Math.sin(Q),(nt=D*(et=Math.cos(Q))+k*tt)>0&&Math.abs(Q)<Math.PI)?(k=k*et-D*tt,D=nt,D/=c=i.hypot(D,k),k/=c,X=Math.abs(J)<=16*y):(D=(V+W)/2,k=(H+K)/2,D/=c=i.hypot(D,k),k/=c,X=!1,Z=Math.abs(V-D)+(H-k)<x||Math.abs(D-W)+(k-K)<x);it=o|(o&(t.REDUCEDLENGTH|t.GEODESICSCALE)?t.DISTANCE:t.NONE),v=(F=this.Lengths(U,E,G,O,b,B,z,C,_,g,it,T,L)).s12b,w=F.m12b,0!==(o&t.GEODESICSCALE)&&(wt.M12=F.M12,wt.M21=F.M21),w*=this._b,v*=this._b,wt.a12=E/i.degree,o&t.AREA&&(vt=Math.sin(_t),pt=A*(xt=Math.cos(_t))-M*vt,dt=M*xt+A*vt)}return o&t.DISTANCE&&(wt.s12=0+v),o&t.REDUCEDLENGTH&&(wt.m12=0+w),o&t.AREA&&(st=D*_,0!==(rt=i.hypot(k,D*d))&&0!==st?(G=d,O=k*_,B=f,z=I*g,U=(at=i.sq(rt)*this._ep2)/(2*(1+Math.sqrt(1+at))+at),ht=i.sq(this.a)*rt*st*this._e2,G/=c=i.hypot(G,O),O/=c,B/=c=i.hypot(B,z),z/=c,lt=new Array(t.nC4_),this.C4f(U,lt),ct=t.SinCosSeries(!1,G,O,lt),ut=t.SinCosSeries(!1,B,z,lt),wt.S12=ht*(ut-ct)):wt.S12=0,!R&&pt>1&&(pt=Math.sin(q),dt=Math.cos(q)),!R&&dt>-.7071&&f-d<1.75?(_t=1+dt,ft=1+_,mt=1+g,ot=2*Math.atan2(pt*(d*mt+f*ft),_t*(d*f+ft*mt))):(gt=I*k+P*D,0===(yt=P*k-I*D)&><0&&(yt=t.tiny_*k,gt=-1),ot=Math.atan2(yt,gt)),wt.S12+=this._c2*ot,wt.S12*=u*l*p,wt.S12+=0),u<0&&(c=D,D=P,P=c,c=k,k=I,I=c,o&t.GEODESICSCALE&&(c=wt.M12,wt.M12=wt.M21,wt.M21=c)),{vals:wt,salp1:D*=u*l,calp1:k*=u*p,salp2:P*=u*l,calp2:I*=u*p}},t.Geodesic.prototype.GenDirect=function(n,i,s,r,o,a){return a?a===t.LONG_UNROLL&&(a|=t.STANDARD):a=t.STANDARD,r||(a|=t.DISTANCE_IN),new e.GeodesicLine(this,n,i,s,a).GenPosition(r,o,a)},t.Geodesic.prototype.Direct=function(t,e,n,i,s){return this.GenDirect(t,e,n,!1,i,s)},t.Geodesic.prototype.ArcDirect=function(t,e,n,i,s){return this.GenDirect(t,e,n,!0,i,s)},t.Geodesic.prototype.Line=function(t,n,i,s){return new e.GeodesicLine(this,t,n,i,s)},t.Geodesic.prototype.DirectLine=function(t,e,n,i,s){return this.GenDirectLine(t,e,n,!1,i,s)},t.Geodesic.prototype.ArcDirectLine=function(t,e,n,i,s){return this.GenDirectLine(t,e,n,!0,i,s)},t.Geodesic.prototype.GenDirectLine=function(n,i,s,r,o,a){var h;return a||(a=t.STANDARD|t.DISTANCE_IN),r||(a|=t.DISTANCE_IN),(h=new e.GeodesicLine(this,n,i,s,a)).GenSetDistance(r,o),h},t.Geodesic.prototype.InverseLine=function(n,s,r,o,a){var h,l,c;return a||(a=t.STANDARD|t.DISTANCE_IN),h=this.InverseInt(n,s,r,o,t.ARC),c=i.atan2d(h.salp1,h.calp1),a&t.OUT_MASK&t.DISTANCE_IN&&(a|=t.DISTANCE),(l=new e.GeodesicLine(this,n,s,c,a,h.salp1,h.calp1)).SetArc(h.vals.a12),l},t.Geodesic.prototype.Polygon=function(t){return new n.PolygonArea(this,t)},t.WGS84=new t.Geodesic(s.WGS84.a,s.WGS84.f)}(Ve.Geodesic,Ve.GeodesicLine,Ve.PolygonArea,Ve.Math,Ve.Constants),function(t,e,n){e.GeodesicLine=function(e,i,s,r,o,a,h){var l,c,u,p,d,_;o||(o=t.STANDARD|t.DISTANCE_IN),this.a=e.a,this.f=e.f,this._b=e._b,this._c2=e._c2,this._f1=e._f1,this.caps=o|t.LATITUDE|t.AZIMUTH|t.LONG_UNROLL,this.lat1=n.LatFix(i),this.lon1=s,void 0===a||void 0===h?(this.azi1=n.AngNormalize(r),l=n.sincosd(n.AngRound(this.azi1)),this.salp1=l.s,this.calp1=l.c):(this.azi1=r,this.salp1=a,this.calp1=h),l=n.sincosd(n.AngRound(this.lat1)),u=this._f1*l.s,c=l.c,u/=l=n.hypot(u,c),c/=l,c=Math.max(t.tiny_,c),this._dn1=Math.sqrt(1+e._ep2*n.sq(u)),this._salp0=this.salp1*c,this._calp0=n.hypot(this.calp1,this.salp1*u),this._ssig1=u,this._somg1=this._salp0*u,this._csig1=this._comg1=0!==u||0!==this.calp1?c*this.calp1:1,l=n.hypot(this._ssig1,this._csig1),this._ssig1/=l,this._csig1/=l,this._k2=n.sq(this._calp0)*e._ep2,p=this._k2/(2*(1+Math.sqrt(1+this._k2))+this._k2),this.caps&t.CAP_C1&&(this._A1m1=t.A1m1f(p),this._C1a=new Array(t.nC1_+1),t.C1f(p,this._C1a),this._B11=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C1a),d=Math.sin(this._B11),_=Math.cos(this._B11),this._stau1=this._ssig1*_+this._csig1*d,this._ctau1=this._csig1*_-this._ssig1*d),this.caps&t.CAP_C1p&&(this._C1pa=new Array(t.nC1p_+1),t.C1pf(p,this._C1pa)),this.caps&t.CAP_C2&&(this._A2m1=t.A2m1f(p),this._C2a=new Array(t.nC2_+1),t.C2f(p,this._C2a),this._B21=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C2a)),this.caps&t.CAP_C3&&(this._C3a=new Array(t.nC3_),e.C3f(p,this._C3a),this._A3c=-this.f*this._salp0*e.A3f(p),this._B31=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C3a)),this.caps&t.CAP_C4&&(this._C4a=new Array(t.nC4_),e.C4f(p,this._C4a),this._A4=n.sq(this.a)*this._calp0*this._salp0*e._e2,this._B41=t.SinCosSeries(!1,this._ssig1,this._csig1,this._C4a)),this.a13=this.s13=Number.NaN},e.GeodesicLine.prototype.GenPosition=function(e,i,s){var r,o,a,h,l,c,u,p,d,_,f,m,y,g,v,x,w,b,C,S,A,M,E,k,D,I,P={};return s?s===t.LONG_UNROLL&&(s|=t.STANDARD):s=t.STANDARD,s&=this.caps&t.OUT_MASK,P.lat1=this.lat1,P.azi1=this.azi1,P.lon1=s&t.LONG_UNROLL?this.lon1:n.AngNormalize(this.lon1),e?P.a12=i:P.s12=i,e||this.caps&t.DISTANCE_IN&t.OUT_MASK?(h=0,l=0,e?(r=i*n.degree,o=(E=n.sincosd(i)).s,a=E.c):(p=i/(this._b*(1+this._A1m1)),d=Math.sin(p),_=Math.cos(p),r=p-((h=-t.SinCosSeries(!0,this._stau1*_+this._ctau1*d,this._ctau1*_-this._stau1*d,this._C1pa))-this._B11),o=Math.sin(r),a=Math.cos(r),Math.abs(this.f)>.01&&(c=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,h=t.SinCosSeries(!0,c,u,this._C1a),r-=((1+this._A1m1)*(r+(h-this._B11))-i/this._b)/Math.sqrt(1+this._k2*n.sq(c)),o=Math.sin(r),a=Math.cos(r))),c=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,C=Math.sqrt(1+this._k2*n.sq(c)),s&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&((e||Math.abs(this.f)>.01)&&(h=t.SinCosSeries(!0,c,u,this._C1a)),l=(1+this._A1m1)*(h-this._B11)),y=this._calp0*c,0===(g=n.hypot(this._salp0,this._calp0*u))&&(g=u=t.tiny_),w=this._salp0,b=this._calp0*u,e&&s&t.DISTANCE&&(P.s12=this._b*((1+this._A1m1)*r+l)),s&t.LONGITUDE&&(v=this._salp0*c,x=u,m=n.copysign(1,this._salp0),f=((s&t.LONG_UNROLL?m*(r-(Math.atan2(c,u)-Math.atan2(this._ssig1,this._csig1))+(Math.atan2(m*v,x)-Math.atan2(m*this._somg1,this._comg1))):Math.atan2(v*this._comg1-x*this._somg1,x*this._comg1+v*this._somg1))+this._A3c*(r+(t.SinCosSeries(!0,c,u,this._C3a)-this._B31)))/n.degree,P.lon2=s&t.LONG_UNROLL?this.lon1+f:n.AngNormalize(n.AngNormalize(this.lon1)+n.AngNormalize(f))),s&t.LATITUDE&&(P.lat2=n.atan2d(y,this._f1*g)),s&t.AZIMUTH&&(P.azi2=n.atan2d(w,b)),s&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(S=t.SinCosSeries(!0,c,u,this._C2a),A=(1+this._A2m1)*(S-this._B21),M=(this._A1m1-this._A2m1)*r+(l-A),s&t.REDUCEDLENGTH&&(P.m12=this._b*(C*(this._csig1*c)-this._dn1*(this._ssig1*u)-this._csig1*u*M)),s&t.GEODESICSCALE&&(E=this._k2*(c-this._ssig1)*(c+this._ssig1)/(this._dn1+C),P.M12=a+(E*c-u*M)*this._ssig1/this._dn1,P.M21=a-(E*this._ssig1-this._csig1*M)*c/C)),s&t.AREA&&(k=t.SinCosSeries(!1,c,u,this._C4a),0===this._calp0||0===this._salp0?(D=w*this.calp1-b*this.salp1,I=b*this.calp1+w*this.salp1):(D=this._calp0*this._salp0*(a<=0?this._csig1*(1-a)+o*this._ssig1:o*(this._csig1*o/(1+a)+this._ssig1)),I=n.sq(this._salp0)+n.sq(this._calp0)*this._csig1*u),P.S12=this._c2*Math.atan2(D,I)+this._A4*(k-this._B41)),e||(P.a12=r/n.degree),P):(P.a12=Number.NaN,P)},e.GeodesicLine.prototype.Position=function(t,e){return this.GenPosition(!1,t,e)},e.GeodesicLine.prototype.ArcPosition=function(t,e){return this.GenPosition(!0,t,e)},e.GeodesicLine.prototype.GenSetDistance=function(t,e){t?this.SetArc(e):this.SetDistance(e)},e.GeodesicLine.prototype.SetDistance=function(e){var n;this.s13=e,n=this.GenPosition(!1,this.s13,t.ARC),this.a13=0+n.a12},e.GeodesicLine.prototype.SetArc=function(e){var n;this.a13=e,n=this.GenPosition(!0,this.a13,t.DISTANCE),this.s13=0+n.s12}}(Ve.Geodesic,Ve.GeodesicLine,Ve.Math),function(t,e,n,i){var s,r;s=function(t,e){var i;return t=n.AngNormalize(t),e=n.AngNormalize(e),i=n.AngDiff(t,e).s,t<=0&&e>0&&i>0?1:e<=0&&t>0&&i<0?-1:0},r=function(t,e){return((e%=720)>=0&&e<360||e<-360?0:1)-((t%=720)>=0&&t<360||t<-360?0:1)},t.PolygonArea=function(t,n){this._geod=t,this.a=this._geod.a,this.f=this._geod.f,this._area0=4*Math.PI*t._c2,this.polyline=n||!1,this._mask=e.LATITUDE|e.LONGITUDE|e.DISTANCE|(this.polyline?e.NONE:e.AREA|e.LONG_UNROLL),this.polyline||(this._areasum=new i.Accumulator(0)),this._perimetersum=new i.Accumulator(0),this.Clear()},t.PolygonArea.prototype.Clear=function(){this.num=0,this._crossings=0,this.polyline||this._areasum.Set(0),this._perimetersum.Set(0),this._lat0=this._lon0=this.lat=this.lon=Number.NaN},t.PolygonArea.prototype.AddPoint=function(t,e){var n;0===this.num?(this._lat0=this.lat=t,this._lon0=this.lon=e):(n=this._geod.Inverse(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(n.s12),this.polyline||(this._areasum.Add(n.S12),this._crossings+=s(this.lon,e)),this.lat=t,this.lon=e),++this.num},t.PolygonArea.prototype.AddEdge=function(t,e){var n;this.num&&(n=this._geod.Direct(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(e),this.polyline||(this._areasum.Add(n.S12),this._crossings+=r(this.lon,n.lon2)),this.lat=n.lat2,this.lon=n.lon2),++this.num},t.PolygonArea.prototype.Compute=function(t,e){var n,r,o={number:this.num};return this.num<2?(o.perimeter=0,this.polyline||(o.area=0),o):this.polyline?(o.perimeter=this._perimetersum.Sum(),o):(n=this._geod.Inverse(this.lat,this.lon,this._lat0,this._lon0,this._mask),o.perimeter=this._perimetersum.Sum(n.s12),(r=new i.Accumulator(this._areasum)).Add(n.S12),1&this._crossings+s(this.lon,this._lon0)&&r.Add((r.Sum()<0?1:-1)*this._area0/2),t||r.Negate(),e?r.Sum()>this._area0/2?r.Add(-this._area0):r.Sum()<=-this._area0/2&&r.Add(+this._area0):(r.Sum()>=this._area0||r<0)&&r.Add(-this._area0),o.area=r.Sum(),o)},t.PolygonArea.prototype.TestPoint=function(t,e,n,i){var r,o,a,h,l={number:this.num+1};if(0===this.num)return l.perimeter=0,this.polyline||(l.area=0),l;for(l.perimeter=this._perimetersum.Sum(),o=this.polyline?0:this._areasum.Sum(),a=this._crossings,h=0;h<(this.polyline?1:2);++h)r=this._geod.Inverse(0===h?this.lat:t,0===h?this.lon:e,0!==h?this._lat0:t,0!==h?this._lon0:e,this._mask),l.perimeter+=r.s12,this.polyline||(o+=r.S12,a+=s(0===h?this.lon:e,0!==h?this._lon0:e));return this.polyline||(1&a&&(o+=(o<0?1:-1)*this._area0/2),n||(o*=-1),i?o>this._area0/2?o-=this._area0:o<=-this._area0/2&&(o+=this._area0):o>=this._area0?o-=this._area0:o<0&&(o+=this._area0),l.area=o),l},t.PolygonArea.prototype.TestEdge=function(t,e,n,i){var o,a,h,l={number:this.num?this.num+1:0};return 0===this.num||(l.perimeter=this._perimetersum.Sum()+e,this.polyline||(a=this._areasum.Sum(),h=this._crossings,a+=(o=this._geod.Direct(this.lat,this.lon,t,e,this._mask)).S12,h+=r(this.lon,o.lon2),o=this._geod.Inverse(o.lat2,o.lon2,this._lat0,this._lon0,this._mask),l.perimeter+=o.s12,a+=o.S12,1&(h+=s(o.lon2,this._lon0))&&(a+=(a<0?1:-1)*this._area0/2),n||(a*=-1),i?a>this._area0/2?a-=this._area0:a<=-this._area0/2&&(a+=this._area0):a>=this._area0?a-=this._area0:a<0&&(a+=this._area0),l.area=a)),l}}(Ve.PolygonArea,Ve.Geodesic,Ve.Math,Ve.Accumulator),tt(function(t){var e=Z(t.params,"rlat_1"),n=Z(t.params,"rlat_2");Ke(t,e,n)},"aea","Albers Equal Area","Conic Sph&Ell\nlat_1= lat_2="),tt(function(t){var e=Z(t.params,"rlat_1"),n=Z(t.params,"bsouth")?-k:k;Ke(t,e,n)},"leac","Lambert Equal Area Conic","Conic, Sph&Ell\nlat_1= south"),tt(function(e){var r,o,h,u,p,d,f,m=1e-10;if(e.phi0=Z(e.params,"rlat_0"),t(t(e.phi0)-k)<m?(p=e.phi0<0?1:0,r=e.phi0<0?-1:1,o=0):t(e.phi0)<m?(p=2,r=0,o=1):(p=3,r=n(e.phi0),o=i(e.phi0)),e.es)if(f=new Ve.Geodesic.Geodesic(e.a,e.es/(1+c(e.one_es))),d=Xe(e.es),Z(e.params,"bguam"))h=Ze(e.phi0,r,o,d),e.inv=function(t,r){var o,a,l;for(o=.5*t.x*t.x,r.phi=e.phi0,l=0;l<3;++l)a=e.e*n(r.phi),r.phi=Je(h+t.y-o*s(r.phi)*(a=c(1-a*a)),e.es,d);r.lam=t.x*a/i(r.phi)},e.fwd=function(t,s){var r,o,a;r=i(t.phi),o=n(t.phi),a=1/c(1-e.es*o*o),s.x=t.lam*r*a,s.y=Ze(t.phi,o,r,d)-h+.5*t.lam*t.lam*r*o*a};else{switch(p){case 0:u=Ze(k,1,0,d);break;case 1:u=Ze(-k,-1,0,d);break;case 2:case 3:e.inv=g,e.fwd=y,c(1-e.es*r*r),e.e,c(e.one_es)}e.inv=g,e.fwd=y}else e.inv=function(t,s){var a,h,c,u=t.x,d=t.y;if((h=_(u,d))>b)h-m>b&&U(),h=b;else if(h<m)return s.phi=e.phi0,void(s.lam=0);3==p||2==p?(c=n(h),a=i(h),2==p?(s.phi=Ye(d*c/h),u*=c,d=a*h):(s.phi=Ye(a*r+d*c*o/h),d=(a-r*n(s.phi))*h,u*=c*o),s.lam=0==d?0:l(u,d)):0==p?(s.phi=k-h,s.lam=l(u,-d)):(s.phi=h-k,s.lam=l(u,d))},e.fwd=function(e,s){var h,l,c;switch(c=n(e.phi),l=i(e.phi),h=i(e.lam),p){case 2:case 3:s.y=2==p?l*h:r*c+o*l*h,t(t(s.y)-1)<1e-14?s.y<0?z():s.x=s.y=0:(s.y=a(s.y),s.y/=n(s.y),s.x=s.y*l*n(e.lam),s.y*=2==p?c:o*c-r*l*h);break;case 0:e.phi=-e.phi,h=-h;case 1:t(e.phi-k)<m&&z(),s.x=(s.y=k+e.phi)*n(e.lam),s.y*=h}};function y(s,r){var o,a,h,l,c,_,y,g,v,x,w;switch(o=i(s.lam),a=i(s.phi),h=n(s.phi),p){case 0:o=-o;case 1:r.x=(l=t(u-Ze(s.phi,h,a,d)))*n(s.lam),r.y=l*o;break;case 2:case 3:if(t(s.lam)<m&&t(s.phi-e.phi0)<m){r.x=r.y=0;break}g=e.phi0/S,y=e.lam0/S,x=s.phi/S,v=(s.lam+e.lam0)/S,c=(w=f.Inverse(g,y,x,v,f.AZIMUTH)).azi1*S,_=w.s12,r.x=_*n(c)/e.a,r.y=_*i(c)/e.a}}function g(t,n){var i,s,r,o,a,h,y,g;if((i=_(t.x,t.y))<m)return n.phi=e.phi0,n.lam=0,n;3==p||2==p?(o=t.x*e.a,a=t.y*e.a,h=e.phi0/S,y=e.lam0/S,s=l(o,a)/S,r=c(o*o+a*a),g=f.Direct(h,y,s,r,f.STANDARD),n.phi=g.lat2*S,n.lam=g.lon2*S,n.lam-=e.lam0):(n.phi=Je(0==p?u-i:u+i,e.es,d),n.lam=l(t.x,0==p?-t.y:t.y))}},"aeqd","Azimuthal Equidistant","Azi, Sph&Ell\nlat_0 guam"),tt(function(e){var r,o,a,h,l,c,u=1e-10;e.es=0,e.fwd=function(e,c){var p,_,f,m,y,g,v,x;switch(p=n(e.lam),_=i(e.lam),h){case 2:case 3:m=n(e.phi),x=(f=i(e.phi))*_,3==h&&(x=r*m+o*x),!l&&x<-u&&z(),v=t(g=1-x)>u?-d(y=.5*(1+x))/g-a/y:.5-a,c.x=v*f*p,c.y=3==h?v*(o*m-r*f*_):v*m;break;case 1:case 0:e.phi=t(p_halfpi-e.phi),!l&&e.phi-u>k&&z(),(e.phi*=.5)>u?(y=s(e.phi),v=-2*(d(i(e.phi))/y+y*a),c.x=v*p,c.y=v*_,0==h&&(c.y=-c.y)):c.x=c.y=0}},l=Z(e.params,"bno_cut"),c=.5*(k-Z(e.params,"rlat_b")),t(c)<u?a=-.5:(a=1/s(c),a*=a*d(i(c))),t(t(e.phi0)-k)<u?e.phi0<0?(p_halfpi=-k,h=1):(p_halfpi=k,h=0):t(e.phi0)<u?h=2:(h=3,r=n(e.phi0),o=i(e.phi0))},"airy","Airy","Misc Sph, no inv.\nno_cut lat_b="),tt(function(t){var e=t.opaque={mode:1};Z(t.params,"tlat_1")?0===(e.cosphi1=i(Z(t.params,"rlat_1")))&&j(-22):e.cosphi1=.6366197723675814,nn(t)},"wintri","Winkel Tripel","Misc Sph\nlat_1"),tt(nn,"aitoff","Aitoff","Misc Sph"),tt(function(t){t.fwd=function(t,e){var r,o,a,h,l,u,p,d=4/3,_=t.lam;r=s(.5*t.phi),a=1+(o=c(1-r*r))*i(_*=.5),h=n(_)*o/a,u=r/a,e.x=d*h*(3+(l=h*h)-3*(p=u*u)),e.y=d*u*(3+3*l-p)},t.es=0},"august","August Epicycloidal","Misc Sph, no inv."),tt(function(t){sn(t,!1,!1)},"apian","Apian Globular I","Misc Sph, no inv."),tt(function(t){sn(t,!1,!0)},"ortel","Ortelius Oval","Misc Sph, no inv."),tt(function(t){sn(t,!0,!1)},"bacon","Bacon Globular","Misc Sph, no inv."),tt(function(t){var e,s,r,a;t.es=0,t.fwd=function(t,h){var u,p,d,_,f,m;return t.lam+=-16.5*S,p=i(t.phi),d=i(t.lam)*p,_=n(t.lam)*p,m=(f=n(t.phi))*e+d*s,t.lam=l(_*r-m*a,d*e-f*s),m=m*r+_*a,t.phi=o(m),t.lam=Et(t.lam),t.lam+t.phi<-1.4&&(u=(t.lam-t.phi+1.6)*(t.lam+t.phi+1.4)/8,t.lam+=u,t.phi-=.8*u*n(t.phi+b/2)),p=i(t.phi),u=c(2/(1+p*i(t.lam/2))),h.x=1.68*u*p*n(t.lam/2),h.y=u*n(t.phi),u=(1-i(t.lam*t.phi))/12,h.y<0&&(h.x*=1+u),h.y>0&&(h.y*=1+u/1.5*h.x*h.x),h},t.lam0=0,t.phi0=-42*S,e=i(t.phi0),s=n(t.phi0),r=1,a=0},"bertin1953","Bertin 1953","Misc., Sph., NoInv."),tt(function(e){var s=c(2);e.fwd=function(e,r){var o,a,h,l;if(o=e.phi,t(t(e.phi)-k)<1e-7)r.x=0;else{for(h=n(o)*b,l=20;l&&(o-=a=(o+n(o)-h)/(1+i(o)),!(t(a)<1e-7));--l);o*=.5,r.x=2.00276*e.lam/(1/i(e.phi)+1.11072/i(o))}r.y=.49931*(e.phi+s*n(o))},e.es=0},"boggs","Boggs Eumorphic","PCyl., no inv., Sph."),tt(function(e){var r,o,a,h,u,p,d=1e-10;r=Z(e.params,"rlat_1"),t(r)<d&&j(-23),e.es?(u=Xe(e.es),h=Ze(r,a=n(r),p=i(r),u),a=p/(c(1-e.es*a*a)*a),e.inv=function(s,r){var o,p;p=_(s.x,s.y=a-s.y),r.phi=Je(a+h-p,e.es,u),(o=t(r.phi))<k?(o=n(r.phi),r.lam=p*l(s.x,s.y)*c(1-e.es*o*o)/i(r.phi)):t(o-k)<=d?r.lam=0:U()},e.fwd=function(t,s){var r,o,l;r=a+h-Ze(t.phi,o=n(t.phi),l=i(t.phi),u),o=l*t.lam/(r*c(1-e.es*o*o)),s.x=r*n(o),s.y=a-r*i(o)}):(o=t(r)+d>=k?0:1/s(r),e.inv=function(e,n){var s=_(e.x,e.y=o-e.y);n.phi=o+r-s,t(n.phi)>k&&U(),t(t(n.phi)-k)<=d?n.lam=0:n.lam=s*l(e.x,e.y)/i(n.phi)},e.fwd=function(e,s){var a,h;h=o+r-e.phi,t(h)>d?(s.x=h*n(a=e.lam*i(e.phi)/h),s.y=o-h*i(a)):s.x=s.y=0})},"bonne","Bonne (Werner lat_1=90)","Conic Sph&Ell\nlat_1="),tt(function(t){var e,r,a=.16666666666666666,h=.008333333333333333,u=.041666666666666664,p=.06666666666666667;t.es?(r=Xe(t.es),e=Ze(t.phi0,n(t.phi0),i(t.phi0),r),t.fwd=function(o,l){var p,d,_,f,m,y;l.y=Ze(o.phi,p=n(o.phi),f=i(o.phi),r),p=1/c(1-t.es*p*p),y=s(o.phi),d=y*y,_=o.lam*f,f*=t.es*f/(1-t.es),m=_*_,l.x=p*_*(1-m*d*(a-(8-d+8*f)*m*h)),l.y-=e-p*y*m*(.5+(5-d+6*f)*m*u)},t.inv=function(o,a){var h,l,d,_,f,m,y;y=Je(e+o.y,t.es,r),m=s(y),l=m*m,h=n(y),d=1/(1-t.es*h*h),h=c(d),d*=(1-t.es)*h,_=o.x/h,f=_*_,a.phi=y-h*m/d*f*(.5-(1+3*l)*f*u),a.lam=_*(1+l*f*((1+3*l)*f*p-.3333333333333333))/i(y)}):(t.fwd=function(e,r){r.x=o(i(e.phi)*n(e.lam)),r.y=l(s(e.phi),i(e.lam))-t.phi0},t.inv=function(e,r){var a=e.y+t.phi0;r.phi=o(n(a)*i(e.x)),r.lam=l(s(e.x),i(a))})},"cass","Cassini","Cyl, Sph&Ell"),tt(function(e){var s,r,a=0;Z(e.params,"tlat_ts")&&(e.k0=i(a=Z(e.params,"rlat_ts")),e.k0<0&&j(-24)),e.es?(a=n(a),e.k0/=c(1-e.es*a*a),e.e=c(e.es),(r=rn(e.es))||e_error_0(),s=He(1,e.e,e.one_es),e.fwd=function(t,i){i.x=e.k0*t.lam,i.y=.5*He(n(t.phi),e.e,e.one_es)/e.k0},e.inv=function(t,n){n.phi=on(o(2*t.y*e.k0/s),r),n.lam=t.x/e.k0}):(e.fwd=function(t,i){i.x=e.k0*t.lam,i.y=n(t.phi)/e.k0},e.inv=function(n,i){var s,r=n.x,a=n.y;(s=t(a*=e.k0))-N<=1?(i.phi=s>=1?a<0?-k:k:o(a),i.lam=r/e.k0):U()})},"cea","Equal Area Cylindrical","Cyl, Sph&Ell\nlat_ts="),tt(function(e){var s,r,o,a,h,u,p,d=1/3,_=[];for(u=0;u<3;++u)_[u]={p:{}},_[u].phi=Z(e.params,"rlat_"+(u+1)),_[u].lam=Z(e.params,"rlon_"+(u+1)),_[u].lam=Et(_[u].lam-e.lam0),_[u].cosphi=i(_[u].phi),_[u].sinphi=n(_[u].phi);for(u=0;u<3;++u)p=2==u?0:u+1,_[u].v=f(_[p].phi-_[u].phi,_[u].cosphi,_[u].sinphi,_[p].cosphi,_[p].sinphi,_[p].lam-_[u].lam),_[u].v.r||j(-25);function f(e,s,r,o,a,h){var u,p,d,_={};return u=i(h),t(e)>1||t(h)>1?_.r=Qe(cs1*a+s*o*u):(p=n(.5*e),d=n(.5*h),_.r=2*Ye(c(p*p+s*o*d*d))),t(_.r)>1e-9?_.Az=l(o*n(h),s*a-r*o*u):_.r=_.Az=0,_}function m(t,e,n){return Qe(.5*(t*t+e*e-n*n)/(t*e))}o=m(_[0].v.r,_[2].v.r,_[1].v.r),a=m(_[0].v.r,_[1].v.r,_[2].v.r),h=b-o,r=2*(_[0].p.y=_[1].p.y=_[2].v.r*n(o)),_[2].p.y=0,_[0].p.x=-(_[1].p.x=.5*_[0].v.r),s=_[2].p.x=_[0].p.x+_[2].v.r*i(o),e.es=0,e.fwd=function(t,e){var o,l,c,u,p,y,g,v=[];for(o=n(t.phi),l=i(t.phi),u=0;u<3&&(v[u]=f(t.phi-_[u].phi,_[u].cosphi,_[u].sinphi,l,o,t.lam-_[u].lam),v[u].r);++u)v[u].Az=Et(v[u].Az-_[u].v.Az);if(u<3)y=_[u].p.x,g=_[u].p.y;else{for(y=s,g=r,u=0;u<3;++u)p=2==u?0:u+1,c=m(_[u].v.r,v[u].r,v[p].r),v[u].Az<0&&(c=-c),u?1==u?(c=a-c,y-=v[u].r*i(c),g-=v[u].r*n(c)):(c=h-c,y+=v[u].r*i(c),g+=v[u].r*n(c)):(y+=v[u].r*i(c),g-=v[u].r*n(c));y*=d,g*=d}e.x=y,e.y=g}},"chamb","Chamberlin Trimetric","Misc Sph, no inv.\nlat_1= lon_1= lat_2= lon_2= lat_3= lon_3="),tt(function(t){var e=1/3;t.inv=function(t,n){n.phi=3*o(.32573500793527993*t.y),n.lam=1.0233267079464885*t.x/(2*i((n.phi+n.phi)*e)-1)},t.fwd=function(t,s){t.phi*=e,s.x=.9772050238058398*t.lam*(2*i(t.phi+t.phi)-1),s.y=3.0699801238394655*n(t.phi)},t.es=0},"crast","Craster Parabolic (Putnins P4)","PCyl., Sph."),tt(function(t){var e=.5253,s=.7264,r=1/Math.sqrt(e*s),a=.9701,h=d(22*S),l=_(0),u=n(h),p=i(h);function d(t){return o(s*n(t)+.4188*c(e*s))}function _(t){return e*t}Z(t.params,"tlon_0")||(t.lam0=11.023*S),t.es=0,t.fwd=function(t,e){var s=d(t.phi),o=_(t.lam),f=n(s),m=i(s),y=n(o-l),g=i(o-l),v=c(2/(1+n(h)*f+p*m*g));e.x=r*v*m*y*a,e.y=r*v*(p*f-u*m*g)/a}},"cupola","Cupola","PCyl., Sph., NoInv."),tt(function(e){e.fwd=function(e,n){var s=t(e.lam);n.y=e.phi,n.x=e.lam,n.x*=i((.95+s*(s*s*.0016666666666666666-.08333333333333333))*(e.phi*(.9+.03*e.phi*e.phi*e.phi*e.phi)))},e.es=0},"denoy","Denoyer Semi-Elliptical","PCyl, Sph., no inv."),tt(function(e){var n=.9213177319235613,i=.3183098861837907;e.es=0,e.fwd=function(e,s){s.x=n*e.lam*(1-i*t(e.phi)),s.y=n*e.phi},e.inv=function(e,s){s.phi=e.y/n,s.lam=e.x/(n*(1-i*t(s.phi)))}},"eck1","Eckert I","PCyl Sph"),tt(function(e){var i=.46065886596178063,s=1.4472025091165353;e.es=0,e.fwd=function(e,r){r.x=i*e.lam*(r.y=c(4-3*n(t(e.phi)))),r.y=s*(2-r.y),e.phi<0&&(r.y=-r.y)},e.inv=function(e,n){n.lam=e.x/(i*(n.phi=2-t(e.y)/s)),n.phi=.3333333333333333*(4-n.phi*n.phi),t(n.phi)>=1?t(n.phi)>1.0000001?U():n.phi=n.phi<0?-k:k:n.phi=o(n.phi),e.y<0&&(n.phi=-n.phi)}},"eck2","Eckert II","PCyl Sph"),tt(function(t){an(t,{C_x:.4222382003157712,C_y:.8444764006315424,A:1,B:.4052847345693511})},"eck3","Eckert III","PCyl Sph"),tt(function(t){an(t,{C_x:.94745,C_y:.94745,A:0,B:.3039635509270133})},"wag6","Wagner VI","PCyl Sph"),tt(function(t){an(t,{C_x:.8660254037844,C_y:1,A:0,B:.3039635509270133})},"kav7","Kavraisky VII","PCyl Sph"),tt(function(t){an(t,{C_x:1.8949,C_y:.94745,A:-.5,B:.3039635509270133})},"putp1","Putnins P1","PCyl Sph"),tt(function(e){var s=.4222382003157712,r=1.3265004281770023,o=3.5707963267948966;e.es=0,e.fwd=function(e,a){var h,l,c,u,p;for(h=o*n(e.phi),l=e.phi*e.phi,e.phi*=.895168+l*(.0218849+.00826809*l),p=6;p&&(u=i(e.phi),c=n(e.phi),e.phi-=l=(e.phi+c*(u+2)-h)/(1+u*(u+2)-c*c),!(t(l)<1e-7));--p);p?(a.x=s*e.lam*(1+i(e.phi)),a.y=r*n(e.phi)):(a.x=s*e.lam,a.y=e.phi<0?-r:r)},e.inv=function(t,e){var a;e.phi=Ye(t.y/r),e.lam=t.x/(s*(1+(a=i(e.phi)))),e.phi=Ye((e.phi+n(e.phi)*(a+2))/o)}},"eck4","Eckert IV","PCyl Sph"),tt(function(t){t.es=0,t.fwd=function(t,e){e.x=.4410127717245515*(1+i(t.phi))*t.lam,e.y=.882025543449103*t.phi},t.inv=function(t,e){e.lam=2.267508027238226*t.x/(1+i(e.phi=1.133754013619113*t.y))}},"eck5","Eckert V","PCyl Sph"),tt(function(t){var e=i(Z(t.params,"rlat_ts"));e<=0&&j(-24),t.es=0,t.fwd=function(n,i){i.x=e*n.lam,i.y=n.phi-t.phi0},t.inv=function(n,i){i.lam=n.x/e,i.phi=n.y+t.phi0}},"eqc","Equidistant Cylindrical (Plate Caree)","Cyl, Sph\nlat_ts=[, lat_0=0]"),tt(function(e){var s,r,o,a,h,c,u,p,d,f,m,y,g;s=Z(e.params,"rlat_1"),r=Z(e.params,"rlat_2"),t(s+r)<N&&j(-21),(u=Xe(e.es))||e_error_0(),o=f=n(s),d=i(s),m=t(s-r)>=N,(p=e.es>0)?(g=We(f,d,e.es),y=Ze(s,f,d,u),m&&(f=n(r),d=i(r),o=(g-We(f,d,e.es))/(Ze(r,f,d,u)-y)),h=(c=y+g/o)-Ze(e.phi0,n(e.phi0),i(e.phi0),u)):(m&&(o=(d-i(r))/(r-s)),c=s+i(s)/o,h=c-e.phi0),e.fwd=function(t,e){a=c-(p?Ze(t.phi,n(t.phi),i(t.phi),u):t.phi),e.x=a*n(t.lam*=o),e.y=h-a*i(t.lam)},e.inv=function(t,n){0!=(a=_(t.x,t.y=h-t.y))?(o<0&&(a=-a,t.x=-t.x,t.y=-t.y),n.phi=c-a,p&&(n.phi=Je(n.phi,e.es,u)),n.lam=l(t.x,t.y)/o):(n.lam=0,n.phi=o>0?k:-k)}},"eqdc","Equidistant Conic","Conic, Sph&Ell\nlat_1= lat_2="),tt(function(t){var e=1.340264,n=-.081106,i=893e-6,s=.003796,r=Math.sqrt(3)/2;t.es=0,t.fwd=function(t,o){var a=Math.asin(r*Math.sin(t.phi)),h=a*a,l=h*h*h;o.x=t.lam*Math.cos(a)/(r*(e+3*n*h+l*(7*i+9*s*h))),o.y=a*(e+n*h+l*(i+s*h))},t.inv=function(t,o){var a,h,l,c,u=t.y;for(c=0;c<12&&(u-=l=(u*(e+n*(a=u*u)+(h=a*a*a)*(i+s*a))-t.y)/(e+3*n*a+h*(7*i+9*s*a)),!(Math.abs(l)<1e-9));++c);h=(a=u*u)*a*a,o.lam=r*t.x*(e+3*n*a+h*(7*i+9*s*a))/Math.cos(u),o.phi=Math.asin(Math.sin(u)/r)}},"eqearth","Equal Earth","PCyl., Sph."),tt(hn,"etmerc","Extended Transverse Mercator","Cyl, Sph\nlat_ts=(0)\nlat_0=(0)"),tt(function(t){t.fwd=function(t,e){e.x=.7071067811865476*t.lam,e.y=1.7071067811865475*s(.5*t.phi)},t.inv=function(t,e){e.lam=1.4142135623730951*t.x,e.phi=2*h(.585786437626905*t.y)},t.es=0},"gall","Gall (Gall Stereographic)","Cyl, Sph"),tt(function(t){t.is_geocent=!0,t.x0=0,t.y0=0,t.fwd=function(t,e){e.x=t.lam,e.y=t.phi},t.inv=function(t,e){e.phi=t.y,e.lam=t.x}},"geocent","Geocentric",""),tt(function(t){var e,r,o,a,u,p,d,f=Z(t.params,"dh"),m=Z(t.params,"ssweep");m?"x"==m?d=1:"y"==m?d=0:j(-49):d=0,((u=f/t.a)<=0||u>1e10)&&j(-50),p=(a=1+u)*a-1,0!=t.es?(e=c(t.one_es),r=t.one_es,o=t.rone_es,t.inv=function(t,n){var r,f,m,y,g,v;r=-1,d?(m=s(t.y/u),f=s(t.x/u)*_(1,m)):(f=s(t.x/u),m=s(t.y/u)*_(1,f));var x=(g=2*a*r)*g-4*(y=f*f+(y=m/e)*y+r*r)*p;x<0&&j(-51),v=(-g-c(x))/(2*y),r=a+v*r,f*=v,m*=v,n.lam=l(f,r),n.phi=h(m*i(n.lam)/r),n.phi=h(o*s(n.phi))},t.fwd=function(t,l){var c,p,f,m,y;t.phi=h(r*s(t.phi)),c=e/_(e*i(t.phi),n(t.phi)),p=c*i(t.lam)*i(t.phi),f=c*n(t.lam)*i(t.phi),m=c*n(t.phi),(a-p)*p-f*f-m*m*o<0&&j(-51),y=a-p,d?(l.x=u*h(f/_(m,y)),l.y=u*h(m/y)):(l.x=u*h(f/y),l.y=u*h(m/_(f,y)))}):(e=r=o=1,t.inv=function(t,e){var n,r,o,_,f,m;n=-1,d?(o=s(t.y/u),r=s(t.x/u)*c(1+o*o)):(r=s(t.x/u),o=s(t.y/u)*c(1+r*r));var y=(f=2*a*n)*f-4*(_=r*r+o*o+n*n)*p;y<0&&j(-51),m=(-f-c(y))/(2*_),n=a+m*n,r*=m,o*=m,e.lam=l(r,n),e.phi=h(o*i(e.lam)/n)},t.fwd=function(t,e){var s=i(t.phi),r=i(t.lam)*s,o=n(t.lam)*s,l=n(t.phi);s=a-r,d?(e.x=u*h(o/_(l,s)),e.y=u*h(l/s)):(e.x=u*h(o/s),e.y=u*h(l/_(o,s)))})},"geos","Geostationary Satellite View","Azi, Sph&Ell"),tt(function(t){var e=a(Z(t.params,"tlat_1")?Z(t.params,"rlat_1"):0),r=n(e),o=i(e);function a(t){return Ye(s(.5*t))}t.fwd=function(t,e){var s=.5*t.lam,h=a(t.phi),l=n(h),c=i(h),u=i(s);r*l+o*c*u>=0?(e.x=c*n(s),e.y=o*l-r*c*u):z()},t.es=0},"gilbert","Gilbert Two World Perspective","PCyl., Sph., NoInv.\nlat_1="),tt(function(t){t.fwd=function(t,e){var n=t.phi*t.phi;e.y=t.phi*(1+.08333333333333333*n),e.x=t.lam*(1-.162388*n),n=t.lam*t.lam,e.x*=.87-952426e-9*n*n},t.es=0},"gins8","Ginsburg VIII (TsNIIGAiK)","PCyl, Sph., no inv."),tt(function(t){Z(t.params,"tn"),Z(t.params,"tm")?cn(t,Z(t.params,"dm"),Z(t.params,"dn")):j(-99)},"gn_sinu","General Sinusoidal Series","PCyl, Sph.\nm= n="),tt(ln,"sinu","Sinusoidal (Sanson-Flamsteed)","PCyl, Sph&Ell"),tt(function(t){cn(t,1,2.5707963267948966)},"eck6","Eckert VI","PCyl, Sph.\nm= n="),tt(function(t){cn(t,.5,1.7853981633974483)},"mbtfps","McBryde-Thomas Flat-Polar Sinusoidal","PCyl, Sph."),tt(function(e){var s,r,a=1e-10;t(t(e.phi0)-k)<a?r=e.phi0<0?1:0:t(e.phi0)<a?r=2:(r=3,sinph0=n(e.phi0),s=i(e.phi0)),e.inv=function(i,u){var p,d,f,m=i.x,y=i.y;if(p=_(m,y),f=n(u.phi=h(p)),d=c(1-f*f),t(p)<=a)u.phi=e.phi0,u.lam=0;else{switch(r){case 3:u.phi=d*sinph0+y*f*s/p,t(u.phi)>=1?u.phi=u.phi>0?k:-k:u.phi=o(u.phi),y=(d-sinph0*n(u.phi))*p,m*=f*s;break;case 2:u.phi=y*f/p,t(u.phi)>=1?u.phi=u.phi>0?k:-k:u.phi=o(u.phi),y=d*p,m*=f;break;case 1:u.phi-=k;break;case 0:u.phi=k-u.phi,y=-y}u.lam=l(m,y)}},e.fwd=function(t,e){var o,h,l;switch(l=n(t.phi),h=i(t.phi),o=i(t.lam),r){case 2:e.y=h*o;break;case 3:e.y=sinph0*l+s*h*o;break;case 1:e.y=-l;break;case 0:e.y=l}switch(e.y<=a&&z(),e.x=(e.y=1/e.y)*h*n(t.lam),r){case 2:e.y*=l;break;case 3:e.y*=s*l-sinph0*h*o;break;case 0:o=-o;case 1:e.y*=h*o}},e.es=0},"gnom","Gnomonic","Azi, Sph."),tt(un,"moll","Mollweide","PCyl Sph"),tt(function(t){dn(t,pn(0,b/3))},"wag4","Wagner IV","PCyl Sph"),tt(function(t){dn(t,{C_x:.90977,C_y:1.65014,C_p:3.00896})},"wag5","Wagner V","PCyl Sph"),tt(function(e){var n,i,s,r,o=.0528,a=.7109307819790236;e.es=0,ln(e),n=e.fwd,i=e.inv,un(e),s=e.fwd,r=e.inv,e.fwd=function(e,i){t(e.phi)<a?n(e,i):(s(e,i),i.y-=e.phi>0?o:-o)},e.inv=function(e,n){t(e.y)<=a?i(e,n):(e.y+=e.y>0?o:-o,r(e,n))}},"goode","Goode Homolosine","PCyl, Sph."),tt(function(e){var s,r,o;e.inv=function(e,n){var i=c(1-.25*s*s*e.x*e.x-.25*e.y*e.y);t(2*i*i-1)<1e-10?(n.lam=x,n.phi=x,pj_errno=-14):(n.lam=en(s*e.x*i,2*i*i-1)/s,n.phi=Ye(i*e.y))},e.fwd=function(t,e){var a,h;h=c(2/(1+(a=i(t.phi))*i(t.lam*=s))),e.x=r*h*a*n(t.lam),e.y=o*h*n(t.phi)},e.es=0,Z(e.params,"tW")?(s=t(Z(e.params,"dW")))<=0&&j(-27):s=.5,Z(e.params,"tM")?(r=t(Z(e.params,"dM")))<=0&&j(-27):r=1,o=1/r,r/=s},"hammer","Hammer & Eckert-Greifendorff","Misc Sph,\nW= M="),tt(function(e){var s=1.000001;e.inv=function(e,r){var a=e.y*(e.y<0?.5179951515653813:.5686373742600607);t(a)>1?t(a)>s?U():a=a>0?k:-k:a=o(a),r.lam=1.1764705882352942*e.x/i(a),a+=a,r.phi=(a+n(a))*(e.y<0?.4102345310814193:.3736990601468637),t(r.phi)>1?t(r.phi)>s?U():r.phi=r.phi>0?k:-k:r.phi=o(r.phi)},e.fwd=function(e,s){var r,o,a;for(o=n(e.phi)*(e.phi<0?2.43763:2.67595),a=20;a&&(e.phi-=r=(e.phi+n(e.phi)-o)/(1+i(e.phi)),!(t(r)<1e-7));--a);s.x=.85*e.lam*i(e.phi*=.5),s.y=n(e.phi)*(e.phi<0?1.93052:1.75859)},e.es=0},"hatano","Hatano Asymmetrical Equal Area","PCyl., Sph."),tt(_n,"healpix","HEALPix","Sph., Ellps."),tt(function(t){_n(t,!0)},"rhealpix","rHEALPix","Sph., Ellps.\nnorth_square= south_square="),tt(function(e){var s,r=n(.5),h=o(r),u=2*c(b/(s=b+4*h*2)),p=.5*u*(2+c(3));e.es=0,e.fwd=function(e,r){var o,a,d=1-n(e.phi);if(d&&d<2){var _,f,m,y,g,v=k-e.phi,x=25;do{f=n(v),m=i(v),g=h+l(f,2-m),v-=_=(v-1*h-2*f+(y=5-4*m)*g-.5*d*s)/(4*f*g)}while(t(_)>1e-12&&--x>0);o=u*c(y),a=e.lam*g/b}else o=u*(1+d),a=e.lam*h/b;r.x=o*n(a),r.y=p-o*i(a)},e.inv=function(t,e){var i=t.x,r=t.y,d=i*i+(r-=p)*r,_=(5-d/(u*u))/4,f=a(_),m=n(f),y=h+l(m,2-_);e.lam=o(i/c(d))*b/y,e.phi=o(1-2*(f-1*h-2*m+(5-4*_)*y)/s)}},"hill","Hill Eucyclic","PCyl., Sph."),tt(function(e){var r,a,p,d,_,f,m,y,g,v=.785398163397448,x=1.37008346281555;e.a=6377397.155,e.e=c(e.es=.006674372230614),Z(e.params,"tlat_0")||(e.phi0=.863937979737193),Z(e.params,"tlon_0")||(e.lam0=.4334234309119251),Z(e.params,"tk")||(e.k0=.9999),g=1,Z(e.params,"tczech")||(g=-1),d=c(1+e.es*u(i(e.phi0),4)/(1-e.es)),r=o(n(e.phi0)/d),p=u((1+e.e*n(e.phi0))/(1-e.e*n(e.phi0)),d*e.e/2),_=s(r/2+v)/u(s(e.phi0/2+v),d)*p,a=c(1-e.es)/(1-e.es*u(n(e.phi0),2)),f=n(x),m=e.k0*a/s(x),y=.5286277629901559,e.inv=function(r,a){var p,w,b,C,S,A,M,E;M=r.x,r.x=r.y,r.y=M,r.x*=g,r.y*=g,S=c(r.x*r.x+r.y*r.y),C=l(r.y,r.x)/n(x),b=2*(h(u(m/S,1/f)*s(x/2+v))-v),p=o(i(y)*n(b)-n(y)*i(b)*i(C)),w=o(i(b)*n(C)/i(p)),a.lam=e.lam0-w/d,A=p,E=0;do{a.phi=2*(h(u(_,-1/d)*u(s(p/2+v),1/d)*u((1+e.e*n(A))/(1-e.e*n(A)),e.e/2))-v),t(A-a.phi)<1e-15&&(E=1),A=a.phi}while(0===E);a.lam-=e.lam0},e.fwd=function(t,r){var a,l,c,p,w,b,C;a=u((1+e.e*n(t.phi))/(1-e.e*n(t.phi)),d*e.e/2),l=2*(h(_*u(s(t.phi/2+v),d)/a)-v),c=-t.lam*d,p=o(i(y)*n(l)+n(y)*i(l)*i(c)),w=o(i(l)*n(c)/i(p)),b=f*w,C=m*u(s(x/2+v),f)/u(s(p/2+v),f),r.y=C*i(b),r.x=C*n(b),r.y*=g,r.x*=g}},"krovak","Krovak","PCyl., Ellps."),tt(function(e){var s,r,a,h,u,p,d,f,m,y,g,v=1e-10;if(y=t(e.phi0),m=t(y-k)<v?e.phi0<0?1:0:t(y)<v?2:3,e.es){switch(e.e=c(e.es),u=He(1,e.e,e.one_es),e.es,f=rn(e.es),m){case 0:case 1:p=1;break;case 2:p=1/(d=c(.5*u)),a=1,h=.5*u;break;case 3:d=c(.5*u),g=n(e.phi0),s=He(g,e.e,e.one_es)/u,r=c(1-s*s),p=i(e.phi0)/(c(1-e.es*g*g)*d*r),h=(a=d)/p,a*=p}e.inv=function(t,a){var h,c,y,g,x=0;switch(m){case 2:case 3:if(t.x/=p,t.y*=p,(g=_(t.x,t.y))<v)return a.lam=0,a.phi=e.phi0,a;c=2*o(.5*g/d),h=i(c),c=n(c),t.x*=c,3==m?(x=h*s+t.y*c*r/g,t.y=g*r*h-t.y*s*c):(x=t.y*c/g,t.y=g*h);break;case 0:t.y=-t.y;case 1:if(!(y=t.x*t.x+t.y*t.y))return a.lam=0,a.phi=e.phi0,a;x=1-y/u,1==m&&(x=-x)}return a.lam=l(t.x,t.y),a.phi=on(o(x),f),a},e.fwd=function(o,l){var p,d,_,f,y=0,g=0,x=0;switch(p=i(o.lam),d=n(o.lam),_=n(o.phi),f=He(_,e.e,e.one_es),(3==m||2==m)&&(g=c(1-(y=f/u)*y)),m){case 3:x=1+s*y+r*g*p;break;case 2:x=1+g*p;break;case 0:x=k+o.phi,f=u-f;break;case 1:x=o.phi-k,f=u+f}switch(t(x)<v&&z(),m){case 3:case 2:3==m?(x=c(2/x),l.y=h*x*(r*y-s*g*p)):(x=c(2/(1+g*p)),l.y=x*y*h),l.x=a*x*g*d;break;case 0:case 1:f>=0?(x=c(f),l.x=x*d,l.y=p*(1==m?x:-x)):l.x=l.y=0}}}else 3==m&&(s=n(e.phi0),r=i(e.phi0)),e.inv=function(a,h){var c,u=0,p=0;switch(c=_(a.x,a.y),(h.phi=.5*c)>1&&U(),h.phi=2*o(h.phi),(3==m||2==m)&&(p=n(h.phi),u=i(h.phi)),m){case 2:h.phi=t(c)<=v?0:o(a.y*p/c),a.x*=p,a.y=u*c;break;case 3:h.phi=t(c)<=v?e.phi0:o(u*s+a.y*p*r/c),a.x*=p*r,a.y=(u-n(h.phi)*s)*c;break;case 0:a.y=-a.y,h.phi=k-h.phi;break;case 1:h.phi-=k}h.lam=0!=a.y||2!=m&&3!=m?l(a.x,a.y):0},e.fwd=function(o,a){var h,l,u;switch(u=n(o.phi),l=i(o.phi),h=i(o.lam),m){case 2:case 3:a.y=2==m?1+l*h:1+s*u+r*l*h,a.y<=v&&z(),a.y=c(2/a.y),a.x=a.y*l*n(o.lam),a.y*=2==m?u:r*u-s*l*h;break;case 0:h=-h;case 1:t(o.phi+e.phi0)<v&&z(),a.y=E-.5*o.phi,a.y=2*(1==m?i(a.y):n(a.y)),a.x=a.y*n(o.lam),a.y*=h}}},"laea","Lambert Azimuthal Equal Area","Azi, Sph&Ell"),tt(fn,"lonlat","Lat/long (Geodetic)",""),tt(fn,"longlat","Lat/long (Geodetic alias)",""),tt(fn,"latlon","Lat/long (Geodetic alias)",""),tt(fn,"latlong","Lat/long (Geodetic alias)",""),tt(function(e){var r,o,a,p,f,m,y,g,v,w,b,C=1e-10;e.inv=function(t,n){var i,s=t.x,r=t.y;s/=e.k0,r/=e.k0,0!=(i=_(s,r=y-r))?(m<0&&(i=-i,s=-s,r=-r),v?(n.phi=yn(u(i/g,1/m),e.e),n.phi==x&&U()):n.phi=2*h(u(g/i,1/m))-k,n.lam=l(s,r)/m):(n.lam=0,n.phi=m>0?k:-k)},e.fwd=function(r,o){var a,h=r.lam;t(t(r.phi)-k)<C?(r.phi*m<=0&&z(),a=0):a=g*(v?u(mn(r.phi,n(r.phi),e.e),m):u(s(E+.5*r.phi),-m)),h*=m,o.x=e.k0*(a*n(h)),o.y=e.k0*(y-a*i(h))},p=Z(e.params,"rlat_1"),Z(e.params,"tlat_2")?f=Z(e.params,"rlat_2"):(f=p,Z(e.params,"tlat_0")||(e.phi0=p)),t(p+f)<C&&j(-21),m=o=n(p),r=i(p),a=t(p-f)>=C,(v=0!=e.es)?(e.e=c(e.es),b=We(o,r,e.es),w=mn(p,o,e.e),a&&(o=n(f),m=d(b/We(o,i(f),e.es)),m/=d(w/mn(f,o,e.e))),g=y=b*u(w,-m)/m,y*=t(t(e.phi0)-k)<C?0:u(mn(e.phi0,n(e.phi0),e.e),m)):(a&&(m=d(r/i(f))/d(s(E+.5*f)/s(E+.5*p))),g=r*u(s(E+.5*p),m)/m,y=t(t(e.phi0)-k)<C?0:g*u(s(E+.5*e.phi0),-m))},"lcc","Lambert Conformal Conic","Conic, Sph&Ell\nlat_1= and lat_2= or lat_0="),tt(function(e){var n,r,o,a=1e-8;n=Z(e.params,"rlat_1"),r=i(n),o=s(E+.5*n),r<a&&j(-22),e.fwd=function(e,i){i.y=e.phi-n,t(i.y)<a?i.x=e.lam*r:(i.x=E+.5*e.phi,t(i.x)<a||t(t(i.x)-k)<a?i.x=0:i.x=e.lam*i.y/d(s(i.x)/o))},e.inv=function(e,i){i.phi=e.y+n,t(e.y)<a?i.lam=e.x/r:(i.lam=E+.5*i.phi,t(i.lam)<a||t(t(i.lam)-k)<a?i.lam=0:i.lam=e.x*d(s(i.lam)/o)/e.y)},e.es=0},"loxim","Loximuthal","PCyl Sph"),tt(function(e){var s=.9525793444156804,r=.9258200997725514,a=3.401680257083045,h=2/3,l=1/3,c=1.0000001;e.fwd=function(t,e){t.phi=o(s*n(t.phi)),e.x=r*t.lam*(2*i(h*t.phi)-1),e.y=a*n(l*t.phi)},e.inv=function(e,l){l.phi=e.y/a,t(l.phi)>=1?t(l.phi)>c?U():l.phi=l.phi<0?-k:k:l.phi=o(l.phi),l.lam=e.x/(r*(2*i(h*(l.phi*=3))-1)),t(l.phi=n(l.phi)/s)>=1?t(l.phi)>c?U():l.phi=l.phi<0?-k:k:l.phi=o(l.phi)},e.es=0},"mbt_fpp","McBride-Thomas Flat-Polar Parabolic","Cyl., Sph."),tt(function(e){var s=1.000001;e.fwd=function(e,s){var r,o,a;for(o=1.7071067811865475*n(e.phi),a=20;a&&(e.phi-=r=(n(.5*e.phi)+n(e.phi)-o)/(.5*i(.5*e.phi)+i(e.phi)),!(t(r)<1e-7));--a);s.x=.3124597141037825*e.lam*(1+2*i(e.phi)/i(.5*e.phi)),s.y=1.874758284622695*n(.5*e.phi)},e.inv=function(e,r){var a;r.phi=.533402096794177*e.y,t(r.phi)>1?t(r.phi)>s?U():r.phi<0?(a=-1,r.phi=-b):(a=1,r.phi=b):r.phi=2*o(a=r.phi),r.lam=3.2004125807650623*e.x/(1+2*i(r.phi)/i(.5*r.phi)),r.phi=.585786437626905*(a+n(r.phi)),t(r.phi)>1?t(r.phi)>s?U():r.phi=r.phi<0?-k:k:r.phi=o(r.phi)},e.es=0},"mbt_fpq","McBryde-Thomas Flat-Polar Quartic","Cyl., Sph."),tt(function(e){var s=.45503,r=1.36509,o=1.41546,a=.22248,h=1.44492,l=1/3;e.fwd=function(e,c){var u,p,d,_;for(u=o*n(e.phi),_=10;_&&(d=e.phi/r,e.phi-=p=(s*n(d)+n(e.phi)-u)/(l*i(d)+i(e.phi)),!(t(p)<1e-7));--_);d=e.phi/r,c.x=a*e.lam*(1+3*i(e.phi)/i(d)),c.y=h*n(d)},e.inv=function(t,e){var l;e.phi=r*(l=Ye(t.y/h)),e.lam=t.x/(a*(1+3*i(e.phi)/i(l))),e.phi=Ye((s*n(l)+n(e.phi))/o)},e.es=0},"mbt_fps","McBryde-Thomas Flat-Pole Sine (No. 2)","Cyl., Sph."),tt(function(e){var r=1e-10,o=0,a=Z(e.params,"tlat_ts");a&&(o=Z(e.params,"rlat_ts"))>=k&&j(-24),e.es?(a&&(e.k0=We(n(o),i(o),e.es)),e.inv=function(t,n){n.phi=yn(p(-t.y/e.k0),e.e),n.phi===x&&U(),n.lam=t.x/e.k0},e.fwd=function(i,s){t(t(i.phi)-k)<=r&&z(),s.x=e.k0*i.lam,s.y=-e.k0*d(mn(i.phi,n(i.phi),e.e))}):(e.inv=function(t,n){n.phi=k-2*h(p(-t.y/e.k0)),n.lam=t.x/e.k0},e.fwd=function(n,i){t(t(n.phi)-k)<=r&&z(),i.x=e.k0*n.lam,i.y=e.k0*d(s(E+.5*n.phi))})},"merc","Mercator","Cyl, Sph&Ell\nlat_ts="),tt(function(e){e.k0=1,e.inv=function(t,n){n.phi=k-2*h(p(-t.y/e.k0)),n.lam=t.x/e.k0},e.fwd=function(n,i){t(t(n.phi)-k)<=N&&z(),i.x=e.k0*n.lam,i.y=e.k0*d(s(E+.5*n.phi))}},"webmerc","Web Mercator / Pseudo Mercator","Cyl, Ell"),tt(function(t){t.fwd=function(t,e){e.x=t.lam,e.y=1.25*d(s(E+.4*t.phi))},t.inv=function(t,e){e.lam=t.x,e.phi=2.5*(h(p(.8*t.y))-E)},t.es=0},"mill","Miller Cylindrical","Cyl, Sph"),tt(function(t){t.lam0=20*S,t.phi0=18*S,t.es=0,xn(t,[[.9245,0],[0,0],[.01943,0]])},"mil_os","Miller Oblated Stereographic","Azi(mod)"),tt(function(t){t.lam0=-165*S,t.phi0=-10*S,t.es=0,xn(t,[[.721316,0],[0,0],[-.0088162,-.00617325]])},"lee_os","Lee Oblated Stereographic","Azi(mod)"),tt(function(t){t.lam0=-96*S,t.phi0=39*S,t.es=0,t.a=6370997,xn(t,[[.98879,0],[0,0],[-.050909,0],[0,0],[.075528,0]])},"gs48","Mod Stereographic of 48 U.S.","Azi(mod)"),tt(function(t){var e;t.lam0=-152*S,t.phi0=64*S,0!=t.es?(e=[[.9945303,0],[.0052083,-.0027404],[.0072721,.0048181],[-.0151089,-.1932526],[.0642675,-.1381226],[.3582802,-.2884586]],t.a=6378206.4,t.e=c(t.es=.00676866)):(e=[[.9972523,0],[.0052513,-.0041175],[.0074606,.0048125],[-.0153783,-.1968253],[.0636871,-.1408027],[.3660976,-.2937382]],t.a=6370997),xn(t,e)},"alsk","Mod Stereographic of Alaska","Azi(mod)"),tt(function(t){var e;t.lam0=-120*S,t.phi0=45*S,0!=t.es?(e=[[.9827497,0],[.0210669,.0053804],[-.1031415,-.0571664],[-.0323337,-.0322847],[.0502303,.1211983],[.0251805,.0895678],[-.0012315,-.1416121],[.0072202,-.1317091],[-.0194029,.0759677],[-.0210072,.0834037]],t.a=6378206.4,t.e=c(t.es=.00676866)):(e=[[.984299,0],[.0211642,.0037608],[-.1036018,-.0575102],[-.0329095,-.0320119],[.0499471,.1223335],[.026046,.0899805],[7388e-7,-.1435792],[.0075848,-.1334108],[-.0216473,.0776645],[-.0225161,.0853673]],t.a=6370997),xn(t,e)},"gs50","Mod Stereographic of 50 U.S.","Azi(mod)"),tt(function(e){var n=.8707,i=-.131979,s=-.013791,r=.003971,o=-.001529,a=1.007226,h=.015085,l=-.044475,c=.028874,u=-.005916,p=a,d=3*h,_=7*l,f=9*c,m=11*u,y=.8707*.52*b;e.es=0,e.fwd=function(t,e){var p,d;d=(p=t.phi*t.phi)*p,e.x=t.lam*(n+p*(i+p*(s+d*p*(r+p*o)))),e.y=t.phi*(a+p*(h+d*(l+c*p+u*d)))},e.inv=function(e,g){var v,x,w,b,C=e.x,S=e.y;for(S>y?S=y:S<-y&&(S=-y),v=S;v-=x=(v*(a+(w=v*v)*(h+(b=w*w)*(l+c*w+u*b)))-S)/(p+w*(d+b*(_+f*w+m*b))),!(t(x)<1e-11););g.phi=v,w=v*v,g.lam=C/(n+w*(i+w*(s+w*w*w*(r+w*o))))}},"natearth","Natural Earth","PCyl., Sph."),tt(function(e){var n=.84719,i=-.13063,s=-.04515,r=.05494,o=-.02326,a=.00331,h=1.01183,l=-.02625,c=.01926,u=-.00396,p=h,d=9*l,_=.45334622460635143*b;e.es=0,e.fwd=function(t,e){var p,d,_;_=(p=t.phi*t.phi)*(d=p*p),e.x=t.lam*(n+i*p+_*_*(s+r*p+o*d+a*_)),e.y=t.phi*(h+d*d*(l+c*p+u*d))},e.inv=function(e,f){var m,y,g,v,x,w=e.x,b=e.y;for(b>_?b=_:b<-_&&(b=-_),m=b;m-=y=(m*(h+(v=(g=m*m)*g)*v*(l+c*g+u*v))-b)/(p+v*v*(d+.21186*g+-.05148*v)),!(t(y)<1e-11););f.phi=m,x=(g=m*m)*(v=g*g),f.lam=w/(n+i*g+x*x*(s+r*g+o*v+a*x))}},"natearth2","Natural Earth 2","PCyl., Sph."),tt(function(e){e.inv=function(t,e){e.lam=2*t.x/(1+i(t.y)),e.phi=Ye(.5*(t.y+n(t.y)))},e.fwd=function(e,s){var r,o,a;for(r=2*n(e.phi),o=e.phi*e.phi,e.phi*=1.00371+o*(-.011412*o-.0935382),a=10;a&&(e.phi-=o=(e.phi+n(e.phi)-r)/(1+i(e.phi)),!(t(o)<1e-7));--a);s.x=.5*e.lam*(1+i(e.phi)),s.y=e.phi},e.es=0},"nell","Nell","PCyl., Sph."),tt(function(e){e.es=0,e.fwd=function(t,e){e.x=.5*t.lam*(1+i(t.phi)),e.y=2*(t.phi-s(.5*t.phi))},e.inv=function(e,n){var r,o,a,h;for(a=.5*e.y,h=9;h>0&&(o=i(.5*n.phi),n.phi-=r=(n.phi-s(n.phi/2)-a)/(1-.5/(o*o)),!(t(r)<1e-7));--h);h?n.lam=2*e.x/(1+i(n.phi)):(n.phi=a<0?-k:k,n.lam=2*e.x)}},"nell_h","Nell-Hammer","PCyl., Sph."),tt(function(e){e.es=0,e.fwd=function(e,s){var r=1e-10;if(t(e.lam)<r)s.x=0,s.y=e.phi;else if(t(e.phi)<r)s.x=e.lam,s.y=0;else if(t(t(e.lam)-k)<r)s.x=e.lam*i(e.phi),s.y=k*n(e.phi);else if(t(t(e.phi)-k)<r)s.x=0,s.y=e.phi;else{var o=k/e.lam-e.lam/k,a=e.phi/k,h=n(e.phi),l=(1-a*a)/(h-a),u=o/l,p=(o*h/l-.5*o)/(1+(u*=u)),d=(h/u+.5*l)/(1+1/u);s.x=i(e.phi),s.x=c(p*p+s.x*s.x/(1+u)),s.x=k*(p+(e.lam<0?-s.x:s.x)),s.y=c(d*d-(h*h/u+l*h-1)/(1+1/u)),s.y=k*(d+(e.phi<0?s.y:-s.y))}}},"nicol","Nicolosi Globular","Misc Sph, no inv"),tt(function(t){wn(t,Z(t.params,"dh"))},"nsper","Near-sided perspective","Azi, Sph\nh="),tt(function(t){var e=Z(t.params,"dtilt")*S,n=Z(t.params,"dazi")*S,i=Z(t.params,"dh");wn(t,i,e,n)},"tpers","Tilted perspective","Azi, Sph\ntilt= azi= h="),tt(function(e){var n=[[.7557853228,0],[.249204646,.003371507],[-.001541739,.04105856],[-.10162907,.01727609],[-.26623489,-.36249218],[-.6870983,-1.1651967]],i=[1.5627014243,.5185406398,-.03333098,-.1052906,-.0368594,.007317,.0122,.00394,-.0013],s=[.6399175073,-.1358797613,.063294409,-.02526853,.0117879,-.0055161,.0026906,-.001333,67e-5,-34e-5];e.ra=1/(e.a=6378388),e.lam0=173*S,e.phi0=-41*S,e.x0=251e4,e.y0=6023150,e.inv=function(s,r){var o,a,h,l,c,u,p={r:s.y,i:s.x},d={};for(o=20;o>0&&((c=vn(p,n,d)).r-=s.y,c.i-=s.x,u=d.r*d.r+d.i*d.i,p.r+=h=-(c.r*d.r+c.i*d.i)/u,p.i+=l=-(c.i*d.r-c.r*d.i)/u,!(t(h)+t(l)<=1e-10));--o);if(o>0){for(r.lam=p.i,a=i.length-1,r.phi=i[a],--a;a>=0;--a)r.phi=i[a]+p.r*r.phi;r.phi=e.phi0+p.r*r.phi*.484813681109536}else r.lam=r.phi=x},e.fwd=function(t,i){var r=s.length-1,o={r:s[r]},a=2.0626480624709638*(t.phi-e.phi0);for(--r;r>=0;--r)o.r=s[r]+a*o.r;o.r*=a,o.i=t.lam,o=gn(o,n),i.x=o.i,i.y=o.r}},"nzmg","New Zealand Map Grid","fixed Earth"),tt(function(e){var r,o,a,c,u,p,d,_,f,m,y,g,v,w,b,A=1e-10;r=Z(e.params,"so_proj"),o=Q[r],r||j(-26),o&&"ob_tran"!=r||j(-37),e.es=0,a={},Object.keys(e).forEach(function(t){a[t]=e[t]}),o.init(a),a.is_latlong&&1==e.to_meter&&(e.to_meter=S,e.fr_meter=C),Z(e.params,"to_alpha")?(_=Z(e.params,"ro_lon_c"),f=Z(e.params,"ro_lat_c"),m=Z(e.params,"ro_alpha"),t(t(f)-k)<=A&&j(-32),c=_+en(-i(m),-n(m)*n(f)),d=Ye(i(f)*n(m))):Z(e.params,"to_lat_p")?(c=Z(e.params,"ro_lon_p"),d=Z(e.params,"ro_lat_p")):(y=Z(e.params,"ro_lon_1"),v=Z(e.params,"ro_lat_1"),g=Z(e.params,"ro_lon_2"),w=Z(e.params,"ro_lat_2"),(t(v-w)<=A||(b=t(v))<=A||t(b-k)<=A||t(t(w)-k)<=A)&&j(-33),c=l(i(v)*n(w)*i(y)-n(v)*i(w)*i(g),n(v)*i(w)*n(g)-i(v)*n(w)*n(y)),d=h(-i(c-y)/s(v))),t(d)>A?(u=i(d),p=n(d),e.fwd=function(t,e){var s,r,o;s=i(t.lam),r=n(t.phi),o=i(t.phi),t.lam=Et(en(o*n(t.lam),p*o*s+u*r)+c),t.phi=Ye(p*r-u*o*s),a.fwd(t,e)},e.inv=a.inv?function(t,e){var s,r,o;a.inv(t,e),e.lam!=x&&(s=i(e.lam-=c),r=n(e.phi),o=i(e.phi),e.phi=Ye(p*r+u*o*s),e.lam=en(o*n(e.lam),p*o*s-u*r))}:null):(e.fwd=function(t,e){var s,r;s=i(t.phi),r=i(t.lam),t.lam=Et(en(s*n(t.lam),n(t.phi))+c),t.phi=Ye(-s*r),a.fwd(t,e)},e.inv=a.inv?function(t,e){var s,r;a.inv(t,e),e.lam!=x&&(s=i(e.phi),r=e.lam-c,e.lam=en(s*n(r),-n(e.phi)),e.phi=Ye(s*i(r)))}:null)},"ob_tran","General Oblique Transformation","Misc Sph\no_proj= plus parameters for projection\no_lat_p= o_lon_p= (new pole) or\no_alpha= o_lon_c= o_lat_c= or\no_lon_1= o_lat_1= o_lon_2= o_lat_2="),tt(function(t){var e,r,a,u,p,d,_,f,m,y,g;_=1/t.k0,f=t.k0,Z(t.params,"talpha")?(d=Z(t.params,"ralpha"),p=Z(t.params,"rlonc"),g=h(-i(d)/(-n(0)*n(d)))+p,m=o(i(0)*n(d))):(e=Z(t.params,"rlat_1"),r=Z(t.params,"rlat_2"),a=Z(t.params,"rlon_1"),u=Z(t.params,"rlon_2"),g=l(i(e)*n(r)*i(a)-n(e)*i(r)*i(u),n(e)*i(r)*n(u)-i(e)*n(r)*n(a)),a==-k&&(g=-g),m=h(-i(g-a)/s(e))),t.lam0=g+k,y=i(m),m=n(m),g=n(g),t.es=0,t.fwd=function(t,e){var r;e.y=n(t.lam),r=i(t.lam),e.x=h((s(t.phi)*y+m*e.y)/r),r<0&&(e.x+=b),e.x*=f,e.y=_*(m*n(t.phi)-y*i(t.phi)*e.y)},t.inv=function(t,e){var s,r;t.y/=_,t.x/=f,s=c(1-t.y*t.y),e.phi=o(t.y*m+s*y*(r=n(t.x))),e.lam=l(s*m*r-t.y*y,s*i(t.x))}},"ocea","Oblique Cylindrical Equal Area","Cyl, Sph lonc= alpha= or\nlat_1= lat_2= lon_1= lon_2="),tt(function(e){var r,a,_,f,m,y,g,v,w,C,S,A,M,D,P,T,L,R,F,G,O,B,q,$,V,H,W,K=1e-7,X=0,J=0,Y=0,Q=0,tt=0,et=0,nt=0,it=0;W=Z(e.params,"tno_rot"),0!=(A=Z(e.params,"talpha"))&&(nt=Z(e.params,"ralpha")),0!=(M=Z(e.params,"tgamma"))&&(X=Z(e.params,"rgamma")),A||M?(J=Z(e.params,"rlonc"),(it=Z(e.params,"tno_off")||Z(e.params,"tno_uoff"))&&(Z(e.params,"sno_uoff"),Z(e.params,"sno_off"))):(Y=Z(e.params,"rlon_1"),tt=Z(e.params,"rlat_1"),Q=Z(e.params,"rlon_2"),et=Z(e.params,"rlat_2"),(t(tt-et)<=K||(r=t(tt))<=K||t(r-k)<=K||t(t(e.phi0)-k)<=K||t(t(et)-k)<=K)&&j(-33)),a=c(e.one_es),t(e.phi0)>N?(v=n(e.phi0),_=i(e.phi0),r=1-e.es*v*v,P=_*_,P=c(1+e.es*P*P/e.one_es),D=P*e.k0*a/r,(m=(f=P*a/(_*c(r)))*f-1)<=0?m=0:(m=c(m),e.phi0<0&&(m=-m)),T=m+=f,T*=u(mn(e.phi0,v,e.e),P)):(P=1/a,D=e.k0,T=f=m=1),A||M?(A?(S=o(n(nt)/f),M||(X=nt)):nt=o(f*n(S=X)),e.lam0=J-o(.5*(m-1/m)*s(S))/P):(y=u(mn(tt,n(tt),e.e),P),g=u(mn(et,n(et),e.e),P),m=T/y,w=(g-y)/(g+y),C=((C=T*T)-g*y)/(C+g*y),(r=Y-Q)<-b?Q-=I:r>b&&(Q+=I),e.lam0=Et(.5*(Y+Q)-h(C*s(.5*P*(Y-Q))/w)/P),S=h(2*n(P*Et(Y-e.lam0))/(m-1/m)),X=nt=o(f*n(S))),G=n(S),O=i(S),B=n(X),q=i(X),R=1/(L=D*(F=1/P)),it?H=0:(H=t(L*h(c(f*f-1)/i(nt))),e.phi0<0&&(H=-H)),$=L*d(s(E-(m=.5*S))),V=L*d(s(E+m)),e.fwd=function(s,r){var o,a,h,c,p,_,f,m;t(t(s.phi)-k)>N?(o=.5*((p=T/u(mn(s.phi,n(s.phi),e.e),P))-(_=1/p)),a=.5*(p+_),c=n(P*s.lam),t(t(h=(o*G-c*O)/a)-1)<N&&z(),m=.5*L*d((1-h)/(1+h)),_=i(P*s.lam),f=t(_)<K?D*s.lam:L*l(o*O+c*G,_)):(m=s.phi>0?$:V,f=L*s.phi),W?(r.x=f,r.y=m):(f-=H,r.x=m*q+f*B,r.y=f*q-m*B)},e.inv=function(s,r){var o,a,h,d,_,f,m;W?(a=s.y,o=s.x):(a=s.x*q-s.y*B,o=s.y*q+s.x*B+H),d=.5*((h=p(-R*a))-1/h),_=.5*(h+1/h),f=n(R*o),t(t(m=(f*O+d*G)/_)-1)<N?(r.lam=0,r.phi=m<0?-k:k):(r.phi=T/c((1+m)/(1-m)),(r.phi=yn(u(r.phi,1/P),e.e))==x&&U(),r.lam=-F*l(d*O-f*G,i(R*o)))}},"omerc","Oblique Mercator","Cyl, Sph&Ell no_rot\nalpha= [gamma=] [no_off] lonc= or\nlon_1= lat_1= lon_2= lat_2="),tt(function(e){var s=1e-10,r={};t(t(e.phi0)-k)<=s?r.mode=e.phi0<0?1:0:t(e.phi0)>s?(r.mode=3,r.sinph0=n(e.phi0),r.cosph0=i(e.phi0)):r.mode=2,e.fwd=function(o,a){var h,l,c;switch(l=i(o.phi),h=i(o.lam),r.mode){case 2:l*h<-1e-10&&z(),a.y=n(o.phi);break;case 3:r.sinph0*(c=n(o.phi))+r.cosph0*l*h<-1e-10&&z(),a.y=r.cosph0*c-r.sinph0*l*h;break;case 0:h=-h;case 1:t(o.phi-e.phi0)-s>k&&z(),a.y=l*h}a.x=l*n(o.lam)},e.inv=function(n,i){var h,u,p;if((p=h=_(n.x,n.y))>1&&(p-1>s&&U(),p=1),u=c(1-p*p),t(h)<=s)i.phi=e.phi0,i.lam=0;else{switch(r.mode){case 0:n.y=-n.y,i.phi=a(p);break;case 1:i.phi=-a(p);break;case 2:case 3:2==r.mode?(i.phi=n.y*p/h,n.x*=p,n.y=u*h):(i.phi=u*r.sinph0+n.y*p*r.cosph0/h,n.y=(u-r.sinph0*i.phi)*h,n.x*=p*r.cosph0),t(i.phi)>=1?i.phi=i.phi<0?-k:k:i.phi=o(i.phi)}i.lam=0!=n.y||3!=r.mode&&2!=r.mode?l(n.x,n.y):0==n.x?0:n.x<0?-k:k}},e.es=0},"ortho","Orthographic","Azi, Sph."),tt(function(e){var n=1.0148,i=.23185,s=-.14499,r=.02406,o=n,a=5*i,h=7*s,l=908571831.7;e.es=0,e.fwd=function(t,e){var o=t.phi*t.phi;e.x=t.lam,e.y=t.phi*(n+o*o*(i+o*(s+r*o)))},e.inv=function(e,c){var u,p,d,_;for(u=e.y,e.y>l?e.y=l:e.y<-l&&(e.y=-l),_=100;_&&(u-=p=(u*(n+(d=u*u)*d*(i+d*(s+r*d)))-e.y)/(o+d*d*(a+d*(h+.21654*d))),!(t(p)<1e-11));--_);c.phi=u,c.lam=e.x}},"patterson","Patterson Cylindrical","Cyl., Sph."),tt(function(e){var r,a,h=1e-10,l=1e-12;e.es?(a=Xe(e.es),r=Ze(e.phi0,n(e.phi0),i(e.phi0),a),e.fwd=function(s,o){var l,c,u;t(s.phi)<=h?(o.x=s.lam,o.y=-r):(c=n(s.phi),l=t(u=i(s.phi))>h?We(c,u,e.es)/c:0,o.x=l*n(s.lam*=c),o.y=Ze(s.phi,c,u,a)-r+l*(1-i(s.lam)))},e.inv=function(u,p){var d,_,f,m,y,g,v,x,w,b,C=u.x,S=u.y;if(t(S+=r)<=h)p.lam=C,p.phi=0;else{for(d=S*S+C*C,p.phi=S,b=20;b>0&&(y=(f=n(p.phi))*(m=i(p.phi)),t(m)<l&&U(),_=f*(x=c(1-e.es*f*f))/m,v=(g=Ze(p.phi,f,m,a))*g+d,x=e.one_es/(x*x*x),p.phi+=w=(g+g+_*v-2*S*(_*g+1))/(e.es*y*(v-2*S*g)/_+2*(S-g)*(_*x-1/y)-x-x),!(t(w)<=l));--b);b||U(),_=n(p.phi),p.lam=o(C*s(p.phi)*c(1-e.es*_*_))/n(p.phi)}}):(r=-e.phi0,e.fwd=function(o,a){var l,c;t(o.phi)<=h?(a.x=o.lam,a.y=r):(l=1/s(o.phi),a.x=n(c=o.lam*n(o.phi))*l,a.y=o.phi-e.phi0+l*(1-i(c)))},e.inv=function(i,r){var a,l,c,u;if(t(i.y=e.phi0+i.y)<=h)r.lam=i.x,r.phi=0;else{r.phi=i.y,a=i.x*i.x+i.y*i.y,u=10;do{c=s(r.phi),r.phi-=l=(i.y*(r.phi*c+1)-r.phi-.5*(r.phi*r.phi+a)*c)/((r.phi-i.y)/c-1)}while(t(l)>1e-10&&--u);u||U(),r.lam=o(i.x*s(r.phi))/n(r.phi)}})},"poly","Polyconic (American)","Conic, Sph&Ell"),tt(function(e){var s=1.8949,r=1.71848,o=.6141848493043784,a=1.0471975511965976;e.es=0,e.fwd=function(e,h){var l,c,u,p,d;for(l=o*n(e.phi),u=e.phi*e.phi,e.phi*=.615709+u*(.00909953+.0046292*u),d=10;d&&(c=i(e.phi),u=n(e.phi),e.phi-=p=(e.phi+u*(c-1)-l)/(1+c*(c-1)-u*u),!(t(p)<1e-10));--d);d||(e.phi=e.phi<0?-a:a),h.x=s*e.lam*(i(e.phi)-.5),h.y=r*n(e.phi)},e.inv=function(t,e){var a;e.phi=Ye(t.y/r),e.lam=t.x/(s*((a=i(e.phi))-.5)),e.phi=Ye((e.phi+n(e.phi)*(a-1))/o)}},"putp2","Putnins P2","PCyl., Sph."),tt(bn,"putp3","Putnins P3","PCyl., Sph."),tt(function(t){bn(t,!0)},"putp3p","Putnins P3'","PCyl., Sph."),tt(function(t){Cn(t,.874038744,3.883251825)},"putp4p","Putnins P4'","PCyl., Sph."),tt(function(t){Cn(t,1,4.442882938)},"weren","Werenskiold I","PCyl., Sph."),tt(Sn,"putp5","Putnins P5","PCyl., Sph."),tt(function(t){Sn(t,!0)},"putp5p","Putnins P5'","PCyl., Sph."),tt(An,"putp6","Putnins P6","PCyl., Sph."),tt(function(t){An(t,!0)},"putp6p","Putnins P6'","PCyl., Sph."),tt(function(e){var r,o,u,p;function d(e,n,i){var s,r;return e<1e-10?(s=0,r=0):(r=l(n,i),t(r)<=E?s=0:r>E&&r<=k+E?(s=1,r-=k):r>k+E||r<=-(k+E)?(s=2,r=r>=0?r-b:r+b):(s=3,r+=k)),{area:s,theta:r}}function _(t,e){var n=t+e;return n<-b?n+=I:n>+b&&(n-=I),n}r=e.phi0>=k-E/2?4:e.phi0<=-(k-E/2)?5:t(e.lam0)<=E?0:t(e.lam0)<=k+E?e.lam0>0?1:3:2,0!==e.es&&(e.a,e.a,o=e.a*c(1-e.es),u=1-(e.a-o)/e.a,p=u*u),e.fwd=function(t,o){var l,u,f,m,y,g,v,x,w,C,S,A,M,I;l=0!==e.es?h(p*s(t.phi)):t.phi,u=t.lam,4==r?(m=k-l,u>=E&&u<=k+E?(v=0,f=u-k):u>k+E||u<=-(k+E)?(v=1,f=u>0?u-b:u+b):u>-(k+E)&&u<=-E?(v=2,f=u+k):(v=3,f=u)):5==r?(m=k+l,u>=E&&u<=k+E?(v=0,f=-u+k):u<E&&u>=-E?(v=1,f=-u):u<-E&&u>=-(k+E)?(v=2,f=-u-k):(v=3,f=u>0?-u+b:-u-b)):(1==r?u=_(u,+k):2==r?u=_(u,+b):3==r&&(u=_(u,-k)),S=n(l),A=i(l),M=n(u),x=A*i(u),w=A*M,C=S,0==r?I=d(m=a(x),C,w):1==r?I=d(m=a(w),C,-x):2==r?I=d(m=a(-x),C,-w):3==r?I=d(m=a(-w),C,x):(m=0,I={area:0,theta:0}),f=I.theta,v=I.area),g=h(12/b*(f+a(n(f)*i(E))-k)),y=c((1-i(m))/(i(g)*i(g))/(1-i(h(1/i(f))))),1==v?g+=k:2==v?g+=b:3==v&&(g+=D),o.x=y*i(g),o.y=y*n(g)},e.inv=function(d,f){var m,y,g,v,x,w,C,S,A,M,E,D,I;if(y=h(c(d.x*d.x+d.y*d.y)),m=l(d.y,d.x),d.x>=0&&d.x>=t(d.y)?M=0:d.y>=0&&d.y>=t(d.x)?(M=1,m-=k):d.x<0&&-d.x>=t(d.y)?(M=2,m=m<0?m+b:m-b):(M=3,m+=k),A=b/12*s(m),x=n(A)/(i(A)-1/c(2)),w=h(x),(C=1-(g=i(m))*g*(v=s(y))*v*(1-i(h(1/i(w)))))<-1?C=-1:C>1&&(C=1),4==r)S=a(C),f.phi=k-S,f.lam=0==M?w+k:1==M?w<0?w+b:w-b:2==M?w-k:w;else if(5==r)S=a(C),f.phi=S-k,f.lam=0==M?-w+k:1==M?-w:2==M?-w-k:w<0?-w-b:-w+b;else{var P,T,L;A=(P=C)*P,T=(A+=(L=A>=1?0:c(1-A)*n(w))*L)>=1?0:c(1-A),1==M?(A=T,T=-L,L=A):2==M?(T=-T,L=-L):3==M&&(A=T,T=L,L=-A),1==r?(A=P,P=-T,T=A):2==r?(P=-P,T=-T):3==r&&(A=P,P=T,T=-A),f.phi=a(-L)-k,f.lam=l(T,P),1==r?f.lam=_(f.lam,-k):2==r?f.lam=_(f.lam,-b):3==r&&(f.lam=_(f.lam,+k))}0!==e.es&&(E=f.phi<0?1:0,D=s(f.phi),I=o/c(D*D+p),f.phi=h(c(e.a*e.a-I*I)/(u*I)),E&&(f.phi=-f.phi))}},"qsc","Quadrilateralized Spherical Cube","Azi, Sph."),tt(function(n){var i=l([[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-9.86701e-7],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,1.8736e-8],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,9.34959e-7],[.7986,-.00755338,-500009e-10,9.35324e-7],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]]),s=l([[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-1.26793e-9,4.22642e-10],[.124,.0124,5.07171e-9,-1.60604e-9],[.186,.0123999,-1.90189e-8,6.00152e-9],[.248,.0124002,7.10039e-8,-2.24e-8],[.31,.0123992,-2.64997e-7,8.35986e-8],[.372,.0124029,9.88983e-7,-3.11994e-7],[.434,.0123893,-369093e-11,-4.35621e-7],[.4958,.0123198,-102252e-10,-3.45523e-7],[.5571,.0121916,-154081e-10,-5.82288e-7],[.6176,.0119938,-241424e-10,-5.25327e-7],[.6769,.011713,-320223e-10,-5.16405e-7],[.7346,.0113541,-397684e-10,-6.09052e-7],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-1.40374e-9],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]]),r=.8487,o=1.3523;function a(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))}function h(t,e){return t[1]+e*(t[2]+t[2]+3*e*t[3])}function l(t){return t.map(function(t){return new Float32Array(t)})}n.es=0,n.fwd=function(n,h){var l,c;(l=e(11.459155902616464*(c=t(n.phi))))<0&&z(),l>=18&&(l=17),c=C*(c-.08726646259971647*l),h.x=a(i[l],c)*r*n.lam,h.y=a(s[l],c)*o,n.phi<0&&(h.y=-h.y)},n.inv=function(n,l){var c,u,p,d;if(l.lam=n.x/r,l.phi=t(n.y/o),l.phi>=1)l.phi>1.000001?U():(l.phi=n.y<0?-k:k,l.lam/=i[18][0]);else{if((d=e(18*l.phi))<0||d>=18)return U();for(;;)if(s[d][0]>l.phi)--d;else{if(!(s[d+1][0]<=l.phi))break;++d}for(p=new Float32Array(s[d]),c=5*(l.phi-p[0])/(s[d+1][0]-p[0]),p[0]-=l.phi;c-=u=a(p,c)/h(p,c),!(t(u)<1e-8););l.phi=(5*d+c)*S,n.y<0&&(l.phi=-l.phi),l.lam/=a(i[d],c)}}},"robin","Robinson","PCyl., Sph."),tt(Mn("EULER"),"euler","Euler","Conic, Sph\nlat_1= and lat_2="),tt(Mn("MURD1"),"murd1","Murdoch I","Conic, Sph\nlat_1= and lat_2="),tt(Mn("MURD2"),"murd2","Murdoch II","Conic, Sph\nlat_1= and lat_2="),tt(Mn("MURD3"),"murd3","Murdoch III","Conic, Sph\nlat_1= and lat_2="),tt(Mn("PCONIC"),"pconic","Perspective Conic","Conic, Sph\nlat_1= and lat_2="),tt(Mn("TISSOT"),"tissot","Tissot","Conic, Sph\nlat_1= and lat_2="),tt(Mn("VITK1"),"vitk1","Vitkovsky I","Conic, Sph\nlat_1= and lat_2="),tt(function(e){var r,o,a,l,u,_,f,m,y;a=.5*e.e,f=i(e.phi0),f*=f,o=c(1+e.es*f*f*e.rone_es),y=n(e.phi0),u=i(m=Ye(_=y/o)),y*=e.e,r=d(s(E+.5*m))-o*(d(s(E+.5*e.phi0))-a*d((1+y)/(1-y))),l=e.k0*c(e.one_es)/(1-y*y),e.inv=function(c,f){var m,y,g,v,x,w,b,C,S;for(g=2*(h(p(c.y/l))-E),v=c.x/l,x=i(g),m=Ye(u*n(g)+_*x*i(v)),y=Ye(x*n(v)/i(m)),b=(r-d(s(E+.5*m)))/o,S=6;S&&(w=e.e*n(m),m-=C=(b+d(s(E+.5*m))-a*d((1+w)/(1-w)))*(1-w*w)*i(m)*e.rone_es,!(t(C)<1e-10));--S);S?(f.phi=m,f.lam=y/o):U()},e.fwd=function(t,c){var f,m,y,g,v,x;v=e.e*n(t.phi),f=2*h(p(o*(d(s(E+.5*t.phi))-a*d((1+v)/(1-v)))+r))-k,m=o*t.lam,x=i(f),y=Ye(u*n(f)-_*x*i(m)),g=Ye(x*n(m)/i(y)),c.x=l*g,c.y=l*d(s(E+.5*y))}},"somerc","Swiss. Obl. Mercator","Cyl, Ell\nFor CH1903"),tt(function(t){var e=Z(t.params,"tlat_ts")?Z(t.params,"rlat_ts"):k;En(t,e)},"stere","Stereographic","Azi, Sph&Ell\nlat_ts="),tt(function(t){t.phi0=Z(t.params,"bsouth")?-k:k,t.k0=.994,t.x0=2e6,t.y0=2e6,t.lam0=0,t.es||j(-34),En(t,k)},"ups","Universal Polar Stereographic","Azi, Sph&Ell\nsouth"),tt(function(e){var r,a,p,d,f,m,y,g,v,x=(r=e.e,a=e.phi0,p=r*r,d=n(a),f=i(a),m=c(1-p)/(1-p*d*d),y=c(1+p*f*f*f*f/(1-p)),g=o(d/y),v=.5*y*r,{e:r,K:s(.5*g+E)/(u(s(.5*a+E),y)*kn(r*d,v)),C:y,chi:g,ratexp:v,rc:m}),w=x.chi,b=2*x.rc,C=n(w),S=i(w);e.fwd=function(t,r){var o,a,l,c;t=function(t,e){return{phi:2*h(e.K*u(s(.5*t.phi+E),e.C)*kn(e.e*n(t.phi),e.ratexp))-k,lam:e.C*t.lam}}(t,x),a=n(t.phi),o=i(t.phi),l=i(t.lam),c=e.k0*b/(1+C*a+S*o*l),r.x=c*o*n(t.lam),r.y=c*(S*a-C*o*l)},e.inv=function(r,a){var c,p,d,f,m=r.x/e.k0,y=r.y/e.k0;(c=_(m,y))?(p=2*l(c,b),d=n(p),f=i(p),a.phi=o(f*C+y*d*S/c),a.lam=l(m*d,c*S*f-y*C*d)):(a.phi=w,a.lam=0),function(e,i){e.phi;var r,o,a=u(s(.5*e.phi+E)/i.K,1/i.C);for(e.lam/=i.C,r=20;r>0&&(o=2*h(a*kn(i.e*n(e.phi),-.5*i.e))-k,!(t(o-e.phi)<1e-14));--r)e.phi=o;r||B(-17)}(a,x)}},"sterea","Oblique Stereographic Alternative","Azimuthal, Sph&Ell"),tt(function(t){Dn(t,1.50488,1.35439,!1)},"kav5","Kavraisky V","PCyl., Sph."),tt(function(t){Dn(t,2,2,!1)},"qua_aut","Quartic Authalic","PCyl., Sph."),tt(function(t){Dn(t,2,2,!0)},"fouc","Foucaut","PCyl., Sph."),tt(function(t){Dn(t,1.48875,1.36509,!1)},"mbt_s","McBryde-Thomas Flat-Polar Sine (No. 1)","PCyl., Sph."),tt(function(t){t.es=0,t.fwd=function(e,r){r.x=i(e.phi)*n(e.lam)/t.k0,r.y=t.k0*(l(s(e.phi),i(e.lam))-t.phi0)},t.inv=function(e,s){var r;e.y=e.y/t.k0+t.phi0,e.x*=t.k0,r=c(1-e.x*e.x),s.phi=o(r*n(e.y)),s.lam=l(e.x,r*i(e.y))}},"tcea","Transverse Cylindrical Equal Area","Cyl, Sph"),tt(function(t){t.es=0,t.fwd=function(t,e){var i=s(t.phi/2),r=n(E*i);e.x=t.lam*(.74482-.34588*r*r),e.y=1.70711*i},t.inv=function(t,e){var i=t.y/1.70711,s=n(E*i);e.lam=t.x/(.74482-.34588*s*s),e.phi=2*h(i)}},"times","Times","Cyl, Sph"),tt(function(e){Z(e.params,"bapprox")?In(e):function(e){if(0===e.es)return In(e);hn(e);var n=e.fwd,i=e.inv;In(e);var s=e.fwd,r=e.inv;e.fwd=function(e,i){t(e.lam)>3*S?n(e,i):s(e,i)},e.inv=function(e,n){t(e.x)>.053-.022*e.y*e.y?i(e,n):r(e,n)}}(e)},"tmerc","Transverse Mercator","Cyl, Sph&Ell"),tt(function(t){var n;t.es||j(-34),t.y0=Z(t.params,"bsouth")?1e7:0,t.x0=5e5,Z(t.params,"tzone")?(n=Z(t.params,"izone"))>0&&n<=60?--n:j(-35):(n=e(30*(Et(t.lam0)+b)/b))<0?n=0:n>=60&&(n=59),t.lam0=(n+.5)*b/30-b,t.k0=.9996,t.phi0=0,hn(t)},"utm","Universal Transverse Mercator (UTM)","Cyl, Sph\nzone= south"),tt(function(t){var e,r,o,a,h,c,u,p,d,f,m,y,g,v,x,w,b,C,S,A,M,E,D;A=Z(t.params,"rlat_1"),C=Z(t.params,"rlon_1"),M=Z(t.params,"rlat_2"),S=Z(t.params,"rlon_2"),A==M&&C==S&&j(-25),t.lam0=Et(.5*(C+S)),f=Et(S-C),e=i(A),o=i(M),r=n(A),a=n(M),c=e*a,u=r*o,h=e*o*n(f),d=Qe(r*a+e*o*i(f)),m=.5*d,E=l(o*n(f),e*a-r*o*i(f)),v=i(D=Ye(e*n(E))),x=n(D),w=Et(l(e*i(E),r)-m),f*=.5,b=k-l(n(E)*r,i(E))-f,y=s(m),g=.5/n(m),p=.5/d,d*=d,t.fwd=function(t,s){var l,_,m,y,g,v,x;v=n(t.phi),x=i(t.phi),_=Qe(r*v+e*x*i(y=t.lam+f)),m=Qe(a*v+o*x*i(g=t.lam-f)),_*=_,m*=m,s.x=p*(l=_-m),l=d-l,s.y=p*tn(4*d*m-l*l),h*v-x*(c*n(y)-u*n(g))<0&&(s.y=-s.y)},t.inv=function(t,e){var s,r,o,a,h,c;o=(s=i(_(t.y,t.x+m)))+(r=i(_(t.y,t.x-m))),a=s-r,e.lam=-l(a,o*y),e.phi=Qe(_(y*o,a)*g),t.y<0&&(e.phi=-e.phi),c=n(e.phi),h=i(e.phi),e.phi=Ye(x*c+v*h*(o=i(e.lam-=w))),e.lam=l(h*n(e.lam),x*h*o-v*c)+b},t.es=0},"tpeqd","Two Point Equidistant","Misc Sph\nlat_1= lon_1= lat_2= lon_2="),tt(function(t){var e,s,r,o,a,h;(o=Z(t.params,"dn"))>0&&o<=1==0&&j(-40),r=Z(t.params,"dq")/3,a=Z(t.params,"ralpha"),h=o*n(a),e=i(a)/c(1-h*h),s=1/(e*o),t.fwd=function(t,a){var h=t.phi=Ye(o*n(t.phi));a.x=e*t.lam*i(t.phi),h*=h,a.y=t.phi*(1+h*r)*s},t.es=0},"urm5","Urmaev V","PCyl., Sph., no inv.\nn= q= alpha="),tt(function(t){var e=Z(t.params,"dn");(e<=0||e>1)&&j(-40),Pn(t,e)},"urmfps","Urmaev Flat-Polar Sinusoidal","PCyl, Sph.\nn="),tt(function(t){Pn(t,.8660254037844386)},"wag1","Wagner I (Kavraisky VI)","PCyl, Sph."),tt(function(e){var n=1e-10,r=.3333333333333333,h=9.869604401089358,l=19.739208802178716,u=4.934802200544679;e.fwd=function(e,i){var r,a,h,l,u;(u=t(e.phi/k))-n>1&&z(),u>1&&(u=1),t(e.phi)<=n?(i.x=e.lam,i.y=0):t(e.lam)<=n||t(u-1)<n?(i.x=0,i.y=b*s(.5*o(u)),e.phi<0&&(i.y=-i.y)):(a=(r=.5*t(b/e.lam-e.lam/b))*r,h=c(1-u*u),l=(h/=u+h-1)*h,u=h*(2/u-1),u*=u,i.x=h-u,h=u+a,i.x=b*(r*i.x+c(a*i.x*i.x-h*(l-u)))/h,e.lam<0&&(i.x=-i.x),i.y=t(i.x/b),i.y=1-i.y*(i.y+2*r),i.y<-n&&z(),i.y<0?i.y=0:i.y=c(i.y)*(e.phi<0?-b:b))},e.inv=function(e,s){var o,p,d,_,f,m,y,g,v,x,w,C,S;if(C=e.x*e.x,(w=t(e.y))<n)return s.phi=0,o=C*C+l*(C+u),s.lam=t(e.x)<=n?0:.5*(C-h+c(o))/e.x,s;S=e.y*e.y,_=(d=-b*w*((g=C+S)+h))+h*(g-3*S),p=b*w,v=2*c(-r*(m=d/(f=(y=g*g)+I*(w*g+b*(S+b*(w+k))))-r*(_/=f)*_)),(o=t(x=3*(x=.07407407407407407*_*_*_+(p*p-r*_*d)/f)/(m*v)))-n<=1?(x=o>1?x>0?0:b:a(x),s.phi=b*(v*i(x*r+4.188790204786391)-r*_),e.y<0&&(s.phi=-s.phi),o=y+l*(C-S+u),s.lam=t(e.x)<=n?0:.5*(g-h+(o<=0?0:c(o)))/e.x):U()}},"vandg","van der Grinten (I)","Misc Sph"),tt(function(t){Tn(t,!1)},"vandg2","van der Grinten II","Misc Sph, no inv."),tt(function(t){Tn(t,!0)},"vandg3","van der Grinten III","Misc Sph, no inv."),tt(function(e){e.es=0,e.fwd=function(e,n){var i,s,r,o,a,h,l,u,p=1e-10;t(e.phi)<p?(n.x=e.lam,n.y=0):t(e.lam)<p||t(t(e.phi)-k)<p?(n.x=0,n.y=e.phi):(h=(o=.5*((r=t(P*e.phi))*(8-r*(2+(a=r*r)))-5)/(a*(r-1)))*o,l=P*e.lam,l=c((l+=1/l)*l-4),t(e.lam)-k<0&&(l=-l),i=r+o,i=(l*((i*=i)+h-1)+2*c(i*(a+h*(u=l*l)-1)+(1-a)*(a*((s=r+3*o)*s+4*h)+h*(12*r*o+4*h))))/(4*i+u),n.x=k*i,n.y=k*c(1+l*t(i)-i*i),e.lam<0&&(n.x=-n.x),e.phi<0&&(n.y=-n.y))}},"vandg4","van der Grinten IV","Misc Sph, no inv."),tt(function(t){var e=.92483,s=1.38725,r=.88022,o=.8855;t.fwd=function(t,a){t.phi=Ye(r*n(o*t.phi)),a.x=e*t.lam*i(t.phi),a.y=s*t.phi},t.inv=function(t,a){a.phi=t.y/s,a.lam=t.x/(e*i(a.phi)),a.phi=Ye(n(a.phi)/r)/o}},"wag2","Wagner II","PCyl., Sph."),tt(function(t){var e=.6666666666666666,n=Z(t.params,"rlat_ts"),s=i(n)/i(2*n/3);t.es=0,t.fwd=function(t,n){n.x=s*t.lam*i(e*t.phi),n.y=t.phi},t.inv=function(t,n){n.phi=t.y,n.lam=t.x/(s*i(e*n.phi))}},"wag3","Wagner III","PCyl., Sph.\nlat_ts="),tt(function(t){t.es=0,t.fwd=function(t,e){var s,r,a;s=o(e.y=.9063077870366499*n(t.phi)),e.x=2.66723*(r=i(s))*n(t.lam/=3),e.y*=1.24104*(a=1/c(.5*(1+r*i(t.lam)))),e.x*=a}},"wag7","Wagner VII","Misc Sph, no inv."),tt(function(t){var e=i(Z(t.params,"rlat_ts"));t.fwd=function(t,n){n.x=.5*t.lam*(e+i(t.phi)),n.y=t.phi},t.inv=function(t,n){n.phi=t.y,n.lam=2*t.x/(e+i(n.phi))},t.es=0},"wink1","Winkel I","PCyl., Sph.\nlat_ts="),tt(function(e){var s=i(Z(e.params,"rlat_1"));e.fwd=function(e,r){var o,a,h,l=e.phi;for(r.y=l*P,o=b*n(l),l*=1.8,h=10;h&&(l-=a=(l+n(l)-o)/(1+i(l)),!(t(a)<1e-7));--h);h?l*=.5:l=l<0?-k:k,r.x=.5*e.lam*(i(l)+s),r.y=E*(n(l)+r.y)},e.inv=null,e.es=0},"wink2","Winkel II","PCyl., Sph., no inv.\nlat_1=");var Ln=Pt;Ln.pj_init=mt,Ln.pj_fwd=kt,Ln.pj_inv=Dt,Ln.pj_transform=Ct,Ln.pj_add=tt,Ln.pj_fwd_deg=function(t,e){return kt({lam:t.lam*S,phi:t.phi*S},e)},Ln.pj_inv_deg=function(t,e){var n=Dt(t,e);return{lam:n.lam*C,phi:n.phi*C}},Ln.pj_transform_point=bt,Ln.internal={dmstod:W,dmstor:H,get_rtodms:function(t,e,n,i){var s=It(t,e,n,i);return function(t){return s(t*C)}},get_dtodms:It,get_proj_defn:it,pj_latlong_from_proj:function(t){return mt("+proj=latlong"+nt(t))},pj_get_params:J,pj_datums:rt,pj_list:Q,pj_ellps:ht,pj_units:ct,pj_read_init_opts:ft,find_datum:at,DEG_TO_RAD:S,RAD_TO_DEG:C,wkt_parse:Be,wkt_unpack:ze,convert_wkt_quotes:Ue,wkt_to_proj4:function(t){var e,n,i=Be(t);return i.PROJCS?e=Ot(n=i.PROJCS)(n):i.GEOGCS?e="+proj=longlat "+Wt(i.GEOGCS):i.GEOCCS?$t("geocentric coordinates are not supported"):$t("missing a supported WKT CS type"),e},wkt_from_proj4:function(t){return t.length&&(t=mt(t)),Fe(et(t)?{GEOGCS:Yt(t)}:re(t))},wkt_make_projcs:re,wkt_get_geogcs_name:ee,wkt_stringify:Fe,mproj_insert_libcache:function(t,e){dt[t]=e},mproj_search_libcache:_t,GeographicLib:Ve},v.exports=Ln}();var b=s.exports,C=e({__proto__:null,default:n(b)},[b]);class S{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(t,e){let n=this.length++;for(;n>0;){const t=n-1>>1,i=this.values[t];if(e>=i)break;this.ids[n]=this.ids[t],this.values[n]=i,n=t}this.ids[n]=t,this.values[n]=e}pop(){if(0===this.length)return;const t=this.ids,e=this.values,n=t[0],i=--this.length;if(i>0){const n=t[i],s=e[i];let r=0;const o=i>>1;for(;r<o;){const n=1+(r<<1),o=n+1,a=n+(+(o<i)&+(e[o]<e[n]));if(e[a]>=s)break;t[r]=t[a],e[r]=e[a],r=a}t[r]=n,e[r]=s}return n}peek(){return this.length>0?this.ids[0]:void 0}peekValue(){return this.length>0?this.values[0]:void 0}shrink(){this.ids.length=this.values.length=this.length}}const A=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class M{static from(t,e=0){if(e%8!=0)throw new Error("byteOffset must be 8-byte aligned.");if(!t||void 0===t.byteLength||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[n,i]=new Uint8Array(t,e+0,2);if(251!==n)throw new Error("Data does not appear to be in a Flatbush format.");const s=i>>4;if(3!==s)throw new Error(`Got v${s} data when expected v3.`);const r=A[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,e+2,1),[a]=new Uint32Array(t,e+4,1);return new M(a,o,r,void 0,t,e)}constructor(t,e=16,n=Float64Array,i=ArrayBuffer,s,r=0){if(void 0===t)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.byteOffset=r;let o=t,a=o;this._levelBounds=[4*o];do{o=Math.ceil(o/this.nodeSize),a+=o,this._levelBounds.push(4*a)}while(1!==o);this.ArrayType=n,this.IndexArrayType=a<16384?Uint16Array:Uint32Array;const h=A.indexOf(n),l=4*a*n.BYTES_PER_ELEMENT;if(h<0)throw new Error(`Unexpected typed array class: ${n}.`);if(s)this.data=s,this._boxes=new n(s,r+8,4*a),this._indices=new this.IndexArrayType(s,r+8+l,a),this._pos=4*a,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1];else{const s=this.data=new i(8+l+a*this.IndexArrayType.BYTES_PER_ELEMENT);this._boxes=new n(s,8,4*a),this._indices=new this.IndexArrayType(s,8+l,a),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(s,0,2).set([251,48+h]),new Uint16Array(s,2,1)[0]=e,new Uint32Array(s,4,1)[0]=t}this._queue=new S}add(t,e,n=t,i=e){const s=this._pos>>2,r=this._boxes;return this._indices[s]=s,r[this._pos++]=t,r[this._pos++]=e,r[this._pos++]=n,r[this._pos++]=i,t<this.minX&&(this.minX=t),e<this.minY&&(this.minY=e),n>this.maxX&&(this.maxX=n),i>this.maxY&&(this.maxY=i),s}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);const t=this._boxes;if(this.numItems<=this.nodeSize)return t[this._pos++]=this.minX,t[this._pos++]=this.minY,t[this._pos++]=this.maxX,void(t[this._pos++]=this.maxY);const e=this.maxX-this.minX||1,n=this.maxY-this.minY||1,i=new Uint32Array(this.numItems);for(let s=0,r=0;s<this.numItems;s++){const o=t[r++],a=t[r++],h=t[r++],l=t[r++],c=Math.floor(65535*((o+h)/2-this.minX)/e),u=Math.floor(65535*((a+l)/2-this.minY)/n);i[s]=I(c,u)}k(i,t,this._indices,0,this.numItems-1,this.nodeSize);for(let e=0,n=0;e<this._levelBounds.length-1;e++){const i=this._levelBounds[e];for(;n<i;){const e=n;let s=t[n++],r=t[n++],o=t[n++],a=t[n++];for(let e=1;e<this.nodeSize&&n<i;e++)s=Math.min(s,t[n++]),r=Math.min(r,t[n++]),o=Math.max(o,t[n++]),a=Math.max(a,t[n++]);this._indices[this._pos>>2]=e,t[this._pos++]=s,t[this._pos++]=r,t[this._pos++]=o,t[this._pos++]=a}}}search(t,e,n,i,s){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let r=this._boxes.length-4;const o=[],a=[];for(;void 0!==r;){const h=Math.min(r+4*this.nodeSize,E(r,this._levelBounds));for(let l=r;l<h;l+=4){const h=this._boxes[l];if(n<h)continue;const c=this._boxes[l+1];if(i<c)continue;const u=this._boxes[l+2];if(t>u)continue;const p=this._boxes[l+3];if(e>p)continue;const d=0|this._indices[l>>2];r>=4*this.numItems?o.push(d):(void 0===s||s(d,h,c,u,p))&&a.push(d)}r=o.pop()}return a}neighbors(t,e,n=1/0,i=1/0,s){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let r=this._boxes.length-4;const o=this._queue,a=[],h=i*i;t:for(;void 0!==r;){const i=Math.min(r+4*this.nodeSize,E(r,this._levelBounds));for(let n=r;n<i;n+=4){const i=0|this._indices[n>>2],a=this._boxes[n],l=this._boxes[n+1],c=this._boxes[n+2],u=this._boxes[n+3],p=t<a?a-t:t>c?t-c:0,d=e<l?l-e:e>u?e-u:0,_=p*p+d*d;_>h||(r>=4*this.numItems?o.push(i<<1,_):(void 0===s||s(i))&&o.push(1+(i<<1),_))}for(;o.length&&1&o.peek();){if(o.peekValue()>h)break t;if(a.push(o.pop()>>1),a.length===n)break t}r=o.length?o.pop()>>1:void 0}return o.clear(),a}}function E(t,e){let n=0,i=e.length-1;for(;n<i;){const s=n+i>>1;e[s]>t?i=s:n=s+1}return e[n]}function k(t,e,n,i,s,r){if(Math.floor(i/r)>=Math.floor(s/r))return;const o=t[i],a=t[i+s>>1],h=t[s];let l=h;const c=Math.max(o,a);h>c?l=c:c===o?l=Math.max(a,h):c===a&&(l=Math.max(o,h));let u=i-1,p=s+1;for(;;){do{u++}while(t[u]<l);do{p--}while(t[p]>l);if(u>=p)break;D(t,e,n,u,p)}k(t,e,n,i,p,r),k(t,e,n,p+1,s,r)}function D(t,e,n,i,s){const r=t[i];t[i]=t[s],t[s]=r;const o=4*i,a=4*s,h=e[o],l=e[o+1],c=e[o+2],u=e[o+3];e[o]=e[a],e[o+1]=e[a+1],e[o+2]=e[a+2],e[o+3]=e[a+3],e[a]=h,e[a+1]=l,e[a+2]=c,e[a+3]=u;const p=n[i];n[i]=n[s],n[s]=p}function I(t,e){let n=t^e,i=65535^n,s=65535^(t|e),r=t&(65535^e),o=n|i>>1,a=n>>1^n,h=s>>1^i&r>>1^s,l=n&s>>1^r>>1^r;n=o,i=a,s=h,r=l,o=n&n>>2^i&i>>2,a=n&i>>2^i&(n^i)>>2,h^=n&s>>2^i&r>>2,l^=i&s>>2^(n^i)&r>>2,n=o,i=a,s=h,r=l,o=n&n>>4^i&i>>4,a=n&i>>4^i&(n^i)>>4,h^=n&s>>4^i&r>>4,l^=i&s>>4^(n^i)&r>>4,n=o,i=a,s=h,r=l,h^=n&s>>8^i&r>>8,l^=i&s>>8^(n^i)&r>>8,n=h^h>>1,i=l^l>>1;let c=t^e,u=i|65535^(c|n);return c=16711935&(c|c<<8),c=252645135&(c|c<<4),c=858993459&(c|c<<2),c=1431655765&(c|c<<1),u=16711935&(u|u<<8),u=252645135&(u|u<<4),u=858993459&(u|u<<2),u=1431655765&(u|u<<1),(u<<1|c)>>>0}const P=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class T{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,n]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const i=n>>4;if(1!==i)throw new Error(`Got v${i} data when expected v1.`);const s=P[15&n];if(!s)throw new Error("Unrecognized array type.");const[r]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new T(o,r,s,t)}constructor(t,e=64,n=Float64Array,i){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=n,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=P.indexOf(this.ArrayType),r=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${n}.`);i&&i instanceof ArrayBuffer?(this.data=i,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+r+o+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=t,this.coords[this._pos++]=e,n}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return L(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,n,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:r,nodeSize:o}=this,a=[0,s.length-1,0],h=[];for(;a.length;){const l=a.pop()||0,c=a.pop()||0,u=a.pop()||0;if(c-u<=o){for(let o=u;o<=c;o++){const a=r[2*o],l=r[2*o+1];a>=t&&a<=n&&l>=e&&l<=i&&h.push(s[o])}continue}const p=u+c>>1,d=r[2*p],_=r[2*p+1];d>=t&&d<=n&&_>=e&&_<=i&&h.push(s[p]),(0===l?t<=d:e<=_)&&(a.push(u),a.push(p-1),a.push(1-l)),(0===l?n>=d:i>=_)&&(a.push(p+1),a.push(c),a.push(1-l))}return h}within(t,e,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:r}=this,o=[0,i.length-1,0],a=[],h=n*n;for(;o.length;){const l=o.pop()||0,c=o.pop()||0,u=o.pop()||0;if(c-u<=r){for(let n=u;n<=c;n++)G(s[2*n],s[2*n+1],t,e)<=h&&a.push(i[n]);continue}const p=u+c>>1,d=s[2*p],_=s[2*p+1];G(d,_,t,e)<=h&&a.push(i[p]),(0===l?t-n<=d:e-n<=_)&&(o.push(u),o.push(p-1),o.push(1-l)),(0===l?t+n>=d:e+n>=_)&&(o.push(p+1),o.push(c),o.push(1-l))}return a}}function L(t,e,n,i,s,r){if(s-i<=n)return;const o=i+s>>1;N(t,e,o,i,s,r),L(t,e,n,i,o-1,1-r),L(t,e,n,o+1,s,1-r)}function N(t,e,n,i,s,r){for(;s>i;){if(s-i>600){const o=s-i+1,a=n-i+1,h=Math.log(o),l=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*l*(o-l)/o)*(a-o/2<0?-1:1);N(t,e,n,Math.max(i,Math.floor(n-a*l/o+c)),Math.min(s,Math.floor(n+(o-a)*l/o+c)),r)}const o=e[2*n+r];let a=i,h=s;for(R(t,e,i,n),e[2*s+r]>o&&R(t,e,i,s);a<h;){for(R(t,e,a,h),a++,h--;e[2*a+r]<o;)a++;for(;e[2*h+r]>o;)h--}e[2*i+r]===o?R(t,e,i,h):(h++,R(t,e,h,s)),h<=n&&(i=h+1),n<=h&&(s=h-1)}}function R(t,e,n,i){F(t,n,i),F(e,2*n,2*i),F(e,2*n+1,2*i+1)}function F(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function G(t,e,n,i){const s=t-n,r=e-i;return s*s+r*r}var O={exports:{}};!function(t){var e,n,i,s;(s={}).Constants={},s.Math={},s.Accumulator={},(e=s.Constants).WGS84={a:6378137,f:1/298.257223563},e.version={major:2,minor:2,patch:0},e.version_string="2.2.0",(n=s.Math).digits=53,n.epsilon=Math.pow(.5,n.digits-1),n.degree=Math.PI/180,n.sq=function(t){return t*t},n.hypot=function(t,e){return Math.sqrt(t*t+e*e)},n.cbrt=Math.cbrt||function(t){var e=Math.pow(Math.abs(t),1/3);return t>0?e:t<0?-e:t},n.log1p=Math.log1p||function(t){var e=1+t,n=e-1;return 0===n?t:t*Math.log(e)/n},n.atanh=Math.atanh||function(t){var e=Math.abs(t);return e=n.log1p(2*e/(1-e))/2,t>0?e:t<0?-e:t},n.copysign=function(t,e){return Math.abs(t)*(e<0||0===e&&1/e<0?-1:1)},n.sum=function(t,e){var n=t+e,i=n-e,s=n-i;return i-=t,{s:n,t:n?0-(i+(s-=e)):n}},n.polyval=function(t,e,n,i){for(var s=t<0?0:e[n++];--t>=0;)s=s*i+e[n++];return s},n.AngRound=function(t){var e=1/16,i=Math.abs(t);return i=i<e?e-(e-i):i,n.copysign(i,t)},n.remainder=function(t,e){return(t%=e)<-e/2?t+e:t<e/2?t:t-e},n.AngNormalize=function(t){var e=n.remainder(t,360);return 180===Math.abs(e)?n.copysign(180,t):e},n.LatFix=function(t){return Math.abs(t)>90?NaN:t},n.AngDiff=function(t,e){var i,s,r=n.sum(n.remainder(-t,360),n.remainder(e,360));return i=(r=n.sum(n.remainder(r.s,360),r.t)).s,s=r.t,0!==i&&180!==Math.abs(i)||(i=n.copysign(i,0===s?e-t:-s)),{d:i,e:s}},n.sincosd=function(t){var e,i,s,r,o,a,h;switch(e=t%360,i=(e-=90*(s=Math.round(e/90)))*this.degree,r=Math.sin(i),o=Math.cos(i),45===Math.abs(e)?(o=Math.sqrt(.5),r=n.copysign(o,i)):30===Math.abs(e)&&(o=Math.sqrt(.75),r=n.copysign(.5,i)),3&s){case 0:a=r,h=o;break;case 1:a=o,h=-r;break;case 2:a=-r,h=-o;break;default:a=-o,h=r}return h+=0,0===a&&(a=n.copysign(a,t)),{s:a,c:h}},n.sincosde=function(t,e){var i,s,r,o,a,h,l;switch(i=t%360,r=Math.round(i/90),s=(i=n.AngRound(i-90*r+e))*this.degree,o=Math.sin(s),a=Math.cos(s),45===Math.abs(i)?(a=Math.sqrt(.5),o=n.copysign(a,s)):30===Math.abs(i)&&(a=Math.sqrt(.75),o=n.copysign(.5,s)),3&r){case 0:h=o,l=a;break;case 1:h=a,l=-o;break;case 2:h=-o,l=-a;break;default:h=-a,l=o}return l+=0,0===h&&(h=n.copysign(h,t+e)),{s:h,c:l}},n.atan2d=function(t,e){var i,s=0;switch(Math.abs(t)>Math.abs(e)&&([t,e]=[e,t],s=2),n.copysign(1,e)<0&&(e=-e,++s),i=Math.atan2(t,e)/this.degree,s){case 1:i=n.copysign(180,t)-i;break;case 2:i=90-i;break;case 3:i=-90+i}return i},function(t,e){t.Accumulator=function(t){this.Set(t)},t.Accumulator.prototype.Set=function(e){e||(e=0),e.constructor===t.Accumulator?(this._s=e._s,this._t=e._t):(this._s=e,this._t=0)},t.Accumulator.prototype.Add=function(t){var n=e.sum(t,this._t),i=e.sum(n.s,this._s);n=n.t,this._s=i.s,this._t=i.t,0===this._s?this._s=n:this._t+=n},t.Accumulator.prototype.Sum=function(e){var n;return e?((n=new t.Accumulator(this)).Add(e),n._s):this._s},t.Accumulator.prototype.Negate=function(){this._s*=-1,this._t*=-1},t.Accumulator.prototype.Remainder=function(t){this._s=e.remainder(this._s,t),this.Add(0)}}(s.Accumulator,s.Math),s.Geodesic={},s.GeodesicLine={},s.PolygonArea={},function(t,e,n,i,s){var r,o,a,h,l,c,u,p,d,_,f,m=20+i.digits+10,y=i.epsilon,g=200*y,v=Math.sqrt(y),x=y,w=1e3*v;t.tiny_=Math.sqrt(Number.MIN_VALUE/Number.EPSILON),t.nC1_=6,t.nC1p_=6,t.nC2_=6,t.nC3_=6,t.nC4_=6,r=t.nC3_*(t.nC3_-1)/2,o=t.nC4_*(t.nC4_+1)/2,t.CAP_C1=1,t.CAP_C1p=2,t.CAP_C2=4,t.CAP_C3=8,t.CAP_C4=16,t.NONE=0,t.ARC=64,t.LATITUDE=128,t.LONGITUDE=256|t.CAP_C3,t.AZIMUTH=512,t.DISTANCE=1024|t.CAP_C1,t.STANDARD=t.LATITUDE|t.LONGITUDE|t.AZIMUTH|t.DISTANCE,t.DISTANCE_IN=2048|t.CAP_C1|t.CAP_C1p,t.REDUCEDLENGTH=4096|t.CAP_C1|t.CAP_C2,t.GEODESICSCALE=8192|t.CAP_C1|t.CAP_C2,t.AREA=16384|t.CAP_C4,t.ALL=32671,t.LONG_UNROLL=32768,t.OUT_MASK=32640|t.LONG_UNROLL,t.SinCosSeries=function(t,e,n,i){var s=i.length,r=s-(t?1:0),o=2*(n-e)*(n+e),a=1&r?i[--s]:0,h=0;for(r=Math.floor(r/2);r--;)a=o*(h=o*a-h+i[--s])-a+i[--s];return t?2*e*n*a:n*(a-h)},a=function(t,e){var n,s,r,o,a,h,l,c,u,p,d,_,f=i.sq(t),m=i.sq(e),y=(f+m-1)/6;return 0===m&&y<=0?n=0:(h=y,(a=(s=f*m/4)*(s+2*(o=y*(r=i.sq(y)))))>=0?(l=s+o,l+=l<0?-Math.sqrt(a):Math.sqrt(a),h+=(c=i.cbrt(l))+(0!==c?r/c:0)):(u=Math.atan2(Math.sqrt(-a),-(s+o)),h+=2*y*Math.cos(u/3)),p=Math.sqrt(i.sq(h)+m),_=((d=h<0?m/(p-h):h+p)-m)/(2*p),n=d/(Math.sqrt(d+i.sq(_))+_)),n},h=[1,4,64,0,256],t.A1m1f=function(t){var e=Math.floor(3);return(i.polyval(e,h,0,i.sq(t))/h[e+1]+t)/(1-t)},l=[-1,6,-16,32,-9,64,-128,2048,9,-16,768,3,-5,512,-7,1280,-7,2048],t.C1f=function(e,n){var s,r,o=i.sq(e),a=e,h=0;for(s=1;s<=t.nC1_;++s)r=Math.floor((t.nC1_-s)/2),n[s]=a*i.polyval(r,l,h,o)/l[h+r+1],h+=r+2,a*=e},c=[205,-432,768,1536,4005,-4736,3840,12288,-225,116,384,-7173,2695,7680,3467,7680,38081,61440],t.C1pf=function(e,n){var s,r,o=i.sq(e),a=e,h=0;for(s=1;s<=t.nC1p_;++s)r=Math.floor((t.nC1p_-s)/2),n[s]=a*i.polyval(r,c,h,o)/c[h+r+1],h+=r+2,a*=e},u=[-11,-28,-192,0,256],t.A2m1f=function(t){var e=Math.floor(3);return(i.polyval(e,u,0,i.sq(t))/u[e+1]-t)/(1+t)},p=[1,2,16,32,35,64,384,2048,15,80,768,7,35,512,63,1280,77,2048],t.C2f=function(e,n){var s,r,o=i.sq(e),a=e,h=0;for(s=1;s<=t.nC2_;++s)r=Math.floor((t.nC2_-s)/2),n[s]=a*i.polyval(r,p,h,o)/p[h+r+1],h+=r+2,a*=e},t.Geodesic=function(t,e){if(this.a=t,this.f=e,this._f1=1-this.f,this._e2=this.f*(2-this.f),this._ep2=this._e2/i.sq(this._f1),this._n=this.f/(2-this.f),this._b=this.a*this._f1,this._c2=(i.sq(this.a)+i.sq(this._b)*(0===this._e2?1:(this._e2>0?i.atanh(Math.sqrt(this._e2)):Math.atan(Math.sqrt(-this._e2)))/Math.sqrt(Math.abs(this._e2))))/2,this._etol2=.1*v/Math.sqrt(Math.max(.001,Math.abs(this.f))*Math.min(1,1-this.f/2)/2),!(isFinite(this.a)&&this.a>0))throw new Error("Equatorial radius is not positive");if(!(isFinite(this._b)&&this._b>0))throw new Error("Polar semi-axis is not positive");this._A3x=new Array(6),this._C3x=new Array(r),this._C4x=new Array(o),this.A3coeff(),this.C3coeff(),this.C4coeff()},d=[-3,128,-2,-3,64,-1,-3,-1,16,3,-1,-2,8,1,-1,2,1,1],t.Geodesic.prototype.A3coeff=function(){var t,e,n=0,s=0;for(t=5;t>=0;--t)e=Math.min(6-t-1,t),this._A3x[s++]=i.polyval(e,d,n,this._n)/d[n+e+1],n+=e+2},_=[3,128,2,5,128,-1,3,3,64,-1,0,1,8,-1,1,4,5,256,1,3,128,-3,-2,3,64,1,-3,2,32,7,512,-10,9,384,5,-9,5,192,7,512,-14,7,512,21,2560],t.Geodesic.prototype.C3coeff=function(){var e,n,s,r=0,o=0;for(e=1;e<t.nC3_;++e)for(n=t.nC3_-1;n>=e;--n)s=Math.min(t.nC3_-n-1,n),this._C3x[o++]=i.polyval(s,_,r,this._n)/_[r+s+1],r+=s+2},f=[97,15015,1088,156,45045,-224,-4784,1573,45045,-10656,14144,-4576,-858,45045,64,624,-4576,6864,-3003,15015,100,208,572,3432,-12012,30030,45045,1,9009,-2944,468,135135,5792,1040,-1287,135135,5952,-11648,9152,-2574,135135,-64,-624,4576,-6864,3003,135135,8,10725,1856,-936,225225,-8448,4992,-1144,225225,-1440,4160,-4576,1716,225225,-136,63063,1024,-208,105105,3584,-3328,1144,315315,-128,135135,-2560,832,405405,128,99099],t.Geodesic.prototype.C4coeff=function(){var e,n,s,r=0,o=0;for(e=0;e<t.nC4_;++e)for(n=t.nC4_-1;n>=e;--n)s=t.nC4_-n-1,this._C4x[o++]=i.polyval(s,f,r,this._n)/f[r+s+1],r+=s+2},t.Geodesic.prototype.A3f=function(t){return i.polyval(5,this._A3x,0,t)},t.Geodesic.prototype.C3f=function(e,n){var s,r,o=1,a=0;for(s=1;s<t.nC3_;++s)r=t.nC3_-s-1,o*=e,n[s]=o*i.polyval(r,this._C3x,a,e),a+=r+1},t.Geodesic.prototype.C4f=function(e,n){var s,r,o=1,a=0;for(s=0;s<t.nC4_;++s)r=t.nC4_-s-1,n[s]=o*i.polyval(r,this._C4x,a,e),a+=r+1,o*=e},t.Geodesic.prototype.Lengths=function(e,n,i,s,r,o,a,h,l,c,u,p,d){var _,f,m,y,g={},v=0,x=0,w=0,b=0;if((u&=t.OUT_MASK)&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&(w=t.A1m1f(e),t.C1f(e,p),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(b=t.A2m1f(e),t.C2f(e,d),v=w-b,b=1+b),w=1+w),u&t.DISTANCE)_=t.SinCosSeries(!0,o,a,p)-t.SinCosSeries(!0,i,s,p),g.s12b=w*(n+_),u&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(x=v*n+(w*_-b*(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,i,s,d))));else if(u&(t.REDUCEDLENGTH|t.GEODESICSCALE)){for(f=1;f<=t.nC2_;++f)d[f]=w*p[f]-b*d[f];x=v*n+(t.SinCosSeries(!0,o,a,d)-t.SinCosSeries(!0,i,s,d))}return u&t.REDUCEDLENGTH?(g.m0=v,g.m12b=h*(s*o)-r*(i*a)-s*a*x):g.m12b=NaN,u&t.GEODESICSCALE&&(m=s*a+i*o,y=this._ep2*(l-c)*(l+c)/(r+h),g.M12=m+(y*o-a*x)*i/r,g.M21=m-(y*i-s*x)*o/h),g},t.Geodesic.prototype.InverseStart=function(e,n,s,r,o,h,l,c,u,p,d){var _,f,m,y,v,x,b,C,S,A,M,E,k,D,I,P,T,L,N,R,F={},G=r*n-o*e,O=o*n+r*e;return F.sig12=-1,_=r*n,_+=o*e,(f=O>=0&&G<.5&&o*l<.5)?(y=i.sq(e+r),y/=y+i.sq(n+o),F.dnm=Math.sqrt(1+this._ep2*y),m=l/(this._f1*F.dnm),v=Math.sin(m),x=Math.cos(m)):(v=c,x=u),F.salp1=o*v,F.calp1=x>=0?G+o*e*i.sq(v)/(1+x):_-o*e*i.sq(v)/(1-x),C=i.hypot(F.salp1,F.calp1),S=e*r+n*o*x,f&&C<this._etol2?(F.salp2=n*v,F.calp2=G-n*r*(x>=0?i.sq(v)/(1+x):1-x),b=i.hypot(F.salp2,F.calp2),F.salp2/=b,F.calp2/=b,F.sig12=Math.atan2(C,S)):Math.abs(this._n)>.1||S>=0||C>=6*Math.abs(this._n)*Math.PI*i.sq(n)||(R=Math.atan2(-c,-u),this.f>=0?(D=(k=i.sq(e)*this._ep2)/(2*(1+Math.sqrt(1+k))+k),A=R/(E=this.f*n*this.A3f(D)*Math.PI),M=_/(E*n)):(I=o*n-r*e,P=Math.atan2(_,I),M=l/(E=((A=(T=this.Lengths(this._n,Math.PI+P,e,-n,s,r,o,h,n,o,t.REDUCEDLENGTH,p,d)).m12b/(n*o*T.m0*Math.PI)-1)<-.01?_/A:-this.f*i.sq(n)*Math.PI)/n)),M>-g&&A>-1-w?this.f>=0?(F.salp1=Math.min(1,-A),F.calp1=-Math.sqrt(1-i.sq(F.salp1))):(F.calp1=Math.max(A>-g?0:-1,A),F.salp1=Math.sqrt(1-i.sq(F.calp1))):(L=a(A,M),N=E*(this.f>=0?-A*L/(1+L):-M*(1+L)/L),v=Math.sin(N),x=-Math.cos(N),F.salp1=o*v,F.calp1=_-o*e*i.sq(v)/(1-x))),F.salp1<=0?(F.salp1=1,F.calp1=0):(b=i.hypot(F.salp1,F.calp1),F.salp1/=b,F.calp1/=b),F},t.Geodesic.prototype.Lambda12=function(e,n,s,r,o,a,h,l,c,u,p,d,_,f){var m,y,g,v,x,w,b,C,S,A,M,E,k,D={};return 0===e&&0===l&&(l=-t.tiny_),y=h*n,g=i.hypot(l,h*e),D.ssig1=e,v=y*e,D.csig1=x=l*n,m=i.hypot(D.ssig1,D.csig1),D.ssig1/=m,D.csig1/=m,D.salp2=o!==n?y/o:h,D.calp2=o!==n||Math.abs(r)!==-e?Math.sqrt(i.sq(l*n)+(n<-e?(o-n)*(n+o):(e-r)*(e+r)))/o:Math.abs(l),D.ssig2=r,w=y*r,D.csig2=b=D.calp2*o,m=i.hypot(D.ssig2,D.csig2),D.ssig2/=m,D.csig2/=m,D.sig12=Math.atan2(Math.max(0,D.csig1*D.ssig2-D.ssig1*D.csig2),D.csig1*D.csig2+D.ssig1*D.ssig2),C=Math.max(0,x*w-v*b),S=x*b+v*w,M=Math.atan2(C*u-S*c,S*u+C*c),E=i.sq(g)*this._ep2,D.eps=E/(2*(1+Math.sqrt(1+E))+E),this.C3f(D.eps,f),A=t.SinCosSeries(!0,D.ssig2,D.csig2,f)-t.SinCosSeries(!0,D.ssig1,D.csig1,f),D.domg12=-this.f*this.A3f(D.eps)*y*(D.sig12+A),D.lam12=M+D.domg12,p&&(0===D.calp2?D.dlam12=-2*this._f1*s/e:(k=this.Lengths(D.eps,D.sig12,D.ssig1,D.csig1,s,D.ssig2,D.csig2,a,n,o,t.REDUCEDLENGTH,d,_),D.dlam12=k.m12b,D.dlam12*=this._f1/(D.calp2*o))),D},t.Geodesic.prototype.Inverse=function(e,n,s,r,o){var a,h;return o||(o=t.STANDARD),o===t.LONG_UNROLL&&(o|=t.STANDARD),o&=t.OUT_MASK,h=(a=this.InverseInt(e,n,s,r,o)).vals,o&t.AZIMUTH&&(h.azi1=i.atan2d(a.salp1,a.calp1),h.azi2=i.atan2d(a.salp2,a.calp2)),h},t.Geodesic.prototype.InverseInt=function(e,n,s,r,o){var a,h,l,c,u,p,d,_,f,g,w,b,C,S,A,M,E,k,D,I,P,T,L,N,R,F,G,O,B,z,U,q,j,$,V,H,W,K,X,Z,J,Y,Q,tt,et,nt,it,st,rt,ot,at,ht,lt,ct,ut,pt,dt,_t,ft,mt,yt,gt,vt,xt,wt,bt={};if(bt.lat1=e=i.LatFix(e),bt.lat2=s=i.LatFix(s),e=i.AngRound(e),s=i.AngRound(s),h=(a=i.AngDiff(n,r)).e,a=a.d,o&t.LONG_UNROLL?(bt.lon1=n,bt.lon2=n+a+h):(bt.lon1=i.AngNormalize(n),bt.lon2=i.AngNormalize(r)),h*=l=i.copysign(1,a),A=(a*=l)*i.degree,M=(c=i.sincosde(a,h)).s,E=c.c,h=180-a-h,(u=Math.abs(e)<Math.abs(s)||isNaN(s)?-1:1)<0&&(l*=-1,[s,e]=[e,s]),e*=p=i.copysign(1,-e),s*=p,c=i.sincosd(e),d=this._f1*c.s,_=c.c,d/=c=i.hypot(d,_),_/=c,_=Math.max(t.tiny_,_),c=i.sincosd(s),f=this._f1*c.s,g=c.c,f/=c=i.hypot(f,g),g/=c,g=Math.max(t.tiny_,g),_<-d?g===_&&(f=i.copysign(d,f)):Math.abs(f)===-d&&(g=_),C=Math.sqrt(1+this._ep2*i.sq(d)),S=Math.sqrt(1+this._ep2*i.sq(f)),L=new Array(t.nC1_+1),N=new Array(t.nC2_+1),R=new Array(t.nC3_),(F=-90===e||0===M)&&(I=M,T=0,O=d,B=(D=E)*_,z=f,U=(P=1)*g,k=Math.atan2(Math.max(0,B*z-O*U),B*U+O*z),w=(G=this.Lengths(this._n,k,O,B,C,z,U,S,_,g,o|t.DISTANCE|t.REDUCEDLENGTH,L,N)).s12b,b=G.m12b,o&t.GEODESICSCALE&&(bt.M12=G.M12,bt.M21=G.M21),k<v||b>=0?((k<3*t.tiny_||k<y&&(w<0||b<0))&&(k=b=w=0),b*=this._b,w*=this._b,bt.a12=k/i.degree):F=!1),dt=2,!F&&0===d&&(this.f<=0||h>=180*this.f))D=P=0,I=T=1,w=this.a*A,k=j=A/this._f1,b=this._b*Math.sin(k),o&t.GEODESICSCALE&&(bt.M12=bt.M21=Math.cos(k)),bt.a12=a/this._f1;else if(!F)if(k=(G=this.InverseStart(d,_,C,f,g,S,A,M,E,L,N)).sig12,I=G.salp1,D=G.calp1,k>=0)T=G.salp2,P=G.calp2,$=G.dnm,w=k*this._b*$,b=i.sq($)*this._b*Math.sin(k/$),o&t.GEODESICSCALE&&(bt.M12=bt.M21=Math.cos(k/$)),bt.a12=k/i.degree,j=A/(this._f1*$);else{for(V=0,H=t.tiny_,W=1,K=t.tiny_,X=-1,Z=!1,J=!1;Y=(G=this.Lambda12(d,_,C,f,g,S,I,D,M,E,V<20,L,N,R)).lam12,T=G.salp2,P=G.calp2,k=G.sig12,O=G.ssig1,B=G.csig1,z=G.ssig2,U=G.csig2,q=G.eps,ft=G.domg12,Q=G.dlam12,!J&&Math.abs(Y)>=(Z?8:1)*y&&V!=m;++V)Y>0&&(V<20||D/I>X/K)?(K=I,X=D):Y<0&&(V<20||D/I<W/H)&&(H=I,W=D),V<20&&Q>0&&(tt=-Y/Q,Math.abs(tt)<Math.PI&&(et=Math.sin(tt),(it=I*(nt=Math.cos(tt))+D*et)>0))?(D=D*nt-I*et,I=it,I/=c=i.hypot(I,D),D/=c,Z=Math.abs(Y)<=16*y):(I=(H+K)/2,D=(W+X)/2,I/=c=i.hypot(I,D),D/=c,Z=!1,J=Math.abs(H-I)+(W-D)<x||Math.abs(I-K)+(D-X)<x);st=o|(o&(t.REDUCEDLENGTH|t.GEODESICSCALE)?t.DISTANCE:t.NONE),w=(G=this.Lengths(q,k,O,B,C,z,U,S,_,g,st,L,N)).s12b,b=G.m12b,o&t.GEODESICSCALE&&(bt.M12=G.M12,bt.M21=G.M21),b*=this._b,w*=this._b,bt.a12=k/i.degree,o&t.AREA&&(xt=Math.sin(ft),dt=M*(wt=Math.cos(ft))-E*xt,_t=E*wt+M*xt)}return o&t.DISTANCE&&(bt.s12=0+w),o&t.REDUCEDLENGTH&&(bt.m12=0+b),o&t.AREA&&(rt=I*_,0!==(ot=i.hypot(D,I*d))&&0!==rt?(O=d,B=D*_,z=f,U=P*g,q=(ht=i.sq(ot)*this._ep2)/(2*(1+Math.sqrt(1+ht))+ht),lt=i.sq(this.a)*ot*rt*this._e2,O/=c=i.hypot(O,B),B/=c,z/=c=i.hypot(z,U),U/=c,ct=new Array(t.nC4_),this.C4f(q,ct),ut=t.SinCosSeries(!1,O,B,ct),pt=t.SinCosSeries(!1,z,U,ct),bt.S12=lt*(pt-ut)):bt.S12=0,F||2!=dt||(dt=Math.sin(j),_t=Math.cos(j)),!F&&_t>-.7071&&f-d<1.75?(ft=1+_t,mt=1+_,yt=1+g,at=2*Math.atan2(dt*(d*yt+f*mt),ft*(d*f+mt*yt))):(vt=P*D+T*I,0===(gt=T*D-P*I)&&vt<0&&(gt=t.tiny_*D,vt=-1),at=Math.atan2(gt,vt)),bt.S12+=this._c2*at,bt.S12*=u*l*p,bt.S12+=0),u<0&&([T,I]=[I,T],[P,D]=[D,P],o&t.GEODESICSCALE&&([bt.M21,bt.M12]=[bt.M12,bt.M21])),{vals:bt,salp1:I*=u*l,calp1:D*=u*p,salp2:T*=u*l,calp2:P*=u*p}},t.Geodesic.prototype.GenDirect=function(n,i,s,r,o,a){return a?a===t.LONG_UNROLL&&(a|=t.STANDARD):a=t.STANDARD,r||(a|=t.DISTANCE_IN),new e.GeodesicLine(this,n,i,s,a).GenPosition(r,o,a)},t.Geodesic.prototype.Direct=function(t,e,n,i,s){return this.GenDirect(t,e,n,!1,i,s)},t.Geodesic.prototype.ArcDirect=function(t,e,n,i,s){return this.GenDirect(t,e,n,!0,i,s)},t.Geodesic.prototype.Line=function(t,n,i,s){return new e.GeodesicLine(this,t,n,i,s)},t.Geodesic.prototype.DirectLine=function(t,e,n,i,s){return this.GenDirectLine(t,e,n,!1,i,s)},t.Geodesic.prototype.ArcDirectLine=function(t,e,n,i,s){return this.GenDirectLine(t,e,n,!0,i,s)},t.Geodesic.prototype.GenDirectLine=function(n,i,s,r,o,a){var h;return a||(a=t.STANDARD|t.DISTANCE_IN),r||(a|=t.DISTANCE_IN),(h=new e.GeodesicLine(this,n,i,s,a)).GenSetDistance(r,o),h},t.Geodesic.prototype.InverseLine=function(n,s,r,o,a){var h,l,c;return a||(a=t.STANDARD|t.DISTANCE_IN),h=this.InverseInt(n,s,r,o,t.ARC),c=i.atan2d(h.salp1,h.calp1),a&t.OUT_MASK&t.DISTANCE_IN&&(a|=t.DISTANCE),(l=new e.GeodesicLine(this,n,s,c,a,h.salp1,h.calp1)).SetArc(h.vals.a12),l},t.Geodesic.prototype.Polygon=function(t){return new n.PolygonArea(this,t)},t.WGS84=new t.Geodesic(s.WGS84.a,s.WGS84.f)}(s.Geodesic,s.GeodesicLine,s.PolygonArea,s.Math,s.Constants),function(t,e,n){e.GeodesicLine=function(e,i,s,r,o,a,h){var l,c,u,p,d,_;o||(o=t.STANDARD|t.DISTANCE_IN),this.a=e.a,this.f=e.f,this._b=e._b,this._c2=e._c2,this._f1=e._f1,this.caps=o|t.LATITUDE|t.AZIMUTH|t.LONG_UNROLL,this.lat1=n.LatFix(i),this.lon1=s,void 0===a||void 0===h?(this.azi1=n.AngNormalize(r),l=n.sincosd(n.AngRound(this.azi1)),this.salp1=l.s,this.calp1=l.c):(this.azi1=r,this.salp1=a,this.calp1=h),l=n.sincosd(n.AngRound(this.lat1)),u=this._f1*l.s,c=l.c,u/=l=n.hypot(u,c),c/=l,c=Math.max(t.tiny_,c),this._dn1=Math.sqrt(1+e._ep2*n.sq(u)),this._salp0=this.salp1*c,this._calp0=n.hypot(this.calp1,this.salp1*u),this._ssig1=u,this._somg1=this._salp0*u,this._csig1=this._comg1=0!==u||0!==this.calp1?c*this.calp1:1,l=n.hypot(this._ssig1,this._csig1),this._ssig1/=l,this._csig1/=l,this._k2=n.sq(this._calp0)*e._ep2,p=this._k2/(2*(1+Math.sqrt(1+this._k2))+this._k2),this.caps&t.CAP_C1&&(this._A1m1=t.A1m1f(p),this._C1a=new Array(t.nC1_+1),t.C1f(p,this._C1a),this._B11=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C1a),d=Math.sin(this._B11),_=Math.cos(this._B11),this._stau1=this._ssig1*_+this._csig1*d,this._ctau1=this._csig1*_-this._ssig1*d),this.caps&t.CAP_C1p&&(this._C1pa=new Array(t.nC1p_+1),t.C1pf(p,this._C1pa)),this.caps&t.CAP_C2&&(this._A2m1=t.A2m1f(p),this._C2a=new Array(t.nC2_+1),t.C2f(p,this._C2a),this._B21=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C2a)),this.caps&t.CAP_C3&&(this._C3a=new Array(t.nC3_),e.C3f(p,this._C3a),this._A3c=-this.f*this._salp0*e.A3f(p),this._B31=t.SinCosSeries(!0,this._ssig1,this._csig1,this._C3a)),this.caps&t.CAP_C4&&(this._C4a=new Array(t.nC4_),e.C4f(p,this._C4a),this._A4=n.sq(this.a)*this._calp0*this._salp0*e._e2,this._B41=t.SinCosSeries(!1,this._ssig1,this._csig1,this._C4a)),this.a13=this.s13=NaN},e.GeodesicLine.prototype.GenPosition=function(e,i,s){var r,o,a,h,l,c,u,p,d,_,f,m,y,g,v,x,w,b,C,S,A,M,E,k,D,I,P={};return s?s===t.LONG_UNROLL&&(s|=t.STANDARD):s=t.STANDARD,s&=this.caps&t.OUT_MASK,P.lat1=this.lat1,P.azi1=this.azi1,P.lon1=s&t.LONG_UNROLL?this.lon1:n.AngNormalize(this.lon1),e?P.a12=i:P.s12=i,e||this.caps&t.DISTANCE_IN&t.OUT_MASK?(h=0,l=0,e?(r=i*n.degree,o=(E=n.sincosd(i)).s,a=E.c):(p=i/(this._b*(1+this._A1m1)),d=Math.sin(p),_=Math.cos(p),r=p-((h=-t.SinCosSeries(!0,this._stau1*_+this._ctau1*d,this._ctau1*_-this._stau1*d,this._C1pa))-this._B11),o=Math.sin(r),a=Math.cos(r),Math.abs(this.f)>.01&&(c=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,h=t.SinCosSeries(!0,c,u,this._C1a),r-=((1+this._A1m1)*(r+(h-this._B11))-i/this._b)/Math.sqrt(1+this._k2*n.sq(c)),o=Math.sin(r),a=Math.cos(r))),c=this._ssig1*a+this._csig1*o,u=this._csig1*a-this._ssig1*o,C=Math.sqrt(1+this._k2*n.sq(c)),s&(t.DISTANCE|t.REDUCEDLENGTH|t.GEODESICSCALE)&&((e||Math.abs(this.f)>.01)&&(h=t.SinCosSeries(!0,c,u,this._C1a)),l=(1+this._A1m1)*(h-this._B11)),y=this._calp0*c,0===(g=n.hypot(this._salp0,this._calp0*u))&&(g=u=t.tiny_),w=this._salp0,b=this._calp0*u,e&&s&t.DISTANCE&&(P.s12=this._b*((1+this._A1m1)*r+l)),s&t.LONGITUDE&&(v=this._salp0*c,x=u,m=n.copysign(1,this._salp0),f=((s&t.LONG_UNROLL?m*(r-(Math.atan2(c,u)-Math.atan2(this._ssig1,this._csig1))+(Math.atan2(m*v,x)-Math.atan2(m*this._somg1,this._comg1))):Math.atan2(v*this._comg1-x*this._somg1,x*this._comg1+v*this._somg1))+this._A3c*(r+(t.SinCosSeries(!0,c,u,this._C3a)-this._B31)))/n.degree,P.lon2=s&t.LONG_UNROLL?this.lon1+f:n.AngNormalize(n.AngNormalize(this.lon1)+n.AngNormalize(f))),s&t.LATITUDE&&(P.lat2=n.atan2d(y,this._f1*g)),s&t.AZIMUTH&&(P.azi2=n.atan2d(w,b)),s&(t.REDUCEDLENGTH|t.GEODESICSCALE)&&(S=t.SinCosSeries(!0,c,u,this._C2a),A=(1+this._A2m1)*(S-this._B21),M=(this._A1m1-this._A2m1)*r+(l-A),s&t.REDUCEDLENGTH&&(P.m12=this._b*(C*(this._csig1*c)-this._dn1*(this._ssig1*u)-this._csig1*u*M)),s&t.GEODESICSCALE&&(E=this._k2*(c-this._ssig1)*(c+this._ssig1)/(this._dn1+C),P.M12=a+(E*c-u*M)*this._ssig1/this._dn1,P.M21=a-(E*this._ssig1-this._csig1*M)*c/C)),s&t.AREA&&(k=t.SinCosSeries(!1,c,u,this._C4a),0===this._calp0||0===this._salp0?(D=w*this.calp1-b*this.salp1,I=b*this.calp1+w*this.salp1):(D=this._calp0*this._salp0*(a<=0?this._csig1*(1-a)+o*this._ssig1:o*(this._csig1*o/(1+a)+this._ssig1)),I=n.sq(this._salp0)+n.sq(this._calp0)*this._csig1*u),P.S12=this._c2*Math.atan2(D,I)+this._A4*(k-this._B41)),e||(P.a12=r/n.degree),P):(P.a12=NaN,P)},e.GeodesicLine.prototype.Position=function(t,e){return this.GenPosition(!1,t,e)},e.GeodesicLine.prototype.ArcPosition=function(t,e){return this.GenPosition(!0,t,e)},e.GeodesicLine.prototype.GenSetDistance=function(t,e){t?this.SetArc(e):this.SetDistance(e)},e.GeodesicLine.prototype.SetDistance=function(e){var n;this.s13=e,n=this.GenPosition(!1,this.s13,t.ARC),this.a13=0+n.a12},e.GeodesicLine.prototype.SetArc=function(e){var n;this.a13=e,n=this.GenPosition(!0,this.a13,t.DISTANCE),this.s13=0+n.s12}}(s.Geodesic,s.GeodesicLine,s.Math),function(t,e,n,i){var s,r,o,a;s=function(t,e){var i=n.AngDiff(t,e).d;return t=n.AngNormalize(t),e=n.AngNormalize(e),i>0&&(t<0&&e>=0||t>0&&0===e)?1:i<0&&t>=0&&e<0?-1:0},r=function(t,e){return(0<=(e%=720)&&e<360||e<-360?0:1)-(0<=(t%=720)&&t<360||t<-360?0:1)},o=function(t,e,n,i,s){return t.Remainder(e),1&n&&t.Add((t.Sum()<0?1:-1)*e/2),i||t.Negate(),s?t.Sum()>e/2?t.Add(-e):t.Sum()<=-e/2&&t.Add(+e):t.Sum()>=e?t.Add(-e):t.Sum()<0&&t.Add(+e),0+t.Sum()},a=function(t,e,i,s,r){return t=n.remainder(t,e),1&i&&(t+=(t<0?1:-1)*e/2),s||(t*=-1),r?t>e/2?t-=e:t<=-e/2&&(t+=e):t>=e?t-=e:t<0&&(t+=e),0+t},t.PolygonArea=function(t,n){this._geod=t,this.a=this._geod.a,this.f=this._geod.f,this._area0=4*Math.PI*t._c2,this.polyline=n||!1,this._mask=e.LATITUDE|e.LONGITUDE|e.DISTANCE|(this.polyline?e.NONE:e.AREA|e.LONG_UNROLL),this.polyline||(this._areasum=new i.Accumulator(0)),this._perimetersum=new i.Accumulator(0),this.Clear()},t.PolygonArea.prototype.Clear=function(){this.num=0,this._crossings=0,this.polyline||this._areasum.Set(0),this._perimetersum.Set(0),this._lat0=this._lon0=this.lat=this.lon=NaN},t.PolygonArea.prototype.AddPoint=function(t,e){var n;0===this.num?(this._lat0=this.lat=t,this._lon0=this.lon=e):(n=this._geod.Inverse(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(n.s12),this.polyline||(this._areasum.Add(n.S12),this._crossings+=s(this.lon,e)),this.lat=t,this.lon=e),++this.num},t.PolygonArea.prototype.AddEdge=function(t,e){var n;this.num&&(n=this._geod.Direct(this.lat,this.lon,t,e,this._mask),this._perimetersum.Add(e),this.polyline||(this._areasum.Add(n.S12),this._crossings+=r(this.lon,n.lon2)),this.lat=n.lat2,this.lon=n.lon2),++this.num},t.PolygonArea.prototype.Compute=function(t,e){var n,r,a={number:this.num};return this.num<2?(a.perimeter=0,this.polyline||(a.area=0),a):this.polyline?(a.perimeter=this._perimetersum.Sum(),a):(n=this._geod.Inverse(this.lat,this.lon,this._lat0,this._lon0,this._mask),a.perimeter=this._perimetersum.Sum(n.s12),(r=new i.Accumulator(this._areasum)).Add(n.S12),a.area=o(r,this._area0,this._crossings+s(this.lon,this._lon0),t,e),a)},t.PolygonArea.prototype.TestPoint=function(t,e,n,i){var r,o,h,l,c={number:this.num+1};if(0===this.num)return c.perimeter=0,this.polyline||(c.area=0),c;for(c.perimeter=this._perimetersum.Sum(),o=this.polyline?0:this._areasum.Sum(),h=this._crossings,l=0;l<(this.polyline?1:2);++l)r=this._geod.Inverse(0===l?this.lat:t,0===l?this.lon:e,0!==l?this._lat0:t,0!==l?this._lon0:e,this._mask),c.perimeter+=r.s12,this.polyline||(o+=r.S12,h+=s(0===l?this.lon:e,0!==l?this._lon0:e));return this.polyline||(c.area=a(o,this._area0,h,n,i)),c},t.PolygonArea.prototype.TestEdge=function(t,e,n,i){var o,h,l,c={number:this.num?this.num+1:0};return 0===this.num||(c.perimeter=this._perimetersum.Sum()+e,this.polyline||(h=this._areasum.Sum(),l=this._crossings,h+=(o=this._geod.Direct(this.lat,this.lon,t,e,this._mask)).S12,l+=r(this.lon,o.lon2),l+=s(o.lon2,this._lon0),o=this._geod.Inverse(o.lat2,o.lon2,this._lat0,this._lon0,this._mask),c.perimeter+=o.s12,h+=o.S12,c.area=a(h,this._area0,l,n,i))),c}}(s.PolygonArea,s.Geodesic,s.Math,s.Accumulator),i=s,t.exports?t.exports=i:window.geodesic=i}(O);var B=O.exports,z=e({__proto__:null,default:n(B)},[B]);const U=globalThis;"undefined"==typeof window&&(U.window=U.window||{},U.window.document||(U.window.document={}));const q=U.window.modules=U.window.modules||{};q.mproj=C,q.flatbush=M,q.kdbush=T,q["geographiclib-geodesic"]=z;class j{_listeners={};on(t,e){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e),this}once(t,e){const n=i=>{this.off(t,n),e(i)};return this.on(t,n)}off(t,e){return this._listeners[t]?(this._listeners[t]=this._listeners[t].filter(t=>t!==e),this):this}fire(t,e){if(!this._listeners[t])return this;const n={type:t,...e};return this._listeners[t].forEach(t=>t(n)),this}}class ${mx;my;bx;by;constructor(t=1,e=1,n=0,i=0){this.mx=t,this.my=e,this.bx=n,this.by=i}static fromBounds(t,e,n=!1){const i=e.width/t.width||1,s=(n?-e.height/t.height:e.height/t.height)||1,r=e.xmin-i*t.xmin,o=n?e.ymax-s*t.ymin:e.ymin-s*t.ymin;return new $(i,s,r,o)}project(t,e){return[t*this.mx+this.bx,e*this.my+this.by]}unproject(t,e){return[(t-this.bx)/this.mx,(e-this.by)/this.my]}translate(t,e){this.bx+=t,this.by+=e}scale(t,e,n){this.bx=e*(1-t)+this.bx*t,this.by=n*(1-t)+this.by*t,this.mx*=t,this.my*=t}clone(){return new $(this.mx,this.my,this.bx,this.by)}}class V{xmin;ymin;xmax;ymax;constructor(t=1/0,e=1/0,n=-1/0,i=-1/0){this.xmin=t,this.ymin=e,this.xmax=n,this.ymax=i}static fromArray(t){return new V(t[0],t[1],t[2],t[3])}get width(){return this.xmax-this.xmin}get height(){return this.ymax-this.ymin}get centerX(){return.5*(this.xmin+this.xmax)}get centerY(){return.5*(this.ymin+this.ymax)}hasBounds(){return this.xmin<=this.xmax&&this.ymin<=this.ymax}clone(){return new V(this.xmin,this.ymin,this.xmax,this.ymax)}mergePoint(t,e){t<this.xmin&&(this.xmin=t),t>this.xmax&&(this.xmax=t),e<this.ymin&&(this.ymin=e),e>this.ymax&&(this.ymax=e)}merge(t){t.hasBounds()&&(t.xmin<this.xmin&&(this.xmin=t.xmin),t.xmax>this.xmax&&(this.xmax=t.xmax),t.ymin<this.ymin&&(this.ymin=t.ymin),t.ymax>this.ymax&&(this.ymax=t.ymax))}fillOut(t,e=.5,n=.5){const i=this.width,s=this.height;let r;return i/s<t?(r=s*t-i,this.xmin-=(1-e)*r,this.xmax+=e*r):(r=i/t-s,this.ymin-=(1-n)*r,this.ymax+=n*r),this}scale(t){const e=this.centerX,n=this.centerY,i=this.width*t,s=this.height*t;this.xmin=e-i/2,this.xmax=e+i/2,this.ymin=n-s/2,this.ymax=n+s/2}}class H extends j{_running=!1;_busy=!1;_tickTime=0;_startTime=0;_duration=1/0;constructor(){super()}start(t){const e=Date.now();this._duration=t||1/0,this._startTime=e,this._running=!0,this._busy||this._startTick(e)}stop(){this._running=!1}_startTick(t){this._busy=!0,this._tickTime=t,("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,25))(()=>this._onTick())}_onTick(){const t=Date.now(),e=t-this._startTime,n=Math.min((e+10)/this._duration,1),i=n>=1;this._running?(i&&(this._running=!1),this.fire("tick",{elapsed:e,pct:n,done:i,time:t,tickTime:t-this._tickTime}),this._busy=!1,this._running&&this._startTick(t)):this._busy=!1}}class W extends j{_timer=new H;_startValue=0;_endValue=0;_ease;constructor(t){super(),this._ease=t||null,this._timer.on("tick",t=>this._onTick(t))}start(t,e,n){this._startValue=t,this._endValue=e,this._timer.start(n||500)}stop(){this._timer.stop()}_onTick(t){const e=this._ease?this._ease(t.pct):t.pct,n=this._endValue*e+this._startValue*(1-e);this.fire("change",{value:n})}static sineInOut(t){return.5-Math.cos(t*Math.PI)/2}static quadraticOut(t){return 1-Math.pow(1-t,2)}}const K=18485274.7;class X{_transform=new $;_extent=new V;_width=0;_height=0;_initialMX=0;_initialExtent=null;_zoomTween=new W(W.sineInOut);_zoomFocus=[0,0];_animatingTransform=null;onViewChange=null;_crs="EPSG:4326";setCRS(t){this._crs=t}get transform(){return this._transform}get extent(){return this._extent}get width(){return this._width}get height(){return this._height}get initialMX(){return this._initialMX}updateSize(t,e){this._width=t,this._height=e}setExtent(t){this._extent=t.clone(),this._initialExtent||(this._initialExtent=t.clone()),this._updateTransform()}reset(){this._initialExtent&&this.setExtent(this._initialExtent)}clearInitialState(){this._initialExtent=null,this._initialMX=0}_updateTransform(){if(!this._extent.hasBounds())return;const t=this._width/this._height,e=this._extent.clone().fillOut(t),n=new V(0,0,this._width,this._height);this._transform=$.fromBounds(e,n,!0),0===this._initialMX&&(this._initialMX=Math.abs(this._transform.mx),this._initialExtent=e)}pan(t,e){this._transform.translate(t,e),this._applyConstraints()}cancelZoomAnimation(){this._zoomTween.stop(),this._animatingTransform=null}applyWheelZoom(t,e,n,i){const s=1+.12*e,r=t>0?s:1/s;this._transform.scale(r,n,i),this._applyConstraints()}zoomIn(){this._zoomTo(1.15)}zoomOut(){this._zoomTo(1/1.15)}_zoomTo(t){const e=[this._width/2,this._height/2],n=Math.abs(this._transform.mx),i=n*t;this._zoomFocus=e,this._animatingTransform=this._transform.clone(),this._zoomTween.start(n,i,200)}initZoomTween(){this._zoomTween.on("change",t=>{if(!this._animatingTransform)return;const e=t.value/this._animatingTransform.mx,n=this._animatingTransform.clone();n.scale(e,this._zoomFocus[0],this._zoomFocus[1]),this._transform=n,this.onViewChange?.(),t.done&&(this._animatingTransform=null)})}project(t,e){return this._transform.project(t,e)}unproject(t,e){return this._transform.unproject(t,e)}getLineScale(){if(0===this._initialMX)return 1;const t=Math.abs(this._transform.mx)/this._initialMX;let e=1;return t<.5?e*=Math.pow(t+.5,.35):t>30&&(e*=Math.pow(t-29,.065)),e}getArcFilter(t){const e=.1*(1/Math.abs(this._transform.mx)),n=this._initialMX>0?Math.abs(this._transform.mx)/this._initialMX:1,i=n<1?e*n:e,s=this._getViewBounds();return e=>!t.arcIsSmaller?.(e,i)&&!(s&&t.arcIntersectsBBox&&!t.arcIntersectsBBox(e,s))}getViewBounds(){return this._getViewBounds()}_getViewBounds(){if(!this._transform||0===this._width)return null;const t=this._transform,e=-t.bx/t.mx,n=(this._width-t.bx)/t.mx,i=-t.by/t.my,s=(this._height-t.by)/t.my;return[Math.min(e,n),Math.min(i,s),Math.max(e,n),Math.max(i,s)]}_applyConstraints(){const t=this._transform;let e=Math.abs(t.mx);const n=this._getMinMX(),i=this._getMaxMX();(this._crs.toLowerCase().includes("3857")||this._crs.toLowerCase().includes("webmercator"))&&e<n&&(e=n),e>i&&(e=i);const s=t.my>0?e:-e,r=this._getStrictBounds(),o=(this._width/2-t.bx)/t.mx;let a=(this._height/2-t.by)/t.my;if(r){const t=this._height/(2*e),n=r.ymax-t,i=r.ymin+t;i>n?a=(r.ymin+r.ymax)/2:a>n?a=n:a<i&&(a=i)}const h=this._width/2-o*e,l=this._height/2-a*s;this._transform=new $(e,s,h,l)}_getMaxMX(){if(!this._initialExtent)return 1/0;const t=this._initialExtent,e=(...t)=>Math.max(...t.map(Math.abs)),n=e(t.xmin,t.xmax,t.centerX),i=e(t.ymin,t.ymax,t.centerY),s=t.width/this._width/(1e-16*n),r=t.height/this._height/(1e-16*i);return Math.max(s,r)}_getStrictBounds(){const t=this._crs.toLowerCase();return"epsg:3857"===t||"webmercator"===t?new V(-1/0,-18485274.7,1/0,K):null}_getMinMX(){const t=this._crs.toLowerCase();let e;if("epsg:3857"===t||"webmercator"===t)e=36970549.4;else{if("epsg:4326"!==t&&"wgs84"!==t)return.01*this._initialMX;e=180}return this._height/e}}class Z{snapVertices(e,n,i){t.internal.snapVerticesToPoint(e,n,i)}insertVertex(e,n,i){t.internal.insertVertex(e,n,i)}deleteVertex(e,n){t.internal.deleteVertex(e,n)}appendEmptyArc(e){t.internal.appendEmptyArc(e)}appendVertex(e,n){t.internal.appendVertex(e,n)}deleteLastArc(e){t.internal.deleteLastArc(e)}findNearestVertices(e,n,i){return t.internal.findNearestVertices(e,n,i)}findArcIdFromVertexId(e,n){return t.internal.findArcIdFromVertexId(e,n)}vertexIsArcEndpoint(e,n){return t.internal.vertexIsArcEndpoint(e,n)}forEachSegmentInShape(e,n,i){t.internal.forEachSegmentInShape(e,n,i)}findClosestPointOnSeg(e,n,i,s,r,o,a){return t.internal.findClosestPointOnSeg(e,n,i,s,r,o,a)}addIntersectionCuts(e,n){t.internal.addIntersectionCuts(e,n)}findSegmentIntersections(e,n){return t.internal.findSegmentIntersections(e,n)}getIntersectionLayer(e,n,i){return t.internal.getIntersectionLayer(e,n,i)}getAvgSegment(e){return t.internal.getAvgSegment(e)}simplifyArcsFast(e,n){return t.internal.simplifyArcsFast(e,n)}layerHasGeometry(e){return t.internal.layerHasGeometry(e)}getLayerBounds(e,n){const i=t.internal.getLayerBounds(e,n);return i?{xmin:i.xmin,ymin:i.ymin,xmax:i.xmax,ymax:i.ymax}:{xmin:NaN,ymin:NaN,xmax:NaN,ymax:NaN}}getDatasetBounds(e){const n=t.internal.getDatasetBounds(e);return{xmin:n.xmin,ymin:n.ymin,xmax:n.xmax,ymax:n.ymax}}exportDatasetsToPack(e,n){return t.internal.exportDatasetsToPack(e,n??{})}restoreSessionData(e){return t.internal.restoreSessionData(e)}pack(e){return t.internal.pack(e)}unpackSessionData(e){return t.internal.unpackSessionData(e)}exportPackedDatasets(e,n){return t.internal.exportPackedDatasets(e,n??{})}exportFileContent(e,n){return t.internal.exportFileContent(e,n)}copyDataset(e){return t.internal.copyDataset(e)}runImport(e,n){const i=t.internal.parseCommands(e);return i.length>0&&"i"===i[0].name&&(i[0].options.input=n),new Promise((e,n)=>{t.internal.runParsedCommands(i,new t.internal.Job,(t,i)=>{if(t)return void n(t);const s=i.catalog.getDefaultTargets();0!==s.length?e(s[0].dataset):n(new Error("No layers found in dataset"))})})}runOnDataset(e,n,i){return new Promise((s,r)=>{const o=new t.internal.Job;o.catalog.addDataset(n);const a=t.internal.parseCommands(e);if(i)for(const t of a)t.options&&(t.options.input=i);t.internal.runParsedCommands(a,o,(t,e)=>{if(t)return void r(t);const n=e.catalog.getDefaultTargets();0!==n.length?s(n[0].dataset):r(new Error("mapshaper command completed but produced no default target"))})})}runOnDatasetParsed(e,n,i){return new Promise((s,r)=>{const o=new t.internal.Job;if(o.catalog.addDataset(n),i)for(const t of e)t.options&&(t.options.input=i);t.internal.runParsedCommands(e,o,(t,e)=>{if(t)return void r(t);const n=e.catalog.getDefaultTargets();0!==n.length?s(n[0].dataset):r(new Error("mapshaper command completed but produced no default target"))})})}}let J=null;function Y(){return J??(J=new Z)}function Q(t){J=t}const tt=6378137;class et{_crs="EPSG:4326";get crs(){return this._crs}setCRS(t){this._crs=t}getCenter(t,e){const n=this._crs.toLowerCase();return"epsg:3857"===n||"webmercator"===n?this._webMercatorToLatLng(t,e):[t,e]}getZoom(t){const e=this._crs.toLowerCase();return"epsg:3857"===e||"webmercator"===e?Math.log2(40075016.6855*t/512):0}async reproject(t,e){for(const n of e.values())n.reproject&&await n.reproject(t);this._crs=t;const n=Y(),i=new V;for(const t of e.values()){const e=t.getDataset();if(e?.layers)for(const t of e.layers)if(n.layerHasGeometry(t)){const s=n.getLayerBounds(t,e.arcs);s&&i.merge(new V(s.xmin,s.ymin,s.xmax,s.ymax))}}return i.hasBounds()&&i.scale(1.07),i}_webMercatorToLatLng(t,e){const n=180/Math.PI;return[t/tt*n,n*(.5*Math.PI-2*Math.atan(Math.exp(-e/tt)))]}}function nt(t,e){return t?.name?String(t.name):t?.id?String(t.id):`layer-${e}`}function it(t){return t&&Array.isArray(t)?"number"==typeof t[0]?[t]:Array.isArray(t[0])?t:[]:[]}class st{_canvas;_ctx;_transform=new $;_pixelRatio=window.devicePixelRatio||1;constructor(t){this._canvas=t;const e=t.getContext("2d");if(!e)throw new Error("Failed to get 2D context");this._ctx=e}setTransform(t){this._transform=t}setPixelRatio(t){this._pixelRatio=t}drawPaths(t,e,n){if(0===e.width)return;const i=this._ctx;i.strokeStyle=e.color||"#333",i.lineWidth=(e.width??1)*this._pixelRatio,i.lineCap="round",i.lineJoin="round";let s=0;i.beginPath(),t.forEach(t=>{t&&t.forEach(t=>{t.forEach(t=>{s>0&&s%25==0&&(i.stroke(),i.beginPath());const e=n.getArcIter(t);this.drawPathSnapping(e,i),s++})})}),i.stroke()}drawArcs(t,e,n){if(0===e.width)return;const i=this._ctx,s=t.size();i.strokeStyle=e.color||"#333",i.lineWidth=(e.width??1)*this._pixelRatio,i.lineCap="round",i.lineJoin="round";let r=0;i.beginPath();for(let e=0;e<s;e++){if(n&&!n(e))continue;r>0&&r%25==0&&(i.stroke(),i.beginPath());const s=t.getArcIter(e);this.drawPathSnapping(s,i),r++}i.stroke()}drawPathSnapping(t,e){const n=this._transform.mx*this._pixelRatio,i=this._transform.my*this._pixelRatio,s=this._transform.bx*this._pixelRatio,r=this._transform.by*this._pixelRatio;let o,a,h,l,c=0;if(t.hasNext()){for(o=2*(t.x*n+s)|0,a=2*(t.y*i+r)|0,e.moveTo(o/2,a/2);t.hasNext();)h=o,l=a,o=2*(t.x*n+s)|0,a=2*(t.y*i+r)|0,o===h&&a===l||(e.lineTo(o/2,a/2),c++);0===c&&e.lineTo(o/2+.1,a/2)}}drawPoints(t,e){const n=this._ctx,i=this._pixelRatio,s=this._transform.mx*i,r=this._transform.my*i,o=this._transform.bx*i,a=this._transform.by*i,h=(Number(e?.radius)||4)*i,l=e?.color||"#333",c=!1!==e?.fill;n.beginPath(),n.fillStyle=l,n.strokeStyle=l,t.forEach(t=>{if(!t)return;it(t).forEach(t=>{const e=t[0]*s+o,i=t[1]*r+a;n.moveTo(e+h,i),n.arc(e,i,h,0,2*Math.PI)})}),c?n.fill():n.stroke()}drawVertexDots(t,e,n={}){const i=this._ctx,s=this._pixelRatio,r=this._transform.mx*s,o=this._transform.my*s,a=this._transform.bx*s,h=this._transform.by*s,l=n.dotColor||"#333",c=(n.dotRadius||3)*s,u=n.hoverColor||"#cc6acc",p=(n.hoverRadius||6)*s,d=n.hoverVertex;let _=null;d&&(_=[d[0]*r+a,d[1]*o+h]),i.fillStyle=l,i.beginPath(),t.forEach(t=>{t&&t.forEach(t=>{t.forEach(t=>{const n=t>=0?t:~t,s=e.getArcIter(n);for(;s.hasNext();){const t=s.x*r+a,e=s.y*o+h;_&&Math.abs(t-_[0])<1&&Math.abs(e-_[1])<1||(i.moveTo(t+c,e),i.arc(t,e,c,0,2*Math.PI))}})})}),i.fill(),_&&(i.fillStyle=u,i.beginPath(),"interpolated"===n.hoverType?i.rect(_[0]-p,_[1]-p,2*p,2*p):i.arc(_[0],_[1],p,0,2*Math.PI),i.fill())}drawPolygonFill(t,e,n,i,s){if(!e.getShapeIter)return;const r=this._ctx,o=this._pixelRatio,a=this._transform.mx*o,h=this._transform.my*o,l=this._transform.bx*o,c=this._transform.by*o;r.fillStyle=n;const u="number"==typeof s&&1!==s,p=r.globalAlpha;u&&(r.globalAlpha=p*Math.max(0,Math.min(1,s)));let d=0;r.beginPath();for(let n=0;n<t.length;n++){const s=t[n];if(!s)continue;let o=!0;if(i){o=!1;for(const t of s){for(const e of t){if(i(e>=0?e:~e)){o=!0;break}}if(o)break}}if(o){d>0&&d>=100&&(r.fill("evenodd"),r.beginPath(),d=0);for(const t of s){const n=e.getShapeIter(t);if(!n.hasNext())continue;let i,s,o=2*(n.x*a+l)|0,u=2*(n.y*h+c)|0;for(r.moveTo(o/2,u/2);n.hasNext();)i=o,s=u,o=2*(n.x*a+l)|0,u=2*(n.y*h+c)|0,o===i&&u===s||r.lineTo(o/2,u/2);r.closePath()}d++}}d>0&&r.fill("evenodd"),u&&(r.globalAlpha=p)}drawDrawingOverlay(t){const e=this._ctx,n=this._pixelRatio,i=this._transform.mx*n,s=this._transform.my*n,r=this._transform.bx*n,o=this._transform.by*n,a=t.drawColor||"#0078ff",h=t.vertices,l=t.cursorCoord,c=t=>[t[0]*i+r,t[1]*s+o];if(h.length>0){e.strokeStyle=a,e.lineWidth=2*n,e.lineJoin="round",e.lineCap="round",e.setLineDash([]),e.beginPath();const t=c(h[0]);e.moveTo(t[0],t[1]);for(let t=1;t<h.length;t++){const n=c(h[t]);e.lineTo(n[0],n[1])}e.stroke()}if(h.length>0&&l){const i=c(h[h.length-1]),s=c(l);if(e.strokeStyle=a,e.lineWidth=1.5*n,e.setLineDash([6*n,4*n]),e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(s[0],s[1]),"polygon"===t.geometryType&&h.length>=2){const t=c(h[0]);e.moveTo(s[0],s[1]),e.lineTo(t[0],t[1])}e.stroke(),e.setLineDash([])}if(h.length>0){const t=4*n;e.fillStyle=a,e.beginPath();for(const n of h){const i=c(n);e.moveTo(i[0]+t,i[1]),e.arc(i[0],i[1],t,0,2*Math.PI)}e.fill()}if(t.snapCoord){const i=c(t.snapCoord),s=7*n;e.strokeStyle="#ff4444",e.lineWidth=2*n,e.beginPath(),"edge"===t.snapKind?e.rect(i[0]-s,i[1]-s,2*s,2*s):e.arc(i[0],i[1],s,0,2*Math.PI),e.stroke()}}clear(){this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){const n=this._pixelRatio;this._canvas.width=t*n,this._canvas.height=e*n,this._canvas.style.width=t+"px",this._canvas.style.height=e+"px"}}class rt{_painter;constructor(t){this._painter=t}render(t,e,n){"vertex"===t&&e?this._renderVertexOverlay(e):"draw"===t&&n&&this._painter.drawDrawingOverlay(n)}_renderVertexOverlay(t){const e=t.arcs;"polygon"===t.geometryType&&t.polygonFill&&this._painter.drawPolygonFill(t.shapes,e,t.polygonFill),this._painter.drawVertexDots(t.shapes,e,{dotColor:"#333",dotRadius:3,hoverVertex:t.hoverVertex,hoverType:t.hoverType??"vertex",hoverColor:"#cc6acc",hoverRadius:6})}}class ot{opts;label;invalidatesPriorCommands=!0;constructor(t){this.opts=t,this.label=t.label}do(){this.opts.source.setDataset(this.opts.after)}undo(){this.opts.source.setDataset(this.opts.before)}}const at=Object.freeze({ok:!0,value:void 0});function ht(t){return{ok:!0,value:t}}const lt=Object.freeze({notFound:(t,e)=>({ok:!1,error:{kind:"not-found",what:t,id:e}}),validation:(t,e)=>({ok:!1,error:{kind:"validation",field:t,reason:e}}),expressionDisabled:t=>({ok:!1,error:{kind:"expression-disabled",operation:t}}),mapshaper:(t,e)=>({ok:!1,error:{kind:"mapshaper",cause:t,...e??{}}}),hostRemoved:()=>({ok:!1,error:{kind:"host-removed"}})}),ct=new Set(["rename-fields","rename-layers","sort","sort-features","filter-fields","drop","target","uniq","unique-features"]),ut=new Set(["buffer","clean","dissolve","mosaic","union","snap","check-geometry","simplify"]);function pt(t){const e=[],n=/(?:^|\s)-([a-z][a-z-]*)/gi;let i;for(;null!==(i=n.exec(t));)e.push(i[1].toLowerCase());return e}function dt(t,e,n,i){if(!1===n)return!1;if(!0===n)return!0;if(0===t.length)return e>=i;if(t.every(t=>ct.has(t)))return!1;return e>=(t.some(t=>ut.has(t))?Math.floor(.5*i):i)}const _t={clip:"shape-count",erase:"shape-count",dissolve:"shape-count",explode:"shape-count",filter:"shape-count","filter-geom":"shape-count","filter-islands":"shape-count","filter-slivers":"shape-count","merge-layers":"shape-count",mosaic:"shape-count",union:"shape-count",divide:"shape-count",points:"shape-count",lines:"shape-count",polygons:"shape-count",innerlines:"shape-count",split:"shape-count","split-layer":"shape-count",uniq:"shape-count",buffer:"shape-count",drop:"shape-count","intersection-points":"shape-count",clean:"topology-only",snap:"topology-only",simplify:"topology-only","rebuild-topology":"topology-only",each:"attribute-only",join:"attribute-only","rename-fields":"attribute-only","rename-layers":"attribute-only","filter-fields":"attribute-only","data-fill":"attribute-only",sort:"attribute-only",proj:"crs-only",project:"crs-only",affine:"crs-only"};function ft(t){let e="attribute-only",n=!1;for(const i of t){if("target"===i)continue;const t=_t[i];if(void 0===t)return"unknown";n=!0,e=yt(e,t)}return n?e:"unknown"}const mt={"attribute-only":0,"crs-only":1,"topology-only":2,"shape-count":3,unknown:3};function yt(t,e){return mt[t]>=mt[e]?t:e}async function gt(t,e,n,i,s){if(t._removed)return lt.hostRemoved();const r=t._sources.get(e);if(!r)return lt.notFound("source",e);const o=r.getDataset();if(!o)return lt.notFound("source",e);const a=Y().copyDataset(o);let h,l=!1;if(t._workerPool){const e=o.arcs?.getPointCount?.()??0,i=function(t,e,n,i){return!1!==n&&(!0===n||dt(pt(t),e,n,i))}(n,e,t._workerMode,t._workerThreshold),s=t._workerRouting;l=s?s({cmd:n,heads:pt(n),vertexCount:e,mode:t._workerMode,threshold:t._workerThreshold,defaultDecision:i}):i}try{h=l?await async function(t,e,n,i,s){if(!t._workerPool)throw new Error("_runViaWorker: worker pool not available");const r=t._workerPool.reserveId(),o=e.arcs?.getPointCount?.()??0,a="undefined"!=typeof performance?performance.now():Date.now();t.fire("workerjobstart",{id:r,cmd:n,label:i,datasetVertexCount:o});try{const i=await Y().exportDatasetsToPack([e],{compact:!1}),o=wt(i),h=t._workerPool.dispatchWithId(r,n,i,s,o),l=await h,c=await Y().restoreSessionData(l);if(!c.datasets||0===c.datasets.length)throw new Error("worker: no dataset in response");const u=("undefined"!=typeof performance?performance.now():Date.now())-a;return t.fire("workerjobend",{id:r,ok:!0,durationMs:u}),c.datasets[0]}catch(e){const n=("undefined"!=typeof performance?performance.now():Date.now())-a;throw t.fire("workerjobend",{id:r,ok:!1,durationMs:n,errorMessage:e?.message??String(e)}),e}}(t,o,n,i,s):await Y().runOnDataset(n,o,s)}catch(e){return t._removed?lt.hostRemoved():(t.fire("error",{error:e}),lt.mapshaper(e,{cmd:n,operation:i}))}return t._removed?lt.hostRemoved():xt(t,e,a,h,i,function(t){return ft(pt(t))}(n))}async function vt(t,e,n,i,s){if(t._removed)return lt.hostRemoved();const r=t._sources.get(e);if(!r)return lt.notFound("source",e);const o=r.getDataset();if(!o)return lt.notFound("source",e);const a=Y().copyDataset(o),h=n.map(t=>t.name);let l,c=!1;if(t._workerPool){const e=o.arcs?.getPointCount?.()??0,n=dt(h,e,t._workerMode,t._workerThreshold),i=t._workerRouting;c=i?i({cmd:h.map(t=>`-${t}`).join(" "),heads:h,vertexCount:e,mode:t._workerMode,threshold:t._workerThreshold,defaultDecision:n}):n}try{l=c?await async function(t,e,n,i,s){if(!t._workerPool)throw new Error("_runViaWorkerParsed: worker pool not available");const r=t._workerPool.reserveId(),o=e.arcs?.getPointCount?.()??0,a="undefined"!=typeof performance?performance.now():Date.now(),h=n.map(t=>`-${t.name}`).join(" ");t.fire("workerjobstart",{id:r,cmd:h,label:i,datasetVertexCount:o});try{const i=await Y().exportDatasetsToPack([e],{compact:!1}),o=wt(i),h=t._workerPool.dispatchWithId(r,n,i,s,o),l=await h,c=await Y().restoreSessionData(l);if(!c.datasets||0===c.datasets.length)throw new Error("worker: no dataset in response");const u=("undefined"!=typeof performance?performance.now():Date.now())-a;return t.fire("workerjobend",{id:r,ok:!0,durationMs:u}),c.datasets[0]}catch(e){const n=("undefined"!=typeof performance?performance.now():Date.now())-a;throw t.fire("workerjobend",{id:r,ok:!1,durationMs:n,errorMessage:e?.message??String(e)}),e}}(t,o,n,i,s):await Y().runOnDatasetParsed(n,o,s)}catch(e){return t._removed?lt.hostRemoved():(t.fire("error",{error:e}),lt.mapshaper(e,{operation:i}))}return t._removed?lt.hostRemoved():xt(t,e,a,l,i,ft(h))}function xt(t,e,n,i,s,r="unknown"){const o=t._sources.get(e);return o?(t._activeTransaction&&t._activeTransaction._captureFirstTouch(e,n),o.setDataset(i),t._history.push(new ot({source:o,before:n,after:i,label:s})),t._history.isCapturing()||t._fireHistoryChange(),function(t){return"shape-count"===t||"topology-only"===t||"unknown"===t}(r)&&t._fireSelectionChange(t._selection.clear()),t._scheduleRender(),at):lt.notFound("source",e)}function wt(t){const e=[],n=new Set,i=t=>{if(t&&"object"==typeof t){if(t instanceof Uint8Array){const i=t.buffer;return void(i instanceof ArrayBuffer&&!n.has(i)&&(n.add(i),e.push(i)))}if(t instanceof ArrayBuffer)n.has(t)||(n.add(t),e.push(t));else if(Array.isArray(t))for(const e of t)i(e);else for(const e of Object.keys(t))i(t[e])}};return i(t),e}function bt(t,e){for(let n=0;n<t.length;n++){const i=t[n];if(i){if(nt(i,n)===e)return i;if(i.name===e)return i;if(i.id===e)return i}}return null}class Ct{_sources;constructor(t){this._sources=t}resolve(t,e){const n=this._sources.get(t);return n?bt(n.getLayers(),e):null}resolveInLayers(t,e){return bt(t,e)}}async function St(t,e,n){const i=t.host._sources.get(e.source);if(!i)return lt.notFound("source",e.source);const s=i.getDataset();if(!s)return lt.notFound("source",e.source);if(!bt(s.layers,e.target))return lt.notFound("layer",e.target);const r="string"==typeof e.mask&&e.mask.length>0;if(r===Array.isArray(e.bbox))return lt.validation(r?"mask":"bbox","must supply exactly one of `mask` or `bbox`");if(r){if(!bt(s.layers,e.mask))return lt.notFound("mask",e.mask)}else{const t=e.bbox;if(4!==t.length||!t.every(t=>Number.isFinite(t)))return lt.validation("bbox","must be [xmin, ymin, xmax, ymax] of finite numbers");if(t[0]>=t[2]||t[1]>=t[3])return lt.validation("bbox","must satisfy xmin<xmax and ymin<ymax")}const o=r?{source:e.mask}:{bbox:e.bbox};e.cleanup&&(o.cleanup=!0),e.removeSlivers&&(o.remove_slivers=!0);const a="clip"===n?"Clip":"Erase";return t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:n,options:o}],`${a} ${e.target}`)}const At="__emap_merge";async function Mt(t){const e=t.host._selection.getAll();if(0===e.length)return lt.validation("selection","selection is empty");const n=e[0].source,i=e[0].layer;for(const t of e)if(t.source!==n||t.layer!==i)return lt.validation("selection","selection spans multiple sources or layers");const s=t.host.layers.resolve(n,i);if(!s)return lt.notFound("layer",i);if(!function(t,e){const n=t.data?.getRecords?.();if(!n||0===n.length)return!1;const i=new Set(e);for(let t=0;t<n.length;t++){const e=n[t]??{};e[At]=i.has(t)?"M":`k_${t}`,n[t]=e}return!0}(s,e.map(t=>t.id).slice().sort((t,e)=>t-e)))return lt.validation("layer","layer has no data table; cannot stamp discriminator");const r=function(t,e){const n={fields:[At]},i=e.data?.getFields?.();if(i&&i.length>0){const t=i.filter(t=>t!==At&&!t.includes(","));t.length>0&&(n.copy_fields=t)}return[{name:"target",options:{target:t}},{name:"dissolve",options:n},{name:"filter-fields",options:{fields:[At],invert:!0}}]}(i,s),o=`Merge ${e.length} feature${e.length>1?"s":""}`,a=await t.runDatasetCommandParsed(n,r,o);return a.ok||function(t){const e=t.data?.getRecords?.();if(!e)return;for(const t of e)t&&At in t&&delete t[At]}(s),a}const Et=new Set(["left","right","outer","inner"]),kt=new Set(["flat","round"]),Dt=/^-?\d+(\.\d+)?$/;function It(t){return"number"==typeof t&&Number.isInteger(t)&&t>0}async function Pt(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);const s=bt(i.layers,e.target);if(!s)return lt.notFound("layer",e.target);if("number"==typeof e.radius){if(!Number.isFinite(e.radius)||e.radius<=0)return lt.validation("radius","must be a positive finite number")}else{if("string"!=typeof e.radius||0===e.radius.trim().length)return lt.validation("radius","must be a positive number or non-empty expression");if(Dt.test(e.radius)&&Number(e.radius)<=0)return lt.validation("radius","numeric string must be a positive number")}if("string"==typeof e.radius&&!t.host._allowExpressionEvaluation([e.radius],"bufferLayer"))return lt.expressionDisabled("bufferLayer");if(void 0!==e.vertices&&!It(e.vertices))return lt.validation("vertices","must be a positive integer");if(void 0!==e.arcQuality&&!It(e.arcQuality))return lt.validation("arcQuality","must be a positive integer");if(void 0!==e.sliceLength&&!It(e.sliceLength))return lt.validation("sliceLength","must be a positive integer");if(void 0!==e.backtrack&&!It(e.backtrack))return lt.validation("backtrack","must be a positive integer");if(void 0!==e.tolerance&&!("number"==typeof(r=e.tolerance)&&Number.isFinite(r)&&r>0))return lt.validation("tolerance","must be a positive finite number");var r;if(void 0!==e.type&&!Et.has(e.type))return lt.validation("type","must be one of: left, right, outer, inner");if(void 0!==e.capStyle&&!kt.has(e.capStyle))return lt.validation("capStyle","must be one of: flat, round");void 0!==e.type&&"polygon"===s.geometry_type&&console.warn(`bufferLayer: type="${e.type}" is intended for polyline layers; applying to polygon layer "${e.target}" may produce unexpected output.`);const o={radius:String(e.radius)};void 0!==e.capStyle&&(o.cap_style=e.capStyle),void 0!==e.vertices&&(o.vertices=e.vertices),void 0!==e.arcQuality&&(o.arc_quality=e.arcQuality),void 0!==e.tolerance&&(o.tolerance=e.tolerance),void 0!==e.type&&(o.type=e.type),!0===e.planar&&(o.planar=!0),!0===e.v2&&(o.v2=!0),void 0!==e.sliceLength&&(o.slice_length=e.sliceLength),void 0!==e.backtrack&&(o.backtrack=e.backtrack);const a=[{name:"target",options:{target:e.target}},{name:"buffer",options:o}];return t.runDatasetCommandParsed(e.source,a,`Buffer ${e.target}`)}class Tt{_emap;constructor(t){this._emap=t}get _ctx(){return{host:this._emap,runDatasetCommand:(t,e,n,i)=>gt(this._emap,t,e,n,i),runDatasetCommandParsed:(t,e,n,i)=>vt(this._emap,t,e,n,i),applyDatasetReplace:(t,e,n,i)=>xt(this._emap,t,e,n,i)}}clipLayer(t){return async function(t,e){return St(t,e,"clip")}(this._ctx,t)}eraseLayer(t){return async function(t,e){return St(t,e,"erase")}(this._ctx,t)}dissolveLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=Array.isArray(e.fields)&&e.fields.length>0;if(void 0!==e.field&&s)return lt.validation("field","`field` and `fields` are mutually exclusive");if(void 0!==e.field&&("string"!=typeof e.field||e.field.includes(",")))return lt.validation("field","field name must be a string without `,`");if(!t.host._allowExpressionEvaluation([e.calc,e.where],"dissolveLayer"))return lt.expressionDisabled("dissolveLayer");const r={};if(e.field)r.fields=[e.field];else if(s){const t=e.fields.filter(t=>"string"==typeof t&&!t.includes(","));t.length>0&&(r.fields=t)}const o=t=>Array.isArray(t)?t.filter(t=>"string"==typeof t&&!t.includes(",")):[],a=o(e.sumFields);a.length>0&&(r.sum_fields=a);const h=o(e.copyFields);return h.length>0&&(r.copy_fields=h),e.calc&&e.calc.trim()&&(r.calc=e.calc),e.where&&e.where.trim()&&(r.where=e.where),e.multipart&&(r.multipart=!0),e.name&&e.name.trim()&&(r.name=e.name),e.noReplace&&(r.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"dissolve",options:r}],`Dissolve ${e.target}`)}(this._ctx,t)}bufferLayer(t){return Pt(this._ctx,t)}applyExpression(t){return async function(t,e){if(!e.expression||!e.expression.trim())return lt.validation("expression","must be a non-empty expression");const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.expression,e.where],"applyExpression"))return lt.expressionDisabled("applyExpression");const s={expression:e.expression};return e.where&&e.where.trim()&&(s.where=e.where),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"each",options:s}],`Update ${e.target}`)}(this._ctx,t)}filterFeatures(t){return async function(t,e){const n=!(!e.expression||!e.expression.trim());if(!n&&!e.removeEmpty)return lt.validation("expression","must supply `expression` or `removeEmpty: true`");const i=t.host._sources.get(e.source);if(!i)return lt.notFound("source",e.source);const s=i.getDataset();if(!s)return lt.notFound("source",e.source);if(!bt(s.layers,e.target))return lt.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.expression],"filterFeatures"))return lt.expressionDisabled("filterFeatures");const r={};return n&&(r.expression=e.expression),e.invert&&(r.invert=!0),e.removeEmpty&&(r.remove_empty=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter",options:r}],`Filter ${e.target}`)}(this._ctx,t)}filterIslands(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s="number"==typeof e.minArea&&Number.isFinite(e.minArea),r="number"==typeof e.minVertices&&Number.isInteger(e.minVertices)&&e.minVertices>0;if(!s&&!r)return lt.validation("minArea","must supply at least one of `minArea` or `minVertices`");if(s&&e.minArea<0)return lt.validation("minArea","must be non-negative");const o={};return s&&(o.min_area=String(e.minArea)),r&&(o.min_vertices=e.minVertices),e.removeEmpty&&(o.remove_empty=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-islands",options:o}],`Filter islands ${e.target}`)}(this._ctx,t)}filterSlivers(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if("number"!=typeof e.minArea||!Number.isFinite(e.minArea)||e.minArea<=0)return lt.validation("minArea","must be a positive finite number");const s={min_area:String(e.minArea)};return e.weighted&&(s.weighted=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-slivers",options:s}],`Filter slivers ${e.target}`)}(this._ctx,t)}filterGeom(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=e.bbox;return Array.isArray(s)&&4===s.length&&s.every(t=>Number.isFinite(t))?s[0]>=s[2]||s[1]>=s[3]?lt.validation("bbox","must satisfy xmin<xmax and ymin<ymax"):t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-geom",options:{bbox:[s[0],s[1],s[2],s[3]]}}],`Filter geom ${e.target}`):lt.validation("bbox","must be [xmin, ymin, xmax, ymax] of finite numbers")}(this._ctx,t)}explodeLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();return i?bt(i.layers,e.target)?t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"explode",options:{}}],`Explode ${e.target}`):lt.notFound("layer",e.target):lt.notFound("source",e.source)}(this._ctx,t)}innerlinesLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.where],"innerlinesLayer"))return lt.expressionDisabled("innerlinesLayer");const s={};return e.where&&e.where.trim()&&(s.where=e.where),e.name&&e.name.trim()&&(s.name=e.name),e.noReplace&&(s.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"innerlines",options:s}],`Innerlines ${e.target}`)}(this._ctx,t)}snapLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s={};return"number"==typeof e.interval&&(s.interval=String(e.interval)),e.endpoints&&(s.endpoints=!0),"number"==typeof e.precision&&(s.precision=e.precision),e.fixGeometry&&(s.fix_geometry=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"snap",options:s}],`Snap ${e.target}`)}(this._ctx,t)}cleanLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=t=>void 0===t||"number"==typeof t&&Number.isFinite(t)&&t>=0;if(!s(e.gapFillArea))return lt.validation("gapFillArea","must be a finite non-negative number");if(!s(e.sliverControl))return lt.validation("sliverControl","must be a finite non-negative number");if(!s(e.snapInterval))return lt.validation("snapInterval","must be a finite non-negative number");if(void 0!==e.overlapRule){const t=["min-id","max-id","min-area","max-area"];if(!t.includes(e.overlapRule))return lt.validation("overlapRule",`must be one of ${t.join(", ")}`)}const r={};return void 0!==e.gapFillArea&&(r.gap_fill_area=String(e.gapFillArea)),void 0!==e.sliverControl&&(r.sliver_control=e.sliverControl),void 0!==e.snapInterval&&(r.snap_interval=String(e.snapInterval)),e.noSnap&&(r.no_snap=!0),e.allowOverlaps&&(r.allow_overlaps=!0),void 0!==e.overlapRule&&(r.overlap_rule=e.overlapRule),e.allowEmpty&&(r.allow_empty=!0),e.rewind&&(r.rewind=!0),e.onlyArcs&&(r.only_arcs=!0),e.noArcDissolve&&(r.no_arc_dissolve=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"clean",options:r}],`Clean ${e.target}`)}(this._ctx,t)}mosaicLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!t.host._allowExpressionEvaluation([e.calc],"mosaicLayer"))return lt.expressionDisabled("mosaicLayer");const s={};return"number"==typeof e.snapInterval&&(s.snap_interval=String(e.snapInterval)),e.noSnap&&(s.no_snap=!0),e.noReplace&&(s.no_replace=!0),e.name&&e.name.trim()&&(s.name=e.name),e.calc&&e.calc.trim()&&(s.calc=e.calc),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"mosaic",options:s}],`Mosaic ${e.target}`)}(this._ctx,t)}unionLayers(t){return async function(t,e){if(!e.targets||e.targets.length<2)return lt.validation("targets","must supply at least 2 target layers");const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);for(const t of e.targets){if("string"!=typeof t||t.includes(","))return lt.validation("targets",`target name must not contain ',': ${String(t)}`);if(!bt(i.layers,t))return lt.notFound("layer",t)}const s=e.targets.join(","),r={};if(e.fields&&e.fields.length>0){const t=e.fields.filter(t=>!t.includes(","));t.length>0&&(r.fields=t)}return e.name&&e.name.trim()&&(r.name=e.name),e.noReplace&&(r.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:s}},{name:"union",options:r}],`Union ${s}`)}(this._ctx,t)}divideLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);const s=bt(i.layers,e.target);if(!s)return lt.notFound("layer",e.target);if("polyline"!==s.geometry_type)return lt.validation("target",`expected polyline layer, got ${s.geometry_type??"unknown"}`);const r=bt(i.layers,e.divider);if(!r)return lt.notFound("divider",e.divider);if("polygon"!==r.geometry_type)return lt.validation("divider",`expected polygon layer, got ${r.geometry_type??"unknown"}`);const o={source:e.divider};if(e.fields&&e.fields.length>0){const t=e.fields.filter(t=>!t.includes(","));t.length>0&&(o.fields=t)}return e.force&&(o.force=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"divide",options:o}],`Divide ${e.target}`)}(this._ctx,t)}pointsLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);const s=bt(i.layers,e.target);if(!s)return lt.notFound("layer",e.target);const r=s.geometry_type;switch(e.type){case"centroid":case"inner":if("polygon"!==r)return lt.validation("type",`${e.type} requires polygon target, got ${r??"unknown"}`);break;case"midpoints":case"interpolated":if("polyline"!==r)return lt.validation("type",`${e.type} requires polyline target, got ${r??"unknown"}`);break;case"vertices":case"endpoints":if("polygon"!==r&&"polyline"!==r)return lt.validation("type",`${e.type} requires polygon/polyline target, got ${r??"unknown"}`);break;default:return lt.validation("type",`unknown type: ${String(e.type)}`)}if("interpolated"===e.type&&!("number"==typeof e.interval&&e.interval>0))return lt.validation("interval","interpolated points require a positive interval");const o={[e.type]:!0};return"interpolated"===e.type&&(o.interval=String(e.interval)),e.name&&e.name.trim()&&(o.name=e.name),e.noReplace&&(o.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"points",options:o}],`Points ${e.target}`)}(this._ctx,t)}linesLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);const s=bt(i.layers,e.target);if(!s)return lt.notFound("layer",e.target);if("polygon"!==s.geometry_type)return lt.validation("target",`expected polygon layer, got ${s.geometry_type??"unknown"}`);const r={},o=e.fields?.filter(t=>"string"==typeof t&&!t.includes(","));return o&&o.length>0&&(r.fields=o),e.name&&e.name.trim()&&(r.name=e.name),e.noReplace&&(r.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"lines",options:r}],`Lines ${e.target}`)}(this._ctx,t)}polygonsLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);const s=bt(i.layers,e.target);if(!s)return lt.notFound("layer",e.target);if("polyline"!==s.geometry_type)return lt.validation("target",`expected polyline layer, got ${s.geometry_type??"unknown"}`);const r={};return"number"==typeof e.gapTolerance&&e.gapTolerance>0&&(r.gap_tolerance=String(e.gapTolerance)),e.fromRings&&(r.from_rings=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"polygons",options:r}],`Polygons ${e.target}`)}(this._ctx,t)}simplifyLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(void 0!==e.target&&!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(1!==[void 0!==e.percentage,void 0!==e.interval,void 0!==e.resolution].filter(Boolean).length)return lt.validation("threshold","must supply exactly one of percentage, interval, resolution");const s={};if(void 0!==e.percentage){const t=e.percentage;if(!Number.isFinite(t)||t<0||t>100)return lt.validation("percentage","must be a finite number in [0, 100]");s.percentage=`${t}%`}else if(void 0!==e.interval){const t=e.interval;if(!Number.isFinite(t)||t<=0)return lt.validation("interval","must be a positive finite number");s.interval=String(t)}else{const t=e.resolution;if(!/^\d+x\d+$/.test(t))return lt.validation("resolution","must match `WIDTHxHEIGHT` (digits)");s.resolution=t}if(void 0!==e.weighting&&void 0!==e.method&&"weighted"!==e.method)return lt.validation("weighting",`weighting only applies to method='weighted', not ${e.method}`);e.method&&(s.method=e.method),"number"==typeof e.weighting&&Number.isFinite(e.weighting)&&(s.weighting=e.weighting),e.planar&&(s.planar=!0),e.keepShapes&&(s.keep_shapes=!0),e.lockBox&&(s.lock_box=!0),e.noRepair&&(s.no_repair=!0);const r=[];e.target&&r.push({name:"target",options:{target:e.target}}),r.push({name:"simplify",options:s});const o=`Simplify ${e.target??e.source}`;return t.runDatasetCommandParsed(e.source,r,o)}(this._ctx,t)}projectLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(void 0!==e.target&&!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=(e.crs??"").trim();if(0===s.length)return lt.validation("crs","must be a non-empty CRS string");const r={crs:s};e.init&&e.init.trim()&&(r.init=e.init),e.densify&&(r.densify=!0);const o=[];e.target&&o.push({name:"target",options:{target:e.target}}),o.push({name:"proj",options:r});const a=`Project ${e.target??e.source}`;return t.runDatasetCommandParsed(e.source,o,a)}(this._ctx,t)}affineLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(void 0!==e.target&&!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=Array.isArray(e.shift),r="number"==typeof e.rotate&&0!==e.rotate,o=void 0!==e.scale&&("number"==typeof e.scale?1!==e.scale:Array.isArray(e.scale));if(!s&&!r&&!o)return lt.validation("shift","must supply at least one of `shift`, `rotate`, or `scale`");if(s){const t=e.shift;if(2!==t.length||!t.every(t=>Number.isFinite(t)))return lt.validation("shift","must be [dx, dy] of finite numbers")}if(r&&!Number.isFinite(e.rotate))return lt.validation("rotate","must be a finite number (degrees)");if(o&&Array.isArray(e.scale)){const t=e.scale;if(2!==t.length||!t.every(t=>Number.isFinite(t)&&0!==t))return lt.validation("scale","must be [sx, sy] of nonzero finite numbers")}else if(o&&"number"==typeof e.scale&&(!Number.isFinite(e.scale)||0===e.scale))return lt.validation("scale","must be a nonzero finite number");if(!(void 0===e.anchor||Array.isArray(e.anchor)&&2===e.anchor.length&&e.anchor.every(t=>Number.isFinite(t))))return lt.validation("anchor","must be [x, y] of finite numbers");if(!t.host._allowExpressionEvaluation([e.where],"affineLayer"))return lt.expressionDisabled("affineLayer");const a={};s&&(a.shift=[String(e.shift[0]),String(e.shift[1])]),r&&(a.rotate=e.rotate),o&&(a.scale=(e.scale,e.scale)),e.anchor&&(a.anchor=[e.anchor[0],e.anchor[1]]),e.where&&e.where.trim()&&(a.where=e.where);const h=[];e.target&&h.push({name:"target",options:{target:e.target}}),h.push({name:"affine",options:a});const l=`Affine ${e.target??e.source}`;return t.runDatasetCommandParsed(e.source,h,l)}(this._ctx,t)}renameLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=(e.name??"").trim();if(0===s.length)return lt.validation("name","must be a non-empty string");if(s.includes(","))return lt.validation("name","must not contain `,`");if(s!==e.target&&i.layers.some(t=>(t?.name??"")===s))return lt.validation("name",`another layer already named '${s}'`);return t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"rename-layers",options:{names:[s]}}],`Rename ${e.target} → ${s}`)}(this._ctx,t)}mergeLayers(t){return async function(t,e){if(!e.targets||e.targets.length<2)return lt.validation("targets","must supply at least 2 target layers");const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);for(const t of e.targets)if("string"!=typeof t||t.includes(","))return lt.validation("targets",`target name must not contain ',': ${String(t)}`);const s=e.targets.map(t=>bt(i.layers,t));for(let t=0;t<s.length;t++)if(!s[t])return lt.notFound("layer",e.targets[t]);if(!e.force){const t=s[0]?.geometry_type;if(!s.every(e=>e?.geometry_type===t))return lt.validation("targets","targets have mixed geometry types; pass `force: true` to merge anyway")}const r=e.targets.join(","),o={};return e.name&&e.name.trim()&&(o.name=e.name),e.force&&(o.force=!0),e.flatten&&(o.flatten=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:r}},{name:"merge-layers",options:o}],`Merge ${r}`)}(this._ctx,t)}splitLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=(e.expression??"").trim();if(0===s.length)return lt.validation("expression","must be a non-empty expression");if(!t.host._allowExpressionEvaluation([s],"splitLayer"))return lt.expressionDisabled("splitLayer");const r={expression:s};return e.noReplace&&(r.no_replace=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"split",options:r}],`Split ${e.target}`)}(this._ctx,t)}dropLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();return i?bt(i.layers,e.target)?t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"drop",options:{}}],`Drop ${e.target}`):lt.notFound("layer",e.target):lt.notFound("source",e.source)}(this._ctx,t)}sortFeatures(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=(e.expression??"").trim();if(0===s.length)return lt.validation("expression","must be a non-empty expression");if(!t.host._allowExpressionEvaluation([s],"sortFeatures"))return lt.expressionDisabled("sortFeatures");const r={expression:s};return e.descending&&(r.descending=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"sort",options:r}],`Sort ${e.target}`)}(this._ctx,t)}uniqueFeatures(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);const s=(e.expression??"").trim();if(0===s.length)return lt.validation("expression","must be a non-empty expression");if(!t.host._allowExpressionEvaluation([s],"uniqueFeatures"))return lt.expressionDisabled("uniqueFeatures");if(void 0!==e.maxCount&&!("number"==typeof e.maxCount&&e.maxCount>0))return lt.validation("maxCount","must be a positive number");const r={expression:s};return void 0!==e.maxCount&&(r.max_count=e.maxCount),e.invert&&(r.invert=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"uniq",options:r}],`Uniq ${e.target}`)}(this._ctx,t)}filterFields(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!Array.isArray(e.fields)||0===e.fields.length)return lt.validation("fields","must be a non-empty array");for(const t of e.fields){if("string"!=typeof t||0===t.trim().length)return lt.validation("fields",`field name must be a non-empty string: ${String(t)}`);if(t.includes(","))return lt.validation("fields",`field name must not contain ',': ${t}`)}const s={fields:e.fields.slice()};return e.invert&&(s.invert=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"filter-fields",options:s}],`Filter fields ${e.target}`)}(this._ctx,t)}renameFields(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!e.mapping||"object"!=typeof e.mapping)return lt.validation("mapping","must be an object of { oldName: newName }");const s=Object.entries(e.mapping);if(0===s.length)return lt.validation("mapping","must contain at least one rename pair");const r=[];for(const[t,e]of s){const n=(t??"").trim(),i=(e??"").trim();if(0===n.length||0===i.length)return lt.validation("mapping",`field names must be non-empty: ${t}=${e}`);if(n.includes(",")||n.includes("=")||i.includes(",")||i.includes("="))return lt.validation("mapping",`field names must not contain ',' or '=': ${t}=${e}`);r.push(`${n}=${i}`)}return t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"rename-fields",options:{fields:r}}],`Rename fields ${e.target}`)}(this._ctx,t)}joinTable(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!Array.isArray(e.keys)||2!==e.keys.length)return lt.validation("keys","must be a 2-element [targetKey, sourceKey] array");const[s,r]=e.keys.map(t=>"string"==typeof t?t.trim():"");if(0===s.length||0===r.length)return lt.validation("keys","both keys must be non-empty strings");if(s.includes(",")||r.includes(","))return lt.validation("keys","keys must not contain `,`");let o,a;const h=e.data;if(!h||"object"!=typeof h)return lt.validation("data","must be { csv } | { json } | { layer }");if("layer"in h&&"string"==typeof h.layer&&h.layer.trim().length>0)o=h.layer.trim();else if("csv"in h&&("string"==typeof h.csv||h.csv instanceof Uint8Array)){const t=".emap-join.csv";o=t,a={[t]:h.csv}}else{if(!("json"in h)||void 0===h.json)return lt.validation("data","must contain one of `csv`, `json`, or `layer`");{const t=".emap-join.json";let e;e="string"==typeof h.json||h.json instanceof Uint8Array?h.json:JSON.stringify(h.json),o=t,a={[t]:e}}}if(!t.host._allowExpressionEvaluation([e.where,e.calc],"joinTable"))return lt.expressionDisabled("joinTable");const l={source:o,keys:[s,r]};if(e.fields&&e.fields.length>0){const t=e.fields.filter(t=>"string"==typeof t&&!t.includes(","));t.length>0&&(l.fields=t)}return e.prefix&&e.prefix.length>0&&(l.prefix=e.prefix),e.where&&e.where.trim().length>0&&(l.where=e.where),e.calc&&e.calc.trim().length>0&&(l.calc=e.calc),e.unjoined&&(l.unjoined=!0),e.unmatched&&(l.unmatched=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"join",options:l}],`Join ${e.target}`,a)}(this._ctx,t)}dataFill(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!bt(i.layers,e.target))return lt.notFound("layer",e.target);if("string"!=typeof e.field||0===e.field.trim().length)return lt.validation("field","must be a non-empty string");if(e.field.includes(",")||e.field.includes("="))return lt.validation("field","must not contain `,` or `=`");if(void 0!==e.weightField){if("string"!=typeof e.weightField||0===e.weightField.trim().length)return lt.validation("weightField","must be a non-empty string when supplied");if(e.weightField.includes(",")||e.weightField.includes("="))return lt.validation("weightField","must not contain `,` or `=`")}const s={field:e.field};return e.weightField&&(s.weight_field=e.weightField),e.contiguous&&(s.contiguous=!0),t.runDatasetCommandParsed(e.source,[{name:"target",options:{target:e.target}},{name:"data-fill",options:s}],`Data fill ${e.target}.${e.field}`)}(this._ctx,t)}rebuildTopology(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(!i.arcs)return at;const s=Y(),r=s.copyDataset(i),o=s.copyDataset(i);try{s.addIntersectionCuts(o,{snap_interval:e.snapInterval,no_snap:e.noSnap,rebuild_topology:e.rebuildTopology})}catch(e){return t.host.fire("error",{error:e}),lt.mapshaper(e,{operation:"rebuildTopology"})}return t.applyDatasetReplace(e.source,r,o,"Rebuild topology")}(this._ctx,t)}checkGeometry(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);if(void 0!==e.target&&!bt(i.layers,e.target))return lt.notFound("layer",e.target);if(!i.arcs)return ht({ok:!0,intersections:[],intersectionCount:0});const s={};void 0!==e.tolerance&&(s.tolerance=e.tolerance);const r=Y().findSegmentIntersections(i.arcs,s).map(t=>({x:t.x,y:t.y}));return ht({ok:0===r.length,intersections:r,intersectionCount:r.length})}(this._ctx,t)}intersectionPointsLayer(t){return async function(t,e){const n=t.host._sources.get(e.source);if(!n)return lt.notFound("source",e.source);const i=n.getDataset();if(!i)return lt.notFound("source",e.source);const s=bt(i.layers,e.target);if(!s)return lt.notFound("layer",e.target);if("polygon"!==s.geometry_type&&"polyline"!==s.geometry_type)return lt.validation("target",`expected polygon/polyline target, got ${s.geometry_type??"unknown"}`);if(!i.arcs)return lt.validation("source","source has no arcs");const r=e.name&&e.name.trim()||`${e.target}-intersections`;if(i.layers.some(t=>t?.name===r))return lt.validation("name",`another layer already named '${r}'`);if(void 0!==e.tolerance&&("number"!=typeof e.tolerance||!Number.isFinite(e.tolerance)||e.tolerance<=0))return lt.validation("tolerance","must be a positive finite number");const o={};void 0!==e.tolerance&&(o.tolerance=e.tolerance);const a=Y(),h=a.copyDataset(i),l=a.copyDataset(i);let c;try{const t=a.findSegmentIntersections(l.arcs,o),n=bt(l.layers,e.target);if(!n)throw new Error("intersectionPointsLayer: target lost in copyDataset");c=a.getIntersectionLayer(t,n,l.arcs),c.name=r,l.layers.push(c)}catch(e){return t.host.fire("error",{error:e}),lt.mapshaper(e,{operation:"intersectionPointsLayer"})}return t.applyDatasetReplace(e.source,h,l,`Intersection points ${e.target}`)}(this._ctx,t)}mergeSelected(){return Mt(this._ctx)}}class Lt{children;label;constructor(t,e){this.children=t,this.label=e}do(){for(const t of this.children)t.do()}undo(){for(let t=this.children.length-1;t>=0;t--)this.children[t].undo()}}function Nt(t){return"polygon"===t.geometry_type||"polyline"===t.geometry_type}function Rt(t){return"point"===t.geometry_type}function Ft(t){t&&(t.editVersion=(t.editVersion??0)+1)}class Gt{opts;label;_mergeAt=Date.now();constructor(t){this.opts=t;const e=t.arcIds.length+t.pointFeatures.length;this.label=`Translate ${e} feature${1===e?"":"s"}`}do(){this._apply(this.opts.dx,this.opts.dy)}undo(){this._apply(-this.opts.dx,-this.opts.dy)}mergeable(t){if(!(t instanceof Gt))return!1;if(t.opts.source!==this.opts.source)return!1;if(Date.now()-t._mergeAt>500)return!1;const e=t.opts.arcIds,n=this.opts.arcIds;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;const i=t.opts.pointFeatures,s=this.opts.pointFeatures;if(i.length!==s.length)return!1;for(let t=0;t<i.length;t++){if(i[t].featureId!==s[t].featureId)return!1;if(i[t].layer!==s[t].layer)return!1}return!0}merge(t){t instanceof Gt&&(this.opts.dx+=t.opts.dx,this.opts.dy+=t.opts.dy,this._mergeAt=Date.now())}_apply(t,e){const{arcs:n,arcIds:i,pointFeatures:s,source:r}=this.opts;if(n&&i.length>0){const s=n.getVertexData?.();if(s){const{xx:r,yy:o,ii:a,nn:h}=s;for(const s of i){const i=a[s],l=h[s];for(let n=i;n<i+l;n++)r[n]+=t,o[n]+=e;n.updateArcBounds?.(s)}}}for(const n of s){const i=n.layer.shapes?.[n.featureId];if(i)for(const n of it(i))n&&n.length>=2&&(n[0]+=t,n[1]+=e)}r.markDisplayArcsDirty?.(),Ft(r.getDataset?.())}}class Ot{opts;label;constructor(t){this.opts=t;const e=t.arcIds.length+t.pointFeatures.length;this.label=t.label??`Transform ${e} feature${1===e?"":"s"}`}do(){this._apply(this.opts.matrix)}undo(){this._apply(jt(this.opts.matrix))}_apply(t){const{arcs:e,arcIds:n,pointFeatures:i,source:s}=this.opts;if(e&&n.length>0){const i=e.getVertexData?.();if(i){const{xx:s,yy:r,ii:o,nn:a}=i;for(const i of n){const n=o[i],h=a[i];for(let e=n;e<n+h;e++){const n=s[e],i=r[e];s[e]=t.a*n+t.c*i+t.tx,r[e]=t.b*n+t.d*i+t.ty}e.updateArcBounds?.(i)}}}for(const e of i){const n=e.layer.shapes?.[e.featureId];if(n)for(const e of it(n))if(e&&e.length>=2){const n=e[0],i=e[1];e[0]=t.a*n+t.c*i+t.tx,e[1]=t.b*n+t.d*i+t.ty}}s.markDisplayArcsDirty?.(),Ft(s.getDataset?.())}}function Bt(t,e=0,n=0){const i=Math.cos(t),s=Math.sin(t);return{a:i,b:s,c:-s,d:i,tx:e-i*e+s*n,ty:n-s*e-i*n}}function zt(t,e,n=0,i=0){return{a:t,b:0,c:0,d:e,tx:n-t*n,ty:i-e*i}}function Ut(t,e){return{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,tx:t.a*e.tx+t.c*e.ty+t.tx,ty:t.b*e.tx+t.d*e.ty+t.ty}}const qt={a:1,b:0,c:0,d:1,tx:0,ty:0};function jt(t){const e=t.a*t.d-t.b*t.c;if(0===e)throw new Error("FeatureAffineCommand: matrix is singular (det=0)");const n=t.d/e,i=-t.b/e,s=-t.c/e,r=t.a/e;return{a:n,b:i,c:s,d:r,tx:-(n*t.tx+s*t.ty),ty:-(i*t.tx+r*t.ty)}}class $t{opts;label;constructor(t){this.opts=t,this.label=`Split ${t.appendedArcs.length} shared arc${1===t.appendedArcs.length?"":"s"}`}do(){const t=this.opts.source.getArcs();if(t){!function(t,e){const n=t.getVertexData?.();if(!n)return;const{xx:i,yy:s,zz:r,nn:o}=n,a=!!r&&e.every(t=>t.zz);let h=0;for(const t of e)h+=t.xx.length;const l=new Float64Array(i.length+h),c=new Float64Array(s.length+h),u=a?new Float64Array(r.length+h):null;l.set(i),c.set(s),u&&r&&u.set(r);let p=i.length;for(const t of e)l.set(t.xx,p),c.set(t.yy,p),u&&t.zz&&u.set(t.zz,p),p+=t.xx.length;const d=new Int32Array(o.length+e.length);d.set(o);for(let t=0;t<e.length;t++)d[o.length+t]=e[t].xx.length;t.updateVertexData(d,l,c,u)}(t,this.opts.appendedArcs);for(const t of this.opts.remaps)t.layer.shapes[t.featureId]=Wt(t.newShape);this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}undo(){const t=this.opts.source.getArcs();if(t){!function(t,e){const n=t.getVertexData?.();if(!n)return;const{xx:i,yy:s,zz:r,nn:o}=n;if(o.length===e)return;if(e>o.length)return;let a=0;for(let t=0;t<e;t++)a+=o[t];const h=new Int32Array(e);h.set(o.subarray(0,e));const l=new Float64Array(i.subarray(0,a)),c=new Float64Array(s.subarray(0,a)),u=r?new Float64Array(r.subarray(0,a)):null;t.updateVertexData(h,l,c,u)}(t,this.opts.originalArcCount);for(const t of this.opts.remaps)t.layer.shapes[t.featureId]=Wt(t.originalShape);this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}}function Vt(t,e,n){const i=t.getArcs();if(!i)return null;const s=i.size();if(0===s||0===e.length)return null;const r=new Uint32Array(s),o=new Uint32Array(s),a=new Set;for(const t of e)a.add(Ht(t.layer,t.featureId));for(const t of n){if(!t.shapes)continue;if(!Nt(t))continue;const e=t.shapes;for(let n=0;n<e.length;n++){const i=e[n];if(!i)continue;const h=a.has(Ht(t,n));for(const t of i)if(Array.isArray(t))for(const e of t){if("number"!=typeof e)continue;const t=e>=0?e:~e;t<0||t>=s||(h?r[t]++:o[t]++)}}}const h=[];for(let t=0;t<s;t++)r[t]>0&&o[t]>0&&h.push(t);if(0===h.length)return null;const l=new globalThis.Map;for(let t=0;t<h.length;t++)l.set(h[t],s+t);const c=i.getVertexData?.();if(!c)return null;const{xx:u,yy:p,zz:d,ii:_,nn:f}=c,m=h.map(t=>{const e=_[t],n=f[t];return{xx:new Float64Array(u.subarray(e,e+n)),yy:new Float64Array(p.subarray(e,e+n)),zz:d?new Float64Array(d.subarray(e,e+n)):null}}),y=[];for(const t of e){if(!Nt(t.layer))continue;const e=t.layer.shapes?.[t.featureId];if(!e)continue;let n=!1;const i=e.map(t=>t.map(t=>{const e=t>=0?t:~t,i=l.get(e);return void 0===i?t:(n=!0,t>=0?i:~i)}));n&&y.push({layer:t.layer,featureId:t.featureId,originalShape:Wt(e),newShape:i})}return 0===y.length?null:{source:t,remaps:y,appendedArcs:m,originalArcCount:s}}function Ht(t,e){return`${t.name??""}#${e}`}function Wt(t){return t.map(t=>t.slice())}class Kt{_emap;constructor(t){this._emap=t}translateSelected(t,e){if(0===t&&0===e)return lt.validation("offset","dx and dy are both 0 (no-op)");const n=this._emap._selection.getAll();if(0===n.length)return lt.validation("selection","selection is empty");const i=new globalThis.Map;for(const t of n){const e=this._emap.layers.resolve(t.source,t.layer);if(!e?.shapes)continue;const n=e.shapes[t.id];if(!n)continue;let s=i.get(t.source);if(s||(s={arcIdSet:new Set,pointFeatures:[]},i.set(t.source,s)),"point"===e.geometry_type)s.pointFeatures.push({layer:e,featureId:t.id});else{const t=n;for(const e of t)if(Array.isArray(e))for(const t of e)"number"==typeof t&&s.arcIdSet.add(t>=0?t:~t)}}if(0===i.size)return lt.validation("selection","no resolvable layers in selection");const s=[],r=[];for(const[n,o]of i){const i=this._emap._sources.get(n);if(!i)continue;if(0===o.arcIdSet.size&&0===o.pointFeatures.length)continue;const a=new Gt({source:i,arcs:i.getArcs(),dx:t,dy:e,arcIds:Array.from(o.arcIdSet),pointFeatures:o.pointFeatures});a.do(),s.push(a),r.push(n)}if(0===s.length)return lt.validation("selection","every resolved layer was empty");const o=1===s.length?s[0]:new Lt(s,`Translate ${n.length} features`);return this._emap._history.push(o),this._emap._fireHistoryChange(),this._emap._clearSpatialIndexesForSources(r),this._emap._scheduleRender(),at}_buildSelectionBuckets(t){const e=this._emap._selection.getAll();if(0===e.length)return null;const n=new globalThis.Map;for(const t of e){const e=this._emap.layers.resolve(t.source,t.layer);if(!e?.shapes)continue;if(!e.shapes[t.id])continue;const i=this._emap._sources.get(t.source);if(!i)continue;let s=n.get(t.source);s||(s={sourceId:t.source,source:i,arcIds:[],pointFeatures:[],pathFeatures:[]},n.set(t.source,s)),"point"===e.geometry_type?s.pointFeatures.push({layer:e,featureId:t.id}):s.pathFeatures.push({layer:e,featureId:t.id})}if(0===n.size)return null;const i=[];if(t)for(const t of n.values()){if(0===t.pathFeatures.length)continue;const e=Vt(t.source,t.pathFeatures,t.source.getLayers());if(!e)continue;const n=new $t(e);n.do(),i.push(n),this._emap._invalidateShapeCachesForSources([t.sourceId])}for(const t of n.values()){const e=new Set;for(const n of t.pathFeatures){const i=n.layer.shapes?.[n.featureId];if(i)for(const n of i)if(Array.isArray(n))for(const i of n){if("number"!=typeof i)continue;const n=i>=0?i:~i;e.has(n)||(e.add(n),t.arcIds.push(n))}}}return{buckets:Array.from(n.values()).map(t=>({sourceId:t.sourceId,source:t.source,arcIds:t.arcIds,pointFeatures:t.pointFeatures})),splitCmds:i}}beginTranslateSession(t){const e=this._buildSelectionBuckets(!1!==t?.splitSharedArcs);if(!e)return null;const{buckets:n,splitCmds:i}=e;let s=0,r=0,o=!1;const a=(t,e)=>{for(const i of n)0===i.arcIds.length&&0===i.pointFeatures.length||new Gt({source:i.source,arcs:i.source.getArcs(),dx:t,dy:e,arcIds:i.arcIds,pointFeatures:i.pointFeatures}).do()};return{move:(t,e)=>{o||0===t&&0===e||(a(t,e),s+=t,r+=e,this._emap._scheduleRender())},commit:()=>{if(o)return!1;o=!0;if(!!(0===s&&0===r)){for(let t=i.length-1;t>=0;t--)i[t].undo();return i.length>0&&this._emap._scheduleRender(),!1}const t=n.map(t=>new Gt({source:t.source,arcs:t.source.getArcs(),dx:s,dy:r,arcIds:t.arcIds,pointFeatures:t.pointFeatures})),e=n.reduce((t,e)=>t+e.arcIds.length+e.pointFeatures.length,0),a=[...i,...t],h=1===a.length?a[0]:new Lt(a,`Translate ${e} features`);return this._emap._history.push(h),this._emap._fireHistoryChange(),this._emap._invalidateShapeCachesForSources(n.map(t=>t.sourceId)),this._emap._scheduleRender(),!0},cancel:()=>{if(!o){o=!0,0===s&&0===r||a(-s,-r);for(let t=i.length-1;t>=0;t--)i[t].undo();s=0,r=0,i.length>0&&this._emap._invalidateShapeCachesForSources(n.map(t=>t.sourceId)),this._emap._scheduleRender()}},getAccumulated:()=>[s,r]}}beginAffineSession(t,e){const n=this._buildSelectionBuckets(!1!==e?.splitSharedArcs);if(!n)return null;const{buckets:i,splitCmds:s}=n;let r,o;if(t)[r,o]=t;else{const t=new globalThis.Map;for(const e of i)t.set(e.sourceId,{arcIdSet:new Set(e.arcIds),pointFeatures:e.pointFeatures});const e=this._computeSelectionCentroid(t);if(!e){for(let t=s.length-1;t>=0;t--)s[t].undo();return null}[r,o]=e}if(!Number.isFinite(r)||!Number.isFinite(o)){for(let t=s.length-1;t>=0;t--)s[t].undo();return null}const a=[r,o];let h={...qt},l=!1;const c=t=>1===t.a&&0===t.b&&0===t.c&&1===t.d&&0===t.tx&&0===t.ty,u=t=>{for(const e of i)0===e.arcIds.length&&0===e.pointFeatures.length||new Ot({source:e.source,arcs:e.source.getArcs(),matrix:t,arcIds:e.arcIds,pointFeatures:e.pointFeatures}).do()};return{origin:a,applyDelta:t=>{l||c(t)||(u(t),h=Ut(t,h),this._emap._scheduleRender())},commit:t=>{if(l)return!1;if(l=!0,c(h)){for(let t=s.length-1;t>=0;t--)s[t].undo();return s.length>0&&this._emap._scheduleRender(),!1}const e=i.reduce((t,e)=>t+e.arcIds.length+e.pointFeatures.length,0),n=i.map(e=>new Ot({source:e.source,arcs:e.source.getArcs(),matrix:h,arcIds:e.arcIds,pointFeatures:e.pointFeatures,label:t})),r=[...s,...n],o=1===r.length?r[0]:new Lt(r,t??`Transform ${e} feature${1===e?"":"s"}`);return this._emap._history.push(o),this._emap._fireHistoryChange(),this._emap._invalidateShapeCachesForSources(i.map(t=>t.sourceId)),this._emap._scheduleRender(),!0},cancel:()=>{if(!l){l=!0,c(h)||u(jt(h));for(let t=s.length-1;t>=0;t--)s[t].undo();h={...qt},s.length>0&&this._emap._invalidateShapeCachesForSources(i.map(t=>t.sourceId)),this._emap._scheduleRender()}},getCumulative:()=>({...h})}}rotateSelected(t,e){if(0===t)return lt.validation("angleDegrees","angle is 0 (no-op)");const n=t*Math.PI/180;return this._applyAffineToSelection((t,e)=>Bt(n,t,e),e,t=>`Rotate ${t} feature${1===t?"":"s"}`)}scaleSelected(t,e,n){const i=t,s=e??t;return 1===i&&1===s?lt.validation("scale","sx and sy are both 1 (no-op)"):this._applyAffineToSelection((t,e)=>zt(i,s,t,e),n,t=>`Scale ${t} feature${1===t?"":"s"}`)}_applyAffineToSelection(t,e,n){const i=this._emap._selection.getAll();if(0===i.length)return lt.validation("selection","selection is empty");const s=new globalThis.Map;for(const t of i){const e=this._emap.layers.resolve(t.source,t.layer);if(!e?.shapes)continue;const n=e.shapes[t.id];if(!n)continue;let i=s.get(t.source);if(i||(i={arcIdSet:new Set,pointFeatures:[]},s.set(t.source,i)),"point"===e.geometry_type)i.pointFeatures.push({layer:e,featureId:t.id});else{const t=n;for(const e of t)if(Array.isArray(e))for(const t of e)"number"==typeof t&&i.arcIdSet.add(t>=0?t:~t)}}if(0===s.size)return lt.validation("selection","no resolvable layers in selection");let r,o;if(e)r=e[0],o=e[1];else{const t=this._computeSelectionCentroid(s);if(!t)return lt.validation("origin","no vertices in selection; cannot compute centroid");[r,o]=t}if(!Number.isFinite(r)||!Number.isFinite(o))return lt.validation("origin","computed origin is not finite");const a=t(r,o),h=[],l=[];for(const[t,e]of s){const n=this._emap._sources.get(t);if(!n)continue;if(0===e.arcIdSet.size&&0===e.pointFeatures.length)continue;const i=new Ot({source:n,arcs:n.getArcs(),matrix:a,arcIds:Array.from(e.arcIdSet),pointFeatures:e.pointFeatures});i.do(),h.push(i),l.push(t)}if(0===h.length)return lt.validation("selection","every resolved layer was empty");const c=1===h.length?h[0]:new Lt(h,n(i.length));return this._emap._history.push(c),this._emap._fireHistoryChange(),this._emap._clearSpatialIndexesForSources(l),this._emap._scheduleRender(),at}_computeSelectionCentroid(t){let e=1/0,n=1/0,i=-1/0,s=-1/0,r=!1;for(const[o,a]of t){const t=this._emap._sources.get(o);if(!t)continue;const h=t.getArcs(),l=h?.getVertexData?.();if(l&&a.arcIdSet.size>0){const{xx:t,yy:o,ii:h,nn:c}=l;for(const l of a.arcIdSet){const a=h[l],u=c[l];for(let h=a;h<a+u;h++){const a=t[h],l=o[h];a<e&&(e=a),a>i&&(i=a),l<n&&(n=l),l>s&&(s=l),r=!0}}}for(const t of a.pointFeatures){const o=t.layer.shapes?.[t.featureId];if(o)for(const t of it(o)){if(!t||t.length<2)continue;const o=t[0],a=t[1];o<e&&(e=o),o>i&&(i=o),a<n&&(n=a),a>s&&(s=a),r=!0}}}return r?[(e+i)/2,(n+s)/2]:null}}class Xt{opts;label;constructor(t){this.opts=t,this.label=t.label??"Edit properties"}do(){Zt(this.opts.layer,this.opts.featureId,this.opts.prev,this.opts.next)}undo(){Zt(this.opts.layer,this.opts.featureId,this.opts.next,this.opts.prev)}}function Zt(t,e,n,i){const s=t.data?.getRecords?.(),r=s?.[e];if(r){for(const t of Object.keys(i))r[t]=i[t];for(const t of Object.keys(n))t in i||delete r[t]}}class Jt{opts;label;_addedIndices=[];constructor(t){this.opts=t,this.label=`Add field ${t.field}`}do(){const t=this.opts.layer.data?.getRecords?.();if(!t)return;const e=this.opts.defaultValue??null;this._addedIndices=[];for(let n=0;n<t.length;n++)t[n]&&!(this.opts.field in t[n])&&(t[n][this.opts.field]=e,this._addedIndices.push(n))}undo(){const t=this.opts.layer.data?.getRecords?.();if(t){for(const e of this._addedIndices)delete t[e]?.[this.opts.field];this._addedIndices=[]}}}class Yt{opts;label;_snapshot=new globalThis.Map;constructor(t){this.opts=t,this.label=`Remove field ${t.field}`}do(){const t=this.opts.layer.data?.getRecords?.();if(t){this._snapshot.clear();for(let e=0;e<t.length;e++){const n=t[e];n&&this.opts.field in n&&(this._snapshot.set(e,n[this.opts.field]),delete n[this.opts.field])}}}undo(){const t=this.opts.layer.data?.getRecords?.();if(t)for(const[e,n]of this._snapshot){const i=t[e];i&&(i[this.opts.field]=n)}}}class Qt{opts;label;constructor(t){this.opts=t,this.label=`Rename field ${t.from} → ${t.to}`}do(){te(this.opts.layer,this.opts.from,this.opts.to)}undo(){te(this.opts.layer,this.opts.to,this.opts.from)}}function te(t,e,n){const i=t.data?.getRecords?.();if(i)for(const t of i)t&&e in t&&(t[n]=t[e],delete t[e])}class ee{_emap;constructor(t){this._emap=t}setFeatureProperty(t,e,n){return this.setFeatureProperties(t,{[e]:n})}setFeatureProperties(t,e){const n=this._emap.layers.resolve(t.source,t.layer);if(!n)return lt.notFound("layer",t.layer);const i=n.data?.getRecords?.(),s=i?.[t.id];if(!s)return lt.notFound("field",`record#${t.id}`);const r={},o={};for(const t of Object.keys(e)){const n=t in s,i=n?s[t]:void 0,a=e[t];(void 0!==a||n)&&(void 0!==a&&n&&s[t]===a||(n&&(r[t]=i),void 0!==a&&(o[t]=a)))}if(0===Object.keys(r).length&&0===Object.keys(o).length)return lt.validation("props","no-op: every requested value already matches the record");const a=new Xt({layer:n,featureId:t.id,prev:r,next:o});return a.do(),this._emap._history.push(a),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}addField(t){const e=this._emap.layers.resolve(t.source,t.target);if(!e)return lt.notFound("layer",t.target);if(!e.data)return lt.validation("target","layer has no data table");const n=new Jt({layer:e,field:t.field,defaultValue:t.defaultValue});return n.do(),this._emap._history.push(n),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}removeField(t){const e=this._emap.layers.resolve(t.source,t.target);if(!e)return lt.notFound("layer",t.target);if(!e.data)return lt.validation("target","layer has no data table");const n=new Yt({layer:e,field:t.field});return n.do(),this._emap._history.push(n),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}renameField(t){const e=this._emap.layers.resolve(t.source,t.target);if(!e)return lt.notFound("layer",t.target);if(!e.data)return lt.validation("target","layer has no data table");const n=e.data.getRecords?.();if(!n)return lt.validation("target","data table has no records");if(t.from===t.to)return lt.validation("to","`from` and `to` are identical");for(const e of n)if(e&&t.from in e&&t.to in e)return lt.validation("to",`would overwrite existing '${t.to}' on at least one record`);const i=new Qt({layer:e,from:t.from,to:t.to});return i.do(),this._emap._history.push(i),this._emap._fireHistoryChange(),this._emap._scheduleRender(),at}}class ne{_onChange;_mode="none";_vertex=null;_draw=null;constructor(t){this._onChange=t}get mode(){return this._mode}get vertex(){return this._vertex}get draw(){return this._draw}setMode(t){if(t===this._mode)return;const e=this._mode;this._mode=t,"vertex"!==t&&(this._vertex=null),"draw"!==t&&(this._draw=null),this._fire(e)}setVertex(t){this._vertex!==t&&(this._vertex=t,this._fire(this._mode))}clearVertex(){null!==this._vertex&&(this._vertex=null,this._fire(this._mode))}setDraw(t){this._draw!==t&&(this._draw=t,this._fire(this._mode))}clearDraw(){null!==this._draw&&(this._draw=null,this._fire(this._mode))}_fire(t){this._onChange({current:{mode:this._mode,vertex:this._vertex,draw:this._draw},previousMode:t,modeChanged:t!==this._mode})}}var ie={},se=Uint8Array,re=Uint16Array,oe=Int32Array,ae=new se([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),he=new se([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),le=new se([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ce=function(t,e){for(var n=new re(31),i=0;i<31;++i)n[i]=e+=1<<t[i-1];var s=new oe(n[30]);for(i=1;i<30;++i)for(var r=n[i];r<n[i+1];++r)s[r]=r-n[i]<<5|i;return{b:n,r:s}},ue=ce(ae,2),pe=ue.b,de=ue.r;pe[28]=258,de[258]=28;for(var _e=ce(he,0),fe=_e.b,me=_e.r,ye=new re(32768),ge=0;ge<32768;++ge){var ve=(43690&ge)>>1|(21845&ge)<<1;ve=(61680&(ve=(52428&ve)>>2|(13107&ve)<<2))>>4|(3855&ve)<<4,ye[ge]=((65280&ve)>>8|(255&ve)<<8)>>1}var xe=function(t,e,n){for(var i=t.length,s=0,r=new re(e);s<i;++s)t[s]&&++r[t[s]-1];var o,a=new re(e);for(s=1;s<e;++s)a[s]=a[s-1]+r[s-1]<<1;if(n){o=new re(1<<e);var h=15-e;for(s=0;s<i;++s)if(t[s])for(var l=s<<4|t[s],c=e-t[s],u=a[t[s]-1]++<<c,p=u|(1<<c)-1;u<=p;++u)o[ye[u]>>h]=l}else for(o=new re(i),s=0;s<i;++s)t[s]&&(o[s]=ye[a[t[s]-1]++]>>15-t[s]);return o},we=new se(288);for(ge=0;ge<144;++ge)we[ge]=8;for(ge=144;ge<256;++ge)we[ge]=9;for(ge=256;ge<280;++ge)we[ge]=7;for(ge=280;ge<288;++ge)we[ge]=8;var be=new se(32);for(ge=0;ge<32;++ge)be[ge]=5;var Ce=xe(we,9,0),Se=xe(we,9,1),Ae=xe(be,5,0),Me=xe(be,5,1),Ee=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},ke=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},De=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Ie=function(t){return(t+7)/8|0},Pe=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new se(t.subarray(e,n))},Te=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Le=function(t,e,n){var i=new Error(e||Te[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Le),!n)throw i;return i},Ne=function(t,e,n,i){var s=t.length,r=i?i.length:0;if(!s||e.f&&!e.l)return n||new se(0);var o=!n,a=o||2!=e.i,h=e.i;o&&(n=new se(3*s));var l=function(t){var e=n.length;if(t>e){var i=new se(Math.max(2*e,t));i.set(n),n=i}},c=e.f||0,u=e.p||0,p=e.b||0,d=e.l,_=e.d,f=e.m,m=e.n,y=8*s;do{if(!d){c=ke(t,u,1);var g=ke(t,u+1,3);if(u+=3,!g){var v=t[(I=Ie(u)+4)-4]|t[I-3]<<8,x=I+v;if(x>s){h&&Le(0);break}a&&l(p+v),n.set(t.subarray(I,x),p),e.b=p+=v,e.p=u=8*x,e.f=c;continue}if(1==g)d=Se,_=Me,f=9,m=5;else if(2==g){var w=ke(t,u,31)+257,b=ke(t,u+10,15)+4,C=w+ke(t,u+5,31)+1;u+=14;for(var S=new se(C),A=new se(19),M=0;M<b;++M)A[le[M]]=ke(t,u+3*M,7);u+=3*b;var E=Ee(A),k=(1<<E)-1,D=xe(A,E,1);for(M=0;M<C;){var I,P=D[ke(t,u,k)];if(u+=15&P,(I=P>>4)<16)S[M++]=I;else{var T=0,L=0;for(16==I?(L=3+ke(t,u,3),u+=2,T=S[M-1]):17==I?(L=3+ke(t,u,7),u+=3):18==I&&(L=11+ke(t,u,127),u+=7);L--;)S[M++]=T}}var N=S.subarray(0,w),R=S.subarray(w);f=Ee(N),m=Ee(R),d=xe(N,f,1),_=xe(R,m,1)}else Le(1);if(u>y){h&&Le(0);break}}a&&l(p+131072);for(var F=(1<<f)-1,G=(1<<m)-1,O=u;;O=u){var B=(T=d[De(t,u)&F])>>4;if((u+=15&T)>y){h&&Le(0);break}if(T||Le(2),B<256)n[p++]=B;else{if(256==B){O=u,d=null;break}var z=B-254;if(B>264){var U=ae[M=B-257];z=ke(t,u,(1<<U)-1)+pe[M],u+=U}var q=_[De(t,u)&G],j=q>>4;q||Le(3),u+=15&q;R=fe[j];if(j>3){U=he[j];R+=De(t,u)&(1<<U)-1,u+=U}if(u>y){h&&Le(0);break}a&&l(p+131072);var $=p+z;if(p<R){var V=r-R,H=Math.min(R,$);for(V+p<0&&Le(3);p<H;++p)n[p]=i[V+p]}for(;p<$;++p)n[p]=n[p-R]}}e.l=d,e.p=O,e.b=p,e.f=c,d&&(c=1,e.m=f,e.d=_,e.n=m)}while(!c);return p!=n.length&&o?Pe(n,0,p):n.subarray(0,p)},Re=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8},Fe=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8,t[i+2]|=n>>16},Ge=function(t,e){for(var n=[],i=0;i<t.length;++i)t[i]&&n.push({s:i,f:t[i]});var s=n.length,r=n.slice();if(!s)return{t:$e,l:0};if(1==s){var o=new se(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var a=n[0],h=n[1],l=0,c=1,u=2;for(n[0]={s:-1,f:a.f+h.f,l:a,r:h};c!=s-1;)a=n[n[l].f<n[u].f?l++:u++],h=n[l!=c&&n[l].f<n[u].f?l++:u++],n[c++]={s:-1,f:a.f+h.f,l:a,r:h};var p=r[0].s;for(i=1;i<s;++i)r[i].s>p&&(p=r[i].s);var d=new re(p+1),_=Oe(n[c-1],d,0);if(_>e){i=0;var f=0,m=_-e,y=1<<m;for(r.sort(function(t,e){return d[e.s]-d[t.s]||t.f-e.f});i<s;++i){var g=r[i].s;if(!(d[g]>e))break;f+=y-(1<<_-d[g]),d[g]=e}for(f>>=m;f>0;){var v=r[i].s;d[v]<e?f-=1<<e-d[v]++-1:++i}for(;i>=0&&f;--i){var x=r[i].s;d[x]==e&&(--d[x],++f)}_=e}return{t:new se(d),l:_}},Oe=function(t,e,n){return-1==t.s?Math.max(Oe(t.l,e,n+1),Oe(t.r,e,n+1)):e[t.s]=n},Be=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new re(++e),i=0,s=t[0],r=1,o=function(t){n[i++]=t},a=1;a<=e;++a)if(t[a]==s&&a!=e)++r;else{if(!s&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(s),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(s);r=1,s=t[a]}return{c:n.subarray(0,i),n:e}},ze=function(t,e){for(var n=0,i=0;i<e.length;++i)n+=t[i]*e[i];return n},Ue=function(t,e,n){var i=n.length,s=Ie(e+2);t[s]=255&i,t[s+1]=i>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var r=0;r<i;++r)t[s+r+4]=n[r];return 8*(s+4+i)},qe=function(t,e,n,i,s,r,o,a,h,l,c){Re(e,c++,n),++s[256];for(var u=Ge(s,15),p=u.t,d=u.l,_=Ge(r,15),f=_.t,m=_.l,y=Be(p),g=y.c,v=y.n,x=Be(f),w=x.c,b=x.n,C=new re(19),S=0;S<g.length;++S)++C[31&g[S]];for(S=0;S<w.length;++S)++C[31&w[S]];for(var A=Ge(C,7),M=A.t,E=A.l,k=19;k>4&&!M[le[k-1]];--k);var D,I,P,T,L=l+5<<3,N=ze(s,we)+ze(r,be)+o,R=ze(s,p)+ze(r,f)+o+14+3*k+ze(C,M)+2*C[16]+3*C[17]+7*C[18];if(h>=0&&L<=N&&L<=R)return Ue(e,c,t.subarray(h,h+l));if(Re(e,c,1+(R<N)),c+=2,R<N){D=xe(p,d,0),I=p,P=xe(f,m,0),T=f;var F=xe(M,E,0);Re(e,c,v-257),Re(e,c+5,b-1),Re(e,c+10,k-4),c+=14;for(S=0;S<k;++S)Re(e,c+3*S,M[le[S]]);c+=3*k;for(var G=[g,w],O=0;O<2;++O){var B=G[O];for(S=0;S<B.length;++S){var z=31&B[S];Re(e,c,F[z]),c+=M[z],z>15&&(Re(e,c,B[S]>>5&127),c+=B[S]>>12)}}}else D=Ce,I=we,P=Ae,T=be;for(S=0;S<a;++S){var U=i[S];if(U>255){Fe(e,c,D[(z=U>>18&31)+257]),c+=I[z+257],z>7&&(Re(e,c,U>>23&31),c+=ae[z]);var q=31&U;Fe(e,c,P[q]),c+=T[q],q>3&&(Fe(e,c,U>>5&8191),c+=he[q])}else Fe(e,c,D[U]),c+=I[U]}return Fe(e,c,D[256]),c+I[256]},je=new oe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$e=new se(0),Ve=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),He=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i<e.length;++i)n=Ve[255&n^e[i]]^n>>>8;t=n},d:function(){return~t}}},We=function(t,e,n,i,s){if(!s&&(s={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new se(r.length+t.length);o.set(r),o.set(t,r.length),t=o,s.w=r.length}return function(t,e,n,i,s,r){var o=r.z||t.length,a=new se(i+o+5*(1+Math.ceil(o/7e3))+s),h=a.subarray(i,a.length-s),l=r.l,c=7&(r.r||0);if(e){c&&(h[0]=r.r>>3);for(var u=je[e-1],p=u>>13,d=8191&u,_=(1<<n)-1,f=r.p||new re(32768),m=r.h||new re(_+1),y=Math.ceil(n/3),g=2*y,v=function(e){return(t[e]^t[e+1]<<y^t[e+2]<<g)&_},x=new oe(25e3),w=new re(288),b=new re(32),C=0,S=0,A=r.i||0,M=0,E=r.w||0,k=0;A+2<o;++A){var D=v(A),I=32767&A,P=m[D];if(f[I]=P,m[D]=I,E<=A){var T=o-A;if((C>7e3||M>24576)&&(T>423||!l)){c=qe(t,h,0,x,w,b,S,M,k,A-k,c),M=C=S=0,k=A;for(var L=0;L<286;++L)w[L]=0;for(L=0;L<30;++L)b[L]=0}var N=2,R=0,F=d,G=I-P&32767;if(T>2&&D==v(A-G))for(var O=Math.min(p,T)-1,B=Math.min(32767,A),z=Math.min(258,T);G<=B&&--F&&I!=P;){if(t[A+N]==t[A+N-G]){for(var U=0;U<z&&t[A+U]==t[A+U-G];++U);if(U>N){if(N=U,R=G,U>O)break;var q=Math.min(G,U-2),j=0;for(L=0;L<q;++L){var $=A-G+L&32767,V=$-f[$]&32767;V>j&&(j=V,P=$)}}}G+=(I=P)-(P=f[I])&32767}if(R){x[M++]=268435456|de[N]<<18|me[R];var H=31&de[N],W=31&me[R];S+=ae[H]+he[W],++w[257+H],++b[W],E=A+N,++C}else x[M++]=t[A],++w[t[A]]}}for(A=Math.max(A,E);A<o;++A)x[M++]=t[A],++w[t[A]];c=qe(t,h,l,x,w,b,S,M,k,A-k,c),l||(r.r=7&c|h[c/8|0]<<3,c-=7,r.h=m,r.p=f,r.i=A,r.w=E)}else{for(A=r.w||0;A<o+l;A+=65535){var K=A+65535;K>=o&&(h[c/8|0]=l,K=o),c=Ue(h,c+1,t.subarray(A,K))}r.i=o}return Pe(a,0,i+Ie(c)+s)}(t,null==e.level?6:e.level,null==e.mem?s.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,i,s)},Ke=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},Xe=function(t,e,n){for(var i=t(),s=t.toString(),r=s.slice(s.indexOf("[")+1,s.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<i.length;++o){var a=i[o],h=r[o];if("function"==typeof a){e+=";"+h+"=";var l=a.toString();if(a.prototype)if(-1!=l.indexOf("[native code]")){var c=l.indexOf(" ",8)+1;e+=l.slice(c,l.indexOf("(",c))}else for(var u in e+=l,a.prototype)e+=";"+h+".prototype."+u+"="+a.prototype[u].toString();else e+=l}else n[h]=a}return e},Ze=[],Je=function(t,e,n,i){if(!Ze[n]){for(var s="",r={},o=t.length-1,a=0;a<o;++a)s=Xe(t[a],s,r);Ze[n]={c:Xe(t[o],s,r),e:r}}var h=Ke({},Ze[n].e);return function(t,e,n,i,s){var r=new Worker(ie[e]||(ie[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return r.onmessage=function(t){var e=t.data,n=e.$e$;if(n){var i=new Error(n[0]);i.code=n[1],i.stack=n[2],s(i,null)}else s(null,e)},r.postMessage(n,i),r}(Ze[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,h,function(t){var e=[];for(var n in t)t[n].buffer&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e}(h),i)},Ye=function(){return[se,re,oe,ae,he,le,pe,fe,Se,Me,ye,Te,xe,Ee,ke,De,Ie,Pe,Le,Ne,hn,Qe,tn]},Qe=function(t){return postMessage(t,[t.buffer])},tn=function(t){return t&&{out:t.size&&new se(t.size),dictionary:t.dictionary}},en=function(t,e){return t[e]|t[e+1]<<8},nn=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},sn=function(t,e){return nn(t,e)+4294967296*nn(t,e+4)},rn=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function on(t,e){return We(t,e||{},0,0)}function an(t,e,n){return n||(n=e,e={}),"function"!=typeof n&&Le(7),function(t,e,n,i,s,r){var o=Je(n,i,s,function(t,e){o.terminate(),r(t,e)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}}(t,e,[Ye],function(t){return Qe(hn(t.data[0],tn(t.data[1])))},1,n)}function hn(t,e){return Ne(t,{i:2},e&&e.out,e&&e.dictionary)}var ln=function(t,e,n,i){for(var s in t){var r=t[s],o=e+s,a=i;Array.isArray(r)&&(a=Ke(i,r[1]),r=r[0]),r instanceof se?n[o]=[r,a]:(n[o+="/"]=[new se(0),a],ln(r,o,n,i))}},cn="undefined"!=typeof TextEncoder&&new TextEncoder,un="undefined"!=typeof TextDecoder&&new TextDecoder;try{un.decode($e,{stream:!0})}catch(t){}function pn(t,e){if(cn)return cn.encode(t);for(var n=t.length,i=new se(t.length+(t.length>>1)),s=0,r=function(t){i[s++]=t},o=0;o<n;++o){if(s+5>i.length){var a=new se(s+8+(n-o<<1));a.set(i),i=a}var h=t.charCodeAt(o);h<128||e?r(h):h<2048?(r(192|h>>6),r(128|63&h)):h>55295&&h<57344?(r(240|(h=65536+(1047552&h)|1023&t.charCodeAt(++o))>>18),r(128|h>>12&63),r(128|h>>6&63),r(128|63&h)):(r(224|h>>12),r(128|h>>6&63),r(128|63&h))}return Pe(i,0,s)}function dn(t,e){if(e){for(var n="",i=0;i<t.length;i+=16384)n+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return n}if(un)return un.decode(t);var s=function(t){for(var e="",n=0;;){var i=t[n++],s=(i>127)+(i>223)+(i>239);if(n+s>t.length)return{s:e,r:Pe(t,n-1)};s?3==s?(i=((15&i)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|i>>10,56320|1023&i)):e+=1&s?String.fromCharCode((31&i)<<6|63&t[n++]):String.fromCharCode((15&i)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(i)}}(t),r=s.s;return(n=s.r).length&&Le(8),r}var _n=function(t,e){for(;1!=en(t,e);e+=4+en(t,e+2));return[sn(t,e+12),sn(t,e+4),sn(t,e+20)]},fn=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&Le(9),e+=i+4}return e},mn=function(t,e,n,i,s,r,o,a){var h=i.length,l=n.extra,c=a&&a.length,u=fn(l);rn(t,e,null!=o?33639248:67324752),e+=4,null!=o&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(r<0&&8),t[e++]=s&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var p=new Date(null==n.mtime?Date.now():n.mtime),d=p.getFullYear()-1980;if((d<0||d>119)&&Le(10),rn(t,e,d<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,-1!=r&&(rn(t,e,n.crc),rn(t,e+4,r<0?-r-2:r),rn(t,e+8,n.size)),rn(t,e+12,h),rn(t,e+14,u),e+=16,null!=o&&(rn(t,e,c),rn(t,e+6,n.attrs),rn(t,e+10,o),e+=14),t.set(i,e),e+=h,u)for(var _ in l){var f=l[_],m=f.length;rn(t,e,+_),rn(t,e+2,m),t.set(f,e+4),e+=4+m}return c&&(t.set(a,e),e+=c),e};function yn(t,e){e||(e={});var n={},i=[];ln(t,"",n,e);var s=0,r=0;for(var o in n){var a=n[o],h=a[0],l=a[1],c=0==l.level?0:8,u=(C=pn(o)).length,p=l.comment,d=p&&pn(p),_=d&&d.length,f=fn(l.extra);u>65535&&Le(11);var m=c?on(h,l):h,y=m.length,g=He();g.p(h),i.push(Ke(l,{size:h.length,crc:g.d(),c:m,f:C,m:d,u:u!=o.length||d&&p.length!=_,o:s,compression:c})),s+=30+u+f+y,r+=76+2*(u+f)+(_||0)+y}for(var v=new se(r+22),x=s,w=r-s,b=0;b<i.length;++b){var C=i[b];mn(v,C.o,C,C.f,C.u,C.c.length);var S=30+C.f.length+fn(C.extra);v.set(C.c,C.o+S),mn(v,s,C,C.f,C.u,C.c.length,C.o,C.m),s+=16+S+(C.m?C.m.length:0)}return function(t,e,n,i,s){rn(t,e,101010256),rn(t,e+8,n),rn(t,e+10,n),rn(t,e+12,i),rn(t,e+16,s)}(v,s,i.length,w,x),v}var gn="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()};function vn(t,e,n){n||(n=e,e={}),"function"!=typeof n&&Le(7);var i=[],s=function(){for(var t=0;t<i.length;++t)i[t]()},r={},o=function(t,e){gn(function(){n(t,e)})};gn(function(){o=n});for(var a=t.length-22;101010256!=nn(t,a);--a)if(!a||t.length-a>65558)return o(Le(13,0,1),null),s;var h=en(t,a+8);if(h){var l=h,c=nn(t,a+16),u=4294967295==c||65535==l;if(u){var p=nn(t,a-12);(u=101075792==nn(t,p))&&(l=h=nn(t,p+32),c=nn(t,p+48))}for(var d=e&&e.filter,_=function(e){var n=function(t,e,n){var i=en(t,e+28),s=dn(t.subarray(e+46,e+46+i),!(2048&en(t,e+8))),r=e+46+i,o=nn(t,e+20),a=n&&4294967295==o?_n(t,r):[o,nn(t,e+24),nn(t,e+42)],h=a[0],l=a[1],c=a[2];return[en(t,e+10),h,l,s,r+en(t,e+30)+en(t,e+32),c]}(t,c,u),a=n[0],l=n[1],p=n[2],_=n[3],f=n[4],m=n[5],y=function(t,e){return e+30+en(t,e+26)+en(t,e+28)}(t,m);c=f;var g=function(t,e){t?(s(),o(t,null)):(e&&(r[_]=e),--h||o(null,r))};if(!d||d({name:_,size:l,originalSize:p,compression:a}))if(a)if(8==a){var v=t.subarray(y,y+l);if(p<524288||l>.8*p)try{g(null,hn(v,{out:new se(p)}))}catch(t){g(t,null)}else i.push(an(v,{size:p},g))}else g(Le(14,"unknown compression type "+a,1),null);else g(null,Pe(t,y,y+l));else g(null,null)},f=0;f<l;++f)_()}else o(null,{});return s}const xn=5e5;class wn{_unfilteredArcs;_filteredArcs=null;_filteredSegLen=0;_dirty=!1;constructor(t){this._unfilteredArcs=t;(t.getPointCount?.()??0)>xn&&this._initFilteredArcs()}markDirty(){this._dirty=!0}_initFilteredArcs(){const t=this._unfilteredArcs,e=t.getVertexData?.();if(e?.zz){const e=.08,n=Math.ceil((t.getPointCount?.()??0)/xn),i=t.getRetainedInterval?.()??0,s=t.getThresholdByPct?.(e,n)??0;this._filteredArcs=t.setRetainedInterval?.(s)?.getFilteredCopy?.()??null,t.setRetainedInterval?.(i),this._filteredArcs&&(this._filteredSegLen=Y().getAvgSegment(this._filteredArcs))}else{const e=Y();this._filteredSegLen=4*e.getAvgSegment(t),this._filteredArcs=e.simplifyArcsFast(t,this._filteredSegLen)}}getScaledArcs(t){const e=null!==this._filteredArcs&&t>1.5*this._filteredSegLen;if(this._filteredArcs){(this._filteredArcs.size()!==this._unfilteredArcs.size()||this._dirty&&e)&&(this._initFilteredArcs(),this._dirty=!1)}else if(this._dirty){(this._unfilteredArcs.getPointCount?.()??0)>xn&&this._initFilteredArcs(),this._dirty=!1}this._filteredArcs&&this._filteredArcs.setRetainedInterval?.(this._unfilteredArcs.getRetainedInterval?.()??0);return this._filteredArcs&&t>1.5*this._filteredSegLen?this._filteredArcs:this._unfilteredArcs}getArcs(){return this._unfilteredArcs}hasLOD(){return null!==this._filteredArcs}}class bn{_adapter;constructor(t=Y()){this._adapter=t}async runImport(t,e){return this._adapter.runImport(t,e)}}let Cn=null;const Sn="EPSG:4326";function An(t){if(!t)return Sn;const e=t.info;if(!e)return Sn;if(e.crs_string)return Mn(e.crs_string);if(e.prj){const t=En(e.prj);if(t)return t}if(e.crs){if(e.crs.is_latlong)return"EPSG:4326";if("merc"===e.crs.projName&&6378137===e.crs.a)return"EPSG:3857"}return Sn}function Mn(t){const e=t.toLowerCase();return"wgs84"===e||e.includes("4326")?"EPSG:4326":e.includes("3857")||"webmercator"===e?"EPSG:3857":(/^epsg:\d+$/i.test(t),t.toUpperCase())}function En(t){const e=t.match(/AUTHORITY\["EPSG"\s*,\s*"(\d+)"\]/i);return e?`EPSG:${e[1]}`:/Mercator.*WGS.*84.*Pseudo/i.test(t)||/WGS.*84.*Pseudo.*Mercator/i.test(t)||/Web_Mercator/i.test(t)?"EPSG:3857":/DATUM\["WGS_1984"/i.test(t)&&/GEOGCS/i.test(t)?"EPSG:4326":null}const kn={geojson:"application/geo+json",topojson:"application/json",shapefile:"application/zip",msx:"application/octet-stream"};function Dn(t){return"string"==typeof t?(new TextEncoder).encode(t):t instanceof Uint8Array?t:new Uint8Array(t)}const In={maxBytes:209715200,maxEntries:5e3,maxRatio:100};class Pn extends j{id;type="topology";_dataset;_displayArcs=null;_options;_data;_loadVersion=0;_abortController=null;_simplifyFloor=0;_runner;getSimplifyFloor(){return this._simplifyFloor}constructor(t,e){super(),this.id=t,this._options=e||{},this._data=this._options.data,this._runner=this._options.mapshaperRunner??Cn??(Cn=new bn),this._data&&this._updateData()}static async fromUrl(t,e,n){const i=new Pn(t,n);return await new Promise((t,n)=>{let s,r;const o=()=>{i.off("data",s),i.off("error",r)};s=()=>{o(),t()},r=t=>{o(),n(t?.error??t)},i.on("data",s),i.on("error",r),i.setData(e)}),i}static async fromBytes(t,e,n){const{filename:i=`${t}.geojson`,...s}=n??{},r=e instanceof Uint8Array?e:new Uint8Array(e),o=new Pn(t,s);return await new Promise((t,e)=>{let n,s;const a=()=>{o.off("data",n),o.off("error",s)};n=()=>{a(),t()},s=t=>{a(),e(t?.error??t)},o.on("data",n),o.on("error",s),o.setData({filename:i,content:r})}),o}setData(t){return this._loadVersion++,this._abortController?.abort(),this._abortController=null,this._data=t,this._updateData(),this}async _updateData(){if(!this._data)return;const t=this._loadVersion,e=new AbortController;this._abortController=e,this.fire("dataloading");try{const n={},i=[];if(Array.isArray(this._data)){if(0===this._data.length)throw new Error("setData received an empty array; nothing to import");for(const t of this._data)if(this._isZipFile(t.filename)){const e=await this._extractZip(t.content),s=this._findPrimaryFile(e);if(!s)throw new Error(`No importable file found in zip archive: ${t.filename}`);for(const[t,i]of Object.entries(e))n[t]=i;i.push(s)}else n[t.filename]=t.content,i.push(t.filename)}else{let t;if("string"==typeof this._data){const n=this._data,i=await fetch(n,{signal:e.signal});if(!i.ok)throw new Error(`Failed to fetch ${n}: HTTP ${i.status}`);const s=await i.arrayBuffer(),r=new Uint8Array(s);let o=new URL(n).pathname.split("/").pop()||"";if(!this._hasSupportedExtension(o)){const t=i.headers.get("Content-Type")||"";o=this._filenameFromContentType(t,o)}o||(o="data.json"),t={filename:o,content:r}}else t=this._data;if(this._isZipFile(t.filename)){const e=await this._extractZip(t.content),s=this._findPrimaryFile(e);if(!s)throw new Error("No importable file found in zip archive");for(const[t,i]of Object.entries(e))n[t]=i;i.push(s)}else n[t.filename]=t.content,i.push(t.filename)}const s=`-i ${i.map(t=>`"${t.replace(/"/g,'\\"')}"`).join(" ")}`,r=await this._runner.runImport(s,n);if(t!==this._loadVersion)return;this._dataset=r,this._dataset?.arcs&&(this._displayArcs=new wn(this._dataset.arcs)),this._simplifyFloor=this._dataset?.arcs?.getRetainedInterval?.()??0,this.fire("data",{reason:"load"})}catch(e){if(t!==this._loadVersion)return;if("AbortError"===e?.name)return;this.fire("error",{error:e})}}_hasSupportedExtension(t){return/\.(json|geojson|topojson|zip|shp|kml|msx)$/i.test(t)}_filenameFromContentType(t,e){return(e||"data")+({"application/json":".json","application/geo+json":".geojson","application/vnd.geo+json":".geojson","application/topojson+json":".topojson","application/zip":".zip","application/x-zip-compressed":".zip","application/octet-stream":".zip","application/vnd.google-earth.kml+xml":".kml","text/plain":".json"}[t.toLowerCase().split(";")[0].trim()]||".json")}getDataset(){return this._dataset}getCRS(){return An(this._dataset)}async reproject(t){if(!this._dataset)return;this._dataset?.arcs?.setRetainedInterval&&this._dataset.arcs.setRetainedInterval(0),this._dataset.info&&(delete this._dataset.info.crs_string,delete this._dataset.info.prj,delete this._dataset.info.wkt1);const e=`-proj ${t}`,n=await Y().runOnDataset(e,this._dataset);this._dataset=n,this._dataset?.arcs&&(this._displayArcs=new wn(this._dataset.arcs))}getExtent(){if(!this._dataset)return new V;const t=Y().getDatasetBounds(this._dataset);return new V(t.xmin,t.ymin,t.xmax,t.ymax)}getArcs(){return this._dataset?.arcs}getDisplayArcs(){return this._displayArcs}markDisplayArcsDirty(){this._displayArcs?.markDirty()}refreshDisplayArcs(){this._dataset?.arcs&&(this._displayArcs=new wn(this._dataset.arcs))}setDataset(t){this._dataset=t,t.arcs?this._displayArcs=new wn(t.arcs):this._displayArcs=null,this._simplifyFloor=t.arcs?.getRetainedInterval?.()??0,this.fire("data",{reason:"replace"})}async export(t){if(!this._dataset)throw new Error("TopologySource has no dataset to export");const e=this._dataset.arcs,n=e?.getRetainedInterval?.()??0;n&&e?.setRetainedInterval&&e.setRetainedInterval(0);try{const e=Y(),n="msx"===t.format?await e.exportPackedDatasets([this._dataset],{compact:!0}):e.exportFileContent(this._dataset,{format:t.format});return this._filesToBlob(n,t.format)}finally{n&&e?.setRetainedInterval&&e.setRetainedInterval(n)}}_filesToBlob(t,e){if(0===t.length)throw new Error(`mapshaper produced no output for format=${e}`);if("shapefile"===e){const e={};for(const n of t)e[n.filename]=Dn(n.content);const n=yn(e);return new Blob([n],{type:kn.shapefile})}return new Blob([t[0].content],{type:kn[e]})}getLayers(){return this._dataset?.layers||[]}_isZipFile(t){return/\.zip$/i.test(t)}async _extractZip(t){const e={...In,...this._options.zipLimits};let n=0,i=0;const s=await new Promise((s,r)=>{vn(t,{filter:s=>{if(i++,i>e.maxEntries)throw new Error(`ZIP extraction limit exceeded: ${i} entries > maxEntries ${e.maxEntries}`);if(n+=s.originalSize,n>e.maxBytes)throw new Error(`ZIP extraction limit exceeded: uncompressed total ${n} > maxBytes ${e.maxBytes}`);if(t.byteLength>0){const i=n/t.byteLength;if(i>e.maxRatio)throw new Error(`ZIP extraction limit exceeded: ratio ${i.toFixed(1)} > maxRatio ${e.maxRatio}`)}return!(/^__MACOSX/.test(s.name)||s.name.split("/").pop()?.startsWith("."))}},(t,e)=>{t?r(t):s(e)})}),r={};for(const t of Object.keys(s)){const e=s[t],n=t.split("/").pop()||t;this._isTextFile(n)?r[n]=dn(e):r[n]=e}return r}_isTextFile(t){return/\.(prj|cpg|csv|json|geojson|kml|txt)$/i.test(t)}_findPrimaryFile(t){const e=Object.keys(t),n=[".shp",".geojson",".json",".kml",".topojson"];for(const t of n){const n=e.find(e=>e.toLowerCase().endsWith(t));if(n)return n}return e.find(t=>!this._isAuxiliaryFile(t))||""}_isAuxiliaryFile(t){return/\.(prj|shx|dbf)$/i.test(t)}}function Tn(t){const e=[];return function(n){e.push(n),e.length>t&&e.shift();return e.reduce((t,e)=>t+e,0)/e.length}}class Ln extends j{_element;_active=!1;_timer=new H;_sustainInterval=150;_fadeDelay=70;_eventTime=0;_getAverageRate=Tn(10);_getWheelDirection=function(){let t=0,e=null;return function(n,i){const s=n>0?1:n<0?-1:0;(!e||i-t>300)&&(e=Tn(3)),t=i;const r=e(s)||s;return r>0?1:r<0?-1:0}}();_wheelDirection=0;_mouseX=0;_mouseY=0;_wheelHandler=t=>this._handleWheel(t);constructor(t){super(),this._element=t,this._timer.on("tick",t=>this._onTick(t)),this._element.addEventListener("wheel",this._wheelHandler,{passive:!1})}destroy(){this._element.removeEventListener("wheel",this._wheelHandler),this._timer.stop()}_updateSustainInterval(t){this._fadeDelay=t+50,this._sustainInterval=this._fadeDelay+80}_handleWheel(t){const e=Date.now();if(this._wheelDirection=this._getWheelDirection(-t.deltaY,e),0===this._wheelDirection)return;t.preventDefault();const n=this._element.getBoundingClientRect();this._mouseX=t.clientX-n.left,this._mouseY=t.clientY-n.top,this._active?this._updateSustainInterval(this._getAverageRate(e-this._eventTime)):(this._active=!0,this.fire("mousewheelstart")),this._eventTime=e,this._timer.start(this._sustainInterval)}_onTick(t){const e=t.time-this._eventTime;let n=t.tickTime/25,i=0;e>this._fadeDelay&&(i=Math.min(1,(e-this._fadeDelay)/(this._sustainInterval-this._fadeDelay))),t.done?(this._active=!1,this.fire("mousewheelend")):(i>0&&(n*=W.quadraticOut(1-i)),this.fire("mousewheel",{direction:this._wheelDirection,multiplier:n,x:this._mouseX,y:this._mouseY}))}}class Nn extends j{_element;_isDragging=!1;_lastMousePos=[0,0];_enabled=!0;_onMouseDownBound;_onMouseMoveBound;_onMouseUpBound;constructor(t){super(),this._element=t,this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this),t.addEventListener("mousedown",this._onMouseDownBound),window.addEventListener("mousemove",this._onMouseMoveBound),window.addEventListener("mouseup",this._onMouseUpBound)}setEnabled(t){this._enabled=t,!t&&this._isDragging&&(this._isDragging=!1,this.fire("panend"))}isEnabled(){return this._enabled}isDragging(){return this._isDragging}destroy(){this._element.removeEventListener("mousedown",this._onMouseDownBound),window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound)}_onMouseDown(t){this._enabled&&(t.shiftKey||(this._isDragging=!0,this._lastMousePos=[t.clientX,t.clientY],this.fire("panstart")))}_onMouseMove(t){if(!this._isDragging)return;const e=t.clientX-this._lastMousePos[0],n=t.clientY-this._lastMousePos[1];this._lastMousePos=[t.clientX,t.clientY],this.fire("pan",{dx:e,dy:n})}_onMouseUp(){this._isDragging&&(this._isDragging=!1,this.fire("panend"))}}class Rn{_workerUrl;_WorkerCtor;_slots;_pending=new Map;_nextId=1;_rrCursor=0;_destroyed=!1;constructor(t){this._workerUrl=t.workerUrl,this._WorkerCtor=t.WorkerCtor??globalThis.Worker;const e=Math.max(1,Math.floor(t.poolSize??1));this._slots=Array.from({length:e},()=>({worker:null,epoch:0,pendingCount:0}))}run(t,e,n){return this.runWithId(t,e,n).promise}runWithId(t,e,n){const i=this.reserveId();return{id:i,promise:this.dispatchWithId(i,t,e,n)}}reserveId(){return this._nextId++}dispatchWithId(t,e,n,i,s){if(this._destroyed)return Promise.reject(new Error("MapshaperWorkerPool: destroyed"));const r=this._pickWorker();let o;try{o=this._ensureWorker(r)}catch(t){return Promise.reject(t)}const a=this._slots[r],h=a.epoch;return a.pendingCount++,new Promise((a,l)=>{this._pending.set(t,{resolve:a,reject:l,workerIndex:r,epoch:h});const c={id:t,type:"run",packed:n};"string"==typeof e?c.cmd=e:c.commands=e,i&&(c.inputFiles=i),s&&s.length>0?o.postMessage(c,s):o.postMessage(c)})}destroy(){this._destroyed||(this._destroyed=!0,this._terminateAll(new Error("MapshaperWorkerPool: destroyed")))}cancelAll(){this._destroyed||this._terminateAll(new Error("MapshaperWorkerPool: cancelled"))}isWorkerSpawned(){return this._slots.some(t=>null!==t.worker)}get poolSize(){return this._slots.length}_pickWorker(){let t=0,e=1/0,n=!1;const i=this._slots.length;for(let s=0;s<i;s++){const r=(this._rrCursor+s)%i,o=this._slots[r],a=null!==o.worker;(o.pendingCount<e||o.pendingCount===e&&a&&!n)&&(t=r,e=o.pendingCount,n=a)}return this._rrCursor=(t+1)%i,t}_terminateAll(t){for(const t of this._slots)t.worker&&(t.worker.terminate(),t.worker=null),t.epoch++,t.pendingCount=0;for(const{reject:e}of this._pending.values())e(t);this._pending.clear()}_ensureWorker(t){const e=this._slots[t];if(e.worker)return e.worker;if(!this._WorkerCtor)throw new Error("MapshaperWorkerPool: Worker constructor not available in this environment");const n=new this._WorkerCtor(this._workerUrl);return n.onmessage=e=>this._onMessage(t,e.data),n.onerror=e=>this._onWorkerError(t,e),e.worker=n,n}_onMessage(t,e){if(!e||"number"!=typeof e.id)return;const n=this._pending.get(e.id);if(!n)return;const i=this._slots[t];n.workerIndex===t&&n.epoch===i.epoch&&(this._pending.delete(e.id),i.pendingCount=Math.max(0,i.pendingCount-1),"ok"===e.type?n.resolve(e.packed):n.reject(new Error(e.message||"mapshaper worker error")))}_onWorkerError(t,e){const n=new Error(`mapshaper worker error: ${e.message||"unknown"}`),i=this._slots[t];i.worker&&(i.worker.terminate(),i.worker=null),i.epoch++,i.pendingCount=0;const s=[];for(const[e,n]of this._pending)n.workerIndex===t&&s.push(e);for(const t of s){const e=this._pending.get(t);this._pending.delete(t),e?.reject(n)}}}class Fn{_sources;_getTransform;_getSize;_getInitialMX;_indexCache=new globalThis.Map;constructor(t,e,n,i){this._sources=t,this._getTransform=e,this._getSize=n,this._getInitialMX=i}prebuild(t){if(void 0!==t){const e=this._sources.get(t);return void(e&&this._prebuildSource(t,e))}for(const[t,e]of this._sources)this._prebuildSource(t,e)}clear(t){if(void 0===t)return void this._indexCache.clear();const e=`${t}|`,n=[];for(const t of this._indexCache.keys())t.startsWith(e)&&n.push(t);for(const t of n)this._indexCache.delete(t)}_prebuildSource(t,e){if("topology"!==e.type)return;const n=e.getLayers(),i=e.getArcs(),s=e.getDataset?.();for(let e=0;e<n.length;e++)this._getOrBuildIndex(t,e,n[e],i,s)}_getOrBuildIndex(t,e,n,i,s){const r=n?.shapes;if(!r||0===r.length)return null;const o=i?.size?.()??0,a=s?.editVersion??0,h=`${t}|${e}|${r.length}|${o}|${a}`,l=this._indexCache.get(h);if(void 0!==l)return l;const c=`${t}|${e}|`,u=[];for(const t of this._indexCache.keys())t!==h&&t.startsWith(c)&&u.push(t);for(const t of u)this._indexCache.delete(t);const p="point"===n.geometry_type,d=new M(r.length),_=[];for(let t=0;t<r.length;t++){const e=r[t];if(!e){d.add(0,0,0,0);continue}let n=1/0,s=1/0,o=-1/0,a=-1/0;if(p)for(const t of it(e))!t||t.length<2||(t[0]<n&&(n=t[0]),t[0]>o&&(o=t[0]),t[1]<s&&(s=t[1]),t[1]>a&&(a=t[1]));else if(i?.getSimpleShapeBbox){const t=e;for(let e=0;e<t.length;e++)i.getSimpleShapeBbox(t[e],_),_[0]<n&&(n=_[0]),_[1]<s&&(s=_[1]),_[2]>o&&(o=_[2]),_[3]>a&&(a=_[3])}n!==1/0?d.add(n,s,o,a):d.add(0,0,0,0)}d.finish();const f={index:d,shapeCount:r.length};return this._indexCache.set(h,f),f}query(t,e,n){const{width:i,height:s}=this._getSize(),r=Array.isArray(t),o=r?t:[[0,0],[i,s]],a=e||(r?{}:t)||{};if(Array.isArray(o)&&"number"==typeof o[0]){const t=o;return this._queryFeaturesAtPoint(t,a,n)}const h=o;return this._queryFeaturesInBBox(h,a,n)}_layerMatchesFilter(t,e,n){if(!n||0===n.length)return!0;const i=nt(t,e);return!!n.includes(i)||(!(!t?.name||!n.includes(t.name))||!(!t?.id||!n.includes(t.id)))}_unproject(t,e){return this._getTransform().unproject(t,e)}_getHitBuffer(t){return t/Math.abs(this._getTransform().mx||1)}_getZoomAdjustedHitBuffer(t,e){const n=this._getTransform(),i=this._getInitialMX(),s=Math.abs(n.mx)/(i||Math.abs(n.mx)||1);return s<1&&(t*=s),e>0&&t<e&&(t=e),this._getHitBuffer(t)}_findHitCandidates(t,e,n,i,s,r,o,a){const h=[],l={},c=[],u=n.shapes;if(!u)return h;const p=this._getOrBuildIndex(t,e,n,i,a),d=p?p.index.search(s-o,r-o,s+o,r+o):null,_=null!==d?d.length:u.length;for(let t=0;t<_;t++){const e=null!==d?d[t]:t,n=u[e];if(n)for(let t=0;t<n.length;t++){const a=n[t];if(i.getSimpleShapeBbox(a,c),s+o<c[0]||s-o>c[2]||r+o<c[1]||r-o>c[3])continue;let u=l[e];u||(u=l[e]={shape:[],id:e,dist:0},h.push(u)),u.shape.push(a)}}return h}_sortByDistance(e,n,i,s){const r=t.geom;for(const t of i)t.info=r.getPointToShapeInfo(e,n,t.shape,s),t.dist=t.info.distance;i.sort((t,e)=>t.dist-e.dist)}_pickNearestCandidates(t,e,n){const i=[];let s=0;for(let r=0;r<t.length;r++){const o=t[r];if(!(o.dist<n))break;if(0===r)s=o.dist;else if(o.dist-s>e)break;i.push(o)}return i}_pointTest(e,n,i,s,r,o){const a=t.geom,h=Math.abs(this._getTransform().mx||1);let l=-1,c=1/0,u=25;const p=i.shapes;if(!p)return[];const d=u/(h||1),_=this._getOrBuildIndex(e,n,i,void 0,o),f=_?_.index.search(s-d,r-d,s+d,r+d):null,m=null!==f?f.length:p.length;for(let t=0;t<m;t++){const e=null!==f?f[t]:t,n=p[e];if(n)for(const t of it(n)){if(!t)continue;const n=a.distance2D(s,r,t[0],t[1])*h;n>u||(n<u&&u>2&&(u=Math.max(2,n)),n<c&&(c=n,l=e))}}return-1===l?[]:[l]}_polylineTest(t,e,n,i,s,r,o,a){const h=this._getZoomAdjustedHitBuffer(15,2),l=o>=0?o:.05,c=this._getZoomAdjustedHitBuffer(l,0);let u=this._findHitCandidates(t,e,n,i,s,r,h,a);return this._sortByDistance(s,r,u,i),u=this._pickNearestCandidates(u,c,h),u.length?[u[0].id]:[]}_polygonTest(e,n,i,s,r,o,a){const h=t.geom,l=this._getZoomAdjustedHitBuffer(10,1),c=this._findHitCandidates(e,n,i,s,r,o,l,a);let u=[];for(const t of c)h.testPointInPolygon(r,o,t.shape,s)&&u.push(t);return c.length>0&&0===u.length?(this._sortByDistance(r,o,c,s),u=this._pickNearestCandidates(c,0,l)):u.length>1&&this._sortByDistance(r,o,u,s),u.length?[u[0].id]:[]}_polygonVertexTest(t,e,n,i,s,r,o){const a=this._polygonTest(t,e,n,i,s,r,o),h=this._polylineTest(t,e,n,i,s,r,5,o);return a.length?a:h}_queryFeaturesAtPoint(t,e,n){const i=this._getTransform(),s=[],[r,o]=this._unproject(t[0],t[1]),a=1/Math.abs(i.mx||1);for(const[t,i]of this._sources){const h=i.getLayers(),l=i.getDisplayArcs(),c=l?l.getScaledArcs(a):i.getArcs(),u=i.getDataset?.();for(let i=0;i<h.length;i++){const a=h[i];if(!a?.shapes)continue;if(!this._layerMatchesFilter(a,i,e.layers))continue;const l=nt(a,i);if(n&&!n.has(`${t}:${l}`))continue;const p=a.geometry_type;let d=[];if("point"===p?d=this._pointTest(t,i,a,r,o,u):"polyline"===p&&c?d=this._polylineTest(t,i,a,c,r,o,-1,u):"polygon"===p&&c&&(d=this._polygonVertexTest(t,i,a,c,r,o,u)),0!==d.length)for(const e of d){const n=a.data,i=n?.getRecordAt?.(e)??n?.getRecords?.()?.[e]??{};s.push({id:e,source:t,layer:l,geometryType:p||"unknown",properties:{...i}})}}}return s}_queryFeaturesInBBox(t,e,n){const i=this._getTransform(),s=[],[r,o]=t,a=this._unproject(r[0],r[1]),h=this._unproject(o[0],o[1]),l=Math.min(a[0],h[0]),c=Math.min(a[1],h[1]),u=Math.max(a[0],h[0]),p=Math.max(a[1],h[1]),d=1/Math.abs(i.mx||1);for(const[t,i]of this._sources){const r=i.getLayers(),o=i.getDisplayArcs(),a=o?o.getScaledArcs(d):i.getArcs(),h=i.getDataset?.();for(let i=0;i<r.length;i++){const o=r[i];if(!o?.shapes)continue;if(!this._layerMatchesFilter(o,i,e.layers))continue;const d=nt(o,i);if(n&&!n.has(`${t}:${d}`))continue;const _=o.geometry_type,f=o.data,m=[],y=this._getOrBuildIndex(t,i,o,a,h),g=y?y.index.search(l,c,u,p):null,v=null!==g?g.length:o.shapes.length;for(let e=0;e<v;e++){const n=null!==g?g[e]:e,i=o.shapes[n];if(!i)continue;let r=!1;if("point"===_)r=it(i).some(t=>t[0]>=l&&t[0]<=u&&t[1]>=c&&t[1]<=p);else if(a){const t=i;for(let e=0;e<t.length;e++)if(a.getSimpleShapeBbox(t[e],m),!(u<m[0]||l>m[2]||p<m[1]||c>m[3])){r=!0;break}}if(!r)continue;const h=f?.getRecordAt?.(n)??f?.getRecords?.()?.[n]??{};s.push({id:n,source:t,layer:d,geometryType:_||"unknown",properties:{...h}})}}}return s}}class Gn{_host;constructor(t){this._host=t}get(t){const e=this._host.layers.resolve(t.source,t.layer);if(!e)return null;if(!Number.isInteger(t.id)||t.id<0)return null;const n=e.shapes??null;if(!n||t.id>=n.length)return null;const i=n[t.id],s=e.data?.getRecords?.()??[];return{ref:t,geometry:i,properties:Object.freeze({...s[t.id]??{}})}}*iter(t,e){const n=this._host.layers.resolve(t,e);if(!n||!n.shapes)return;const i=n.shapes,s=n.data?.getRecords?.()??[];for(let n=0;n<i.length;n++)yield{ref:{source:t,layer:e,id:n},geometry:i[n],properties:Object.freeze({...s[n]??{}})}}count(t,e){const n=this._host.layers.resolve(t,e);return n?.shapes?.length??0}}class On{_all=new globalThis.Set;get size(){return this._all.size}register(t){return this._all.add(t),()=>{this._all.delete(t)}}unregisterAll(){this._all.clear()}async runFor(t,e,n){if(0===this._all.size)return[];const i=[];for(const e of this._all)e.phase===t&&i.push(e);if(0===i.length)return[];const s=await Promise.allSettled(i.map(t=>t.run(e,n))),r=[];for(let t=0;t<i.length;t++){const e=i[t],n=s[t];let o;o="fulfilled"===n.status?n.value:{ok:!1,issues:[{severity:"error",message:`validator '${e.name}' threw: ${n.reason instanceof Error?n.reason.message:String(n.reason)}`}]},r.push({validator:e.name,report:o})}return r}}class Bn{_highlighted=new globalThis.Map;_highlightStyle={color:"#ff7a00",width:2.2,radius:6,fill:!0};get size(){return this._highlighted.size}setHighlightedFeatures(t,e){this._highlighted.clear(),e&&(this._highlightStyle={...this._highlightStyle,...e});for(const e of t){const t=this._highlighted.get(e.source)||new globalThis.Map,n=t.get(e.layer)||new Set;n.add(e.id),t.set(e.layer,n),this._highlighted.set(e.source,t)}}clearHighlightedFeatures(){return 0!==this._highlighted.size&&(this._highlighted.clear(),!0)}setHighlightStyle(t){return this._highlightStyle={...this._highlightStyle,...t},this._highlighted.size>0}renderHighlights(t,e,n,i,s){if(0===this._highlighted.size)return;const r=this._highlightStyle.color||"#ff7a00",o=(this._highlightStyle.width??2.2)*i,a=this._highlightStyle.radius??6,h=!1!==this._highlightStyle.fill,l=1/Math.abs(n.mx||1);for(const[n,i]of e){const e=this._highlighted.get(n);if(!e)continue;const c=i.getLayers(),u=i.getDisplayArcs(),p=u?u.getScaledArcs(l):i.getArcs();for(let i=0;i<c.length;i++){const l=c[i];if(!l?.shapes)continue;const u=nt(l,i);if(s&&!s.has(`${n}:${u}`))continue;const d=e.get(u);if(!d||0===d.size)continue;const _=[];for(const t of d){const e=l.shapes[t];e&&_.push(e)}0!==_.length&&("point"===l.geometry_type?t.drawPoints(_,{color:r,radius:a,fill:h}):p&&t.drawPaths(_,{color:r,width:o},p))}}}}class zn{_byKey=new globalThis.Map;_size=0;get size(){return this._size}has(t){return this._byKey.get(t.source)?.get(t.layer)?.has(t.id)??!1}getAll(){const t=[];for(const[e,n]of this._byKey)for(const[i,s]of n)for(const n of s)t.push({source:e,layer:i,id:n});return t}getByLayer(t,e){const n=this._byKey.get(t)?.get(e);return n?Array.from(n):[]}clear(){if(0===this._size)return{added:[],removed:[],changed:!1};const t=this.getAll();return this._byKey.clear(),this._size=0,{added:[],removed:t,changed:!0}}apply(t,e){const n=$n(t);if("replace"===e){const t=this._refSetSnapshot();this._byKey.clear(),this._size=0;for(const t of n)this._addOne(t);return jn(t,this._refSetSnapshot())}const i=[],s=[];if("add"===e)for(const t of n)this._addOne(t)&&i.push(t);else for(const t of n)this.has(t)?this._removeOne(t)&&s.push(t):this._addOne(t)&&i.push(t);return{added:i,removed:s,changed:i.length>0||s.length>0}}remove(t){const e=[];for(const n of $n(t))this._removeOne(n)&&e.push(n);return{added:[],removed:e,changed:e.length>0}}snapshot(){return this._refSetSnapshot()}restore(t){const e=this._refSetSnapshot();this._byKey.clear(),this._size=0;for(const e of t)this._addOne(qn(e));return jn(e,t)}_addOne(t){let e=this._byKey.get(t.source);e||(e=new globalThis.Map,this._byKey.set(t.source,e));let n=e.get(t.layer);return n||(n=new Set,e.set(t.layer,n)),!n.has(t.id)&&(n.add(t.id),this._size++,!0)}_removeOne(t){const e=this._byKey.get(t.source),n=e?.get(t.layer);return!!n?.has(t.id)&&(n.delete(t.id),this._size--,0===n.size&&(e.delete(t.layer),0===e.size&&this._byKey.delete(t.source)),!0)}_refSetSnapshot(){const t=new Set;for(const[e,n]of this._byKey)for(const[i,s]of n)for(const n of s)t.add(Un(e,i,n));return t}}function Un(t,e,n){return JSON.stringify([t,e,n])}function qn(t){const[e,n,i]=JSON.parse(t);return{source:e,layer:n,id:i}}function jn(t,e){const n=[],i=[];for(const i of e)t.has(i)||n.push(qn(i));for(const n of t)e.has(n)||i.push(qn(n));return{added:n,removed:i,changed:n.length>0||i.length>0}}function $n(t){const e=new Set,n=[];for(const i of t){const t=Un(i.source,i.layer,i.id);e.has(t)||(e.add(t),n.push(i))}return n}class Vn{_undoStack=[];_redoStack=[];_maxSize;_lastSkippedStale=!1;_captureBuffer=null;constructor(t={}){if(this._maxSize=t.maxSize??200,this._maxSize<1)throw new Error("EditHistory: maxSize must be >= 1")}push(t){if(this._captureBuffer)return void this._captureBuffer.push(t);const e=this._undoStack[this._undoStack.length-1];if(e&&!e.stale&&e.merge&&t.mergeable?.(e))return e.merge(t),void(this._redoStack.length=0);if(t.invalidatesPriorCommands){for(const t of this._undoStack)t.stale=!0;this._redoStack.length=0}this._undoStack.push(t),this._redoStack.length=0,this._undoStack.length>this._maxSize&&this._undoStack.shift()}beginCapture(){if(this._captureBuffer)throw new Error("EditHistory: nested capture not supported");this._captureBuffer=[]}endCapture(){const t=this._captureBuffer;return this._captureBuffer=null,t??[]}isCapturing(){return null!==this._captureBuffer}undo(){const t=this._undoStack.pop();return t?(t.stale?this._lastSkippedStale=!0:(t.undo(),this._lastSkippedStale=!1),this._redoStack.push(t),t):null}redo(){const t=this._redoStack.pop();return t?(t.stale?this._lastSkippedStale=!0:(t.do(),this._lastSkippedStale=!1),this._undoStack.push(t),t):null}clear(){this._undoStack.length=0,this._redoStack.length=0,this._lastSkippedStale=!1}canUndo(){return this._undoStack.length>0}canRedo(){return this._redoStack.length>0}size(){return this._undoStack.length}snapshot(){const t=this._undoStack[this._undoStack.length-1];let e=0;for(const t of this._undoStack)t.stale&&e++;const n={canUndo:this._undoStack.length>0,canRedo:this._redoStack.length>0,label:t?.label,staleCount:e,topIsStale:!!t?.stale};return this._lastSkippedStale&&(n.skippedStale=!0),n}}class Hn{_host;_datasetSnapshots=new globalThis.Map;_selectionSnapshot;_closed=!1;constructor(t){if(t._activeTransaction)throw new Error("Transaction: another transaction is already active");this._host=t,this._selectionSnapshot=t._selection.snapshot(),t._history.beginCapture(),t._activeTransaction=this}_captureFirstTouch(t,e){this._datasetSnapshots.has(t)||this._datasetSnapshots.set(t,e)}get isOpen(){return!this._closed}async commit(t){this._end();const e=this._host._history.endCapture();if(0===e.length)return at;const n=new Lt(e,t);return this._host._history.push(n),this._host._fireHistoryChange(),at}rollback(){this._end(),this._host._history.endCapture();for(const[t,e]of this._datasetSnapshots){const n=this._host._sources.get(t);n&&n.setDataset(e)}const t=this._host._selection.restore(this._selectionSnapshot);t.changed&&this._host._fireSelectionChange(t),this._host._fireHistoryChange(),this._host._scheduleRender()}_end(){if(this._closed)throw new Error("Transaction: already committed or rolled back");this._closed=!0,this._host._activeTransaction=null}}class Wn{opts;label="Delete feature";constructor(t){this.opts=t}do(){const{layer:t,featureId:e}=this.opts;if(!t.shapes)return;t.shapes.splice(e,1);const n=t.data?.getRecords?.();n?.splice(e,1)}undo(){const{layer:t,featureId:e,shape:n,record:i}=this.opts;if(t.shapes||(t.shapes=[]),t.shapes.splice(e,0,n),null!==i){const n=t.data?.getRecords?.();n?.splice(e,0,i)}}}class Kn{opts;label;constructor(t){this.opts=t,this.label=`Delete ${t.snapshots.length} feature${1===t.snapshots.length?"":"s"}`}do(){const{layer:t,snapshots:e}=this.opts;if(!t.shapes||0===e.length)return;const n=new Set;for(const t of e)n.add(t.id);const i=t.shapes,s=new Array(i.length-n.size);let r=0;for(let t=0;t<i.length;t++)n.has(t)||(s[r++]=i[t]);t.shapes=s;const o=t.data?.getRecords?.();if(o){let t=0;for(let e=0;e<o.length;e++)n.has(e)||(o[t++]=o[e]);o.length=t}}undo(){const{layer:t,snapshots:e}=this.opts;t.shapes||(t.shapes=[]);const n=[...e].sort((t,e)=>t.id-e.id),i=t.data?.getRecords?.();for(const e of n)t.shapes.splice(e.id,0,e.shape),i&&null!==e.record&&i.splice(e.id,0,e.record)}}function Xn(t,e){const n=t||{};return{color:n["line-color"]||n["fill-color"]||"#333",width:(n["line-width"]??.8)*e}}function Zn(t){const e=t||{};return{color:e["circle-color"]||"#333",radius:e["circle-radius"]??4,fill:!1!==e["circle-fill"]}}class Jn extends j{_container;_canvasContainer;_canvas;_painter;_editOverlay;_viewport=new X;_projection=new et;_sources=new globalThis.Map;_layersCache;get layers(){return this._layersCache??(this._layersCache=new Ct(this._sources))}_sourceListeners=new globalThis.Map;_layers=[];_effectiveLayersCache=[];_defaultLayersDirty=!0;_layerArcFlagsCache=new globalThis.Map;_mouseWheel;_dragPan;_pendingRender=0;_rafId=0;_controlContainers=new globalThis.Map;_controls=[];_highlightManager=new Bn;_featureQuery;features;_selection=new zn;_history=new Vn;_activeTransaction=null;_validators=new On;get validators(){return this._validators}_historyShortcutUnbind=null;_ops;_editSession;_attributes;get ops(){return this._ops??(this._ops=new Tt(this))}get editSession(){return this._editSession??(this._editSession=new Kt(this))}get attributes(){return this._attributes??(this._attributes=new ee(this))}_editState=new ne(t=>{t.modeChanged&&(this._dragPan?.setEnabled("none"===t.current.mode),this.fire("editmodechange",{mode:t.current.mode})),this._scheduleRender()});_workerPool=null;_workerMode=!1;_workerThreshold=5e4;_workerRouting;_expressionPolicy="disabled";constructor(t){if(super(),"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container #${t.container} not found`);this._container=e}else this._container=t.container;this._canvasContainer=this._createCanvasContainer(),this._container.appendChild(this._canvasContainer),this._canvas=document.createElement("canvas"),this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0",this._canvasContainer.appendChild(this._canvas),this._painter=new st(this._canvas),this._painter.setPixelRatio(window.devicePixelRatio||1),this._editOverlay=new rt(this._painter),this._updateSize(),this._viewport.onViewChange=()=>this.fire("move"),this._viewport.initZoomTween(),this._mouseWheel=new Ln(this._canvasContainer),this._dragPan=new Nn(this._canvasContainer),this._featureQuery=new Fn(this._sources,()=>this._viewport.transform,()=>({width:this._viewport.width,height:this._viewport.height}),()=>this._viewport.initialMX),this.features=new Gn(this),this._attachEventListeners(),this.on("move",()=>this._scheduleRender()),this.on("resize",()=>this._scheduleRender()),this.on("reset",()=>this.reset()),this.on("historychange",()=>this._runAfterCommitValidators()),this._expressionPolicy=t.expressionPolicy??"disabled",this._workerMode=t.useWorker??t.workerMode??!1,"number"==typeof t.workerThreshold&&t.workerThreshold>=0&&(this._workerThreshold=t.workerThreshold),this._workerRouting=t.workerRouting,(!1!==this._workerMode||t.workerPool)&&(t.workerPool?this._workerPool=t.workerPool:this._workerPool=new Rn({workerUrl:t.workerUrl??"emap-worker.js",poolSize:t.workerPoolSize}))}cancelWorkerJobs(){this._workerPool?.cancelAll()}setExpressionPolicy(t){this._expressionPolicy=t}getExpressionPolicy(){return this._expressionPolicy??"disabled"}_allowExpressionEvaluation(t,e){return!t.some(t=>"string"==typeof t&&t.trim().length>0)||"trusted"===this.getExpressionPolicy()||(this.fire("error",{error:new Error(`${e}: expression evaluation is disabled`)}),!1)}getCanvasContainer(){return this._canvasContainer}getEditMode(){return this._editState.mode}setEditMode(t){this._editState.setMode(t)}setEditVertexState(t){this._editState.setVertex(t)}clearEditVertexState(){this._editState.clearVertex()}setEditDrawState(t){this._editState.setDraw(t)}clearEditDrawState(){this._editState.clearDraw()}_attachEventListeners(){this._dragPan.on("pan",t=>{this._viewport.pan(t.dx,t.dy),this.fire("move")}),this._dragPan.on("panstart",()=>{this._viewport.cancelZoomAnimation()}),this._mouseWheel.on("mousewheel",t=>{this._viewport.applyWheelZoom(t.direction,t.multiplier,t.x,t.y),this.fire("move")})}_createCanvasContainer(){const t=document.createElement("div");t.style.position="relative",t.style.width="100%",t.style.height="100%",t.style.overflow="hidden",t.className="emap-canvas-container";const e=["top-left","top-right","bottom-left","bottom-right"];for(const n of e){const e=document.createElement("div");e.className=`emap-ctrl-${n}`,e.style.position="absolute",e.style.pointerEvents="none",e.style.zIndex="10";const[i,s]=n.split("-");e.style[i]="10px",e.style[s]="10px",e.style.display="flex",e.style.flexDirection="column",e.style.gap="8px";const r=t=>t.stopPropagation();for(const t of["click","mousedown","mouseup","dblclick","contextmenu"])e.addEventListener(t,r);e.addEventListener("wheel",r,{passive:!0}),t.appendChild(e),this._controlContainers.set(n,e)}return t}_updateSize(){const t=this._container.clientWidth,e=this._container.clientHeight;this._viewport.updateSize(t,e),this._painter.resize(t,e)}addSource(t,e){this._sources.set(t,e);const n=n=>{if(1===this._sources.size&&e.getCRS){const t=e.getCRS();t&&this._projection.crs!==t&&(this._projection.setCRS(t),this._viewport.setCRS(t),this.fire("crschange"))}this.fire("data",{sourceId:t,...n}),this._defaultLayersDirty=!0,this._layerArcFlagsCache.clear(),this._scheduleRender()};this._sourceListeners.set(t,n),e.on("data",n),e.getDataset&&e.getDataset()&&n({type:"data"})}removeSource(t){const e=this._sources.get(t);if(e){const n=this._sourceListeners.get(t);n&&(e.off("data",n),this._sourceListeners.delete(t)),this._sources.delete(t),this._defaultLayersDirty=!0,this._layerArcFlagsCache.delete(t);for(const e of this._layerArcFlagsCache.keys())e.startsWith(`${t}:`)&&this._layerArcFlagsCache.delete(e);this._scheduleRender()}}getSource(t){return this._sources.get(t)}async exportSnapshot(t={}){const e=!1!==t.compact,n=[],i=[];for(const[t,e]of this._sources){if("topology"!==e.type)continue;const s=e.getDataset?.();s&&(n.push(t),i.push(s))}const s=Y(),r=await s.exportDatasetsToPack(i,{compact:e});r.emap={version:1,sources:n.map(t=>({id:t}))};const o=s.pack(r);return new Blob([o],{type:"application/octet-stream"})}async loadSnapshot(t,e={}){const n=!1!==e.replace,i=e.idPrefix??"",s=e.defaultIds??[];let r;if(t instanceof Uint8Array)r=t;else if(t instanceof ArrayBuffer)r=new Uint8Array(t);else{if(!("undefined"!=typeof Blob&&t instanceof Blob))throw new Error("loadSnapshot: input must be Blob, Uint8Array, or ArrayBuffer");r=new Uint8Array(await t.arrayBuffer())}if(!function(t){if(!t||0===t.length)return!1;const e=t[0];return e>=128&&e<=143||222===e||223===e}(r))throw new Error("loadSnapshot: input does not look like a mapshaper .msx snapshot (expected msgpack map marker as the first byte)");const o=await Y().unpackSessionData(r),a=o.datasets??[],h=o.emap,l=h?.sources?.map(t=>t?.id).filter(t=>"string"==typeof t)??[],c=a.map((t,e)=>{const n=l[e],r=s[e]??`snapshot-${e}`;return i+(n??r)});if(!n)for(const t of c)if(this._sources.has(t))throw new Error(`loadSnapshot: source "${t}" already exists (pass { replace: true } to overwrite)`);this._history.clear(),this._fireSelectionChange(this._selection.clear()),this.fire("historychange");const u=[];for(let t=0;t<a.length;t++){const e=c[t];n&&this._sources.has(e)&&this.removeSource(e);const i=new Pn(e);i.setDataset(a[t]),this.addSource(e,i),u.push(e)}return u}addLayer(t,e){if(!this._sources.has(t.source))throw new Error(`Source "${t.source}" not found`);if(this._layers.some(e=>e.id===t.id))throw new Error(`Layer "${t.id}" already exists`);if(e){const n=this._layers.findIndex(t=>t.id===e);if(-1===n)throw new Error(`Layer "${e}" not found`);this._layers.splice(n,0,{...t})}else this._layers.push({...t});this._defaultLayersDirty=!0,this._scheduleRender()}removeLayer(t){const e=this._layers.findIndex(e=>e.id===t);-1!==e&&(this._layers.splice(e,1),this._defaultLayersDirty=!0,this._scheduleRender())}getLayer(t){return this._layers.find(e=>e.id===t)}getLayers(){return[...this._layers]}setLayerVisibility(t,e){const n=this._layers.find(e=>e.id===t);n&&(n.layout||(n.layout={}),n.layout.visibility=e,this._scheduleRender())}setPaintProperty(t,e,n){const i=this._layers.find(e=>e.id===t);i&&(i.paint||(i.paint={}),i.paint[e]=n,this._scheduleRender())}moveLayer(t,e){const n=this._layers.findIndex(e=>e.id===t);if(-1===n)return;const[i]=this._layers.splice(n,1);if(e){const t=this._layers.findIndex(t=>t.id===e);-1===t?this._layers.push(i):this._layers.splice(t,0,i)}else this._layers.push(i);this._defaultLayersDirty=!0,this._scheduleRender()}_getEffectiveLayers(){if(this._layers.length>0)return this._layers;if(!this._defaultLayersDirty)return this._effectiveLayersCache;const t=[];for(const[e,n]of this._sources){const i=n.getLayers();if(0===i.length)t.push({id:`${e}:default`,type:"line",source:e,paint:{"line-color":"#333","line-width":.8}});else for(let n=0;n<i.length;n++){const s=i[n],r=nt(s,n),o=s.geometry_type;t.push({id:`${e}:${r}`,type:"point"===o?"circle":"line",source:e,"source-layer":r,paint:"point"===o?{"circle-color":"#333","circle-radius":4}:{"line-color":"#333","line-width":.8}})}}return this._effectiveLayersCache=t,this._defaultLayersDirty=!1,t}_resolveSourceLayer(t,e){const n=t.getLayers();if(!n.length)return null;if(!e)return n[0];for(let t=0;t<n.length;t++){if(nt(n[t],t)===e)return n[t]}return null}_getLayerArcFlags(t,e,n){if(!t||!t.shapes||!e)return null;let i=this._layerArcFlagsCache.get(n);if(i)return i;const s=e.size();i=new Uint8Array(s);const r=t.shapes;for(const t of r)if(t)for(const e of t)for(const t of e){i[t>=0?t:~t]=1}return this._layerArcFlagsCache.set(n,i),i}_getVisibleLayerKeys(){const t=new Set,e=this._getEffectiveLayers();for(const n of e){if("none"===n.layout?.visibility)continue;const e=this._sources.get(n.source);if(!e)continue;const i=this._resolveSourceLayer(e,n["source-layer"]);if(i){const s=e.getLayers().indexOf(i),r=nt(i,s>=0?s:0);t.add(`${n.source}:${r}`)}}return t}getPainter(){return this._painter}getCRS(){return this._projection.crs}setCRS(t){this._projection.setCRS(t),this._viewport.setCRS(t),this.fire("crschange")}async reproject(t){if(this._projection.crs===t)return;const e=await this._projection.reproject(t,this._sources);this._viewport.setCRS(t),this._viewport.clearInitialState(),e.hasBounds()&&this.setExtent(e),this.fire("crschange"),this.fire("data",{reason:"reproject"})}getCenter(){const t=this._viewport.transform,e=(this._viewport.width/2-t.bx)/t.mx,n=(this._viewport.height/2-t.by)/t.my;return this._projection.getCenter(e,n)}getZoom(){return this._projection.getZoom(Math.abs(this._viewport.transform.mx))}getTransform(){return this._viewport.transform}getExtent(){return this._viewport.extent}setExtent(t){this._viewport.setExtent(t),this.fire("move")}reset(){this._viewport.reset()}addControl(t,e="top-left"){const n=t.onAdd(this);n.style.pointerEvents="auto",this._controlContainers.get(e)?.appendChild(n),this._controls.push(t)}removeControl(t){t.onRemove(this);const e=this._controls.indexOf(t);-1!==e&&this._controls.splice(e,1)}zoomIn(){this._viewport.zoomIn()}zoomOut(){this._viewport.zoomOut()}_scheduleRender(){this._removed||(this._pendingRender++,0===this._rafId&&(this._rafId=requestAnimationFrame(()=>this._doRender())))}_doRender(){this._rafId=0,this._pendingRender>0&&(this._pendingRender=0,this.render())}render(){const t=this._viewport.transform;this._painter.setTransform(t),this._painter.clear();const e=this._viewport.getLineScale(),n=1/Math.abs(t.mx);this._renderLayers(n,e),this._renderHighlight(t,e),this._editOverlay.render(this._editState.mode,this._editState.vertex,this._editState.draw)}_renderLayers(t,e){const n=this._getEffectiveLayers();for(const i of n){if("none"===i.layout?.visibility)continue;const n=this._sources.get(i.source);if(!n)continue;const s=n.getDisplayArcs(),r=s?s.getScaledArcs(t):n.getArcs();if(r&&r.setRetainedInterval&&("function"!=typeof r.isFlat||!r.isFlat())){const e=n.getSimplifyFloor?.()??0;r.setRetainedInterval(Math.max(e,.5*t))}const o=this._resolveSourceLayer(n,i["source-layer"]),a=`${i.source}:${i["source-layer"]||"default"}`;if("line"===i.type&&r)this._renderLineLayer(i,o,r,a,e);else if("fill"===i.type&&r&&o?.shapes)this._renderFillLayer(i,o,r,a,e);else if("circle"===i.type&&o?.shapes){const t=Zn(i.paint);this._painter.drawPoints(o.shapes,t)}}}_renderLineLayer(t,e,n,i,s){const r=Xn(t.paint,s);if(e?.shapes){const t=this._getLayerArcFlags(e,n,i),s=this._combineArcFilters(t,this._viewport.getArcFilter(n));this._painter.drawArcs(n,r,s)}else this._painter.drawArcs(n,r,this._viewport.getArcFilter(n))}_renderFillLayer(t,e,n,i,s){const r=t.paint,o=r?.["fill-color"]||"rgba(200, 200, 200, 0.4)",a=r?.["fill-opacity"],h=this._viewport.getArcFilter(n);this._painter.drawPolygonFill(e.shapes,n,o,h,a);const l=Xn(t.paint,s),c=this._getLayerArcFlags(e,n,i);this._painter.drawArcs(n,l,this._combineArcFilters(c,h))}_combineArcFilters(t,e){return t&&e?n=>1===t[n]&&e(n):t?e=>1===t[e]:e}_renderHighlight(t,e){const n=this._getVisibleLayerKeys();this._highlightManager.renderHighlights(this._painter,this._sources,t,e,n)}project(t,e){return this._viewport.project(t,e)}unproject(t,e){return this._viewport.unproject(t,e)}resize(){this._updateSize(),this._viewport.setExtent(this._viewport.extent),this.fire("resize")}queryFeatures(t,e){const n=this._getVisibleLayerKeys();return this._featureQuery.query(t,e,n)}prebuildSpatialIndex(t){this._featureQuery.prebuild(t)}clearSpatialIndex(t){this._featureQuery.clear(t)}_clearSpatialIndexesForSources(t){for(const e of t)this._featureQuery?.clear(e)}setHighlightedFeatures(t,e){this._highlightManager.setHighlightedFeatures(t,e),this._scheduleRender()}clearHighlightedFeatures(){this._highlightManager.clearHighlightedFeatures()&&this._scheduleRender()}setHighlightStyle(t){this._highlightManager.setHighlightStyle(t)&&this._scheduleRender()}select(t,e){const n=e?.mode??"replace",i=this._selection.apply(t,n);this._fireSelectionChange(i)}deselect(t){const e=this._selection.remove(t);this._fireSelectionChange(e)}clearSelection(){const t=this._selection.clear();this._fireSelectionChange(t)}getSelection(){return this._selection.getAll()}isSelected(t){return this._selection.has(t)}_fireSelectionChange(t){t.changed&&this.fire("selectionchange",{selected:this._selection.getAll(),added:t.added,removed:t.removed})}deleteSelected(){const t=this._selection.getAll();if(0===t.length)return!1;const e=new globalThis.Map;for(const n of t){let t=e.get(n.source);t||(t=new globalThis.Map,e.set(n.source,t));const i=t.get(n.layer)??[];i.push(n.id),t.set(n.layer,i)}const n=[];let i=0;for(const[t,s]of e){const e=this._sources.get(t);if(!e)continue;const r=e.getLayers();for(const[t,e]of s){let s=null;for(let e=0;e<r.length;e++)if(nt(r[e],e)===t){s=r[e];break}if(!s?.shapes)continue;const o=s.data?.getRecords?.(),a=[],h=new Set;for(const t of e){if(h.has(t))continue;h.add(t);const e=s.shapes[t];if(void 0===e)continue;const n=o?o[t]:null;a.push({id:t,shape:e,record:n??null})}if(0===a.length)continue;const l=new Kn({layer:s,snapshots:a});l.do(),n.push(l),i+=a.length}}if(0===n.length)return!1;const s=new Lt(n,`Delete ${i} feature${i>1?"s":""}`);return this._history.push(s),this._fireHistoryChange(),this._invalidateShapeCachesForSources(e.keys()),this._fireSelectionChange(this._selection.clear()),this._scheduleRender(),!0}_invalidateShapeCachesForSources(t){for(const e of t){const t=`${e}:`;for(const e of this._layerArcFlagsCache.keys())e.startsWith(t)&&this._layerArcFlagsCache.delete(e);this._featureQuery?.clear(e)}}pushCommand(t){this._history.push(t),this._fireHistoryChange()}undo(){return!!this._history.undo()&&(this._fireHistoryChange(),this._invalidateAllShapeCaches(),this._scheduleRender(),!0)}redo(){return!!this._history.redo()&&(this._fireHistoryChange(),this._invalidateAllShapeCaches(),this._scheduleRender(),!0)}_invalidateAllShapeCaches(){this._layerArcFlagsCache.clear();for(const t of this._sources.keys())this._featureQuery?.clear(t)}canUndo(){return this._history.canUndo()}canRedo(){return this._history.canRedo()}clearHistory(){const t=this._history.canUndo()||this._history.canRedo();this._history.clear(),t&&this._fireHistoryChange()}beginTransaction(){return new Hn(this)}bindHistoryShortcuts(t){this._historyShortcutUnbind?.();const e=t??this._canvasContainer;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1");const n=t=>{if(!(t.ctrlKey||t.metaKey))return;const e="z"===t.key||"Z"===t.key,n="y"===t.key||"Y"===t.key;e&&!t.shiftKey?(t.preventDefault(),this.undo()):(e&&t.shiftKey||n)&&(t.preventDefault(),this.redo())};e.addEventListener("keydown",n);const i=()=>{e.removeEventListener("keydown",n),this._historyShortcutUnbind===i&&(this._historyShortcutUnbind=null)};return this._historyShortcutUnbind=i,i}_fireHistoryChange(){const t=this._history.snapshot();this.fire("historychange",t)}_runAfterCommitValidators(){if(0===this._validators.size)return;const t={label:this._history.snapshot().label??""};this._validators.runFor("after-commit",this,t).then(e=>{if(this._removed)return;const n=e.filter(t=>!t.report.ok);n.length>0&&this.fire("validationfailed",{results:n,label:t.label})})}_resolveLayer(t,e){return this.layers.resolve(t,e)}remove(){if(this._removed)return;this._removed=!0,0!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=0),this._pendingRender=0,this._dragPan.destroy(),this._mouseWheel.destroy(),this._historyShortcutUnbind?.(),this._historyShortcutUnbind=null,this._workerPool&&(this._workerPool.cancelAll(),this._workerPool.destroy(),this._workerPool=null);for(const[t,e]of this._sourceListeners){const n=this._sources.get(t);n?.off("data",e)}this._sourceListeners.clear();for(const t of this._sources.keys())this._featureQuery?.clear(t);this._layerArcFlagsCache.clear(),this._sources.clear();const t=this._controls??[];for(const e of[...t])try{e.onRemove(this)}catch(t){this.fire("error",{error:t})}t.length=0,this._controlContainers?.clear(),this._editState?.setMode("none"),this._container&&this._canvasContainer&&this._container.removeChild(this._canvasContainer)}_removed=!1}function Yn(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\0/g,"\\0")}"`}const Qn=/^[A-Za-z0-9_\-:.一-鿿][A-Za-z0-9_\-:. 一-鿿]*$/,ti=/^[A-Za-z0-9_\-.一-鿿][A-Za-z0-9_\-. 一-鿿]*$/;function ei(t){return"string"==typeof t&&t.length>0&&Qn.test(t)}function ni(t){return"string"==typeof t&&t.length>0&&ti.test(t)}function ii(t){for(const e of t)if(!ni(e))return"string"==typeof e?e:String(e);return null}function si(t={}){const e=t.severity??"error";return{name:"topology",phase:"after-commit",async run(n){const i=Y(),s=t.sources??Array.from(n._sources.keys()),r=[];for(const o of s){const s=n._sources.get(o)?.getDataset();if(!s||!s.arcs)continue;const a={};void 0!==t.tolerance&&(a.tolerance=t.tolerance);const h=i.findSegmentIntersections(s.arcs,a);h.length>0&&r.push({severity:e,message:`${o}: ${h.length} self-intersection${1===h.length?"":"s"}`})}return{ok:0===r.length,issues:r}}}}class ri{opts;label="Move vertex";_mergeAt=Date.now();constructor(t){this.opts=t}do(){(this.opts.adapter??Y()).snapVertices(this.opts.vertexIds,this.opts.to,this.opts.arcs),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}undo(){(this.opts.adapter??Y()).snapVertices(this.opts.vertexIds,this.opts.from,this.opts.arcs),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}mergeable(t){if(!(t instanceof ri))return!1;if(t.opts.source!==this.opts.source)return!1;if(Date.now()-t._mergeAt>500)return!1;const e=t.opts.vertexIds,n=this.opts.vertexIds;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}merge(t){t instanceof ri&&(this.opts.to=t.opts.to,this._mergeAt=Date.now())}}class oi{opts;label="Insert vertex";constructor(t){this.opts=t}do(){(this.opts.adapter??Y()).insertVertex(this.opts.arcs,this.opts.insertionId,this.opts.point),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}undo(){(this.opts.adapter??Y()).deleteVertex(this.opts.arcs,this.opts.insertionId),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}class ai{opts;label="Delete vertex";constructor(t){this.opts=t}do(){(this.opts.adapter??Y()).deleteVertex(this.opts.arcs,this.opts.vertexIndex),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}undo(){(this.opts.adapter??Y()).insertVertex(this.opts.arcs,this.opts.vertexIndex,this.opts.coords),this.opts.source.markDisplayArcsDirty?.(),Ft(this.opts.source.getDataset?.())}}class hi{opts;label;constructor(t){this.opts=t,this.label=`Draw ${t.geometryType}`}do(){const t=this.opts,e=t.adapter??Y();if("point"!==t.geometryType){if(!t.arcs||!t.arcVertices)throw new Error("FeatureCreateCommand: path features require arcs and arcVertices");e.appendEmptyArc(t.arcs);for(const n of t.arcVertices)e.appendVertex(t.arcs,n)}if(t.layer.shapes||(t.layer.shapes=[]),t.layer.shapes.push(t.appendedShape),null!==t.appendedRecord){const e=t.layer.data?.getRecords?.();e?.push(t.appendedRecord)}t.source.markDisplayArcsDirty?.(),Ft(t.source.getDataset?.())}undo(){const t=this.opts,e=t.adapter??Y();if(t.layer.shapes?.pop(),null!==t.appendedRecord){const e=t.layer.data?.getRecords?.();e?.pop()}"point"!==t.geometryType&&t.arcs&&e.deleteLastArc(t.arcs),t.source.markDisplayArcsDirty?.(),Ft(t.source.getDataset?.())}}class li{_map=null;_container=null;_options;constructor(t={}){this._options={showZoom:!0,showHome:!0,...t}}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className=`emap-ctrl emap-ctrl-group ${this._options.className||""}`,this._options.showZoom&&(this._createButton("zoom-in","+","Zoom In",()=>{this._map?.zoomIn()}),this._createButton("zoom-out","-","Zoom Out",()=>{this._map?.zoomOut()})),this._options.showHome&&this._createButton("home","⌂","Reset View",()=>{this._map?.fire("reset")}),this._container}_createButton(t,e,n,i){const s=document.createElement("button");s.className=`emap-ctrl-${t}`,s.type="button",s.title=n;const r=document.createElement("span");r.className="emap-ctrl-icon",r.textContent=e,s.appendChild(r),s.addEventListener("click",i),this._container?.appendChild(s)}onRemove(){this._container&&this._container.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null}}class ci{_map=null;_container=null;_options;_mousePosEl=null;_epsgEl=null;_onMouseMoveBound;_onUpdateEPSGBound;_rafPending=!1;constructor(t={}){this._options={showMousePos:!0,showEPSG:!0,alignment:"left",...t},this._onMouseMoveBound=this._onMouseMove.bind(this),this._onUpdateEPSGBound=this._updateEPSG.bind(this)}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className=`emap-ctrl emap-status-ctrl emap-align-${this._options.alignment} ${this._options.className||""}`,this._options.showMousePos&&(this._mousePosEl=document.createElement("span"),this._mousePosEl.className="emap-status-mousepos",this._container.appendChild(this._mousePosEl)),this._options.showEPSG&&(this._epsgEl=document.createElement("span"),this._epsgEl.className="emap-status-epsg",this._container.appendChild(this._epsgEl),this._updateEPSG()),this._map.on("crschange",this._onUpdateEPSGBound),this._map.getCanvasContainer().addEventListener("mousemove",this._onMouseMoveBound),this._container}_onMouseMove(t){if(!this._map||!this._mousePosEl||!this._options.showMousePos)return;if(this._rafPending)return;this._rafPending=!0;const e=t.clientX,n=t.clientY;requestAnimationFrame(()=>{if(this._rafPending=!1,!this._map||!this._mousePosEl)return;const t=this._map.getCanvasContainer().getBoundingClientRect(),i=e-t.left,s=n-t.top,[r,o]=this._map.unproject(i,s);this._mousePosEl.textContent=` ${r.toFixed(4)}, ${o.toFixed(4)}`})}_updateEPSG(){if(!this._map||!this._epsgEl)return;const t=this._map.getCRS();this._epsgEl.textContent=` | ${t}`}onRemove(){this._map&&(this._map.getCanvasContainer().removeEventListener("mousemove",this._onMouseMoveBound),this._map.off("crschange",this._onUpdateEPSGBound)),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null}}const ui=[{name:"OSM",url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png",type:"raster"},{name:"CartoDB Light",url:"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",type:"raster"},{name:"CartoDB Dark",url:"https://basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png",type:"raster"}];class pi{_map=null;_container=null;_basemapContainer=null;_maplibre=null;_maplibreMap=null;_styles;_activeStyle=null;_isOn=!1;_syncBasemapBound;constructor(t={}){this._styles=t.styles||ui,this._syncBasemapBound=this._syncBasemap.bind(this)}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-basemap-ctrl",this._styles.forEach(t=>{const e=document.createElement("button");e.className="emap-basemap-btn",e.textContent=t.name,e.onclick=()=>this._toggleStyle(t),this._container.appendChild(e)}),this._createBasemapLayer(),this._map.on("move",this._syncBasemapBound),this._container}_createBasemapLayer(){if(!this._map)return;const t=this._map.getCanvasContainer();this._basemapContainer=document.createElement("div"),this._basemapContainer.className="emap-basemap",this._basemapContainer.style.cssText="\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 0;\n display: none;\n ",t.insertBefore(this._basemapContainer,t.firstChild)}_toggleStyle(t){this._activeStyle===t?this._turnOff():this._showBasemap(t),this._updateButtons()}async _showBasemap(t){if(this._activeStyle=t,this._isOn=!0,!this._basemapContainer||!this._map)return;this._basemapContainer.style.display="block";const e=(this._map.getCRS()||"").toLowerCase();"webmercator"!==e&&"epsg:3857"!==e&&this._map.reproject&&await this._map.reproject("webmercator"),this._maplibreMap?(this._maplibreMap.resize(),this._setStyle(t),this._syncBasemap()):await this._initMapLibre(t)}async _initMapLibre(t){if(!this._basemapContainer||!this._map)return;const e=await this._loadMapLibre(),n=this._createMapLibreStyle(t);this._maplibreMap=new e.Map({container:this._basemapContainer,style:n,center:this._map.getCenter(),zoom:this._map.getZoom(),interactive:!1,attributionControl:!1,maxPitch:0,renderWorldCopies:!0}),this._maplibreMap.on("load",()=>{this._syncBasemap()})}async _loadMapLibre(){return this._maplibre||(this._maplibre=await import("maplibre-gl")),this._maplibre}_setStyle(t){if(!this._maplibreMap)return;const e=this._createMapLibreStyle(t);this._maplibreMap.setStyle(e)}_createMapLibreStyle(t){return"raster"===t.type||t.url.includes("{z}")?{version:8,sources:{"basemap-tiles":{type:"raster",tiles:[t.url],tileSize:512}},layers:[{id:"basemap-layer",type:"raster",source:"basemap-tiles",minzoom:0,maxzoom:22}]}:t.url}_syncBasemap(){if(this._maplibreMap&&this._map&&this._isOn)try{this._maplibreMap.jumpTo({center:this._map.getCenter(),zoom:this._map.getZoom()})}catch(t){console.warn("Sync basemap failed:",t)}}_turnOff(){this._activeStyle=null,this._isOn=!1,this._basemapContainer&&(this._basemapContainer.style.display="none")}_updateButtons(){if(!this._container)return;this._container.querySelectorAll(".emap-basemap-btn").forEach((t,e)=>{const n=this._styles[e]===this._activeStyle;t.classList.toggle("active",n)})}isOn(){return this._isOn}onRemove(){this._map&&this._map.off("move",this._syncBasemapBound),this._maplibreMap&&(this._maplibreMap.remove(),this._maplibreMap=null),this._basemapContainer?.parentNode&&this._basemapContainer.parentNode.removeChild(this._basemapContainer),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null}}class di{_map=null;_container=null;_btn=null;_active=!1;_polygonFillColor;_hoveredFeature=null;_hoverVertexCoords=null;_hoverVertexIds=[];_hoverType=null;_hoverInsertionId=-1;_dragging=!1;_neighborShapes=[];_dragFromCoords=null;_onMouseMoveBound;_onMouseDownBound;_onMouseUpBound;_onMoveHandlerBound;_onContextMenuBound;constructor(t={}){this._polygonFillColor=void 0!==t.polygonFillColor?t.polygonFillColor:"rgba(0,0,0,0.15)",this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this),this._onMoveHandlerBound=this._onMapMove.bind(this),this._onContextMenuBound=this._onContextMenu.bind(this)}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group",this._btn=document.createElement("button"),this._btn.className="emap-ctrl-edit",this._btn.type="button",this._btn.title="Edit Vertices",this._btn.innerHTML='<span class="emap-ctrl-icon">✏</span>',this._btn.addEventListener("click",()=>this._toggle()),this._container.appendChild(this._btn),this._container}onRemove(){this._deactivate(),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null,this._btn=null}_toggle(){this._active?this._deactivate():this._activate()}_activate(){if(!this._map)return;this._active=!0,this._btn?.classList.add("active"),this._map.setEditMode("vertex");const t=this._map.getCanvasContainer();t.classList.add("emap-edit-active"),t.addEventListener("mousemove",this._onMouseMoveBound),t.addEventListener("mousedown",this._onMouseDownBound),t.addEventListener("contextmenu",this._onContextMenuBound),window.addEventListener("mouseup",this._onMouseUpBound),this._map.on("move",this._onMoveHandlerBound)}_deactivate(){if(!this._map)return;this._active=!1,this._btn?.classList.remove("active"),this._map.setEditMode("none"),this._map.clearEditVertexState(),this._hoveredFeature=null,this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._dragging=!1;const t=this._map.getCanvasContainer();t.classList.remove("emap-edit-active"),t.removeEventListener("mousemove",this._onMouseMoveBound),t.removeEventListener("mousedown",this._onMouseDownBound),t.removeEventListener("contextmenu",this._onContextMenuBound),window.removeEventListener("mouseup",this._onMouseUpBound),this._map.off("move",this._onMoveHandlerBound),this._map.render()}_onMapMove(){this._hoveredFeature&&!this._dragging&&(this._updateEditState(),this._map?.render())}_onContextMenu(t){if(t.preventDefault(),this._dragging)return;if("vertex"!==this._hoverType||0===this._hoverVertexIds.length)return;if(!this._hoveredFeature)return;const e=this._hoverVertexIds[0],n=this._hoveredFeature.arcs;Y().vertexIsArcEndpoint(e,n)||this._showContextMenu(t.clientX,t.clientY,()=>{this._deleteHoveredVertex()})}_deleteHoveredVertex(){if(!this._map||!this._hoveredFeature||0===this._hoverVertexIds.length)return;const t=this._hoveredFeature.arcs,e=this._hoverVertexIds[0],n=this._hoveredFeature.source,i=t.getVertex2(e);if(Y().deleteVertex(t,e),this._refreshSourceDisplayArcs(n),this._bumpSourceEditVersion(n),i){const s=this._map.getSource(n);s&&this._map.pushCommand(new ai({vertexIndex:e,coords:[i[0],i[1]],arcs:t,source:s}))}this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._map.clearEditVertexState(),this._map.render()}_refreshSourceDisplayArcs(t){this._map?.getSource(t)?.refreshDisplayArcs()}_bumpSourceEditVersion(t){const e=this._map?.getSource(t);Ft(e?.getDataset?.()??null)}_showContextMenu(t,e,n){document.getElementById("emap-ctx-menu")?.remove();const i=document.createElement("div");i.id="emap-ctx-menu",Object.assign(i.style,{position:"fixed",left:`${t}px`,top:`${e}px`,background:"#fff",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.18)",padding:"4px 0",zIndex:"9999",minWidth:"120px",font:"13px/1.5 system-ui, sans-serif"});const s=document.createElement("div");s.textContent="删除节点",Object.assign(s.style,{padding:"6px 16px",cursor:"pointer",color:"#d32"}),s.addEventListener("mouseenter",()=>{s.style.background="#f5f5f5"}),s.addEventListener("mouseleave",()=>{s.style.background=""}),s.addEventListener("click",t=>{t.stopPropagation(),i.remove(),document.removeEventListener("click",r),n()}),i.appendChild(s),document.body.appendChild(i);const r=()=>{i.remove(),document.removeEventListener("click",r)};setTimeout(()=>document.addEventListener("click",r),0)}_onMouseMove(t){if(!this._map)return;if(this._dragging)return void this._handleDrag(t);const e=this._map.getCanvasContainer().getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,s=this._map.queryFeatures([n,i]);if(0===s.length)return this._hoveredFeature=null,this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._map.clearEditVertexState(),void this._map.render();const r=s[0];if("point"===r.geometryType)return this._hoveredFeature=null,this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1,this._neighborShapes=[],this._map.clearEditVertexState(),void this._map.render();const o=this._map.getSource(r.source);if(!o)return;const a=o.getLayers(),h=o.getArcs();if(!h)return;let l=null;for(const t of a)if(t.shapes&&t.shapes[r.id]){l=t.shapes[r.id];break}l&&(this._hoveredFeature={source:r.source,layer:r.layer,id:r.id,shape:l,arcs:h,geometryType:r.geometryType,allLayers:a},this._findNearestVertices(l,h,n,i),this._hoverVertexCoords||this._findInterpolatedPoint(l,h,n,i),this._findNeighborShapes(h),this._updateEditState(),this._map.render())}_findNearestVertices(t,e,n,i){if(!this._map)return;const s=this._map.unproject(n,i),r=Y().findNearestVertices(s,t,e);if(!r||0===r.length)return this._hoverVertexCoords=null,void(this._hoverVertexIds=[]);const o=e.getVertex2(r[0]);if(!o)return this._hoverVertexCoords=null,void(this._hoverVertexIds=[]);const a=this._map.project(o[0],o[1]);Math.sqrt((a[0]-n)*(a[0]-n)+(a[1]-i)*(a[1]-i))<=10?(this._hoverVertexCoords=[o[0],o[1]],this._hoverVertexIds=r,this._hoverType="vertex",this._hoverInsertionId=-1):(this._hoverVertexCoords=null,this._hoverVertexIds=[],this._hoverType=null,this._hoverInsertionId=-1)}_findInterpolatedPoint(t,e,n,i){if(!this._map)return;const s=this._map.unproject(n,i);let r=1/0,o=null;const a=Y();if(a.forEachSegmentInShape(t,e,(t,e,n,i)=>{const h=n[t],l=i[t],c=n[e],u=i[e],p=a.findClosestPointOnSeg(s[0],s[1],h,l,c,u,0),d=p[0]-s[0],_=p[1]-s[1],f=Math.sqrt(d*d+_*_);f<r&&(r=f,o={insertionId:(t<e?t:e)+1,point:[p[0],p[1]]})}),!o)return;const h=o,l=this._map.project(h.point[0],h.point[1]);Math.sqrt((l[0]-n)*(l[0]-n)+(l[1]-i)*(l[1]-i))<=10&&(this._hoverVertexCoords=h.point,this._hoverVertexIds=[],this._hoverType="interpolated",this._hoverInsertionId=h.insertionId)}_findNeighborShapes(t){if(this._neighborShapes=[],!this._hoveredFeature||"polygon"!==this._hoveredFeature.geometryType)return;const{ii:e}=t.getVertexData(),n=this._hoveredFeature.id,i=new Set;if(this._hoverVertexIds.length>0)for(const t of this._hoverVertexIds)i.add(Y().findArcIdFromVertexId(t,e));else"interpolated"===this._hoverType&&this._hoverInsertionId>0&&i.add(Y().findArcIdFromVertexId(this._hoverInsertionId-1,e));if(0===i.size)return;const s=[];for(const t of this._hoveredFeature.allLayers)if(t.shapes)for(let e=0;e<t.shapes.length;e++){if(e===n)continue;const r=t.shapes[e];if(!r)continue;let o=!1;for(const t of r){for(const e of t){const t=e>=0?e:~e;if(i.has(t)){o=!0;break}}if(o)break}o&&s.push(r)}this._neighborShapes=s}_updateEditState(){if(!this._map||!this._hoveredFeature)return;const t=this._hoveredFeature.geometryType,e=this._neighborShapes.length>0?[this._hoveredFeature.shape,...this._neighborShapes]:[this._hoveredFeature.shape];this._map.setEditVertexState({shapes:e,arcs:this._hoveredFeature.arcs,hoverVertex:this._hoverVertexCoords,hoverType:this._hoverType,geometryType:t,polygonFill:"polygon"===t?this._polygonFillColor:null,neighborShapes:this._neighborShapes.length>0?this._neighborShapes:void 0})}_onMouseDown(t){if(this._hoverVertexCoords&&this._hoveredFeature){if(t.preventDefault(),t.stopPropagation(),"interpolated"===this._hoverType&&this._hoverInsertionId>=0){const t=this._hoveredFeature.arcs,e=[this._hoverVertexCoords[0],this._hoverVertexCoords[1]];Y().insertVertex(t,this._hoverInsertionId,e),this._hoverVertexIds=[this._hoverInsertionId],this._hoverType="vertex",this._bumpSourceEditVersion(this._hoveredFeature.source),this._pushVertexInsertCommand(this._hoverInsertionId,e)}this._dragFromCoords=this._hoverVertexCoords?[this._hoverVertexCoords[0],this._hoverVertexCoords[1]]:null,this._dragging=!0}}_pushVertexInsertCommand(t,e){if(!this._map||!this._hoveredFeature)return;const n=this._map.getSource(this._hoveredFeature.source);n&&this._map.pushCommand(new oi({insertionId:t,point:e,arcs:this._hoveredFeature.arcs,source:n}))}_handleDrag(t){if(!this._map||!this._hoveredFeature||0===this._hoverVertexIds.length)return;const e=this._map.getCanvasContainer().getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,s=this._map.unproject(n,i),r=this._hoveredFeature.arcs;Y().snapVertices(this._hoverVertexIds,[s[0],s[1]],r),this._hoverVertexCoords=[s[0],s[1]],this._updateEditState(),this._map.render()}_onMouseUp(t){if(!this._dragging||!this._map||!this._hoveredFeature)return;this._dragging=!1;const e=this._map.getCanvasContainer().getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,s=this._map.unproject(n,i),r=this._hoveredFeature.source,o=this._hoveredFeature.arcs;o.transformPoints&&o.transformPoints(function(){}),this._refreshSourceDisplayArcs(r),this._bumpSourceEditVersion(r);const a=this._dragFromCoords;if(a&&(a[0]!==s[0]||a[1]!==s[1])&&this._hoverVertexIds.length>0){const t=this._map.getSource(r);t&&this._map.pushCommand(new ri({vertexIds:[...this._hoverVertexIds],from:[a[0],a[1]],to:[s[0],s[1]],arcs:o,source:t}))}this._dragFromCoords=null,this._map.fire("vertex_moved",{id:this._hoveredFeature.id,source:r,layer:this._hoveredFeature.layer,vertexIndex:this._hoverVertexIds[0]??null,vertexIds:this._hoverVertexIds,coords:s}),this._map.render()}}const _i={polygon:"▢",polyline:"╱",point:"●"},fi={polygon:"Draw Polygon",polyline:"Draw Polyline",point:"Draw Point"};class mi{_options;_map=null;_container=null;_btn=null;_active=!1;_vertices=[];_cursorCoord=null;_snapCoord=null;_snapKind=null;_snapThreshold;_onMouseMoveBound;_onClickBound;_onDblClickBound;_onKeyDownBound;_onMoveHandlerBound;constructor(t){this._options=t,this._snapThreshold=t.snapThreshold??10,this._onMouseMoveBound=this._onMouseMove.bind(this),this._onClickBound=this._onClick.bind(this),this._onDblClickBound=this._onDblClick.bind(this),this._onKeyDownBound=this._onKeyDown.bind(this),this._onMoveHandlerBound=this._onMapMove.bind(this)}onAdd(t){this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group",this._btn=document.createElement("button"),this._btn.className="emap-ctrl-draw",this._btn.type="button",this._btn.title=fi[this._options.type];const e=document.createElement("span");e.className="emap-ctrl-icon";const n=this._options.icon??_i[this._options.type];return"string"==typeof n?e.textContent=n:e.appendChild(n),this._btn.replaceChildren(e),this._btn.addEventListener("click",()=>this._toggle()),this._container.appendChild(this._btn),t.on("editmodechange",t=>{this._active&&"draw"!==t.mode&&this._deactivateQuiet()}),this._container}onRemove(){this._deactivate(),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null,this._btn=null}_toggle(){this._active?this._deactivate():this._activate()}_activate(){if(!this._map)return;this._active=!0,this._btn?.classList.add("active"),this._map.setEditMode("draw");const t=this._map.getCanvasContainer();t.classList.add("emap-draw-active"),t.addEventListener("mousemove",this._onMouseMoveBound),t.addEventListener("click",this._onClickBound),t.addEventListener("dblclick",this._onDblClickBound),window.addEventListener("keydown",this._onKeyDownBound),this._map.on("move",this._onMoveHandlerBound)}_deactivate(){this._clearDrawState(),this._deactivateQuiet(),this._map?.setEditMode("none")}_deactivateQuiet(){if(!this._map)return;this._active=!1,this._btn?.classList.remove("active");const t=this._map.getCanvasContainer();t.classList.remove("emap-draw-active"),t.removeEventListener("mousemove",this._onMouseMoveBound),t.removeEventListener("click",this._onClickBound),t.removeEventListener("dblclick",this._onDblClickBound),window.removeEventListener("keydown",this._onKeyDownBound),this._map.off("move",this._onMoveHandlerBound),this._map.clearEditDrawState(),this._map.render()}_clearDrawState(){this._vertices=[],this._cursorCoord=null,this._snapCoord=null,this._snapKind=null}_onMapMove(){this._vertices.length>0&&(this._updateDrawState(),this._map?.render())}_onMouseMove(t){if(!this._map)return;const e=this._map.getCanvasContainer().getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,s=this._map.unproject(n,i);this._cursorCoord=[s[0],s[1]];const r=this._findSnapTarget(n,i);this._snapCoord=r?.coord??null,this._snapKind=r?.kind??null,(this._vertices.length>0||this._snapCoord)&&(this._updateDrawState(),this._map.render())}_onClick(t){if(!this._map)return;const e=this._map.getCanvasContainer().getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,s=this._snapCoord?[this._snapCoord[0],this._snapCoord[1]]:this._map.unproject(n,i);if("point"===this._options.type)return this._vertices=[s],void this._commitFeature();if("polygon"===this._options.type&&this._vertices.length>=3){const t=this._vertices[0],e=this._map.project(t[0],t[1]);if(Math.hypot(e[0]-n,e[1]-i)<=12)return void this._commitFeature()}this._vertices.push(s),this._updateDrawState(),this._map.render()}_onDblClick(t){this._map&&(t.preventDefault(),t.stopPropagation(),"point"!==this._options.type&&("polyline"===this._options.type&&this._vertices.length>=2||"polygon"===this._options.type&&this._vertices.length>=3)&&this._commitFeature())}_onKeyDown(t){"Escape"===t.key&&(this._clearDrawState(),this._map?.clearEditDrawState(),this._map?.render())}_findSnapTarget(t,e){if(!this._map)return null;const n=this._map,i=this._options.snapSources??[this._options.source],s=!1!==this._options.snapToVertex,r=!1!==this._options.snapToEdge;let o=this._snapThreshold,a=null,h=null;for(const l of i){const i=n.getSource(l);if(!i)continue;const c=i.getArcs();if(!c?.getVertexData)continue;const u=c.getVertexData();if(!u)continue;const p=u.xx,d=u.yy;if(s)for(let i=0;i<p.length;i++){const s=n.project(p[i],d[i]),r=Math.hypot(s[0]-t,s[1]-e);r<o&&(o=r,a=[p[i],d[i]],h="vertex")}r&&c.forEachSegment&&c.forEachSegment((i,s,r,l)=>{const c=n.project(r[i],l[i]),u=n.project(r[s],l[s]),p=yi([t,e],c,u);p.dist<o&&(o=p.dist,a=n.unproject(p.point[0],p.point[1]),h="edge")})}if(s)for(const i of this._vertices){const s=n.project(i[0],i[1]),r=Math.hypot(s[0]-t,s[1]-e);r<o&&(o=r,a=[i[0],i[1]],h="vertex")}return a?{coord:a,kind:h}:null}_commitFeature(){if(!this._map||0===this._vertices.length)return;const t=this._map.getSource(this._options.source);if(!t)return;const e=t.getDataset();if(!e)return;const n=this._resolveTargetLayer(e.layers);if(!n)return;const i=e.layers.indexOf(n);let s,r,o;if(n.shapes||(n.shapes=[]),"point"===this._options.type)s=[this._vertices[0]],n.shapes.push(s);else{if(r="polygon"===this._options.type?[...this._vertices,this._vertices[0]]:[...this._vertices],o=e.arcs,!o)return;s=[[this._appendArc(o,r)]],n.shapes.push(s)}let a=null;if(n.data){const t=n.data.getRecords?.();t&&(a={},t.push(a))}t.refreshDisplayArcs(),this._map.pushCommand(new hi({geometryType:this._options.type,layer:n,source:t,appendedShape:s,appendedRecord:a,arcVertices:r,arcs:o}));const h=n.shapes.length-1,l=nt(n,i>=0?i:0);this._map.fire("feature_created",{id:h,source:this._options.source,layer:l,geometryType:this._options.type,properties:{}}),this._clearDrawState(),this._map.clearEditDrawState(),t.fire("data",{reason:"edit"})}_resolveTargetLayer(t){if(!t.length)return null;if(this._options.sourceLayer)for(let e=0;e<t.length;e++){if(nt(t[e],e)===this._options.sourceLayer)return t[e]}const e="polygon"===this._options.type?"polygon":"polyline"===this._options.type?"polyline":"point";for(const n of t)if(n.geometry_type===e)return n;return t[0]}_appendArc(t,e){const n=t.getVertexData(),i=n.xx,s=n.yy,r=n.nn,o=n.zz,a=i.length,h=r.length,l=e.length,c=new Float64Array(a+l),u=new Float64Array(a+l),p=new Int32Array(h+1);c.set(i),u.set(s),p.set(r);for(let t=0;t<l;t++)c[a+t]=e[t][0],u[a+t]=e[t][1];p[h]=l;let d=null;if(o){d=new Float64Array(a+l),d.set(o);for(let t=0;t<l;t++)d[a+t]=1/0}return t.updateVertexData(p,c,u,d),h}_updateDrawState(){this._map&&this._map.setEditDrawState({vertices:[...this._vertices],cursorCoord:this._snapCoord||this._cursorCoord,snapCoord:this._snapCoord,snapKind:this._snapKind,geometryType:this._options.type,drawColor:this._options.drawColor||"#0078ff"})}}function yi(t,e,n){const i=e[0],s=e[1],r=n[0],o=n[1],a=t[0],h=t[1],l=r-i,c=o-s,u=l*l+c*c;if(0===u){const t=a-i,e=h-s;return{point:[i,s],dist:Math.hypot(t,e)}}let p=((a-i)*l+(h-s)*c)/u;p<0?p=0:p>1&&(p=1);const d=i+p*l,_=s+p*c;return{point:[d,_],dist:Math.hypot(a-d,h-_)}}class gi{_container=null;_vertexEditControl;_drawControls=[];_options;constructor(t){this._options=t||{},this._vertexEditControl=new di,this._options.drawSource&&(this._drawControls=[new mi({source:this._options.drawSource,sourceLayer:this._options.drawSourceLayer,type:"polygon"}),new mi({source:this._options.drawSource,sourceLayer:this._options.drawSourceLayer,type:"polyline"}),new mi({source:this._options.drawSource,sourceLayer:this._options.drawSourceLayer,type:"point"})])}onAdd(t){const e=this._vertexEditControl.onAdd(t);this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group emap-edit-toolbar";const n=e.querySelector("button");n&&this._container.appendChild(n);for(const e of this._drawControls){const n=e.onAdd(t).querySelector("button");n&&this._container.appendChild(n)}return this._container}onRemove(){this._vertexEditControl.onRemove();for(const t of this._drawControls)t.onRemove();this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._container=null}}class vi{_map=null;_container=null;_undoBtn=null;_redoBtn=null;_options;_onHistoryChange=null;constructor(t={}){this._options=t}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className=`emap-ctrl emap-ctrl-group ${this._options.className||""}`.trim(),this._undoBtn=this._createButton("undo","↶",this._options.undoTitle??"Undo (Ctrl+Z)",()=>{this._map?.undo()}),this._redoBtn=this._createButton("redo","↷",this._options.redoTitle??"Redo (Ctrl+Shift+Z)",()=>{this._map?.redo()}),this._setEnabled(t.canUndo(),t.canRedo()),this._onHistoryChange=t=>this._setEnabled(t.canUndo,t.canRedo),t.on("historychange",this._onHistoryChange),this._container}onRemove(){this._map&&this._onHistoryChange&&this._map.off("historychange",this._onHistoryChange),this._onHistoryChange=null,this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._container=null,this._undoBtn=null,this._redoBtn=null}_setEnabled(t,e){this._undoBtn&&(this._undoBtn.disabled=!t),this._redoBtn&&(this._redoBtn.disabled=!e)}_createButton(t,e,n,i){const s=document.createElement("button");s.className=`emap-ctrl-${t}`,s.type="button",s.title=n,s.disabled=!0;const r=document.createElement("span");return r.className="emap-ctrl-icon",r.textContent=e,s.appendChild(r),s.addEventListener("click",i),this._container?.appendChild(s),s}}class xi{_options;_dragThreshold;_enabled=!0;_map=null;_container=null;_overlay=null;_canvasContainer=null;_startPx=null;_onMouseDownBound;_onMouseMoveBound;_onMouseUpBound;constructor(t={}){this._options=t,this._dragThreshold=t.dragThreshold??4,this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this)}onAdd(t){this._map=t,this._canvasContainer=t.getCanvasContainer();const e=document.createElement("div");e.className="emap-box-select",e.style.position="absolute",e.style.pointerEvents="none",e.style.display="none",e.style.left="0",e.style.top="0",e.style.width="0",e.style.height="0";const n=this._options.style??{};e.style.border=`${n.strokeWidth??1.5}px solid ${n.stroke??"#0078ff"}`,e.style.background=n.fill??"rgba(0, 120, 255, 0.1)",e.style.boxSizing="border-box",this._canvasContainer.appendChild(e),this._overlay=e,this._canvasContainer.addEventListener("mousedown",this._onMouseDownBound);const i=document.createElement("div");return i.className="emap-ctrl emap-box-select-anchor",i.style.width="0",i.style.height="0",i.style.pointerEvents="none",this._container=i,i}onRemove(){this._canvasContainer&&this._canvasContainer.removeEventListener("mousedown",this._onMouseDownBound),window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound),this._overlay?.parentNode&&this._overlay.parentNode.removeChild(this._overlay),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._canvasContainer=null,this._overlay=null,this._container=null,this._startPx=null}disable(){this._enabled=!1,this._startPx&&this._cancelDrag()}enable(){this._enabled=!0}isEnabled(){return this._enabled}_onMouseDown(t){if(!this._enabled)return;if(!t.shiftKey)return;if(0!==t.button)return;if(!this._canvasContainer||!this._overlay)return;t.preventDefault();const[e,n]=this._eventToContainerPx(t);this._startPx=[e,n],this._overlay.style.left=`${e}px`,this._overlay.style.top=`${n}px`,this._overlay.style.width="0",this._overlay.style.height="0",this._overlay.style.display="block",window.addEventListener("mousemove",this._onMouseMoveBound),window.addEventListener("mouseup",this._onMouseUpBound)}_onMouseMove(t){if(!this._startPx||!this._overlay)return;const[e,n]=this._eventToContainerPx(t),[i,s]=this._startPx,r=Math.min(i,e),o=Math.min(s,n),a=Math.abs(e-i),h=Math.abs(n-s);this._overlay.style.left=`${r}px`,this._overlay.style.top=`${o}px`,this._overlay.style.width=`${a}px`,this._overlay.style.height=`${h}px`}_onMouseUp(t){if(!this._startPx||!this._map||!this._overlay)return void this._cleanupDrag();const[e,n]=this._startPx,[i,s]=this._eventToContainerPx(t),r=i-e,o=s-n,a=Math.hypot(r,o);if(this._overlay.style.display="none",a<this._dragThreshold)return void this._cleanupDrag();const h=Math.min(e,i),l=Math.min(n,s),c=Math.max(e,i),u=Math.max(n,s),p=function(t){const e=new Set,n=[];for(const i of t){const t=`${i.source}|${i.layer}|${i.id}`;e.has(t)||(e.add(t),n.push({source:i.source,layer:i.layer,id:i.id}))}return n}(this._map.queryFeatures([[h,l],[c,u]],this._options.layers?{layers:this._options.layers}:void 0)),d=this._modeFromEvent(t);this._map.select(p,{mode:d}),this._cleanupDrag()}_cancelDrag(){this._overlay&&(this._overlay.style.display="none"),this._cleanupDrag()}_cleanupDrag(){this._startPx=null,window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound)}_eventToContainerPx(t){if(!this._canvasContainer)return[0,0];const e=this._canvasContainer.getBoundingClientRect();return[t.clientX-e.left,t.clientY-e.top]}_modeFromEvent(t){return t.altKey?"toggle":t.ctrlKey||t.metaKey?"add":"replace"}}class wi{_options;_dragThreshold;_enabled=!0;_map=null;_container=null;_svg=null;_polyline=null;_canvasContainer=null;_path=null;_onMouseDownBound;_onMouseMoveBound;_onMouseUpBound;constructor(t={}){this._options=t,this._dragThreshold=t.dragThreshold??4,this._onMouseDownBound=this._onMouseDown.bind(this),this._onMouseMoveBound=this._onMouseMove.bind(this),this._onMouseUpBound=this._onMouseUp.bind(this)}onAdd(t){this._map=t,this._canvasContainer=t.getCanvasContainer();const e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"svg");n.setAttribute("class","emap-lasso-select"),n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",n.style.display="none";const i=document.createElementNS(e,"polyline"),s=this._options.style??{};i.setAttribute("stroke",s.stroke??"#0078ff"),i.setAttribute("stroke-width",String(s.strokeWidth??1.5)),i.setAttribute("fill",s.fill??"rgba(0, 120, 255, 0.1)"),i.setAttribute("stroke-dasharray",s.strokeDasharray??"4 3"),i.setAttribute("points",""),n.appendChild(i),this._canvasContainer.appendChild(n),this._svg=n,this._polyline=i,this._canvasContainer.addEventListener("mousedown",this._onMouseDownBound);const r=document.createElement("div");return r.className="emap-ctrl emap-lasso-select-anchor",r.style.width="0",r.style.height="0",r.style.pointerEvents="none",this._container=r,r}onRemove(){this._canvasContainer&&this._canvasContainer.removeEventListener("mousedown",this._onMouseDownBound),window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound),this._svg?.parentNode&&this._svg.parentNode.removeChild(this._svg),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=null,this._canvasContainer=null,this._svg=null,this._polyline=null,this._container=null,this._path=null}disable(){this._enabled=!1,this._path&&this._cancelDrag()}enable(){this._enabled=!0}isEnabled(){return this._enabled}_onMouseDown(t){if(!this._enabled)return;if(!t.shiftKey)return;if(0!==t.button)return;if(!this._canvasContainer||!this._svg||!this._polyline)return;t.preventDefault();const e=this._eventToContainerPx(t);this._path=[e],this._polyline.setAttribute("points",`${e[0]},${e[1]}`),this._svg.style.display="block",window.addEventListener("mousemove",this._onMouseMoveBound),window.addEventListener("mouseup",this._onMouseUpBound)}_onMouseMove(t){if(!this._path||!this._polyline)return;const e=this._eventToContainerPx(t);this._path.push(e),this._polyline.setAttribute("points",this._path.map(t=>`${t[0]},${t[1]}`).join(" "))}_onMouseUp(t){const e=this._path;if(!e||!this._map||!this._svg)return void this._cleanupDrag();if(this._svg.style.display="none",e.length<3)return void this._cleanupDrag();const n=function(t){let e=1/0,n=1/0,i=-1/0,s=-1/0;for(const[r,o]of t)r<e&&(e=r),o<n&&(n=o),r>i&&(i=r),o>s&&(s=o);return[e,n,i,s]}(e),i=n[2]-n[0],s=n[3]-n[1];if(Math.hypot(i,s)<this._dragThreshold)return void this._cleanupDrag();const r=e.slice();r.push(e[0]);const o=this._map.queryFeatures([[n[0],n[1]],[n[2],n[3]]],this._options.layers?{layers:this._options.layers}:void 0),a=[],h=new Set,l=!1!==this._options.includeIntersecting;for(const t of o){const e=`${t.source}|${t.layer}|${t.id}`;h.has(e)||Ci(this._map,t,r,l)&&(h.add(e),a.push({source:t.source,layer:t.layer,id:t.id}))}const c=function(t){return t.altKey?"toggle":t.ctrlKey||t.metaKey?"add":"replace"}(t);this._map.select(a,{mode:c}),this._cleanupDrag()}_cancelDrag(){this._svg&&(this._svg.style.display="none"),this._cleanupDrag()}_cleanupDrag(){this._path=null,window.removeEventListener("mousemove",this._onMouseMoveBound),window.removeEventListener("mouseup",this._onMouseUpBound)}_eventToContainerPx(t){if(!this._canvasContainer)return[0,0];const e=this._canvasContainer.getBoundingClientRect();return[t.clientX-e.left,t.clientY-e.top]}}function bi(t,e){const[n,i]=t;let s=!1;const r=e.length;for(let t=0,o=r-1;t<r;o=t++){const[r,a]=e[t],[h,l]=e[o];a>i!=l>i&&n<(h-r)*(i-a)/(l-a)+r&&(s=!s)}return s}function Ci(t,e,n,i){const s=function(t,e){const n=t.getSource(e.source);if(!n)return null;let i=t.layers?.resolve(e.source,e.layer);if(!i){const t=n.getDataset?.();i=t?.layers.find((t,n)=>nt(t,n)===e.layer||t?.name===e.layer||t?.id===e.layer)}if(!i?.shapes)return null;const s=i.shapes?.[e.id];return s?{layer:i,shape:s,arcs:n.getArcs?.()}:null}(t,e);if(!s)return!1;if("point"===s.layer.geometry_type){const e=it(s.shape);if(0===e.length)return!1;const r=e.map(([e,n])=>t.project(e,n));return i?r.some(t=>Ai(t,n)):r.every(t=>Ai(t,n))}if(!s.arcs)return!1;const r=function(t,e,n){const i=[];for(const s of e){const e=[],r=n.getShapeIter?.(s);if(r)for(;r.hasNext();)e.push(t.project(r.x,r.y));else for(const i of s){const s=i>=0?i:~i,r=n.getArcIter(s);for(;r.hasNext();)e.push(t.project(r.x,r.y))}e.length>0&&i.push(e)}return i}(t,s.shape,s.arcs);if(0===r.length)return!1;const o="polygon"===s.layer.geometry_type;return i?function(t,e,n){for(const i of t){if(i.some(t=>Ai(t,e)))return!0;if(Si(i,e,n))return!0}return!(!n||!e.some(e=>function(t,e){let n=!1;for(const i of e){if(Mi(t,i))return!0;bi(t,i)&&(n=!n)}return n}(e,t)))}(r,n,o):function(t,e,n){for(const i of t){if(!i.every(t=>Ai(t,e)))return!1;if(Si(i,e,n))return!1}return!0}(r,n,o)}function Si(t,e,n){const i=n?Ei(t):t,s=Ei(e);for(let t=0;t<i.length-1;t++){const e=i[t],n=i[t+1];for(let t=0;t<s.length-1;t++){if(ki(e,n,s[t],s[t+1]))return!0}}return!1}function Ai(t,e){return Mi(t,e)||bi(t,e)}function Mi(t,e){const n=Ei(e);for(let e=0;e<n.length-1;e++)if(Di(t,n[e],n[e+1]))return!0;return!1}function Ei(t){if(t.length<2)return t;const e=t[0],n=t[t.length-1];return i=e,s=n,Math.abs(i[0]-s[0])<=Ti&&Math.abs(i[1]-s[1])<=Ti?t:[...t,e];var i,s}function ki(t,e,n,i){const s=Ii(t,e,n),r=Ii(t,e,i),o=Ii(n,i,t),a=Ii(n,i,e);return!(!Pi(s)||!Di(n,t,e))||(!(!Pi(r)||!Di(i,t,e))||(!(!Pi(o)||!Di(t,n,i))||(!(!Pi(a)||!Di(e,n,i))||s>0!=r>0&&o>0!=a>0)))}function Di(t,e,n){return!!Pi(Ii(e,n,t))&&(t[0]>=Math.min(e[0],n[0])-Ti&&t[0]<=Math.max(e[0],n[0])+Ti&&t[1]>=Math.min(e[1],n[1])-Ti&&t[1]<=Math.max(e[1],n[1])+Ti)}function Ii(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Pi(t){return Math.abs(t)<=Ti}const Ti=1e-9;const Li=[{value:"",label:"weighted (default)"},{value:"weighted",label:"weighted"},{value:"visvalingam",label:"visvalingam"},{value:"dp",label:"dp (Douglas–Peucker)"}];class Ni{_opts;_map=null;_container=null;_btn=null;_popup=null;_percentageInput=null;_percentageLabel=null;_methodSel=null;_keepShapes=null;_planar=null;_applyBtn=null;_statusEl=null;_onDocClick=null;_onDocKey=null;constructor(t){this._opts=t}onAdd(t){return this._map=t,this._container=document.createElement("div"),this._container.className="emap-ctrl emap-ctrl-group emap-ctrl-simplify-wrap",this._btn=document.createElement("button"),this._btn.type="button",this._btn.className="emap-ctrl-simplify",this._btn.innerHTML='<span class="emap-ctrl-icon">≈</span>',this._btn.title=this._opts.title??"Simplify geometry",this._btn.onclick=t=>{t.stopPropagation(),this._togglePopup()},this._container.appendChild(this._btn),this._popup=this._buildPopup(),this._container.appendChild(this._popup),this._container}onRemove(){this._teardownDocListeners(),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._container=null,this._btn=null,this._popup=null,this._percentageInput=null,this._percentageLabel=null,this._methodSel=null,this._keepShapes=null,this._planar=null,this._applyBtn=null,this._statusEl=null,this._map=null}_buildPopup(){const t=document.createElement("div");t.className="emap-simplify-popup",t.style.display="none",t.style.cssText+="\n position:absolute; top:36px; left:0; min-width:240px; padding:10px;\n background:#fff; border:1px solid #ccc; border-radius:4px;\n box-shadow:0 2px 8px rgba(0,0,0,.15); font-size:13px;\n z-index:10; color:#222;",t.onclick=t=>t.stopPropagation();const e=this._opts.initialPercentage??10,n=this._opts.initialMethod??"";return t.innerHTML=`\n <div style="margin-bottom:8px;">\n <label style="display:flex; align-items:center; gap:6px;">\n <span>Percentage:</span>\n <input type="range" min="0" max="100" step="0.1" value="${e}" style="flex:1;" />\n <span class="value" style="min-width:48px; text-align:right;">${e}%</span>\n </label>\n </div>\n <div style="margin-bottom:8px;">\n <label style="display:flex; align-items:center; gap:6px;">\n <span>Method:</span>\n <select style="flex:1;">\n ${Li.map(t=>`<option value="${t.value}"${t.value===n?" selected":""}>${t.label}</option>`).join("")}\n </select>\n </label>\n </div>\n <div style="margin-bottom:8px; display:flex; gap:12px; flex-wrap:wrap;">\n <label><input type="checkbox" data-flag="keep-shapes" checked /> keep-shapes</label>\n <label><input type="checkbox" data-flag="planar" /> planar</label>\n </div>\n <div style="display:flex; gap:6px; align-items:center;">\n <button type="button" class="apply" style="padding:4px 12px;">Apply</button>\n <span class="status" style="opacity:.8; font-size:12px;"></span>\n </div>\n `,this._percentageInput=t.querySelector("input[type=range]"),this._percentageLabel=t.querySelector(".value"),this._methodSel=t.querySelector("select"),this._keepShapes=t.querySelector("input[data-flag=keep-shapes]"),this._planar=t.querySelector("input[data-flag=planar]"),this._applyBtn=t.querySelector("button.apply"),this._statusEl=t.querySelector(".status"),this._percentageInput.oninput=()=>{this._percentageLabel&&this._percentageInput&&(this._percentageLabel.textContent=`${this._percentageInput.value}%`)},this._applyBtn.onclick=()=>this._apply(),t}_togglePopup(){if(!this._popup)return;const t="none"===this._popup.style.display;this._popup.style.display=t?"block":"none",this._btn?.classList.toggle("active",t),t?(this._setupDocListeners(),this._setStatus("")):this._teardownDocListeners()}_setupDocListeners(){this._onDocClick=t=>{this._container&&!this._container.contains(t.target)&&this._togglePopup()},this._onDocKey=t=>{"Escape"===t.key&&this._togglePopup()},document.addEventListener("mousedown",this._onDocClick),document.addEventListener("keydown",this._onDocKey)}_teardownDocListeners(){this._onDocClick&&document.removeEventListener("mousedown",this._onDocClick),this._onDocKey&&document.removeEventListener("keydown",this._onDocKey),this._onDocClick=null,this._onDocKey=null}_setStatus(t){this._statusEl&&(this._statusEl.textContent=t)}async _apply(){if(!this._map||!this._percentageInput||!this._methodSel)return;const t=Number(this._percentageInput.value),e=this._methodSel.value,n={source:this._opts.source,percentage:t};this._opts.target&&(n.target=this._opts.target),e&&(n.method=e),this._keepShapes?.checked&&(n.keepShapes=!0),this._planar?.checked&&(n.planar=!0),this._applyBtn&&(this._applyBtn.disabled=!0),this._setStatus("Running…");try{const e=await this._map.ops.simplifyLayer(n);if(e?.ok)this._setStatus(`Simplified at ${t}%`);else{const t=e?.error,n=t?`${t.kind}${t.field?" field="+t.field:""}`:"unknown";this._setStatus(`Failed: ${n}`)}}catch(t){this._setStatus(`Error: ${t?.message??t}`)}finally{this._applyBtn&&(this._applyBtn.disabled=!1)}}}export{$ as AffineTransform,pi as BasemapControl,V as Bounds,xi as BoxSelectControl,Kn as BulkFeatureDeleteCommand,st as CanvasPainter,Lt as CompositeCommand,Sn as DEFAULT_CRS,ot as DatasetReplaceCommand,Z as DefaultMapshaperAdapter,Nn as DragPanHandler,mi as DrawFeatureControl,Vn as EditHistory,rt as EditOverlayRenderer,gi as EditToolbar,Jn as Emap,lt as Err,j as EventDispatcher,Gn as FeatureAccessor,Ot as FeatureAffineCommand,hi as FeatureCreateCommand,Wn as FeatureDeleteCommand,Xt as FeaturePropertyChangeCommand,Fn as FeatureQuery,Gt as FeatureTranslateCommand,Jt as FieldAddCommand,Yt as FieldRemoveCommand,Qt as FieldRenameCommand,Bn as HighlightManager,vi as HistoryControl,qt as IDENTITY_MATRIX,wi as LassoSelectControl,Rn as MapshaperWorkerPool,li as NavigationControl,at as OK,et as Projection,zn as Selection,Ni as SimplifyControl,$t as SplitSharedArcsCommand,ci as StatusControl,Pn as TopologySource,Hn as Transaction,$ as Transform,On as ValidatorRegistry,ai as VertexDeleteCommand,di as VertexEditControl,oi as VertexInsertCommand,ri as VertexMoveCommand,X as Viewport,Ft as bumpEditVersion,Ut as composeMatrix,Ci as featureMatchesLasso,ii as findInvalidFieldName,Y as getDefaultMapshaperAdapter,En as inferFromPrj,jt as invertMatrix,Nt as isPathLayer,Rt as isPointLayer,ni as isValidFieldName,ei as isValidLayerName,Mn as normalizeCrsString,ht as okValue,Vt as planSharedArcSplit,bi as pointInPolygon,Yn as quoteCliArg,An as resolveDatasetCRS,Zn as resolvePointStyle,Xn as resolveStrokeStyle,Bt as rotateMatrix,zt as scaleMatrix,Q as setDefaultMapshaperAdapter,si as topologyValidator};
|