mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
820 lines
1.0 MiB
820 lines
1.0 MiB
var I_=Object.defineProperty,mn=(xt,at)=>I_(xt,"name",{value:at,configurable:!0});function Ki(xt,at){let Et="script";return xt==="name"?Et="script":xt==="name2"?Et="script2":xt==="name3"&&(Et="script3"),[["coalesce",["get",`pgf:${xt}`],["get",xt]],{"text-font":["case",["==",["get",Et],"Devanagari"],["literal",["Noto Sans Devanagari Regular v1"]],["literal",[at||"Noto Sans Regular"]]]}]}mn(Ki,"get_name_block");function fn(xt,at,Et){let At="name";return Et==="name"?At="":Et==="name2"?At="2":Et==="name3"&&(At="3"),at==="Latin"?["has",`script${At}`]:xt==="ja"?["all",["!=",["get",`script${At}`],"Han"],["!=",["get",`script${At}`],"Hiragana"],["!=",["get",`script${At}`],"Katakana"],["!=",["get",`script${At}`],"Mixed-Japanese"]]:["!=",["get",`script${At}`],at]}mn(fn,"is_not_in_target_script");function Gr(xt){return xt==="Devanagari"?{"text-font":["literal",["Noto Sans Devanagari Regular v1"]]}:{}}mn(Gr,"get_font_formatting");function id(xt){let at=E_.find(Et=>Et.lang===xt);return at===void 0?"Latin":at.script}mn(id,"get_default_script");function lf(xt,at){let Et=at||id(xt),At;return Et==="Devanagari"?At="pgf:":At="",["format",["coalesce",["get",`${At}name:${xt}`],["get","name:en"]],Gr(Et)]}mn(lf,"get_country_name");function Ur(xt,at,Et){let At=at||id(xt),se;return At==="Devanagari"?se="pgf:":se="",["case",["all",["any",["has","name"],["has","pgf:name"]],["!",["any",["has","name2"],["has","pgf:name2"]]],["!",["any",["has","name3"],["has","pgf:name3"]]]],["case",fn(xt,At,"name"),["case",["any",["is-supported-script",["get","name"]],["has","pgf:name"]],["format",["coalesce",["get",`${se}name:${xt}`],["get","name:en"]],Gr(At),`
|
||
`,{},["case",["all",["!",["has",`${se}name:${xt}`]],["has","name:en"],["!",["has","script"]]],"",["coalesce",["get","pgf:name"],["get","name"]]],{"text-font":["case",["==",["get","script"],"Devanagari"],["literal",["Noto Sans Devanagari Regular v1"]],["literal",[Et||"Noto Sans Regular"]]]}],["get","name:en"]],["format",["coalesce",["get",`${se}name:${xt}`],["get","pgf:name"],["get","name"]],Gr(At)]],["all",["any",["has","name"],["has","pgf:name"]],["any",["has","name2"],["has","pgf:name2"]],["!",["any",["has","name3"],["has","pgf:name3"]]]],["case",["all",fn(xt,At,"name"),fn(xt,At,"name2")],["format",["get",`${se}name:${xt}`],Gr(At),`
|
||
`,{},...Ki("name",Et),`
|
||
`,{},...Ki("name2",Et)],["case",fn(xt,At,"name2"),["format",["coalesce",["get",`${se}name:${xt}`],["get","pgf:name"],["get","name"]],Gr(At),`
|
||
`,{},...Ki("name2",Et)],["format",["coalesce",["get",`${se}name:${xt}`],["get","pgf:name2"],["get","name2"]],Gr(At),`
|
||
`,{},...Ki("name",Et)]]],["case",["all",fn(xt,At,"name"),fn(xt,At,"name2"),fn(xt,At,"name3")],["format",["get",`${se}name:${xt}`],Gr(At),`
|
||
`,{},...Ki("name",Et),`
|
||
`,{},...Ki("name2",Et),`
|
||
`,{},...Ki("name3",Et)],["case",["!",fn(xt,At,"name")],["format",["coalesce",["get",`${se}name:${xt}`],["get","pgf:name"],["get","name"]],Gr(At),`
|
||
`,{},...Ki("name2",Et),`
|
||
`,{},...Ki("name3",Et)],["!",fn(xt,At,"name2")],["format",["coalesce",["get",`${se}name:${xt}`],["get","pgf:name2"],["get","name2"]],Gr(At),`
|
||
`,{},...Ki("name",Et),`
|
||
`,{},...Ki("name3",Et)],["format",["coalesce",["get",`${se}name:${xt}`],["get","pgf:name3"],["get","name3"]],Gr(At),`
|
||
`,{},...Ki("name",Et),`
|
||
`,{},...Ki("name2",Et)]]]]}mn(Ur,"get_multiline_name");var E_=[{lang:"ar",full_name:"Arabic",script:"Arabic"},{lang:"cs",full_name:"Czech",script:"Latin"},{lang:"bg",full_name:"Bulgarian",script:"Cyrillic"},{lang:"da",full_name:"Danish",script:"Latin"},{lang:"de",full_name:"German",script:"Latin"},{lang:"el",full_name:"Greek",script:"Greek"},{lang:"en",full_name:"English",script:"Latin"},{lang:"es",full_name:"Spanish",script:"Latin"},{lang:"et",full_name:"Estonian",script:"Latin"},{lang:"fa",full_name:"Persian",script:"Arabic"},{lang:"fi",full_name:"Finnish",script:"Latin"},{lang:"fr",full_name:"French",script:"Latin"},{lang:"ga",full_name:"Irish",script:"Latin"},{lang:"he",full_name:"Hebrew",script:"Hebrew"},{lang:"hi",full_name:"Hindi",script:"Devanagari"},{lang:"hr",full_name:"Croatian",script:"Latin"},{lang:"hu",full_name:"Hungarian",script:"Latin"},{lang:"id",full_name:"Indonesian",script:"Latin"},{lang:"it",full_name:"Italian",script:"Latin"},{lang:"ja",full_name:"Japanese",script:""},{lang:"ko",full_name:"Korean",script:"Hangul"},{lang:"lt",full_name:"Lithuanian",script:"Latin"},{lang:"lv",full_name:"Latvian",script:"Latin"},{lang:"ne",full_name:"Nepali",script:"Devanagari"},{lang:"nl",full_name:"Dutch",script:"Latin"},{lang:"no",full_name:"Norwegian",script:"Latin"},{lang:"mr",full_name:"Marathi",script:"Devanagari"},{lang:"mt",full_name:"Maltese",script:"Latin"},{lang:"pl",full_name:"Polish",script:"Latin"},{lang:"pt",full_name:"Portuguese",script:"Latin"},{lang:"ro",full_name:"Romanian",script:"Latin"},{lang:"ru",full_name:"Russian",script:"Cyrillic"},{lang:"sk",full_name:"Slovak",script:"Latin"},{lang:"sl",full_name:"Slovenian",script:"Latin"},{lang:"sv",full_name:"Swedish",script:"Latin"},{lang:"tr",full_name:"Turkish",script:"Latin"},{lang:"uk",full_name:"Ukrainian",script:"Cyrillic"},{lang:"ur",full_name:"Urdu",script:"Arabic"},{lang:"vi",full_name:"Vietnamese",script:"Latin"},{lang:"zh-Hans",full_name:"Chinese (Simplified)",script:"Han"},{lang:"zh-Hant",full_name:"Chinese (Traditional)",script:"Han"}];function cf(xt,at){return[{id:"background",type:"background",paint:{"background-color":at.background}},{id:"earth",type:"fill",filter:["==","$type","Polygon"],source:xt,"source-layer":"earth",paint:{"fill-color":at.earth}},...at.landcover?[{id:"landcover",type:"fill",source:xt,"source-layer":"landcover",paint:{"fill-color":["match",["get","kind"],"grassland",at.landcover.grassland,"barren",at.landcover.barren,"urban_area",at.landcover.urban_area,"farmland",at.landcover.farmland,"glacier",at.landcover.glacier,"scrub",at.landcover.scrub,at.landcover.forest],"fill-opacity":["interpolate",["linear"],["zoom"],5,1,7,0]}}]:[],{id:"landuse_park",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course","wood","nature_reserve","forest","scrub","grassland","grass","military","naval_base","airfield"],paint:{"fill-opacity":["interpolate",["linear"],["zoom"],6,0,11,1],"fill-color":["case",["in",["get","kind"],["literal",["national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course"]]],at.park_b,["in",["get","kind"],["literal",["wood","nature_reserve","forest"]]],at.wood_b,["in",["get","kind"],["literal",["scrub","grassland","grass"]]],at.scrub_b,["in",["get","kind"],["literal",["glacier"]]],at.glacier,["in",["get","kind"],["literal",["sand"]]],at.sand,["in",["get","kind"],["literal",["military","naval_base","airfield"]]],at.zoo,at.earth]}},{id:"landuse_urban_green",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","allotments","village_green","playground"],paint:{"fill-color":at.park_b,"fill-opacity":.7}},{id:"landuse_hospital",type:"fill",source:xt,"source-layer":"landuse",filter:["==","kind","hospital"],paint:{"fill-color":at.hospital}},{id:"landuse_industrial",type:"fill",source:xt,"source-layer":"landuse",filter:["==","kind","industrial"],paint:{"fill-color":at.industrial}},{id:"landuse_school",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","school","university","college"],paint:{"fill-color":at.school}},{id:"landuse_beach",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","beach"],paint:{"fill-color":at.beach}},{id:"landuse_zoo",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","zoo"],paint:{"fill-color":at.zoo}},{id:"landuse_aerodrome",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","aerodrome"],paint:{"fill-color":at.aerodrome}},{id:"roads_runway",type:"line",source:xt,"source-layer":"roads",filter:["==","kind_detail","runway"],paint:{"line-color":at.runway,"line-width":["interpolate",["exponential",1.6],["zoom"],10,0,12,4,18,30]}},{id:"roads_taxiway",type:"line",source:xt,"source-layer":"roads",minzoom:13,filter:["==","kind_detail","taxiway"],paint:{"line-color":at.runway,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,15,6]}},{id:"landuse_runway",type:"fill",source:xt,"source-layer":"landuse",filter:["any",["in","kind","runway","taxiway"]],paint:{"fill-color":at.runway}},{id:"water",type:"fill",filter:["==","$type","Polygon"],source:xt,"source-layer":"water",paint:{"fill-color":at.water}},{id:"water_stream",type:"line",source:xt,"source-layer":"water",minzoom:14,filter:["in","kind","stream"],paint:{"line-color":at.water,"line-width":.5}},{id:"water_river",type:"line",source:xt,"source-layer":"water",minzoom:9,filter:["in","kind","river"],paint:{"line-color":at.water,"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1,18,12]}},{id:"landuse_pedestrian",type:"fill",source:xt,"source-layer":"landuse",filter:["in","kind","pedestrian","dam"],paint:{"fill-color":at.pedestrian}},{id:"landuse_pier",type:"fill",source:xt,"source-layer":"landuse",filter:["==","kind","pier"],paint:{"fill-color":at.pier}},{id:"roads_tunnels_other_casing",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["in","kind","other","path"]],paint:{"line-color":at.tunnel_other_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_tunnels_minor_casing",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","minor_road"]],paint:{"line-color":at.tunnel_minor_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_tunnels_link_casing",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["has","is_link"]],paint:{"line-color":at.tunnel_link_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_tunnels_major_casing",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":at.tunnel_major_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_tunnels_highway_casing",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":at.tunnel_highway_casing,"line-dasharray":[6,.5],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_tunnels_other",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["in","kind","other","path"]],paint:{"line-color":at.tunnel_other,"line-dasharray":[4.5,.5],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_tunnels_minor",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","minor_road"]],paint:{"line-color":at.tunnel_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_tunnels_link",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["has","is_link"]],paint:{"line-color":at.tunnel_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_tunnels_major",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","major_road"]],paint:{"line-color":at.tunnel_major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_tunnels_highway",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==",["get","kind"],"highway"],["!",["has","is_link"]]],paint:{"line-color":at.tunnel_highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}},{id:"buildings",type:"fill",source:xt,"source-layer":"buildings",filter:["in","kind","building","building_part"],paint:{"fill-color":at.buildings,"fill-opacity":.5}},{id:"roads_pier",type:"line",source:xt,"source-layer":"roads",filter:["==","kind_detail","pier"],paint:{"line-color":at.pier,"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,.5,20,16]}},{id:"roads_minor_service_casing",type:"line",source:xt,"source-layer":"roads",minzoom:13,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["==","kind_detail","service"]],paint:{"line-color":at.minor_service_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,18,8],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,.8]}},{id:"roads_minor_casing",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["!=","kind_detail","service"]],paint:{"line-color":at.minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_link_casing",type:"line",source:xt,"source-layer":"roads",minzoom:13,filter:["has","is_link"],paint:{"line-color":at.minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1.5]}},{id:"roads_major_casing_late",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":at.major_casing_late,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_highway_casing_late",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":at.highway_casing_late,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_other",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["in","kind","other","path"],["!=","kind_detail","pier"]],paint:{"line-color":at.other,"line-dasharray":[3,1],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_link",type:"line",source:xt,"source-layer":"roads",filter:["has","is_link"],paint:{"line-color":at.link,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_minor_service",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["==","kind_detail","service"]],paint:{"line-color":at.minor_service,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,18,8]}},{id:"roads_minor",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["!=","kind_detail","service"]],paint:{"line-color":["interpolate",["exponential",1.6],["zoom"],11,at.minor_a,16,at.minor_b],"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_major_casing_early",type:"line",source:xt,"source-layer":"roads",maxzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":at.major_casing_early,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_major",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":at.major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_highway_casing_early",type:"line",source:xt,"source-layer":"roads",maxzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":at.highway_casing_early,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1]}},{id:"roads_highway",type:"line",source:xt,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":at.highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}},{id:"roads_rail",type:"line",source:xt,"source-layer":"roads",filter:["==","kind","rail"],paint:{"line-dasharray":[.3,.75],"line-opacity":.5,"line-color":at.railway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,.15,18,9]}},{id:"boundaries_country",type:"line",source:xt,"source-layer":"boundaries",filter:["<=","kind_detail",2],paint:{"line-color":at.boundaries,"line-width":.7,"line-dasharray":["step",["zoom"],["literal",[2]],4,["literal",[2,1]]]}},{id:"boundaries",type:"line",source:xt,"source-layer":"boundaries",filter:[">","kind_detail",2],paint:{"line-color":at.boundaries,"line-width":.4,"line-dasharray":["step",["zoom"],["literal",[2]],4,["literal",[2,1]]]}},{id:"roads_bridges_other_casing",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["in","kind","other","path"]],paint:{"line-color":at.bridges_other_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_bridges_link_casing",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["has","is_link"]],paint:{"line-color":at.bridges_minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1.5]}},{id:"roads_bridges_minor_casing",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","minor_road"]],paint:{"line-color":at.bridges_minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,.8]}},{id:"roads_bridges_major_casing",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":at.bridges_major_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,10],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1.5]}},{id:"roads_bridges_other",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["in","kind","other","path"]],paint:{"line-color":at.bridges_other,"line-dasharray":[2,1],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_bridges_minor",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","minor_road"]],paint:{"line-color":at.bridges_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_bridges_link",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["has","is_link"]],paint:{"line-color":at.bridges_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_bridges_major",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":at.bridges_major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_bridges_highway_casing",type:"line",source:xt,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":at.bridges_highway_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_bridges_highway",type:"line",source:xt,"source-layer":"roads",filter:["all",["has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":at.bridges_highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}}]}mn(cf,"nolabels_layers");function uf(xt,at,Et,At){return[{id:"address_label",type:"symbol",source:xt,"source-layer":"buildings",minzoom:18,filter:["==","kind","address"],layout:{"symbol-placement":"point","text-font":[at.italic||"Noto Sans Italic"],"text-field":["get","addr_housenumber"],"text-size":12},paint:{"text-color":at.address_label,"text-halo-color":at.address_label_halo,"text-halo-width":1}},{id:"water_waterway_label",type:"symbol",source:xt,"source-layer":"water",minzoom:13,filter:["in","kind","river","stream"],layout:{"symbol-placement":"line","text-font":[at.italic||"Noto Sans Italic"],"text-field":Ur(Et,At,at.regular),"text-size":12,"text-letter-spacing":.2},paint:{"text-color":at.ocean_label,"text-halo-color":at.water,"text-halo-width":1}},{id:"roads_labels_minor",type:"symbol",source:xt,"source-layer":"roads",minzoom:15,filter:["in","kind","minor_road","other","path"],layout:{"symbol-sort-key":["get","min_zoom"],"symbol-placement":"line","text-font":[at.regular||"Noto Sans Regular"],"text-field":Ur(Et,At,at.regular),"text-size":12},paint:{"text-color":at.roads_label_minor,"text-halo-color":at.roads_label_minor_halo,"text-halo-width":1}},{id:"water_label_ocean",type:"symbol",source:xt,"source-layer":"water",filter:["in","kind","sea","ocean","bay","strait","fjord"],layout:{"text-font":[at.italic||"Noto Sans Italic"],"text-field":Ur(Et,At,at.regular),"text-size":["interpolate",["linear"],["zoom"],3,10,10,12],"text-letter-spacing":.1,"text-max-width":9,"text-transform":"uppercase"},paint:{"text-color":at.ocean_label,"text-halo-width":1,"text-halo-color":at.water}},{id:"earth_label_islands",type:"symbol",source:xt,"source-layer":"earth",filter:["in","kind","island"],layout:{"text-font":[at.italic||"Noto Sans Italic"],"text-field":Ur(Et,At,at.regular),"text-size":10,"text-letter-spacing":.1,"text-max-width":8},paint:{"text-color":at.subplace_label,"text-halo-color":at.subplace_label_halo,"text-halo-width":1}},{id:"water_label_lakes",type:"symbol",source:xt,"source-layer":"water",filter:["in","kind","lake","water"],layout:{"text-font":[at.italic||"Noto Sans Italic"],"text-field":Ur(Et,At,at.regular),"text-size":["interpolate",["linear"],["zoom"],3,10,6,12,10,12],"text-letter-spacing":.1,"text-max-width":9},paint:{"text-color":at.ocean_label,"text-halo-color":at.water,"text-halo-width":1}},{id:"roads_labels_major",type:"symbol",source:xt,"source-layer":"roads",minzoom:11,filter:["in","kind","highway","major_road"],layout:{"symbol-sort-key":["get","min_zoom"],"symbol-placement":"line","text-font":[at.regular||"Noto Sans Regular"],"text-field":Ur(Et,At,at.regular),"text-size":12},paint:{"text-color":at.roads_label_major,"text-halo-color":at.roads_label_major_halo,"text-halo-width":1}},...at.pois?[{id:"pois",type:"symbol",source:xt,"source-layer":"pois",filter:["all",["in",["get","kind"],["literal",["beach","forest","marina","park","peak","zoo","garden","bench","aerodrome","station","bus_stop","ferry_terminal","stadium","university","library","school","animal","toilets","drinking_water"]]],[">=",["zoom"],["+",["get","min_zoom"],0]]],layout:{"icon-image":["match",["get","kind"],"station","train_station",["get","kind"]],"text-font":[at.regular||"Noto Sans Regular"],"text-justify":"auto","text-field":Ur(Et,At,at.regular),"text-size":["interpolate",["linear"],["zoom"],17,10,19,16],"text-max-width":8,"text-offset":[1.1,0],"text-variable-anchor":["left","right"]},paint:{"text-color":["case",["in",["get","kind"],["literal",["beach","forest","marina","park","peak","zoo","garden","bench"]]],at.pois.green,["in",["get","kind"],["literal",["aerodrome","station","bus_stop","ferry_terminal"]]],at.pois.lapis,["in",["get","kind"],["literal",["stadium","university","library","school","animal","toilets","drinking_water"]]],at.pois.slategray,at.earth],"text-halo-color":at.earth,"text-halo-width":1}}]:[],{id:"places_subplace",type:"symbol",source:xt,"source-layer":"places",filter:["==","kind","neighbourhood"],layout:{"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-field":Ur(Et,At,at.regular),"text-font":[at.regular||"Noto Sans Regular"],"text-max-width":7,"text-letter-spacing":.1,"text-padding":["interpolate",["linear"],["zoom"],5,2,8,4,12,18,15,20],"text-size":["interpolate",["exponential",1.2],["zoom"],11,8,14,14,18,24],"text-transform":"uppercase"},paint:{"text-color":at.subplace_label,"text-halo-color":at.subplace_label_halo,"text-halo-width":1}},{id:"places_region",type:"symbol",source:xt,"source-layer":"places",filter:["==","kind","region"],layout:{"symbol-sort-key":["get","sort_key"],"text-field":["step",["zoom"],["coalesce",["get","ref:en"],["get","ref"]],6,Ur(Et,At,at.regular)],"text-font":[at.regular||"Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],3,11,7,16],"text-radial-offset":.2,"text-anchor":"center","text-transform":"uppercase"},paint:{"text-color":at.state_label,"text-halo-color":at.state_label_halo,"text-halo-width":1}},{id:"places_locality",type:"symbol",source:xt,"source-layer":"places",filter:["==","kind","locality"],layout:{"icon-image":["step",["zoom"],"townspot",8,""],"icon-size":.7,"text-field":Ur(Et,At,at.regular),"text-font":["case",["<=",["get","min_zoom"],5],["literal",[at.bold||"Noto Sans Medium"]],["literal",[at.regular||"Noto Sans Regular"]]],"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-padding":["interpolate",["linear"],["zoom"],5,3,8,7,12,11],"text-size":["interpolate",["linear"],["zoom"],2,["case",["<",["get","population_rank"],13],8,[">=",["get","population_rank"],13],13,0],4,["case",["<",["get","population_rank"],13],10,[">=",["get","population_rank"],13],15,0],6,["case",["<",["get","population_rank"],12],11,[">=",["get","population_rank"],12],17,0],8,["case",["<",["get","population_rank"],11],11,[">=",["get","population_rank"],11],18,0],10,["case",["<",["get","population_rank"],9],12,[">=",["get","population_rank"],9],20,0],15,["case",["<",["get","population_rank"],8],12,[">=",["get","population_rank"],8],22,0]],"icon-padding":["interpolate",["linear"],["zoom"],0,0,8,4,10,8,12,6,22,2],"text-justify":"auto","text-anchor":["step",["zoom"],"left",8,"center"],"text-radial-offset":.4},paint:{"text-color":at.city_label,"text-halo-color":at.city_label_halo,"text-halo-width":1}},{id:"places_country",type:"symbol",source:xt,"source-layer":"places",filter:["==","kind","country"],layout:{"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-field":lf(Et,At),"text-font":[at.bold||"Noto Sans Medium"],"text-size":["interpolate",["linear"],["zoom"],2,["case",["<",["get","population_rank"],10],8,[">=",["get","population_rank"],10],12,0],6,["case",["<",["get","population_rank"],8],10,[">=",["get","population_rank"],8],18,0],8,["case",["<",["get","population_rank"],7],11,[">=",["get","population_rank"],7],20,0]],"icon-padding":["interpolate",["linear"],["zoom"],0,2,14,2,16,20,17,2,22,2],"text-transform":"uppercase"},paint:{"text-color":at.country_label,"text-halo-color":at.earth,"text-halo-width":1}}]}mn(uf,"labels_layers");var C_={background:"#cccccc",earth:"#e2dfda",park_a:"#cfddd5",park_b:"#9cd3b4",hospital:"#e4dad9",industrial:"#d1dde1",school:"#e4ded7",wood_a:"#d0ded0",wood_b:"#a0d9a0",pedestrian:"#e3e0d4",scrub_a:"#cedcd7",scrub_b:"#99d2bb",glacier:"#e7e7e7",sand:"#e2e0d7",beach:"#e8e4d0",aerodrome:"#dadbdf",runway:"#e9e9ed",water:"#80deea",zoo:"#c6dcdc",military:"#dcdcdc",tunnel_other_casing:"#e0e0e0",tunnel_minor_casing:"#e0e0e0",tunnel_link_casing:"#e0e0e0",tunnel_major_casing:"#e0e0e0",tunnel_highway_casing:"#e0e0e0",tunnel_other:"#d5d5d5",tunnel_minor:"#d5d5d5",tunnel_link:"#d5d5d5",tunnel_major:"#d5d5d5",tunnel_highway:"#d5d5d5",pier:"#e0e0e0",buildings:"#cccccc",minor_service_casing:"#e0e0e0",minor_casing:"#e0e0e0",link_casing:"#e0e0e0",major_casing_late:"#e0e0e0",highway_casing_late:"#e0e0e0",other:"#ebebeb",minor_service:"#ebebeb",minor_a:"#ebebeb",minor_b:"#ffffff",link:"#ffffff",major_casing_early:"#e0e0e0",major:"#ffffff",highway_casing_early:"#e0e0e0",highway:"#ffffff",railway:"#a7b1b3",boundaries:"#adadad",bridges_other_casing:"#e0e0e0",bridges_minor_casing:"#e0e0e0",bridges_link_casing:"#e0e0e0",bridges_major_casing:"#e0e0e0",bridges_highway_casing:"#e0e0e0",bridges_other:"#ebebeb",bridges_minor:"#ffffff",bridges_link:"#ffffff",bridges_major:"#f5f5f5",bridges_highway:"#ffffff",roads_label_minor:"#91888b",roads_label_minor_halo:"#ffffff",roads_label_major:"#938a8d",roads_label_major_halo:"#ffffff",ocean_label:"#728dd4",subplace_label:"#8f8f8f",subplace_label_halo:"#e0e0e0",city_label:"#5c5c5c",city_label_halo:"#e0e0e0",state_label:"#b3b3b3",state_label_halo:"#e0e0e0",country_label:"#a3a3a3",address_label:"#91888b",address_label_halo:"#ffffff",pois:{blue:"#1A8CBD",green:"#20834D",lapis:"#315BCF",pink:"#EF56BA",red:"#F2567A",slategray:"#6A5B8F",tangerine:"#CB6704",turquoise:"#00C3D4"},landcover:{grassland:"rgba(210, 239, 207, 1)",barren:"rgba(255, 243, 215, 1)",urban_area:"rgba(230, 230, 230, 1)",farmland:"rgba(216, 239, 210, 1)",glacier:"rgba(255, 255, 255, 1)",scrub:"rgba(234, 239, 210, 1)",forest:"rgba(196, 231, 210, 1)"}},A_={background:"#34373d",earth:"#1f1f1f",park_a:"#1c2421",park_b:"#192a24",hospital:"#252424",industrial:"#222222",school:"#262323",wood_a:"#202121",wood_b:"#202121",pedestrian:"#1e1e1e",scrub_a:"#222323",scrub_b:"#222323",glacier:"#1c1c1c",sand:"#212123",beach:"#28282a",aerodrome:"#1e1e1e",runway:"#333333",water:"#31353f",zoo:"#222323",military:"#242323",tunnel_other_casing:"#141414",tunnel_minor_casing:"#141414",tunnel_link_casing:"#141414",tunnel_major_casing:"#141414",tunnel_highway_casing:"#141414",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",pier:"#333333",buildings:"#111111",minor_service_casing:"#1f1f1f",minor_casing:"#1f1f1f",link_casing:"#1f1f1f",major_casing_late:"#1f1f1f",highway_casing_late:"#1f1f1f",other:"#333333",minor_service:"#333333",minor_a:"#3d3d3d",minor_b:"#333333",link:"#3d3d3d",major_casing_early:"#1f1f1f",major:"#3d3d3d",highway_casing_early:"#1f1f1f",highway:"#474747",railway:"#000000",boundaries:"#5b6374",bridges_other_casing:"#2b2b2b",bridges_minor_casing:"#1f1f1f",bridges_link_casing:"#1f1f1f",bridges_major_casing:"#1f1f1f",bridges_highway_casing:"#1f1f1f",bridges_other:"#333333",bridges_minor:"#333333",bridges_link:"#3d3d3d",bridges_major:"#3d3d3d",bridges_highway:"#474747",roads_label_minor:"#525252",roads_label_minor_halo:"#1f1f1f",roads_label_major:"#666666",roads_label_major_halo:"#1f1f1f",ocean_label:"#717784",subplace_label:"#525252",subplace_label_halo:"#1f1f1f",city_label:"#7a7a7a",city_label_halo:"#212121",state_label:"#3d3d3d",state_label_halo:"#1f1f1f",country_label:"#5c5c5c",address_label:"#525252",address_label_halo:"#1f1f1f",pois:{blue:"#4299BB",green:"#30C573",lapis:"#2B5CEA",pink:"#EF56BA",red:"#F2567A",slategray:"#93939F",tangerine:"#F19B6E",turquoise:"#00C3D4"},landcover:{grassland:"rgba(30, 41, 31, 1)",barren:"rgba(38, 38, 36, 1)",urban_area:"rgba(28, 28, 28, 1)",farmland:"rgba(31, 36, 32, 1)",glacier:"rgba(43, 43, 43, 1)",scrub:"rgba(34, 36, 30, 1)",forest:"rgba(28, 41, 37, 1)"}},D_={background:"#ffffff",earth:"#ffffff",park_a:"#fcfcfc",park_b:"#fcfcfc",hospital:"#f8f8f8",industrial:"#fcfcfc",school:"#f8f8f8",wood_a:"#fafafa",wood_b:"#fafafa",pedestrian:"#fdfdfd",scrub_a:"#fafafa",scrub_b:"#fafafa",glacier:"#fcfcfc",sand:"#fafafa",beach:"#f6f6f6",aerodrome:"#fdfdfd",runway:"#efefef",water:"#dcdcdc",zoo:"#f7f7f7",military:"#fcfcfc",tunnel_other_casing:"#d6d6d6",tunnel_minor_casing:"#fcfcfc",tunnel_link_casing:"#fcfcfc",tunnel_major_casing:"#fcfcfc",tunnel_highway_casing:"#fcfcfc",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",pier:"#efefef",buildings:"#efefef",minor_service_casing:"#ffffff",minor_casing:"#ffffff",link_casing:"#ffffff",major_casing_late:"#ffffff",highway_casing_late:"#ffffff",other:"#f5f5f5",minor_service:"#f5f5f5",minor_a:"#ebebeb",minor_b:"#f5f5f5",link:"#ebebeb",major_casing_early:"#ffffff",major:"#ebebeb",highway_casing_early:"#ffffff",highway:"#ebebeb",railway:"#d6d6d6",boundaries:"#adadad",bridges_other_casing:"#ffffff",bridges_minor_casing:"#ffffff",bridges_link_casing:"#ffffff",bridges_major_casing:"#ffffff",bridges_highway_casing:"#ffffff",bridges_other:"#f5f5f5",bridges_minor:"#f5f5f5",bridges_link:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#adadad",roads_label_minor_halo:"#ffffff",roads_label_major:"#999999",roads_label_major_halo:"#ffffff",ocean_label:"#adadad",subplace_label:"#8f8f8f",subplace_label_halo:"#ffffff",city_label:"#5c5c5c",city_label_halo:"#ffffff",state_label:"#b3b3b3",state_label_halo:"#ffffff",country_label:"#b8b8b8",address_label:"#adadad",address_label_halo:"#ffffff"},z_={background:"#a3a3a3",earth:"#cccccc",park_a:"#c2c2c2",park_b:"#c2c2c2",hospital:"#d0d0d0",industrial:"#c6c6c6",school:"#d0d0d0",wood_a:"#c2c2c2",wood_b:"#c2c2c2",pedestrian:"#c4c4c4",scrub_a:"#c2c2c2",scrub_b:"#c2c2c2",glacier:"#d2d2d2",sand:"#d2d2d2",beach:"#d2d2d2",aerodrome:"#c9c9c9",runway:"#f5f5f5",water:"#a3a3a3",zoo:"#c7c7c7",military:"#bfbfbf",tunnel_other_casing:"#b8b8b8",tunnel_minor_casing:"#b8b8b8",tunnel_link_casing:"#b8b8b8",tunnel_major_casing:"#b8b8b8",tunnel_highway_casing:"#b8b8b8",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",pier:"#b8b8b8",buildings:"#e0e0e0",minor_service_casing:"#cccccc",minor_casing:"#cccccc",link_casing:"#cccccc",major_casing_late:"#cccccc",highway_casing_late:"#cccccc",other:"#e0e0e0",minor_service:"#e0e0e0",minor_a:"#ebebeb",minor_b:"#e0e0e0",link:"#ebebeb",major_casing_early:"#cccccc",major:"#ebebeb",highway_casing_early:"#cccccc",highway:"#ebebeb",railway:"#f5f5f5",boundaries:"#5c5c5c",bridges_other_casing:"#cccccc",bridges_minor_casing:"#cccccc",bridges_link_casing:"#cccccc",bridges_major_casing:"#cccccc",bridges_highway_casing:"#cccccc",bridges_other:"#e0e0e0",bridges_minor:"#e0e0e0",bridges_link:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#999999",roads_label_minor_halo:"#e0e0e0",roads_label_major:"#8f8f8f",roads_label_major_halo:"#ebebeb",ocean_label:"#7a7a7a",subplace_label:"#7a7a7a",subplace_label_halo:"#cccccc",city_label:"#474747",city_label_halo:"#cccccc",state_label:"#999999",state_label_halo:"#cccccc",country_label:"#858585",address_label:"#999999",address_label_halo:"#e0e0e0"},k_={background:"#2b2b2b",earth:"#141414",park_a:"#181818",park_b:"#181818",hospital:"#1d1d1d",industrial:"#101010",school:"#111111",wood_a:"#1a1a1a",wood_b:"#1a1a1a",pedestrian:"#191919",scrub_a:"#1c1c1c",scrub_b:"#1c1c1c",glacier:"#191919",sand:"#161616",beach:"#1f1f1f",aerodrome:"#191919",runway:"#323232",water:"#333333",zoo:"#191919",military:"#121212",tunnel_other_casing:"#101010",tunnel_minor_casing:"#101010",tunnel_link_casing:"#101010",tunnel_major_casing:"#101010",tunnel_highway_casing:"#101010",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",pier:"#0a0a0a",buildings:"#0a0a0a",minor_service_casing:"#141414",minor_casing:"#141414",link_casing:"#141414",major_casing_late:"#141414",highway_casing_late:"#141414",other:"#1f1f1f",minor_service:"#1f1f1f",minor_a:"#292929",minor_b:"#1f1f1f",link:"#1f1f1f",major_casing_early:"#141414",major:"#292929",highway_casing_early:"#141414",highway:"#292929",railway:"#292929",boundaries:"#707070",bridges_other_casing:"#141414",bridges_minor_casing:"#141414",bridges_link_casing:"#141414",bridges_major_casing:"#141414",bridges_highway_casing:"#141414",bridges_other:"#1f1f1f",bridges_minor:"#1f1f1f",bridges_link:"#292929",bridges_major:"#292929",bridges_highway:"#292929",roads_label_minor:"#525252",roads_label_minor_halo:"#141414",roads_label_major:"#5c5c5c",roads_label_major_halo:"#141414",ocean_label:"#707070",subplace_label:"#5c5c5c",subplace_label_halo:"#141414",city_label:"#999999",city_label_halo:"#141414",state_label:"#3d3d3d",state_label_halo:"#141414",country_label:"#707070",address_label:"#525252",address_label_halo:"#141414"};function R_(xt){switch(xt){case"light":return C_;case"dark":return A_;case"white":return D_;case"grayscale":return z_;case"black":return k_}throw new Error("Flavor not found")}mn(R_,"namedFlavor");function L_(xt,at,Et){let At=[];return Et!=null&&Et.labelsOnly||(At=cf(xt,at)),Et!=null&&Et.lang&&(At=At.concat(uf(xt,at,Et.lang))),At}mn(L_,"layers");var ku={exports:{}};var F_=ku.exports,sf;function B_(){return sf||(sf=1,function(xt,at){(function(Et,At){xt.exports=At()})(F_,function(){var Et={},At={};function se(D,h,It){if(At[D]=It,D==="index"){var si="var sharedModule = {}; ("+At.shared+")(sharedModule); ("+At.worker+")(sharedModule);",Ve={};return At.shared(Ve),At.index(Et,Ve),typeof window<"u"&&Et.setWorkerUrl(window.URL.createObjectURL(new Blob([si],{type:"text/javascript"}))),Et}}se("shared",["exports"],function(D){function h(r,t,i,a){return new(i||(i=Promise))(function(s,l){function u(y){try{_(a.next(y))}catch(v){l(v)}}function f(y){try{_(a.throw(y))}catch(v){l(v)}}function _(y){var v;y.done?s(y.value):(v=y.value,v instanceof i?v:new i(function(w){w(v)})).then(u,f)}_((a=a.apply(r,t||[])).next())})}function It(r,t){this.x=r,this.y=t}function si(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ve,dr;typeof SuppressedError=="function"&&SuppressedError,It.prototype={clone(){return new It(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,t){return this.clone()._rotateAround(r,t)},matMult(r){return this.clone()._matMult(r)},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(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const t=r.x-this.x,i=r.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,t){return Math.atan2(this.x*t-this.y*r,this.x*r+this.y*t)},_matMult(r){const t=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=t,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const t=Math.cos(r),i=Math.sin(r),a=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=a,this},_rotateAround(r,t){const i=Math.cos(r),a=Math.sin(r),s=t.y+a*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-a*(this.y-t.y),this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:It},It.convert=function(r){if(r instanceof It)return r;if(Array.isArray(r))return new It(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new It(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var Ji=function(){if(dr)return Ve;function r(t,i,a,s){this.cx=3*t,this.bx=3*(a-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(s-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=a,this.p2y=s}return dr=1,Ve=r,r.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,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var a=t,s=0;s<8;s++){var l=this.sampleCurveX(a)-t;if(Math.abs(l)<i)return a;var u=this.sampleCurveDerivativeX(a);if(Math.abs(u)<1e-6)break;a-=l/u}var f=0,_=1;for(a=t,s=0;s<20&&(l=this.sampleCurveX(a),!(Math.abs(l-t)<i));s++)t>l?f=a:_=a,a=.5*(_-f)+f;return a},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},Ve}(),Ze=si(Ji);let Zr,ie;function pt(){return Zr==null&&(Zr=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Zr}function _n(){if(ie==null&&(ie=!1,pt())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let a=0;a<5*5;a++){const s=4*a;t.fillStyle=`rgb(${s},${s+1},${s+2})`,t.fillRect(a%5,Math.floor(a/5),1,1)}const i=t.getImageData(0,0,5,5).data;for(let a=0;a<5*5*4;a++)if(a%4!=3&&i[a]!==a){ie=!0;break}}}return ie||!1}var ze=1e-6,Se=typeof Float32Array<"u"?Float32Array:Array;function Wn(){var r=new Se(9);return Se!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function Hn(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Aa(){var r=new Se(3);return Se!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function Ci(r){var t=r[0],i=r[1],a=r[2];return Math.sqrt(t*t+i*i+a*a)}function Ps(r,t,i){var a=new Se(3);return a[0]=r,a[1]=t,a[2]=i,a}function Ir(r,t,i){return r[0]=t[0]+i[0],r[1]=t[1]+i[1],r[2]=t[2]+i[2],r}function $r(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r}function gn(r,t,i){var a=t[0],s=t[1],l=t[2],u=i[0],f=i[1],_=i[2];return r[0]=s*_-l*f,r[1]=l*u-a*_,r[2]=a*f-s*u,r}var qr,yn=Ci;function Da(r,t,i){var a=t[0],s=t[1],l=t[2],u=t[3];return r[0]=i[0]*a+i[4]*s+i[8]*l+i[12]*u,r[1]=i[1]*a+i[5]*s+i[9]*l+i[13]*u,r[2]=i[2]*a+i[6]*s+i[10]*l+i[14]*u,r[3]=i[3]*a+i[7]*s+i[11]*l+i[15]*u,r}function za(){var r=new Se(4);return Se!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function ka(r,t,i,a){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",l=Math.PI/360;t*=l,a*=l,i*=l;var u=Math.sin(t),f=Math.cos(t),_=Math.sin(i),y=Math.cos(i),v=Math.sin(a),w=Math.cos(a);switch(s){case"xyz":r[0]=u*y*w+f*_*v,r[1]=f*_*w-u*y*v,r[2]=f*y*v+u*_*w,r[3]=f*y*w-u*_*v;break;case"xzy":r[0]=u*y*w-f*_*v,r[1]=f*_*w-u*y*v,r[2]=f*y*v+u*_*w,r[3]=f*y*w+u*_*v;break;case"yxz":r[0]=u*y*w+f*_*v,r[1]=f*_*w-u*y*v,r[2]=f*y*v-u*_*w,r[3]=f*y*w+u*_*v;break;case"yzx":r[0]=u*y*w+f*_*v,r[1]=f*_*w+u*y*v,r[2]=f*y*v-u*_*w,r[3]=f*y*w-u*_*v;break;case"zxy":r[0]=u*y*w-f*_*v,r[1]=f*_*w+u*y*v,r[2]=f*y*v+u*_*w,r[3]=f*y*w-u*_*v;break;case"zyx":r[0]=u*y*w-f*_*v,r[1]=f*_*w+u*y*v,r[2]=f*y*v-u*_*w,r[3]=f*y*w+u*_*v;break;default:throw new Error("Unknown angle order "+s)}return r}function Qi(){var r=new Se(2);return Se!=Float32Array&&(r[0]=0,r[1]=0),r}function Ms(r,t){var i=new Se(2);return i[0]=r,i[1]=t,i}Aa(),qr=new Se(4),Se!=Float32Array&&(qr[0]=0,qr[1]=0,qr[2]=0,qr[3]=0),Aa(),Ps(1,0,0),Ps(0,1,0),za(),za(),Wn(),Qi();const oe=8192;function Xn(r,t,i){return t*(oe/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function pr(r,t){return(r%t+t)%t}function xn(r,t,i){return r*(1-i)+t*i}function Is(r){if(r<=0)return 0;if(r>=1)return 1;const t=r*r,i=t*r;return 4*(r<.5?i:3*(r-t)+i-.75)}function Wr(r,t,i,a){const s=new Ze(r,t,i,a);return l=>s.solve(l)}const Hr=Wr(.25,.1,.25,1);function wi(r,t,i){return Math.min(i,Math.max(t,r))}function tr(r,t,i){const a=i-t,s=((r-t)%a+a)%a+t;return s===t?i:s}function di(r,...t){for(const i of t)for(const a in i)r[a]=i[a];return r}let Yn=1;function Xr(r,t,i){const a={};for(const s in r)a[s]=t.call(this,r[s],s,r);return a}function vn(r,t,i){const a={};for(const s in r)t.call(this,r[s],s,r)&&(a[s]=r[s]);return a}function Zi(r){return Array.isArray(r)?r.map(Zi):typeof r=="object"&&r?Xr(r,Zi):r}const Ra={};function Pe(r){Ra[r]||(typeof console<"u"&&console.warn(r),Ra[r]=!0)}function er(r,t,i){return(i.y-r.y)*(t.x-r.x)>(t.y-r.y)*(i.x-r.x)}function fr(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let Me=null;function mr(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const _r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Kn(r,t,i,a,s){return h(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const l=new VideoFrame(r,{timestamp:0});try{const u=l?.format;if(!u||!u.startsWith("BGR")&&!u.startsWith("RGB"))throw new Error(`Unrecognized format ${u}`);const f=u.startsWith("BGR"),_=new Uint8ClampedArray(a*s*4);if(yield l.copyTo(_,function(y,v,w,S,P){const M=4*Math.max(-v,0),C=(Math.max(0,w)-w)*S*4+M,z=4*S,F=Math.max(0,v),Z=Math.max(0,w);return{rect:{x:F,y:Z,width:Math.min(y.width,v+S)-F,height:Math.min(y.height,w+P)-Z},layout:[{offset:C,stride:z}]}}(r,t,i,a,s)),f)for(let y=0;y<_.length;y+=4){const v=_[y];_[y]=_[y+2],_[y+2]=v}return _}finally{l.close()}})}let Yr,gr;function Kr(r,t,i,a){return r.addEventListener(t,i,a),{unsubscribe:()=>{r.removeEventListener(t,i,a)}}}function bn(r){return r*Math.PI/180}function Ai(r){return r/Math.PI*180}const La={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Fa={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},wn="AbortError";function Jn(){return new Error(wn)}const Jr={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Qn(r){return Jr.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const Tn="global-dispatcher";class ir extends Error{constructor(t,i,a,s){super(`AJAXError: ${i} (${t}): ${a}`),this.status=t,this.statusText=i,this.url=a,this.body=s}}const Oi=()=>fr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,tt=function(r,t){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const a=Qn(r.url);if(a)return a(r,t);if(fr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:Tn},t)}if(!(/^file:/.test(i=r.url)||/^file:/.test(Oi())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(a,s){return h(this,void 0,void 0,function*(){const l=new Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,cache:a.cache,referrer:Oi(),signal:s.signal});let u,f;a.type!=="json"||l.headers.has("Accept")||l.headers.set("Accept","application/json");try{u=yield fetch(l)}catch(y){throw new ir(0,y.message,a.url,new Blob)}if(!u.ok){const y=yield u.blob();throw new ir(u.status,u.statusText,a.url,y)}f=a.type==="arrayBuffer"||a.type==="image"?u.arrayBuffer():a.type==="json"?u.json():u.text();const _=yield f;if(s.signal.aborted)throw Jn();return{data:_,cacheControl:u.headers.get("Cache-Control"),expires:u.headers.get("Expires")}})}(r,t);if(fr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:Tn},t)}var i;return function(a,s){return new Promise((l,u)=>{var f;const _=new XMLHttpRequest;_.open(a.method||"GET",a.url,!0),a.type!=="arrayBuffer"&&a.type!=="image"||(_.responseType="arraybuffer");for(const y in a.headers)_.setRequestHeader(y,a.headers[y]);a.type==="json"&&(_.responseType="text",!((f=a.headers)===null||f===void 0)&&f.Accept||_.setRequestHeader("Accept","application/json")),_.withCredentials=a.credentials==="include",_.onerror=()=>{u(new Error(_.statusText))},_.onload=()=>{if(!s.signal.aborted)if((_.status>=200&&_.status<300||_.status===0)&&_.response!==null){let y=_.response;if(a.type==="json")try{y=JSON.parse(_.response)}catch(v){return void u(v)}l({data:y,cacheControl:_.getResponseHeader("Cache-Control"),expires:_.getResponseHeader("Expires")})}else{const y=new Blob([_.response],{type:_.getResponseHeader("Content-Type")});u(new ir(_.status,_.statusText,a.url,y))}},s.signal.addEventListener("abort",()=>{_.abort(),u(Jn())}),_.send(a.body)})}(r,t)};function k(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const t=new URL(r),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function R(r,t,i){i[r]&&i[r].indexOf(t)!==-1||(i[r]=i[r]||[],i[r].push(t))}function B(r,t,i){if(i&&i[r]){const a=i[r].indexOf(t);a!==-1&&i[r].splice(a,1)}}class W{constructor(t,i={}){di(this,i),this.type=t}}class X extends W{constructor(t,i={}){super("error",di({error:t},i))}}class nt{on(t,i){return this._listeners=this._listeners||{},R(t,i,this._listeners),{unsubscribe:()=>{this.off(t,i)}}}off(t,i){return B(t,i,this._listeners),B(t,i,this._oneTimeListeners),this}once(t,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},R(t,i,this._oneTimeListeners),this):new Promise(a=>this.once(t,a))}fire(t,i){typeof t=="string"&&(t=new W(t,i||{}));const a=t.type;if(this.listens(a)){t.target=this;const s=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const f of s)f.call(this,t);const l=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const f of l)B(a,f,this._oneTimeListeners),f.call(this,t);const u=this._eventedParent;u&&(di(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),u.fire(t))}else t instanceof X&&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,i){return this._eventedParent=t,this._eventedParentData=i,this}}var U={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},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:"array",value:"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:"*"},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","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"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","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},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"}}};const rt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ht(r,t){const i={};for(const a in r)a!=="ref"&&(i[a]=r[a]);return rt.forEach(a=>{a in t&&(i[a]=t[a])}),i}function dt(r,t){if(Array.isArray(r)){if(!Array.isArray(t)||r.length!==t.length)return!1;for(let i=0;i<r.length;i++)if(!dt(r[i],t[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&t!==null){if(typeof t!="object"||Object.keys(r).length!==Object.keys(t).length)return!1;for(const i in r)if(!dt(r[i],t[i]))return!1;return!0}return r===t}function ft(r,t){r.push(t)}function zt(r,t,i){ft(i,{command:"addSource",args:[r,t[r]]})}function jt(r,t,i){ft(t,{command:"removeSource",args:[r]}),i[r]=!0}function qt(r,t,i,a){jt(r,i,a),zt(r,t,i)}function ke(r,t,i){let a;for(a in r[i])if(Object.prototype.hasOwnProperty.call(r[i],a)&&a!=="data"&&!dt(r[i][a],t[i][a]))return!1;for(a in t[i])if(Object.prototype.hasOwnProperty.call(t[i],a)&&a!=="data"&&!dt(r[i][a],t[i][a]))return!1;return!0}function Yt(r,t,i,a,s,l){r=r||{},t=t||{};for(const u in r)Object.prototype.hasOwnProperty.call(r,u)&&(dt(r[u],t[u])||i.push({command:l,args:[a,u,t[u],s]}));for(const u in t)Object.prototype.hasOwnProperty.call(t,u)&&!Object.prototype.hasOwnProperty.call(r,u)&&(dt(r[u],t[u])||i.push({command:l,args:[a,u,t[u],s]}))}function ne(r){return r.id}function de(r,t){return r[t.id]=t,r}class bt{constructor(t,i,a,s){this.message=(t?`${t}: `:"")+a,s&&(this.identifier=s),i!=null&&i.__line__&&(this.line=i.__line__)}}function xe(r,...t){for(const i of t)for(const a in i)r[a]=i[a];return r}class pe extends Error{constructor(t,i){super(i),this.message=i,this.key=t}}class $e{constructor(t,i=[]){this.parent=t,this.bindings={};for(const[a,s]of i)this.bindings[a]=s}concat(t){return new $e(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 fe={kind:"null"},Tt={kind:"number"},Lt={kind:"string"},Ut={kind:"boolean"},Di={kind:"color"},Sn={kind:"projectionDefinition"},ti={kind:"object"},Gt={kind:"value"},Er={kind:"collator"},ta={kind:"formatted"},ea={kind:"padding"},rr={kind:"colorArray"},Pn={kind:"numberArray"},ia={kind:"resolvedImage"},ra={kind:"variableAnchorOffsetCollection"};function ji(r,t){return{kind:"array",itemType:r,N:t}}function me(r){if(r.kind==="array"){const t=me(r.itemType);return typeof r.N=="number"?`array<${t}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${t}>`}return r.kind}const Ru=[fe,Tt,Lt,Ut,Di,Sn,ta,ti,ji(Gt),ea,Pn,rr,ia,ra];function yr(r,t){if(t.kind==="error")return null;if(r.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!yr(r.itemType,t.itemType))&&(typeof r.N!="number"||r.N===t.N))return null}else{if(r.kind===t.kind)return null;if(r.kind==="value"){for(const i of Ru)if(!yr(i,t))return null}}return`Expected ${me(r)} but found ${me(t)} instead.`}function Ba(r,t){return t.some(i=>i.kind===r.kind)}function Ie(r,t){return t.some(i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r)}function Qr(r,t){return r.kind==="array"&&t.kind==="array"?r.itemType.kind===t.itemType.kind&&typeof r.N=="number":r.kind===t.kind}const zo=.96422,na=.82521,ko=4/29,aa=6/29,Jl=3*aa*aa,Ql=aa*aa*aa,Lu=Math.PI/180,tc=180/Math.PI;function ec(r){return(r%=360)<0&&(r+=360),r}function ic([r,t,i,a]){let s,l;const u=Lo((.2225045*(r=Ro(r))+.7168786*(t=Ro(t))+.0606169*(i=Ro(i)))/1);r===t&&t===i?s=l=u:(s=Lo((.4360747*r+.3850649*t+.1430804*i)/zo),l=Lo((.0139322*r+.0971045*t+.7141733*i)/na));const f=116*u-16;return[f<0?0:f,500*(s-u),200*(u-l),a]}function Ro(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function Lo(r){return r>Ql?Math.pow(r,1/3):r/Jl+ko}function rc([r,t,i,a]){let s=(r+16)/116,l=isNaN(t)?s:s+t/500,u=isNaN(i)?s:s-i/200;return s=1*Bo(s),l=zo*Bo(l),u=na*Bo(u),[Fo(3.1338561*l-1.6168667*s-.4906146*u),Fo(-.9787684*l+1.9161415*s+.033454*u),Fo(.0719453*l-.2289914*s+1.4052427*u),a]}function Fo(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function Bo(r){return r>aa?r*r*r:Jl*(r-ko)}const nc=Object.hasOwn||function(r,t){return Object.prototype.hasOwnProperty.call(r,t)};function Cr(r,t){return nc(r,t)?r[t]:void 0}function Es(r){return parseInt(r.padEnd(2,r),16)/255}function ac(r,t){return xr(t?r/100:r,0,1)}function xr(r,t,i){return Math.min(Math.max(t,r),i)}function sc(r){return!r.some(Number.isNaN)}const Fu={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 tn(r,t,i){return r+i*(t-r)}function Mn(r,t,i){return r.map((a,s)=>tn(a,t[s],i))}class Kt{constructor(t,i,a,s=1,l=!0){this.r=t,this.g=i,this.b=a,this.a=s,l||(this.r*=s,this.g*=s,this.b*=s,s||this.overwriteGetter("rgb",[t,i,a,s]))}static parse(t){if(t instanceof Kt)return t;if(typeof t!="string")return;const i=function(a){if((a=a.toLowerCase().trim())==="transparent")return[0,0,0,0];const s=Cr(Fu,a);if(s){const[u,f,_]=s;return[u/255,f/255,_/255,1]}if(a.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(a)){const u=a.length<6?1:2;let f=1;return[Es(a.slice(f,f+=u)),Es(a.slice(f,f+=u)),Es(a.slice(f,f+=u)),Es(a.slice(f,f+u)||"ff")]}if(a.startsWith("rgb")){const u=a.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[f,_,y,v,w,S,P,M,C,z,F,Z]=u,O=[v||" ",P||" ",z].join("");if(O===" "||O===" /"||O===",,"||O===",,,"){const N=[y,S,C].join(""),Q=N==="%%%"?100:N===""?255:0;if(Q){const et=[xr(+_/Q,0,1),xr(+w/Q,0,1),xr(+M/Q,0,1),F?ac(+F,Z):1];if(sc(et))return et}}return}}const l=a.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(l){const[u,f,_,y,v,w,S,P,M]=l,C=[_||" ",v||" ",S].join("");if(C===" "||C===" /"||C===",,"||C===",,,"){const z=[+f,xr(+y,0,100),xr(+w,0,100),P?ac(+P,M):1];if(sc(z))return function([F,Z,O,N]){function Q(et){const lt=(et+F/30)%12,yt=Z*Math.min(O,1-O);return O-yt*Math.max(-1,Math.min(lt-3,9-lt,1))}return F=ec(F),Z/=100,O/=100,[Q(0),Q(8),Q(4),N]}(z)}}}(t);return i?new Kt(...i,!1):void 0}get rgb(){const{r:t,g:i,b:a,a:s}=this,l=s||1/0;return this.overwriteGetter("rgb",[t/l,i/l,a/l,s])}get hcl(){return this.overwriteGetter("hcl",function(t){const[i,a,s,l]=ic(t),u=Math.sqrt(a*a+s*s);return[Math.round(1e4*u)?ec(Math.atan2(s,a)*tc):NaN,u,i,l]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ic(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){const[t,i,a,s]=this.rgb;return`rgba(${[t,i,a].map(l=>Math.round(255*l)).join(",")},${s})`}static interpolate(t,i,a,s="rgb"){switch(s){case"rgb":{const[l,u,f,_]=Mn(t.rgb,i.rgb,a);return new Kt(l,u,f,_,!1)}case"hcl":{const[l,u,f,_]=t.hcl,[y,v,w,S]=i.hcl;let P,M;if(isNaN(l)||isNaN(y))isNaN(l)?isNaN(y)?P=NaN:(P=y,f!==1&&f!==0||(M=v)):(P=l,w!==1&&w!==0||(M=u));else{let O=y-l;y>l&&O>180?O-=360:y<l&&l-y>180&&(O+=360),P=l+a*O}const[C,z,F,Z]=function([O,N,Q,et]){return O=isNaN(O)?0:O*Lu,rc([Q,Math.cos(O)*N,Math.sin(O)*N,et])}([P,M??tn(u,v,a),tn(f,w,a),tn(_,S,a)]);return new Kt(C,z,F,Z,!1)}case"lab":{const[l,u,f,_]=rc(Mn(t.lab,i.lab,a));return new Kt(l,u,f,_,!1)}}}}Kt.black=new Kt(0,0,0,1),Kt.white=new Kt(1,1,1,1),Kt.transparent=new Kt(0,0,0,0),Kt.red=new Kt(1,0,0,1);class $i{constructor(t,i,a){this.sensitivity=t?i?"variant":"case":i?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,i){return this.collator.compare(t,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const te=["bottom","center","top"];class en{constructor(t,i,a,s,l,u){this.text=t,this.image=i,this.scale=a,this.fontStack=s,this.textColor=l,this.verticalAlign=u}}class qe{constructor(t){this.sections=t}static fromString(t){return new qe([new en(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof qe?t:qe.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}}class pi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof pi)return t;if(typeof t=="number")return new pi([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const i of t)if(typeof i!="number")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 pi(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,a){return new pi(Mn(t.values,i.values,a))}}class fi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof fi)return t;if(typeof t=="number")return new fi([t]);if(Array.isArray(t)){for(const i of t)if(typeof i!="number")return;return new fi(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,a){return new fi(Mn(t.values,i.values,a))}}class Je{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Je)return t;if(typeof t=="string"){const a=Kt.parse(t);return a?new Je([a]):void 0}if(!Array.isArray(t))return;const i=[];for(const a of t){if(typeof a!="string")return;const s=Kt.parse(a);if(!s)return;i.push(s)}return new Je(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,a,s="rgb"){const l=[];if(t.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let u=0;u<t.values.length;u++)l.push(Kt.interpolate(t.values[u],i.values[u],a,s));return new Je(l)}}class _e extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}}const Cs=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ti{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ti)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let i=0;i<t.length;i+=2){const a=t[i],s=t[i+1];if(typeof a!="string"||!Cs.has(a)||!Array.isArray(s)||s.length!==2||typeof s[0]!="number"||typeof s[1]!="number")return}return new Ti(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,a){const s=t.values,l=i.values;if(s.length!==l.length)throw new _e(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`);const u=[];for(let f=0;f<s.length;f+=2){if(s[f]!==l[f])throw new _e(`Cannot interpolate values containing mismatched anchors. from[${f}]: ${s[f]}, to[${f}]: ${l[f]}`);u.push(s[f]);const[_,y]=s[f+1],[v,w]=l[f+1];u.push([tn(_,v,a),tn(y,w,a)])}return new Ti(u)}}class zi{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new zi({name:t,available:!1}):null}}class mi{constructor(t,i,a){this.from=t,this.to=i,this.transition=a}static interpolate(t,i,a){return new mi(t,i,a)}static parse(t){return t instanceof mi?t:Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number"?new mi(t[0],t[1],t[2]):typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number"?new mi(t.from,t.to,t.transition):typeof t=="string"?new mi(t,t,1):void 0}}function oc(r,t,i,a){return typeof r=="number"&&r>=0&&r<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?a===void 0||typeof a=="number"&&a>=0&&a<=1?null:`Invalid rgba value [${[r,t,i,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof a=="number"?[r,t,i,a]:[r,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function rn(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof mi||r instanceof Kt||r instanceof $i||r instanceof qe||r instanceof pi||r instanceof fi||r instanceof Je||r instanceof Ti||r instanceof zi)return!0;if(Array.isArray(r)){for(const t of r)if(!rn(t))return!1;return!0}if(typeof r=="object"){for(const t in r)if(!rn(r[t]))return!1;return!0}return!1}function ve(r){if(r===null)return fe;if(typeof r=="string")return Lt;if(typeof r=="boolean")return Ut;if(typeof r=="number")return Tt;if(r instanceof Kt)return Di;if(r instanceof mi)return Sn;if(r instanceof $i)return Er;if(r instanceof qe)return ta;if(r instanceof pi)return ea;if(r instanceof fi)return Pn;if(r instanceof Je)return rr;if(r instanceof Ti)return ra;if(r instanceof zi)return ia;if(Array.isArray(r)){const t=r.length;let i;for(const a of r){const s=ve(a);if(i){if(i===s)continue;i=Gt;break}i=s}return ji(i||Gt,t)}return ti}function sa(r){const t=typeof r;return r===null?"":t==="string"||t==="number"||t==="boolean"?String(r):r instanceof Kt||r instanceof mi||r instanceof qe||r instanceof pi||r instanceof fi||r instanceof Je||r instanceof Ti||r instanceof zi?r.toString():JSON.stringify(r)}class nn{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!rn(t[1]))return i.error("invalid value");const a=t[1];let s=ve(a);const l=i.expectedType;return s.kind!=="array"||s.N!==0||!l||l.kind!=="array"||typeof l.N=="number"&&l.N!==0||(s=l),new nn(s,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Oa={string:Lt,number:Tt,boolean:Ut,object:ti};class ki{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let a,s=1;const l=t[0];if(l==="array"){let f,_;if(t.length>2){const y=t[1];if(typeof y!="string"||!(y in Oa)||y==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);f=Oa[y],s++}else f=Gt;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);_=t[2],s++}a=ji(f,_)}else{if(!Oa[l])throw new Error(`Types doesn't contain name = ${l}`);a=Oa[l]}const u=[];for(;s<t.length;s++){const f=i.parse(t[s],s,Gt);if(!f)return null;u.push(f)}return new ki(a,u)}evaluate(t){for(let i=0;i<this.args.length;i++){const a=this.args[i].evaluate(t);if(!yr(this.type,ve(a)))return a;if(i===this.args.length-1)throw new _e(`Expected value to be of type ${me(this.type)}, but found ${me(ve(a))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const be={"to-boolean":Ut,"to-color":Di,"to-number":Tt,"to-string":Lt};class vr{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const a=t[0];if(!be[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if((a==="to-boolean"||a==="to-string")&&t.length!==2)return i.error("Expected one argument.");const s=be[a],l=[];for(let u=1;u<t.length;u++){const f=i.parse(t[u],u,Gt);if(!f)return null;l.push(f)}return new vr(s,l)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,a;for(const s of this.args){if(i=s.evaluate(t),a=null,i instanceof Kt)return i;if(typeof i=="string"){const l=t.parseColor(i);if(l)return l}else if(Array.isArray(i)&&(a=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:oc(i[0],i[1],i[2],i[3]),!a))return new Kt(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new _e(a||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const a of this.args){i=a.evaluate(t);const s=pi.parse(i);if(s)return s}throw new _e(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const a of this.args){i=a.evaluate(t);const s=fi.parse(i);if(s)return s}throw new _e(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const a of this.args){i=a.evaluate(t);const s=Je.parse(i);if(s)return s}throw new _e(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const a of this.args){i=a.evaluate(t);const s=Ti.parse(i);if(s)return s}throw new _e(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const a of this.args){if(i=a.evaluate(t),i===null)return 0;const s=Number(i);if(!isNaN(s))return s}throw new _e(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return qe.fromString(sa(this.args[0].evaluate(t)));case"resolvedImage":return zi.fromString(sa(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return sa(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const re=["Unknown","Point","LineString","Polygon"];class Ht{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?typeof this.feature.type=="number"?re[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 i=this._parseColorCache.get(t);return i||(i=Kt.parse(t),this._parseColorCache.set(t,i)),i}}class oa{constructor(t,i,a=[],s,l=new $e,u=[]){this.registry=t,this.path=a,this.key=a.map(f=>`[${f}]`).join(""),this.scope=l,this.errors=u,this.expectedType=s,this._isConstant=i}parse(t,i,a,s,l={}){return i?this.concat(i,a,s)._parse(t,l):this._parse(t,l)}_parse(t,i){function a(s,l,u){return u==="assert"?new ki(l,[s]):u==="coerce"?new vr(l,[s]):s}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const s=t[0];if(typeof s!="string")return this.error(`Expression name must be a string, but found ${typeof s} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const l=this.registry[s];if(l){let u=l.parse(t,this);if(!u)return null;if(this.expectedType){const f=this.expectedType,_=u.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value"){if(f.kind==="projectionDefinition"&&["string","array"].includes(_.kind)||["color","formatted","resolvedImage"].includes(f.kind)&&["value","string"].includes(_.kind)||["padding","numberArray"].includes(f.kind)&&["value","number","array"].includes(_.kind)||f.kind==="colorArray"&&["value","string","array"].includes(_.kind)||f.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(_.kind))u=a(u,f,i.typeAnnotation||"coerce");else if(this.checkSubtype(f,_))return null}else u=a(u,f,i.typeAnnotation||"assert")}if(!(u instanceof nn)&&u.type.kind!=="resolvedImage"&&this._isConstant(u)){const f=new Ht;try{u=new nn(u.type,u.evaluate(f))}catch(_){return this.error(_.message),null}}return u}return this.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,i,a){const s=typeof t=="number"?this.path.concat(t):this.path,l=a?this.scope.concat(a):this.scope;return new oa(this.registry,this._isConstant,s,i||null,l,this.errors)}error(t,...i){const a=`${this.key}${i.map(s=>`[${s}]`).join("")}`;this.errors.push(new pe(a,t))}checkSubtype(t,i){const a=yr(t,i);return a&&this.error(a),a}}class ee{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const a=[];for(let l=1;l<t.length-1;l+=2){const u=t[l];if(typeof u!="string")return i.error(`Expected string, but found ${typeof u} instead.`,l);if(/[^a-zA-Z0-9_]/.test(u))return i.error("Variable names must contain only alphanumeric characters or '_'.",l);const f=i.parse(t[l+1],l+1);if(!f)return null;a.push([u,f])}const s=i.parse(t[t.length-1],t.length-1,i.expectedType,a);return s?new ee(a,s):null}outputDefined(){return this.result.outputDefined()}}class la{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const a=t[1];return i.scope.has(a)?new la(a,i.scope.get(a)):i.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class nr{constructor(t,i,a){this.type=t,this.index=i,this.input=a}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const a=i.parse(t[1],1,Tt),s=i.parse(t[2],2,ji(i.expectedType||Gt));return a&&s?new nr(s.type.itemType,a,s):null}evaluate(t){const i=this.index.evaluate(t),a=this.input.evaluate(t);if(i<0)throw new _e(`Array index out of bounds: ${i} < 0.`);if(i>=a.length)throw new _e(`Array index out of bounds: ${i} > ${a.length-1}.`);if(i!==Math.floor(i))throw new _e(`Array index must be an integer, but found ${i} instead.`);return a[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ja{constructor(t,i){this.type=Ut,this.needle=t,this.haystack=i}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const a=i.parse(t[1],1,Gt),s=i.parse(t[2],2,Gt);return a&&s?Ba(a.type,[Ut,Lt,Tt,fe,Gt])?new ja(a,s):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${me(a.type)} instead`):null}evaluate(t){const i=this.needle.evaluate(t),a=this.haystack.evaluate(t);if(!a)return!1;if(!Ie(i,["boolean","string","number","null"]))throw new _e(`Expected first argument to be of type boolean, string, number or null, but found ${me(ve(i))} instead.`);if(!Ie(a,["string","array"]))throw new _e(`Expected second argument to be of type array or string, but found ${me(ve(a))} instead.`);return a.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class In{constructor(t,i,a){this.type=Tt,this.needle=t,this.haystack=i,this.fromIndex=a}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const a=i.parse(t[1],1,Gt),s=i.parse(t[2],2,Gt);if(!a||!s)return null;if(!Ba(a.type,[Ut,Lt,Tt,fe,Gt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${me(a.type)} instead`);if(t.length===4){const l=i.parse(t[3],3,Tt);return l?new In(a,s,l):null}return new In(a,s)}evaluate(t){const i=this.needle.evaluate(t),a=this.haystack.evaluate(t);if(!Ie(i,["boolean","string","number","null"]))throw new _e(`Expected first argument to be of type boolean, string, number or null, but found ${me(ve(i))} instead.`);let s;if(this.fromIndex&&(s=this.fromIndex.evaluate(t)),Ie(a,["string"])){const l=a.indexOf(i,s);return l===-1?-1:[...a.slice(0,l)].length}if(Ie(a,["array"]))return a.indexOf(i,s);throw new _e(`Expected second argument to be of type array or string, but found ${me(ve(a))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class As{constructor(t,i,a,s,l,u){this.inputType=t,this.type=i,this.input=a,this.cases=s,this.outputs=l,this.otherwise=u}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let a,s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const l={},u=[];for(let y=2;y<t.length-1;y+=2){let v=t[y];const w=t[y+1];Array.isArray(v)||(v=[v]);const S=i.concat(y);if(v.length===0)return S.error("Expected at least one branch label.");for(const M of v){if(typeof M!="number"&&typeof M!="string")return S.error("Branch labels must be numbers or strings.");if(typeof M=="number"&&Math.abs(M)>Number.MAX_SAFE_INTEGER)return S.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof M=="number"&&Math.floor(M)!==M)return S.error("Numeric branch labels must be integer values.");if(a){if(S.checkSubtype(a,ve(M)))return null}else a=ve(M);if(l[String(M)]!==void 0)return S.error("Branch labels must be unique.");l[String(M)]=u.length}const P=i.parse(w,y,s);if(!P)return null;s=s||P.type,u.push(P)}const f=i.parse(t[1],1,Gt);if(!f)return null;const _=i.parse(t[t.length-1],t.length-1,s);return _?f.type.kind!=="value"&&i.concat(1).checkSubtype(a,f.type)?null:new As(a,s,f,l,u,_):null}evaluate(t){const i=this.input.evaluate(t);return(ve(i)===this.inputType&&this.outputs[this.cases[i]]||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 Va{constructor(t,i,a){this.type=t,this.branches=i,this.otherwise=a}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.expectedType);const s=[];for(let u=1;u<t.length-1;u+=2){const f=i.parse(t[u],u,Ut);if(!f)return null;const _=i.parse(t[u+1],u+1,a);if(!_)return null;s.push([f,_]),a=a||_.type}const l=i.parse(t[t.length-1],t.length-1,a);if(!l)return null;if(!a)throw new Error("Can't infer output type");return new Va(a,s,l)}evaluate(t){for(const[i,a]of this.branches)if(i.evaluate(t))return a.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[i,a]of this.branches)t(i),t(a);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}}class Na{constructor(t,i,a,s){this.type=t,this.input=i,this.beginIndex=a,this.endIndex=s}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const a=i.parse(t[1],1,Gt),s=i.parse(t[2],2,Tt);if(!a||!s)return null;if(!Ba(a.type,[ji(Gt),Lt,Gt]))return i.error(`Expected first argument to be of type array or string, but found ${me(a.type)} instead`);if(t.length===4){const l=i.parse(t[3],3,Tt);return l?new Na(a.type,a,s,l):null}return new Na(a.type,a,s)}evaluate(t){const i=this.input.evaluate(t),a=this.beginIndex.evaluate(t);let s;if(this.endIndex&&(s=this.endIndex.evaluate(t)),Ie(i,["string"]))return[...i].slice(a,s).join("");if(Ie(i,["array"]))return i.slice(a,s);throw new _e(`Expected first argument to be of type array or string, but found ${me(ve(i))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function Ds(r,t){const i=r.length-1;let a,s,l=0,u=i,f=0;for(;l<=u;)if(f=Math.floor((l+u)/2),a=r[f],s=r[f+1],a<=t){if(f===i||t<s)return f;l=f+1}else{if(!(a>t))throw new _e("Input is not a number.");u=f-1}return 0}class ca{constructor(t,i,a){this.type=t,this.input=i,this.labels=[],this.outputs=[];for(const[s,l]of a)this.labels.push(s),this.outputs.push(l)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");const a=i.parse(t[1],1,Tt);if(!a)return null;const s=[];let l=null;i.expectedType&&i.expectedType.kind!=="value"&&(l=i.expectedType);for(let u=1;u<t.length;u+=2){const f=u===1?-1/0:t[u],_=t[u+1],y=u,v=u+1;if(typeof f!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',y);if(s.length&&s[s.length-1][0]>=f)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',y);const w=i.parse(_,v,l);if(!w)return null;l=l||w.type,s.push([f,w])}return new ca(l,a,s)}evaluate(t){const i=this.labels,a=this.outputs;if(i.length===1)return a[0].evaluate(t);const s=this.input.evaluate(t);if(s<=i[0])return a[0].evaluate(t);const l=i.length;return s>=i[l-1]?a[l-1].evaluate(t):a[Ds(i,s)].evaluate(t)}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function lc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var br,oi,zs=function(){if(oi)return br;function r(t,i,a,s){this.cx=3*t,this.bx=3*(a-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(s-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=a,this.p2y=s}return oi=1,br=r,r.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,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var a=t,s=0;s<8;s++){var l=this.sampleCurveX(a)-t;if(Math.abs(l)<i)return a;var u=this.sampleCurveDerivativeX(a);if(Math.abs(u)<1e-6)break;a-=l/u}var f=0,_=1;for(a=t,s=0;s<20&&(l=this.sampleCurveX(a),!(Math.abs(l-t)<i));s++)t>l?f=a:_=a,a=.5*(_-f)+f;return a},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},br}(),cc=lc(zs);class li{constructor(t,i,a,s,l){this.type=t,this.operator=i,this.interpolation=a,this.input=s,this.labels=[],this.outputs=[];for(const[u,f]of l)this.labels.push(u),this.outputs.push(f)}static interpolationFactor(t,i,a,s){let l=0;if(t.name==="exponential")l=We(i,t.base,a,s);else if(t.name==="linear")l=We(i,1,a,s);else if(t.name==="cubic-bezier"){const u=t.controlPoints;l=new cc(u[0],u[1],u[2],u[3]).solve(We(i,1,a,s))}return l}static parse(t,i){let[a,s,l,...u]=t;if(!Array.isArray(s)||s.length===0)return i.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){const y=s[1];if(typeof y!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:y}}else{if(s[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(s[0])}`,1,0);{const y=s.slice(1);if(y.length!==4||y.some(v=>typeof v!="number"||v<0||v>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:y}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(l=i.parse(l,2,Tt),!l)return null;const f=[];let _=null;a!=="interpolate-hcl"&&a!=="interpolate-lab"||i.expectedType==rr?i.expectedType&&i.expectedType.kind!=="value"&&(_=i.expectedType):_=Di;for(let y=0;y<u.length;y+=2){const v=u[y],w=u[y+1],S=y+3,P=y+4;if(typeof v!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',S);if(f.length&&f[f.length-1][0]>=v)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',S);const M=i.parse(w,P,_);if(!M)return null;_=_||M.type,f.push([v,M])}return Qr(_,Tt)||Qr(_,Sn)||Qr(_,Di)||Qr(_,ea)||Qr(_,Pn)||Qr(_,rr)||Qr(_,ra)||Qr(_,ji(Tt))?new li(_,a,s,l,f):i.error(`Type ${me(_)} is not interpolatable.`)}evaluate(t){const i=this.labels,a=this.outputs;if(i.length===1)return a[0].evaluate(t);const s=this.input.evaluate(t);if(s<=i[0])return a[0].evaluate(t);const l=i.length;if(s>=i[l-1])return a[l-1].evaluate(t);const u=Ds(i,s),f=li.interpolationFactor(this.interpolation,s,i[u],i[u+1]),_=a[u].evaluate(t),y=a[u+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return tn(_,y,f);case"color":return Kt.interpolate(_,y,f);case"padding":return pi.interpolate(_,y,f);case"colorArray":return Je.interpolate(_,y,f);case"numberArray":return fi.interpolate(_,y,f);case"variableAnchorOffsetCollection":return Ti.interpolate(_,y,f);case"array":return Mn(_,y,f);case"projectionDefinition":return mi.interpolate(_,y,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return Kt.interpolate(_,y,f,"hcl");case"colorArray":return Je.interpolate(_,y,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Kt.interpolate(_,y,f,"lab");case"colorArray":return Je.interpolate(_,y,f,"lab")}}}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function We(r,t,i,a){const s=a-i,l=r-i;return s===0?0:t===1?l/s:(Math.pow(t,l)-1)/(Math.pow(t,s)-1)}const ar={color:Kt.interpolate,number:tn,padding:pi.interpolate,numberArray:fi.interpolate,colorArray:Je.interpolate,variableAnchorOffsetCollection:Ti.interpolate,array:Mn};class ua{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let a=null;const s=i.expectedType;s&&s.kind!=="value"&&(a=s);const l=[];for(const f of t.slice(1)){const _=i.parse(f,1+l.length,a,void 0,{typeAnnotation:"omit"});if(!_)return null;a=a||_.type,l.push(_)}if(!a)throw new Error("No output type");const u=s&&l.some(f=>yr(s,f.type));return new ua(u?Gt:a,l)}evaluate(t){let i,a=null,s=0;for(const l of this.args)if(s++,a=l.evaluate(t),a&&a instanceof zi&&!a.available&&(i||(i=a.name),a=null,s===this.args.length&&(a=i)),a!==null)break;return a}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function Oo(r,t){return r==="=="||r==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function uc(r,t,i,a){return a.compare(t,i)===0}function sr(r,t,i){const a=r!=="=="&&r!=="!=";return class hf{constructor(l,u,f){this.type=Ut,this.lhs=l,this.rhs=u,this.collator=f,this.hasUntypedArgument=l.type.kind==="value"||u.type.kind==="value"}static parse(l,u){if(l.length!==3&&l.length!==4)return u.error("Expected two or three arguments.");const f=l[0];let _=u.parse(l[1],1,Gt);if(!_)return null;if(!Oo(f,_.type))return u.concat(1).error(`"${f}" comparisons are not supported for type '${me(_.type)}'.`);let y=u.parse(l[2],2,Gt);if(!y)return null;if(!Oo(f,y.type))return u.concat(2).error(`"${f}" comparisons are not supported for type '${me(y.type)}'.`);if(_.type.kind!==y.type.kind&&_.type.kind!=="value"&&y.type.kind!=="value")return u.error(`Cannot compare types '${me(_.type)}' and '${me(y.type)}'.`);a&&(_.type.kind==="value"&&y.type.kind!=="value"?_=new ki(y.type,[_]):_.type.kind!=="value"&&y.type.kind==="value"&&(y=new ki(_.type,[y])));let v=null;if(l.length===4){if(_.type.kind!=="string"&&y.type.kind!=="string"&&_.type.kind!=="value"&&y.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(v=u.parse(l[3],3,Er),!v)return null}return new hf(_,y,v)}evaluate(l){const u=this.lhs.evaluate(l),f=this.rhs.evaluate(l);if(a&&this.hasUntypedArgument){const _=ve(u),y=ve(f);if(_.kind!==y.kind||_.kind!=="string"&&_.kind!=="number")throw new _e(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${_.kind}, ${y.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){const _=ve(u),y=ve(f);if(_.kind!=="string"||y.kind!=="string")return t(l,u,f)}return this.collator?i(l,u,f,this.collator.evaluate(l)):t(l,u,f)}eachChild(l){l(this.lhs),l(this.rhs),this.collator&&l(this.collator)}outputDefined(){return!0}}}const ks=sr("==",function(r,t,i){return t===i},uc),jo=sr("!=",function(r,t,i){return t!==i},function(r,t,i,a){return!uc(0,t,i,a)}),Bu=sr("<",function(r,t,i){return t<i},function(r,t,i,a){return a.compare(t,i)<0}),hc=sr(">",function(r,t,i){return t>i},function(r,t,i,a){return a.compare(t,i)>0}),Rs=sr("<=",function(r,t,i){return t<=i},function(r,t,i,a){return a.compare(t,i)<=0}),Ls=sr(">=",function(r,t,i){return t>=i},function(r,t,i,a){return a.compare(t,i)>=0});class Ri{constructor(t,i,a){this.type=Er,this.locale=a,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");const a=t[1];if(typeof a!="object"||Array.isArray(a))return i.error("Collator options argument must be an object.");const s=i.parse(a["case-sensitive"]!==void 0&&a["case-sensitive"],1,Ut);if(!s)return null;const l=i.parse(a["diacritic-sensitive"]!==void 0&&a["diacritic-sensitive"],1,Ut);if(!l)return null;let u=null;return a.locale&&(u=i.parse(a.locale,1,Lt),!u)?null:new Ri(s,l,u)}evaluate(t){return new $i(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 Fs{constructor(t,i,a,s,l){this.type=Lt,this.number=t,this.locale=i,this.currency=a,this.minFractionDigits=s,this.maxFractionDigits=l}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");const a=i.parse(t[1],1,Tt);if(!a)return null;const s=t[2];if(typeof s!="object"||Array.isArray(s))return i.error("NumberFormat options argument must be an object.");let l=null;if(s.locale&&(l=i.parse(s.locale,1,Lt),!l))return null;let u=null;if(s.currency&&(u=i.parse(s.currency,1,Lt),!u))return null;let f=null;if(s["min-fraction-digits"]&&(f=i.parse(s["min-fraction-digits"],1,Tt),!f))return null;let _=null;return s["max-fraction-digits"]&&(_=i.parse(s["max-fraction-digits"],1,Tt),!_)?null:new Fs(a,l,u,f,_)}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 En{constructor(t){this.type=ta,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const a=t[1];if(!Array.isArray(a)&&typeof a=="object")return i.error("First argument must be an image or text section.");const s=[];let l=!1;for(let u=1;u<=t.length-1;++u){const f=t[u];if(l&&typeof f=="object"&&!Array.isArray(f)){l=!1;let _=null;if(f["font-scale"]&&(_=i.parse(f["font-scale"],1,Tt),!_))return null;let y=null;if(f["text-font"]&&(y=i.parse(f["text-font"],1,ji(Lt)),!y))return null;let v=null;if(f["text-color"]&&(v=i.parse(f["text-color"],1,Di),!v))return null;let w=null;if(f["vertical-align"]){if(typeof f["vertical-align"]=="string"&&!te.includes(f["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${f["vertical-align"]}' instead.`);if(w=i.parse(f["vertical-align"],1,Lt),!w)return null}const S=s[s.length-1];S.scale=_,S.font=y,S.textColor=v,S.verticalAlign=w}else{const _=i.parse(t[u],1,Gt);if(!_)return null;const y=_.type.kind;if(y!=="string"&&y!=="value"&&y!=="null"&&y!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");l=!0,s.push({content:_,scale:null,font:null,textColor:null,verticalAlign:null})}}return new En(s)}evaluate(t){return new qe(this.sections.map(i=>{const a=i.content.evaluate(t);return ve(a)===ia?new en("",a,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new en(sa(a),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}}class Vo{constructor(t){this.type=ia,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");const a=i.parse(t[1],1,Lt);return a?new Vo(a):i.error("No image name provided.")}evaluate(t){const i=this.input.evaluate(t),a=zi.fromString(i);return a&&t.availableImages&&(a.available=t.availableImages.indexOf(i)>-1),a}eachChild(t){t(this.input)}outputDefined(){return!1}}class Ua{constructor(t){this.type=Tt,this.input=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const a=i.parse(t[1],1);return a?a.type.kind!=="array"&&a.type.kind!=="string"&&a.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${me(a.type)} instead.`):new Ua(a):null}evaluate(t){const i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new _e(`Expected value to be of type string or array, but found ${me(ve(i))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const wr=8192;function Ou(r,t){const i=(180+r[0])/360,a=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,s=Math.pow(2,t.z);return[Math.round(i*s*wr),Math.round(a*s*wr)]}function No(r,t){const i=Math.pow(2,t.z);return[(s=(r[0]/wr+t.x)/i,360*s-180),(a=(r[1]/wr+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90)];var a,s}function Ga(r,t){r[0]=Math.min(r[0],t[0]),r[1]=Math.min(r[1],t[1]),r[2]=Math.max(r[2],t[0]),r[3]=Math.max(r[3],t[1])}function an(r,t){return!(r[0]<=t[0]||r[2]>=t[2]||r[1]<=t[1]||r[3]>=t[3])}function ju(r,t,i){const a=r[0]-t[0],s=r[1]-t[1],l=r[0]-i[0],u=r[1]-i[1];return a*u-l*s==0&&a*l<=0&&s*u<=0}function Za(r,t,i,a){return(s=[a[0]-i[0],a[1]-i[1]])[0]*(l=[t[0]-r[0],t[1]-r[1]])[1]-s[1]*l[0]!=0&&!(!mc(r,t,i,a)||!mc(i,a,r,t));var s,l}function dc(r,t,i){for(const a of i)for(let s=0;s<a.length-1;++s)if(Za(r,t,a[s],a[s+1]))return!0;return!1}function ha(r,t,i=!1){let a=!1;for(const f of t)for(let _=0;_<f.length-1;_++){if(ju(r,f[_],f[_+1]))return i;(l=f[_])[1]>(s=r)[1]!=(u=f[_+1])[1]>s[1]&&s[0]<(u[0]-l[0])*(s[1]-l[1])/(u[1]-l[1])+l[0]&&(a=!a)}var s,l,u;return a}function pc(r,t){for(const i of t)if(ha(r,i))return!0;return!1}function fc(r,t){for(const i of r)if(!ha(i,t))return!1;for(let i=0;i<r.length-1;++i)if(dc(r[i],r[i+1],t))return!1;return!0}function Vu(r,t){for(const i of t)if(fc(r,i))return!0;return!1}function mc(r,t,i,a){const s=a[0]-i[0],l=a[1]-i[1],u=(r[0]-i[0])*l-s*(r[1]-i[1]),f=(t[0]-i[0])*l-s*(t[1]-i[1]);return u>0&&f<0||u<0&&f>0}function Uo(r,t,i){const a=[];for(let s=0;s<r.length;s++){const l=[];for(let u=0;u<r[s].length;u++){const f=Ou(r[s][u],i);Ga(t,f),l.push(f)}a.push(l)}return a}function _c(r,t,i){const a=[];for(let s=0;s<r.length;s++){const l=Uo(r[s],t,i);a.push(l)}return a}function Go(r,t,i,a){if(r[0]<i[0]||r[0]>i[2]){const s=.5*a;let l=r[0]-i[0]>s?-a:i[0]-r[0]>s?a:0;l===0&&(l=r[0]-i[2]>s?-a:i[2]-r[0]>s?a:0),r[0]+=l}Ga(t,r)}function Zo(r,t,i,a){const s=Math.pow(2,a.z)*wr,l=[a.x*wr,a.y*wr],u=[];for(const f of r)for(const _ of f){const y=[_.x+l[0],_.y+l[1]];Go(y,t,i,s),u.push(y)}return u}function $o(r,t,i,a){const s=Math.pow(2,a.z)*wr,l=[a.x*wr,a.y*wr],u=[];for(const _ of r){const y=[];for(const v of _){const w=[v.x+l[0],v.y+l[1]];Ga(t,w),y.push(w)}u.push(y)}if(t[2]-t[0]<=s/2){(f=t)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const _ of u)for(const y of _)Go(y,t,i,s)}var f;return u}class Cn{constructor(t,i){this.type=Ut,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rn(t[1])){const a=t[1];if(a.type==="FeatureCollection"){const s=[];for(const l of a.features){const{type:u,coordinates:f}=l.geometry;u==="Polygon"&&s.push(f),u==="MultiPolygon"&&s.push(...f)}if(s.length)return new Cn(a,{type:"MultiPolygon",coordinates:s})}else if(a.type==="Feature"){const s=a.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new Cn(a,a.geometry)}else if(a.type==="Polygon"||a.type==="MultiPolygon")return new Cn(a,a)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(i,a){const s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(a.type==="Polygon"){const f=Uo(a.coordinates,l,u),_=Zo(i.geometry(),s,l,u);if(!an(s,l))return!1;for(const y of _)if(!ha(y,f))return!1}if(a.type==="MultiPolygon"){const f=_c(a.coordinates,l,u),_=Zo(i.geometry(),s,l,u);if(!an(s,l))return!1;for(const y of _)if(!pc(y,f))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,a){const s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(a.type==="Polygon"){const f=Uo(a.coordinates,l,u),_=$o(i.geometry(),s,l,u);if(!an(s,l))return!1;for(const y of _)if(!fc(y,f))return!1}if(a.type==="MultiPolygon"){const f=_c(a.coordinates,l,u),_=$o(i.geometry(),s,l,u);if(!an(s,l))return!1;for(const y of _)if(!Vu(y,f))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let gc=class{constructor(r=[],t=(i,a)=>i<a?-1:i>a?1:0){if(this.data=r,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:t,compare:i}=this,a=t[r];for(;r>0;){const s=r-1>>1,l=t[s];if(i(a,l)>=0)break;t[r]=l,r=s}t[r]=a}_down(r){const{data:t,compare:i}=this,a=this.length>>1,s=t[r];for(;r<a;){let l=1+(r<<1);const u=l+1;if(u<this.length&&i(t[u],t[l])<0&&(l=u),i(t[l],s)>=0)break;t[r]=t[l],r=l}t[r]=s}};function yc(r,t,i=0,a=r.length-1,s=Bs){for(;a>i;){if(a-i>600){const _=a-i+1,y=t-i+1,v=Math.log(_),w=.5*Math.exp(2*v/3),S=.5*Math.sqrt(v*w*(_-w)/_)*(y-_/2<0?-1:1);yc(r,t,Math.max(i,Math.floor(t-y*w/_+S)),Math.min(a,Math.floor(t+(_-y)*w/_+S)),s)}const l=r[t];let u=i,f=a;for($a(r,i,t),s(r[a],l)>0&&$a(r,i,a);u<f;){for($a(r,u,f),u++,f--;s(r[u],l)<0;)u++;for(;s(r[f],l)>0;)f--}s(r[i],l)===0?$a(r,i,f):(f++,$a(r,f,a)),f<=t&&(i=f+1),t<=f&&(a=f-1)}}function $a(r,t,i){const a=r[t];r[t]=r[i],r[i]=a}function Bs(r,t){return r<t?-1:r>t?1:0}function qa(r,t){if(r.length<=1)return[r];const i=[];let a,s;for(const l of r){const u=Uu(l);u!==0&&(l.area=Math.abs(u),s===void 0&&(s=u<0),s===u<0?(a&&i.push(a),a=[l]):a.push(l))}if(a&&i.push(a),t>1)for(let l=0;l<i.length;l++)i[l].length<=t||(yc(i[l],t,1,i[l].length-1,Nu),i[l]=i[l].slice(0,t));return i}function Nu(r,t){return t.area-r.area}function Uu(r){let t=0;for(let i,a,s=0,l=r.length,u=l-1;s<l;u=s++)i=r[s],a=r[u],t+=(a.x-i.x)*(i.y+a.y);return t}const xc=1/298.257223563,Os=xc*(2-xc),qo=Math.PI/180;class Wo{constructor(t){const i=6378.137*qo*1e3,a=Math.cos(t*qo),s=1/(1-Os*(1-a*a)),l=Math.sqrt(s);this.kx=i*l*a,this.ky=i*l*s*(1-Os)}distance(t,i){const a=this.wrap(t[0]-i[0])*this.kx,s=(t[1]-i[1])*this.ky;return Math.sqrt(a*a+s*s)}pointOnLine(t,i){let a,s,l,u,f=1/0;for(let _=0;_<t.length-1;_++){let y=t[_][0],v=t[_][1],w=this.wrap(t[_+1][0]-y)*this.kx,S=(t[_+1][1]-v)*this.ky,P=0;w===0&&S===0||(P=(this.wrap(i[0]-y)*this.kx*w+(i[1]-v)*this.ky*S)/(w*w+S*S),P>1?(y=t[_+1][0],v=t[_+1][1]):P>0&&(y+=w/this.kx*P,v+=S/this.ky*P)),w=this.wrap(i[0]-y)*this.kx,S=(i[1]-v)*this.ky;const M=w*w+S*S;M<f&&(f=M,a=y,s=v,l=_,u=P)}return{point:[a,s],index:l,t:Math.max(0,Math.min(1,u))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function vc(r,t){return t[0]-r[0]}function Wa(r){return r[1]-r[0]+1}function Tr(r,t){return r[1]>=r[0]&&r[1]<t}function Ho(r,t){if(r[0]>r[1])return[null,null];const i=Wa(r);if(t){if(i===2)return[r,null];const s=Math.floor(i/2);return[[r[0],r[0]+s],[r[0]+s,r[1]]]}if(i===1)return[r,null];const a=Math.floor(i/2)-1;return[[r[0],r[0]+a],[r[0]+a+1,r[1]]]}function Xo(r,t){if(!Tr(t,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let a=t[0];a<=t[1];++a)Ga(i,r[a]);return i}function Yo(r){const t=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const a of i)Ga(t,a);return t}function Ko(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function Jo(r,t,i){if(!Ko(r)||!Ko(t))return NaN;let a=0,s=0;return r[2]<t[0]&&(a=t[0]-r[2]),r[0]>t[2]&&(a=r[0]-t[2]),r[1]>t[3]&&(s=r[1]-t[3]),r[3]<t[1]&&(s=t[1]-r[3]),i.distance([0,0],[a,s])}function An(r,t,i){const a=i.pointOnLine(t,r);return i.distance(r,a.point)}function Qo(r,t,i,a,s){const l=Math.min(An(r,[i,a],s),An(t,[i,a],s)),u=Math.min(An(i,[r,t],s),An(a,[r,t],s));return Math.min(l,u)}function Gu(r,t,i,a,s){if(!Tr(t,r.length)||!Tr(a,i.length))return 1/0;let l=1/0;for(let u=t[0];u<t[1];++u){const f=r[u],_=r[u+1];for(let y=a[0];y<a[1];++y){const v=i[y],w=i[y+1];if(Za(f,_,v,w))return 0;l=Math.min(l,Qo(f,_,v,w,s))}}return l}function ae(r,t,i,a,s){if(!Tr(t,r.length)||!Tr(a,i.length))return NaN;let l=1/0;for(let u=t[0];u<=t[1];++u)for(let f=a[0];f<=a[1];++f)if(l=Math.min(l,s.distance(r[u],i[f])),l===0)return l;return l}function Zu(r,t,i){if(ha(r,t,!0))return 0;let a=1/0;for(const s of t){const l=s[0],u=s[s.length-1];if(l!==u&&(a=Math.min(a,An(r,[u,l],i)),a===0))return a;const f=i.pointOnLine(s,r);if(a=Math.min(a,i.distance(r,f.point)),a===0)return a}return a}function $u(r,t,i,a){if(!Tr(t,r.length))return NaN;for(let l=t[0];l<=t[1];++l)if(ha(r[l],i,!0))return 0;let s=1/0;for(let l=t[0];l<t[1];++l){const u=r[l],f=r[l+1];for(const _ of i)for(let y=0,v=_.length,w=v-1;y<v;w=y++){const S=_[w],P=_[y];if(Za(u,f,S,P))return 0;s=Math.min(s,Qo(u,f,S,P,a))}}return s}function bc(r,t){for(const i of r)for(const a of i)if(ha(a,t,!0))return!0;return!1}function qu(r,t,i,a=1/0){const s=Yo(r),l=Yo(t);if(a!==1/0&&Jo(s,l,i)>=a)return a;if(an(s,l)){if(bc(r,t))return 0}else if(bc(t,r))return 0;let u=1/0;for(const f of r)for(let _=0,y=f.length,v=y-1;_<y;v=_++){const w=f[v],S=f[_];for(const P of t)for(let M=0,C=P.length,z=C-1;M<C;z=M++){const F=P[z],Z=P[M];if(Za(w,S,F,Z))return 0;u=Math.min(u,Qo(w,S,F,Z,i))}}return u}function wc(r,t,i,a,s,l){if(!l)return;const u=Jo(Xo(a,l),s,i);u<t&&r.push([u,l,[0,0]])}function js(r,t,i,a,s,l,u){if(!l||!u)return;const f=Jo(Xo(a,l),Xo(s,u),i);f<t&&r.push([f,l,u])}function Vs(r,t,i,a,s=1/0){let l=Math.min(a.distance(r[0],i[0][0]),s);if(l===0)return l;const u=new gc([[0,[0,r.length-1],[0,0]]],vc),f=Yo(i);for(;u.length>0;){const _=u.pop();if(_[0]>=l)continue;const y=_[1],v=t?50:100;if(Wa(y)<=v){if(!Tr(y,r.length))return NaN;if(t){const w=$u(r,y,i,a);if(isNaN(w)||w===0)return w;l=Math.min(l,w)}else for(let w=y[0];w<=y[1];++w){const S=Zu(r[w],i,a);if(l=Math.min(l,S),l===0)return 0}}else{const w=Ho(y,t);wc(u,l,a,r,f,w[0]),wc(u,l,a,r,f,w[1])}}return l}function Ns(r,t,i,a,s,l=1/0){let u=Math.min(l,s.distance(r[0],i[0]));if(u===0)return u;const f=new gc([[0,[0,r.length-1],[0,i.length-1]]],vc);for(;f.length>0;){const _=f.pop();if(_[0]>=u)continue;const y=_[1],v=_[2],w=t?50:100,S=a?50:100;if(Wa(y)<=w&&Wa(v)<=S){if(!Tr(y,r.length)&&Tr(v,i.length))return NaN;let P;if(t&&a)P=Gu(r,y,i,v,s),u=Math.min(u,P);else if(t&&!a){const M=r.slice(y[0],y[1]+1);for(let C=v[0];C<=v[1];++C)if(P=An(i[C],M,s),u=Math.min(u,P),u===0)return u}else if(!t&&a){const M=i.slice(v[0],v[1]+1);for(let C=y[0];C<=y[1];++C)if(P=An(r[C],M,s),u=Math.min(u,P),u===0)return u}else P=ae(r,y,i,v,s),u=Math.min(u,P)}else{const P=Ho(y,t),M=Ho(v,a);js(f,u,s,r,i,P[0],M[0]),js(f,u,s,r,i,P[0],M[1]),js(f,u,s,r,i,P[1],M[0]),js(f,u,s,r,i,P[1],M[1])}}return u}function tl(r){return r.type==="MultiPolygon"?r.coordinates.map(t=>({type:"Polygon",coordinates:t})):r.type==="MultiLineString"?r.coordinates.map(t=>({type:"LineString",coordinates:t})):r.type==="MultiPoint"?r.coordinates.map(t=>({type:"Point",coordinates:t})):[r]}class Dn{constructor(t,i){this.type=Tt,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(rn(t[1])){const a=t[1];if(a.type==="FeatureCollection")return new Dn(a,a.features.map(s=>tl(s.geometry)).flat());if(a.type==="Feature")return new Dn(a,tl(a.geometry));if("type"in a&&"coordinates"in a)return new Dn(a,tl(a))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(i,a){const s=i.geometry(),l=s.flat().map(_=>No([_.x,_.y],i.canonical));if(s.length===0)return NaN;const u=new Wo(l[0][1]);let f=1/0;for(const _ of a){switch(_.type){case"Point":f=Math.min(f,Ns(l,!1,[_.coordinates],!1,u,f));break;case"LineString":f=Math.min(f,Ns(l,!1,_.coordinates,!0,u,f));break;case"Polygon":f=Math.min(f,Vs(l,!1,_.coordinates,u,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,a){const s=i.geometry(),l=s.flat().map(_=>No([_.x,_.y],i.canonical));if(s.length===0)return NaN;const u=new Wo(l[0][1]);let f=1/0;for(const _ of a){switch(_.type){case"Point":f=Math.min(f,Ns(l,!0,[_.coordinates],!1,u,f));break;case"LineString":f=Math.min(f,Ns(l,!0,_.coordinates,!0,u,f));break;case"Polygon":f=Math.min(f,Vs(l,!0,_.coordinates,u,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="Polygon")return function(i,a){const s=i.geometry();if(s.length===0||s[0].length===0)return NaN;const l=qa(s,0).map(_=>_.map(y=>y.map(v=>No([v.x,v.y],i.canonical)))),u=new Wo(l[0][0][0][1]);let f=1/0;for(const _ of a)for(const y of l){switch(_.type){case"Point":f=Math.min(f,Vs([_.coordinates],!1,y,u,f));break;case"LineString":f=Math.min(f,Vs(_.coordinates,!0,y,u,f));break;case"Polygon":f=Math.min(f,qu(y,_.coordinates,u,f))}if(f===0)return f}return f}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Ha{constructor(t){this.type=Gt,this.key=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const a=t[1];return a==null?i.error("Global state property must be defined."):typeof a!="string"?i.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Ha(a)}evaluate(t){var i;const a=(i=t.globals)===null||i===void 0?void 0:i.globalState;return a&&Object.keys(a).length!==0?Cr(a,this.key):null}eachChild(){}outputDefined(){return!1}}const da={"==":ks,"!=":jo,">":hc,"<":Bu,">=":Ls,"<=":Rs,array:ki,at:nr,boolean:ki,case:Va,coalesce:ua,collator:Ri,format:En,image:Vo,in:ja,"index-of":In,interpolate:li,"interpolate-hcl":li,"interpolate-lab":li,length:Ua,let:ee,literal:nn,match:As,number:ki,"number-format":Fs,object:ki,slice:Na,step:ca,string:ki,"to-boolean":vr,"to-color":vr,"to-number":vr,"to-string":vr,var:la,within:Cn,distance:Dn,"global-state":Ha};class qi{constructor(t,i,a,s){this.name=t,this.type=i,this._evaluate=a,this.args=s}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,i){const a=t[0],s=qi.definitions[a];if(!s)return i.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const l=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,f=u.filter(([y])=>!Array.isArray(y)||y.length===t.length-1);let _=null;for(const[y,v]of f){_=new oa(i.registry,Us,i.path,null,i.scope);const w=[];let S=!1;for(let P=1;P<t.length;P++){const M=t[P],C=Array.isArray(y)?y[P-1]:y.type,z=_.parse(M,1+w.length,C);if(!z){S=!0;break}w.push(z)}if(!S)if(Array.isArray(y)&&y.length!==w.length)_.error(`Expected ${y.length} arguments, but found ${w.length} instead.`);else{for(let P=0;P<w.length;P++){const M=Array.isArray(y)?y[P]:y.type,C=w[P];_.concat(P+1).checkSubtype(M,C.type)}if(_.errors.length===0)return new qi(a,l,v,w)}}if(f.length===1)i.errors.push(..._.errors);else{const y=(f.length?f:u).map(([w])=>{return S=w,Array.isArray(S)?`(${S.map(me).join(", ")})`:`(${me(S.type)}...)`;var S}).join(" | "),v=[];for(let w=1;w<t.length;w++){const S=i.parse(t[w],1+v.length);if(!S)return null;v.push(me(S.type))}i.error(`Expected arguments of type ${y}, but found (${v.join(", ")}) instead.`)}return null}static register(t,i){qi.definitions=i;for(const a in i)t[a]=qi}}function Tc(r,[t,i,a,s]){t=t.evaluate(r),i=i.evaluate(r),a=a.evaluate(r);const l=s?s.evaluate(r):1,u=oc(t,i,a,l);if(u)throw new _e(u);return new Kt(t/255,i/255,a/255,l,!1)}function Sc(r,t){return r in t}function el(r,t){const i=t[r];return i===void 0?null:i}function zn(r){return{type:r}}function Us(r){if(r instanceof la)return Us(r.boundExpression);if(r instanceof qi&&r.name==="error"||r instanceof Ri||r instanceof Cn||r instanceof Dn||r instanceof Ha)return!1;const t=r instanceof vr||r instanceof ki;let i=!0;return r.eachChild(a=>{i=t?i&&Us(a):i&&a instanceof nn}),!!i&&Gs(r)&&Zs(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Gs(r){if(r instanceof qi&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof Cn||r instanceof Dn)return!1;let t=!0;return r.eachChild(i=>{t&&!Gs(i)&&(t=!1)}),t}function Xa(r){if(r instanceof qi&&r.name==="feature-state")return!1;let t=!0;return r.eachChild(i=>{t&&!Xa(i)&&(t=!1)}),t}function Zs(r,t){if(r instanceof qi&&t.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild(a=>{i&&!Zs(a,t)&&(i=!1)}),i}function Pc(r){return{result:"success",value:r}}function pa(r){return{result:"error",value:r}}function fa(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function Mc(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function il(r){return!!r.expression&&r.expression.interpolated}function Jt(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function $s(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&ve(r)===ti}function Wu(r){return r}function Ic(r,t){const i=r.stops&&typeof r.stops[0][0]=="object",a=i||!(i||r.property!==void 0),s=r.type||(il(t)?"exponential":"interval"),l=function(v){switch(v.type){case"color":return Kt.parse;case"padding":return pi.parse;case"numberArray":return fi.parse;case"colorArray":return Je.parse;default:return null}}(t);if(l&&((r=xe({},r)).stops&&(r.stops=r.stops.map(v=>[v[0],l(v[1])])),r.default=l(r.default?r.default:t.default)),r.colorSpace&&(u=r.colorSpace)!=="rgb"&&u!=="hcl"&&u!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var u;const f=function(v){switch(v){case"exponential":return Ec;case"interval":return Hu;case"categorical":return rl;case"identity":return Xu;default:throw new Error(`Unknown function type "${v}"`)}}(s);let _,y;if(s==="categorical"){_=Object.create(null);for(const v of r.stops)_[v[0]]=v[1];y=typeof r.stops[0][0]}if(i){const v={},w=[];for(let M=0;M<r.stops.length;M++){const C=r.stops[M],z=C[0].zoom;v[z]===void 0&&(v[z]={zoom:z,type:r.type,property:r.property,default:r.default,stops:[]},w.push(z)),v[z].stops.push([C[0].value,C[1]])}const S=[];for(const M of w)S.push([v[M].zoom,Ic(v[M],t)]);const P={name:"linear"};return{kind:"composite",interpolationType:P,interpolationFactor:li.interpolationFactor.bind(void 0,P),zoomStops:S.map(M=>M[0]),evaluate:({zoom:M},C)=>Ec({stops:S,base:r.base},t,M).evaluate(M,C)}}if(a){const v=s==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:li.interpolationFactor.bind(void 0,v),zoomStops:r.stops.map(w=>w[0]),evaluate:({zoom:w})=>f(r,t,w,_,y)}}return{kind:"source",evaluate(v,w){const S=w&&w.properties?w.properties[r.property]:void 0;return S===void 0?Ya(r.default,t.default):f(r,t,S,_,y)}}}function Ya(r,t,i){return r!==void 0?r:t!==void 0?t:i!==void 0?i:void 0}function rl(r,t,i,a,s){return Ya(typeof i===s?a[i]:void 0,r.default,t.default)}function Hu(r,t,i){if(Jt(i)!=="number")return Ya(r.default,t.default);const a=r.stops.length;if(a===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[a-1][0])return r.stops[a-1][1];const s=Ds(r.stops.map(l=>l[0]),i);return r.stops[s][1]}function Ec(r,t,i){const a=r.base!==void 0?r.base:1;if(Jt(i)!=="number")return Ya(r.default,t.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const l=Ds(r.stops.map(v=>v[0]),i),u=function(v,w,S,P){const M=P-S,C=v-S;return M===0?0:w===1?C/M:(Math.pow(w,C)-1)/(Math.pow(w,M)-1)}(i,a,r.stops[l][0],r.stops[l+1][0]),f=r.stops[l][1],_=r.stops[l+1][1],y=ar[t.type]||Wu;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),S=_.evaluate.apply(void 0,v);if(w!==void 0&&S!==void 0)return y(w,S,u,r.colorSpace)}}:y(f,_,u,r.colorSpace)}function Xu(r,t,i){switch(t.type){case"color":i=Kt.parse(i);break;case"formatted":i=qe.fromString(i.toString());break;case"resolvedImage":i=zi.fromString(i.toString());break;case"padding":i=pi.parse(i);break;case"colorArray":i=Je.parse(i);break;case"numberArray":i=fi.parse(i);break;default:Jt(i)===t.type||t.type==="enum"&&t.values[i]||(i=void 0)}return Ya(i,r.default,t.default)}qi.register(da,{error:[{kind:"error"},[Lt],(r,[t])=>{throw new _e(t.evaluate(r))}],typeof:[Lt,[Gt],(r,[t])=>me(ve(t.evaluate(r)))],"to-rgba":[ji(Tt,4),[Di],(r,[t])=>{const[i,a,s,l]=t.evaluate(r).rgb;return[255*i,255*a,255*s,l]}],rgb:[Di,[Tt,Tt,Tt],Tc],rgba:[Di,[Tt,Tt,Tt,Tt],Tc],has:{type:Ut,overloads:[[[Lt],(r,[t])=>Sc(t.evaluate(r),r.properties())],[[Lt,ti],(r,[t,i])=>Sc(t.evaluate(r),i.evaluate(r))]]},get:{type:Gt,overloads:[[[Lt],(r,[t])=>el(t.evaluate(r),r.properties())],[[Lt,ti],(r,[t,i])=>el(t.evaluate(r),i.evaluate(r))]]},"feature-state":[Gt,[Lt],(r,[t])=>el(t.evaluate(r),r.featureState||{})],properties:[ti,[],r=>r.properties()],"geometry-type":[Lt,[],r=>r.geometryType()],id:[Gt,[],r=>r.id()],zoom:[Tt,[],r=>r.globals.zoom],"heatmap-density":[Tt,[],r=>r.globals.heatmapDensity||0],elevation:[Tt,[],r=>r.globals.elevation||0],"line-progress":[Tt,[],r=>r.globals.lineProgress||0],accumulated:[Gt,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[Tt,zn(Tt),(r,t)=>{let i=0;for(const a of t)i+=a.evaluate(r);return i}],"*":[Tt,zn(Tt),(r,t)=>{let i=1;for(const a of t)i*=a.evaluate(r);return i}],"-":{type:Tt,overloads:[[[Tt,Tt],(r,[t,i])=>t.evaluate(r)-i.evaluate(r)],[[Tt],(r,[t])=>-t.evaluate(r)]]},"/":[Tt,[Tt,Tt],(r,[t,i])=>t.evaluate(r)/i.evaluate(r)],"%":[Tt,[Tt,Tt],(r,[t,i])=>t.evaluate(r)%i.evaluate(r)],ln2:[Tt,[],()=>Math.LN2],pi:[Tt,[],()=>Math.PI],e:[Tt,[],()=>Math.E],"^":[Tt,[Tt,Tt],(r,[t,i])=>Math.pow(t.evaluate(r),i.evaluate(r))],sqrt:[Tt,[Tt],(r,[t])=>Math.sqrt(t.evaluate(r))],log10:[Tt,[Tt],(r,[t])=>Math.log(t.evaluate(r))/Math.LN10],ln:[Tt,[Tt],(r,[t])=>Math.log(t.evaluate(r))],log2:[Tt,[Tt],(r,[t])=>Math.log(t.evaluate(r))/Math.LN2],sin:[Tt,[Tt],(r,[t])=>Math.sin(t.evaluate(r))],cos:[Tt,[Tt],(r,[t])=>Math.cos(t.evaluate(r))],tan:[Tt,[Tt],(r,[t])=>Math.tan(t.evaluate(r))],asin:[Tt,[Tt],(r,[t])=>Math.asin(t.evaluate(r))],acos:[Tt,[Tt],(r,[t])=>Math.acos(t.evaluate(r))],atan:[Tt,[Tt],(r,[t])=>Math.atan(t.evaluate(r))],min:[Tt,zn(Tt),(r,t)=>Math.min(...t.map(i=>i.evaluate(r)))],max:[Tt,zn(Tt),(r,t)=>Math.max(...t.map(i=>i.evaluate(r)))],abs:[Tt,[Tt],(r,[t])=>Math.abs(t.evaluate(r))],round:[Tt,[Tt],(r,[t])=>{const i=t.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[Tt,[Tt],(r,[t])=>Math.floor(t.evaluate(r))],ceil:[Tt,[Tt],(r,[t])=>Math.ceil(t.evaluate(r))],"filter-==":[Ut,[Lt,Gt],(r,[t,i])=>r.properties()[t.value]===i.value],"filter-id-==":[Ut,[Gt],(r,[t])=>r.id()===t.value],"filter-type-==":[Ut,[Lt],(r,[t])=>r.geometryType()===t.value],"filter-<":[Ut,[Lt,Gt],(r,[t,i])=>{const a=r.properties()[t.value],s=i.value;return typeof a==typeof s&&a<s}],"filter-id-<":[Ut,[Gt],(r,[t])=>{const i=r.id(),a=t.value;return typeof i==typeof a&&i<a}],"filter->":[Ut,[Lt,Gt],(r,[t,i])=>{const a=r.properties()[t.value],s=i.value;return typeof a==typeof s&&a>s}],"filter-id->":[Ut,[Gt],(r,[t])=>{const i=r.id(),a=t.value;return typeof i==typeof a&&i>a}],"filter-<=":[Ut,[Lt,Gt],(r,[t,i])=>{const a=r.properties()[t.value],s=i.value;return typeof a==typeof s&&a<=s}],"filter-id-<=":[Ut,[Gt],(r,[t])=>{const i=r.id(),a=t.value;return typeof i==typeof a&&i<=a}],"filter->=":[Ut,[Lt,Gt],(r,[t,i])=>{const a=r.properties()[t.value],s=i.value;return typeof a==typeof s&&a>=s}],"filter-id->=":[Ut,[Gt],(r,[t])=>{const i=r.id(),a=t.value;return typeof i==typeof a&&i>=a}],"filter-has":[Ut,[Gt],(r,[t])=>t.value in r.properties()],"filter-has-id":[Ut,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Ut,[ji(Lt)],(r,[t])=>t.value.indexOf(r.geometryType())>=0],"filter-id-in":[Ut,[ji(Gt)],(r,[t])=>t.value.indexOf(r.id())>=0],"filter-in-small":[Ut,[Lt,ji(Gt)],(r,[t,i])=>i.value.indexOf(r.properties()[t.value])>=0],"filter-in-large":[Ut,[Lt,ji(Gt)],(r,[t,i])=>function(a,s,l,u){for(;l<=u;){const f=l+u>>1;if(s[f]===a)return!0;s[f]>a?u=f-1:l=f+1}return!1}(r.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Ut,overloads:[[[Ut,Ut],(r,[t,i])=>t.evaluate(r)&&i.evaluate(r)],[zn(Ut),(r,t)=>{for(const i of t)if(!i.evaluate(r))return!1;return!0}]]},any:{type:Ut,overloads:[[[Ut,Ut],(r,[t,i])=>t.evaluate(r)||i.evaluate(r)],[zn(Ut),(r,t)=>{for(const i of t)if(i.evaluate(r))return!0;return!1}]]},"!":[Ut,[Ut],(r,[t])=>!t.evaluate(r)],"is-supported-script":[Ut,[Lt],(r,[t])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(t.evaluate(r))}],upcase:[Lt,[Lt],(r,[t])=>t.evaluate(r).toUpperCase()],downcase:[Lt,[Lt],(r,[t])=>t.evaluate(r).toLowerCase()],concat:[Lt,zn(Gt),(r,t)=>t.map(i=>sa(i.evaluate(r))).join("")],"resolved-locale":[Lt,[Er],(r,[t])=>t.evaluate(r).resolvedLocale()]});class qs{constructor(t,i,a){this.expression=t,this._warningHistory={},this._evaluator=new Ht,this._defaultValue=i?function(s){if(s.type==="color"&&$s(s.default))return new Kt(0,0,0,0);switch(s.type){case"color":return Kt.parse(s.default)||null;case"padding":return pi.parse(s.default)||null;case"numberArray":return fi.parse(s.default)||null;case"colorArray":return Je.parse(s.default)||null;case"variableAnchorOffsetCollection":return Ti.parse(s.default)||null;case"projectionDefinition":return mi.parse(s.default)||null;default:return s.default===void 0?null:s.default}}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=a}evaluateWithoutErrorHandling(t,i,a,s,l,u){return this._globalState&&(t=ma(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=i,this._evaluator.featureState=a,this._evaluator.canonical=s,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u,this.expression.evaluate(this._evaluator)}evaluate(t,i,a,s,l,u){this._globalState&&(t=ma(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=i||null,this._evaluator.featureState=a||null,this._evaluator.canonical=s,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new _e(`Expected value to be one of ${Object.keys(this._enumValues).map(_=>JSON.stringify(_)).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function Ws(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in da}function Hs(r,t,i){const a=new oa(da,Us,[],t?function(l){const u={color:Di,string:Lt,number:Tt,enum:Lt,boolean:Ut,formatted:ta,padding:ea,numberArray:Pn,colorArray:rr,projectionDefinition:Sn,resolvedImage:ia,variableAnchorOffsetCollection:ra};return l.type==="array"?ji(u[l.value]||Gt,l.length):u[l.type]}(t):void 0),s=a.parse(r,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?Pc(new qs(s,t,i)):pa(a.errors)}class kn{constructor(t,i,a){this.kind=t,this._styleExpression=i,this.isStateDependent=t!=="constant"&&!Xa(i.expression),this.globalStateRefs=Js(i.expression),this._globalState=a}evaluateWithoutErrorHandling(t,i,a,s,l,u){return this._globalState&&(t=ma(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,i,a,s,l,u)}evaluate(t,i,a,s,l,u){return this._globalState&&(t=ma(t,this._globalState)),this._styleExpression.evaluate(t,i,a,s,l,u)}}class Xs{constructor(t,i,a,s,l){this.kind=t,this.zoomStops=a,this._styleExpression=i,this.isStateDependent=t!=="camera"&&!Xa(i.expression),this.globalStateRefs=Js(i.expression),this.interpolationType=s,this._globalState=l}evaluateWithoutErrorHandling(t,i,a,s,l,u){return this._globalState&&(t=ma(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,i,a,s,l,u)}evaluate(t,i,a,s,l,u){return this._globalState&&(t=ma(t,this._globalState)),this._styleExpression.evaluate(t,i,a,s,l,u)}interpolationFactor(t,i,a){return this.interpolationType?li.interpolationFactor(this.interpolationType,t,i,a):0}}function Cc(r,t,i){const a=Hs(r,t,i);if(a.result==="error")return a;const s=a.value.expression,l=Gs(s);if(!l&&!fa(t))return pa([new pe("","data expressions not supported")]);const u=Zs(s,["zoom"]);if(!u&&!Mc(t))return pa([new pe("","zoom expressions not supported")]);const f=Ks(s);return f||u?f instanceof pe?pa([f]):f instanceof li&&!il(t)?pa([new pe("",'"interpolate" expressions cannot be used with this property')]):Pc(f?new Xs(l?"camera":"composite",a.value,f.labels,f instanceof li?f.interpolation:void 0,i):new kn(l?"constant":"source",a.value,i)):pa([new pe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Ys{constructor(t,i){this._parameters=t,this._specification=i,xe(this,Ic(this._parameters,this._specification))}static deserialize(t){return new Ys(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Ks(r){let t=null;if(r instanceof ee)t=Ks(r.result);else if(r instanceof ua){for(const i of r.args)if(t=Ks(i),t)break}else(r instanceof ca||r instanceof li)&&r.input instanceof qi&&r.input.name==="zoom"&&(t=r);return t instanceof pe||r.eachChild(i=>{const a=Ks(i);a instanceof pe?t=a:!t&&a?t=new pe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&a&&t!==a&&(t=new pe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Js(r,t=new Set){return r instanceof Ha&&t.add(r.key),r.eachChild(i=>{Js(i,t)}),t}function ma(r,t){const{zoom:i,heatmapDensity:a,elevation:s,lineProgress:l,isSupportedScript:u,accumulated:f}=r??{};return{zoom:i,heatmapDensity:a,elevation:s,lineProgress:l,isSupportedScript:u,accumulated:f,globalState:t}}function Qs(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const t of r.slice(1))if(!Qs(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const Ac={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ka(r,t){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Qs(r)||(r=Ja(r));const i=Hs(r,Ac,t);if(i.result==="error")throw new Error(i.value.map(a=>`${a.key}: ${a.message}`).join(", "));return{filter:(a,s,l)=>i.value.evaluate(a,s,{},l),needGeometry:nl(r),getGlobalStateRefs:()=>Js(i.value.expression)}}function Yu(r,t){return r<t?-1:r>t?1:0}function nl(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let t=1;t<r.length;t++)if(nl(r[t]))return!0;return!1}function Ja(r){if(!r)return!0;const t=r[0];return r.length<=1?t!=="any":t==="=="?to(r[1],r[2],"=="):t==="!="?eo(to(r[1],r[2],"==")):t==="<"||t===">"||t==="<="||t===">="?to(r[1],r[2],t):t==="any"?(i=r.slice(1),["any"].concat(i.map(Ja))):t==="all"?["all"].concat(r.slice(1).map(Ja)):t==="none"?["all"].concat(r.slice(1).map(Ja).map(eo)):t==="in"?Dc(r[1],r.slice(2)):t==="!in"?eo(Dc(r[1],r.slice(2))):t==="has"?zc(r[1]):t!=="!has"||eo(zc(r[1]));var i}function to(r,t,i){switch(r){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,r,t]}}function Dc(r,t){if(t.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(i=>typeof i!=typeof t[0])?["filter-in-large",r,["literal",t.sort(Yu)]]:["filter-in-small",r,["literal",t]]}}function zc(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function eo(r){return["!",r]}function al(r){const t=typeof r;if(t==="number"||t==="boolean"||t==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let s="[";for(const l of r)s+=`${al(l)},`;return`${s}]`}const i=Object.keys(r).sort();let a="{";for(let s=0;s<i.length;s++)a+=`${JSON.stringify(i[s])}:${al(r[i[s]])},`;return`${a}}`}function kc(r){let t="";for(const i of rt)t+=`/${al(r[i])}`;return t}function sl(r){const t=r.value;return t?[new bt(r.key,t,"constants have been deprecated as of v8")]:[]}function Ee(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Ar(r){if(Array.isArray(r))return r.map(Ar);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const t={};for(const i in r)t[i]=Ar(r[i]);return t}return Ee(r)}function Li(r){const t=r.key,i=r.value,a=r.valueSpec||{},s=r.objectElementValidators||{},l=r.style,u=r.styleSpec,f=r.validateSpec;let _=[];const y=Jt(i);if(y!=="object")return[new bt(t,i,`object expected, ${y} found`)];for(const v in i){const w=v.split(".")[0],S=Cr(a,w)||a["*"];let P;if(Cr(s,w))P=s[w];else if(Cr(a,w))P=f;else if(s["*"])P=s["*"];else{if(!a["*"]){_.push(new bt(t,i[v],`unknown property "${v}"`));continue}P=f}_=_.concat(P({key:(t&&`${t}.`)+v,value:i[v],valueSpec:S,style:l,styleSpec:u,object:i,objectKey:v,validateSpec:f},i))}for(const v in a)s[v]||a[v].required&&a[v].default===void 0&&i[v]===void 0&&_.push(new bt(t,i,`missing required property "${v}"`));return _}function Qa(r){const t=r.value,i=r.valueSpec,a=r.style,s=r.styleSpec,l=r.key,u=r.arrayElementValidator||r.validateSpec;if(Jt(t)!=="array")return[new bt(l,t,`array expected, ${Jt(t)} found`)];if(i.length&&t.length!==i.length)return[new bt(l,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new bt(l,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let f={type:i.value,values:i.values};s.$version<7&&(f.function=i.function),Jt(i.value)==="object"&&(f=i.value);let _=[];for(let y=0;y<t.length;y++)_=_.concat(u({array:t,arrayIndex:y,value:t[y],valueSpec:f,validateSpec:r.validateSpec,style:a,styleSpec:s,key:`${l}[${y}]`}));return _}function Rn(r){const t=r.key,i=r.value,a=r.valueSpec;let s=Jt(i);return s==="number"&&i!=i&&(s="NaN"),s!=="number"?[new bt(t,i,`number expected, ${s} found`)]:"minimum"in a&&i<a.minimum?[new bt(t,i,`${i} is less than the minimum value ${a.minimum}`)]:"maximum"in a&&i>a.maximum?[new bt(t,i,`${i} is greater than the maximum value ${a.maximum}`)]:[]}function Rc(r){const t=r.valueSpec,i=Ee(r.value.type);let a,s,l,u={};const f=i!=="categorical"&&r.value.property===void 0,_=!f,y=Jt(r.value.stops)==="array"&&Jt(r.value.stops[0])==="array"&&Jt(r.value.stops[0][0])==="object",v=Li({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(P){if(i==="identity")return[new bt(P.key,P.value,'identity function may not have a "stops" property')];let M=[];const C=P.value;return M=M.concat(Qa({key:P.key,value:C,valueSpec:P.valueSpec,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec,arrayElementValidator:w})),Jt(C)==="array"&&C.length===0&&M.push(new bt(P.key,C,"array must have at least one stop")),M},default:function(P){return P.validateSpec({key:P.key,value:P.value,valueSpec:t,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec})}}});return i==="identity"&&f&&v.push(new bt(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||v.push(new bt(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!il(r.valueSpec)&&v.push(new bt(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(_&&!fa(r.valueSpec)?v.push(new bt(r.key,r.value,"property functions not supported")):f&&!Mc(r.valueSpec)&&v.push(new bt(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!y||r.value.property!==void 0||v.push(new bt(r.key,r.value,'"property" property is required')),v;function w(P){let M=[];const C=P.value,z=P.key;if(Jt(C)!=="array")return[new bt(z,C,`array expected, ${Jt(C)} found`)];if(C.length!==2)return[new bt(z,C,`array length 2 expected, length ${C.length} found`)];if(y){if(Jt(C[0])!=="object")return[new bt(z,C,`object expected, ${Jt(C[0])} found`)];if(C[0].zoom===void 0)return[new bt(z,C,"object stop key must have zoom")];if(C[0].value===void 0)return[new bt(z,C,"object stop key must have value")];if(l&&l>Ee(C[0].zoom))return[new bt(z,C[0].zoom,"stop zoom values must appear in ascending order")];Ee(C[0].zoom)!==l&&(l=Ee(C[0].zoom),s=void 0,u={}),M=M.concat(Li({key:`${z}[0]`,value:C[0],valueSpec:{zoom:{}},validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec,objectElementValidators:{zoom:Rn,value:S}}))}else M=M.concat(S({key:`${z}[0]`,value:C[0],validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec},C));return Ws(Ar(C[1]))?M.concat([new bt(`${z}[1]`,C[1],"expressions are not allowed in function stops.")]):M.concat(P.validateSpec({key:`${z}[1]`,value:C[1],valueSpec:t,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec}))}function S(P,M){const C=Jt(P.value),z=Ee(P.value),F=P.value!==null?P.value:M;if(a){if(C!==a)return[new bt(P.key,F,`${C} stop domain type must match previous stop domain type ${a}`)]}else a=C;if(C!=="number"&&C!=="string"&&C!=="boolean")return[new bt(P.key,F,"stop domain value must be a number, string, or boolean")];if(C!=="number"&&i!=="categorical"){let Z=`number expected, ${C} found`;return fa(t)&&i===void 0&&(Z+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new bt(P.key,F,Z)]}return i!=="categorical"||C!=="number"||isFinite(z)&&Math.floor(z)===z?i!=="categorical"&&C==="number"&&s!==void 0&&z<s?[new bt(P.key,F,"stop domain values must appear in ascending order")]:(s=z,i==="categorical"&&z in u?[new bt(P.key,F,"stop domain values must be unique")]:(u[z]=!0,[])):[new bt(P.key,F,`integer expected, found ${z}`)]}}function _a(r){const t=(r.expressionContext==="property"?Cc:Hs)(Ar(r.value),r.valueSpec);if(t.result==="error")return t.value.map(a=>new bt(`${r.key}${a.key}`,r.value,a.message));const i=t.value.expression||t.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new bt(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!Xa(i))return[new bt(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!Xa(i))return[new bt(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Zs(i,["zoom","feature-state"]))return[new bt(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!Gs(i))return[new bt(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ol(r){const t=r.key,i=r.value,a=Jt(i);return a!=="string"?[new bt(t,i,`color expected, ${a} found`)]:Kt.parse(String(i))?[]:[new bt(t,i,`color expected, "${i}" found`)]}function ts(r){const t=r.key,i=r.value,a=r.valueSpec,s=[];return Array.isArray(a.values)?a.values.indexOf(Ee(i))===-1&&s.push(new bt(t,i,`expected one of [${a.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(a.values).indexOf(Ee(i))===-1&&s.push(new bt(t,i,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function ll(r){return Qs(Ar(r.value))?_a(xe({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Lc(r)}function Lc(r){const t=r.value,i=r.key;if(Jt(t)!=="array")return[new bt(i,t,`array expected, ${Jt(t)} found`)];const a=r.styleSpec;let s,l=[];if(t.length<1)return[new bt(i,t,"filter array must have at least 1 element")];switch(l=l.concat(ts({key:`${i}[0]`,value:t[0],valueSpec:a.filter_operator,style:r.style,styleSpec:r.styleSpec})),Ee(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&Ee(t[1])==="$type"&&l.push(new bt(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&l.push(new bt(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(s=Jt(t[1]),s!=="string"&&l.push(new bt(`${i}[1]`,t[1],`string expected, ${s} found`)));for(let u=2;u<t.length;u++)s=Jt(t[u]),Ee(t[1])==="$type"?l=l.concat(ts({key:`${i}[${u}]`,value:t[u],valueSpec:a.geometry_type,style:r.style,styleSpec:r.styleSpec})):s!=="string"&&s!=="number"&&s!=="boolean"&&l.push(new bt(`${i}[${u}]`,t[u],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let u=1;u<t.length;u++)l=l.concat(Lc({key:`${i}[${u}]`,value:t[u],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":s=Jt(t[1]),t.length!==2?l.push(new bt(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):s!=="string"&&l.push(new bt(`${i}[1]`,t[1],`string expected, ${s} found`))}return l}function cl(r,t){const i=r.key,a=r.validateSpec,s=r.style,l=r.styleSpec,u=r.value,f=r.objectKey,_=l[`${t}_${r.layerType}`];if(!_)return[];const y=f.match(/^(.*)-transition$/);if(t==="paint"&&y&&_[y[1]]&&_[y[1]].transition)return a({key:i,value:u,valueSpec:l.transition,style:s,styleSpec:l});const v=r.valueSpec||_[f];if(!v)return[new bt(i,u,`unknown property "${f}"`)];let w;if(Jt(u)==="string"&&fa(v)&&!v.tokens&&(w=/^{([^}]+)}$/.exec(u)))return[new bt(i,u,`"${f}" does not support interpolation syntax
|
||
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];const S=[];return r.layerType==="symbol"&&f==="text-font"&&$s(Ar(u))&&Ee(u.type)==="identity"&&S.push(new bt(i,u,'"text-font" does not support identity functions')),S.concat(a({key:r.key,value:u,valueSpec:v,style:s,styleSpec:l,expressionContext:"property",propertyType:t,propertyKey:f}))}function ul(r){return cl(r,"paint")}function es(r){return cl(r,"layout")}function Fc(r){let t=[];const i=r.value,a=r.key,s=r.style,l=r.styleSpec;if(Jt(i)!=="object")return[new bt(a,i,`object expected, ${Jt(i)} found`)];i.type||i.ref||t.push(new bt(a,i,'either "type" or "ref" is required'));let u=Ee(i.type);const f=Ee(i.ref);if(i.id){const _=Ee(i.id);for(let y=0;y<r.arrayIndex;y++){const v=s.layers[y];Ee(v.id)===_&&t.push(new bt(a,i.id,`duplicate layer id "${i.id}", previously used at line ${v.id.__line__}`))}}if("ref"in i){let _;["type","source","source-layer","filter","layout"].forEach(y=>{y in i&&t.push(new bt(a,i[y],`"${y}" is prohibited for ref layers`))}),s.layers.forEach(y=>{Ee(y.id)===f&&(_=y)}),_?_.ref?t.push(new bt(a,i.ref,"ref cannot reference another ref layer")):u=Ee(_.type):t.push(new bt(a,i.ref,`ref layer "${f}" not found`))}else if(u!=="background")if(i.source){const _=s.sources&&s.sources[i.source],y=_&&Ee(_.type);_?y==="vector"&&u==="raster"?t.push(new bt(a,i.source,`layer "${i.id}" requires a raster source`)):y!=="raster-dem"&&u==="hillshade"||y!=="raster-dem"&&u==="color-relief"?t.push(new bt(a,i.source,`layer "${i.id}" requires a raster-dem source`)):y==="raster"&&u!=="raster"?t.push(new bt(a,i.source,`layer "${i.id}" requires a vector source`)):y!=="vector"||i["source-layer"]?y==="raster-dem"&&u!=="hillshade"&&u!=="color-relief"?t.push(new bt(a,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):u!=="line"||!i.paint||!i.paint["line-gradient"]||y==="geojson"&&_.lineMetrics||t.push(new bt(a,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new bt(a,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new bt(a,i.source,`source "${i.source}" not found`))}else t.push(new bt(a,i,'missing required property "source"'));return t=t.concat(Li({key:a,value:i,valueSpec:l.layer,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,objectElementValidators:{"*":()=>[],type:()=>r.validateSpec({key:`${a}.type`,value:i.type,valueSpec:l.layer.type,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,object:i,objectKey:"type"}),filter:ll,layout:_=>Li({layer:i,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":y=>es(xe({layerType:u},y))}}),paint:_=>Li({layer:i,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":y=>ul(xe({layerType:u},y))}})}})),t}function sn(r){const t=r.value,i=r.key,a=Jt(t);return a!=="string"?[new bt(i,t,`string expected, ${a} found`)]:[]}const hl={promoteId:function({key:r,value:t}){if(Jt(t)==="string")return sn({key:r,value:t});{const i=[];for(const a in t)i.push(...sn({key:`${r}.${a}`,value:t[a]}));return i}}};function Bc(r){const t=r.value,i=r.key,a=r.styleSpec,s=r.style,l=r.validateSpec;if(!t.type)return[new bt(i,t,'"type" is required')];const u=Ee(t.type);let f;switch(u){case"vector":case"raster":return f=Li({key:i,value:t,valueSpec:a[`source_${u.replace("-","_")}`],style:r.style,styleSpec:a,objectElementValidators:hl,validateSpec:l}),f;case"raster-dem":return f=function(_){var y;const v=(y=_.sourceName)!==null&&y!==void 0?y:"",w=_.value,S=_.styleSpec,P=S.source_raster_dem,M=_.style;let C=[];const z=Jt(w);if(w===void 0)return C;if(z!=="object")return C.push(new bt("source_raster_dem",w,`object expected, ${z} found`)),C;const F=Ee(w.encoding)==="custom",Z=["redFactor","greenFactor","blueFactor","baseShift"],O=_.value.encoding?`"${_.value.encoding}"`:"Default";for(const N in w)!F&&Z.includes(N)?C.push(new bt(N,w[N],`In "${v}": "${N}" is only valid when "encoding" is set to "custom". ${O} encoding found`)):P[N]?C=C.concat(_.validateSpec({key:N,value:w[N],valueSpec:P[N],validateSpec:_.validateSpec,style:M,styleSpec:S})):C.push(new bt(N,w[N],`unknown property "${N}"`));return C}({sourceName:i,value:t,style:r.style,styleSpec:a,validateSpec:l}),f;case"geojson":if(f=Li({key:i,value:t,valueSpec:a.source_geojson,style:s,styleSpec:a,validateSpec:l,objectElementValidators:hl}),t.cluster)for(const _ in t.clusterProperties){const[y,v]=t.clusterProperties[_],w=typeof y=="string"?[y,["accumulated"],["get",_]]:y;f.push(..._a({key:`${i}.${_}.map`,value:v,expressionContext:"cluster-map"})),f.push(..._a({key:`${i}.${_}.reduce`,value:w,expressionContext:"cluster-reduce"}))}return f;case"video":return Li({key:i,value:t,valueSpec:a.source_video,style:s,validateSpec:l,styleSpec:a});case"image":return Li({key:i,value:t,valueSpec:a.source_image,style:s,validateSpec:l,styleSpec:a});case"canvas":return[new bt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ts({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function dl(r){const t=r.value,i=r.styleSpec,a=i.light,s=r.style;let l=[];const u=Jt(t);if(t===void 0)return l;if(u!=="object")return l=l.concat([new bt("light",t,`object expected, ${u} found`)]),l;for(const f in t){const _=f.match(/^(.*)-transition$/);l=l.concat(_&&a[_[1]]&&a[_[1]].transition?r.validateSpec({key:f,value:t[f],valueSpec:i.transition,validateSpec:r.validateSpec,style:s,styleSpec:i}):a[f]?r.validateSpec({key:f,value:t[f],valueSpec:a[f],validateSpec:r.validateSpec,style:s,styleSpec:i}):[new bt(f,t[f],`unknown property "${f}"`)])}return l}function pl(r){const t=r.value,i=r.styleSpec,a=i.sky,s=r.style,l=Jt(t);if(t===void 0)return[];if(l!=="object")return[new bt("sky",t,`object expected, ${l} found`)];let u=[];for(const f in t)u=u.concat(a[f]?r.validateSpec({key:f,value:t[f],valueSpec:a[f],style:s,styleSpec:i}):[new bt(f,t[f],`unknown property "${f}"`)]);return u}function ga(r){const t=r.value,i=r.styleSpec,a=i.terrain,s=r.style;let l=[];const u=Jt(t);if(t===void 0)return l;if(u!=="object")return l=l.concat([new bt("terrain",t,`object expected, ${u} found`)]),l;for(const f in t)l=l.concat(a[f]?r.validateSpec({key:f,value:t[f],valueSpec:a[f],validateSpec:r.validateSpec,style:s,styleSpec:i}):[new bt(f,t[f],`unknown property "${f}"`)]);return l}function Oc(r){let t=[];const i=r.value,a=r.key;if(Array.isArray(i)){const s=[],l=[];for(const u in i)i[u].id&&s.includes(i[u].id)&&t.push(new bt(a,i,`all the sprites' ids must be unique, but ${i[u].id} is duplicated`)),s.push(i[u].id),i[u].url&&l.includes(i[u].url)&&t.push(new bt(a,i,`all the sprites' URLs must be unique, but ${i[u].url} is duplicated`)),l.push(i[u].url),t=t.concat(Li({key:`${a}[${u}]`,value:i[u],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return t}return sn({key:a,value:i})}function jc(r){return t=r.value,t&&t.constructor===Object?[]:[new bt(r.key,r.value,`object expected, ${Jt(r.value)} found`)];var t}const Vc={"*":()=>[],array:Qa,boolean:function(r){const t=r.value,i=r.key,a=Jt(t);return a!=="boolean"?[new bt(i,t,`boolean expected, ${a} found`)]:[]},number:Rn,color:ol,constants:sl,enum:ts,filter:ll,function:Rc,layer:Fc,object:Li,source:Bc,light:dl,sky:pl,terrain:ga,projection:function(r){const t=r.value,i=r.styleSpec,a=i.projection,s=r.style,l=Jt(t);if(t===void 0)return[];if(l!=="object")return[new bt("projection",t,`object expected, ${l} found`)];let u=[];for(const f in t)u=u.concat(a[f]?r.validateSpec({key:f,value:t[f],valueSpec:a[f],style:s,styleSpec:i}):[new bt(f,t[f],`unknown property "${f}"`)]);return u},projectionDefinition:function(r){const t=r.key;let i=r.value;i=i instanceof String?i.valueOf():i;const a=Jt(i);return a!=="array"||function(s){return Array.isArray(s)&&s.length===3&&typeof s[0]=="string"&&typeof s[1]=="string"&&typeof s[2]=="number"}(i)||function(s){return!!["interpolate","step","literal"].includes(s[0])}(i)?["array","string"].includes(a)?[]:[new bt(t,i,`projection expected, invalid type "${a}" found`)]:[new bt(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:sn,formatted:function(r){return sn(r).length===0?[]:_a(r)},resolvedImage:function(r){return sn(r).length===0?[]:_a(r)},padding:function(r){const t=r.key,i=r.value;if(Jt(i)==="array"){if(i.length<1||i.length>4)return[new bt(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const a={type:"number"};let s=[];for(let l=0;l<i.length;l++)s=s.concat(r.validateSpec({key:`${t}[${l}]`,value:i[l],validateSpec:r.validateSpec,valueSpec:a}));return s}return Rn({key:t,value:i,valueSpec:{}})},numberArray:function(r){const t=r.key,i=r.value;if(Jt(i)==="array"){const a={type:"number"};if(i.length<1)return[new bt(t,i,"array length at least 1 expected, length 0 found")];let s=[];for(let l=0;l<i.length;l++)s=s.concat(r.validateSpec({key:`${t}[${l}]`,value:i[l],validateSpec:r.validateSpec,valueSpec:a}));return s}return Rn({key:t,value:i,valueSpec:{}})},colorArray:function(r){const t=r.key,i=r.value;if(Jt(i)==="array"){if(i.length<1)return[new bt(t,i,"array length at least 1 expected, length 0 found")];let a=[];for(let s=0;s<i.length;s++)a=a.concat(ol({key:`${t}[${s}]`,value:i[s]}));return a}return ol({key:t,value:i})},variableAnchorOffsetCollection:function(r){const t=r.key,i=r.value,a=Jt(i),s=r.styleSpec;if(a!=="array"||i.length<1||i.length%2!=0)return[new bt(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let l=[];for(let u=0;u<i.length;u+=2)l=l.concat(ts({key:`${t}[${u}]`,value:i[u],valueSpec:s.layout_symbol["text-anchor"]})),l=l.concat(Qa({key:`${t}[${u+1}]`,value:i[u+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:s}));return l},sprite:Oc,state:jc};function io(r){const t=r.value,i=r.valueSpec,a=r.styleSpec;return r.validateSpec=io,i.expression&&$s(Ee(t))?Rc(r):i.expression&&Ws(Ar(t))?_a(r):i.type&&Vc[i.type]?Vc[i.type](r):Li(xe({},r,{valueSpec:i.type?a[i.type]:i}))}function Nc(r){const t=r.value,i=r.key,a=sn(r);return a.length||(t.indexOf("{fontstack}")===-1&&a.push(new bt(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&a.push(new bt(i,t,'"glyphs" url must include a "{range}" token'))),a}function Wi(r,t=U){let i=[];return i=i.concat(io({key:"",value:r,valueSpec:t.$root,styleSpec:t,style:r,validateSpec:io,objectElementValidators:{glyphs:Nc,"*":()=>[]}})),r.constants&&(i=i.concat(sl({key:"constants",value:r.constants}))),ya(i)}function Si(r){return function(t){return r(Object.assign({},t,{validateSpec:io}))}}function ya(r){return[].concat(r).sort((t,i)=>t.line-i.line)}function Re(r){return function(...t){return ya(r.apply(this,t))}}Wi.source=Re(Si(Bc)),Wi.sprite=Re(Si(Oc)),Wi.glyphs=Re(Si(Nc)),Wi.light=Re(Si(dl)),Wi.sky=Re(Si(pl)),Wi.terrain=Re(Si(ga)),Wi.state=Re(Si(jc)),Wi.layer=Re(Si(Fc)),Wi.filter=Re(Si(ll)),Wi.paintProperty=Re(Si(ul)),Wi.layoutProperty=Re(Si(es));const is=U,Ln=Wi,Ku=Ln.light,Ju=Ln.sky,rs=Ln.paintProperty,Uc=Ln.layoutProperty;function ro(r,t){let i=!1;if(t&&t.length)for(const a of t)r.fire(new X(new Error(a.message))),i=!0;return i}class ns{constructor(t,i,a){const s=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const u=new Int32Array(this.arrayBuffer);t=u[0],this.d=(i=u[1])+2*(a=u[2]);for(let _=0;_<this.d*this.d;_++){const y=u[3+_],v=u[3+_+1];s.push(y===v?null:u.subarray(y,v))}const f=u[3+s.length+1];this.keys=u.subarray(u[3+s.length],f),this.bboxes=u.subarray(f),this.insert=this._insertReadonly}else{this.d=i+2*a;for(let u=0;u<this.d*this.d;u++)s.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=a,this.scale=i/t,this.uid=0;const l=a/i*t;this.min=-l,this.max=t+l}insert(t,i,a,s,l){this._forEachCell(i,a,s,l,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(a),this.bboxes.push(s),this.bboxes.push(l)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,a,s,l,u){this.cells[l].push(u)}query(t,i,a,s,l){const u=this.min,f=this.max;if(t<=u&&i<=u&&f<=a&&f<=s&&!l)return Array.prototype.slice.call(this.keys);{const _=[];return this._forEachCell(t,i,a,s,this._queryCell,_,{},l),_}}_queryCell(t,i,a,s,l,u,f,_){const y=this.cells[l];if(y!==null){const v=this.keys,w=this.bboxes;for(let S=0;S<y.length;S++){const P=y[S];if(f[P]===void 0){const M=4*P;(_?_(w[M+0],w[M+1],w[M+2],w[M+3]):t<=w[M+2]&&i<=w[M+3]&&a>=w[M+0]&&s>=w[M+1])?(f[P]=!0,u.push(v[P])):f[P]=!1}}}}_forEachCell(t,i,a,s,l,u,f,_){const y=this._convertToCellCoord(t),v=this._convertToCellCoord(i),w=this._convertToCellCoord(a),S=this._convertToCellCoord(s);for(let P=y;P<=w;P++)for(let M=v;M<=S;M++){const C=this.d*M+P;if((!_||_(this._convertFromCellCoord(P),this._convertFromCellCoord(M),this._convertFromCellCoord(P+1),this._convertFromCellCoord(M+1)))&&l.call(this,t,i,a,s,C,u,f,_))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,i=3+this.cells.length+1+1;let a=0;for(let u=0;u<this.cells.length;u++)a+=this.cells[u].length;const s=new Int32Array(i+a+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;let l=i;for(let u=0;u<t.length;u++){const f=t[u];s[3+u]=l,s.set(f,l),l+=f.length}return s[3+t.length]=l,s.set(this.keys,l),l+=this.keys.length,s[3+t.length+1]=l,s.set(this.bboxes,l),l+=this.bboxes.length,s.buffer}static serialize(t,i){const a=t.toArrayBuffer();return i&&i.push(a),{buffer:a}}static deserialize(t){return new ns(t.buffer)}}const or={};function Dt(r,t,i={}){if(or[r])throw new Error(`${r} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:r,writeable:!1}),or[r]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}Dt("Object",Object),Dt("Set",Set),Dt("TransferableGridIndex",ns),Dt("Color",Kt),Dt("Error",Error),Dt("AJAXError",ir),Dt("ResolvedImage",zi),Dt("StylePropertyFunction",Ys),Dt("StyleExpression",qs,{omit:["_evaluator"]}),Dt("ZoomDependentExpression",Xs),Dt("ZoomConstantExpression",kn),Dt("CompoundExpression",qi,{omit:["_evaluate"]});for(const r in da)da[r]._classRegistryKey||Dt(`Expression_${r}`,da[r]);function xa(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function fl(r){return r.$name||r.constructor._classRegistryKey}function Gc(r){return!function(t){if(t===null||typeof t!="object")return!1;const i=fl(t);return!(!i||i==="Object")}(r)&&(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||r instanceof Blob||r instanceof Error||xa(r)||mr(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function as(r,t){if(Gc(r))return(xa(r)||mr(r))&&t&&t.push(r),ArrayBuffer.isView(r)&&t&&t.push(r.buffer),r instanceof ImageData&&t&&t.push(r.data.buffer),r;if(Array.isArray(r)){const l=[];for(const u of r)l.push(as(u,t));return l}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=fl(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!or[i])throw new Error(`${i} is not registered.`);const{klass:a}=or[i],s=a.serialize?a.serialize(r,t):{};if(a.serialize){if(t&&s===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const l in r){if(!r.hasOwnProperty(l)||or[i].omit.indexOf(l)>=0)continue;const u=r[l];s[l]=or[i].shallow.indexOf(l)>=0?u:as(u,t)}r instanceof Error&&(s.message=r.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(s.$name=i),s}function Dr(r){if(Gc(r))return r;if(Array.isArray(r))return r.map(Dr);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const t=fl(r)||"Object";if(!or[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=or[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(r);const a=Object.create(i.prototype);for(const s of Object.keys(r)){if(s==="$name")continue;const l=r[s];a[s]=or[t].shallow.indexOf(s)>=0?l:Dr(l)}return a}class ml{constructor(){this.first=!0}update(t,i){const a=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=i),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=a,!0))}}function Qu(r){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(r))}function va(r){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(r))}function Zc(r){return/\s/u.test(String.fromCodePoint(r))}function ss(r){for(const t of r)if(va(t.codePointAt(0)))return!0;return!1}function no(r){for(const t of r)if(!qc(t.codePointAt(0)))return!1;return!0}function _l(r){const t=r.map(i=>{try{return new RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}}).filter(i=>i);return new RegExp(t.join("|"),"u")}const $c=_l(["Arab","Dupl","Mong","Ougr","Syrc"]);function qc(r){return!$c.test(String.fromCodePoint(r))}function gl(r){return!(va(r)||(t=r,/[\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(t))));var t}const yl=_l(["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 xl(r){return yl.test(String.fromCodePoint(r))}function th(r,t){return!(!t&&xl(r)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(r)))}function Wc(r){for(const t of r)if(xl(t.codePointAt(0)))return!0;return!1}const on=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(r){this.pluginStatus=r.pluginStatus,this.pluginURL=r.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(r){if(on.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=r.applyArabicShaping,this.processBidirectionalText=r.processBidirectionalText,this.processStyledBidirectionalText=r.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(r,t){return h(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if(r.pluginStatus!=="loading")return this.setState(r),r;const i=r.pluginURL,a=new Promise(l=>{this.loadScriptResolve=l});t(i);const s=new Promise(l=>setTimeout(()=>l(),this.TIMEOUT));if(yield Promise.race([a,s]),this.isParsed()){const l={pluginStatus:"loaded",pluginURL:i};return this.setState(l),l}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)})}};class le{constructor(t,i){this.isSupportedScript=eh,this.zoom=t,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new ml,this.transition=i.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ml,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,i=t-Math.floor(t),a=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*i}}}function eh(r){return function(t,i){for(const a of t)if(!th(a.codePointAt(0),i))return!1;return!0}(r,on.getRTLTextPluginStatus()==="loaded")}const os="-transition";class ls{constructor(t,i,a){this.property=t,this.value=i,this.expression=function(s,l,u){if($s(s))return new Ys(s,l);if(Ws(s)){const f=Cc(s,l,u);if(f.result==="error")throw new Error(f.value.map(_=>`${_.key}: ${_.message}`).join(", "));return f.value}{let f=s;return l.type==="color"&&typeof s=="string"?f=Kt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type!=="numberArray"||typeof s!="number"&&!Array.isArray(s)?l.type!=="colorArray"||typeof s!="string"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)?f=Ti.parse(s):l.type==="projectionDefinition"&&typeof s=="string"&&(f=mi.parse(s)):f=Je.parse(s):f=fi.parse(s):f=pi.parse(s),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>f}}}(i===void 0?t.specification.default:i,t.specification,a)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,i,a){return this.property.possiblyEvaluate(this,t,i,a)}}class vl{constructor(t,i){this.property=t,this.value=new ls(t,void 0,i)}transitioned(t,i){return new bl(this.property,this.value,i,di({},t.transition,this.transition),t.now)}untransitioned(){return new bl(this.property,this.value,null,{},0)}}class Hc{constructor(t,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=i}getValue(t){return Zi(this._values[t].value.value)}setValue(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new vl(this._values[t].property,this._globalState)),this._values[t].value=new ls(this._values[t].property,i===null?void 0:Zi(i),this._globalState)}getTransition(t){return Zi(this._values[t].transition)}setTransition(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new vl(this._values[t].property,this._globalState)),this._values[t].transition=Zi(i)||void 0}serialize(){const t={};for(const i of Object.keys(this._values)){const a=this.getValue(i);a!==void 0&&(t[i]=a);const s=this.getTransition(i);s!==void 0&&(t[`${i}${os}`]=s)}return t}transitioned(t,i){const a=new wl(this._properties);for(const s of Object.keys(this._values))a._values[s]=this._values[s].transitioned(t,i._values[s]);return a}untransitioned(){const t=new wl(this._properties);for(const i of Object.keys(this._values))t._values[i]=this._values[i].untransitioned();return t}}class bl{constructor(t,i,a,s,l){this.property=t,this.value=i,this.begin=l+s.delay||0,this.end=this.begin+s.duration||0,t.specification.transition&&(s.delay||s.duration)&&(this.prior=a)}possiblyEvaluate(t,i,a){const s=t.now||0,l=this.value.possiblyEvaluate(t,i,a),u=this.prior;if(u){if(s>this.end)return this.prior=null,l;if(this.value.isDataDriven())return this.prior=null,l;if(s<this.begin)return u.possiblyEvaluate(t,i,a);{const f=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(t,i,a),l,Is(f))}}return l}}class wl{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,i,a){const s=new Fn(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(t,i,a);return s}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Xc{constructor(t,i){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=i}hasValue(t){return this._values[t].value!==void 0}getValue(t){return Zi(this._values[t].value)}setValue(t,i){this._values[t]=new ls(this._values[t].property,i===null?void 0:Zi(i),this._globalState)}serialize(){const t={};for(const i of Object.keys(this._values)){const a=this.getValue(i);a!==void 0&&(t[i]=a)}return t}possiblyEvaluate(t,i,a){const s=new Fn(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(t,i,a);return s}}class lr{constructor(t,i,a){this.property=t,this.value=i,this.parameters=a}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,i,a,s){return this.property.evaluate(this.value,this.parameters,t,i,a,s)}}class Fn{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Ft{constructor(t){this.specification=t}possiblyEvaluate(t,i){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(i)}interpolate(t,i,a){const s=ar[this.specification.type];return s?s(t,i,a):t}}class Vt{constructor(t,i){this.specification=t,this.overrides=i}possiblyEvaluate(t,i,a,s){return new lr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(i,null,{},a,s)}:t.expression,i)}interpolate(t,i,a){if(t.value.kind!=="constant"||i.value.kind!=="constant")return t;if(t.value.value===void 0||i.value.value===void 0)return new lr(this,{kind:"constant",value:void 0},t.parameters);const s=ar[this.specification.type];if(s){const l=s(t.value.value,i.value.value,a);return new lr(this,{kind:"constant",value:l},t.parameters)}return t}evaluate(t,i,a,s,l,u){return t.kind==="constant"?t.value:t.evaluate(i,a,s,l,u)}}class cs extends Vt{possiblyEvaluate(t,i,a,s){if(t.value===void 0)return new lr(this,{kind:"constant",value:void 0},i);if(t.expression.kind==="constant"){const l=t.expression.evaluate(i,null,{},a,s),u=t.property.specification.type==="resolvedImage"&&typeof l!="string"?l.name:l,f=this._calculate(u,u,u,i);return new lr(this,{kind:"constant",value:f},i)}if(t.expression.kind==="camera"){const l=this._calculate(t.expression.evaluate({zoom:i.zoom-1}),t.expression.evaluate({zoom:i.zoom}),t.expression.evaluate({zoom:i.zoom+1}),i);return new lr(this,{kind:"constant",value:l},i)}return new lr(this,t.expression,i)}evaluate(t,i,a,s,l,u){if(t.kind==="source"){const f=t.evaluate(i,a,s,l,u);return this._calculate(f,f,f,i)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(i.zoom)-1},a,s),t.evaluate({zoom:Math.floor(i.zoom)},a,s),t.evaluate({zoom:Math.floor(i.zoom)+1},a,s),i):t.value}_calculate(t,i,a,s){return s.zoom>s.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:a,to:i}}interpolate(t){return t}}class Yc{constructor(t){this.specification=t}possiblyEvaluate(t,i,a,s){if(t.value!==void 0){if(t.expression.kind==="constant"){const l=t.expression.evaluate(i,null,{},a,s);return this._calculate(l,l,l,i)}return this._calculate(t.expression.evaluate(new le(Math.floor(i.zoom-1),i)),t.expression.evaluate(new le(Math.floor(i.zoom),i)),t.expression.evaluate(new le(Math.floor(i.zoom+1),i)),i)}}_calculate(t,i,a,s){return s.zoom>s.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:a,to:i}}interpolate(t){return t}}class us{constructor(t){this.specification=t}possiblyEvaluate(t,i,a,s){return!!t.expression.evaluate(i,null,{},a,s)}interpolate(){return!1}}class _i{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const i in t){const a=t[i];a.specification.overridable&&this.overridableProperties.push(i);const s=this.defaultPropertyValues[i]=new ls(a,void 0,void 0),l=this.defaultTransitionablePropertyValues[i]=new vl(a,void 0);this.defaultTransitioningPropertyValues[i]=l.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=s.possiblyEvaluate({})}}}Dt("DataDrivenProperty",Vt),Dt("DataConstantProperty",Ft),Dt("CrossFadedDataDrivenProperty",cs),Dt("CrossFadedProperty",Yc),Dt("ColorRampProperty",us);class Hi extends nt{constructor(t,i,a){if(super(),this.id=t.id,this.type=t.type,this._globalState=a,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=Ka(t.filter,a)),i.layout&&(this._unevaluatedLayout=new Xc(i.layout,a)),i.paint)){this._transitionablePaint=new Hc(i.paint,a);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Fn(i.paint)}}setFilter(t){this.filter=t,this._featureFilter=Ka(t,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;if(this._unevaluatedLayout)for(const i in this._unevaluatedLayout._values){const a=this._unevaluatedLayout._values[i];for(const s of a.getGlobalStateRefs())t.add(s)}for(const i of this._featureFilter.getGlobalStateRefs())t.add(i);return t}getPaintAffectingGlobalStateRefs(){var t;const i=new globalThis.Map;if(this._transitionablePaint)for(const a in this._transitionablePaint._values){const s=this._transitionablePaint._values[a].value;for(const l of s.getGlobalStateRefs()){const u=(t=i.get(l))!==null&&t!==void 0?t:[];u.push({name:a,value:s.value}),i.set(l,u)}}return i}setLayoutProperty(t,i,a={}){i!=null&&this._validate(Uc,`layers.${this.id}.layout.${t}`,t,i,a)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,i):this.visibility=i)}getPaintProperty(t){return t.endsWith(os)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,i,a={}){if(i!=null&&this._validate(rs,`layers.${this.id}.paint.${t}`,t,i,a))return!1;if(t.endsWith(os))return this._transitionablePaint.setTransition(t.slice(0,-11),i||void 0),!1;{const s=this._transitionablePaint._values[t],l=s.property.specification["property-type"]==="cross-faded-data-driven",u=s.value.isDataDriven(),f=s.value;this._transitionablePaint.setValue(t,i),this._handleSpecialPaintPropertyUpdate(t);const _=this._transitionablePaint._values[t].value;return _.isDataDriven()||u||l||this._handleOverridablePaintPropertyUpdate(t,f,_)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,i,a){return!1}isHidden(t,i=!1){return!!(this.minzoom&&t<(i?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,i){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,i)}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),vn(t,(i,a)=>!(i===void 0||a==="layout"&&!Object.keys(i).length||a==="paint"&&!Object.keys(i).length))}_validate(t,i,a,s,l={}){return(!l||l.validate!==!1)&&ro(this,t.call(Ln,{key:i,layerType:this.type,objectKey:a,value:s,styleSpec:U,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const i=this.paint.get(t);if(i instanceof lr&&fa(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}let Kc;var ih={get paint(){return Kc=Kc||new _i({"raster-opacity":new Ft(U.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ft(U.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ft(U.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ft(U.paint_raster["raster-brightness-max"]),"raster-saturation":new Ft(U.paint_raster["raster-saturation"]),"raster-contrast":new Ft(U.paint_raster["raster-contrast"]),"raster-resampling":new Ft(U.paint_raster["raster-resampling"]),"raster-fade-duration":new Ft(U.paint_raster["raster-fade-duration"])})}};class rh extends Hi{constructor(t,i){super(t,ih,i)}}const nh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class hs{constructor(t,i){this._structArray=t,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ce{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,i){return t._trim(),i&&(t.isTransferred=!0,i.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const i=Object.create(this.prototype);return i.arrayBuffer=t.arrayBuffer,i.length=t.length,i.capacity=t.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_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 i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Be(r,t=1){let i=0,a=0;return{members:r.map(s=>{const l=nh[s.type].BYTES_PER_ELEMENT,u=i=Jc(i,Math.max(t,l)),f=s.components||1;return a=Math.max(a,l),i+=l*f,{name:s.name,type:s.type,components:f,offset:u}}),size:Jc(i,Math.max(a,t)),alignment:t}}function Jc(r,t){return Math.ceil(r/t)*t}class ds extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,i)}emplace(t,i,a){const s=2*t;return this.int16[s+0]=i,this.int16[s+1]=a,t}}ds.prototype.bytesPerElement=4,Dt("StructArrayLayout2i4",ds);class ps extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,i,a)}emplace(t,i,a,s){const l=3*t;return this.int16[l+0]=i,this.int16[l+1]=a,this.int16[l+2]=s,t}}ps.prototype.bytesPerElement=6,Dt("StructArrayLayout3i6",ps);class Tl extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,a,s)}emplace(t,i,a,s,l){const u=4*t;return this.int16[u+0]=i,this.int16[u+1]=a,this.int16[u+2]=s,this.int16[u+3]=l,t}}Tl.prototype.bytesPerElement=8,Dt("StructArrayLayout4i8",Tl);class Sl extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u){const f=this.length;return this.resize(f+1),this.emplace(f,t,i,a,s,l,u)}emplace(t,i,a,s,l,u,f){const _=6*t;return this.int16[_+0]=i,this.int16[_+1]=a,this.int16[_+2]=s,this.int16[_+3]=l,this.int16[_+4]=u,this.int16[_+5]=f,t}}Sl.prototype.bytesPerElement=12,Dt("StructArrayLayout2i4i12",Sl);class zr extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u){const f=this.length;return this.resize(f+1),this.emplace(f,t,i,a,s,l,u)}emplace(t,i,a,s,l,u,f){const _=4*t,y=8*t;return this.int16[_+0]=i,this.int16[_+1]=a,this.uint8[y+4]=s,this.uint8[y+5]=l,this.uint8[y+6]=u,this.uint8[y+7]=f,t}}zr.prototype.bytesPerElement=8,Dt("StructArrayLayout2i4ub8",zr);class ba extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,i)}emplace(t,i,a){const s=2*t;return this.float32[s+0]=i,this.float32[s+1]=a,t}}ba.prototype.bytesPerElement=8,Dt("StructArrayLayout2f8",ba);class fs extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u,f,_,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,t,i,a,s,l,u,f,_,y,v)}emplace(t,i,a,s,l,u,f,_,y,v,w){const S=10*t;return this.uint16[S+0]=i,this.uint16[S+1]=a,this.uint16[S+2]=s,this.uint16[S+3]=l,this.uint16[S+4]=u,this.uint16[S+5]=f,this.uint16[S+6]=_,this.uint16[S+7]=y,this.uint16[S+8]=v,this.uint16[S+9]=w,t}}fs.prototype.bytesPerElement=20,Dt("StructArrayLayout10ui20",fs);class ao extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u,f,_){const y=this.length;return this.resize(y+1),this.emplace(y,t,i,a,s,l,u,f,_)}emplace(t,i,a,s,l,u,f,_,y){const v=8*t;return this.uint16[v+0]=i,this.uint16[v+1]=a,this.uint16[v+2]=s,this.uint16[v+3]=l,this.uint16[v+4]=u,this.uint16[v+5]=f,this.uint16[v+6]=_,this.uint16[v+7]=y,t}}ao.prototype.bytesPerElement=16,Dt("StructArrayLayout8ui16",ao);class ms extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u,f,_,y,v,w,S){const P=this.length;return this.resize(P+1),this.emplace(P,t,i,a,s,l,u,f,_,y,v,w,S)}emplace(t,i,a,s,l,u,f,_,y,v,w,S,P){const M=12*t;return this.int16[M+0]=i,this.int16[M+1]=a,this.int16[M+2]=s,this.int16[M+3]=l,this.uint16[M+4]=u,this.uint16[M+5]=f,this.uint16[M+6]=_,this.uint16[M+7]=y,this.int16[M+8]=v,this.int16[M+9]=w,this.int16[M+10]=S,this.int16[M+11]=P,t}}ms.prototype.bytesPerElement=24,Dt("StructArrayLayout4i4ui4i24",ms);class Pl extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,i,a)}emplace(t,i,a,s){const l=3*t;return this.float32[l+0]=i,this.float32[l+1]=a,this.float32[l+2]=s,t}}Pl.prototype.bytesPerElement=12,Dt("StructArrayLayout3f12",Pl);class wa extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint32[1*t+0]=i,t}}wa.prototype.bytesPerElement=4,Dt("StructArrayLayout1ul4",wa);class Bn extends ce{_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,i,a,s,l,u,f,_,y){const v=this.length;return this.resize(v+1),this.emplace(v,t,i,a,s,l,u,f,_,y)}emplace(t,i,a,s,l,u,f,_,y,v){const w=10*t,S=5*t;return this.int16[w+0]=i,this.int16[w+1]=a,this.int16[w+2]=s,this.int16[w+3]=l,this.int16[w+4]=u,this.int16[w+5]=f,this.uint32[S+3]=_,this.uint16[w+8]=y,this.uint16[w+9]=v,t}}Bn.prototype.bytesPerElement=20,Dt("StructArrayLayout6i1ul2ui20",Bn);class Ml extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u){const f=this.length;return this.resize(f+1),this.emplace(f,t,i,a,s,l,u)}emplace(t,i,a,s,l,u,f){const _=6*t;return this.int16[_+0]=i,this.int16[_+1]=a,this.int16[_+2]=s,this.int16[_+3]=l,this.int16[_+4]=u,this.int16[_+5]=f,t}}Ml.prototype.bytesPerElement=12,Dt("StructArrayLayout2i2i2i12",Ml);class so extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,i,a,s,l)}emplace(t,i,a,s,l,u){const f=4*t,_=8*t;return this.float32[f+0]=i,this.float32[f+1]=a,this.float32[f+2]=s,this.int16[_+6]=l,this.int16[_+7]=u,t}}so.prototype.bytesPerElement=16,Dt("StructArrayLayout2f1f2i16",so);class On extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,a,s,l,u){const f=this.length;return this.resize(f+1),this.emplace(f,t,i,a,s,l,u)}emplace(t,i,a,s,l,u,f){const _=16*t,y=4*t,v=8*t;return this.uint8[_+0]=i,this.uint8[_+1]=a,this.float32[y+1]=s,this.float32[y+2]=l,this.int16[v+6]=u,this.int16[v+7]=f,t}}On.prototype.bytesPerElement=16,Dt("StructArrayLayout2ub2f2i16",On);class oo extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,i,a)}emplace(t,i,a,s){const l=3*t;return this.uint16[l+0]=i,this.uint16[l+1]=a,this.uint16[l+2]=s,t}}oo.prototype.bytesPerElement=6,Dt("StructArrayLayout3ui6",oo);class Il extends ce{_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,i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F){const Z=this.length;return this.resize(Z+1),this.emplace(Z,t,i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F)}emplace(t,i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F,Z){const O=24*t,N=12*t,Q=48*t;return this.int16[O+0]=i,this.int16[O+1]=a,this.uint16[O+2]=s,this.uint16[O+3]=l,this.uint32[N+2]=u,this.uint32[N+3]=f,this.uint32[N+4]=_,this.uint16[O+10]=y,this.uint16[O+11]=v,this.uint16[O+12]=w,this.float32[N+7]=S,this.float32[N+8]=P,this.uint8[Q+36]=M,this.uint8[Q+37]=C,this.uint8[Q+38]=z,this.uint32[N+10]=F,this.int16[O+22]=Z,t}}Il.prototype.bytesPerElement=48,Dt("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Il);class lo extends ce{_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,i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F,Z,O,N,Q,et,lt,yt,mt,vt,Ct,St){const Pt=this.length;return this.resize(Pt+1),this.emplace(Pt,t,i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F,Z,O,N,Q,et,lt,yt,mt,vt,Ct,St)}emplace(t,i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F,Z,O,N,Q,et,lt,yt,mt,vt,Ct,St,Pt){const _t=32*t,Bt=16*t;return this.int16[_t+0]=i,this.int16[_t+1]=a,this.int16[_t+2]=s,this.int16[_t+3]=l,this.int16[_t+4]=u,this.int16[_t+5]=f,this.int16[_t+6]=_,this.int16[_t+7]=y,this.uint16[_t+8]=v,this.uint16[_t+9]=w,this.uint16[_t+10]=S,this.uint16[_t+11]=P,this.uint16[_t+12]=M,this.uint16[_t+13]=C,this.uint16[_t+14]=z,this.uint16[_t+15]=F,this.uint16[_t+16]=Z,this.uint16[_t+17]=O,this.uint16[_t+18]=N,this.uint16[_t+19]=Q,this.uint16[_t+20]=et,this.uint16[_t+21]=lt,this.uint16[_t+22]=yt,this.uint32[Bt+12]=mt,this.float32[Bt+13]=vt,this.float32[Bt+14]=Ct,this.uint16[_t+30]=St,this.uint16[_t+31]=Pt,t}}lo.prototype.bytesPerElement=64,Dt("StructArrayLayout8i15ui1ul2f2ui64",lo);class co extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.float32[1*t+0]=i,t}}co.prototype.bytesPerElement=4,Dt("StructArrayLayout1f4",co);class d extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,i,a)}emplace(t,i,a,s){const l=3*t;return this.uint16[6*t+0]=i,this.float32[l+1]=a,this.float32[l+2]=s,t}}d.prototype.bytesPerElement=12,Dt("StructArrayLayout1ui2f12",d);class e extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,i,a)}emplace(t,i,a,s){const l=4*t;return this.uint32[2*t+0]=i,this.uint16[l+2]=a,this.uint16[l+3]=s,t}}e.prototype.bytesPerElement=8,Dt("StructArrayLayout1ul2ui8",e);class n extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,i)}emplace(t,i,a){const s=2*t;return this.uint16[s+0]=i,this.uint16[s+1]=a,t}}n.prototype.bytesPerElement=4,Dt("StructArrayLayout2ui4",n);class o extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint16[1*t+0]=i,t}}o.prototype.bytesPerElement=2,Dt("StructArrayLayout1ui2",o);class c extends ce{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,a,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,a,s)}emplace(t,i,a,s,l){const u=4*t;return this.float32[u+0]=i,this.float32[u+1]=a,this.float32[u+2]=s,this.float32[u+3]=l,t}}c.prototype.bytesPerElement=16,Dt("StructArrayLayout4f16",c);class p extends hs{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 It(this.anchorPointX,this.anchorPointY)}}p.prototype.size=20;class m extends Bn{get(t){return new p(this,t)}}Dt("CollisionBoxArray",m);class g extends hs{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]}}g.prototype.size=48;class x extends Il{get(t){return new g(this,t)}}Dt("PlacedSymbolArray",x);class b extends hs{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]}}b.prototype.size=64;class T extends lo{get(t){return new b(this,t)}}Dt("SymbolInstanceArray",T);class E extends co{getoffsetX(t){return this.float32[1*t+0]}}Dt("GlyphOffsetArray",E);class I extends ps{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Dt("SymbolLineVertexArray",I);class A extends hs{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]}}A.prototype.size=12;class L extends d{get(t){return new A(this,t)}}Dt("TextAnchorOffsetArray",L);class j extends hs{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]}}j.prototype.size=8;class V extends e{get(t){return new j(this,t)}}Dt("FeatureIndexArray",V);class G extends ds{}class q extends ds{}class Y extends ds{}class $ extends Sl{}class K extends zr{}class J extends ba{}class H extends fs{}class it extends ao{}class ut extends ms{}class st extends Pl{}class ot extends wa{}class ct extends Ml{}class Mt extends On{}class wt extends oo{}class gt extends n{}const Rt=Be([{name:"a_pos",components:2,type:"Int16"}],4),{members:$t}=Rt;class Zt{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,a,s){const l=this.segments[this.segments.length-1];return t>Zt.MAX_VERTEX_ARRAY_LENGTH&&Pe(`Max vertices per segment is ${Zt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Zt.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!l||l.vertexLength+t>Zt.MAX_VERTEX_ARRAY_LENGTH||l.sortKey!==s?this.createNewSegment(i,a,s):l}createNewSegment(t,i,a){const s={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return a!==void 0&&(s.sortKey=a),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(s),s}getOrCreateLatestSegment(t,i,a){return this.prepareSegment(0,t,i,a)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,a,s){return new Zt([{vertexOffset:t,primitiveOffset:i,vertexLength:a,primitiveLength:s,vaos:{},sortKey:0}])}}function ge(r,t){return 256*(r=wi(Math.floor(r),0,255))+wi(Math.floor(t),0,255)}Zt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Dt("SegmentVector",Zt);const ye=Be([{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"}]),Ce=Be([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var ue,He,we,Ne={exports:{}},Oe={exports:{}},Ue={exports:{}},Fi=function(){if(we)return Ne.exports;we=1;var r=(ue||(ue=1,Oe.exports=function(i,a){var s,l,u,f,_,y,v,w;for(l=i.length-(s=3&i.length),u=a,_=3432918353,y=461845907,w=0;w<l;)v=255&i.charCodeAt(w)|(255&i.charCodeAt(++w))<<8|(255&i.charCodeAt(++w))<<16|(255&i.charCodeAt(++w))<<24,++w,u=27492+(65535&(f=5*(65535&(u=(u^=v=(65535&(v=(v=(65535&v)*_+(((v>>>16)*_&65535)<<16)&4294967295)<<15|v>>>17))*y+(((v>>>16)*y&65535)<<16)&4294967295)<<13|u>>>19))+((5*(u>>>16)&65535)<<16)&4294967295))+((58964+(f>>>16)&65535)<<16);switch(v=0,s){case 3:v^=(255&i.charCodeAt(w+2))<<16;case 2:v^=(255&i.charCodeAt(w+1))<<8;case 1:u^=v=(65535&(v=(v=(65535&(v^=255&i.charCodeAt(w)))*_+(((v>>>16)*_&65535)<<16)&4294967295)<<15|v>>>17))*y+(((v>>>16)*y&65535)<<16)&4294967295}return u^=i.length,u=2246822507*(65535&(u^=u>>>16))+((2246822507*(u>>>16)&65535)<<16)&4294967295,u=3266489909*(65535&(u^=u>>>13))+((3266489909*(u>>>16)&65535)<<16)&4294967295,(u^=u>>>16)>>>0}),Oe.exports),t=(He||(He=1,Ue.exports=function(i,a){for(var s,l=i.length,u=a^l,f=0;l>=4;)s=1540483477*(65535&(s=255&i.charCodeAt(f)|(255&i.charCodeAt(++f))<<8|(255&i.charCodeAt(++f))<<16|(255&i.charCodeAt(++f))<<24))+((1540483477*(s>>>16)&65535)<<16),u=1540483477*(65535&u)+((1540483477*(u>>>16)&65535)<<16)^(s=1540483477*(65535&(s^=s>>>24))+((1540483477*(s>>>16)&65535)<<16)),l-=4,++f;switch(l){case 3:u^=(255&i.charCodeAt(f+2))<<16;case 2:u^=(255&i.charCodeAt(f+1))<<8;case 1:u=1540483477*(65535&(u^=255&i.charCodeAt(f)))+((1540483477*(u>>>16)&65535)<<16)}return u=1540483477*(65535&(u^=u>>>13))+((1540483477*(u>>>16)&65535)<<16),(u^=u>>>15)>>>0}),Ue.exports);return Ne.exports=r,Ne.exports.murmur3=r,Ne.exports.murmur2=t,Ne.exports}(),kr=si(Fi);class Sr{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,a,s){this.ids.push(ln(t)),this.positions.push(i,a,s)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=ln(t);let a=0,s=this.ids.length-1;for(;a<s;){const u=a+s>>1;this.ids[u]>=i?s=u:a=u+1}const l=[];for(;this.ids[a]===i;)l.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return l}static serialize(t,i){const a=new Float64Array(t.ids),s=new Uint32Array(t.positions);return cn(a,s,0,a.length-1),i&&i.push(a.buffer,s.buffer),{ids:a,positions:s}}static deserialize(t){const i=new Sr;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}}function ln(r){const t=+r;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:kr(String(r))}function cn(r,t,i,a){for(;i<a;){const s=r[i+a>>1];let l=i-1,u=a+1;for(;;){do l++;while(r[l]<s);do u--;while(r[u]>s);if(l>=u)break;jn(r,l,u),jn(t,3*l,3*u),jn(t,3*l+1,3*u+1),jn(t,3*l+2,3*u+2)}u-i<a-u?(cn(r,t,i,u),i=u+1):(cn(r,t,u+1,a),a=u)}}function jn(r,t,i){const a=r[t];r[t]=r[i],r[i]=a}Dt("FeaturePositionMap",Sr);class Xi{constructor(t,i){this.gl=t.gl,this.location=i}}class Rr extends Xi{constructor(t,i){super(t,i),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Vi extends Xi{constructor(t,i){super(t,i),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 Lr extends Xi{constructor(t,i){super(t,i),this.current=Kt.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 Vn=new Float32Array(16);function Nn(r){return[ge(255*r.r,255*r.g),ge(255*r.b,255*r.a)]}class Le{constructor(t,i,a){this.value=t,this.uniformNames=i.map(s=>`u_${s}`),this.type=a}setUniform(t,i,a){t.set(a.constantOr(this.value))}getBinding(t,i,a){return this.type==="color"?new Lr(t,i):new Rr(t,i)}}class Ae{constructor(t,i){this.uniformNames=i.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,i){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,i.y,i.height,i.width]}setUniform(t,i,a,s){let l=null;s==="u_pattern_to"?l=this.patternTo:s==="u_pattern_from"?l=this.patternFrom:s==="u_dasharray_to"?l=this.dashTo:s==="u_dasharray_from"?l=this.dashFrom:s==="u_pixel_ratio_to"?l=this.pixelRatioTo:s==="u_pixel_ratio_from"&&(l=this.pixelRatioFrom),l!==null&&t.set(l)}getBinding(t,i,a){return a.substr(0,9)==="u_pattern"||a.substr(0,12)==="u_dasharray_"?new Vi(t,i):new Rr(t,i)}}class Xe{constructor(t,i,a,s){this.expression=t,this.type=a,this.maxValue=0,this.paintVertexAttributes=i.map(l=>({name:`a_${l}`,type:"Float32",components:a==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(t,i,a){const s=this.paintVertexArray.length,l=this.expression.evaluate(new le(0,a),i,{},a.canonical,[],a.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(s,t,l)}updatePaintArray(t,i,a,s,l){const u=this.expression.evaluate(new le(0,l),a,s);this._setPaintValue(t,i,u)}_setPaintValue(t,i,a){if(this.type==="color"){const s=Nn(a);for(let l=t;l<i;l++)this.paintVertexArray.emplace(l,s[0],s[1])}else{for(let s=t;s<i;s++)this.paintVertexArray.emplace(s,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}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 he{constructor(t,i,a,s,l,u){this.expression=t,this.uniformNames=i.map(f=>`u_${f}_t`),this.type=a,this.useIntegerZoom=s,this.zoom=l,this.maxValue=0,this.paintVertexAttributes=i.map(f=>({name:`a_${f}`,type:"Float32",components:a==="color"?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(t,i,a){const s=this.expression.evaluate(new le(this.zoom,a),i,{},a.canonical,[],a.formattedSection),l=this.expression.evaluate(new le(this.zoom+1,a),i,{},a.canonical,[],a.formattedSection),u=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(u,t,s,l)}updatePaintArray(t,i,a,s,l){const u=this.expression.evaluate(new le(this.zoom,l),a,s),f=this.expression.evaluate(new le(this.zoom+1,l),a,s);this._setPaintValue(t,i,u,f)}_setPaintValue(t,i,a,s){if(this.type==="color"){const l=Nn(a),u=Nn(s);for(let f=t;f<i;f++)this.paintVertexArray.emplace(f,l[0],l[1],u[0],u[1])}else{for(let l=t;l<i;l++)this.paintVertexArray.emplace(l,a,s);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(s))}}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,i){const a=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,s=wi(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);t.set(s)}getBinding(t,i,a){return new Rr(t,i)}}class un{constructor(t,i,a,s,l,u){this.expression=t,this.type=i,this.useIntegerZoom=a,this.zoom=s,this.layerId=u,this.zoomInPaintVertexArray=new l,this.zoomOutPaintVertexArray=new l}populatePaintArray(t,i,a){const s=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(s,t,this.getPositionIds(i),a)}updatePaintArray(t,i,a,s,l){this._setPaintValues(t,i,this.getPositionIds(a),l)}_setPaintValues(t,i,a,s){const l=this.getPositions(s);if(!l||!a)return;const u=l[a.min],f=l[a.mid],_=l[a.max];if(u&&f&&_)for(let y=t;y<i;y++)this.emplace(this.zoomInPaintVertexArray,y,f,u),this.emplace(this.zoomOutPaintVertexArray,y,f,_)}upload(t){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const i=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,i,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,i,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Qc extends un{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns&&t.patterns[this.layerId]}getVertexAttributes(){return ye.members}emplace(t,i,a,s){t.emplace(i,a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],s.tlbr[0],s.tlbr[1],s.tlbr[2],s.tlbr[3],a.pixelRatio,s.pixelRatio)}}class tu extends un{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes&&t.dashes[this.layerId]}getVertexAttributes(){return Ce.members}emplace(t,i,a,s){t.emplace(i,0,a.y,a.height,a.width,0,s.y,s.height,s.width)}}class eu{constructor(t,i,a){this.binders={},this._buffers=[];const s=[];for(const l in t.paint._values){if(!a(l))continue;const u=t.paint.get(l);if(!(u instanceof lr&&fa(u.property.specification)))continue;const f=ah(l,t.type),_=u.value,y=u.property.specification.type,v=u.property.useIntegerZoom,w=u.property.specification["property-type"],S=w==="cross-faded"||w==="cross-faded-data-driven";if(_.kind==="constant")this.binders[l]=S?new Ae(_.value,f):new Le(_.value,f,y),s.push(`/u_${l}`);else if(_.kind==="source"||S){const P=hn(l,y,"source");this.binders[l]=S?l==="line-dasharray"?new tu(_,y,v,i,P,t.id):new Qc(_,y,v,i,P,t.id):new Xe(_,f,y,P),s.push(`/a_${l}`)}else{const P=hn(l,y,"composite");this.binders[l]=new he(_,f,y,v,i,P),s.push(`/z_${l}`)}}this.cacheKey=s.sort().join("")}getMaxValue(t){const i=this.binders[t];return i instanceof Xe||i instanceof he?i.maxValue:0}populatePaintArrays(t,i,a){for(const s in this.binders){const l=this.binders[s];(l instanceof Xe||l instanceof he||l instanceof un)&&l.populatePaintArray(t,i,a)}}setConstantPatternPositions(t,i){for(const a in this.binders){const s=this.binders[a];s instanceof Ae&&s.setConstantPatternPositions(t,i)}}setConstantDashPositions(t,i){for(const a in this.binders){const s=this.binders[a];s instanceof Ae&&s.setConstantDashPositions(t,i)}}updatePaintArrays(t,i,a,s,l){let u=!1;for(const f in t){const _=i.getPositions(f);for(const y of _){const v=a.feature(y.index);for(const w in this.binders){const S=this.binders[w];if((S instanceof Xe||S instanceof he||S instanceof un)&&S.expression.isStateDependent===!0){const P=s.paint.get(w);S.expression=P.value,S.updatePaintArray(y.start,y.end,v,t[f],l),u=!0}}}}return u}defines(){const t=[];for(const i in this.binders){const a=this.binders[i];(a instanceof Le||a instanceof Ae)&&t.push(...a.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return t}getBinderAttributes(){const t=[];for(const i in this.binders){const a=this.binders[i];if(a instanceof Xe||a instanceof he)for(let s=0;s<a.paintVertexAttributes.length;s++)t.push(a.paintVertexAttributes[s].name);else if(a instanceof un){const s=a.getVertexAttributes();for(const l of s)t.push(l.name)}}return t}getBinderUniforms(){const t=[];for(const i in this.binders){const a=this.binders[i];if(a instanceof Le||a instanceof Ae||a instanceof he)for(const s of a.uniformNames)t.push(s)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,i){const a=[];for(const s in this.binders){const l=this.binders[s];if(l instanceof Le||l instanceof Ae||l instanceof he){for(const u of l.uniformNames)if(i[u]){const f=l.getBinding(t,i[u],u);a.push({name:u,property:s,binding:f})}}}return a}setUniforms(t,i,a,s){for(const{name:l,property:u,binding:f}of i)this.binders[u].setUniform(f,s,a.get(u),l)}updatePaintBuffers(t){this._buffers=[];for(const i in this.binders){const a=this.binders[i];if(t&&a instanceof un){const s=t.fromScale===2?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;s&&this._buffers.push(s)}else(a instanceof Xe||a instanceof he)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(t){for(const i in this.binders){const a=this.binders[i];(a instanceof Xe||a instanceof he||a instanceof un)&&a.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const i=this.binders[t];(i instanceof Xe||i instanceof he||i instanceof un)&&i.destroy()}}}class Un{constructor(t,i,a=()=>!0){this.programConfigurations={};for(const s of t)this.programConfigurations[s.id]=new eu(s,i,a);this.needsUpload=!1,this._featureMap=new Sr,this._bufferOffset=0}populatePaintArrays(t,i,a,s){for(const l in this.programConfigurations)this.programConfigurations[l].populatePaintArrays(t,i,s);i.id!==void 0&&this._featureMap.add(i.id,a,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,i,a,s){for(const l of a)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(t,this._featureMap,i,l,s)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function ah(r,t){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"]}[r]||[r.replace(`${t}-`,"").replace(/-/g,"_")]}function hn(r,t,i){const a={color:{source:ba,composite:c},number:{source:co,composite:ba}},s=function(l){return{"line-pattern":{source:H,composite:H},"fill-pattern":{source:H,composite:H},"fill-extrusion-pattern":{source:H,composite:H},"line-dasharray":{source:it,composite:it}}[l]}(r);return s&&s[i]||a[t][i]}Dt("ConstantBinder",Le),Dt("CrossFadedConstantBinder",Ae),Dt("SourceExpressionBinder",Xe),Dt("CrossFadedPatternBinder",Qc),Dt("CrossFadedDasharrayBinder",tu),Dt("CompositeExpressionBinder",he),Dt("ProgramConfiguration",eu,{omit:["_buffers"]}),Dt("ProgramConfigurationSet",Un);const uo=Math.pow(2,14)-1,El=-uo-1;function dn(r){const t=oe/r.extent,i=r.loadGeometry();for(let a=0;a<i.length;a++){const s=i[a];for(let l=0;l<s.length;l++){const u=s[l],f=Math.round(u.x*t),_=Math.round(u.y*t);u.x=wi(f,El,uo),u.y=wi(_,El,uo),(f<u.x||f>u.x+1||_<u.y||_>u.y+1)&&Pe("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Fr(r,t){return{type:r.type,id:r.id,properties:r.properties,geometry:t?dn(r):[]}}const Cl=-32768;function Al(r,t,i,a,s){r.emplaceBack(Cl+8*t+a,Cl+8*i+s)}class sh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new q,this.indexArray=new wt,this.segments=new Zt,this.programConfigurations=new Un(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,a){const s=this.layers[0],l=[];let u=null,f=!1,_=s.type==="heatmap";if(s.type==="circle"){const v=s;u=v.layout.get("circle-sort-key"),f=!u.isConstant(),_=_||v.paint.get("circle-pitch-alignment")==="map"}const y=_?i.subdivisionGranularity.circle:1;for(const{feature:v,id:w,index:S,sourceLayerIndex:P}of t){const M=this.layers[0]._featureFilter.needGeometry,C=Fr(v,M);if(!this.layers[0]._featureFilter.filter(new le(this.zoom),C,a))continue;const z=f?u.evaluate(C,{},a):void 0,F={id:w,properties:v.properties,type:v.type,sourceLayerIndex:P,index:S,geometry:M?C.geometry:dn(v),patterns:{},sortKey:z};l.push(F)}f&&l.sort((v,w)=>v.sortKey-w.sortKey);for(const v of l){const{geometry:w,index:S,sourceLayerIndex:P}=v,M=t[S].feature;this.addFeature(v,w,S,a,y),i.featureIndex.insert(M,w,S,P,this.index)}}update(t,i,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:a})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$t),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,i,a,s,l=1){let u;switch(l){case 1:u=[0,7];break;case 3:u=[0,2,5,7];break;case 5:u=[0,1,3,4,6,7];break;case 7:u=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${l}; valid values are 1, 3, 5, 7.`)}const f=u.length;for(const _ of i)for(const y of _){const v=y.x,w=y.y;if(v<0||v>=oe||w<0||w>=oe)continue;const S=this.segments.prepareSegment(f*f,this.layoutVertexArray,this.indexArray,t.sortKey),P=S.vertexLength;for(let M=0;M<f;M++)for(let C=0;C<f;C++)Al(this.layoutVertexArray,v,w,u[C],u[M]);for(let M=0;M<f-1;M++)for(let C=0;C<f-1;C++){const z=P+M*f+C,F=P+(M+1)*f+C;this.indexArray.emplaceBack(z,F+1,z+1),this.indexArray.emplaceBack(z,F,F+1)}S.vertexLength+=f*f,S.primitiveLength+=(f-1)*(f-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,a,{imagePositions:{},canonical:s})}}function rd(r,t){for(let i=0;i<r.length;i++)if(ho(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(ho(r,t[i]))return!0;return!!oh(r,t)}function iu(r,t,i){return!!ho(r,t)||!!lh(t,r,i)}function nd(r,t){if(r.length===1)return sd(t,r[0]);for(let i=0;i<t.length;i++){const a=t[i];for(let s=0;s<a.length;s++)if(ho(r,a[s]))return!0}for(let i=0;i<r.length;i++)if(sd(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(oh(r,t[i]))return!0;return!1}function df(r,t,i){if(r.length>1){if(oh(r,t))return!0;for(let a=0;a<t.length;a++)if(lh(t[a],r,i))return!0}for(let a=0;a<r.length;a++)if(lh(r[a],t,i))return!0;return!1}function oh(r,t){if(r.length===0||t.length===0)return!1;for(let i=0;i<r.length-1;i++){const a=r[i],s=r[i+1];for(let l=0;l<t.length-1;l++)if(pf(a,s,t[l],t[l+1]))return!0}return!1}function pf(r,t,i,a){return er(r,i,a)!==er(t,i,a)&&er(r,t,i)!==er(r,t,a)}function lh(r,t,i){const a=i*i;if(t.length===1)return r.distSqr(t[0])<a;for(let s=1;s<t.length;s++)if(ad(r,t[s-1],t[s])<a)return!0;return!1}function ad(r,t,i){const a=t.distSqr(i);if(a===0)return r.distSqr(t);const s=((r.x-t.x)*(i.x-t.x)+(r.y-t.y)*(i.y-t.y))/a;return r.distSqr(s<0?t:s>1?i:i.sub(t)._mult(s)._add(t))}function sd(r,t){let i,a,s,l=!1;for(let u=0;u<r.length;u++){i=r[u];for(let f=0,_=i.length-1;f<i.length;_=f++)a=i[f],s=i[_],a.y>t.y!=s.y>t.y&&t.x<(s.x-a.x)*(t.y-a.y)/(s.y-a.y)+a.x&&(l=!l)}return l}function ho(r,t){let i=!1;for(let a=0,s=r.length-1;a<r.length;s=a++){const l=r[a],u=r[s];l.y>t.y!=u.y>t.y&&t.x<(u.x-l.x)*(t.y-l.y)/(u.y-l.y)+l.x&&(i=!i)}return i}function ff(r,t,i){const a=i[0],s=i[2];if(r.x<a.x&&t.x<a.x||r.x>s.x&&t.x>s.x||r.y<a.y&&t.y<a.y||r.y>s.y&&t.y>s.y)return!1;const l=er(r,t,i[0]);return l!==er(r,t,i[1])||l!==er(r,t,i[2])||l!==er(r,t,i[3])}function po(r,t,i){const a=t.paint.get(r).value;return a.kind==="constant"?a.value:i.programConfigurations.get(t.id).getMaxValue(r)}function ru(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function nu(r,t,i,a,s){if(!t[0]&&!t[1])return r;const l=It.convert(t)._mult(s);i==="viewport"&&l._rotate(-a);const u=[];for(let f=0;f<r.length;f++)u.push(r[f].sub(l));return u}function mf({queryGeometry:r,size:t},i){return iu(r,i,t)}function _f({queryGeometry:r,size:t,transform:i,unwrappedTileID:a,getElevation:s},l){return iu(r,l,t*(i.projectTileCoordinates(l.x,l.y,a,s).signedDistanceFromCamera/i.cameraToCenterDistance))}function gf({queryGeometry:r,size:t,transform:i,unwrappedTileID:a,getElevation:s},l){const u=i.projectTileCoordinates(l.x,l.y,a,s).signedDistanceFromCamera,f=t*(i.cameraToCenterDistance/u);return iu(r,ch(l,i,a,s),f)}function yf({queryGeometry:r,size:t,transform:i,unwrappedTileID:a,getElevation:s},l){return iu(r,ch(l,i,a,s),t)}function od({queryGeometry:r,size:t,transform:i,unwrappedTileID:a,getElevation:s,pitchAlignment:l="map",pitchScale:u="map"},f){const _=l==="map"?u==="map"?mf:_f:u==="map"?gf:yf,y={queryGeometry:r,size:t,transform:i,unwrappedTileID:a,getElevation:s};for(const v of f)for(const w of v)if(_(y,w))return!0;return!1}function ch(r,t,i,a){const s=t.projectTileCoordinates(r.x,r.y,i,a).point;return new It((.5*s.x+.5)*t.width,(.5*-s.y+.5)*t.height)}let ld,cd;Dt("CircleBucket",sh,{omit:["layers"]});var xf={get paint(){return cd=cd||new _i({"circle-radius":new Vt(U.paint_circle["circle-radius"]),"circle-color":new Vt(U.paint_circle["circle-color"]),"circle-blur":new Vt(U.paint_circle["circle-blur"]),"circle-opacity":new Vt(U.paint_circle["circle-opacity"]),"circle-translate":new Ft(U.paint_circle["circle-translate"]),"circle-translate-anchor":new Ft(U.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Ft(U.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Ft(U.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Vt(U.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Vt(U.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Vt(U.paint_circle["circle-stroke-opacity"])})},get layout(){return ld=ld||new _i({"circle-sort-key":new Vt(U.layout_circle["circle-sort-key"])})}};class vf extends Hi{constructor(t,i){super(t,xf,i)}createBucket(t){return new sh(t)}queryRadius(t){const i=t;return po("circle-radius",this,i)+po("circle-stroke-width",this,i)+ru(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:a,geometry:s,transform:l,pixelsToTileUnits:u,unwrappedTileID:f,getElevation:_}){const y=nu(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-l.bearingInRadians,u),v=this.paint.get("circle-radius").evaluate(i,a)+this.paint.get("circle-stroke-width").evaluate(i,a),w=this.paint.get("circle-pitch-scale"),S=this.paint.get("circle-pitch-alignment");let P,M;return S==="map"?(P=y,M=v*u):(P=function(C,z,F,Z){return C.map(O=>ch(O,z,F,Z))}(y,l,f,_),M=v),od({queryGeometry:P,size:M,transform:l,unwrappedTileID:f,getElevation:_,pitchAlignment:S,pitchScale:w},s)}}class ud extends sh{}let hd;Dt("HeatmapBucket",ud,{omit:["layers"]});var bf={get paint(){return hd=hd||new _i({"heatmap-radius":new Vt(U.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Vt(U.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ft(U.paint_heatmap["heatmap-intensity"]),"heatmap-color":new us(U.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ft(U.paint_heatmap["heatmap-opacity"])})}};function uh(r,{width:t,height:i},a,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==t*i*a)throw new RangeError(`mismatched image size. expected: ${s.length} but got: ${t*i*a}`)}else s=new Uint8Array(t*i*a);return r.width=t,r.height=i,r.data=s,r}function dd(r,{width:t,height:i},a){if(t===r.width&&i===r.height)return;const s=uh({},{width:t,height:i},a);hh(r,s,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,t),height:Math.min(r.height,i)},a),r.width=t,r.height=i,r.data=s.data}function hh(r,t,i,a,s,l){if(s.width===0||s.height===0)return t;if(s.width>r.width||s.height>r.height||i.x>r.width-s.width||i.y>r.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>t.width||s.height>t.height||a.x>t.width-s.width||a.y>t.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const u=r.data,f=t.data;if(u===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<s.height;_++){const y=((i.y+_)*r.width+i.x)*l,v=((a.y+_)*t.width+a.x)*l;for(let w=0;w<s.width*l;w++)f[v+w]=u[y+w]}return t}class Dl{constructor(t,i){uh(this,t,1,i)}resize(t){dd(this,t,1)}clone(){return new Dl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,a,s,l){hh(t,i,a,s,l,1)}}class Ni{constructor(t,i){uh(this,t,4,i)}resize(t){dd(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Ni({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,a,s,l){hh(t,i,a,s,l,4)}setPixel(t,i,a){const s=4*(t*this.width+i);this.data[s+0]=Math.round(255*a.r/a.a),this.data[s+1]=Math.round(255*a.g/a.a),this.data[s+2]=Math.round(255*a.b/a.a),this.data[s+3]=Math.round(255*a.a)}}function pd(r){const t={},i=r.resolution||256,a=r.clips?r.clips.length:1,s=r.image||new Ni({width:i,height:a});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const l=(u,f,_)=>{t[r.evaluationKey]=_;const y=r.expression.evaluate(t);s.setPixel(u/4/i,f/4,y)};if(r.clips)for(let u=0,f=0;u<a;++u,f+=4*i)for(let _=0,y=0;_<i;_++,y+=4){const v=_/(i-1),{start:w,end:S}=r.clips[u];l(f,y,w*(1-v)+S*v)}else for(let u=0,f=0;u<i;u++,f+=4)l(0,f,u/(i-1));return s}Dt("AlphaImage",Dl),Dt("RGBAImage",Ni);const dh="big-fb";class wf extends Hi{createBucket(t){return new ud(t)}constructor(t,i){super(t,bf,i),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=pd({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(dh)&&this.heatmapFbos.delete(dh)}queryRadius(t){return po("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:a,geometry:s,transform:l,pixelsToTileUnits:u,unwrappedTileID:f,getElevation:_}){return od({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(i,a)*u,transform:l,unwrappedTileID:f,getElevation:_},s)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let fd;var Tf={get paint(){return fd=fd||new _i({"hillshade-illumination-direction":new Ft(U.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Ft(U.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Ft(U.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Ft(U.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Ft(U.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Ft(U.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Ft(U.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Ft(U.paint_hillshade["hillshade-method"])})}};class Sf extends Hi{constructor(t,i){super(t,Tf,i),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,a=this.paint.get("hillshade-highlight-color").values,s=this.paint.get("hillshade-shadow-color").values;const l=Math.max(t.length,i.length,a.length,s.length);t=t.concat(Array(l-t.length).fill(t.at(-1))),i=i.concat(Array(l-i.length).fill(i.at(-1))),a=a.concat(Array(l-a.length).fill(a.at(-1))),s=s.concat(Array(l-s.length).fill(s.at(-1)));const u=i.map(bn);return{directionRadians:t.map(bn),altitudeRadians:u,shadowColor:s,highlightColor:a}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}let md;var Pf={get paint(){return md=md||new _i({"color-relief-opacity":new Ft(U["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new us(U["paint_color-relief"]["color-relief-color"])})}};class ph{constructor(t,i,a,s){this.context=t,this.format=a,this.texture=t.gl.createTexture(),this.update(i,s)}update(t,i,a){const{width:s,height:l}=t,u=!(this.size&&this.size[0]===s&&this.size[1]===l||a),{context:f}=this,{gl:_}=f;if(this.useMipmap=!!(i&&i.useMipmap),_.bindTexture(_.TEXTURE_2D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1),f.pixelStoreUnpackPremultiplyAlpha.set(this.format===_.RGBA&&(!i||i.premultiply!==!1)),u)this.size=[s,l],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||mr(t)?_.texImage2D(_.TEXTURE_2D,0,this.format,this.format,_.UNSIGNED_BYTE,t):_.texImage2D(_.TEXTURE_2D,0,this.format,s,l,0,this.format,_.UNSIGNED_BYTE,t.data);else{const{x:y,y:v}=a||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||mr(t)?_.texSubImage2D(_.TEXTURE_2D,0,y,v,_.RGBA,_.UNSIGNED_BYTE,t):_.texSubImage2D(_.TEXTURE_2D,0,y,v,s,l,_.RGBA,_.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&_.generateMipmap(_.TEXTURE_2D),f.pixelStoreUnpackFlipY.setDefault(),f.pixelStoreUnpack.setDefault(),f.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(t,i,a){const{context:s}=this,{gl:l}=s;l.bindTexture(l.TEXTURE_2D,this.texture),a!==l.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=l.LINEAR),t!==this.filter&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,t),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,a||t),this.filter=t),i!==this.wrap&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,i),this.wrap=i)}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 _d{constructor(t,i,a,s=1,l=1,u=1,f=0){if(this.uid=t,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(a&&!["mapbox","terrarium","custom"].includes(a))return void Pe(`"${a}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;const _=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),a){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=s,this.greenFactor=l,this.blueFactor=u,this.baseShift=f;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let y=0;y<_;y++)this.data[this._idx(-1,y)]=this.data[this._idx(0,y)],this.data[this._idx(_,y)]=this.data[this._idx(_-1,y)],this.data[this._idx(y,-1)]=this.data[this._idx(y,0)],this.data[this._idx(y,_)]=this.data[this._idx(y,_-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(_,-1)]=this.data[this._idx(_-1,0)],this.data[this._idx(-1,_)]=this.data[this._idx(0,_-1)],this.data[this._idx(_,_)]=this.data[this._idx(_-1,_-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let y=0;y<_;y++)for(let v=0;v<_;v++){const w=this.get(y,v);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(t,i){const a=new Uint8Array(this.data.buffer),s=4*this._idx(t,i);return this.unpack(a[s],a[s+1],a[s+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,i){if(t<-1||t>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(t+1)}unpack(t,i,a){return t*this.redFactor+i*this.greenFactor+a*this.blueFactor-this.baseShift}pack(t){return gd(t,this.getUnpackVector())}getPixels(){return new Ni({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,i,a){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let s=i*this.dim,l=i*this.dim+this.dim,u=a*this.dim,f=a*this.dim+this.dim;switch(i){case-1:s=l-1;break;case 1:l=s+1}switch(a){case-1:u=f-1;break;case 1:f=u+1}const _=-i*this.dim,y=-a*this.dim;for(let v=u;v<f;v++)for(let w=s;w<l;w++)this.data[this._idx(w,v)]=t.data[this._idx(w+_,v+y)]}}function gd(r,t){const i=t[0],a=t[1],s=t[2],l=t[3],u=Math.min(i,a,s),f=Math.round((r+l)/u);return{r:Math.floor(f*u/i)%256,g:Math.floor(f*u/a)%256,b:Math.floor(f*u/s)%256}}Dt("DEMData",_d);class Mf extends Hi{constructor(t,i){super(t,Pf,i)}_createColorRamp(t){const i={elevationStops:[],colorStops:[]},a=this._transitionablePaint._values["color-relief-color"].value.expression;if(a instanceof kn&&a._styleExpression.expression instanceof li){this.colorRampExpression=a;const u=a._styleExpression.expression;i.elevationStops=u.labels,i.colorStops=[];for(const f of i.elevationStops)i.colorStops.push(u.evaluate({globals:{elevation:f}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[Kt.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=t)return i;const s={elevationStops:[],colorStops:[]},l=(i.elevationStops.length-1)/(t-1);for(let u=0;u<i.elevationStops.length-.5;u+=l)s.elevationStops.push(i.elevationStops[Math.round(u)]),s.colorStops.push(i.colorStops[Math.round(u)]);return Pe(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${i.elevationStops.length}`),s}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,i,a){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const s=this._createColorRamp(i),l=new Ni({width:s.colorStops.length,height:1}),u=new Ni({width:s.colorStops.length,height:1});for(let f=0;f<s.elevationStops.length;f++){const _=gd(s.elevationStops[f],a);u.setPixel(0,f,new Kt(_.r/255,_.g/255,_.b/255,1)),l.setPixel(0,f,s.colorStops[f])}return this.colorRampTextures={elevationTexture:new ph(t,u,t.gl.RGBA),colorTexture:new ph(t,l,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return this.visibility!=="none"&&!!this.colorRampTextures}}const If=Be([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ef}=If;function au(r,t,i){const a=i.patternDependencies;let s=!1;for(const l of t){const u=l.paint.get(`${r}-pattern`);u.isConstant()||(s=!0);const f=u.constantOr(null);f&&(s=!0,a[f.to]=!0,a[f.from]=!0)}return s}function fh(r,t,i,a,s){const{zoom:l}=a,u=s.patternDependencies;for(const f of t){const _=f.paint.get(`${r}-pattern`).value;if(_.kind!=="constant"){let y=_.evaluate({zoom:l-1},i,{},s.availableImages),v=_.evaluate({zoom:l},i,{},s.availableImages),w=_.evaluate({zoom:l+1},i,{},s.availableImages);y=y&&y.name?y.name:y,v=v&&v.name?v.name:v,w=w&&w.name?w.name:w,u[y]=!0,u[v]=!0,u[w]=!0,i.patterns[f.id]={min:y,mid:v,max:w}}}return i}function yd(r,t,i,a,s){let l;if(s===function(u,f,_,y){let v=0;for(let w=f,S=_-y;w<_;w+=y)v+=(u[S]-u[w])*(u[w+1]+u[S+1]),S=w;return v}(r,t,i,a)>0)for(let u=t;u<i;u+=a)l=wd(u/a|0,r[u],r[u+1],l);else for(let u=i-a;u>=t;u-=a)l=wd(u/a|0,r[u],r[u+1],l);return l&&fo(l,l.next)&&(Ll(l),l=l.next),l}function _s(r,t){if(!r)return r;t||(t=r);let i,a=r;do if(i=!1,a.steiner||!fo(a,a.next)&&Ge(a.prev,a,a.next)!==0)a=a.next;else{if(Ll(a),a=t=a.prev,a===a.next)break;i=!0}while(i||a!==t);return t}function zl(r,t,i,a,s,l,u){if(!r)return;!u&&l&&function(_,y,v,w){let S=_;do S.z===0&&(S.z=mh(S.x,S.y,y,v,w)),S.prevZ=S.prev,S.nextZ=S.next,S=S.next;while(S!==_);S.prevZ.nextZ=null,S.prevZ=null,function(P){let M,C=1;do{let z,F=P;P=null;let Z=null;for(M=0;F;){M++;let O=F,N=0;for(let et=0;et<C&&(N++,O=O.nextZ,O);et++);let Q=C;for(;N>0||Q>0&&O;)N!==0&&(Q===0||!O||F.z<=O.z)?(z=F,F=F.nextZ,N--):(z=O,O=O.nextZ,Q--),Z?Z.nextZ=z:P=z,z.prevZ=Z,Z=z;F=O}Z.nextZ=null,C*=2}while(M>1)}(S)}(r,a,s,l);let f=r;for(;r.prev!==r.next;){const _=r.prev,y=r.next;if(l?Af(r,a,s,l):Cf(r))t.push(_.i,r.i,y.i),Ll(r),r=y.next,f=y.next;else if((r=y)===f){u?u===1?zl(r=Df(_s(r),t),t,i,a,s,l,2):u===2&&zf(r,t,i,a,s,l):zl(_s(r),t,i,a,s,l,1);break}}}function Cf(r){const t=r.prev,i=r,a=r.next;if(Ge(t,i,a)>=0)return!1;const s=t.x,l=i.x,u=a.x,f=t.y,_=i.y,y=a.y,v=Math.min(s,l,u),w=Math.min(f,_,y),S=Math.max(s,l,u),P=Math.max(f,_,y);let M=a.next;for(;M!==t;){if(M.x>=v&&M.x<=S&&M.y>=w&&M.y<=P&&kl(s,f,l,_,u,y,M.x,M.y)&&Ge(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function Af(r,t,i,a){const s=r.prev,l=r,u=r.next;if(Ge(s,l,u)>=0)return!1;const f=s.x,_=l.x,y=u.x,v=s.y,w=l.y,S=u.y,P=Math.min(f,_,y),M=Math.min(v,w,S),C=Math.max(f,_,y),z=Math.max(v,w,S),F=mh(P,M,t,i,a),Z=mh(C,z,t,i,a);let O=r.prevZ,N=r.nextZ;for(;O&&O.z>=F&&N&&N.z<=Z;){if(O.x>=P&&O.x<=C&&O.y>=M&&O.y<=z&&O!==s&&O!==u&&kl(f,v,_,w,y,S,O.x,O.y)&&Ge(O.prev,O,O.next)>=0||(O=O.prevZ,N.x>=P&&N.x<=C&&N.y>=M&&N.y<=z&&N!==s&&N!==u&&kl(f,v,_,w,y,S,N.x,N.y)&&Ge(N.prev,N,N.next)>=0))return!1;N=N.nextZ}for(;O&&O.z>=F;){if(O.x>=P&&O.x<=C&&O.y>=M&&O.y<=z&&O!==s&&O!==u&&kl(f,v,_,w,y,S,O.x,O.y)&&Ge(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;N&&N.z<=Z;){if(N.x>=P&&N.x<=C&&N.y>=M&&N.y<=z&&N!==s&&N!==u&&kl(f,v,_,w,y,S,N.x,N.y)&&Ge(N.prev,N,N.next)>=0)return!1;N=N.nextZ}return!0}function Df(r,t){let i=r;do{const a=i.prev,s=i.next.next;!fo(a,s)&&vd(a,i,i.next,s)&&Rl(a,s)&&Rl(s,a)&&(t.push(a.i,i.i,s.i),Ll(i),Ll(i.next),i=r=s),i=i.next}while(i!==r);return _s(i)}function zf(r,t,i,a,s,l){let u=r;do{let f=u.next.next;for(;f!==u.prev;){if(u.i!==f.i&&Bf(u,f)){let _=bd(u,f);return u=_s(u,u.next),_=_s(_,_.next),zl(u,t,i,a,s,l,0),void zl(_,t,i,a,s,l,0)}f=f.next}u=u.next}while(u!==r)}function kf(r,t){let i=r.x-t.x;return i===0&&(i=r.y-t.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Rf(r,t){const i=function(s,l){let u=l;const f=s.x,_=s.y;let y,v=-1/0;if(fo(s,u))return u;do{if(fo(s,u.next))return u.next;if(_<=u.y&&_>=u.next.y&&u.next.y!==u.y){const C=u.x+(_-u.y)*(u.next.x-u.x)/(u.next.y-u.y);if(C<=f&&C>v&&(v=C,y=u.x<u.next.x?u:u.next,C===f))return y}u=u.next}while(u!==l);if(!y)return null;const w=y,S=y.x,P=y.y;let M=1/0;u=y;do{if(f>=u.x&&u.x>=S&&f!==u.x&&xd(_<P?f:v,_,S,P,_<P?v:f,_,u.x,u.y)){const C=Math.abs(_-u.y)/(f-u.x);Rl(u,s)&&(C<M||C===M&&(u.x>y.x||u.x===y.x&&Lf(y,u)))&&(y=u,M=C)}u=u.next}while(u!==w);return y}(r,t);if(!i)return t;const a=bd(i,r);return _s(a,a.next),_s(i,i.next)}function Lf(r,t){return Ge(r.prev,r,t.prev)<0&&Ge(t.next,r,r.next)<0}function mh(r,t,i,a,s){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*s|0)|r<<8))|r<<4))|r<<2))|r<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-a)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ff(r){let t=r,i=r;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==r);return i}function xd(r,t,i,a,s,l,u,f){return(s-u)*(t-f)>=(r-u)*(l-f)&&(r-u)*(a-f)>=(i-u)*(t-f)&&(i-u)*(l-f)>=(s-u)*(a-f)}function kl(r,t,i,a,s,l,u,f){return!(r===u&&t===f)&&xd(r,t,i,a,s,l,u,f)}function Bf(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!function(i,a){let s=i;do{if(s.i!==i.i&&s.next.i!==i.i&&s.i!==a.i&&s.next.i!==a.i&&vd(s,s.next,i,a))return!0;s=s.next}while(s!==i);return!1}(r,t)&&(Rl(r,t)&&Rl(t,r)&&function(i,a){let s=i,l=!1;const u=(i.x+a.x)/2,f=(i.y+a.y)/2;do s.y>f!=s.next.y>f&&s.next.y!==s.y&&u<(s.next.x-s.x)*(f-s.y)/(s.next.y-s.y)+s.x&&(l=!l),s=s.next;while(s!==i);return l}(r,t)&&(Ge(r.prev,r,t.prev)||Ge(r,t.prev,t))||fo(r,t)&&Ge(r.prev,r,r.next)>0&&Ge(t.prev,t,t.next)>0)}function Ge(r,t,i){return(t.y-r.y)*(i.x-t.x)-(t.x-r.x)*(i.y-t.y)}function fo(r,t){return r.x===t.x&&r.y===t.y}function vd(r,t,i,a){const s=ou(Ge(r,t,i)),l=ou(Ge(r,t,a)),u=ou(Ge(i,a,r)),f=ou(Ge(i,a,t));return s!==l&&u!==f||!(s!==0||!su(r,i,t))||!(l!==0||!su(r,a,t))||!(u!==0||!su(i,r,a))||!(f!==0||!su(i,t,a))}function su(r,t,i){return t.x<=Math.max(r.x,i.x)&&t.x>=Math.min(r.x,i.x)&&t.y<=Math.max(r.y,i.y)&&t.y>=Math.min(r.y,i.y)}function ou(r){return r>0?1:r<0?-1:0}function Rl(r,t){return Ge(r.prev,r,r.next)<0?Ge(r,t,r.next)>=0&&Ge(r,r.prev,t)>=0:Ge(r,t,r.prev)<0||Ge(r,r.next,t)<0}function bd(r,t){const i=_h(r.i,r.x,r.y),a=_h(t.i,t.x,t.y),s=r.next,l=t.prev;return r.next=t,t.prev=r,i.next=s,s.prev=i,a.next=i,i.prev=a,l.next=a,a.prev=l,a}function wd(r,t,i,a){const s=_h(r,t,i);return a?(s.next=a.next,s.prev=a,a.next.prev=s,a.next=s):(s.prev=s,s.next=s),s}function Ll(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function _h(r,t,i){return{i:r,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class mo{constructor(t,i){if(i>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=i}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class lu{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}lu.noSubdivision=new lu({fill:new mo(0,0),line:new mo(0,0),tile:new mo(0,0),stencil:new mo(0,0),circle:1}),Dt("SubdivisionGranularityExpression",mo),Dt("SubdivisionGranularitySetting",lu);const _o=-32768,Fl=32767;class Of{constructor(t,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=oe/t,this._canonical=i}_getKey(t,i){return(t+=32768)<<16|i+32768}_vertexToIndex(t,i){if(t<-32768||i<-32768||t>32767||i>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const a=0|Math.round(t),s=0|Math.round(i),l=this._getKey(a,s);if(this._vertexDictionary.has(l))return this._vertexDictionary.get(l);const u=this._vertexBuffer.length/2;return this._vertexDictionary.set(l,u),this._vertexBuffer.push(a,s),u}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(s,l){const u=[];for(let f=0;f<l.length;f+=3){const _=l[f],y=l[f+1],v=l[f+2],w=s[2*_],S=s[2*_+1];(s[2*y]-w)*(s[2*v+1]-S)-(s[2*y+1]-S)*(s[2*v]-w)>0?(u.push(_),u.push(v),u.push(y)):(u.push(_),u.push(y),u.push(v))}return u}(this._vertexBuffer,t);const i=[],a=t.length;for(let s=0;s<a;s+=3){const l=[t[s+0],t[s+1],t[s+2]],u=[this._vertexBuffer[2*t[s+0]+0],this._vertexBuffer[2*t[s+0]+1],this._vertexBuffer[2*t[s+1]+0],this._vertexBuffer[2*t[s+1]+1],this._vertexBuffer[2*t[s+2]+0],this._vertexBuffer[2*t[s+2]+1]];let f=1/0,_=1/0,y=-1/0,v=-1/0;for(let C=0;C<3;C++){const z=u[2*C],F=u[2*C+1];f=Math.min(f,z),y=Math.max(y,z),_=Math.min(_,F),v=Math.max(v,F)}if(f===y||_===v)continue;const w=Math.floor(f/this._granularityCellSize),S=Math.ceil(y/this._granularityCellSize),P=Math.floor(_/this._granularityCellSize),M=Math.ceil(v/this._granularityCellSize);if(w!==S||P!==M)for(let C=P;C<M;C++){const z=this._scanlineGenerateVertexRingForCellRow(C,u,l);jf(this._vertexBuffer,z,i)}else i.push(...l)}return i}_scanlineGenerateVertexRingForCellRow(t,i,a){const s=t*this._granularityCellSize,l=s+this._granularityCellSize,u=[];for(let f=0;f<3;f++){const _=i[2*f],y=i[2*f+1],v=i[2*(f+1)%6],w=i[(2*(f+1)+1)%6],S=i[2*(f+2)%6],P=i[(2*(f+2)+1)%6],M=v-_,C=w-y,z=M===0,F=C===0,Z=(s-y)/C,O=(l-y)/C,N=Math.min(Z,O),Q=Math.max(Z,O);if(!F&&(N>=1||Q<=0)||F&&(y<s||y>l)){w>=s&&w<=l&&u.push(a[(f+1)%3]);continue}!F&&N>0&&u.push(this._vertexToIndex(_+M*N,y+C*N));const et=_+M*Math.max(N,0),lt=_+M*Math.min(Q,1);z||this._generateIntraEdgeVertices(u,_,y,v,w,et,lt),!F&&Q<1&&u.push(this._vertexToIndex(_+M*Q,y+C*Q)),(F||w>=s&&w<=l)&&u.push(a[(f+1)%3]),!F&&(w<=s||w>=l)&&this._generateInterEdgeVertices(u,_,y,v,w,S,P,lt,s,l)}return u}_generateIntraEdgeVertices(t,i,a,s,l,u,f){const _=s-i,y=l-a,v=y===0,w=v?Math.min(i,s):Math.min(u,f),S=v?Math.max(i,s):Math.max(u,f),P=Math.floor(w/this._granularityCellSize)+1,M=Math.ceil(S/this._granularityCellSize)-1;if(v?i<s:u<f)for(let C=P;C<=M;C++){const z=C*this._granularityCellSize;t.push(this._vertexToIndex(z,a+y*(z-i)/_))}else for(let C=M;C>=P;C--){const z=C*this._granularityCellSize;t.push(this._vertexToIndex(z,a+y*(z-i)/_))}}_generateInterEdgeVertices(t,i,a,s,l,u,f,_,y,v){const w=l-a,S=u-s,P=f-l,M=(y-l)/P,C=(v-l)/P,z=Math.min(M,C),F=Math.max(M,C),Z=s+S*z;let O=Math.floor(Math.min(Z,_)/this._granularityCellSize)+1,N=Math.ceil(Math.max(Z,_)/this._granularityCellSize)-1,Q=_<Z;const et=P===0;if(et&&(f===y||f===v))return;if(et||z>=1||F<=0){const yt=a-f,mt=u+(i-u)*Math.min((y-f)/yt,(v-f)/yt);O=Math.floor(Math.min(mt,_)/this._granularityCellSize)+1,N=Math.ceil(Math.max(mt,_)/this._granularityCellSize)-1,Q=_<mt}const lt=w>0?v:y;if(Q)for(let yt=O;yt<=N;yt++)t.push(this._vertexToIndex(yt*this._granularityCellSize,lt));else for(let yt=N;yt>=O;yt--)t.push(this._vertexToIndex(yt*this._granularityCellSize,lt))}_generateOutline(t){const i=[];for(const a of t){const s=gs(a,this._granularity,!0),l=this._pointArrayToIndices(s),u=[];for(let f=1;f<l.length;f++)u.push(l[f-1]),u.push(l[f]);i.push(u)}return i}_handlePoles(t){let i=!1,a=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(a=!0)),(i||a)&&this._fillPoles(t,i,a)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let i=0;i<t.length;i+=2){const a=t[i+1];a===_o&&(t[i+1]=-32767),a===Fl&&(t[i+1]=32766)}}_generatePoleQuad(t,i,a,s,l,u){s>l!=(u===_o)?(t.push(i),t.push(a),t.push(this._vertexToIndex(s,u)),t.push(a),t.push(this._vertexToIndex(l,u)),t.push(this._vertexToIndex(s,u))):(t.push(a),t.push(i),t.push(this._vertexToIndex(s,u)),t.push(this._vertexToIndex(l,u)),t.push(a),t.push(this._vertexToIndex(s,u)))}_fillPoles(t,i,a){const s=this._vertexBuffer,l=oe,u=t.length;for(let f=2;f<u;f+=3){const _=t[f-2],y=t[f-1],v=t[f],w=s[2*_],S=s[2*_+1],P=s[2*y],M=s[2*y+1],C=s[2*v],z=s[2*v+1];i&&(S===0&&M===0&&this._generatePoleQuad(t,_,y,w,P,_o),M===0&&z===0&&this._generatePoleQuad(t,y,v,P,C,_o),z===0&&S===0&&this._generatePoleQuad(t,v,_,C,w,_o)),a&&(S===l&&M===l&&this._generatePoleQuad(t,_,y,w,P,Fl),M===l&&z===l&&this._generatePoleQuad(t,y,v,P,C,Fl),z===l&&S===l&&this._generatePoleQuad(t,v,_,C,w,Fl))}}_initializeVertices(t){for(let i=0;i<t.length;i+=2)this._vertexToIndex(t[i],t[i+1])}subdividePolygonInternal(t,i){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:a,holeIndices:s}=function(f){const _=[],y=[];for(const v of f)if(v.length!==0){v!==f[0]&&_.push(y.length/2);for(let w=0;w<v.length;w++)y.push(v[w].x),y.push(v[w].y)}return{flattened:y,holeIndices:_}}(t);let l;this._initializeVertices(a);try{const f=function(y,v,w=2){const S=v&&v.length,P=S?v[0]*w:y.length;let M=yd(y,0,P,w,!0);const C=[];if(!M||M.next===M.prev)return C;let z,F,Z;if(S&&(M=function(O,N,Q,et){const lt=[];for(let yt=0,mt=N.length;yt<mt;yt++){const vt=yd(O,N[yt]*et,yt<mt-1?N[yt+1]*et:O.length,et,!1);vt===vt.next&&(vt.steiner=!0),lt.push(Ff(vt))}lt.sort(kf);for(let yt=0;yt<lt.length;yt++)Q=Rf(lt[yt],Q);return Q}(y,v,M,w)),y.length>80*w){z=y[0],F=y[1];let O=z,N=F;for(let Q=w;Q<P;Q+=w){const et=y[Q],lt=y[Q+1];et<z&&(z=et),lt<F&&(F=lt),et>O&&(O=et),lt>N&&(N=lt)}Z=Math.max(O-z,N-F),Z=Z!==0?32767/Z:0}return zl(M,C,w,z,F,Z,0),C}(a,s),_=this._convertIndices(a,f);l=this._subdivideTrianglesScanline(_)}catch(f){console.error(f)}let u=[];return i&&(u=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(l),{verticesFlattened:this._vertexBuffer,indicesTriangles:l,indicesLineList:u}}_convertIndices(t,i){const a=[];for(let s=0;s<i.length;s++)a.push(this._vertexToIndex(t[2*i[s]],t[2*i[s]+1]));return a}_pointArrayToIndices(t){const i=[];for(let a=0;a<t.length;a++){const s=t[a];i.push(this._vertexToIndex(s.x,s.y))}return i}}function Td(r,t,i,a=!0){return new Of(i,t).subdividePolygonInternal(r,a)}function gs(r,t,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const a=r[0],s=r[r.length-1],l=i&&(a.x!==s.x||a.y!==s.y);if(t<2)return l?[...r,r[0]]:[...r];const u=Math.floor(oe/t),f=[];f.push(new It(r[0].x,r[0].y));const _=r.length,y=l?_:_-1;for(let v=0;v<y;v++){const w=r[v],S=v<_-1?r[v+1]:r[0],P=w.x,M=w.y,C=S.x,z=S.y,F=P!==C,Z=M!==z;if(!F&&!Z)continue;const O=C-P,N=z-M,Q=Math.abs(O),et=Math.abs(N);let lt=P,yt=M;for(;;){const vt=O>0?(Math.floor(lt/u)+1)*u:(Math.ceil(lt/u)-1)*u,Ct=N>0?(Math.floor(yt/u)+1)*u:(Math.ceil(yt/u)-1)*u,St=Math.abs(lt-vt),Pt=Math.abs(yt-Ct),_t=Math.abs(lt-C),Bt=Math.abs(yt-z),Ot=F?St/Q:Number.POSITIVE_INFINITY,Nt=Z?Pt/et:Number.POSITIVE_INFINITY;if((_t<=St||!F)&&(Bt<=Pt||!Z))break;if(Ot<Nt&&F||!Z){lt=vt,yt+=N*Ot;const kt=new It(lt,Math.round(yt));f[f.length-1].x===kt.x&&f[f.length-1].y===kt.y||f.push(kt)}else{lt+=O*Nt,yt=Ct;const kt=new It(Math.round(lt),yt);f[f.length-1].x===kt.x&&f[f.length-1].y===kt.y||f.push(kt)}}const mt=new It(C,z);f[f.length-1].x===mt.x&&f[f.length-1].y===mt.y||f.push(mt)}return f}function jf(r,t,i){if(t.length===0)throw new Error("Subdivision vertex ring is empty.");let a=0,s=r[2*t[0]];for(let _=1;_<t.length;_++){const y=r[2*t[_]];y<s&&(s=y,a=_)}const l=t.length;let u=a,f=(u+1)%l;for(;;){const _=u-1>=0?u-1:l-1,y=(f+1)%l,v=r[2*t[_]],w=r[2*t[y]],S=r[2*t[u]],P=r[2*t[u]+1],M=r[2*t[f]+1];let C=!1;if(v<w)C=!0;else if(v>w)C=!1;else{const z=M-P,F=-(r[2*t[f]]-S),Z=P<M?1:-1;((v-S)*z+(r[2*t[_]+1]-P)*F)*Z>((w-S)*z+(r[2*t[y]+1]-P)*F)*Z&&(C=!0)}if(C){const z=t[_],F=t[u],Z=t[f];z!==F&&z!==Z&&F!==Z&&i.push(Z,F,z),u--,u<0&&(u=l-1)}else{const z=t[y],F=t[u],Z=t[f];z!==F&&z!==Z&&F!==Z&&i.push(Z,F,z),f++,f>=l&&(f=0)}if(_===y)break}}function Sd(r,t,i,a,s,l,u,f,_){const y=s.length/2,v=u&&f&&_;if(y<Zt.MAX_VERTEX_ARRAY_LENGTH){const w=t.prepareSegment(y,i,a),S=w.vertexLength;for(let C=0;C<l.length;C+=3)a.emplaceBack(S+l[C],S+l[C+1],S+l[C+2]);let P,M;w.vertexLength+=y,w.primitiveLength+=l.length/3,v&&(M=u.prepareSegment(y,i,f),P=M.vertexLength,M.vertexLength+=y);for(let C=0;C<s.length;C+=2)r(s[C],s[C+1]);if(v)for(let C=0;C<_.length;C++){const z=_[C];for(let F=1;F<z.length;F+=2)f.emplaceBack(P+z[F-1],P+z[F]);M.primitiveLength+=z.length/2}}else(function(w,S,P,M,C,z){const F=[];for(let et=0;et<M.length/2;et++)F.push(-1);const Z={count:0};let O=0,N=w.getOrCreateLatestSegment(S,P),Q=N.vertexLength;for(let et=2;et<C.length;et+=3){const lt=C[et-2],yt=C[et-1],mt=C[et];let vt=F[lt]<O,Ct=F[yt]<O,St=F[mt]<O;N.vertexLength+((vt?1:0)+(Ct?1:0)+(St?1:0))>Zt.MAX_VERTEX_ARRAY_LENGTH&&(N=w.createNewSegment(S,P),O=Z.count,vt=!0,Ct=!0,St=!0,Q=0);const Pt=Bl(F,M,z,Z,lt,vt,N),_t=Bl(F,M,z,Z,yt,Ct,N),Bt=Bl(F,M,z,Z,mt,St,N);P.emplaceBack(Q+Pt-O,Q+_t-O,Q+Bt-O),N.primitiveLength++}})(t,i,a,s,l,r),v&&function(w,S,P,M,C,z){const F=[];for(let et=0;et<M.length/2;et++)F.push(-1);const Z={count:0};let O=0,N=w.getOrCreateLatestSegment(S,P),Q=N.vertexLength;for(let et=0;et<C.length;et++){const lt=C[et];for(let yt=1;yt<C[et].length;yt+=2){const mt=lt[yt-1],vt=lt[yt];let Ct=F[mt]<O,St=F[vt]<O;N.vertexLength+((Ct?1:0)+(St?1:0))>Zt.MAX_VERTEX_ARRAY_LENGTH&&(N=w.createNewSegment(S,P),O=Z.count,Ct=!0,St=!0,Q=0);const Pt=Bl(F,M,z,Z,mt,Ct,N),_t=Bl(F,M,z,Z,vt,St,N);P.emplaceBack(Q+Pt-O,Q+_t-O),N.primitiveLength++}}}(u,i,f,s,_,r),t.forceNewSegmentOnNextPrepare(),u?.forceNewSegmentOnNextPrepare()}function Bl(r,t,i,a,s,l,u){if(l){const f=a.count;return i(t[2*s],t[2*s+1]),r[s]=a.count,a.count++,u.vertexLength++,f}return r[s]}class gh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Y,this.indexArray=new wt,this.indexArray2=new gt,this.programConfigurations=new Un(t.layers,t.zoom),this.segments=new Zt,this.segments2=new Zt,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,a){this.hasDependencies=au("fill",this.layers,i);const s=this.layers[0].layout.get("fill-sort-key"),l=!s.isConstant(),u=[];for(const{feature:f,id:_,index:y,sourceLayerIndex:v}of t){const w=this.layers[0]._featureFilter.needGeometry,S=Fr(f,w);if(!this.layers[0]._featureFilter.filter(new le(this.zoom),S,a))continue;const P=l?s.evaluate(S,{},a,i.availableImages):void 0,M={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:y,geometry:w?S.geometry:dn(f),patterns:{},sortKey:P};u.push(M)}l&&u.sort((f,_)=>f.sortKey-_.sortKey);for(const f of u){const{geometry:_,index:y,sourceLayerIndex:v}=f;if(this.hasDependencies){const w=fh("fill",this.layers,f,{zoom:this.zoom},i);this.patternFeatures.push(w)}else this.addFeature(f,_,y,a,{},i.subdivisionGranularity);i.featureIndex.insert(t[y].feature,_,y,v,this.index)}}update(t,i,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:a})}addFeatures(t,i,a){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,i,a,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ef),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,i,a,s,l,u){for(const f of qa(i,500)){const _=Td(f,s,u.fill.getGranularityForZoomLevel(s.z)),y=this.layoutVertexArray;Sd((v,w)=>{y.emplaceBack(v,w)},this.segments,this.layoutVertexArray,this.indexArray,_.verticesFlattened,_.indicesTriangles,this.segments2,this.indexArray2,_.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,a,{imagePositions:l,canonical:s})}}let Pd,Md;Dt("FillBucket",gh,{omit:["layers","patternFeatures"]});var Vf={get paint(){return Md=Md||new _i({"fill-antialias":new Ft(U.paint_fill["fill-antialias"]),"fill-opacity":new Vt(U.paint_fill["fill-opacity"]),"fill-color":new Vt(U.paint_fill["fill-color"]),"fill-outline-color":new Vt(U.paint_fill["fill-outline-color"]),"fill-translate":new Ft(U.paint_fill["fill-translate"]),"fill-translate-anchor":new Ft(U.paint_fill["fill-translate-anchor"]),"fill-pattern":new cs(U.paint_fill["fill-pattern"])})},get layout(){return Pd=Pd||new _i({"fill-sort-key":new Vt(U.layout_fill["fill-sort-key"])})}};class Nf extends Hi{constructor(t,i){super(t,Vf,i)}recalculate(t,i){super.recalculate(t,i);const a=this.paint._values["fill-outline-color"];a.value.kind==="constant"&&a.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new gh(t)}queryRadius(){return ru(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:i,transform:a,pixelsToTileUnits:s}){return nd(nu(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-a.bearingInRadians,s),i)}isTileClipped(){return!0}}const Uf=Be([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Gf=Be([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Zf}=Uf;class go{constructor(t,i,a,s,l){this.properties={},this.extent=a,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=s,this._values=l,t.readFields($f,this,i)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos,a=[];let s,l=1,u=0,f=0,_=0;for(;t.pos<i;){if(u<=0){const y=t.readVarint();l=7&y,u=y>>3}if(u--,l===1||l===2)f+=t.readSVarint(),_+=t.readSVarint(),l===1&&(s&&a.push(s),s=[]),s&&s.push(new It(f,_));else{if(l!==7)throw new Error(`unknown command ${l}`);s&&s.push(s[0].clone())}}return s&&a.push(s),a}bbox(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos;let a=1,s=0,l=0,u=0,f=1/0,_=-1/0,y=1/0,v=-1/0;for(;t.pos<i;){if(s<=0){const w=t.readVarint();a=7&w,s=w>>3}if(s--,a===1||a===2)l+=t.readSVarint(),u+=t.readSVarint(),l<f&&(f=l),l>_&&(_=l),u<y&&(y=u),u>v&&(v=u);else if(a!==7)throw new Error(`unknown command ${a}`)}return[f,y,_,v]}toGeoJSON(t,i,a){const s=this.extent*Math.pow(2,a),l=this.extent*t,u=this.extent*i,f=this.loadGeometry();function _(S){return[360*(S.x+l)/s-180,360/Math.PI*Math.atan(Math.exp((1-2*(S.y+u)/s)*Math.PI))-90]}function y(S){return S.map(_)}let v;if(this.type===1){const S=[];for(const M of f)S.push(M[0]);const P=y(S);v=S.length===1?{type:"Point",coordinates:P[0]}:{type:"MultiPoint",coordinates:P}}else if(this.type===2){const S=f.map(y);v=S.length===1?{type:"LineString",coordinates:S[0]}:{type:"MultiLineString",coordinates:S}}else{if(this.type!==3)throw new Error("unknown feature type");{const S=function(M){const C=M.length;if(C<=1)return[M];const z=[];let F,Z;for(let O=0;O<C;O++){const N=qf(M[O]);N!==0&&(Z===void 0&&(Z=N<0),Z===N<0?(F&&z.push(F),F=[M[O]]):F&&F.push(M[O]))}return F&&z.push(F),z}(f),P=[];for(const M of S)P.push(M.map(y));v=P.length===1?{type:"Polygon",coordinates:P[0]}:{type:"MultiPolygon",coordinates:P}}}const w={type:"Feature",geometry:v,properties:this.properties};return this.id!=null&&(w.id=this.id),w}}function $f(r,t,i){r===1?t.id=i.readVarint():r===2?function(a,s){const l=a.readVarint()+a.pos;for(;a.pos<l;){const u=s._keys[a.readVarint()],f=s._values[a.readVarint()];s.properties[u]=f}}(i,t):r===3?t.type=i.readVarint():r===4&&(t._geometry=i.pos)}function qf(r){let t=0;for(let i,a,s=0,l=r.length,u=l-1;s<l;u=s++)i=r[s],a=r[u],t+=(a.x-i.x)*(i.y+a.y);return t}go.types=["Unknown","Point","LineString","Polygon"];class Id{constructor(t,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Wf,this,i),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 i=this._pbf.readVarint()+this._pbf.pos;return new go(this._pbf,i,this.extent,this._keys,this._values)}}function Wf(r,t,i){r===15?t.version=i.readVarint():r===1?t.name=i.readString():r===5?t.extent=i.readVarint():r===2?t._features.push(i.pos):r===3?t._keys.push(i.readString()):r===4&&t._values.push(function(a){let s=null;const l=a.readVarint()+a.pos;for(;a.pos<l;){const u=a.readVarint()>>3;s=u===1?a.readString():u===2?a.readFloat():u===3?a.readDouble():u===4?a.readVarint64():u===5?a.readVarint():u===6?a.readSVarint():u===7?a.readBoolean():null}if(s==null)throw new Error("unknown feature value");return s}(i))}class Ed{constructor(t,i){this.layers=t.readFields(Hf,{},i)}}function Hf(r,t,i){if(r===3){const a=new Id(i,i.readVarint()+i.pos);a.length&&(t[a.name]=a)}}const yh=Math.pow(2,13);function Ol(r,t,i,a,s,l,u,f){r.emplaceBack(t,i,2*Math.floor(a*yh)+u,s*yh*2,l*yh*2,Math.round(f))}class xh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new $,this.centroidVertexArray=new G,this.indexArray=new wt,this.programConfigurations=new Un(t.layers,t.zoom),this.segments=new Zt,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,a){this.features=[],this.hasDependencies=au("fill-extrusion",this.layers,i);for(const{feature:s,id:l,index:u,sourceLayerIndex:f}of t){const _=this.layers[0]._featureFilter.needGeometry,y=Fr(s,_);if(!this.layers[0]._featureFilter.filter(new le(this.zoom),y,a))continue;const v={id:l,sourceLayerIndex:f,index:u,geometry:_?y.geometry:dn(s),properties:s.properties,type:s.type,patterns:{}};this.hasDependencies?this.features.push(fh("fill-extrusion",this.layers,v,{zoom:this.zoom},i)):this.addFeature(v,v.geometry,u,a,{},i.subdivisionGranularity),i.featureIndex.insert(s,v.geometry,u,f,this.index,!0)}}addFeatures(t,i,a){for(const s of this.features){const{geometry:l}=s;this.addFeature(s,l,s.index,i,a,t.subdivisionGranularity)}}update(t,i,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:a})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Zf),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Gf.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,i,a,s,l,u){for(const f of qa(i,500)){const _={x:0,y:0,sampleCount:0},y=this.layoutVertexArray.length;this.processPolygon(_,s,t,f,u);const v=this.layoutVertexArray.length-y,w=Math.floor(_.x/_.sampleCount),S=Math.floor(_.y/_.sampleCount);for(let P=0;P<v;P++)this.centroidVertexArray.emplaceBack(w,S)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,a,{imagePositions:l,canonical:s})}processPolygon(t,i,a,s,l){if(s.length<1||Cd(s[0]))return;for(const w of s)w.length!==0&&Xf(t,w);const u={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},f=l.fill.getGranularityForZoomLevel(i.z),_=go.types[a.type]==="Polygon";for(const w of s){if(w.length===0||Cd(w))continue;const S=gs(w,f,_);this._generateSideFaces(S,u)}if(!_)return;const y=Td(s,i,f,!1),v=this.layoutVertexArray;Sd((w,S)=>{Ol(v,w,S,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,y.verticesFlattened,y.indicesTriangles)}_generateSideFaces(t,i){let a=0;for(let s=1;s<t.length;s++){const l=t[s],u=t[s-1];if(Yf(l,u))continue;i.segment.vertexLength+4>Zt.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const f=l.sub(u)._perp()._unit(),_=u.dist(l);a+_>32768&&(a=0),Ol(this.layoutVertexArray,l.x,l.y,f.x,f.y,0,0,a),Ol(this.layoutVertexArray,l.x,l.y,f.x,f.y,0,1,a),a+=_,Ol(this.layoutVertexArray,u.x,u.y,f.x,f.y,0,0,a),Ol(this.layoutVertexArray,u.x,u.y,f.x,f.y,0,1,a);const y=i.segment.vertexLength;this.indexArray.emplaceBack(y,y+2,y+1),this.indexArray.emplaceBack(y+1,y+2,y+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}}function Xf(r,t){for(let i=0;i<t.length;i++){const a=t[i];i===t.length-1&&t[0].x===a.x&&t[0].y===a.y||(r.x+=a.x,r.y+=a.y,r.sampleCount++)}}function Yf(r,t){return r.x===t.x&&(r.x<0||r.x>oe)||r.y===t.y&&(r.y<0||r.y>oe)}function Cd(r){return r.every(t=>t.x<0)||r.every(t=>t.x>oe)||r.every(t=>t.y<0)||r.every(t=>t.y>oe)}let Ad;Dt("FillExtrusionBucket",xh,{omit:["layers","features"]});var Kf={get paint(){return Ad=Ad||new _i({"fill-extrusion-opacity":new Ft(U["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Vt(U["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ft(U["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ft(U["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new cs(U["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Vt(U["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Vt(U["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ft(U["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Jf extends Hi{constructor(t,i){super(t,Kf,i)}createBucket(t){return new xh(t)}queryRadius(){return ru(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:a,geometry:s,transform:l,pixelsToTileUnits:u,pixelPosMatrix:f}){const _=nu(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-l.bearingInRadians,u),y=this.paint.get("fill-extrusion-height").evaluate(i,a),v=this.paint.get("fill-extrusion-base").evaluate(i,a),w=function(P,M){const C=[];for(const z of P){const F=[z.x,z.y,0,1];Da(F,F,M),C.push(new It(F[0]/F[3],F[1]/F[3]))}return C}(_,f),S=function(P,M,C,z){const F=[],Z=[],O=z[8]*M,N=z[9]*M,Q=z[10]*M,et=z[11]*M,lt=z[8]*C,yt=z[9]*C,mt=z[10]*C,vt=z[11]*C;for(const Ct of P){const St=[],Pt=[];for(const _t of Ct){const Bt=_t.x,Ot=_t.y,Nt=z[0]*Bt+z[4]*Ot+z[12],kt=z[1]*Bt+z[5]*Ot+z[13],Xt=z[2]*Bt+z[6]*Ot+z[14],Te=z[3]*Bt+z[7]*Ot+z[15],Ye=Xt+Q,xi=Te+et,Pr=Nt+lt,Bi=kt+yt,ci=Xt+mt,vi=Te+vt,je=new It((Nt+O)/xi,(kt+N)/xi);je.z=Ye/xi,St.push(je);const ui=new It(Pr/vi,Bi/vi);ui.z=ci/vi,Pt.push(ui)}F.push(St),Z.push(Pt)}return[F,Z]}(s,v,y,f);return function(P,M,C){let z=1/0;nd(C,M)&&(z=Dd(C,M[0]));for(let F=0;F<M.length;F++){const Z=M[F],O=P[F];for(let N=0;N<Z.length-1;N++){const Q=Z[N],et=[Q,Z[N+1],O[N+1],O[N],Q];rd(C,et)&&(z=Math.min(z,Dd(C,et)))}}return z!==1/0&&z}(S[0],S[1],w)}}function jl(r,t){return r.x*t.x+r.y*t.y}function Dd(r,t){if(r.length===1){let i=0;const a=t[i++];let s;for(;!s||a.equals(s);)if(s=t[i++],!s)return 1/0;for(;i<t.length;i++){const l=t[i],u=r[0],f=s.sub(a),_=l.sub(a),y=u.sub(a),v=jl(f,f),w=jl(f,_),S=jl(_,_),P=jl(y,f),M=jl(y,_),C=v*S-w*w,z=(S*P-w*M)/C,F=(v*M-w*P)/C,Z=a.z*(1-z-F)+s.z*z+l.z*F;if(isFinite(Z))return Z}return 1/0}{let i=1/0;for(const a of t)i=Math.min(i,a.z);return i}}const Qf=Be([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:tm}=Qf,em=Be([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:im}=em,rm=Math.cos(Math.PI/180*37.5),zd=Math.pow(2,14)/.5;class vh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new K,this.layoutVertexArray2=new J,this.indexArray=new wt,this.programConfigurations=new Un(t.layers,t.zoom),this.segments=new Zt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,a){this.hasDependencies=au("line",this.layers,i)||this.hasLineDasharray(this.layers);const s=this.layers[0].layout.get("line-sort-key"),l=!s.isConstant(),u=[];for(const{feature:f,id:_,index:y,sourceLayerIndex:v}of t){const w=this.layers[0]._featureFilter.needGeometry,S=Fr(f,w);if(!this.layers[0]._featureFilter.filter(new le(this.zoom),S,a))continue;const P=l?s.evaluate(S,{},a):void 0,M={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:y,geometry:w?S.geometry:dn(f),patterns:{},dashes:{},sortKey:P};u.push(M)}l&&u.sort((f,_)=>f.sortKey-_.sortKey);for(const f of u){const{geometry:_,index:y,sourceLayerIndex:v}=f;this.hasDependencies?(au("line",this.layers,i)?fh("line",this.layers,f,{zoom:this.zoom},i):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,f,this.zoom,i),this.patternFeatures.push(f)):this.addFeature(f,_,y,a,{},{},i.subdivisionGranularity),i.featureIndex.insert(t[y].feature,_,y,v,this.index)}}update(t,i,a,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:a,dashPositions:s})}addFeatures(t,i,a,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,i,a,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,im)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,tm),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,i,a,s,l,u,f){const _=this.layers[0].layout,y=_.get("line-join").evaluate(t,{}),v=_.get("line-cap"),w=_.get("line-miter-limit"),S=_.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const P of i)this.addLine(P,t,y,v,w,S,s,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,a,{imagePositions:l,dashPositions:u,canonical:s})}addLine(t,i,a,s,l,u,f,_){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=gs(t,f?_.line.getGranularityForZoomLevel(f.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let O=0;O<t.length-1;O++)this.totalDistance+=t[O].dist(t[O+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const y=go.types[i.type]==="Polygon";let v=t.length;for(;v>=2&&t[v-1].equals(t[v-2]);)v--;let w=0;for(;w<v-1&&t[w].equals(t[w+1]);)w++;if(v<(y?3:2))return;a==="bevel"&&(l=1.05);const S=this.overscaling<=16?122880/(512*this.overscaling):0,P=this.segments.prepareSegment(10*v,this.layoutVertexArray,this.indexArray);let M,C,z,F,Z;this.e1=this.e2=-1,y&&(M=t[v-2],Z=t[w].sub(M)._unit()._perp());for(let O=w;O<v;O++){if(z=O===v-1?y?t[w+1]:void 0:t[O+1],z&&t[O].equals(z))continue;Z&&(F=Z),M&&(C=M),M=t[O],Z=z?z.sub(M)._unit()._perp():F,F=F||Z;let N=F.add(Z);N.x===0&&N.y===0||N._unit();const Q=F.x*Z.x+F.y*Z.y,et=N.x*Z.x+N.y*Z.y,lt=et!==0?1/et:1/0,yt=2*Math.sqrt(2-2*et),mt=et<rm&&C&&z,vt=F.x*Z.y-F.y*Z.x>0;if(mt&&O>w){const Pt=M.dist(C);if(Pt>2*S){const _t=M.sub(M.sub(C)._mult(S/Pt)._round());this.updateDistance(C,_t),this.addCurrentVertex(_t,F,0,0,P),C=_t}}const Ct=C&&z;let St=Ct?a:y?"butt":s;if(Ct&&St==="round"&&(lt<u?St="miter":lt<=2&&(St="fakeround")),St==="miter"&<>l&&(St="bevel"),St==="bevel"&&(lt>2&&(St="flipbevel"),lt<l&&(St="miter")),C&&this.updateDistance(C,M),St==="miter")N._mult(lt),this.addCurrentVertex(M,N,0,0,P);else if(St==="flipbevel"){if(lt>100)N=Z.mult(-1);else{const Pt=lt*F.add(Z).mag()/F.sub(Z).mag();N._perp()._mult(Pt*(vt?-1:1))}this.addCurrentVertex(M,N,0,0,P),this.addCurrentVertex(M,N.mult(-1),0,0,P)}else if(St==="bevel"||St==="fakeround"){const Pt=-Math.sqrt(lt*lt-1),_t=vt?Pt:0,Bt=vt?0:Pt;if(C&&this.addCurrentVertex(M,F,_t,Bt,P),St==="fakeround"){const Ot=Math.round(180*yt/Math.PI/20);for(let Nt=1;Nt<Ot;Nt++){let kt=Nt/Ot;if(kt!==.5){const Te=kt-.5;kt+=kt*Te*(kt-1)*((1.0904+Q*(Q*(3.55645-1.43519*Q)-3.2452))*Te*Te+(.848013+Q*(.215638*Q-1.06021)))}const Xt=Z.sub(F)._mult(kt)._add(F)._unit()._mult(vt?-1:1);this.addHalfVertex(M,Xt.x,Xt.y,!1,vt,0,P)}}z&&this.addCurrentVertex(M,Z,-_t,-Bt,P)}else if(St==="butt")this.addCurrentVertex(M,N,0,0,P);else if(St==="square"){const Pt=C?1:-1;this.addCurrentVertex(M,N,Pt,Pt,P)}else St==="round"&&(C&&(this.addCurrentVertex(M,F,0,0,P),this.addCurrentVertex(M,F,1,1,P,!0)),z&&(this.addCurrentVertex(M,Z,-1,-1,P,!0),this.addCurrentVertex(M,Z,0,0,P)));if(mt&&O<v-1){const Pt=M.dist(z);if(Pt>2*S){const _t=M.add(z.sub(M)._mult(S/Pt)._round());this.updateDistance(M,_t),this.addCurrentVertex(_t,Z,0,0,P),M=_t}}}}addCurrentVertex(t,i,a,s,l,u=!1){const f=i.y*s-i.x,_=-i.y-i.x*s;this.addHalfVertex(t,i.x+i.y*a,i.y-i.x*a,u,!1,a,l),this.addHalfVertex(t,f,_,u,!0,-s,l),this.distance>zd/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,i,a,s,l,u))}addHalfVertex({x:t,y:i},a,s,l,u,f,_){const y=.5*(this.lineClips?this.scaledDistance*(zd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(l?1:0),(i<<1)+(u?1:0),Math.round(63*a)+128,Math.round(63*s)+128,1+(f===0?0:f<0?-1:1)|(63&y)<<2,y>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const v=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,v,this.e2),_.primitiveLength++),u?this.e2=v:this.e1=v}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,i){this.distance+=t.dist(i),this.updateScaledDistance()}hasLineDasharray(t){for(const i of t){const a=i.paint.get("line-dasharray");if(a&&!a.isConstant())return!0}return!1}addLineDashDependencies(t,i,a,s){for(const l of t){const u=l.paint.get("line-dasharray");if(!u||u.value.kind==="constant")continue;const f=l.layout.get("line-cap")==="round",_={dasharray:u.value.evaluate({zoom:a-1},i,{}),round:f},y={dasharray:u.value.evaluate({zoom:a},i,{}),round:f},v={dasharray:u.value.evaluate({zoom:a+1},i,{}),round:f},w=`${_.dasharray.join(",")},${_.round}`,S=`${y.dasharray.join(",")},${y.round}`,P=`${v.dasharray.join(",")},${v.round}`;s.dashDependencies[w]=_,s.dashDependencies[S]=y,s.dashDependencies[P]=v,i.dashes[l.id]={min:w,mid:S,max:P}}}}let kd,Rd;Dt("LineBucket",vh,{omit:["layers","patternFeatures"]});var Ld={get paint(){return Rd=Rd||new _i({"line-opacity":new Vt(U.paint_line["line-opacity"]),"line-color":new Vt(U.paint_line["line-color"]),"line-translate":new Ft(U.paint_line["line-translate"]),"line-translate-anchor":new Ft(U.paint_line["line-translate-anchor"]),"line-width":new Vt(U.paint_line["line-width"]),"line-gap-width":new Vt(U.paint_line["line-gap-width"]),"line-offset":new Vt(U.paint_line["line-offset"]),"line-blur":new Vt(U.paint_line["line-blur"]),"line-dasharray":new cs(U.paint_line["line-dasharray"]),"line-pattern":new cs(U.paint_line["line-pattern"]),"line-gradient":new us(U.paint_line["line-gradient"])})},get layout(){return kd=kd||new _i({"line-cap":new Ft(U.layout_line["line-cap"]),"line-join":new Vt(U.layout_line["line-join"]),"line-miter-limit":new Ft(U.layout_line["line-miter-limit"]),"line-round-limit":new Ft(U.layout_line["line-round-limit"]),"line-sort-key":new Vt(U.layout_line["line-sort-key"])})}};class nm extends Vt{possiblyEvaluate(t,i){return i=new le(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(t,i)}evaluate(t,i,a,s){return i=di({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(t,i,a,s)}}let cu;class am extends Hi{constructor(t,i){super(t,Ld,i),this.gradientVersion=0,cu||(cu=new nm(Ld.paint.properties["line-width"].specification),cu.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const i=this.gradientExpression();this.stepInterpolant=!!function(a){return a._styleExpression!==void 0}(i)&&i._styleExpression.expression instanceof ca,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,i){super.recalculate(t,i),this.paint._values["line-floorwidth"]=cu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new vh(t)}queryRadius(t){const i=t,a=Fd(po("line-width",this,i),po("line-gap-width",this,i)),s=po("line-offset",this,i);return a/2+Math.abs(s)+ru(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:a,geometry:s,transform:l,pixelsToTileUnits:u}){const f=nu(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-l.bearingInRadians,u),_=u/2*Fd(this.paint.get("line-width").evaluate(i,a),this.paint.get("line-gap-width").evaluate(i,a)),y=this.paint.get("line-offset").evaluate(i,a);return y&&(s=function(v,w){const S=[];for(let P=0;P<v.length;P++){const M=v[P],C=[];for(let z=0;z<M.length;z++){const F=M[z-1],Z=M[z],O=M[z+1],N=z===0?new It(0,0):Z.sub(F)._unit()._perp(),Q=z===M.length-1?new It(0,0):O.sub(Z)._unit()._perp(),et=N._add(Q)._unit(),lt=et.x*Q.x+et.y*Q.y;lt!==0&&et._mult(1/lt),C.push(et._mult(w)._add(Z))}S.push(C)}return S}(s,y*u)),function(v,w,S){for(let P=0;P<w.length;P++){const M=w[P];if(v.length>=3){for(let C=0;C<M.length;C++)if(ho(v,M[C]))return!0}if(df(v,M,S))return!0}return!1}(f,s,_)}isTileClipped(){return!0}}function Fd(r,t){return t>0?t+2*r:r}const sm=Be([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),om=Be([{name:"a_projected_pos",components:3,type:"Float32"}],4);Be([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const lm=Be([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Be([{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 Bd=Be([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),cm=Be([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function um(r,t,i){return r.sections.forEach(a=>{a.text=function(s,l,u){const f=l.layout.get("text-transform").evaluate(u,{});return f==="uppercase"?s=s.toLocaleUpperCase():f==="lowercase"&&(s=s.toLocaleLowerCase()),on.applyArabicShaping&&(s=on.applyArabicShaping(s)),s}(a.text,t,i)}),r}Be([{name:"triangle",components:3,type:"Uint16"}]),Be([{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"}]),Be([{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"}]),Be([{type:"Float32",name:"offsetX"}]),Be([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Be([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var ei=24;const Vl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},hm={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},dm={40:!0};function Od(r,t,i,a,s,l){if("fontStack"in t){const u=i[t.fontStack],f=u&&u[r];return f?f.metrics.advance*t.scale+s:0}{const u=a[t.imageName];return u?u.displaySize[0]*t.scale*ei/l+s:0}}function jd(r,t,i,a){const s=Math.pow(r-t,2);return a?r<t?s/2:2*s:s+Math.abs(i)*i}function pm(r,t,i){let a=0;return r===10&&(a-=1e4),i&&(a+=150),r!==40&&r!==65288||(a+=50),t!==41&&t!==65289||(a+=50),a}function Vd(r,t,i,a,s,l){let u=null,f=jd(t,i,s,l);for(const _ of a){const y=jd(t-_.x,i,s,l)+_.badness;y<=f&&(u=_,f=y)}return{index:r,x:t,priorBreak:u,badness:f}}function Nd(r){return r?Nd(r.priorBreak).concat(r.index):[]}class yo{constructor(t="",i=[],a=[]){this.text=t,this.sections=i,this.sectionIndex=a,this.imageSectionID=null}static fromFeature(t,i){const a=new yo;for(let s=0;s<t.sections.length;s++){const l=t.sections[s];l.image?a.addImageSection(l):a.addTextSection(l,i)}return a}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 i="",a={premature:!0,value:void 0};const s=t[Symbol.iterator]();let l=s.next();const u=t[Symbol.iterator]();u.next();let f=u.next();for(;!l.done;)i+=!f.done&&gl(f.value.codePointAt(0))&&!Vl[f.value]||!a.premature&&gl(a.value.codePointAt(0))&&!Vl[a.value]||!Vl[l.value]?l.value:Vl[l.value],a={value:l.value,premature:!1},l=s.next(),f=u.next();return i}(this.text)}hasZeroWidthSpaces(){return this.text.includes("")}trim(){const t=this.text.match(/^\s*/),i=t?t[0].length:0,a=this.text.match(/\S\s*$/),s=a?a[0].length-1:0;this.text=this.text.substring(i,this.text.length-s),this.sectionIndex=this.sectionIndex.slice(i,this.sectionIndex.length-s)}substring(t,i){const a=[...this.text].slice(t,i).join(""),s=this.sectionIndex.slice(t,i);return new yo(a,this.sections,s)}toCodeUnitIndex(t){return[...this.text].slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,a=0;for(let s=0;s<this.length();s++){const l=this.getSection(s);if("imageName"in l){const u=t[l.imageName];if(!u)continue;const f=u.displaySize;i=Math.max(i,f[0]),a=Math.max(a,f[1])}}return{maxImageWidth:i,maxImageHeight:a}}addTextSection(t,i){this.text+=t.text,this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||i});const a=this.sections.length-1;this.sectionIndex.push(...[...t.text].map(()=>a))}addImageSection(t){const i=t.image?t.image.name:"";if(i.length===0)return void Pe("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:i}),this.sectionIndex.push(this.sections.length-1)):Pe("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,i,a,s,l){const u=[],f=this.determineAverageLineWidth(t,i,a,s,l),_=this.hasZeroWidthSpaces();let y=0,v=0;const w=this.text[Symbol.iterator]();let S=w.next();const P=this.text[Symbol.iterator]();P.next();let M=P.next();const C=this.text[Symbol.iterator]();C.next(),C.next();let z=C.next();for(;!S.done;){const F=this.getSection(v),Z=S.value.codePointAt(0);if(Zc(Z)||(y+=Od(Z,F,a,s,t,l)),!M.done){const O=Qu(Z),N=M.value.codePointAt(0);(hm[Z]||O||"imageName"in F||!z.done&&dm[N])&&u.push(Vd(v+1,y,f,u,pm(Z,N,O&&_),!1))}v++,S=w.next(),M=P.next(),z=C.next()}return Nd(Vd(this.length(),y,f,u,0,!0))}determineAverageLineWidth(t,i,a,s,l){let u=0,f=0;for(const _ of this.text){const y=this.getSection(f);u+=Od(_.codePointAt(0),y,a,s,t,l),f++}return u/Math.max(1,Math.ceil(u/i))}}const bh=4294967296,Ud=1/bh,Gd=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class wh{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,i,a=this.length){for(;this.pos<a;){const s=this.readVarint(),l=s>>3,u=this.pos;this.type=7&s,t(l,i,this),this.pos===u&&this.skip(s)}return i}readMessage(t,i){return this.readFields(t,i,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)*bh;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*bh;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 i=this.buf;let a,s;return s=i[this.pos++],a=127&s,s<128?a:(s=i[this.pos++],a|=(127&s)<<7,s<128?a:(s=i[this.pos++],a|=(127&s)<<14,s<128?a:(s=i[this.pos++],a|=(127&s)<<21,s<128?a:(s=i[this.pos],a|=(15&s)<<28,function(l,u,f){const _=f.buf;let y,v;if(v=_[f.pos++],y=(112&v)>>4,v<128||(v=_[f.pos++],y|=(127&v)<<3,v<128)||(v=_[f.pos++],y|=(127&v)<<10,v<128)||(v=_[f.pos++],y|=(127&v)<<17,v<128)||(v=_[f.pos++],y|=(127&v)<<24,v<128)||(v=_[f.pos++],y|=(1&v)<<31,v<128))return xo(l,y,u);throw new Error("Expected varint not more than 10 bytes")}(a,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,i=this.pos;return this.pos=t,t-i>=12&&Gd?Gd.decode(this.buf.subarray(i,t)):function(a,s,l){let u="",f=s;for(;f<l;){const _=a[f];let y,v,w,S=null,P=_>239?4:_>223?3:_>191?2:1;if(f+P>l)break;P===1?_<128&&(S=_):P===2?(y=a[f+1],(192&y)==128&&(S=(31&_)<<6|63&y,S<=127&&(S=null))):P===3?(y=a[f+1],v=a[f+2],(192&y)==128&&(192&v)==128&&(S=(15&_)<<12|(63&y)<<6|63&v,(S<=2047||S>=55296&&S<=57343)&&(S=null))):P===4&&(y=a[f+1],v=a[f+2],w=a[f+3],(192&y)==128&&(192&v)==128&&(192&w)==128&&(S=(15&_)<<18|(63&y)<<12|(63&v)<<6|63&w,(S<=65535||S>=1114112)&&(S=null))),S===null?(S=65533,P=1):S>65535&&(S-=65536,u+=String.fromCharCode(S>>>10&1023|55296),S=56320|1023&S),u+=String.fromCharCode(S),f+=P}return u}(this.buf,i,t)}readBytes(){const t=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,t);return this.pos=t,i}readPackedVarint(t=[],i){const a=this.readPackedEnd();for(;this.pos<a;)t.push(this.readVarint(i));return t}readPackedSVarint(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(t){const i=7&t;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(t,i){this.writeVarint(t<<3|i)}realloc(t){let i=this.length||16;for(;i<this.pos+t;)i*=2;if(i!==this.length){const a=new Uint8Array(i);a.set(this.buf),this.buf=a,this.dataView=new DataView(a.buffer),this.length=i}}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*Ud),!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*Ud),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(i,a){let s,l;if(i>=0?(s=i%4294967296|0,l=i/4294967296|0):(s=~(-i%4294967296),l=~(-i/4294967296),4294967295^s?s=s+1|0:(s=0,l=l+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");a.realloc(10),function(u,f,_){_.buf[_.pos++]=127&u|128,u>>>=7,_.buf[_.pos++]=127&u|128,u>>>=7,_.buf[_.pos++]=127&u|128,u>>>=7,_.buf[_.pos++]=127&u|128,_.buf[_.pos]=127&(u>>>=7)}(s,0,a),function(u,f){const _=(7&u)<<4;f.buf[f.pos++]|=_|((u>>>=3)?128:0),u&&(f.buf[f.pos++]=127&u|((u>>>=7)?128:0),u&&(f.buf[f.pos++]=127&u|((u>>>=7)?128:0),u&&(f.buf[f.pos++]=127&u|((u>>>=7)?128:0),u&&(f.buf[f.pos++]=127&u|((u>>>=7)?128:0),u&&(f.buf[f.pos++]=127&u)))))}(l,a)}(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 i=this.pos;this.pos=function(s,l,u){for(let f,_,y=0;y<l.length;y++){if(f=l.charCodeAt(y),f>55295&&f<57344){if(!_){f>56319||y+1===l.length?(s[u++]=239,s[u++]=191,s[u++]=189):_=f;continue}if(f<56320){s[u++]=239,s[u++]=191,s[u++]=189,_=f;continue}f=_-55296<<10|f-56320|65536,_=null}else _&&(s[u++]=239,s[u++]=191,s[u++]=189,_=null);f<128?s[u++]=f:(f<2048?s[u++]=f>>6|192:(f<65536?s[u++]=f>>12|224:(s[u++]=f>>18|240,s[u++]=f>>12&63|128),s[u++]=f>>6&63|128),s[u++]=63&f|128)}return u}(this.buf,t,this.pos);const a=this.pos-i;a>=128&&Zd(i,a,this),this.pos=i-1,this.writeVarint(a),this.pos+=a}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 i=t.length;this.writeVarint(i),this.realloc(i);for(let a=0;a<i;a++)this.buf[this.pos++]=t[a]}writeRawMessage(t,i){this.pos++;const a=this.pos;t(i,this);const s=this.pos-a;s>=128&&Zd(a,s,this),this.pos=a-1,this.writeVarint(s),this.pos+=s}writeMessage(t,i,a){this.writeTag(t,2),this.writeRawMessage(i,a)}writePackedVarint(t,i){i.length&&this.writeMessage(t,fm,i)}writePackedSVarint(t,i){i.length&&this.writeMessage(t,mm,i)}writePackedBoolean(t,i){i.length&&this.writeMessage(t,ym,i)}writePackedFloat(t,i){i.length&&this.writeMessage(t,_m,i)}writePackedDouble(t,i){i.length&&this.writeMessage(t,gm,i)}writePackedFixed32(t,i){i.length&&this.writeMessage(t,xm,i)}writePackedSFixed32(t,i){i.length&&this.writeMessage(t,vm,i)}writePackedFixed64(t,i){i.length&&this.writeMessage(t,bm,i)}writePackedSFixed64(t,i){i.length&&this.writeMessage(t,wm,i)}writeBytesField(t,i){this.writeTag(t,2),this.writeBytes(i)}writeFixed32Field(t,i){this.writeTag(t,5),this.writeFixed32(i)}writeSFixed32Field(t,i){this.writeTag(t,5),this.writeSFixed32(i)}writeFixed64Field(t,i){this.writeTag(t,1),this.writeFixed64(i)}writeSFixed64Field(t,i){this.writeTag(t,1),this.writeSFixed64(i)}writeVarintField(t,i){this.writeTag(t,0),this.writeVarint(i)}writeSVarintField(t,i){this.writeTag(t,0),this.writeSVarint(i)}writeStringField(t,i){this.writeTag(t,2),this.writeString(i)}writeFloatField(t,i){this.writeTag(t,5),this.writeFloat(i)}writeDoubleField(t,i){this.writeTag(t,1),this.writeDouble(i)}writeBooleanField(t,i){this.writeVarintField(t,+i)}}function xo(r,t,i){return i?4294967296*t+(r>>>0):4294967296*(t>>>0)+(r>>>0)}function Zd(r,t,i){const a=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(a);for(let s=i.pos-1;s>=r;s--)i.buf[s+a]=i.buf[s]}function fm(r,t){for(let i=0;i<r.length;i++)t.writeVarint(r[i])}function mm(r,t){for(let i=0;i<r.length;i++)t.writeSVarint(r[i])}function _m(r,t){for(let i=0;i<r.length;i++)t.writeFloat(r[i])}function gm(r,t){for(let i=0;i<r.length;i++)t.writeDouble(r[i])}function ym(r,t){for(let i=0;i<r.length;i++)t.writeBoolean(r[i])}function xm(r,t){for(let i=0;i<r.length;i++)t.writeFixed32(r[i])}function vm(r,t){for(let i=0;i<r.length;i++)t.writeSFixed32(r[i])}function bm(r,t){for(let i=0;i<r.length;i++)t.writeFixed64(r[i])}function wm(r,t){for(let i=0;i<r.length;i++)t.writeSFixed64(r[i])}function Tm(r,t,i){r===1&&i.readMessage(Sm,t)}function Sm(r,t,i){if(r===3){const{id:a,bitmap:s,width:l,height:u,left:f,top:_,advance:y}=i.readMessage(Pm,{});t.push({id:a,bitmap:new Dl({width:l+6,height:u+6},s),metrics:{width:l,height:u,left:f,top:_,advance:y}})}}function Pm(r,t,i){r===1?t.id=i.readVarint():r===2?t.bitmap=i.readBytes():r===3?t.width=i.readVarint():r===4?t.height=i.readVarint():r===5?t.left=i.readSVarint():r===6?t.top=i.readSVarint():r===7&&(t.advance=i.readVarint())}function $d(r){let t=0,i=0;for(const u of r)t+=u.w*u.h,i=Math.max(i,u.w);r.sort((u,f)=>f.h-u.h);const a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let s=0,l=0;for(const u of r)for(let f=a.length-1;f>=0;f--){const _=a[f];if(!(u.w>_.w||u.h>_.h)){if(u.x=_.x,u.y=_.y,l=Math.max(l,u.y+u.h),s=Math.max(s,u.x+u.w),u.w===_.w&&u.h===_.h){const y=a.pop();y&&f<a.length&&(a[f]=y)}else u.h===_.h?(_.x+=u.w,_.w-=u.w):u.w===_.w?(_.y+=u.h,_.h-=u.h):(a.push({x:_.x+u.w,y:_.y,w:_.w-u.w,h:u.h}),_.y+=u.h,_.h-=u.h);break}}return{w:s,h:l,fill:t/(s*l)||0}}class Th{constructor(t,{pixelRatio:i,version:a,stretchX:s,stretchY:l,content:u,textFitWidth:f,textFitHeight:_}){this.paddedRect=t,this.pixelRatio=i,this.stretchX=s,this.stretchY=l,this.content=u,this.version=a,this.textFitWidth=f,this.textFitHeight=_}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 qd{constructor(t,i){const a={},s={};this.haveRenderCallbacks=[];const l=[];this.addImages(t,a,l),this.addImages(i,s,l);const{w:u,h:f}=$d(l),_=new Ni({width:u||1,height:f||1});for(const y in t){const v=t[y],w=a[y].paddedRect;Ni.copy(v.data,_,{x:0,y:0},{x:w.x+1,y:w.y+1},v.data)}for(const y in i){const v=i[y],w=s[y].paddedRect,S=w.x+1,P=w.y+1,M=v.data.width,C=v.data.height;Ni.copy(v.data,_,{x:0,y:0},{x:S,y:P},v.data),Ni.copy(v.data,_,{x:0,y:C-1},{x:S,y:P-1},{width:M,height:1}),Ni.copy(v.data,_,{x:0,y:0},{x:S,y:P+C},{width:M,height:1}),Ni.copy(v.data,_,{x:M-1,y:0},{x:S-1,y:P},{width:1,height:C}),Ni.copy(v.data,_,{x:0,y:0},{x:S+M,y:P},{width:1,height:C})}this.image=_,this.iconPositions=a,this.patternPositions=s}addImages(t,i,a){for(const s in t){const l=t[s],u={x:0,y:0,w:l.data.width+2,h:l.data.height+2};a.push(u),i[s]=new Th(u,l),l.hasRenderCallback&&this.haveRenderCallbacks.push(s)}}patchUpdatedImages(t,i){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const a in t.updatedImages)this.patchUpdatedImage(this.iconPositions[a],t.getImage(a),i),this.patchUpdatedImage(this.patternPositions[a],t.getImage(a),i)}patchUpdatedImage(t,i,a){if(!t||!i||t.version===i.version)return;t.version=i.version;const[s,l]=t.tl;a.update(i.data,void 0,{x:s,y:l})}}var Ta;function uu(r,t,i,a,s,l,u,f,_,y,v,w,S,P,M){const C=yo.fromFeature(r,s);let z;w===D.ay.vertical&&C.verticalizePunctuation();let F=C.determineLineBreaks(y,l,t,a,P);const{processBidirectionalText:Z,processStyledBidirectionalText:O}=on;if(Z&&C.sections.length===1){z=[],F=F.map(lt=>C.toCodeUnitIndex(lt));const et=Z(C.toString(),F);for(const lt of et){const yt=[...lt].map(()=>0);z.push(new yo(lt,C.sections,yt))}}else if(O){z=[],F=F.map(mt=>C.toCodeUnitIndex(mt));let et=0;const lt=[];for(const mt of C.text)lt.push(...Array(mt.length).fill(C.sectionIndex[et])),et++;const yt=O(C.text,lt,F);for(const mt of yt){const vt=[];let Ct="";for(const St of mt[0])vt.push(mt[1][Ct.length]),Ct+=St;z.push(new yo(mt[0],C.sections,vt))}}else z=function(et,lt){const yt=[];let mt=0;for(const vt of lt)yt.push(et.substring(mt,vt)),mt=vt;return mt<et.length()&&yt.push(et.substring(mt,et.length())),yt}(C,F);const N=[],Q={positionedLines:N,text:C.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:w,iconsInText:!1,verticalizable:!1};return function(et,lt,yt,mt,vt,Ct,St,Pt,_t,Bt,Ot,Nt){let kt=0,Xt=0,Te=0,Ye=0;const xi=Pt==="right"?1:Pt==="left"?0:.5,Pr=ei/Nt;let Bi=0;for(const je of vt){je.trim();const ui=je.getMaxScale(),Mi={positionedGlyphs:[],lineOffset:0};et.positionedLines[Bi]=Mi;const Ii=Mi.positionedGlyphs;let Ui=0;if(!je.length()){Xt+=Ct,++Bi;continue}const bi=Mm(mt,je,Pr);let Gi=0;for(const ni of je.text){const De=je.getSection(Gi),Ke=ni.codePointAt(0),Fe=Im(_t,Ot,Ke),ai={glyph:Ke,imageName:null,x:kt,y:Xt+-17,vertical:Fe,scale:1,fontStack:"",sectionIndex:je.getSectionIndex(Gi),metrics:null,rect:null};let $n;if("fontStack"in De){if($n=Em(De,Ke,Fe,bi,lt,yt),!$n)continue;ai.fontStack=De.fontStack}else{if(et.iconsInText=!0,De.scale*=Pr,$n=Cm(De,Fe,ui,bi,mt),!$n)continue;Ui=Math.max(Ui,$n.imageOffset),ai.imageName=De.imageName}const{rect:jr,metrics:Kl,baselineOffset:Ea}=$n;ai.y+=Ea,ai.scale=De.scale,ai.metrics=Kl,ai.rect=jr,Ii.push(ai),Fe?(et.verticalizable=!0,kt+=("imageName"in De?Kl.advance:ei)*De.scale+Bt):kt+=Kl.advance*De.scale+Bt,Gi++}Ii.length!==0&&(Te=Math.max(kt-Bt,Te),Am(Ii,0,Ii.length-1,xi)),kt=0,Mi.lineOffset=Math.max(Ui,(ui-1)*ei);const Mr=Ct*ui+Ui;Xt+=Mr,Ye=Math.max(Mr,Ye),++Bi}const{horizontalAlign:ci,verticalAlign:vi}=Sh(St);(function(je,ui,Mi,Ii,Ui,bi,Gi,Mr,ni){const De=(ui-Mi)*Ui;let Ke=0;Ke=bi!==Gi?-Mr*Ii- -17:-Ii*ni*Gi+.5*Gi;for(const Fe of je)for(const ai of Fe.positionedGlyphs)ai.x+=De,ai.y+=Ke})(et.positionedLines,xi,ci,vi,Te,Ye,Ct,Xt,vt.length),et.top+=-vi*Xt,et.bottom=et.top+Xt,et.left+=-ci*Te,et.right=et.left+Te}(Q,t,i,a,z,u,f,_,w,y,S,M),!function(et){for(const lt of et)if(lt.positionedGlyphs.length!==0)return!1;return!0}(N)&&Q}function Sh(r){let t=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function Mm(r,t,i){const a=t.getMaxScale()*ei,{maxImageWidth:s,maxImageHeight:l}=t.getMaxImageSize(r),u=Math.max(a,l*i);return{verticalLineContentWidth:Math.max(a,s*i),horizontalLineContentHeight:u}}function Wd(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function Im(r,t,i){return!(r===D.ay.horizontal||!t&&!va(i)||t&&(Zc(i)||(a=i,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(a)))));var a}function Em(r,t,i,a,s,l){const u=l[r.fontStack],f=function(y,v,w,S){if(y&&y.rect)return y;const P=v[w.fontStack],M=P&&P[S];return M?{rect:null,metrics:M.metrics}:null}(u&&u[t],s,r,t);if(f===null)return null;let _;if(i)_=a.verticalLineContentWidth-r.scale*ei;else{const y=Wd(r.verticalAlign);_=(a.horizontalLineContentHeight-r.scale*ei)*y}return{rect:f.rect,metrics:f.metrics,baselineOffset:_}}function Cm(r,t,i,a,s){const l=s[r.imageName];if(!l)return null;const u=l.paddedRect,f=l.displaySize,_={width:f[0],height:f[1],left:1,top:-3,advance:t?f[1]:f[0]};let y;if(t)y=a.verticalLineContentWidth-f[1]*r.scale;else{const v=Wd(r.verticalAlign);y=(a.horizontalLineContentHeight-f[1]*r.scale)*v}return{rect:u,metrics:_,baselineOffset:y,imageOffset:(t?f[0]:f[1])*r.scale-ei*i}}function Am(r,t,i,a){if(a===0)return;const s=r[i],l=(r[i].x+s.metrics.advance*s.scale)*a;for(let u=t;u<=i;u++)r[u].x-=l}function Dm(r,t,i){const{horizontalAlign:a,verticalAlign:s}=Sh(i),l=t[0]-r.displaySize[0]*a,u=t[1]-r.displaySize[1]*s;return{image:r,top:u,bottom:u+r.displaySize[1],left:l,right:l+r.displaySize[0]}}function Hd(r){var t,i;let a=r.left,s=r.top,l=r.right-a,u=r.bottom-s;const f=(t=r.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",_=(i=r.image.textFitHeight)!==null&&i!==void 0?i:"stretchOrShrink",y=(r.image.content[2]-r.image.content[0])/(r.image.content[3]-r.image.content[1]);if(_==="proportional"){if(f==="stretchOnly"&&l/u<y||f==="proportional"){const v=Math.ceil(u*y);a*=v/l,l=v}}else if(f==="proportional"&&_==="stretchOnly"&&y!==0&&l/u>y){const v=Math.ceil(l/y);s*=v/u,u=v}return{x1:a,y1:s,x2:a+l,y2:s+u}}function Xd(r,t,i,a,s,l){const u=r.image;let f;if(u.content){const z=u.content,F=u.pixelRatio||1;f=[z[0]/F,z[1]/F,u.displaySize[0]-z[2]/F,u.displaySize[1]-z[3]/F]}const _=t.left*l,y=t.right*l;let v,w,S,P;i==="width"||i==="both"?(P=s[0]+_-a[3],w=s[0]+y+a[1]):(P=s[0]+(_+y-u.displaySize[0])/2,w=P+u.displaySize[0]);const M=t.top*l,C=t.bottom*l;return i==="height"||i==="both"?(v=s[1]+M-a[0],S=s[1]+C+a[2]):(v=s[1]+(M+C-u.displaySize[1])/2,S=v+u.displaySize[1]),{image:u,top:v,right:w,bottom:S,left:P,collisionPadding:f}}Dt("ImagePosition",Th),Dt("ImageAtlas",qd),D.ay=void 0,(Ta=D.ay||(D.ay={}))[Ta.none=0]="none",Ta[Ta.horizontal=1]="horizontal",Ta[Ta.vertical=2]="vertical",Ta[Ta.horizontalOnly=3]="horizontalOnly";const Gn=128,Sa=32640;function Yd(r,t){const{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new le(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:a,interpolationType:s}=i;let l=0;for(;l<a.length&&a[l]<=r;)l++;l=Math.max(0,l-1);let u=l;for(;u<a.length&&a[u]<r+1;)u++;u=Math.min(a.length-1,u);const f=a[l],_=a[u];return i.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:_,interpolationType:s}:{kind:"camera",minZoom:f,maxZoom:_,minSize:i.evaluate(new le(f)),maxSize:i.evaluate(new le(_)),interpolationType:s}}}function Ph(r,t,i){let a="never";const s=r.get(t);return s?a=s:r.get(i)&&(a="always"),a}const zm=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function hu(r,t,i,a,s,l,u,f,_,y,v,w,S){const P=f?Math.min(Sa,Math.round(f[0])):0,M=f?Math.min(Sa,Math.round(f[1])):0;r.emplaceBack(t,i,Math.round(32*a),Math.round(32*s),l,u,(P<<1)+(_?1:0),M,16*y,16*v,256*w,256*S)}function Mh(r,t,i){r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i)}function km(r){for(const t of r.sections)if(Wc(t.text))return!0;return!1}class Ih{constructor(t){this.layoutVertexArray=new ut,this.indexArray=new wt,this.programConfigurations=t,this.segments=new Zt,this.dynamicLayoutVertexArray=new st,this.opacityVertexArray=new ot,this.hasVisibleVertices=!1,this.placedSymbolArray=new x}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,i,a,s){this.isEmpty()||(a&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,sm.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,om.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,zm,!0),this.opacityVertexBuffer.itemSize=1),(a||s)&&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())}}Dt("SymbolBuffers",Ih);class Eh{constructor(t,i,a){this.layoutVertexArray=new t,this.layoutAttributes=i,this.indexArray=new a,this.segments=new Zt,this.collisionVertexArray=new Mt}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,lm.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Dt("CollisionBuffers",Eh);class vo{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(u=>u.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Yd(this.zoom,i["text-size"]),this.iconSizeData=Yd(this.zoom,i["icon-size"]);const a=this.layers[0].layout,s=a.get("symbol-sort-key"),l=a.get("symbol-z-order");this.canOverlap=Ph(a,"text-overlap","text-allow-overlap")!=="never"||Ph(a,"icon-overlap","icon-allow-overlap")!=="never"||a.get("text-ignore-placement")||a.get("icon-ignore-placement"),this.sortFeaturesByKey=l!=="viewport-y"&&!s.isConstant(),this.sortFeaturesByY=(l==="viewport-y"||l==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,a.get("symbol-placement")==="point"&&(this.writingModes=a.get("text-writing-mode").map(u=>D.ay[u])),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=t.sourceID}createArrays(){this.text=new Ih(new Un(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Ih(new Un(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new E,this.lineVertexArray=new I,this.symbolInstances=new T,this.textAnchorOffsets=new L}calculateGlyphDependencies(t,i,a,s,l){for(const u of t)if(i[u.codePointAt(0)]=!0,(a||s)&&l){const f=Vl[u];f&&(i[f.codePointAt(0)]=!0)}}populate(t,i,a){const s=this.layers[0],l=s.layout,u=l.get("text-font"),f=l.get("text-field"),_=l.get("icon-image"),y=(f.value.kind!=="constant"||f.value.value instanceof qe&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(u.value.kind!=="constant"||u.value.value.length>0),v=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,w=l.get("symbol-sort-key");if(this.features=[],!y&&!v)return;const S=i.iconDependencies,P=i.glyphDependencies,M=i.availableImages,C=new le(this.zoom);for(const{feature:z,id:F,index:Z,sourceLayerIndex:O}of t){const N=s._featureFilter.needGeometry,Q=Fr(z,N);if(!s._featureFilter.filter(C,Q,a))continue;let et,lt;if(N||(Q.geometry=dn(z)),y){const mt=s.getValueAndResolveTokens("text-field",Q,a,M),vt=qe.factory(mt),Ct=this.hasRTLText=this.hasRTLText||km(vt);(!Ct||on.getRTLTextPluginStatus()==="unavailable"||Ct&&on.isParsed())&&(et=um(vt,s,Q))}if(v){const mt=s.getValueAndResolveTokens("icon-image",Q,a,M);lt=mt instanceof zi?mt:zi.fromString(mt)}if(!et&&!lt)continue;const yt=this.sortFeaturesByKey?w.evaluate(Q,{},a):void 0;if(this.features.push({id:F,text:et,icon:lt,index:Z,sourceLayerIndex:O,geometry:Q.geometry,properties:z.properties,type:go.types[z.type],sortKey:yt}),lt&&(S[lt.name]=!0),et){const mt=u.evaluate(Q,{},a).join(","),vt=l.get("text-rotation-alignment")!=="viewport"&&l.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(D.ay.vertical)>=0;for(const Ct of et.sections)if(Ct.image)S[Ct.image.name]=!0;else{const St=ss(et.toString()),Pt=Ct.fontStack||mt,_t=P[Pt]=P[Pt]||{};this.calculateGlyphDependencies(Ct.text,_t,vt,this.allowVerticalPlacement,St)}}}l.get("symbol-placement")==="line"&&(this.features=function(z){const F={},Z={},O=[];let N=0;function Q(mt){O.push(z[mt]),N++}function et(mt,vt,Ct){const St=Z[mt];return delete Z[mt],Z[vt]=St,O[St].geometry[0].pop(),O[St].geometry[0]=O[St].geometry[0].concat(Ct[0]),St}function lt(mt,vt,Ct){const St=F[vt];return delete F[vt],F[mt]=St,O[St].geometry[0].shift(),O[St].geometry[0]=Ct[0].concat(O[St].geometry[0]),St}function yt(mt,vt,Ct){const St=Ct?vt[0][vt[0].length-1]:vt[0][0];return`${mt}:${St.x}:${St.y}`}for(let mt=0;mt<z.length;mt++){const vt=z[mt],Ct=vt.geometry,St=vt.text?vt.text.toString():null;if(!St){Q(mt);continue}const Pt=yt(St,Ct),_t=yt(St,Ct,!0);if(Pt in Z&&_t in F&&Z[Pt]!==F[_t]){const Bt=lt(Pt,_t,Ct),Ot=et(Pt,_t,O[Bt].geometry);delete F[Pt],delete Z[_t],Z[yt(St,O[Ot].geometry,!0)]=Ot,O[Bt].geometry=null}else Pt in Z?et(Pt,_t,Ct):_t in F?lt(Pt,_t,Ct):(Q(mt),F[Pt]=N-1,Z[_t]=N-1)}return O.filter(mt=>mt.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((z,F)=>z.sortKey-F.sortKey)}update(t,i,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:a}),this.icon.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:a}))}isEmpty(){return this.symbolInstances.length===0&&!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,i){const a=this.lineVertexArray.length;if(t.segment!==void 0){let s=t.dist(i[t.segment+1]),l=t.dist(i[t.segment]);const u={};for(let f=t.segment+1;f<i.length;f++)u[f]={x:i[f].x,y:i[f].y,tileUnitDistanceFromAnchor:s},f<i.length-1&&(s+=i[f+1].dist(i[f]));for(let f=t.segment||0;f>=0;f--)u[f]={x:i[f].x,y:i[f].y,tileUnitDistanceFromAnchor:l},f>0&&(l+=i[f-1].dist(i[f]));for(let f=0;f<i.length;f++){const _=u[f];this.lineVertexArray.emplaceBack(_.x,_.y,_.tileUnitDistanceFromAnchor)}}return{lineStartIndex:a,lineLength:this.lineVertexArray.length-a}}addSymbols(t,i,a,s,l,u,f,_,y,v,w,S){const P=t.indexArray,M=t.layoutVertexArray,C=t.segments.prepareSegment(4*i.length,M,P,this.canOverlap?u.sortKey:void 0),z=this.glyphOffsetArray.length,F=C.vertexLength,Z=this.allowVerticalPlacement&&f===D.ay.vertical?Math.PI/2:0,O=u.text&&u.text.sections;for(let N=0;N<i.length;N++){const{tl:Q,tr:et,bl:lt,br:yt,tex:mt,pixelOffsetTL:vt,pixelOffsetBR:Ct,minFontScaleX:St,minFontScaleY:Pt,glyphOffset:_t,isSDF:Bt,sectionIndex:Ot}=i[N],Nt=C.vertexLength,kt=_t[1];hu(M,_.x,_.y,Q.x,kt+Q.y,mt.x,mt.y,a,Bt,vt.x,vt.y,St,Pt),hu(M,_.x,_.y,et.x,kt+et.y,mt.x+mt.w,mt.y,a,Bt,Ct.x,vt.y,St,Pt),hu(M,_.x,_.y,lt.x,kt+lt.y,mt.x,mt.y+mt.h,a,Bt,vt.x,Ct.y,St,Pt),hu(M,_.x,_.y,yt.x,kt+yt.y,mt.x+mt.w,mt.y+mt.h,a,Bt,Ct.x,Ct.y,St,Pt),Mh(t.dynamicLayoutVertexArray,_,Z),P.emplaceBack(Nt,Nt+2,Nt+1),P.emplaceBack(Nt+1,Nt+2,Nt+3),C.vertexLength+=4,C.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(_t[0]),N!==i.length-1&&Ot===i[N+1].sectionIndex||t.programConfigurations.populatePaintArrays(M.length,u,u.index,{imagePositions:{},canonical:S,formattedSection:O&&O[Ot]})}t.placedSymbolArray.emplaceBack(_.x,_.y,z,this.glyphOffsetArray.length-z,F,y,v,_.segment,a?a[0]:0,a?a[1]:0,s[0],s[1],f,0,!1,0,w)}_addCollisionDebugVertex(t,i,a,s,l,u){return i.emplaceBack(0,0),t.emplaceBack(a.x,a.y,s,l,Math.round(u.x),Math.round(u.y))}addCollisionDebugVertices(t,i,a,s,l,u,f){const _=l.segments.prepareSegment(4,l.layoutVertexArray,l.indexArray),y=_.vertexLength,v=l.layoutVertexArray,w=l.collisionVertexArray,S=f.anchorX,P=f.anchorY;this._addCollisionDebugVertex(v,w,u,S,P,new It(t,i)),this._addCollisionDebugVertex(v,w,u,S,P,new It(a,i)),this._addCollisionDebugVertex(v,w,u,S,P,new It(a,s)),this._addCollisionDebugVertex(v,w,u,S,P,new It(t,s)),_.vertexLength+=4;const M=l.indexArray;M.emplaceBack(y,y+1),M.emplaceBack(y+1,y+2),M.emplaceBack(y+2,y+3),M.emplaceBack(y+3,y),_.primitiveLength+=4}addDebugCollisionBoxes(t,i,a,s){for(let l=t;l<i;l++){const u=this.collisionBoxArray.get(l);this.addCollisionDebugVertices(u.x1,u.y1,u.x2,u.y2,s?this.textCollisionBox:this.iconCollisionBox,u.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Eh(ct,Bd.members,gt),this.iconCollisionBox=new Eh(ct,Bd.members,gt);for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.addDebugCollisionBoxes(i.textBoxStartIndex,i.textBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.iconBoxStartIndex,i.iconBoxEndIndex,i,!1),this.addDebugCollisionBoxes(i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex,i,!1)}}_deserializeCollisionBoxesForSymbol(t,i,a,s,l,u,f,_,y){const v={};for(let w=i;w<a;w++){const S=t.get(w);v.textBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.textFeatureIndex=S.featureIndex;break}for(let w=s;w<l;w++){const S=t.get(w);v.verticalTextBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.verticalTextFeatureIndex=S.featureIndex;break}for(let w=u;w<f;w++){const S=t.get(w);v.iconBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.iconFeatureIndex=S.featureIndex;break}for(let w=_;w<y;w++){const S=t.get(w);v.verticalIconBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.verticalIconFeatureIndex=S.featureIndex;break}return v}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const a=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.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,i){const a=t.placedSymbolArray.get(i),s=a.vertexStartIndex+4*a.numGlyphs;for(let l=a.vertexStartIndex;l<s;l+=4)t.indexArray.emplaceBack(l,l+2,l+1),t.indexArray.emplaceBack(l+1,l+2,l+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(t),a=Math.cos(t),s=[],l=[],u=[];for(let f=0;f<this.symbolInstances.length;++f){u.push(f);const _=this.symbolInstances.get(f);s.push(0|Math.round(i*_.anchorX+a*_.anchorY)),l.push(_.featureIndex)}return u.sort((f,_)=>s[f]-s[_]||l[_]-l[f]),u}addToSortKeyRanges(t,i){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===i?a.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:i,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 i of this.symbolInstanceIndexes){const a=this.symbolInstances.get(i);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach((s,l,u)=>{s>=0&&u.indexOf(s)===l&&this.addIndicesForPlacedSymbol(this.text,s)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Kd,Jd;Dt("SymbolBucket",vo,{omit:["layers","collisionBoxArray","features","compareText"]}),vo.MAX_GLYPHS=65535,vo.addDynamicAttributes=Mh;var Ch={get paint(){return Jd=Jd||new _i({"icon-opacity":new Vt(U.paint_symbol["icon-opacity"]),"icon-color":new Vt(U.paint_symbol["icon-color"]),"icon-halo-color":new Vt(U.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vt(U.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vt(U.paint_symbol["icon-halo-blur"]),"icon-translate":new Ft(U.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ft(U.paint_symbol["icon-translate-anchor"]),"text-opacity":new Vt(U.paint_symbol["text-opacity"]),"text-color":new Vt(U.paint_symbol["text-color"],{runtimeType:Di,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Vt(U.paint_symbol["text-halo-color"]),"text-halo-width":new Vt(U.paint_symbol["text-halo-width"]),"text-halo-blur":new Vt(U.paint_symbol["text-halo-blur"]),"text-translate":new Ft(U.paint_symbol["text-translate"]),"text-translate-anchor":new Ft(U.paint_symbol["text-translate-anchor"])})},get layout(){return Kd=Kd||new _i({"symbol-placement":new Ft(U.layout_symbol["symbol-placement"]),"symbol-spacing":new Ft(U.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ft(U.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vt(U.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ft(U.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ft(U.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ft(U.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ft(U.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ft(U.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ft(U.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vt(U.layout_symbol["icon-size"]),"icon-text-fit":new Ft(U.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ft(U.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vt(U.layout_symbol["icon-image"]),"icon-rotate":new Vt(U.layout_symbol["icon-rotate"]),"icon-padding":new Vt(U.layout_symbol["icon-padding"]),"icon-keep-upright":new Ft(U.layout_symbol["icon-keep-upright"]),"icon-offset":new Vt(U.layout_symbol["icon-offset"]),"icon-anchor":new Vt(U.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ft(U.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ft(U.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ft(U.layout_symbol["text-rotation-alignment"]),"text-field":new Vt(U.layout_symbol["text-field"]),"text-font":new Vt(U.layout_symbol["text-font"]),"text-size":new Vt(U.layout_symbol["text-size"]),"text-max-width":new Vt(U.layout_symbol["text-max-width"]),"text-line-height":new Ft(U.layout_symbol["text-line-height"]),"text-letter-spacing":new Vt(U.layout_symbol["text-letter-spacing"]),"text-justify":new Vt(U.layout_symbol["text-justify"]),"text-radial-offset":new Vt(U.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ft(U.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Vt(U.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Vt(U.layout_symbol["text-anchor"]),"text-max-angle":new Ft(U.layout_symbol["text-max-angle"]),"text-writing-mode":new Ft(U.layout_symbol["text-writing-mode"]),"text-rotate":new Vt(U.layout_symbol["text-rotate"]),"text-padding":new Ft(U.layout_symbol["text-padding"]),"text-keep-upright":new Ft(U.layout_symbol["text-keep-upright"]),"text-transform":new Vt(U.layout_symbol["text-transform"]),"text-offset":new Vt(U.layout_symbol["text-offset"]),"text-allow-overlap":new Ft(U.layout_symbol["text-allow-overlap"]),"text-overlap":new Ft(U.layout_symbol["text-overlap"]),"text-ignore-placement":new Ft(U.layout_symbol["text-ignore-placement"]),"text-optional":new Ft(U.layout_symbol["text-optional"])})}};class Qd{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:fe,this.defaultValue=t}evaluate(t){if(t.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(t.formattedSection))return i.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}}Dt("FormatSectionOverride",Qd,{omit:["defaultValue"]});class du extends Hi{constructor(t,i){super(t,Ch,i)}recalculate(t,i){if(super.recalculate(t,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const a=this.layout.get("text-writing-mode");if(a){const s=[];for(const l of a)s.indexOf(l)<0&&s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,i,a,s){const l=this.layout.get(t).evaluate(i,{},a,s),u=this._unevaluatedLayout._values[t];return u.isDataDriven()||Ws(u.value)||!l?l:function(f,_){return _.replace(/{([^{}]+)}/g,(y,v)=>f&&v in f?String(f[v]):"")}(i.properties,l)}createBucket(t){return new vo(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Ch.paint.overridableProperties){if(!du.hasPaintOverride(this.layout,t))continue;const i=this.paint.get(t),a=new Qd(i),s=new qs(a,i.property.specification);let l=null;l=i.value.kind==="constant"||i.value.kind==="source"?new kn("source",s):new Xs("composite",s,i.value.zoomStops),this.paint._values[t]=new lr(i.property,l,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,a){return!(!this.layout||i.isDataDriven()||a.isDataDriven())&&du.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){const a=t.get("text-field"),s=Ch.paint.properties[i];let l=!1;const u=f=>{for(const _ of f)if(s.overrides&&s.overrides.hasOverride(_))return void(l=!0)};if(a.value.kind==="constant"&&a.value.value instanceof qe)u(a.value.value.sections);else if(a.value.kind==="source"||a.value.kind==="composite"){const f=y=>{l||(y instanceof nn&&ve(y.value)===ta?u(y.value.sections):y instanceof En?u(y.sections):y.eachChild(f))},_=a.value;_._styleExpression&&f(_._styleExpression.expression)}return l}}let tp;var Rm={get paint(){return tp=tp||new _i({"background-color":new Ft(U.paint_background["background-color"]),"background-pattern":new Yc(U.paint_background["background-pattern"]),"background-opacity":new Ft(U.paint_background["background-opacity"])})}};class Lm extends Hi{constructor(t,i){super(t,Rm,i)}}class Fm extends Hi{constructor(t,i){super(t,{},i),this.onAdd=a=>{this.implementation.onAdd&&this.implementation.onAdd(a,a.painter.context.gl)},this.onRemove=a=>{this.implementation.onRemove&&this.implementation.onRemove(a,a.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Bm{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(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 Om={once:!0},Ah=63710088e-1;class Pa{constructor(t,i){if(isNaN(t)||isNaN(i))throw new Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pa(tr(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const i=Math.PI/180,a=this.lat*i,s=t.lat*i,l=Math.sin(a)*Math.sin(s)+Math.cos(a)*Math.cos(s)*Math.cos((t.lng-this.lng)*i);return Ah*Math.acos(Math.min(l,1))}static convert(t){if(t instanceof Pa)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new Pa(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new Pa(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 ep=2*Math.PI*Ah;function ip(r){return ep*Math.cos(r*Math.PI/180)}function rp(r){return(180+r)/360}function np(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function ap(r,t){return r/ip(t)}function sp(r){return 360*r-180}function pu(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function op(r,t){return r*ip(pu(t))}class Nl{constructor(t,i,a=0){this.x=+t,this.y=+i,this.z=+a}static fromLngLat(t,i=0){const a=Pa.convert(t);return new Nl(rp(a.lng),np(a.lat),ap(i,a.lat))}toLngLat(){return new Pa(sp(this.x),pu(this.y))}toAltitude(){return op(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ep*(t=pu(this.y),1/Math.cos(t*Math.PI/180));var t}}function lp(r,t,i){var a=2*Math.PI*6378137/256/Math.pow(2,i);return[r*a-2*Math.PI*6378137/2,t*a-2*Math.PI*6378137/2]}class Dh{constructor(t,i,a){if(!function(s,l,u){return!(s<0||s>25||u<0||u>=Math.pow(2,s)||l<0||l>=Math.pow(2,s))}(t,i,a))throw new Error(`x=${i}, y=${a}, 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=i,this.y=a,this.key=bo(0,t,t,i,a)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,i,a){const s=(u=this.y,f=this.z,_=lp(256*(l=this.x),256*(u=Math.pow(2,f)-u-1),f),y=lp(256*(l+1),256*(u+1),f),_[0]+","+_[1]+","+y[0]+","+y[1]);var l,u,f,_,y;const v=function(w,S,P){let M,C="";for(let z=w;z>0;z--)M=1<<z-1,C+=(S&M?1:0)+(P&M?2:0);return C}(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(a==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,i>1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,s)}isChildOf(t){const i=this.z-t.z;return i>0&&t.x===this.x>>i&&t.y===this.y>>i}getTilePoint(t){const i=Math.pow(2,this.z);return new It((t.x*i-this.x)*oe,(t.y*i-this.y)*oe)}toString(){return`${this.z}/${this.x}/${this.y}`}}class cp{constructor(t,i){this.wrap=t,this.canonical=i,this.key=bo(t,i.z,i.z,i.x,i.y)}}class cr{constructor(t,i,a,s,l){if(this.terrainRttPosMatrix32f=null,t<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${a}`);this.overscaledZ=t,this.wrap=i,this.canonical=new Dh(a,+s,+l),this.key=bo(i,t,a,s,l)}clone(){return new cr(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 i=this.canonical.z-t;return t>this.canonical.z?new cr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new cr(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,i){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-t;return t>this.canonical.z?bo(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):bo(this.wrap*+i,t,t,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(t.overscaledZ===0)return this.overscaledZ>0;const i=this.canonical.z-t.canonical.z;return!(i<0)&&t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new cr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,a=2*this.canonical.x,s=2*this.canonical.y;return[new cr(i,this.wrap,i,a,s),new cr(i,this.wrap,i,a+1,s),new cr(i,this.wrap,i,a,s+1),new cr(i,this.wrap,i,a+1,s+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 cr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new cr(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 cp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Nl(t.x-this.wrap,t.y))}}function bo(r,t,i,a,s){(r*=2)<0&&(r=-1*r-1);const l=1<<i;return(l*l*r+l*s+a).toString(36)+i.toString(36)+t.toString(36)}function Ul(r,t){return t?r.properties[t]:r.id}function jm(r,t){const i={id:r.id};if(t.removeAllProperties&&(delete r.removeProperties,delete r.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(const a of t.removeProperties){const s=r.addOrUpdateProperties.findIndex(l=>l.key===a);s>-1&&r.addOrUpdateProperties.splice(s,1)}return(r.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(r.removeProperties||t.removeProperties)&&(i.removeProperties=[...r.removeProperties||[],...t.removeProperties||[]]),(r.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...r.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(r.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||r.newGeometry),i}function up(r){var t,i;if(!r)return{};const a={};return a.removeAll=r.removeAll,a.remove=new Set(r.remove||[]),a.add=new Map((t=r.add)===null||t===void 0?void 0:t.map(s=>[s.id,s])),a.update=new Map((i=r.update)===null||i===void 0?void 0:i.map(s=>[s.id,s])),a}Dt("CanonicalTileID",Dh),Dt("OverscaledTileID",cr,{omit:["terrainRttPosMatrix32f"]});class hp{constructor(t){this._stringToNumber={},this._numberToString=[];for(let i=0;i<t.length;i++){const a=t[i];this._stringToNumber[a]=i,this._numberToString[i]=a}}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 dp{constructor(t,i,a,s,l){this.type="Feature",this._vectorTileFeature=t,t._z=i,t._x=a,t._y=s,this.properties=t.properties,this.id=l}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&(t[i]=this[i]);return t}}class wo{_name;dataBuffer;nullabilityBuffer;_size;constructor(t,i,a){this._name=t,this.dataBuffer=i,typeof a=="number"?this._size=a:(this.nullabilityBuffer=a,this._size=a.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 fu extends wo{}class zh extends fu{getValueFromBuffer(t){return this.dataBuffer[t]}}class kh extends fu{getValueFromBuffer(t){return this.dataBuffer[t]}}class pp extends wo{delta;constructor(t,i,a,s){super(t,i,s),this.delta=a}}class Rh extends pp{constructor(t,i,a,s){super(t,Int32Array.of(i),a,s)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}}class Lh extends wo{constructor(t,i,a){super(t,Int32Array.of(i),a)}getValueFromBuffer(t){return this.dataBuffer[0]}}class Vm{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(t,i,a,s,l=4096){this._name=t,this._geometryVector=i,this._idVector=a,this._propertyVectors=s,this._extent=l}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(i=>[i.name,i]))),this.propertyVectorsMap.get(t)}*[Symbol.iterator](){const t=this.geometryVector[Symbol.iterator]();let i=0;for(;i<this.numFeatures;){let a;this.idVector&&(a=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(i)):this.idVector.getValue(i));const s=t?.next().value,l={};for(const u of this.propertyVectors){if(!u)continue;const f=u.name,_=u.getValue(i);_!==null&&(l[f]=_)}i++,yield{id:a,geometry:s,properties:l}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const t=[],i=this.geometryVector.getGeometries();for(let a=0;a<this.numFeatures;a++){let s;this.idVector&&(s=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(a)):this.idVector.getValue(a));const l={coordinates:i[a],type:this.geometryVector.geometryType(a)},u={};for(const f of this.propertyVectors){if(!f)continue;const _=f.name,y=f.getValue(a);y!==null&&(u[_]=y)}t.push({id:s,geometry:l,properties:u})}return t}containsMaxSaveIntegerValues(t){return t instanceof zh||t instanceof Lh&&t instanceof Rh||t instanceof kh}}class Nm{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 gi,Qt,Zn,Br,ys,Yi,ii,ri,fp,ur;(function(r){r.PRESENT="PRESENT",r.DATA="DATA",r.OFFSET="OFFSET",r.LENGTH="LENGTH"})(gi||(gi={}));class Fh{_dictionaryType;_offsetType;_lengthType;constructor(t,i,a){this._dictionaryType=t,this._offsetType=i,this._lengthType=a}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Qe(r,t,i){const a=new Int32Array(i);let s=0,l=t.get();for(let u=0;u<a.length;u++){let f=r[l++],_=127&f;f<128||(f=r[l++],_|=(127&f)<<7,f<128||(f=r[l++],_|=(127&f)<<14,f<128||(f=r[l++],_|=(127&f)<<21,f<128||(f=r[l++],_|=(15&f)<<28)))),a[s++]=_}return t.set(l),a}function mu(r,t,i){const a=new BigInt64Array(i);for(let s=0;s<a.length;s++)a[s]=Gm(r,t);return a}function Um(r,t){let i,a;return a=r[t.get()],t.increment(),i=127&a,a<128?i:(a=r[t.get()],t.increment(),i|=(127&a)<<7,a<128?i:(a=r[t.get()],t.increment(),i|=(127&a)<<14,a<128?i:(a=r[t.get()],t.increment(),i|=(127&a)<<21,a<128?i:(a=r[t.get()],i|=(15&a)<<28,function(s,l,u){let f,_;if(_=l[u.get()],u.increment(),f=(112&_)>>4,_<128||(_=l[u.get()],u.increment(),f|=(127&_)<<3,_<128)||(_=l[u.get()],u.increment(),f|=(127&_)<<10,_<128)||(_=l[u.get()],u.increment(),f|=(127&_)<<17,_<128)||(_=l[u.get()],u.increment(),f|=(127&_)<<24,_<128)||(_=l[u.get()],u.increment(),f|=(1&_)<<31,_<128))return 4294967296*f+(s>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,r,t)))))}function mp(r,t,i,a){throw new Error("FastPFor is not implemented yet.")}function xs(r){return r>>>1^-(1&r)}function To(r){return r>>1n^-(1n&r)}function Gm(r,t){let i=0n,a=0,s=t.get();for(;s<r.length;){const l=r[s++];if(i|=BigInt(127&l)<<BigInt(a),!(128&l))break;if(a+=7,a>=64)throw new Error("Varint too long")}return t.set(s),i}function _p(r,t,i){const a=new Int32Array(i);let s=0;for(let l=0;l<t;l++){const u=r[l];a.fill(r[l+t],s,s+u),s+=u}return a}function gp(r,t,i){const a=new BigInt64Array(i);let s=0;for(let l=0;l<t;l++){const u=Number(r[l]);a.fill(r[l+t],s,s+u),s+=u}return a}function yp(r,t,i){const a=new Float64Array(i);let s=0;for(let l=0;l<t;l++){const u=r[l];a.fill(r[l+t],s,s+u),s+=u}return a}function Bh(r){const t=r.length/4*4;let i=1;if(t>=4)for(let a=r[0];i<t-4;i+=4)a=r[i]+=a,a=r[i+1]+=a,a=r[i+2]+=a,a=r[i+3]+=a;for(;i!=r.length;)r[i]+=r[i-1],++i}function xp(r){r[0]=r[0]>>>1^-(1&r[0]),r[1]=r[1]>>>1^-(1&r[1]);const t=r.length/4*4;let i=2;if(t>=4)for(;i<t-4;i+=4){const a=r[i],s=r[i+1],l=r[i+2],u=r[i+3];r[i]=(a>>>1^-(1&a))+r[i-2],r[i+1]=(s>>>1^-(1&s))+r[i-1],r[i+2]=(l>>>1^-(1&l))+r[i],r[i+3]=(u>>>1^-(1&u))+r[i+1]}for(;i!=r.length;i+=2)r[i]=(r[i]>>>1^-(1&r[i]))+r[i-2],r[i+1]=(r[i+1]>>>1^-(1&r[i+1]))+r[i-1]}function Ma(r,t,i){return Math.min(i,Math.max(t,r))}(function(r){r.NONE="NONE",r.DELTA="DELTA",r.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",r.RLE="RLE",r.MORTON="MORTON",r.PDE="PDE"})(Qt||(Qt={})),function(r){r.NONE="NONE",r.FAST_PFOR="FAST_PFOR",r.VARINT="VARINT",r.ALP="ALP"}(Zn||(Zn={})),function(r){r.NONE="NONE",r.SINGLE="SINGLE",r.SHARED="SHARED",r.VERTEX="VERTEX",r.MORTON="MORTON",r.FSST="FSST"}(Br||(Br={})),function(r){r.VERTEX="VERTEX",r.INDEX="INDEX",r.STRING="STRING",r.KEY="KEY"}(ys||(ys={})),function(r){r.VAR_BINARY="VAR_BINARY",r.GEOMETRIES="GEOMETRIES",r.PARTS="PARTS",r.RINGS="RINGS",r.TRIANGLES="TRIANGLES",r.SYMBOL="SYMBOL",r.DICTIONARY="DICTIONARY"}(Yi||(Yi={}));class vs{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(t,i,a,s,l,u,f){this._physicalStreamType=t,this._logicalStreamType=i,this._logicalLevelTechnique1=a,this._logicalLevelTechnique2=s,this._physicalLevelTechnique=l,this._numValues=u,this._byteLength=f}static decode(t,i){const a=t[i.get()],s=Object.values(gi)[a>>4];let l=null;switch(s){case gi.DATA:l=new Fh(Object.values(Br)[15&a]);break;case gi.OFFSET:l=new Fh(null,Object.values(ys)[15&a]);break;case gi.LENGTH:l=new Fh(null,null,Object.values(Yi)[15&a])}i.increment();const u=t[i.get()],f=Object.values(Qt)[u>>5],_=Object.values(Qt)[u>>2&7],y=Object.values(Zn)[3&u];i.increment();const v=Qe(t,i,2);return new vs(s,l,f,_,y,v[0],v[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class _u extends vs{num_bits;coordinate_shift;constructor(t,i,a,s,l,u,f,_,y){super(t,i,a,s,l,u,f),this.num_bits=_,this.coordinate_shift=y}static decode(t,i){const a=vs.decode(t,i),s=Qe(t,i,2);return new _u(a.physicalStreamType,a.logicalStreamType,a.logicalLevelTechnique1,a.logicalLevelTechnique2,a.physicalLevelTechnique,a.numValues,a.byteLength,s[0],s[1])}static decodePartial(t,i,a){const s=Qe(i,a,2);return new _u(t.physicalStreamType,t.logicalStreamType,t.logicalLevelTechnique1,t.logicalLevelTechnique2,t.physicalLevelTechnique,t.numValues,t.byteLength,s[0],s[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class Gl extends vs{_runs;_numRleValues;constructor(t,i,a,s,l,u,f,_,y){super(t,i,a,s,l,u,f),this._runs=_,this._numRleValues=y}static decode(t,i){const a=vs.decode(t,i),s=Qe(t,i,2);return new Gl(a.physicalStreamType,a.logicalStreamType,a.logicalLevelTechnique1,a.logicalLevelTechnique2,a.physicalLevelTechnique,a.numValues,a.byteLength,s[0],s[1])}static decodePartial(t,i,a){const s=Qe(i,a,2);return new Gl(t.physicalStreamType,t.logicalStreamType,t.logicalLevelTechnique1,t.logicalLevelTechnique2,t.physicalLevelTechnique,t.numValues,t.byteLength,s[0],s[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class Pi{static decode(t,i){const a=vs.decode(t,i);return a.logicalLevelTechnique1===Qt.MORTON?_u.decodePartial(a,t,i):Qt.RLE!==a.logicalLevelTechnique1&&Qt.RLE!==a.logicalLevelTechnique2||Zn.NONE===a.physicalLevelTechnique?a:Gl.decodePartial(a,t,i)}}(function(r){r[r.FLAT=0]="FLAT",r[r.CONST=1]="CONST",r[r.SEQUENCE=2]="SEQUENCE",r[r.DICTIONARY=3]="DICTIONARY",r[r.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(ii||(ii={}));class Or{values;_size;constructor(t,i){this.values=t,this._size=i}get(t){const i=Math.floor(t/8);return(this.values[i]>>t%8&1)==1}set(t,i){const a=Math.floor(t/8);this.values[a]=this.values[a]|(i?1:0)<<t%8}getInt(t){const i=Math.floor(t/8);return this.values[i]>>t%8&1}size(){return this._size}getBuffer(){return this.values}}class Wt{constructor(){}static decodeIntStream(t,i,a,s,l){const u=Wt.decodePhysicalLevelTechnique(t,i,a);return this.decodeIntBuffer(u,a,s,l)}static decodeLengthStreamToOffsetBuffer(t,i,a){const s=Wt.decodePhysicalLevelTechnique(t,i,a);return this.decodeLengthToOffsetBuffer(s,a)}static decodePhysicalLevelTechnique(t,i,a){const s=a.physicalLevelTechnique;if(s===Zn.FAST_PFOR)return mp();if(s===Zn.VARINT)return Qe(t,i,a.numValues);if(s===Zn.NONE){const l=i.get();i.add(a.byteLength);const u=t.subarray(l,i.get());return new Int32Array(u)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(t,i,a,s){const l=Wt.decodePhysicalLevelTechnique(t,i,a);if(l.length===1){const u=l[0];return s?xs(u):u}return s?function(u){return xs(u[1])}(l):function(u){return u[1]}(l)}static decodeSequenceIntStream(t,i,a){return function(s){if(s.length==2){const l=xs(s[1]);return[l,l]}return[xs(s[2]),xs(s[3])]}(Wt.decodePhysicalLevelTechnique(t,i,a))}static decodeSequenceLongStream(t,i,a){return function(s){if(s.length==2){const l=To(s[1]);return[l,l]}return[To(s[2]),To(s[3])]}(mu(t,i,a.numValues))}static decodeLongStream(t,i,a,s){const l=mu(t,i,a.numValues);return this.decodeLongBuffer(l,a,s)}static decodeLongFloat64Stream(t,i,a,s){const l=function(u,f,_){const y=new Float64Array(f);for(let v=0;v<f;v++)y[v]=Um(u,_);return y}(t,a.numValues,i);return this.decodeFloat64Buffer(l,a,s)}static decodeConstLongStream(t,i,a,s){const l=mu(t,i,a.numValues);if(l.length===1){const u=l[0];return s?To(u):u}return s?function(u){return To(u[1])}(l):function(u){return u[1]}(l)}static decodeIntBuffer(t,i,a,s){switch(i.logicalLevelTechnique1){case Qt.DELTA:return i.logicalLevelTechnique2===Qt.RLE?function(l,u,f){const _=new Int32Array(f);let y=0,v=0;for(let w=0;w<u;w++){const S=l[w],P=xs(l[w+u]);for(let M=0;M<S;M++)v+=P,_[y++]=v}return _}(t,i.runs,i.numRleValues):(function(l){l[0]=l[0]>>>1^-(1&l[0]);const u=l.length/4*4;let f=1;if(u>=4)for(;f<u-4;f+=4){const _=l[f],y=l[f+1],v=l[f+2],w=l[f+3];l[f]=(_>>>1^-(1&_))+l[f-1],l[f+1]=(y>>>1^-(1&y))+l[f],l[f+2]=(v>>>1^-(1&v))+l[f+1],l[f+3]=(w>>>1^-(1&w))+l[f+2]}for(;f!=l.length;++f)l[f]=(l[f]>>>1^-(1&l[f]))+l[f-1]}(t),t);case Qt.RLE:return function(l,u,f){return f?function(_,y,v){const w=new Int32Array(v);let S=0;for(let P=0;P<y;P++){const M=_[P];let C=_[P+y];C=C>>>1^-(1&C),w.fill(C,S,S+M),S+=M}return w}(l,u.runs,u.numRleValues):_p(l,u.runs,u.numRleValues)}(t,i,a);case Qt.MORTON:return Bh(t),t;case Qt.COMPONENTWISE_DELTA:return s?(function(l,u,f,_){let y=l[0]>>>1^-(1&l[0]),v=l[1]>>>1^-(1&l[1]);l[0]=Ma(Math.round(y*u),f,_),l[1]=Ma(Math.round(v*u),f,_);const w=l.length/16;let S=2;if(w>=4)for(;S<w-4;S+=4){const P=l[S],M=l[S+1],C=(P>>>1^-(1&P))+y,z=(M>>>1^-(1&M))+v;l[S]=Ma(Math.round(C*u),f,_),l[S+1]=Ma(Math.round(z*u),f,_);const F=l[S+2],Z=l[S+3];y=(F>>>1^-(1&F))+C,v=(Z>>>1^-(1&Z))+z,l[S+2]=Ma(Math.round(y*u),f,_),l[S+3]=Ma(Math.round(v*u),f,_)}for(;S!=l.length;S+=2)y+=l[S]>>>1^-(1&l[S]),v+=l[S+1]>>>1^-(1&l[S+1]),l[S]=Ma(Math.round(y*u),f,_),l[S+1]=Ma(Math.round(v*u),f,_)}(t,s.scale,s.min,s.max),t):(xp(t),t);case Qt.NONE:return a&&function(l){for(let u=0;u<l.length;u++){const f=l[u];l[u]=f>>>1^-(1&f)}}(t),t;default:throw new Error(`The specified Logical level technique is not supported: ${i.logicalLevelTechnique1}`)}}static decodeLongBuffer(t,i,a){switch(i.logicalLevelTechnique1){case Qt.DELTA:return i.logicalLevelTechnique2===Qt.RLE?function(s,l,u){const f=new BigInt64Array(u);let _=0,y=0n;for(let v=0;v<l;v++){const w=Number(s[v]),S=To(s[v+l]);for(let P=0;P<w;P++)y+=S,f[_++]=y}return f}(t,i.runs,i.numRleValues):(function(s){s[0]=s[0]>>1n^-(1n&s[0]);const l=s.length/4*4;let u=1;if(l>=4)for(;u<l-4;u+=4){const f=s[u],_=s[u+1],y=s[u+2],v=s[u+3];s[u]=(f>>1n^-(1n&f))+s[u-1],s[u+1]=(_>>1n^-(1n&_))+s[u],s[u+2]=(y>>1n^-(1n&y))+s[u+1],s[u+3]=(v>>1n^-(1n&v))+s[u+2]}for(;u!=s.length;++u)s[u]=(s[u]>>1n^-(1n&s[u]))+s[u-1]}(t),t);case Qt.RLE:return function(s,l,u){return u?function(f,_,y){const v=new BigInt64Array(y);let w=0;for(let S=0;S<_;S++){const P=Number(f[S]);let M=f[S+_];M=M>>1n^-(1n&M),v.fill(M,w,w+P),w+=P}return v}(s,l.runs,l.numRleValues):gp(s,l.runs,l.numRleValues)}(t,i,a);case Qt.NONE:return a&&function(s){for(let l=0;l<s.length;l++){const u=s[l];s[l]=u>>1n^-(1n&u)}}(t),t;default:throw new Error(`The specified Logical level technique is not supported: ${i.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(t,i,a){switch(i.logicalLevelTechnique1){case Qt.DELTA:return i.logicalLevelTechnique2===Qt.RLE&&(t=yp(t,i.runs,i.numRleValues)),function(s){s[0]=s[0]%2==1?(s[0]+1)/-2:s[0]/2;const l=s.length/4*4;let u=1;if(l>=4)for(;u<l-4;u+=4){const f=s[u],_=s[u+1],y=s[u+2],v=s[u+3];s[u]=(f%2==1?(f+1)/-2:f/2)+s[u-1],s[u+1]=(_%2==1?(_+1)/-2:_/2)+s[u],s[u+2]=(y%2==1?(y+1)/-2:y/2)+s[u+1],s[u+3]=(v%2==1?(v+1)/-2:v/2)+s[u+2]}for(;u!=s.length;++u)s[u]=(s[u]%2==1?(s[u]+1)/-2:s[u]/2)+s[u-1]}(t),t;case Qt.RLE:return function(s,l,u){return u?function(f,_,y){const v=new Float64Array(y);let w=0;for(let S=0;S<_;S++){const P=f[S];let M=f[S+_];M=M%2==1?(M+1)/-2:M/2,v.fill(M,w,w+P),w+=P}return v}(s,l.runs,l.numRleValues):yp(s,l.runs,l.numRleValues)}(t,i,a);case Qt.NONE:return a&&function(s){for(let l=0;l<s.length;l++){const u=s[l];s[l]=u%2==1?(u+1)/-2:u/2}}(t),t;default:throw new Error(`The specified Logical level technique is not supported: ${i.logicalLevelTechnique1}`)}}static decodeLengthToOffsetBuffer(t,i){if(i.logicalLevelTechnique1===Qt.DELTA&&i.logicalLevelTechnique2===Qt.NONE)return function(a){const s=new Int32Array(a.length+1);s[0]=0,s[1]=xs(a[0]);let l=s[1],u=2;for(;u!=s.length;++u){const f=a[u-1];l+=f>>>1^-(1&f),s[u]=s[u-1]+l}return s}(t);if(i.logicalLevelTechnique1===Qt.RLE&&i.logicalLevelTechnique2===Qt.NONE)return function(a,s,l){const u=new Int32Array(l+1);u[0]=0;let f=1,_=u[0];for(let y=0;y<s;y++){const v=a[y],w=a[y+s];for(let S=f;S<f+v;S++)u[S]=w+_,_=u[S];f+=v}return u}(t,i.runs,i.numRleValues);if(i.logicalLevelTechnique1===Qt.NONE&&i.logicalLevelTechnique2===Qt.NONE){(function(s){let l=0;for(let u=0;u<s.length;u++)s[u]+=l,l=s[u]})(t);const a=new Int32Array(i.numValues+1);return a[0]=0,a.set(t,1),a}if(i.logicalLevelTechnique1===Qt.DELTA&&i.logicalLevelTechnique2===Qt.RLE){const a=function(s,l,u){const f=new Int32Array(u+1);f[0]=0;let _=1,y=f[0];for(let v=0;v<l;v++){const w=s[v];let S=s[v+l];S=S>>>1^-(1&S);for(let P=_;P<_+w;P++)f[P]=S+y,y=f[P];_+=w}return f}(t,i.runs,i.numRleValues);return Bh(a),a}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}static decodeNullableIntStream(t,i,a,s,l){const u=a.physicalLevelTechnique===Zn.FAST_PFOR?mp():Qe(t,i,a.numValues);return this.decodeNullableIntBuffer(u,a,s,l)}static decodeNullableLongStream(t,i,a,s,l){const u=mu(t,i,a.numValues);return this.decodeNullableLongBuffer(u,a,s,l)}static decodeNullableIntBuffer(t,i,a,s){switch(i.logicalLevelTechnique1){case Qt.DELTA:return i.logicalLevelTechnique2===Qt.RLE&&(t=_p(t,i.runs,i.numRleValues)),function(l,u){const f=new Int32Array(l.size());let _=0;l.get(0)?(f[0]=l.get(0)?u[0]>>>1^-(1&u[0]):0,_=1):f[0]=0;let y=1;for(;y!=f.length;++y)f[y]=l.get(y)?f[y-1]+(u[_]>>>1^-(1&u[_++])):f[y-1];return f}(s,t);case Qt.RLE:return function(l,u,f,_){const y=u;return f?function(v,w,S){const P=new Int32Array(v.size());let M=0;for(let C=0;C<S;C++){const z=w[C];let F=w[C+S];F=F>>>1^-(1&F);for(let Z=M;Z<M+z;Z++)v.get(Z)?P[Z]=F:(P[Z]=0,M++);M+=z}return P}(_,l,y.runs):function(v,w,S){const P=new Int32Array(v.size());let M=0;for(let C=0;C<S;C++){const z=w[C],F=w[C+S];for(let Z=M;Z<M+z;Z++)v.get(Z)?P[Z]=F:(P[Z]=0,M++);M+=z}return P}(_,l,y.runs)}(t,i,a,s);case Qt.MORTON:return Bh(t),t;case Qt.COMPONENTWISE_DELTA:return xp(t),t;case Qt.NONE:return t=a?function(l,u){const f=new Int32Array(l.size());let _=0,y=0;for(;y!=f.length;++y)if(l.get(y)){const v=u[_++];f[y]=v>>>1^-(1&v)}else f[y]=0;return f}(s,t):function(l,u){const f=new Int32Array(l.size());let _=0,y=0;for(;y!=f.length;++y)f[y]=l.get(y)?u[_++]:0;return f}(s,t),t;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(t,i,a,s){switch(i.logicalLevelTechnique1){case Qt.DELTA:return i.logicalLevelTechnique2===Qt.RLE&&(t=gp(t,i.runs,i.numRleValues)),function(l,u){const f=new BigInt64Array(l.size());let _=0;l.get(0)?(f[0]=l.get(0)?u[0]>>1n^-(1n&u[0]):0n,_=1):f[0]=0n;let y=1;for(;y!=f.length;++y)f[y]=l.get(y)?f[y-1]+(u[_]>>1n^-(1n&u[_++])):f[y-1];return f}(s,t);case Qt.RLE:return function(l,u,f,_){const y=u;return f?function(v,w,S){const P=new BigInt64Array(v.size());let M=0;for(let C=0;C<S;C++){const z=Number(w[C]);let F=w[C+S];F=F>>1n^-(1n&F);for(let Z=M;Z<M+z;Z++)v.get(Z)?P[Z]=F:(P[Z]=0n,M++);M+=z}return P}(_,l,y.runs):function(v,w,S){const P=new BigInt64Array(v.size());let M=0;for(let C=0;C<S;C++){const z=Number(w[C]),F=w[C+S];for(let Z=M;Z<M+z;Z++)v.get(Z)?P[Z]=F:(P[Z]=0n,M++);M+=z}return P}(_,l,y.runs)}(t,i,a,s);case Qt.NONE:return t=a?function(l,u){const f=new BigInt64Array(l.size());let _=0,y=0;for(;y!=f.length;++y)if(l.get(y)){const v=u[_++];f[y]=v>>1n^-(1n&v)}else f[y]=0n;return f}(s,t):function(l,u){const f=new BigInt64Array(l.size());let _=0,y=0;for(;y!=f.length;++y)f[y]=l.get(y)?u[_++]:0n;return f}(s,t),t;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(t,i,a,s){const l=t.logicalLevelTechnique1;if(l===Qt.RLE)return t.runs===1?ii.CONST:ii.FLAT;const u=i instanceof Or?i.size():i;if(l===Qt.DELTA&&t.logicalLevelTechnique2===Qt.RLE){const f=t.runs,_=2;if(t.numRleValues!==u)return ii.FLAT;if(f===1)return ii.SEQUENCE;if(f===2){const y=s.get();let v;if(t.physicalLevelTechnique===Zn.VARINT)v=Qe(a,s,4);else{const w=s.get();v=new Int32Array(a.buffer,a.byteOffset+w,4)}if(s.set(y),v[2]===_&&v[3]===_)return ii.SEQUENCE}}return t.numValues===1?ii.CONST:ii.FLAT}}class vp extends fu{getValueFromBuffer(t){return this.dataBuffer[t]}}class bp extends pp{constructor(t,i,a,s){super(t,BigInt64Array.of(i),a,s)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}}class So{_geometryOffsets;_partOffsets;_ringOffsets;constructor(t,i,a){this._geometryOffsets=t,this._partOffsets=i,this._ringOffsets=a}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class Zm{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(t,i){this._coordinateShift=t<0?Math.abs(t):0,this.tileExtent=i+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=t,this.maxBound=i}validateCoordinates(t){if(t.x<this.minBound||t.y<this.minBound||t.x>this.maxBound||t.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class Po extends Zm{encode(t){this.validateCoordinates(t);const i=t.x+this._coordinateShift,a=t.y+this._coordinateShift;let s=0;for(let l=0;l<this._numBits;l++)s|=(i&1<<l)<<l|(a&1<<l)<<l+1;return s}decode(t){return{x:this.decodeMorton(t)-this._coordinateShift,y:this.decodeMorton(t>>1)-this._coordinateShift}}decodeMorton(t){let i=0;for(let a=0;a<this._numBits;a++)i|=(t&1<<2*a)>>a;return i}static decode(t,i,a){return{x:Po.decodeMorton(t,i)-a,y:Po.decodeMorton(t>>1,i)-a}}static decodeMorton(t,i){let a=0;for(let s=0;s<i;s++)a|=(t&1<<2*s)>>s;return a}}(function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON",r[r.MULTIPOINT=3]="MULTIPOINT",r[r.MULTILINESTRING=4]="MULTILINESTRING",r[r.MULTIPOLYGON=5]="MULTIPOLYGON"})(ri||(ri={})),function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON"}(fp||(fp={})),function(r){r[r.MORTON=0]="MORTON",r[r.VEC_2=1]="VEC_2",r[r.VEC_3=2]="VEC_3"}(ur||(ur={}));class $m{createPoint(t){return[[t]]}createMultiPoint(t){return t.map(i=>[i])}createLineString(t){return[t]}createMultiLineString(t){return t}createPolygon(t,i){return[t,...i]}createMultiPolygon(t){return t.flat()}}function wp(r){const t=new Array(r.numGeometries);let i=1,a=1,s=1,l=0;const u=new $m;let f=0,_=0;const y=r.mortonSettings,v=r.topologyVector,w=v.geometryOffsets,S=v.partOffsets,P=v.ringOffsets,M=r.vertexOffsets,C=r.containsPolygonGeometry(),z=r.vertexBuffer;for(let F=0;F<r.numGeometries;F++){const Z=r.geometryType(F);if(Z===ri.POINT){if(M&&M.length!==0)if(r.vertexBufferType===ur.VEC_2){const O=2*M[_++],N=new It(z[O],z[O+1]);t[l++]=u.createPoint(N)}else{const O=M[_++],N=Po.decode(z[O],y.numBits,y.coordinateShift),Q=new It(N.x,N.y);t[l++]=u.createPoint(Q)}else{const O=new It(z[f++],z[f++]);t[l++]=u.createPoint(O)}w&&s++,S&&i++,P&&a++}else if(Z===ri.MULTIPOINT){const O=w[s]-w[s-1];s++;const N=new Array(O);if(M&&M.length!==0){for(let Q=0;Q<O;Q++){const et=2*M[_++];N[Q]=new It(z[et],z[et+1])}t[l++]=u.createMultiPoint(N)}else{for(let Q=0;Q<O;Q++){const et=z[f++],lt=z[f++];N[Q]=new It(et,lt)}t[l++]=u.createMultiPoint(N)}}else if(Z===ri.LINESTRING){let O,N=0;C?(N=P[a]-P[a-1],a++):N=S[i]-S[i-1],i++,M&&M.length!==0?(O=r.vertexBufferType===ur.VEC_2?jh(z,M,_,N,!1):Vh(z,M,_,N,!1,y),_+=N):(O=Oh(z,f,N,!1),f+=2*N),t[l++]=u.createLineString(O),w&&s++}else if(Z===ri.POLYGON){const O=S[i]-S[i-1];i++;const N=new Array(O-1);let Q=P[a]-P[a-1];if(a++,M&&M.length!==0){const et=r.vertexBufferType===ur.VEC_2?yu(z,M,_,Q):xu(z,M,_,Q,0,y);_+=Q;for(let lt=0;lt<N.length;lt++)Q=P[a]-P[a-1],a++,N[lt]=r.vertexBufferType===ur.VEC_2?yu(z,M,_,Q):xu(z,M,_,Q,0,y),_+=Q;t[l++]=u.createPolygon(et,N)}else{const et=gu(z,f,Q);f+=2*Q;for(let lt=0;lt<N.length;lt++)Q=P[a]-P[a-1],a++,N[lt]=gu(z,f,Q),f+=2*Q;t[l++]=u.createPolygon(et,N)}w&&s++}else if(Z===ri.MULTILINESTRING){const O=w[s]-w[s-1];s++;const N=new Array(O);if(M&&M.length!==0){for(let Q=0;Q<O;Q++){let et=0;C?(et=P[a]-P[a-1],a++):et=S[i]-S[i-1],i++;const lt=r.vertexBufferType===ur.VEC_2?jh(z,M,_,et,!1):Vh(z,M,_,et,!1,y);N[Q]=lt,_+=et}t[l++]=u.createMultiLineString(N)}else{for(let Q=0;Q<O;Q++){let et=0;C?(et=P[a]-P[a-1],a++):et=S[i]-S[i-1],i++,N[Q]=Oh(z,f,et,!1),f+=2*et}t[l++]=u.createMultiLineString(N)}}else{if(Z!==ri.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const O=w[s]-w[s-1];s++;const N=new Array(O);let Q=0;if(M&&M.length!==0){for(let et=0;et<O;et++){const lt=S[i]-S[i-1];i++;const yt=new Array(lt-1);Q=P[a]-P[a-1],a++;const mt=r.vertexBufferType===ur.VEC_2?yu(z,M,_,Q):xu(z,M,_,Q,0,y);_+=Q;for(let vt=0;vt<yt.length;vt++)Q=P[a]-P[a-1],a++,yt[vt]=r.vertexBufferType===ur.VEC_2?yu(z,M,_,Q):xu(z,M,_,Q,0,y),_+=Q;N[et]=u.createPolygon(mt,yt)}t[l++]=u.createMultiPolygon(N)}else{for(let et=0;et<O;et++){const lt=S[i]-S[i-1];i++;const yt=new Array(lt-1);Q=P[a]-P[a-1],a++;const mt=gu(z,f,Q);f+=2*Q;for(let vt=0;vt<yt.length;vt++){const Ct=P[a]-P[a-1];a++,yt[vt]=gu(z,f,Ct),f+=2*Ct}N[et]=u.createPolygon(mt,yt)}t[l++]=u.createMultiPolygon(N)}}}}return t}function gu(r,t,i){return Oh(r,t,i,!0)}function yu(r,t,i,a){return jh(r,t,i,a,!0)}function xu(r,t,i,a,s,l){return Vh(r,t,i,a,!0,l)}function Oh(r,t,i,a){const s=new Array(a?i+1:i);for(let l=0;l<2*i;l+=2)s[l/2]=new It(r[t+l],r[t+l+1]);return a&&(s[s.length-1]=s[0]),s}function jh(r,t,i,a,s){const l=new Array(s?a+1:a);for(let u=0;u<2*a;u+=2){const f=2*t[i+u/2];l[u/2]=new It(r[f],r[f+1])}return s&&(l[l.length-1]=l[0]),l}function Vh(r,t,i,a,s,l){const u=new Array(s?a+1:a);for(let f=0;f<a;f++){const _=Po.decode(r[t[i+f]],l.numBits,l.coordinateShift);u[f]=new It(_.x,_.y)}return s&&(u[u.length-1]=u[0]),u}class Tp{_vertexBufferType;_topologyVector;_vertexOffsets;_vertexBuffer;_mortonSettings;constructor(t,i,a,s,l){this._vertexBufferType=t,this._topologyVector=i,this._vertexOffsets=a,this._vertexBuffer=s,this._mortonSettings=l}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const t=wp(this);let i=0;for(;i<this.numGeometries;)yield{coordinates:t[i],type:this.geometryType(i)},i++}getSimpleEncodedVertex(t){const i=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[i],this.vertexBuffer[i+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){const a=Po.decode(this.vertexBuffer[this.vertexOffsets[t]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[a.x,a.y]}const i=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[i],this.vertexBuffer[i+1]]}getGeometries(){return wp(this)}get mortonSettings(){return this._mortonSettings}}class Zl extends Tp{_numGeometries;_geometryType;constructor(t,i,a,s,l,u,f){super(a,s,l,u,f),this._numGeometries=t,this._geometryType=i}static createMortonEncoded(t,i,a,s,l,u){return new Zl(t,i,ur.MORTON,a,s,l,u)}static create(t,i,a,s,l){return new Zl(t,i,ur.VEC_2,a,s,l)}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===ri.POLYGON||this._geometryType===ri.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class $l extends Tp{_geometryTypes;constructor(t,i,a,s,l,u){super(t,a,s,l,u),this._geometryTypes=i}static createMortonEncoded(t,i,a,s,l){return new $l(ur.MORTON,t,i,a,s,l)}static create(t,i,a,s){return new $l(ur.VEC_2,t,i,a,s)}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)===ri.POLYGON||this.geometryType(t)===ri.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class Sp{_triangleOffsets;_indexBuffer;_vertexBuffer;_topologyVector;constructor(t,i,a,s){this._triangleOffsets=t,this._indexBuffer=i,this._vertexBuffer=a,this._topologyVector=s}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),i=this._topologyVector,a=i.partOffsets,s=i.ringOffsets,l=i.geometryOffsets;let u=0,f=1,_=1,y=1;for(let v=0;v<this.numGeometries;v++)switch(this.geometryType(v)){case ri.POLYGON:{const w=a[f]-a[f-1];f++;const S=[];for(let P=0;P<w;P++){const M=s[_]-s[_-1];_++;const C=[];for(let z=0;z<M;z++){const F=this._vertexBuffer[u++],Z=this._vertexBuffer[u++];C.push(new It(F,Z))}C.length>0&&C.push(C[0]),S.push(C)}t[v]=S,l&&y++}break;case ri.MULTIPOLYGON:{const w=l[y]-l[y-1];y++;const S=[];for(let P=0;P<w;P++){const M=a[f]-a[f-1];f++;for(let C=0;C<M;C++){const z=s[_]-s[_-1];_++;const F=[];for(let Z=0;Z<z;Z++){const O=this._vertexBuffer[u++],N=this._vertexBuffer[u++];F.push(new It(O,N))}F.length>0&&F.push(F[0]),S.push(F)}}t[v]=S}}return t}[Symbol.iterator](){return null}}class vu extends Sp{_numGeometries;_geometryType;constructor(t,i,a,s,l,u){super(a,s,l,u),this._numGeometries=t,this._geometryType=i}static create(t,i,a,s,l,u){return new vu(t,i,a,s,l,u)}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class bu extends Sp{_geometryTypes;constructor(t,i,a,s,l){super(i,a,s,l),this._geometryTypes=t}static create(t,i,a,s,l){return new bu(t,i,a,s,l)}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function qm(r,t,i,a,s){const l=Pi.decode(r,i);let u=null,f=null,_=null,y=null,v=null,w=null,S=null,P=null;if(Wt.getVectorType(l,a,r,i)===ii.CONST){const C=Wt.decodeConstIntStream(r,i,l,!1);for(let z=0;z<t-1;z++){const F=Pi.decode(r,i);switch(F.physicalStreamType){case gi.LENGTH:switch(F.logicalStreamType.lengthType){case Yi.GEOMETRIES:u=Wt.decodeLengthStreamToOffsetBuffer(r,i,F);break;case Yi.PARTS:f=Wt.decodeLengthStreamToOffsetBuffer(r,i,F);break;case Yi.RINGS:_=Wt.decodeLengthStreamToOffsetBuffer(r,i,F);break;case Yi.TRIANGLES:S=Wt.decodeLengthStreamToOffsetBuffer(r,i,F)}break;case gi.OFFSET:switch(F.logicalStreamType.offsetType){case ys.VERTEX:y=Wt.decodeIntStream(r,i,F,!1);break;case ys.INDEX:P=Wt.decodeIntStream(r,i,F,!1)}break;case gi.DATA:if(Br.VERTEX===F.logicalStreamType.dictionaryType)v=Wt.decodeIntStream(r,i,F,!0,s);else{const Z=F;w={numBits:Z.numBits(),coordinateShift:Z.coordinateShift()},v=Wt.decodeIntStream(r,i,F,!1,s)}}}if(P!==null){if(u!=null||f!=null){const z=new So(u,f,_);return vu.create(a,C,S,P,v,z)}return vu.create(a,C,S,P,v)}return w===null?Zl.create(a,C,new So(u,f,_),y,v):Zl.createMortonEncoded(a,C,new So(u,f,_),y,v,w)}const M=Wt.decodeIntStream(r,i,l,!1);for(let C=0;C<t-1;C++){const z=Pi.decode(r,i);switch(z.physicalStreamType){case gi.LENGTH:switch(z.logicalStreamType.lengthType){case Yi.GEOMETRIES:u=Wt.decodeIntStream(r,i,z,!1);break;case Yi.PARTS:f=Wt.decodeIntStream(r,i,z,!1);break;case Yi.RINGS:_=Wt.decodeIntStream(r,i,z,!1);break;case Yi.TRIANGLES:S=Wt.decodeLengthStreamToOffsetBuffer(r,i,z)}break;case gi.OFFSET:switch(z.logicalStreamType.offsetType){case ys.VERTEX:y=Wt.decodeIntStream(r,i,z,!1);break;case ys.INDEX:P=Wt.decodeIntStream(r,i,z,!1)}break;case gi.DATA:if(Br.VERTEX===z.logicalStreamType.dictionaryType)v=Wt.decodeIntStream(r,i,z,!0,s);else{const F=z;w={numBits:F.numBits(),coordinateShift:F.coordinateShift()},v=Wt.decodeIntStream(r,i,z,!1,s)}}}return P!==null&&f===null?bu.create(M,S,P,v):(u!==null?(u=Nh(M,u,2),f!==null&&_!==null?(f=Pp(M,u,f,!1),_=function(C,z,F,Z){const O=new Int32Array(F[F.length-1]+1);let N=0;O[0]=N;let Q=1,et=1,lt=0;for(let yt=0;yt<C.length;yt++){const mt=C[yt],vt=z[yt+1]-z[yt];if(mt!==0&&mt!==3)for(let Ct=0;Ct<vt;Ct++){const St=F[Q]-F[Q-1];Q++;for(let Pt=0;Pt<St;Pt++)N=O[et++]=N+Z[lt++]}else for(let Ct=0;Ct<vt;Ct++)O[et++]=++N,Q++}return O}(M,u,f,_)):f!==null&&(f=function(C,z,F){const Z=new Int32Array(z[z.length-1]+1);let O=0;Z[0]=O;let N=1,Q=0;for(let et=0;et<C.length;et++){const lt=C[et],yt=z[et+1]-z[et];if(lt===4||lt===1)for(let mt=0;mt<yt;mt++)O=Z[N++]=O+F[Q++];else for(let mt=0;mt<yt;mt++)Z[N++]=++O}return Z}(M,u,f))):f!==null&&_!==null?(f=Nh(M,f,1),_=Pp(M,f,_,!0)):f!==null&&(f=Nh(M,f,0)),P!==null?bu.create(M,S,P,v,new So(u,f,_)):w===null?$l.create(M,new So(u,f,_),y,v):$l.createMortonEncoded(M,new So(u,f,_),y,v,w))}function Nh(r,t,i){const a=new Int32Array(r.length+1);let s=0;a[0]=s;let l=0;for(let u=0;u<r.length;u++)s=a[u+1]=s+(r[u]>i?t[l++]:1);return a}function Pp(r,t,i,a){const s=new Int32Array(t[t.length-1]+1);let l=0;s[0]=l;let u=1,f=0;for(let _=0;_<r.length;_++){const y=r[_],v=t[_+1]-t[_];if(y===5||y===2||a&&(y===4||y===1))for(let w=0;w<v;w++)l=s[u++]=l+i[f++];else for(let w=0;w<v;w++)s[u++]=++l}return s}class Wm extends wo{dataVector;constructor(t,i,a){super(t,i.getBuffer(),a),this.dataVector=i}getValueFromBuffer(t){return this.dataVector.get(t)}}class Hm extends fu{getValueFromBuffer(t){return this.dataBuffer[t]}}class Mp extends wo{constructor(t,i,a){super(t,BigInt64Array.of(i),a)}getValueFromBuffer(t){return this.dataBuffer[0]}}function Xm(r,t,i){for(let a=0;a<r;a++){const s=Pi.decode(t,i);i.add(s.byteLength)}}function ql(r,t,i){return Ip(r,Math.ceil(t/8),i)}function Ip(r,t,i){const a=new Uint8Array(t);let s=0;for(;s<t;){const l=r[i.increment()];if(l<=127){const u=l+3,f=r[i.increment()],_=s+u;a.fill(f,s,_),s=_}else{const u=256-l;for(let f=0;f<u;f++)a[s++]=r[i.increment()]}}return a}const Ym=new TextDecoder;function Uh(r,t,i){return i-t>=12?Ym.decode(r.subarray(t,i)):function(a,s,l){let u="",f=s;for(;f<l;){const _=a[f];let y,v,w,S=null,P=_>239?4:_>223?3:_>191?2:1;if(f+P>l)break;P===1?_<128&&(S=_):P===2?(y=a[f+1],(192&y)==128&&(S=(31&_)<<6|63&y,S<=127&&(S=null))):P===3?(y=a[f+1],v=a[f+2],(192&y)==128&&(192&v)==128&&(S=(15&_)<<12|(63&y)<<6|63&v,(S<=2047||S>=55296&&S<=57343)&&(S=null))):P===4&&(y=a[f+1],v=a[f+2],w=a[f+3],(192&y)==128&&(192&v)==128&&(192&w)==128&&(S=(15&_)<<18|(63&y)<<12|(63&v)<<6|63&w,(S<=65535||S>=1114112)&&(S=null))),S===null?(S=65533,P=1):S>65535&&(S-=65536,u+=String.fromCharCode(S>>>10&1023|55296),S=56320|1023&S),u+=String.fromCharCode(S),f+=P}return u}(r,t,i)}class Gh extends wo{offsetBuffer;constructor(t,i,a,s){super(t,a,s),this.offsetBuffer=i}}class Ep extends Gh{textEncoder;constructor(t,i,a,s){super(t,i,a,s??i.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(t){return Uh(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Mo extends Gh{indexBuffer;textEncoder;constructor(t,i,a,s,l){super(t,a,s,l??i.length),this.indexBuffer=i,this.indexBuffer=i,this.textEncoder=new TextEncoder}getValueFromBuffer(t){const i=this.indexBuffer[t];return Uh(this.dataBuffer,this.offsetBuffer[i],this.offsetBuffer[i+1])}}class Cp extends Gh{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(t,i,a,s,l,u,f){super(t,a,s,f),this.indexBuffer=i,this.symbolOffsetBuffer=l,this.symbolTableBuffer=u,this.textEncoder=new TextEncoder}getValueFromBuffer(t){this.decodedDictionary==null&&(this.symbolLengthBuffer==null&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(a,s,l){const u=[],f=new Array(s.length).fill(0);for(let _=1;_<s.length;_++)f[_]=f[_-1]+s[_-1];for(let _=0;_<l.length;_++)if(l[_]===255)u.push(l[++_]);else{const y=s[l[_]],v=f[l[_]];for(let w=0;w<y;w++)u.push(a[v+w])}return new Uint8Array(u)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const i=this.indexBuffer[t];return Uh(this.decodedDictionary,this.offsetBuffer[i],this.offsetBuffer[i+1])}offsetToLengthBuffer(t){const i=new Uint32Array(t.length-1);let a=t[0];for(let s=1;s<t.length;s++){const l=t[s];i[s-1]=l-a,a=l}return i}}class Wl{static ROOT_COLUMN_NAME="default";static NESTED_COLUMN_SEPARATOR=":";constructor(){}static decode(t,i,a,s,l){let u=null,f=null,_=null,y=null,v=null,w=null,S=null,P=null;for(let M=0;M<s;M++){const C=Pi.decode(i,a);if(C.byteLength!==0)switch(C.physicalStreamType){case gi.PRESENT:{const z=ql(i,C.numValues,a);w=new Or(z,C.numValues);break}case gi.OFFSET:f=l!=null||w!=null?Wt.decodeNullableIntStream(i,a,C,!1,l??w):Wt.decodeIntStream(i,a,C,!1);break;case gi.LENGTH:{const z=Wt.decodeLengthStreamToOffsetBuffer(i,a,C);Yi.DICTIONARY===C.logicalStreamType.lengthType?u=z:Yi.SYMBOL===C.logicalStreamType.lengthType?y=z:S=z;break}case gi.DATA:{const z=i.subarray(a.get(),a.get()+C.byteLength);a.add(C.byteLength);const F=C.logicalStreamType.dictionaryType;Br.FSST===F?v=z:Br.SINGLE===F||Br.SHARED===F?_=z:Br.NONE===F&&(P=z);break}}}return this.decodeFsstDictionaryVector(t,v,f,u,_,y,l??w)??this.decodeDictionaryVector(t,_,f,u,l??w)??this.decodePlainStringVector(t,S,P,f,l??w)}static decodeFsstDictionaryVector(t,i,a,s,l,u,f){return i?new Cp(t,a,s,l,u,i,f):null}static decodeDictionaryVector(t,i,a,s,l){return i?l?new Mo(t,a,s,i,l):new Mo(t,a,s,i):null}static decodePlainStringVector(t,i,a,s,l){if(!i||!a)return null;if(s)return l?new Mo(t,s,i,a,l):new Mo(t,s,i,a);if(l&&l.size()!==i.length-1){const u=new Int32Array(l.size());let f=0;for(let _=0;_<l.size();_++)u[_]=l.get(_)?f++:0;return new Mo(t,u,i,a,l)}return l?new Ep(t,i,a,l):new Ep(t,i,a)}static decodeSharedDictionary(t,i,a,s,l){let u=null,f=null,_=null,y=null,v=!1;for(;!v;){const M=Pi.decode(t,i);switch(M.physicalStreamType){case gi.LENGTH:Yi.DICTIONARY===M.logicalStreamType.lengthType?u=Wt.decodeLengthStreamToOffsetBuffer(t,i,M):_=Wt.decodeLengthStreamToOffsetBuffer(t,i,M);break;case gi.DATA:Br.SINGLE===M.logicalStreamType.dictionaryType||Br.SHARED===M.logicalStreamType.dictionaryType?(f=t.subarray(i.get(),i.get()+M.byteLength),v=!0):y=t.subarray(i.get(),i.get()+M.byteLength),i.add(M.byteLength)}}const w=a.complexType.children,S=[];let P=0;for(const M of w){const C=Qe(t,i,1)[0];if(C==0)continue;const z=`${a.name}${M.name===Wl.ROOT_COLUMN_NAME?"":Wl.NESTED_COLUMN_SEPARATOR+M.name}`;if(l&&!l.has(z)){Xm(C,t,i);continue}if(C!==2||M.type!=="scalarField"||M.scalarField.physicalType!==9)throw new Error("Currently only optional string fields are implemented for a struct.");const F=Pi.decode(t,i),Z=ql(t,F.numValues,i),O=Pi.decode(t,i),N=(O instanceof Gl?O.numRleValues:O.numValues)!==s?Wt.decodeNullableIntStream(t,i,O,!1,new Or(Z,F.numValues)):Wt.decodeIntStream(t,i,O,!1);S[P++]=y?new Cp(z,N,u,f,_,y,new Or(Z,F.numValues)):new Mo(z,N,u,f,new Or(Z,F.numValues))}return S}}function Km(r,t,i,a,s,l){return i.type==="scalarType"?function(u,f,_,y,v,w){let S=null,P=0;if(u===0)return null;if(w.nullable){const C=Pi.decode(f,_);P=C.numValues;const z=_.get(),F=ql(f,P,_);_.set(z+C.byteLength),S=new Or(F,C.numValues)}const M=S??y;switch(v.physicalType){case 4:case 3:return function(C,z,F,Z,O){const N=Pi.decode(C,z),Q=Wt.getVectorType(N,O,C,z),et=Z.physicalType===3;if(Q===ii.FLAT){const lt=Hl(O)?Wt.decodeNullableIntStream(C,z,N,et,O):Wt.decodeIntStream(C,z,N,et);return new zh(F.name,lt,O)}if(Q===ii.SEQUENCE){const lt=Wt.decodeSequenceIntStream(C,z,N);return new Rh(F.name,lt[0],lt[1],N.numRleValues)}{const lt=Wt.decodeConstIntStream(C,z,N,et);return new Lh(F.name,lt,O)}}(f,_,w,v,M);case 9:return Wl.decode(w.name,f,_,w.nullable?u-1:u,S);case 0:return function(C,z,F,Z,O){const N=Pi.decode(C,z),Q=N.numValues,et=z.get(),lt=Hl(O)?function(mt,vt,Ct,St){const Pt=Ip(mt,Math.ceil(vt/8),Ct),_t=new Or(Pt,vt),Bt=St.size(),Ot=new Or(new Uint8Array(Bt),Bt);let Nt=0;for(let kt=0;kt<St.size();kt++){const Xt=!!St.get(kt)&&_t.get(Nt++);Ot.set(kt,Xt)}return Ot.getBuffer()}(C,Q,z,O):ql(C,Q,z);z.set(et+N.byteLength);const yt=new Or(lt,Q);return new Wm(F.name,yt,O)}(f,_,w,0,M);case 6:case 5:return function(C,z,F,Z,O){const N=Pi.decode(C,z),Q=Wt.getVectorType(N,Z,C,z),et=O.physicalType===5;if(Q===ii.FLAT){const lt=Hl(Z)?Wt.decodeNullableLongStream(C,z,N,et,Z):Wt.decodeLongStream(C,z,N,et);return new vp(F.name,lt,Z)}if(Q===ii.SEQUENCE){const lt=Wt.decodeSequenceLongStream(C,z,N);return new bp(F.name,lt[0],lt[1],N.numRleValues)}{const lt=Wt.decodeConstLongStream(C,z,N,et);return new Mp(F.name,lt,Z)}}(f,_,w,M,v);case 7:return function(C,z,F,Z){const O=Pi.decode(C,z),N=Hl(Z)?function(Q,et,lt,yt){const mt=et.get(),vt=mt+yt*Float32Array.BYTES_PER_ELEMENT,Ct=new Uint8Array(Q.subarray(mt,vt)).buffer,St=new Float32Array(Ct);et.set(vt);const Pt=lt.size(),_t=new Float32Array(Pt);let Bt=0;for(let Ot=0;Ot<Pt;Ot++)_t[Ot]=lt.get(Ot)?St[Bt++]:0;return _t}(C,z,Z,O.numValues):function(Q,et,lt){const yt=et.get(),mt=yt+lt*Float32Array.BYTES_PER_ELEMENT,vt=new Uint8Array(Q.subarray(yt,mt)).buffer,Ct=new Float32Array(vt);return et.set(mt),Ct}(C,z,O.numValues);return new Hm(F.name,N,Z)}(f,_,w,M);case 8:return function(C,z,F,Z){const O=Pi.decode(C,z),N=Hl(Z)?function(Q,et,lt,yt){const mt=et.get(),vt=mt+yt*Float64Array.BYTES_PER_ELEMENT,Ct=new Uint8Array(Q.subarray(mt,vt)).buffer,St=new Float64Array(Ct);et.set(vt);const Pt=lt.size(),_t=new Float64Array(Pt);let Bt=0;for(let Ot=0;Ot<Pt;Ot++)_t[Ot]=lt.get(Ot)?St[Bt++]:0;return _t}(C,z,Z,O.numValues):function(Q,et,lt){const yt=et.get(),mt=yt+lt*Float64Array.BYTES_PER_ELEMENT,vt=new Uint8Array(Q.subarray(yt,mt)).buffer,Ct=new Float64Array(vt);return et.set(mt),Ct}(C,z,O.numValues);return new kh(F.name,N,Z)}(f,_,w,M);default:throw new Error(`The specified data type for the field is currently not supported: ${v}`)}}(a,r,t,s,i.scalarType,i):a!=1?null:Wl.decodeSharedDictionary(r,t,i,s,l)}function Hl(r){return r instanceof Or}class wu{static decodeColumnType(t){switch(t){case 0:case 1:case 2:case 3:{const i={};i.nullable=!!(1&t),i.columnScope=0;const a={};return a.physicalType=t>1?6:4,a.type="physicalType",i.scalarType=a,i.type="scalarType",i}case 4:{const i={nullable:!1,columnScope:0},a={type:"physicalType",physicalType:0};return i.type="complexType",i.complexType=a,i}case 30:{const i={nullable:!1,columnScope:0},a={type:"physicalType",physicalType:1};return i.type="complexType",i.complexType=a,i}default:return this.mapScalarType(t)}}static columnTypeHasName(t){return t>=10}static columnTypeHasChildren(t){return t===30}static hasStreamCount(t){if(t.name==="id")return!1;if(t.type==="scalarType"){const i=t.scalarType;if(i.type==="physicalType")switch(i.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(i.type==="logicalType")return!1}else if(t.type==="complexType"){const i=t.complexType;if(i.type==="physicalType")switch(i.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}static mapScalarType(t){let i=null;switch(t){case 10:case 11:i=0;break;case 12:case 13:i=1;break;case 14:case 15:i=2;break;case 16:case 17:i=3;break;case 18:case 19:i=4;break;case 20:case 21:i=5;break;case 22:case 23:i=6;break;case 24:case 25:i=7;break;case 26:case 27:i=8;break;case 28:case 29:i=9;break;default:return null}const a={};a.nullable=!!(1&t),a.columnScope=0;const s={type:"physicalType"};return s.physicalType=i,a.type="scalarType",a.scalarType=s,a}}const Jm=new TextDecoder;function Ap(r,t){const i=Qe(r,t,1)[0];if(i===0)return"";const a=t.get(),s=r.subarray(a,a+i);return t.add(i),Jm.decode(s)}function Dp(r,t){const i=Qe(r,t,1)[0]>>>0,a=!!(4&i),s=!!(2&i),l=Qe(r,t,1)[0]>>>0,u={};if(1&i&&(u.nullable=!0),s){const f={};if(a?(f.type="logicalType",f.logicalType=l):(f.type="physicalType",f.physicalType=l),8&i){const _=Qe(r,t,1)[0]>>>0;f.children=new Array(_);for(let y=0;y<_;y++)f.children[y]=Dp(r,t)}u.type="complexField",u.complexField=f}else{const f={};a?(f.type="logicalType",f.logicalType=l):(f.type="physicalType",f.physicalType=l),u.type="scalarField",u.scalarField=f}return u}function Qm(r,t){const i=Qe(r,t,1)[0]>>>0,a=wu.decodeColumnType(i);if(!a)throw new Error(`Unsupported column type code: ${i}`);if(wu.columnTypeHasName(i)?a.name=Ap(r,t):i>=0&&i<=3?a.name="id":i===4&&(a.name="geometry"),wu.columnTypeHasChildren(i)){const s=Qe(r,t,1)[0]>>>0,l=a.complexType;l.children=new Array(s);for(let u=0;u<s;u++)l.children[u]=Dp(r,t)}return a}function t_(r,t){const i={featureTables:[]},a={};a.name=Ap(r,t);const s=Qe(r,t,1)[0]>>>0,l=Qe(r,t,1)[0]>>>0;a.columns=new Array(l);for(let u=0;u<l;u++)a.columns[u]=Qm(r,t);return i.featureTables.push(a),[i,s]}function e_(r,t,i,a,s,l,u=!1){const f=t.scalarType.physicalType,_=Wt.getVectorType(s,l,r,i);if(f===4)switch(_){case ii.FLAT:{const y=Wt.decodeIntStream(r,i,s,!1);return new zh(a,y,l)}case ii.SEQUENCE:{const y=Wt.decodeSequenceIntStream(r,i,s);return new Rh(a,y[0],y[1],s.numRleValues)}case ii.CONST:{const y=Wt.decodeConstIntStream(r,i,s,!1);return new Lh(a,y,l)}}else switch(_){case ii.FLAT:{if(u){const v=Wt.decodeLongFloat64Stream(r,i,s,!1);return new kh(a,v,l)}const y=Wt.decodeLongStream(r,i,s,!1);return new vp(a,y,l)}case ii.SEQUENCE:{const y=Wt.decodeSequenceLongStream(r,i,s);return new bp(a,y[0],y[1],s.numRleValues)}case ii.CONST:{const y=Wt.decodeConstLongStream(r,i,s,!1);return new Mp(a,y,l)}}throw new Error("Vector type not supported for id column.")}class i_{constructor(t,i){var a;switch(this._featureData=t,this.properties=this._featureData.properties||{},(a=this._featureData.geometry)===null||a===void 0?void 0:a.type){case ri.POINT:case ri.MULTIPOINT:this.type=1;break;case ri.LINESTRING:case ri.MULTILINESTRING:this.type=2;break;case ri.POLYGON:case ri.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=i,this.id=Number(this._featureData.id)}projectPoint(t,i,a,s){return[360*(t.x+i)/s-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+a)/s)*Math.PI))-90]}projectLine(t,i,a,s){return t.map(l=>this.projectPoint(l,i,a,s))}toGeoJSON(t,i,a){const s=this.extent*Math.pow(2,a),l=this.extent*t,u=this.extent*i,f=this.loadGeometry();let _;switch(this.type){case 1:{const v=[];for(const S of f)v.push(S[0]);const w=this.projectLine(v,l,u,s);_=v.length===1?{type:"Point",coordinates:w[0]}:{type:"MultiPoint",coordinates:w};break}case 2:{const v=f.map(w=>this.projectLine(w,l,u,s));_=v.length===1?{type:"LineString",coordinates:v[0]}:{type:"MultiLineString",coordinates:v};break}case 3:{const v=qa(f),w=[];for(const S of v)w.push(S.map(P=>this.projectLine(P,l,u,s)));_=w.length===1?{type:"Polygon",coordinates:w[0]}:{type:"MultiPolygon",coordinates:w};break}default:throw new Error(`unknown feature type: ${this.type}`)}const y={type:"Feature",geometry:_,properties:this.properties};return this.id!=null&&(y.id=this.id),y}loadGeometry(){const t=[];for(const i of this._featureData.geometry.coordinates){const a=[];for(const s of i)a.push(new It(s.x,s.y));t.push(a)}return t}bbox(){return[0,0,0,0]}}class r_{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 i_(this.features[t],this.extent)}}class zp{constructor(t){this.layers={};const i=function(a,s,l=!0){const u=new Nm(0),f=[];for(;u.get()<a.length;){const _=Qe(a,u,1)[0]>>>0,y=u.get()+_;if(y>a.length)throw new Error(`Block overruns tile: ${y} > ${a.length}`);if(Qe(a,u,1)[0]>>>0!=1){u.set(y);continue}const v=t_(a,u),w=v[1],S=v[0].featureTables[0];let P=null,M=null;const C=[];let z=0;for(const Z of S.columns){const O=Z.name;if(O==="id"){let N=null;if(Z.nullable){const et=Pi.decode(a,u),lt=u.get(),yt=ql(a,et.numValues,u);u.set(lt+et.byteLength),N=new Or(yt,et.numValues)}const Q=Pi.decode(a,u);z=Q.getDecompressedCount(),P=e_(a,Z,u,O,Q,N??z,l)}else if(O==="geometry"){const N=Qe(a,u,1)[0];if(z===0){const Q=u.get();z=Pi.decode(a,u).getDecompressedCount(),u.set(Q)}M=qm(a,N,u,z,s)}else{const N=wu.hasStreamCount(Z)?Qe(a,u,1)[0]:1;if(N===0&&Z.type==="scalarType")continue;const Q=Km(a,u,Z,N,z,void 0);Q&&(Array.isArray(Q)?C.push(...Q):C.push(Q))}}const F=new Vm(S.name,M,P,C,w);f.push(F),u.set(y)}return f}(new Uint8Array(t));this.layers=i.reduce((a,s)=>Object.assign(Object.assign({},a),{[s.name]:new r_(s)}),{})}}class bs{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 i=new bs;return i.extend(t(new It(this.minX,this.minY))),i.extend(t(new It(this.maxX,this.minY))),i.extend(t(new It(this.minX,this.maxY))),i.extend(t(new It(this.maxX,this.maxY))),i}static fromPoints(t){const i=new bs;for(const a of t)i.extend(a);return i}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}}const Zh="_geojsonTileLayer";class kp{constructor(t,i){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ns(oe,16,0),this.grid3D=new ns(oe,16,0),this.featureIndexArray=new V,this.promoteId=i}insert(t,i,a,s,l,u){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,s,l);const _=u?this.grid3D:this.grid;for(let y=0;y<i.length;y++){const v=i[y],w=[1/0,1/0,-1/0,-1/0];for(let S=0;S<v.length;S++){const P=v[S];w[0]=Math.min(w[0],P.x),w[1]=Math.min(w[1],P.y),w[2]=Math.max(w[2],P.x),w[3]=Math.max(w[3],P.y)}w[0]<oe&&w[1]<oe&&w[2]>=0&&w[3]>=0&&_.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding!=="mlt"?new Ed(new wh(this.rawTileData)).layers:new zp(this.rawTileData).layers,this.sourceLayerCoder=new hp(this.vtLayers?Object.keys(this.vtLayers).sort():[Zh])),this.vtLayers}query(t,i,a,s){this.loadVTLayers();const l=t.params,u=oe/t.tileSize/t.scale,f=Ka(l.filter,l.globalState),_=t.queryGeometry,y=t.queryPadding*u,v=bs.fromPoints(_),w=this.grid.query(v.minX-y,v.minY-y,v.maxX+y,v.maxY+y),S=bs.fromPoints(t.cameraQueryGeometry).expandBy(y),P=this.grid3D.query(S.minX,S.minY,S.maxX,S.maxY,(z,F,Z,O)=>function(N,Q,et,lt,yt){for(const vt of N)if(Q<=vt.x&&et<=vt.y&<>=vt.x&&yt>=vt.y)return!0;const mt=[new It(Q,et),new It(Q,yt),new It(lt,yt),new It(lt,et)];if(N.length>2){for(const vt of mt)if(ho(N,vt))return!0}for(let vt=0;vt<N.length-1;vt++)if(ff(N[vt],N[vt+1],mt))return!0;return!1}(t.cameraQueryGeometry,z-y,F-y,Z+y,O+y));for(const z of P)w.push(z);w.sort(n_);const M={};let C;for(let z=0;z<w.length;z++){const F=w[z];if(F===C)continue;C=F;const Z=this.featureIndexArray.get(F);let O=null;this.loadMatchingFeature(M,Z.bucketIndex,Z.sourceLayerIndex,Z.featureIndex,f,l.layers,l.availableImages,i,a,s,(N,Q,et)=>(O||(O=dn(N)),Q.queryIntersectsFeature({queryGeometry:_,feature:N,featureState:et,geometry:O,zoom:this.z,transform:t.transform,pixelsToTileUnits:u,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return M}loadMatchingFeature(t,i,a,s,l,u,f,_,y,v,w){const S=this.bucketLayerIDs[i];if(u&&!S.some(z=>u.has(z)))return;const P=this.sourceLayerCoder.decode(a),M=this.vtLayers[P].feature(s);if(l.needGeometry){const z=Fr(M,!0);if(!l.filter(new le(this.tileID.overscaledZ),z,this.tileID.canonical))return}else if(!l.filter(new le(this.tileID.overscaledZ),M))return;const C=this.getId(M,P);for(let z=0;z<S.length;z++){const F=S[z];if(u&&!u.has(F))continue;const Z=_[F];if(!Z)continue;let O={};C&&v&&(O=v.getState(Z.sourceLayer||Zh,C));const N=di({},y[F]);N.paint=Rp(N.paint,Z.paint,M,O,f),N.layout=Rp(N.layout,Z.layout,M,O,f);const Q=!w||w(M,Z,O);if(!Q)continue;const et=new dp(M,this.z,this.x,this.y,C);et.layer=N;let lt=t[F];lt===void 0&&(lt=t[F]=[]),lt.push({featureIndex:s,feature:et,intersectionZ:Q})}}lookupSymbolFeatures(t,i,a,s,l,u,f,_){const y={};this.loadVTLayers();const v=Ka(l.filterSpec,l.globalState);for(const w of t)this.loadMatchingFeature(y,a,s,w,v,u,f,_,i);return y}hasLayer(t){for(const i of this.bucketLayerIDs)for(const a of i)if(t===a)return!0;return!1}getId(t,i){var a;let s=t.id;return this.promoteId&&(s=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof s=="boolean"&&(s=Number(s)),s===void 0&&(!((a=t.properties)===null||a===void 0)&&a.cluster)&&this.promoteId&&(s=Number(t.properties.cluster_id))),s}}function Rp(r,t,i,a,s){return Xr(r,(l,u)=>{const f=t instanceof Fn?t.get(u):null;return f&&f.evaluate?f.evaluate(i,a,s):f})}function n_(r,t){return t-r}function Lp(r,t,i,a,s){const l=[];for(let u=0;u<r.length;u++){const f=r[u];let _;for(let y=0;y<f.length-1;y++){let v=f[y],w=f[y+1];v.x<t&&w.x<t||(v.x<t?v=new It(t,v.y+(t-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x<t&&(w=new It(t,v.y+(t-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y<i&&w.y<i||(v.y<i?v=new It(v.x+(i-v.y)/(w.y-v.y)*(w.x-v.x),i)._round():w.y<i&&(w=new It(v.x+(i-v.y)/(w.y-v.y)*(w.x-v.x),i)._round()),v.x>=a&&w.x>=a||(v.x>=a?v=new It(a,v.y+(a-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=a&&(w=new It(a,v.y+(a-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=s&&w.y>=s||(v.y>=s?v=new It(v.x+(s-v.y)/(w.y-v.y)*(w.x-v.x),s)._round():w.y>=s&&(w=new It(v.x+(s-v.y)/(w.y-v.y)*(w.x-v.x),s)._round()),_&&v.equals(_[_.length-1])||(_=[v],l.push(_)),_.push(w)))))}}return l}function Fp(r,t,i,a,s){switch(t){case 1:return function(l,u,f,_){const y=[];for(const v of l)for(const w of v){const S=_===0?w.x:w.y;S>=u&&S<=f&&y.push([w])}return y}(r,i,a,s);case 2:return Bp(r,i,a,s,!1);case 3:return Bp(r,i,a,s,!0)}return[]}function a_(r,t,i,a,s){const l=a===0?s_:o_;let u=[];const f=[];for(let v=0;v<r.length-1;v++){const w=r[v],S=r[v+1],P=a===0?w.x:w.y,M=a===0?S.x:S.y;let C=!1;P<t?M>t&&u.push(l(w,S,t)):P>i?M<i&&u.push(l(w,S,i)):u.push(w),M<t&&P>=t&&(u.push(l(w,S,t)),C=!0),M>i&&P<=i&&(u.push(l(w,S,i)),C=!0),!s&&C&&(f.push(u),u=[])}const _=r.length-1,y=a===0?r[_].x:r[_].y;return y>=t&&y<=i&&u.push(r[_]),s&&u.length>0&&!u[0].equals(u[u.length-1])&&u.push(new It(u[0].x,u[0].y)),u.length>0&&f.push(u),f}function Bp(r,t,i,a,s){const l=[];for(const u of r){const f=a_(u,t,i,a,s);f.length>0&&l.push(...f)}return l}function s_(r,t,i){return new It(i,r.y+(i-r.x)/(t.x-r.x)*(t.y-r.y))}function o_(r,t,i){return new It(r.x+(i-r.y)/(t.y-r.y)*(t.x-r.x),i)}Dt("FeatureIndex",kp,{omit:["rawTileData","sourceLayerCoder"]});class Ia extends It{constructor(t,i,a,s){super(t,i),this.angle=a,s!==void 0&&(this.segment=s)}clone(){return new Ia(this.x,this.y,this.angle,this.segment)}}function Op(r,t,i,a,s){if(t.segment===void 0||i===0)return!0;let l=t,u=t.segment+1,f=0;for(;f>-i/2;){if(u--,u<0)return!1;f-=r[u].dist(l),l=r[u]}f+=r[u].dist(r[u+1]),u++;const _=[];let y=0;for(;f<i/2;){const v=r[u],w=r[u+1];if(!w)return!1;let S=r[u-1].angleTo(v)-v.angleTo(w);for(S=Math.abs((S+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:S}),y+=S;f-_[0].distance>a;)y-=_.shift().angleDelta;if(y>s)return!1;u++,f+=v.dist(w)}return!0}function jp(r){let t=0;for(let i=0;i<r.length-1;i++)t+=r[i].dist(r[i+1]);return t}function Vp(r,t,i){return r?.6*t*i:0}function Np(r,t){return Math.max(r?r.right-r.left:0,t?t.right-t.left:0)}function l_(r,t,i,a,s,l){const u=Vp(i,s,l),f=Np(i,a)*l;let _=0;const y=jp(r)/2;for(let v=0;v<r.length-1;v++){const w=r[v],S=r[v+1],P=w.dist(S);if(_+P>y){const M=(y-_)/P,C=ar.number(w.x,S.x,M),z=ar.number(w.y,S.y,M),F=new Ia(C,z,S.angleTo(w),v);return F._round(),!u||Op(r,F,f,u,t)?F:void 0}_+=P}}function c_(r,t,i,a,s,l,u,f,_){const y=Vp(a,l,u),v=Np(a,s),w=v*u,S=r[0].x===0||r[0].x===_||r[0].y===0||r[0].y===_;return t-w<t/4&&(t=w+t/4),Up(r,S?t/2*f%t:(v/2+2*l)*u*f%t,t,y,i,w,S,!1,_)}function Up(r,t,i,a,s,l,u,f,_){const y=l/2,v=jp(r);let w=0,S=t-i,P=[];for(let M=0;M<r.length-1;M++){const C=r[M],z=r[M+1],F=C.dist(z),Z=z.angleTo(C);for(;S+i<w+F;){S+=i;const O=(S-w)/F,N=ar.number(C.x,z.x,O),Q=ar.number(C.y,z.y,O);if(N>=0&&N<_&&Q>=0&&Q<_&&S-y>=0&&S+y<=v){const et=new Ia(N,Q,Z,M);et._round(),a&&!Op(r,et,l,a,s)||P.push(et)}}w+=F}return f||P.length||u||(P=Up(r,w/2,i,a,s,l,u,!0,_)),P}function Gp(r,t,i,a){const s=[],l=r.image,u=l.pixelRatio,f=l.paddedRect.w-2,_=l.paddedRect.h-2;let y={x1:r.left,y1:r.top,x2:r.right,y2:r.bottom};const v=l.stretchX||[[0,f]],w=l.stretchY||[[0,_]],S=(_t,Bt)=>_t+Bt[1]-Bt[0],P=v.reduce(S,0),M=w.reduce(S,0),C=f-P,z=_-M;let F=0,Z=P,O=0,N=M,Q=0,et=C,lt=0,yt=z;if(l.content&&a){const _t=l.content,Bt=_t[2]-_t[0],Ot=_t[3]-_t[1];(l.textFitWidth||l.textFitHeight)&&(y=Hd(r)),F=Tu(v,0,_t[0]),O=Tu(w,0,_t[1]),Z=Tu(v,_t[0],_t[2]),N=Tu(w,_t[1],_t[3]),Q=_t[0]-F,lt=_t[1]-O,et=Bt-Z,yt=Ot-N}const mt=y.x1,vt=y.y1,Ct=y.x2-mt,St=y.y2-vt,Pt=(_t,Bt,Ot,Nt)=>{const kt=Su(_t.stretch-F,Z,Ct,mt),Xt=Pu(_t.fixed-Q,et,_t.stretch,P),Te=Su(Bt.stretch-O,N,St,vt),Ye=Pu(Bt.fixed-lt,yt,Bt.stretch,M),xi=Su(Ot.stretch-F,Z,Ct,mt),Pr=Pu(Ot.fixed-Q,et,Ot.stretch,P),Bi=Su(Nt.stretch-O,N,St,vt),ci=Pu(Nt.fixed-lt,yt,Nt.stretch,M),vi=new It(kt,Te),je=new It(xi,Te),ui=new It(xi,Bi),Mi=new It(kt,Bi),Ii=new It(Xt/u,Ye/u),Ui=new It(Pr/u,ci/u),bi=t*Math.PI/180;if(bi){const ni=Math.sin(bi),De=Math.cos(bi),Ke=[De,-ni,ni,De];vi._matMult(Ke),je._matMult(Ke),Mi._matMult(Ke),ui._matMult(Ke)}const Gi=_t.stretch+_t.fixed,Mr=Bt.stretch+Bt.fixed;return{tl:vi,tr:je,bl:Mi,br:ui,tex:{x:l.paddedRect.x+1+Gi,y:l.paddedRect.y+1+Mr,w:Ot.stretch+Ot.fixed-Gi,h:Nt.stretch+Nt.fixed-Mr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ii,pixelOffsetBR:Ui,minFontScaleX:et/u/Ct,minFontScaleY:yt/u/St,isSDF:i}};if(a&&(l.stretchX||l.stretchY)){const _t=Zp(v,C,P),Bt=Zp(w,z,M);for(let Ot=0;Ot<_t.length-1;Ot++){const Nt=_t[Ot],kt=_t[Ot+1];for(let Xt=0;Xt<Bt.length-1;Xt++)s.push(Pt(Nt,Bt[Xt],kt,Bt[Xt+1]))}}else s.push(Pt({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:_+1}));return s}function Tu(r,t,i){let a=0;for(const s of r)a+=Math.max(t,Math.min(i,s[1]))-Math.max(t,Math.min(i,s[0]));return a}function Zp(r,t,i){const a=[{fixed:-1,stretch:0}];for(const[s,l]of r){const u=a[a.length-1];a.push({fixed:s-u.stretch,stretch:u.stretch}),a.push({fixed:s-u.stretch,stretch:u.stretch+(l-s)})}return a.push({fixed:t+1,stretch:i}),a}function Su(r,t,i,a){return r/t*i+a}function Pu(r,t,i,a){return r-t*i/a}Dt("Anchor",Ia);class Mu{constructor(t,i,a,s,l,u,f,_,y,v){var w;if(this.boxStartIndex=t.length,y){let S=u.top,P=u.bottom;const M=u.collisionPadding;M&&(S-=M[1],P+=M[3]);let C=P-S;C>0&&(C=Math.max(10,C),this.circleDiameter=C)}else{const S=!((w=u.image)===null||w===void 0)&&w.content&&(u.image.textFitWidth||u.image.textFitHeight)?Hd(u):{x1:u.left,y1:u.top,x2:u.right,y2:u.bottom};S.y1=S.y1*f-_[0],S.y2=S.y2*f+_[2],S.x1=S.x1*f-_[3],S.x2=S.x2*f+_[1];const P=u.collisionPadding;if(P&&(S.x1-=P[0]*f,S.y1-=P[1]*f,S.x2+=P[2]*f,S.y2+=P[3]*f),v){const M=new It(S.x1,S.y1),C=new It(S.x2,S.y1),z=new It(S.x1,S.y2),F=new It(S.x2,S.y2),Z=v*Math.PI/180;M._rotate(Z),C._rotate(Z),z._rotate(Z),F._rotate(Z),S.x1=Math.min(M.x,C.x,z.x,F.x),S.x2=Math.max(M.x,C.x,z.x,F.x),S.y1=Math.min(M.y,C.y,z.y,F.y),S.y2=Math.max(M.y,C.y,z.y,F.y)}t.emplaceBack(i.x,i.y,S.x1,S.y1,S.x2,S.y2,a,s,l)}this.boxEndIndex=t.length}}class u_{constructor(t=[],i=(a,s)=>a<s?-1:a>s?1:0){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:i,compare:a}=this,s=i[t];for(;t>0;){const l=t-1>>1,u=i[l];if(a(s,u)>=0)break;i[t]=u,t=l}i[t]=s}_down(t){const{data:i,compare:a}=this,s=this.length>>1,l=i[t];for(;t<s;){let u=1+(t<<1);const f=u+1;if(f<this.length&&a(i[f],i[u])<0&&(u=f),a(i[u],l)>=0)break;i[t]=i[u],t=u}i[t]=l}}function h_(r,t=1,i=!1){const a=bs.fromPoints(r[0]),s=Math.min(a.width(),a.height());let l=s/2;const u=new u_([],d_),{minX:f,minY:_,maxX:y,maxY:v}=a;if(s===0)return new It(f,_);for(let P=f;P<y;P+=s)for(let M=_;M<v;M+=s)u.push(new Io(P+l,M+l,l,r));let w=function(P){let M=0,C=0,z=0;const F=P[0];for(let Z=0,O=F.length,N=O-1;Z<O;N=Z++){const Q=F[Z],et=F[N],lt=Q.x*et.y-et.x*Q.y;C+=(Q.x+et.x)*lt,z+=(Q.y+et.y)*lt,M+=3*lt}return new Io(C/M,z/M,0,P)}(r),S=u.length;for(;u.length;){const P=u.pop();(P.d>w.d||!w.d)&&(w=P,i&&console.log("found best %d after %d probes",Math.round(1e4*P.d)/1e4,S)),P.max-w.d<=t||(l=P.h/2,u.push(new Io(P.p.x-l,P.p.y-l,l,r)),u.push(new Io(P.p.x+l,P.p.y-l,l,r)),u.push(new Io(P.p.x-l,P.p.y+l,l,r)),u.push(new Io(P.p.x+l,P.p.y+l,l,r)),S+=4)}return i&&(console.log(`num probes: ${S}`),console.log(`best distance: ${w.d}`)),w.p}function d_(r,t){return t.max-r.max}function Io(r,t,i,a){this.p=new It(r,t),this.h=i,this.d=function(s,l){let u=!1,f=1/0;for(let _=0;_<l.length;_++){const y=l[_];for(let v=0,w=y.length,S=w-1;v<w;S=v++){const P=y[v],M=y[S];P.y>s.y!=M.y>s.y&&s.x<(M.x-P.x)*(s.y-P.y)/(M.y-P.y)+P.x&&(u=!u),f=Math.min(f,ad(s,P,M))}}return(u?1:-1)*Math.sqrt(f)}(this.p,a),this.max=this.d+this.h*Math.SQRT2}var yi;D.aO=void 0,(yi=D.aO||(D.aO={}))[yi.center=1]="center",yi[yi.left=2]="left",yi[yi.right=3]="right",yi[yi.top=4]="top",yi[yi.bottom=5]="bottom",yi[yi["top-left"]=6]="top-left",yi[yi["top-right"]=7]="top-right",yi[yi["bottom-left"]=8]="bottom-left",yi[yi["bottom-right"]=9]="bottom-right";const $h=Number.POSITIVE_INFINITY;function $p(r,t){return t[1]!==$h?function(i,a,s){let l=0,u=0;switch(a=Math.abs(a),s=Math.abs(s),i){case"top-right":case"top-left":case"top":u=s-7;break;case"bottom-right":case"bottom-left":case"bottom":u=7-s}switch(i){case"top-right":case"bottom-right":case"right":l=-a;break;case"top-left":case"bottom-left":case"left":l=a}return[l,u]}(r,t[0],t[1]):function(i,a){let s=0,l=0;a<0&&(a=0);const u=a/Math.SQRT2;switch(i){case"top-right":case"top-left":l=u-7;break;case"bottom-right":case"bottom-left":l=7-u;break;case"bottom":l=7-a;break;case"top":l=a-7}switch(i){case"top-right":case"bottom-right":s=-u;break;case"top-left":case"bottom-left":s=u;break;case"left":s=a;break;case"right":s=-a}return[s,l]}(r,t[0])}function qp(r,t,i){var a;const s=r.layout,l=(a=s.get("text-variable-anchor-offset"))===null||a===void 0?void 0:a.evaluate(t,{},i);if(l){const f=l.values,_=[];for(let y=0;y<f.length;y+=2){const v=_[y]=f[y],w=f[y+1].map(S=>S*ei);v.startsWith("top")?w[1]-=7:v.startsWith("bottom")&&(w[1]+=7),_[y+1]=w}return new Ti(_)}const u=s.get("text-variable-anchor");if(u){let f;f=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[s.get("text-radial-offset").evaluate(t,{},i)*ei,$h]:s.get("text-offset").evaluate(t,{},i).map(y=>y*ei);const _=[];for(const y of u)_.push(y,$p(y,f));return new Ti(_)}return null}function qh(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function p_(r,t,i,a,s,l,u,f,_,y,v,w){let S=l.textMaxSize.evaluate(t,{});S===void 0&&(S=u);const P=r.layers[0].layout,M=P.get("icon-offset").evaluate(t,{},v),C=Hp(i.horizontal),z=u/24,F=r.tilePixelRatio*z,Z=r.tilePixelRatio*S/24,O=r.tilePixelRatio*f,N=r.tilePixelRatio*P.get("symbol-spacing"),Q=P.get("text-padding")*r.tilePixelRatio,et=function(Ot,Nt,kt,Xt=1){const Te=Ot.get("icon-padding").evaluate(Nt,{},kt),Ye=Te&&Te.values;return[Ye[0]*Xt,Ye[1]*Xt,Ye[2]*Xt,Ye[3]*Xt]}(P,t,v,r.tilePixelRatio),lt=P.get("text-max-angle")/180*Math.PI,yt=P.get("text-rotation-alignment")!=="viewport"&&P.get("symbol-placement")!=="point",mt=P.get("icon-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point",vt=P.get("symbol-placement"),Ct=N/2,St=P.get("icon-text-fit");let Pt;a&&St!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(Pt=Xd(a,i.vertical,St,P.get("icon-text-fit-padding"),M,z)),C&&(a=Xd(a,C,St,P.get("icon-text-fit-padding"),M,z)));const _t=v?w.line.getGranularityForZoomLevel(v.z):1,Bt=(Ot,Nt)=>{Nt.x<0||Nt.x>=oe||Nt.y<0||Nt.y>=oe||function(kt,Xt,Te,Ye,xi,Pr,Bi,ci,vi,je,ui,Mi,Ii,Ui,bi,Gi,Mr,ni,De,Ke,Fe,ai,$n,jr,Kl){const Ea=kt.addToLineVertexArray(Xt,Te);let ws,Eo,Co,Ao,Jp=0,Qp=0,tf=0,ef=0,td=-1,ed=-1;const qn={};let rf=kr("");if(kt.allowVerticalPlacement&&Ye.vertical){const Ei=ci.layout.get("text-rotate").evaluate(Fe,{},jr)+90;Co=new Mu(vi,Xt,je,ui,Mi,Ye.vertical,Ii,Ui,bi,Ei),Bi&&(Ao=new Mu(vi,Xt,je,ui,Mi,Bi,Mr,ni,bi,Ei))}if(xi){const Ei=ci.layout.get("icon-rotate").evaluate(Fe,{}),hr=ci.layout.get("icon-text-fit")!=="none",Ts=Gp(xi,Ei,$n,hr),Nr=Bi?Gp(Bi,Ei,$n,hr):void 0;Eo=new Mu(vi,Xt,je,ui,Mi,xi,Mr,ni,!1,Ei),Jp=4*Ts.length;const Ss=kt.iconSizeData;let pn=null;Ss.kind==="source"?(pn=[Gn*ci.layout.get("icon-size").evaluate(Fe,{})],pn[0]>Sa&&Pe(`${kt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Ss.kind==="composite"&&(pn=[Gn*ai.compositeIconSizes[0].evaluate(Fe,{},jr),Gn*ai.compositeIconSizes[1].evaluate(Fe,{},jr)],(pn[0]>Sa||pn[1]>Sa)&&Pe(`${kt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),kt.addSymbols(kt.icon,Ts,pn,Ke,De,Fe,D.ay.none,Xt,Ea.lineStartIndex,Ea.lineLength,-1,jr),td=kt.icon.placedSymbolArray.length-1,Nr&&(Qp=4*Nr.length,kt.addSymbols(kt.icon,Nr,pn,Ke,De,Fe,D.ay.vertical,Xt,Ea.lineStartIndex,Ea.lineLength,-1,jr),ed=kt.icon.placedSymbolArray.length-1)}const nf=Object.keys(Ye.horizontal);for(const Ei of nf){const hr=Ye.horizontal[Ei];if(!ws){rf=kr(hr.text);const Nr=ci.layout.get("text-rotate").evaluate(Fe,{},jr);ws=new Mu(vi,Xt,je,ui,Mi,hr,Ii,Ui,bi,Nr)}const Ts=hr.positionedLines.length===1;if(tf+=Wp(kt,Xt,hr,Pr,ci,bi,Fe,Gi,Ea,Ye.vertical?D.ay.horizontal:D.ay.horizontalOnly,Ts?nf:[Ei],qn,td,ai,jr),Ts)break}Ye.vertical&&(ef+=Wp(kt,Xt,Ye.vertical,Pr,ci,bi,Fe,Gi,Ea,D.ay.vertical,["vertical"],qn,ed,ai,jr));const __=ws?ws.boxStartIndex:kt.collisionBoxArray.length,g_=ws?ws.boxEndIndex:kt.collisionBoxArray.length,y_=Co?Co.boxStartIndex:kt.collisionBoxArray.length,x_=Co?Co.boxEndIndex:kt.collisionBoxArray.length,v_=Eo?Eo.boxStartIndex:kt.collisionBoxArray.length,b_=Eo?Eo.boxEndIndex:kt.collisionBoxArray.length,w_=Ao?Ao.boxStartIndex:kt.collisionBoxArray.length,T_=Ao?Ao.boxEndIndex:kt.collisionBoxArray.length;let Vr=-1;const Eu=(Ei,hr)=>Ei&&Ei.circleDiameter?Math.max(Ei.circleDiameter,hr):hr;Vr=Eu(ws,Vr),Vr=Eu(Co,Vr),Vr=Eu(Eo,Vr),Vr=Eu(Ao,Vr);const af=Vr>-1?1:0;af&&(Vr*=Kl/ei),kt.glyphOffsetArray.length>=vo.MAX_GLYPHS&&Pe("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Fe.sortKey!==void 0&&kt.addToSortKeyRanges(kt.symbolInstances.length,Fe.sortKey);const S_=qp(ci,Fe,jr),[P_,M_]=function(Ei,hr){const Ts=Ei.length,Nr=hr?.values;if(Nr?.length>0)for(let Ss=0;Ss<Nr.length;Ss+=2){const pn=Nr[Ss+1];Ei.emplaceBack(D.aO[Nr[Ss]],pn[0],pn[1])}return[Ts,Ei.length]}(kt.textAnchorOffsets,S_);kt.symbolInstances.emplaceBack(Xt.x,Xt.y,qn.right>=0?qn.right:-1,qn.center>=0?qn.center:-1,qn.left>=0?qn.left:-1,qn.vertical||-1,td,ed,rf,__,g_,y_,x_,v_,b_,w_,T_,je,tf,ef,Jp,Qp,af,0,Ii,Vr,P_,M_)}(r,Nt,Ot,i,a,s,Pt,r.layers[0],r.collisionBoxArray,t.index,t.sourceLayerIndex,r.index,F,[Q,Q,Q,Q],yt,_,O,et,mt,M,t,l,y,v,u)};if(vt==="line")for(const Ot of Lp(t.geometry,0,0,oe,oe)){const Nt=gs(Ot,_t),kt=c_(Nt,N,lt,i.vertical||C,a,24,Z,r.overscaling,oe);for(const Xt of kt)C&&f_(r,C.text,Ct,Xt)||Bt(Nt,Xt)}else if(vt==="line-center"){for(const Ot of t.geometry)if(Ot.length>1){const Nt=gs(Ot,_t),kt=l_(Nt,lt,i.vertical||C,a,24,Z);kt&&Bt(Nt,kt)}}else if(t.type==="Polygon")for(const Ot of qa(t.geometry,0)){const Nt=h_(Ot,16);Bt(gs(Ot[0],_t,!0),new Ia(Nt.x,Nt.y,0))}else if(t.type==="LineString")for(const Ot of t.geometry){const Nt=gs(Ot,_t);Bt(Nt,new Ia(Nt[0].x,Nt[0].y,0))}else if(t.type==="Point")for(const Ot of t.geometry)for(const Nt of Ot)Bt([Nt],new Ia(Nt.x,Nt.y,0))}function Wp(r,t,i,a,s,l,u,f,_,y,v,w,S,P,M){const C=function(Z,O,N,Q,et,lt,yt,mt){const vt=Q.layout.get("text-rotate").evaluate(lt,{})*Math.PI/180,Ct=[];for(const St of O.positionedLines)for(const Pt of St.positionedGlyphs){if(!Pt.rect)continue;const _t=Pt.rect||{};let Bt=4,Ot=!0,Nt=1,kt=0;const Xt=(et||mt)&&Pt.vertical,Te=Pt.metrics.advance*Pt.scale/2;if(mt&&O.verticalizable&&(kt=St.lineOffset/2-(Pt.imageName?-(ei-Pt.metrics.width*Pt.scale)/2:(Pt.scale-1)*ei)),Pt.imageName){const ni=yt[Pt.imageName];Ot=ni.sdf,Nt=ni.pixelRatio,Bt=1/Nt}const Ye=et?[Pt.x+Te,Pt.y]:[0,0];let xi=et?[0,0]:[Pt.x+Te+N[0],Pt.y+N[1]-kt],Pr=[0,0];Xt&&(Pr=xi,xi=[0,0]);const Bi=Pt.metrics.isDoubleResolution?2:1,ci=(Pt.metrics.left-Bt)*Pt.scale-Te+xi[0],vi=(-Pt.metrics.top-Bt)*Pt.scale+xi[1],je=ci+_t.w/Bi*Pt.scale/Nt,ui=vi+_t.h/Bi*Pt.scale/Nt,Mi=new It(ci,vi),Ii=new It(je,vi),Ui=new It(ci,ui),bi=new It(je,ui);if(Xt){const ni=new It(-Te,Te- -17),De=-Math.PI/2,Ke=12-Te,Fe=new It(22-Ke,-(Pt.imageName?Ke:0)),ai=new It(...Pr);Mi._rotateAround(De,ni)._add(Fe)._add(ai),Ii._rotateAround(De,ni)._add(Fe)._add(ai),Ui._rotateAround(De,ni)._add(Fe)._add(ai),bi._rotateAround(De,ni)._add(Fe)._add(ai)}if(vt){const ni=Math.sin(vt),De=Math.cos(vt),Ke=[De,-ni,ni,De];Mi._matMult(Ke),Ii._matMult(Ke),Ui._matMult(Ke),bi._matMult(Ke)}const Gi=new It(0,0),Mr=new It(0,0);Ct.push({tl:Mi,tr:Ii,bl:Ui,br:bi,tex:_t,writingMode:O.writingMode,glyphOffset:Ye,sectionIndex:Pt.sectionIndex,isSDF:Ot,pixelOffsetTL:Gi,pixelOffsetBR:Mr,minFontScaleX:0,minFontScaleY:0})}return Ct}(0,i,f,s,l,u,a,r.allowVerticalPlacement),z=r.textSizeData;let F=null;z.kind==="source"?(F=[Gn*s.layout.get("text-size").evaluate(u,{})],F[0]>Sa&&Pe(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):z.kind==="composite"&&(F=[Gn*P.compositeTextSizes[0].evaluate(u,{},M),Gn*P.compositeTextSizes[1].evaluate(u,{},M)],(F[0]>Sa||F[1]>Sa)&&Pe(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,C,F,f,l,u,y,t,_.lineStartIndex,_.lineLength,S,M);for(const Z of v)w[Z]=r.text.placedSymbolArray.length-1;return 4*C.length}function Hp(r){for(const t in r)return r[t];return null}function f_(r,t,i,a){const s=r.compareText;if(t in s){const l=s[t];for(let u=l.length-1;u>=0;u--)if(a.dist(l[u])<i)return!0}else s[t]=[];return s[t].push(a),!1}const Xp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Wh{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,a]=new Uint8Array(t,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=a>>4;if(s!==1)throw new Error(`Got v${s} data when expected v1.`);const l=Xp[15&a];if(!l)throw new Error("Unrecognized array type.");const[u]=new Uint16Array(t,2,1),[f]=new Uint32Array(t,4,1);return new Wh(f,u,l,t)}constructor(t,i=64,a=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=a,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const l=Xp.indexOf(this.ArrayType),u=2*t*this.ArrayType.BYTES_PER_ELEMENT,f=t*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-f%8)%8;if(l<0)throw new Error(`Unexpected typed array class: ${a}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+_,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+u+f+_),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+_,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+l]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=t)}add(t,i){const a=this._pos>>1;return this.ids[a]=a,this.coords[this._pos++]=t,this.coords[this._pos++]=i,a}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Hh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,a,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:u,nodeSize:f}=this,_=[0,l.length-1,0],y=[];for(;_.length;){const v=_.pop()||0,w=_.pop()||0,S=_.pop()||0;if(w-S<=f){for(let z=S;z<=w;z++){const F=u[2*z],Z=u[2*z+1];F>=t&&F<=a&&Z>=i&&Z<=s&&y.push(l[z])}continue}const P=S+w>>1,M=u[2*P],C=u[2*P+1];M>=t&&M<=a&&C>=i&&C<=s&&y.push(l[P]),(v===0?t<=M:i<=C)&&(_.push(S),_.push(P-1),_.push(1-v)),(v===0?a>=M:s>=C)&&(_.push(P+1),_.push(w),_.push(1-v))}return y}within(t,i,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:l,nodeSize:u}=this,f=[0,s.length-1,0],_=[],y=a*a;for(;f.length;){const v=f.pop()||0,w=f.pop()||0,S=f.pop()||0;if(w-S<=u){for(let z=S;z<=w;z++)Kp(l[2*z],l[2*z+1],t,i)<=y&&_.push(s[z]);continue}const P=S+w>>1,M=l[2*P],C=l[2*P+1];Kp(M,C,t,i)<=y&&_.push(s[P]),(v===0?t-a<=M:i-a<=C)&&(f.push(S),f.push(P-1),f.push(1-v)),(v===0?t+a>=M:i+a>=C)&&(f.push(P+1),f.push(w),f.push(1-v))}return _}}function Hh(r,t,i,a,s,l){if(s-a<=i)return;const u=a+s>>1;Yp(r,t,u,a,s,l),Hh(r,t,i,a,u-1,1-l),Hh(r,t,i,u+1,s,1-l)}function Yp(r,t,i,a,s,l){for(;s>a;){if(s-a>600){const y=s-a+1,v=i-a+1,w=Math.log(y),S=.5*Math.exp(2*w/3),P=.5*Math.sqrt(w*S*(y-S)/y)*(v-y/2<0?-1:1);Yp(r,t,i,Math.max(a,Math.floor(i-v*S/y+P)),Math.min(s,Math.floor(i+(y-v)*S/y+P)),l)}const u=t[2*i+l];let f=a,_=s;for(Xl(r,t,a,i),t[2*s+l]>u&&Xl(r,t,a,s);f<_;){for(Xl(r,t,f,_),f++,_--;t[2*f+l]<u;)f++;for(;t[2*_+l]>u;)_--}t[2*a+l]===u?Xl(r,t,a,_):(_++,Xl(r,t,_,s)),_<=i&&(a=_+1),i<=_&&(s=_-1)}}function Xl(r,t,i,a){Xh(r,i,a),Xh(t,2*i,2*a),Xh(t,2*i+1,2*a+1)}function Xh(r,t,i){const a=r[t];r[t]=r[i],r[i]=a}function Kp(r,t,i,a){const s=r-i,l=t-a;return s*s+l*l}var Yh;D.cG=void 0,(Yh=D.cG||(D.cG={})).create="create",Yh.load="load",Yh.fullLoad="fullLoad";let Iu=null,Yl=[];const Kh=1e3/60,Jh="loadTime",Qh="fullLoadTime",m_={mark(r){performance.mark(r)},frame(r){const t=r;Iu!=null&&Yl.push(t-Iu),Iu=t},clearMetrics(){Iu=null,Yl=[],performance.clearMeasures(Jh),performance.clearMeasures(Qh);for(const r in D.cG)performance.clearMarks(D.cG[r])},getPerformanceMetrics(){performance.measure(Jh,D.cG.create,D.cG.load),performance.measure(Qh,D.cG.create,D.cG.fullLoad);const r=performance.getEntriesByName(Jh)[0].duration,t=performance.getEntriesByName(Qh)[0].duration,i=Yl.length,a=1/(Yl.reduce((l,u)=>l+u,0)/i/1e3),s=Yl.filter(l=>l>Kh).reduce((l,u)=>l+(u-Kh)/Kh,0);return{loadTime:r,fullLoadTime:t,fps:a,percentDroppedFrames:s/(i+s)*100,totalFrames:i}}};D.$=_n,D.A=Se,D.B=ro,D.C=Ln,D.D=Ft,D.E=nt,D.F=function([r,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:r*Math.cos(t)*Math.sin(i),y:r*Math.sin(t)*Math.sin(i),z:r*Math.cos(i)}},D.G=ar,D.H=le,D.I=Th,D.J=Ju,D.K=function(r){if(Me==null){const t=r.navigator?r.navigator.userAgent:null;Me=!!r.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Me},D.L=class{constructor(r,t){this.target=r,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Bm(()=>this.process()),this.subscription=Kr(this.target,"message",i=>this.receive(i),!1),this.globalScope=fr(self)?r:window}registerMessageHandler(r,t){this.messageHandlers[r]=t}unregisterMessageHandler(r){delete this.messageHandlers[r]}sendAsync(r,t){return new Promise((i,a)=>{const s=Math.round(1e18*Math.random()).toString(36).substring(0,10),l=t?Kr(t.signal,"abort",()=>{l?.unsubscribe(),delete this.resolveRejects[s];const _={id:s,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(_)},Om):null;this.resolveRejects[s]={resolve:_=>{l?.unsubscribe(),i(_)},reject:_=>{l?.unsubscribe(),a(_)}};const u=[],f=Object.assign(Object.assign({},r),{id:s,sourceMapId:this.mapId,origin:location.origin,data:as(r.data,u)});this.target.postMessage(f,{transfer:u})})}receive(r){const t=r.data,i=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[i];const a=this.abortControllers[i];return delete this.abortControllers[i],void(a&&a.abort())}if(fr(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(this.taskQueue.length===0)return;const r=this.taskQueue.shift(),t=this.tasks[r];delete this.tasks[r],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(r,t)}processTask(r,t){return h(this,void 0,void 0,function*(){if(t.type==="<response>"){const s=this.resolveRejects[r];return delete this.resolveRejects[r],s?void(t.error?s.reject(Dr(t.error)):s.resolve(Dr(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(r,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=Dr(t.data),a=new AbortController;this.abortControllers[r]=a;try{const s=yield this.messageHandlers[t.type](t.sourceMapId,i,a);this.completeTask(r,null,s)}catch(s){this.completeTask(r,s)}})}completeTask(r,t,i){const a=[];delete this.abortControllers[r];const s={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?as(t):null,data:as(i,a)};this.target.postMessage(s,{transfer:a})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},D.M=Tn,D.N=function(){var r=new Se(16);return Se!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},D.O=function(r,t,i){var a,s,l,u,f,_,y,v,w,S,P,M,C=i[0],z=i[1],F=i[2];return t===r?(r[12]=t[0]*C+t[4]*z+t[8]*F+t[12],r[13]=t[1]*C+t[5]*z+t[9]*F+t[13],r[14]=t[2]*C+t[6]*z+t[10]*F+t[14],r[15]=t[3]*C+t[7]*z+t[11]*F+t[15]):(s=t[1],l=t[2],u=t[3],f=t[4],_=t[5],y=t[6],v=t[7],w=t[8],S=t[9],P=t[10],M=t[11],r[0]=a=t[0],r[1]=s,r[2]=l,r[3]=u,r[4]=f,r[5]=_,r[6]=y,r[7]=v,r[8]=w,r[9]=S,r[10]=P,r[11]=M,r[12]=a*C+f*z+w*F+t[12],r[13]=s*C+_*z+S*F+t[13],r[14]=l*C+y*z+P*F+t[14],r[15]=u*C+v*z+M*F+t[15]),r},D.P=It,D.Q=function(r,t,i){var a=i[0],s=i[1],l=i[2];return r[0]=t[0]*a,r[1]=t[1]*a,r[2]=t[2]*a,r[3]=t[3]*a,r[4]=t[4]*s,r[5]=t[5]*s,r[6]=t[6]*s,r[7]=t[7]*s,r[8]=t[8]*l,r[9]=t[9]*l,r[10]=t[10]*l,r[11]=t[11]*l,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},D.R=Ni,D.S=function(r,t,i){var a=t[0],s=t[1],l=t[2],u=t[3],f=t[4],_=t[5],y=t[6],v=t[7],w=t[8],S=t[9],P=t[10],M=t[11],C=t[12],z=t[13],F=t[14],Z=t[15],O=i[0],N=i[1],Q=i[2],et=i[3];return r[0]=O*a+N*f+Q*w+et*C,r[1]=O*s+N*_+Q*S+et*z,r[2]=O*l+N*y+Q*P+et*F,r[3]=O*u+N*v+Q*M+et*Z,r[4]=(O=i[4])*a+(N=i[5])*f+(Q=i[6])*w+(et=i[7])*C,r[5]=O*s+N*_+Q*S+et*z,r[6]=O*l+N*y+Q*P+et*F,r[7]=O*u+N*v+Q*M+et*Z,r[8]=(O=i[8])*a+(N=i[9])*f+(Q=i[10])*w+(et=i[11])*C,r[9]=O*s+N*_+Q*S+et*z,r[10]=O*l+N*y+Q*P+et*F,r[11]=O*u+N*v+Q*M+et*Z,r[12]=(O=i[12])*a+(N=i[13])*f+(Q=i[14])*w+(et=i[15])*C,r[13]=O*s+N*_+Q*S+et*z,r[14]=O*l+N*y+Q*P+et*F,r[15]=O*u+N*v+Q*M+et*Z,r},D.T=ph,D.U=function(r,t){const i={};for(let a=0;a<t.length;a++){const s=t[a];s in r&&(i[s]=r[s])}return i},D.V=Pa,D.W=tr,D.X=np,D.Y=rp,D.Z=pt,D._=h,D.a=Jr,D.a$=Ir,D.a0=Kn,D.a1=cr,D.a2=sp,D.a3=pu,D.a4=oe,D.a5=function(r,t,i){if(!r)return t||{};if(!t)return r||{};const a=up(r),s=up(t);(function(u,f){f.removeAll&&(u.add.clear(),u.update.clear(),u.remove.clear(),f.remove.clear());for(const _ of f.remove)u.add.delete(_),u.update.delete(_);for(const[_,y]of f.update){const v=u.update.get(_);v&&(f.update.set(_,jm(v,y)),u.update.delete(_))}})(a,s);const l={};if((a.removeAll||s.removeAll)&&(l.removeAll=!0),l.remove=new Set([...a.remove,...s.remove]),l.add=new Map([...a.add,...s.add]),l.update=new Map([...a.update,...s.update]),l.remove.size&&l.add.size)for(const u of l.add.keys())l.remove.delete(u);return function(u){const f={};return u.removeAll&&(f.removeAll=u.removeAll),u.remove&&(f.remove=Array.from(u.remove)),u.add&&(f.add=Array.from(u.add.values())),u.update&&(f.update=Array.from(u.update.values())),f}(l)},D.a6=function(r,t){if(r==null)return!0;if(r.type==="Feature")return Ul(r,t)!=null;if(r.type==="FeatureCollection"){const i=new Set;for(const a of r.features){const s=Ul(a,t);if(s==null||i.has(s))return!1;i.add(s)}return!0}return!1},D.a7=function(r,t){const i=new Map;if(r!=null)if(r.type==="Feature")i.set(Ul(r,t),r);else for(const a of r.features)i.set(Ul(a,t),a);return i},D.a8=function(r,t,i){var a,s;if(t.removeAll)r.clear();else if(t.remove)for(const l of t.remove)r.delete(l);if(t.add)for(const l of t.add){const u=Ul(l,i);u!=null&&r.set(u,l)}if(t.update)for(const l of t.update){let u=r.get(l.id);if(!u)continue;const f=!!l.newGeometry,_=l.removeAllProperties||((a=l.removeProperties)===null||a===void 0?void 0:a.length)>0||((s=l.addOrUpdateProperties)===null||s===void 0?void 0:s.length)>0;if((f||_)&&(u=Object.assign({},u),r.set(l.id,u),f&&(u.geometry=l.newGeometry),_)){if(u.properties=l.removeAllProperties?{}:Object.assign({},u.properties||{}),l.removeProperties)for(const y of l.removeProperties)delete u.properties[y];if(l.addOrUpdateProperties)for(const{key:y,value:v}of l.addOrUpdateProperties)u.properties[y]=v}}},D.a9=Zh,D.aA=function(r,t){var i=t[0],a=t[1],s=t[2],l=t[3],u=t[4],f=t[5],_=t[6],y=t[7],v=t[8],w=t[9],S=t[10],P=t[11],M=t[12],C=t[13],z=t[14],F=t[15],Z=i*f-a*u,O=i*_-s*u,N=i*y-l*u,Q=a*_-s*f,et=a*y-l*f,lt=s*y-l*_,yt=v*C-w*M,mt=v*z-S*M,vt=v*F-P*M,Ct=w*z-S*C,St=w*F-P*C,Pt=S*F-P*z,_t=Z*Pt-O*St+N*Ct+Q*vt-et*mt+lt*yt;return _t?(r[0]=(f*Pt-_*St+y*Ct)*(_t=1/_t),r[1]=(s*St-a*Pt-l*Ct)*_t,r[2]=(C*lt-z*et+F*Q)*_t,r[3]=(S*et-w*lt-P*Q)*_t,r[4]=(_*vt-u*Pt-y*mt)*_t,r[5]=(i*Pt-s*vt+l*mt)*_t,r[6]=(z*N-M*lt-F*O)*_t,r[7]=(v*lt-S*N+P*O)*_t,r[8]=(u*St-f*vt+y*yt)*_t,r[9]=(a*vt-i*St-l*yt)*_t,r[10]=(M*et-C*N+F*Z)*_t,r[11]=(w*N-v*et-P*Z)*_t,r[12]=(f*mt-u*Ct-_*yt)*_t,r[13]=(i*Ct-a*mt+s*yt)*_t,r[14]=(C*O-M*Q-z*Z)*_t,r[15]=(v*Q-w*O+S*Z)*_t,r):null},D.aB=Qi,D.aC=function(r){var t=r[0],i=r[1];return Math.sqrt(t*t+i*i)},D.aD=function(r){return r[0]=0,r[1]=0,r},D.aE=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r},D.aF=Mh,D.aG=Da,D.aH=function(r,t,i,a){const s=t.y-r.y,l=t.x-r.x,u=a.y-i.y,f=a.x-i.x,_=u*l-f*s;if(_===0)return null;const y=(f*(r.y-i.y)-u*(r.x-i.x))/_;return new It(r.x+y*l,r.y+y*s)},D.aI=Lp,D.aJ=rd,D.aK=function(r){let t=1/0,i=1/0,a=-1/0,s=-1/0;for(const l of r)t=Math.min(t,l.x),i=Math.min(i,l.y),a=Math.max(a,l.x),s=Math.max(s,l.y);return[t,i,a,s]},D.aL=ei,D.aM=Xn,D.aN=function(r,t,i,a,s=!1){if(!i[0]&&!i[1])return[0,0];const l=s?a==="map"?-r.bearingInRadians:0:a==="viewport"?r.bearingInRadians:0;if(l){const u=Math.sin(l),f=Math.cos(l);i=[i[0]*f-i[1]*u,i[0]*u+i[1]*f]}return[s?i[0]:Xn(t,i[0],r.zoom),s?i[1]:Xn(t,i[1],r.zoom)]},D.aP=Ph,D.aQ=qh,D.aR=Sh,D.aS=Wh,D.aT=Be,D.aU=lu,D.aV=G,D.aW=Zt,D.aX=wt,D.aY=Ai,D.aZ=op,D.a_=$r,D.aa=Nl,D.ab=bs,D.ac=25,D.ad=Dh,D.ae=r=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const a of r){const s=window.document.createElement("source");k(a)||(t.crossOrigin="Anonymous"),s.src=a,t.appendChild(s)}})},D.af=bt,D.ag=function(){return Yn++},D.ah=m,D.ai=vo,D.aj=Ka,D.ak=Fr,D.al=dp,D.am=function(r){const t={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,a,s,l)=>{const u=s||l;return t[a]=!u||u.toLowerCase(),""}),t["max-age"]){const i=parseInt(t["max-age"],10);isNaN(i)?delete t["max-age"]:t["max-age"]=i}return t},D.an=wi,D.ao=85.051129,D.ap=bn,D.aq=function(r){return Math.pow(2,r)},D.ar=Hn,D.as=ap,D.at=function(r){return Math.log(r)/Math.LN2},D.au=function(r){var t=r[0],i=r[1];return t*t+i*i},D.av=class{constructor(r,t){this.max=r,this.onRemove=t,this.reset()}reset(){for(const r in this.data)for(const t of this.data[r])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(r,t,i){const a=r.wrapped().key;this.data[a]===void 0&&(this.data[a]=[]);const s={value:t,timeout:void 0};if(i!==void 0&&(s.timeout=setTimeout(()=>{this.remove(r,s)},i)),this.data[a].push(s),this.order.push(a),this.order.length>this.max){const l=this._getAndRemoveByKey(this.order[0]);l&&this.onRemove(l)}return this}has(r){return r.wrapped().key in this.data}getAndRemove(r){return this.has(r)?this._getAndRemoveByKey(r.wrapped().key):null}_getAndRemoveByKey(r){const t=this.data[r].shift();return t.timeout&&clearTimeout(t.timeout),this.data[r].length===0&&delete this.data[r],this.order.splice(this.order.indexOf(r),1),t.value}getByKey(r){const t=this.data[r];return t?t[0].value:null}get(r){return this.has(r)?this.data[r.wrapped().key][0].value:null}remove(r,t){if(!this.has(r))return this;const i=r.wrapped().key,a=t===void 0?0:this.data[i].indexOf(t),s=this.data[i][a];return this.data[i].splice(a,1),s.timeout&&clearTimeout(s.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(r){for(this.max=r;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(r){const t=[];for(const i in this.data)for(const a of this.data[i])r(a.value)||t.push(a);for(const i of t)this.remove(i.value.tileID,i)}},D.aw=function(r){if(!r.length)return new Set;const t=Math.max(...r.map(_=>_.canonical.z));let i=1/0,a=-1/0,s=1/0,l=-1/0;const u=[];for(const _ of r){const{x:y,y:v,z:w}=_.canonical,S=Math.pow(2,t-w),P=y*S,M=v*S;u.push({id:_,x:P,y:M}),P<i&&(i=P),P>a&&(a=P),M<s&&(s=M),M>l&&(l=M)}const f=new Set;for(const _ of u)_.x!==i&&_.x!==a&&_.y!==s&&_.y!==l||f.add(_.id);return f},D.ax=function(r,t){let i=0,a=0;if(r.kind==="constant")a=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:s,minZoom:l,maxZoom:u}=r,f=s?wi(li.interpolationFactor(s,t,l,u),0,1):0;r.kind==="camera"?a=ar.number(r.minSize,r.maxSize,f):i=f}return{uSizeT:i,uSize:a}},D.az=function(r,{uSize:t,uSizeT:i},{lowerSize:a,upperSize:s}){return r.kind==="source"?a/Gn:r.kind==="composite"?ar.number(a/Gn,s/Gn,i):t},D.b=mr,D.b$=class extends Xi{constructor(r,t){super(r,t),this.current=Vn}set(r){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}},D.b0=function(r){var t=new Se(3);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t},D.b1=function(r,t,i){return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],r},D.b2=function(r,t){var i=t[0],a=t[1],s=t[2],l=i*i+a*a+s*s;return l>0&&(l=1/Math.sqrt(l)),r[0]=t[0]*l,r[1]=t[1]*l,r[2]=t[2]*l,r},D.b3=gn,D.b4=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]},D.b5=function(r,t,i){return r[0]=t[0]*i[0],r[1]=t[1]*i[1],r[2]=t[2]*i[2],r[3]=t[3]*i[3],r},D.b6=Ci,D.b7=function(r,t,i){const a=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return a===0?null:(-(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])-i[3])/a},D.b8=yn,D.b9=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r[3]=t[3]*i,r},D.bA=ka,D.bB=function(r,t,i){var a=i[0],s=i[1],l=i[2],u=i[3],f=t[0],_=t[1],y=t[2],v=s*y-l*_,w=l*f-a*y,S=a*_-s*f;return r[0]=f+u*(v+=v)+s*(S+=S)-l*(w+=w),r[1]=_+u*w+l*v-a*S,r[2]=y+u*S+a*w-s*v,r},D.bC=function(r,t,i){const a=(s=[r[0],r[1],r[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((v=s[8])*(u=s[4])-(f=s[5])*(y=s[7]))+s[1]*(-v*(l=s[3])+f*(_=s[6]))+s[2]*(y*l-u*_);var s,l,u,f,_,y,v;if(a===0)return null;const w=gn([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),S=gn([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),P=gn([],[r[0],r[1],r[2]],[t[0],t[1],t[2]]),M=$r([],w,-r[3]);return Ir(M,M,$r([],S,-t[3])),Ir(M,M,$r([],P,-i[3])),$r(M,M,1/a),M},D.bD=Ah,D.bE=function(){return new Float64Array(4)},D.bF=function(r,t,i,a){var s=[],l=[];return s[0]=t[0]-i[0],s[1]=t[1]-i[1],s[2]=t[2]-i[2],l[0]=s[0]*Math.cos(a)-s[1]*Math.sin(a),l[1]=s[0]*Math.sin(a)+s[1]*Math.cos(a),l[2]=s[2],r[0]=l[0]+i[0],r[1]=l[1]+i[1],r[2]=l[2]+i[2],r},D.bG=function(r,t,i,a){var s=[],l=[];return s[0]=t[0]-i[0],s[1]=t[1]-i[1],s[2]=t[2]-i[2],l[0]=s[0],l[1]=s[1]*Math.cos(a)-s[2]*Math.sin(a),l[2]=s[1]*Math.sin(a)+s[2]*Math.cos(a),r[0]=l[0]+i[0],r[1]=l[1]+i[1],r[2]=l[2]+i[2],r},D.bH=function(r,t,i,a){var s=[],l=[];return s[0]=t[0]-i[0],s[1]=t[1]-i[1],s[2]=t[2]-i[2],l[0]=s[2]*Math.sin(a)+s[0]*Math.cos(a),l[1]=s[1],l[2]=s[2]*Math.cos(a)-s[0]*Math.sin(a),r[0]=l[0]+i[0],r[1]=l[1]+i[1],r[2]=l[2]+i[2],r},D.bI=function(r,t,i){var a=Math.sin(i),s=Math.cos(i),l=t[0],u=t[1],f=t[2],_=t[3],y=t[8],v=t[9],w=t[10],S=t[11];return t!==r&&(r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=l*s-y*a,r[1]=u*s-v*a,r[2]=f*s-w*a,r[3]=_*s-S*a,r[8]=l*a+y*s,r[9]=u*a+v*s,r[10]=f*a+w*s,r[11]=_*a+S*s,r},D.bJ=function(r,t){const i=pr(r,360),a=pr(t,360),s=a-i,l=a>i?s-360:s+360;return Math.abs(s)<Math.abs(l)?s:l},D.bK=function(r){return r[0]=0,r[1]=0,r[2]=0,r},D.bL=function(r,t,i,a){const s=Math.sqrt(r*r+t*t),l=Math.sqrt(i*i+a*a);r/=s,t/=s,i/=l,a/=l;const u=Math.acos(r*i+t*a);return-t*i+r*a>0?u:-u},D.bM=function(r,t){const i=pr(r,2*Math.PI),a=pr(t,2*Math.PI);return Math.min(Math.abs(i-a),Math.abs(i-a+2*Math.PI),Math.abs(i-a-2*Math.PI))},D.bN=function(){const r={},t=U.$version;for(const i in U.$root){const a=U.$root[i];if(a.required){let s=null;s=i==="version"?t:a.type==="array"?[]:{},s!=null&&(r[i]=s)}}return r},D.bO=Oi,D.bP=ml,D.bQ=function r(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let a=0;a<t.length;a++)if(!r(t[a],i[a]))return!1;return!0}if(typeof t=="object"&&t!==null&&i!==null){if(typeof i!="object"||Object.keys(t).length!==Object.keys(i).length)return!1;for(const a in t)if(!r(t[a],i[a]))return!1;return!0}return t===i},D.bR=function(r){r=r.slice();const t=Object.create(null);for(let i=0;i<r.length;i++)t[r[i].id]=r[i];for(let i=0;i<r.length;i++)"ref"in r[i]&&(r[i]=ht(r[i],t[r[i].ref]));return r},D.bS=function(r,t){if(r.type==="custom")return new Fm(r,t);switch(r.type){case"background":return new Lm(r,t);case"circle":return new vf(r,t);case"color-relief":return new Mf(r,t);case"fill":return new Nf(r,t);case"fill-extrusion":return new Jf(r,t);case"heatmap":return new wf(r,t);case"hillshade":return new Sf(r,t);case"line":return new am(r,t);case"raster":return new rh(r,t);case"symbol":return new du(r,t)}},D.bT=r=>r.type==="raster",D.bU=Zi,D.bV=function(r,t){if(!r)return[{command:"setStyle",args:[t]}];let i=[];try{if(!dt(r.version,t.version))return[{command:"setStyle",args:[t]}];dt(r.center,t.center)||i.push({command:"setCenter",args:[t.center]}),dt(r.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),dt(r.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),dt(r.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),dt(r.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),dt(r.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),dt(r.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),dt(r.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),dt(r.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),dt(r.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),dt(r.light,t.light)||i.push({command:"setLight",args:[t.light]}),dt(r.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),dt(r.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),dt(r.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const a={},s=[];(function(u,f,_,y){let v;for(v in f=f||{},u=u||{})Object.prototype.hasOwnProperty.call(u,v)&&(Object.prototype.hasOwnProperty.call(f,v)||jt(v,_,y));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(u,v)?dt(u[v],f[v])||(u[v].type==="geojson"&&f[v].type==="geojson"&&ke(u,f,v)?ft(_,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):qt(v,f,_,y)):zt(v,f,_))})(r.sources,t.sources,s,a);const l=[];r.layers&&r.layers.forEach(u=>{"source"in u&&a[u.source]?i.push({command:"removeLayer",args:[u.id]}):l.push(u)}),i=i.concat(s),function(u,f,_){f=f||[];const y=(u=u||[]).map(ne),v=f.map(ne),w=u.reduce(de,{}),S=f.reduce(de,{}),P=y.slice(),M=Object.create(null);let C,z,F,Z,O;for(let N=0,Q=0;N<y.length;N++)C=y[N],Object.prototype.hasOwnProperty.call(S,C)?Q++:(ft(_,{command:"removeLayer",args:[C]}),P.splice(P.indexOf(C,Q),1));for(let N=0,Q=0;N<v.length;N++)C=v[v.length-1-N],P[P.length-1-N]!==C&&(Object.prototype.hasOwnProperty.call(w,C)?(ft(_,{command:"removeLayer",args:[C]}),P.splice(P.lastIndexOf(C,P.length-Q),1)):Q++,Z=P[P.length-N],ft(_,{command:"addLayer",args:[S[C],Z]}),P.splice(P.length-N,0,C),M[C]=!0);for(let N=0;N<v.length;N++)if(C=v[N],z=w[C],F=S[C],!M[C]&&!dt(z,F))if(dt(z.source,F.source)&&dt(z["source-layer"],F["source-layer"])&&dt(z.type,F.type)){for(O in Yt(z.layout,F.layout,_,C,null,"setLayoutProperty"),Yt(z.paint,F.paint,_,C,null,"setPaintProperty"),dt(z.filter,F.filter)||ft(_,{command:"setFilter",args:[C,F.filter]}),dt(z.minzoom,F.minzoom)&&dt(z.maxzoom,F.maxzoom)||ft(_,{command:"setLayerZoomRange",args:[C,F.minzoom,F.maxzoom]}),z)Object.prototype.hasOwnProperty.call(z,O)&&O!=="layout"&&O!=="paint"&&O!=="filter"&&O!=="metadata"&&O!=="minzoom"&&O!=="maxzoom"&&(O.indexOf("paint.")===0?Yt(z[O],F[O],_,C,O.slice(6),"setPaintProperty"):dt(z[O],F[O])||ft(_,{command:"setLayerProperty",args:[C,O,F[O]]}));for(O in F)Object.prototype.hasOwnProperty.call(F,O)&&!Object.prototype.hasOwnProperty.call(z,O)&&O!=="layout"&&O!=="paint"&&O!=="filter"&&O!=="metadata"&&O!=="minzoom"&&O!=="maxzoom"&&(O.indexOf("paint.")===0?Yt(z[O],F[O],_,C,O.slice(6),"setPaintProperty"):dt(z[O],F[O])||ft(_,{command:"setLayerProperty",args:[C,O,F[O]]}))}else ft(_,{command:"removeLayer",args:[C]}),Z=P[P.lastIndexOf(C)+1],ft(_,{command:"addLayer",args:[F,Z]})}(l,t.layers,i)}catch(a){console.warn("Unable to compute style diff:",a),i=[{command:"setStyle",args:[t]}]}return i},D.bW=function(r){const t=[],i=r.id;return i===void 0&&t.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&t.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},D.bX=Xr,D.bY=vn,D.bZ=class extends Xi{constructor(r,t){super(r,t),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},D.b_=Lr,D.ba=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]},D.bb=cp,D.bc=bo,D.bd=function(r,t,i,a,s){var l=1/Math.tan(t/2);if(r[0]=l/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=l,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!=null&&s!==1/0){var u=1/(a-s);r[10]=(s+a)*u,r[14]=2*s*a*u}else r[10]=-1,r[14]=-2*a;return r},D.be=function(r){var t=new Se(16);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],t},D.bf=function(r,t,i){var a=Math.sin(i),s=Math.cos(i),l=t[0],u=t[1],f=t[2],_=t[3],y=t[4],v=t[5],w=t[6],S=t[7];return t!==r&&(r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=l*s+y*a,r[1]=u*s+v*a,r[2]=f*s+w*a,r[3]=_*s+S*a,r[4]=y*s-l*a,r[5]=v*s-u*a,r[6]=w*s-f*a,r[7]=S*s-_*a,r},D.bg=function(r,t,i){var a=Math.sin(i),s=Math.cos(i),l=t[4],u=t[5],f=t[6],_=t[7],y=t[8],v=t[9],w=t[10],S=t[11];return t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[4]=l*s+y*a,r[5]=u*s+v*a,r[6]=f*s+w*a,r[7]=_*s+S*a,r[8]=y*s-l*a,r[9]=v*s-u*a,r[10]=w*s-f*a,r[11]=S*s-_*a,r},D.bh=function(){const r=new Float32Array(16);return Hn(r),r},D.bi=function(){const r=new Float64Array(16);return Hn(r),r},D.bj=function(){return new Float64Array(16)},D.bk=function(r,t,i){const a=new Float64Array(4);return ka(a,r,t-90,i),a},D.bl=function(r,t,i,a){var s,l,u,f,_,y=t[0],v=t[1],w=t[2],S=t[3],P=i[0],M=i[1],C=i[2],z=i[3];return(l=y*P+v*M+w*C+S*z)<0&&(l=-l,P=-P,M=-M,C=-C,z=-z),1-l>ze?(s=Math.acos(l),u=Math.sin(s),f=Math.sin((1-a)*s)/u,_=Math.sin(a*s)/u):(f=1-a,_=a),r[0]=f*y+_*P,r[1]=f*v+_*M,r[2]=f*w+_*C,r[3]=f*S+_*z,r},D.bm=function(r){const t=new Float64Array(9);var i,a,s,l,u,f,_,y,v,w,S,P,M,C,z,F,Z,O;w=(s=(a=r)[0])*(_=s+s),S=(l=a[1])*_,M=(u=a[2])*_,C=u*(y=l+l),F=(f=a[3])*_,Z=f*y,O=f*(v=u+u),(i=t)[0]=1-(P=l*y)-(z=u*v),i[3]=S-O,i[6]=M+Z,i[1]=S+O,i[4]=1-w-z,i[7]=C-F,i[2]=M-Z,i[5]=C+F,i[8]=1-w-P;const N=Ai(-Math.asin(wi(t[2],-1,1)));let Q,et;return Math.hypot(t[5],t[8])<.001?(Q=0,et=-Ai(Math.atan2(t[3],t[4]))):(Q=Ai(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),et=Ai(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:Q,pitch:N+90,bearing:et}},D.bn=function(r,t){return r.roll==t.roll&&r.pitch==t.pitch&&r.bearing==t.bearing},D.bo=Kt,D.bp=Rr,D.bq=_o,D.br=Fl,D.bs=mo,D.bt=xn,D.bu=Is,D.bv=mi,D.bw=function(r,t,i,a,s){return xn(a,s,wi((r-t)/(i-t),0,1))},D.bx=pr,D.by=function(){return new Float64Array(3)},D.bz=function(r,t,i,a){return r[0]=t[0]+i[0]*a,r[1]=t[1]+i[1]*a,r[2]=t[2]+i[2]*a,r},D.c=Jn,D.c$=class{constructor(r){this._marks={start:[r.url,"start"].join("#"),end:[r.url,"end"].join("#"),measure:r.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let r=performance.getEntriesByName(this._marks.measure);return r.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),r=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),r}},D.c0=Vi,D.c1=class extends Xi{constructor(r,t){super(r,t),this.current=[0,0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2]))}},D.c2=class extends Xi{constructor(r,t){super(r,t),this.current=[0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1]))}},D.c3=Wn,D.c4=function(r,t){var i=Math.sin(t),a=Math.cos(t);return r[0]=a,r[1]=i,r[2]=0,r[3]=-i,r[4]=a,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},D.c5=function(r,t,i){var a=t[0],s=t[1],l=t[2];return r[0]=a*i[0]+s*i[3]+l*i[6],r[1]=a*i[1]+s*i[4]+l*i[7],r[2]=a*i[2]+s*i[5]+l*i[8],r},D.c6=function(r,t,i,a,s,l,u){var f=1/(t-i),_=1/(a-s),y=1/(l-u);return r[0]=-2*f,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*_,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*y,r[11]=0,r[12]=(t+i)*f,r[13]=(s+a)*_,r[14]=(u+l)*y,r[15]=1,r},D.c7=class extends Xi{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(4*r.length);for(let i=0;i<r.length;i++)t[4*i]=r[i].r,t[4*i+1]=r[i].g,t[4*i+2]=r[i].b,t[4*i+3]=r[i].a;this.gl.uniform4fv(this.location,t)}}},D.c8=class extends Xi{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(r);this.gl.uniform1fv(this.location,t)}}},D.c9=class extends so{},D.cA=function(r){return La[r]||Fa[r]},D.cB=function(r,t,i){var a=t[0],s=t[1];return r[0]=i[0]*a+i[4]*s+i[12],r[1]=i[1]*a+i[5]*s+i[13],r},D.cC=function(r,t){const{x:i,y:a}=Nl.fromLngLat(t);return!(r<0||r>25||a<0||a>=1||i<0||i>=1)},D.cD=function(r,t){return r[0]=t[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=t[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=t[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},D.cE=class extends ps{},D.cF=m_,D.cH=function(r){return r.message===wn},D.cI=ir,D.cJ=function(r,t){Jr.REGISTERED_PROTOCOLS[r]=t},D.cK=function(r){delete Jr.REGISTERED_PROTOCOLS[r]},D.cL=function(r,t){const i={};for(let s=0;s<r.length;s++){const l=t&&t[r[s].id]||kc(r[s]);t&&(t[r[s].id]=l);let u=i[l];u||(u=i[l]=[]),u.push(r[s])}const a=[];for(const s in i)a.push(i[s]);return a},D.cM=Dt,D.cN=hp,D.cO=kp,D.cP=qd,D.cQ=function(r){r.bucket.createArrays(),r.bucket.tilePixelRatio=oe/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const t=r.bucket.layers[0],i=t.layout,a=t._unevaluatedLayout._values,s={layoutIconSize:a["icon-size"].possiblyEvaluate(new le(r.bucket.zoom+1),r.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new le(r.bucket.zoom+1),r.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new le(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:y,maxZoom:v}=r.bucket.textSizeData;s.compositeTextSizes=[a["text-size"].possiblyEvaluate(new le(y),r.canonical),a["text-size"].possiblyEvaluate(new le(v),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:y,maxZoom:v}=r.bucket.iconSizeData;s.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new le(y),r.canonical),a["icon-size"].possiblyEvaluate(new le(v),r.canonical)]}const l=i.get("text-line-height")*ei,u=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",f=i.get("text-keep-upright"),_=i.get("text-size");for(const y of r.bucket.features){const v=i.get("text-font").evaluate(y,{},r.canonical).join(","),w=_.evaluate(y,{},r.canonical),S=s.layoutTextSize.evaluate(y,{},r.canonical),P=s.layoutIconSize.evaluate(y,{},r.canonical),M={horizontal:{},vertical:void 0},C=y.text;let z,F=[0,0];if(C){const N=C.toString(),Q=i.get("text-letter-spacing").evaluate(y,{},r.canonical)*ei,et=no(N)?Q:0,lt=i.get("text-anchor").evaluate(y,{},r.canonical),yt=qp(t,y,r.canonical);if(!yt){const St=i.get("text-radial-offset").evaluate(y,{},r.canonical);F=St?$p(lt,[St*ei,$h]):i.get("text-offset").evaluate(y,{},r.canonical).map(Pt=>Pt*ei)}let mt=u?"center":i.get("text-justify").evaluate(y,{},r.canonical);const vt=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(y,{},r.canonical)*ei:1/0,Ct=()=>{r.bucket.allowVerticalPlacement&&ss(N)&&(M.vertical=uu(C,r.glyphMap,r.glyphPositions,r.imagePositions,v,vt,l,lt,"left",et,F,D.ay.vertical,!0,S,w))};if(!u&&yt){const St=new Set;if(mt==="auto")for(let _t=0;_t<yt.values.length;_t+=2)St.add(qh(yt.values[_t]));else St.add(mt);let Pt=!1;for(const _t of St)if(!M.horizontal[_t])if(Pt)M.horizontal[_t]=M.horizontal[0];else{const Bt=uu(C,r.glyphMap,r.glyphPositions,r.imagePositions,v,vt,l,"center",_t,et,F,D.ay.horizontal,!1,S,w);Bt&&(M.horizontal[_t]=Bt,Pt=Bt.positionedLines.length===1)}Ct()}else{mt==="auto"&&(mt=qh(lt));const St=uu(C,r.glyphMap,r.glyphPositions,r.imagePositions,v,vt,l,lt,mt,et,F,D.ay.horizontal,!1,S,w);St&&(M.horizontal[mt]=St),Ct(),ss(N)&&u&&f&&(M.vertical=uu(C,r.glyphMap,r.glyphPositions,r.imagePositions,v,vt,l,lt,mt,et,F,D.ay.vertical,!1,S,w))}}let Z=!1;if(y.icon&&y.icon.name){const N=r.imageMap[y.icon.name];N&&(z=Dm(r.imagePositions[y.icon.name],i.get("icon-offset").evaluate(y,{},r.canonical),i.get("icon-anchor").evaluate(y,{},r.canonical)),Z=!!N.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=Z:r.bucket.sdfIcons!==Z&&Pe("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(N.pixelRatio!==r.bucket.pixelRatio||i.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const O=Hp(M.horizontal)||M.vertical;r.bucket.iconsInText=!!O&&O.iconsInText,(O||z)&&p_(r.bucket,y,M,z,r.imageMap,s,S,P,F,Z,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},D.cR=gh,D.cS=xh,D.cT=vh,D.cU=Id,D.cV=wh,D.cW=go,D.cX=function(r,t,i,a,s,l){let u=Fp(r,t,i,s,0);return u=Fp(u,t,a,l,1),u},D.cY=class{constructor(r){this.maxEntries=r,this.map=new Map}get(r){const t=this.map.get(r);return t!==void 0&&(this.map.delete(r),this.map.set(r,t)),t}set(r,t){if(this.map.has(r))this.map.delete(r);else if(this.map.size>=this.maxEntries){const i=this.map.keys().next().value;this.map.delete(i)}this.map.set(r,t)}clear(){this.map.clear()}},D.cZ=Ed,D.c_=zp,D.ca=cm,D.cb=class extends oo{},D.cc=dh,D.cd=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},D.ce=pd,D.cf=function(r,t,i){var a=t[0],s=t[1],l=t[2],u=i[3]*a+i[7]*s+i[11]*l+i[15];return r[0]=(i[0]*a+i[4]*s+i[8]*l+i[12])/(u=u||1),r[1]=(i[1]*a+i[5]*s+i[9]*l+i[13])/u,r[2]=(i[2]*a+i[6]*s+i[10]*l+i[14])/u,r},D.cg=class extends Tl{},D.ch=class extends o{},D.ci=function(r,t){return r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]&&r[3]===t[3]&&r[4]===t[4]&&r[5]===t[5]&&r[6]===t[6]&&r[7]===t[7]&&r[8]===t[8]&&r[9]===t[9]&&r[10]===t[10]&&r[11]===t[11]&&r[12]===t[12]&&r[13]===t[13]&&r[14]===t[14]&&r[15]===t[15]},D.cj=function(r,t){var i=r[0],a=r[1],s=r[2],l=r[3],u=r[4],f=r[5],_=r[6],y=r[7],v=r[8],w=r[9],S=r[10],P=r[11],M=r[12],C=r[13],z=r[14],F=r[15],Z=t[0],O=t[1],N=t[2],Q=t[3],et=t[4],lt=t[5],yt=t[6],mt=t[7],vt=t[8],Ct=t[9],St=t[10],Pt=t[11],_t=t[12],Bt=t[13],Ot=t[14],Nt=t[15];return Math.abs(i-Z)<=ze*Math.max(1,Math.abs(i),Math.abs(Z))&&Math.abs(a-O)<=ze*Math.max(1,Math.abs(a),Math.abs(O))&&Math.abs(s-N)<=ze*Math.max(1,Math.abs(s),Math.abs(N))&&Math.abs(l-Q)<=ze*Math.max(1,Math.abs(l),Math.abs(Q))&&Math.abs(u-et)<=ze*Math.max(1,Math.abs(u),Math.abs(et))&&Math.abs(f-lt)<=ze*Math.max(1,Math.abs(f),Math.abs(lt))&&Math.abs(_-yt)<=ze*Math.max(1,Math.abs(_),Math.abs(yt))&&Math.abs(y-mt)<=ze*Math.max(1,Math.abs(y),Math.abs(mt))&&Math.abs(v-vt)<=ze*Math.max(1,Math.abs(v),Math.abs(vt))&&Math.abs(w-Ct)<=ze*Math.max(1,Math.abs(w),Math.abs(Ct))&&Math.abs(S-St)<=ze*Math.max(1,Math.abs(S),Math.abs(St))&&Math.abs(P-Pt)<=ze*Math.max(1,Math.abs(P),Math.abs(Pt))&&Math.abs(M-_t)<=ze*Math.max(1,Math.abs(M),Math.abs(_t))&&Math.abs(C-Bt)<=ze*Math.max(1,Math.abs(C),Math.abs(Bt))&&Math.abs(z-Ot)<=ze*Math.max(1,Math.abs(z),Math.abs(Ot))&&Math.abs(F-Nt)<=ze*Math.max(1,Math.abs(F),Math.abs(Nt))},D.ck=function(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},D.cl=r=>r.type==="symbol",D.cm=r=>r.type==="circle",D.cn=r=>r.type==="heatmap",D.co=r=>r.type==="line",D.cp=r=>r.type==="fill",D.cq=r=>r.type==="fill-extrusion",D.cr=r=>r.type==="hillshade",D.cs=r=>r.type==="color-relief",D.ct=r=>r.type==="background",D.cu=r=>r.type==="custom",D.cv=Wr,D.cw=function(r,t,i){const a=Ms(t.x-i.x,t.y-i.y),s=Ms(r.x-i.x,r.y-i.y);var l,u;return Ai(Math.atan2(a[0]*s[1]-a[1]*s[0],(l=a)[0]*(u=s)[0]+l[1]*u[1]))},D.cx=Hr,D.cy=function(r,t){return Fa[t]&&(r instanceof MouseEvent||r instanceof WheelEvent)},D.cz=function(r,t){return La[t]&&"touches"in r},D.d=k,D.d0=function(r,t,i,a,s){return h(this,void 0,void 0,function*(){if(_n())try{return yield Kn(r,t,i,a,s)}catch{}return function(l,u,f,_,y){const v=l.width,w=l.height;Yr&&gr||(Yr=new OffscreenCanvas(v,w),gr=Yr.getContext("2d",{willReadFrequently:!0})),Yr.width=v,Yr.height=w,gr.drawImage(l,0,0,v,w);const S=gr.getImageData(u,f,_,y);return gr.clearRect(0,0,v,w),S.data}(r,t,i,a,s)})},D.d1=_d,D.d2=si,D.d3=Hs,D.d4=on,D.e=di,D.f=r=>h(void 0,void 0,void 0,function*(){if(r.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(r)],{type:"image/png"});try{return createImageBitmap(t)}catch(i){throw new Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),D.g=Qn,D.h=r=>new Promise((t,i)=>{const a=new Image;a.onload=()=>{t(a),URL.revokeObjectURL(a.src),a.onload=null,window.requestAnimationFrame(()=>{a.src=_r})},a.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 s=new Blob([new Uint8Array(r)],{type:"image/png"});a.src=r.byteLength?URL.createObjectURL(s):_r}),D.i=fr,D.j=(r,t)=>tt(di(r,{type:"json"}),t),D.k=X,D.l=W,D.m=tt,D.n=(r,t)=>tt(di(r,{type:"arrayBuffer"}),t),D.o=function(r){return new wh(r).readFields(Tm,[])},D.p=$d,D.q=function(r){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(r))},D.r=Dl,D.s=Kr,D.t=_i,D.u=U,D.v=is,D.w=Pe,D.x=Hc,D.y=Ku,D.z=os}),se("worker",["./shared"],function(D){class h{constructor(k,R){this.keyCache={},k&&this.replace(k,R)}replace(k,R){this._layerConfigs={},this._layers={},this.update(k,[],R)}update(k,R,B){for(const X of k){this._layerConfigs[X.id]=X;const nt=this._layers[X.id]=D.bS(X,B);nt._featureFilter=D.aj(nt.filter,B),this.keyCache[X.id]&&delete this.keyCache[X.id]}for(const X of R)delete this.keyCache[X],delete this._layerConfigs[X],delete this._layers[X];this.familiesBySource={};const W=D.cL(Object.values(this._layerConfigs),this.keyCache);for(const X of W){const nt=X.map(zt=>this._layers[zt.id]),U=nt[0];if(U.visibility==="none")continue;const rt=U.source||"";let ht=this.familiesBySource[rt];ht||(ht=this.familiesBySource[rt]={});const dt=U.sourceLayer||D.a9;let ft=ht[dt];ft||(ft=ht[dt]=[]),ft.push(nt)}}}class It{constructor(k){const R={},B=[];for(const U in k){const rt=k[U],ht=R[U]={};for(const dt in rt){const ft=rt[+dt];if(!ft||ft.bitmap.width===0||ft.bitmap.height===0)continue;const zt={x:0,y:0,w:ft.bitmap.width+2,h:ft.bitmap.height+2};B.push(zt),ht[dt]={rect:zt,metrics:ft.metrics}}}const{w:W,h:X}=D.p(B),nt=new D.r({width:W||1,height:X||1});for(const U in k){const rt=k[U];for(const ht in rt){const dt=rt[+ht];if(!dt||dt.bitmap.width===0||dt.bitmap.height===0)continue;const ft=R[U][ht].rect;D.r.copy(dt.bitmap,nt,{x:0,y:0},{x:ft.x+1,y:ft.y+1},dt.bitmap)}}this.image=nt,this.positions=R}}D.cM("GlyphAtlas",It);class si{constructor(k){this.tileID=new D.a1(k.tileID.overscaledZ,k.tileID.wrap,k.tileID.canonical.z,k.tileID.canonical.x,k.tileID.canonical.y),this.uid=k.uid,this.zoom=k.zoom,this.pixelRatio=k.pixelRatio,this.tileSize=k.tileSize,this.source=k.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=k.showCollisionBoxes,this.collectResourceTiming=!!k.collectResourceTiming,this.returnDependencies=!!k.returnDependencies,this.promoteId=k.promoteId,this.inFlightDependencies=[]}parse(k,R,B,W,X){return D._(this,void 0,void 0,function*(){this.status="parsing",this.data=k,this.collisionBoxArray=new D.ah;const nt=new D.cN(Object.keys(k.layers).sort()),U=new D.cO(this.tileID,this.promoteId);U.bucketLayerIDs=[];const rt={},ht={featureIndex:U,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:B,subdivisionGranularity:X},dt=R.familiesBySource[this.source];for(const Lt in dt){const Ut=k.layers[Lt];if(!Ut)continue;Ut.version===1&&D.w(`Vector tile source "${this.source}" layer "${Lt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Di=nt.encode(Lt),Sn=[];for(let ti=0;ti<Ut.length;ti++){const Gt=Ut.feature(ti),Er=U.getId(Gt,Lt);Sn.push({feature:Gt,id:Er,index:ti,sourceLayerIndex:Di})}for(const ti of dt[Lt]){const Gt=ti[0];Gt.source!==this.source&&D.w(`layer.source = ${Gt.source} does not equal this.source = ${this.source}`),Gt.isHidden(this.zoom,!0)||(Ve(ti,this.zoom,B),(rt[Gt.id]=Gt.createBucket({index:U.bucketLayerIDs.length,layers:ti,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Di,sourceID:this.source})).populate(Sn,ht,this.tileID.canonical),U.bucketLayerIDs.push(ti.map(Er=>Er.id)))}}const ft=D.bX(ht.glyphDependencies,Lt=>Object.keys(Lt).map(Number));this.inFlightDependencies.forEach(Lt=>Lt?.abort()),this.inFlightDependencies=[];let zt=Promise.resolve({});if(Object.keys(ft).length){const Lt=new AbortController;this.inFlightDependencies.push(Lt),zt=W.sendAsync({type:"GG",data:{stacks:ft,source:this.source,tileID:this.tileID,type:"glyphs"}},Lt)}const jt=Object.keys(ht.iconDependencies);let qt=Promise.resolve({});if(jt.length){const Lt=new AbortController;this.inFlightDependencies.push(Lt),qt=W.sendAsync({type:"GI",data:{icons:jt,source:this.source,tileID:this.tileID,type:"icons"}},Lt)}const ke=Object.keys(ht.patternDependencies);let Yt=Promise.resolve({});if(ke.length){const Lt=new AbortController;this.inFlightDependencies.push(Lt),Yt=W.sendAsync({type:"GI",data:{icons:ke,source:this.source,tileID:this.tileID,type:"patterns"}},Lt)}const ne=ht.dashDependencies;let de=Promise.resolve({});if(Object.keys(ne).length){const Lt=new AbortController;this.inFlightDependencies.push(Lt),de=W.sendAsync({type:"GDA",data:{dashes:ne}},Lt)}const[bt,xe,pe,$e]=yield Promise.all([zt,qt,Yt,de]),fe=new It(bt),Tt=new D.cP(xe,pe);for(const Lt in rt){const Ut=rt[Lt];Ut instanceof D.ai?(Ve(Ut.layers,this.zoom,B),D.cQ({bucket:Ut,glyphMap:bt,glyphPositions:fe.positions,imageMap:xe,imagePositions:Tt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:ht.subdivisionGranularity})):Ut.hasDependencies&&(Ut instanceof D.cR||Ut instanceof D.cS||Ut instanceof D.cT)&&(Ve(Ut.layers,this.zoom,B),Ut.addFeatures(ht,this.tileID.canonical,Tt.patternPositions,$e))}return this.status="done",{buckets:Object.values(rt).filter(Lt=>!Lt.isEmpty()),featureIndex:U,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:fe.image,imageAtlas:Tt,dashPositions:$e,glyphMap:this.returnDependencies?bt:null,iconMap:this.returnDependencies?xe:null,glyphPositions:this.returnDependencies?fe.positions:null}})}}function Ve(tt,k,R){const B=new D.H(k);for(const W of tt)W.recalculate(B,R)}class dr extends D.cW{constructor(k,R){super(new D.cV,0,R,[],[]),this.feature=k,this.type=k.type,this.properties=k.tags?k.tags:{},"id"in k&&(typeof k.id=="string"?this.id=parseInt(k.id,10):typeof k.id!="number"||isNaN(k.id)||(this.id=k.id))}loadGeometry(){const k=[],R=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const B of R){const W=[];for(const X of B)W.push(new D.P(X[0],X[1]));k.push(W)}return k}}class Ji extends D.cU{constructor(k,R){super(new D.cV),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=R?R.version:1,this.extent=R?R.extent:4096,this.length=k.length,this.features=k}feature(k){return new dr(this.features[k],this.extent)}}function Ze(tt,k){k.writeVarintField(15,tt.version||1),k.writeStringField(1,tt.name||""),k.writeVarintField(5,tt.extent||4096);const R={keys:[],values:[],keycache:{},valuecache:{}};for(let X=0;X<tt.length;X++)R.feature=tt.feature(X),k.writeMessage(2,Zr,R);const B=R.keys;for(const X of B)k.writeStringField(3,X);const W=R.values;for(const X of W)k.writeMessage(4,Se,X)}function Zr(tt,k){if(!tt.feature)return;const R=tt.feature;R.id!==void 0&&k.writeVarintField(1,R.id),k.writeMessage(2,ie,tt),k.writeVarintField(3,R.type),k.writeMessage(4,ze,R)}function ie(tt,k){for(const R in tt.feature?.properties){let B=tt.feature.properties[R],W=tt.keycache[R];if(B===null)continue;W===void 0&&(tt.keys.push(R),W=tt.keys.length-1,tt.keycache[R]=W),k.writeVarint(W),typeof B!="string"&&typeof B!="boolean"&&typeof B!="number"&&(B=JSON.stringify(B));const X=typeof B+":"+B;let nt=tt.valuecache[X];nt===void 0&&(tt.values.push(B),nt=tt.values.length-1,tt.valuecache[X]=nt),k.writeVarint(nt)}}function pt(tt,k){return(k<<3)+(7&tt)}function _n(tt){return tt<<1^tt>>31}function ze(tt,k){const R=tt.loadGeometry(),B=tt.type;let W=0,X=0;for(const nt of R){let U=1;B===1&&(U=nt.length),k.writeVarint(pt(1,U));const rt=B===3?nt.length-1:nt.length;for(let ht=0;ht<rt;ht++){ht===1&&B!==1&&k.writeVarint(pt(2,rt-1));const dt=nt[ht].x-W,ft=nt[ht].y-X;k.writeVarint(_n(dt)),k.writeVarint(_n(ft)),W+=dt,X+=ft}tt.type===3&&k.writeVarint(pt(7,1))}}function Se(tt,k){const R=typeof tt;R==="string"?k.writeStringField(1,tt):R==="boolean"?k.writeBooleanField(7,tt):R==="number"&&(tt%1!=0?k.writeDoubleField(3,tt):tt<0?k.writeSVarintField(6,tt):k.writeVarintField(5,tt))}class Wn extends D.cW{constructor(k,R,B,W,X){super(new D.cV,0,X,[],[]),this.type=k,this.properties=B||{},this.extent=X,this.pointsArray=R,this.id=W}loadGeometry(){return this.pointsArray.map(k=>k.map(R=>new D.P(R.x,R.y)))}}class Hn extends D.cU{constructor(k,R,B){super(new D.cV),this.version=2,this._myFeatures=k,this.name=R,this.length=k.length,this.extent=B}feature(k){return this._myFeatures[k]}}class Aa{constructor(){this.layers={}}addLayer(k){this.layers[k.name]=k}}function Ci(tt){let k=function(R){const B=new D.cV;return function(W,X){for(const nt in W.layers)X.writeMessage(3,Ze,W.layers[nt])}(R,B),B.finish()}(tt);return k.byteOffset===0&&k.byteLength===k.buffer.byteLength||(k=new Uint8Array(k)),{vectorTile:tt,rawData:k.buffer}}function Ps(tt,k,R){const{extent:B}=tt,W=Math.pow(2,R.z-k.z),X=(R.x-k.x*W)*B,nt=(R.y-k.y*W)*B,U=[];for(let rt=0;rt<tt.length;rt++){const ht=tt.feature(rt);let dt=ht.loadGeometry();for(const zt of dt)for(const jt of zt)jt.x=jt.x*W-X,jt.y=jt.y*W-nt;const ft=128;dt=D.cX(dt,ht.type,-ft,-ft,B+ft,B+ft),dt.length!==0&&U.push(new Wn(ht.type,dt,ht.properties,ht.id,B))}return new Hn(U,tt.name,B)}class Ir{constructor(k,R,B){this.actor=k,this.layerIndex=R,this.availableImages=B,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new D.cY(1e3)}loadVectorTile(k,R){return D._(this,void 0,void 0,function*(){const B=yield D.n(k.request,R);try{return{vectorTile:k.encoding!=="mlt"?new D.cZ(new D.cV(B.data)):new D.c_(B.data),rawData:B.data,cacheControl:B.cacheControl,expires:B.expires}}catch(W){const X=new Uint8Array(B.data);let nt=`Unable to parse the tile at ${k.request.url}, `;throw nt+=X[0]===31&&X[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${W.message}`,new Error(nt)}})}loadTile(k){return D._(this,void 0,void 0,function*(){const{uid:R,overzoomParameters:B}=k;B&&(k.request=B.overzoomRequest);const W=!!(k&&k.request&&k.request.collectResourceTiming)&&new D.c$(k.request),X=new si(k);this.loading[R]=X;const nt=new AbortController;X.abort=nt;try{const U=yield this.loadVectorTile(k,nt);if(delete this.loading[R],!U)return null;if(B){const zt=this._getOverzoomTile(k,U.vectorTile);U.rawData=zt.rawData,U.vectorTile=zt.vectorTile}const rt=U.rawData,ht={};U.expires&&(ht.expires=U.expires),U.cacheControl&&(ht.cacheControl=U.cacheControl);const dt={};if(W){const zt=W.finish();zt&&(dt.resourceTiming=JSON.parse(JSON.stringify(zt)))}X.vectorTile=U.vectorTile;const ft=X.parse(U.vectorTile,this.layerIndex,this.availableImages,this.actor,k.subdivisionGranularity);this.loaded[R]=X,this.fetching[R]={rawTileData:rt,cacheControl:ht,resourceTiming:dt};try{const zt=yield ft;return D.e({rawTileData:rt.slice(0),encoding:k.encoding},zt,ht,dt)}finally{delete this.fetching[R]}}catch(U){throw delete this.loading[R],X.status="done",this.loaded[R]=X,U}})}_getOverzoomTile(k,R){const{tileID:B,source:W,overzoomParameters:X}=k,{maxZoomTileID:nt}=X,U=`${nt.key}_${B.key}`,rt=this.overzoomedTileResultCache.get(U);if(rt)return rt;const ht=new Aa,dt=this.layerIndex.familiesBySource[W];for(const zt in dt){const jt=R.layers[zt];if(!jt)continue;const qt=Ps(jt,nt,B.canonical);qt.length>0&&ht.addLayer(qt)}const ft=Ci(ht);return this.overzoomedTileResultCache.set(U,ft),ft}reloadTile(k){return D._(this,void 0,void 0,function*(){const R=k.uid;if(!this.loaded||!this.loaded[R])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const B=this.loaded[R];if(B.showCollisionBoxes=k.showCollisionBoxes,B.status==="parsing"){const W=yield B.parse(B.vectorTile,this.layerIndex,this.availableImages,this.actor,k.subdivisionGranularity);let X;if(this.fetching[R]){const{rawTileData:nt,cacheControl:U,resourceTiming:rt}=this.fetching[R];delete this.fetching[R],X=D.e({rawTileData:nt.slice(0),encoding:k.encoding},W,U,rt)}else X=W;return X}if(B.status==="done"&&B.vectorTile)return B.parse(B.vectorTile,this.layerIndex,this.availableImages,this.actor,k.subdivisionGranularity)})}abortTile(k){return D._(this,void 0,void 0,function*(){const R=this.loading,B=k.uid;R&&R[B]&&R[B].abort&&(R[B].abort.abort(),delete R[B])})}removeTile(k){return D._(this,void 0,void 0,function*(){this.loaded&&this.loaded[k.uid]&&delete this.loaded[k.uid]})}}class $r{constructor(){this.loaded={}}loadTile(k){return D._(this,void 0,void 0,function*(){const{uid:R,encoding:B,rawImageData:W,redFactor:X,greenFactor:nt,blueFactor:U,baseShift:rt}=k,ht=W.width+2,dt=W.height+2,ft=D.b(W)?new D.R({width:ht,height:dt},yield D.d0(W,-1,-1,ht,dt)):W,zt=new D.d1(R,ft,B,X,nt,U,rt);return this.loaded=this.loaded||{},this.loaded[R]=zt,zt})}removeTile(k){const R=this.loaded,B=k.uid;R&&R[B]&&delete R[B]}}var gn,qr,yn=function(){if(qr)return gn;function tt(R,B){if(R.length!==0){k(R[0],B);for(var W=1;W<R.length;W++)k(R[W],!B)}}function k(R,B){for(var W=0,X=0,nt=0,U=R.length,rt=U-1;nt<U;rt=nt++){var ht=(R[nt][0]-R[rt][0])*(R[rt][1]+R[nt][1]),dt=W+ht;X+=Math.abs(W)>=Math.abs(ht)?W-dt+ht:ht-dt+W,W=dt}W+X>=0!=!!B&&R.reverse()}return qr=1,gn=function R(B,W){var X,nt=B&&B.type;if(nt==="FeatureCollection")for(X=0;X<B.features.length;X++)R(B.features[X],W);else if(nt==="GeometryCollection")for(X=0;X<B.geometries.length;X++)R(B.geometries[X],W);else if(nt==="Feature")R(B.geometry,W);else if(nt==="Polygon")tt(B.coordinates,W);else if(nt==="MultiPolygon")for(X=0;X<B.coordinates.length;X++)tt(B.coordinates[X],W);return B}}(),Da=D.d2(yn);const za={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:tt=>tt},ka=Math.fround||(Qi=new Float32Array(1),tt=>(Qi[0]=+tt,Qi[0]));var Qi;class Ms{constructor(k){this.options=Object.assign(Object.create(za),k),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(k){const{log:R,minZoom:B,maxZoom:W}=this.options;R&&console.time("total time");const X=`prepare ${k.length} points`;R&&console.time(X),this.points=k;const nt=[];for(let rt=0;rt<k.length;rt++){const ht=k[rt];if(!ht.geometry)continue;const[dt,ft]=ht.geometry.coordinates,zt=ka(pr(dt)),jt=ka(xn(ft));nt.push(zt,jt,1/0,rt,-1,1),this.options.reduce&&nt.push(0)}let U=this.trees[W+1]=this._createTree(nt);R&&console.timeEnd(X);for(let rt=W;rt>=B;rt--){const ht=+Date.now();U=this.trees[rt]=this._createTree(this._cluster(U,rt)),R&&console.log("z%d: %d clusters in %dms",rt,U.numItems,+Date.now()-ht)}return R&&console.timeEnd("total time"),this}getClusters(k,R){let B=((k[0]+180)%360+360)%360-180;const W=Math.max(-90,Math.min(90,k[1]));let X=k[2]===180?180:((k[2]+180)%360+360)%360-180;const nt=Math.max(-90,Math.min(90,k[3]));if(k[2]-k[0]>=360)B=-180,X=180;else if(B>X){const ft=this.getClusters([B,W,180,nt],R),zt=this.getClusters([-180,W,X,nt],R);return ft.concat(zt)}const U=this.trees[this._limitZoom(R)],rt=U.range(pr(B),xn(nt),pr(X),xn(W)),ht=U.data,dt=[];for(const ft of rt){const zt=this.stride*ft;dt.push(ht[zt+5]>1?oe(ht,zt,this.clusterProps):this.points[ht[zt+3]])}return dt}getChildren(k){const R=this._getOriginId(k),B=this._getOriginZoom(k),W="No cluster with the specified id.",X=this.trees[B];if(!X)throw new Error(W);const nt=X.data;if(R*this.stride>=nt.length)throw new Error(W);const U=this.options.radius/(this.options.extent*Math.pow(2,B-1)),rt=X.within(nt[R*this.stride],nt[R*this.stride+1],U),ht=[];for(const dt of rt){const ft=dt*this.stride;nt[ft+4]===k&&ht.push(nt[ft+5]>1?oe(nt,ft,this.clusterProps):this.points[nt[ft+3]])}if(ht.length===0)throw new Error(W);return ht}getLeaves(k,R,B){const W=[];return this._appendLeaves(W,k,R=R||10,B=B||0,0),W}getTile(k,R,B){const W=this.trees[this._limitZoom(k)],X=Math.pow(2,k),{extent:nt,radius:U}=this.options,rt=U/nt,ht=(B-rt)/X,dt=(B+1+rt)/X,ft={features:[]};return this._addTileFeatures(W.range((R-rt)/X,ht,(R+1+rt)/X,dt),W.data,R,B,X,ft),R===0&&this._addTileFeatures(W.range(1-rt/X,ht,1,dt),W.data,X,B,X,ft),R===X-1&&this._addTileFeatures(W.range(0,ht,rt/X,dt),W.data,-1,B,X,ft),ft.features.length?ft:null}getClusterExpansionZoom(k){let R=this._getOriginZoom(k)-1;for(;R<=this.options.maxZoom;){const B=this.getChildren(k);if(R++,B.length!==1)break;k=B[0].properties.cluster_id}return R}_appendLeaves(k,R,B,W,X){const nt=this.getChildren(R);for(const U of nt){const rt=U.properties;if(rt&&rt.cluster?X+rt.point_count<=W?X+=rt.point_count:X=this._appendLeaves(k,rt.cluster_id,B,W,X):X<W?X++:k.push(U),k.length===B)break}return X}_createTree(k){const R=new D.aS(k.length/this.stride|0,this.options.nodeSize,Float32Array);for(let B=0;B<k.length;B+=this.stride)R.add(k[B],k[B+1]);return R.finish(),R.data=k,R}_addTileFeatures(k,R,B,W,X,nt){for(const U of k){const rt=U*this.stride,ht=R[rt+5]>1;let dt,ft,zt;if(ht)dt=Xn(R,rt,this.clusterProps),ft=R[rt],zt=R[rt+1];else{const ke=this.points[R[rt+3]];dt=ke.properties;const[Yt,ne]=ke.geometry.coordinates;ft=pr(Yt),zt=xn(ne)}const jt={type:1,geometry:[[Math.round(this.options.extent*(ft*X-B)),Math.round(this.options.extent*(zt*X-W))]],tags:dt};let qt;qt=ht||this.options.generateId?R[rt+3]:this.points[R[rt+3]].id,qt!==void 0&&(jt.id=qt),nt.features.push(jt)}}_limitZoom(k){return Math.max(this.options.minZoom,Math.min(Math.floor(+k),this.options.maxZoom+1))}_cluster(k,R){const{radius:B,extent:W,reduce:X,minPoints:nt}=this.options,U=B/(W*Math.pow(2,R)),rt=k.data,ht=[],dt=this.stride;for(let ft=0;ft<rt.length;ft+=dt){if(rt[ft+2]<=R)continue;rt[ft+2]=R;const zt=rt[ft],jt=rt[ft+1],qt=k.within(rt[ft],rt[ft+1],U),ke=rt[ft+5];let Yt=ke;for(const ne of qt){const de=ne*dt;rt[de+2]>R&&(Yt+=rt[de+5])}if(Yt>ke&&Yt>=nt){let ne,de=zt*ke,bt=jt*ke,xe=-1;const pe=(ft/dt<<5)+(R+1)+this.points.length;for(const $e of qt){const fe=$e*dt;if(rt[fe+2]<=R)continue;rt[fe+2]=R;const Tt=rt[fe+5];de+=rt[fe]*Tt,bt+=rt[fe+1]*Tt,rt[fe+4]=pe,X&&(ne||(ne=this._map(rt,ft,!0),xe=this.clusterProps.length,this.clusterProps.push(ne)),X(ne,this._map(rt,fe)))}rt[ft+4]=pe,ht.push(de/Yt,bt/Yt,1/0,pe,-1,Yt),X&&ht.push(xe)}else{for(let ne=0;ne<dt;ne++)ht.push(rt[ft+ne]);if(Yt>1)for(const ne of qt){const de=ne*dt;if(!(rt[de+2]<=R)){rt[de+2]=R;for(let bt=0;bt<dt;bt++)ht.push(rt[de+bt])}}}}return ht}_getOriginId(k){return k-this.points.length>>5}_getOriginZoom(k){return(k-this.points.length)%32}_map(k,R,B){if(k[R+5]>1){const nt=this.clusterProps[k[R+6]];return B?Object.assign({},nt):nt}const W=this.points[k[R+3]].properties,X=this.options.map(W);return B&&X===W?Object.assign({},X):X}}function oe(tt,k,R){return{type:"Feature",id:tt[k+3],properties:Xn(tt,k,R),geometry:{type:"Point",coordinates:[(B=tt[k],360*(B-.5)),Is(tt[k+1])]}};var B}function Xn(tt,k,R){const B=tt[k+5],W=B>=1e4?`${Math.round(B/1e3)}k`:B>=1e3?Math.round(B/100)/10+"k":B,X=tt[k+6],nt=X===-1?{}:Object.assign({},R[X]);return Object.assign(nt,{cluster:!0,cluster_id:tt[k+3],point_count:B,point_count_abbreviated:W})}function pr(tt){return tt/360+.5}function xn(tt){const k=Math.sin(tt*Math.PI/180),R=.5-.25*Math.log((1+k)/(1-k))/Math.PI;return R<0?0:R>1?1:R}function Is(tt){const k=(180-360*tt)*Math.PI/180;return 360*Math.atan(Math.exp(k))/Math.PI-90}function Wr(tt,k,R,B){let W=B;const X=k+(R-k>>1);let nt,U=R-k;const rt=tt[k],ht=tt[k+1],dt=tt[R],ft=tt[R+1];for(let zt=k+3;zt<R;zt+=3){const jt=Hr(tt[zt],tt[zt+1],rt,ht,dt,ft);if(jt>W)nt=zt,W=jt;else if(jt===W){const qt=Math.abs(zt-X);qt<U&&(nt=zt,U=qt)}}W>B&&(nt-k>3&&Wr(tt,k,nt,B),tt[nt+2]=W,R-nt>3&&Wr(tt,nt,R,B))}function Hr(tt,k,R,B,W,X){let nt=W-R,U=X-B;if(nt!==0||U!==0){const rt=((tt-R)*nt+(k-B)*U)/(nt*nt+U*U);rt>1?(R=W,B=X):rt>0&&(R+=nt*rt,B+=U*rt)}return nt=tt-R,U=k-B,nt*nt+U*U}function wi(tt,k,R,B){const W={id:tt??null,type:k,geometry:R,tags:B,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(k==="Point"||k==="MultiPoint"||k==="LineString")tr(W,R);else if(k==="Polygon")tr(W,R[0]);else if(k==="MultiLineString")for(const X of R)tr(W,X);else if(k==="MultiPolygon")for(const X of R)tr(W,X[0]);return W}function tr(tt,k){for(let R=0;R<k.length;R+=3)tt.minX=Math.min(tt.minX,k[R]),tt.minY=Math.min(tt.minY,k[R+1]),tt.maxX=Math.max(tt.maxX,k[R]),tt.maxY=Math.max(tt.maxY,k[R+1])}function di(tt,k,R,B){if(!k.geometry)return;const W=k.geometry.coordinates;if(W&&W.length===0)return;const X=k.geometry.type,nt=Math.pow(R.tolerance/((1<<R.maxZoom)*R.extent),2);let U=[],rt=k.id;if(R.promoteId?rt=k.properties[R.promoteId]:R.generateId&&(rt=B||0),X==="Point")Yn(W,U);else if(X==="MultiPoint")for(const ht of W)Yn(ht,U);else if(X==="LineString")Xr(W,U,nt,!1);else if(X==="MultiLineString"){if(R.lineMetrics){for(const ht of W)U=[],Xr(ht,U,nt,!1),tt.push(wi(rt,"LineString",U,k.properties));return}vn(W,U,nt,!1)}else if(X==="Polygon")vn(W,U,nt,!0);else{if(X!=="MultiPolygon"){if(X==="GeometryCollection"){for(const ht of k.geometry.geometries)di(tt,{id:rt,geometry:ht,properties:k.properties},R,B);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const ht of W){const dt=[];vn(ht,dt,nt,!0),U.push(dt)}}tt.push(wi(rt,X,U,k.properties))}function Yn(tt,k){k.push(Zi(tt[0]),Ra(tt[1]),0)}function Xr(tt,k,R,B){let W,X,nt=0;for(let rt=0;rt<tt.length;rt++){const ht=Zi(tt[rt][0]),dt=Ra(tt[rt][1]);k.push(ht,dt,0),rt>0&&(nt+=B?(W*dt-ht*X)/2:Math.sqrt(Math.pow(ht-W,2)+Math.pow(dt-X,2))),W=ht,X=dt}const U=k.length-3;k[2]=1,Wr(k,0,U,R),k[U+2]=1,k.size=Math.abs(nt),k.start=0,k.end=k.size}function vn(tt,k,R,B){for(let W=0;W<tt.length;W++){const X=[];Xr(tt[W],X,R,B),k.push(X)}}function Zi(tt){return tt/360+.5}function Ra(tt){const k=Math.sin(tt*Math.PI/180),R=.5-.25*Math.log((1+k)/(1-k))/Math.PI;return R<0?0:R>1?1:R}function Pe(tt,k,R,B,W,X,nt,U){if(B/=k,X>=(R/=k)&&nt<B)return tt;if(nt<R||X>=B)return null;const rt=[];for(const ht of tt){const dt=ht.geometry;let ft=ht.type;const zt=W===0?ht.minX:ht.minY,jt=W===0?ht.maxX:ht.maxY;if(zt>=R&&jt<B){rt.push(ht);continue}if(jt<R||zt>=B)continue;let qt=[];if(ft==="Point"||ft==="MultiPoint")er(dt,qt,R,B,W);else if(ft==="LineString")fr(dt,qt,R,B,W,!1,U.lineMetrics);else if(ft==="MultiLineString")mr(dt,qt,R,B,W,!1);else if(ft==="Polygon")mr(dt,qt,R,B,W,!0);else if(ft==="MultiPolygon")for(const ke of dt){const Yt=[];mr(ke,Yt,R,B,W,!0),Yt.length&&qt.push(Yt)}if(qt.length){if(U.lineMetrics&&ft==="LineString"){for(const ke of qt)rt.push(wi(ht.id,ft,ke,ht.tags));continue}ft!=="LineString"&&ft!=="MultiLineString"||(qt.length===1?(ft="LineString",qt=qt[0]):ft="MultiLineString"),ft!=="Point"&&ft!=="MultiPoint"||(ft=qt.length===3?"Point":"MultiPoint"),rt.push(wi(ht.id,ft,qt,ht.tags))}}return rt.length?rt:null}function er(tt,k,R,B,W){for(let X=0;X<tt.length;X+=3){const nt=tt[X+W];nt>=R&&nt<=B&&_r(k,tt[X],tt[X+1],tt[X+2])}}function fr(tt,k,R,B,W,X,nt){let U=Me(tt);const rt=W===0?Kn:Yr;let ht,dt,ft=tt.start;for(let Yt=0;Yt<tt.length-3;Yt+=3){const ne=tt[Yt],de=tt[Yt+1],bt=tt[Yt+2],xe=tt[Yt+3],pe=tt[Yt+4],$e=W===0?ne:de,fe=W===0?xe:pe;let Tt=!1;nt&&(ht=Math.sqrt(Math.pow(ne-xe,2)+Math.pow(de-pe,2))),$e<R?fe>R&&(dt=rt(U,ne,de,xe,pe,R),nt&&(U.start=ft+ht*dt)):$e>B?fe<B&&(dt=rt(U,ne,de,xe,pe,B),nt&&(U.start=ft+ht*dt)):_r(U,ne,de,bt),fe<R&&$e>=R&&(dt=rt(U,ne,de,xe,pe,R),Tt=!0),fe>B&&$e<=B&&(dt=rt(U,ne,de,xe,pe,B),Tt=!0),!X&&Tt&&(nt&&(U.end=ft+ht*dt),k.push(U),U=Me(tt)),nt&&(ft+=ht)}let zt=tt.length-3;const jt=tt[zt],qt=tt[zt+1],ke=W===0?jt:qt;ke>=R&&ke<=B&&_r(U,jt,qt,tt[zt+2]),zt=U.length-3,X&&zt>=3&&(U[zt]!==U[0]||U[zt+1]!==U[1])&&_r(U,U[0],U[1],U[2]),U.length&&k.push(U)}function Me(tt){const k=[];return k.size=tt.size,k.start=tt.start,k.end=tt.end,k}function mr(tt,k,R,B,W,X){for(const nt of tt)fr(nt,k,R,B,W,X,!1)}function _r(tt,k,R,B){tt.push(k,R,B)}function Kn(tt,k,R,B,W,X){const nt=(X-k)/(B-k);return _r(tt,X,R+(W-R)*nt,1),nt}function Yr(tt,k,R,B,W,X){const nt=(X-R)/(W-R);return _r(tt,k+(B-k)*nt,X,1),nt}function gr(tt,k){const R=[];for(let B=0;B<tt.length;B++){const W=tt[B],X=W.type;let nt;if(X==="Point"||X==="MultiPoint"||X==="LineString")nt=Kr(W.geometry,k);else if(X==="MultiLineString"||X==="Polygon"){nt=[];for(const U of W.geometry)nt.push(Kr(U,k))}else if(X==="MultiPolygon"){nt=[];for(const U of W.geometry){const rt=[];for(const ht of U)rt.push(Kr(ht,k));nt.push(rt)}}R.push(wi(W.id,X,nt,W.tags))}return R}function Kr(tt,k){const R=[];R.size=tt.size,tt.start!==void 0&&(R.start=tt.start,R.end=tt.end);for(let B=0;B<tt.length;B+=3)R.push(tt[B]+k,tt[B+1],tt[B+2]);return R}function bn(tt,k){if(tt.transformed)return tt;const R=1<<tt.z,B=tt.x,W=tt.y;for(const X of tt.features){const nt=X.geometry,U=X.type;if(X.geometry=[],U===1)for(let rt=0;rt<nt.length;rt+=2)X.geometry.push(Ai(nt[rt],nt[rt+1],k,R,B,W));else for(let rt=0;rt<nt.length;rt++){const ht=[];for(let dt=0;dt<nt[rt].length;dt+=2)ht.push(Ai(nt[rt][dt],nt[rt][dt+1],k,R,B,W));X.geometry.push(ht)}}return tt.transformed=!0,tt}function Ai(tt,k,R,B,W,X){return[Math.round(R*(tt*B-W)),Math.round(R*(k*B-X))]}function La(tt,k,R,B,W){const X=k===W.maxZoom?0:W.tolerance/((1<<k)*W.extent),nt={features:[],numPoints:0,numSimplified:0,numFeatures:tt.length,source:null,x:R,y:B,z:k,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const U of tt)Fa(nt,U,X,W);return nt}function Fa(tt,k,R,B){const W=k.geometry,X=k.type,nt=[];if(tt.minX=Math.min(tt.minX,k.minX),tt.minY=Math.min(tt.minY,k.minY),tt.maxX=Math.max(tt.maxX,k.maxX),tt.maxY=Math.max(tt.maxY,k.maxY),X==="Point"||X==="MultiPoint")for(let U=0;U<W.length;U+=3)nt.push(W[U],W[U+1]),tt.numPoints++,tt.numSimplified++;else if(X==="LineString")wn(nt,W,tt,R,!1,!1);else if(X==="MultiLineString"||X==="Polygon")for(let U=0;U<W.length;U++)wn(nt,W[U],tt,R,X==="Polygon",U===0);else if(X==="MultiPolygon")for(let U=0;U<W.length;U++){const rt=W[U];for(let ht=0;ht<rt.length;ht++)wn(nt,rt[ht],tt,R,!0,ht===0)}if(nt.length){let U=k.tags||null;if(X==="LineString"&&B.lineMetrics){U={};for(const ht in k.tags)U[ht]=k.tags[ht];U.mapbox_clip_start=W.start/W.size,U.mapbox_clip_end=W.end/W.size}const rt={geometry:nt,type:X==="Polygon"||X==="MultiPolygon"?3:X==="LineString"||X==="MultiLineString"?2:1,tags:U};k.id!==null&&(rt.id=k.id),tt.features.push(rt)}}function wn(tt,k,R,B,W,X){const nt=B*B;if(B>0&&k.size<(W?nt:B))return void(R.numPoints+=k.length/3);const U=[];for(let rt=0;rt<k.length;rt+=3)(B===0||k[rt+2]>nt)&&(R.numSimplified++,U.push(k[rt],k[rt+1])),R.numPoints++;W&&function(rt,ht){let dt=0;for(let ft=0,zt=rt.length,jt=zt-2;ft<zt;jt=ft,ft+=2)dt+=(rt[ft]-rt[jt])*(rt[ft+1]+rt[jt+1]);if(dt>0===ht)for(let ft=0,zt=rt.length;ft<zt/2;ft+=2){const jt=rt[ft],qt=rt[ft+1];rt[ft]=rt[zt-2-ft],rt[ft+1]=rt[zt-1-ft],rt[zt-2-ft]=jt,rt[zt-1-ft]=qt}}(U,X),tt.push(U)}const Jn={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Jr{constructor(k,R){const B=(R=this.options=function(X,nt){for(const U in nt)X[U]=nt[U];return X}(Object.create(Jn),R)).debug;if(B&&console.time("preprocess data"),R.maxZoom<0||R.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(R.promoteId&&R.generateId)throw new Error("promoteId and generateId cannot be used together.");let W=function(X,nt){const U=[];if(X.type==="FeatureCollection")for(let rt=0;rt<X.features.length;rt++)di(U,X.features[rt],nt,rt);else di(U,X.type==="Feature"?X:{geometry:X},nt);return U}(k,R);this.tiles={},this.tileCoords=[],B&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",R.indexMaxZoom,R.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),W=function(X,nt){const U=nt.buffer/nt.extent;let rt=X;const ht=Pe(X,1,-1-U,U,0,-1,2,nt),dt=Pe(X,1,1-U,2+U,0,-1,2,nt);return(ht||dt)&&(rt=Pe(X,1,-U,1+U,0,-1,2,nt)||[],ht&&(rt=gr(ht,1).concat(rt)),dt&&(rt=rt.concat(gr(dt,-1)))),rt}(W,R),W.length&&this.splitTile(W,0,0,0),B&&(W.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(k,R,B,W,X,nt,U){const rt=[k,R,B,W],ht=this.options,dt=ht.debug;for(;rt.length;){W=rt.pop(),B=rt.pop(),R=rt.pop(),k=rt.pop();const ft=1<<R,zt=Qn(R,B,W);let jt=this.tiles[zt];if(!jt&&(dt>1&&console.time("creation"),jt=this.tiles[zt]=La(k,R,B,W,ht),this.tileCoords.push({z:R,x:B,y:W}),dt)){dt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",R,B,W,jt.numFeatures,jt.numPoints,jt.numSimplified),console.timeEnd("creation"));const Tt=`z${R}`;this.stats[Tt]=(this.stats[Tt]||0)+1,this.total++}if(jt.source=k,X==null){if(R===ht.indexMaxZoom||jt.numPoints<=ht.indexMaxPoints)continue}else{if(R===ht.maxZoom||R===X)continue;if(X!=null){const Tt=X-R;if(B!==nt>>Tt||W!==U>>Tt)continue}}if(jt.source=null,k.length===0)continue;dt>1&&console.time("clipping");const qt=.5*ht.buffer/ht.extent,ke=.5-qt,Yt=.5+qt,ne=1+qt;let de=null,bt=null,xe=null,pe=null,$e=Pe(k,ft,B-qt,B+Yt,0,jt.minX,jt.maxX,ht),fe=Pe(k,ft,B+ke,B+ne,0,jt.minX,jt.maxX,ht);k=null,$e&&(de=Pe($e,ft,W-qt,W+Yt,1,jt.minY,jt.maxY,ht),bt=Pe($e,ft,W+ke,W+ne,1,jt.minY,jt.maxY,ht),$e=null),fe&&(xe=Pe(fe,ft,W-qt,W+Yt,1,jt.minY,jt.maxY,ht),pe=Pe(fe,ft,W+ke,W+ne,1,jt.minY,jt.maxY,ht),fe=null),dt>1&&console.timeEnd("clipping"),rt.push(de||[],R+1,2*B,2*W),rt.push(bt||[],R+1,2*B,2*W+1),rt.push(xe||[],R+1,2*B+1,2*W),rt.push(pe||[],R+1,2*B+1,2*W+1)}}getTile(k,R,B){k=+k,R=+R,B=+B;const W=this.options,{extent:X,debug:nt}=W;if(k<0||k>24)return null;const U=1<<k,rt=Qn(k,R=R+U&U-1,B);if(this.tiles[rt])return bn(this.tiles[rt],X);nt>1&&console.log("drilling down to z%d-%d-%d",k,R,B);let ht,dt=k,ft=R,zt=B;for(;!ht&&dt>0;)dt--,ft>>=1,zt>>=1,ht=this.tiles[Qn(dt,ft,zt)];return ht&&ht.source?(nt>1&&(console.log("found parent tile z%d-%d-%d",dt,ft,zt),console.time("drilling down")),this.splitTile(ht.source,dt,ft,zt,k,R,B),nt>1&&console.timeEnd("drilling down"),this.tiles[rt]?bn(this.tiles[rt],X):null):null}}function Qn(tt,k,R){return 32*((1<<tt)*R+k)+tt}class Tn extends Ir{constructor(k,R,B,W=ir){super(k,R,B),this._dataUpdateable=new Map,this._createGeoJSONIndex=W}loadVectorTile(k,R){return D._(this,void 0,void 0,function*(){const B=k.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const W=this._geoJSONIndex.getTile(B.z,B.x,B.y);return W?Ci(new Ji(W.features,{version:2,extent:D.a4})):null})}loadData(k){return D._(this,void 0,void 0,function*(){var R;(R=this._pendingRequest)===null||R===void 0||R.abort();const B=this._startPerformance(k);this._pendingRequest=new AbortController;try{(!this._pendingData||k.request||k.data||k.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(k,this._pendingRequest));const W=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(W,k),this.loaded={};const X=k.dataDiff&&D.a6(W)?{applyDiff:!0}:{data:W};return this._finishPerformance(B,k,X),X}catch(W){if(delete this._pendingRequest,D.cH(W))return{abandoned:!0};throw W}})}_startPerformance(k){var R;if(!((R=k?.request)===null||R===void 0)&&R.collectResourceTiming)return new D.c$(k.request)}_finishPerformance(k,R,B){if(!k)return;const W=k.finish();W&&(B.resourceTiming={},B.resourceTiming[R.source]=JSON.parse(JSON.stringify(W)))}getData(){return D._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(k){const R=this.loaded;return R&&R[k.uid]?super.reloadTile(k):this.loadTile(k)}loadAndProcessGeoJSON(k,R){return D._(this,void 0,void 0,function*(){let B;if(k.request?B=yield this.loadGeoJSONFromUrl(k.request,k.promoteId,R):k.data?B=this._loadGeoJSONFromObject(k.data,k.promoteId):k.dataDiff&&(B=this._loadGeoJSONFromDiff(k.dataDiff,k.promoteId,k.source)),delete this._pendingRequest,typeof B!="object")throw new Error(`Input data given to '${k.source}' is not a valid GeoJSON object.`);return Da(B,!0),k.filter&&(B=this._filterGeoJSON(B,k.filter)),B})}loadGeoJSONFromUrl(k,R,B){return D._(this,void 0,void 0,function*(){const W=yield D.j(k,B);return this._dataUpdateable=D.a6(W.data,R)?D.a7(W.data,R):void 0,W.data})}_loadGeoJSONFromObject(k,R){return this._dataUpdateable=D.a6(k,R)?D.a7(k,R):void 0,k}_loadGeoJSONFromDiff(k,R,B){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${B}`);D.a8(this._dataUpdateable,k,R);const W=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(W)}_filterGeoJSON(k,R){const B=D.d3(R,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(B.result==="error")throw new Error(B.value.map(X=>`${X.key}: ${X.message}`).join(", "));const W=k.features.filter(X=>B.value.evaluate({zoom:0},X));return this._toFeatureCollection(W)}_toFeatureCollection(k){return{type:"FeatureCollection",features:k}}removeSource(k){return D._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(k){return this._geoJSONIndex.getClusterExpansionZoom(k.clusterId)}getClusterChildren(k){return this._geoJSONIndex.getChildren(k.clusterId)}getClusterLeaves(k){return this._geoJSONIndex.getLeaves(k.clusterId,k.limit,k.offset)}}function ir(tt,k){return k.cluster?new Ms(function({superclusterOptions:R,clusterProperties:B}){if(!B||!R)return R;const W={},X={},nt={accumulated:null,zoom:0},U={properties:null},rt=Object.keys(B);for(const ht of rt){const[dt,ft]=B[ht],zt=D.d3(ft),jt=D.d3(typeof dt=="string"?[dt,["accumulated"],["get",ht]]:dt);W[ht]=zt.value,X[ht]=jt.value}return R.map=ht=>{U.properties=ht;const dt={};for(const ft of rt)dt[ft]=W[ft].evaluate(nt,U);return dt},R.reduce=(ht,dt)=>{U.properties=dt;for(const ft of rt)nt.accumulated=ht[ft],ht[ft]=X[ft].evaluate(nt,U)},R}(k)).load(tt.features):function(R,B){return new Jr(R,B)}(tt,k.geojsonVtOptions)}class Oi{constructor(k){this.self=k,this.actor=new D.L(k),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(R,B)=>{if(this.externalWorkerSourceTypes[R])throw new Error(`Worker source with name "${R}" already registered.`);this.externalWorkerSourceTypes[R]=B},this.self.addProtocol=D.cJ,this.self.removeProtocol=D.cK,this.self.registerRTLTextPlugin=R=>{D.d4.setMethods(R)},this.actor.registerMessageHandler("LDT",(R,B)=>this._getDEMWorkerSource(R,B.source).loadTile(B)),this.actor.registerMessageHandler("RDT",(R,B)=>D._(this,void 0,void 0,function*(){this._getDEMWorkerSource(R,B.source).removeTile(B)})),this.actor.registerMessageHandler("GCEZ",(R,B)=>D._(this,void 0,void 0,function*(){return this._getWorkerSource(R,B.type,B.source).getClusterExpansionZoom(B)})),this.actor.registerMessageHandler("GCC",(R,B)=>D._(this,void 0,void 0,function*(){return this._getWorkerSource(R,B.type,B.source).getClusterChildren(B)})),this.actor.registerMessageHandler("GCL",(R,B)=>D._(this,void 0,void 0,function*(){return this._getWorkerSource(R,B.type,B.source).getClusterLeaves(B)})),this.actor.registerMessageHandler("LD",(R,B)=>this._getWorkerSource(R,B.type,B.source).loadData(B)),this.actor.registerMessageHandler("GD",(R,B)=>this._getWorkerSource(R,B.type,B.source).getData()),this.actor.registerMessageHandler("LT",(R,B)=>this._getWorkerSource(R,B.type,B.source).loadTile(B)),this.actor.registerMessageHandler("RT",(R,B)=>this._getWorkerSource(R,B.type,B.source).reloadTile(B)),this.actor.registerMessageHandler("AT",(R,B)=>this._getWorkerSource(R,B.type,B.source).abortTile(B)),this.actor.registerMessageHandler("RMT",(R,B)=>this._getWorkerSource(R,B.type,B.source).removeTile(B)),this.actor.registerMessageHandler("RS",(R,B)=>D._(this,void 0,void 0,function*(){if(!this.workerSources[R]||!this.workerSources[R][B.type]||!this.workerSources[R][B.type][B.source])return;const W=this.workerSources[R][B.type][B.source];delete this.workerSources[R][B.type][B.source],W.removeSource!==void 0&&W.removeSource(B)})),this.actor.registerMessageHandler("RM",R=>D._(this,void 0,void 0,function*(){delete this.layerIndexes[R],delete this.availableImages[R],delete this.workerSources[R],delete this.demWorkerSources[R],this.globalStates.delete(R)})),this.actor.registerMessageHandler("SR",(R,B)=>D._(this,void 0,void 0,function*(){this.referrer=B})),this.actor.registerMessageHandler("SRPS",(R,B)=>this._syncRTLPluginState(R,B)),this.actor.registerMessageHandler("IS",(R,B)=>D._(this,void 0,void 0,function*(){this.self.importScripts(B)})),this.actor.registerMessageHandler("SI",(R,B)=>this._setImages(R,B)),this.actor.registerMessageHandler("UL",(R,B)=>D._(this,void 0,void 0,function*(){this._getLayerIndex(R).update(B.layers,B.removedIds,this._getGlobalState(R))})),this.actor.registerMessageHandler("UGS",(R,B)=>D._(this,void 0,void 0,function*(){const W=this._getGlobalState(R);for(const X in B)W[X]=B[X]})),this.actor.registerMessageHandler("SL",(R,B)=>D._(this,void 0,void 0,function*(){this._getLayerIndex(R).replace(B,this._getGlobalState(R))}))}_getGlobalState(k){let R=this.globalStates.get(k);return R||(R={},this.globalStates.set(k,R)),R}_setImages(k,R){return D._(this,void 0,void 0,function*(){this.availableImages[k]=R;for(const B in this.workerSources[k]){const W=this.workerSources[k][B];for(const X in W)W[X].availableImages=R}})}_syncRTLPluginState(k,R){return D._(this,void 0,void 0,function*(){return yield D.d4.syncState(R,this.self.importScripts)})}_getAvailableImages(k){let R=this.availableImages[k];return R||(R=[]),R}_getLayerIndex(k){let R=this.layerIndexes[k];return R||(R=this.layerIndexes[k]=new h),R}_getWorkerSource(k,R,B){if(this.workerSources[k]||(this.workerSources[k]={}),this.workerSources[k][R]||(this.workerSources[k][R]={}),!this.workerSources[k][R][B]){const W={sendAsync:(X,nt)=>(X.targetMapId=k,this.actor.sendAsync(X,nt))};switch(R){case"vector":this.workerSources[k][R][B]=new Ir(W,this._getLayerIndex(k),this._getAvailableImages(k));break;case"geojson":this.workerSources[k][R][B]=new Tn(W,this._getLayerIndex(k),this._getAvailableImages(k));break;default:this.workerSources[k][R][B]=new this.externalWorkerSourceTypes[R](W,this._getLayerIndex(k),this._getAvailableImages(k))}}return this.workerSources[k][R][B]}_getDEMWorkerSource(k,R){return this.demWorkerSources[k]||(this.demWorkerSources[k]={}),this.demWorkerSources[k][R]||(this.demWorkerSources[k][R]=new $r),this.demWorkerSources[k][R]}}return D.i(self)&&(self.worker=new Oi(self)),Oi}),se("index",["exports","./shared"],function(D,h){var It="5.13.0";function si(){var d=new h.A(4);return h.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}let Ve,dr,Ji;const Ze={frame(d,e,n){const o=requestAnimationFrame(p=>{c(),e(p)}),{unsubscribe:c}=h.s(d.signal,"abort",()=>{c(),cancelAnimationFrame(o),n(h.c())},!1)},frameAsync(d){return new Promise((e,n)=>{this.frame(d,e,n)})},getImageData(d,e=0){return this.getImageCanvasContext(d).getImageData(-e,-e,d.width+2*e,d.height+2*e)},getImageCanvasContext(d){const e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=d.width,e.height=d.height,n.drawImage(d,0,0,d.width,d.height),n},resolveURL:d=>(Ve||(Ve=document.createElement("a")),Ve.href=d,Ve.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return Ji!==void 0?Ji:!!matchMedia&&(dr==null&&(dr=matchMedia("(prefers-reduced-motion: reduce)")),dr.matches)},set prefersReducedMotion(d){Ji=d}},Zr=new class{constructor(){this._realTime=typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return this._frozenAt!==null?this._frozenAt:this._realTime()}setNow(d){this._frozenAt=d}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function ie(){return Zr.getCurrentTime()}class pt{static testProp(e){if(!pt.docStyle)return e[0];for(let n=0;n<e.length;n++)if(e[n]in pt.docStyle)return e[n];return e[0]}static create(e,n,o){const c=window.document.createElement(e);return n!==void 0&&(c.className=n),o&&o.appendChild(c),c}static createNS(e,n){return window.document.createElementNS(e,n)}static disableDrag(){pt.docStyle&&pt.selectProp&&(pt.userSelect=pt.docStyle[pt.selectProp],pt.docStyle[pt.selectProp]="none")}static enableDrag(){pt.docStyle&&pt.selectProp&&(pt.docStyle[pt.selectProp]=pt.userSelect)}static setTransform(e,n){e.style[pt.transformProp]=n}static addEventListener(e,n,o,c={}){e.addEventListener(n,o,"passive"in c?c:c.capture)}static removeEventListener(e,n,o,c={}){e.removeEventListener(n,o,"passive"in c?c:c.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",pt.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",pt.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",pt.suppressClickInternal,!0)},0)}static getScale(e){const n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,o){const c=n.boundingClientRect;return new h.P((o.clientX-c.left)/n.x-e.clientLeft,(o.clientY-c.top)/n.y-e.clientTop)}static mousePos(e,n){const o=pt.getScale(e);return pt.getPoint(e,o,n)}static touchPos(e,n){const o=[],c=pt.getScale(e);for(let p=0;p<n.length;p++)o.push(pt.getPoint(e,c,n[p]));return o}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){const n=new DOMParser().parseFromString(e,"text/html").body||document.createElement("body"),o=n.querySelectorAll("script");for(const c of o)c.remove();return pt.clean(n),n.innerHTML}static isPossiblyDangerous(e,n){const o=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!o.includes("javascript:")&&!o.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const n=e.children;for(const o of n)pt.removeAttributes(o),pt.clean(o)}static removeAttributes(e){for(const{name:n,value:o}of e.attributes)pt.isPossiblyDangerous(n,o)&&e.removeAttribute(n)}}pt.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,pt.selectProp=pt.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),pt.transformProp=pt.testProp(["transform","WebkitTransform"]);const _n={supported:!1,testSupport:function(d){!Wn&&Se&&(Hn?Aa(d):ze=d)}};let ze,Se,Wn=!1,Hn=!1;function Aa(d){const e=d.createTexture();d.bindTexture(d.TEXTURE_2D,e);try{if(d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,Se),d.isContextLost())return;_n.supported=!0}catch{}d.deleteTexture(e),Wn=!0}var Ci;typeof document<"u"&&(Se=document.createElement("img"),Se.onload=()=>{ze&&Aa(ze),ze=null,Hn=!0},Se.onerror=()=>{Wn=!0,ze=null},Se.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(d){let e,n,o,c;d.resetRequestQueue=()=>{e=[],n=0,o=0,c={}},d.addThrottleControl=x=>{const b=o++;return c[b]=x,b},d.removeThrottleControl=x=>{delete c[x],m()},d.getImage=(x,b,T=!0)=>new Promise((E,I)=>{_n.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),h.e(x,{type:"image"}),e.push({abortController:b,requestParameters:x,supportImageRefresh:T,state:"queued",onError:A=>{I(A)},onSuccess:A=>{E(A)}}),m()});const p=x=>h._(this,void 0,void 0,function*(){x.state="running";const{requestParameters:b,supportImageRefresh:T,onError:E,onSuccess:I,abortController:A}=x,L=T===!1&&!h.i(self)&&!h.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce((G,q)=>G&&q==="accept",!0));n++;const j=L?g(b,A):h.m(b,A);try{const G=yield j;delete x.abortController,x.state="completed",G.data instanceof HTMLImageElement||h.b(G.data)?I(G):G.data&&I({data:yield(V=G.data,typeof createImageBitmap=="function"?h.f(V):h.h(V)),cacheControl:G.cacheControl,expires:G.expires})}catch(G){delete x.abortController,E(G)}finally{n--,m()}var V}),m=()=>{const x=(()=>{for(const b of Object.keys(c))if(c[b]())return!0;return!1})()?h.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:h.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b<x&&e.length>0;b++){const T=e.shift();T.abortController.signal.aborted?b--:p(T)}},g=(x,b)=>new Promise((T,E)=>{const I=new Image,A=x.url,L=x.credentials;L&&L==="include"?I.crossOrigin="use-credentials":(L&&L==="same-origin"||!h.d(A))&&(I.crossOrigin="anonymous"),b.signal.addEventListener("abort",()=>{I.src="",E(h.c())}),I.fetchPriority="high",I.onload=()=>{I.onerror=I.onload=null,T({data:I})},I.onerror=()=>{I.onerror=I.onload=null,b.signal.aborted||E(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."))},I.src=A})}(Ci||(Ci={})),Ci.resetRequestQueue();class Ps{constructor(e){this._transformRequestFn=e??null}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Ir(d){const e=[];if(typeof d=="string")e.push({id:"default",url:d});else if(d&&d.length>0){const n=[];for(const{id:o,url:c}of d){const p=`${o}${c}`;n.indexOf(p)===-1&&(n.push(p),e.push({id:o,url:c}))}}return e}function $r(d,e,n){try{const o=new URL(d);return o.pathname+=`${e}${n}`,o.toString()}catch{throw new Error(`Invalid sprite URL "${d}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function gn(d){const{userImage:e}=d;return!!(e&&e.render&&e.render())&&(d.data.replace(new Uint8Array(e.data.buffer)),!0)}class qr extends h.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new h.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new h.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:n,promiseResolve:o}of this.requestors)o(this._getImagesForIds(n));this.requestors=[]}}getImage(e){const n=this.images[e];if(n&&!n.data&&n.spriteData){const o=n.spriteData;n.data=new h.R({width:o.width,height:o.height},o.context.getImageData(o.x,o.y,o.width,o.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let o=!0;const c=n.data||n.spriteData;return this._validateStretch(n.stretchX,c&&c.width)||(this.fire(new h.k(new Error(`Image "${e}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,c&&c.height)||(this.fire(new h.k(new Error(`Image "${e}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new h.k(new Error(`Image "${e}" has invalid "content" value`))),o=!1),o}_validateStretch(e,n){if(!e)return!0;let o=0;for(const c of e){if(c[0]<o||c[1]<c[0]||n<c[1])return!1;o=c[1]}return!0}_validateContent(e,n){if(!e)return!0;if(e.length!==4)return!1;const o=n.spriteData,c=o&&o.width||n.data.width,p=o&&o.height||n.data.height;return!(e[0]<0||c<e[0]||e[1]<0||p<e[1]||e[2]<0||c<e[2]||e[3]<0||p<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,n,o=!0){const c=this.getImage(e);if(o&&(c.data.width!==n.data.width||c.data.height!==n.data.height))throw new Error(`size mismatch between old image (${c.data.width}x${c.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=c.version+1,this.images[e]=n,this.updatedImages[e]=!0}removeImage(e){const n=this.images[e];delete this.images[e],delete this.patterns[e],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise((n,o)=>{let c=!0;if(!this.isLoaded())for(const p of e)this.images[p]||(c=!1);this.isLoaded()||c?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){const n={};for(const o of e){let c=this.getImage(o);c||(this.fire(new h.l("styleimagemissing",{id:o})),c=this.getImage(o)),c?n[o]={data:c.data.clone(),pixelRatio:c.pixelRatio,sdf:c.sdf,version:c.version,stretchX:c.stretchX,stretchY:c.stretchY,content:c.content,textFitWidth:c.textFitWidth,textFitHeight:c.textFitHeight,hasRenderCallback:!!(c.userImage&&c.userImage.render)}:h.w(`Image "${o}" 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 n}getPixelSize(){const{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){const n=this.patterns[e],o=this.getImage(e);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{const c={w:o.data.width+2,h:o.data.height+2,x:0,y:0},p=new h.I(c,o);this.patterns[e]={bin:c,position:p}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new h.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const p in this.patterns)e.push(this.patterns[p].bin);const{w:n,h:o}=h.p(e),c=this.atlasImage;c.resize({width:n||1,height:o||1});for(const p in this.patterns){const{bin:m}=this.patterns[p],g=m.x+1,x=m.y+1,b=this.getImage(p).data,T=b.width,E=b.height;h.R.copy(b,c,{x:0,y:0},{x:g,y:x},{width:T,height:E}),h.R.copy(b,c,{x:0,y:E-1},{x:g,y:x-1},{width:T,height:1}),h.R.copy(b,c,{x:0,y:0},{x:g,y:x+E},{width:T,height:1}),h.R.copy(b,c,{x:T-1,y:0},{x:g-1,y:x},{width:1,height:E}),h.R.copy(b,c,{x:0,y:0},{x:g+T,y:x},{width:1,height:E})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const o=this.getImage(n);o||h.w(`Image with ID: "${n}" was not found`),gn(o)&&this.updateImage(n,o)}}cloneImages(){const e={};for(const n in this.images){const o=this.images[n];e[n]=Object.assign(Object.assign({},o),{data:o.data?o.data.clone():null})}return e}}const yn=1e20;function Da(d,e,n,o,c,p,m,g,x){for(let b=e;b<e+o;b++)za(d,n*p+b,p,c,m,g,x);for(let b=n;b<n+c;b++)za(d,b*p+e,1,o,m,g,x)}function za(d,e,n,o,c,p,m){p[0]=0,m[0]=-yn,m[1]=yn,c[0]=d[e];for(let g=1,x=0,b=0;g<o;g++){c[g]=d[e+g*n];const T=g*g;do{const E=p[x];b=(c[g]-c[E]+T-E*E)/(g-E)/2}while(b<=m[x]&&--x>-1);x++,p[x]=g,m[x]=b,m[x+1]=yn}for(let g=0,x=0;g<o;g++){for(;m[x+1]<g;)x++;const b=p[x],T=g-b;d[e+g*n]=c[b]+T*T}}const ka=h.v.layout_symbol["text-font"].default.join(",");class Qi{constructor(e,n,o){this.requestManager=e,this.localIdeographFontFamily=n,this.entries={},this.lang=o}setURL(e){this.url=e}getGlyphs(e){return h._(this,void 0,void 0,function*(){const n=[];for(const p in e)for(const m of e[p])n.push(this._getAndCacheGlyphsPromise(p,m));const o=yield Promise.all(n),c={};for(const{stack:p,id:m,glyph:g}of o)c[p]||(c[p]={}),c[p][m]=g&&{id:g.id,bitmap:g.bitmap.clone(),metrics:g.metrics};return c})}_getAndCacheGlyphsPromise(e,n){return h._(this,void 0,void 0,function*(){let o=this.entries[e];o||(o=this.entries[e]={glyphs:{},requests:{},ranges:{}});let c=o.glyphs[n];return c!==void 0?{stack:e,id:n,glyph:c}:!this.url||this._charUsesLocalIdeographFontFamily(n)?(c=o.glyphs[n]=this._drawGlyph(o,e,n),{stack:e,id:n,glyph:c}):yield this._downloadAndCacheRangePromise(e,n)})}_downloadAndCacheRangePromise(e,n){return h._(this,void 0,void 0,function*(){const o=this.entries[e],c=Math.floor(n/256);if(o.ranges[c])return{stack:e,id:n,glyph:null};if(!o.requests[c]){const p=Qi.loadGlyphRange(e,c,this.url,this.requestManager);o.requests[c]=p}try{const p=yield o.requests[c];for(const m in p)o.glyphs[+m]=p[+m];return o.ranges[c]=!0,{stack:e,id:n,glyph:p[n]||null}}catch(p){const m=o.glyphs[n]=this._drawGlyph(o,e,n);return this._warnOnMissingGlyphRange(m,c,n,p),{stack:e,id:n,glyph:m}}})}_warnOnMissingGlyphRange(e,n,o,c){const p=256*n,m=p+255,g=o.toString(16).padStart(4,"0").toUpperCase();h.w(`Unable to load glyph range ${n}, ${p}-${m}. Rendering codepoint U+${g} locally instead. ${c}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&h.q(e)}_drawGlyph(e,n,o){const c=n===ka&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(o),p=c?"ideographTinySDF":"tinySDF";e[p]||(e[p]=this._createTinySDF(c?this.localIdeographFontFamily:n));const m=e[p].draw(String.fromCodePoint(o));return{id:o,bitmap:new h.r({width:m.width||60,height:m.height||60},m.data),metrics:{width:m.glyphWidth/2||24,height:m.glyphHeight/2||24,left:m.glyphLeft/2+.5||0,top:m.glyphTop/2-27.5||-8,advance:m.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){const n=e?e.split(","):[];n.push("sans-serif");const o=n.map(c=>/[-\w]+/.test(c)?c:`'${CSS.escape(c)}'`).join(",");return new Qi.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:this._fontWeight(n[0]),fontStyle:this._fontStyle(n[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const n={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 o;for(const[c,p]of Object.entries(n))new RegExp(`\\b${c}\\b`,"i").test(e)&&(o=`${p}`);return o}destroy(){for(const e in this.entries){const n=this.entries[e];n.tinySDF&&(n.tinySDF=null),n.ideographTinySDF&&(n.ideographTinySDF=null),n.glyphs={},n.requests={},n.ranges={}}this.entries={}}}Qi.loadGlyphRange=function(d,e,n,o){return h._(this,void 0,void 0,function*(){const c=256*e,p=c+255,m=o.transformRequest(n.replace("{fontstack}",d).replace("{range}",`${c}-${p}`),"Glyphs"),g=yield h.n(m,new AbortController);if(!g||!g.data)throw new Error(`Could not load glyph range. range: ${e}, ${c}-${p}`);const x={};for(const b of h.o(g.data))x[b.id]=b;return x})},Qi.TinySDF=class{constructor({fontSize:d=24,buffer:e=3,radius:n=8,cutoff:o=.25,fontFamily:c="sans-serif",fontWeight:p="normal",fontStyle:m="normal",lang:g=null}={}){this.buffer=e,this.cutoff=o,this.radius=n,this.lang=g;const x=this.size=d+4*e,b=this._createCanvas(x),T=this.ctx=b.getContext("2d",{willReadFrequently:!0});T.font=`${m} ${p} ${d}px ${c}`,T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(x*x),this.gridInner=new Float64Array(x*x),this.f=new Float64Array(x),this.z=new Float64Array(x+1),this.v=new Uint16Array(x)}_createCanvas(d){const e=document.createElement("canvas");return e.width=e.height=d,e}draw(d){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:c,actualBoundingBoxRight:p}=this.ctx.measureText(d),m=Math.ceil(n),g=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-c))),x=Math.min(this.size-this.buffer,m+Math.ceil(o)),b=g+2*this.buffer,T=x+2*this.buffer,E=Math.max(b*T,0),I=new Uint8ClampedArray(E),A={data:I,width:b,height:T,glyphWidth:g,glyphHeight:x,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(g===0||x===0)return A;const{ctx:L,buffer:j,gridInner:V,gridOuter:G}=this;this.lang&&(L.lang=this.lang),L.clearRect(j,j,g,x),L.fillText(d,j,j+m);const q=L.getImageData(j,j,g,x);G.fill(yn,0,E),V.fill(0,0,E);for(let Y=0;Y<x;Y++)for(let $=0;$<g;$++){const K=q.data[4*(Y*g+$)+3]/255;if(K===0)continue;const J=(Y+j)*b+$+j;if(K===1)G[J]=0,V[J]=yn;else{const H=.5-K;G[J]=H>0?H*H:0,V[J]=H<0?H*H:0}}Da(G,0,0,b,T,b,this.f,this.v,this.z),Da(V,j,j,g,x,b,this.f,this.v,this.z);for(let Y=0;Y<E;Y++){const $=Math.sqrt(G[Y])-Math.sqrt(V[Y]);I[Y]=Math.round(255-255*($/this.radius+this.cutoff))}return A}};class Ms{constructor(){this.specification=h.u.light.position}possiblyEvaluate(e,n){return h.F(e.expression.evaluate(n))}interpolate(e,n,o){return{x:h.G.number(e.x,n.x,o),y:h.G.number(e.y,n.y,o),z:h.G.number(e.z,n.z,o)}}}let oe;class Xn extends h.E{constructor(e){super(),oe=oe||new h.t({anchor:new h.D(h.u.light.anchor),position:new Ms,color:new h.D(h.u.light.color),intensity:new h.D(h.u.light.intensity)}),this._transitionable=new h.x(oe,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(h.y,e,n))for(const o in e){const c=e[o];o.endsWith(h.z)?this._transitionable.setTransition(o.slice(0,-h.z.length),c):this._transitionable.setValue(o,c)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o){return(!o||o.validate!==!1)&&h.B(this,e.call(h.C,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:h.u}))}}const pr=new h.t({"sky-color":new h.D(h.u.sky["sky-color"]),"horizon-color":new h.D(h.u.sky["horizon-color"]),"fog-color":new h.D(h.u.sky["fog-color"]),"fog-ground-blend":new h.D(h.u.sky["fog-ground-blend"]),"horizon-fog-blend":new h.D(h.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new h.D(h.u.sky["sky-horizon-blend"]),"atmosphere-blend":new h.D(h.u.sky["atmosphere-blend"])});class xn extends h.E{constructor(e){super(),this._transitionable=new h.x(pr,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new h.H(0))}setSky(e,n={}){if(!this._validate(h.J,e,n)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const o in e){const c=e[o];o.endsWith(h.z)?this._transitionable.setTransition(o.slice(0,-h.z.length),c):this._transitionable.setValue(o,c)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o={}){return o?.validate!==!1&&h.B(this,e.call(h.C,h.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:h.u})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class Is{constructor(e,n){this.width=e,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,n){const o=e.join(",")+String(n);return this.dashEntry[o]||(this.dashEntry[o]=this.addDash(e,n)),this.dashEntry[o]}getDashRanges(e,n,o){const c=[];let p=e.length%2==1?-e[e.length-1]*o:0,m=e[0]*o,g=!0;c.push({left:p,right:m,isDash:g,zeroLength:e[0]===0});let x=e[0];for(let b=1;b<e.length;b++){g=!g;const T=e[b];p=x*o,x+=T,m=x*o,c.push({left:p,right:m,isDash:g,zeroLength:T===0})}return c}addRoundDash(e,n,o){const c=n/2;for(let p=-o;p<=o;p++){const m=this.width*(this.nextRow+o+p);let g=0,x=e[g];for(let b=0;b<this.width;b++){b/x.right>1&&(x=e[++g]);const T=Math.abs(b-x.left),E=Math.abs(b-x.right),I=Math.min(T,E);let A;const L=p/o*(c+1);if(x.isDash){const j=c-Math.abs(L);A=Math.sqrt(I*I+j*j)}else A=c-Math.sqrt(I*I+L*L);this.data[m+b]=Math.max(0,Math.min(255,A+128))}}}addRegularDash(e){for(let g=e.length-1;g>=0;--g){const x=e[g],b=e[g+1];x.zeroLength?e.splice(g,1):b&&b.isDash===x.isDash&&(b.left=x.left,e.splice(g,1))}const n=e[0],o=e[e.length-1];n.isDash===o.isDash&&(n.left=o.left-this.width,o.right=n.right+this.width);const c=this.width*this.nextRow;let p=0,m=e[p];for(let g=0;g<this.width;g++){g/m.right>1&&(m=e[++p]);const x=Math.abs(g-m.left),b=Math.abs(g-m.right),T=Math.min(x,b);this.data[c+g]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(e,n){const o=n?7:0,c=2*o+1;if(this.nextRow+c>this.height)return h.w("LineAtlas out of space"),null;let p=0;for(let g=0;g<e.length;g++)p+=e[g];if(p!==0){const g=this.width/p,x=this.getDashRanges(e,this.width,g);n?this.addRoundDash(x,g,o):this.addRegularDash(x)}const m={y:this.nextRow+o,height:2*o,width:p};return this.nextRow+=c,this.dirty=!0,m}bind(e){const n=e.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const Wr="maplibre_preloaded_worker_pool";class Hr{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Hr.workerCount;)this.workers.push(new Worker(h.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.numActive()===0&&(this.workers.forEach(n=>{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Wr]}numActive(){return Object.keys(this.active).length}}const wi=Math.floor(Ze.hardwareConcurrency/2);let tr,di;function Yn(){return tr||(tr=new Hr),tr}Hr.workerCount=h.K(globalThis)?Math.max(Math.min(wi,3),1):1;class Xr{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;const o=this.workerPool.acquire(n);for(let c=0;c<o.length;c++){const p=new h.L(o[c],n);p.name=`Worker ${c}`,this.actors.push(p)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,n){const o=[];for(const c of this.actors)o.push(c.sendAsync({type:e,data:n}));return Promise.all(o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(const o of this.actors)o.registerMessageHandler(e,n)}unregisterMessageHandler(e){for(const n of this.actors)n.unregisterMessageHandler(e)}}function vn(){return di||(di=new Xr(Yn(),h.M),di.registerMessageHandler("GR",(d,e,n)=>h.m(e,n))),di}function Zi(d,e){const n=h.N();return h.O(n,n,[1,1,0]),h.Q(n,n,[.5*d.width,.5*d.height,1]),d.calculatePosMatrix?h.S(n,n,d.calculatePosMatrix(e.toUnwrapped())):n}function Ra(d,e,n,o,c,p,m){var g;const x=function(I,A,L){if(I)for(const j of I){const V=A[j];if(V&&V.source===L&&V.type==="fill-extrusion")return!0}else for(const j in A){const V=A[j];if(V.source===L&&V.type==="fill-extrusion")return!0}return!1}((g=c?.layers)!==null&&g!==void 0?g:null,e,d.id),b=p.maxPitchScaleFactor(),T=d.tilesIn(o,b,x);T.sort(Pe);const E=[];for(const I of T)E.push({wrappedTileID:I.tileID.wrapped().key,queryResults:I.tile.queryRenderedFeatures(e,n,d.getState(),I.queryGeometry,I.cameraQueryGeometry,I.scale,c,p,b,Zi(p,I.tileID),m?(A,L)=>m(I.tileID,A,L):void 0)});return function(I,A){for(const L in I)for(const j of I[L])er(j,A);return I}(function(I){const A={},L={};for(const j of I){const V=j.queryResults,G=j.wrappedTileID,q=L[G]=L[G]||{};for(const Y in V){const $=V[Y],K=q[Y]=q[Y]||{},J=A[Y]=A[Y]||[];for(const H of $)K[H.featureIndex]||(K[H.featureIndex]=!0,J.push(H))}}return A}(E),d)}function Pe(d,e){const n=d.tileID,o=e.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function er(d,e){const n=d.feature,o=e.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}function fr(d,e,n){return h._(this,void 0,void 0,function*(){let o=d;if(d.url?o=(yield h.j(e.transformRequest(d.url,"Source"),n)).data:yield Ze.frameAsync(n),!o)return null;const c=h.U(h.e(o,d),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in o&&o.vector_layers&&(c.vectorLayerIds=o.vector_layers.map(p=>p.id)),c})}class Me{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof h.V?new h.V(e.lng,e.lat):h.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof h.V?new h.V(e.lng,e.lat):h.V.convert(e),this}extend(e){const n=this._sw,o=this._ne;let c,p;if(e instanceof h.V)c=e,p=e;else{if(!(e instanceof Me))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Me.convert(e)):this.extend(h.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(h.V.convert(e)):this;if(c=e._sw,p=e._ne,!c||!p)return this}return n||o?(n.lng=Math.min(c.lng,n.lng),n.lat=Math.min(c.lat,n.lat),o.lng=Math.max(p.lng,o.lng),o.lat=Math.max(p.lat,o.lat)):(this._sw=new h.V(c.lng,c.lat),this._ne=new h.V(p.lng,p.lat)),this}getCenter(){return new h.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 h.V(this.getWest(),this.getNorth())}getSouthEast(){return new h.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(e){const{lng:n,lat:o}=h.V.convert(e);let c=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&c}intersects(e){if((e=Me.convert(e)).getNorth()<this.getSouth()||e.getSouth()>this.getNorth())return!1;const n=h.W(this.getWest(),-180,180),o=h.W(this.getEast(),-180,180),c=h.W(e.getWest(),-180,180),p=h.W(e.getEast(),-180,180),m=n>o,g=c>p;return!(!m||!g)||(m?p>=n||c<=o:g?o>=c||n<=p:!(c>o||p<n))}static convert(e){return e instanceof Me?e:e&&new Me(e)}static fromLngLat(e,n=0){const o=360*n/40075017,c=o/Math.cos(Math.PI/180*e.lat);return new Me(new h.V(e.lng-c,e.lat-o),new h.V(e.lng+c,e.lat+o))}adjustAntiMeridian(){const e=new h.V(this._sw.lng,this._sw.lat),n=new h.V(this._ne.lng,this._ne.lat);return new Me(e,e.lng>n.lng?new h.V(n.lng+360,n.lat):n)}}class mr{constructor(e,n,o){this.bounds=Me.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const n=Math.pow(2,e.z),o=Math.floor(h.Y(this.bounds.getWest())*n),c=Math.floor(h.X(this.bounds.getNorth())*n),p=Math.ceil(h.Y(this.bounds.getEast())*n),m=Math.ceil(h.X(this.bounds.getSouth())*n);return e.x>=o&&e.x<p&&e.y>=c&&e.y<m}}class _r extends h.E{constructor(e,n,o,c){if(super(),this.id=e,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,h.e(this,h.U(n,["url","scheme","tileSize","promoteId","encoding"])),this._options=h.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}load(){return h._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new h.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield fr(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),e&&(h.e(this,e),e.bounds&&(this.tileBounds=new mr(e.bounds,this.minzoom,this.maxzoom)),this.fire(new h.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.l("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new h.k(e))}})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return h.e({},this._options)}loadTile(e){return h._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.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(e)};o.request.collectResourceTiming=this._collectResourceTiming;let c="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((p,m)=>{e.reloadPromise={resolve:p,reject:m}})}else e.actor=this.dispatcher.getActor(),c="LT";e.abortController=new AbortController;try{const p=yield e.actor.sendAsync({type:c,data:o},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,p)}catch(p){if(delete e.abortController,e.aborted)return;if(p&&p.status!==404)throw p;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;const n=e.tileID.scaledTo(this.maxzoom).canonical,o=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:this.map._requestManager.transformRequest(o,"Tile")}}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){const o=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(o.resolve).catch(o.reject)}}abortTile(e){return h._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return h._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Kn extends h.E{constructor(e,n,o,c){super(),this.id=e,this.dispatcher=o,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=h.e({type:"raster"},n),h.e(this,h.U(n,["url","scheme","tileSize"]))}load(){return h._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new h.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield fr(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(h.e(this,n),n.bounds&&(this.tileBounds=new mr(n.bounds,this.minzoom,this.maxzoom)),this.fire(new h.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(n){this._tileJSONRequest=null,this._loaded=!0,this.fire(new h.k(n))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return h.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return h._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const o=yield Ci.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){this.map._refreshExpiredTiles&&(o.cacheControl||o.expires)&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const c=this.map.painter.context,p=c.gl,m=o.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new h.T(c,m,p.RGBA,{useMipmap:!0}),e.texture.bind(p.LINEAR,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}})}abortTile(e){return h._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return h._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Yr extends Kn{constructor(e,n,o,c){super(e,n,o,c),this.type="raster-dem",this.maxzoom=22,this._options=h.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return h._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const c=yield Ci.getImage(o,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(c&&c.data){const p=c.data;this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&e.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const m=h.b(p)&&h.Z()?p:yield this.readImageNow(p),g={type:this.type,uid:e.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();const x=yield e.actor.sendAsync({type:"LDT",data:g});e.dem=x,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(c){if(delete e.abortController,e.aborted)e.state="unloaded";else if(c)throw e.state="errored",c}})}readImageNow(e){return h._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&h.$()){const n=e.width+2,o=e.height+2;try{return new h.R({width:n,height:o},yield h.a0(e,-1,-1,n,o))}catch{}}return Ze.getImageData(e,1)})}_getNeighboringTiles(e){const n=e.canonical,o=Math.pow(2,n.z),c=(n.x-1+o)%o,p=n.x===0?e.wrap-1:e.wrap,m=(n.x+1+o)%o,g=n.x+1===o?e.wrap+1:e.wrap,x={};return x[new h.a1(e.overscaledZ,p,n.z,c,n.y).key]={backfilled:!1},x[new h.a1(e.overscaledZ,g,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(x[new h.a1(e.overscaledZ,p,n.z,c,n.y-1).key]={backfilled:!1},x[new h.a1(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},x[new h.a1(e.overscaledZ,g,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<o&&(x[new h.a1(e.overscaledZ,p,n.z,c,n.y+1).key]={backfilled:!1},x[new h.a1(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},x[new h.a1(e.overscaledZ,g,n.z,m,n.y+1).key]={backfilled:!1}),x}unloadTile(e){return h._(this,void 0,void 0,function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))})}}function gr(d){return d.type==="GeometryCollection"?d.geometries.map(e=>e.coordinates).flat(1/0):d.coordinates.flat(1/0)}function Kr(d){const e=new Me;let n;switch(d.type){case"FeatureCollection":n=d.features.map(o=>gr(o.geometry)).flat(1/0);break;case"Feature":n=gr(d.geometry);break;default:n=gr(d)}if(n.length==0)return e;for(let o=0;o<n.length-1;o+=2)e.extend([n[o],n[o+1]]);return e}class bn extends h.E{constructor(e,n,o,c){super(),this.id=e,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:n.data},this.actor=o.getActor(),this.setEventedParent(c),this._data=typeof n.data=="string"?{url:n.data}:{geojson:n.data},this._options=h.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&h.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=h.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:h.a4,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:h.a4,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(e){return e*(h.a4/this.tileSize)}_getClusterMaxZoom(e){const n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||h.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return h._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e,n){this._data=typeof e=="string"?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};const o=this._updateWorkerData();return n?o:this}updateData(e,n){this._pendingWorkerUpdate.diff=h.a5(this._pendingWorkerUpdate.diff,e);const o=this._updateWorkerData();return n?o:this}getData(){return h._(this,void 0,void 0,function*(){const e=h.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})})}getBounds(){return h._(this,void 0,void 0,function*(){return Kr(yield this.getData())})}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,n,o){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:n,offset:o}})}_updateWorkerData(){return h._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void h.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:e,diff:n}=this._pendingWorkerUpdate,o=h.e({type:this.type},this.workerOptions);e?(typeof e=="string"?(o.request=this.map._requestManager.transformRequest(Ze.resolveURL(e),"Source"),o.request.collectResourceTiming=this._collectResourceTiming):o.data=e,this._pendingWorkerUpdate.data=void 0):n&&(o.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,this._isUpdatingWorker=!0,this.fire(new h.l("dataloading",{dataType:"source"}));try{const c=yield this.actor.sendAsync({type:"LD",data:o});if(this._isUpdatingWorker=!1,this._removed||c.abandoned)return void this.fire(new h.l("dataabort",{dataType:"source"}));c.applyDiff?this._applyDiff(n):this._data={geojson:c.data};let p=null;c.resourceTiming&&c.resourceTiming[this.id]&&(p=c.resourceTiming[this.id].slice(0));const m={dataType:"source"};this._collectResourceTiming&&p&&p.length>0&&h.e(m,{resourceTiming:p}),this.fire(new h.l("data",Object.assign(Object.assign({},m),{sourceDataType:"metadata"}))),this.fire(new h.l("data",Object.assign(Object.assign({},m),{sourceDataType:"content",shouldReloadTileOptions:this._getShouldReloadTileOptions(n)})))}catch(c){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new h.l("dataabort",{dataType:"source"}));this.fire(new h.k(c))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyDiff(e){const n=typeof this.promoteId=="string"?this.promoteId:void 0;this._data.url||this._data.updateable||!h.a6(this._data.geojson,n)||(this._data={updateable:h.a7(this._data.geojson,n)}),e&&this._data.updateable?h.a8(this._data.updateable,e,n):h.w("Cannot apply GeoJSONSource#updateData due to internal error")}_getShouldReloadTileOptions(e){if(this._options.cluster||!e||e.removeAll)return;const{add:n=[],update:o=[],remove:c=[]}=e||{},p=new Set([...o.map(m=>m.id),...c]);for(const m of p.values())if(typeof m!="number"&&this.promoteId==null)return void h.w(`GeoJSONSource "${this.id}": updateData is slower when using string GeoJSON feature IDs (e.g. "${m}"). Consider using promoteId or numeric IDs for better performance.`);return{nextBounds:[...o.map(m=>m.newGeometry),...n.map(m=>m.geometry)].filter(Boolean).map(m=>Kr(m)),prevIds:p}}shouldReloadTile(e,{nextBounds:n,prevIds:o}){if(!e.latestFeatureIndex)return e.state!=="unloaded";const c=e.latestFeatureIndex.loadVTLayers();for(let x=0;x<e.latestFeatureIndex.featureIndexArray.length;x++){const b=e.latestFeatureIndex.featureIndexArray.get(x),T=c[h.a9].feature(b.featureIndex),E=e.latestFeatureIndex.getId(T,h.a9);if(o.has(E))return!0}const{buffer:p,extent:m}=this.workerOptions.geojsonVtOptions,g=function({x,y:b,z:T},E=0){const I=h.a2((x-E)/Math.pow(2,T)),A=h.a3((b+1+E)/Math.pow(2,T)),L=h.a2((x+1+E)/Math.pow(2,T)),j=h.a3((b-E)/Math.pow(2,T));return new Me([I,A],[L,j])}(e.tileID.canonical,p/m);for(const x of n)if(g.intersects(x))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return h._(this,void 0,void 0,function*(){const n=e.actor?"RT":"LT";e.actor=this.actor;const o={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.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};e.abortController=new AbortController;const c=yield this.actor.sendAsync({type:n,data:o},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(c,this.map.painter,n==="RT")})}abortTile(e){return h._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return h._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.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 h.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 Ai extends h.E{constructor(e,n,o,c){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=o,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=n}load(e){return h._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new h.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Ci.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new h.k(n))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new h.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const n=e.map(h.aa.fromLngLat);var o;return this.tileID=function(c){const p=h.ab.fromPoints(c),m=p.width(),g=p.height(),x=Math.max(m,g),b=Math.max(0,Math.floor(-Math.log(x)/Math.LN2)),T=Math.pow(2,b);return new h.ad(b,Math.floor((p.minX+p.maxX)/2*T),Math.floor((p.minY+p.maxY)/2*T))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(c=>this.tileID.getTilePoint(c)._round()),this.flippedWindingOrder=((o=this.tileCoords)[1].x-o[0].x)*(o[2].y-o[0].y)-(o[1].y-o[0].y)*(o[2].x-o[0].x)<0,this.fire(new h.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new h.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const c in this.tiles){const p=this.tiles[c];p.state!=="loaded"&&(p.state="loaded",p.texture=this.texture,o=!0)}o&&this.fire(new h.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return h._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:n,minY:o,maxX:c,maxY:p}=h.ab.fromPoints(e),m={};for(let g=0;g<=h.ac;g++){const x=Math.pow(2,g),b=Math.floor(n*x),T=Math.floor(o*x),E=Math.floor(c*x),I=Math.floor(p*x);m[g]={minTileX:b,minTileY:T,maxTileX:E,maxTileY:I}}return m}}class La extends Ai{constructor(e,n,o,c){super(e,n,o,c),this.roundZoom=!0,this.type="video",this.options=n}load(){return h._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield h.ae(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new h.k(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new h.k(new h.af(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,n=e.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new h.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const c in this.tiles){const p=this.tiles[c];p.state!=="loaded"&&(p.state="loaded",p.texture=this.texture,o=!0)}o&&this.fire(new h.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 Fa extends Ai{constructor(e,n,o,c){super(e,n,o,c),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(p=>!Array.isArray(p)||p.length!==2||p.some(m=>typeof m!="number"))||this.fire(new h.k(new h.af(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new h.k(new h.af(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new h.k(new h.af(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new h.k(new h.af(`sources.${e}`,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 h.k(new h.af(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return h._(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 h.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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,o=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new h.T(n,this.canvas,o.RGBA,{premultiply:!0});let c=!1;for(const p in this.tiles){const m=this.tiles[p];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,c=!0)}c&&this.fire(new h.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 e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const wn={},Jn=d=>{switch(d){case"geojson":return bn;case"image":return Ai;case"raster":return Kn;case"raster-dem":return Yr;case"vector":return _r;case"video":return La;case"canvas":return Fa}return wn[d]},Jr="RTLPluginLoaded";class Qn extends h.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=vn()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return h._(this,arguments,void 0,function*(n,o=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Ze.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!o)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return h._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new h.l(Jr))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Tn=null;function ir(){return Tn||(Tn=new Qn),Tn}var Oi,tt;(function(d){d[d.Base=0]="Base",d[d.Parent=1]="Parent"})(Oi||(Oi={})),function(d){d[d.Departing=0]="Departing",d[d.Incoming=1]="Incoming"}(tt||(tt={}));class k{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=h.ag(),this.uses=0,this.tileSize=n,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(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:n,fadingParentID:o,fadeEndTime:c}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=n,this.fadingParentID=o,this.fadeEndTime=c}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=ie(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,o){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(c,p){const m={};if(!p)return m;for(const g of c){const x=g.layerIds.map(b=>p.getLayer(b)).filter(Boolean);if(x.length!==0){g.layers=x,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(b=>x.filter(T=>T.id===b)[0]));for(const b of x)m[b.id]=g}}return m}(e.buckets,n?.style),this.hasSymbolBuckets=!1;for(const c in this.buckets){const p=this.buckets[c];if(p instanceof h.ai){if(this.hasSymbolBuckets=!0,!o)break;p.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const c in this.buckets){const p=this.buckets[c];if(p instanceof h.ai&&p.hasRTLText){this.hasRTLText=!0,ir().lazyLoad();break}}this.queryPadding=0;for(const c in this.buckets){const p=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(c).queryRadius(p))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new h.ah}unloadVectorData(){for(const e in this.buckets)this.buckets[e].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(e){return this.buckets[e.id]}upload(e){for(const o in this.buckets){const c=this.buckets[o];c.uploadPending()&&c.upload(e)}const n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new h.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new h.T(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,o,c,p,m,g,x,b,T,E){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:p,scale:m,tileSize:this.tileSize,pixelPosMatrix:T,transform:x,params:g,queryPadding:this.queryPadding*b,getElevation:E},e,n,o):{}}querySourceFeatures(e,n){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const c=o.loadVTLayers(),p=n&&n.sourceLayer?n.sourceLayer:"",m=c[h.a9]||c[p];if(!m)return;const g=h.aj(n?.filter,n?.globalState),{z:x,x:b,y:T}=this.tileID.canonical,E={z:x,x:b,y:T};for(let I=0;I<m.length;I++){const A=m.feature(I);if(g.needGeometry){const V=h.ak(A,!0);if(!g.filter(new h.H(this.tileID.overscaledZ),V,this.tileID.canonical))continue}else if(!g.filter(new h.H(this.tileID.overscaledZ),A))continue;const L=o.getId(A,p),j=new h.al(A,x,b,T,L);j.tile=E,e.push(j)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const n=this.expirationTime;if(e.cacheControl){const o=h.am(e.cacheControl);o["max-age"]&&(this.expirationTime=Date.now()+1e3*o["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const o=Date.now();let c=!1;if(this.expirationTime>o)c=!1;else if(n)if(this.expirationTime<n)c=!0;else{const p=this.expirationTime-n;p?this.expirationTime=o+Math.max(p,3e4):c=!0}else c=!0;c?(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(e,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0)return;const o=this.latestFeatureIndex.loadVTLayers();for(const c in this.buckets){if(!n.style.hasLayer(c))continue;const p=this.buckets[c],m=p.layers[0].sourceLayer||h.a9,g=o[m],x=e[m];if(!g||!x||Object.keys(x).length===0)continue;p.update(x,g,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const b=n&&n.style&&n.style.getLayer(c);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(p)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ie()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=ie()+e}setDependencies(e,n){const o={};for(const c of n)o[c]=!0;this.dependencies[e]=o}hasDependency(e,n){for(const o of e){const c=this.dependencies[o];if(c){for(const p of n)if(c[p])return!0}}return!1}}class R{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,o){const c=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][c]=this.stateChanges[e][c]||{},h.e(this.stateChanges[e][c],o),this.deletedStates[e]===null){this.deletedStates[e]={};for(const p in this.state[e])p!==c&&(this.deletedStates[e][p]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][c]===null){this.deletedStates[e][c]={};for(const p in this.state[e][c])o[p]||(this.deletedStates[e][c][p]=null)}else for(const p in o)this.deletedStates[e]&&this.deletedStates[e][c]&&this.deletedStates[e][c][p]===null&&delete this.deletedStates[e][c][p]}removeFeatureState(e,n,o){if(this.deletedStates[e]===null)return;const c=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},o&&n!==void 0)this.deletedStates[e][c]!==null&&(this.deletedStates[e][c]=this.deletedStates[e][c]||{},this.deletedStates[e][c][o]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][c])for(o in this.deletedStates[e][c]={},this.stateChanges[e][c])this.deletedStates[e][c][o]=null;else this.deletedStates[e][c]=null;else this.deletedStates[e]=null}getState(e,n){const o=String(n),c=h.e({},(this.state[e]||{})[o],(this.stateChanges[e]||{})[o]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const p=this.deletedStates[e][n];if(p===null)return{};for(const m in p)delete c[m]}return c}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){const o={};for(const c in this.stateChanges){this.state[c]=this.state[c]||{};const p={};for(const m in this.stateChanges[c])this.state[c][m]||(this.state[c][m]={}),h.e(this.state[c][m],this.stateChanges[c][m]),p[m]=this.state[c][m];o[c]=p}for(const c in this.deletedStates){this.state[c]=this.state[c]||{};const p={};if(this.deletedStates[c]===null)for(const m in this.state[c])p[m]={},this.state[c][m]={};else for(const m in this.deletedStates[c]){if(this.deletedStates[c][m]===null)this.state[c][m]={};else for(const g of Object.keys(this.deletedStates[c][m]))delete this.state[c][m][g];p[m]=this.state[c][m]}o[c]=o[c]||{},h.e(o[c],p)}if(this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0)for(const c in e)e[c].setFeatureState(o,n)}}const B=89.25;function W(d,e){const n=h.an(e.lat,-h.ao,h.ao);return new h.P(h.Y(e.lng)*d,h.X(n)*d)}function X(d,e){return new h.aa(e.x/d,e.y/d).toLngLat()}function nt(d){return d.cameraToCenterDistance*Math.min(.85*Math.tan(h.ap(90-d.pitch)),Math.tan(h.ap(B-d.pitch)))}function U(d,e){const n=d.canonical,o=e/h.aq(n.z),c=n.x+Math.pow(2,n.z)*d.wrap,p=h.ar(new Float64Array(16));return h.O(p,p,[c*o,n.y*o,0]),h.Q(p,p,[o/h.a4,o/h.a4,1]),p}function rt(d,e,n,o,c){const p=h.aa.fromLngLat(d,e),m=c*h.as(1,d.lat),g=m*Math.cos(h.ap(n)),x=Math.sqrt(m*m-g*g),b=x*Math.sin(h.ap(-o)),T=x*Math.cos(h.ap(-o));return new h.aa(p.x+b,p.y+T,p.z+g)}function ht(d,e,n){const o=e.intersectsFrustum(d);if(!n||o===0)return o;const c=e.intersectsPlane(n);return c===0?0:o===2&&c===2?2:1}function dt(d,e,n){let o=0;const c=(n-e)/10;for(let p=0;p<10;p++)o+=c*Math.pow(Math.cos(e+(p+.5)/10*(n-e)),d);return o}function ft(d,e){return function(n,o,c,p,m){const g=2*((d-1)/h.at(Math.cos(h.ap(B-m))/Math.cos(h.ap(B)))-1),x=Math.acos(c/p),b=2*dt(g-1,0,h.ap(m/2)),T=Math.min(h.ap(B),x+h.ap(m/2)),E=dt(g-1,Math.min(T,x-h.ap(m/2)),T),I=Math.atan(o/c),A=Math.hypot(o,c);let L=n;return L+=h.at(p/A/Math.max(.5,Math.cos(h.ap(m/2)))),L+=g*h.at(Math.cos(I))/2,L-=h.at(Math.max(1,E/b/e))/2,L}}const zt=ft(9.314,3);function jt(d,e){const n=(e.roundZoom?Math.round:Math.floor)(d.zoom+h.at(d.tileSize/e.tileSize));return Math.max(0,n)}function qt(d,e){const n=d.getCameraFrustum(),o=d.getClippingPlane(),c=d.screenPointToMercatorCoordinate(d.getCameraPoint()),p=h.aa.fromLngLat(d.center,d.elevation);c.z=p.z+Math.cos(d.pitchInRadians)*d.cameraToCenterDistance/d.worldSize;const m=d.getCoveringTilesDetailsProvider(),g=m.allowVariableZoom(d,e),x=jt(d,e),b=e.minzoom||0,T=e.maxzoom!==void 0?e.maxzoom:d.maxZoom,E=Math.min(Math.max(0,x),T),I=Math.pow(2,E),A=[I*c.x,I*c.y,0],L=[I*p.x,I*p.y,0],j=Math.hypot(p.x-c.x,p.y-c.y),V=Math.abs(p.z-c.z),G=Math.hypot(j,V),q=K=>({zoom:0,x:0,y:0,wrap:K,fullyVisible:!1}),Y=[],$=[];if(d.renderWorldCopies&&m.allowWorldCopies())for(let K=1;K<=3;K++)Y.push(q(-K)),Y.push(q(K));for(Y.push(q(0));Y.length>0;){const K=Y.pop(),J=K.x,H=K.y;let it=K.fullyVisible;const ut={x:J,y:H,z:K.zoom},st=m.getTileBoundingVolume(ut,K.wrap,d.elevation,e);if(!it){const wt=ht(n,st,o);if(wt===0)continue;it=wt===2}const ot=m.distanceToTile2d(c.x,c.y,ut,st);let ct=x;g&&(ct=(e.calculateTileZoom||zt)(d.zoom+h.at(d.tileSize/e.tileSize),ot,V,G,d.fov)),ct=(e.roundZoom?Math.round:Math.floor)(ct),ct=Math.max(0,ct);const Mt=Math.min(ct,T);if(K.wrap=m.getWrap(p,ut,K.wrap),K.zoom>=Mt){if(K.zoom<b)continue;const wt=E-K.zoom,gt=A[0]-.5-(J<<wt),Rt=A[1]-.5-(H<<wt),$t=e.reparseOverscaled?Math.max(K.zoom,ct):K.zoom;$.push({tileID:new h.a1(K.zoom===T?$t:K.zoom,K.wrap,K.zoom,J,H),distanceSq:h.au([L[0]-.5-J,L[1]-.5-H]),tileDistanceToCamera:Math.sqrt(gt*gt+Rt*Rt)})}else for(let wt=0;wt<4;wt++)Y.push({zoom:K.zoom+1,x:(J<<1)+wt%2,y:(H<<1)+(wt>>1),wrap:K.wrap,fullyVisible:it})}return $.sort((K,J)=>K.distanceSq-J.distanceSq).map(K=>K.tileID)}const ke=h.ab.fromPoints([new h.P(0,0),new h.P(h.a4,h.a4)]);class Yt extends h.E{constructor(e,n,o){super(),this.id=e,this.dispatcher=o,this.on("data",c=>this._dataHandler(c)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((c,p,m,g)=>{const x=new(Jn(p.type))(c,p,m,g);if(x.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${x.id}`);return x})(e,n,o,this),this._tiles={},this._cache=new h.av(0,c=>this._unloadTile(c)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new R,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,o){return h._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,o)}catch(c){e.state="errored",c.status!==404?this._source.fire(new h.k(c,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new h.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const o=this._tiles[n];o.upload(e),o.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(ne).map(e=>e.key)}getRenderableIds(e){const n=[];for(const o in this._tiles)this._isIdRenderable(o,e)&&n.push(this._tiles[o]);return e?n.sort((o,c)=>{const p=o.tileID,m=c.tileID,g=new h.P(p.canonical.x,p.canonical.y)._rotate(-this.transform.bearingInRadians),x=new h.P(m.canonical.x,m.canonical.y)._rotate(-this.transform.bearingInRadians);return p.overscaledZ-m.overscaledZ||x.y-g.y||x.x-g.x}).map(o=>o.tileID.key):n.map(o=>o.tileID).sort(ne).map(o=>o.key)}hasRenderableParent(e){const n=e.overscaledZ-1;if(n>=this._source.minzoom){const o=this.getLoadedTile(e.scaledTo(n));if(o)return this._isIdRenderable(o.tileID.key)}return!1}_isIdRenderable(e,n=!1){var o;return(o=this._tiles[e])===null||o===void 0?void 0:o.isRenderable(n)}reload(e,n=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const o in this._tiles)n&&this._source.shouldReloadTile&&!this._source.shouldReloadTile(this._tiles[o],n)||(e?this._reloadTile(o,"expired"):this._tiles[o].state!=="errored"&&this._reloadTile(o,"reloading"))}}_reloadTile(e,n){return h._(this,void 0,void 0,function*(){const o=this._tiles[e];o&&(o.state!=="loading"&&(o.state=n),yield this._loadTile(o,e,n))})}_tileLoaded(e,n,o){e.timeAdded=ie(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),o==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new h.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const n=this.getRenderableIds();for(let c=0;c<n.length;c++){const p=n[c];if(e.neighboringTiles&&e.neighboringTiles[p]){const m=this.getTileByID(p);o(e,m),o(m,e)}}function o(c,p){c.needsHillshadePrepare=!0,c.needsTerrainPrepare=!0;let m=p.tileID.canonical.x-c.tileID.canonical.x;const g=p.tileID.canonical.y-c.tileID.canonical.y,x=Math.pow(2,c.tileID.canonical.z),b=p.tileID.key;m===0&&g===0||Math.abs(g)>1||(Math.abs(m)>1&&(Math.abs(m+x)===1?m+=x:Math.abs(m-x)===1&&(m-=x)),p.dem&&c.dem&&(c.dem.backfillBorder(p.dem,m,g),c.neighboringTiles&&c.neighboringTiles[b]&&(c.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n){const o=this._getLoadedDescendents(n),c=new Set;for(const p of n){const m=o[p.key];if(!m?.length){c.add(p);continue}const g=p.overscaledZ+Yt.maxOverzooming,x=m.filter(E=>E.tileID.overscaledZ<=g);if(!x.length){c.add(p);continue}const b=Math.min(...x.map(E=>E.tileID.overscaledZ)),T=x.filter(E=>E.tileID.overscaledZ===b).map(E=>E.tileID);for(const E of T)e[E.key]=E;this._areDescendentsComplete(T,b,p.overscaledZ)||c.add(p)}return c}_getLoadedDescendents(e){var n;const o={};for(const c in this._tiles){const p=this._tiles[c];if(p.hasData())for(const m of e)p.tileID.isChildOf(m)&&(o[n=m.key]||(o[n]=[])).push(p)}return o}_areDescendentsComplete(e,n,o){return e.length===1&&e[0].isOverscaled()?e[0].overscaledZ===n:Math.pow(4,n-o)===e.length}getLoadedTile(e){const n=this._tiles[e.key];return n?.hasData()?n:null}updateCacheSize(e){const n=Math.ceil(e.width/this._source.tileSize)+1,o=Math.ceil(e.height/this._source.tileSize)+1,c=Math.floor(n*o*(this._maxTileCacheZoomLevels===null?h.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(p)}handleWrapJump(e){const n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){const o={};for(const c in this._tiles){const p=this._tiles[c];p.tileID=p.tileID.unwrapTo(p.tileID.wrap+n),o[p.tileID.key]=p}this._tiles=o,this._resetTileReloadTimers()}}update(e,n){if(!this._sourceLoaded||this._paused)return;let o;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?o=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(x=>new h.a1(x.canonical.z,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y)):(o=qt(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(o=o.filter(x=>this._source.hasTile(x)))):o=[],this.usedForTerrain&&(o=this._addTerrainIdealTiles(o));const c=o.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,c&&this.fire(new h.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const p=jt(e,this._source),m=this._updateRetainedTiles(o,p),g=de(this._source.type);g&&this._rasterFadeDuration>0&&!n&&this._updateFadingTiles(o,m),g?this._cleanUpRasterTiles(m):this._cleanUpVectorTiles(m)}_cleanUpRasterTiles(e){for(const n in this._tiles)e[n]||this._removeTile(n)}_cleanUpVectorTiles(e){for(const n in this._tiles){const o=this._tiles[n];e[n]?o.clearSymbolFadeHold():o.hasSymbolBuckets?o.holdingForSymbolFade()?o.symbolFadeFinished()&&this._removeTile(n):o.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(n)}}_addTerrainIdealTiles(e){const n=[];for(const o of e)if(o.canonical.z>this._source.minzoom){const c=o.scaledTo(o.canonical.z-1);n.push(c);const p=o.scaledTo(Math.max(this._source.minzoom,Math.min(o.canonical.z,5)));n.push(p)}return e.concat(n)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var o;const c=new Set;for(const b of e)this._addTile(b).hasData()||c.add(b);const p=e.reduce((b,T)=>(b[T.key]=T,b),{}),m=this._retainLoadedChildren(p,c),g={},x=Math.max(n-Yt.maxUnderzooming,this._source.minzoom);for(const b of m){let T=this._tiles[b.key],E=T?.wasRequested();for(let I=b.overscaledZ-1;I>=x;--I){const A=b.scaledTo(I);if(g[A.key])break;if(g[A.key]=!0,T=this.getTile(A),!T&&E&&(T=this._addTile(A)),T){const L=T.hasData();if((L||!(!((o=this.map)===null||o===void 0)&&o.cancelPendingTileRequestsWhileZooming)||E)&&(p[A.key]=A),E=T.wasRequested(),L)break}}}return p}_updateFadingTiles(e,n){const o=ie(),c=h.aw(e);for(const p of e){const m=this._tiles[p.key];m.fadingDirection!==tt.Departing&&m.fadeOpacity!==0||m.resetFadeLogic(),this._updateFadingAncestor(m,n,o)||this._updateFadingDescendents(m,n,o)||this._updateFadingEdge(m,c,o)||m.resetFadeLogic()}}_updateFadingAncestor(e,n,o){if(!e.hasData())return!1;const{tileID:c,fadingRole:p,fadingDirection:m,fadingParentID:g}=e;if(p===Oi.Base&&m===tt.Incoming&&g)return n[g.key]=g,!0;const x=Math.max(c.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let b=c.overscaledZ-1;b>=x;b--){const T=c.scaledTo(b),E=this.getLoadedTile(T);if(E)return e.setCrossFadeLogic({fadingRole:Oi.Base,fadingDirection:tt.Incoming,fadingParentID:E.tileID,fadeEndTime:o+this._rasterFadeDuration}),E.setCrossFadeLogic({fadingRole:Oi.Parent,fadingDirection:tt.Departing,fadeEndTime:o+this._rasterFadeDuration}),n[T.key]=T,!0}return!1}_updateFadingDescendents(e,n,o){if(!e.hasData())return!1;const c=e.tileID.children(this._source.maxzoom);let p=this._updateFadingChildren(e,c,n,o);if(p)return!0;for(const m of c){const g=m.children(this._source.maxzoom);this._updateFadingChildren(e,g,n,o)&&(p=!0)}return p}_updateFadingChildren(e,n,o,c){if(n[0].overscaledZ>=this._source.maxzoom)return!1;let p=!1;for(const m of n){const g=this.getLoadedTile(m);if(!g)continue;const{fadingRole:x,fadingDirection:b,fadingParentID:T}=g;x===Oi.Base&&b===tt.Departing&&T||(g.setCrossFadeLogic({fadingRole:Oi.Base,fadingDirection:tt.Departing,fadingParentID:e.tileID,fadeEndTime:c+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:Oi.Parent,fadingDirection:tt.Incoming,fadeEndTime:c+this._rasterFadeDuration})),o[m.key]=m,p=!0}return p}_updateFadingEdge(e,n,o){const c=e.tileID;return!!e.selfFading||!e.hasData()&&!!n.has(c)&&(e.setSelfFadeLogic(o+this._rasterFadeDuration),!0)}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(n.resetFadeLogic(),this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null));const o=n;return n||(n=new k(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,o||this._source.fire(new h.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){this._clearTileReloadTimer(e);const o=n.getExpiryTimeout();o&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},o))}_clearTileReloadTimer(e){const n=this._timers[e];n&&(clearTimeout(n),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}refreshTiles(e){for(const n in this._tiles)(this._isIdRenderable(n)||this._tiles[n].state=="errored")&&e.some(o=>o.equals(this._tiles[n].tileID.canonical))&&this._reloadTile(n,"expired")}_removeTile(e){const n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._clearTileReloadTimer(e),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){e.dataType==="source"&&(e.sourceDataType!=="metadata"?e.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,o){const c=[],p=this.transform;if(!p)return c;const m=p.getCoveringTilesDetailsProvider().allowWorldCopies(),g=o?p.getCameraQueryGeometry(e):e,x=A=>p.screenPointToMercatorCoordinate(A,this.terrain),b=this.transformBbox(e,x,!m),T=this.transformBbox(g,x,!m),E=this.getIds(),I=h.ab.fromPoints(T);for(let A=0;A<E.length;A++){const L=this._tiles[E[A]];if(L.holdingForSymbolFade())continue;const j=m?[L.tileID]:[L.tileID.unwrapTo(-1),L.tileID.unwrapTo(0)],V=Math.pow(2,p.zoom-L.tileID.overscaledZ),G=n*L.queryPadding*h.a4/L.tileSize/V;for(const q of j){const Y=I.map($=>q.getTilePoint(new h.aa($.x,$.y)));if(Y.expandBy(G),Y.intersects(ke)){const $=b.map(J=>q.getTilePoint(J)),K=T.map(J=>q.getTilePoint(J));c.push({tile:L,tileID:m?q:q.unwrapTo(0),queryGeometry:$,cameraQueryGeometry:K,scale:V})}}}return c}transformBbox(e,n,o){let c=e.map(n);if(o){const p=h.ab.fromPoints(e);p.shrinkBy(.001*Math.min(p.width(),p.height()));const m=p.map(n);h.ab.fromPoints(c).covers(m)||(c=c.map(g=>g.x>.5?new h.aa(g.x-1,g.y,g.z):g))}return c}getVisibleCoordinates(e){const n=this.getRenderableIds(e).map(o=>this._tiles[o].tileID);return this.transform&&this.transform.populateCache(n),n}hasTransition(){if(this._source.hasTransition())return!0;if(de(this._source.type)&&this._rasterFadeDuration>0){const e=ie();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,n,o){this._state.updateState(e=e||h.a9,n,o)}removeFeatureState(e,n,o){this._state.removeFeatureState(e=e||h.a9,n,o)}getFeatureState(e,n){return this._state.getState(e=e||h.a9,n)}setDependencies(e,n,o){const c=this._tiles[e];c&&c.setDependencies(n,o)}reloadTilesForDependencies(e,n){for(const o in this._tiles)this._tiles[o].hasDependency(e,n)&&this._reloadTile(o,"reloading");this._cache.filter(o=>!o.hasDependency(e,n))}}function ne(d,e){const n=Math.abs(2*d.wrap)-+(d.wrap<0),o=Math.abs(2*e.wrap)-+(e.wrap<0);return d.overscaledZ-e.overscaledZ||o-n||e.canonical.y-d.canonical.y||e.canonical.x-d.canonical.x}function de(d){return d==="raster"||d==="image"||d==="video"}Yt.maxUnderzooming=10,Yt.maxOverzooming=3;class bt{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let o=1;o<this.points.length;o++)this._distances[o]=this._distances[o-1]+this.points[o].dist(this.points[o-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=h.an(e,0,1);let n=1,o=this._distances[n];const c=e*this.paddedLength+this.padding;for(;o<c&&n<this._distances.length;)o=this._distances[++n];const p=n-1,m=this._distances[p],g=o-m,x=g>0?(c-m)/g:0;return this.points[p].mult(1-x).add(this.points[n].mult(x))}}function xe(d,e){let n=!0;return d==="always"||d!=="never"&&e!=="never"||(n=!1),n}class pe{constructor(e,n,o){const c=this.boxCells=[],p=this.circleCells=[];this.xCellCount=Math.ceil(e/o),this.yCellCount=Math.ceil(n/o);for(let m=0;m<this.xCellCount*this.yCellCount;m++)c.push([]),p.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=n,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,n,o,c,p){this._forEachCell(n,o,c,p,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(c),this.bboxes.push(p)}insertCircle(e,n,o,c){this._forEachCell(n-c,o-c,n+c,o+c,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(n),this.circles.push(o),this.circles.push(c)}_insertBoxCell(e,n,o,c,p,m){this.boxCells[p].push(m)}_insertCircleCell(e,n,o,c,p,m){this.circleCells[p].push(m)}_query(e,n,o,c,p,m,g){if(o<0||e>this.width||c<0||n>this.height)return[];const x=[];if(e<=0&&n<=0&&this.width<=o&&this.height<=c){if(p)return[{key:null,x1:e,y1:n,x2:o,y2:c}];for(let b=0;b<this.boxKeys.length;b++)x.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const T=this.circles[3*b],E=this.circles[3*b+1],I=this.circles[3*b+2];x.push({key:this.circleKeys[b],x1:T-I,y1:E-I,x2:T+I,y2:E+I})}}else this._forEachCell(e,n,o,c,this._queryCell,x,{hitTest:p,overlapMode:m,seenUids:{box:{},circle:{}}},g);return x}query(e,n,o,c){return this._query(e,n,o,c,!1,null)}hitTest(e,n,o,c,p,m){return this._query(e,n,o,c,!0,p,m).length>0}hitTestCircle(e,n,o,c,p){const m=e-o,g=e+o,x=n-o,b=n+o;if(g<0||m>this.width||b<0||x>this.height)return!1;const T=[];return this._forEachCell(m,x,g,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:c,circle:{x:e,y:n,radius:o},seenUids:{box:{},circle:{}}},p),T.length>0}_queryCell(e,n,o,c,p,m,g,x){const{seenUids:b,hitTest:T,overlapMode:E}=g,I=this.boxCells[p];if(I!==null){const L=this.bboxes;for(const j of I)if(!b.box[j]){b.box[j]=!0;const V=4*j,G=this.boxKeys[j];if(e<=L[V+2]&&n<=L[V+3]&&o>=L[V+0]&&c>=L[V+1]&&(!x||x(G))&&(!T||!xe(E,G.overlapMode))&&(m.push({key:G,x1:L[V],y1:L[V+1],x2:L[V+2],y2:L[V+3]}),T))return!0}}const A=this.circleCells[p];if(A!==null){const L=this.circles;for(const j of A)if(!b.circle[j]){b.circle[j]=!0;const V=3*j,G=this.circleKeys[j];if(this._circleAndRectCollide(L[V],L[V+1],L[V+2],e,n,o,c)&&(!x||x(G))&&(!T||!xe(E,G.overlapMode))){const q=L[V],Y=L[V+1],$=L[V+2];if(m.push({key:G,x1:q-$,y1:Y-$,x2:q+$,y2:Y+$}),T)return!0}}}return!1}_queryCellCircle(e,n,o,c,p,m,g,x){const{circle:b,seenUids:T,overlapMode:E}=g,I=this.boxCells[p];if(I!==null){const L=this.bboxes;for(const j of I)if(!T.box[j]){T.box[j]=!0;const V=4*j,G=this.boxKeys[j];if(this._circleAndRectCollide(b.x,b.y,b.radius,L[V+0],L[V+1],L[V+2],L[V+3])&&(!x||x(G))&&!xe(E,G.overlapMode))return m.push(!0),!0}}const A=this.circleCells[p];if(A!==null){const L=this.circles;for(const j of A)if(!T.circle[j]){T.circle[j]=!0;const V=3*j,G=this.circleKeys[j];if(this._circlesCollide(L[V],L[V+1],L[V+2],b.x,b.y,b.radius)&&(!x||x(G))&&!xe(E,G.overlapMode))return m.push(!0),!0}}}_forEachCell(e,n,o,c,p,m,g,x){const b=this._convertToXCellCoord(e),T=this._convertToYCellCoord(n),E=this._convertToXCellCoord(o),I=this._convertToYCellCoord(c);for(let A=b;A<=E;A++)for(let L=T;L<=I;L++)if(p.call(this,e,n,o,c,this.xCellCount*L+A,m,g,x))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,o,c,p,m){const g=c-e,x=p-n,b=o+m;return b*b>g*g+x*x}_circleAndRectCollide(e,n,o,c,p,m,g){const x=(m-c)/2,b=Math.abs(e-(c+x));if(b>x+o)return!1;const T=(g-p)/2,E=Math.abs(n-(p+T));if(E>T+o)return!1;if(b<=x||E<=T)return!0;const I=b-x,A=E-T;return I*I+A*A<=o*o}}function $e(d,e,n){const o=h.N();if(!d){const{vecSouth:E,vecEast:I}=Tt(e),A=si();A[0]=I[0],A[1]=I[1],A[2]=E[0],A[3]=E[1],c=A,(T=(m=(p=A)[0])*(b=p[3])-(x=p[2])*(g=p[1]))&&(c[0]=b*(T=1/T),c[1]=-g*T,c[2]=-x*T,c[3]=m*T),o[0]=A[0],o[1]=A[1],o[4]=A[2],o[5]=A[3]}var c,p,m,g,x,b,T;return h.Q(o,o,[1/n,1/n,1]),o}function fe(d,e,n,o){if(d){const c=h.N();if(!e){const{vecSouth:p,vecEast:m}=Tt(n);c[0]=m[0],c[1]=m[1],c[4]=p[0],c[5]=p[1]}return h.Q(c,c,[o,o,1]),c}return n.pixelsToClipSpaceMatrix}function Tt(d){const e=Math.cos(d.rollInRadians),n=Math.sin(d.rollInRadians),o=Math.cos(d.pitchInRadians),c=Math.cos(d.bearingInRadians),p=Math.sin(d.bearingInRadians),m=h.aB();m[0]=-c*o*n-p*e,m[1]=-p*o*n+c*e;const g=h.aC(m);g<1e-9?h.aD(m):h.aE(m,m,1/g);const x=h.aB();x[0]=c*o*e-p*n,x[1]=p*o*e+c*n;const b=h.aC(x);return b<1e-9?h.aD(x):h.aE(x,x,1/b),{vecEast:x,vecSouth:m}}function Lt(d,e,n,o){let c;o?(c=[d,e,o(d,e),1],h.aG(c,c,n)):(c=[d,e,0,1],Ba(c,c,n));const p=c[3];return{point:new h.P(c[0]/p,c[1]/p),signedDistanceFromCamera:p,isOccluded:!1}}function Ut(d,e){return .5+d/e*.5}function Di(d,e){return d.x>=-e[0]&&d.x<=e[0]&&d.y>=-e[1]&&d.y<=e[1]}function Sn(d,e,n,o,c,p,m,g,x,b,T,E,I){const A=n?d.textSizeData:d.iconSizeData,L=h.ax(A,e.transform.zoom),j=[256/e.width*2+1,256/e.height*2+1],V=n?d.text.dynamicLayoutVertexArray:d.icon.dynamicLayoutVertexArray;V.clear();const G=d.lineVertexArray,q=n?d.text.placedSymbolArray:d.icon.placedSymbolArray,Y=e.transform.width/e.transform.height;let $=!1;for(let K=0;K<q.length;K++){const J=q.get(K);if(J.hidden||J.writingMode===h.ay.vertical&&!$){yr(J.numGlyphs,V);continue}$=!1;const H=new h.P(J.anchorX,J.anchorY),it={getElevation:I,pitchedLabelPlaneMatrix:o,lineVertexArray:G,pitchWithMap:p,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:H,unwrappedTileID:x,width:b,height:T,translation:E},ut=ia(J.anchorX,J.anchorY,it);if(!Di(ut.point,j)){yr(J.numGlyphs,V);continue}const st=Ut(e.transform.cameraToCenterDistance,ut.signedDistanceFromCamera),ot=h.az(A,L,J),ct=p?ot*e.transform.getPitchedTextCorrection(J.anchorX,J.anchorY,x)/st:ot*st,Mt=Er({projectionContext:it,pitchedLabelPlaneMatrixInverse:c,symbol:J,fontSize:ct,flip:!1,keepUpright:m,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:V,aspectRatio:Y,rotateToLine:g});$=Mt.useVertical,(Mt.notEnoughRoom||$||Mt.needsFlipping&&Er({projectionContext:it,pitchedLabelPlaneMatrixInverse:c,symbol:J,fontSize:ct,flip:!0,keepUpright:m,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:V,aspectRatio:Y,rotateToLine:g}).notEnoughRoom)&&yr(J.numGlyphs,V)}n?d.text.dynamicLayoutVertexBuffer.updateData(V):d.icon.dynamicLayoutVertexBuffer.updateData(V)}function ti(d,e,n,o,c,p,m,g){const x=p.glyphStartIndex+p.numGlyphs,b=p.lineStartIndex,T=p.lineStartIndex+p.lineLength,E=e.getoffsetX(p.glyphStartIndex),I=e.getoffsetX(x-1),A=me(d*E,n,o,c,p.segment,b,T,g,m);if(!A)return null;const L=me(d*I,n,o,c,p.segment,b,T,g,m);return L?g.projectionCache.anyProjectionOccluded?null:{first:A,last:L}:null}function Gt(d,e,n,o){return d===h.ay.horizontal&&Math.abs(n.y-e.y)>Math.abs(n.x-e.x)*o?{useVertical:!0}:(d===h.ay.vertical?e.y<n.y:e.x>n.x)?{needsFlipping:!0}:null}function Er(d){const{projectionContext:e,pitchedLabelPlaneMatrixInverse:n,symbol:o,fontSize:c,flip:p,keepUpright:m,glyphOffsetArray:g,dynamicLayoutVertexArray:x,aspectRatio:b,rotateToLine:T}=d,E=c/24,I=o.lineOffsetX*E,A=o.lineOffsetY*E;let L;if(o.numGlyphs>1){const j=o.glyphStartIndex+o.numGlyphs,V=o.lineStartIndex,G=o.lineStartIndex+o.lineLength,q=ti(E,g,I,A,p,o,T,e);if(!q)return{notEnoughRoom:!0};const Y=Pn(q.first.point.x,q.first.point.y,e,n),$=Pn(q.last.point.x,q.last.point.y,e,n);if(m&&!p){const K=Gt(o.writingMode,Y,$,b);if(K)return K}L=[q.first];for(let K=o.glyphStartIndex+1;K<j-1;K++){const J=me(E*g.getoffsetX(K),I,A,p,o.segment,V,G,e,T);if(!J)return{notEnoughRoom:!0};L.push(J)}L.push(q.last)}else{if(m&&!p){const V=rr(e.tileAnchorPoint.x,e.tileAnchorPoint.y,e).point,G=o.lineStartIndex+o.segment+1,q=new h.P(e.lineVertexArray.getx(G),e.lineVertexArray.gety(G)),Y=rr(q.x,q.y,e),$=Y.signedDistanceFromCamera>0?Y.point:ta(e.tileAnchorPoint,q,V,1,e),K=Pn(V.x,V.y,e,n),J=Pn($.x,$.y,e,n),H=Gt(o.writingMode,K,J,b);if(H)return H}const j=me(E*g.getoffsetX(o.glyphStartIndex),I,A,p,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,e,T);if(!j||e.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};L=[j]}for(const j of L)h.aF(x,j.point,j.angle);return{}}function ta(d,e,n,o,c){const p=d.add(d.sub(e)._unit()),m=rr(p.x,p.y,c).point,g=n.sub(m);return n.add(g._mult(o/g.mag()))}function ea(d,e,n){const o=e.projectionCache;if(o.projections[d])return o.projections[d];const c=new h.P(e.lineVertexArray.getx(d),e.lineVertexArray.gety(d)),p=rr(c.x,c.y,e);if(p.signedDistanceFromCamera>0)return o.projections[d]=p.point,o.anyProjectionOccluded=o.anyProjectionOccluded||p.isOccluded,p.point;const m=d-n.direction;return ta(n.distanceFromAnchor===0?e.tileAnchorPoint:new h.P(e.lineVertexArray.getx(m),e.lineVertexArray.gety(m)),c,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function rr(d,e,n){const o=d+n.translation[0],c=e+n.translation[1];let p;return n.pitchWithMap?(p=Lt(o,c,n.pitchedLabelPlaneMatrix,n.getElevation),p.isOccluded=!1):(p=n.transform.projectTileCoordinates(o,c,n.unwrappedTileID,n.getElevation),p.point.x=(.5*p.point.x+.5)*n.width,p.point.y=(.5*-p.point.y+.5)*n.height),p}function Pn(d,e,n,o){if(n.pitchWithMap){const c=[d,e,0,1];return h.aG(c,c,o),n.transform.projectTileCoordinates(c[0]/c[3],c[1]/c[3],n.unwrappedTileID,n.getElevation).point}return{x:d/n.width*2-1,y:1-e/n.height*2}}function ia(d,e,n){return n.transform.projectTileCoordinates(d,e,n.unwrappedTileID,n.getElevation)}function ra(d,e,n){return d._unit()._perp()._mult(e*n)}function ji(d,e,n,o,c,p,m,g,x){if(g.projectionCache.offsets[d])return g.projectionCache.offsets[d];const b=n.add(e);if(d+x.direction<o||d+x.direction>=c)return g.projectionCache.offsets[d]=b,b;const T=ea(d+x.direction,g,x),E=ra(T.sub(n),m,x.direction),I=n.add(E),A=T.add(E);return g.projectionCache.offsets[d]=h.aH(p,b,I,A)||b,g.projectionCache.offsets[d]}function me(d,e,n,o,c,p,m,g,x){const b=o?d-e:d+e;let T=b>0?1:-1,E=0;o&&(T*=-1,E=Math.PI),T<0&&(E+=Math.PI);let I,A=T>0?p+c:p+c+1;g.projectionCache.cachedAnchorPoint?I=g.projectionCache.cachedAnchorPoint:(I=rr(g.tileAnchorPoint.x,g.tileAnchorPoint.y,g).point,g.projectionCache.cachedAnchorPoint=I);let L,j,V=I,G=I,q=0,Y=0;const $=Math.abs(b),K=[];let J;for(;q+Y<=$;){if(A+=T,A<p||A>=m)return null;q+=Y,G=V,j=L;const ut={absOffsetX:$,direction:T,distanceFromAnchor:q,previousVertex:G};if(V=ea(A,g,ut),n===0)K.push(G),J=V.sub(G);else{let st;const ot=V.sub(G);st=ot.mag()===0?ra(ea(A+T,g,ut).sub(V),n,T):ra(ot,n,T),j||(j=G.add(st)),L=ji(A,st,V,p,m,j,n,g,ut),K.push(j),J=L.sub(j)}Y=J.mag()}const H=J._mult(($-q)/Y)._add(j||G),it=E+Math.atan2(V.y-G.y,V.x-G.x);return K.push(H),{point:H,angle:x?it:0,path:K}}const Ru=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function yr(d,e){for(let n=0;n<d;n++){const o=e.length;e.resize(o+4),e.float32.set(Ru,3*o)}}function Ba(d,e,n){const o=e[0],c=e[1];return d[0]=n[0]*o+n[4]*c+n[12],d[1]=n[1]*o+n[5]*c+n[13],d[3]=n[3]*o+n[7]*c+n[15],d}const Ie=100;class Qr{constructor(e,n=new pe(e.width+200,e.height+200,25),o=new pe(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=o,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Ie,this.screenBottomBoundary=e.height+Ie,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,n,o,c,p,m,g,x,b,T,E,I){const A=this.projectAndGetPerspectiveRatio(e.anchorPointX+x[0],e.anchorPointY+x[1],p,T,I),L=o*A.perspectiveRatio;let j;if(m||g)j=this._projectCollisionBox(e,L,c,p,m,g,x,A,T,E,I);else{const J=A.x+(E?E.x*L:0),H=A.y+(E?E.y*L:0);j={allPointsOccluded:!1,box:[J+e.x1*L,H+e.y1*L,J+e.x2*L,H+e.y2*L]}}const[V,G,q,Y]=j.box,$=m?j.allPointsOccluded:A.isOccluded;let K=$;return K||(K=A.perspectiveRatio<this.perspectiveRatioCutoff),K||(K=!this.isInsideGrid(V,G,q,Y)),K||n!=="always"&&this.grid.hitTest(V,G,q,Y,n,b)?{box:[V,G,q,Y],placeable:!1,offscreen:!1,occluded:$}:{box:[V,G,q,Y],placeable:!0,offscreen:this.isOffscreen(V,G,q,Y),occluded:$}}placeCollisionCircles(e,n,o,c,p,m,g,x,b,T,E,I,A,L){const j=[],V=new h.P(n.anchorX,n.anchorY),G=this.getPerspectiveRatio(V.x,V.y,m,L),q=(b?p*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,m)/G:p*G)/h.aL,Y={getElevation:L,pitchedLabelPlaneMatrix:g,lineVertexArray:o,pitchWithMap:b,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:V,unwrappedTileID:m,width:this.transform.width,height:this.transform.height,translation:A},$=ti(q,c,n.lineOffsetX*q,n.lineOffsetY*q,!1,n,!1,Y);let K=!1,J=!1,H=!0;if($){const it=.5*E*G+I,ut=new h.P(-100,-100),st=new h.P(this.screenRightBoundary,this.screenBottomBoundary),ot=new bt,ct=$.first,Mt=$.last;let wt=[];for(let $t=ct.path.length-1;$t>=1;$t--)wt.push(ct.path[$t]);for(let $t=1;$t<Mt.path.length;$t++)wt.push(Mt.path[$t]);const gt=2.5*it;if(b){const $t=this.projectPathToScreenSpace(wt,Y);wt=$t.some(Zt=>Zt.signedDistanceFromCamera<=0)?[]:$t.map(Zt=>Zt.point)}let Rt=[];if(wt.length>0){const $t=wt[0].clone(),Zt=wt[0].clone();for(let ge=1;ge<wt.length;ge++)$t.x=Math.min($t.x,wt[ge].x),$t.y=Math.min($t.y,wt[ge].y),Zt.x=Math.max(Zt.x,wt[ge].x),Zt.y=Math.max(Zt.y,wt[ge].y);Rt=$t.x>=ut.x&&Zt.x<=st.x&&$t.y>=ut.y&&Zt.y<=st.y?[wt]:Zt.x<ut.x||$t.x>st.x||Zt.y<ut.y||$t.y>st.y?[]:h.aI([wt],ut.x,ut.y,st.x,st.y)}for(const $t of Rt){ot.reset($t,.25*it);let Zt=0;Zt=ot.length<=.5*it?1:Math.ceil(ot.paddedLength/gt)+1;for(let ge=0;ge<Zt;ge++){const ye=ge/Math.max(Zt-1,1),Ce=ot.lerp(ye),ue=Ce.x+Ie,He=Ce.y+Ie;j.push(ue,He,it,0);const we=ue-it,Ne=He-it,Oe=ue+it,Ue=He+it;if(H=H&&this.isOffscreen(we,Ne,Oe,Ue),J=J||this.isInsideGrid(we,Ne,Oe,Ue),e!=="always"&&this.grid.hitTestCircle(ue,He,it,e,T)&&(K=!0,!x))return{circles:[],offscreen:!1,collisionDetected:K}}}}return{circles:!x&&K||!J||G<this.perspectiveRatioCutoff?[]:j,offscreen:H,collisionDetected:K}}projectPathToScreenSpace(e,n){const o=function(c,p){const m=h.N();return h.aA(m,p.pitchedLabelPlaneMatrix),c.map(g=>{const x=Lt(g.x,g.y,m,p.getElevation),b=p.transform.projectTileCoordinates(x.point.x,x.point.y,p.unwrappedTileID,p.getElevation);return b.point.x=(.5*b.point.x+.5)*p.width,b.point.y=(.5*-b.point.y+.5)*p.height,b})}(e,n);return function(c){let p=0,m=0,g=0,x=0;for(let b=0;b<c.length;b++)c[b].isOccluded?(g=b+1,x=0):(x++,x>m&&(m=x,p=g));return c.slice(p,p+m)}(o)}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],o=new h.ab;for(const E of e){const I=new h.P(E.x+Ie,E.y+Ie);o.extend(I),n.push(I)}const{minX:c,minY:p,maxX:m,maxY:g}=o,x=this.grid.query(c,p,m,g).concat(this.ignoredGrid.query(c,p,m,g)),b={},T={};for(const E of x){const I=E.key;if(b[I.bucketInstanceId]===void 0&&(b[I.bucketInstanceId]={}),b[I.bucketInstanceId][I.featureIndex])continue;const A=[new h.P(E.x1,E.y1),new h.P(E.x2,E.y1),new h.P(E.x2,E.y2),new h.P(E.x1,E.y2)];h.aJ(n,A)&&(b[I.bucketInstanceId][I.featureIndex]=!0,T[I.bucketInstanceId]===void 0&&(T[I.bucketInstanceId]=[]),T[I.bucketInstanceId].push(I.featureIndex))}return T}insertCollisionBox(e,n,o,c,p,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:p,collisionGroupID:m,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,o,c,p,m){const g=o?this.ignoredGrid:this.grid,x={bucketInstanceId:c,featureIndex:p,collisionGroupID:m,overlapMode:n};for(let b=0;b<e.length;b+=4)g.insertCircle(x,e[b],e[b+1],e[b+2])}projectAndGetPerspectiveRatio(e,n,o,c,p){if(p){let m;c?(m=[e,n,c(e,n),1],h.aG(m,m,p)):(m=[e,n,0,1],Ba(m,m,p));const g=m[3];return{x:(m[0]/g+1)/2*this.transform.width+Ie,y:(-m[1]/g+1)/2*this.transform.height+Ie,perspectiveRatio:.5+this.transform.cameraToCenterDistance/g*.5,isOccluded:!1,signedDistanceFromCamera:g}}{const m=this.transform.projectTileCoordinates(e,n,o,c);return{x:(m.point.x+1)/2*this.transform.width+Ie,y:(1-m.point.y)/2*this.transform.height+Ie,perspectiveRatio:.5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5,isOccluded:m.isOccluded,signedDistanceFromCamera:m.signedDistanceFromCamera}}}getPerspectiveRatio(e,n,o,c){const p=this.transform.projectTileCoordinates(e,n,o,c);return .5+this.transform.cameraToCenterDistance/p.signedDistanceFromCamera*.5}isOffscreen(e,n,o,c){return o<Ie||e>=this.screenRightBoundary||c<Ie||n>this.screenBottomBoundary}isInsideGrid(e,n,o,c){return o>=0&&e<this.gridRightBoundary&&c>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const e=h.ar([]);return h.O(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,o,c,p,m,g,x,b,T,E){let I=1,A=0,L=0,j=1;const V=e.anchorPointX+g[0],G=e.anchorPointY+g[1];if(m&&!p){const wt=this.projectAndGetPerspectiveRatio(V+1,G,c,b,E),gt=wt.x-x.x,Rt=Math.atan((wt.y-x.y)/gt)+(gt<0?Math.PI:0),$t=Math.sin(Rt),Zt=Math.cos(Rt);I=Zt,A=$t,L=-$t,j=Zt}else if(!m&&p){const wt=Tt(this.transform);I=wt.vecEast[0],A=wt.vecEast[1],L=wt.vecSouth[0],j=wt.vecSouth[1]}let q=x.x,Y=x.y,$=n;p&&(q=V,Y=G,$=Math.pow(2,-(this.transform.zoom-o.overscaledZ)),$*=this.transform.getPitchedTextCorrection(V,G,c),T||($*=h.an(.5+x.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),T&&(q+=I*T.x*$+L*T.y*$,Y+=A*T.x*$+j*T.y*$);const K=e.x1*$,J=e.x2*$,H=(K+J)/2,it=e.y1*$,ut=e.y2*$,st=(it+ut)/2,ot=[{offsetX:K,offsetY:it},{offsetX:H,offsetY:it},{offsetX:J,offsetY:it},{offsetX:J,offsetY:st},{offsetX:J,offsetY:ut},{offsetX:H,offsetY:ut},{offsetX:K,offsetY:ut},{offsetX:K,offsetY:st}];let ct=[];for(const{offsetX:wt,offsetY:gt}of ot)ct.push(new h.P(q+I*wt+L*gt,Y+A*wt+j*gt));let Mt=!1;if(p){const wt=ct.map(gt=>this.projectAndGetPerspectiveRatio(gt.x,gt.y,c,b,E));Mt=wt.some(gt=>!gt.isOccluded),ct=wt.map(gt=>new h.P(gt.x,gt.y))}else Mt=!0;return{box:h.aK(ct),allPointsOccluded:!Mt}}}class zo{constructor(e,n,o,c){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):c&&o?1:0,this.placed=o}isHidden(){return this.opacity===0&&!this.placed}}class na{constructor(e,n,o,c,p){this.text=new zo(e?e.text:null,n,o,p),this.icon=new zo(e?e.icon:null,n,c,p)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ko{constructor(e,n,o){this.text=e,this.icon=n,this.skipFade=o}}class aa{constructor(e,n,o,c,p){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=o,this.bucketIndex=c,this.tileID=p}}class Jl{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:o=>o.collisionGroupID===n}}return this.collisionGroups[e]}}function Ql(d,e,n,o,c){const{horizontalAlign:p,verticalAlign:m}=h.aR(d);return new h.P(-(p-.5)*e+o[0]*c,-(m-.5)*n+o[1]*c)}class Lu{constructor(e,n,o,c,p){this.transform=e.clone(),this.terrain=n,this.collisionIndex=new Qr(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Jl(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=p,p&&(p.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const n=this.terrain;return n?(o,c)=>n.getElevation(e,o,c):null}getBucketParts(e,n,o,c){const p=o.getBucket(n),m=o.latestFeatureIndex;if(!p||!m||n.id!==p.layerIds[0])return;const g=o.collisionBoxArray,x=p.layers[0].layout,b=p.layers[0].paint,T=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),E=o.tileSize/h.a4,I=o.tileID.toUnwrapped(),A=x.get("text-rotation-alignment")==="map",L=h.aM(o,1,this.transform.zoom),j=h.aN(this.collisionIndex.transform,o,b.get("text-translate"),b.get("text-translate-anchor")),V=h.aN(this.collisionIndex.transform,o,b.get("icon-translate"),b.get("icon-translate-anchor")),G=$e(A,this.transform,L);this.retainedQueryData[p.bucketInstanceId]=new aa(p.bucketInstanceId,m,p.sourceLayerIndex,p.index,o.tileID);const q={bucket:p,layout:x,translationText:j,translationIcon:V,unwrappedTileID:I,pitchedLabelPlaneMatrix:G,scale:T,textPixelRatio:E,holdingForFade:o.holdingForSymbolFade(),collisionBoxArray:g,partiallyEvaluatedTextSize:h.ax(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(c)for(const Y of p.sortKeyRanges){const{sortKey:$,symbolInstanceStart:K,symbolInstanceEnd:J}=Y;e.push({sortKey:$,symbolInstanceStart:K,symbolInstanceEnd:J,parameters:q})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:q})}attemptAnchorPlacement(e,n,o,c,p,m,g,x,b,T,E,I,A,L,j,V,G,q,Y,$){const K=h.aO[e.textAnchor],J=[e.textOffset0,e.textOffset1],H=Ql(K,o,c,J,p),it=this.collisionIndex.placeCollisionBox(n,I,x,b,T,g,m,V,E.predicate,Y,H,$);if((!q||this.collisionIndex.placeCollisionBox(q,I,x,b,T,g,m,G,E.predicate,Y,H,$).placeable)&&it.placeable){let ut;if(this.prevPlacement&&this.prevPlacement.variableOffsets[A.crossTileID]&&this.prevPlacement.placements[A.crossTileID]&&this.prevPlacement.placements[A.crossTileID].text&&(ut=this.prevPlacement.variableOffsets[A.crossTileID].anchor),A.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[A.crossTileID]={textOffset:J,width:o,height:c,anchor:K,textBoxScale:p,prevAnchor:ut},this.markUsedJustification(L,K,A,j),L.allowVerticalPlacement&&(this.markUsedOrientation(L,j,A),this.placedOrientations[A.crossTileID]=j),{shift:H,placedGlyphBoxes:it}}}placeLayerBucketPart(e,n,o){const{bucket:c,layout:p,translationText:m,translationIcon:g,unwrappedTileID:x,pitchedLabelPlaneMatrix:b,textPixelRatio:T,holdingForFade:E,collisionBoxArray:I,partiallyEvaluatedTextSize:A,collisionGroup:L}=e.parameters,j=p.get("text-optional"),V=p.get("icon-optional"),G=h.aP(p,"text-overlap","text-allow-overlap"),q=G==="always",Y=h.aP(p,"icon-overlap","icon-allow-overlap"),$=Y==="always",K=p.get("text-rotation-alignment")==="map",J=p.get("text-pitch-alignment")==="map",H=p.get("icon-text-fit")!=="none",it=p.get("symbol-z-order")==="viewport-y",ut=q&&($||!c.hasIconData()||V),st=$&&(q||!c.hasTextData()||j);!c.collisionArrays&&I&&c.deserializeCollisionBoxes(I);const ot=this.retainedQueryData[c.bucketInstanceId].tileID,ct=this._getTerrainElevationFunc(ot),Mt=this.transform.getFastPathSimpleProjectionMatrix(ot),wt=(gt,Rt,$t)=>{var Zt,ge;if(n[gt.crossTileID])return;if(E)return void(this.placements[gt.crossTileID]=new ko(!1,!1,!1));let ye=!1,Ce=!1,ue=!0,He=null,we={box:null,placeable:!1,offscreen:null,occluded:!1},Ne={placeable:!1},Oe=null,Ue=null,Fi=null,kr=0,Sr=0,ln=0;Rt.textFeatureIndex?kr=Rt.textFeatureIndex:gt.useRuntimeCollisionCircles&&(kr=gt.featureIndex),Rt.verticalTextFeatureIndex&&(Sr=Rt.verticalTextFeatureIndex);const cn=Rt.textBox;if(cn){const Vi=Le=>{let Ae=h.ay.horizontal;if(c.allowVerticalPlacement&&!Le&&this.prevPlacement){const Xe=this.prevPlacement.placedOrientations[gt.crossTileID];Xe&&(this.placedOrientations[gt.crossTileID]=Xe,Ae=Xe,this.markUsedOrientation(c,Ae,gt))}return Ae},Lr=(Le,Ae)=>{if(c.allowVerticalPlacement&>.numVerticalGlyphVertices>0&&Rt.verticalTextBox){for(const Xe of c.writingModes)if(Xe===h.ay.vertical?(we=Ae(),Ne=we):we=Le(),we&&we.placeable)break}else we=Le()},Vn=gt.textAnchorOffsetStartIndex,Nn=gt.textAnchorOffsetEndIndex;if(Nn===Vn){const Le=(Ae,Xe)=>{const he=this.collisionIndex.placeCollisionBox(Ae,G,T,ot,x,J,K,m,L.predicate,ct,void 0,Mt);return he&&he.placeable&&(this.markUsedOrientation(c,Xe,gt),this.placedOrientations[gt.crossTileID]=Xe),he};Lr(()=>Le(cn,h.ay.horizontal),()=>{const Ae=Rt.verticalTextBox;return c.allowVerticalPlacement&>.numVerticalGlyphVertices>0&&Ae?Le(Ae,h.ay.vertical):{box:null,offscreen:null}}),Vi(we&&we.placeable)}else{let Le=h.aO[(ge=(Zt=this.prevPlacement)===null||Zt===void 0?void 0:Zt.variableOffsets[gt.crossTileID])===null||ge===void 0?void 0:ge.anchor];const Ae=(he,un,Qc)=>{const tu=he.x2-he.x1,eu=he.y2-he.y1,Un=gt.textBoxScale,ah=H&&Y==="never"?un:null;let hn=null,uo=G==="never"?1:2,El="never";Le&&uo++;for(let dn=0;dn<uo;dn++){for(let Fr=Vn;Fr<Nn;Fr++){const Cl=c.textAnchorOffsets.get(Fr);if(Le&&Cl.textAnchor!==Le)continue;const Al=this.attemptAnchorPlacement(Cl,he,tu,eu,Un,K,J,T,ot,x,L,El,gt,c,Qc,m,g,ah,ct);if(Al&&(hn=Al.placedGlyphBoxes,hn&&hn.placeable))return ye=!0,He=Al.shift,hn}Le?Le=null:El=G}return o&&!hn&&(hn={box:this.collisionIndex.placeCollisionBox(cn,"always",T,ot,x,J,K,m,L.predicate,ct,void 0,Mt).box,offscreen:!1,placeable:!1,occluded:!1}),hn};Lr(()=>Ae(cn,Rt.iconBox,h.ay.horizontal),()=>{const he=Rt.verticalTextBox;return c.allowVerticalPlacement&&(!we||!we.placeable)&>.numVerticalGlyphVertices>0&&he?Ae(he,Rt.verticalIconBox,h.ay.vertical):{box:null,occluded:!0,offscreen:null}}),we&&(ye=we.placeable,ue=we.offscreen);const Xe=Vi(we&&we.placeable);if(!ye&&this.prevPlacement){const he=this.prevPlacement.variableOffsets[gt.crossTileID];he&&(this.variableOffsets[gt.crossTileID]=he,this.markUsedJustification(c,he.anchor,gt,Xe))}}}if(Oe=we,ye=Oe&&Oe.placeable,ue=Oe&&Oe.offscreen,gt.useRuntimeCollisionCircles&>.centerJustifiedTextSymbolIndex>=0){const Vi=c.text.placedSymbolArray.get(gt.centerJustifiedTextSymbolIndex),Lr=h.az(c.textSizeData,A,Vi),Vn=p.get("text-padding");Ue=this.collisionIndex.placeCollisionCircles(G,Vi,c.lineVertexArray,c.glyphOffsetArray,Lr,x,b,o,J,L.predicate,gt.collisionCircleDiameter,Vn,m,ct),Ue.circles.length&&Ue.collisionDetected&&!o&&h.w("Collisions detected, but collision boxes are not shown"),ye=q||Ue.circles.length>0&&!Ue.collisionDetected,ue=ue&&Ue.offscreen}if(Rt.iconFeatureIndex&&(ln=Rt.iconFeatureIndex),Rt.iconBox){const Vi=Lr=>this.collisionIndex.placeCollisionBox(Lr,Y,T,ot,x,J,K,g,L.predicate,ct,H&&He?He:void 0,Mt);Ne&&Ne.placeable&&Rt.verticalIconBox?(Fi=Vi(Rt.verticalIconBox),Ce=Fi.placeable):(Fi=Vi(Rt.iconBox),Ce=Fi.placeable),ue=ue&&Fi.offscreen}const jn=j||gt.numHorizontalGlyphVertices===0&>.numVerticalGlyphVertices===0,Xi=V||gt.numIconVertices===0;jn||Xi?Xi?jn||(Ce=Ce&&ye):ye=Ce&&ye:Ce=ye=Ce&&ye;const Rr=Ce&&Fi.placeable;if(ye&&Oe.placeable&&this.collisionIndex.insertCollisionBox(Oe.box,G,p.get("text-ignore-placement"),c.bucketInstanceId,Ne&&Ne.placeable&&Sr?Sr:kr,L.ID),Rr&&this.collisionIndex.insertCollisionBox(Fi.box,Y,p.get("icon-ignore-placement"),c.bucketInstanceId,ln,L.ID),Ue&&ye&&this.collisionIndex.insertCollisionCircles(Ue.circles,G,p.get("text-ignore-placement"),c.bucketInstanceId,kr,L.ID),o&&this.storeCollisionData(c.bucketInstanceId,$t,Rt,Oe,Fi,Ue),gt.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(c.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[gt.crossTileID]=new ko((ye||ut)&&!Oe?.occluded,(Ce||st)&&!Fi?.occluded,ue||c.justReloaded),n[gt.crossTileID]=!0};if(it){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const gt=c.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Rt=gt.length-1;Rt>=0;--Rt){const $t=gt[Rt];wt(c.symbolInstances.get($t),c.collisionArrays[$t],$t)}}else for(let gt=e.symbolInstanceStart;gt<e.symbolInstanceEnd;gt++)wt(c.symbolInstances.get(gt),c.collisionArrays[gt],gt);c.justReloaded=!1}storeCollisionData(e,n,o,c,p,m){if(o.textBox||o.iconBox){let g,x;this.collisionBoxArrays.has(e)?g=this.collisionBoxArrays.get(e):(g=new Map,this.collisionBoxArrays.set(e,g)),g.has(n)?x=g.get(n):(x={text:null,icon:null},g.set(n,x)),o.textBox&&(x.text=c.box),o.iconBox&&(x.icon=p.box)}if(m){let g=this.collisionCircleArrays[e];g===void 0&&(g=this.collisionCircleArrays[e]=[]);for(let x=0;x<m.circles.length;x+=4)g.push(m.circles[x+0]-Ie),g.push(m.circles[x+1]-Ie),g.push(m.circles[x+2]),g.push(m.collisionDetected?1:0)}}markUsedJustification(e,n,o,c){let p;p=c===h.ay.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[h.aQ(n)];const m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(const g of m)g>=0&&(e.text.placedSymbolArray.get(g).crossTileID=p>=0&&g!==p?0:o.crossTileID)}markUsedOrientation(e,n,o){const c=n===h.ay.horizontal||n===h.ay.horizontalOnly?n:0,p=n===h.ay.vertical?n:0,m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const g of m)e.text.placedSymbolArray.get(g).placedOrientation=c;o.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=p)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let o=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const c=n?n.symbolFadeChange(e):1,p=n?n.opacities:{},m=n?n.variableOffsets:{},g=n?n.placedOrientations:{};for(const x in this.placements){const b=this.placements[x],T=p[x];T?(this.opacities[x]=new na(T,c,b.text,b.icon),o=o||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[x]=new na(null,c,b.text,b.icon,b.skipFade),o=o||b.text||b.icon)}for(const x in p){const b=p[x];if(!this.opacities[x]){const T=new na(b,c,!1,!1);T.isHidden()||(this.opacities[x]=T,o=o||b.text.placed||b.icon.placed)}}for(const x in m)this.variableOffsets[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.variableOffsets[x]=m[x]);for(const x in g)this.placedOrientations[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.placedOrientations[x]=g[x]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");o?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){const o={};for(const c of n){const p=c.getBucket(e);p&&c.latestFeatureIndex&&e.id===p.layerIds[0]&&this.updateBucketOpacities(p,c.tileID,o,c.collisionBoxArray)}}updateBucketOpacities(e,n,o,c){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const p=e.layers[0],m=p.layout,g=new na(null,0,!1,!1,!0),x=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),T=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=m.get("text-rotation-alignment")==="map",I=m.get("text-pitch-alignment")==="map",A=m.get("icon-text-fit")!=="none",L=new na(null,0,x&&(b||!e.hasIconData()||m.get("icon-optional")),b&&(x||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&c&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(c);const j=(G,q,Y)=>{for(let $=0;$<q/4;$++)G.opacityVertexArray.emplaceBack(Y);G.hasVisibleVertices=G.hasVisibleVertices||Y!==Cr},V=this.collisionBoxArrays.get(e.bucketInstanceId);for(let G=0;G<e.symbolInstances.length;G++){const q=e.symbolInstances.get(G),{numHorizontalGlyphVertices:Y,numVerticalGlyphVertices:$,crossTileID:K}=q;let J=this.opacities[K];o[K]?J=g:J||(J=L,this.opacities[K]=J),o[K]=!0;const H=q.numIconVertices>0,it=this.placedOrientations[q.crossTileID],ut=it===h.ay.vertical,st=it===h.ay.horizontal||it===h.ay.horizontalOnly;if(Y>0||$>0){const ct=nc(J.text);j(e.text,Y,ut?Cr:ct),j(e.text,$,st?Cr:ct);const Mt=J.text.isHidden();[q.rightJustifiedTextSymbolIndex,q.centerJustifiedTextSymbolIndex,q.leftJustifiedTextSymbolIndex].forEach(Rt=>{Rt>=0&&(e.text.placedSymbolArray.get(Rt).hidden=Mt||ut?1:0)}),q.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(q.verticalPlacedTextSymbolIndex).hidden=Mt||st?1:0);const wt=this.variableOffsets[q.crossTileID];wt&&this.markUsedJustification(e,wt.anchor,q,it);const gt=this.placedOrientations[q.crossTileID];gt&&(this.markUsedJustification(e,"left",q,gt),this.markUsedOrientation(e,gt,q))}if(H){const ct=nc(J.icon),Mt=!(A&&q.verticalPlacedIconSymbolIndex&&ut);q.placedIconSymbolIndex>=0&&(j(e.icon,q.numIconVertices,Mt?ct:Cr),e.icon.placedSymbolArray.get(q.placedIconSymbolIndex).hidden=J.icon.isHidden()),q.verticalPlacedIconSymbolIndex>=0&&(j(e.icon,q.numVerticalIconVertices,Mt?Cr:ct),e.icon.placedSymbolArray.get(q.verticalPlacedIconSymbolIndex).hidden=J.icon.isHidden())}const ot=V&&V.has(G)?V.get(G):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const ct=e.collisionArrays[G];if(ct){let Mt=new h.P(0,0);if(ct.textBox||ct.verticalTextBox){let wt=!0;if(T){const gt=this.variableOffsets[K];gt?(Mt=Ql(gt.anchor,gt.width,gt.height,gt.textOffset,gt.textBoxScale),E&&Mt._rotate(I?-this.transform.bearingInRadians:this.transform.bearingInRadians)):wt=!1}if(ct.textBox||ct.verticalTextBox){let gt;ct.textBox&&(gt=ut),ct.verticalTextBox&&(gt=st),tc(e.textCollisionBox.collisionVertexArray,J.text.placed,!wt||gt,ot.text,Mt.x,Mt.y)}}if(ct.iconBox||ct.verticalIconBox){const wt=!!(!st&&ct.verticalIconBox);let gt;ct.iconBox&&(gt=wt),ct.verticalIconBox&&(gt=!wt),tc(e.iconCollisionBox.collisionVertexArray,J.icon.placed,gt,ot.icon,A?Mt.x:0,A?Mt.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,n){const o=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*o>e}setStale(){this.stale=!0}}function tc(d,e,n,o,c,p){o&&o.length!==0||(o=[0,0,0,0]);const m=o[0]-Ie,g=o[1]-Ie,x=o[2]-Ie,b=o[3]-Ie;d.emplaceBack(e?1:0,n?1:0,c||0,p||0,m,g),d.emplaceBack(e?1:0,n?1:0,c||0,p||0,x,g),d.emplaceBack(e?1:0,n?1:0,c||0,p||0,x,b),d.emplaceBack(e?1:0,n?1:0,c||0,p||0,m,b)}const ec=Math.pow(2,25),ic=Math.pow(2,24),Ro=Math.pow(2,17),Lo=Math.pow(2,16),rc=Math.pow(2,9),Fo=Math.pow(2,8),Bo=Math.pow(2,1);function nc(d){if(d.opacity===0&&!d.placed)return 0;if(d.opacity===1&&d.placed)return 4294967295;const e=d.placed?1:0,n=Math.floor(127*d.opacity);return n*ec+e*ic+n*Ro+e*Lo+n*rc+e*Fo+n*Bo+e}const Cr=0;class Es{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,o,c,p){const m=this._bucketParts;for(;this._currentTileIndex<e.length;)if(n.getBucketParts(m,c,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,p())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort((g,x)=>g.sortKey-x.sortKey));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,o),this._currentPartIndex++,p())return!0;return!1}}class ac{constructor(e,n,o,c,p,m,g,x){this.placement=new Lu(e,n,m,g,x),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=c,this._showCollisionBoxes=p,this._done=!1}isDone(){return this._done}continuePlacement(e,n,o){const c=ie(),p=()=>!this._forceFullPlacement&&ie()-c>2;for(;this._currentPlacementIndex>=0;){const m=n[e[this._currentPlacementIndex]],g=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=g)&&(!m.maxzoom||m.maxzoom>g)){if(this._inProgressLayer||(this._inProgressLayer=new Es(m)),this._inProgressLayer.continuePlacement(o[m.source],this.placement,this._showCollisionBoxes,m,p))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const xr=512/h.a4/2;class sc{constructor(e,n,o){this.tileID=e,this.bucketInstanceId=o,this._symbolsByKey={};const c=new Map;for(let p=0;p<n.length;p++){const m=n.get(p),g=m.key,x=c.get(g);x?x.push(m):c.set(g,[m])}for(const[p,m]of c){const g={positions:m.map(x=>({x:Math.floor(x.anchorX*xr),y:Math.floor(x.anchorY*xr)})),crossTileIDs:m.map(x=>x.crossTileID)};if(g.positions.length>128){const x=new h.aS(g.positions.length,16,Uint16Array);for(const{x:b,y:T}of g.positions)x.add(b,T);x.finish(),delete g.positions,g.index=x}this._symbolsByKey[p]=g}}getScaledCoordinates(e,n){const{x:o,y:c,z:p}=this.tileID.canonical,{x:m,y:g,z:x}=n.canonical,b=xr/Math.pow(2,x-p),T=(g*h.a4+e.anchorY)*b,E=c*h.a4*xr;return{x:Math.floor((m*h.a4+e.anchorX)*b-o*h.a4*xr),y:Math.floor(T-E)}}findMatches(e,n,o){const c=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let p=0;p<e.length;p++){const m=e.get(p);if(m.crossTileID)continue;const g=this._symbolsByKey[m.key];if(!g)continue;const x=this.getScaledCoordinates(m,n);if(g.index){const b=g.index.range(x.x-c,x.y-c,x.x+c,x.y+c).sort();for(const T of b){const E=g.crossTileIDs[T];if(!o[E]){o[E]=!0,m.crossTileID=E;break}}}else if(g.positions)for(let b=0;b<g.positions.length;b++){const T=g.positions[b],E=g.crossTileIDs[b];if(Math.abs(T.x-x.x)<=c&&Math.abs(T.y-x.y)<=c&&!o[E]){o[E]=!0,m.crossTileID=E;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class Fu{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class tn{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const n=Math.round((e-this.lng)/360);if(n!==0)for(const o in this.indexes){const c=this.indexes[o],p={};for(const m in c){const g=c[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+n),p[g.tileID.key]=g}this.indexes[o]=p}this.lng=e}addBucket(e,n,o){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let p=0;p<n.symbolInstances.length;p++)n.symbolInstances.get(p).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const c=this.usedCrossTileIDs[e.overscaledZ];for(const p in this.indexes){const m=this.indexes[p];if(Number(p)>e.overscaledZ)for(const g in m){const x=m[g];x.tileID.isChildOf(e)&&x.findMatches(n.symbolInstances,e,c)}else{const g=m[e.scaledTo(Number(p)).key];g&&g.findMatches(n.symbolInstances,e,c)}}for(let p=0;p<n.symbolInstances.length;p++){const m=n.symbolInstances.get(p);m.crossTileID||(m.crossTileID=o.generate(),c[m.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new sc(e,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(e,n){for(const o of n.getCrossTileIDsLists())for(const c of o)delete this.usedCrossTileIDs[e][c]}removeStaleBuckets(e){let n=!1;for(const o in this.indexes){const c=this.indexes[o];for(const p in c)e[c[p].bucketInstanceId]||(this.removeBucketCrossTileIDs(o,c[p]),delete c[p],n=!0)}return n}}class Mn{constructor(){this.layerIndexes={},this.crossTileIDs=new Fu,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,n,o){let c=this.layerIndexes[e.id];c===void 0&&(c=this.layerIndexes[e.id]=new tn);let p=!1;const m={};c.handleWrapJump(o);for(const g of n){const x=g.getBucket(e);x&&e.id===x.layerIds[0]&&(x.bucketInstanceId||(x.bucketInstanceId=++this.maxBucketInstanceId),c.addBucket(g.tileID,x,this.crossTileIDs)&&(p=!0),m[x.bucketInstanceId]=!0)}return c.removeStaleBuckets(m)&&(p=!0),p}pruneUnusedLayers(e){const n={};e.forEach(o=>{n[o]=!0});for(const o in this.layerIndexes)n[o]||delete this.layerIndexes[o]}}var Kt="void main() {fragColor=vec4(1.0);}";const $i={prelude:te(`#ifdef GL_ES
|
||
precision mediump float;
|
||
#else
|
||
#if !defined(lowp)
|
||
#define lowp
|
||
#endif
|
||
#if !defined(mediump)
|
||
#define mediump
|
||
#endif
|
||
#if !defined(highp)
|
||
#define highp
|
||
#endif
|
||
#endif
|
||
out highp vec4 fragColor;`,`#ifdef GL_ES
|
||
precision highp float;
|
||
#else
|
||
#if !defined(lowp)
|
||
#define lowp
|
||
#endif
|
||
#if !defined(mediump)
|
||
#define mediump
|
||
#endif
|
||
#if !defined(highp)
|
||
#define highp
|
||
#endif
|
||
#endif
|
||
vec2 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
|
||
);}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
|
||
);}
|
||
#ifdef TERRAIN3D
|
||
uniform 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;
|
||
#endif
|
||
const 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) {
|
||
#ifdef TERRAIN3D
|
||
highp 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));
|
||
#else
|
||
return 1.0;
|
||
#endif
|
||
}float calculate_visibility(vec4 pos) {
|
||
#ifdef TERRAIN3D
|
||
vec3 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;
|
||
#else
|
||
return 1.0;
|
||
#endif
|
||
}float ele(vec2 pos) {
|
||
#ifdef TERRAIN3D
|
||
vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
|
||
#else
|
||
return 0.0;
|
||
#endif
|
||
}float get_elevation(vec2 pos) {
|
||
#ifdef TERRAIN3D
|
||
#ifdef GLOBE
|
||
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
|
||
#endif
|
||
vec2 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;
|
||
#else
|
||
return 0.0;
|
||
#endif
|
||
}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:te("","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:te("",`#define GLOBE_RADIUS 6371008.8
|
||
uniform 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
|
||
);}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);
|
||
if (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
|
||
);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:te(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:te(`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;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,"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:te(`in vec3 v_data;in float v_visibility;
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define mediump float radius
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define highp vec4 stroke_color
|
||
#pragma mapbox: define mediump float stroke_width
|
||
#pragma mapbox: define lowp float stroke_opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize mediump float radius
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize highp vec4 stroke_color
|
||
#pragma mapbox: initialize mediump float stroke_width
|
||
#pragma mapbox: initialize lowp float stroke_opacity
|
||
vec2 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;}
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define mediump float radius
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define highp vec4 stroke_color
|
||
#pragma mapbox: define mediump float stroke_width
|
||
#pragma mapbox: define lowp float stroke_opacity
|
||
void main(void) {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize mediump float radius
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize highp vec4 stroke_color
|
||
#pragma mapbox: initialize mediump float stroke_width
|
||
#pragma mapbox: initialize lowp float stroke_opacity
|
||
vec2 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) {
|
||
#ifdef GLOBE
|
||
vec3 center_vector=projectToSphere(circle_center);
|
||
#endif
|
||
float 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 {
|
||
#ifdef GLOBE
|
||
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
|
||
#else
|
||
vec4 projected_center=projectTileWithElevation(circle_center,ele);
|
||
#endif
|
||
corner_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);}
|
||
#ifdef GLOBE
|
||
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
|
||
#else
|
||
gl_Position=projectTileWithElevation(corner_position,ele);
|
||
#endif
|
||
} 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:te(Kt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:te(`uniform highp float u_intensity;in vec2 v_extrude;
|
||
#pragma mapbox: define highp float weight
|
||
#define GAUSS_COEF 0.3989422804014327
|
||
void main() {
|
||
#pragma mapbox: initialize highp float weight
|
||
float 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);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#pragma mapbox: define highp float weight
|
||
#pragma mapbox: define mediump float radius
|
||
const highp float ZERO=1.0/255.0/16.0;
|
||
#define GAUSS_COEF 0.3989422804014327
|
||
void main(void) {
|
||
#pragma mapbox: initialize highp float weight
|
||
#pragma mapbox: initialize mediump float radius
|
||
vec2 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);
|
||
#ifdef GLOBE
|
||
vec2 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);
|
||
#else
|
||
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
|
||
#endif
|
||
}`),heatmapTexture:te(`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;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(0.0);
|
||
#endif
|
||
}`,"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:te("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:te("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:te(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform 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
|
||
{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));
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,"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:te("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:te(Kt,`in vec2 a_pos;void main() {
|
||
#ifdef GLOBE
|
||
gl_Position=projectTileFor3D(a_pos,0.0);
|
||
#else
|
||
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
|
||
#endif
|
||
}`),fill:te(`#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
fragColor=color*opacity;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_fill_translate;in vec2 a_pos;
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:te(`in vec2 v_pos;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 outline_color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 outline_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 outline_color
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 outline_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
}`),fillOutlinePattern:te(`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;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
vec2 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;
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
}`),fillPattern:te(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
vec2 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;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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:te(`in vec4 v_color;void main() {fragColor=v_color;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#ifdef TERRAIN3D
|
||
in vec2 a_centroid;
|
||
#endif
|
||
out vec4 v_color;
|
||
#pragma mapbox: define highp float base
|
||
#pragma mapbox: define highp float height
|
||
#pragma mapbox: define highp vec4 color
|
||
void main() {
|
||
#pragma mapbox: initialize highp float base
|
||
#pragma mapbox: initialize highp float height
|
||
#pragma mapbox: initialize highp vec4 color
|
||
vec3 normal=a_normal_ed.xyz;
|
||
#ifdef TERRAIN3D
|
||
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
||
#else
|
||
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
||
#endif
|
||
base=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;
|
||
#ifdef GLOBE
|
||
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
||
#else
|
||
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
||
#endif
|
||
float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
|
||
#ifdef GLOBE
|
||
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
|
||
#endif
|
||
directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:te(`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;
|
||
#pragma mapbox: define lowp float base
|
||
#pragma mapbox: define lowp float height
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float base
|
||
#pragma mapbox: initialize lowp float height
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#ifdef TERRAIN3D
|
||
in vec2 a_centroid;
|
||
#endif
|
||
#ifdef GLOBE
|
||
out vec3 v_sphere_pos;
|
||
#endif
|
||
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
|
||
#pragma mapbox: define lowp float base
|
||
#pragma mapbox: define lowp float height
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float base
|
||
#pragma mapbox: initialize lowp float height
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
vec2 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;
|
||
#ifdef TERRAIN3D
|
||
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
||
#else
|
||
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
||
#endif
|
||
base=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;
|
||
#ifdef GLOBE
|
||
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
||
#else
|
||
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
||
#endif
|
||
vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
|
||
? a_pos
|
||
: 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:te(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform 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);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,"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:te(`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];
|
||
#define PI 3.141592653589793
|
||
#define STANDARD 0
|
||
#define COMBINED 1
|
||
#define IGOR 2
|
||
#define MULTIDIRECTIONAL 3
|
||
#define BASIC 4
|
||
float 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
|
||
{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
|
||
{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);}
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,"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:te(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
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);fragColor=color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
in 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;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
float 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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float 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;
|
||
#endif
|
||
v_width2=vec2(outset,inset);}`),lineGradient:te(`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;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
in 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;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
float 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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float 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;
|
||
#endif
|
||
v_width2=vec2(outset,inset);}`),linePattern:te(`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
uniform 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;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
vec2 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;
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
#define LINE_DISTANCE_SCALE 2.0
|
||
in 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;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define lowp vec4 pattern_from
|
||
#pragma mapbox: define lowp vec4 pattern_to
|
||
#pragma mapbox: define lowp float pixel_ratio_from
|
||
#pragma mapbox: define lowp float pixel_ratio_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 pattern_from
|
||
#pragma mapbox: initialize mediump vec4 pattern_to
|
||
#pragma mapbox: initialize lowp float pixel_ratio_from
|
||
#pragma mapbox: initialize lowp float pixel_ratio_to
|
||
float 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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float 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;
|
||
#endif
|
||
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:te(`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;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
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 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);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
#define LINE_DISTANCE_SCALE 2.0
|
||
in 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;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define highp vec4 color
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 color
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
float 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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float 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;
|
||
#endif
|
||
float 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:te(`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;
|
||
#ifdef GLOBE
|
||
in float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
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);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);
|
||
#ifdef GLOBE
|
||
if (v_depth > 1.0) {discard;}
|
||
#endif
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`
|
||
#define scale 0.015873016
|
||
#define LINE_DISTANCE_SCALE 2.0
|
||
in 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;
|
||
#ifdef GLOBE
|
||
out float v_depth;
|
||
#endif
|
||
#pragma mapbox: define lowp float blur
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define mediump float gapwidth
|
||
#pragma mapbox: define lowp float offset
|
||
#pragma mapbox: define mediump float width
|
||
#pragma mapbox: define lowp float floorwidth
|
||
#pragma mapbox: define mediump vec4 dasharray_from
|
||
#pragma mapbox: define mediump vec4 dasharray_to
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float blur
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize mediump float gapwidth
|
||
#pragma mapbox: initialize lowp float offset
|
||
#pragma mapbox: initialize mediump float width
|
||
#pragma mapbox: initialize lowp float floorwidth
|
||
#pragma mapbox: initialize mediump vec4 dasharray_from
|
||
#pragma mapbox: initialize mediump vec4 dasharray_to
|
||
float 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;
|
||
#ifdef GLOBE
|
||
v_depth=gl_Position.z/gl_Position.w;
|
||
#endif
|
||
#ifdef TERRAIN3D
|
||
v_gamma_scale=1.0;
|
||
#else
|
||
float 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;
|
||
#endif
|
||
float 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:te(`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);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#ifdef GLOBE
|
||
if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
|
||
#endif
|
||
v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:te(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#pragma mapbox: define lowp float opacity
|
||
void main() {
|
||
#pragma mapbox: initialize lowp float opacity
|
||
vec2 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 ?
|
||
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
u_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;
|
||
#ifdef GLOBE
|
||
if(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);}
|
||
#endif
|
||
vec4 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:te(`#define SDF_PX 8.0
|
||
uniform 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;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
float 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);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
vec2 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 ?
|
||
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
u_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;
|
||
#ifdef GLOBE
|
||
if(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);}
|
||
#endif
|
||
vec4 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:te(`#define SDF_PX 8.0
|
||
#define SDF 1.0
|
||
#define ICON 0.0
|
||
uniform 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;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
float 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;
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
return;}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);
|
||
#ifdef OVERDRAW_INSPECTOR
|
||
fragColor=vec4(1.0);
|
||
#endif
|
||
}`,`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;
|
||
#pragma mapbox: define highp vec4 fill_color
|
||
#pragma mapbox: define highp vec4 halo_color
|
||
#pragma mapbox: define lowp float opacity
|
||
#pragma mapbox: define lowp float halo_width
|
||
#pragma mapbox: define lowp float halo_blur
|
||
void main() {
|
||
#pragma mapbox: initialize highp vec4 fill_color
|
||
#pragma mapbox: initialize highp vec4 halo_color
|
||
#pragma mapbox: initialize lowp float opacity
|
||
#pragma mapbox: initialize lowp float halo_width
|
||
#pragma mapbox: initialize lowp float halo_blur
|
||
vec2 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 ?
|
||
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
u_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;
|
||
#ifdef GLOBE
|
||
if(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);}
|
||
#endif
|
||
vec4 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:te("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:te("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:te("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:te("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:te(`in 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
|
||
);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:te("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 te(d,e){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=e.match(/in ([\w]+) ([\w]+)/g),c=d.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=p?p.concat(c):c,g={};return{fragmentSource:d=d.replace(n,(x,b,T,E,I)=>(g[I]=!0,b==="define"?`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
in ${T} ${E} ${I};
|
||
#else
|
||
uniform ${T} ${E} u_${I};
|
||
#endif
|
||
`:`
|
||
#ifdef HAS_UNIFORM_u_${I}
|
||
${T} ${E} ${I} = u_${I};
|
||
#endif
|
||
`)),vertexSource:e=e.replace(n,(x,b,T,E,I)=>{const A=E==="float"?"vec2":"vec4",L=I.match(/color/)?"color":A;return g[I]?b==="define"?`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
uniform lowp float u_${I}_t;
|
||
in ${T} ${A} a_${I};
|
||
out ${T} ${E} ${I};
|
||
#else
|
||
uniform ${T} ${E} u_${I};
|
||
#endif
|
||
`:L==="vec4"?`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
${I} = a_${I};
|
||
#else
|
||
${T} ${E} ${I} = u_${I};
|
||
#endif
|
||
`:`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
${I} = unpack_mix_${L}(a_${I}, u_${I}_t);
|
||
#else
|
||
${T} ${E} ${I} = u_${I};
|
||
#endif
|
||
`:b==="define"?`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
uniform lowp float u_${I}_t;
|
||
in ${T} ${A} a_${I};
|
||
#else
|
||
uniform ${T} ${E} u_${I};
|
||
#endif
|
||
`:L==="vec4"?`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
${T} ${E} ${I} = a_${I};
|
||
#else
|
||
${T} ${E} ${I} = u_${I};
|
||
#endif
|
||
`:`
|
||
#ifndef HAS_UNIFORM_u_${I}
|
||
${T} ${E} ${I} = unpack_mix_${L}(a_${I}, u_${I}_t);
|
||
#else
|
||
${T} ${E} ${I} = u_${I};
|
||
#endif
|
||
`}),staticAttributes:o,staticUniforms:m}}class en{constructor(e,n,o){this.vertexBuffer=e,this.indexBuffer=n,this.segments=o}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var qe=h.aT([{name:"a_pos",type:"Int16",components:2}]);const pi="#define PROJECTION_MERCATOR",fi="mercator";class Je{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return fi}get shaderDefine(){return pi}get shaderPreludeCode(){return $i.projectionMercator}get vertexShaderPreludeCode(){return $i.projectionMercator.vertexSource}get subdivisionGranularity(){return h.aU.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,o,c,p){if(this._cachedMesh)return this._cachedMesh;const m=new h.aV;m.emplaceBack(0,0),m.emplaceBack(h.a4,0),m.emplaceBack(0,h.a4),m.emplaceBack(h.a4,h.a4);const g=e.createVertexBuffer(m,qe.members),x=h.aW.simpleSegment(0,0,4,2),b=new h.aX;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3);const T=e.createIndexBuffer(b);return this._cachedMesh=new en(g,T,x),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class _e{constructor(e=0,n=0,o=0,c=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(o)||o<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=o,this.right=c}interpolate(e,n,o){return n.top!=null&&e.top!=null&&(this.top=h.G.number(e.top,n.top,o)),n.bottom!=null&&e.bottom!=null&&(this.bottom=h.G.number(e.bottom,n.bottom,o)),n.left!=null&&e.left!=null&&(this.left=h.G.number(e.left,n.left,o)),n.right!=null&&e.right!=null&&(this.right=h.G.number(e.right,n.right,o)),this}getCenter(e,n){const o=h.an((this.left+e-this.right)/2,0,e),c=h.an((this.top+n-this.bottom)/2,0,n);return new h.P(o,c)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new _e(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Cs(d,e){if(!d.renderWorldCopies||d.lngRange)return;const n=e.lng-d.center.lng;e.lng+=n>180?-360:n<-180?360:0}function Ti(d){return Math.max(0,Math.floor(d))}class zi{constructor(e,n){var o;this.applyConstrain=(c,p)=>this._constrainOverride!==null?this._constrainOverride(c,p):this._callbacks.defaultConstrain(c,p),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch==null?0:n?.minPitch,this._maxPitch=n?.maxPitch==null?60:n?.maxPitch,this._constrainOverride=(o=n?.constrainOverride)!==null&&o!==void 0?o:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new h.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ti(this._zoom),this._scale=h.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new _e,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,n,o){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Ti(this._zoom),this._scale=h.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new _e(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!o&&e.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}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(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){e===void 0&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,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 h.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const n=h.W(e,-180,180)*Math.PI/180;var o,c,p,m,g,x,b,T,E;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=si(),o=this._rotationMatrix,p=-this._bearingInRadians,m=(c=this._rotationMatrix)[0],g=c[1],x=c[2],b=c[3],T=Math.sin(p),E=Math.cos(p),o[0]=m*E+x*T,o[1]=g*E+b*T,o[2]=m*-T+x*E,o[3]=g*-T+b*E)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const n=h.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const n=e/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return h.aY(this._fovInRadians)}setFov(e){e=h.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=h.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const n=this.applyConstrain(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=h.aq(n),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,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(e,n){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,o){this._unmodified=!1,this._edgeInsets.interpolate(e,n,o),this.constrainInternal(),this._calcMatrices()}resize(e,n,o=!0){this._width=e,this._height=n,o&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new Me([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-h.ao,h.ao])}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{const{minX:o,minY:c,maxX:p,maxY:m}=h.ab.fromPoints(n).extend(e);return[new h.P(o,c),new h.P(p,c),new h.P(p,m),new h.P(o,m),new h.P(o,c)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:o}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(o),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=h.ar(new Float64Array(16));h.Q(e,e,[this._width/2,-this._height/2,1]),h.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=h.ar(new Float64Array(16)),h.Q(e,e,[1,-1,1]),h.O(e,e,[-1,-1,0]),h.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,o,c){const p=o!==void 0?o:this.bearing,m=c=c!==void 0?c:this.pitch,g=h.aa.fromLngLat(e,n),x=-Math.cos(h.ap(m)),b=Math.sin(h.ap(m)),T=b*Math.sin(h.ap(p)),E=-b*Math.cos(h.ap(p));let I=this.elevation;const A=n-I;let L;x*A>=0||Math.abs(x)<.1?(L=1e4,I=n+L*x):L=-A/x;let j,V,G=h.aZ(1,g.y),q=0;do{if(q+=1,q>10)break;V=L/G,j=new h.aa(g.x+T*V,g.y+E*V),G=1/j.meterInMercatorCoordinateUnits()}while(Math.abs(L-V*G)>1e-12);return{center:j.toLngLat(),elevation:I,zoom:h.at(this.height/2/Math.tan(this.fovInRadians/2)/V/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const n=h.as(1,this.center.lat)*this.worldSize,o=this.cameraToCenterDistance/n,c=h.aa.fromLngLat(this.center,this.elevation),p=rt(this.center,this.elevation,this.pitch,this.bearing,o);this._elevation=e;const m=this.calculateCenterFromCameraLngLatAlt(p.toLngLat(),h.aZ(p.z,c.y),this.bearing,this.pitch);this._elevation=m.elevation,this._center=m.center,this.setZoom(m.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new h.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=h.as(1,this.center.lat)*this.worldSize;return rt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const n=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/n,e.canonical.y/n,1/n/h.a4,1/n/h.a4]}}class mi{constructor(e,n){this.min=e,this.max=n,this.center=h.a_([],h.a$([],this.min,this.max),.5)}quadrant(e){const n=[e%2==0,e<2],o=h.b0(this.min),c=h.b0(this.max);for(let p=0;p<n.length;p++)o[p]=n[p]?this.min[p]:this.center[p],c[p]=n[p]?this.center[p]:this.max[p];return c[2]=this.max[2],new mi(o,c)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let n=!0;for(let o=0;o<e.planes.length;o++){const c=this.intersectsPlane(e.planes[o]);if(c===0)return 0;c===1&&(n=!1)}return n?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let n=e[3],o=e[3];for(let c=0;c<3;c++)e[c]>0?(n+=e[c]*this.min[c],o+=e[c]*this.max[c]):(o+=e[c]*this.min[c],n+=e[c]*this.max[c]);return n>=0?2:o<0?0:1}}class oc{distanceToTile2d(e,n,o,c){const p=c.distanceX([e,n]),m=c.distanceY([e,n]);return Math.hypot(p,m)}getWrap(e,n,o){return o}getTileBoundingVolume(e,n,o,c){var p,m;let g=0,x=0;if(c?.terrain){const T=new h.a1(e.z,n,e.z,e.x,e.y),E=c.terrain.getMinMaxElevation(T);g=(p=E.minElevation)!==null&&p!==void 0?p:Math.min(0,o),x=(m=E.maxElevation)!==null&&m!==void 0?m:Math.max(0,o)}const b=1<<e.z;return new mi([n+e.x/b,e.y/b,g],[n+(e.x+1)/b,(e.y+1)/b,x])}allowVariableZoom(e,n){const o=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,c=h.an(78.5-o/2,0,60);return!!n.terrain||e.pitch>c}allowWorldCopies(){return!0}prepareNextFrame(){}}class rn{constructor(e,n,o){this.points=e,this.planes=n,this.aabb=o}static fromInvProjectionMatrix(e,n=1,o=0,c,p){const m=p?[[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]],g=Math.pow(2,o),x=[[-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(I=>function(A,L,j,V){const G=h.aG([],A,L),q=1/G[3]/j*V;return h.b5(G,G,[q,q,1/G[3],q])}(I,e,n,g));c&&function(I,A,L,j){const V=j?4:0,G=j?0:4;let q=0;const Y=[],$=[];for(let H=0;H<4;H++){const it=h.b1([],I[H+G],I[H+V]),ut=h.b6(it);h.a_(it,it,1/ut),Y.push(ut),$.push(it)}for(let H=0;H<4;H++){const it=h.b7(I[H+V],$[H],L);q=it!==null&&it>=0?Math.max(q,it):Math.max(q,Y[H])}const K=function(H,it){const ut=h.b1([],H[it[0]],H[it[1]]),st=h.b1([],H[it[2]],H[it[1]]),ot=[0,0,0,0];return h.b2(ot,h.b3([],ut,st)),ot[3]=-h.b4(ot,H[it[0]]),ot}(I,A),J=function(H,it){const ut=h.b8(H),st=h.b9([],H,1/ut),ot=h.b1([],it,h.a_([],st,h.b4(it,st))),ct=h.b8(ot);if(ct>0){const Mt=Math.sqrt(1-st[3]*st[3]),wt=h.a_([],st,-st[3]),gt=h.a$([],wt,h.a_([],ot,Mt/ct));return h.ba(it,gt)}return null}(L,K);if(J!==null){const H=J/h.b4($[0],K);q=Math.min(q,H)}for(let H=0;H<4;H++){const it=Math.min(q,Y[H]);I[H+G]=[I[H+V][0]+$[H][0]*it,I[H+V][1]+$[H][1]*it,I[H+V][2]+$[H][2]*it,1]}}(x,m[0],c,p);const b=m.map(I=>{const A=h.b1([],x[I[0]],x[I[1]]),L=h.b1([],x[I[2]],x[I[1]]),j=h.b2([],h.b3([],A,L)),V=-h.b4(j,x[I[1]]);return j.concat(V)}),T=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],E=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const I of x)for(let A=0;A<3;A++)T[A]=Math.min(T[A],I[A]),E[A]=Math.max(E[A],I[A]);return new rn(x,b,new mi(T,E))}}class ve{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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,o){return this._helper.interpolatePadding(e,n,o)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,o=!0){this._helper.resize(e,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e,n){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(n,o)=>{o=h.an(+o,this.minZoom,this.maxZoom);const c={center:new h.V(n.lng,n.lat),zoom:o};let p=this._helper._lngRange;if(!this._helper._renderWorldCopies&&p===null){const $=179.9999999999;p=[-$,$]}const m=this.tileSize*h.aq(c.zoom);let g=0,x=m,b=0,T=m,E=0,I=0;const{x:A,y:L}=this.size;if(this._helper._latRange){const $=this._helper._latRange;g=h.X($[1])*m,x=h.X($[0])*m,x-g<L&&(E=L/(x-g))}p&&(b=h.W(h.Y(p[0])*m,0,m),T=h.W(h.Y(p[1])*m,0,m),T<b&&(T+=m),T-b<A&&(I=A/(T-b)));const{x:j,y:V}=W(m,n);let G,q;const Y=Math.max(I||0,E||0);if(Y){const $=new h.P(I?(T+b)/2:j,E?(x+g)/2:V);return c.center=X(m,$).wrap(),c.zoom+=h.at(Y),c}if(this._helper._latRange){const $=L/2;V-$<g&&(q=g+$),V+$>x&&(q=x-$)}if(p){const $=(b+T)/2;let K=j;this._helper._renderWorldCopies&&(K=h.W(j,$-m/2,$+m/2));const J=A/2;K-J<b&&(G=b+J),K+J>T&&(G=T-J)}if(G!==void 0||q!==void 0){const $=new h.P(G??j,q??V);c.center=X(m,$).wrap()}return c},this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new zi({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},e),this._coveringTilesDetailsProvider=new oc}clone(){const e=new ve;return e.apply(this),e}apply(e,n,o){this._helper.apply(e,n,o)}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(e){const n=[new h.bb(0,e)];if(this._helper._renderWorldCopies){const o=this.screenPointToMercatorCoordinate(new h.P(0,0)),c=this.screenPointToMercatorCoordinate(new h.P(this._helper._width,0)),p=this.screenPointToMercatorCoordinate(new h.P(this._helper._width,this._helper._height)),m=this.screenPointToMercatorCoordinate(new h.P(0,this._helper._height)),g=Math.floor(Math.min(o.x,c.x,p.x,m.x)),x=Math.floor(Math.max(o.x,c.x,p.x,m.x)),b=1;for(let T=g-b;T<=x+b;T++)T!==0&&n.push(new h.bb(T,e))}return n}getCameraFrustum(){return rn.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const n=this.screenPointToLocation(this.centerPoint,e),o=e?e.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(o)}setLocationAtPoint(e,n){const o=h.as(this.elevation,this.center.lat),c=this.screenPointToMercatorCoordinateAtZ(n,o),p=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,o),m=h.aa.fromLngLat(e),g=new h.aa(m.x-(c.x-p.x),m.y-(c.y-p.y));this.setCenter(g?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(h.aa.fromLngLat(e),n.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(h.aa.fromLngLat(e))}screenPointToLocation(e,n){var o;return(o=this.screenPointToMercatorCoordinate(e,n))===null||o===void 0?void 0:o.toLngLat()}screenPointToMercatorCoordinate(e,n){if(n){const o=n.pointCoordinate(e);if(o!=null)return o}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){const o=n||0,c=[e.x,e.y,0,1],p=[e.x,e.y,1,1];h.aG(c,c,this._pixelMatrixInverse),h.aG(p,p,this._pixelMatrixInverse);const m=c[3],g=p[3],x=c[1]/m,b=p[1]/g,T=c[2]/m,E=p[2]/g,I=T===E?0:(o-T)/(E-T);return new h.aa(h.G.number(c[0]/m,p[0]/g,I)/this.worldSize,h.G.number(x,b,I)/this.worldSize,o)}coordinatePoint(e,n=0,o=this._pixelMatrix){const c=[e.x*this.worldSize,e.y*this.worldSize,n,1];return h.aG(c,c,o),new h.P(c[0]/c[3],c[1]/c[3])}getBounds(){const e=Math.max(0,this._helper._height/2-nt(this));return new Me().extend(this.screenPointToLocation(new h.P(0,e))).extend(this.screenPointToLocation(new h.P(this._helper._width,e))).extend(this.screenPointToLocation(new h.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new h.P(0,this._helper._height)))}isPointOnMapSurface(e,n){return n?n.pointCoordinate(e)!=null:e.y>this.height/2-nt(this)}calculatePosMatrix(e,n=!1,o){var c;const p=(c=e.key)!==null&&c!==void 0?c:h.bc(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),m=n?this._alignedPosMatrixCache:this._posMatrixCache;if(m.has(p)){const b=m.get(p);return o?b.f32:b.f64}const g=U(e,this.worldSize);h.S(g,n?this._alignedProjMatrix:this._viewProjMatrix,g);const x={f64:g,f32:new Float32Array(g)};return m.set(p,x),o?x.f32:x.f64}calculateFogMatrix(e){const n=e.key,o=this._fogMatrixCacheF32;if(o.has(n))return o.get(n);const c=U(e,this.worldSize);return h.S(c,this._fogMatrix,c),o.set(n,new Float32Array(c)),o.get(n)}calculateCenterFromCameraLngLatAlt(e,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,o,c)}_calculateNearFarZIfNeeded(e,n,o){if(!this._helper.autoCalculateNearFarZ)return;const c=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),p=e-c*this._helper._pixelPerMeter/Math.cos(n),m=c<0?p:e,g=Math.PI/2+this.pitchInRadians,x=h.ap(this.fov)*(Math.abs(Math.cos(h.ap(this.roll)))*this.height+Math.abs(Math.sin(h.ap(this.roll)))*this.width)/this.height*(.5+o.y/this.height),b=Math.sin(x)*m/Math.sin(h.an(Math.PI-g-x,.01,Math.PI-.01)),T=nt(this),E=Math.atan(T/this._helper.cameraToCenterDistance),I=h.ap(.75),A=E>I?2*E*(.5+o.y/(2*T)):I,L=Math.sin(A)*m/Math.sin(h.an(Math.PI-g-A,.01,Math.PI-.01)),j=Math.min(b,L);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*j+m),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,n=W(this.worldSize,this.center),o=n.x,c=n.y;this._helper._pixelPerMeter=h.as(1,this.center.lat)*this.worldSize;const p=h.ap(Math.min(this.pitch,B)),m=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(p));let g;this._calculateNearFarZIfNeeded(m,p,e),g=new Float64Array(16),h.bd(g,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),h.aA(this._invProjMatrix,g),g[8]=2*-e.x/this._helper._width,g[9]=2*e.y/this._helper._height,this._projectionMatrix=h.be(g),h.Q(g,g,[1,-1,1]),h.O(g,g,[0,0,-this._helper.cameraToCenterDistance]),h.bf(g,g,-this.rollInRadians),h.bg(g,g,this.pitchInRadians),h.bf(g,g,-this.bearingInRadians),h.O(g,g,[-o,-c,0]),this._mercatorMatrix=h.Q([],g,[this.worldSize,this.worldSize,this.worldSize]),h.Q(g,g,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=h.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,g),h.O(g,g,[0,0,-this.elevation]),this._viewProjMatrix=g,this._invViewProjMatrix=h.aA([],g);const x=[0,0,-1,1];h.aG(x,x,this._invViewProjMatrix),this._cameraPosition=[x[0]/x[3],x[1]/x[3],x[2]/x[3]],this._fogMatrix=new Float64Array(16),h.bd(this._fogMatrix,this.fovInRadians,this.width/this.height,m,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,h.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),h.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),h.bf(this._fogMatrix,this._fogMatrix,-this.rollInRadians),h.bg(this._fogMatrix,this._fogMatrix,this.pitchInRadians),h.bf(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),h.O(this._fogMatrix,this._fogMatrix,[-o,-c,0]),h.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),h.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=h.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,g);const b=this._helper._width%2/2,T=this._helper._height%2/2,E=Math.cos(this.bearingInRadians),I=Math.sin(-this.bearingInRadians),A=o-Math.round(o)+E*b+I*T,L=c-Math.round(c)+E*T+I*b,j=new Float64Array(g);if(h.O(j,j,[A>.5?A-1:A,L>.5?L-1:L,0]),this._alignedProjMatrix=j,g=h.aA(new Float64Array(16),this._pixelMatrix),!g)throw new Error("failed to invert matrix");this._pixelMatrixInverse=g,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new h.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return h.aG(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=h.as(1,this.center.lat)*this.worldSize;return rt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){const o=h.aa.fromLngLat(e),c=[o.x*this.worldSize,o.y*this.worldSize,n,1];return h.aG(c,c,this._viewProjMatrix),c[2]/c[3]}getProjectionData(e){const{overscaledTileID:n,aligned:o,applyTerrainMatrix:c}=e,p=this._helper.getMercatorTileCoordinates(n),m=n?this.calculatePosMatrix(n,o,!0):null;let g;return g=n&&n.terrainRttPosMatrix32f&&c?n.terrainRttPosMatrix32f:m||h.bh(),{mainMatrix:g,tileMercatorCoords:p,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:g}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,n,o){return 1}transformLightDirection(e){return h.b0(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,n,o,c){const p=this.calculatePosMatrix(o);let m;c?(m=[e,n,c(e,n),1],h.aG(m,m,p)):(m=[e,n,0,1],Ba(m,m,p));const g=m[3];return{point:new h.P(m[0]/g,m[1]/g),signedDistanceFromCamera:g,isOccluded:!1}}populateCache(e){for(const n of e)this.calculatePosMatrix(n)}getMatrixForModel(e,n){const o=h.aa.fromLngLat(e,n),c=o.meterInMercatorCoordinateUnits(),p=h.bi();return h.O(p,p,[o.x,o.y,o.z]),h.bf(p,p,Math.PI),h.bg(p,p,Math.PI/2),h.Q(p,p,[-c,c,c]),p}getProjectionDataForCustomLayer(e=!0){const n=new h.a1(0,0,0,0,0),o=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),c=U(n,this.worldSize);h.S(c,this._viewProjMatrix,c),o.tileMercatorCoords=[0,0,1,1];const p=[h.a4,h.a4,this.worldSize/this._helper.pixelsPerMeter],m=h.bj();return h.Q(m,c,p),o.fallbackMatrix=m,o.mainMatrix=m,o}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function sa(){h.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function nn(d){if(d.useSlerp)if(d.k<1){const e=h.bk(d.startEulerAngles.roll,d.startEulerAngles.pitch,d.startEulerAngles.bearing),n=h.bk(d.endEulerAngles.roll,d.endEulerAngles.pitch,d.endEulerAngles.bearing),o=new Float64Array(4);h.bl(o,e,n,d.k);const c=h.bm(o);d.tr.setRoll(c.roll),d.tr.setPitch(c.pitch),d.tr.setBearing(c.bearing)}else d.tr.setRoll(d.endEulerAngles.roll),d.tr.setPitch(d.endEulerAngles.pitch),d.tr.setBearing(d.endEulerAngles.bearing);else d.tr.setRoll(h.G.number(d.startEulerAngles.roll,d.endEulerAngles.roll,d.k)),d.tr.setPitch(h.G.number(d.startEulerAngles.pitch,d.endEulerAngles.pitch,d.k)),d.tr.setBearing(h.G.number(d.startEulerAngles.bearing,d.endEulerAngles.bearing,d.k))}function Oa(d,e,n,o,c){const p=c.padding,m=W(c.worldSize,n.getNorthWest()),g=W(c.worldSize,n.getNorthEast()),x=W(c.worldSize,n.getSouthEast()),b=W(c.worldSize,n.getSouthWest()),T=h.ap(-o),E=m.rotate(T),I=g.rotate(T),A=x.rotate(T),L=b.rotate(T),j=new h.P(Math.max(E.x,I.x,L.x,A.x),Math.max(E.y,I.y,L.y,A.y)),V=new h.P(Math.min(E.x,I.x,L.x,A.x),Math.min(E.y,I.y,L.y,A.y)),G=j.sub(V),q=(c.width-(p.left+p.right+e.left+e.right))/G.x,Y=(c.height-(p.top+p.bottom+e.top+e.bottom))/G.y;if(Y<0||q<0)return void sa();const $=Math.min(h.at(c.scale*Math.min(q,Y)),d.maxZoom),K=h.P.convert(d.offset),J=new h.P((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(h.ap(o)),H=K.add(J).mult(c.scale/h.aq($));return{center:X(c.worldSize,m.add(x).div(2).sub(H)),zoom:$,bearing:o}}class ki{get useGlobeControls(){return!1}handlePanInertia(e,n){const o=e.mag(),c=Math.abs(nt(n));return{easingOffset:e.mult(Math.min(.75*c/o,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(e,n){e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta),e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta)}handleMapControlsPan(e,n,o){e.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(o,e.around)}cameraForBoxAndBearing(e,n,o,c,p){return Oa(e,n,o,c,p)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom!==void 0?+n.zoom:e.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(h.V.convert(n.center))}handleEaseTo(e,n){const o=e.zoom,c=e.padding,p={roll:e.roll,pitch:e.pitch,bearing:e.bearing},m={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},g=n.zoom!==void 0,x=!e.isPaddingEqual(n.padding);let b=!1;const T=g?+n.zoom:e.zoom;let E=e.centerPoint.add(n.offsetAsPoint);const I=e.screenPointToLocation(E),{center:A,zoom:L}=e.applyConstrain(h.V.convert(n.center||I),T??o);Cs(e,A);const j=W(e.worldSize,I),V=W(e.worldSize,A).sub(j),G=h.aq(L-o);return b=L!==o,{easeFunc:q=>{if(b&&e.setZoom(h.G.number(o,L,q)),h.bn(p,m)||nn({startEulerAngles:p,endEulerAngles:m,tr:e,k:q,useSlerp:p.roll!=m.roll}),x&&(e.interpolatePadding(c,n.padding,q),E=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{const Y=h.aq(e.zoom-o),$=L>o?Math.min(2,G):Math.max(.5,G),K=Math.pow($,1-q),J=X(e.worldSize,j.add(V.mult(q*K)).mult(Y));e.setLocationAtPoint(e.renderWorldCopies?J.wrap():J,E)}},isZooming:b,elevationCenter:A}}handleFlyTo(e,n){const o=n.zoom!==void 0,c=e.zoom,p=e.applyConstrain(h.V.convert(n.center||n.locationAtOffset),o?+n.zoom:c),m=p.center,g=p.zoom;Cs(e,m);const x=W(e.worldSize,n.locationAtOffset),b=W(e.worldSize,m).sub(x),T=b.mag(),E=h.aq(g-c);let I;if(n.minZoom!==void 0){const A=Math.min(+n.minZoom,c,g),L=e.applyConstrain(m,A).zoom;I=h.aq(L-c)}return{easeFunc:(A,L,j,V)=>{e.setZoom(A===1?g:c+h.at(L));const G=A===1?m:X(e.worldSize,x.add(b.mult(j)).mult(L));e.setLocationAtPoint(e.renderWorldCopies?G.wrap():G,V)},scaleOfZoom:E,targetCenter:m,scaleOfMinZoom:I,pixelPathLength:T}}}class be{constructor(e,n,o){this.blendFunction=e,this.blendColor=n,this.mask=o}}be.Replace=[1,0],be.disabled=new be(be.Replace,h.bo.transparent,[!1,!1,!1,!1]),be.unblended=new be(be.Replace,h.bo.transparent,[!0,!0,!0,!0]),be.alphaBlended=new be([1,771],h.bo.transparent,[!0,!0,!0,!0]);const vr=2305;class re{constructor(e,n,o){this.enable=e,this.mode=n,this.frontFace=o}}re.disabled=new re(!1,1029,vr),re.backCCW=new re(!0,1029,vr),re.frontCCW=new re(!0,1028,vr);class Ht{constructor(e,n,o){this.func=e,this.mask=n,this.range=o}}Ht.ReadOnly=!1,Ht.ReadWrite=!0,Ht.disabled=new Ht(519,Ht.ReadOnly,[0,1]);const oa=7680;class ee{constructor(e,n,o,c,p,m){this.test=e,this.ref=n,this.mask=o,this.fail=c,this.depthFail=p,this.pass=m}}ee.disabled=new ee({func:519,mask:0},0,0,oa,oa,oa);const la=new WeakMap;function nr(d){var e;if(la.has(d))return la.get(d);{const n=(e=d.getParameter(d.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return la.set(d,n),n}}class ja{get awaitingQuery(){return!!this._readbackQueue}constructor(e){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=e;const n=e.context,o=n.gl;this._texFormat=o.RGBA,this._texType=o.UNSIGNED_BYTE;const c=new h.aV;c.emplaceBack(-1,-1),c.emplaceBack(2,-1),c.emplaceBack(-1,2);const p=new h.aX;p.emplaceBack(0,1,2),this._fullscreenTriangle=new en(n.createVertexBuffer(c,qe.members),n.createIndexBuffer(p),h.aW.simpleSegment(0,0,c.length,p.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(o.TEXTURE1);const m=o.createTexture();o.bindTexture(o.TEXTURE_2D,m),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texImage2D(o.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(m),nr(o)&&(this._pbo=o.createBuffer(),o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.bufferData(o.PIXEL_PACK_BUFFER,4,o.STREAM_READ),o.bindBuffer(o.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,n){const o=this._updateCount;return this._readbackQueue?o>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():o>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,n=e.gl;e.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){const o=this._cachedRenderContext.context,c=o.gl;if(this._bindFramebuffer(),o.viewport.set([0,0,this._texWidth,this._texHeight]),o.clear({color:h.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(o,c.TRIANGLES,Ht.disabled,ee.disabled,be.unblended,re.disabled,((p,m)=>({u_input:p,u_output_expected:m}))(e,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&nr(c)){c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.readBuffer(c.COLOR_ATTACHMENT0),c.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const p=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:p}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&nr(e)){const n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return h.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ja._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let n=0;return n+=e[0]/256,n+=e[1]/65536,n+=e[2]/16777216,e[3]<127&&(n=-n),n/128}}const In=h.a4/128;function As(d,e){const n=d.granularity!==void 0?Math.max(d.granularity,1):1,o=n+(d.generateBorders?2:0),c=n+(d.extendToNorthPole||d.generateBorders?1:0)+(d.extendToSouthPole||d.generateBorders?1:0),p=o+1,m=c+1,g=d.generateBorders?-1:0,x=d.generateBorders||d.extendToNorthPole?-1:0,b=n+(d.generateBorders?1:0),T=n+(d.generateBorders||d.extendToSouthPole?1:0),E=p*m,I=o*c*6,A=p*m>65536;if(A&&e==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const L=A||e==="32bit",j=new Int16Array(2*E);let V=0;for(let Y=x;Y<=T;Y++)for(let $=g;$<=b;$++){let K=$/n*h.a4;$===-1&&(K=-In),$===n+1&&(K=h.a4+In);let J=Y/n*h.a4;Y===-1&&(J=d.extendToNorthPole?h.bq:-In),Y===n+1&&(J=d.extendToSouthPole?h.br:h.a4+In),j[V++]=K,j[V++]=J}const G=L?new Uint32Array(I):new Uint16Array(I);let q=0;for(let Y=0;Y<c;Y++)for(let $=0;$<o;$++){const K=$+1+Y*p,J=$+(Y+1)*p,H=$+1+(Y+1)*p;G[q++]=$+Y*p,G[q++]=J,G[q++]=K,G[q++]=K,G[q++]=J,G[q++]=H}return{vertices:j.buffer.slice(0),indices:G.buffer.slice(0),uses32bitIndices:L}}const Va=new h.aU({fill:new h.bs(128,2),line:new h.bs(512,0),tile:new h.bs(128,32),stencil:new h.bs(128,1),circle:3});class Na{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 $i.projectionGlobe}get vertexShaderPreludeCode(){return $i.projectionMercator.vertexSource}get subdivisionGranularity(){return Va}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new ja(e));const n=h.X(this._errorQueryLatitudeDegrees),o=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,c=this._errorMeasurement.updateErrorLoop(n,o),p=ie();c!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=c,this._errorMeasurementLastChangeTime=p);const m=Math.min(Math.max((p-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=h.bt(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,h.bu(m))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,n,o,c,p){const m=(p==="stencil"?Va.stencil:Va.tile).getGranularityForZoomLevel(n.z);return this._getMesh(e,{granularity:m,generateBorders:o,extendToNorthPole:n.y===0&&c,extendToSouthPole:n.y===(1<<n.z)-1&&c})}_getMesh(e,n){const o=this._getMeshKey(n);if(o in this._tileMeshCache)return this._tileMeshCache[o];const c=function(p,m){const g=As(m,"16bit"),x=h.aV.deserialize({arrayBuffer:g.vertices,length:g.vertices.byteLength/2/2}),b=h.aX.deserialize({arrayBuffer:g.indices,length:g.indices.byteLength/2/3});return new en(p.createVertexBuffer(x,qe.members),p.createIndexBuffer(b),h.aW.simpleSegment(0,0,x.length,b.length))}(e,n);return this._tileMeshCache[o]=c,c}recalculate(e){}hasTransition(){const e=ie();let n=!1;return n=n||(e-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const Ds=new h.t({type:new h.D(h.u.projection.type)});class ca extends h.E{constructor(e){super(),this._transitionable=new h.x(Ds,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new h.H(0)),this._mercatorProjection=new Je,this._verticalPerspectiveProjection=new Na}get transitionState(){const e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof h.bv){if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.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(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,n,o,c,p){return this.currentProjection.getMeshFromTileID(e,n,o,c,p)}setProjection(e){this._transitionable.setValue("type",e?.type||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function lc(d){const e=zs(d.worldSize,d.center.lat);return 2*Math.PI*e}function br(d,e,n,o,c){const p=1/(1<<c),m=e/h.a4*p+o*p,g=h.bx((d/h.a4*p+n*p)*Math.PI*2+Math.PI,2*Math.PI),x=2*Math.atan(Math.exp(Math.PI-m*Math.PI*2))-.5*Math.PI,b=Math.cos(x),T=new Float64Array(3);return T[0]=Math.sin(g)*b,T[1]=Math.sin(x),T[2]=Math.cos(g)*b,T}function oi(d){return function(e,n){const o=Math.cos(n),c=new Float64Array(3);return c[0]=Math.sin(e)*o,c[1]=Math.sin(n),c[2]=Math.cos(e)*o,c}(d.lng*Math.PI/180,d.lat*Math.PI/180)}function zs(d,e){return d/(2*Math.PI)/Math.cos(e*Math.PI/180)}function cc(d){const e=Math.asin(d[1])/Math.PI*180,n=Math.sqrt(d[0]*d[0]+d[2]*d[2]);if(n>1e-6){const o=d[0]/n,c=Math.acos(d[2]/n),p=(o>0?c:-c)/Math.PI*180;return new h.V(h.W(p,-180,180),e)}return new h.V(0,e)}function li(d){return Math.cos(d*Math.PI/180)}function We(d,e){const n=li(d),o=li(e);return h.at(o/n)}function ar(d,e){const n=d.rotate(e.bearingInRadians),o=e.zoom+We(e.center.lat,0),c=h.bt(1/li(e.center.lat),1/li(Math.min(Math.abs(e.center.lat),60)),h.bw(o,7,3,0,1)),p=360/lc({worldSize:e.worldSize,center:{lat:e.center.lat}});return new h.V(e.center.lng-n.x*p*c,h.an(e.center.lat+n.y*p,-h.ao,h.ao))}function ua(d){const e=.5*d,n=Math.sin(e),o=Math.cos(e);return Math.log(n+o)-Math.log(o-n)}function Oo(d,e,n,o){const c=d.lat+n*o;if(Math.abs(n)>1){const p=(Math.sign(d.lat+n)!==Math.sign(d.lat)?-Math.abs(d.lat):Math.abs(d.lat))*Math.PI/180,m=Math.abs(d.lat+n)*Math.PI/180,g=ua(p+o*(m-p)),x=ua(p),b=ua(m);return new h.V(d.lng+e*((g-x)/(b-x)),c)}return new h.V(d.lng+e*o,c)}class uc{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,n,o,c){const p=`${e.z}_${e.x}_${e.y}_${c?.terrain?"t":""}`,m=this._cache.get(p);if(m)return m;const g=this._cachePrevious.get(p);if(g)return this._cache.set(p,g),g;const x=this._boundingVolumeFactory(e,n,o,c);return this._cache.set(p,x),this._hadAnyChanges=!0,x}}class sr{constructor(e,n,o,c){this.min=o,this.max=c,this.points=e,this.planes=n}static fromAabb(e,n){const o=[];for(let c=0;c<8;c++)o.push([1&~c?e[0]:n[0],(c>>1&1)==1?n[1]:e[1],(c>>2&1)==1?n[2]:e[2]]);return new sr(o,[[-1,0,0,n[0]],[1,0,0,-e[0]],[0,-1,0,n[1]],[0,1,0,-e[1]],[0,0,-1,n[2]],[0,0,1,-e[2]]],e,n)}static fromCenterSizeAngles(e,n,o){const c=h.bA([],o[0],o[1],o[2]),p=h.bB([],[n[0],0,0],c),m=h.bB([],[0,n[1],0],c),g=h.bB([],[0,0,n[2]],c),x=[...e],b=[...e];for(let E=0;E<8;E++)for(let I=0;I<3;I++){const A=e[I]+p[I]*(1&~E?-1:1)+m[I]*((E>>1&1)==1?1:-1)+g[I]*((E>>2&1)==1?1:-1);x[I]=Math.min(x[I],A),b[I]=Math.max(b[I],A)}const T=[];for(let E=0;E<8;E++){const I=[...e];h.a$(I,I,h.a_([],p,1&~E?-1:1)),h.a$(I,I,h.a_([],m,(E>>1&1)==1?1:-1)),h.a$(I,I,h.a_([],g,(E>>2&1)==1?1:-1)),T.push(I)}return new sr(T,[[...p,-h.b4(p,T[0])],[...m,-h.b4(m,T[0])],[...g,-h.b4(g,T[0])],[-p[0],-p[1],-p[2],-h.b4(p,T[7])],[-m[0],-m[1],-m[2],-h.b4(m,T[7])],[-g[0],-g[1],-g[2],-h.b4(g,T[7])]],x,b)}intersectsFrustum(e){let n=!0;const o=this.points.length,c=this.planes.length,p=e.planes.length,m=e.points.length;for(let g=0;g<p;g++){const x=e.planes[g];let b=0;for(let T=0;T<o;T++){const E=this.points[T];x[0]*E[0]+x[1]*E[1]+x[2]*E[2]+x[3]>=0&&b++}if(b===0)return 0;b<o&&(n=!1)}if(n)return 2;for(let g=0;g<c;g++){const x=this.planes[g];let b=0;for(let T=0;T<m;T++){const E=e.points[T];x[0]*E[0]+x[1]*E[1]+x[2]*E[2]+x[3]>=0&&b++}if(b===0)return 0}return 1}intersectsPlane(e){const n=this.points.length;let o=0;for(let c=0;c<n;c++){const p=this.points[c];e[0]*p[0]+e[1]*p[1]+e[2]*p[2]+e[3]>=0&&o++}return o===n?2:o===0?0:1}}function ks(d,e,n){const o=d-e;return o<0?-o:Math.max(0,o-n)}function jo(d,e,n,o,c){const p=d-n;let m;return m=p<0?Math.min(-p,1+p-c):p>1?Math.min(Math.max(p-c,0),1-p):0,Math.max(m,ks(e,o,c))}class Bu{constructor(){this._boundingVolumeCache=new uc(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,n,o,c){const p=1<<o.z,m=1/p,g=o.x/p,x=o.y/p;let b=2;return b=Math.min(b,jo(e,n,g,x,m)),b=Math.min(b,jo(e,n,g+.5,-x-m,m)),b=Math.min(b,jo(e,n,g+.5,2-x-m,m)),b}getWrap(e,n,o){const c=1<<n.z,p=1/c,m=n.x/c,g=ks(e.x,m,p),x=ks(e.x,m-1,p),b=ks(e.x,m+1,p),T=Math.min(g,x,b);return T===b?1:T===x?-1:0}allowVariableZoom(e,n){return jt(e,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,n,o,c){return this._boundingVolumeCache.getTileBoundingVolume(e,n,o,c)}_computeTileBoundingVolume(e,n,o,c){var p,m;let g=0,x=0;if(c?.terrain){const b=new h.a1(e.z,n,e.z,e.x,e.y),T=c.terrain.getMinMaxElevation(b);g=(p=T.minElevation)!==null&&p!==void 0?p:Math.min(0,o),x=(m=T.maxElevation)!==null&&m!==void 0?m:Math.max(0,o)}if(g/=h.bD,x/=h.bD,g+=1,x+=1,e.z<=0)return sr.fromAabb([-x,-x,-x],[x,x,x]);if(e.z===1)return sr.fromAabb([e.x===0?-x:0,e.y===0?0:-x,-x],[e.x===0?0:x,e.y===0?x:0,x]);{const b=[br(0,0,e.x,e.y,e.z),br(h.a4,0,e.x,e.y,e.z),br(h.a4,h.a4,e.x,e.y,e.z),br(0,h.a4,e.x,e.y,e.z)],T=[];for(const ot of b)T.push(h.a_([],ot,x));if(x!==g)for(const ot of b)T.push(h.a_([],ot,g));e.y===0&&T.push([0,1,0]),e.y===(1<<e.z)-1&&T.push([0,-1,0]);const E=[1,1,1],I=[-1,-1,-1];for(const ot of T)for(let ct=0;ct<3;ct++)E[ct]=Math.min(E[ct],ot[ct]),I[ct]=Math.max(I[ct],ot[ct]);const A=br(h.a4/2,h.a4/2,e.x,e.y,e.z),L=h.b3([],[0,1,0],A);h.b2(L,L);const j=h.b3([],A,L);h.b2(j,j);const V=h.b3([],b[2],b[1]);h.b2(V,V);const G=h.b3([],b[0],b[3]);h.b2(G,G),T.push(h.a_([],A,x)),e.y>=(1<<e.z)/2&&T.push(h.a_([],br(h.a4/2,0,e.x,e.y,e.z),x)),e.y<(1<<e.z)/2&&T.push(h.a_([],br(h.a4/2,h.a4,e.x,e.y,e.z),x));const q=hc(A,T),Y=hc(j,T),$=[-A[0],-A[1],-A[2],q.max],K=[A[0],A[1],A[2],-q.min],J=[-j[0],-j[1],-j[2],Y.max],H=[j[0],j[1],j[2],-Y.min],it=[...V,0],ut=[...G,0],st=[];return e.y===0?st.push(h.bC(ut,it,$),h.bC(ut,it,K)):st.push(h.bC(J,it,$),h.bC(J,it,K),h.bC(J,ut,$),h.bC(J,ut,K)),e.y===(1<<e.z)-1?st.push(h.bC(ut,it,$),h.bC(ut,it,K)):st.push(h.bC(H,it,$),h.bC(H,it,K),h.bC(H,ut,$),h.bC(H,ut,K)),new sr(st,[$,K,J,H,it,ut],E,I)}}}function hc(d,e){let n=1/0,o=-1/0;for(const c of e){const p=h.b4(d,c);n=Math.min(n,p),o=Math.max(o,p)}return{min:n,max:o}}class Rs{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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,o){return this._helper.interpolatePadding(e,n,o)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n){this._helper.resize(e,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e){}constructor(e){this._cachedClippingPlane=h.bE(),this._projectionMatrix=h.bi(),this._globeViewProjMatrix32f=h.bh(),this._globeViewProjMatrixNoCorrection=h.bi(),this._globeViewProjMatrixNoCorrectionInverted=h.bi(),this._globeProjMatrixInverted=h.bi(),this._cameraPosition=h.by(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(n,o)=>{const c=h.an(n.lat,-h.ao,h.ao),p=h.an(+o,this.minZoom+We(0,c),this.maxZoom);return{center:new h.V(n.lng,c),zoom:p}},this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new zi({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},e),this._coveringTilesDetailsProvider=new Bu}clone(){const e=new Rs;return e.apply(this),e}apply(e,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=h.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:n,applyGlobeMatrix:o}=e,c=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:c,clippingPlane:this._cachedClippingPlane,projectionTransition:o?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const n=this.pitchInRadians,o=this.cameraToCenterDistance/e,c=Math.sin(n)*o,p=Math.cos(n)*o+1,m=1/Math.sqrt(c*c+p*p)*1;let g=-c,x=p;const b=Math.sqrt(g*g+x*x);g/=b,x/=b;const T=[0,g,x];h.bF(T,T,[0,0,0],-this.bearingInRadians),h.bG(T,T,[0,0,0],-1*this.center.lat*Math.PI/180),h.bH(T,T,[0,0,0],this.center.lng*Math.PI/180);const E=1/h.b6(T);return h.a_(T,T,E),[...T,-m*E]}isLocationOccluded(e){return!this.isSurfacePointVisible(oi(e))}transformLightDirection(e){const n=this._helper._center.lng*Math.PI/180,o=this._helper._center.lat*Math.PI/180,c=Math.cos(o),p=[Math.sin(n)*c,Math.sin(o),Math.cos(n)*c],m=[p[2],0,-p[0]],g=[0,0,0];h.b3(g,m,p),h.b2(m,m),h.b2(g,g);const x=[0,0,0];return h.b2(x,[m[0]*e[0]+g[0]*e[1]+p[0]*e[2],m[1]*e[0]+g[1]*e[1]+p[1]*e[2],m[2]*e[0]+g[2]*e[1]+p[2]*e[2]]),x}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,o){const c=function(g,x,b){const T=1/(1<<b.z);return new h.aa(g/h.a4*T+b.x*T,x/h.a4*T+b.y*T)}(e,n,o.canonical),p=(m=c.y,[h.bx(c.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-m*Math.PI*2))-.5*Math.PI]);var m;return this.getCircleRadiusCorrection()/Math.cos(p[1])}projectTileCoordinates(e,n,o,c){const p=o.canonical,m=br(e,n,p.x,p.y,p.z),g=1+(c?c(e,n):0)/h.bD,x=[m[0]*g,m[1]*g,m[2]*g,1];h.aG(x,x,this._globeViewProjMatrixNoCorrection);const b=this._cachedClippingPlane,T=b[0]*m[0]+b[1]*m[1]+b[2]*m[2]+b[3]<0;return{point:new h.P(x[0]/x[3],x[1]/x[3]),signedDistanceFromCamera:x[3],isOccluded:T}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=zs(this.worldSize,this.center.lat),n=h.bj(),o=h.bj();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),h.bd(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const c=this.centerOffset;n[8]=2*-c.x/this._helper._width,n[9]=2*c.y/this._helper._height,this._projectionMatrix=h.be(n),this._globeProjMatrixInverted=h.bj(),h.aA(this._globeProjMatrixInverted,n),h.O(n,n,[0,0,-this.cameraToCenterDistance]),h.bf(n,n,this.rollInRadians),h.bg(n,n,-this.pitchInRadians),h.bf(n,n,this.bearingInRadians),h.O(n,n,[0,0,-e]);const p=h.by();p[0]=e,p[1]=e,p[2]=e,h.bg(o,n,this.center.lat*Math.PI/180),h.bI(o,o,-this.center.lng*Math.PI/180),h.Q(o,o,p),this._globeViewProjMatrixNoCorrection=o,h.bg(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),h.bI(n,n,-this.center.lng*Math.PI/180),h.Q(n,n,p),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=h.bj(),h.aA(this._globeViewProjMatrixNoCorrectionInverted,o);const m=h.by();this._cameraPosition=h.by(),this._cameraPosition[2]=this.cameraToCenterDistance/e,h.bF(this._cameraPosition,this._cameraPosition,m,-this.rollInRadians),h.bG(this._cameraPosition,this._cameraPosition,m,this.pitchInRadians),h.bF(this._cameraPosition,this._cameraPosition,m,-this.bearingInRadians),h.a$(this._cameraPosition,this._cameraPosition,[0,0,1]),h.bG(this._cameraPosition,this._cameraPosition,m,-this.center.lat*Math.PI/180),h.bH(this._cameraPosition,this._cameraPosition,m,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const g=h.be(this._globeViewProjMatrixNoCorrectionInverted);h.Q(g,g,[1,1,-1]),this._cachedFrustum=rn.fromInvProjectionMatrix(g,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){h.w("calculateFogMatrix is not supported on globe projection.");const n=h.bj();return h.ar(n),n}getVisibleUnwrappedCoordinates(e){return[new h.bb(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&h.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(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const o=oi(e);h.a_(o,o,1+n/h.bD);const c=h.bE();return h.aG(c,[o[0],o[1],o[2],1],this._globeViewProjMatrixNoCorrection),c[2]/c[3]}populateCache(e){}getBounds(){const e=.5*this.width,n=.5*this.height,o=[new h.P(0,0),new h.P(e,0),new h.P(this.width,0),new h.P(this.width,n),new h.P(this.width,this.height),new h.P(e,this.height),new h.P(0,this.height),new h.P(0,n)],c=[];for(const E of o)c.push(this.unprojectScreenPoint(E));let p=0,m=0,g=0,x=0;const b=this.center;for(const E of c){const I=h.bJ(b.lng,E.lng),A=h.bJ(b.lat,E.lat);I<m&&(m=I),I>p&&(p=I),A<x&&(x=A),A>g&&(g=A)}const T=[b.lng+m,b.lat+x,b.lng+p,b.lat+g];return this.isSurfacePointOnScreen([0,1,0])&&(T[3]=90,T[0]=-180,T[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(T[1]=-90,T[0]=-180,T[2]=180),new Me(T)}calculateCenterFromCameraLngLatAlt(e,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,o,c)}setLocationAtPoint(e,n){const o=oi(this.unprojectScreenPoint(n)),c=oi(e),p=h.by();h.bK(p);const m=h.by();h.bH(m,o,p,-this.center.lng*Math.PI/180),h.bG(m,m,p,this.center.lat*Math.PI/180);const g=c[0]*c[0]+c[2]*c[2],x=m[0]*m[0];if(g<x)return;const b=Math.sqrt(g-x),T=-b,E=h.bL(c[0],c[2],m[0],b),I=h.bL(c[0],c[2],m[0],T),A=h.by();h.bH(A,c,p,-E);const L=h.bL(A[1],A[2],m[1],m[2]),j=h.by();h.bH(j,c,p,-I);const V=h.bL(j[1],j[2],m[1],m[2]),G=.5*Math.PI,q=L>=-G&&L<=G,Y=V>=-G&&V<=G;let $,K;if(q&&Y){const ut=this.center.lng*Math.PI/180,st=this.center.lat*Math.PI/180;h.bM(E,ut)+h.bM(L,st)<h.bM(I,ut)+h.bM(V,st)?($=E,K=L):($=I,K=V)}else if(q)$=E,K=L;else{if(!Y)return;$=I,K=V}const J=$/Math.PI*180,H=K/Math.PI*180,it=this.center.lat;this.setCenter(new h.V(J,h.an(H,-90,90))),this.setZoom(this.zoom+We(it,this.center.lat))}locationToScreenPoint(e,n){const o=oi(e);if(n){const c=n.getElevationForLngLatZoom(e,this._helper._tileZoom);h.a_(o,o,1+c/h.bD)}return this._projectSurfacePointToScreen(o)}_projectSurfacePointToScreen(e){const n=h.bE();return h.aG(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new h.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){const o=n.pointCoordinate(e);if(o)return o}return h.aa.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,n){var o;return(o=this.screenPointToMercatorCoordinate(e,n))===null||o===void 0?void 0:o.toLngLat()}isPointOnMapSurface(e,n){const o=this._cameraPosition,c=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(o,c)}getRayDirectionFromPixel(e){const n=h.bE();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,h.aG(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const o=h.by();o[0]=n[0]-this._cameraPosition[0],o[1]=n[1]-this._cameraPosition[1],o[2]=n[2]-this._cameraPosition[2];const c=h.by();return h.b2(c,o),c}isSurfacePointVisible(e){const n=this._cachedClippingPlane;return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const n=h.bE();return h.aG(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){const o=h.b4(e,n),c=h.by(),p=h.by();h.a_(p,n,o),h.b1(c,e,p);const m=1-h.b4(c,c);if(m<0)return null;const g=h.b4(e,e)-1,x=-o+(o<0?1:-1)*Math.sqrt(m),b=g/x,T=x;return{tMin:Math.min(b,T),tMax:Math.max(b,T)}}unprojectScreenPoint(e){const n=this._cameraPosition,o=this.getRayDirectionFromPixel(e),c=this.rayPlanetIntersection(n,o);if(c){const T=h.by();h.a$(T,n,[o[0]*c.tMin,o[1]*c.tMin,o[2]*c.tMin]);const E=h.by();return h.b2(E,T),cc(E)}const p=this._cachedClippingPlane,m=p[0]*o[0]+p[1]*o[1]+p[2]*o[2],g=-h.ba(p,n)/m,x=h.by();if(g>0)h.a$(x,n,[o[0]*g,o[1]*g,o[2]*g]);else{const T=h.by();h.a$(T,n,[2*o[0],2*o[1],2*o[2]]);const E=h.ba(this._cachedClippingPlane,T);h.b1(x,T,[this._cachedClippingPlane[0]*E,this._cachedClippingPlane[1]*E,this._cachedClippingPlane[2]*E])}const b=function(T){const E=h.by();return E[0]=T[0]*-T[3],E[1]=T[1]*-T[3],E[2]=T[2]*-T[3],{center:E,radius:Math.sqrt(1-T[3]*T[3])}}(p);return cc(function(T,E,I){const A=h.by();h.b1(A,I,T);const L=h.by();return h.bz(L,T,A,E/h.b8(A)),L}(b.center,b.radius,x))}getMatrixForModel(e,n){const o=h.V.convert(e),c=1/h.bD,p=h.bi();return h.bI(p,p,o.lng/180*Math.PI),h.bg(p,p,-o.lat/180*Math.PI),h.O(p,p,[0,0,1+n/h.bD]),h.bg(p,p,.5*Math.PI),h.Q(p,p,[c,c,c]),p}getProjectionDataForCustomLayer(e=!0){const n=this.getProjectionData({overscaledTileID:new h.a1(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class Ls{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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,o){return this._helper.interpolatePadding(e,n,o)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,o=!0){this._helper.resize(e,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e,n){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(n,o)=>this.currentTransform.defaultConstrain(n,o),this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new zi({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},e),this._globeness=1,this._mercatorTransform=new ve,this._verticalPerspectiveTransform=new Rs}clone(){const e=new Ls;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,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(e){const n=this._mercatorTransform.getProjectionData(e),o=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?o.mainMatrix:n.mainMatrix,clippingPlane:o.clippingPlane,tileMercatorCoords:o.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return h.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return h.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,o){const c=this._mercatorTransform.getPitchedTextCorrection(e,n,o),p=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,o);return h.bt(c,p,this._globeness)}projectTileCoordinates(e,n,o,c){return this.currentTransform.projectTileCoordinates(e,n,o,c)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,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(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){return this.currentTransform.lngLatToCameraDepth(e,n)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,o,c)}setLocationAtPoint(e,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,n),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,n),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,n){return this.currentTransform.locationToScreenPoint(e,n)}screenPointToMercatorCoordinate(e,n){return this.currentTransform.screenPointToMercatorCoordinate(e,n)}screenPointToLocation(e,n){return this.currentTransform.screenPointToLocation(e,n)}isPointOnMapSurface(e,n){return this.currentTransform.isPointOnMapSurface(e,n)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,n){return this.currentTransform.getMatrixForModel(e,n)}getProjectionDataForCustomLayer(e=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return n;const o=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return o.fallbackMatrix=n.mainMatrix,o}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ri{get useGlobeControls(){return!0}handlePanInertia(e,n){const o=ar(e,n);return Math.abs(o.lng-n.center.lng)>180&&(o.lng=n.center.lng+179.5*Math.sign(o.lng-n.center.lng)),{easingCenter:o,easingOffset:new h.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){const o=e.around,c=n.screenPointToLocation(o);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);const p=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);const m=n.zoom-p;if(m===0)return;const g=h.bJ(n.center.lng,c.lng),x=g/(Math.abs(g/180)+1),b=h.bJ(n.center.lat,c.lat),T=n.getRayDirectionFromPixel(o),E=n.cameraPosition,I=-1*h.b4(E,T),A=h.by();h.a$(A,E,[T[0]*I,T[1]*I,T[2]*I]);const L=h.b6(A)-1,j=Math.exp(.5*-Math.max(L-.3,0)),V=zs(n.worldSize,n.center.lat)/Math.min(n.width,n.height),G=h.bw(V,.9,.5,1,.25),q=(1-h.aq(-m))*Math.min(j,G),Y=n.center.lat,$=n.zoom,K=new h.V(n.center.lng+x*q,h.an(n.center.lat+b*q,-h.ao,h.ao));n.setLocationAtPoint(c,o);const J=n.center,H=h.bw(Math.abs(g),45,85,0,1),it=h.bw(V,.75,.35,0,1),ut=Math.pow(Math.max(H,it),.25),st=h.bJ(J.lng,K.lng),ot=h.bJ(J.lat,K.lat);n.setCenter(new h.V(J.lng+st*ut,J.lat+ot*ut).wrap()),n.setZoom($+We(Y,n.center.lat))}handleMapControlsPan(e,n,o){if(!e.panDelta)return;const c=n.center.lat,p=n.zoom;n.setCenter(ar(e.panDelta,n).wrap()),n.setZoom(p+We(c,n.center.lat))}cameraForBoxAndBearing(e,n,o,c,p){const m=Oa(e,n,o,c,p),g=n.left/p.width*2-1,x=(p.width-n.right)/p.width*2-1,b=n.top/p.height*-2+1,T=(p.height-n.bottom)/p.height*-2+1,E=h.bJ(o.getWest(),o.getEast())<0,I=E?o.getEast():o.getWest(),A=E?o.getWest():o.getEast(),L=Math.max(o.getNorth(),o.getSouth()),j=Math.min(o.getNorth(),o.getSouth()),V=I+.5*h.bJ(I,A),G=L+.5*h.bJ(L,j),q=p.clone();q.setCenter(m.center),q.setBearing(m.bearing),q.setPitch(0),q.setRoll(0),q.setZoom(m.zoom);const Y=q.modelViewProjectionMatrix,$=[oi(o.getNorthWest()),oi(o.getNorthEast()),oi(o.getSouthWest()),oi(o.getSouthEast()),oi(new h.V(A,G)),oi(new h.V(I,G)),oi(new h.V(V,L)),oi(new h.V(V,j))],K=oi(m.center);let J=Number.POSITIVE_INFINITY;for(const H of $)g<0&&(J=Ri.getLesserNonNegativeNonNull(J,Ri.solveVectorScale(H,K,Y,"x",g))),x>0&&(J=Ri.getLesserNonNegativeNonNull(J,Ri.solveVectorScale(H,K,Y,"x",x))),b>0&&(J=Ri.getLesserNonNegativeNonNull(J,Ri.solveVectorScale(H,K,Y,"y",b))),T<0&&(J=Ri.getLesserNonNegativeNonNull(J,Ri.solveVectorScale(H,K,Y,"y",T)));if(Number.isFinite(J)&&J!==0)return m.zoom=q.zoom+h.at(J),m;sa()}handleJumpToCenterZoom(e,n){const o=e.center.lat,c=e.applyConstrain(n.center?h.V.convert(n.center):e.center,e.zoom).center;e.setCenter(c.wrap());const p=n.zoom!==void 0?+n.zoom:e.zoom+We(o,c.lat);e.zoom!==p&&e.setZoom(p)}handleEaseTo(e,n){const o=e.zoom,c=e.center,p=e.padding,m={roll:e.roll,pitch:e.pitch,bearing:e.bearing},g={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},x=n.zoom!==void 0,b=!e.isPaddingEqual(n.padding);let T=!1;const E=n.center?h.V.convert(n.center):c,I=e.applyConstrain(E,o).center;Cs(e,I);const A=e.clone();A.setCenter(I),A.setZoom(x?+n.zoom:o+We(c.lat,E.lat)),A.setBearing(n.bearing);const L=new h.P(h.an(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),h.an(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));A.setLocationAtPoint(I,L);const j=(n.offset&&n.offsetAsPoint.mag())>0?A.center:I,V=x?+n.zoom:o+We(c.lat,j.lat),G=o+We(c.lat,0),q=V+We(j.lat,0),Y=h.bJ(c.lng,j.lng),$=h.bJ(c.lat,j.lat),K=h.aq(q-G);return T=V!==o,{easeFunc:J=>{if(h.bn(m,g)||nn({startEulerAngles:m,endEulerAngles:g,tr:e,k:J,useSlerp:m.roll!=g.roll}),b&&e.interpolatePadding(p,n.padding,J),n.around)h.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(n.around,n.aroundPoint);else{const H=q>G?Math.min(2,K):Math.max(.5,K),it=Math.pow(H,1-J),ut=Oo(c,Y,$,J*it);e.setCenter(ut.wrap())}if(T){const H=h.G.number(G,q,J)+We(0,e.center.lat);e.setZoom(H)}},isZooming:T,elevationCenter:j}}handleFlyTo(e,n){const o=n.zoom!==void 0,c=e.center,p=e.zoom,m=e.padding,g=!e.isPaddingEqual(n.padding),x=e.applyConstrain(h.V.convert(n.center||n.locationAtOffset),p).center,b=o?+n.zoom:e.zoom+We(e.center.lat,x.lat),T=e.clone();T.setCenter(x),T.setZoom(b),T.setBearing(n.bearing);const E=new h.P(h.an(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),h.an(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));T.setLocationAtPoint(x,E);const I=T.center;Cs(e,I);const A=function($,K,J){const H=oi(K),it=oi(J),ut=h.b4(H,it),st=Math.acos(ut),ot=lc($);return st/(2*Math.PI)*ot}(e,c,I),L=p+We(c.lat,0),j=b+We(I.lat,0),V=h.aq(j-L);let G;if(typeof n.minZoom=="number"){const $=+n.minZoom+We(I.lat,0),K=Math.min($,L,j)+We(0,I.lat),J=e.applyConstrain(I,K).zoom+We(I.lat,0);G=h.aq(J-L)}const q=h.bJ(c.lng,I.lng),Y=h.bJ(c.lat,I.lat);return{easeFunc:($,K,J,H)=>{const it=Oo(c,q,Y,J);g&&e.interpolatePadding(m,n.padding,$);const ut=$===1?I:it;e.setCenter(ut.wrap());const st=L+h.at(K);e.setZoom($===1?b:st+We(0,ut.lat))},scaleOfZoom:V,targetCenter:I,scaleOfMinZoom:G,pixelPathLength:A}}static solveVectorScale(e,n,o,c,p){const m=c==="x"?[o[0],o[4],o[8],o[12]]:[o[1],o[5],o[9],o[13]],g=[o[3],o[7],o[11],o[15]],x=e[0]*m[0]+e[1]*m[1]+e[2]*m[2],b=e[0]*g[0]+e[1]*g[1]+e[2]*g[2],T=n[0]*m[0]+n[1]*m[1]+n[2]*m[2],E=n[0]*g[0]+n[1]*g[1]+n[2]*g[2];return T+p*b===x+p*E||g[3]*(x-T)+m[3]*(E-b)+x*E==T*b?null:(T+m[3]-p*E-p*g[3])/(T-x-p*E+p*b)}static getLesserNonNegativeNonNull(e,n){return n!==null&&n>=0&&n<e?n:e}}class Fs{constructor(e){this._globe=e,this._mercatorCameraHelper=new ki,this._verticalPerspectiveCameraHelper=new Ri}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,n){return this.currentHelper.handlePanInertia(e,n)}handleMapControlsRollPitchBearingZoom(e,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,n)}handleMapControlsPan(e,n,o){this.currentHelper.handleMapControlsPan(e,n,o)}cameraForBoxAndBearing(e,n,o,c,p){return this.currentHelper.cameraForBoxAndBearing(e,n,o,c,p)}handleJumpToCenterZoom(e,n){this.currentHelper.handleJumpToCenterZoom(e,n)}handleEaseTo(e,n){return this.currentHelper.handleEaseTo(e,n)}handleFlyTo(e,n){return this.currentHelper.handleFlyTo(e,n)}}const En=(d,e)=>h.B(d,e&&e.filter(n=>n.identifier!=="source.canvas")),Vo=h.bN();class Ua extends h.E{constructor(e,n={}){var o,c;super(),this._rtlPluginLoaded=()=>{for(const m in this.tileManagers){const g=this.tileManagers[m].getSource().type;g!=="vector"&&g!=="geojson"||this.tileManagers[m].reload()}},this.map=e,this.dispatcher=new Xr(Yn(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(m,g)=>this.getGlyphs(m,g)),this.dispatcher.registerMessageHandler("GI",(m,g)=>this.getImages(m,g)),this.dispatcher.registerMessageHandler("GDA",(m,g)=>this.getDashes(m,g)),this.imageManager=new qr,this.imageManager.setEventedParent(this);const p=((o=e._container)===null||o===void 0?void 0:o.lang)||typeof document<"u"&&((c=document.documentElement)===null||c===void 0?void 0:c.lang)||void 0;this.glyphManager=new Qi(e._requestManager,n.localIdeographFontFamily,p),this.lineAtlas=new Is(256,512),this.crossTileSymbolIndex=new Mn,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",h.bO()),ir().on(Jr,this._rtlPluginLoaded),this.on("data",m=>{if(m.dataType!=="source"||m.sourceDataType!=="metadata")return;const g=this.tileManagers[m.sourceId];if(!g)return;const x=g.getSource();if(x&&x.vectorLayerIds)for(const b in this._layers){const T=this._layers[b];T.source===x.id&&this._validateLayer(T)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new h.bP,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(((e=this.crossTileSymbolIndex)===null||e===void 0?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,n){var o,c,p;this._checkLoaded();const m=n===null?(p=(c=(o=this.stylesheet.state)===null||o===void 0?void 0:o[e])===null||c===void 0?void 0:c.default)!==null&&p!==void 0?p:null:n;if(h.bQ(m,this._globalState[e]))return this;this._globalState[e]=m,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const n=[];for(const o in e)!h.bQ(this._globalState[o],e[o].default)&&(n.push(o),this._globalState[o]=e[o].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;const n=new Set,o={};for(const c of e){o[c]=this._globalState[c];for(const p in this._layers){const m=this._layers[p],g=m.getLayoutAffectingGlobalStateRefs(),x=m.getPaintAffectingGlobalStateRefs();if(g.has(c)&&n.add(m.source),x.has(c))for(const{name:b,value:T}of x.get(c))this._updatePaintProperty(m,b,T)}}this.dispatcher.broadcast("UGS",o);for(const c in this.tileManagers)n.has(c)&&(this._reloadSource(c),this._changed=!0)}loadURL(e,n={},o){this.fire(new h.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const c=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const p=this._loadStyleRequest;h.j(c,this._loadStyleRequest).then(m=>{this._loadStyleRequest=null,this._load(m.data,n,o)}).catch(m=>{this._loadStyleRequest=null,m&&!p.signal.aborted&&this.fire(new h.k(m))})}loadJSON(e,n={},o){this.fire(new h.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,Ze.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,o)}).catch(()=>{})}loadEmpty(){this.fire(new h.l("dataloading",{dataType:"style"})),this._load(Vo,{validate:!1})}_load(e,n,o){var c,p;let m=n.transformStyle?n.transformStyle(o,e):e;if(!n.validate||!En(this,h.C(m))){m=Object.assign({},m),this._loaded=!0,this.stylesheet=m;for(const g in m.sources)this.addSource(g,m.sources[g],{validate:!1});m.sprite?this._loadSprite(m.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(m.glyphs),this._createLayers(),this.light=new Xn(this.stylesheet.light),this._setProjectionInternal(((c=this.stylesheet.projection)===null||c===void 0?void 0:c.type)||"mercator"),this.sky=new xn(this.stylesheet.sky),this.map.setTerrain((p=this.stylesheet.terrain)!==null&&p!==void 0?p:null),this.fire(new h.l("data",{dataType:"style"})),this.fire(new h.l("style.load"))}}_createLayers(){var e,n,o;const c=h.bR(this.stylesheet.layers);this.setGlobalState((e=this.stylesheet.state)!==null&&e!==void 0?e:null),this.dispatcher.broadcast("SL",c),this._order=c.map(p=>p.id),this._layers={},this._serializedLayers=null;for(const p of c){const m=h.bS(p,this._globalState);if(m.setEventedParent(this,{layer:{id:p.id}}),this._layers[p.id]=m,h.bT(m)&&this.tileManagers[m.source]){const g=(o=(n=p.paint)===null||n===void 0?void 0:n["raster-fade-duration"])!==null&&o!==void 0?o:m.paint.get("raster-fade-duration");this.tileManagers[m.source].setRasterFadeDuration(g)}}}_loadSprite(e,n=!1,o=void 0){let c;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(p,m,g,x){return h._(this,void 0,void 0,function*(){const b=Ir(p),T=g>1?"@2x":"",E={},I={};for(const{id:A,url:L}of b){const j=m.transformRequest($r(L,T,".json"),"SpriteJSON");E[A]=h.j(j,x);const V=m.transformRequest($r(L,T,".png"),"SpriteImage");I[A]=Ci.getImage(V,x)}return yield Promise.all([...Object.values(E),...Object.values(I)]),function(A,L){return h._(this,void 0,void 0,function*(){const j={};for(const V in A){j[V]={};const G=Ze.getImageCanvasContext((yield L[V]).data),q=(yield A[V]).data;for(const Y in q){const{width:$,height:K,x:J,y:H,sdf:it,pixelRatio:ut,stretchX:st,stretchY:ot,content:ct,textFitWidth:Mt,textFitHeight:wt}=q[Y];j[V][Y]={data:null,pixelRatio:ut,sdf:it,stretchX:st,stretchY:ot,content:ct,textFitWidth:Mt,textFitHeight:wt,spriteData:{width:$,height:K,x:J,y:H,context:G}}}}return j})}(E,I)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(p=>{if(this._spriteRequest=null,p)for(const m in p){this._spritesImagesIds[m]=[];const g=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(x=>!(x in p)):[];for(const x of g)this.imageManager.removeImage(x),this._changedImages[x]=!0;for(const x in p[m]){const b=m==="default"?x:`${m}:${x}`;this._spritesImagesIds[m].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,p[m][x],!1):this.imageManager.addImage(b,p[m][x]),n&&(this._changedImages[b]=!0)}}}).catch(p=>{this._spriteRequest=null,c=p,this.fire(new h.k(c))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new h.l("data",{dataType:"style"})),o&&o(c)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new h.l("data",{dataType:"style"}))}_validateLayer(e){const n=this.tileManagers[e.source];if(!n)return;const o=e.sourceLayer;if(!o)return;const c=n.getSource();(c.type==="geojson"||c.vectorLayerIds&&c.vectorLayerIds.indexOf(o)===-1)&&this.fire(new h.k(new Error(`Source layer "${o}" does not exist on source "${c.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){const o=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?h.bU(o):o);const c=[];for(const p of e)if(o[p]){const m=n?h.bU(o[p]):o[p];c.push(m)}return c}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const n=Object.keys(this._layers);for(const o of n){const c=this._layers[o];c.type!=="custom"&&(e[o]=c.serialize())}return e}hasTransitions(){var e,n,o;if(!((e=this.light)===null||e===void 0)&&e.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((o=this.projection)===null||o===void 0)&&o.hasTransition())return!0;for(const c in this.tileManagers)if(this.tileManagers[c].hasTransition())return!0;for(const c in this._layers)if(this._layers[c].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const n=this._changed;if(n){const c=Object.keys(this._updatedLayers),p=Object.keys(this._removedLayers);(c.length||p.length)&&this._updateWorkerLayers(c,p);for(const m in this._updatedSources){const g=this._updatedSources[m];if(g==="reload")this._reloadSource(m);else{if(g!=="clear")throw new Error(`Invalid action ${g}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const o={};for(const c in this.tileManagers){const p=this.tileManagers[c];o[c]=p.used,p.used=!1}for(const c of this._order){const p=this._layers[c];p.recalculate(e,this._availableImages),!p.isHidden(e.zoom)&&p.source&&(this.tileManagers[p.source].used=!0)}for(const c in o){const p=this.tileManagers[c];!!o[c]!=!!p.used&&p.fire(new h.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:c}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new h.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var o;this._checkLoaded();const c=this.serialize();if(e=n.transformStyle?n.transformStyle(c,e):e,((o=n.validate)===null||o===void 0||o)&&En(this,h.C(e)))return!1;(e=h.bU(e)).layers=h.bR(e.layers);const p=h.bV(c,e),m=this._getOperationsToPerform(p);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(const g of m.operations)g();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const n=[],o=[];for(const c of e)switch(c.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,c.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,c.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,c.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,c.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,c.args));break;case"addSource":n.push(()=>this.addSource.apply(this,c.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,c.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,c.args));break;case"setLight":n.push(()=>this.setLight.apply(this,c.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,c.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,c.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,c.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,c.args));break;case"setSky":n.push(()=>this.setSky.apply(this,c.args));break;case"setProjection":this.setProjection.apply(this,c.args);break;case"setGlobalState":n.push(()=>this.setGlobalState.apply(this,c.args));break;case"setTransition":n.push(()=>{});break;default:o.push(c.command)}return{operations:n,unimplemented:o}}addImage(e,n){if(this.getImage(e))return this.fire(new h.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new h.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new h.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,o={}){if(this._checkLoaded(),this.tileManagers[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(h.C.source,`sources.${e}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const c=this.tileManagers[e]=new Yt(e,n,this.dispatcher);c.style=this,c.setEventedParent(this,()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:e})),c.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw new Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===e)return this.fire(new h.k(new Error(`Source "${e}" cannot be removed while layer "${o}" is using it.`)));const n=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],n.fire(new h.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.tileManagers[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const o=this.tileManagers[e].getSource();if(o.type!=="geojson")throw new Error(`geojsonSource.type is ${o.type}, which is !== 'geojson`);o.setData(n),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,n,o={}){this._checkLoaded();const c=e.id;if(this.getLayer(c))return void this.fire(new h.k(new Error(`Layer "${c}" already exists on this map.`)));let p;if(e.type==="custom"){if(En(this,h.bW(e)))return;p=h.bS(e,this._globalState)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(c,e.source),e=h.bU(e),e=h.e(e,{source:c})),this._validate(h.C.layer,`layers.${c}`,e,{arrayIndex:-1},o))return;p=h.bS(e,this._globalState),this._validateLayer(p),p.setEventedParent(this,{layer:{id:c}})}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new h.k(new Error(`Cannot add layer "${c}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,c),this._layerOrderChanged=!0,this._layers[c]=p,this._removedLayers[c]&&p.source&&p.type!=="custom"){const g=this._removedLayers[c];delete this._removedLayers[c],g.type!==p.type?this._updatedSources[p.source]="clear":(this._updatedSources[p.source]="reload",this.tileManagers[p.source].pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new h.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const o=this._order.indexOf(e);this._order.splice(o,1);const c=n?this._order.indexOf(n):this._order.length;n&&c===-1?this.fire(new h.k(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(c,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new h.k(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);const o=this._order.indexOf(e);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,o){this._checkLoaded();const c=this.getLayer(e);c?c.minzoom===n&&c.maxzoom===o||(n!=null&&(c.minzoom=n),o!=null&&(c.maxzoom=o),this._updateLayer(c)):this.fire(new h.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,o={}){this._checkLoaded();const c=this.getLayer(e);if(c){if(!h.bQ(c.filter,n))return n==null?(c.setFilter(void 0),void this._updateLayer(c)):void(this._validate(h.C.filter,`layers.${c.id}.filter`,n,null,o)||(c.setFilter(h.bU(n)),this._updateLayer(c)))}else this.fire(new h.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return h.bU(this.getLayer(e).filter)}setLayoutProperty(e,n,o,c={}){this._checkLoaded();const p=this.getLayer(e);p?h.bQ(p.getLayoutProperty(n),o)||(p.setLayoutProperty(n,o,c),this._updateLayer(p)):this.fire(new h.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){const o=this.getLayer(e);if(o)return o.getLayoutProperty(n);this.fire(new h.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,o,c={}){this._checkLoaded();const p=this.getLayer(e);p?h.bQ(p.getPaintProperty(n),o)||this._updatePaintProperty(p,n,o,c):this.fire(new h.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,n,o,c={}){e.setPaintProperty(n,o,c)&&this._updateLayer(e),h.bT(e)&&n==="raster-fade-duration"&&this.tileManagers[e.source].setRasterFadeDuration(o),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();const o=e.source,c=e.sourceLayer,p=this.tileManagers[o];if(p===void 0)return void this.fire(new h.k(new Error(`The source '${o}' does not exist in the map's style.`)));const m=p.getSource().type;m==="geojson"&&c?this.fire(new h.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||c?(e.id===void 0&&this.fire(new h.k(new Error("The feature id parameter must be provided."))),p.setFeatureState(c,e.id,n)):this.fire(new h.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();const o=e.source,c=this.tileManagers[o];if(c===void 0)return void this.fire(new h.k(new Error(`The source '${o}' does not exist in the map's style.`)));const p=c.getSource().type,m=p==="vector"?e.sourceLayer:void 0;p!=="vector"||m?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new h.k(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(m,e.id,n):this.fire(new h.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const n=e.source,o=e.sourceLayer,c=this.tileManagers[n];if(c!==void 0)return c.getSource().type!=="vector"||o?(e.id===void 0&&this.fire(new h.k(new Error("The feature id parameter must be provided."))),c.getFeatureState(o,e.id)):void this.fire(new h.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new h.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return h.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=h.bX(this.tileManagers,p=>p.serialize()),n=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,c=this.stylesheet;return h.bY({version:c.version,name:c.name,metadata:c.metadata,light:c.light,sky:c.sky,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,projection:c.projection,sources:e,layers:n,terrain:o},p=>p!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.tileManagers[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const n=m=>this._layers[m].type==="fill-extrusion",o={},c=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g)){o[g]=m;for(const x of e){const b=x[g];if(b)for(const T of b)c.push(T)}}}c.sort((m,g)=>g.intersectionZ-m.intersectionZ);const p=[];for(let m=this._order.length-1;m>=0;m--){const g=this._order[m];if(n(g))for(let x=c.length-1;x>=0;x--){const b=c[x].feature;if(o[b.layer.id]<m)break;p.push(b),c.pop()}else for(const x of e){const b=x[g];if(b)for(const T of b)p.push(T.feature)}}return p}queryRenderedFeatures(e,n,o){n&&n.filter&&this._validate(h.C.filter,"queryRenderedFeatures.filter",n.filter,null,n);const c={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new h.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const b of n.layers){const T=this._layers[b];if(!T)return this.fire(new h.k(new Error(`The layer '${b}' does not exist in the map's style and cannot be queried for features.`))),[];c[T.source]=!0}}const p=[];n.availableImages=this._availableImages;const m=this._serializedAllLayers(),g=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,x=Object.assign(Object.assign({},n),{layers:g,globalState:this._globalState});for(const b in this.tileManagers)n.layers&&!c[b]||p.push(Ra(this.tileManagers[b],this._layers,m,e,x,o,this.map.terrain?(T,E,I)=>this.map.terrain.getElevation(T,E,I):void 0));return this.placement&&p.push(function(b,T,E,I,A,L,j){const V={},G=L.queryRenderedSymbols(I),q=[];for(const Y of Object.keys(G).map(Number))q.push(j[Y]);q.sort(Pe);for(const Y of q){const $=Y.featureIndex.lookupSymbolFeatures(G[Y.bucketInstanceId],T,Y.bucketIndex,Y.sourceLayerIndex,{filterSpec:A.filter,globalState:A.globalState},A.layers,A.availableImages,b);for(const K in $){const J=V[K]=V[K]||[],H=$[K];H.sort((it,ut)=>{const st=Y.featureSortOrder;if(st){const ot=st.indexOf(it.featureIndex);return st.indexOf(ut.featureIndex)-ot}return ut.featureIndex-it.featureIndex});for(const it of H)J.push(it)}}return function(Y,$,K){for(const J in Y)for(const H of Y[J])er(H,K[$[J].source]);return Y}(V,b,E)}(this._layers,m,this.tileManagers,e,x,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(e,n){n?.filter&&this._validate(h.C.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this.tileManagers[e];return o?function(c,p){const m=c.getRenderableIds().map(b=>c.getTileByID(b)),g=[],x={};for(let b=0;b<m.length;b++){const T=m[b],E=T.tileID.canonical.key;x[E]||(x[E]=!0,T.querySourceFeatures(g,p))}return g}(o,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const o=this.light.getLight();let c=!1;for(const m in e)if(!h.bQ(e[m],o[m])){c=!0;break}if(!c)return;const p={now:ie(),transition:h.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(p)}getProjection(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,n={}){this._checkLoaded();const o=this.getSky();let c=!1;if(!e&&!o)return;if(e&&!o)c=!0;else if(!e&&o)c=!0;else for(const m in e)if(!h.bQ(e[m],o[m])){c=!0;break}if(!c)return;const p={now:ie(),transition:h.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(p)}_setProjectionInternal(e){const n=function(o,c){const p={constrainOverride:c};if(Array.isArray(o)){const m=new ca({type:o});return{projection:m,transform:new Ls(p),cameraHelper:new Fs(m)}}switch(o){case"mercator":return{projection:new Je,transform:new ve(p),cameraHelper:new ki};case"globe":{const m=new ca({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:m,transform:new Ls(p),cameraHelper:new Fs(m)}}case"vertical-perspective":return{projection:new Na,transform:new Rs(p),cameraHelper:new Ri};default:return h.w(`Unknown projection name: ${o}. Falling back to mercator projection.`),{projection:new Je,transform:new ve(p),cameraHelper:new ki}}}(e,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const o in this.tileManagers)this.tileManagers[o].reload()}_validate(e,n,o,c,p={}){return(!p||p.validate!==!1)&&En(this,e.call(h.C,h.e({key:n,style:this.serialize(),value:o,styleSpec:h.u},c)))}_remove(e=!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),ir().off(Jr,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.tileManagers){const o=this.tileManagers[n];o.setEventedParent(null),o.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(const n in this.tileManagers)this.tileManagers[n].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,n,o,c,p=!1){let m=!1,g=!1;const x={};for(const b of this._order){const T=this._layers[b];if(T.type!=="symbol")continue;if(!x[T.source]){const I=this.tileManagers[T.source];x[T.source]=I.getRenderableIds(!0).map(A=>I.getTileByID(A)).sort((A,L)=>L.tileID.overscaledZ-A.tileID.overscaledZ||(A.tileID.isLessThan(L.tileID)?-1:1))}const E=this.crossTileSymbolIndex.addLayer(T,x[T.source],e.center.lng);m=m||E}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((p=p||this._layerOrderChanged||o===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ie(),e.zoom))&&(this.pauseablePlacement=new ac(e,this.map.terrain,this._order,p,n,o,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,x),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ie()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(const b of this._order){const T=this._layers[b];T.type==="symbol"&&this.placement.updateLayerOpacities(T,x[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ie())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,n){return h._(this,void 0,void 0,function*(){const o=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const c=this.tileManagers[n.source];return c&&c.setDependencies(n.tileID.key,n.type,n.icons),o})}getGlyphs(e,n){return h._(this,void 0,void 0,function*(){const o=yield this.glyphManager.getGlyphs(n.stacks),c=this.tileManagers[n.source];return c&&c.setDependencies(n.tileID.key,n.type,[""]),o})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(h.C.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,n){return h._(this,void 0,void 0,function*(){const o={};for(const[c,p]of Object.entries(n.dashes))o[c]=this.lineAtlas.getDash(p.dasharray,p.round);return o})}addSprite(e,n,o={},c){this._checkLoaded();const p=[{id:e,url:n}],m=[...Ir(this.stylesheet.sprite),...p];this._validate(h.C.sprite,"sprite",m,null,o)||(this.stylesheet.sprite=m,this._loadSprite(p,!0,c))}removeSprite(e){this._checkLoaded();const n=Ir(this.stylesheet.sprite);if(n.find(o=>o.id===e)){if(this._spritesImagesIds[e])for(const o of this._spritesImagesIds[e])this.imageManager.removeImage(o),this._changedImages[o]=!0;n.splice(n.findIndex(o=>o.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new h.l("data",{dataType:"style"}))}else this.fire(new h.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Ir(this.stylesheet.sprite)}setSprite(e,n={},o){this._checkLoaded(),e&&this._validate(h.C.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,o):(this._unloadSprite(),o&&o(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 e in this.tileManagers){const n=this.tileManagers[e];if(n.setEventedParent(null),n._tiles){for(const o in n._tiles)n._tiles[o].unloadVectorData();n._tiles={}}n._cache.reset(),n.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 e in this._layers){const n=this._layers[e];n.setEventedParent(null),n.onRemove&&n.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 wr=h.aT([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ou{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,o,c,p,m,g,x,b){this.context=e;let T=this.boundPaintVertexBuffers.length!==c.length;for(let E=0;!T&&E<c.length;E++)this.boundPaintVertexBuffers[E]!==c[E]&&(T=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==o||T||this.boundIndexBuffer!==p||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==g||this.boundDynamicVertexBuffer2!==x||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,o,c,p,m,g,x,b):(e.bindVertexArray.set(this.vao),g&&g.bind(),p&&p.dynamicDraw&&p.bind(),x&&x.bind(),b&&b.bind())}freshBind(e,n,o,c,p,m,g,x){const b=e.numAttributes,T=this.context,E=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=o,this.boundIndexBuffer=c,this.boundVertexOffset=p,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=g,this.boundDynamicVertexBuffer3=x,n.enableAttributes(E,e);for(const I of o)I.enableAttributes(E,e);m&&m.enableAttributes(E,e),g&&g.enableAttributes(E,e),x&&x.enableAttributes(E,e),n.bind(),n.setVertexAttribPointers(E,e,p);for(const I of o)I.bind(),I.setVertexAttribPointers(E,e,p);m&&(m.bind(),m.setVertexAttribPointers(E,e,p)),c&&c.bind(),g&&(g.bind(),g.setVertexAttribPointers(E,e,p)),x&&(x.bind(),x.setVertexAttribPointers(E,e,p)),T.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const No=(d,e,n,o,c)=>({u_texture:0,u_ele_delta:d,u_fog_matrix:e,u_fog_color:n?n.properties.get("fog-color"):h.bo.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:c?0:n?n.calculateFogBlendOpacity(o):0,u_horizon_color:n?n.properties.get("horizon-color"):h.bo.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:c?1:0}),Ga={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 an(d){const e=[];for(let n=0;n<d.length;n++){if(d[n]===null)continue;const o=d[n].split(" ");e.push(o.pop())}return e}class ju{constructor(e,n,o,c,p,m,g,x,b=[]){const T=e.gl;this.program=T.createProgram();const E=an(n.staticAttributes),I=o?o.getBinderAttributes():[],A=E.concat(I),L=$i.prelude.staticUniforms?an($i.prelude.staticUniforms):[],j=g.staticUniforms?an(g.staticUniforms):[],V=n.staticUniforms?an(n.staticUniforms):[],G=o?o.getBinderUniforms():[],q=L.concat(j).concat(V).concat(G),Y=[];for(const st of q)Y.indexOf(st)<0&&Y.push(st);const $=o?o.defines():[];nr(T)&&$.unshift("#version 300 es"),p&&$.push("#define OVERDRAW_INSPECTOR;"),m&&$.push("#define TERRAIN3D;"),x&&$.push(x),b&&$.push(...b);let K=$.concat($i.prelude.fragmentSource,g.fragmentSource,n.fragmentSource).join(`
|
||
`),J=$.concat($i.prelude.vertexSource,g.vertexSource,n.vertexSource).join(`
|
||
`);nr(T)||(K=function(st){return st.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(K),J=function(st){return st.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(J));const H=T.createShader(T.FRAGMENT_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);if(T.shaderSource(H,K),T.compileShader(H),!T.getShaderParameter(H,T.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${T.getShaderInfoLog(H)}`);T.attachShader(this.program,H);const it=T.createShader(T.VERTEX_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);if(T.shaderSource(it,J),T.compileShader(it),!T.getShaderParameter(it,T.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${T.getShaderInfoLog(it)}`);T.attachShader(this.program,it),this.attributes={};const ut={};this.numAttributes=A.length;for(let st=0;st<this.numAttributes;st++)A[st]&&(T.bindAttribLocation(this.program,st,A[st]),this.attributes[A[st]]=st);if(T.linkProgram(this.program),!T.getProgramParameter(this.program,T.LINK_STATUS))throw new Error(`Program failed to link: ${T.getProgramInfoLog(this.program)}`);T.deleteShader(it),T.deleteShader(H);for(let st=0;st<Y.length;st++){const ot=Y[st];if(ot&&!ut[ot]){const ct=T.getUniformLocation(this.program,ot);ct&&(ut[ot]=ct)}}this.fixedUniforms=c(e,ut),this.terrainUniforms=((st,ot)=>({u_depth:new h.bZ(st,ot.u_depth),u_terrain:new h.bZ(st,ot.u_terrain),u_terrain_dim:new h.bp(st,ot.u_terrain_dim),u_terrain_matrix:new h.b$(st,ot.u_terrain_matrix),u_terrain_unpack:new h.c0(st,ot.u_terrain_unpack),u_terrain_exaggeration:new h.bp(st,ot.u_terrain_exaggeration)}))(e,ut),this.projectionUniforms=((st,ot)=>({u_projection_matrix:new h.b$(st,ot.u_projection_matrix),u_projection_tile_mercator_coords:new h.c0(st,ot.u_projection_tile_mercator_coords),u_projection_clipping_plane:new h.c0(st,ot.u_projection_clipping_plane),u_projection_transition:new h.bp(st,ot.u_projection_transition),u_projection_fallback_matrix:new h.b$(st,ot.u_projection_fallback_matrix)}))(e,ut),this.binderUniforms=o?o.getUniforms(e,ut):[]}draw(e,n,o,c,p,m,g,x,b,T,E,I,A,L,j,V,G,q,Y){const $=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(o),e.setStencilMode(c),e.setColorMode(p),e.setCullFace(m),x){e.activeTexture.set($.TEXTURE2),$.bindTexture($.TEXTURE_2D,x.depthTexture),e.activeTexture.set($.TEXTURE3),$.bindTexture($.TEXTURE_2D,x.texture);for(const J in this.terrainUniforms)this.terrainUniforms[J].set(x[J])}if(b)for(const J in b)this.projectionUniforms[Ga[J]].set(b[J]);if(g)for(const J in this.fixedUniforms)this.fixedUniforms[J].set(g[J]);V&&V.setUniforms(e,this.binderUniforms,L,{zoom:j});let K=0;switch(n){case $.LINES:K=2;break;case $.TRIANGLES:K=3;break;case $.LINE_STRIP:K=1}for(const J of A.get()){const H=J.vaos||(J.vaos={});(H[T]||(H[T]=new Ou)).bind(e,this,E,V?V.getPaintVertexBuffers():[],I,J.vertexOffset,G,q,Y),$.drawElements(n,J.primitiveLength*K,$.UNSIGNED_SHORT,J.primitiveOffset*K*2)}}}function Za(d,e,n){const o=1/h.aM(n,1,e.transform.tileZoom),c=Math.pow(2,n.tileID.overscaledZ),p=n.tileSize*Math.pow(2,e.transform.tileZoom)/c,m=p*(n.tileID.canonical.x+n.tileID.wrap*c),g=p*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[o,d.fromScale,d.toScale],u_fade:d.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}const dc=(d,e,n,o)=>{const c=d.style.light,p=c.properties.get("position"),m=[p.x,p.y,p.z],g=h.c3();c.properties.get("anchor")==="viewport"&&h.c4(g,d.transform.bearingInRadians),h.c5(m,m,g);const x=d.transform.transformLightDirection(m),b=c.properties.get("color");return{u_lightpos:m,u_lightpos_globe:x,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+e,u_opacity:n,u_fill_translate:o}},ha=(d,e,n,o,c,p,m)=>h.e(dc(d,e,n,o),Za(p,d,m),{u_height_factor:-Math.pow(2,c.overscaledZ)/m.tileSize/8}),pc=(d,e,n,o)=>h.e(Za(e,d,n),{u_fill_translate:o}),fc=(d,e)=>({u_world:d,u_fill_translate:e}),Vu=(d,e,n,o,c)=>h.e(pc(d,e,n,c),{u_world:o}),mc=(d,e,n,o,c)=>{const p=d.transform;let m,g,x=0;if(n.paint.get("circle-pitch-alignment")==="map"){const b=h.aM(e,1,p.zoom);m=!0,g=[b,b],x=b/(h.a4*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*c}else m=!1,g=p.pixelsToGLUnits;return{u_camera_to_center_distance:p.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+m,u_device_pixel_ratio:d.pixelRatio,u_extrude_scale:g,u_globe_extrude_scale:x,u_translate:o}},Uo=d=>({u_pixel_extrude_scale:[1/d.width,1/d.height]}),_c=d=>({u_viewport_size:[d.width,d.height]}),Go=(d,e=1)=>({u_color:d,u_overlay:0,u_overlay_scale:e}),Zo=(d,e,n,o)=>{const c=h.aM(d,1,e)/(h.a4*Math.pow(2,d.tileID.overscaledZ))*2*Math.PI*o;return{u_extrude_scale:h.aM(d,1,e),u_intensity:n,u_globe_extrude_scale:c}},$o=(d,e,n,o)=>{const c=h.N();h.c6(c,0,d.width,d.height,0,0,1);const p=d.context.gl;return{u_matrix:c,u_world:[p.drawingBufferWidth,p.drawingBufferHeight],u_image:n,u_color_ramp:o,u_opacity:e.paint.get("heatmap-opacity")}},Cn=(d,e,n)=>{const o=n.paint.get("hillshade-accent-color");let c;switch(n.paint.get("hillshade-method")){case"basic":c=4;break;case"combined":c=1;break;case"igor":c=2;break;case"multidirectional":c=3;break;default:c=0}const p=n.getIlluminationProperties();for(let m=0;m<p.directionRadians.length;m++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(p.directionRadians[m]+=d.transform.bearingInRadians);return{u_image:0,u_latrange:yc(0,e.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:p.altitudeRadians,u_azimuths:p.directionRadians,u_accent:o,u_method:c,u_highlights:p.highlightColor,u_shadows:p.shadowColor}},gc=(d,e)=>{const n=e.stride,o=h.N();return h.c6(o,0,h.a4,-h.a4,0,0,1),h.O(o,o,[0,-h.a4,0]),{u_matrix:o,u_image:1,u_dimension:[n,n],u_zoom:d.overscaledZ,u_unpack:e.getUnpackVector()}};function yc(d,e){const n=Math.pow(2,e.canonical.z),o=e.canonical.y;return[new h.aa(0,o/n).toLngLat().lat,new h.aa(0,(o+1)/n).toLngLat().lat]}const $a=(d,e,n=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:n,u_opacity:d.paint.get("color-relief-opacity")}),Bs=(d,e,n,o)=>{const c=d.transform;return{u_translation:qo(d,e,n),u_ratio:o/h.aM(e,1,c.zoom),u_device_pixel_ratio:d.pixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},qa=(d,e,n,o,c)=>h.e(Bs(d,e,n,o),{u_image:0,u_image_height:c}),Nu=(d,e,n,o,c)=>{const p=d.transform,m=Os(e,p);return{u_translation:qo(d,e,n),u_texsize:e.imageAtlasTexture.size,u_ratio:o/h.aM(e,1,p.zoom),u_device_pixel_ratio:d.pixelRatio,u_image:0,u_scale:[m,c.fromScale,c.toScale],u_fade:c.t,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},Uu=(d,e,n,o,c)=>{const p=Os(e,d.transform);return h.e(Bs(d,e,n,o),{u_tileratio:p,u_crossfade_from:c.fromScale,u_crossfade_to:c.toScale,u_image:0,u_mix:c.t,u_lineatlas_width:d.lineAtlas.width,u_lineatlas_height:d.lineAtlas.height})},xc=(d,e,n,o,c,p)=>{const m=Os(e,d.transform);return h.e(Bs(d,e,n,o),{u_image:0,u_image_height:p,u_tileratio:m,u_crossfade_from:c.fromScale,u_crossfade_to:c.toScale,u_image_dash:1,u_mix:c.t,u_lineatlas_width:d.lineAtlas.width,u_lineatlas_height:d.lineAtlas.height})};function Os(d,e){return 1/h.aM(d,1,e.tileZoom)}function qo(d,e,n){return h.aN(d.transform,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Wo=(d,e,n,o,c)=>{return{u_tl_parent:d,u_scale_parent:e,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(p=o.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:vc(o.paint.get("raster-hue-rotate")),u_coords_top:[c[0].x,c[0].y,c[1].x,c[1].y],u_coords_bottom:[c[3].x,c[3].y,c[2].x,c[2].y]};var p,m};function vc(d){d*=Math.PI/180;const e=Math.sin(d),n=Math.cos(d);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const Wa=(d,e,n,o,c,p,m,g,x,b,T,E,I)=>{const A=m.transform;return{u_is_size_zoom_constant:+(d==="constant"||d==="source"),u_is_size_feature_constant:+(d==="constant"||d==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:A.cameraToCenterDistance,u_pitch:A.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:A.width/A.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_label_plane_matrix:g,u_coord_matrix:x,u_is_text:+T,u_pitch_with_map:+o,u_is_along_line:c,u_is_variable_anchor:p,u_texsize:E,u_texture:0,u_translation:b,u_pitched_scale:I}},Tr=(d,e,n,o,c,p,m,g,x,b,T,E,I,A)=>{const L=m.transform;return h.e(Wa(d,e,n,o,c,p,m,g,x,b,T,E,A),{u_gamma_scale:o?Math.cos(L.pitch*Math.PI/180)*L.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:1})},Ho=(d,e,n,o,c,p,m,g,x,b,T,E,I)=>h.e(Tr(d,e,n,o,c,p,m,g,x,b,!0,T,0,I),{u_texsize_icon:E,u_texture_icon:1}),Xo=(d,e)=>({u_opacity:d,u_color:e}),Yo=(d,e,n,o,c)=>h.e(function(p,m,g,x){const b=g.imageManager.getPattern(p.from.toString()),T=g.imageManager.getPattern(p.to.toString()),{width:E,height:I}=g.imageManager.getPixelSize(),A=Math.pow(2,x.tileID.overscaledZ),L=x.tileSize*Math.pow(2,g.transform.tileZoom)/A,j=L*(x.tileID.canonical.x+x.tileID.wrap*A),V=L*x.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:b.tl,u_pattern_br_a:b.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[E,I],u_mix:m.t,u_pattern_size_a:b.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:m.fromScale,u_scale_b:m.toScale,u_tile_units_to_pixels:1/h.aM(x,1,g.transform.tileZoom),u_pixel_coord_upper:[j>>16,V>>16],u_pixel_coord_lower:[65535&j,65535&V]}}(n,c,e,o),{u_opacity:d}),Ko=(d,e)=>{},Jo={fillExtrusion:(d,e)=>({u_lightpos:new h.c1(d,e.u_lightpos),u_lightpos_globe:new h.c1(d,e.u_lightpos_globe),u_lightintensity:new h.bp(d,e.u_lightintensity),u_lightcolor:new h.c1(d,e.u_lightcolor),u_vertical_gradient:new h.bp(d,e.u_vertical_gradient),u_opacity:new h.bp(d,e.u_opacity),u_fill_translate:new h.c2(d,e.u_fill_translate)}),fillExtrusionPattern:(d,e)=>({u_lightpos:new h.c1(d,e.u_lightpos),u_lightpos_globe:new h.c1(d,e.u_lightpos_globe),u_lightintensity:new h.bp(d,e.u_lightintensity),u_lightcolor:new h.c1(d,e.u_lightcolor),u_vertical_gradient:new h.bp(d,e.u_vertical_gradient),u_height_factor:new h.bp(d,e.u_height_factor),u_opacity:new h.bp(d,e.u_opacity),u_fill_translate:new h.c2(d,e.u_fill_translate),u_image:new h.bZ(d,e.u_image),u_texsize:new h.c2(d,e.u_texsize),u_pixel_coord_upper:new h.c2(d,e.u_pixel_coord_upper),u_pixel_coord_lower:new h.c2(d,e.u_pixel_coord_lower),u_scale:new h.c1(d,e.u_scale),u_fade:new h.bp(d,e.u_fade)}),fill:(d,e)=>({u_fill_translate:new h.c2(d,e.u_fill_translate)}),fillPattern:(d,e)=>({u_image:new h.bZ(d,e.u_image),u_texsize:new h.c2(d,e.u_texsize),u_pixel_coord_upper:new h.c2(d,e.u_pixel_coord_upper),u_pixel_coord_lower:new h.c2(d,e.u_pixel_coord_lower),u_scale:new h.c1(d,e.u_scale),u_fade:new h.bp(d,e.u_fade),u_fill_translate:new h.c2(d,e.u_fill_translate)}),fillOutline:(d,e)=>({u_world:new h.c2(d,e.u_world),u_fill_translate:new h.c2(d,e.u_fill_translate)}),fillOutlinePattern:(d,e)=>({u_world:new h.c2(d,e.u_world),u_image:new h.bZ(d,e.u_image),u_texsize:new h.c2(d,e.u_texsize),u_pixel_coord_upper:new h.c2(d,e.u_pixel_coord_upper),u_pixel_coord_lower:new h.c2(d,e.u_pixel_coord_lower),u_scale:new h.c1(d,e.u_scale),u_fade:new h.bp(d,e.u_fade),u_fill_translate:new h.c2(d,e.u_fill_translate)}),circle:(d,e)=>({u_camera_to_center_distance:new h.bp(d,e.u_camera_to_center_distance),u_scale_with_map:new h.bZ(d,e.u_scale_with_map),u_pitch_with_map:new h.bZ(d,e.u_pitch_with_map),u_extrude_scale:new h.c2(d,e.u_extrude_scale),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_globe_extrude_scale:new h.bp(d,e.u_globe_extrude_scale),u_translate:new h.c2(d,e.u_translate)}),collisionBox:(d,e)=>({u_pixel_extrude_scale:new h.c2(d,e.u_pixel_extrude_scale)}),collisionCircle:(d,e)=>({u_viewport_size:new h.c2(d,e.u_viewport_size)}),debug:(d,e)=>({u_color:new h.b_(d,e.u_color),u_overlay:new h.bZ(d,e.u_overlay),u_overlay_scale:new h.bp(d,e.u_overlay_scale)}),depth:Ko,clippingMask:Ko,heatmap:(d,e)=>({u_extrude_scale:new h.bp(d,e.u_extrude_scale),u_intensity:new h.bp(d,e.u_intensity),u_globe_extrude_scale:new h.bp(d,e.u_globe_extrude_scale)}),heatmapTexture:(d,e)=>({u_matrix:new h.b$(d,e.u_matrix),u_world:new h.c2(d,e.u_world),u_image:new h.bZ(d,e.u_image),u_color_ramp:new h.bZ(d,e.u_color_ramp),u_opacity:new h.bp(d,e.u_opacity)}),hillshade:(d,e)=>({u_image:new h.bZ(d,e.u_image),u_latrange:new h.c2(d,e.u_latrange),u_exaggeration:new h.bp(d,e.u_exaggeration),u_altitudes:new h.c8(d,e.u_altitudes),u_azimuths:new h.c8(d,e.u_azimuths),u_accent:new h.b_(d,e.u_accent),u_method:new h.bZ(d,e.u_method),u_shadows:new h.c7(d,e.u_shadows),u_highlights:new h.c7(d,e.u_highlights)}),hillshadePrepare:(d,e)=>({u_matrix:new h.b$(d,e.u_matrix),u_image:new h.bZ(d,e.u_image),u_dimension:new h.c2(d,e.u_dimension),u_zoom:new h.bp(d,e.u_zoom),u_unpack:new h.c0(d,e.u_unpack)}),colorRelief:(d,e)=>({u_image:new h.bZ(d,e.u_image),u_unpack:new h.c0(d,e.u_unpack),u_dimension:new h.c2(d,e.u_dimension),u_elevation_stops:new h.bZ(d,e.u_elevation_stops),u_color_stops:new h.bZ(d,e.u_color_stops),u_color_ramp_size:new h.bZ(d,e.u_color_ramp_size),u_opacity:new h.bp(d,e.u_opacity)}),line:(d,e)=>({u_translation:new h.c2(d,e.u_translation),u_ratio:new h.bp(d,e.u_ratio),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_units_to_pixels:new h.c2(d,e.u_units_to_pixels)}),lineGradient:(d,e)=>({u_translation:new h.c2(d,e.u_translation),u_ratio:new h.bp(d,e.u_ratio),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_units_to_pixels:new h.c2(d,e.u_units_to_pixels),u_image:new h.bZ(d,e.u_image),u_image_height:new h.bp(d,e.u_image_height)}),linePattern:(d,e)=>({u_translation:new h.c2(d,e.u_translation),u_texsize:new h.c2(d,e.u_texsize),u_ratio:new h.bp(d,e.u_ratio),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_image:new h.bZ(d,e.u_image),u_units_to_pixels:new h.c2(d,e.u_units_to_pixels),u_scale:new h.c1(d,e.u_scale),u_fade:new h.bp(d,e.u_fade)}),lineSDF:(d,e)=>({u_translation:new h.c2(d,e.u_translation),u_ratio:new h.bp(d,e.u_ratio),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_units_to_pixels:new h.c2(d,e.u_units_to_pixels),u_image:new h.bZ(d,e.u_image),u_mix:new h.bp(d,e.u_mix),u_tileratio:new h.bp(d,e.u_tileratio),u_crossfade_from:new h.bp(d,e.u_crossfade_from),u_crossfade_to:new h.bp(d,e.u_crossfade_to),u_lineatlas_width:new h.bp(d,e.u_lineatlas_width),u_lineatlas_height:new h.bp(d,e.u_lineatlas_height)}),lineGradientSDF:(d,e)=>({u_translation:new h.c2(d,e.u_translation),u_ratio:new h.bp(d,e.u_ratio),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_units_to_pixels:new h.c2(d,e.u_units_to_pixels),u_image:new h.bZ(d,e.u_image),u_image_height:new h.bp(d,e.u_image_height),u_tileratio:new h.bp(d,e.u_tileratio),u_crossfade_from:new h.bp(d,e.u_crossfade_from),u_crossfade_to:new h.bp(d,e.u_crossfade_to),u_image_dash:new h.bZ(d,e.u_image_dash),u_mix:new h.bp(d,e.u_mix),u_lineatlas_width:new h.bp(d,e.u_lineatlas_width),u_lineatlas_height:new h.bp(d,e.u_lineatlas_height)}),raster:(d,e)=>({u_tl_parent:new h.c2(d,e.u_tl_parent),u_scale_parent:new h.bp(d,e.u_scale_parent),u_buffer_scale:new h.bp(d,e.u_buffer_scale),u_fade_t:new h.bp(d,e.u_fade_t),u_opacity:new h.bp(d,e.u_opacity),u_image0:new h.bZ(d,e.u_image0),u_image1:new h.bZ(d,e.u_image1),u_brightness_low:new h.bp(d,e.u_brightness_low),u_brightness_high:new h.bp(d,e.u_brightness_high),u_saturation_factor:new h.bp(d,e.u_saturation_factor),u_contrast_factor:new h.bp(d,e.u_contrast_factor),u_spin_weights:new h.c1(d,e.u_spin_weights),u_coords_top:new h.c0(d,e.u_coords_top),u_coords_bottom:new h.c0(d,e.u_coords_bottom)}),symbolIcon:(d,e)=>({u_is_size_zoom_constant:new h.bZ(d,e.u_is_size_zoom_constant),u_is_size_feature_constant:new h.bZ(d,e.u_is_size_feature_constant),u_size_t:new h.bp(d,e.u_size_t),u_size:new h.bp(d,e.u_size),u_camera_to_center_distance:new h.bp(d,e.u_camera_to_center_distance),u_pitch:new h.bp(d,e.u_pitch),u_rotate_symbol:new h.bZ(d,e.u_rotate_symbol),u_aspect_ratio:new h.bp(d,e.u_aspect_ratio),u_fade_change:new h.bp(d,e.u_fade_change),u_label_plane_matrix:new h.b$(d,e.u_label_plane_matrix),u_coord_matrix:new h.b$(d,e.u_coord_matrix),u_is_text:new h.bZ(d,e.u_is_text),u_pitch_with_map:new h.bZ(d,e.u_pitch_with_map),u_is_along_line:new h.bZ(d,e.u_is_along_line),u_is_variable_anchor:new h.bZ(d,e.u_is_variable_anchor),u_texsize:new h.c2(d,e.u_texsize),u_texture:new h.bZ(d,e.u_texture),u_translation:new h.c2(d,e.u_translation),u_pitched_scale:new h.bp(d,e.u_pitched_scale)}),symbolSDF:(d,e)=>({u_is_size_zoom_constant:new h.bZ(d,e.u_is_size_zoom_constant),u_is_size_feature_constant:new h.bZ(d,e.u_is_size_feature_constant),u_size_t:new h.bp(d,e.u_size_t),u_size:new h.bp(d,e.u_size),u_camera_to_center_distance:new h.bp(d,e.u_camera_to_center_distance),u_pitch:new h.bp(d,e.u_pitch),u_rotate_symbol:new h.bZ(d,e.u_rotate_symbol),u_aspect_ratio:new h.bp(d,e.u_aspect_ratio),u_fade_change:new h.bp(d,e.u_fade_change),u_label_plane_matrix:new h.b$(d,e.u_label_plane_matrix),u_coord_matrix:new h.b$(d,e.u_coord_matrix),u_is_text:new h.bZ(d,e.u_is_text),u_pitch_with_map:new h.bZ(d,e.u_pitch_with_map),u_is_along_line:new h.bZ(d,e.u_is_along_line),u_is_variable_anchor:new h.bZ(d,e.u_is_variable_anchor),u_texsize:new h.c2(d,e.u_texsize),u_texture:new h.bZ(d,e.u_texture),u_gamma_scale:new h.bp(d,e.u_gamma_scale),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_is_halo:new h.bZ(d,e.u_is_halo),u_translation:new h.c2(d,e.u_translation),u_pitched_scale:new h.bp(d,e.u_pitched_scale)}),symbolTextAndIcon:(d,e)=>({u_is_size_zoom_constant:new h.bZ(d,e.u_is_size_zoom_constant),u_is_size_feature_constant:new h.bZ(d,e.u_is_size_feature_constant),u_size_t:new h.bp(d,e.u_size_t),u_size:new h.bp(d,e.u_size),u_camera_to_center_distance:new h.bp(d,e.u_camera_to_center_distance),u_pitch:new h.bp(d,e.u_pitch),u_rotate_symbol:new h.bZ(d,e.u_rotate_symbol),u_aspect_ratio:new h.bp(d,e.u_aspect_ratio),u_fade_change:new h.bp(d,e.u_fade_change),u_label_plane_matrix:new h.b$(d,e.u_label_plane_matrix),u_coord_matrix:new h.b$(d,e.u_coord_matrix),u_is_text:new h.bZ(d,e.u_is_text),u_pitch_with_map:new h.bZ(d,e.u_pitch_with_map),u_is_along_line:new h.bZ(d,e.u_is_along_line),u_is_variable_anchor:new h.bZ(d,e.u_is_variable_anchor),u_texsize:new h.c2(d,e.u_texsize),u_texsize_icon:new h.c2(d,e.u_texsize_icon),u_texture:new h.bZ(d,e.u_texture),u_texture_icon:new h.bZ(d,e.u_texture_icon),u_gamma_scale:new h.bp(d,e.u_gamma_scale),u_device_pixel_ratio:new h.bp(d,e.u_device_pixel_ratio),u_is_halo:new h.bZ(d,e.u_is_halo),u_translation:new h.c2(d,e.u_translation),u_pitched_scale:new h.bp(d,e.u_pitched_scale)}),background:(d,e)=>({u_opacity:new h.bp(d,e.u_opacity),u_color:new h.b_(d,e.u_color)}),backgroundPattern:(d,e)=>({u_opacity:new h.bp(d,e.u_opacity),u_image:new h.bZ(d,e.u_image),u_pattern_tl_a:new h.c2(d,e.u_pattern_tl_a),u_pattern_br_a:new h.c2(d,e.u_pattern_br_a),u_pattern_tl_b:new h.c2(d,e.u_pattern_tl_b),u_pattern_br_b:new h.c2(d,e.u_pattern_br_b),u_texsize:new h.c2(d,e.u_texsize),u_mix:new h.bp(d,e.u_mix),u_pattern_size_a:new h.c2(d,e.u_pattern_size_a),u_pattern_size_b:new h.c2(d,e.u_pattern_size_b),u_scale_a:new h.bp(d,e.u_scale_a),u_scale_b:new h.bp(d,e.u_scale_b),u_pixel_coord_upper:new h.c2(d,e.u_pixel_coord_upper),u_pixel_coord_lower:new h.c2(d,e.u_pixel_coord_lower),u_tile_units_to_pixels:new h.bp(d,e.u_tile_units_to_pixels)}),terrain:(d,e)=>({u_texture:new h.bZ(d,e.u_texture),u_ele_delta:new h.bp(d,e.u_ele_delta),u_fog_matrix:new h.b$(d,e.u_fog_matrix),u_fog_color:new h.b_(d,e.u_fog_color),u_fog_ground_blend:new h.bp(d,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new h.bp(d,e.u_fog_ground_blend_opacity),u_horizon_color:new h.b_(d,e.u_horizon_color),u_horizon_fog_blend:new h.bp(d,e.u_horizon_fog_blend),u_is_globe_mode:new h.bp(d,e.u_is_globe_mode)}),terrainDepth:(d,e)=>({u_ele_delta:new h.bp(d,e.u_ele_delta)}),terrainCoords:(d,e)=>({u_texture:new h.bZ(d,e.u_texture),u_terrain_coords_id:new h.bp(d,e.u_terrain_coords_id),u_ele_delta:new h.bp(d,e.u_ele_delta)}),projectionErrorMeasurement:(d,e)=>({u_input:new h.bp(d,e.u_input),u_output_expected:new h.bp(d,e.u_output_expected)}),atmosphere:(d,e)=>({u_sun_pos:new h.c1(d,e.u_sun_pos),u_atmosphere_blend:new h.bp(d,e.u_atmosphere_blend),u_globe_position:new h.c1(d,e.u_globe_position),u_globe_radius:new h.bp(d,e.u_globe_radius),u_inv_proj_matrix:new h.b$(d,e.u_inv_proj_matrix)}),sky:(d,e)=>({u_sky_color:new h.b_(d,e.u_sky_color),u_horizon_color:new h.b_(d,e.u_horizon_color),u_horizon:new h.c2(d,e.u_horizon),u_horizon_normal:new h.c2(d,e.u_horizon_normal),u_sky_horizon_blend:new h.bp(d,e.u_sky_horizon_blend),u_sky_blend:new h.bp(d,e.u_sky_blend)})};class An{constructor(e,n,o){this.context=e;const c=e.gl;this.buffer=c.createBuffer(),this.dynamicDraw=!!o,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Qo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Gu{constructor(e,n,o,c){this.length=n.length,this.attributes=o,this.itemSize=n.bytesPerElement,this.dynamicDraw=c,this.context=e;const p=e.gl;this.buffer=p.createBuffer(),e.bindVertexBuffer.set(this.buffer),p.bufferData(p.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let o=0;o<this.attributes.length;o++){const c=n.attributes[this.attributes[o].name];c!==void 0&&e.enableVertexAttribArray(c)}}setVertexAttribPointers(e,n,o){for(let c=0;c<this.attributes.length;c++){const p=this.attributes[c],m=n.attributes[p.name];m!==void 0&&e.vertexAttribPointer(m,p.components,e[Qo[p.type]],!1,this.itemSize,p.offset+this.itemSize*(o||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ae{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Zu extends ae{getDefault(){return h.bo.transparent}set(e){const n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class $u extends ae{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class bc extends ae{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class qu extends ae{getDefault(){return[!0,!0,!0,!0]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class wc extends ae{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class js extends ae{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Vs extends ae{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const n=this.current;(e.func!==n.func||e.ref!==n.ref||e.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Ns extends ae{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class tl extends ae{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=e,this.dirty=!1}}class Dn extends ae{getDefault(){return[0,1]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Ha extends ae{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=e,this.dirty=!1}}class da extends ae{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class qi extends ae{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.BLEND):n.disable(n.BLEND),this.current=e,this.dirty=!1}}class Tc extends ae{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Sc extends ae{getDefault(){return h.bo.transparent}set(e){const n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class el extends ae{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class zn extends ae{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=e,this.dirty=!1}}class Us extends ae{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Gs extends ae{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Xa extends ae{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Zs extends ae{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Pc extends ae{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class pa extends ae{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class fa extends ae{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Mc extends ae{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class il extends ae{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Jt extends ae{getDefault(){return null}set(e){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class $s extends ae{getDefault(){return null}set(e){var n;if(e===this.current&&!this.dirty)return;const o=this.gl;nr(o)?o.bindVertexArray(e):(n=o.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Wu extends ae{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Ic extends ae{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Ya extends ae{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class rl extends ae{constructor(e,n){super(e),this.context=e,this.parent=n}getDefault(){return null}}class Hu extends rl{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Ec extends rl{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Xu extends rl{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const qs="Framebuffer is not complete";class Ws{constructor(e,n,o,c,p){this.context=e,this.width=n,this.height=o;const m=e.gl,g=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new Hu(e,g),c)this.depthAttachment=p?new Xu(e,g):new Ec(e,g);else if(p)throw new Error("Stencil cannot be set without depth");if(m.checkFramebufferStatus(m.FRAMEBUFFER)!==m.FRAMEBUFFER_COMPLETE)throw new Error(qs)}destroy(){const e=this.context.gl,n=this.colorAttachment.get();if(n&&e.deleteTexture(n),this.depthAttachment){const o=this.depthAttachment.get();o&&e.deleteRenderbuffer(o)}e.deleteFramebuffer(this.framebuffer)}}class Hs{constructor(e){var n,o;if(this.gl=e,this.clearColor=new Zu(this),this.clearDepth=new $u(this),this.clearStencil=new bc(this),this.colorMask=new qu(this),this.depthMask=new wc(this),this.stencilMask=new js(this),this.stencilFunc=new Vs(this),this.stencilOp=new Ns(this),this.stencilTest=new tl(this),this.depthRange=new Dn(this),this.depthTest=new Ha(this),this.depthFunc=new da(this),this.blend=new qi(this),this.blendFunc=new Tc(this),this.blendColor=new Sc(this),this.blendEquation=new el(this),this.cullFace=new zn(this),this.cullFaceSide=new Us(this),this.frontFace=new Gs(this),this.program=new Xa(this),this.activeTexture=new Zs(this),this.viewport=new Pc(this),this.bindFramebuffer=new pa(this),this.bindRenderbuffer=new fa(this),this.bindTexture=new Mc(this),this.bindVertexBuffer=new il(this),this.bindElementBuffer=new Jt(this),this.bindVertexArray=new $s(this),this.pixelStoreUnpack=new Wu(this),this.pixelStoreUnpackPremultiplyAlpha=new Ic(this),this.pixelStoreUnpackFlipY=new Ya(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),nr(e)){this.HALF_FLOAT=e.HALF_FLOAT;const c=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=e.RGBA16F)!==null&&n!==void 0?n:c?.RGBA16F_EXT,this.RGB16F=(o=e.RGB16F)!==null&&o!==void 0?o:c?.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const c=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=c?.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(e,n){return new An(this,e,n)}createVertexBuffer(e,n,o){return new Gu(this,e,n,o)}createRenderbuffer(e,n,o){const c=this.gl,p=c.createRenderbuffer();return this.bindRenderbuffer.set(p),c.renderbufferStorage(c.RENDERBUFFER,e,n,o),this.bindRenderbuffer.set(null),p}createFramebuffer(e,n,o,c){return new Ws(this,e,n,o,c)}clear({color:e,depth:n,stencil:o}){const c=this.gl;let p=0;e&&(p|=c.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(p|=c.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),o!==void 0&&(p|=c.STENCIL_BUFFER_BIT,this.clearStencil.set(o),this.stencilMask.set(255)),c.clear(p)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){h.bQ(e.blendFunction,be.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return nr(this.gl)?this.gl.createVertexArray():(e=this.gl.getExtension("OES_vertex_array_object"))===null||e===void 0?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var n;return nr(this.gl)?this.gl.deleteVertexArray(e):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let kn;function Xs(d,e,n,o,c){const p=d.context,m=d.transform,g=p.gl,x=d.useProgram("collisionBox"),b=[];let T=0,E=0;for(let G=0;G<o.length;G++){const q=o[G],Y=e.getTile(q).getBucket(n);if(!Y)continue;const $=c?Y.textCollisionBox:Y.iconCollisionBox,K=Y.collisionCircleArray;K.length>0&&(b.push({circleArray:K,circleOffset:E,coord:q}),T+=K.length/4,E=T),$&&x.draw(p,g.LINES,Ht.disabled,ee.disabled,d.colorModeForRenderPass(),re.disabled,Uo(d.transform),d.style.map.terrain&&d.style.map.terrain.getTerrainData(q),m.getProjectionData({overscaledTileID:q,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,$.layoutVertexBuffer,$.indexBuffer,$.segments,null,d.transform.zoom,null,null,$.collisionVertexBuffer)}if(!c||!b.length)return;const I=d.useProgram("collisionCircle"),A=new h.c9;A.resize(4*T),A._trim();let L=0;for(const G of b)for(let q=0;q<G.circleArray.length/4;q++){const Y=4*q,$=G.circleArray[Y+0],K=G.circleArray[Y+1],J=G.circleArray[Y+2],H=G.circleArray[Y+3];A.emplace(L++,$,K,J,H,0),A.emplace(L++,$,K,J,H,1),A.emplace(L++,$,K,J,H,2),A.emplace(L++,$,K,J,H,3)}(!kn||kn.length<2*T)&&(kn=function(G){const q=2*G,Y=new h.cb;Y.resize(q),Y._trim();for(let $=0;$<q;$++){const K=6*$;Y.uint16[K+0]=4*$+0,Y.uint16[K+1]=4*$+1,Y.uint16[K+2]=4*$+2,Y.uint16[K+3]=4*$+2,Y.uint16[K+4]=4*$+3,Y.uint16[K+5]=4*$+0}return Y}(T));const j=p.createIndexBuffer(kn,!0),V=p.createVertexBuffer(A,h.ca.members,!0);for(const G of b){const q=_c(d.transform);I.draw(p,g.TRIANGLES,Ht.disabled,ee.disabled,d.colorModeForRenderPass(),re.disabled,q,d.style.map.terrain&&d.style.map.terrain.getTerrainData(G.coord),null,n.id,V,j,h.aW.simpleSegment(0,2*G.circleOffset,G.circleArray.length,G.circleArray.length/2),null,d.transform.zoom,null,null,null)}V.destroy(),j.destroy()}const Cc=h.ar(new Float32Array(16));function Ys(d,e,n,o,c,p){const{horizontalAlign:m,verticalAlign:g}=h.aR(d);return new h.P((-(m-.5)*e/c+o[0])*p,(-(g-.5)*n/c+o[1])*p)}function Ks(d,e,n,o,c,p){const m=e.tileAnchorPoint.add(new h.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let g=o.mult(p);n||(g=g.rotate(-c));const x=m.add(g);return Lt(x.x,x.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(n){const g=rr(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(d),x=Math.atan(g.y/g.x)+(g.x<0?Math.PI:0);return d.add(o.rotate(x))}return d.add(o)}function Js(d,e,n,o,c,p,m,g,x,b,T,E){const I=d.text.placedSymbolArray,A=d.text.dynamicLayoutVertexArray,L=d.icon.dynamicLayoutVertexArray,j={};A.clear();for(let V=0;V<I.length;V++){const G=I.get(V),q=G.hidden||!G.crossTileID||d.allowVerticalPlacement&&!G.placedOrientation?null:o[G.crossTileID];if(q){const Y=new h.P(G.anchorX,G.anchorY),$={getElevation:E,width:c.width,height:c.height,pitchedLabelPlaneMatrix:p,pitchWithMap:n,transform:c,tileAnchorPoint:Y,translation:b,unwrappedTileID:T},K=n?ia(Y.x,Y.y,$):rr(Y.x,Y.y,$),J=Ut(c.cameraToCenterDistance,K.signedDistanceFromCamera);let H=h.az(d.textSizeData,g,G)*J/h.aL;n&&(H*=d.tilePixelRatio/m);const{width:it,height:ut,anchor:st,textOffset:ot,textBoxScale:ct}=q,Mt=Ys(st,it,ut,ot,ct,H),wt=c.getPitchedTextCorrection(Y.x+b[0],Y.y+b[1],T),gt=Ks(K.point,$,e,Mt,-c.bearingInRadians,wt),Rt=d.allowVerticalPlacement&&G.placedOrientation===h.ay.vertical?Math.PI/2:0;for(let $t=0;$t<G.numGlyphs;$t++)h.aF(A,gt,Rt);x&&G.associatedIconIndex>=0&&(j[G.associatedIconIndex]={shiftedAnchor:gt,angle:Rt})}else yr(G.numGlyphs,A)}if(x){L.clear();const V=d.icon.placedSymbolArray;for(let G=0;G<V.length;G++){const q=V.get(G);if(q.hidden)yr(q.numGlyphs,L);else{const Y=j[G];if(Y)for(let $=0;$<q.numGlyphs;$++)h.aF(L,Y.shiftedAnchor,Y.angle);else yr(q.numGlyphs,L)}}d.icon.dynamicLayoutVertexBuffer.updateData(L)}d.text.dynamicLayoutVertexBuffer.updateData(A)}function ma(d,e,n){return n.iconsInText&&e?"symbolTextAndIcon":d?"symbolSDF":"symbolIcon"}function Qs(d,e,n,o,c,p,m,g,x,b,T,E,I){const A=d.context,L=A.gl,j=d.transform,V=g==="map",G=x==="map",q=g!=="viewport"&&n.layout.get("symbol-placement")!=="point",Y=V&&!G&&!q,$=!n.layout.get("symbol-sort-key").isConstant();let K=!1;const J=d.getDepthModeForSublayer(0,Ht.ReadOnly),H=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),it=[],ut=j.getCircleRadiusCorrection();for(const st of o){const ot=e.getTile(st),ct=ot.getBucket(n);if(!ct)continue;const Mt=c?ct.text:ct.icon;if(!Mt||!Mt.segments.get().length||!Mt.hasVisibleVertices)continue;const wt=Mt.programConfigurations.get(n.id),gt=c||ct.sdfIcons,Rt=c?ct.textSizeData:ct.iconSizeData,$t=G||j.pitch!==0,Zt=d.useProgram(ma(gt,c,ct),wt),ge=h.ax(Rt,j.zoom),ye=d.style.map.terrain&&d.style.map.terrain.getTerrainData(st);let Ce,ue,He,we,Ne=[0,0],Oe=null;if(c)ue=ot.glyphAtlasTexture,He=L.LINEAR,Ce=ot.glyphAtlasTexture.size,ct.iconsInText&&(Ne=ot.imageAtlasTexture.size,Oe=ot.imageAtlasTexture,we=$t||d.options.rotating||d.options.zooming||Rt.kind==="composite"||Rt.kind==="camera"?L.LINEAR:L.NEAREST);else{const Le=n.layout.get("icon-size").constantOr(0)!==1||ct.iconsNeedLinear;ue=ot.imageAtlasTexture,He=gt||d.options.rotating||d.options.zooming||Le||$t?L.LINEAR:L.NEAREST,Ce=ot.imageAtlasTexture.size}const Ue=h.aM(ot,1,d.transform.zoom),Fi=$e(V,d.transform,Ue),kr=h.N();h.aA(kr,Fi);const Sr=fe(G,V,d.transform,Ue),ln=h.aN(j,ot,p,m),cn=j.getProjectionData({overscaledTileID:st,applyGlobeMatrix:!I,applyTerrainMatrix:!0}),jn=H&&ct.hasTextData(),Xi=n.layout.get("icon-text-fit")!=="none"&&jn&&ct.hasIconData();if(q){const Le=d.style.map.terrain?(Xe,he)=>d.style.map.terrain.getElevation(st,Xe,he):null,Ae=n.layout.get("text-rotation-alignment")==="map";Sn(ct,d,c,Fi,kr,G,b,Ae,st.toUnwrapped(),j.width,j.height,ln,Le)}const Rr=c&&H||Xi,Vi=q||Rr?Cc:G?Fi:d.transform.clipSpaceToPixelsMatrix,Lr=gt&&n.paint.get(c?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Vn;Vn=gt?ct.iconsInText?Ho(Rt.kind,ge,Y,G,q,Rr,d,Vi,Sr,ln,Ce,Ne,ut):Tr(Rt.kind,ge,Y,G,q,Rr,d,Vi,Sr,ln,c,Ce,0,ut):Wa(Rt.kind,ge,Y,G,q,Rr,d,Vi,Sr,ln,c,Ce,ut);const Nn={program:Zt,buffers:Mt,uniformValues:Vn,projectionData:cn,atlasTexture:ue,atlasTextureIcon:Oe,atlasInterpolation:He,atlasInterpolationIcon:we,isSDF:gt,hasHalo:Lr};if($&&ct.canOverlap){K=!0;const Le=Mt.segments.get();for(const Ae of Le)it.push({segments:new h.aW([Ae]),sortKey:Ae.sortKey,state:Nn,terrainData:ye})}else it.push({segments:Mt.segments,sortKey:0,state:Nn,terrainData:ye})}K&&it.sort((st,ot)=>st.sortKey-ot.sortKey);for(const st of it){const ot=st.state;if(A.activeTexture.set(L.TEXTURE0),ot.atlasTexture.bind(ot.atlasInterpolation,L.CLAMP_TO_EDGE),ot.atlasTextureIcon&&(A.activeTexture.set(L.TEXTURE1),ot.atlasTextureIcon&&ot.atlasTextureIcon.bind(ot.atlasInterpolationIcon,L.CLAMP_TO_EDGE)),ot.isSDF){const ct=ot.uniformValues;ot.hasHalo&&(ct.u_is_halo=1,Ac(ot.buffers,st.segments,n,d,ot.program,J,T,E,ct,ot.projectionData,st.terrainData)),ct.u_is_halo=0}Ac(ot.buffers,st.segments,n,d,ot.program,J,T,E,ot.uniformValues,ot.projectionData,st.terrainData)}}function Ac(d,e,n,o,c,p,m,g,x,b,T){const E=o.context;c.draw(E,E.gl.TRIANGLES,p,m,g,re.backCCW,x,T,b,n.id,d.layoutVertexBuffer,d.indexBuffer,e,n.paint,o.transform.zoom,d.programConfigurations.get(n.id),d.dynamicLayoutVertexBuffer,d.opacityVertexBuffer)}function Ka(d,e,n,o,c){const p=d.context,m=p.gl,g=ee.disabled,x=new be([m.ONE,m.ONE],h.bo.transparent,[!0,!0,!0,!0]),b=e.getBucket(n);if(!b)return;const T=o.key;let E=n.heatmapFbos.get(T);E||(E=nl(p,e.tileSize,e.tileSize),n.heatmapFbos.set(T,E)),p.bindFramebuffer.set(E.framebuffer),p.viewport.set([0,0,e.tileSize,e.tileSize]),p.clear({color:h.bo.transparent});const I=b.programConfigurations.get(n.id),A=d.useProgram("heatmap",I,!c),L=d.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),j=d.style.map.terrain.getTerrainData(o);A.draw(p,m.TRIANGLES,Ht.disabled,g,x,re.disabled,Zo(e,d.transform.zoom,n.paint.get("heatmap-intensity"),1),j,L,n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,n.paint,d.transform.zoom,I)}function Yu(d,e,n,o,c){const p=d.context,m=p.gl,g=d.transform;p.setColorMode(d.colorModeForRenderPass());const x=Ja(p,e),b=n.key,T=e.heatmapFbos.get(b);if(!T)return;p.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,T.colorAttachment.get()),p.activeTexture.set(m.TEXTURE1),x.bind(m.LINEAR,m.CLAMP_TO_EDGE);const E=g.getProjectionData({overscaledTileID:n,applyTerrainMatrix:c,applyGlobeMatrix:!o});d.useProgram("heatmapTexture").draw(p,m.TRIANGLES,Ht.disabled,ee.disabled,d.colorModeForRenderPass(),re.disabled,$o(d,e,0,1),null,E,e.id,d.rasterBoundsBuffer,d.quadTriangleIndexBuffer,d.rasterBoundsSegments,e.paint,g.zoom),T.destroy(),e.heatmapFbos.delete(b)}function nl(d,e,n){var o,c;const p=d.gl,m=p.createTexture();p.bindTexture(p.TEXTURE_2D,m),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR);const g=(o=d.HALF_FLOAT)!==null&&o!==void 0?o:p.UNSIGNED_BYTE,x=(c=d.RGBA16F)!==null&&c!==void 0?c:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,x,e,n,0,p.RGBA,g,null);const b=d.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function Ja(d,e){return e.colorRampTexture||(e.colorRampTexture=new h.T(d,e.colorRamp,d.gl.RGBA)),e.colorRampTexture}function to(d,e,n,o,c,p,m,g){let x=256;if(c.stepInterpolant){const b=e.getSource().maxzoom,T=m.canonical.z===b?Math.ceil(1<<d.transform.maxZoom-m.canonical.z):1;x=h.an(h.cd(p.maxLineLength/h.a4*1024*T),256,n.maxTextureSize)}return g.gradient=h.ce({expression:c.gradientExpression(),evaluationKey:"lineProgress",resolution:x,image:g.gradient||void 0,clips:p.lineClipsArray}),g.texture?g.texture.update(g.gradient):g.texture=new h.T(n,g.gradient,o.RGBA),g.version=c.gradientVersion,g.texture}function Dc(d,e,n,o,c){d.activeTexture.set(e.TEXTURE0),n.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),o.updatePaintBuffers(c)}function zc(d,e,n,o,c,p){(c||d.lineAtlas.dirty)&&(e.activeTexture.set(n.TEXTURE0),d.lineAtlas.bind(e)),o.updatePaintBuffers(p)}function eo(d,e,n,o,c,p,m){const g=p.gradients[c.id];let x=g.texture;c.gradientVersion!==g.version&&(x=to(d,e,n,o,c,p,m,g)),n.activeTexture.set(o.TEXTURE0),x.bind(c.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE)}function al(d,e,n,o,c,p,m,g,x){const b=p.gradients[c.id];let T=b.texture;c.gradientVersion!==b.version&&(T=to(d,e,n,o,c,p,m,b)),n.activeTexture.set(o.TEXTURE0),T.bind(c.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE1),d.lineAtlas.bind(n),g.updatePaintBuffers(x)}function kc(d,e,n,o,c){if(!n||!o||!o.imageAtlas)return;const p=o.imageAtlas.patternPositions;let m=p[n.to.toString()],g=p[n.from.toString()];if(!m&&g&&(m=g),!g&&m&&(g=m),!m||!g){const x=c.getPaintProperty(e);m=p[x],g=p[x]}m&&g&&d.setConstantPatternPositions(m,g)}function sl(d,e,n,o,c,p,m,g){const x=d.context.gl,b="fill-pattern",T=n.paint.get(b),E=T&&T.constantOr(1),I=n.getCrossfadeParameters();let A,L,j,V,G;const q=d.transform,Y=n.paint.get("fill-translate"),$=n.paint.get("fill-translate-anchor");m?(L=E&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",A=x.LINES):(L=E?"fillPattern":"fill",A=x.TRIANGLES);const K=T.constantOr(null);for(const J of o){const H=e.getTile(J);if(E&&!H.patternsLoaded())continue;const it=H.getBucket(n);if(!it)continue;const ut=it.programConfigurations.get(n.id),st=d.useProgram(L,ut),ot=d.style.map.terrain&&d.style.map.terrain.getTerrainData(J);E&&(d.context.activeTexture.set(x.TEXTURE0),H.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),ut.updatePaintBuffers(I)),kc(ut,b,K,H,n);const ct=q.getProjectionData({overscaledTileID:J,applyGlobeMatrix:!g,applyTerrainMatrix:!0}),Mt=h.aN(q,H,Y,$);if(m){V=it.indexBuffer2,G=it.segments2;const gt=[x.drawingBufferWidth,x.drawingBufferHeight];j=L==="fillOutlinePattern"&&E?Vu(d,I,H,gt,Mt):fc(gt,Mt)}else V=it.indexBuffer,G=it.segments,j=E?pc(d,I,H,Mt):{u_fill_translate:Mt};const wt=d.stencilModeForClipping(J);st.draw(d.context,A,c,wt,p,re.backCCW,j,ot,ct,n.id,it.layoutVertexBuffer,V,G,n.paint,d.transform.zoom,ut)}}function Ee(d,e,n,o,c,p,m,g){const x=d.context,b=x.gl,T="fill-extrusion-pattern",E=n.paint.get(T),I=E.constantOr(1),A=n.getCrossfadeParameters(),L=n.paint.get("fill-extrusion-opacity"),j=E.constantOr(null),V=d.transform;for(const G of o){const q=e.getTile(G),Y=q.getBucket(n);if(!Y)continue;const $=d.style.map.terrain&&d.style.map.terrain.getTerrainData(G),K=Y.programConfigurations.get(n.id),J=d.useProgram(I?"fillExtrusionPattern":"fillExtrusion",K);I&&(d.context.activeTexture.set(b.TEXTURE0),q.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),K.updatePaintBuffers(A));const H=V.getProjectionData({overscaledTileID:G,applyGlobeMatrix:!g,applyTerrainMatrix:!0});kc(K,T,j,q,n);const it=h.aN(V,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ut=n.paint.get("fill-extrusion-vertical-gradient"),st=I?ha(d,ut,L,it,G,A,q):dc(d,ut,L,it);J.draw(x,x.gl.TRIANGLES,c,p,m,re.backCCW,st,$,H,n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,n.paint,d.transform.zoom,K,d.style.map.terrain&&Y.centroidVertexBuffer)}}function Ar(d,e,n,o,c,p,m,g,x){var b;const T=d.style.projection,E=d.context,I=d.transform,A=E.gl,L=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],j=d.useProgram("hillshade",null,!1,L),V=!d.options.moving;for(const G of o){const q=e.getTile(G),Y=q.fbo;if(!Y)continue;const $=T.getMeshFromTileID(E,G.canonical,g,!0,"raster"),K=(b=d.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(G);E.activeTexture.set(A.TEXTURE0),A.bindTexture(A.TEXTURE_2D,Y.colorAttachment.get());const J=I.getProjectionData({overscaledTileID:G,aligned:V,applyGlobeMatrix:!x,applyTerrainMatrix:!0});j.draw(E,A.TRIANGLES,p,c[G.overscaledZ],m,re.backCCW,Cn(d,q,n),K,J,n.id,$.vertexBuffer,$.indexBuffer,$.segments)}}function Li(d,e,n,o,c,p,m,g,x){var b;const T=d.style.projection,E=d.context,I=d.transform,A=E.gl,L=d.useProgram("colorRelief"),j=!d.options.moving;let V=!0,G=0;for(const q of o){const Y=e.getTile(q),$=Y.dem;if(V){const st=A.getParameter(A.MAX_TEXTURE_SIZE),{elevationTexture:ot,colorTexture:ct}=n.getColorRampTextures(E,st,$.getUnpackVector());E.activeTexture.set(A.TEXTURE1),ot.bind(A.NEAREST,A.CLAMP_TO_EDGE),E.activeTexture.set(A.TEXTURE4),ct.bind(A.LINEAR,A.CLAMP_TO_EDGE),V=!1,G=ot.size[0]}if(!$||!$.data)continue;const K=$.stride,J=$.getPixels();if(E.activeTexture.set(A.TEXTURE0),E.pixelStoreUnpackPremultiplyAlpha.set(!1),Y.demTexture=Y.demTexture||d.getTileTexture(K),Y.demTexture){const st=Y.demTexture;st.update(J,{premultiply:!1}),st.bind(A.LINEAR,A.CLAMP_TO_EDGE)}else Y.demTexture=new h.T(E,J,A.RGBA,{premultiply:!1}),Y.demTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE);const H=T.getMeshFromTileID(E,q.canonical,g,!0,"raster"),it=(b=d.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(q),ut=I.getProjectionData({overscaledTileID:q,aligned:j,applyGlobeMatrix:!x,applyTerrainMatrix:!0});L.draw(E,A.TRIANGLES,p,c[q.overscaledZ],m,re.backCCW,$a(n,Y.dem,G),it,ut,n.id,H.vertexBuffer,H.indexBuffer,H.segments)}}const Qa=[new h.P(0,0),new h.P(h.a4,0),new h.P(h.a4,h.a4),new h.P(0,h.a4)];function Rn(d,e,n,o,c,p,m,g,x=!1,b=!1){const T=o[o.length-1].overscaledZ,E=d.context,I=E.gl,A=d.useProgram("raster"),L=d.transform,j=d.style.projection,V=d.colorModeForRenderPass(),G=!d.options.moving,q=n.paint.get("raster-opacity"),Y=n.paint.get("raster-resampling"),$=n.paint.get("raster-fade-duration"),K=!!d.style.map.terrain;for(const J of o){const H=d.getDepthModeForSublayer(J.overscaledZ-T,q===1?Ht.ReadWrite:Ht.ReadOnly,I.LESS),it=e.getTile(J),ut=Y==="nearest"?I.NEAREST:I.LINEAR;E.activeTexture.set(I.TEXTURE0),it.texture.bind(ut,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST),E.activeTexture.set(I.TEXTURE1);const{parentTile:st,parentScaleBy:ot,parentTopLeft:ct,fadeValues:Mt}=Rc(it,e,$,K);it.fadeOpacity=Mt.tileOpacity,st?(st.fadeOpacity=Mt.parentTileOpacity,st.texture.bind(ut,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST)):it.texture.bind(ut,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST),it.texture.useMipmap&&E.extTextureFilterAnisotropic&&d.transform.pitch>20&&I.texParameterf(I.TEXTURE_2D,E.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,E.extTextureFilterAnisotropicMax);const wt=d.style.map.terrain&&d.style.map.terrain.getTerrainData(J),gt=L.getProjectionData({overscaledTileID:J,aligned:G,applyGlobeMatrix:!b,applyTerrainMatrix:!0}),Rt=Wo(ct,ot,Mt.fadeMix,n,g),$t=j.getMeshFromTileID(E,J.canonical,p,m,"raster");A.draw(E,I.TRIANGLES,H,c?c[J.overscaledZ]:ee.disabled,V,x?re.frontCCW:re.backCCW,Rt,wt,gt,n.id,$t.vertexBuffer,$t.indexBuffer,$t.segments)}}function Rc(d,e,n,o){const c={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||o)return c;if(d.fadingParentID){const p=e.getLoadedTile(d.fadingParentID);if(!p)return c;const m=Math.pow(2,p.tileID.overscaledZ-d.tileID.overscaledZ),g=[d.tileID.canonical.x*m%1,d.tileID.canonical.y*m%1],x=function(b,T,E){const I=ie(),A=(I-T.timeAdded)/E,L=b.fadingDirection===tt.Incoming,j=h.an((I-b.timeAdded)/E,0,1),V=h.an(1-A,0,1),G=L?j:V;return{tileOpacity:G,parentTileOpacity:L?V:j,fadeMix:{opacity:1,mix:1-G}}}(d,p,n);return{parentTile:p,parentScaleBy:m,parentTopLeft:g,fadeValues:x}}if(d.selfFading){const p=function(m,g){const x=(ie()-m.timeAdded)/g,b=h.an(x,0,1);return{tileOpacity:b,fadeMix:{opacity:b,mix:0}}}(d,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:p}}return c}const _a=new h.bo(1,0,0,1),ol=new h.bo(0,1,0,1),ts=new h.bo(0,0,1,1),ll=new h.bo(1,0,1,1),Lc=new h.bo(0,1,1,1);function cl(d,e,n,o){es(d,0,e+n/2,d.transform.width,n,o)}function ul(d,e,n,o){es(d,e-n/2,0,n,d.transform.height,o)}function es(d,e,n,o,c,p){const m=d.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(e*d.pixelRatio,n*d.pixelRatio,o*d.pixelRatio,c*d.pixelRatio),m.clear({color:p}),g.disable(g.SCISSOR_TEST)}function Fc(d,e,n){const o=d.context,c=o.gl,p=d.useProgram("debug"),m=Ht.disabled,g=ee.disabled,x=d.colorModeForRenderPass(),b="$debug",T=d.style.map.terrain&&d.style.map.terrain.getTerrainData(n);o.activeTexture.set(c.TEXTURE0);const E=e.getTileByID(n.key).latestRawTileData,I=Math.floor((E&&E.byteLength||0)/1024),A=e.getTile(n).tileSize,L=512/Math.min(A,512)*(n.overscaledZ/d.transform.zoom)*.5;let j=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(j+=` => ${n.overscaledZ}`),function(G,q){G.initDebugOverlayCanvas();const Y=G.debugOverlayCanvas,$=G.context.gl,K=G.debugOverlayCanvas.getContext("2d");K.clearRect(0,0,Y.width,Y.height),K.shadowColor="white",K.shadowBlur=2,K.lineWidth=1.5,K.strokeStyle="white",K.textBaseline="top",K.font="bold 36px Open Sans, sans-serif",K.fillText(q,5,5),K.strokeText(q,5,5),G.debugOverlayTexture.update(Y),G.debugOverlayTexture.bind($.LINEAR,$.CLAMP_TO_EDGE)}(d,`${j} ${I}kB`);const V=d.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(o,c.TRIANGLES,m,g,be.alphaBlended,re.disabled,Go(h.bo.transparent,L),null,V,b,d.debugBuffer,d.quadTriangleIndexBuffer,d.debugSegments),p.draw(o,c.LINE_STRIP,m,g,x,re.disabled,Go(h.bo.red),T,V,b,d.debugBuffer,d.tileBorderIndexBuffer,d.debugSegments)}function sn(d,e,n,o){const{isRenderingGlobe:c}=o,p=d.context,m=p.gl,g=d.transform,x=d.colorModeForRenderPass(),b=d.getDepthModeFor3D(),T=d.useProgram("terrain");p.bindFramebuffer.set(null),p.viewport.set([0,0,d.width,d.height]);for(const E of n){const I=e.getTerrainMesh(E.tileID),A=d.renderToTexture.getTexture(E),L=e.getTerrainData(E.tileID);p.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,A.texture);const j=e.getMeshFrameDelta(g.zoom),V=g.calculateFogMatrix(E.tileID.toUnwrapped()),G=No(j,V,d.style.sky,g.pitch,c),q=g.getProjectionData({overscaledTileID:E.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});T.draw(p,m.TRIANGLES,b,ee.disabled,x,re.backCCW,G,L,q,"terrain",I.vertexBuffer,I.indexBuffer,I.segments)}}function hl(d,e){if(!e.mesh){const n=new h.aV;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const o=new h.aX;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),e.mesh=new en(d.createVertexBuffer(n,qe.members),d.createIndexBuffer(o),h.aW.simpleSegment(0,0,n.length,o.length))}return e.mesh}class Bc{constructor(e,n){this.context=new Hs(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:h.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Yt.maxOverzooming+Yt.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Mn}resize(e,n,o){if(this.width=Math.floor(e*o),this.height=Math.floor(n*o),this.pixelRatio=o,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style._order)this.style._layers[c].resize()}setup(){const e=this.context,n=new h.aV;n.emplaceBack(0,0),n.emplaceBack(h.a4,0),n.emplaceBack(0,h.a4),n.emplaceBack(h.a4,h.a4),this.tileExtentBuffer=e.createVertexBuffer(n,qe.members),this.tileExtentSegments=h.aW.simpleSegment(0,0,4,2);const o=new h.aV;o.emplaceBack(0,0),o.emplaceBack(h.a4,0),o.emplaceBack(0,h.a4),o.emplaceBack(h.a4,h.a4),this.debugBuffer=e.createVertexBuffer(o,qe.members),this.debugSegments=h.aW.simpleSegment(0,0,4,5);const c=new h.cg;c.emplaceBack(0,0,0,0),c.emplaceBack(h.a4,0,h.a4,0),c.emplaceBack(0,h.a4,0,h.a4),c.emplaceBack(h.a4,h.a4,h.a4,h.a4),this.rasterBoundsBuffer=e.createVertexBuffer(c,wr.members),this.rasterBoundsSegments=h.aW.simpleSegment(0,0,4,2);const p=new h.aV;p.emplaceBack(0,0),p.emplaceBack(h.a4,0),p.emplaceBack(0,h.a4),p.emplaceBack(h.a4,h.a4),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(p,qe.members),this.rasterBoundsSegmentsPosOnly=h.aW.simpleSegment(0,0,4,5);const m=new h.aV;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(m,qe.members),this.viewportSegments=h.aW.simpleSegment(0,0,4,2);const g=new h.ch;g.emplaceBack(0),g.emplaceBack(1),g.emplaceBack(3),g.emplaceBack(2),g.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(g);const x=new h.aX;x.emplaceBack(1,0,2),x.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(x);const b=this.context.gl;this.stencilClearMode=new ee({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.tileExtentMesh=new en(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const o=h.N();h.c6(o,0,this.width,this.height,0,0,1),h.Q(o,o,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const c={mainMatrix:o,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o};this.useProgram("clippingMask",null,!0).draw(e,n.TRIANGLES,Ht.disabled,this.stencilClearMode,be.disabled,re.disabled,null,null,c,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n,o){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source,this.nextStencilID+n.length>256&&this.clearStencil();const c=this.context;c.setColorMode(be.disabled),c.setDepthMode(Ht.disabled);const p={};for(const m of n)p[m.key]=this.nextStencilID++;this._renderTileMasks(p,n,o,!0),this._renderTileMasks(p,n,o,!1),this._tileClippingMaskIDs=p}_renderTileMasks(e,n,o,c){const p=this.context,m=p.gl,g=this.style.projection,x=this.transform,b=this.useProgram("clippingMask");for(const T of n){const E=e[T.key],I=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T),A=g.getMeshFromTileID(this.context,T.canonical,c,!0,"stencil"),L=x.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!o,applyTerrainMatrix:!0});b.draw(p,m.TRIANGLES,Ht.disabled,new ee({func:m.ALWAYS,mask:0},E,255,m.KEEP,m.KEEP,m.REPLACE),be.disabled,o?re.disabled:re.backCCW,null,I,L,"$clipping",A.vertexBuffer,A.indexBuffer,A.segments)}}_renderTilesDepthBuffer(){const e=this.context,n=e.gl,o=this.style.projection,c=this.transform,p=this.useProgram("depth"),m=this.getDepthModeFor3D(),g=qt(c,{tileSize:c.tileSize});for(const x of g){const b=this.style.map.terrain&&this.style.map.terrain.getTerrainData(x),T=o.getMeshFromTileID(this.context,x.canonical,!0,!0,"raster"),E=c.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(e,n.TRIANGLES,m,ee.disabled,be.disabled,re.backCCW,null,b,E,"$clipping",T.vertexBuffer,T.indexBuffer,T.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new ee({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new ee({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const n=this.context.gl,o=e.sort((m,g)=>g.overscaledZ-m.overscaledZ),c=o[o.length-1].overscaledZ,p=o[0].overscaledZ-c+1;if(p>1){this.currentStencilSource=void 0,this.nextStencilID+p>256&&this.clearStencil();const m={};for(let g=0;g<p;g++)m[g+c]=new ee({func:n.GEQUAL,mask:255},g+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=p,[m,o]}return[{[c]:ee.disabled},o]}stencilConfigForOverlapTwoPass(e){const n=this.context.gl,o=e.sort((m,g)=>g.overscaledZ-m.overscaledZ),c=o[o.length-1].overscaledZ,p=o[0].overscaledZ-c+1;if(this.clearStencil(),p>1){const m={},g={};for(let x=0;x<p;x++)m[x+c]=new ee({func:n.GREATER,mask:255},p+1+x,255,n.KEEP,n.KEEP,n.REPLACE),g[x+c]=new ee({func:n.GREATER,mask:255},1+x,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*p+1,[m,g,o]}return this.nextStencilID=3,[{[c]:new ee({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[c]:new ee({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},o]}colorModeForRenderPass(){const e=this.context.gl;return this._showOverdrawInspector?new be([e.CONSTANT_COLOR,e.ONE],new h.bo(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?be.unblended:be.alphaBlended}getDepthModeForSublayer(e,n,o){if(!this.opaquePassEnabledForLayer())return Ht.disabled;const c=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ht(o||this.context.gl.LEQUAL,n,[c,c])}getDepthModeFor3D(){return new Ht(this.context.gl.LEQUAL,Ht.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var o,c;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(ie()),this.imageManager.beginFrame();const p=this.style._order,m=this.style.tileManagers,g={},x={},b={},T={isRenderingToTexture:!1,isRenderingGlobe:((o=e.projection)===null||o===void 0?void 0:o.transitionState)>0};for(const I in m){const A=m[I];A.used&&A.prepare(this.context),g[I]=A.getVisibleCoordinates(!1),x[I]=g[I].slice().reverse(),b[I]=A.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let I=0;I<p.length;I++)if(this.style._layers[p[I]].is3D()){this.opaquePassCutoff=I;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const I of p){const A=this.style._layers[I];if(!A.hasOffscreenPass()||A.isHidden(this.transform.zoom))continue;const L=x[A.source];(A.type==="custom"||L.length)&&this.renderLayer(this,m[A.source],A,L,T)}if((c=this.style.projection)===null||c===void 0||c.updateGPUdependent({context:this.context,useProgram:I=>this.useProgram(I)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?h.bo.black:h.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(I,A){const L=I.context,j=L.gl,V=((J,H,it)=>{const ut=Math.cos(H.rollInRadians),st=Math.sin(H.rollInRadians),ot=nt(H),ct=H.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:J.properties.get("sky-color"),u_horizon_color:J.properties.get("horizon-color"),u_horizon:[(H.width/2-ot*st)*it,(H.height/2+ot*ut)*it],u_horizon_normal:[-st,ut],u_sky_horizon_blend:J.properties.get("sky-horizon-blend")*H.height/2*it,u_sky_blend:ct}})(A,I.style.map.transform,I.pixelRatio),G=new Ht(j.LEQUAL,Ht.ReadWrite,[0,1]),q=ee.disabled,Y=I.colorModeForRenderPass(),$=I.useProgram("sky"),K=hl(L,A);$.draw(L,j.TRIANGLES,G,q,Y,re.disabled,V,null,void 0,"sky",K.vertexBuffer,K.indexBuffer,K.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=p.length-1;this.currentLayer>=0;this.currentLayer--){const I=this.style._layers[p[this.currentLayer]],A=m[I.source],L=g[I.source];this._renderTileClippingMasks(I,L,!1),this.renderLayer(this,A,I,L,T)}this.renderPass="translucent";let E=!1;for(this.currentLayer=0;this.currentLayer<p.length;this.currentLayer++){const I=this.style._layers[p[this.currentLayer]],A=m[I.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(I,T))continue;this.opaquePassEnabledForLayer()||E||(E=!0,T.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const L=(I.type==="symbol"?b:x)[I.source];this._renderTileClippingMasks(I,g[I.source],!!this.renderToTexture),this.renderLayer(this,A,I,L,T)}if(T.isRenderingGlobe&&function(I,A,L){const j=I.context,V=j.gl,G=I.useProgram("atmosphere"),q=new Ht(V.LEQUAL,Ht.ReadOnly,[0,1]),Y=I.transform,$=function(ct,Mt){const wt=ct.properties.get("position"),gt=[-wt.x,-wt.y,-wt.z],Rt=h.ar(new Float64Array(16));return ct.properties.get("anchor")==="map"&&(h.bf(Rt,Rt,Mt.rollInRadians),h.bg(Rt,Rt,-Mt.pitchInRadians),h.bf(Rt,Rt,Mt.bearingInRadians),h.bg(Rt,Rt,Mt.center.lat*Math.PI/180),h.bI(Rt,Rt,-Mt.center.lng*Math.PI/180)),h.cf(gt,gt,Rt),gt}(L,I.transform),K=Y.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),J=A.properties.get("atmosphere-blend")*K.projectionTransition;if(J===0)return;const H=zs(Y.worldSize,Y.center.lat),it=Y.inverseProjectionMatrix,ut=new Float64Array(4);ut[3]=1,h.aG(ut,ut,Y.modelViewProjectionMatrix),ut[0]/=ut[3],ut[1]/=ut[3],ut[2]/=ut[3],ut[3]=1,h.aG(ut,ut,it),ut[0]/=ut[3],ut[1]/=ut[3],ut[2]/=ut[3],ut[3]=1;const st=((ct,Mt,wt,gt,Rt)=>({u_sun_pos:ct,u_atmosphere_blend:Mt,u_globe_position:wt,u_globe_radius:gt,u_inv_proj_matrix:Rt}))($,J,[ut[0],ut[1],ut[2]],H,it),ot=hl(j,A);G.draw(j,V.TRIANGLES,q,ee.disabled,be.alphaBlended,re.disabled,st,null,null,"atmosphere",ot.vertexBuffer,ot.indexBuffer,ot.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const I=function(A,L){let j=null;const V=Object.values(A._layers).flatMap($=>$.source&&!$.isHidden(L)?[A.tileManagers[$.source]]:[]),G=V.filter($=>$.getSource().type==="vector"),q=V.filter($=>$.getSource().type!=="vector"),Y=$=>{(!j||j.getSource().maxzoom<$.getSource().maxzoom)&&(j=$)};return G.forEach($=>Y($)),j||q.forEach($=>Y($)),j}(this.style,this.transform.zoom);I&&function(A,L,j){for(let V=0;V<j.length;V++)Fc(A,L,j[V])}(this,I,I.getVisibleCoordinates())}this.options.showPadding&&function(I){const A=I.transform.padding;cl(I,I.transform.height-(A.top||0),3,_a),cl(I,A.bottom||0,3,ol),ul(I,A.left||0,3,ts),ul(I,I.transform.width-(A.right||0),3,ll);const L=I.transform.centerPoint;(function(j,V,G,q){es(j,V-1,G-10,2,20,q),es(j,V-10,G-1,20,2,q)})(I,L.x,I.transform.height-L.y,Lc)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix;let c=this.terrainFacilitator.dirty;c||(c=e?!h.ci(n,o):!h.cj(n,o)),c||(c=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),c&&(h.ck(n,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(p,m){const g=p.context,x=g.gl,b=p.transform,T=be.unblended,E=new Ht(x.LEQUAL,Ht.ReadWrite,[0,1]),I=m.tileManager.getRenderableTiles(),A=p.useProgram("terrainDepth");g.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),g.viewport.set([0,0,p.width/devicePixelRatio,p.height/devicePixelRatio]),g.clear({color:h.bo.transparent,depth:1});for(const L of I){const j=m.getTerrainMesh(L.tileID),V=m.getTerrainData(L.tileID),G=b.getProjectionData({overscaledTileID:L.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),q={u_ele_delta:m.getMeshFrameDelta(b.zoom)};A.draw(g,x.TRIANGLES,E,ee.disabled,T,re.backCCW,q,V,G,"terrain",j.vertexBuffer,j.indexBuffer,j.segments)}g.bindFramebuffer.set(null),g.viewport.set([0,0,p.width,p.height])}(this,this.style.map.terrain),function(p,m){const g=p.context,x=g.gl,b=p.transform,T=be.unblended,E=new Ht(x.LEQUAL,Ht.ReadWrite,[0,1]),I=m.getCoordsTexture(),A=m.tileManager.getRenderableTiles(),L=p.useProgram("terrainCoords");g.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),g.viewport.set([0,0,p.width/devicePixelRatio,p.height/devicePixelRatio]),g.clear({color:h.bo.transparent,depth:1}),m.coordsIndex=[];for(const j of A){const V=m.getTerrainMesh(j.tileID),G=m.getTerrainData(j.tileID);g.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,I.texture);const q={u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(b.zoom)},Y=b.getProjectionData({overscaledTileID:j.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});L.draw(g,x.TRIANGLES,E,ee.disabled,T,re.backCCW,q,G,Y,"terrain",V.vertexBuffer,V.indexBuffer,V.segments),m.coordsIndex.push(j.tileID.key)}g.bindFramebuffer.set(null),g.viewport.set([0,0,p.width,p.height])}(this,this.style.map.terrain))}renderLayer(e,n,o,c,p){o.isHidden(this.transform.zoom)||(o.type==="background"||o.type==="custom"||(c||[]).length)&&(this.id=o.id,h.cl(o)?function(m,g,x,b,T,E){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:I}=E,A=ee.disabled,L=m.colorModeForRenderPass();(x._unevaluatedLayout.hasValue("text-variable-anchor")||x._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(j,V,G,q,Y,$,K,J,H){const it=V.transform,ut=V.style.map.terrain,st=Y==="map",ot=$==="map";for(const ct of j){const Mt=q.getTile(ct),wt=Mt.getBucket(G);if(!wt||!wt.text||!wt.text.segments.get().length)continue;const gt=h.ax(wt.textSizeData,it.zoom),Rt=h.aM(Mt,1,V.transform.zoom),$t=$e(st,V.transform,Rt),Zt=G.layout.get("icon-text-fit")!=="none"&&wt.hasIconData();if(gt){const ge=Math.pow(2,it.zoom-Mt.tileID.overscaledZ),ye=ut?(Ce,ue)=>ut.getElevation(ct,Ce,ue):null;Js(wt,st,ot,H,it,$t,ge,gt,Zt,h.aN(it,Mt,K,J),ct.toUnwrapped(),ye)}}}(b,m,x,g,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),T),x.paint.get("icon-opacity").constantOr(1)!==0&&Qs(m,g,x,b,!1,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),x.layout.get("icon-rotation-alignment"),x.layout.get("icon-pitch-alignment"),x.layout.get("icon-keep-upright"),A,L,I),x.paint.get("text-opacity").constantOr(1)!==0&&Qs(m,g,x,b,!0,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),x.layout.get("text-keep-upright"),A,L,I),g.map.showCollisionBoxes&&(Xs(m,g,x,b,!0),Xs(m,g,x,b,!1))}(e,n,o,c,this.style.placement.variableOffsets,p):h.cm(o)?function(m,g,x,b,T){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:E}=T,I=x.paint.get("circle-opacity"),A=x.paint.get("circle-stroke-width"),L=x.paint.get("circle-stroke-opacity"),j=!x.layout.get("circle-sort-key").isConstant();if(I.constantOr(1)===0&&(A.constantOr(1)===0||L.constantOr(1)===0))return;const V=m.context,G=V.gl,q=m.transform,Y=m.getDepthModeForSublayer(0,Ht.ReadOnly),$=ee.disabled,K=m.colorModeForRenderPass(),J=[],H=q.getCircleRadiusCorrection();for(let it=0;it<b.length;it++){const ut=b[it],st=g.getTile(ut),ot=st.getBucket(x);if(!ot)continue;const ct=x.paint.get("circle-translate"),Mt=x.paint.get("circle-translate-anchor"),wt=h.aN(q,st,ct,Mt),gt=ot.programConfigurations.get(x.id),Rt=m.useProgram("circle",gt),$t=ot.layoutVertexBuffer,Zt=ot.indexBuffer,ge=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ut),ye={programConfiguration:gt,program:Rt,layoutVertexBuffer:$t,indexBuffer:Zt,uniformValues:mc(m,st,x,wt,H),terrainData:ge,projectionData:q.getProjectionData({overscaledTileID:ut,applyGlobeMatrix:!E,applyTerrainMatrix:!0})};if(j){const Ce=ot.segments.get();for(const ue of Ce)J.push({segments:new h.aW([ue]),sortKey:ue.sortKey,state:ye})}else J.push({segments:ot.segments,sortKey:0,state:ye})}j&&J.sort((it,ut)=>it.sortKey-ut.sortKey);for(const it of J){const{programConfiguration:ut,program:st,layoutVertexBuffer:ot,indexBuffer:ct,uniformValues:Mt,terrainData:wt,projectionData:gt}=it.state;st.draw(V,G.TRIANGLES,Y,$,K,re.backCCW,Mt,wt,gt,x.id,ot,ct,it.segments,x.paint,m.transform.zoom,ut)}}(e,n,o,c,p):h.cn(o)?function(m,g,x,b,T){if(x.paint.get("heatmap-opacity")===0)return;const E=m.context,{isRenderingToTexture:I,isRenderingGlobe:A}=T;if(m.style.map.terrain){for(const L of b){const j=g.getTile(L);g.hasRenderableParent(L)||(m.renderPass==="offscreen"?Ka(m,j,x,L,A):m.renderPass==="translucent"&&Yu(m,x,L,I,A))}E.viewport.set([0,0,m.width,m.height])}else m.renderPass==="offscreen"?function(L,j,V,G){const q=L.context,Y=q.gl,$=L.transform,K=ee.disabled,J=new be([Y.ONE,Y.ONE],h.bo.transparent,[!0,!0,!0,!0]);(function(H,it,ut){const st=H.gl;H.activeTexture.set(st.TEXTURE1),H.viewport.set([0,0,it.width/4,it.height/4]);let ot=ut.heatmapFbos.get(h.cc);ot?(st.bindTexture(st.TEXTURE_2D,ot.colorAttachment.get()),H.bindFramebuffer.set(ot.framebuffer)):(ot=nl(H,it.width/4,it.height/4),ut.heatmapFbos.set(h.cc,ot))})(q,L,V),q.clear({color:h.bo.transparent});for(let H=0;H<G.length;H++){const it=G[H];if(j.hasRenderableParent(it))continue;const ut=j.getTile(it),st=ut.getBucket(V);if(!st)continue;const ot=st.programConfigurations.get(V.id),ct=L.useProgram("heatmap",ot),Mt=$.getProjectionData({overscaledTileID:it,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),wt=$.getCircleRadiusCorrection();ct.draw(q,Y.TRIANGLES,Ht.disabled,K,J,re.backCCW,Zo(ut,$.zoom,V.paint.get("heatmap-intensity"),wt),null,Mt,V.id,st.layoutVertexBuffer,st.indexBuffer,st.segments,V.paint,$.zoom,ot)}q.viewport.set([0,0,L.width,L.height])}(m,g,x,b):m.renderPass==="translucent"&&function(L,j){const V=L.context,G=V.gl;V.setColorMode(L.colorModeForRenderPass());const q=j.heatmapFbos.get(h.cc);q&&(V.activeTexture.set(G.TEXTURE0),G.bindTexture(G.TEXTURE_2D,q.colorAttachment.get()),V.activeTexture.set(G.TEXTURE1),Ja(V,j).bind(G.LINEAR,G.CLAMP_TO_EDGE),L.useProgram("heatmapTexture").draw(V,G.TRIANGLES,Ht.disabled,ee.disabled,L.colorModeForRenderPass(),re.disabled,$o(L,j,0,1),null,null,j.id,L.viewportBuffer,L.quadTriangleIndexBuffer,L.viewportSegments,j.paint,L.transform.zoom))}(m,x)}(e,n,o,c,p):h.co(o)?function(m,g,x,b,T){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:E}=T,I=x.paint.get("line-opacity"),A=x.paint.get("line-width");if(I.constantOr(1)===0||A.constantOr(1)===0)return;const L=m.getDepthModeForSublayer(0,Ht.ReadOnly),j=m.colorModeForRenderPass(),V=x.paint.get("line-dasharray"),G=V.constantOr(1),q=x.paint.get("line-pattern"),Y=q.constantOr(1),$=x.paint.get("line-gradient"),K=x.getCrossfadeParameters();let J;J=Y?"linePattern":G&&$?"lineGradientSDF":G?"lineSDF":$?"lineGradient":"line";const H=m.context,it=H.gl,ut=m.transform;let st=!0;for(const ot of b){const ct=g.getTile(ot);if(Y&&!ct.patternsLoaded())continue;const Mt=ct.getBucket(x);if(!Mt)continue;const wt=Mt.programConfigurations.get(x.id),gt=m.context.program.get(),Rt=m.useProgram(J,wt),$t=st||Rt.program!==gt,Zt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ot),ge=q.constantOr(null),ye=V&&V.constantOr(null);if(ge&&ct.imageAtlas){const Ne=ct.imageAtlas,Oe=Ne.patternPositions[ge.to.toString()],Ue=Ne.patternPositions[ge.from.toString()];Oe&&Ue&&wt.setConstantPatternPositions(Oe,Ue)}else if(ye){const Ne=x.layout.get("line-cap")==="round",Oe=m.lineAtlas.getDash(ye.to,Ne),Ue=m.lineAtlas.getDash(ye.from,Ne);wt.setConstantDashPositions(Oe,Ue)}const Ce=ut.getProjectionData({overscaledTileID:ot,applyGlobeMatrix:!E,applyTerrainMatrix:!0}),ue=ut.getPixelScale();let He;Y?(He=Nu(m,ct,x,ue,K),Dc(H,it,ct,wt,K)):G&&$?(He=xc(m,ct,x,ue,K,Mt.lineClipsArray.length),al(m,g,H,it,x,Mt,ot,wt,K)):G?(He=Uu(m,ct,x,ue,K),zc(m,H,it,wt,$t,K)):$?(He=qa(m,ct,x,ue,Mt.lineClipsArray.length),eo(m,g,H,it,x,Mt,ot)):He=Bs(m,ct,x,ue);const we=m.stencilModeForClipping(ot);Rt.draw(H,it.TRIANGLES,L,we,j,re.disabled,He,Zt,Ce,x.id,Mt.layoutVertexBuffer,Mt.indexBuffer,Mt.segments,x.paint,m.transform.zoom,wt,Mt.layoutVertexBuffer2),st=!1}}(e,n,o,c,p):h.cp(o)?function(m,g,x,b,T){const E=x.paint.get("fill-color"),I=x.paint.get("fill-opacity");if(I.constantOr(1)===0)return;const{isRenderingToTexture:A}=T,L=m.colorModeForRenderPass(),j=x.paint.get("fill-pattern"),V=m.opaquePassEnabledForLayer()&&!j.constantOr(1)&&E.constantOr(h.bo.transparent).a===1&&I.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===V){const G=m.getDepthModeForSublayer(1,m.renderPass==="opaque"?Ht.ReadWrite:Ht.ReadOnly);sl(m,g,x,b,G,L,!1,A)}if(m.renderPass==="translucent"&&x.paint.get("fill-antialias")){const G=m.getDepthModeForSublayer(x.getPaintProperty("fill-outline-color")?2:0,Ht.ReadOnly);sl(m,g,x,b,G,L,!0,A)}}(e,n,o,c,p):h.cq(o)?function(m,g,x,b,T){const E=x.paint.get("fill-extrusion-opacity");if(E===0)return;const{isRenderingToTexture:I}=T;if(m.renderPass==="translucent"){const A=new Ht(m.context.gl.LEQUAL,Ht.ReadWrite,m.depthRangeFor3D);if(E!==1||x.paint.get("fill-extrusion-pattern").constantOr(1))Ee(m,g,x,b,A,ee.disabled,be.disabled,I),Ee(m,g,x,b,A,m.stencilModeFor3D(),m.colorModeForRenderPass(),I);else{const L=m.colorModeForRenderPass();Ee(m,g,x,b,A,ee.disabled,L,I)}}}(e,n,o,c,p):h.cr(o)?function(m,g,x,b,T){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;const{isRenderingToTexture:E}=T,I=m.context,A=m.style.projection.useSubdivision,L=m.getDepthModeForSublayer(0,Ht.ReadOnly),j=m.colorModeForRenderPass();if(m.renderPass==="offscreen")(function(V,G,q,Y,$,K,J){const H=V.context,it=H.gl;for(const ut of q){const st=G.getTile(ut),ot=st.dem;if(!ot||!ot.data||!st.needsHillshadePrepare)continue;const ct=ot.dim,Mt=ot.stride,wt=ot.getPixels();if(H.activeTexture.set(it.TEXTURE1),H.pixelStoreUnpackPremultiplyAlpha.set(!1),st.demTexture=st.demTexture||V.getTileTexture(Mt),st.demTexture){const Rt=st.demTexture;Rt.update(wt,{premultiply:!1}),Rt.bind(it.NEAREST,it.CLAMP_TO_EDGE)}else st.demTexture=new h.T(H,wt,it.RGBA,{premultiply:!1}),st.demTexture.bind(it.NEAREST,it.CLAMP_TO_EDGE);H.activeTexture.set(it.TEXTURE0);let gt=st.fbo;if(!gt){const Rt=new h.T(H,{width:ct,height:ct,data:null},it.RGBA);Rt.bind(it.LINEAR,it.CLAMP_TO_EDGE),gt=st.fbo=H.createFramebuffer(ct,ct,!0,!1),gt.colorAttachment.set(Rt.texture)}H.bindFramebuffer.set(gt.framebuffer),H.viewport.set([0,0,ct,ct]),V.useProgram("hillshadePrepare").draw(H,it.TRIANGLES,$,K,J,re.disabled,gc(st.tileID,ot),null,null,Y.id,V.rasterBoundsBuffer,V.quadTriangleIndexBuffer,V.rasterBoundsSegments),st.needsHillshadePrepare=!1}})(m,g,b,x,L,ee.disabled,j),I.viewport.set([0,0,m.width,m.height]);else if(m.renderPass==="translucent")if(A){const[V,G,q]=m.stencilConfigForOverlapTwoPass(b);Ar(m,g,x,q,V,L,j,!1,E),Ar(m,g,x,q,G,L,j,!0,E)}else{const[V,G]=m.getStencilConfigForOverlapAndUpdateStencilID(b);Ar(m,g,x,G,V,L,j,!1,E)}}(e,n,o,c,p):h.cs(o)?function(m,g,x,b,T){if(m.renderPass!=="translucent"||!b.length)return;const{isRenderingToTexture:E}=T,I=m.style.projection.useSubdivision,A=m.getDepthModeForSublayer(0,Ht.ReadOnly),L=m.colorModeForRenderPass();if(I){const[j,V,G]=m.stencilConfigForOverlapTwoPass(b);Li(m,g,x,G,j,A,L,!1,E),Li(m,g,x,G,V,A,L,!0,E)}else{const[j,V]=m.getStencilConfigForOverlapAndUpdateStencilID(b);Li(m,g,x,V,j,A,L,!1,E)}}(e,n,o,c,p):h.bT(o)?function(m,g,x,b,T){if(m.renderPass!=="translucent"||x.paint.get("raster-opacity")===0||!b.length)return;const{isRenderingToTexture:E}=T,I=g.getSource(),A=m.style.projection.useSubdivision;if(I instanceof Ai)Rn(m,g,x,b,null,!1,!1,I.tileCoords,I.flippedWindingOrder,E);else if(A){const[L,j,V]=m.stencilConfigForOverlapTwoPass(b);Rn(m,g,x,V,L,!1,!0,Qa,!1,E),Rn(m,g,x,V,j,!0,!0,Qa,!1,E)}else{const[L,j]=m.getStencilConfigForOverlapAndUpdateStencilID(b);Rn(m,g,x,j,L,!1,!0,Qa,!1,E)}}(e,n,o,c,p):h.ct(o)?function(m,g,x,b,T){const E=x.paint.get("background-color"),I=x.paint.get("background-opacity");if(I===0)return;const{isRenderingToTexture:A}=T,L=m.context,j=L.gl,V=m.style.projection,G=m.transform,q=G.tileSize,Y=x.paint.get("background-pattern");if(m.isPatternMissing(Y))return;const $=!Y&&E.a===1&&I===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==$)return;const K=ee.disabled,J=m.getDepthModeForSublayer(0,$==="opaque"?Ht.ReadWrite:Ht.ReadOnly),H=m.colorModeForRenderPass(),it=m.useProgram(Y?"backgroundPattern":"background"),ut=b||qt(G,{tileSize:q,terrain:m.style.map.terrain});Y&&(L.activeTexture.set(j.TEXTURE0),m.imageManager.bind(m.context));const st=x.getCrossfadeParameters();for(const ot of ut){const ct=G.getProjectionData({overscaledTileID:ot,applyGlobeMatrix:!A,applyTerrainMatrix:!0}),Mt=Y?Yo(I,m,Y,{tileID:ot,tileSize:q},st):Xo(I,E),wt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ot),gt=V.getMeshFromTileID(L,ot.canonical,!1,!0,"raster");it.draw(L,j.TRIANGLES,J,K,H,re.backCCW,Mt,wt,ct,x.id,gt.vertexBuffer,gt.indexBuffer,gt.segments)}}(e,0,o,c,p):h.cu(o)&&function(m,g,x,b){const{isRenderingGlobe:T}=b,E=m.context,I=x.implementation,A=m.style.projection,L=m.transform,j=L.getProjectionDataForCustomLayer(T),V={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;
|
||
uniform mat4 u_projection_matrix;
|
||
${A.shaderPreludeCode.vertexSource}`,define:A.shaderDefine},defaultProjectionData:j},G=I.renderingMode?I.renderingMode:"2d";if(m.renderPass==="offscreen"){const q=I.prerender;q&&(m.setCustomLayerDefaults(),E.setColorMode(m.colorModeForRenderPass()),q.call(I,E.gl,V),E.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),E.setColorMode(m.colorModeForRenderPass()),E.setStencilMode(ee.disabled);const q=G==="3d"?m.getDepthModeFor3D():m.getDepthModeForSublayer(0,Ht.ReadOnly);E.setDepthMode(q),I.render(E.gl,V),E.setDirty(),m.setBaseState(),E.bindFramebuffer.set(null)}}(e,0,o,p))}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),o=this.imageManager.getPattern(e.to.toString());return!n||!o}useProgram(e,n,o=!1,c=[]){this.cache=this.cache||{};const p=!!this.style.map.terrain,m=this.style.projection,g=o?$i.projectionMercator:m.shaderPreludeCode,x=o?pi:m.shaderDefine,b=e+(n?n.cacheKey:"")+`/${o?fi:m.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(p?"/terrain":"")+(c?`/${c.join("/")}`:"");return this.cache[b]||(this.cache[b]=new ju(this.context,$i[e],n,Jo[e],this._showOverdrawInspector,p,g,x,c)),this.cache[b]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new h.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,n;if(this._tileTextures){for(const o in this._tileTextures){const c=this._tileTextures[o];if(c)for(const p of c)p.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&&((e=this.tileExtentMesh.vertexBuffer)===null||e===void 0||e.destroy()),this.tileExtentMesh&&((n=this.tileExtentMesh.indexBuffer)===null||n===void 0||n.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const o in this.cache){const c=this.cache[o];c&&c.program&&this.context.gl.deleteProgram(c.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}function dl(d,e){let n,o=!1,c=null,p=null;const m=()=>{c=null,o&&(d.apply(p,n),c=setTimeout(m,e),o=!1)};return(...g)=>(o=!0,p=this,n=g,c||m(),c)}class pl{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let o;return n.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(o=c)}),(o&&o[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:o,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const o=n.join("/");let c=o;c.split("&").length>0&&(c=c.split("&")[0]),this._hashName&&(c=`${this._hashName}=${o}`);let p=window.location.hash.replace(c,"");p.startsWith("#&")?p=p.slice(0,1)+p.slice(2):p==="#"&&(p="");let m=window.location.href.replace(/(#.+)?$/,p);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=dl(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,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(e){const n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,c=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),p=Math.pow(10,c),m=Math.round(n.lng*p)/p,g=Math.round(n.lat*p)/p,x=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=e?`/${m}/${g}/${o}`:`${o}/${g}/${m}`,(x||b)&&(T+="/"+Math.round(10*x)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const E=this._hashName;let I=!1;const A=window.location.hash.slice(1).split("&").map(L=>{const j=L.split("=")[0];return j===E?(I=!0,`${j}=${T}`):L}).filter(L=>L);return I||A.push(`${E}=${T}`),`#${A.join("&")}`}return`#${T}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new h.V(+e[2],+e[1])}catch{return!1}const n=+e[0],o=+(e[3]||0),c=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&o>=-180&&o<=180&&c>=this._map.getMinPitch()&&c<=this._map.getMaxPitch()}}const ga={linearity:.3,easing:h.cv(0,0,.3,1)},Oc=h.e({deceleration:2500,maxSpeed:1400},ga),jc=h.e({deceleration:20,maxSpeed:1400},ga),Vc=h.e({deceleration:1e3,maxSpeed:360},ga),io=h.e({deceleration:1e3,maxSpeed:90},ga),Nc=h.e({deceleration:1e3,maxSpeed:360},ga);class Wi{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ie(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=ie();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new h.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:p}of this._inertiaBuffer)n.zoom+=p.zoomDelta||0,n.bearing+=p.bearingDelta||0,n.pitch+=p.pitchDelta||0,n.roll+=p.rollDelta||0,p.panDelta&&n.pan._add(p.panDelta),p.around&&(n.around=p.around),p.pinchAround&&(n.pinchAround=p.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(n.pan.mag()){const p=ya(n.pan.mag(),o,h.e({},Oc,e||{})),m=n.pan.mult(p.amount/n.pan.mag()),g=this._map.cameraHelper.handlePanInertia(m,this._map.transform);c.center=g.easingCenter,c.offset=g.easingOffset,Si(c,p)}if(n.zoom){const p=ya(n.zoom,o,jc);c.zoom=this._map.transform.zoom+p.amount,Si(c,p)}if(n.bearing){const p=ya(n.bearing,o,Vc);c.bearing=this._map.transform.bearing+h.an(p.amount,-179,179),Si(c,p)}if(n.pitch){const p=ya(n.pitch,o,io);c.pitch=this._map.transform.pitch+p.amount,Si(c,p)}if(n.roll){const p=ya(n.roll,o,Nc);c.roll=this._map.transform.roll+h.an(p.amount,-179,179),Si(c,p)}if(c.zoom||c.bearing){const p=n.pinchAround===void 0?n.around:n.pinchAround;c.around=p?this._map.unproject(p):this._map.getCenter()}return this.clear(),h.e(c,{noMoveStart:!0})}}function Si(d,e){(!d.duration||d.duration<e.duration)&&(d.duration=e.duration,d.easing=e.easing)}function ya(d,e,n){const{maxSpeed:o,linearity:c,deceleration:p}=n,m=h.an(d*c/(e/1e3),-o,o),g=Math.abs(m)/(p*c);return{easing:n.easing,duration:1e3*g,amount:m*(g/2)}}class Re extends h.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o,c={}){o=o instanceof MouseEvent?o:new MouseEvent(e,o);const p=pt.mousePos(n.getCanvas(),o),m=n.unproject(p);super(e,h.e({point:p,lngLat:m,originalEvent:o},c)),this._defaultPrevented=!1,this.target=n}}class is extends h.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){const c=e==="touchend"?o.changedTouches:o.touches,p=pt.touchPos(n.getCanvasContainer(),c),m=p.map(x=>n.unproject(x)),g=p.reduce((x,b,T,E)=>x.add(b.div(E.length)),new h.P(0,0));super(e,{points:p,point:g,lngLats:m,lngLat:n.unproject(g),originalEvent:o}),this._defaultPrevented=!1}}class Ln extends h.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){super(e,{originalEvent:o}),this._defaultPrevented=!1}}class Ku{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Ln(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new Re(e.type,this._map,e))}mouseup(e){this._map.fire(new Re(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Re(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Re(e.type,this._map,e))}mouseover(e){this._map.fire(new Re(e.type,this._map,e))}mouseout(e){this._map.fire(new Re(e.type,this._map,e))}touchstart(e){return this._firePreventable(new is(e.type,this._map,e))}touchmove(e){this._map.fire(new is(e.type,this._map,e))}touchend(e){this._map.fire(new is(e.type,this._map,e))}touchcancel(e){this._map.fire(new is(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ju{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Re(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Re("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Re(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class rs{constructor(e){this._map=e}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(e){return this.transform.screenPointToLocation(h.P.convert(e),this._map.terrain)}}class Uc{constructor(e,n){this._map=e,this._tr=new rs(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(pt.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const o=n;if(this._lastPos.equals(o)||!this._box&&o.dist(this._startPos)<this._clickTolerance)return;const c=this._startPos;this._lastPos=o,this._box||(this._box=pt.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const p=Math.min(c.x,o.x),m=Math.max(c.x,o.x),g=Math.min(c.y,o.y),x=Math.max(c.y,o.y);pt.setTransform(this._box,`translate(${p}px,${g}px)`),this._box.style.width=m-p+"px",this._box.style.height=x-g+"px"}mouseupWindow(e,n){if(!this._active||e.button!==0)return;const o=this._startPos,c=n;if(this.reset(),pt.suppressClick(),o.x!==c.x||o.y!==c.y)return this._map.fire(new h.l("boxzoomend",{originalEvent:e})),{cameraAnimation:p=>p.fitScreenCoordinates(o,c,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(pt.remove(this._box),this._box=null),pt.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new h.l(e,{originalEvent:n}))}}function ro(d,e){if(d.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${d.length}, points ${e.length}`);const n={};for(let o=0;o<d.length;o++)n[d[o].identifier]=e[o];return n}class ns{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),o.length===this.numTouches&&(this.centroid=function(c){const p=new h.P(0,0);for(const m of c)p._add(m);return p.div(c.length)}(n),this.touches=ro(o,n)))}touchmove(e,n,o){if(this.aborted||!this.centroid)return;const c=ro(o,n);for(const p in this.touches){const m=c[p];(!m||m.dist(this.touches[p])>30)&&(this.aborted=!0)}}touchend(e,n,o){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),o.length===0){const c=!this.aborted&&this.centroid;if(this.reset(),c)return c}}}class or{constructor(e){this.singleTap=new ns(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,o){this.singleTap.touchstart(e,n,o)}touchmove(e,n,o){this.singleTap.touchmove(e,n,o)}touchend(e,n,o){const c=this.singleTap.touchend(e,n,o);if(c){const p=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(c)<30;if(p&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class Dt{constructor(e){this._tr=new rs(e),this._zoomIn=new or({numTouches:1,numTaps:2}),this._zoomOut=new or({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,o){this._zoomIn.touchstart(e,n,o),this._zoomOut.touchstart(e,n,o)}touchmove(e,n,o){this._zoomIn.touchmove(e,n,o),this._zoomOut.touchmove(e,n,o)}touchend(e,n,o){const c=this._zoomIn.touchend(e,n,o),p=this._zoomOut.touchend(e,n,o),m=this._tr;return c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(c)},{originalEvent:e})}):p?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(p)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class xa{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const o=this._lastPoint;if(!o)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const c=Array.isArray(n)?n[0]:n;return!this._moved&&c.dist(o)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=c,this._move(o,c))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&pt.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const fl=0,Gc=2,as={[fl]:1,[Gc]:2};class Dr{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){const n=pt.mouseButton(e);this._eventButton=n}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(n,o){const c=as[o];return n.buttons===void 0||(n.buttons&c)!==c}(e,this._eventButton)}isValidEndEvent(e){return pt.mouseButton(e)===this._eventButton}}class ml{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class Qu{constructor(e=new Dr({checkCorrectEvent:()=>!0}),n=new ml){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(e,n,o){return e instanceof MouseEvent?n(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?o(e):void 0}startMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.startMove(n),n=>this.oneFingerTouchMoveStateManager.startMove(n))}endMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.endMove(n),n=>this.oneFingerTouchMoveStateManager.endMove(n))}isValidStartEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidStartEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n))}isValidMoveEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidMoveEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n))}isValidEndEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidEndEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n))}}const va=d=>{d.mousedown=d.dragStart,d.mousemoveWindow=d.dragMove,d.mouseup=d.dragEnd,d.contextmenu=e=>{e.preventDefault()}};class Zc{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new h.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,o){return this._calculateTransform(e,n,o)}touchmove(e,n,o){if(this._active){if(!this._shouldBePrevented(o.length))return e.preventDefault(),this._calculateTransform(e,n,o);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,o){this._calculateTransform(e,n,o),this._active&&this._shouldBePrevented(o.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,o){o.length>0&&(this._active=!0);const c=ro(o,n),p=new h.P(0,0),m=new h.P(0,0);let g=0;for(const b in c){const T=c[b],E=this._touches[b];E&&(p._add(T),m._add(T.sub(E)),g++,c[b]=T)}if(this._touches=c,this._shouldBePrevented(g)||!m.mag())return;const x=m.div(g);return this._sum._add(x),this._sum.mag()<this._clickTolerance?void 0:{around:p.div(g),panDelta:x}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ss{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,n,o){this._firstTwoTouches||o.length<2||(this._firstTwoTouches=[o[0].identifier,o[1].identifier],this._start([n[0],n[1]]))}touchmove(e,n,o){if(!this._firstTwoTouches)return;e.preventDefault();const[c,p]=this._firstTwoTouches,m=no(o,n,c),g=no(o,n,p);if(!m||!g)return;const x=this._aroundCenter?null:m.add(g).div(2);return this._move([m,g],x,e)}touchend(e,n,o){if(!this._firstTwoTouches)return;const[c,p]=this._firstTwoTouches,m=no(o,n,c),g=no(o,n,p);m&&g||(this._active&&pt.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function no(d,e,n){for(let o=0;o<d.length;o++)if(d[o].identifier===n)return e[o]}function _l(d,e){return Math.log(d/e)/Math.LN2}class $c extends ss{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,n){const o=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(_l(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:_l(this._distance,o),pinchAround:n}}}function qc(d,e){return 180*d.angleWith(e)/Math.PI}class gl extends ss{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,n,o){const c=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:qc(this._vector,c),pinchAround:n}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const n=25/(Math.PI*this._minDiameter)*360,o=qc(e,this._startVector);return Math.abs(o)<n}}function yl(d){return Math.abs(d.y)>Math.abs(d.x)}class xl extends ss{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,o){super.touchstart(e,n,o),this._currentTouchCount=o.length}_start(e){this._lastPoints=e,yl(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,o){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const c=e[0].sub(this._lastPoints[0]),p=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,p,o.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(c.y+p.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,o){if(this._valid!==void 0)return this._valid;const c=e.mag()>=2,p=n.mag()>=2;if(!c&&!p)return;if(!c||!p)return this._firstMove===void 0&&(this._firstMove=o),o-this._firstMove<100&&void 0;const m=e.y>0==n.y>0;return yl(e)&&yl(n)&&m}}const th={panStep:100,bearingStep:15,pitchStep:10};class Wc{constructor(e){this._tr=new rs(e);const n=th;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,o=0,c=0,p=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?o=-1:(e.preventDefault(),p=-1);break;case 39:e.shiftKey?o=1:(e.preventDefault(),p=1);break;case 38:e.shiftKey?c=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?c=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(o=0,c=0),{cameraAnimation:g=>{const x=this._tr;g.easeTo({duration:300,easeId:"keyboardHandler",easing:on,zoom:n?Math.round(x.zoom)+n*(e.shiftKey?2:1):x.zoom,bearing:x.bearing+o*this._bearingStep,pitch:x.pitch+c*this._pitchStep,offset:[-p*this._panStep,-m*this._panStep],center:x.center},{originalEvent:e})}}}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 on(d){return d*(2-d)}const le=4.000244140625,eh=1/450;class os{constructor(e,n){this._onTimeout=o=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)},this._map=e,this._tr=new rs(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=eh}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const o=ie(),c=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,n!==0&&n%le==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(c*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){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 n=pt.mousePos(this._map.getCanvas(),e),o=this._tr;this._aroundPoint=this._aroundCenter?o.transform.locationToScreenPoint(h.V.convert(o.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const g=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=g),typeof this._targetZoom=="number"&&(this._targetZoom+=g)}if(this._delta!==0){const g=this._type==="wheel"&&Math.abs(this._delta)>le?this._wheelZoomRate:this._defaultZoomRate;let x=2/(1+Math.exp(-Math.abs(this._delta*g)));this._delta<0&&x!==0&&(x=1/x);const b=typeof this._targetZoom!="number"?e.scale:h.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),h.at(b*x)).zoom,this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?e.zoom:this._targetZoom,o=this._startZoom,c=this._easing;let p,m=!1;if(this._type==="wheel"&&o&&c){const g=ie()-this._lastWheelEventTime,x=Math.min((g+5)/200,1),b=c(x);p=h.G.number(o,n,b),x<1?this._frameId||(this._frameId=!0):m=!0}else p=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=p,{noInertia:!0,needsRenderFrame:!m,zoomDelta:p-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=h.cx;if(this._prevEase){const o=this._prevEase,c=(ie()-o.start)/o.duration,p=o.easing(c+.01)-o.easing(c),m=.27/Math.sqrt(p*p+1e-4)*.01,g=Math.sqrt(.0729-m*m);n=h.cv(m,g,.25,1)}return this._prevEase={start:ie(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class ls{constructor(e,n){this._clickZoom=e,this._tapZoom=n}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 vl{constructor(e){this._tr=new rs(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Hc{constructor(){this._tap=new or({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(e,n,o){if(!this._swipePoint)if(this._tapTime){const c=n[0],p=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(c)<30;p&&m?o.length>0&&(this._swipePoint=c,this._swipeTouch=o[0].identifier):this.reset()}else this._tap.touchstart(e,n,o)}touchmove(e,n,o){if(this._tapTime){if(this._swipePoint){if(o[0].identifier!==this._swipeTouch)return;const c=n[0],p=c.y-this._swipePoint.y;return this._swipePoint=c,e.preventDefault(),this._active=!0,{zoomDelta:p/128}}}else this._tap.touchmove(e,n,o)}touchend(e,n,o){if(this._tapTime)this._swipePoint&&o.length===0&&this.reset();else{const c=this._tap.touchend(e,n,o);c&&(this._tapTime=e.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bl{constructor(e,n,o){this._el=e,this._mousePan=n,this._touchPan=o}enable(e){this._inertiaOptions=e||{},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 wl{constructor(e,n,o,c){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=n,this._mousePitch=o,this._mouseRoll=c}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 Xc{constructor(e,n,o,c){this._el=e,this._touchZoom=n,this._touchRotate=o,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),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 lr{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=pt.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const o=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),c=document.createElement("div");c.className="maplibregl-desktop-message",c.textContent=n,this._container.appendChild(c);const p=document.createElement("div");p.className="maplibregl-mobile-message",p.textContent=o,this._container.appendChild(p),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(pt.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(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new h.l("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const Fn=d=>d.zoom||d.drag||d.roll||d.pitch||d.rotate;class Ft extends h.l{}function Vt(d){return d.panDelta&&d.panDelta.mag()||d.zoomDelta||d.bearingDelta||d.pitchDelta||d.rollDelta}class cs{constructor(e,n){this.handleWindowEvent=c=>{this.handleEvent(c,`${c.type}Window`)},this.handleEvent=(c,p)=>{if(c.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=c.type==="renderFrame"?void 0:c,g={needsRenderFrame:!1},x={},b={};for(const{handlerName:I,handler:A,allowed:L}of this._handlers){if(!A.isEnabled())continue;let j;if(this._blockedByActive(b,L,I))A.reset();else if(A[p||c.type]){if(h.cy(c,p||c.type)){const V=pt.mousePos(this._map.getCanvas(),c);j=A[p||c.type](c,V)}else if(h.cz(c,p||c.type)){const V=this._getMapTouches(c.touches),G=pt.touchPos(this._map.getCanvas(),V);j=A[p||c.type](c,G,V)}else h.cA(p||c.type)||(j=A[p||c.type](c));this.mergeHandlerResult(g,x,j,I,m),j&&j.needsRenderFrame&&this._triggerRenderFrame()}(j||A.isActive())&&(b[I]=A)}const T={};for(const I in this._previousActiveHandlers)b[I]||(T[I]=m);this._previousActiveHandlers=b,(Object.keys(T).length||Vt(g))&&(this._changes.push([g,x,T]),this._triggerRenderFrame()),(Object.keys(b).length||Vt(g))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:E}=g;E&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],E(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wi(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[c,p,m]of this._listeners)pt.addEventListener(c,p,c===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[e,n,o]of this._listeners)pt.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(e){const n=this._map,o=n.getCanvasContainer();this._add("mapEvent",new Ku(n,e));const c=n.boxZoom=new Uc(n,e);this._add("boxZoom",c),e.interactive&&e.boxZoom&&c.enable();const p=n.cooperativeGestures=new lr(n,e.cooperativeGestures);this._add("cooperativeGestures",p),e.cooperativeGestures&&p.enable();const m=new Dt(n),g=new vl(n);n.doubleClickZoom=new ls(g,m),this._add("tapZoom",m),this._add("clickZoom",g),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const x=new Hc;this._add("tapDragZoom",x);const b=n.touchPitch=new xl(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const T=()=>n.project(n.getCenter()),E=function({enable:$,clickTolerance:K,aroundCenter:J=!0,minPixelCenterThreshold:H=100,rotateDegreesPerPixelMoved:it=.8},ut){const st=new Dr({checkCorrectEvent:ot=>pt.mouseButton(ot)===0&&ot.ctrlKey||pt.mouseButton(ot)===2&&!ot.ctrlKey});return new xa({clickTolerance:K,move:(ot,ct)=>{const Mt=ut();if(J&&Math.abs(Mt.y-ot.y)>H)return{bearingDelta:h.cw(new h.P(ot.x,ct.y),ct,Mt)};let wt=(ct.x-ot.x)*it;return J&&ct.y<Mt.y&&(wt=-wt),{bearingDelta:wt}},moveStateManager:st,enable:$,assignEvents:va})}(e,T),I=function({enable:$,clickTolerance:K,pitchDegreesPerPixelMoved:J=-.5}){const H=new Dr({checkCorrectEvent:it=>pt.mouseButton(it)===0&&it.ctrlKey||pt.mouseButton(it)===2});return new xa({clickTolerance:K,move:(it,ut)=>({pitchDelta:(ut.y-it.y)*J}),moveStateManager:H,enable:$,assignEvents:va})}(e),A=function({enable:$,clickTolerance:K,rollDegreesPerPixelMoved:J=.3},H){const it=new Dr({checkCorrectEvent:ut=>pt.mouseButton(ut)===2&&ut.ctrlKey});return new xa({clickTolerance:K,move:(ut,st)=>{const ot=H();let ct=(st.x-ut.x)*J;return st.y<ot.y&&(ct=-ct),{rollDelta:ct}},moveStateManager:it,enable:$,assignEvents:va})}(e,T);n.dragRotate=new wl(e,E,I,A),this._add("mouseRotate",E,["mousePitch"]),this._add("mousePitch",I,["mouseRotate","mouseRoll"]),this._add("mouseRoll",A,["mousePitch"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const L=function({enable:$,clickTolerance:K}){const J=new Dr({checkCorrectEvent:H=>pt.mouseButton(H)===0&&!H.ctrlKey});return new xa({clickTolerance:K,move:(H,it)=>({around:it,panDelta:it.sub(H)}),activateOnStart:!0,moveStateManager:J,enable:$,assignEvents:va})}(e),j=new Zc(e,n);n.dragPan=new bl(o,L,j),this._add("mousePan",L),this._add("touchPan",j,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const V=new gl,G=new $c;n.touchZoomRotate=new Xc(o,G,V,x),this._add("touchRotate",V,["touchPan","touchZoom"]),this._add("touchZoom",G,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new Ju(n));const q=n.scrollZoom=new os(n,()=>this._triggerRenderFrame());this._add("scrollZoom",q,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const Y=n.keyboard=new Wc(n);this._add("keyboard",Y),e.interactive&&e.keyboard&&n.keyboard.enable()}_add(e,n,o){this._handlers.push({handlerName:e,handler:n,allowed:o}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Fn(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,o){for(const c in e)if(c!==o&&(!n||n.indexOf(c)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const o of e)this._el.contains(o.target)&&n.push(o);return n}mergeHandlerResult(e,n,o,c,p){if(!o)return;h.e(e,o);const m={handlerName:c,originalEvent:o.originalEvent||p};o.zoomDelta!==void 0&&(n.zoom=m),o.panDelta!==void 0&&(n.drag=m),o.rollDelta!==void 0&&(n.roll=m),o.pitchDelta!==void 0&&(n.pitch=m),o.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const e={},n={},o={};for(const[c,p,m]of this._changes)c.panDelta&&(e.panDelta=(e.panDelta||new h.P(0,0))._add(c.panDelta)),c.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+c.pitchDelta),c.rollDelta&&(e.rollDelta=(e.rollDelta||0)+c.rollDelta),c.around!==void 0&&(e.around=c.around),c.pinchAround!==void 0&&(e.pinchAround=c.pinchAround),c.noInertia&&(e.noInertia=c.noInertia),h.e(n,p),h.e(o,m);this._updateMapTransform(e,n,o),this._changes=[]}_updateMapTransform(e,n,o){const c=this._map,p=c._getTransformForUpdate(),m=c.terrain;if(!(Vt(e)||m&&this._terrainMovement))return this._fireEvents(n,o,!0);c._stop(!0);let{panDelta:g,zoomDelta:x,bearingDelta:b,pitchDelta:T,rollDelta:E,around:I,pinchAround:A}=e;A!==void 0&&(I=A),I=I||c.transform.centerPoint,m&&!p.isPointOnMapSurface(I)&&(I=p.centerPoint);const L={panDelta:g,zoomDelta:x,rollDelta:E,pitchDelta:T,bearingDelta:b,around:I};this._map.cameraHelper.useGlobeControls&&!p.isPointOnMapSurface(I)&&(I=p.centerPoint);const j=I.distSqr(p.centerPoint)<.01?p.center:p.screenPointToLocation(g?I.sub(g):I);this._handleMapControls({terrain:m,tr:p,deltasForHelper:L,preZoomAroundLoc:j,combinedEventsInProgress:n,panDelta:g}),c._applyUpdatedTransform(p),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,o,!0)}_handleMapControls({terrain:e,tr:n,deltasForHelper:o,preZoomAroundLoc:c,combinedEventsInProgress:p,panDelta:m}){const g=this._map.cameraHelper;if(g.handleMapControlsRollPitchBearingZoom(o,n),e)return g.useGlobeControls?(this._terrainMovement||!p.drag&&!p.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void g.handleMapControlsPan(o,n,c)):this._terrainMovement||!p.drag&&!p.zoom?void(p.drag&&this._terrainMovement&&m?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(m))):g.handleMapControlsPan(o,n,c)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void g.handleMapControlsPan(o,n,c));g.handleMapControlsPan(o,n,c)}_fireEvents(e,n,o){const c=Fn(this._eventsInProgress),p=Fn(e),m={};for(const E in e){const{originalEvent:I}=e[E];this._eventsInProgress[E]||(m[`${E}start`]=I),this._eventsInProgress[E]=e[E]}!c&&p&&this._fireEvent("movestart",p.originalEvent);for(const E in m)this._fireEvent(E,m[E]);p&&this._fireEvent("move",p.originalEvent);for(const E in e){const{originalEvent:I}=e[E];this._fireEvent(E,I)}const g={};let x;for(const E in this._eventsInProgress){const{handlerName:I,originalEvent:A}=this._eventsInProgress[E];this._handlersById[I].isActive()||(delete this._eventsInProgress[E],x=n[I]||A,g[`${E}end`]=x)}for(const E in g)this._fireEvent(E,g[E]);const b=Fn(this._eventsInProgress),T=(c||p)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const E=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&E.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(E)}if(o&&T){this._updatingCamera=!0;const E=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),I=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;!E||!E.essential&&Ze.prefersReducedMotion?(this._map.fire(new h.l("moveend",{originalEvent:x})),I(this._map.getBearing())&&this._map.resetNorth()):(I(E.bearing||this._map.getBearing())&&(E.bearing=0),E.freezeElevation=!0,this._map.easeTo(E,{originalEvent:x})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new h.l(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new Ft("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Yc extends h.E{constructor(e,n,o){super(),this._renderFrameCallback=()=>{const c=Math.min((ie()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(c)),c<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=o.bearingSnap,this.cameraHelper=n,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,n){e.apply(this.transform),this.transform=e,this.cameraHelper=n}getCenter(){return new h.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,n){return this.jumpTo({elevation:e},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,o){return e=h.P.convert(e).mult(-1),this.panTo(this.transform.center,h.e({offset:e},n),o)}panTo(e,n,o){return this.easeTo(h.e({center:e},n),o)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,o){return this.easeTo(h.e({zoom:e},n),o)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new h.l("movestart",n)).fire(new h.l("move",n)).fire(new h.l("moveend",n))),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,o){return this.easeTo(h.e({bearing:e},n),o)}resetNorth(e,n){return this.rotateTo(0,h.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(h.e({bearing:0,pitch:0,roll:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,n):this}getPitch(){return this.transform.pitch}setPitch(e,n){return this.jumpTo({pitch:e},n),this}getRoll(){return this.transform.roll}setRoll(e,n){return this.jumpTo({roll:e},n),this}cameraForBounds(e,n){e=Me.convert(e).adjustAntiMeridian();const o=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),o,n)}_cameraForBoxAndBearing(e,n,o,c){const p={top:0,bottom:0,right:0,left:0};if(typeof(c=h.e({padding:p,offset:[0,0],maxZoom:this.transform.maxZoom},c)).padding=="number"){const b=c.padding;c.padding={top:b,bottom:b,right:b,left:b}}const m=h.e(p,c.padding);c.padding=m;const g=this.transform,x=new Me(e,n);return this.cameraHelper.cameraForBoxAndBearing(c,m,x,o,g)}fitBounds(e,n,o){return this._fitInternal(this.cameraForBounds(e,n),n,o)}fitScreenCoordinates(e,n,o,c,p){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(h.P.convert(e)),this.transform.screenPointToLocation(h.P.convert(n)),o,c),c,p)}_fitInternal(e,n,o){return e?(delete(n=h.e(e,n)).padding,n.linear?this.easeTo(n,o):this.flyTo(n,o)):this}jumpTo(e,n){this.stop();const o=this._getTransformForUpdate();let c=!1,p=!1,m=!1;const g=o.zoom;this.cameraHelper.handleJumpToCenterZoom(o,e);const x=o.zoom!==g;return"elevation"in e&&o.elevation!==+e.elevation&&o.setElevation(+e.elevation),"bearing"in e&&o.bearing!==+e.bearing&&(c=!0,o.setBearing(+e.bearing)),"pitch"in e&&o.pitch!==+e.pitch&&(p=!0,o.setPitch(+e.pitch)),"roll"in e&&o.roll!==+e.roll&&(m=!0,o.setRoll(+e.roll)),e.padding==null||o.isPaddingEqual(e.padding)||o.setPadding(e.padding),this._applyUpdatedTransform(o),this.fire(new h.l("movestart",n)).fire(new h.l("move",n)),x&&this.fire(new h.l("zoomstart",n)).fire(new h.l("zoom",n)).fire(new h.l("zoomend",n)),c&&this.fire(new h.l("rotatestart",n)).fire(new h.l("rotate",n)).fire(new h.l("rotateend",n)),p&&this.fire(new h.l("pitchstart",n)).fire(new h.l("pitch",n)).fire(new h.l("pitchend",n)),m&&this.fire(new h.l("rollstart",n)).fire(new h.l("roll",n)).fire(new h.l("rollend",n)),this.fire(new h.l("moveend",n))}calculateCameraOptionsFromTo(e,n,o,c=0){const p=h.aa.fromLngLat(e,n),m=h.aa.fromLngLat(o,c),g=m.x-p.x,x=m.y-p.y,b=m.z-p.z,T=Math.hypot(g,x,b);if(T===0)throw new Error("Can't calculate camera options with same From and To");const E=Math.hypot(g,x),I=h.at(this.transform.cameraToCenterDistance/T/this.transform.tileSize),A=180*Math.atan2(g,-x)/Math.PI;let L=180*Math.acos(E/T)/Math.PI;return L=b<0?90-L:90+L,{center:m.toLngLat(),elevation:c,zoom:I,pitch:L,bearing:A}}calculateCameraOptionsFromCameraLngLatAltRotation(e,n,o,c,p){const m=this.transform.calculateCenterFromCameraLngLatAlt(e,n,o,c);return{center:m.center,elevation:m.elevation,zoom:m.zoom,bearing:o,pitch:c,roll:p}}easeTo(e,n){this._stop(!1,e.easeId),((e=h.e({offset:[0,0],duration:500,easing:h.cx},e)).animate===!1||!e.essential&&Ze.prefersReducedMotion)&&(e.duration=0);const o=this._getTransformForUpdate(),c=this.getBearing(),p=o.pitch,m=o.roll,g="bearing"in e?this._normalizeBearing(e.bearing,c):c,x="pitch"in e?+e.pitch:p,b="roll"in e?this._normalizeBearing(e.roll,m):m,T="padding"in e?e.padding:o.padding,E=h.P.convert(e.offset);let I,A;e.around&&(I=h.V.convert(e.around),A=o.locationToScreenPoint(I));const L={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},j=this.cameraHelper.handleEaseTo(o,{bearing:g,pitch:x,roll:b,padding:T,around:I,aroundPoint:A,offsetAsPoint:E,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||c!==g,this._pitching=this._pitching||x!==p,this._rolling=this._rolling||b!==m,this._padding=!o.isPaddingEqual(T),this._zooming=this._zooming||j.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,L),this.terrain&&this._prepareElevation(j.elevationCenter),this._ease(V=>{j.easeFunc(V),this.terrain&&!e.freezeElevation&&this._updateElevation(V),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},V=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,V)},e),this}_prepareEase(e,n,o={}){this._moving=!0,n||o.moving||this.fire(new h.l("movestart",e)),this._zooming&&!o.zooming&&this.fire(new h.l("zoomstart",e)),this._rotating&&!o.rotating&&this.fire(new h.l("rotatestart",e)),this._pitching&&!o.pitching&&this.fire(new h.l("pitchstart",e)),this._rolling&&!o.rolling&&this.fire(new h.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const o=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(o-(n-(o*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(h.G.number(this._elevationStart,this._elevationTarget,e))}_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(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const n=e.getCameraLngLat(),o=e.getCameraAltitude(),c=this.terrain?this.terrain.getElevationForLngLatZoom(n,e.zoom):0;if(o<c){const p=this.calculateCameraOptionsFromTo(n,c,e.center,e.elevation);return{pitch:p.pitch,zoom:p.zoom}}return{}}_applyUpdatedTransform(e){const n=[];if(n.push(c=>this._elevateCameraIfInsideTerrain(c)),this.transformCameraUpdate&&n.push(c=>this.transformCameraUpdate(c)),!n.length)return;const o=e.clone();for(const c of n){const p=o.clone(),{center:m,zoom:g,roll:x,pitch:b,bearing:T,elevation:E}=c(p);m&&p.setCenter(m),E!==void 0&&p.setElevation(E),g!==void 0&&p.setZoom(g),x!==void 0&&p.setRoll(x),b!==void 0&&p.setPitch(b),T!==void 0&&p.setBearing(T),o.apply(p)}this.transform.apply(o)}_fireMoveEvents(e){this.fire(new h.l("move",e)),this._zooming&&this.fire(new h.l("zoom",e)),this._rotating&&this.fire(new h.l("rotate",e)),this._pitching&&this.fire(new h.l("pitch",e)),this._rolling&&this.fire(new h.l("roll",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const o=this._zooming,c=this._rotating,p=this._pitching,m=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,o&&this.fire(new h.l("zoomend",e)),c&&this.fire(new h.l("rotateend",e)),p&&this.fire(new h.l("pitchend",e)),m&&this.fire(new h.l("rollend",e)),this.fire(new h.l("moveend",e))}flyTo(e,n){if(!e.essential&&Ze.prefersReducedMotion){const ct=h.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(ct,n)}this.stop(),e=h.e({offset:[0,0],speed:1.2,curve:1.42,easing:h.cx},e);const o=this._getTransformForUpdate(),c=o.bearing,p=o.pitch,m=o.roll,g=o.padding,x="bearing"in e?this._normalizeBearing(e.bearing,c):c,b="pitch"in e?+e.pitch:p,T="roll"in e?this._normalizeBearing(e.roll,m):m,E="padding"in e?e.padding:o.padding,I=h.P.convert(e.offset);let A=o.centerPoint.add(I);const L=o.screenPointToLocation(A),j=this.cameraHelper.handleFlyTo(o,{bearing:x,pitch:b,roll:T,padding:E,locationAtOffset:L,offsetAsPoint:I,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let V=e.curve;const G=Math.max(o.width,o.height),q=G/j.scaleOfZoom,Y=j.pixelPathLength;typeof j.scaleOfMinZoom=="number"&&(V=Math.sqrt(G/j.scaleOfMinZoom/Y*2));const $=V*V;function K(ct){const Mt=(q*q-G*G+(ct?-1:1)*$*$*Y*Y)/(2*(ct?q:G)*$*Y);return Math.log(Math.sqrt(Mt*Mt+1)-Mt)}function J(ct){return(Math.exp(ct)-Math.exp(-ct))/2}function H(ct){return(Math.exp(ct)+Math.exp(-ct))/2}const it=K(!1);let ut=function(ct){return H(it)/H(it+V*ct)},st=function(ct){return G*((H(it)*(J(Mt=it+V*ct)/H(Mt))-J(it))/$)/Y;var Mt},ot=(K(!0)-it)/V;if(Math.abs(Y)<2e-6||!isFinite(ot)){if(Math.abs(G-q)<1e-6)return this.easeTo(e,n);const ct=q<G?-1:1;ot=Math.abs(Math.log(q/G))/V,st=()=>0,ut=Mt=>Math.exp(ct*V*Mt)}return e.duration="duration"in e?+e.duration:1e3*ot/("screenSpeed"in e?+e.screenSpeed/V:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=c!==x,this._pitching=b!==p,this._rolling=T!==m,this._padding=!o.isPaddingEqual(E),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(j.targetCenter),this._ease(ct=>{const Mt=ct*ot,wt=1/ut(Mt),gt=st(Mt);this._rotating&&o.setBearing(h.G.number(c,x,ct)),this._pitching&&o.setPitch(h.G.number(p,b,ct)),this._rolling&&o.setRoll(h.G.number(m,T,ct)),this._padding&&(o.interpolatePadding(g,E,ct),A=o.centerPoint.add(I)),j.easeFunc(ct,wt,gt,A),this.terrain&&!e.freezeElevation&&this._updateElevation(ct),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var o;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const c=this._onEaseEnd;delete this._onEaseEnd,c.call(this,n)}return e||(o=this.handlers)===null||o===void 0||o.stop(!1),this}_ease(e,n,o){o.animate===!1||o.duration===0?(e(1),n()):(this._easeStart=ie(),this._easeOptions=o,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=h.W(e,-180,180);const o=Math.abs(e-n);return Math.abs(e-360-n)<o&&(e-=360),Math.abs(e+360-n)<o&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(h.V.convert(e),this.transform.tileZoom):null}}const us={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class _i{constructor(e=us){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=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=pt.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=pt.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=pt.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(){pt.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(e,n){const o=this._map._getUIString(`AttributionControl.${n}`);e.title=o,e.setAttribute("aria-label",o)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(c=>typeof c!="string"?"":c)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const c=this._map.style.stylesheet;this.styleOwner=c.owner,this.styleId=c.id}const n=this._map.style.tileManagers;for(const c in n){const p=n[c];if(p.used||p.usedForTerrain){const m=p.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter(c=>String(c).trim()),e.sort((c,p)=>c.length-p.length),e=e.filter((c,p)=>{for(let m=p+1;m<e.length;m++)if(e[m].indexOf(c)>=0)return!1;return!0});const o=e.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,e.length?(this._innerContainer.innerHTML=pt.sanitize(o),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Hi{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const o=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&o.classList.add("maplibregl-compact"):o.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=pt.create("div","maplibregl-ctrl");const n=pt.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){pt.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Kc{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,o=n?this._queue.concat(n):this._queue;for(const c of o)if(c.id===e)return void(c.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const o of n)if(!o.cancelled&&(o.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var ih=h.aT([{name:"a_pos3d",type:"Int16",components:3}]);class rh extends h.E{constructor(e){super(),this._lastTilesetChange=ie(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,n){this.tileManager.update(e,n),this._renderableTilesKeys=[];const o={};for(const c of qt(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))o[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.terrainRttPosMatrix32f=new Float64Array(16),h.c6(c.terrainRttPosMatrix32f,0,h.a4,h.a4,0,0,1),this._tiles[c.key]=new k(c,this.tileSize),this._lastTilesetChange=ie());for(const c in this._tiles)o[c]||delete this._tiles[c]}freeRtt(e){for(const n in this._tiles){const o=this._tiles[n];(!e||o.tileID.equals(e)||o.tileID.isChildOf(e)||e.isChildOf(o.tileID))&&(o.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,n){return n?this._getTerrainCoordsForTileRanges(e,n):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const n={};for(const o of this._renderableTilesKeys){const c=this._tiles[o].tileID,p=e.clone(),m=h.bj();if(c.canonical.equals(e.canonical))h.c6(m,0,h.a4,h.a4,0,0,1);else if(c.canonical.isChildOf(e.canonical)){const g=c.canonical.z-e.canonical.z,x=c.canonical.x-(c.canonical.x>>g<<g),b=c.canonical.y-(c.canonical.y>>g<<g),T=h.a4>>g;h.c6(m,0,T,T,0,0,1),h.O(m,m,[-x*T,-b*T,0])}else{if(!e.canonical.isChildOf(c.canonical))continue;{const g=e.canonical.z-c.canonical.z,x=e.canonical.x-(e.canonical.x>>g<<g),b=e.canonical.y-(e.canonical.y>>g<<g),T=h.a4>>g;h.c6(m,0,h.a4,h.a4,0,0,1),h.O(m,m,[x*T,b*T,0]),h.Q(m,m,[1/2**g,1/2**g,0])}}p.terrainRttPosMatrix32f=new Float32Array(m),n[o]=p}return n}_getTerrainCoordsForTileRanges(e,n){const o={};for(const c of this._renderableTilesKeys){const p=this._tiles[c].tileID;if(!this._isWithinTileRanges(p,n))continue;const m=e.clone(),g=h.bj();if(p.canonical.z===e.canonical.z){const x=e.canonical.x-p.canonical.x,b=e.canonical.y-p.canonical.y;h.c6(g,0,h.a4,h.a4,0,0,1),h.O(g,g,[x*h.a4,b*h.a4,0])}else if(p.canonical.z>e.canonical.z){const x=p.canonical.z-e.canonical.z,b=p.canonical.x-(p.canonical.x>>x<<x),T=p.canonical.y-(p.canonical.y>>x<<x),E=e.canonical.x-(p.canonical.x>>x),I=e.canonical.y-(p.canonical.y>>x),A=h.a4>>x;h.c6(g,0,A,A,0,0,1),h.O(g,g,[-b*A+E*h.a4,-T*A+I*h.a4,0])}else{const x=e.canonical.z-p.canonical.z,b=e.canonical.x-(e.canonical.x>>x<<x),T=e.canonical.y-(e.canonical.y>>x<<x),E=(e.canonical.x>>x)-p.canonical.x,I=(e.canonical.y>>x)-p.canonical.y,A=h.a4<<x;h.c6(g,0,A,A,0,0,1),h.O(g,g,[b*h.a4+E*A,T*h.a4+I*A,0])}m.terrainRttPosMatrix32f=new Float32Array(g),o[c]=m}return o}getSourceTile(e,n){const o=this.tileManager._source;let c=e.overscaledZ-this.deltaZoom;if(c>o.maxzoom&&(c=o.maxzoom),c<o.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(c).key);let p=this.tileManager.getTileByID(this._sourceTileCache[e.key]);if((!p||!p.dem)&&n)for(;c>=o.minzoom&&(!p||!p.dem);)p=this.tileManager.getTileByID(e.scaledTo(c--).key);return p}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,n){return n[e.canonical.z]&&e.canonical.x>=n[e.canonical.z].minTileX&&e.canonical.x<=n[e.canonical.z].maxTileX&&e.canonical.y>=n[e.canonical.z].minTileY&&e.canonical.y<=n[e.canonical.z].maxTileY}}class nh{constructor(e,n,o){this._meshCache={},this.painter=e,this.tileManager=new rh(n),this.options=o,this.exaggeration=typeof o.exaggeration=="number"?o.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,o,c=h.a4){var p;if(!(n>=0&&n<c&&o>=0&&o<c))return 0;const m=this.getTerrainData(e),g=(p=m.tile)===null||p===void 0?void 0:p.dem;if(!g)return 0;const x=h.cB([],[n/c*h.a4,o/c*h.a4],m.u_terrain_matrix),b=[x[0]*g.dim,x[1]*g.dim],T=Math.floor(b[0]),E=Math.floor(b[1]),I=b[0]-T,A=b[1]-E;return g.get(T,E)*(1-I)*(1-A)+g.get(T+1,E)*I*(1-A)+g.get(T,E+1)*(1-I)*A+g.get(T+1,E+1)*I*A}getElevationForLngLatZoom(e,n){if(!h.cC(n,e.wrap()))return 0;const{tileID:o,mercatorX:c,mercatorY:p}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(o,c%h.a4,p%h.a4,h.a4)}getElevation(e,n,o,c=h.a4){return this.getDEMElevation(e,n,o,c)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const c=this.painter.context,p=new h.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new h.T(c,p,c.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new h.T(c,new h.R({width:1,height:1}),c.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=h.ar([])}const n=this.tileManager.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const c=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new h.T(c,n.dem.getPixels(),c.gl.RGBA,{premultiply:!1}),n.demTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const o=n&&n+n.tileID.key+e.key;if(o&&!this._demMatrixCache[o]){const c=this.tileManager.getSource().maxzoom;let p=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=c?p=e.canonical.z-c:h.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>p<<p),g=e.canonical.y-(e.canonical.y>>p<<p),x=h.cD(new Float64Array(16),[1/(h.a4<<p),1/(h.a4<<p),0]);h.O(x,x,[m*h.a4,g*h.a4,0]),this._demMatrixCache[e.key]={matrix:x,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:o?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){const n=this.painter,o=n.width/devicePixelRatio,c=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===o&&this._fbo.height===c||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new h.T(n.context,{width:o,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new h.T(n.context,{width:o,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(o,c,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,o,c))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let p=0,m=0;p<this._coordsTextureSize;p++)for(let g=0;g<this._coordsTextureSize;g++,m+=4)n[m+0]=255&g,n[m+1]=255&p,n[m+2]=g>>8<<4|p>>8,n[m+3]=0;const o=new h.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),c=new h.T(e,o,e.gl.RGBA,{premultiply:!1});return c.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),o=this.painter.context,c=o.gl,p=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),g=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(p,g-m-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null);const x=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],E=T&&this.tileManager.getTileByID(T);if(!E)return null;const I=this._coordsTextureSize,A=(1<<E.tileID.canonical.z)*I;return new h.aa((E.tileID.canonical.x*I+x)/A+E.tileID.wrap,(E.tileID.canonical.y*I+b)/A,this.getElevation(E.tileID,x,b,I))}depthAtPoint(e){const n=new Uint8Array(4),o=this.painter.context,c=o.gl;return o.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),c.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(e){var n;const o=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,c=o&&e.canonical.y===0,p=o&&e.canonical.y===(1<<e.canonical.z)-1,m=`m_${c?"n":""}_${p?"s":""}`;if(this._meshCache[m])return this._meshCache[m];const g=this.painter.context,x=new h.cE,b=new h.aX,T=this.meshSize,E=h.a4/T,I=T*T;for(let H=0;H<=T;H++)for(let it=0;it<=T;it++)x.emplaceBack(it*E,H*E,0);for(let H=0;H<I;H+=T+1)for(let it=0;it<T;it++)b.emplaceBack(it+H,T+it+H+1,T+it+H+2),b.emplaceBack(it+H,T+it+H+2,it+H+1);const A=x.length,L=A+(T+1),j=(T+1)*T,V=c?h.bq:0,G=c?0:1,q=p?h.br:h.a4,Y=p?0:1;for(let H=0;H<=T;H++)x.emplaceBack(H*E,V,G);for(let H=0;H<=T;H++)x.emplaceBack(H*E,q,Y);for(let H=0;H<T;H++)b.emplaceBack(j+H,L+H,L+H+1),b.emplaceBack(j+H,L+H+1,j+H+1),b.emplaceBack(0+H,A+H+1,A+H),b.emplaceBack(0+H,0+H+1,A+H+1);const $=x.length,K=$+2*(T+1);for(const H of[0,1])for(let it=0;it<=T;it++)for(const ut of[0,1])x.emplaceBack(H*h.a4,it*E,ut);for(let H=0;H<2*T;H+=2)b.emplaceBack($+H,$+H+1,$+H+3),b.emplaceBack($+H,$+H+3,$+H+2),b.emplaceBack(K+H,K+H+3,K+H+1),b.emplaceBack(K+H,K+H+2,K+H+3);const J=new en(g.createVertexBuffer(x,ih.members),g.createIndexBuffer(b),h.aW.simpleSegment(0,0,x.length,b.length));return this._meshCache[m]=J,J}getMeshFrameDelta(e){return 2*Math.PI*h.bD/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,n){var o;const{tileID:c}=this._getOverscaledTileIDFromLngLatZoom(e,n);return(o=this.getMinMaxElevation(c).minElevation)!==null&&o!==void 0?o:0}getMinMaxElevation(e){const n=this.getTerrainData(e).tile,o={minElevation:null,maxElevation:null};return n&&n.dem&&(o.minElevation=n.dem.min*this.exaggeration,o.maxElevation=n.dem.max*this.exaggeration),o}_getOverscaledTileIDFromLngLatZoom(e,n){const o=h.aa.fromLngLat(e.wrap()),c=(1<<n)*h.a4,p=o.x*c,m=o.y*c,g=Math.floor(p/h.a4),x=Math.floor(m/h.a4);return{tileID:new h.a1(n,0,n,g,x),mercatorX:p,mercatorY:m}}}class hs{constructor(e,n,o){this._context=e,this._size=n,this._tileSize=o,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new h.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.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),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(o.texture),{id:e,fbo:n,texture:o,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(e=>!e.inUse)===!1}}const ce={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Be{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new hs(e.context,30,n.tileManager.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(o=>!e._layers[o].isHidden(n)),this._coordsAscending={};for(const o in e.tileManagers){this._coordsAscending[o]={};const c=e.tileManagers[o].getVisibleCoordinates(),p=e.tileManagers[o].getSource(),m=p instanceof Ai?p.terrainTileRanges:null;for(const g of c){const x=this.terrain.tileManager.getTerrainCoords(g,m);for(const b in x)this._coordsAscending[o][b]||(this._coordsAscending[o][b]=[]),this._coordsAscending[o][b].push(x[b])}}this._coordsAscendingStr={};for(const o of e._order){const c=e._layers[o],p=c.source;if(ce[c.type]&&!this._coordsAscendingStr[p]){this._coordsAscendingStr[p]={};for(const m in this._coordsAscending[p])this._coordsAscendingStr[p][m]=this._coordsAscending[p][m].map(g=>g.key).sort().join()}}for(const o of this._renderableTiles)for(const c in this._coordsAscendingStr){const p=this._coordsAscendingStr[c][o.tileID.key];p&&p!==o.rttCoords[c]&&(o.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;const o=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),c=e.type,p=this.painter,m=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ce[c]&&(this._prevType&&ce[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(e.id),!m))return!0;if(ce[this._prevType]||ce[c]&&m){this._prevType=c;const g=this._stacks.length-1,x=this._stacks[g]||[];for(const b of this._renderableTiles){if(this.pool.isFull()&&(sn(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[g]){const E=this.pool.getObjectForId(b.rtt[g].id);if(E.stamp===b.rtt[g].stamp){this.pool.useObject(E);continue}}const T=this.pool.getOrCreateFreeObject();this.pool.useObject(T),this.pool.stampObject(T),b.rtt[g]={id:T.id,stamp:T.stamp},p.context.bindFramebuffer.set(T.fbo.framebuffer),p.context.clear({color:h.bo.transparent,stencil:0}),p.currentStencilSource=void 0;for(let E=0;E<x.length;E++){const I=p.style._layers[x[E]],A=I.source?this._coordsAscending[I.source][b.tileID.key]:[b.tileID];p.context.viewport.set([0,0,T.fbo.width,T.fbo.height]),p._renderTileClippingMasks(I,A,!0),p.renderLayer(p,p.style.tileManagers[I.source],I,A,o),I.source&&(b.rttCoords[I.source]=this._coordsAscendingStr[I.source][b.tileID.key])}}return sn(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects(),ce[c]}return!1}}const Jc={"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"},ds=It,ps={hash:!1,interactive:!0,bearingSnap:7,attributionControl:us,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:h.a.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},Tl={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Sl{constructor(e,n,o=!1){this.mousedown=p=>{this.startMove(p,pt.mousePos(this.element,p)),pt.addEventListener(window,"mousemove",this.mousemove),pt.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=p=>{this.move(p,pt.mousePos(this.element,p))},this.mouseup=p=>{this._rotatePitchHandler.dragEnd(p),this.offTemp()},this.touchstart=p=>{p.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=pt.touchPos(this.element,p.targetTouches)[0],this.startMove(p,this._startPos),pt.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),pt.addEventListener(window,"touchend",this.touchend))},this.touchmove=p=>{p.targetTouches.length!==1?this.reset():(this._lastPos=pt.touchPos(this.element,p.targetTouches)[0],this.move(p,this._lastPos))},this.touchend=p=>{p.targetTouches.length===0&&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=n;const c=new Qu;this._rotatePitchHandler=new xa({clickTolerance:3,move:(p,m)=>{const g=n.getBoundingClientRect(),x=new h.P((g.bottom-g.top)/2,(g.right-g.left)/2);return{bearingDelta:h.cw(new h.P(p.x,m.y),m,x),pitchDelta:o?-.5*(m.y-p.y):void 0}},moveStateManager:c,enable:!0,assignEvents:()=>{}}),this.map=e,pt.addEventListener(n,"mousedown",this.mousedown),pt.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),pt.addEventListener(n,"touchcancel",this.reset)}startMove(e,n){this._rotatePitchHandler.dragStart(e,n),pt.disableDrag()}move(e,n){const o=this.map,{bearingDelta:c,pitchDelta:p}=this._rotatePitchHandler.dragMove(e,n)||{};c&&o.setBearing(o.getBearing()+c),p&&o.setPitch(o.getPitch()+p)}off(){const e=this.element;pt.removeEventListener(e,"mousedown",this.mousedown),pt.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),pt.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),pt.removeEventListener(window,"touchend",this.touchend),pt.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){pt.enableDrag(),pt.removeEventListener(window,"mousemove",this.mousemove),pt.removeEventListener(window,"mouseup",this.mouseup),pt.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),pt.removeEventListener(window,"touchend",this.touchend)}}let zr;function ba(d,e,n,o=!1){if(o||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return d?.wrap();const c=new h.V(d.lng,d.lat);if(d=new h.V(d.lng,d.lat),e){const p=new h.V(d.lng-360,d.lat),m=new h.V(d.lng+360,d.lat),g=n.locationToScreenPoint(d).distSqr(e);n.locationToScreenPoint(p).distSqr(e)<g?d=p:n.locationToScreenPoint(m).distSqr(e)<g&&(d=m)}for(;Math.abs(d.lng-n.center.lng)>180;){const p=n.locationToScreenPoint(d);if(p.x>=0&&p.y>=0&&p.x<=n.width&&p.y<=n.height)break;d.lng>n.center.lng?d.lng-=360:d.lng+=360}return d.lng!==c.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(d))?d:c}const fs={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 ao(d,e,n){const o=d.classList;for(const c in fs)o.remove(`maplibregl-${n}-anchor-${c}`);o.add(`maplibregl-${n}-anchor-${e}`)}class ms extends h.E{constructor(e){if(super(),this._onKeyPress=n=>{const o=n.code,c=n.charCode||n.keyCode;o!=="Space"&&o!=="Enter"&&c!==32&&c!==13||this.togglePopup()},this._onMapClick=n=>{const o=n.originalEvent.target,c=this._element;this._popup&&(o===c||c.contains(o))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();(n?.type==="terrain"||n?.type==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=ba(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 c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let p="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?p="rotateX(0deg)":this._pitchAlignment==="map"&&(p=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),pt.setTransform(this._element,`${fs[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${c}`),Ze.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const o=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new h.l("dragstart"))),this.fire(new h.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),this._state==="active"&&this.fire(new h.l("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.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=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=h.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=pt.create("div");const n=pt.createNS("http://www.w3.org/2000/svg","svg"),o=41,c=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${o}px`),n.setAttributeNS(null,"width",`${c}px`),n.setAttributeNS(null,"viewBox",`0 0 ${c} ${o}`);const p=pt.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"stroke","none"),p.setAttributeNS(null,"stroke-width","1"),p.setAttributeNS(null,"fill","none"),p.setAttributeNS(null,"fill-rule","evenodd");const m=pt.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const g=pt.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"transform","translate(3.0, 29.0)"),g.setAttributeNS(null,"fill","#000000");const x=[{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 G of x){const q=pt.createNS("http://www.w3.org/2000/svg","ellipse");q.setAttributeNS(null,"opacity","0.04"),q.setAttributeNS(null,"cx","10.5"),q.setAttributeNS(null,"cy","5.80029008"),q.setAttributeNS(null,"rx",G.rx),q.setAttributeNS(null,"ry",G.ry),g.appendChild(q)}const b=pt.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=pt.createNS("http://www.w3.org/2000/svg","path");T.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"),b.appendChild(T);const E=pt.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"opacity","0.25"),E.setAttributeNS(null,"fill","#000000");const I=pt.createNS("http://www.w3.org/2000/svg","path");I.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"),E.appendChild(I);const A=pt.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(6.0, 7.0)"),A.setAttributeNS(null,"fill","#FFFFFF");const L=pt.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"transform","translate(8.0, 8.0)");const j=pt.createNS("http://www.w3.org/2000/svg","circle");j.setAttributeNS(null,"fill","#000000"),j.setAttributeNS(null,"opacity","0.25"),j.setAttributeNS(null,"cx","5.5"),j.setAttributeNS(null,"cy","5.5"),j.setAttributeNS(null,"r","5.4999962");const V=pt.createNS("http://www.w3.org/2000/svg","circle");V.setAttributeNS(null,"fill","#FFFFFF"),V.setAttributeNS(null,"cx","5.5"),V.setAttributeNS(null,"cy","5.5"),V.setAttributeNS(null,"r","5.4999962"),L.appendChild(j),L.appendChild(V),m.appendChild(g),m.appendChild(b),m.appendChild(E),m.appendChild(A),m.appendChild(L),n.appendChild(m),n.setAttributeNS(null,"height",o*this._scale+"px"),n.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(n),this._offset=h.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),ao(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.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),pt.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=h.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const c=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[c,-1*(38.1-13.5+c)],"bottom-right":[-c,-1*(38.1-13.5+c)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,o;const c=(n=this._map)===null||n===void 0?void 0:n.terrain,p=this._map.transform.isLocationOccluded(this._lngLat);if(!c||p){const A=p?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==A&&(this._element.style.opacity=A))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const m=this._map,g=m.terrain.depthAtPoint(this._pos),x=m.terrain.getElevationForLngLatZoom(this._lngLat,m.transform.tileZoom);if(m.transform.lngLatToCameraDepth(this._lngLat,x)-g<.006)return void(this._element.style.opacity=this._opacity);const b=-this._offset.y/m.transform.pixelsPerMeter,T=Math.sin(m.getPitch()*Math.PI/180)*b,E=m.terrain.depthAtPoint(new h.P(this._pos.x,this._pos.y-this._offset.y)),I=m.transform.lngLatToCameraDepth(this._lngLat,x+T)-E>.006;!((o=this._popup)===null||o===void 0)&&o.isOpen()&&I&&this._popup.remove(),this._element.style.opacity=I?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=h.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(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(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return(this._opacity===void 0||e===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const Pl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let wa=0,Bn=!1;const Ml={maxWidth:100,unit:"metric"};function so(d,e,n){const o=n&&n.maxWidth||100,c=d._container.clientHeight/2,p=d._container.clientWidth/2,m=d.unproject([p-o/2,c]),g=d.unproject([p+o/2,c]),x=Math.round(d.project(g).x-d.project(m).x),b=Math.min(o,x,d._container.clientWidth),T=m.distanceTo(g);if(n&&n.unit==="imperial"){const E=3.2808*T;E>5280?On(e,b,E/5280,d._getUIString("ScaleControl.Miles")):On(e,b,E,d._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?On(e,b,T/1852,d._getUIString("ScaleControl.NauticalMiles")):T>=1e3?On(e,b,T/1e3,d._getUIString("ScaleControl.Kilometers")):On(e,b,T,d._getUIString("ScaleControl.Meters"))}function On(d,e,n,o){const c=function(p){const m=Math.pow(10,`${Math.floor(p)}`.length-1);let g=p/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:function(x){const b=Math.pow(10,Math.ceil(-Math.log(x)/Math.LN10));return Math.round(x*b)/b}(g),m*g}(n);d.style.width=e*(c/n)+"px",d.innerHTML=`${c} ${o}`}const oo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Il=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function lo(d){if(d){if(typeof d=="number"){const e=Math.round(Math.abs(d)/Math.SQRT2);return{center:new h.P(0,0),top:new h.P(0,d),"top-left":new h.P(e,e),"top-right":new h.P(-e,e),bottom:new h.P(0,-d),"bottom-left":new h.P(e,-e),"bottom-right":new h.P(-e,-e),left:new h.P(d,0),right:new h.P(-d,0)}}if(d instanceof h.P||Array.isArray(d)){const e=h.P.convert(d);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:h.P.convert(d.center||[0,0]),top:h.P.convert(d.top||[0,0]),"top-left":h.P.convert(d["top-left"]||[0,0]),"top-right":h.P.convert(d["top-right"]||[0,0]),bottom:h.P.convert(d.bottom||[0,0]),"bottom-left":h.P.convert(d["bottom-left"]||[0,0]),"bottom-right":h.P.convert(d["bottom-right"]||[0,0]),left:h.P.convert(d.left||[0,0]),right:h.P.convert(d.right||[0,0])}}return lo(new h.P(0,0))}const co=It;D.AJAXError=h.cI,D.Event=h.l,D.Evented=h.E,D.LngLat=h.V,D.MercatorCoordinate=h.aa,D.Point=h.P,D.addProtocol=h.cJ,D.config=h.a,D.removeProtocol=h.cK,D.AttributionControl=_i,D.BoxZoomHandler=Uc,D.CanvasSource=Fa,D.CooperativeGesturesHandler=lr,D.DoubleClickZoomHandler=ls,D.DragPanHandler=bl,D.DragRotateHandler=wl,D.EdgeInsets=_e,D.FullscreenControl=class extends h.E{constructor(d={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n?.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,d&&d.container&&(d.container instanceof HTMLElement?this._container=d.container:h.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(d){return this._map=d,this._container||(this._container=this._map.getContainer()),this._controlContainer=pt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){pt.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const d=this._fullscreenButton=pt.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);pt.create("span","maplibregl-ctrl-icon",d).setAttribute("aria-hidden","true"),d.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const d=this._getTitle();this._fullscreenButton.setAttribute("aria-label",d),this._fullscreenButton.title=d}_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 h.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new h.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()}},D.GeoJSONSource=bn,D.GeolocateControl=class extends h.E{constructor(d){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new h.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),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&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new h.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new h.V(e.coords.longitude,e.coords.latitude),o=e.coords.accuracy,c=this._map.getBearing(),p=h.e({bearing:c},this.options.fitBoundsOptions),m=Me.fromLngLat(n,o);this._map.fitBounds(m,p,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new h.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(e.code===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._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Bn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new h.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=pt.create("button","maplibregl-ctrl-geolocate",this._container),pt.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){h.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=pt.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ms({element:this._dotElement}),this._circleElement=pt.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ms({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",n=>{const o=n?.[0]instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o||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 h.l("trackuserlocationend")),this.fire(new h.l("userlocationlostfocus")))})}},this.options=h.e({},Pl,d)}onAdd(d){return this._map=d,this._container=pt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return h._(this,arguments,void 0,function*(e=!1){if(zr!==void 0&&!e)return zr;if(window.navigator.permissions===void 0)return zr=!!window.navigator.geolocation,zr;try{zr=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{zr=!!window.navigator.geolocation}return zr})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),pt.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,wa=0,Bn=!1}_isOutOfMapMaxBounds(d){const e=this._map.getMaxBounds(),n=d.coords;return e&&(n.longitude<e.getWest()||n.longitude>e.getEast()||n.latitude<e.getSouth()||n.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 d=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&d))return;const e=this._map.project(d),n=this._map.unproject([e.x+100,e.y]),o=d.distanceTo(n)/100,c=2*this._accuracy/o;this._circleElement.style.width=`${c.toFixed(2)}px`,this._circleElement.style.height=`${c.toFixed(2)}px`}trigger(){if(!this._setup)return h.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 h.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":wa--,Bn=!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 h.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 h.l("trackuserlocationstart")),this.fire(new h.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(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let d;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),wa++,wa>1?(d={maximumAge:6e5,timeout:0},Bn=!0):(d=this.options.positionOptions,Bn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,d)}}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)}},D.GlobeControl=class{constructor(){this._toggleProjection=()=>{var d;const e=(d=this._map.getProjection())===null||d===void 0?void 0:d.type;this._map.setProjection(e!=="mercator"&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var d;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((d=this._map.getProjection())===null||d===void 0?void 0:d.type)==="globe"?(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(d){return this._map=d,this._container=pt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=pt.create("button","maplibregl-ctrl-globe",this._container),pt.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(){pt.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},D.Hash=pl,D.ImageSource=Ai,D.KeyboardHandler=Wc,D.LngLatBounds=Me,D.LogoControl=Hi,D.Map=class extends Yc{constructor(d){var e,n;h.cF.mark(h.cG.create);const o=Object.assign(Object.assign(Object.assign({},ps),d),{canvasContextAttributes:Object.assign(Object.assign({},ps.canvasContextAttributes),d.canvasContextAttributes)});if(o.minZoom!=null&&o.maxZoom!=null&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(o.minPitch!=null&&o.maxPitch!=null&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(o.minPitch!=null&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(o.maxPitch!=null&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const c=new ve,p=new ki;if(o.minZoom!==void 0&&c.setMinZoom(o.minZoom),o.maxZoom!==void 0&&c.setMaxZoom(o.maxZoom),o.minPitch!==void 0&&c.setMinPitch(o.minPitch),o.maxPitch!==void 0&&c.setMaxPitch(o.maxPitch),o.renderWorldCopies!==void 0&&c.setRenderWorldCopies(o.renderWorldCopies),o.transformConstrain!==null&&c.setConstrainOverride(o.transformConstrain),super(c,p,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Kc,this._controls=[],this._mapId=h.ag(),this._lostContextStyle={style:null,images:null},this._contextLost=g=>{g.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const x of Object.values(this.style._layers))if(x.type==="custom"&&console.warn(`Custom layer with id '${x.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),x._listeners)for(const[b]of Object.entries(x._listeners))console.warn(`Custom layer with id '${x.id}' had event listeners for event '${b}' 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 h.l("webglcontextlost",{originalEvent:g}))},this._contextRestored=g=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new h.l("webglcontextrestored",{originalEvent:g}))},this._onMapScroll=g=>{if(g.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=o.trackResize===!0,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=o.refreshExpiredTiles===!0,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=o.crossSourceCollisions===!0,this._collectResourceTiming=o.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Jc),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this._zoomLevelsToOverscale=o.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=o.transformCameraUpdate,this.transformConstrain=o.transformConstrain,this.cancelPendingTileRequestsWhileZooming=o.cancelPendingTileRequestsWhileZooming===!0,o.reduceMotion!==void 0&&(Ze.prefersReducedMotion=o.reduceMotion),this._imageQueueHandle=Ci.addThrottleControl(()=>this.isMoving()),this._requestManager=new Ps(o.transformRequest),typeof o.container=="string"){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else{if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container}if(o.maxBounds&&this.setMaxBounds(o.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}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let g=!1;const x=dl(b=>{this._trackResize&&!this._removed&&(this.resize(b),this.redraw())},50);this._resizeObserver=new ResizeObserver(b=>{g?x(b):g=!0}),this._resizeObserver.observe(this._container)}this.handlers=new cs(this,o),this._hash=o.hash&&new pl(typeof o.hash=="string"&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,h.e({},o.fitBoundsOptions,{duration:0}))));const m=typeof o.style=="string"||((n=(e=o.style)===null||e===void 0?void 0:e.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,m),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new _i(typeof o.attributionControl=="boolean"?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Hi,o.logoPosition),this.on("style.load",()=>{if(m||this._resizeTransform(),this.transform.unmodified){const g=h.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(g)}}),this.on("data",g=>{this._update(g.dataType==="style"),this.fire(new h.l(`${g.dataType}data`,g))}),this.on("dataloading",g=>{this.fire(new h.l(`${g.dataType}dataloading`,g))}),this.on("dataabort",g=>{this.fire(new h.l("sourcedataabort",g))})}_getMapId(){return this._mapId}setGlobalStateProperty(d,e){return this.style.setGlobalStateProperty(d,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(d,e){if(e===void 0&&(e=d.getDefaultPosition?d.getDefaultPosition():"top-right"),!d||!d.onAdd)return this.fire(new h.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=d.onAdd(this);this._controls.push(d);const o=this._controlPositions[e];return e.indexOf("bottom")!==-1?o.insertBefore(n,o.firstChild):o.appendChild(n),this}removeControl(d){if(!d||!d.onRemove)return this.fire(new h.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(d);return e>-1&&this._controls.splice(e,1),d.onRemove(this),this}hasControl(d){return this._controls.indexOf(d)>-1}coveringTiles(d){return qt(this.transform,d)}calculateCameraOptionsFromTo(d,e,n,o){return o==null&&this.terrain&&(o=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(d,e,n,o)}resize(d,e=!0){const[n,o]=this._containerDimensions(),c=this._getClampedPixelRatio(n,o);if(this._resizeCanvas(n,o,c),this.painter.resize(n,o,c),this.painter.overLimit()){const m=this.painter.context.gl;this._maxCanvasSize=[m.drawingBufferWidth,m.drawingBufferHeight];const g=this._getClampedPixelRatio(n,o);this._resizeCanvas(n,o,g),this.painter.resize(n,o,g)}this._resizeTransform(e);const p=!this._moving;return p&&(this.stop(),this.fire(new h.l("movestart",d)).fire(new h.l("move",d))),this.fire(new h.l("resize",d)),p&&this.fire(new h.l("moveend",d)),this}_resizeTransform(d=!0){var e;const[n,o]=this._containerDimensions();this.transform.resize(n,o,d),(e=this._requestedCameraState)===null||e===void 0||e.resize(n,o,d)}_getClampedPixelRatio(d,e){const{0:n,1:o}=this._maxCanvasSize,c=this.getPixelRatio(),p=d*c,m=e*c;return Math.min(p>n?n/p:1,m>o?o/m:1)*c}getPixelRatio(){var d;return(d=this._overridePixelRatio)!==null&&d!==void 0?d:devicePixelRatio}setPixelRatio(d){this._overridePixelRatio=d,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(d){return this.transform.setMaxBounds(Me.convert(d)),this._update()}setMinZoom(d){if((d=d??-2)>=-2&&d<=this.transform.maxZoom)return this.transform.setMinZoom(d),this._update(),this.getZoom()<d&&this.setZoom(d),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(d){if((d=d??22)>=this.transform.minZoom)return this.transform.setMaxZoom(d),this._update(),this.getZoom()>d&&this.setZoom(d),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(d){if((d=d??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(d>=0&&d<=this.transform.maxPitch)return this.transform.setMinPitch(d),this._update(),this.getPitch()<d&&this.setPitch(d),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(d){if((d=d??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(d>=this.transform.minPitch)return this.transform.setMaxPitch(d),this._update(),this.getPitch()>d&&this.setPitch(d),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(d){return this.transform.setRenderWorldCopies(d),this._update()}setTransformConstrain(d){return this.transform.setConstrainOverride(d),this._update()}project(d){return this.transform.locationToScreenPoint(h.V.convert(d),this.style&&this.terrain)}unproject(d){return this.transform.screenPointToLocation(h.P.convert(d),this.terrain)}isMoving(){var d;return this._moving||((d=this.handlers)===null||d===void 0?void 0:d.isMoving())}isZooming(){var d;return this._zooming||((d=this.handlers)===null||d===void 0?void 0:d.isZooming())}isRotating(){var d;return this._rotating||((d=this.handlers)===null||d===void 0?void 0:d.isRotating())}_createDelegatedListener(d,e,n){if(d==="mouseenter"||d==="mouseover"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:p=>{const m=e.filter(x=>this.getLayer(x)),g=m.length!==0?this.queryRenderedFeatures(p.point,{layers:m}):[];g.length?o||(o=!0,n.call(this,new Re(d,this,p.originalEvent,{features:g}))):o=!1},mouseout:()=>{o=!1}}}}if(d==="mouseleave"||d==="mouseout"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{const g=e.filter(x=>this.getLayer(x));(g.length!==0?this.queryRenderedFeatures(m.point,{layers:g}):[]).length?o=!0:o&&(o=!1,n.call(this,new Re(d,this,m.originalEvent)))},mouseout:m=>{o&&(o=!1,n.call(this,new Re(d,this,m.originalEvent)))}}}}{const o=c=>{const p=e.filter(g=>this.getLayer(g)),m=p.length!==0?this.queryRenderedFeatures(c.point,{layers:p}):[];m.length&&(c.features=m,n.call(this,c),delete c.features)};return{layers:e,listener:n,delegates:{[d]:o}}}}_saveDelegatedListener(d,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[d]=this._delegatedListeners[d]||[],this._delegatedListeners[d].push(e)}_removeDelegatedListener(d,e,n){if(!this._delegatedListeners||!this._delegatedListeners[d])return;const o=this._delegatedListeners[d];for(let c=0;c<o.length;c++){const p=o[c];if(p.listener===n&&p.layers.length===e.length&&p.layers.every(m=>e.includes(m))){for(const m in p.delegates)this.off(m,p.delegates[m]);return void o.splice(c,1)}}}on(d,e,n){if(n===void 0)return super.on(d,e);const o=typeof e=="string"?[e]:e,c=this._createDelegatedListener(d,o,n);this._saveDelegatedListener(d,c);for(const p in c.delegates)this.on(p,c.delegates[p]);return{unsubscribe:()=>{this._removeDelegatedListener(d,o,n)}}}once(d,e,n){if(n===void 0)return super.once(d,e);const o=typeof e=="string"?[e]:e,c=this._createDelegatedListener(d,o,n);for(const p in c.delegates){const m=c.delegates[p];c.delegates[p]=(...g)=>{this._removeDelegatedListener(d,o,n),m(...g)}}this._saveDelegatedListener(d,c);for(const p in c.delegates)this.once(p,c.delegates[p]);return this}off(d,e,n){return n===void 0?super.off(d,e):(this._removeDelegatedListener(d,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(d,e){if(!this.style)return[];let n;const o=d instanceof h.P||Array.isArray(d),c=o?d:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(o?{}:d)||{},c instanceof h.P||typeof c[0]=="number")n=[h.P.convert(c)];else{const p=h.P.convert(c[0]),m=h.P.convert(c[1]);n=[p,new h.P(m.x,p.y),m,new h.P(p.x,m.y),p]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(d,e){return this.style.querySourceFeatures(d,e)}setStyle(d,e){return(e=h.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&d?(this._diffStyle(d,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(d,e))}setTransformRequest(d){return this._requestManager.setTransformRequest(d),this}_getUIString(d){const e=this._locale[d];if(e==null)throw new Error(`Missing UI string '${d}'`);return e}_updateStyle(d,e){var n,o;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(d,e));const c=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!d)),d?(this.style=new Ua(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof d=="string"?this.style.loadURL(d,e,c):this.style.loadJSON(d,e,c),this):((o=(n=this.style)===null||n===void 0?void 0:n.projection)===null||o===void 0||o.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ua(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(d,e){if(typeof d=="string"){const n=this._requestManager.transformRequest(d,"Style");h.j(n,new AbortController).then(o=>{this._updateDiff(o.data,e)}).catch(o=>{o&&this.fire(new h.k(o))})}else typeof d=="object"&&this._updateDiff(d,e)}_updateDiff(d,e){try{this.style.setState(d,e)&&this._update(!0)}catch(n){h.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(d,e)}}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():h.w("There is no style added to the map.")}addSource(d,e){return this._lazyInitEmptyStyle(),this.style.addSource(d,e),this._update(!0)}isSourceLoaded(d){const e=this.style&&this.style.tileManagers[d];if(e!==void 0)return e.loaded();this.fire(new h.k(new Error(`There is no tile manager with ID '${d}'`)))}setTerrain(d){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),d){const e=this.style.tileManagers[d.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${d.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const o=this.style._layers[n];o.type==="hillshade"&&o.source===d.source&&h.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."),o.type==="color-relief"&&o.source===d.source&&h.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 nh(this.painter,e,d),this.painter.renderToTexture=new Be(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=n=>{var o;n.dataType==="style"?this.terrain.tileManager.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==d.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))),((o=n.source)===null||o===void 0?void 0:o.type)==="image"?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(n.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 h.l("terrain",{terrain:d})),this}getTerrain(){var d,e;return(e=(d=this.terrain)===null||d===void 0?void 0:d.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const d=this.style&&this.style.tileManagers;for(const e in d){const n=d[e]._tiles;for(const o in n){const c=n[o];if(c.state!=="loaded"&&c.state!=="errored")return!1}}return!0}removeSource(d){return this.style.removeSource(d),this._update(!0)}getSource(d){return this.style.getSource(d)}setSourceTileLodParams(d,e,n){if(n){const o=this.getSource(n);if(!o)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);o.calculateTileZoom=ft(Math.max(1,d),Math.max(1,e))}else for(const o in this.style.tileManagers)this.style.tileManagers[o].getSource().calculateTileZoom=ft(Math.max(1,d),Math.max(1,e));return this._update(!0),this}refreshTiles(d,e){const n=this.style.tileManagers[d];if(!n)throw new Error(`There is no tile manager with ID "${d}", cannot refresh tile`);e===void 0?n.reload(!0):n.refreshTiles(e.map(o=>new h.ad(o.z,o.x,o.y)))}addImage(d,e,n={}){const{pixelRatio:o=1,sdf:c=!1,stretchX:p,stretchY:m,content:g,textFitWidth:x,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||h.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new h.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:T,height:E,data:I}=e,A=e;return this.style.addImage(d,{data:new h.R({width:T,height:E},new Uint8Array(I)),pixelRatio:o,stretchX:p,stretchY:m,content:g,textFitWidth:x,textFitHeight:b,sdf:c,version:0,userImage:A}),A.onAdd&&A.onAdd(this,d),this}}{const{width:T,height:E,data:I}=Ze.getImageData(e);this.style.addImage(d,{data:new h.R({width:T,height:E},I),pixelRatio:o,stretchX:p,stretchY:m,content:g,textFitWidth:x,textFitHeight:b,sdf:c,version:0})}}updateImage(d,e){const n=this.style.getImage(d);if(!n)return this.fire(new h.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=e instanceof HTMLImageElement||h.b(e)?Ze.getImageData(e):e,{width:c,height:p,data:m}=o;if(c===void 0||p===void 0)return this.fire(new h.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(c!==n.data.width||p!==n.data.height)return this.fire(new h.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(e instanceof HTMLImageElement||h.b(e));return n.data.replace(m,g),this.style.updateImage(d,n),this}getImage(d){return this.style.getImage(d)}hasImage(d){return d?!!this.style.getImage(d):(this.fire(new h.k(new Error("Missing required image id"))),!1)}removeImage(d){this.style.removeImage(d)}loadImage(d){return Ci.getImage(this._requestManager.transformRequest(d,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(d,e){return this._lazyInitEmptyStyle(),this.style.addLayer(d,e),this._update(!0)}moveLayer(d,e){return this.style.moveLayer(d,e),this._update(!0)}removeLayer(d){return this.style.removeLayer(d),this._update(!0)}getLayer(d){return this.style.getLayer(d)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(d,e,n){return this.style.setLayerZoomRange(d,e,n),this._update(!0)}setFilter(d,e,n={}){return this.style.setFilter(d,e,n),this._update(!0)}getFilter(d){return this.style.getFilter(d)}setPaintProperty(d,e,n,o={}){return this.style.setPaintProperty(d,e,n,o),this._update(!0)}getPaintProperty(d,e){return this.style.getPaintProperty(d,e)}setLayoutProperty(d,e,n,o={}){return this.style.setLayoutProperty(d,e,n,o),this._update(!0)}getLayoutProperty(d,e){return this.style.getLayoutProperty(d,e)}setGlyphs(d,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(d,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(d,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(d,e,n,o=>{o||this._update(!0)}),this}removeSprite(d){return this._lazyInitEmptyStyle(),this.style.removeSprite(d),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(d,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(d,e,n=>{n||this._update(!0)}),this}setLight(d,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(d,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(d,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(d,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(d,e){return this.style.setFeatureState(d,e),this._update()}removeFeatureState(d,e){return this.style.removeFeatureState(d,e),this._update()}getFeatureState(d){return this.style.getFeatureState(d)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let d=0,e=0;return this._container&&(d=this._container.clientWidth||400,e=this._container.clientHeight||300),[d,e]}_setupContainer(){const d=this._container;d.classList.add("maplibregl-map");const e=this._canvasContainer=pt.create("div","maplibregl-canvas-container",d);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=pt.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 n=this._containerDimensions(),o=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],o);const c=this._controlContainer=pt.create("div","maplibregl-control-container",d),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{p[m]=pt.create("div",`maplibregl-ctrl-${m} `,c)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(d,e,n){this._canvas.width=Math.floor(n*d),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${d}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const d=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",o=>{e={requestedAttributes:d},o&&(e.statusMessage=o.statusMessage,e.type=o.type)},{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,d):this._canvas.getContext("webgl2",d)||this._canvas.getContext("webgl",d),!n){const o="Failed to initialize WebGL";throw e?(e.message=o,new Error(JSON.stringify(e))):new Error(o)}this.painter=new Bc(n,this.transform),_n.testSupport(n)}migrateProjection(d,e){super.migrateProjection(d,e),this.painter.transform=d,this.fire(new h.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(d){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||d,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(d){return this._update(),this._renderTaskQueue.add(d)}_cancelRenderFrame(d){this._renderTaskQueue.remove(d)}_render(d){var e,n,o,c,p;const m=this._idleTriggered?this._fadeDuration:0,g=((e=this.style.projection)===null||e===void 0?void 0:e.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(d),this._removed)return;let x=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const E=this.transform.zoom,I=ie();this.style.zoomHistory.update(E,I);const A=new h.H(E,{now:I,fadeDuration:m,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),L=A.crossFadingFactor();L===1&&L===this._crossFadingFactor||(x=!0,this._crossFadingFactor=L),this.style.update(A)}const b=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==g;(o=this.style.projection)===null||o===void 0||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((c=this.style.projection)===null||c===void 0?void 0:c.transitionState,(p=this.style.projection)===null||p===void 0?void 0:p.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||b)&&(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,m,this._crossSourceCollisions,b),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,showPadding:this.showPadding}),this.fire(new h.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,h.cF.mark(h.cG.load),this.fire(new h.l("load"))),this.style&&(this.style.hasTransitions()||x)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const T=this._sourcesDirty||this._styleDirty||this._placementDirty;return T||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new h.l("idle")),!this._loaded||this._fullyLoaded||T||(this._fullyLoaded=!0,h.cF.mark(h.cG.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var d;this._hash&&this._hash.remove();for(const n of this._controls)n.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),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Ci.removeThrottleControl(this._imageQueueHandle),(d=this._resizeObserver)===null||d===void 0||d.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),pt.remove(this._canvasContainer),pt.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),h.cF.clearMetrics(),this._removed=!0,this.fire(new h.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Ze.frame(this._frameRequest,d=>{h.cF.frame(d),this._frameRequest=null;try{this._render(d)}catch(e){if(!h.cH(e)&&!function(n){return n.message===qs}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(d){this._showTileBoundaries!==d&&(this._showTileBoundaries=d,this._update())}get showPadding(){return!!this._showPadding}set showPadding(d){this._showPadding!==d&&(this._showPadding=d,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(d){this._showCollisionBoxes!==d&&(this._showCollisionBoxes=d,d?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(d){this._showOverdrawInspector!==d&&(this._showOverdrawInspector=d,this._update())}get repaint(){return!!this._repaint}set repaint(d){this._repaint!==d&&(this._repaint=d,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(d){this._vertices=d,this._update()}get version(){return ds}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(d){return this._lazyInitEmptyStyle(),this.style.setProjection(d),this._update(!0)}},D.MapMouseEvent=Re,D.MapTouchEvent=is,D.MapWheelEvent=Ln,D.Marker=ms,D.NavigationControl=class{constructor(d){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),o=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.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=(e,n)=>{const o=this._map._getUIString(`NavigationControl.${n}`);e.title=o,e.setAttribute("aria-label",o)},this.options=h.e({},Tl,d),this._container=pt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),pt.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),pt.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=pt.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(d){return this._map=d,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 Sl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){pt.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(d,e){const n=pt.create("button",d,this._container);return n.type="button",n.addEventListener("click",e),n}},D.Popup=class extends h.E{constructor(d){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&pt.remove(this._content),this._container&&(pt.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 h.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=pt.create("div","maplibregl-popup",this._map.getContainer()),this._tip=pt.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const m of this.options.className.split(" "))this._container.classList.add(m);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=ba(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const n=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let o=this.options.anchor;const c=lo(this.options.offset);if(!o){const m=this._container.offsetWidth,g=this._container.offsetHeight;let x;x=n.y+c.bottom.y<g?["top"]:n.y>this._map.transform.height-g?["bottom"]:[],n.x<m/2?x.push("left"):n.x>this._map.transform.width-m/2&&x.push("right"),o=x.length===0?"bottom":x.join("-")}let p=n.add(c[o]);this.options.subpixelPositioning||(p=p.round()),pt.setTransform(this._container,`${fs[o]} translate(${p.x}px,${p.y}px)`),ao(this._container,o,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=h.e(Object.create(oo),d)}addTo(d){return this._map&&this.remove(),this._map=d,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 h.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(d){return this._lngLat=h.V.convert(d),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(d){return this.setDOMContent(document.createTextNode(d))}setHTML(d){const e=document.createDocumentFragment(),n=document.createElement("body");let o;for(n.innerHTML=d;o=n.firstChild,o;)e.appendChild(o);return this.setDOMContent(e)}getMaxWidth(){var d;return(d=this._container)===null||d===void 0?void 0:d.style.maxWidth}setMaxWidth(d){return this.options.maxWidth=d,this._update(),this}setDOMContent(d){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=pt.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(d),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(d){return this._container&&this._container.classList.add(d),this}removeClassName(d){return this._container&&this._container.classList.remove(d),this}setOffset(d){return this.options.offset=d,this._update(),this}toggleClassName(d){if(this._container)return this._container.classList.toggle(d)}setSubpixelPositioning(d){this.options.subpixelPositioning=d}_createCloseButton(){this.options.closeButton&&(this._closeButton=pt.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 d=this._container.querySelector(Il);d&&d.focus()}},D.RasterDEMTileSource=Yr,D.RasterTileSource=Kn,D.ScaleControl=class{constructor(d){this._onMove=()=>{so(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,so(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ml),d)}getDefaultPosition(){return"bottom-left"}onAdd(d){return this._map=d,this._container=pt.create("div","maplibregl-ctrl maplibregl-ctrl-scale",d.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){pt.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},D.ScrollZoomHandler=os,D.Style=Ua,D.TerrainControl=class{constructor(d){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=d}onAdd(d){return this._map=d,this._container=pt.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=pt.create("button","maplibregl-ctrl-terrain",this._container),pt.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(){pt.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},D.TwoFingersTouchPitchHandler=xl,D.TwoFingersTouchRotateHandler=gl,D.TwoFingersTouchZoomHandler=$c,D.TwoFingersTouchZoomRotateHandler=Xc,D.VectorTileSource=_r,D.VideoSource=La,D.addSourceType=(d,e)=>h._(void 0,void 0,void 0,function*(){if(Jn(d))throw new Error(`A source type called "${d}" already exists.`);((n,o)=>{wn[n]=o})(d,e)}),D.clearPrewarmedResources=function(){const d=tr;d&&(d.isPreloaded()&&d.numActive()===1?(d.release(Wr),tr=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()"))},D.createTileMesh=As,D.getMaxParallelImageRequests=function(){return h.a.MAX_PARALLEL_IMAGE_REQUESTS},D.getRTLTextPluginStatus=function(){return ir().getRTLTextPluginStatus()},D.getVersion=function(){return co},D.getWorkerCount=function(){return Hr.workerCount},D.getWorkerUrl=function(){return h.a.WORKER_URL},D.importScriptInWorkers=function(d){return vn().broadcast("IS",d)},D.isTimeFrozen=function(){return Zr.isFrozen()},D.now=ie,D.prewarm=function(){Yn().acquire(Wr)},D.restoreNow=function(){Zr.restoreNow()},D.setMaxParallelImageRequests=function(d){h.a.MAX_PARALLEL_IMAGE_REQUESTS=d},D.setNow=function(d){Zr.setNow(d)},D.setRTLTextPlugin=function(d,e){return ir().setRTLTextPlugin(d,e)},D.setWorkerCount=function(d){Hr.workerCount=d},D.setWorkerUrl=function(d){h.a.WORKER_URL=d}});var hi=Et;return hi})}(ku)),ku.exports}var j_=B_();const Cu=Math.PI/180,Au=180/Math.PI,Du=6378137,Ca=20037508342789244e-9,zu="900913",O_="WGS84",Do={};function of(xt){return Number(xt)===xt&&xt%1!==0}class V_{#t;#e;#n;#a;#r;#i;constructor(at={}){if(this.#t=at.size||256,this.#e=at.antimeridian?2:1,!Do[this.#t]){let Et=this.#t;const At=Do[this.#t]={};At.Bc=[],At.Cc=[],At.zc=[],At.Ac=[];for(let se=0;se<30;se++)At.Bc.push(Et/360),At.Cc.push(Et/(2*Math.PI)),At.zc.push(Et/2),At.Ac.push(Et),Et*=2}this.#n=Do[this.#t].Bc,this.#a=Do[this.#t].Cc,this.#r=Do[this.#t].zc,this.#i=Do[this.#t].Ac}px(at,Et){if(of(Et)){const At=this.#t*Math.pow(2,Et),se=At/2,hi=At/360,D=At/(2*Math.PI),h=At,It=Math.min(Math.max(Math.sin(Cu*at[1]),-.9999),.9999);let si=se+at[0]*hi,Ve=se+.5*Math.log((1+It)/(1-It))*-D;return si>h*this.#e&&(si=h*this.#e),Ve>h&&(Ve=h),[si,Ve]}else{const At=this.#r[Et],se=Math.min(Math.max(Math.sin(Cu*at[1]),-.9999),.9999);let hi=Math.round(At+at[0]*this.#n[Et]),D=Math.round(At+.5*Math.log((1+se)/(1-se))*-this.#a[Et]);return hi>this.#i[Et]*this.#e&&(hi=this.#i[Et]*this.#e),D>this.#i[Et]&&(D=this.#i[Et]),[hi,D]}}ll(at,Et){if(of(Et)){const At=this.#t*Math.pow(2,Et),se=At/360,hi=At/(2*Math.PI),D=At/2,h=(at[1]-D)/-hi,It=(at[0]-D)/se,si=Au*(2*Math.atan(Math.exp(h))-.5*Math.PI);return[It,si]}else{const At=(at[1]-this.#r[Et])/-this.#a[Et],se=(at[0]-this.#r[Et])/this.#n[Et],hi=Au*(2*Math.atan(Math.exp(At))-.5*Math.PI);return[se,hi]}}convert(at,Et){return Et===zu?[...this.forward(at.slice(0,2)),...this.forward(at.slice(2,4))]:[...this.inverse(at.slice(0,2)),...this.inverse(at.slice(2,4))]}inverse(at){return[at[0]*Au/Du,(Math.PI*.5-2*Math.atan(Math.exp(-at[1]/Du)))*Au]}forward(at){const Et=[Du*at[0]*Cu,Du*Math.log(Math.tan(Math.PI*.25+.5*at[1]*Cu))];return Et[0]>Ca&&(Et[0]=Ca),Et[0]<-Ca&&(Et[0]=-Ca),Et[1]>Ca&&(Et[1]=Ca),Et[1]<-Ca&&(Et[1]=-Ca),Et}bbox(at,Et,At,se,hi){se&&(Et=Math.pow(2,At)-1-Et);const D=[at*this.#t,(+Et+1)*this.#t],h=[(+at+1)*this.#t,Et*this.#t],It=[...this.ll(D,At),...this.ll(h,At)];return hi===zu?this.convert(It,zu):It}xyz(at,Et,At,se){const hi=se===zu?this.convert(at,O_):at,D=[hi[0],hi[1]],h=[hi[2],hi[3]],It=this.px(D,Et),si=this.px(h,Et),Ve=[Math.floor(It[0]/this.#t),Math.floor((si[0]-1)/this.#t)],dr=[Math.floor(si[1]/this.#t),Math.floor((It[1]-1)/this.#t)],Ji={minX:Math.min.apply(Math,Ve)<0?0:Math.min.apply(Math,Ve),minY:Math.min.apply(Math,dr)<0?0:Math.min.apply(Math,dr),maxX:Math.max.apply(Math,Ve),maxY:Math.max.apply(Math,dr)};if(At){const Ze={minY:Math.pow(2,Et)-1-Ji.maxY,maxY:Math.pow(2,Et)-1-Ji.minY};Ji.minY=Ze.minY,Ji.maxY=Ze.maxY}return Ji}}export{R_ as C,L_ as R,V_ as S,j_ as m};
|