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)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.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:y180&&(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=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(;st.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;u4?`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=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;yNumber.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;ui.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||tt))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=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)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=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",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(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;i0&&f<0||u<0&&f>0}function Uo(r,t,i){const a=[];for(let s=0;si[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)=>ia?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=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);u0;)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 rt?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;l1?(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;M180;)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]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[2]&&(a=r[0]-t[2]),r[1]>t[3]&&(s=r[1]-t[3]),r[3]=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;_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{return S=w,Array.isArray(S)?`(${S.map(me).join(", ")})`:`(${me(S.type)}...)`;var S}).join(" | "),v=[];for(let w=1;w{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;MM[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{const i=r.id(),a=t.value;return typeof i==typeof a&&i":[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 rt?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"||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;sa.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&&znew 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{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[]}})),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;_=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=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{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(ss.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>>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>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>1];let l=i-1,u=a+1;for(;;){do l++;while(r[l]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`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`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`#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!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;au.x+1||_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;M1){if(oh(r,t))return!0;for(let a=0;a1?i:i.sub(t)._mult(s)._add(t))}function sd(r,t){let i,a,s,l=!1;for(let u=0;ut.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;at.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.xs.x&&t.x>s.x||r.ys.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;fch(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;_{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;uthis.max&&(this.max=w),w=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;v0)for(let u=t;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;et0||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.x&&u.x>=S&&f!==u.x&&xd(_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=(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<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;f0?(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=1||Q<=0)||F&&(yl)){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=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=_=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=_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;fl!=(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;f80*w){z=y[0],F=y[1];let O=z,N=F;for(let Q=w;QO&&(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;s0?(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=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(vw)C=!1;else{const z=M-P,F=-(r[2*t[f]]-S),Z=P((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(yZt.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;etZt.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>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>3}if(s--,a===1||a===2)l+=t.readSVarint(),u+=t.readSVarint(),l_&&(_=l),uv&&(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=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>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{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;sZt.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;ioe)||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;Fi.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=2&&t[v-1].equals(t[v-2]);)v--;let w=0;for(;w0;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"&&(ltl&&(St="bevel"),St==="bevel"&&(lt>2&&(St="flipbevel"),lt100)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;Nt2*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=3){for(let C=0;C0?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?rMath.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,a=0;for(let s=0;sa))}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>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(;f239?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.pos127;);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(;i268435455||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;y55295&&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=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;if.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&&fC.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 mty){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(;lu.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;mtmt.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=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;f0}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;ls[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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}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<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= 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.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.yl.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=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>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=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=4)for(let a=r[0];i>>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>>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&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>>1^-(1&l[0]);const u=l.length/4*4;let f=1;if(u>=4)for(;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>>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>>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>>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>1n^-(1n&s[0]);const l=s.length/4*4;let u=1;if(l>=4)for(;u>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>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>>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>>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>>1^-(1&F);for(let Z=M;Z>>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>1n^-(1n&F);for(let Z=M;Z>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.xthis.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>1)-this._coordinateShift}}decodeMorton(t){let i=0;for(let a=0;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>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;F0&&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;P0&&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;zi?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;_=12?Ym.decode(r.subarray(t,i)):function(a,s,l){let u="",f=s;for(;f239?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;_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>>0,l=Qe(r,t,1)[0]>>>0;a.columns=new Array(l);for(let u=0;uthis.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()>>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=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(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{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=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;vt&&u.push(l(w,S,t)):P>i?M=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(;fa;)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;iy){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=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;Xt0&&(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)=>as?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=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;Pw.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;_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;yS*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=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])>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;)_--}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:"",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===""){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===""){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:"",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;a0||((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}),Pa&&(a=P),Ml&&(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)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;ar.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;Nze?(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;i25||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;sPt*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=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;tiEr.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>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;htk.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;rt0&&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=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;Xtt},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=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):X1;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;ftR&&(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;ne1)for(const ne of qt){const de=ne*dt;if(!(rt[de+2]<=R)){rt[de+2]=R;for(let bt=0;bt>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;ztW)nt=zt,W=jt;else if(jt===W){const qt=Math.abs(zt-X);qtB&&(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;R0&&(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;W1?1:R}function Pe(tt,k,R,B,W,X,nt,U){if(B/=k,X>=(R/=k)&&nt=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)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=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;YtR&&(dt=rt(U,ne,de,xe,pe,R),nt&&(U.start=ft+ht*dt)):$e>B?fe=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;B0&&k.size<(W?nt:B))return void(R.numPoints+=k.length/3);const U=[];for(let rt=0;rtnt)&&(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;ft0===ht)for(let ft=0,zt=rt.length;ft24)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;rt1&&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<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<`${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{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{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;b0;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]{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-1);x++,p[x]=g,m[x]=b,m[x+1]=yn}for(let g=0,x=0;g/[-\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;Y0?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;Y1&&(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;g1&&(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{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{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.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||pn.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=c&&e.y{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+1e.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;o0&&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{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;en.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;Io)c=!1;else if(n)if(this.expirationTime({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>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;c1||(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;Aq.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;o0?(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;mthis.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;b0}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;KMath.abs(n.x-e.x)*o?{useVertical:!0}:(d===h.ay.vertical?e.yn.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;K0?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=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=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=1;$t--)wt.push(ct.path[$t]);for(let $t=1;$tZt.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=ut.x&&Zt.x<=st.x&&$t.y>=ut.y&&Zt.y<=st.y?[wt]:Zt.xst.x||Zt.yst.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{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;bm&&(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=this.screenRightBoundary||cthis.screenBottomBoundary}isInsideGrid(e,n,o,c){return o>=0&&e=0&&nthis.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;dnAe(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=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;$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.lastPlacementChangeTimee}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._currentTileIndexg.sortKey-x.sortKey));this._currentPartIndex!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({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.ze)}}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;pe.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[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<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]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<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-gx&&(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-JT&&(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;Y0}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<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=0&&b++}if(b===0)return 0;b=0&&b++}if(b===0)return 0}return 1}intersectsPlane(e){const n=this.points.length;let o=0;for(let c=0;c=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<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<=(1<{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<p&&(p=I),Ag&&(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=-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)=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&&nh.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]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;bI.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({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({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{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;o0&&(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=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;Gd.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<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;gg.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;x0};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;Ithis.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({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;Vut.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;itit.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;H0?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.durationn.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)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;othis.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)!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()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.ypt.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.ypt.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{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()){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(othis._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=q0,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)MapLibre'};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=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<>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<>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<>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<>x)-p.canonical.x,I=(e.canonical.y>>x)-p.canonical.y,A=h.a4<o.maxzoom&&(c=o.maxzoom),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=0&&oe.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<>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<0,c=o&&e.canonical.y===0,p=o&&e.canonical.y===(1<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!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{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._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)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.longitudee.getEast()||n.latitudee.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()=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()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;ce.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.ythis._map.transform.height-g?["bottom"]:[],n.xthis._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};