xv-webcomponents 1.17.19-dev.0 → 1.17.21-qa.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/maplibre-gl-MCSOKSuo.js +870 -0
  3. package/dist/cjs/{xv-accordion-v2_48.cjs.entry.js → xv-accordion-v2_49.cjs.entry.js} +457 -56
  4. package/dist/cjs/xv-header-next.cjs.entry.js +1 -1
  5. package/dist/cjs/xv-mega-menu-next.cjs.entry.js +2 -2
  6. package/dist/cjs/xv-webcomponents.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +1 -0
  8. package/dist/collection/components/xv-accordion/xv-accordion.js +1 -1
  9. package/dist/collection/components/xv-accordion-item/xv-accordion-item.js +1 -1
  10. package/dist/collection/components/xv-breadcrumbs/xv-breadcrumbs.js +1 -1
  11. package/dist/collection/components/xv-button/xv-button.js +2 -2
  12. package/dist/collection/components/xv-button-group/xv-button-group.js +1 -1
  13. package/dist/collection/components/xv-card/xv-card.js +1 -1
  14. package/dist/collection/components/xv-checkbox/xv-checkbox.js +2 -2
  15. package/dist/collection/components/xv-content-switcher/xv-content-switcher-item/xv-content-switcher-item.js +1 -1
  16. package/dist/collection/components/xv-content-switcher/xv-content-switcher.js +2 -2
  17. package/dist/collection/components/xv-data-table/xv-data-table-cell/xv-data-table-cell.js +1 -1
  18. package/dist/collection/components/xv-data-table/xv-data-table-collapse/xv-data-table-collapse.js +1 -1
  19. package/dist/collection/components/xv-data-table/xv-data-table-row/xv-data-table-row.js +2 -2
  20. package/dist/collection/components/xv-data-table/xv-data-table.js +1 -1
  21. package/dist/collection/components/xv-datepicker/xv-datepicker.js +2 -2
  22. package/dist/collection/components/xv-dropdown/xv-dropdown-item/xv-dropdown-item.js +1 -1
  23. package/dist/collection/components/xv-dropdown/xv-dropdown.js +1 -1
  24. package/dist/collection/components/xv-file-uploader/xv-file-uploader.js +1 -1
  25. package/dist/collection/components/xv-footer/xv-footer.js +1 -1
  26. package/dist/collection/components/xv-geo-map/xv-geo-map.css +866 -0
  27. package/dist/collection/components/xv-geo-map/xv-geo-map.js +790 -0
  28. package/dist/collection/components/xv-header/xv-header.js +1 -1
  29. package/dist/collection/components/xv-header-next/xv-header-next.js +1 -1
  30. package/dist/collection/components/xv-image-viewer/xv-image-viewer.js +1 -1
  31. package/dist/collection/components/xv-link/xv-link.js +1 -1
  32. package/dist/collection/components/xv-mega-menu/xv-mega-menu.js +2 -2
  33. package/dist/collection/components/xv-mega-menu-next/xv-mega-menu-next.js +2 -2
  34. package/dist/collection/components/xv-modal/xv-modal.js +1 -1
  35. package/dist/collection/components/xv-notification/xv-notification.js +1 -1
  36. package/dist/collection/components/xv-number-input/xv-number-input.js +2 -2
  37. package/dist/collection/components/xv-pagination/xv-pagination.js +1 -1
  38. package/dist/collection/components/xv-progress-indicator/xv-progress-indicator-item/xv-progress-indicator-item.js +1 -1
  39. package/dist/collection/components/xv-progress-indicator/xv-progress-indicator.js +1 -1
  40. package/dist/collection/components/xv-radio/xv-radio.js +2 -2
  41. package/dist/collection/components/xv-slider/xv-slider.js +1 -1
  42. package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.js +1 -1
  43. package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.js +1 -1
  44. package/dist/collection/components/xv-table/xv-table-row/xv-table-row.js +1 -1
  45. package/dist/collection/components/xv-table/xv-table.js +1 -1
  46. package/dist/collection/components/xv-tabs/xv-tab/xv-tab.js +1 -1
  47. package/dist/collection/components/xv-tag/xv-tag.js +1 -1
  48. package/dist/collection/components/xv-tag-combobox/xv-tag-combobox.js +2 -2
  49. package/dist/collection/components/xv-text-input/xv-text-input.js +2 -2
  50. package/dist/collection/components/xv-textarea/xv-textarea.js +2 -2
  51. package/dist/collection/components/xv-tile/xv-tile.js +2 -2
  52. package/dist/collection/components/xv-toggle/xv-toggle.js +1 -1
  53. package/dist/collection/components/xv-toggle-tip/xv-toggle-tip.js +1 -1
  54. package/dist/collection/components/xv-tooltip/xv-tooltip.js +2 -2
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/esm/maplibre-gl-CT7CGYe6.js +813 -0
  57. package/dist/esm/maplibre-gl-shared.mjs +6 -0
  58. package/dist/esm/maplibre-gl-worker.mjs +6 -0
  59. package/dist/esm/{xv-accordion-v2_48.entry.js → xv-accordion-v2_49.entry.js} +457 -57
  60. package/dist/esm/xv-header-next.entry.js +1 -1
  61. package/dist/esm/xv-mega-menu-next.entry.js +2 -2
  62. package/dist/esm/xv-webcomponents.js +1 -1
  63. package/dist/types/components/xv-geo-map/xv-geo-map.d.ts +90 -0
  64. package/dist/types/components.d.ts +193 -0
  65. package/dist/xv-webcomponents/{p-6d4d397f.entry.js → p-3c3179fb.entry.js} +2 -2
  66. package/dist/xv-webcomponents/{p-38e5f1e1.entry.js → p-597b353d.entry.js} +1 -1
  67. package/dist/xv-webcomponents/p-CT7CGYe6.js +9 -0
  68. package/dist/xv-webcomponents/{p-7e05cb50.entry.js → p-ef3c818d.entry.js} +1 -1
  69. package/dist/xv-webcomponents/xv-webcomponents.esm.js +1 -1
  70. package/package.json +2 -1
@@ -0,0 +1,9 @@
1
+ /**
2
+ * MapLibre GL JS
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.2.0/LICENSE.txt
4
+ */
5
+ var t=Object.create,e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,s=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,s,o,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(var l,h=r(s),u=0,c=h.length;u<c;u++)!n.call(t,l=h[u])&&l!==o&&e(t,l,{get:(t=>s[t]).bind(null,l),enumerable:!(a=i(s,l))||a.enumerable});return t};function l(t,e){this.x=t,this.y=e}let h,u;function c(){return h??=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap,h}l.prototype={clone(){return new l(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){let e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){let e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround(t,e){let i=Math.cos(t),r=Math.sin(t),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:l},l.convert=function(t){if(t instanceof l)return t;if(Array.isArray(t))return new l(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new l(+t.x,+t.y);throw Error("Expected [x, y] or {x, y} point format")};var f=typeof Float32Array<"u"?Float32Array:Array;function p(){var t=new f(9);return f!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function d(){var t=new f(16);return f!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function m(t){var e=new f(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function _(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function g(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=e[4],a=e[5],l=e[6],h=e[7],u=e[8],c=e[9],f=e[10],p=e[11],d=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*o,v=i*l-s*o,w=i*h-n*o,b=r*l-s*a,x=r*h-n*a,M=s*h-n*l,z=u*m-c*d,S=u*_-f*d,T=u*g-p*d,E=c*_-f*m,A=c*g-p*m,P=f*g-p*_,I=y*P-v*A+w*E+b*T-x*S+M*z;return I?(t[0]=(a*P-l*A+h*E)*(I=1/I),t[1]=(s*A-r*P-n*E)*I,t[2]=(m*M-_*x+g*b)*I,t[3]=(f*x-c*M-p*b)*I,t[4]=(l*T-o*P-h*S)*I,t[5]=(i*P-s*T+n*S)*I,t[6]=(_*w-d*M-g*v)*I,t[7]=(u*M-f*w+p*v)*I,t[8]=(o*A-a*T+h*z)*I,t[9]=(r*T-i*A-n*z)*I,t[10]=(d*x-m*w+g*y)*I,t[11]=(c*w-u*x-p*y)*I,t[12]=(a*S-o*E-l*z)*I,t[13]=(i*E-r*S+s*z)*I,t[14]=(m*v-d*b-_*y)*I,t[15]=(u*b-c*v+f*y)*I,t):null}function y(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=e[9],p=e[10],d=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=i[0],w=i[1],b=i[2],x=i[3];return t[0]=v*r+w*a+b*c+x*m,t[1]=v*s+w*l+b*f+x*_,t[2]=v*n+w*h+b*p+x*g,t[3]=v*o+w*u+b*d+x*y,t[4]=(v=i[4])*r+(w=i[5])*a+(b=i[6])*c+(x=i[7])*m,t[5]=v*s+w*l+b*f+x*_,t[6]=v*n+w*h+b*p+x*g,t[7]=v*o+w*u+b*d+x*y,t[8]=(v=i[8])*r+(w=i[9])*a+(b=i[10])*c+(x=i[11])*m,t[9]=v*s+w*l+b*f+x*_,t[10]=v*n+w*h+b*p+x*g,t[11]=v*o+w*u+b*d+x*y,t[12]=(v=i[12])*r+(w=i[13])*a+(b=i[14])*c+(x=i[15])*m,t[13]=v*s+w*l+b*f+x*_,t[14]=v*n+w*h+b*p+x*g,t[15]=v*o+w*u+b*d+x*y,t}function v(t,e,i){var r,s,n,o,a,l,h,u,c,f,p,d,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(s=e[1],n=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=e[9],p=e[10],d=e[11],t[0]=r=e[0],t[1]=s,t[2]=n,t[3]=o,t[4]=a,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=f,t[10]=p,t[11]=d,t[12]=r*m+a*_+c*g+e[12],t[13]=s*m+l*_+f*g+e[13],t[14]=n*m+h*_+p*g+e[14],t[15]=o*m+u*_+d*g+e[15]),t}function w(t,e,i){var r=i[0],s=i[1],n=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function b(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[4],o=e[5],a=e[6],l=e[7],h=e[8],u=e[9],c=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*s+h*r,t[5]=o*s+u*r,t[6]=a*s+c*r,t[7]=l*s+f*r,t[8]=h*s-n*r,t[9]=u*s-o*r,t[10]=c*s-a*r,t[11]=f*s-l*r,t}function x(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],o=e[1],a=e[2],l=e[3],h=e[8],u=e[9],c=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s-h*r,t[1]=o*s-u*r,t[2]=a*s-c*r,t[3]=l*s-f*r,t[8]=n*r+h*s,t[9]=o*r+u*s,t[10]=a*r+c*s,t[11]=l*r+f*s,t}function M(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],o=e[1],a=e[2],l=e[3],h=e[4],u=e[5],c=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s+h*r,t[1]=o*s+u*r,t[2]=a*s+c*r,t[3]=l*s+f*r,t[4]=h*s-n*r,t[5]=u*s-o*r,t[6]=c*s-a*r,t[7]=f*s-l*r,t}var z=function(t,e,i,r,s){var n=1/Math.tan(e/2);if(t[0]=n/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0){var o=1/(r-s);t[10]=(s+r)*o,t[14]=2*s*r*o}else t[10]=-1,t[14]=-2*r;return t},S=function(t,e,i,r,s,n,o){var a=1/(e-i),l=1/(r-s),h=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+i)*a,t[13]=(s+r)*l,t[14]=(o+n)*h,t[15]=1,t};function T(){var t=new f(3);return f!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function E(t){var e=new f(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function A(t){var e=t[0],i=t[1],r=t[2];return Math.sqrt(e*e+i*i+r*r)}function P(t,e,i){var r=new f(3);return r[0]=t,r[1]=e,r[2]=i,r}function I(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function C(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function k(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function D(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function F(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[0],a=i[1],l=i[2];return t[0]=s*l-n*a,t[1]=n*o-r*l,t[2]=r*a-s*o,t}function $(t,e,i){var r=i[0],s=i[1],n=i[2],o=i[3],a=e[0],l=e[1],h=e[2],u=s*h-n*l,c=n*a-r*h,f=r*l-s*a;return t[0]=a+o*(u+=u)+s*(f+=f)-n*(c+=c),t[1]=l+o*c+n*u-r*f,t[2]=h+o*f+r*c-s*u,t}function j(t,e,i,r){var s=[],n=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],n[0]=s[0],n[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),n[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2],t}function R(t,e,i,r){var s=[],n=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],n[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),n[1]=s[1],n[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2],t}function O(t,e,i,r){var s=[],n=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],n[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),n[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),n[2]=s[2],t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2],t}var L=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t},B=A;function N(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3];return t[0]=i[0]*r+i[4]*s+i[8]*n+i[12]*o,t[1]=i[1]*r+i[5]*s+i[9]*n+i[13]*o,t[2]=i[2]*r+i[6]*s+i[10]*n+i[14]*o,t[3]=i[3]*r+i[7]*s+i[11]*n+i[15]*o,t}T();function U(){var t=new f(4);return f!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function G(t,e,i,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",n=Math.PI/360;e*=n,r*=n,i*=n;var o=Math.sin(e),a=Math.cos(e),l=Math.sin(i),h=Math.cos(i),u=Math.sin(r),c=Math.cos(r);switch(s){case"xyz":t[0]=o*h*c+a*l*u,t[1]=a*l*c-o*h*u,t[2]=a*h*u+o*l*c,t[3]=a*h*c-o*l*u;break;case"xzy":t[0]=o*h*c-a*l*u,t[1]=a*l*c-o*h*u,t[2]=a*h*u+o*l*c,t[3]=a*h*c+o*l*u;break;case"yxz":t[0]=o*h*c+a*l*u,t[1]=a*l*c-o*h*u,t[2]=a*h*u-o*l*c,t[3]=a*h*c+o*l*u;break;case"yzx":t[0]=o*h*c+a*l*u,t[1]=a*l*c+o*h*u,t[2]=a*h*u-o*l*c,t[3]=a*h*c-o*l*u;break;case"zxy":t[0]=o*h*c-a*l*u,t[1]=a*l*c+o*h*u,t[2]=a*h*u+o*l*c,t[3]=a*h*c-o*l*u;break;case"zyx":t[0]=o*h*c-a*l*u,t[1]=a*l*c+o*h*u,t[2]=a*h*u-o*l*c,t[3]=a*h*c+o*l*u;break;default:throw Error("Unknown angle order "+s)}return t}function q(){var t=new f(2);return f!=Float32Array&&(t[0]=0,t[1]=0),t}function V(t){var e=new f(2);return e[0]=t[0],e[1]=t[1],e}function Z(t,e){var i=new f(2);return i[0]=t,i[1]=e,i}function W(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t}function H(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t}function Y(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)}function X(t,e){return t[0]*e[0]+t[1]*e[1]}function J(t,e,i,r){var s=e[0]-i[0],n=e[1]-i[1],o=Math.sin(r),a=Math.cos(r);return t[0]=s*a-n*o+i[0],t[1]=s*o+n*a+i[1],t}function K(t){return t[0]=0,t[1]=0,t}!function(){var t=new f(4);f!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}(),T(),P(1,0,0),P(0,1,0),U(),U(),p();var Q=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},tt=function(t){var e=t[0],i=t[1];return e*e+i*i};q();const et=8192;function it(t,e,i){return e*(et/(t.tileSize*2**(i-t.tileID.overscaledZ)))}function rt(t){return t instanceof Error?t:Error("string"==typeof t?t:String(t))}function st(){return new Float64Array(4)}function nt(){return new Float64Array(3)}function ot(){return new Float64Array(16)}function at(){let t=new Float64Array(16);return _(t),t}function lt(){let t=new Float32Array(16);return _(t),t}function ht(t,e,i,r,s=!1){if(!i[0]&&!i[1])return[0,0];let n=s?"map"===r?-t.bearingInRadians:0:"viewport"===r?t.bearingInRadians:0;if(n){let t=Math.sin(n),e=Math.cos(n);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[s?i[0]:it(e,i[0],t.zoom),s?i[1]:it(e,i[1],t.zoom)]}function ut(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function ct(t,e,i){let r=function(t){var e=t[3],i=t[4],r=t[5],s=t[6],n=t[7],o=t[8];return t[0]*(o*i-r*n)+t[1]*(-o*e+r*s)+t[2]*(n*e-i*s)}([t[0],t[1],t[2],e[0],e[1],e[2],i[0],i[1],i[2]]);if(0===r)return null;let s=F([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),n=F([],[i[0],i[1],i[2]],[t[0],t[1],t[2]]),o=F([],[t[0],t[1],t[2]],[e[0],e[1],e[2]]),a=C([],s,-t[3]);return I(a,a,C([],n,-e[3])),I(a,a,C([],o,-i[3])),C(a,a,1/r),a}function ft(t,e,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2];return 0===r?null:(-(t[0]*i[0]+t[1]*i[1]+t[2]*i[2])-i[3])/r}function pt(t,e,i,r){let s=Math.sqrt(t*t+e*e),n=Math.sqrt(i*i+r*r);t/=s,e/=s,i/=n,r/=n;let o=Math.acos(t*i+e*r);return-e*i+t*r>0?o:-o}function dt(t,e){let i=_t(t,360),r=_t(e,360),s=r-i,n=r>i?s-360:s+360;return Math.abs(s)<Math.abs(n)?s:n}function mt(t,e){let i=_t(t,2*Math.PI),r=_t(e,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))}function _t(t,e){return(t%e+e)%e}function gt(t,e,i,r,s){return yt(r,s,xt((t-e)/(i-e),0,1))}function yt(t,e,i){return t*(1-i)+e*i}function vt(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(let n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);return[e,i,r,s]}function wt(t,e,i,r){return function(t,e,i,r){let s=3*t,n=3*(i-t)-s,o=1-s-n,a=3*e,l=3*(r-e)-a,h=1-a-l;return function(t,e=1e-6){if(t<=0)return 0;if(t>=1)return 1;let i=t;for(let r=0;r<8;r++){let r=((o*i+n)*i+s)*i-t;if(Math.abs(r)<e)return((h*i+l)*i+a)*i;let u=(3*o*i+2*n)*i+s;if(Math.abs(u)<1e-6)break;i-=r/u}let r=0,u=1;i=t;for(let a=0;a<20;a++){let a=((o*i+n)*i+s)*i;if(Math.abs(a-t)<e)break;t>a?r=i:u=i,i=.5*(r+u)}return((h*i+l)*i+a)*i}}(t,e,i,r)}const bt=wt(.25,.1,.25,1);function xt(t,e,i){return Math.min(i,Math.max(e,t))}function Mt(t,e,i){let r=i-e,s=((t-e)%r+r)%r+e;return s===e?i:s}function zt(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function St(t,e){let i={};for(let r of e)r in t&&(i[r]=t[r]);return i}let Tt=1;function Et(){return Tt++}function At(t){return 2**t}function Pt(t){return Math.log(t)/Math.LN2}function It(t,e,i){if(e<=0)return t;let r=1/e;return void 0===i||Math.abs(i)<1e-10?Math.round(t*r)/r:(i>0?Math.ceil(t*r-1e-9):Math.floor(t*r+1e-10))/r}function Ct(t,e){let i={};for(let r in t)i[r]=e.call(this,t[r],r,t);return i}function kt(t,e){let i={};for(let r in t)e.call(this,t[r],r,t)&&(i[r]=t[r]);return i}function Dt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Dt(t[i],e[i]))return!1;return!0}if("object"==typeof t&&t&&null!==e){if("object"!=typeof e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let i in t)if(!Dt(t[i],e[i]))return!1;return!0}return t===e}function Ft(t){return Array.isArray(t)?t.map(Ft):"object"==typeof t&&t?Ct(t,Ft):t}const $t={};function jt(t){$t[t]||(typeof console<"u"&&console.warn(t),$t[t]=!0)}function Rt(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function Ot(t,e,i,r){let s=e.y-t.y,n=e.x-t.x,o=r.y-i.y,a=r.x-i.x,h=o*n-a*s;if(0===h)return null;let u=(a*(t.y-i.y)-o*(t.x-i.x))/h;return new l(t.x+u*n,t.y+u*s)}function Lt(t){return typeof WorkerGlobalScope<"u"&&void 0!==t&&t instanceof WorkerGlobalScope}let Bt=null;function Nt(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap}const Ut="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Gt(t,e,i,r){return t.addEventListener(e,i,r),{unsubscribe:()=>{t.removeEventListener(e,i,r)}}}function qt(t){return t*Math.PI/180}function Vt(t){return t/Math.PI*180}function Zt(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing}function Wt(t,e,i){let r=Z(e.x-i.x,e.y-i.y),s=Z(t.x-i.x,t.y-i.y);return Vt(Math.atan2(r[0]*s[1]-r[1]*s[0],X(r,s)))}function Ht(t,e,i){let r=new Float64Array(4);return G(r,t,e-90,i),r}const Yt=85.051129,Xt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Jt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Kt(t,e){return Xt[e]&&"touches"in t}function Qt(t,e){if(!Jt[e])return!1;let i=t,r=(i?.target)?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function te(t){return Xt[t]||Jt[t]}const ee="AbortError";var ie=class extends Error{constructor(t=ee){super(t instanceof Error?t.message:t),this.name=ee,t instanceof Error&&t.stack&&(this.stack=t.stack)}};function re(t){return t instanceof Error&&"AbortError"===t.name}function se(t){if(t.aborted)throw new ie(t.reason)}const ne={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{}};function oe(t){return ne.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ae="global-dispatcher";var le=class extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}};function he(){if(Lt(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}const ue=async function(t,e){if(t.url.includes("://")&&!/^https?:|^file:/.test(t.url)){let i=oe(t.url);if(i){let r=await i(t,e);return r.data||"arrayBuffer"!==t.type?r:zt(r,{data:new ArrayBuffer(0)})}if(Lt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ae},e)}if(!(t=>t.startsWith("file:")||he()?.startsWith("file:")&&!/^\w+:/.test(t))(t.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return async function(t,e){let i,r,s=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:he(),referrerPolicy:t.referrerPolicy,signal:e.signal});"json"===t.type&&!s.headers.has("Accept")&&s.headers.set("Accept","application/json");try{i=await fetch(s)}catch(e){throw re(e)?e:new le(0,rt(e).message,t.url,new Blob)}if(!i.ok){let e=await i.blob();throw new le(i.status,i.statusText,t.url,e)}r="arrayBuffer"===t.type||"image"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text();let n=await r;return se(e.signal),{data:n,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}(t,e);if(Lt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ae},e)}return function(t,e){return new Promise(((i,r)=>{let s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),("arrayBuffer"===t.type||"image"===t.type)&&(s.responseType="arraybuffer");for(let e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",t.headers?.Accept||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{r(Error(s.statusText))},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response)}catch(t){return void r(t)}i({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires"),etag:s.getResponseHeader("ETag")})}else{let e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});r(new le(s.status,s.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{s.abort(),r(new ie(e.signal.reason))})),s.send(t.body)}))}(t,e)},ce=(t,e)=>ue(zt(t,{type:"json"}),e);function fe(t){if(!t||t.startsWith("data:image/"))return!0;if(t.startsWith("blob:")&&(t=t.slice(5)).startsWith("null"))return!1;if(t.indexOf("://")<=0)return!0;let e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function pe(t,e,i){i[t]?.includes(e)||(i[t]||=[],i[t].push(e))}function de(t,e,i){if(i?.[t]){let r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}var me=class{constructor(t,e={}){zt(this,e),this.type=t}},_e=class extends me{constructor(t,e={}){super("error",zt({error:t},e))}},ge=class{on(t,e){return this._listeners||={},pe(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return de(t,e,this._listeners),de(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||={},pe(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new me(t,e||{}));let i=t.type;if(this.listens(i)){t.target=this;let e=this._listeners?.[i]?this._listeners[i].slice():[];for(let i of e)i.call(this,t);let r=this._oneTimeListeners?.[i]?this._oneTimeListeners[i].slice():[];for(let e of r)de(i,e,this._oneTimeListeners),e.call(this,t);let s=this._eventedParent;s&&(zt(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof _e&&console.error(t.error);return this}listens(t){return this._listeners?.[t]?.length>0||this._oneTimeListeners?.[t]?.length>0||this._eventedParent?.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}};const ye={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"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","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,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-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"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"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,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"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",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"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}},ve=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function we(t,e){let i={};for(let e in t)"ref"!==e&&(i[e]=t[e]);return ve.forEach((t=>{t in e&&(i[t]=e[t])})),i}function be(t){t=t.slice();let e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=we(t[i],e[t[i].ref]));return t}function xe(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!xe(t[i],e[i]))return!1;return!0}if("object"==typeof t&&t&&null!==e){if("object"!=typeof e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let i in t)if(!xe(t[i],e[i]))return!1;return!0}return t===e}function Me(t,e){t.push(e)}function ze(t,e,i){Me(i,{command:"addSource",args:[t,e[t]]})}function Se(t,e,i){Me(e,{command:"removeSource",args:[t]}),i[t]=!0}function Te(t,e,i,r){Se(t,i,r),ze(t,e,i)}function Ee(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!xe(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!xe(t[i][r],e[i][r]))return!1;return!0}function Ae(t,e,i,r,s,n){t||={},e||={};for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(xe(t[o],e[o])||i.push({command:n,args:[r,o,e[o],s]}));for(let o in e)!Object.prototype.hasOwnProperty.call(e,o)||Object.prototype.hasOwnProperty.call(t,o)||xe(t[o],e[o])||i.push({command:n,args:[r,o,e[o],s]})}function Pe(t){return t.id}function Ie(t,e){return t[e.id]=e,t}var Ce=class{constructor(t,e,i,r,s="error"){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),this.severity=s,null!=e&&e.__line__&&(this.line=e.__line__)}},ke=class extends Error{constructor(t,e){super(e),this.message=e,this.key=t}},De=class t{constructor(t,e=[]){this.parent=t,this.bindings={};for(let[t,i]of e)this.bindings[t]=i}concat(e){return new t(this,e)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}};const Fe={kind:"null"},$e={kind:"number"},je={kind:"string"},Re={kind:"boolean"},Oe={kind:"color"},Le={kind:"projectionDefinition"},Be={kind:"object"},Ne={kind:"value"},Ue={kind:"collator"},Ge={kind:"formatted"},qe={kind:"padding"},Ve={kind:"colorArray"},Ze={kind:"numberArray"},We={kind:"resolvedImage"},He={kind:"variableAnchorOffsetCollection"};function Ye(t,e){return{kind:"array",itemType:t,N:e}}function Xe(t){if("array"===t.kind){let e=Xe(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Je=[Fe,$e,je,Re,Oe,Le,Ge,Be,Ye(Ne),qe,Ze,Ve,We,He];function Ke(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ke(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(let t of Je)if(!Ke(t,e))return null}return`Expected ${Xe(t)} but found ${Xe(e)} instead.`}function Qe(t,e){return e.some((e=>e.kind===t.kind))}function ti(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function ei(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const ii=.96422,ri=.82521,si=4/29,ni=6/29,oi=3*ni*ni,ai=Math.PI/180,li=180/Math.PI;function hi(t){return(t%=360)<0&&(t+=360),t}function ui([t,e,i,r]){let s,n,o=fi((.2225045*(t=ci(t))+.7168786*(e=ci(e))+.0606169*(i=ci(i)))/1);t===e&&e===i?s=n=o:(s=fi((.4360747*t+.3850649*e+.1430804*i)/ii),n=fi((.0139322*t+.0971045*e+.7141733*i)/ri));let a=116*o-16;return[a<0?0:a,500*(s-o),200*(o-n),r]}function ci(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function fi(t){return t>.008856451679035631?t**(1/3):t/oi+si}function pi([t,e,i,r]){let s=(t+16)/116,n=isNaN(e)?s:s+e/500,o=isNaN(i)?s:s-i/200;return s=1*mi(s),n=ii*mi(n),o=ri*mi(o),[di(3.1338561*n-1.6168667*s-.4906146*o),di(-.9787684*n+1.9161415*s+.033454*o),di(.0719453*n-.2289914*s+1.4052427*o),r]}function di(t){return(t=t<=.00304?12.92*t:1.055*t**(1/2.4)-.055)<0?0:t>1?1:t}function mi(t){return t>ni?t*t*t:oi*(t-si)}const _i=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function gi(t,e){return _i(t,e)?t[e]:void 0}function yi(t){return parseInt(t.padEnd(2,t),16)/255}function vi(t,e){return wi(e?t/100:t,0,1)}function wi(t,e,i){return Math.min(Math.max(e,t),i)}function bi(t){return!t.some(Number.isNaN)}const xi={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 Mi(t,e,i){return t+i*(e-t)}function zi(t,e,i){return t.map(((t,r)=>Mi(t,e[r],i)))}var Si=class t{constructor(t,e,i,r=1,s=!0){this.r=t,this.g=e,this.b=i,this.a=r,s||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static{this.black=new t(0,0,0,1)}static{this.white=new t(1,1,1,1)}static{this.transparent=new t(0,0,0,0)}static{this.red=new t(1,0,0,1)}static parse(e){if(e instanceof t)return e;if("string"!=typeof e)return;let i=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];let e=gi(xi,t);if(e){let[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){let e=t.length<6?1:2,i=1;return[yi(t.slice(i,i+=e)),yi(t.slice(i,i+=e)),yi(t.slice(i,i+=e)),yi(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){let e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){let[t,i,r,s,n,o,a,l,h,u,c,f]=e,p=[s||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){let t=[r,o,h].join(""),e="%%%"===t?100:""===t?255:0;if(e){let t=[wi(+i/e,0,1),wi(+n/e,0,1),wi(+l/e,0,1),c?vi(+c,f):1];if(bi(t))return t}}return}}let i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[t,e,r,s,n,o,a,l,h]=i,u=[r||" ",n||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){let t=[+e,wi(+s,0,100),wi(+o,0,100),l?vi(+l,h):1];if(bi(t))return function([t,e,i,r]){function s(r){let s=(r+t/30)%12,n=e*Math.min(i,1-i);return i-n*Math.max(-1,Math.min(s-3,9-s,1))}return t=hi(t),e/=100,i/=100,[s(0),s(8),s(4),r]}(t)}}}(e);return i?new t(...i,!1):void 0}get rgb(){let{r:t,g:e,b:i,a:r}=this,s=r||1/0;return this.overwriteGetter("rgb",[t/s,e/s,i/s,r])}get hcl(){return this.overwriteGetter("hcl",function(t){let[e,i,r,s]=ui(t),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?hi(Math.atan2(r,i)*li):NaN,n,e,s]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ui(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){let[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${r})`}static interpolate(e,i,r,s="rgb"){switch(s){case"rgb":{let[s,n,o,a]=zi(e.rgb,i.rgb,r);return new t(s,n,o,a,!1)}case"hcl":{let s,n,[o,a,l,h]=e.hcl,[u,c,f,p]=i.hcl;if(isNaN(o)||isNaN(u))isNaN(o)?isNaN(u)?s=NaN:(s=u,(1===l||0===l)&&(n=c)):(s=o,(1===f||0===f)&&(n=a));else{let t=u-o;u>o&&t>180?t-=360:u<o&&o-u>180&&(t+=360),s=o+r*t}let[d,m,_,g]=function([t,e,i,r]){return t=isNaN(t)?0:t*ai,pi([i,Math.cos(t)*e,Math.sin(t)*e,r])}([s,n??Mi(a,c,r),Mi(l,f,r),Mi(h,p,r)]);return new t(d,m,_,g,!1)}case"lab":{let[s,n,o,a]=pi(zi(e.lab,i.lab,r));return new t(s,n,o,a,!1)}}}},Ti=class{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};const Ei=["bottom","center","top"];var Ai=class{constructor(t,e,i,r,s,n){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=s,this.verticalAlign=n}},Pi=class t{constructor(t){this.sections=t}static fromString(e){return new t([new Ai(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(e){return e instanceof t?e:t.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}},Ii=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r){return new t(zi(e.values,i.values,r))}},Ci=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e]);if(Array.isArray(e)){for(let t of e)if("number"!=typeof t)return;return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r){return new t(zi(e.values,i.values,r))}},ki=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){let i=Si.parse(e);return i?new t([i]):void 0}if(!Array.isArray(e))return;let i=[];for(let t of e){if("string"!=typeof t)return;let e=Si.parse(t);if(!e)return;i.push(e)}return new t(i)}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r,s="rgb"){let n=[];if(e.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let t=0;t<e.values.length;t++)n.push(Si.interpolate(e.values[t],i.values[t],r,s));return new t(n)}},Di=class extends Error{constructor(t,e){super(t),this.name="RuntimeError",this.path=e}toJSON(){return this.message}};const Fi=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var $i=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){let i=e[t],r=e[t+1];if("string"!=typeof i||!Fi.has(i)||!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r,s){let n=e.values,o=i.values;if(n.length!==o.length)throw new Di(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${i.toString()}`,s);let a=[];for(let t=0;t<n.length;t+=2){if(n[t]!==o[t])throw new Di(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${n[t]}, to[${t}]: ${o[t]}`,s);a.push(n[t]);let[e,i]=n[t+1],[l,h]=o[t+1];a.push([Mi(e,l,r),Mi(i,h,r)])}return new t(a)}},ji=class t{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(e){return e?new t({name:e,available:!1}):null}},Ri=class t{constructor(t,e,i){this.from=t,this.to=e,this.transition=i}toString(){return this.from===this.to&&1===this.transition?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(e,i,r){return new t(e,i,r)}static parse(e){return e instanceof t?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new t(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new t(e.from,e.to,e.transition):"string"==typeof e?new t(e,e,1):void 0}};function Oi(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Li(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ri||t instanceof Si||t instanceof Ti||t instanceof Pi||t instanceof Ii||t instanceof Ci||t instanceof ki||t instanceof $i||t instanceof ji)return!0;if(Array.isArray(t)){for(let e of t)if(!Li(e))return!1;return!0}if("object"==typeof t){for(let e in t)if(!Li(t[e]))return!1;return!0}return!1}function Bi(t){if(null===t)return Fe;if("string"==typeof t)return je;if("boolean"==typeof t)return Re;if("number"==typeof t)return $e;if(t instanceof Si)return Oe;if(t instanceof Ri)return Le;if(t instanceof Ti)return Ue;if(t instanceof Pi)return Ge;if(t instanceof Ii)return qe;if(t instanceof Ci)return Ze;if(t instanceof ki)return Ve;if(t instanceof $i)return He;if(t instanceof ji)return We;if(Array.isArray(t)){let e,i=t.length;for(let i of t){let t=Bi(i);if(e){if(e===t)continue;e=Ne;break}e=t}return Ye(e||Ne,i)}return Be}function Ni(t){let e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Si||t instanceof Ri||t instanceof Pi||t instanceof Ii||t instanceof Ci||t instanceof ki||t instanceof $i||t instanceof ji?t.toString():JSON.stringify(t)}var Ui=class t{constructor(t,e){this.type=t,this.value=e}static parse(e,i){if(2!==e.length)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Li(e[1]))return i.error("invalid value");let r=e[1],s=Bi(r),n=i.expectedType;return"array"===s.kind&&0===s.N&&n&&"array"===n.kind&&("number"!=typeof n.N||0===n.N)&&(s=n),new t(s,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const Gi={string:je,number:$e,boolean:Re,object:Be};var qi=class t{constructor(t,e,i){this.type=t,this.args=e,this.key=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r,s=1,n=e[0];if("array"===n){let t,n;if(e.length>2){let r=e[1];if("string"!=typeof r||!(r in Gi)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);t=Gi[r],s++}else t=Ne;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);n=e[2],s++}r=Ye(t,n)}else{if(!Gi[n])throw Error(`Types doesn't contain name = ${n}`);r=Gi[n]}let o=[];for(;s<e.length;s++){let t=i.parse(e[s],s,Ne);if(!t)return null;o.push(t)}return new t(r,o,i.key)}evaluate(t){for(let e=0;e<this.args.length;e++){let i=this.args[e].evaluate(t);if(!Ke(this.type,Bi(i)))return i;if(e===this.args.length-1)throw new Di(`Expected value to be of type ${Xe(this.type)}, but found ${Xe(Bi(i))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};const Vi={"to-boolean":Re,"to-color":Oe,"to-number":$e,"to-string":je};var Zi=class t{constructor(t,e,i){this.type=t,this.args=e,this.key=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[0];if(!Vi[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return i.error("Expected one argument.");let s=Vi[r],n=[];for(let t=1;t<e.length;t++){let r=i.parse(e[t],t,Ne);if(!r)return null;n.push(r)}return new t(s,n,i.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let e,i;for(let r of this.args){if(e=r.evaluate(t),i=null,e instanceof Si)return e;if("string"==typeof e){let i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Oi(e[0],e[1],e[2],e[3]),!i))return new Si(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Di(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"padding":{let e;for(let i of this.args){e=i.evaluate(t);let r=Ii.parse(e);if(r)return r}throw new Di(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"numberArray":{let e;for(let i of this.args){e=i.evaluate(t);let r=Ci.parse(e);if(r)return r}throw new Di(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"colorArray":{let e;for(let i of this.args){e=i.evaluate(t);let r=ki.parse(e);if(r)return r}throw new Di(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"variableAnchorOffsetCollection":{let e;for(let i of this.args){e=i.evaluate(t);let r=$i.parse(e);if(r)return r}throw new Di(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"number":{let e=null;for(let i of this.args){if(e=i.evaluate(t),null===e)return 0;let r=Number(e);if(!isNaN(r))return r}throw new Di(`Could not convert ${JSON.stringify(e)} to number.`,this.key)}case"formatted":return Pi.fromString(Ni(this.args[0].evaluate(t)));case"resolvedImage":return ji.fromString(Ni(this.args[0].evaluate(t)));case"projectionDefinition":{let e=this.args[0].evaluate(t);if(Ri.parse(e))return e;throw new Di(`Could not parse projectionDefinition from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}default:return Ni(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};const Wi=["Unknown","Point","LineString","Polygon"];var Hi=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wi[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=Si.parse(t),this._parseColorCache.set(t,e)),e}},Yi=class t{constructor(t,e,i=[],r,s=new De,n=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=s,this.errors=n,this.expectedType=r,this._isConstant=e}parse(t,e,i,r,s={}){return e?this.concat(e,i,r)._parse(t,s):this._parse(t,s)}_parse(t,e){(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t)&&(t=["literal",t]);let i=this.key;function r(t,e,r){return"assert"===r?new qi(e,[t],i):"coerce"===r?new Zi(e,[t],i):t}if(Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let i=t[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let s=this.registry[i];if(s){let i=s.parse(t,this);if(!i)return null;if(this.expectedType){let t=this.expectedType,s=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind){if("projectionDefinition"===t.kind&&["string","array","value"].includes(s.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(s.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(s.kind)||"colorArray"===t.kind&&["value","string","array"].includes(s.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(s.kind))i=r(i,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,s))return null}else i=r(i,t,e.typeAnnotation||"assert")}if(!(i instanceof Ui)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let e=new Hi;try{i=new Ui(i.type,i.evaluate(e))}catch(t){return this.error(t.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(e,i,r){let s="number"==typeof e?this.path.concat(e):this.path,n=r?this.scope.concat(r):this.scope;return new t(this.registry,this._isConstant,s,i||null,n,this.errors)}error(t,...e){let i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new ke(i,t))}checkSubtype(t,e){let i=Ke(t,e);return i&&this.error(i),i}},Xi=class t{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let e of this.bindings)t(e[1]);t(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let r=[];for(let t=1;t<e.length-1;t+=2){let s=e[t];if("string"!=typeof s)return i.error(`Expected string, but found ${typeof s} instead.`,t);if(/[^a-zA-Z0-9_]/.test(s))return i.error("Variable names must contain only alphanumeric characters or '_'.",t);let n=i.parse(e[t+1],t+1);if(!n)return null;r.push([s,n])}let s=i.parse(e[e.length-1],e.length-1,i.expectedType,r);return s?new t(r,s):null}outputDefined(){return this.result.outputDefined()}},Ji=class t{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(e,i){if(2!==e.length||"string"!=typeof e[1])return i.error("'var' expression requires exactly one string literal argument.");let r=e[1];return i.scope.has(r)?new t(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}};function Ki(t,e,i){let r,s,n=t.length-1,o=0,a=n,l=0;for(;o<=a;)if(l=Math.floor((o+a)/2),r=t[l],s=t[l+1],r<=e){if(l===n||e<s)return l;o=l+1}else{if(!(r>e))throw new Di("Input is not a number.",i);a=l-1}return 0}var Qi=class t{constructor(t,e,i,r){this.type=t,this.input=e,this.key=r,this.labels=[],this.outputs=[];for(let[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(e[1],1,$e);if(!r)return null;let s=[],n=null;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);for(let t=1;t<e.length;t+=2){let r=1===t?-1/0:e[t],o=e[t+1],a=t,l=t+1;if("number"!=typeof r)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(s.length&&s[s.length-1][0]>=r)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);let h=i.parse(o,l,n);if(!h)return null;n||=h.type,s.push([r,h])}return new t(n,r,s,i.key)}evaluate(t){let e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);let r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);let s=e.length;return r>=e[s-1]?i[s-1].evaluate(t):i[Ki(e,r,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}},tr=class t{constructor(t,e,i,r,s,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.key=n,this.labels=[],this.outputs=[];for(let[t,e]of s)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,r){let s=0;if("exponential"===t.name)s=er(e,t.base,i,r);else if("linear"===t.name)s=er(e,1,i,r);else if("cubic-bezier"===t.name){let n=t.controlPoints;s=function(t,e,i,r){let s=3*t,n=3*(i-t)-s,o=1-s-n,a=3*e,l=3*(r-e)-a,h=1-a-l;return function(t,e=1e-6){if(t<=0)return 0;if(t>=1)return 1;let i=t;for(let r=0;r<8;r++){let r=((o*i+n)*i+s)*i-t;if(Math.abs(r)<e)return((h*i+l)*i+a)*i;let u=(3*o*i+2*n)*i+s;if(Math.abs(u)<1e-6)break;i-=r/u}let r=0,u=1;i=t;for(let a=0;a<20;a++){let a=((o*i+n)*i+s)*i;if(Math.abs(a-t)<e)break;t>a?r=i:u=i,i=.5*(r+u)}return((h*i+l)*i+a)*i}}(n[0],n[1],n[2],n[3])(er(e,1,i,r))}return s}static parse(e,i){let[r,s,n,...o]=e;if(!Array.isArray(s)||0===s.length)return i.error("Expected an interpolation type expression.",1);if("linear"===s[0])s={name:"linear"};else if("exponential"===s[0]){let t=s[1];if("number"!=typeof t)return i.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:t}}else{if("cubic-bezier"!==s[0])return i.error(`Unknown interpolation type ${String(s[0])}`,1,0);{let t=s.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:t}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(n=i.parse(n,2,$e),!n)return null;let a=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==Ve?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=Oe;for(let t=0;t<o.length;t+=2){let e=o[t],r=o[t+1],s=t+3,n=t+4;if("number"!=typeof e)return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(a.length&&a[a.length-1][0]>=e)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);let h=i.parse(r,n,l);if(!h)return null;l||=h.type,a.push([e,h])}return ei(l,$e)||ei(l,Le)||ei(l,Oe)||ei(l,qe)||ei(l,Ze)||ei(l,Ve)||ei(l,He)||ei(l,Ye($e))?new t(l,r,s,n,a,i.key):i.error(`Type ${Xe(l)} is not interpolatable.`)}evaluate(e){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(e);let s=this.input.evaluate(e);if(s<=i[0])return r[0].evaluate(e);let n=i.length;if(s>=i[n-1])return r[n-1].evaluate(e);let o=Ki(i,s,this.key),a=t.interpolationFactor(this.interpolation,s,i[o],i[o+1]),l=r[o].evaluate(e),h=r[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Mi(l,h,a);case"color":return Si.interpolate(l,h,a);case"padding":return Ii.interpolate(l,h,a);case"colorArray":return ki.interpolate(l,h,a);case"numberArray":return Ci.interpolate(l,h,a);case"variableAnchorOffsetCollection":return $i.interpolate(l,h,a,this.key);case"array":return zi(l,h,a);case"projectionDefinition":return Ri.interpolate(l,h,a)}case"interpolate-hcl":switch(this.type.kind){case"color":return Si.interpolate(l,h,a,"hcl");case"colorArray":return ki.interpolate(l,h,a,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Si.interpolate(l,h,a,"lab");case"colorArray":return ki.interpolate(l,h,a,"lab")}}}eachChild(t){t(this.input);for(let e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}};function er(t,e,i,r){let s=r-i,n=t-i;return 0===s?0:1===e?n/s:(e**+n-1)/(e**+s-1)}const ir={color:Si.interpolate,number:Mi,padding:Ii.interpolate,numberArray:Ci.interpolate,colorArray:ki.interpolate,variableAnchorOffsetCollection:$i.interpolate,array:zi};var rr=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=null,s=i.expectedType;s&&"value"!==s.kind&&(r=s);let n=[];for(let t of e.slice(1)){let e=i.parse(t,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r||=e.type,n.push(e)}if(!r)throw Error("No output type");return s&&n.some((t=>Ke(s,t.type)))?new t(Ne,n):new t(r,n)}evaluate(t){let e,i=null,r=0;for(let s of this.args)if(r++,i=s.evaluate(t),i&&i instanceof ji&&!i.available&&(e||=i.name,i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};function sr(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function nr(t,e,i,r){return 0===r.compare(e,i)}function or(t,e,i){let r="=="!==t&&"!="!==t;return class s{constructor(t,e,i,r){this.lhs=t,this.rhs=e,this.key=i,this.collator=r,this.type=Re,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");let i=t[0],n=e.parse(t[1],1,Ne);if(!n)return null;if(!sr(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Xe(n.type)}'.`);let o=e.parse(t[2],2,Ne);if(!o)return null;if(!sr(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Xe(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Xe(n.type)}' and '${Xe(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new qi(o.type,[n],e.key):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new qi(n.type,[o],e.key)));let a=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ue),!a)return null}return new s(n,o,e.key,a)}evaluate(s){let n=this.lhs.evaluate(s),o=this.rhs.evaluate(s);if(r&&this.hasUntypedArgument){let e=Bi(n),i=Bi(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Di(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let t=Bi(n),i=Bi(o);if("string"!==t.kind||"string"!==i.kind)return e(s,n,o)}return this.collator?i(s,n,o,this.collator.evaluate(s)):e(s,n,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const ar=or("==",(function(t,e,i){return e===i}),nr),lr=or("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!nr(0,e,i,r)})),hr=or("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),ur=or(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),cr=or("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),fr=or(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));var pr=class t{constructor(t,e,i){this.type=Ue,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(e,i){if(2!==e.length)return i.error("Expected one argument.");let r=e[1];if("object"!=typeof r||Array.isArray(r))return i.error("Collator options argument must be an object.");let s=i.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Re);if(!s)return null;let n=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Re);if(!n)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,je),!o)?null:new t(s,n,o)}evaluate(t){return new Ti(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}},dr=class t{constructor(t){this.type=Ge,this.sections=t}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return i.error("First argument must be an image or text section.");let s=[],n=!1;for(let t=1;t<=e.length-1;++t){let r=e[t];if(n&&"object"==typeof r&&!Array.isArray(r)){n=!1;let t=null;if(r["font-scale"]&&(t=i.parse(r["font-scale"],1,$e),!t))return null;let e=null;if(r["text-font"]&&(e=i.parse(r["text-font"],1,Ye(je)),!e))return null;let o=null;if(r["text-color"]&&(o=i.parse(r["text-color"],1,Oe),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!Ei.includes(r["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(a=i.parse(r["vertical-align"],1,je),!a)return null}let l=s[s.length-1];l.scale=t,l.font=e,l.textColor=o,l.verticalAlign=a}else{let r=i.parse(e[t],1,Ne);if(!r)return null;let o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,s.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new t(s)}evaluate(t){return new Pi(this.sections.map((e=>{let i=e.content.evaluate(t);return Bi(i)===We?new Ai("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new Ai(Ni(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(let e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}};const mr=8192;function _r(t,e){let i=function(t){return(180+t)/360}(t[0]),r=function(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}(t[1]),s=2**e.z;return[Math.round(i*s*mr),Math.round(r*s*mr)]}function gr(t,e){let i=2**e.z,r=(t[1]/mr+e.y)/i;return[yr((t[0]/mr+e.x)/i),vr(r)]}function yr(t){return 360*t-180}function vr(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function wr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function br(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function xr(t,e,i){return e[1]>t[1]!=i[1]>t[1]&&t[0]<(i[0]-e[0])*(t[1]-e[1])/(i[1]-e[1])+e[0]}function Mr(t,e,i){let r=t[0]-e[0],s=t[1]-e[1],n=t[0]-i[0],o=t[1]-i[1];return r*o-n*s==0&&r*n<=0&&s*o<=0}function zr(t,e,i,r){return 0!==function(t,e){return t[0]*e[1]-t[1]*e[0]}([r[0]-i[0],r[1]-i[1]],[e[0]-t[0],e[1]-t[1]])&&!(!Ir(t,e,i,r)||!Ir(i,r,t,e))}function Sr(t,e,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(zr(t,e,r[i],r[i+1]))return!0;return!1}function Tr(t,e,i=!1){let r=!1;for(let s of e)for(let e=0;e<s.length-1;e++){if(Mr(t,s[e],s[e+1]))return i;xr(t,s[e],s[e+1])&&(r=!r)}return r}function Er(t,e){for(let i of e)if(Tr(t,i))return!0;return!1}function Ar(t,e){for(let i of t)if(!Tr(i,e))return!1;for(let i=0;i<t.length-1;++i)if(Sr(t[i],t[i+1],e))return!1;return!0}function Pr(t,e){for(let i of e)if(Ar(t,i))return!0;return!1}function Ir(t,e,i,r){let s=r[0]-i[0],n=r[1]-i[1],o=(t[0]-i[0])*n-s*(t[1]-i[1]),a=(e[0]-i[0])*n-s*(e[1]-i[1]);return o>0&&a<0||o<0&&a>0}function Cr(t,e,i){let r=[];for(let s=0;s<t.length;s++){let n=[];for(let r=0;r<t[s].length;r++){let o=_r(t[s][r],i);wr(e,o),n.push(o)}r.push(n)}return r}function kr(t,e,i){let r=[];for(let s=0;s<t.length;s++){let n=Cr(t[s],e,i);r.push(n)}return r}function Dr(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){let e=.5*r,s=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===s&&(s=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=s}wr(e,t)}function Fr(t,e,i,r){let s=2**r.z*mr,n=[r.x*mr,r.y*mr],o=[];for(let r of t)for(let t of r){let r=[t.x+n[0],t.y+n[1]];Dr(r,e,i,s),o.push(r)}return o}function $r(t,e,i,r){let s=2**r.z*mr,n=[r.x*mr,r.y*mr],o=[];for(let i of t){let t=[];for(let r of i){let i=[r.x+n[0],r.y+n[1]];wr(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=s/2){!function(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}(e);for(let t of o)for(let r of t)Dr(r,e,i,s)}return o}var jr=class t{constructor(t,e){this.type=Re,this.geojson=t,this.geometries=e}static parse(e,i){if(2!==e.length)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Li(e[1])){let i=e[1];if("FeatureCollection"===i.type){let e=[];for(let t of i.features){let{type:i,coordinates:r}=t.geometry;"Polygon"===i&&e.push(r),"MultiPolygon"===i&&e.push(...r)}if(e.length)return new t(i,{type:"MultiPolygon",coordinates:e})}else if("Feature"===i.type){let e=i.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new t(i,i.geometry)}else if("Polygon"===i.type||"MultiPolygon"===i.type)return new t(i,i)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){let n=Cr(e.coordinates,r,s),o=Fr(t.geometry(),i,r,s);if(!br(i,r))return!1;for(let t of o)if(!Tr(t,n))return!1}if("MultiPolygon"===e.type){let n=kr(e.coordinates,r,s),o=Fr(t.geometry(),i,r,s);if(!br(i,r))return!1;for(let t of o)if(!Er(t,n))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){let n=Cr(e.coordinates,r,s),o=$r(t.geometry(),i,r,s);if(!br(i,r))return!1;for(let t of o)if(!Ar(t,n))return!1}if("MultiPolygon"===e.type){let n=kr(e.coordinates,r,s),o=$r(t.geometry(),i,r,s);if(!br(i,r))return!1;for(let t of o)if(!Pr(t,n))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Rr=class{constructor(t=[],e=(t,e)=>t<e?-1:+(t>e)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:i}=this,r=e[t];for(;t>0;){let s=t-1>>1,n=e[s];if(i(r,n)>=0)break;e[t]=n,t=s}e[t]=r}_down(t){let{data:e,compare:i}=this,r=this.length>>1,s=e[t];for(;t<r;){let r=1+(t<<1),n=r+1;if(n<this.length&&i(e[n],e[r])<0&&(r=n),i(e[r],s)>=0)break;e[t]=e[r],t=r}e[t]=s}};function Or(t,e,i=0,r=t.length-1,s=Br){for(;r>i;){if(r-i>600){let n=r-i+1,o=e-i+1,a=Math.log(n),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(n-l)/n)*(o-n/2<0?-1:1);Or(t,e,Math.max(i,Math.floor(e-o*l/n+h)),Math.min(r,Math.floor(e+(n-o)*l/n+h)),s)}let n=t[e],o=i,a=r;for(Lr(t,i,e),s(t[r],n)>0&&Lr(t,i,r);o<a;){for(Lr(t,o,a),o++,a--;s(t[o],n)<0;)o++;for(;s(t[a],n)>0;)a--}0===s(t[i],n)?Lr(t,i,a):(a++,Lr(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Lr(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function Br(t,e){return t<e?-1:+(t>e)}function Nr(t,e){if(t.length<=1)return[t];let i,r,s=[];for(let e of t){let t=Gr(e);0!==t&&(e.area=Math.abs(t),void 0===r&&(r=t<0),r===t<0?(i&&s.push(i),i=[e]):i.push(e))}if(i&&s.push(i),e>1)for(let t=0;t<s.length;t++)s[t].length<=e||(Or(s[t],e,1,s[t].length-1,Ur),s[t]=s[t].slice(0,e));return s}function Ur(t,e){return e.area-t.area}function Gr(t){let e=0;for(let i,r,s=0,n=t.length,o=n-1;s<n;o=s++)i=t[s],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}const qr=Math.PI/180;var Vr=class{constructor(t){let e=6378.137*qr*1e3,i=Math.cos(t*qr),r=1/(1-.0066943799901413165*(1-i*i)),s=Math.sqrt(r);this.kx=e*s*i,this.ky=e*s*r*.9933056200098587}distance(t,e){let i=this.wrap(t[0]-e[0])*this.kx,r=(t[1]-e[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(t,e){let i,r,s,n,o=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],h=t[a][1],u=this.wrap(t[a+1][0]-l)*this.kx,c=(t[a+1][1]-h)*this.ky,f=0;(0!==u||0!==c)&&(f=(this.wrap(e[0]-l)*this.kx*u+(e[1]-h)*this.ky*c)/(u*u+c*c),f>1?(l=t[a+1][0],h=t[a+1][1]):f>0&&(l+=u/this.kx*f,h+=c/this.ky*f)),u=this.wrap(e[0]-l)*this.kx,c=(e[1]-h)*this.ky;let p=u*u+c*c;p<o&&(o=p,i=l,r=h,s=a,n=f)}return{point:[i,r],index:s,t:Math.max(0,Math.min(1,n))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}};function Zr(t,e){return e[0]-t[0]}function Wr(t){return t[1]-t[0]+1}function Hr(t,e){return t[1]>=t[0]&&t[1]<e}function Yr(t,e){if(t[0]>t[1])return[null,null];let i=Wr(t);if(e){if(2===i)return[t,null];let e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];let r=Math.floor(i/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function Xr(t,e){if(!Hr(e,t.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)wr(i,t[r]);return i}function Jr(t){let e=[1/0,1/0,-1/0,-1/0];for(let i of t)for(let t of i)wr(e,t);return e}function Kr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Qr(t,e,i){if(!Kr(t)||!Kr(e))return NaN;let r=0,s=0;return t[2]<e[0]&&(r=e[0]-t[2]),t[0]>e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(s=t[1]-e[3]),t[3]<e[1]&&(s=e[1]-t[3]),i.distance([0,0],[r,s])}function ts(t,e,i){let r=i.pointOnLine(e,t);return i.distance(t,r.point)}function es(t,e,i,r,s){let n=Math.min(ts(t,[i,r],s),ts(e,[i,r],s)),o=Math.min(ts(i,[t,e],s),ts(r,[t,e],s));return Math.min(n,o)}function is(t,e,i,r,s){if(!Hr(e,t.length)||!Hr(r,i.length))return 1/0;let n=1/0;for(let o=e[0];o<e[1];++o){let e=t[o],a=t[o+1];for(let t=r[0];t<r[1];++t){let r=i[t],o=i[t+1];if(zr(e,a,r,o))return 0;n=Math.min(n,es(e,a,r,o,s))}}return n}function rs(t,e,i,r,s){if(!Hr(e,t.length)||!Hr(r,i.length))return NaN;let n=1/0;for(let o=e[0];o<=e[1];++o)for(let e=r[0];e<=r[1];++e)if(n=Math.min(n,s.distance(t[o],i[e])),0===n)return n;return n}function ss(t,e,i){if(Tr(t,e,!0))return 0;let r=1/0;for(let s of e){let e=s[0],n=s[s.length-1];if(e!==n&&(r=Math.min(r,ts(t,[n,e],i)),0===r))return r;let o=i.pointOnLine(s,t);if(r=Math.min(r,i.distance(t,o.point)),0===r)return r}return r}function ns(t,e,i,r){if(!Hr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(Tr(t[r],i,!0))return 0;let s=1/0;for(let n=e[0];n<e[1];++n){let e=t[n],o=t[n+1];for(let t of i)for(let i=0,n=t.length,a=n-1;i<n;a=i++){let n=t[a],l=t[i];if(zr(e,o,n,l))return 0;s=Math.min(s,es(e,o,n,l,r))}}return s}function os(t,e){for(let i of t)for(let t of i)if(Tr(t,e,!0))return!0;return!1}function as(t,e,i,r=1/0){let s=Jr(t),n=Jr(e);if(r!==1/0&&Qr(s,n,i)>=r)return r;if(br(s,n)){if(os(t,e))return 0}else if(os(e,t))return 0;let o=1/0;for(let r of t)for(let t=0,s=r.length,n=s-1;t<s;n=t++){let s=r[n],a=r[t];for(let t of e)for(let e=0,r=t.length,n=r-1;e<r;n=e++){let r=t[n],l=t[e];if(zr(s,a,r,l))return 0;o=Math.min(o,es(s,a,r,l,i))}}return o}function ls(t,e,i,r,s,n){if(!n)return;let o=Qr(Xr(r,n),s,i);o<e&&t.push([o,n,[0,0]])}function hs(t,e,i,r,s,n,o){if(!n||!o)return;let a=Qr(Xr(r,n),Xr(s,o),i);a<e&&t.push([a,n,o])}function us(t,e,i,r,s=1/0){let n=Math.min(r.distance(t[0],i[0][0]),s);if(0===n)return n;let o=new Rr([[0,[0,t.length-1],[0,0]]],Zr),a=Jr(i);for(;o.length>0;){let s=o.pop();if(s[0]>=n)continue;let l=s[1],h=e?50:100;if(Wr(l)<=h){if(!Hr(l,t.length))return NaN;if(e){let e=ns(t,l,i,r);if(isNaN(e)||0===e)return e;n=Math.min(n,e)}else for(let e=l[0];e<=l[1];++e){let s=ss(t[e],i,r);if(n=Math.min(n,s),0===n)return 0}}else{let i=Yr(l,e);ls(o,n,r,t,a,i[0]),ls(o,n,r,t,a,i[1])}}return n}function cs(t,e,i,r,s,n=1/0){let o=Math.min(n,s.distance(t[0],i[0]));if(0===o)return o;let a=new Rr([[0,[0,t.length-1],[0,i.length-1]]],Zr);for(;a.length>0;){let n=a.pop();if(n[0]>=o)continue;let l=n[1],h=n[2],u=e?50:100,c=r?50:100;if(Wr(l)<=u&&Wr(h)<=c){if(!Hr(l,t.length)&&Hr(h,i.length))return NaN;let n;if(e&&r)n=is(t,l,i,h,s),o=Math.min(o,n);else if(e&&!r){let e=t.slice(l[0],l[1]+1);for(let t=h[0];t<=h[1];++t)if(n=ts(i[t],e,s),o=Math.min(o,n),0===o)return o}else if(!e&&r){let e=i.slice(h[0],h[1]+1);for(let i=l[0];i<=l[1];++i)if(n=ts(t[i],e,s),o=Math.min(o,n),0===o)return o}else n=rs(t,l,i,h,s),o=Math.min(o,n)}else{let n=Yr(l,e),u=Yr(h,r);hs(a,o,s,t,i,n[0],u[0]),hs(a,o,s,t,i,n[0],u[1]),hs(a,o,s,t,i,n[1],u[0]),hs(a,o,s,t,i,n[1],u[1])}}return o}function fs(t){return"MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}var ps=class t{constructor(t,e){this.type=$e,this.geojson=t,this.geometries=e}static parse(e,i){if(2!==e.length)return i.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Li(e[1])){let i=e[1];if("FeatureCollection"===i.type)return new t(i,i.features.map((t=>fs(t.geometry))).flat());if("Feature"===i.type)return new t(i,fs(i.geometry));if("type"in i&&"coordinates"in i)return new t(i,fs(i))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){let i=t.geometry(),r=i.flat().map((e=>gr([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let s=new Vr(r[0][1]),n=1/0;for(let t of e){switch(t.type){case"Point":n=Math.min(n,cs(r,!1,[t.coordinates],!1,s,n));break;case"LineString":n=Math.min(n,cs(r,!1,t.coordinates,!0,s,n));break;case"Polygon":n=Math.min(n,us(r,!1,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){let i=t.geometry(),r=i.flat().map((e=>gr([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let s=new Vr(r[0][1]),n=1/0;for(let t of e){switch(t.type){case"Point":n=Math.min(n,cs(r,!0,[t.coordinates],!1,s,n));break;case"LineString":n=Math.min(n,cs(r,!0,t.coordinates,!0,s,n));break;case"Polygon":n=Math.min(n,us(r,!0,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){let i=t.geometry();if(0===i.length||0===i[0].length)return NaN;let r=Nr(i,0).map((e=>e.map((e=>e.map((e=>gr([e.x,e.y],t.canonical))))))),s=new Vr(r[0][0][0][1]),n=1/0;for(let t of e)for(let e of r){switch(t.type){case"Point":n=Math.min(n,us([t.coordinates],!1,e,s,n));break;case"LineString":n=Math.min(n,us(t.coordinates,!0,e,s,n));break;case"Polygon":n=Math.min(n,as(e,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},ds=class t{constructor(t){this.key=t,this.type=Ne}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);let r=e[1];return null==r?i.error("Global state property must be defined."):"string"==typeof r?new t(r):i.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(t){let e=t.globals?.globalState;return e&&0!==Object.keys(e).length?gi(e,this.key)??null:null}eachChild(){}outputDefined(){return!1}};const ms={"==":ar,"!=":lr,">":ur,"<":hr,">=":fr,"<=":cr,array:qi,at:class t{constructor(t,e,i,r){this.type=t,this.index=e,this.input=i,this.key=r}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,$e),s=i.parse(e[2],2,Ye(i.expectedType||Ne));return r&&s?new t(s.type.itemType,r,s,i.key):null}evaluate(t){let e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new Di(`Array index out of bounds: ${e} < 0.`,this.key);if(e>=i.length)throw new Di(`Array index out of bounds: ${e} > ${i.length-1}.`,this.key);if(e!==Math.floor(e))throw new Di(`Array index must be an integer, but found ${e} instead.`,this.key);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},boolean:qi,case:class t{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);let s=[];for(let t=1;t<e.length-1;t+=2){let n=i.parse(e[t],t,Re);if(!n)return null;let o=i.parse(e[t+1],t+1,r);if(!o)return null;s.push([n,o]),r||=o.type}let n=i.parse(e[e.length-1],e.length-1,r);if(!n)return null;if(!r)throw Error("Can't infer output type");return new t(r,s,n)}evaluate(t){for(let[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}},coalesce:rr,collator:pr,format:dr,image:class t{constructor(t){this.type=We,this.input=t}static parse(e,i){if(2!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,je);return r?new t(r):i.error("No image name provided.")}evaluate(t){let e=this.input.evaluate(t),i=ji.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}},in:class t{constructor(t,e,i){this.needle=t,this.haystack=e,this.key=i,this.type=Re}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,Ne),s=i.parse(e[2],2,Ne);return r&&s?Qe(r.type,[Re,je,$e,Fe,Ne])?new t(r,s,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(r.type)} instead`):null}evaluate(t){let e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!ti(e,["boolean","string","number","null"]))throw new Di(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(Bi(e))} instead.`,this.key);if(!ti(i,["string","array"]))throw new Di(`Expected second argument to be of type array or string, but found ${Xe(Bi(i))} instead.`,this.key);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},"index-of":class t{constructor(t,e,i,r){this.needle=t,this.haystack=e,this.key=i,this.fromIndex=r,this.type=$e}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,Ne),s=i.parse(e[2],2,Ne);if(!r||!s)return null;if(!Qe(r.type,[Re,je,$e,Fe,Ne]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(r.type)} instead`);if(4===e.length){let n=i.parse(e[3],3,$e);return n?new t(r,s,i.key,n):null}return new t(r,s,i.key)}evaluate(t){let e,i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!ti(i,["boolean","string","number","null"]))throw new Di(`Expected first argument to be of type boolean, string, number or null, but found ${Xe(Bi(i))} instead.`,this.key);if(this.fromIndex&&(e=this.fromIndex.evaluate(t)),ti(r,["string"])){let t=r.indexOf(i,e);return-1===t?-1:[...r.slice(0,t)].length}if(ti(r,["array"]))return r.indexOf(i,e);throw new Di(`Expected second argument to be of type array or string, but found ${Xe(Bi(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:tr,"interpolate-hcl":tr,"interpolate-lab":tr,length:class t{constructor(t,e){this.input=t,this.key=e,this.type=$e}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);let r=i.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?i.error(`Expected argument of type string or array, but found ${Xe(r.type)} instead.`):new t(r,i.key):null}evaluate(t){let e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new Di(`Expected value to be of type string or array, but found ${Xe(Bi(e))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:Xi,literal:Ui,match:class t{constructor(t,e,i,r,s,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=s,this.otherwise=n}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let r,s;i.expectedType&&"value"!==i.expectedType.kind&&(s=i.expectedType);let n={},o=[];for(let t=2;t<e.length-1;t+=2){let a=e[t],l=e[t+1];Array.isArray(a)||(a=[a]);let h=i.concat(t);if(0===a.length)return h.error("Expected at least one branch label.");for(let t of a){if("number"!=typeof t&&"string"!=typeof t)return h.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>2**53-1)return h.error(`Branch labels must be integers no larger than ${2**53-1}.`);if("number"==typeof t&&Math.floor(t)!==t)return h.error("Numeric branch labels must be integer values.");if(r){if(h.checkSubtype(r,Bi(t)))return null}else r=Bi(t);if(void 0!==n[String(t)])return h.error("Branch labels must be unique.");n[String(t)]=o.length}let u=i.parse(l,t,s);if(!u)return null;s||=u.type,o.push(u)}let a=i.parse(e[1],1,Ne);if(!a)return null;let l=i.parse(e[e.length-1],e.length-1,s);return!l||"value"!==a.type.kind&&i.concat(1).checkSubtype(r,a.type)?null:new t(r,s,a,n,o,l)}evaluate(t){let e=this.input.evaluate(t);return(Bi(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}},number:qi,"number-format":class t{constructor(t,e,i,r,s,n){this.type=je,this.number=t,this.locale=e,this.currency=i,this.unit=r,this.minFractionDigits=s,this.maxFractionDigits=n}static parse(e,i){if(3!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,$e);if(!r)return null;let s=e[2];if("object"!=typeof s||Array.isArray(s))return i.error("NumberFormat options argument must be an object.");let n=null;if(s.locale&&(n=i.parse(s.locale,1,je),!n))return null;let o=null;if(s.currency&&(o=i.parse(s.currency,1,je),!o))return null;let a=null;if(s.unit&&(a=i.parse(s.unit,1,je),!a))return null;if(o&&a)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(s["min-fraction-digits"]&&(l=i.parse(s["min-fraction-digits"],1,$e),!l))return null;let h=null;return s["max-fraction-digits"]&&(h=i.parse(s["max-fraction-digits"],1,$e),!h)?null:new t(r,n,o,a,l,h)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.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.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}},object:qi,slice:class t{constructor(t,e,i,r,s){this.type=t,this.input=e,this.beginIndex=i,this.key=r,this.endIndex=s}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,Ne),s=i.parse(e[2],2,$e);if(!r||!s)return null;if(!Qe(r.type,[Ye(Ne),je,Ne]))return i.error(`Expected first argument to be of type array or string, but found ${Xe(r.type)} instead`);if(4===e.length){let n=i.parse(e[3],3,$e);return n?new t(r.type,r,s,i.key,n):null}return new t(r.type,r,s,i.key)}evaluate(t){let e,i=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(this.endIndex&&(e=this.endIndex.evaluate(t)),ti(i,["string"]))return[...i].slice(r,e).join("");if(ti(i,["array"]))return i.slice(r,e);throw new Di(`Expected first argument to be of type array or string, but found ${Xe(Bi(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:Qi,string:qi,"to-boolean":Zi,"to-color":Zi,"to-number":Zi,"to-string":Zi,var:Ji,within:jr,distance:ps,"global-state":ds};var _s=class t{constructor(t,e,i,r,s){this.name=t,this.type=e,this._evaluate=i,this.args=r,this.key=s}evaluate(t){return this._evaluate(t,this.args,this.key)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(e,i){let r=e[0],s=t.definitions[r];if(!s)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(s)?s[0]:s.type,o=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,a=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1)),l=null;for(let[s,o]of a){l=new Yi(i.registry,bs,i.path,null,i.scope);let a=[],h=!1;for(let t=1;t<e.length;t++){let i=e[t],r=Array.isArray(s)?s[t-1]:s.type,n=l.parse(i,1+a.length,r);if(!n){h=!0;break}a.push(n)}if(!h){if(Array.isArray(s)&&s.length!==a.length){l.error(`Expected ${s.length} arguments, but found ${a.length} instead.`);continue}for(let t=0;t<a.length;t++){let e=Array.isArray(s)?s[t]:s.type,i=a[t];l.concat(t+1).checkSubtype(e,i.type)}if(0===l.errors.length)return new t(r,n,o,a,i.key)}}if(1===a.length)i.errors.push(...l.errors);else{let t=(a.length?a:o).map((([t])=>function(t){return Array.isArray(t)?`(${t.map(Xe).join(", ")})`:`(${Xe(t.type)}...)`}(t))).join(" | "),r=[];for(let t=1;t<e.length;t++){let s=i.parse(e[t],1+r.length);if(!s)return null;r.push(Xe(s.type))}i.error(`Expected arguments of type ${t}, but found (${r.join(", ")}) instead.`)}return null}static register(e,i){t.definitions=i;for(let r in i)e[r]=t}};function gs(t,[e,i,r,s],n){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);let o=s?s.evaluate(t):1,a=Oi(e,i,r,o);if(a)throw new Di(a,n);return new Si(e/255,i/255,r/255,o,!1)}function ys(t,e){return t in e&&void 0!==e[t]}function vs(t,e){let i=e[t];return void 0===i?null:i}function ws(t){return{type:t}}function bs(t){if(t instanceof Ji)return bs(t.boundExpression);if(t instanceof _s&&"error"===t.name||t instanceof pr||t instanceof jr||t instanceof ps||t instanceof ds)return!1;let e=t instanceof Zi||t instanceof qi,i=!0;return t.eachChild((t=>{i&&=e?bs(t):t instanceof Ui})),!!i&&xs(t)&&zs(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function xs(t){if(t instanceof _s&&("get"===t.name&&1===t.args.length||"feature-state"===t.name||"has"===t.name&&1===t.args.length||"properties"===t.name||"geometry-type"===t.name||"id"===t.name||/^filter-/.test(t.name))||t instanceof jr||t instanceof ps)return!1;let e=!0;return t.eachChild((t=>{e&&!xs(t)&&(e=!1)})),e}function Ms(t){if(t instanceof _s&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Ms(t)&&(e=!1)})),e}function zs(t,e){if(t instanceof _s&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!zs(t,e)&&(i=!1)})),i}function Ss(t){return{result:"success",value:t}}function Ts(t){return{result:"error",value:t}}function Es(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function As(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Ps(t){return!!t.expression&&t.expression.interpolated}function Is(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function Cs(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function ks(t){return"object"==typeof t&&!!t&&!Array.isArray(t)&&Bi(t)===Be}function Ds(t){return t}function Fs(t,e){let i=t.stops&&"object"==typeof t.stops[0][0],r=i||!(i||void 0!==t.property),s=t.type||(Ps(e)?"exponential":"interval"),n=function(t){switch(t.type){case"color":return Si.parse;case"padding":return Ii.parse;case"numberArray":return Ci.parse;case"colorArray":return ki.parse;default:return null}}(e);if(n&&((t=Is({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default)),t.colorSpace&&!function(t){return"rgb"===t||"hcl"===t||"lab"===t}(t.colorSpace))throw Error(`Unknown color space: "${t.colorSpace}"`);let o,a,l=function(t){switch(t){case"exponential":return Os;case"interval":return Rs;case"categorical":return js;case"identity":return Ls;default:throw Error(`Unknown function type "${t}"`)}}(s);if("categorical"===s){o=Object.create(null);for(let e of t.stops)o[e[0]]=e[1];a=typeof t.stops[0][0]}if(i){let i={},r=[];for(let e=0;e<t.stops.length;e++){let s=t.stops[e],n=s[0].zoom;void 0===i[n]&&(i[n]={zoom:n,type:t.type,property:t.property,default:t.default,stops:[]},r.push(n)),i[n].stops.push([s[0].value,s[1]])}let s=[];for(let t of r)s.push([i[t].zoom,Fs(i[t],e)]);let n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:tr.interpolationFactor.bind(void 0,n),zoomStops:s.map((t=>t[0])),evaluate:({zoom:i},r)=>Os({stops:s,base:t.base},e,i).evaluate(i,r)}}if(r){let i="exponential"===s?{name:"exponential",base:void 0===t.base?1:t.base}:null;return{kind:"camera",interpolationType:i,interpolationFactor:tr.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>l(t,e,i,o,a)}}return{kind:"source",evaluate(i,r){let s=r&&r.properties?r.properties[t.property]:void 0;return void 0===s?$s(t.default,e.default):l(t,e,s,o,a)}}}function $s(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function js(t,e,i,r,s){return $s(typeof i===s?r[i]:void 0,t.default,e.default)}function Rs(t,e,i){if("number"!==Cs(i))return $s(t.default,e.default);let r=t.stops.length;if(1===r||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];let s=Ki(t.stops.map((t=>t[0])),i,"");return t.stops[s][1]}function Os(t,e,i){let r=void 0===t.base?1:t.base;if("number"!==Cs(i))return $s(t.default,e.default);let s=t.stops.length;if(1===s||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];let n=Ki(t.stops.map((t=>t[0])),i,""),o=function(t,e,i,r){let s=r-i,n=t-i;return 0===s?0:1===e?n/s:(e**+n-1)/(e**+s-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),a=t.stops[n][1],l=t.stops[n+1][1],h=ir[e.type]||Ds;return"function"==typeof a.evaluate?{evaluate(...e){let i=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return h(i,r,o,t.colorSpace)}}:h(a,l,o,t.colorSpace)}function Ls(t,e,i){switch(e.type){case"color":i=Si.parse(i);break;case"formatted":i=Pi.fromString(i.toString());break;case"resolvedImage":i=ji.fromString(i.toString());break;case"padding":i=Ii.parse(i);break;case"colorArray":i=ki.parse(i);break;case"numberArray":i=Ci.parse(i);break;default:Cs(i)!==e.type&&("enum"!==e.type||!e.values[i])&&(i=void 0)}return $s(i,t.default,e.default)}_s.register(ms,{error:[{kind:"error"},[je],(t,[e],i)=>{throw new Di(e.evaluate(t),i)}],typeof:[je,[Ne],(t,[e])=>Xe(Bi(e.evaluate(t)))],"to-rgba":[Ye($e,4),[Oe],(t,[e])=>{let[i,r,s,n]=e.evaluate(t).rgb;return[255*i,255*r,255*s,n]}],rgb:[Oe,[$e,$e,$e],gs],rgba:[Oe,[$e,$e,$e,$e],gs],has:{type:Re,overloads:[[[je],(t,[e])=>ys(e.evaluate(t),t.properties())],[[je,Be],(t,[e,i])=>ys(e.evaluate(t),i.evaluate(t))]]},get:{type:Ne,overloads:[[[je],(t,[e])=>vs(e.evaluate(t),t.properties())],[[je,Be],(t,[e,i])=>vs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Ne,[je],(t,[e])=>vs(e.evaluate(t),t.featureState||{})],properties:[Be,[],t=>t.properties()],"geometry-type":[je,[],t=>t.geometryType()],id:[Ne,[],t=>t.id()],zoom:[$e,[],t=>t.globals.zoom],"heatmap-density":[$e,[],t=>t.globals.heatmapDensity||0],elevation:[$e,[],t=>t.globals.elevation||0],"line-progress":[$e,[],t=>t.globals.lineProgress||0],accumulated:[Ne,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[$e,ws($e),(t,e)=>{let i=0;for(let r of e)i+=r.evaluate(t);return i}],"*":[$e,ws($e),(t,e)=>{let i=1;for(let r of e)i*=r.evaluate(t);return i}],"-":{type:$e,overloads:[[[$e,$e],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[$e],(t,[e])=>-e.evaluate(t)]]},"/":[$e,[$e,$e],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[$e,[$e,$e],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[$e,[],()=>Math.LN2],pi:[$e,[],()=>Math.PI],e:[$e,[],()=>Math.E],"^":[$e,[$e,$e],(t,[e,i])=>e.evaluate(t)**+i.evaluate(t)],sqrt:[$e,[$e],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[$e,[$e],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[$e,[$e],(t,[e])=>Math.log(e.evaluate(t))],log2:[$e,[$e],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[$e,[$e],(t,[e])=>Math.sin(e.evaluate(t))],cos:[$e,[$e],(t,[e])=>Math.cos(e.evaluate(t))],tan:[$e,[$e],(t,[e])=>Math.tan(e.evaluate(t))],asin:[$e,[$e],(t,[e])=>Math.asin(e.evaluate(t))],acos:[$e,[$e],(t,[e])=>Math.acos(e.evaluate(t))],atan:[$e,[$e],(t,[e])=>Math.atan(e.evaluate(t))],min:[$e,ws($e),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[$e,ws($e),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[$e,[$e],(t,[e])=>Math.abs(e.evaluate(t))],round:[$e,[$e],(t,[e])=>{let i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[$e,[$e],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[$e,[$e],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Re,[je,Ne],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Re,[Ne],(t,[e])=>t.id()===e.value],"filter-type-==":[Re,[je],(t,[e])=>t.geometryType()===e.value],"filter-<":[Re,[je,Ne],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<s}],"filter-id-<":[Re,[Ne],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Re,[je,Ne],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[Re,[Ne],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Re,[je,Ne],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[Re,[Ne],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Re,[je,Ne],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[Re,[Ne],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Re,[Ne],(t,[e])=>{let i=e.value,r=t.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[Re,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Re,[Ye(je)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Re,[Ye(Ne)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Re,[je,Ye(Ne)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Re,[je,Ye(Ne)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){let s=i+r>>1;if(e[s]===t)return!0;e[s]>t?r=s-1:i=s+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[ws(Re),(t,e)=>{for(let i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[ws(Re),(t,e)=>{for(let i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Re,[Re],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Re,[je],(t,[e])=>{let i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[je,[je],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[je,[je],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[je,ws(Ne),(t,e)=>e.map((e=>Ni(e.evaluate(t)))).join("")],split:[Ye(je),[je,je],(t,[e,i])=>e.evaluate(t).split(i.evaluate(t))],join:[je,[Ye(je),je],(t,[e,i])=>e.evaluate(t).join(i.evaluate(t))],"resolved-locale":[je,[Ue],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Bs=class{constructor(t,e,i,r){this.expression=t,this._warningHistory={},this._evaluator=new Hi,this._defaultValue=i?Js(i):null,this._enumValues=i&&"enum"===i.type?i.values:null,this._globalState=r,this._rootKey=e}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._globalState&&(t=Ks(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,s,n){this._globalState&&(t=Ks(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||null;try{let t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Di(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`,"");return t}catch(t){let e=t instanceof Di?t.path:"",i=`${e}|${t.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Ns(this._rootKey,e,t.message,this._defaultValue))),this._defaultValue}}};function Ns(t,e,i,r){return`${t}${e}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function Us(t){if(!t)throw Error('rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".')}function Gs(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in ms}function qs(t,e,i,r){Us(e);let s=new Yi(ms,bs,[],i?function(t){let e={color:Oe,string:je,number:$e,enum:je,boolean:Re,formatted:Ge,padding:qe,numberArray:Ze,colorArray:Ve,projectionDefinition:Le,resolvedImage:We,variableAnchorOffsetCollection:He};return"array"===t.type?Ye(e[t.value]||Ne,t.length):e[t.type]}(i):void 0),n=s.parse(t,void 0,void 0,void 0,i&&"string"===i.type?{typeAnnotation:"coerce"}:void 0);return n?Ss(new Bs(n,e,i,r)):Ts(s.errors)}var Vs=class{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ms(e.expression),this.globalStateRefs=Xs(e.expression),this._globalState=i}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._globalState&&(t=Ks(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._globalState&&(t=Ks(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,s,n)}},Zs=class{constructor(t,e,i,r,s){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ms(e.expression),this.globalStateRefs=Xs(e.expression),this.interpolationType=r,this._globalState=s}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._globalState&&(t=Ks(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._globalState&&(t=Ks(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,s,n)}interpolationFactor(t,e,i){return this.interpolationType?tr.interpolationFactor(this.interpolationType,t,e,i):0}};function Ws(t,e,i,r){let s=qs(t,e,i,r);if("error"===s.result)return s;let n=s.value.expression,o=xs(n);if(!o&&!Es(i))return Ts([new ke("","data expressions not supported")]);let a=zs(n,["zoom"]);if(!a&&!As(i))return Ts([new ke("","zoom expressions not supported")]);let l=Ys(n);return l||a?l instanceof ke?Ts([l]):l instanceof tr&&!Ps(i)?Ts([new ke("",'"interpolate" expressions cannot be used with this property')]):Ss(l?new Zs(o?"camera":"composite",s.value,l.labels,l instanceof tr?l.interpolation:void 0,r):new Vs(o?"constant":"source",s.value,r)):Ts([new ke("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}var Hs=class t{constructor(t,e,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Us(e),this._parameters=t,this._specification=i,this._rootKey=e,this._defaultValue=Js(i),this._warningHistory={};let r=Fs(this._parameters,this._specification);this.kind=r.kind,this.interpolationFactor=r.interpolationFactor,this.zoomStops=r.zoomStops,this.interpolationType=r.interpolationType,this._innerEvaluate=r.evaluate}evaluate(t,e){try{return this._innerEvaluate(t,e)}catch(t){let e=t instanceof Error?t.message:String(t),i=`|${e}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Ns(this._rootKey,"",e,this._defaultValue))),this._defaultValue}}static deserialize(e){return new t(e._parameters,e._rootKey,e._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function Ys(t){let e=null;if(t instanceof Xi)e=Ys(t.result);else if(t instanceof rr){for(let i of t.args)if(e=Ys(i),e)break}else(t instanceof Qi||t instanceof tr)&&t.input instanceof _s&&"zoom"===t.input.name&&(e=t);return e instanceof ke||t.eachChild((t=>{let i=Ys(t);i instanceof ke?e=i:!e&&i?e=new ke("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new ke("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Xs(t,e=new Set){return t instanceof ds&&e.add(t.key),t.eachChild((t=>{Xs(t,e)})),e}function Js(t){if("color"===t.type&&ks(t.default))return new Si(0,0,0,0);switch(t.type){case"color":return Si.parse(t.default)||null;case"padding":return Ii.parse(t.default)||null;case"numberArray":return Ci.parse(t.default)||null;case"colorArray":return ki.parse(t.default)||null;case"variableAnchorOffsetCollection":return $i.parse(t.default)||null;case"projectionDefinition":return Ri.parse(t.default)||null;default:return void 0===t.default?null:t.default}}function Ks(t,e){let{zoom:i,heatmapDensity:r,elevation:s,lineProgress:n,isSupportedScript:o,accumulated:a}=t??{};return{zoom:i,heatmapDensity:r,elevation:s,lineProgress:n,isSupportedScript:o,accumulated:a,globalState:e}}function Qs(t){if("boolean"==typeof t)return"neutral";if(!Array.isArray(t)||0===t.length)return"legacy";switch(t[0]){case"has":return t.length<2||"$id"===t[1]||"$type"===t[1]?"legacy":2===t.length?"neutral":"expression";case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]))?"expression":"legacy";case"!in":case"!has":case"none":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2])?"expression":"legacy";case"any":case"all":return function(t){let e=!1;for(let i of t){let t=Qs(i);if("expression"===t)return"expression";"legacy"===t&&(e=!0)}return e?"legacy":"neutral"}(t.slice(1));default:return"expression"}}function tn(t){return"legacy"!==Qs(t)}function en(t){return"$type"===t?["geometry-type"]:"$id"===t?["id"]:["get",t]}function rn(t){if(("<"===t[0]||"<="===t[0]||">"===t[0]||">="===t[0])&&"$type"===t[1])return`"$type" cannot be use with operator "${t[0]}"`;let e=function(t){switch(t[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return 3!==t.length||"string"!=typeof t[1]?null:[t[0],en(t[1]),t[2]];case"in":case"!in":{if(t.length<2||"string"!=typeof t[1])return null;let e=["in",en(t[1]),["literal",t.slice(2)]];return"!in"===t[0]?["!",e]:e}case"has":case"!has":{if(2!==t.length||"string"!=typeof t[1]||"$type"===t[1]||"$id"===t[1])return null;let e=["has",t[1]];return"!has"===t[0]?["!",e]:e}default:return null}}(t);return e?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(t)} with ${JSON.stringify(e)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(t)} to expression syntax.`}function sn(t,e,i){let r=i[t];return Array.isArray(r)?tn(r)?nn(r,e.concat(t)):{path:e.concat(t),legacyFilter:r}:null}function nn(t,e=[]){if(!Array.isArray(t)||t.length<1)return null;switch(t[0]){case"all":case"any":case"none":for(let i=1;i<t.length;i++){let r=sn(i,e,t);if(r)return r}break;case"!":{let i=sn(1,e,t);if(i)return i;break}case"case":for(let i=1;i<t.length-1;i+=2){let r=sn(i,e,t);if(r)return r}}return null}const on={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function an(t,e,i){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};tn(t)?function(t,e){let i=nn(t);if(!i||typeof console>"u")return;let r=i.path.map((t=>`[${t}]`)).join("");console.warn(`${e}${r}: ${rn(i.legacyFilter)}`)}(t,e):t=un(t);let r=qs(t,e,on,i);if("error"===r.result)throw Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,e,i)=>r.value.evaluate(t,e,{},i),needGeometry:hn(t),getGlobalStateRefs:()=>Xs(r.value.expression)}}function ln(t,e){return t<e?-1:+(t>e)}function hn(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(hn(t[e]))return!0;return!1}function un(t){if(!t)return!0;let e=t[0];return t.length<=1?"any"!==e:"=="===e?cn(t[1],t[2],"=="):"!="===e?dn(cn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?cn(t[1],t[2],e):"any"===e?function(t){return["any"].concat(t.map(un))}(t.slice(1)):"all"===e?["all"].concat(t.slice(1).map(un)):"none"===e?["all"].concat(t.slice(1).map(un).map(dn)):"in"===e?fn(t[1],t.slice(2)):"!in"===e?dn(fn(t[1],t.slice(2))):"has"===e?pn(t[1]):"!has"!==e||dn(pn(t[1]))}function cn(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function fn(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ln)]]:["filter-in-small",t,["literal",e]]}}function pn(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function dn(t){return["!",t]}function mn(t){let e=t.value;return e?[new Ce(t.key,e,"constants have been deprecated as of v8")]:[]}function _n(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function gn(t){if(Array.isArray(t))return t.map(gn);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let e={};for(let i in t)e[i]=gn(t[i]);return e}return _n(t)}function yn(t){let e=t.key,i=t.value,r=t.valueSpec||{},s=t.objectElementValidators||{},n=t.style,o=t.styleSpec,a=t.validateSpec,l=[],h=Cs(i);if("object"!==h)return[new Ce(e,i,`object expected, ${h} found`)];for(let t in i){let h,u=t.split(".")[0],c=gi(r,u)||r["*"];if(gi(s,u))h=s[u];else if(gi(r,u)){if(void 0===i[t])continue;h=a}else if(s["*"])h=s["*"];else{if(!r["*"]){l.push(new Ce(e,i[t],`unknown property "${t}"`));continue}h=a}l=l.concat(h({key:(e&&`${e}.`)+t,value:i[t],valueSpec:c,style:n,styleSpec:o,object:i,objectKey:t,validateSpec:a},i))}for(let t in r)s[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&l.push(new Ce(e,i,`missing required property "${t}"`));return l}function vn(t){let e=t.value,i=t.valueSpec,r=t.style,s=t.styleSpec,n=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==Cs(e))return[new Ce(n,e,`array expected, ${Cs(e)} found`)];if(i.length&&e.length!==i.length)return[new Ce(n,e,`array length ${i.length} expected, length ${e.length} found`)];let a={type:i.value,values:i.values};s.$version<7&&(a.function=i.function),"object"===Cs(i.value)&&(a=i.value);let l=[];for(let i=0;i<e.length;i++)l=l.concat(o({array:e,arrayIndex:i,value:e[i],valueSpec:a,validateSpec:t.validateSpec,style:r,styleSpec:s,key:`${n}[${i}]`}));return l}function wn(t){let e=t.key,i=t.value,r=t.valueSpec,s=Cs(i);return"number"===s&&i!=i&&(s="NaN"),"number"===s?"minimum"in r&&i<r.minimum?[new Ce(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new Ce(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new Ce(e,i,`number expected, ${s} found`)]}function bn(t){let e,i,r,s=t.valueSpec,n=_n(t.value.type),o={},a="categorical"!==n&&void 0===t.value.property,l=!a,h="array"===Cs(t.value.stops)&&"array"===Cs(t.value.stops[0])&&"object"===Cs(t.value.stops[0][0]),u=yn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return[new Ce(t.key,t.value,'identity function may not have a "stops" property')];let e=[],i=t.value;return e=e.concat(vn({key:t.key,value:i,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:c})),"array"===Cs(i)&&0===i.length&&e.push(new Ce(t.key,i,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:s,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===n&&a&&u.push(new Ce(t.key,t.value,'missing required property "property"')),"identity"!==n&&!t.value.stops&&u.push(new Ce(t.key,t.value,'missing required property "stops"')),"exponential"===n&&t.valueSpec.expression&&!Ps(t.valueSpec)&&u.push(new Ce(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Es(t.valueSpec)?u.push(new Ce(t.key,t.value,"property functions not supported")):a&&!As(t.valueSpec)&&u.push(new Ce(t.key,t.value,"zoom functions not supported"))),("categorical"===n||h)&&void 0===t.value.property&&u.push(new Ce(t.key,t.value,'"property" property is required')),u;function c(t){let e=[],n=t.value,a=t.key;if("array"!==Cs(n))return[new Ce(a,n,`array expected, ${Cs(n)} found`)];if(2!==n.length)return[new Ce(a,n,`array length 2 expected, length ${n.length} found`)];if(h){if("object"!==Cs(n[0]))return[new Ce(a,n,`object expected, ${Cs(n[0])} found`)];if(void 0===n[0].zoom)return[new Ce(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Ce(a,n,"object stop key must have value")];if(r&&r>_n(n[0].zoom))return[new Ce(a,n[0].zoom,"stop zoom values must appear in ascending order")];_n(n[0].zoom)!==r&&(r=_n(n[0].zoom),i=void 0,o={}),e=e.concat(yn({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:wn,value:f}}))}else e=e.concat(f({key:`${a}[0]`,value:n[0]},n));return Gs(gn(n[1]))?e.concat([new Ce(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):e.concat(t.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:s,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function f(t,r){let a=Cs(t.value),l=_n(t.value),h=null===t.value?r:t.value;if(e){if(a!==e)return[new Ce(t.key,h,`${a} stop domain type must match previous stop domain type ${e}`)]}else e=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Ce(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==n){let e=`number expected, ${a} found`;return Es(s)&&void 0===n&&(e+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ce(t.key,h,e)]}return"categorical"!==n||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===a&&void 0!==i&&l<i?[new Ce(t.key,h,"stop domain values must appear in ascending order")]:(i=l,"categorical"===n&&l in o?[new Ce(t.key,h,"stop domain values must be unique")]:(o[l]=!0,[])):[new Ce(t.key,h,`integer expected, found ${l}`)]}}function xn(t){let e=("property"===t.expressionContext?Ws:qs)(gn(t.value),t.key,t.valueSpec);if("error"===e.result)return e.value.map((e=>new Ce(`${t.key}${e.key}`,t.value,e.message)));let i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new Ce(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Ms(i))return[new Ce(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ms(i))return[new Ce(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!zs(i,["zoom","feature-state"]))return[new Ce(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!xs(i))return[new Ce(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Mn(t){let e=t.key,i=t.value,r=Cs(i);return"string"===r?Si.parse(String(i))?[]:[new Ce(e,i,`color expected, "${i}" found`)]:[new Ce(e,i,`color expected, ${r} found`)]}function zn(t){let e=t.key,i=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(_n(i))&&s.push(new Ce(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(_n(i))&&s.push(new Ce(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function Sn(t,e){let i=t;for(let t of e)i=i[t];return i}function Tn(t,e){let i=nn(e);return i?[new Ce(`${t.key}${i.path.map((t=>`[${t}]`)).join("")}`,Sn(t.value,i.path),rn(i.legacyFilter),null,"warning")]:[]}function En(t){let e=gn(t.value);return tn(e)?[...Tn(t,e),...xn(Is({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:An(t)}function An(t){let e=t.value,i=t.key;if("array"!==Cs(e))return[new Ce(i,e,`array expected, ${Cs(e)} found`)];let r,s=t.styleSpec,n=[];if(e.length<1)return[new Ce(i,e,"filter array must have at least 1 element")];switch(n=n.concat(zn({key:`${i}[0]`,value:e[0],valueSpec:s.filter_operator})),_n(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===_n(e[1])&&n.push(new Ce(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new Ce(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(r=Cs(e[1]),"string"!==r&&n.push(new Ce(`${i}[1]`,e[1],`string expected, ${r} found`)));for(let t=2;t<e.length;t++)r=Cs(e[t]),"$type"===_n(e[1])?n=n.concat(zn({key:`${i}[${t}]`,value:e[t],valueSpec:s.geometry_type})):"string"!==r&&"number"!==r&&"boolean"!==r&&n.push(new Ce(`${i}[${t}]`,e[t],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)n=n.concat(An({key:`${i}[${r}]`,value:e[r],styleSpec:t.styleSpec}));break;case"has":case"!has":r=Cs(e[1]),2===e.length?"string"!==r&&n.push(new Ce(`${i}[1]`,e[1],`string expected, ${r} found`)):n.push(new Ce(i,e,`filter array for "${e[0]}" operator must have 2 elements`))}return n}function Pn(t,e){let i=t.key,r=t.validateSpec,s=t.style,n=t.styleSpec,o=t.value,a=t.objectKey,l=n[`${e}_${t.layerType}`];if(!l)return[];let h=a.match(/^(.*)-transition$/);if("paint"===e&&h&&l[h[1]]&&l[h[1]].transition)return r({key:i,value:o,valueSpec:n.transition,style:s,styleSpec:n});let u,c=t.valueSpec||l[a];if(!c)return[new Ce(i,o,`unknown property "${a}"`)];if("string"===Cs(o)&&Es(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new Ce(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];let f=[];return"symbol"===t.layerType&&"text-font"===a&&ks(gn(o))&&"identity"===_n(o.type)&&f.push(new Ce(i,o,'"text-font" does not support identity functions')),f.concat(r({key:t.key,value:o,valueSpec:c,style:s,styleSpec:n,expressionContext:"property",propertyType:e,propertyKey:a}))}function In(t){return Pn(t,"paint")}function Cn(t){return Pn(t,"layout")}function kn(t){let e=[],i=t.value,r=t.key,s=t.style,n=t.styleSpec;if("object"!==Cs(i))return[new Ce(r,i,`object expected, ${Cs(i)} found`)];!i.type&&!i.ref&&e.push(new Ce(r,i,'either "type" or "ref" is required'));let o=_n(i.type),a=_n(i.ref);if(i.id){let n=_n(i.id);for(let o=0;o<t.arrayIndex;o++){let t=s.layers[o];_n(t.id)===n&&e.push(new Ce(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new Ce(r,i[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{_n(e.id)===a&&(t=e)})),t?t.ref?e.push(new Ce(r,i.ref,"ref cannot reference another ref layer")):o=_n(t.type):e.push(new Ce(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(i.source){let t=s.sources&&s.sources[i.source],n=t&&_n(t.type);t?"vector"===n&&"raster"===o?e.push(new Ce(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===o||"raster-dem"!==n&&"color-relief"===o?e.push(new Ce(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==o?e.push(new Ce(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==o&&"color-relief"!==o?e.push(new Ce(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===o&&i.paint&&i.paint["line-gradient"]&&("geojson"!==n||!t.lineMetrics)&&e.push(new Ce(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ce(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Ce(r,i.source,`source "${i.source}" not found`))}else e.push(new Ce(r,i,'missing required property "source"'));return"raster"===o&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&e.push(new Ce(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),e=e.concat(yn({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:En,layout:t=>yn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Cn(Is({layerType:o},t))}}),paint:t=>yn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>In(Is({layerType:o},t))}})}})),e}function Dn(t){let e=t.value,i=t.key,r=Cs(e);return"string"===r?[]:[new Ce(i,e,`string expected, ${r} found`)]}const Fn={promoteId:function({key:t,value:e}){if("string"===Cs(e))return Dn({key:t,value:e});{let i=[];for(let r in e)i.push(...Dn({key:`${t}.${r}`,value:e[r]}));return i}}};function $n(t){let e=t.value,i=t.key,r=t.styleSpec,s=t.style,n=t.validateSpec;if(!e.type)return[new Ce(i,e,'"type" is required')];let o,a=_n(e.type);switch(a){case"vector":case"raster":return o=yn({key:i,value:e,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Fn,validateSpec:n}),o;case"raster-dem":return o=function(t){let e=t.sourceName??"",i=t.value,r=t.styleSpec,s=r.source_raster_dem,n=t.style,o=[],a=Cs(i);if(void 0===i)return o;if("object"!==a)return o.push(new Ce("source_raster_dem",i,`object expected, ${a} found`)),o;let l="custom"===_n(i.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(let a in i)!l&&h.includes(a)?o.push(new Ce(a,i[a],`In "${e}": "${a}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):s[a]?o=o.concat(t.validateSpec({key:a,value:i[a],valueSpec:s[a],validateSpec:t.validateSpec,style:n,styleSpec:r})):o.push(new Ce(a,i[a],`unknown property "${a}"`));return o}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=yn({key:i,value:e,valueSpec:r.source_geojson,style:s,styleSpec:r,validateSpec:n,objectElementValidators:Fn}),e.cluster)for(let t in e.clusterProperties){let[r,s]=e.clusterProperties[t],n="string"==typeof r?[r,["accumulated"],["get",t]]:r;o.push(...xn({key:`${i}.${t}.map`,value:s,expressionContext:"cluster-map"})),o.push(...xn({key:`${i}.${t}.reduce`,value:n,expressionContext:"cluster-reduce"}))}return o;case"video":return yn({key:i,value:e,valueSpec:r.source_video,style:s,validateSpec:n,styleSpec:r});case"image":return yn({key:i,value:e,valueSpec:r.source_image,style:s,validateSpec:n,styleSpec:r});case"canvas":return[new Ce(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return zn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function jn(t){let e=t.value,i=t.styleSpec,r=i.light,s=t.style,n=[],o=Cs(e);if(void 0===e)return n;if("object"!==o)return n=n.concat([new Ce("light",e,`object expected, ${o} found`)]),n;for(let o in e){let a=o.match(/^(.*)-transition$/);n=n.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:i.transition,validateSpec:t.validateSpec,style:s,styleSpec:i}):r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new Ce(o,e[o],`unknown property "${o}"`)])}return n}function Rn(t){let e=t.value,i=t.styleSpec,r=i.sky,s=t.style,n=Cs(e);if(void 0===e)return[];if("object"!==n)return[new Ce("sky",e,`object expected, ${n} found`)];let o=[];for(let n in e)o=o.concat(r[n]?t.validateSpec({key:n,value:e[n],valueSpec:r[n],style:s,styleSpec:i}):[new Ce(n,e[n],`unknown property "${n}"`)]);return o}function On(t){let e=t.value,i=t.styleSpec,r=i.terrain,s=t.style,n=[],o=Cs(e);if(void 0===e)return n;if("object"!==o)return n=n.concat([new Ce("terrain",e,`object expected, ${o} found`)]),n;for(let o in e)n=n.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new Ce(o,e[o],`unknown property "${o}"`)]);return n}function Ln(t){let e=[],i=t.value,r=t.key;if(Array.isArray(i)){let s=[],n=[];for(let o in i)i[o].id&&s.includes(i[o].id)&&e.push(new Ce(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),s.push(i[o].id),i[o].url&&n.includes(i[o].url)&&e.push(new Ce(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),n.push(i[o].url),e=e.concat(yn({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Dn({key:r,value:i})}function Bn(t){return!!t&&t.constructor===Object}function Nn(t){return Bn(t.value)?[]:[new Ce(t.key,t.value,`object expected, ${Cs(t.value)} found`)]}const Un={"*":()=>[],array:vn,boolean:function(t){let e=t.value,i=t.key,r=Cs(e);return"boolean"===r?[]:[new Ce(i,e,`boolean expected, ${r} found`)]},number:wn,color:Mn,constants:mn,enum:zn,filter:En,function:bn,layer:kn,object:yn,source:$n,light:jn,sky:Rn,terrain:On,projection:function(t){let e=t.value,i=t.styleSpec,r=i.projection,s=t.style,n=Cs(e);if(void 0===e)return[];if("object"!==n)return[new Ce("projection",e,`object expected, ${n} found`)];let o=[];for(let n in e)o=o.concat(r[n]?t.validateSpec({key:n,value:e[n],valueSpec:r[n],style:s,styleSpec:i}):[new Ce(n,e[n],`unknown property "${n}"`)]);return o},projectionDefinition:function(t){let e=t.key,i=t.value;i=i instanceof String?i.valueOf():i;let r=Cs(i);return"array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(i)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(i)?["array","string"].includes(r)?[]:[new Ce(e,i,`projection expected, invalid type "${r}" found`)]:[new Ce(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Dn,formatted:function(t){return 0===Dn(t).length?[]:xn(t)},resolvedImage:function(t){return 0===Dn(t).length?[]:xn(t)},padding:function(t){let e=t.key,i=t.value;if("array"===Cs(i)){if(i.length<1||i.length>4)return[new Ce(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},s=[];for(let n=0;n<i.length;n++)s=s.concat(t.validateSpec({key:`${e}[${n}]`,value:i[n],validateSpec:t.validateSpec,valueSpec:r}));return s}return wn({key:e,value:i,valueSpec:{}})},numberArray:function(t){let e=t.key,i=t.value;if("array"===Cs(i)){let r={type:"number"};if(i.length<1)return[new Ce(e,i,"array length at least 1 expected, length 0 found")];let s=[];for(let n=0;n<i.length;n++)s=s.concat(t.validateSpec({key:`${e}[${n}]`,value:i[n],validateSpec:t.validateSpec,valueSpec:r}));return s}return wn({key:e,value:i,valueSpec:{}})},colorArray:function(t){let e=t.key,i=t.value;if("array"===Cs(i)){if(i.length<1)return[new Ce(e,i,"array length at least 1 expected, length 0 found")];let t=[];for(let r=0;r<i.length;r++)t=t.concat(Mn({key:`${e}[${r}]`,value:i[r]}));return t}return Mn({key:e,value:i})},variableAnchorOffsetCollection:function(t){let e=t.key,i=t.value,r=Cs(i),s=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new Ce(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let n=[];for(let r=0;r<i.length;r+=2)n=n.concat(zn({key:`${e}[${r}]`,value:i[r],valueSpec:s.layout_symbol["text-anchor"]})),n=n.concat(vn({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:s}));return n},sprite:Ln,state:Nn,fontFaces:function(t){let e=t.key,i=t.value,r=t.validateSpec,s=t.styleSpec,n=t.style;if(!Bn(i))return[new Ce(e,i,`object expected, ${Cs(i)} found`)];let o=[];for(let t in i){let a=i[t],l=Cs(a);if("string"===l)o.push(...Dn({key:`${e}.${t}`,value:a}));else if("array"===l){let i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[l,h]of a.entries())o.push(...yn({key:`${e}.${t}[${l}]`,value:h,valueSpec:i,styleSpec:s,style:n,validateSpec:r}))}else o.push(new Ce(`${e}.${t}`,a,`string or array expected, ${l} found`))}return o}};function Gn(t){let e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=Gn,i.expression&&ks(_n(e))?bn(t):i.expression&&Gs(gn(e))?xn(t):i.type&&Un[i.type]?Un[i.type](t):yn(Is({},t,{valueSpec:i.type?r[i.type]:i}))}function qn(t){let e=t.value,i=t.key,r=Dn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new Ce(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new Ce(i,e,'"glyphs" url must include a "{range}" token'))),r}function Vn(t,e=ye){let i=[];return i=i.concat(Gn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Gn,objectElementValidators:{glyphs:qn,"*":()=>[]}})),t.constants&&(i=i.concat(mn({key:"constants",value:t.constants}))),Wn(i)}function Zn(t){return function(e){return t(Object.assign({},e,{validateSpec:Gn}))}}function Wn(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Hn(t){return function(...e){return Wn(t.apply(this,e))}}Vn.source=Hn(Zn($n)),Vn.sprite=Hn(Zn(Ln)),Vn.glyphs=Hn(Zn(qn)),Vn.light=Hn(Zn(jn)),Vn.sky=Hn(Zn(Rn)),Vn.terrain=Hn(Zn(On)),Vn.state=Hn(Zn(Nn)),Vn.layer=Hn(Zn(kn)),Vn.filter=Hn(Zn(En)),Vn.paintProperty=Hn(Zn(In)),Vn.layoutProperty=Hn(Zn(Cn));const Yn={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var Xn=class{constructor(t,e,i){this._rootKey=e,this._globalState=i,this.setValue(t)}evaluate(){return this._literalValue??this._compiledValue.evaluate({})}setValue(t){if(null==t||"visible"===t||"none"===t)return this._literalValue="none"===t?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);let e=qs(t,this._rootKey,Yn,this._globalState);if("error"===e.result)throw this._literalValue="visible",this._compiledValue=void 0,Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=e.value,this._globalStateRefs=Xs(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};const Jn=Vn,Kn=new Set(Object.keys(ye).filter((t=>t.startsWith("source_"))).map((t=>t.slice(7).replaceAll("_","-"))));function Qn(t,e){let i=function(t){return Object.entries(t.sources??{}).filter((([,t])=>!Kn.has(t.type))).map((([t])=>`sources.${t}`))}(e);return to(t,Jn(e).filter((({message:t})=>!i.some((e=>t.startsWith(`${e}:`)||t.startsWith(`${e}.`))))))}function to(t,e){let i=!1;for(let r of e)"warning"!==r.severity?(t.fire(new _e(Error(r.message))),i=!0):jt(r.message);return i}function eo(t,e,i,r){return!1!==r?.validate&&to(t,e({styleSpec:ye,...i}))}var io=class t{constructor(t,e,i){let r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(let t=0;t<this.d*this.d;t++){let e=s[3+t],i=s[3+t+1];r.push(e===i?null:s.subarray(e,i))}let n=s[3+r.length+1];this.keys=s.subarray(s[3+r.length],n),this.bboxes=s.subarray(n),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;let s=i/e*t;this.min=-s,this.max=t+s}insert(t,e,i,r,s){this._forEachCell(e,i,r,s,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(s)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,s,n){this.cells[s].push(n)}query(t,e,i,r,s){let n=this.min,o=this.max;if(t<=n&&e<=n&&o<=i&&o<=r&&!s)return[...this.keys];{let n=[];return this._forEachCell(t,e,i,r,this._queryCell,n,{},s),n}}_queryCell(t,e,i,r,s,n,o,a){let l=this.cells[s];if(null!==l){let s=this.keys,h=this.bboxes;for(let u of l)if(void 0===o[u]){let l=4*u;(a?a(h[l+0],h[l+1],h[l+2],h[l+3]):t<=h[l+2]&&e<=h[l+3]&&i>=h[l+0]&&r>=h[l+1])?(o[u]=!0,n.push(s[u])):o[u]=!1}}}_forEachCell(t,e,i,r,s,n,o,a){let l=this._convertToCellCoord(t),h=this._convertToCellCoord(e),u=this._convertToCellCoord(i),c=this._convertToCellCoord(r);for(let f=l;f<=u;f++)for(let l=h;l<=c;l++){let h=this.d*l+f;if((!a||a(this._convertFromCellCoord(f),this._convertFromCellCoord(l),this._convertFromCellCoord(f+1),this._convertFromCellCoord(l+1)))&&s.call(this,t,e,i,r,h,n,o,a))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,e=3+this.cells.length+1+1,i=0;for(let t of this.cells)i+=t.length;let r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let s=e;for(let e=0;e<t.length;e++){let i=t[e];r[3+e]=s,r.set(i,s),s+=i.length}return r[3+t.length]=s,r.set(this.keys,s),s+=this.keys.length,r[3+t.length+1]=s,r.set(this.bboxes,s),s+=this.bboxes.length,r.buffer}static serialize(t,e){let i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(e){return new t(e.buffer)}};const ro={};function so(t,e,i={}){if(ro[t])throw Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),ro[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}so("Object",Object),so("Set",Set),so("TransferableGridIndex",io),so("Color",Si),so("Error",Error),so("AJAXError",le),so("ResolvedImage",ji),so("StylePropertyFunction",Hs),so("StyleExpression",Bs,{omit:["_evaluator"]}),so("ZoomDependentExpression",Zs),so("ZoomConstantExpression",Vs),so("CompoundExpression",_s,{omit:["_evaluate"]});for(let t in ms)ms[t]._classRegistryKey||so(`Expression_${t}`,ms[t]);function no(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||"ArrayBuffer"===t.constructor?.name)}function oo(t){return t.$name||t.constructor._classRegistryKey}function ao(t){return!function(t){if("object"!=typeof t||!t)return!1;let e=oo(t);return e&&"Object"!==e}(t)&&(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof Error||no(t)||Nt(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function lo(t,e){if(ao(t))return(no(t)||Nt(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){let i=[];for(let r of t)i.push(lo(r,e));return i}if("object"!=typeof t)throw Error("can't serialize object of type "+typeof t);let i=oo(t);if(!i)throw Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!ro[i])throw Error(`${i} is not registered.`);let{klass:r}=ro[i],s=r.serialize?r.serialize(t,e):{};if(r.serialize){if(s===e?.[e.length-1])throw Error("statically serialized object won't survive transfer of $name property")}else{for(let r in t){if(!t.hasOwnProperty(r)||ro[i].omit.includes(r))continue;let n=t[r];void 0!==n&&(s[r]=ro[i].shallow.includes(r)?n:lo(n,e))}t instanceof Error&&(s.message=t.message)}if(s.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(s.$name=i),s}function ho(t){if(ao(t))return t;if(Array.isArray(t))return t.map(ho);if("object"!=typeof t)throw Error("can't deserialize object of type "+typeof t);let e=oo(t)||"Object";if(!ro[e])throw Error(`can't deserialize unregistered class ${e}`);let{klass:i}=ro[e];if(!i)throw Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);let r=Object.create(i.prototype);for(let i of Object.keys(t)){if("$name"===i)continue;let s=t[i];r[i]=ro[e].shallow.includes(i)?s:ho(s)}return r}var uo=class{constructor(){this.first=!0}update(t,e){let i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}};function co(t){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function fo(t){for(let e of t)if(co(e.codePointAt(0)))return!0;return!1}function po(t){let e=t.map((t=>{try{return RegExp(`\\p{sc=${t}}`,"u").source}catch{return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}po(["Arab","Dupl","Mong","Ougr","Syrc"]);const mo=po("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".split("."));function _o(t){return mo.test(String.fromCodePoint(t))}function go(t,e){return!(!e&&_o(t)||function(t){return/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(t))}(t))}function yo(t){for(let e of t)if(_o(e.codePointAt(0)))return!0;return!1}const vo=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(vo.isParsed())throw Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}async syncState(t,e){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;let i=t.pluginURL,r=new Promise((t=>{this.loadScriptResolve=t})),s=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(await e(i),await Promise.race([r,s]),this.isParsed()){let t={pluginStatus:"loaded",pluginURL:i};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}};var wo=class{constructor(t,e){this.isSupportedScript=bo,this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new uo,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new uo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}};function bo(t){return function(t,e){for(let i of t)if(!go(i.codePointAt(0),e))return!1;return!0}(t,"loaded"===vo.getRTLTextPluginStatus())}var xo=class{constructor(t,e,i,r){this.property=t,this.value=e,this.expression=function(t,e,i,r){if(ks(t))return new Hs(t,e,i);if(Gs(t)){let s=Ws(t,e,i,r);if("error"===s.result)throw Error(s.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return s.value}{let e=t;return"color"===i.type&&"string"==typeof t?e=Si.parse(t):"padding"!==i.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==i.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==i.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===i.type&&Array.isArray(t)?e=$i.parse(t):"projectionDefinition"===i.type&&"string"==typeof t&&(e=Ri.parse(t)):e=ki.parse(t):e=Ci.parse(t):e=Ii.parse(t),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>e}}}(void 0===e?t.specification.default:e,i,t.specification,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}},Mo=class{constructor(t,e,i){this.property=t,this.value=new xo(t,void 0,e,i)}transitioned(t,e){return new So(this.property,this.value,e,zt({},t.transition,this.transition),t.now)}untransitioned(){return new So(this.property,this.value,null,{},0)}},zo=class{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=e}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return Ft(this._values[t].value.value)}setValue(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new Mo(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new xo(this._values[t].property,null===e?void 0:Ft(e),this._propertyRootKey(t),this._globalState)}getTransition(t){return Ft(this._values[t].transition)}setTransition(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new Mo(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Ft(e)||void 0}serialize(){let t={};for(let e of Object.keys(this._values)){let i=this.getValue(e);void 0!==i&&(t[e]=i);let r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){let i=new To(this._properties);for(let r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){let t=new To(this._properties);for(let e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}},So=class{constructor(t,e,i,r,s){this.property=t,this.value=e,this.begin=s+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){let r=t.now||0,s=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(!n)return s;if(r>this.end||this.value.isDataDriven())return this.prior=null,s;if(r<this.begin)return n.possiblyEvaluate(t,e,i);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(n.possiblyEvaluate(t,e,i),s,function(t){if(t<=0)return 0;if(t>=1)return 1;let e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(o))}}},To=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){let r=new Po(this._properties);for(let s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}},Eo=class{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=i,this._rootKey=e}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasValue(t){return void 0!==this._values[t].value}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return Ft(this._values[t].value)}setValue(t,e){this._values[t]=new xo(this._values[t].property,null===e?void 0:Ft(e),this._propertyRootKey(t),this._globalState)}serialize(){let t={};for(let e of Object.keys(this._values)){let i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){let r=new Po(this._properties);for(let s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}},Ao=class{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}},Po=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function Io(t){if(Array.isArray(t))return t.length;let e=t?.values;return Array.isArray(e)?e.length:void 0}function Co(t,e){let i=Io(t),r=Io(e);return void 0!==i&&void 0!==r&&i!==r}var ko=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e){if(t.isDataDriven())throw Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){if(Co(t,e))return jt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=ir[this.specification.type];return r?r(t,e,i):t}},Do=class{constructor(t,e,i){this.specification=t,this.name=e,this.overrides=i}possiblyEvaluate(t,e,i,r){return new Ao(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Ao(this,{kind:"constant",value:void 0},t.parameters);if(Co(t.value.value,e.value.value))return jt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=ir[this.specification.type];if(r){let s=r(t.value.value,e.value.value,i);return new Ao(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,e,i,r,s,n){return"constant"===t.kind?t.value:t.evaluate(e,i,r,s,n)}},Fo=class extends Do{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new Ao(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){let s=t.expression.evaluate(e,null,{},i,r),n="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,o=this._calculate(n,n,n,e);return new Ao(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){let i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Ao(this,{kind:"constant",value:i},e)}return new Ao(this,t.expression,e)}evaluate(t,e,i,r,s,n){if("source"===t.kind){let o=t.evaluate(e,i,r,s,n);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}},$o=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){let s=t.expression.evaluate(e,null,{},i,r);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new wo(Math.floor(e.zoom-1),e)),t.expression.evaluate(new wo(Math.floor(e.zoom),e)),t.expression.evaluate(new wo(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}},jo=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}},Ro=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let e in t){let i=t[e];i.specification.overridable&&this.overridableProperties.push(e);let r=this.defaultPropertyValues[e]=new xo(i,void 0,i.name,void 0),s=this.defaultTransitionablePropertyValues[e]=new Mo(i,i.name,void 0);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}};so("DataDrivenProperty",Do),so("DataConstantProperty",ko),so("CrossFadedDataDrivenProperty",Fo),so("CrossFadedProperty",$o),so("ColorRampProperty",jo);const Oo=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Lo=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Bo=class extends ge{constructor(t,e,i){if(super(),this.id=t.id,this.type=t.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(t,e,i){return new Xn(t,e,i)}(this.visibility,`layers[${this.id}].layout.visibility`,i),"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=an(t.filter,`layers[${this.id}].filter`,i)),e.layout&&(this._unevaluatedLayout=new Eo(e.layout,`layers[${this.id}].layout`,i)),e.paint)){this._transitionablePaint=new zo(e.paint,`layers[${this.id}].paint`,i);for(let e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(let e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Po(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=an(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){if("visibility"===t)return this.visibility;if(this._transitionablePaint?.hasProperty(t))throw Error(t+Oo);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){let t=new Set;for(let e of this._visibilityExpression.getGlobalStateRefs())t.add(e);if(this._unevaluatedLayout)for(let e in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[e];for(let e of i.getGlobalStateRefs())t.add(e)}for(let e of this._featureFilter.getGlobalStateRefs())t.add(e);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let e in this._transitionablePaint._values){let i=this._transitionablePaint._values[e].value;for(let r of i.getGlobalStateRefs()){let s=t.get(r)??[];s.push({name:e,value:i.value}),t.set(r,s)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,e,i={}){if("visibility"===t)return this.visibility=e,this._visibilityExpression.setValue(e),void this.recalculateVisibility();this._transitionablePaint?.hasProperty(t)?this.fire(new _e(Error(t+Oo))):null!=e&&this._validate(Jn.layoutProperty,`layers.${this.id}.layout.${t}`,t,e,i)||this._unevaluatedLayout.setValue(t,e)}getPaintProperty(t){if(t.endsWith("-transition")){let e=t.slice(0,-11);if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))throw Error(t+Lo);return this._transitionablePaint.getTransition(e)}if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))throw Error(t+Lo);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))return this.fire(new _e(Error(t+Lo))),!1;if(null!=e&&this._validate(Jn.paintProperty,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith("-transition"))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{let i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],s=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);let o=this._transitionablePaint._values[t].value;return o.isDataDriven()||s||r||this._handleOverridablePaintPropertyUpdate(t,n,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t=this.minzoom,e=!1){return!!(this.minzoom&&t<(e?Math.floor(this.minzoom):this.minzoom)||this.maxzoom&&t>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){let 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?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(t.layout||={},t.layout.visibility=this.visibility),kt(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,s={}){return eo(this,t,{key:e,layerType:this.type,objectKey:i,value:r},s)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let e=this.paint.get(t);if(e instanceof Ao&&Es(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}};let No;var Uo={get paint(){return No||=new Ro({"raster-opacity":new ko(ye.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new ko(ye.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new ko(ye.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new ko(ye.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new ko(ye.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new ko(ye.paint_raster["raster-contrast"],"raster-contrast"),resampling:new ko(ye.paint_raster.resampling,"resampling"),"raster-resampling":new ko(ye.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new ko(ye.paint_raster["raster-fade-duration"],"raster-fade-duration")})}};const Go=t=>"raster"===t.type;var qo=class extends Bo{constructor(t,e){super(t,Uo,e)}};const Vo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Zo=class{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}},Wo=class{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function Ho(t,e=1){let i=0,r=0;return{members:t.map((t=>{let s=function(t){return Vo[t].BYTES_PER_ELEMENT}(t.type),n=i=Yo(i,Math.max(e,s)),o=t.components||1;return r=Math.max(r,s),i+=s*o,{name:t.name,type:t.type,components:o,offset:n}})),size:Yo(i,Math.max(r,e)),alignment:e}}function Yo(t,e){return Math.ceil(t/e)*e}var Xo=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){let i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){let r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}};Xo.prototype.bytesPerElement=4,so("StructArrayLayout2i4",Xo);var Jo=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let s=3*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,t}};Jo.prototype.bytesPerElement=6,so("StructArrayLayout3i6",Jo);var Ko=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){let n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=s,t}};Ko.prototype.bytesPerElement=8,so("StructArrayLayout4i8",Ko);var Qo=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,o){let a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=s,this.int16[a+4]=n,this.int16[a+5]=o,t}};Qo.prototype.bytesPerElement=12,so("StructArrayLayout2i4i12",Qo);var ta=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,o){let a=4*t,l=8*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=s,this.uint8[l+6]=n,this.uint8[l+7]=o,t}};ta.prototype.bytesPerElement=8,so("StructArrayLayout2i4ub8",ta);var ea=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){let i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){let r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}};ea.prototype.bytesPerElement=8,so("StructArrayLayout2f8",ea);var ia=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,o,a,l,h){let u=this.length;return this.resize(u+1),this.emplace(u,t,e,i,r,s,n,o,a,l,h)}emplace(t,e,i,r,s,n,o,a,l,h,u){let c=10*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=s,this.uint16[c+4]=n,this.uint16[c+5]=o,this.uint16[c+6]=a,this.uint16[c+7]=l,this.uint16[c+8]=h,this.uint16[c+9]=u,t}};ia.prototype.bytesPerElement=20,so("StructArrayLayout10ui20",ia);var ra=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,o,a){let l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,s,n,o,a)}emplace(t,e,i,r,s,n,o,a,l){let h=8*t;return this.uint16[h+0]=e,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=s,this.uint16[h+4]=n,this.uint16[h+5]=o,this.uint16[h+6]=a,this.uint16[h+7]=l,t}};ra.prototype.bytesPerElement=16,so("StructArrayLayout8ui16",ra);var sa=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,o,a,l,h,u,c){let f=this.length;return this.resize(f+1),this.emplace(f,t,e,i,r,s,n,o,a,l,h,u,c)}emplace(t,e,i,r,s,n,o,a,l,h,u,c,f){let p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=s,this.uint16[p+4]=n,this.uint16[p+5]=o,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=h,this.int16[p+9]=u,this.int16[p+10]=c,this.int16[p+11]=f,t}};sa.prototype.bytesPerElement=24,so("StructArrayLayout4i4ui4i24",sa);var na=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let s=3*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}};na.prototype.bytesPerElement=12,so("StructArrayLayout3f12",na);var oa=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}};oa.prototype.bytesPerElement=4,so("StructArrayLayout1ul4",oa);var aa=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,o,a,l){let h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,s,n,o,a,l)}emplace(t,e,i,r,s,n,o,a,l,h){let u=10*t,c=5*t;return this.int16[u+0]=e,this.int16[u+1]=i,this.int16[u+2]=r,this.int16[u+3]=s,this.int16[u+4]=n,this.int16[u+5]=o,this.uint32[c+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=h,t}};aa.prototype.bytesPerElement=20,so("StructArrayLayout6i1ul2ui20",aa);var la=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,o){let a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=s,this.int16[a+4]=n,this.int16[a+5]=o,t}};la.prototype.bytesPerElement=12,so("StructArrayLayout2i2i2i12",la);var ha=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s){let n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,s)}emplace(t,e,i,r,s,n){let o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[a+6]=s,this.int16[a+7]=n,t}};ha.prototype.bytesPerElement=16,so("StructArrayLayout2f1f2i16",ha);var ua=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,o){let a=16*t,l=4*t,h=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=s,this.int16[h+6]=n,this.int16[h+7]=o,t}};ua.prototype.bytesPerElement=16,so("StructArrayLayout2ub2f2i16",ua);var ca=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=r,t}};ca.prototype.bytesPerElement=6,so("StructArrayLayout3ui6",ca);var fa=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_){let g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_)}emplace(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_,g){let y=24*t,v=12*t,w=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=s,this.uint32[v+2]=n,this.uint32[v+3]=o,this.uint32[v+4]=a,this.uint16[y+10]=l,this.uint16[y+11]=h,this.uint16[y+12]=u,this.float32[v+7]=c,this.float32[v+8]=f,this.uint8[w+36]=p,this.uint8[w+37]=d,this.uint8[w+38]=m,this.uint32[v+10]=_,this.int16[y+22]=g,t}};fa.prototype.bytesPerElement=48,so("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",fa);var pa=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,M,z,S,T,E){let A=this.length;return this.resize(A+1),this.emplace(A,t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,M,z,S,T,E)}emplace(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,M,z,S,T,E,A){let P=32*t,I=16*t;return this.int16[P+0]=e,this.int16[P+1]=i,this.int16[P+2]=r,this.int16[P+3]=s,this.int16[P+4]=n,this.int16[P+5]=o,this.int16[P+6]=a,this.int16[P+7]=l,this.uint16[P+8]=h,this.uint16[P+9]=u,this.uint16[P+10]=c,this.uint16[P+11]=f,this.uint16[P+12]=p,this.uint16[P+13]=d,this.uint16[P+14]=m,this.uint16[P+15]=_,this.uint16[P+16]=g,this.uint16[P+17]=y,this.uint16[P+18]=v,this.uint16[P+19]=w,this.uint16[P+20]=b,this.uint16[P+21]=x,this.uint16[P+22]=M,this.uint32[I+12]=z,this.float32[I+13]=S,this.float32[I+14]=T,this.uint16[P+30]=E,this.uint16[P+31]=A,t}};pa.prototype.bytesPerElement=64,so("StructArrayLayout8i15ui1ul2f2ui64",pa);var da=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}};da.prototype.bytesPerElement=4,so("StructArrayLayout1f4",da);var ma=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let s=3*t;return this.uint16[6*t+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}};ma.prototype.bytesPerElement=12,so("StructArrayLayout1ui2f12",ma);var _a=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,t}};_a.prototype.bytesPerElement=8,so("StructArrayLayout1ul2ui8",_a);var ga=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){let i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){let r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}};ga.prototype.bytesPerElement=4,so("StructArrayLayout2ui4",ga);var ya=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}};ya.prototype.bytesPerElement=2,so("StructArrayLayout1ui2",ya);var va=class extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){let n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=s,t}};va.prototype.bytesPerElement=16,so("StructArrayLayout4f16",va);var wa=class extends Zo{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 l(this.anchorPointX,this.anchorPointY)}};wa.prototype.size=20;var ba=class extends aa{get(t){return new wa(this,t)}};so("CollisionBoxArray",ba);var xa=class extends Zo{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]}};xa.prototype.size=48;var Ma=class extends fa{get(t){return new xa(this,t)}};so("PlacedSymbolArray",Ma);var za=class extends Zo{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]}};za.prototype.size=64;var Sa=class extends pa{get(t){return new za(this,t)}};so("SymbolInstanceArray",Sa);var Ta=class extends da{getoffsetX(t){return this.float32[1*t+0]}};so("GlyphOffsetArray",Ta);var Ea=class extends Jo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}};so("SymbolLineVertexArray",Ea);var Aa=class extends Zo{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]}};Aa.prototype.size=12;var Pa=class extends ma{get(t){return new Aa(this,t)}};so("TextAnchorOffsetArray",Pa);var Ia=class extends Zo{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]}};Ia.prototype.size=8;var Ca=class extends _a{get(t){return new Ia(this,t)}};so("FeatureIndexArray",Ca);var ka=class extends Xo{},Da=class extends Jo{},Fa=class extends Ko{},$a=class extends Xo{},ja=class extends Xo{},Ra=class extends Qo{},Oa=class extends ta{},La=class extends ea{},Ba=class extends ia{},Na=class extends ra{},Ua=class extends sa{},Ga=class extends na{},qa=class extends oa{},Va=class extends la{},Za=class extends ha{},Wa=class extends ua{},Ha=class extends ca{},Ya=class extends ca{},Xa=class extends ga{},Ja=class extends ya{};const Ka=Ho([{name:"a_pos",components:2,type:"Int16"}],4).members;var Qa=class t{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(e,i,r,s){let n=this.segments[this.segments.length-1];return e>t.MAX_VERTEX_ARRAY_LENGTH&&jt(`Max vertices per segment is ${t.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${t.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+e>t.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==s?this.createNewSegment(i,r,s):n}createNewSegment(t,e,i){let r={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(t,e,i){return this.prepareSegment(0,t,e,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let e in t.vaos)t.vaos[e].destroy()}static simpleSegment(e,i,r,s){return new t([{vertexOffset:e,primitiveOffset:i,vertexLength:r,primitiveLength:s,vaos:{},sortKey:0}])}};function tl(t,e){return 256*(t=xt(Math.floor(t),0,255))+xt(Math.floor(e),0,255)}Qa.MAX_VERTEX_ARRAY_LENGTH=65535,so("SegmentVector",Qa);const el=Ho([{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"}]),il=Ho([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var rl=o(((t,e)=>{void 0!==e&&(e.exports=function(t,e){for(var i,r,s=3&t.length,n=t.length-s,o=e,a=3432918353,l=461845907,h=0;h<n;)r=255&t.charCodeAt(h)|(255&t.charCodeAt(++h))<<8|(255&t.charCodeAt(++h))<<16|(255&t.charCodeAt(++h))<<24,++h,o=27492+(65535&(i=5*(65535&(o=(o^=r=(65535&(r=(r=(65535&r)*a+(((r>>>16)*a&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(i>>>16)&65535)<<16);switch(r=0,s){case 3:r^=(255&t.charCodeAt(h+2))<<16;case 2:r^=(255&t.charCodeAt(h+1))<<8;case 1:o^=r=(65535&(r=(r=(65535&(r^=255&t.charCodeAt(h)))*a+(((r>>>16)*a&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295}return o^=t.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0})})),sl=o(((t,e)=>{e.exports=function(t,e){for(var i,r=t.length,s=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:s^=(255&t.charCodeAt(n+2))<<16;case 2:s^=(255&t.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}})),nl=((i,r,n)=>(n=null==i?{}:t(s(i)),a(e(n,"default",{value:i,enumerable:!0}),i)))(o(((t,e)=>{var i=rl(),r=sl();e.exports=i,e.exports.murmur3=i,e.exports.murmur2=r}))()),ol=class t{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(al(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let e=al(t),i=0,r=this.ids.length-1;for(;i<r;){let t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}let s=[];for(;this.ids[i]===e;)s.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return s}static serialize(t,e){let i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return ll(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){let i=new t;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}};function al(t){let e=+t;return!isNaN(e)&&e<=2**53-1?e:(0,nl.default)(String(t))}function ll(t,e,i,r){for(;i<r;){let s=t[i+r>>1],n=i-1,o=r+1;for(;;){do{n++}while(t[n]<s);do{o--}while(t[o]>s);if(n>=o)break;hl(t,n,o),hl(e,3*n,3*o),hl(e,3*n+1,3*o+1),hl(e,3*n+2,3*o+2)}o-i<r-o?(ll(t,e,i,o),i=o+1):(ll(t,e,o+1,r),r=o)}}function hl(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}so("FeaturePositionMap",ol);var ul=class{constructor(t,e){this.gl=t.gl,this.location=e}},cl=class extends ul{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},fl=class extends ul{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},pl=class extends ul{constructor(t,e){super(t,e),this.current=[0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1])&&(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},dl=class extends ul{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2])&&(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},ml=class extends ul{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){(t[0]!==this.current[0]||t[1]!==this.current[1]||t[2]!==this.current[2]||t[3]!==this.current[3])&&(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}},_l=class extends ul{constructor(t,e){super(t,e),this.current=Si.transparent}set(t){(t.r!==this.current.r||t.g!==this.current.g||t.b!==this.current.b||t.a!==this.current.a)&&(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}},gl=class extends ul{constructor(t,e){super(t,e),this.current=[]}set(t){if(t!=this.current){this.current=t;let e=new Float32Array(4*t.length);for(let i=0;i<t.length;i++)e[4*i]=t[i].r,e[4*i+1]=t[i].g,e[4*i+2]=t[i].b,e[4*i+3]=t[i].a;this.gl.uniform4fv(this.location,e)}}},yl=class extends ul{constructor(t,e){super(t,e),this.current=[]}set(t){if(t!=this.current){this.current=t;let e=new Float32Array(t);this.gl.uniform1fv(this.location,e)}}};const vl=new Float32Array(16);var wl=class extends ul{constructor(t,e){super(t,e),this.current=vl}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}};function bl(t){return[tl(255*t.r,255*t.g),tl(255*t.b,255*t.a)]}var xl=class{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new _l(t,e):new fl(t,e)}},Ml=class{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,e){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,e.y,e.height,e.width]}setUniform(t,e,i,r){let s=null;"u_pattern_to"===r?s=this.patternTo:"u_pattern_from"===r?s=this.patternFrom:"u_dasharray_to"===r?s=this.dashTo:"u_dasharray_from"===r?s=this.dashFrom:"u_pixel_ratio_to"===r?s=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(s=this.pixelRatioFrom),null!==s&&t.set(s)}getBinding(t,e,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new ml(t,e):new fl(t,e)}},zl=class{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i){let r=this.paintVertexArray.length,s=this.expression.evaluate(new wo(0,i),e,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(r,t,s)}updatePaintArray(t,e,i,r,s){let n=this.expression.evaluate(new wo(0,s),i,r);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){let r=bl(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},Sl=class{constructor(t,e,i,r,s,n){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i){let r=this.expression.evaluate(new wo(this.zoom,i),e,{},i.canonical,[],i.formattedSection),s=this.expression.evaluate(new wo(this.zoom+1,i),e,{},i.canonical,[],i.formattedSection),n=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(n,t,r,s)}updatePaintArray(t,e,i,r,s){let n=this.expression.evaluate(new wo(this.zoom,s),i,r),o=this.expression.evaluate(new wo(this.zoom+1,s),i,r);this._setPaintValue(t,e,n,o)}_setPaintValue(t,e,i,r){if("color"===this.type){let s=bl(i),n=bl(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,s[0],s[1],n[0],n[1])}else{for(let s=t;s<e;s++)this.paintVertexArray.emplace(s,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){let i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=xt(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new fl(t,e)}},Tl=class{constructor(t,e,i,r,s,n){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=n,this.zoomInPaintVertexArray=new s,this.zoomOutPaintVertexArray=new s}populatePaintArray(t,e,i){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,this.getPositionIds(e),i)}updatePaintArray(t,e,i,r,s){this._setPaintValues(t,e,this.getPositionIds(i),s)}_setPaintValues(t,e,i,r){let s=this.getPositions(r);if(!s||!i)return;let n=s[i.min],o=s[i.mid],a=s[i.max];if(n&&o&&a)for(let i=t;i<e;i++)this.emplace(this.zoomInPaintVertexArray,i,n,o),this.emplace(this.zoomOutPaintVertexArray,i,a,o)}upload(t){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let e=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,e,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,e,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}},El=class extends Tl{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns?.[this.layerId]}getVertexAttributes(){return el.members}emplace(t,e,i,r){t.emplace(e,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}},Al=class extends Tl{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes?.[this.layerId]}getVertexAttributes(){return il.members}emplace(t,e,i,r){t.emplace(e,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},Pl=class{constructor(t,e,i){this.binders={},this._buffers=[];let r=[];for(let s in t.paint._values){if(!i(s))continue;let n=t.paint.get(s);if(!(n instanceof Ao&&Es(n.property.specification)))continue;let o=Cl(s,t.type),a=n.value,l=n.property.specification.type,h=n.property.useIntegerZoom,u=n.property.specification["property-type"],c="cross-faded"===u||"cross-faded-data-driven"===u;if("constant"===a.kind)this.binders[s]=c?new Ml(a.value,o):new xl(a.value,o,l),r.push(`/u_${s}`);else if("source"===a.kind||c){let i=kl(s,l,"source");this.binders[s]=c?"line-dasharray"===s?new Al(a,l,h,e,i,t.id):new El(a,l,h,e,i,t.id):new zl(a,o,l,i),r.push(`/a_${s}`)}else{let t=kl(s,l,"composite");this.binders[s]=new Sl(a,o,l,h,e,t),r.push(`/z_${s}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){let e=this.binders[t];return e instanceof zl||e instanceof Sl?e.maxValue:0}populatePaintArrays(t,e,i){for(let r in this.binders){let s=this.binders[r];(s instanceof zl||s instanceof Sl||s instanceof Tl)&&s.populatePaintArray(t,e,i)}}setConstantPatternPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof Ml&&r.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof Ml&&r.setConstantDashPositions(t,e)}}updatePaintArrays(t,e,i,r,s){let n=!1;for(let o of t){let t=e.getPositions(o.id);for(let e of t){let t=i.feature(e.index);for(let i in this.binders){let a=this.binders[i];(a instanceof zl||a instanceof Sl||a instanceof Tl)&&!0===a.expression.isStateDependent&&(a.expression=r.paint.get(i).value,a.updatePaintArray(e.start,e.end,t,o.state,s),n=!0)}}}return n}defines(){let t=[];for(let e in this.binders){let i=this.binders[e];(i instanceof xl||i instanceof Ml)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){let t=[];for(let e in this.binders){let i=this.binders[e];if(i instanceof zl||i instanceof Sl)for(let e of i.paintVertexAttributes)t.push(e.name);else if(i instanceof Tl){let e=i.getVertexAttributes();for(let i of e)t.push(i.name)}}return t}getBinderUniforms(){let t=[];for(let e in this.binders){let i=this.binders[e];if(i instanceof xl||i instanceof Ml||i instanceof Sl)for(let e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){let i=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof xl||s instanceof Ml||s instanceof Sl)for(let n of s.uniformNames)if(e[n]){let o=s.getBinding(t,e[n],n);i.push({name:n,property:r,binding:o})}}return i}setUniforms(t,e,i,r){for(let{name:t,property:s,binding:n}of e)this.binders[s].setUniform(n,r,i.get(s),t)}updatePaintBuffers(t){this._buffers=[];for(let e in this.binders){let i=this.binders[e];if(t&&i instanceof Tl){let e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof zl||i instanceof Sl)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(let e in this.binders){let i=this.binders[e];(i instanceof zl||i instanceof Sl||i instanceof Tl)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let e=this.binders[t];(e instanceof zl||e instanceof Sl||e instanceof Tl)&&e.destroy()}}},Il=class{constructor(t,e,i=()=>!0){this.programConfigurations={};for(let r of t)this.programConfigurations[r.id]=new Pl(r,e,i);this.needsUpload=!1,this._featureMap=new ol,this._bufferOffset=0}populatePaintArrays(t,e,i,r){for(let i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(let s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function Cl(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function kl(t,e,i){let r={color:{source:ea,composite:va},number:{source:da,composite:ea}};return function(t){return{"line-pattern":{source:Ba,composite:Ba},"fill-pattern":{source:Ba,composite:Ba},"fill-extrusion-pattern":{source:Ba,composite:Ba},"line-dasharray":{source:Na,composite:Na}}[t]}(t)?.[i]||r[e][i]}so("ConstantBinder",xl),so("CrossFadedConstantBinder",Ml),so("SourceExpressionBinder",zl),so("CrossFadedPatternBinder",El),so("CrossFadedDasharrayBinder",Al),so("CompositeExpressionBinder",Sl),so("ProgramConfiguration",Pl,{omit:["_buffers"]}),so("ProgramConfigurationSet",Il);const Dl=-16384;function Fl(t){let e=et/t.extent,i=t.loadGeometry();for(let t of i)for(let i of t){let t=Math.round(i.x*e),r=Math.round(i.y*e);i.x=xt(t,Dl,16383),i.y=xt(r,Dl,16383),(t<i.x||t>i.x+1||r<i.y||r>i.y+1)&&jt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function $l(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Fl(t):[]}}const jl=-32768;function Rl(t,e,i,r,s){t.emplaceBack(jl+8*e+r,jl+8*i+s)}var Ol=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new $a,this.indexArray=new Ya,this.segments=new Qa,this.programConfigurations=new Il(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){let r=this.layers[0],s=[],n=null,o=!1,a="heatmap"===r.type;if("circle"===r.type){let t=r;n=t.layout.get("circle-sort-key"),o=!n.isConstant(),a||="map"===t.paint.get("circle-pitch-alignment")}let l=a?e.subdivisionGranularity.circle:1,h=new wo(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:r,index:a,sourceLayerIndex:l}of t){let t=$l(e,u);if(!this.layers[0]._featureFilter.filter(h,t,i))continue;let c=o?n.evaluate(t,{},i):void 0,f={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:u?t.geometry:Fl(e),patterns:{},sortKey:c};s.push(f)}o&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(let r of s){let{geometry:s,index:n,sourceLayerIndex:o}=r,a=t[n].feature;this.addFeature(r,s,n,i,l),e.featureIndex.insert(a,s,n,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ka),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r,s=1){let n;switch(s){case 1:n=[0,7];break;case 3:n=[0,2,5,7];break;case 5:n=[0,1,3,4,6,7];break;case 7:n=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${s}; valid values are 1, 3, 5, 7.`)}let o=n.length;for(let i of e)for(let e of i){let i=e.x,r=e.y;if(i<0||i>=8192||r<0||r>=8192)continue;let s=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;for(let t=0;t<o;t++)for(let e=0;e<o;e++)Rl(this.layoutVertexArray,i,r,n[e],n[t]);for(let t=0;t<o-1;t++)for(let e=0;e<o-1;e++){let i=a+t*o+e,r=a+(t+1)*o+e;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}s.vertexLength+=o*o,s.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:{},canonical:r})}};function Ll(t,e){for(let i of t)if(Hl(e,i))return!0;for(let i of e)if(Hl(t,i))return!0;return Gl(t,e)}function Bl(t,e,i){return!!Hl(t,e)||Vl(e,t,i)}function Nl(t,e){if(1===t.length)return Wl(e,t[0]);for(let i of e)for(let e of i)if(Hl(t,e))return!0;for(let i of t)if(Wl(e,i))return!0;for(let i of e)if(Gl(t,i))return!0;return!1}function Ul(t,e,i){if(t.length>1){if(Gl(t,e))return!0;for(let r of e)if(Vl(r,t,i))return!0}for(let r of t)if(Vl(r,e,i))return!0;return!1}function Gl(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){let r=t[i],s=t[i+1];for(let t=0;t<e.length-1;t++)if(ql(r,s,e[t],e[t+1]))return!0}return!1}function ql(t,e,i,r){return Rt(t,i,r)!==Rt(e,i,r)&&Rt(t,e,i)!==Rt(t,e,r)}function Vl(t,e,i){let r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(Zl(t,e[i-1],e[i])<r)return!0;return!1}function Zl(t,e,i){let r=e.distSqr(i);if(0===r)return t.distSqr(e);let s=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function Wl(t,e){let i,r,s,n=!1;for(let o of t){i=o;for(let t=0,o=i.length-1;t<i.length;o=t++)r=i[t],s=i[o],r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n}function Hl(t,e){let i=!1;for(let r=0,s=t.length-1;r<t.length;s=r++){let n=t[r],o=t[s];n.y>e.y!=o.y>e.y&&e.x<(o.x-n.x)*(e.y-n.y)/(o.y-n.y)+n.x&&(i=!i)}return i}function Yl(t,e,i,r,s){for(let n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&s>=n.y)return!0;let n=[new l(e,i),new l(e,s),new l(r,s),new l(r,i)];if(t.length>2)for(let e of n)if(Hl(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Xl(t[e],t[e+1],n))return!0;return!1}function Xl(t,e,i){let r=i[0],s=i[2];if(t.x<r.x&&e.x<r.x||t.x>s.x&&e.x>s.x||t.y<r.y&&e.y<r.y||t.y>s.y&&e.y>s.y)return!1;let n=Rt(t,e,i[0]);return n!==Rt(t,e,i[1])||n!==Rt(t,e,i[2])||n!==Rt(t,e,i[3])}function Jl(t,e,i){let r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Kl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ql(t,e,i,r,s){if(!e[0]&&!e[1])return t;let n=l.convert(e)._mult(s);"viewport"===i&&n._rotate(-r);let o=[];for(let e of t)o.push(e.sub(n));return o}function th(t){let e=[];for(let i=0;i<t.length;i++){let r=t[i],s=e.at(-1);(0===i||s&&!r.equals(s))&&e.push(r)}return e}function eh({queryGeometry:t,size:e},i){return Bl(t,i,e)}function ih({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s},n){return Bl(t,n,e*(i.projectTileCoordinates(n.x,n.y,r,s).signedDistanceFromCamera/i.cameraToCenterDistance))}function rh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s},n){let o=i.projectTileCoordinates(n.x,n.y,r,s).signedDistanceFromCamera,a=e*(i.cameraToCenterDistance/o);return Bl(t,oh(n,i,r,s),a)}function sh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s},n){return Bl(t,oh(n,i,r,s),e)}function nh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s,pitchAlignment:n="map",pitchScale:o="map"},a){let l="map"===n?"map"===o?eh:ih:"map"===o?rh:sh,h={queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s};for(let t of a)for(let e of t)if(l(h,e))return!0;return!1}function oh(t,e,i,r){let s=e.projectTileCoordinates(t.x,t.y,i,r).point;return new l((.5*s.x+.5)*e.width,(.5*-s.y+.5)*e.height)}let ah,lh;so("CircleBucket",Ol,{omit:["layers"]});var hh={get paint(){return lh||=new Ro({"circle-radius":new Do(ye.paint_circle["circle-radius"],"circle-radius"),"circle-color":new Do(ye.paint_circle["circle-color"],"circle-color"),"circle-blur":new Do(ye.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new Do(ye.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new ko(ye.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new ko(ye.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new ko(ye.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new ko(ye.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new Do(ye.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new Do(ye.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new Do(ye.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return ah||=new Ro({"circle-sort-key":new Do(ye.layout_circle["circle-sort-key"],"circle-sort-key")})}},uh=class extends Bo{constructor(t,e){super(t,hh,e)}createBucket(t){return new Ol(t)}queryRadius(t){let e=t;return Jl("circle-radius",this,e)+Jl("circle-stroke-width",this,e)+Kl(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:s,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:a}){let l,h,u=Ql(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-s.bearingInRadians,n),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),f=this.paint.get("circle-pitch-scale"),p=this.paint.get("circle-pitch-alignment");return"map"===p?(l=u,h=c*n):(l=function(t,e,i,r){return t.map((t=>oh(t,e,i,r)))}(u,s,o,a),h=c),nh({queryGeometry:l,size:h,transform:s,unwrappedTileID:o,getElevation:a,pitchAlignment:p,pitchScale:f},r)}},ch=class extends Ol{};let fh;so("HeatmapBucket",ch,{omit:["layers"]});var ph={get paint(){return fh||=new Ro({"heatmap-radius":new Do(ye.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new Do(ye.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new ko(ye.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new jo(ye.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new ko(ye.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function dh(t,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw RangeError(`mismatched image size. expected: ${s.length} but got: ${e*i*r}`)}else s=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=s,t}function mh(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;let s=dh({},{width:e,height:i},r);_h(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=s.data}function _h(t,e,i,r,s,n){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.y>t.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw RangeError("out of range destination coordinates for image copy");let o=t.data,a=e.data;if(o===a)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<s.height;l++){let h=((i.y+l)*t.width+i.x)*n,u=((r.y+l)*e.width+r.x)*n;for(let t=0;t<s.width*n;t++)a[u+t]=o[h+t]}return e}var gh=class t{constructor(t,e){dh(this,t,1,e)}resize(t){mh(this,t,1)}clone(){return new t({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){_h(t,e,i,r,s,1)}},yh=class t{constructor(t,e){dh(this,t,4,e)}resize(t){mh(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new t({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){_h(t,e,i,r,s,4)}setPixel(t,e,i){let r=4*(t*this.width+e);this.data[r+0]=Math.round(255*i.r/i.a),this.data[r+1]=Math.round(255*i.g/i.a),this.data[r+2]=Math.round(255*i.b/i.a),this.data[r+3]=Math.round(255*i.a)}};function vh(t){let e=new Uint8Array(t.length);for(let i=0;i<t.length;i+=4){let r=t[i+3];e[i+0]=Math.round(t[i+0]*r/255),e[i+1]=Math.round(t[i+1]*r/255),e[i+2]=Math.round(t[i+2]*r/255),e[i+3]=r}return e}function wh(t){let e={},i=t.resolution||256,r=t.clips?t.clips.length:1,s=t.image||new yh({width:i,height:r});if(!function(t){return Math.log(t)/Math.LN2%1==0}(i))throw Error(`width is not a power of 2 - ${i}`);let n=(r,n,o)=>{e[t.evaluationKey]=o;let a=t.expression.evaluate(e);s.setPixel(r/4/i,n/4,a)};if(t.clips)for(let e=0,s=0;e<r;++e,s+=4*i)for(let r=0,o=0;r<i;r++,o+=4){let a=r/(i-1),{start:l,end:h}=t.clips[e];n(s,o,l*(1-a)+h*a)}else for(let t=0,e=0;t<i;t++,e+=4)n(0,e,t/(i-1));return s}so("AlphaImage",gh),so("RGBAImage",yh);const bh="big-fb";var xh=class extends Bo{createBucket(t){return new ch(t)}constructor(t,e){super(t,ph,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=wh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(bh)}queryRadius(t){return Jl("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:s,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:a}){return nh({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(e,i)*n,transform:s,unwrappedTileID:o,getElevation:a},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}};let Mh;var zh={get paint(){return Mh||=new Ro({"hillshade-illumination-direction":new ko(ye.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new ko(ye.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new ko(ye.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new ko(ye.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new ko(ye.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new ko(ye.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new ko(ye.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new ko(ye.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new ko(ye.paint_hillshade.resampling,"resampling")})}},Sh=class extends Bo{constructor(t,e){super(t,zh,e),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,e=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values,s=Math.max(t.length,e.length,i.length,r.length);t=t.concat(Array(s-t.length).fill(t.at(-1))),e=e.concat(Array(s-e.length).fill(e.at(-1))),i=i.concat(Array(s-i.length).fill(i.at(-1))),r=r.concat(Array(s-r.length).fill(r.at(-1)));let n=e.map(qt);return{directionRadians:t.map(qt),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}};let Th;var Eh={get paint(){return Th||=new Ro({"color-relief-opacity":new ko(ye["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new jo(ye["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new ko(ye["paint_color-relief"].resampling,"resampling")})}};function Ah(t){return"data"in t}var Ph=class{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(e,r)}update(t,e,i){let{width:r,height:s}=t,n=(this.size?.[0]!==r||this.size[1]!==s)&&!i,{context:o}=this,{gl:a}=o;this.useMipmap=!!e?.useMipmap,n&&this.size&&this.format===a.RGBA&&(a.deleteTexture(this.texture),this.texture=a.createTexture(),this._ownedHandle=this.texture),a.bindTexture(a.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let l=this.format===a.RGBA&&!1!==e?.premultiply;if(n)if(this.size=[r,s],this.format===a.RGBA&&r>0&&s>0){let e=this.useMipmap?Math.floor(Math.log2(Math.max(r,s)))+1:1;if(a.texStorage2D(a.TEXTURE_2D,e,a.RGBA8,r,s),Ah(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:e}=t;l&&e&&(e=vh(e)),e&&a.texSubImage2D(a.TEXTURE_2D,0,0,0,r,s,a.RGBA,a.UNSIGNED_BYTE,e)}else o.pixelStoreUnpackPremultiplyAlpha.set(l),a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,t)}else Ah(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,l,r,s,a)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(t,a));else{let{x:e,y:n}=i||{x:0,y:0};Ah(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,l,e,n,r,s,a)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(t,e,n,a))}this.useMipmap&&a.generateMipmap(a.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,e){e.texImage2D(e.TEXTURE_2D,0,this.format,this.format,e.UNSIGNED_BYTE,t)}_uploadRawData(t,e,i,r,s){let{data:n}=t;e&&n&&(n=vh(n)),s.texImage2D(s.TEXTURE_2D,0,this.format,i,r,0,this.format,s.UNSIGNED_BYTE,n)}_updateDomImage(t,e,i,r){r.texSubImage2D(r.TEXTURE_2D,0,e,i,r.RGBA,r.UNSIGNED_BYTE,t)}_updateRawData(t,e,i,r,s,n,o){let{data:a}=t;e&&a&&(a=vh(a)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,s,n,o.RGBA,o.UNSIGNED_BYTE,a)}bind(t,e,i){let{context:r}=this,{gl:s}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),s.bindTexture(s.TEXTURE_2D,this.texture),i===s.LINEAR_MIPMAP_NEAREST&&!this.useMipmap&&(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,e),this.wrap=e)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},Ih=class t{static{this.byteViewCache=new WeakMap}constructor(e,i,r,s=1,n=1,o=1,a=0){if(this.uid=e,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r))return void jt(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;let l=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),t.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=s,this.greenFactor=n,this.blueFactor=o,this.baseShift=a;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;t<l;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(l,t)]=this.data[this._idx(l-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,l)]=this.data[this._idx(t,l-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(l,-1)]=this.data[this._idx(l-1,0)],this.data[this._idx(-1,l)]=this.data[this._idx(0,l-1)],this.data[this._idx(l,l)]=this.data[this._idx(l-1,l-1)];let h=this._getByteView();this.min=2**53-1,this.max=-9007199254740991;for(let t=0;t<l;t++)for(let e=0;e<l;e++){let i=4*this._idx(t,e),r=this._unpackAtIndex(h,i);r>this.max&&(this.max=r),r<this.min&&(this.min=r)}}get(t,e){let i=this._getByteView(),r=4*this._idx(t,e);return this._unpackAtIndex(i,r)}sampleBilinear(t,e){let i=Math.floor(t),r=Math.floor(e);if(i<-1||i>=this.dim||r<-1||r>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);let s=this._getByteView(),n=4*((r+1)*this.stride+i+1),o=4*this.stride,a=t-i,l=e-r;return this._unpackAtIndex(s,n)*(1-a)*(1-l)+this._unpackAtIndex(s,n+4)*a*(1-l)+this._unpackAtIndex(s,n+o)*(1-a)*l+this._unpackAtIndex(s,n+o+4)*a*l}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);return(e+1)*this.stride+(t+1)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}pack(t){return Ch(t,this.getUnpackVector())}getPixels(){return new yh({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,e,i){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let r=e*this.dim,s=e*this.dim+this.dim,n=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:r=s-1;break;case 1:s=r+1}switch(i){case-1:n=o-1;break;case 1:o=n+1}let a=-e*this.dim,l=-i*this.dim;for(let e=n;e<o;e++)for(let i=r;i<s;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+a,e+l)]}_getByteView(){let e=t.byteViewCache.get(this);return e?.buffer!==this.data.buffer&&(e=new Uint8Array(this.data.buffer),t.byteViewCache.set(this,e)),e}_unpackAtIndex(t,e){return this.unpack(t[e],t[e+1],t[e+2])}};function Ch(t,e){let i=e[0],r=e[1],s=e[2],n=e[3],o=Math.min(i,r,s),a=Math.round((t+n)/o);return{r:Math.floor(a*o/i)%256,g:Math.floor(a*o/r)%256,b:Math.floor(a*o/s)%256}}so("DEMData",Ih);var kh=class extends Bo{constructor(t,e){super(t,Eh,e)}_createColorRamp(t){let e={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof Vs&&i._styleExpression.expression instanceof tr){this.colorRampExpression=i;let t=i._styleExpression.expression;e.elevationStops=t.labels,e.colorStops=[];for(let i of e.elevationStops)e.colorStops.push(t.evaluate({globals:{elevation:i}}))}if(e.elevationStops.length<1&&(e.elevationStops=[0],e.colorStops=[Si.transparent]),e.elevationStops.length<2&&(e.elevationStops.push(e.elevationStops[0]+1),e.colorStops.push(e.colorStops[0])),e.elevationStops.length<=t)return e;let r={elevationStops:[],colorStops:[]},s=(e.elevationStops.length-1)/(t-1);for(let t=0;t<e.elevationStops.length-.5;t+=s)r.elevationStops.push(e.elevationStops[Math.round(t)]),r.colorStops.push(e.colorStops[Math.round(t)]);return jt(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${e.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,e,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(e),s=new yh({width:r.colorStops.length,height:1}),n=new yh({width:r.colorStops.length,height:1});for(let t=0;t<r.elevationStops.length;t++){let e=Ch(r.elevationStops[t],i);n.setPixel(0,t,new Si(e.r/255,e.g/255,e.b/255,1)),s.setPixel(0,t,r.colorStops[t])}return this.colorRampTextures={elevationTexture:new Ph(t,n,t.gl.RGBA),colorTexture:new Ph(t,s,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const Dh=Ho([{name:"a_pos",components:2,type:"Int16"}],4).members;function Fh(t,e,i){let r=i.patternDependencies,s=!1;for(let i of e){let e=i.paint.get(`${t}-pattern`);e.isConstant()||(s=!0);let n=e.constantOr(null);n&&(s=!0,r[n.to]=!0,r[n.from]=!0)}return s}function $h(t,e,i,r,s){let{zoom:n}=r,o=s.patternDependencies;for(let r of e){let e=r.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:n-1},i,{},s.availableImages),a=e.evaluate({zoom:n},i,{},s.availableImages),l=e.evaluate({zoom:n+1},i,{},s.availableImages);t=t?.name?t.name:t,a=a?.name?a.name:a,l=l?.name?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,i.patterns[r.id]={min:t,mid:a,max:l}}}return i}const jh=new Set;let Rh=!1;function Oh(t,e,i,r,s){let n=null;if(s===function(t,e,i,r){let s=0;for(let n=e,o=i-r;n<i;n+=r)s+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return s}(t,e,i,r)>0)for(let s=e;s<i;s+=r)n=yu(s/r|0,t[s],t[s+1],n);else for(let s=i-r;s>=e;s-=r)n=yu(s/r|0,t[s],t[s+1],n);return n&&pu(n,n.next)&&(vu(n),n=n.next),n}function Lh(t,e=t){let i,r=e===t,s=t;do{i=!1,s===s.next||0!==jh.size&&jh.has(s)||!pu(s,s.next)&&0!==fu(s.prev,s,s.next)?(r||s!==e)&&(s=s.next,i=!r):((r||s===e)&&(e=s.prev),Rh=!0,vu(s),s=s.prev,i=!0)}while(i||s!==e);return e}function Bh(t,e,i,r,s){s&&function(t,e,i,r){let s=t,n=0;do{s.z=lu(s.x,s.y,e,i,r),iu[n++]=s,s=s.next}while(s!==t);!function(t){if(t<=32)for(let e=1;e<t;e++){let t=iu[e],i=t.z,r=e-1;for(;r>=0&&iu[r].z>i;)iu[r+1]=iu[r],r--;iu[r+1]=t}else{su.length<t&&(su=new Uint32Array(t),nu=new Uint32Array(t),ru=Array(t));for(let e=0;e<t;e++)su[e]=iu[e].z;au(t,iu,su,ru,nu,0),au(t,ru,nu,iu,su,8),au(t,iu,su,ru,nu,16),au(t,ru,nu,iu,su,24)}}(n);let o=null;for(let t=0;t<n;t++){let e=iu[t];e.prevZ=o,o&&(o.nextZ=e),o=e}o.nextZ=null}(t,i,r,s);let n=t,o=!1;for(;t.prev!==t.next;){let a=t.prev,l=t.next;if(fu(a,t,l)<0&&(s?Uh(t,i,r,s):Nh(t)))e.push(a.i,t.i,l.i),vu(t),t=l,n=l;else if((t=l)===n){if(Rh=!1,t=Lh(t),Rh){n=t;continue}if(!o){n=t=Gh(t,e),o=!0;continue}qh(t,e,i,r,s);break}}}function Nh(t){let e=t.prev,i=t.next,r=e.x,s=t.x,n=i.x,o=e.y,a=t.y,l=i.y,h=Math.min(r,s,n),u=Math.min(o,a,l),c=Math.max(r,s,n),f=Math.max(o,a,l),p=i.next;for(;p!==e;){if(p.x>=h&&p.x<=c&&p.y>=u&&p.y<=f&&(r!==p.x||o!==p.y)&&uu(r,o,s,a,n,l,p.x,p.y)&&fu(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Uh(t,e,i,r){let s=t.prev,n=t.next,o=s.x,a=t.x,l=n.x,h=s.y,u=t.y,c=n.y,f=Math.min(o,a,l),p=Math.min(h,u,c),d=Math.max(o,a,l),m=Math.max(h,u,c),_=lu(f,p,e,i,r),g=lu(d,m,e,i,r),y=t.prevZ;for(;y&&y.z>=_;){if(y.x>=f&&y.x<=d&&y.y>=p&&y.y<=m&&y!==n&&(o!==y.x||h!==y.y)&&uu(o,h,a,u,l,c,y.x,y.y)&&fu(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let v=t.nextZ;for(;v&&v.z<=g;){if(v.x>=f&&v.x<=d&&v.y>=p&&v.y<=m&&v!==n&&(o!==v.x||h!==v.y)&&uu(o,h,a,u,l,c,v.x,v.y)&&fu(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Gh(t,e){let i=t,r=!1;do{let s=i.prev,n=i.next.next;du(s,i,i.next,n,!1)&&_u(s,n)&&_u(n,s)&&(e.push(s.i,i.i,n.i),vu(i),vu(i.next),i=t=n,r=!0),i=i.next}while(i!==t);return r?Lh(i):i}function qh(t,e,i,r,s){let n=t;do{let t=n.next.next;for(;t!==n.prev;){if(n.i!==t.i&&cu(n,t)){let o=gu(n,t);return n=Lh(n,n.next),o=Lh(o,o.next),Bh(n,e,i,r,s),void Bh(o,e,i,r,s)}t=t.next}n=n.next}while(n!==t)}let Vh=!1;function Zh(t,e){return t.x-e.x||t.y-e.y||(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}function Wh(t,e){let i=function(t,e){let i,r=e,s=t.x,n=t.y,o=-1/0;if(pu(t,r))return r;for(let e=0,a=0;e<Yh;e++,a+=4){if(n<Hh[a+1]||n>Hh[a+3]||Hh[a]>s||Hh[a+2]<=o)continue;let l=Qh(e);r=tu(e);do{if(r.prev.next===r){if(pu(t,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let t=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=s&&t>o&&(o=t,i=r.x<r.next.x?r:r.next,t===s))return i}}r=r.next}while(r!==l)}if(!i)return null;let a=i.x,l=i.y,h=Math.min(n,l),u=Math.max(n,l),c=1/0;for(let e=0,f=0;e<Yh;e++,f+=4){if(Hh[f+2]<a||Hh[f]>s||Hh[f+3]<h||Hh[f+1]>u)continue;let p=Qh(e);r=tu(e);do{if(r.prev.next===r&&s>=r.x&&r.x>=a&&s!==r.x&&uu(n<l?s:o,n,a,l,n<l?o:s,n,r.x,r.y)){let e=Math.abs(n-r.y)/(s-r.x);(_u(r,t)||r.y===n&&r.next.y===n&&r.next.x>s)&&(e<c||e===c&&(r.x>i.x||r.x===i.x&&eu(i,r)))&&(i=r,c=e)}r=r.next}while(r!==p)}return i}(t,e);if(!i)return e;let r=gu(i,t);return Kh(i,r.next.next),Lh(r,r.next),Lh(i,i.next)}let Hh=new Float64Array,Yh=0;const Xh=[],Jh=[];function Kh(t,e){let i=t;do{let t=Yh++;Xh[t]=i;let r=1/0,s=1/0,n=-1/0,o=-1/0,a=0;do{let e=i.next;i.z=t,i.x<r&&(r=i.x),i.x>n&&(n=i.x),i.y<s&&(s=i.y),i.y>o&&(o=i.y),e.x<r&&(r=e.x),e.x>n&&(n=e.x),e.y<s&&(s=e.y),e.y>o&&(o=e.y),i=e}while(++a<16&&i!==e);Jh[t]=i;let l=4*t;Hh[l]=r,Hh[l+1]=s,Hh[l+2]=n,Hh[l+3]=o}while(i!==e)}function Qh(t){let e=Jh[t];for(;e.prev.next!==e;)e=e.next;return Jh[t]=e,e}function tu(t){let e=Xh[t];for(;e.prev.next!==e;)e=e.next;return Xh[t]=e,e}function eu(t,e){return fu(t.prev,t,e.prev)<0&&fu(e.next,t,t.next)<0}const iu=[];let ru=[],su=new Uint32Array,nu=new Uint32Array;const ou=new Uint32Array(256);function au(t,e,i,r,s,n){ou.fill(0);for(let e=0;e<t;e++)ou[i[e]>>>n&255]++;let o=0;for(let t=0;t<256;t++){let e=ou[t];ou[t]=o,o+=e}for(let o=0;o<t;o++){let t=i[o],a=ou[t>>>n&255]++;r[a]=e[o],s[a]=t}}function lu(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function hu(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function uu(t,e,i,r,s,n,o,a){return(s-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(n-a)>=(s-o)*(r-a)}function cu(t,e){let i=pu(t,e)&&fu(t.prev,t,t.next)>0&&fu(e.prev,e,e.next)>0;return t.next.i!==e.i&&(i||_u(t,e)&&_u(e,t)&&(0!==fu(t.prev,t,e.prev)||0!==fu(t,e.prev,e)))&&!function(t,e){let i=Math.min(t.x,e.x),r=Math.max(t.x,e.x),s=Math.min(t.y,e.y),n=Math.max(t.y,e.y),o=t;do{let a=o.next;if(o.x>r&&a.x>r||o.x<i&&a.x<i||o.y>n&&a.y>n||o.y<s&&a.y<s)o=a;else{if(o.i!==t.i&&a.i!==t.i&&o.i!==e.i&&a.i!==e.i&&du(o,a,t,e))return!0;o=a}}while(o!==t);return!1}(t,e)&&(i||function(t,e){let i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{let t=i.next;i.y>n!=t.y>n&&s<(t.x-i.x)*(n-i.y)/(t.y-i.y)+i.x&&(r=!r),i=t}while(i!==t);return r}(t,e))}function fu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function pu(t,e){return t.x===e.x&&t.y===e.y}function du(t,e,i,r,s=!0){let n=fu(t,e,i),o=fu(t,e,r),a=fu(i,r,t),l=fu(i,r,e);return(n>0&&o<0||n<0&&o>0)&&(a>0&&l<0||a<0&&l>0)||!!s&&!!(0===n&&mu(t,i,e)||0===o&&mu(t,r,e)||0===a&&mu(i,t,r)||0===l&&mu(i,e,r))}function mu(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function _u(t,e){return fu(t.prev,t,t.next)<0?fu(t,e,t.next)>=0&&fu(t,t.prev,e)>=0:fu(t,e,t.prev)<0||fu(t,t.next,e)<0}function gu(t,e){let i=wu(t.i,t.x,t.y),r=wu(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function yu(t,e,i,r){let s=wu(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function vu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ),Vh&&function(t,e){let i=4*t.z;e.x<Hh[i]&&(Hh[i]=e.x),e.y<Hh[i+1]&&(Hh[i+1]=e.y),e.x>Hh[i+2]&&(Hh[i+2]=e.x),e.y>Hh[i+3]&&(Hh[i+3]=e.y)}(t.prev,t.next)}function wu(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var bu=class{constructor(t,e){if(e>t)throw Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}},xu=class t{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}static{this.noSubdivision=new t({fill:new bu(0,0),line:new bu(0,0),tile:new bu(0,0),stencil:new bu(0,0),circle:1})}};so("SubdivisionGranularityExpression",bu),so("SubdivisionGranularitySetting",xu);const Mu=-32768,zu=32767;var Su=class{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=et/t,this._canonical=e}_getKey(t,e){return(t+=32768)<<16|e+32768}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw Error("Vertex coordinates are out of signed 16 bit integer range.");let i=0|Math.round(t),r=0|Math.round(e),s=this._getKey(i,r);if(this._vertexDictionary.has(s))return this._vertexDictionary.get(s);let n=this._vertexBuffer.length/2;return this._vertexDictionary.set(s,n),this._vertexBuffer.push(i,r),n}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){let i=[];for(let r=0;r<e.length;r+=3){let s=e[r],n=e[r+1],o=e[r+2],a=t[2*s],l=t[2*s+1];(t[2*n]-a)*(t[2*o+1]-l)-(t[2*n+1]-l)*(t[2*o]-a)>0?(i.push(s),i.push(o),i.push(n)):(i.push(s),i.push(n),i.push(o))}return i}(this._vertexBuffer,t);let e=[],i=t.length;for(let r=0;r<i;r+=3){let i=[t[r+0],t[r+1],t[r+2]],s=[this._vertexBuffer[2*t[r+0]+0],this._vertexBuffer[2*t[r+0]+1],this._vertexBuffer[2*t[r+1]+0],this._vertexBuffer[2*t[r+1]+1],this._vertexBuffer[2*t[r+2]+0],this._vertexBuffer[2*t[r+2]+1]],n=1/0,o=1/0,a=-1/0,l=-1/0;for(let t=0;t<3;t++){let e=s[2*t],i=s[2*t+1];n=Math.min(n,e),a=Math.max(a,e),o=Math.min(o,i),l=Math.max(l,i)}if(n===a||o===l)continue;let h=Math.floor(n/this._granularityCellSize),u=Math.ceil(a/this._granularityCellSize),c=Math.floor(o/this._granularityCellSize),f=Math.ceil(l/this._granularityCellSize);if(h!==u||c!==f)for(let t=c;t<f;t++){let r=this._scanlineGenerateVertexRingForCellRow(t,s,i);Au(this._vertexBuffer,r,e)}else e.push(...i)}return e}_scanlineGenerateVertexRingForCellRow(t,e,i){let r=t*this._granularityCellSize,s=r+this._granularityCellSize,n=[];for(let t=0;t<3;t++){let o=e[2*t],a=e[2*t+1],l=e[2*(t+1)%6],h=e[(2*(t+1)+1)%6],u=e[2*(t+2)%6],c=e[(2*(t+2)+1)%6],f=l-o,p=h-a,d=0===f,m=0===p,_=(r-a)/p,g=(s-a)/p,y=Math.min(_,g),v=Math.max(_,g);if(!m&&(y>=1||v<=0)||m&&(a<r||a>s)){h>=r&&h<=s&&n.push(i[(t+1)%3]);continue}!m&&y>0&&n.push(this._vertexToIndex(o+f*y,a+p*y));let w=o+f*Math.max(y,0),b=o+f*Math.min(v,1);d||this._generateIntraEdgeVertices(n,o,a,l,h,w,b),!m&&v<1&&n.push(this._vertexToIndex(o+f*v,a+p*v)),(m||h>=r&&h<=s)&&n.push(i[(t+1)%3]),!m&&(h<=r||h>=s)&&this._generateInterEdgeVertices(n,o,a,l,h,u,c,b,r,s)}return n}_generateIntraEdgeVertices(t,e,i,r,s,n,o){let a=r-e,l=s-i,h=0===l,u=h?Math.min(e,r):Math.min(n,o),c=h?Math.max(e,r):Math.max(n,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(c/this._granularityCellSize)-1;if(h?e<r:n<o)for(let r=f;r<=p;r++){let s=r*this._granularityCellSize;t.push(this._vertexToIndex(s,i+l*(s-e)/a))}else for(let r=p;r>=f;r--){let s=r*this._granularityCellSize;t.push(this._vertexToIndex(s,i+l*(s-e)/a))}}_generateInterEdgeVertices(t,e,i,r,s,n,o,a,l,h){let u=s-i,c=n-r,f=o-s,p=(l-s)/f,d=(h-s)/f,m=Math.min(p,d),_=Math.max(p,d),g=r+c*m,y=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,w=a<g,b=0===f;if(b&&(o===l||o===h))return;if(b||m>=1||_<=0){let t=i-o,r=n+(e-n)*Math.min((l-o)/t,(h-o)/t);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,w=a<r}let x=u>0?h:l;if(w)for(let e=y;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,x));else for(let e=v;e>=y;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,x))}_generateOutline(t){let e=[];for(let i of t){let t=Eu(i,this._granularity,!0),r=this._pointArrayToIndices(t),s=[];for(let t=1;t<r.length;t++)s.push(r[t-1]),s.push(r[t]);e.push(s)}return e}_handlePoles(t){let e=!1,i=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(e||i)&&this._fillPoles(t,e,i)}_ensureNoPoleVertices(){let t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){let i=t[e+1];-32768===i&&(t[e+1]=-32767),32767===i&&(t[e+1]=32766)}}_generatePoleQuad(t,e,i,r,s,n){r>s==(-32768===n)?(t.push(i),t.push(e),t.push(this._vertexToIndex(r,n)),t.push(this._vertexToIndex(s,n)),t.push(i),t.push(this._vertexToIndex(r,n))):(t.push(e),t.push(i),t.push(this._vertexToIndex(r,n)),t.push(i),t.push(this._vertexToIndex(s,n)),t.push(this._vertexToIndex(r,n)))}_fillPoles(t,e,i){let r=this._vertexBuffer,s=et,n=t.length;for(let o=2;o<n;o+=3){let n=t[o-2],a=t[o-1],l=t[o],h=r[2*n],u=r[2*n+1],c=r[2*a],f=r[2*a+1],p=r[2*l],d=r[2*l+1];e&&(0===u&&0===f&&this._generatePoleQuad(t,n,a,h,c,Mu),0===f&&0===d&&this._generatePoleQuad(t,a,l,c,p,Mu),0===d&&0===u&&this._generatePoleQuad(t,l,n,p,h,Mu)),i&&(u===s&&f===s&&this._generatePoleQuad(t,n,a,h,c,zu),f===s&&d===s&&this._generatePoleQuad(t,a,l,c,p,zu),d===s&&u===s&&this._generatePoleQuad(t,l,n,p,h,zu))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let i,{flattened:r,holeIndices:s}=function(t){let e=[],i=[];for(let r of t)if(0!==r.length){r!==t[0]&&e.push(i.length/2);for(let t of r)i.push(t.x),i.push(t.y)}return{flattened:i,holeIndices:e}}(t);this._initializeVertices(r);try{let t=function(t,e,i=2){let r=e&&e.length,s=r?e[0]*i:t.length;jh.size&&jh.clear();let n=Oh(t,0,s,i,!0),o=[];if(!n||n.next===n.prev)return o;let a=0,l=0,h=0;if(r&&(n=function(t,e,i,r){let s=[];for(let i=0,n=e.length;i<n;i++){let o=Oh(t,e[i]*r,i<n-1?e[i+1]*r:t.length,r,!1);o===o.next&&jh.add(o),s.push(hu(o))}s.sort(Zh),function(t,e){let i=Math.ceil((t+2*e)/16)+e+2;Hh.length<4*i&&(Hh=new Float64Array(4*i)),Yh=0}(t.length/r,e.length),Kh(i,i),Vh=!0;for(let t=0;t<s.length;t++)i=Wh(s[t],i);return Vh=!1,Lh(i)}(t,e,n,i)),t.length>80*i){a=t[0],l=t[1];let e=a,r=l;for(let n=i;n<s;n+=i){let i=t[n],s=t[n+1];i<a&&(a=i),s<l&&(l=s),i>e&&(e=i),s>r&&(r=s)}h=Math.max(e-a,r-l),h=0===h?0:32767/h}return Bh(n,o,a,l,h),o}(r,s),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e)}catch(t){console.error(t)}let n=[];return e&&(n=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),this._granularity>=2&&0===this._canonical?.z&&(i=this._removeTrianglesOutsideTileX(i),n=n.map((t=>this._removeLinesOutsideTileX(t)))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:n}}_vertexOutsideTileX(t){let e=this._vertexBuffer[2*t];return e<0||e>8192}_removeTrianglesOutsideTileX(t){let e=[];for(let i=0;i<t.length;i+=3)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||this._vertexOutsideTileX(t[i+2])||e.push(t[i],t[i+1],t[i+2]);return e}_removeLinesOutsideTileX(t){let e=[];for(let i=0;i<t.length;i+=2)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||e.push(t[i],t[i+1]);return e}_convertIndices(t,e){let i=[];for(let r of e)i.push(this._vertexToIndex(t[2*r],t[2*r+1]));return i}_pointArrayToIndices(t){let e=[];for(let i of t)e.push(this._vertexToIndex(i.x,i.y));return e}};function Tu(t,e,i,r=!0){return new Su(i,e).subdividePolygonInternal(t,r)}function Eu(t,e,i=!1){if(!t||t.length<1||t.length<2)return[];let r=t[0],s=t[t.length-1],n=i&&(r.x!==s.x||r.y!==s.y);if(e<2)return n?[...t,t[0]]:[...t];let o=Math.floor(et/e),a=[];a.push(new l(t[0].x,t[0].y));let h=t.length,u=n?h:h-1;for(let e=0;e<u;e++){let i=t[e],r=e<h-1?t[e+1]:t[0],s=i.x,n=i.y,u=r.x,c=r.y,f=s!==u,p=n!==c;if(!f&&!p)continue;let d=u-s,m=c-n,_=Math.abs(d),g=Math.abs(m),y=s,v=n;for(;;){let t=d>0?(Math.floor(y/o)+1)*o:(Math.ceil(y/o)-1)*o,e=m>0?(Math.floor(v/o)+1)*o:(Math.ceil(v/o)-1)*o,i=Math.abs(y-t),r=Math.abs(v-e),s=Math.abs(y-u),n=Math.abs(v-c),h=f?i/_:1/0,w=p?r/g:1/0;if((s<=i||!f)&&(n<=r||!p))break;if(h<w&&f||!p){y=t,v+=m*h;let e=new l(y,Math.round(v));(a[a.length-1].x!==e.x||a[a.length-1].y!==e.y)&&a.push(e)}else{y+=d*w,v=e;let t=new l(Math.round(y),v);(a[a.length-1].x!==t.x||a[a.length-1].y!==t.y)&&a.push(t)}}let w=new l(u,c);(a[a.length-1].x!==w.x||a[a.length-1].y!==w.y)&&a.push(w)}return a}function Au(t,e,i){if(0===e.length)throw Error("Subdivision vertex ring is empty.");let r=0,s=t[2*e[0]];for(let i=1;i<e.length;i++){let n=t[2*e[i]];n<s&&(s=n,r=i)}let n=e.length,o=r,a=(o+1)%n;for(;;){let r=o-1>=0?o-1:n-1,s=(a+1)%n,l=t[2*e[r]],h=t[2*e[r]+1],u=t[2*e[s]],c=t[2*e[s]+1],f=t[2*e[o]],p=t[2*e[o]+1],d=t[2*e[a]],m=t[2*e[a]+1],_=!1;if(l<u)_=!0;else if(l>u)_=!1;else{let t=m-p,e=-(d-f),i=p<m?1:-1;((l-f)*t+(h-p)*e)*i>((u-f)*t+(c-p)*e)*i&&(_=!0)}if(_){let t=e[r],s=e[o],l=e[a];t!==s&&t!==l&&s!==l&&i.push(l,s,t),o--,o<0&&(o=n-1)}else{let t=e[s],r=e[o],l=e[a];t!==r&&t!==l&&r!==l&&i.push(l,r,t),a++,a>=n&&(a=0)}if(r===s)break}}function Pu(t,e,i,r,s,n,o,a,l){let h=s.length/2,u=o&&a&&l;if(h<Qa.MAX_VERTEX_ARRAY_LENGTH){let c,f,p=e.prepareSegment(h,i,r),d=p.vertexLength;for(let t=0;t<n.length;t+=3)r.emplaceBack(d+n[t],d+n[t+1],d+n[t+2]);p.vertexLength+=h,p.primitiveLength+=n.length/3,u&&(f=o.prepareSegment(h,i,a),c=f.vertexLength,f.vertexLength+=h);for(let e=0;e<s.length;e+=2)t(s[e],s[e+1]);if(u)for(let t of l){for(let e=1;e<t.length;e+=2)a.emplaceBack(c+t[e-1],c+t[e]);f.primitiveLength+=t.length/2}}else(function(t,e,i,r,s,n){let o=[];for(let t=0;t<r.length/2;t++)o.push(-1);let a={count:0},l=0,h=t.getOrCreateLatestSegment(e,i),u=h.vertexLength;for(let c=2;c<s.length;c+=3){let f=s[c-2],p=s[c-1],d=s[c],m=o[f]<l,_=o[p]<l,g=o[d]<l;h.vertexLength+(+!!m+ +!!_+ +!!g)>Qa.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,m=!0,_=!0,g=!0,u=0);let y=Iu(o,r,n,a,f,m,h),v=Iu(o,r,n,a,p,_,h),w=Iu(o,r,n,a,d,g,h);i.emplaceBack(u+y-l,u+v-l,u+w-l),h.primitiveLength++}})(e,i,r,s,n,t),u&&function(t,e,i,r,s,n){let o=[];for(let t=0;t<r.length/2;t++)o.push(-1);let a={count:0},l=0,h=t.getOrCreateLatestSegment(e,i),u=h.vertexLength;for(let c of s)for(let s=1;s<c.length;s+=2){let f=c[s-1],p=c[s],d=o[f]<l,m=o[p]<l;h.vertexLength+(+!!d+ +!!m)>Qa.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,d=!0,m=!0,u=0);let _=Iu(o,r,n,a,f,d,h),g=Iu(o,r,n,a,p,m,h);i.emplaceBack(u+_-l,u+g-l),h.primitiveLength++}}(o,i,a,s,l,t),e.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function Iu(t,e,i,r,s,n,o){if(n){let n=r.count;return i(e[2*s],e[2*s+1]),t[s]=r.count,r.count++,o.vertexLength++,n}return t[s]}var Cu=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new ja,this.indexArray=new Ya,this.indexArray2=new Xa,this.programConfigurations=new Il(t.layers,t.zoom),this.segments=new Qa,this.segments2=new Qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=Fh("fill",this.layers,e);let r=this.layers[0].layout.get("fill-sort-key"),s=!r.isConstant(),n=[],o=new wo(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of t){let t=$l(l,a);if(!this.layers[0]._featureFilter.filter(o,t,i))continue;let f=s?r.evaluate(t,{},i,e.availableImages):void 0,p={id:h,properties:l.properties,type:l.type,sourceLayerIndex:c,index:u,geometry:a?t.geometry:Fl(l),patterns:{},sortKey:f};n.push(p)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(let r of n){let{geometry:s,index:n,sourceLayerIndex:o}=r;if(this.hasDependencies){let t=$h("fill",this.layers,r,{zoom:this.zoom},e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{},e.subdivisionGranularity);e.featureIndex.insert(t[n].feature,s,n,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}addFeatures(t,e,i){for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Dh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,s,n){for(let t of Nr(e,500)){let e=Tu(t,r,n.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;Pu(((t,e)=>{i.emplaceBack(t,e)}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:s,canonical:r})}};let ku,Du;so("FillBucket",Cu,{omit:["layers","patternFeatures"]});var Fu={get paint(){return Du||=new Ro({"fill-antialias":new ko(ye.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new Do(ye.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new ko(ye.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new Do(ye.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new Do(ye.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new ko(ye.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new ko(ye.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new Fo(ye.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return ku||=new Ro({"fill-sort-key":new Do(ye.layout_fill["fill-sort-key"],"fill-sort-key")})}},$u=class extends Bo{constructor(t,e){super(t,Fu,e)}recalculate(t,e){super.recalculate(t,e);let i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Cu(t)}queryRadius(){return Kl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return Nl(Ql(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}};const ju=Ho([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ru=Ho([{name:"a_centroid",components:2,type:"Int16"}],4),Ou=ju.members;var Lu=class{constructor(t,e,i,r,s){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=s;t.pos<e;){let e=t.readVarint();if(8===e)this.id=t.readVarint();else if(18===e){let e=t.readVarint()+t.pos;for(;t.pos<e;){let e=r[t.readVarint()],i=s[t.readVarint()];this.properties[e]=i}}else 24===e?this.type=t.readVarint():(34===e&&(this._geometry=t.pos),t.skip(e))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let e,i=t.readVarint()+t.pos,r=[],s=1,n=0,o=0,a=0;for(;t.pos<i;){if(n<=0){let e=t.readVarint();if(s=7&e,n=e>>3,0===n)continue}if(n--,1===s)o+=t.readSVarint(),a+=t.readSVarint(),e&&r.push(e),e=[new l(o,a)];else if(2===s)o+=t.readSVarint(),a+=t.readSVarint(),e&&e.push(new l(o,a));else{if(7!==s)throw Error(`unknown command ${s}`);e&&e.push(e[0].clone())}}return e&&r.push(e),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let e=t.readVarint()+t.pos,i=1,r=0,s=0,n=0,o=1/0,a=-1/0,l=1/0,h=-1/0;for(;t.pos<e;){if(r<=0){let e=t.readVarint();if(i=7&e,r=e>>3,0===r)continue}if(r--,1===i||2===i)s+=t.readSVarint(),n+=t.readSVarint(),s<o&&(o=s),s>a&&(a=s),n<l&&(l=n),n>h&&(h=n);else if(7!==i)throw Error(`unknown command ${i}`)}return[o,l,a,h]}toGeoJSON(t,e,i){let r,s=this.extent*2**i,n=this.extent*t,o=this.extent*e,a=this.loadGeometry();function l(t){return[360*(t.x+n)/s-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+o)/s)*Math.PI))-90]}function h(t){return t.map(l)}if(1===this.type){let t=[];for(let e of a)t.push(e[0]);let e=h(t);r=1===t.length?{type:"Point",coordinates:e[0]}:{type:"MultiPoint",coordinates:e}}else if(2===this.type){let t=a.map(h);r=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}else{if(3!==this.type)throw Error("unknown feature type");{let t=Bu(a),e=[];for(let i of t)e.push(i.map(h));r=1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}}let u={type:"Feature",geometry:r,properties:this.properties};return null!=this.id&&(u.id=this.id),u}};function Bu(t){let e=t.length;if(e<=1)return[t];let i,r,s=[];for(let n=0;n<e;n++){let e=Nu(t[n]);0!==e&&(void 0===r&&(r=e<0),r===e<0?(i&&s.push(i),i=[t[n]]):i&&i.push(t[n]))}return i&&s.push(i),s}function Nu(t){let e=0;for(let i,r,s=0,n=t.length,o=n-1;s<n;o=s++)i=t[s],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}Lu.types=["Unknown","Point","LineString","Polygon"];var Uu=class{constructor(t,e){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],void 0===e&&(e=t.length);t.pos<e;){let e=t.readVarint();10===e?this.name=t.readString():18===e?(this._features.push(t.pos),t.skip(e)):26===e?this._keys.push(t.readString()):34===e?this._values.push(Gu(t)):40===e?this.extent=t.readVarint():120===e?this.version=t.readVarint():t.skip(e)}this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[t];let e=this._pbf.readVarint()+this._pbf.pos;return new Lu(this._pbf,e,this.extent,this._keys,this._values)}};function Gu(t){let e=null,i=t.readVarint()+t.pos;for(;t.pos<i;){let i=t.readVarint();e=10===i?t.readString():21===i?t.readFloat():25===i?t.readDouble():32===i?t.readVarint(!0):40===i?t.readVarint():48===i?t.readSVarint():56===i?t.readBoolean():(t.skip(i),null)}if(null==e)throw Error("unknown feature value");return e}var qu=class{constructor(t,e=t.length){let i=Object.create(null);for(;t.pos<e;){let e=t.readVarint();if(26===e){let e=new Uu(t,t.readVarint()+t.pos);e.length&&(i[e.name]=e)}else t.skip(e)}this.layers=i}};const Vu=6371008.8;var Zu=class t{constructor(t,e){if(isNaN(t)||isNaN(e))throw Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new t(Mt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let e=Math.PI/180,i=this.lat*e,r=t.lat*e,s=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Vu*Math.acos(Math.min(s,1))}static convert(e){if(e instanceof t)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new t(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&e)return new t(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};const Wu=2*Math.PI*Vu;function Hu(t){return Wu*Math.cos(t*Math.PI/180)}function Yu(t){return(180+t)/360}function Xu(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Ju(t,e){return t/Hu(e)}function Ku(t){return 360*t-180}function Qu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function tc(t,e){return t*Hu(Qu(e))}var ec=class t{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(e,i=0){let r=Zu.convert(e);return new t(Yu(r.lng),Xu(r.lat),Ju(i,r.lat))}toLngLat(){return new Zu(Ku(this.x),Qu(this.y))}toAltitude(){return tc(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Wu*function(t){return 1/Math.cos(t*Math.PI/180)}(Qu(this.y))}};const ic=89.25;function rc(t,e,i){let r=1/(1<<i.z);return new ec(t/et*r+i.x*r,e/et*r+i.y*r)}function sc(t,e){let i=xt(e.lat,-85.051129,Yt);return new l(Yu(e.lng)*t,Xu(i)*t)}function nc(t,e){return new ec(e.x/t,e.y/t).toLngLat()}function oc(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(qt(90-t.pitch)),Math.tan(qt(ic-t.pitch)))}function ac(t,e){let i=t.canonical,r=e/At(i.z),s=i.x+2**i.z*t.wrap,n=new Float64Array(16);return _(n),v(n,n,[s*r,i.y*r,0]),w(n,n,[r/et,r/et,1]),n}function lc(t,e,i,r,s){let n=ec.fromLngLat(t,e),o=s*Ju(1,t.lat),{x:a,y:l,z:h}=hc(i,r);return new ec(n.x+o*-a,n.y+o*-l,n.z+o*-h)}function hc(t,e){let i=qt(t),r=qt(e),s=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:s}}function uc(t,e,i){if(e<=0||!t||0===t.length)return t;let r=function(t,e){let i=function(t,e,i){return rc(4096,4096,i).toLngLat()}(0,0,e);return t*ec.fromLngLat(i).meterInMercatorCoordinateUnits()*((1<<e.z)*et)}(e,i);return t.map((t=>function(t,e){if(!t||t.length<3)return t;let i=t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y,r=i?t.length-1:t.length;if(r<3)return t;let s=t.map((t=>Z(t.x,t.y))),n=[];for(let t=0;t<r;t++)cc(n,s[(t-1+r)%r],s[t],s[(t+1)%r],e);return i&&n.length>0&&n.push(V(n[0])),n.map((t=>new l(t[0],t[1])))}(t,r)))}function cc(t,e,i,r,s){let n=Q(q(),e,i),o=Q(q(),r,i),a=Y(n),l=Y(o);if(a<1e-6||l<1e-6)return void t.push(V(i));W(n,n,1/a),W(o,o,1/l);let h=X(n,o);if(Math.abs(h)>Math.cos(5*Math.PI/180))return void t.push(V(i));let u=Math.min(s,.2*a,.2*l),c=H(q(),i,n,u),f=H(q(),i,o,u),p=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t}(q(),n,o);!function(t,e){var i=e[0],r=e[1],s=i*i+r*r;s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s}(p,p);let d=Math.sqrt((1+h)/2),m=H(q(),i,p,u/d),_=Q(q(),c,m),g=Q(q(),f,m),y=function(t,e){var i=t[0],r=t[1],s=e[0],n=e[1];return Math.abs(Math.atan2(r*s-i*n,i*s+r*n))}(_,g),v=Math.sign(_[0]*g[1]-_[1]*g[0]),w=Math.max(2,Math.ceil(y/(Math.PI/6)-1e-6));for(let e=0;e<=w;e++){let i=v*y*(e/w);t.push(J(q(),c,m,i))}}const fc=8192;function pc(t,e,i,r,s,n,o,a){t.emplaceBack(e,i,2*Math.floor(r*fc)+o,s*fc*2,n*fc*2,Math.round(a))}var dc=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Ra,this.centroidVertexArray=new ka,this.indexArray=new Ya,this.programConfigurations=new Il(t.layers,t.zoom),this.segments=new Qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasDependencies=Fh("fill-extrusion",this.layers,e);let r=new wo(this.zoom),s=this.layers[0],n=s.layout.get("fill-extrusion-rounded-corner-distance"),o=s._featureFilter.needGeometry;for(let{feature:a,id:l,index:h,sourceLayerIndex:u}of t){let t=$l(a,o);if(!s._featureFilter.filter(r,t,i))continue;let c=o?t.geometry:Fl(a),f={id:l,sourceLayerIndex:u,index:h,geometry:n>0?uc(c,n,i):c,properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push($h("fill-extrusion",this.layers,f,{zoom:this.zoom},e)):this.addFeature(f,f.geometry,h,i,{},e.subdivisionGranularity),e.featureIndex.insert(a,f.geometry,h,u,this.index,!0)}}addFeatures(t,e,i){for(let r of this.features){let{geometry:s}=r;this.addFeature(r,s,r.index,e,i,t.subdivisionGranularity)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ru.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,s,n){let o=this.layers[0],a=o.layout?o.layout.get("fill-extrusion-rounded-corner-distance"):0,l=a>0?uc(e,a,r):e;for(let e of Nr(l,500)){let i={x:0,y:0,sampleCount:0},s=this.layoutVertexArray.length;this.processPolygon(i,r,t,e,n);let o=this.layoutVertexArray.length-s,a=Math.floor(i.x/i.sampleCount),l=Math.floor(i.y/i.sampleCount);for(let t=0;t<o;t++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:s,canonical:r})}processPolygon(t,e,i,r,s){if(r.length<1||gc(r[0]))return;for(let e of r)0!==e.length&&mc(t,e);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=s.fill.getGranularityForZoomLevel(e.z),a="Polygon"===Lu.types[i.type];for(let t of r){if(0===t.length||gc(t))continue;let e=Eu(t,o,a);this._generateSideFaces(e,n)}if(!a)return;let l=Tu(r,e,o,!1),h=this.layoutVertexArray;Pu(((t,e)=>{pc(h,t,e,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let i=0;for(let r=1;r<t.length;r++){let s=t[r],n=t[r-1];if(_c(s,n))continue;e.segment.vertexLength+4>Qa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=s.sub(n)._perp()._unit(),a=n.dist(s);i+a>32768&&(i=0),pc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),pc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i),i+=a,pc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),pc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i);let l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}};function mc(t,e){for(let i=0;i<e.length;i++){let r=e[i];(i!==e.length-1||e[0].x!==r.x||e[0].y!==r.y)&&(t.x+=r.x,t.y+=r.y,t.sampleCount++)}}function _c(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}function gc(t){return t.every((t=>t.x<0))||t.every((t=>t.x>8192))||t.every((t=>t.y<0))||t.every((t=>t.y>8192))}let yc,vc;so("FillExtrusionBucket",dc,{omit:["layers","features"]});var wc={get paint(){return vc||=new Ro({"fill-extrusion-opacity":new ko(ye["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new Do(ye["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new ko(ye["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new ko(ye["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new Fo(ye["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new Do(ye["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new Do(ye["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new ko(ye["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return yc||=new Ro({"fill-extrusion-rounded-corner-distance":new ko(ye["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},bc=class extends Bo{constructor(t,e){super(t,wc,e)}createBucket(t){return new dc(t)}queryRadius(){return Kl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:s,pixelsToTileUnits:n,pixelPosMatrix:o}){let a=Ql(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-s.bearingInRadians,n),l=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=Sc(a,o,0),c=zc(r,h,l,o);return function(t,e,i){let r=1/0;Nl(i,e)&&(r=Mc(i,e[0]));for(let s=0;s<e.length;s++){let n=e[s],o=t[s];for(let t=0;t<n.length-1;t++){let e=n[t],s=[e,n[t+1],o[t+1],o[t],e];Ll(i,s)&&(r=Math.min(r,Mc(i,s)))}}return r!==1/0&&r}(c[0],c[1],u)}};function xc(t,e){return t.x*e.x+t.y*e.y}function Mc(t,e){if(1===t.length){let i,r=0,s=e[r++];for(;!i||s.equals(i);)if(i=e[r++],!i)return 1/0;for(;r<e.length;r++){let n=e[r],o=t[0],a=i.sub(s),l=n.sub(s),h=o.sub(s),u=xc(a,a),c=xc(a,l),f=xc(l,l),p=xc(h,a),d=xc(h,l),m=u*f-c*c,_=(f*p-c*d)/m,g=(u*d-c*p)/m,y=s.z*(1-_-g)+i.z*_+n.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(let i of e)t=Math.min(t,i.z);return t}}function zc(t,e,i,r){let s=[],n=[],o=r[8]*e,a=r[9]*e,h=r[10]*e,u=r[11]*e,c=r[8]*i,f=r[9]*i,p=r[10]*i,d=r[11]*i;for(let e of t){let t=[],i=[];for(let s of e){let e=s.x,n=s.y,m=r[0]*e+r[4]*n+r[12],_=r[1]*e+r[5]*n+r[13],g=r[2]*e+r[6]*n+r[14],y=r[3]*e+r[7]*n+r[15],v=g+h,w=y+u,b=m+c,x=_+f,M=g+p,z=y+d,S=new l((m+o)/w,(_+a)/w);S.z=v/w,t.push(S);let T=new l(b/z,x/z);T.z=M/z,i.push(T)}s.push(t),n.push(i)}return[s,n]}function Sc(t,e,i){let r=[];for(let s of t){let t=[s.x,s.y,i,1];N(t,t,e),r.push(new l(t[0]/t[3],t[1]/t[3]))}return r}const Tc=Ho([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4).members,Ec=Ho([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]).members,Ac=Math.cos(Math.PI/180*37.5);var Pc=class{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(let t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new Oa,this.layoutVertexArray2=new La,this.indexArray=new Ya,this.programConfigurations=new Il(t.layers,t.zoom),this.segments=new Qa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=Fh("line",this.layers,e)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),s=!r.isConstant(),n=[],o=new wo(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:l,index:h,sourceLayerIndex:u}of t){let t=$l(e,a);if(!this.layers[0]._featureFilter.filter(o,t,i))continue;let c=s?r.evaluate(t,{},i):void 0,f={id:l,properties:e.properties,type:e.type,sourceLayerIndex:u,index:h,geometry:a?t.geometry:Fl(e),patterns:{},dashes:{},sortKey:c};n.push(f)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(let r of n){let{geometry:s,index:n,sourceLayerIndex:o}=r;this.hasDependencies?(Fh("line",this.layers,e)?$h("line",this.layers,r,{zoom:this.zoom},e):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,e),this.patternFeatures.push(r)):this.addFeature(r,s,n,i,{},{},e.subdivisionGranularity),e.featureIndex.insert(t[n].feature,s,n,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures(t,e,i,r){for(let s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,e,i,r,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ec)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Tc),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.hasOwn(t.properties,"geojsonvt_clip_start")&&Object.hasOwn(t.properties,"geojsonvt_clip_end"))return{start:+t.properties.geojsonvt_clip_start,end:+t.properties.geojsonvt_clip_end}}addFeature(t,e,i,r,s,n,o){let a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),h=a.get("line-cap").evaluate(t,{}),u=a.get("line-miter-limit").evaluate(t,{}),c=a.get("line-round-limit").evaluate(t,{});this.lineClips=this.lineFeatureClips(t);for(let i of e)this.addLine(i,t,l,h,u,c,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:s,dashPositions:n,canonical:r})}addLine(t,e,i,r,s,n,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Eu(t,o?a.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let l="Polygon"===Lu.types[e.type],h=t.length;for(;h>=2&&t[h-1].equals(t[h-2]);)h--;let u=0;for(;u<h-1&&t[u].equals(t[u+1]);)u++;if(h-u<(l?3:2))return;"bevel"===i&&(s=1.05);let c,f,p,d,m,_=this.overscaling<=16?15*et/(512*this.overscaling):0,g=this.segments.prepareSegment(10*h,this.layoutVertexArray,this.indexArray);this.e1=this.e2=-1,l&&(c=t[h-2],m=t[u].sub(c)._unit()._perp());for(let e=u;e<h;e++){if(p=e===h-1?l?t[u+1]:void 0:t[e+1],p&&t[e].equals(p))continue;m&&(d=m),c&&(f=c),c=t[e],m=p?p.sub(c)._unit()._perp():d,d||=m;let o=d.add(m);(0!==o.x||0!==o.y)&&o._unit();let a=d.x*m.x+d.y*m.y,y=o.x*m.x+o.y*m.y,v=0===y?1/0:1/y,w=2*Math.sqrt(2-2*y),b=y<Ac&&f&&p,x=d.x*m.y-d.y*m.x>0;if(b&&e>u){let t=c.dist(f);if(t>2*_){let e=c.sub(c.sub(f)._mult(_/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,d,0,0,g),f=e}}let M=f&&p,z=M?i:l?"butt":r;if(M&&"round"===z&&(v<n?z="miter":v<=2&&(z="fakeround")),"miter"===z&&v>s&&(z="bevel"),"bevel"===z&&(v>2&&(z="flipbevel"),v<s&&(z="miter")),f&&this.updateDistance(f,c),"miter"===z)o._mult(v),this.addCurrentVertex(c,o,0,0,g);else if("flipbevel"===z){if(v>100)o=m.mult(-1);else{let t=v*d.add(m).mag()/d.sub(m).mag();o._perp()._mult(t*(x?-1:1))}this.addCurrentVertex(c,o,0,0,g),this.addCurrentVertex(c,o.mult(-1),0,0,g)}else if("bevel"===z||"fakeround"===z){let t=-Math.sqrt(v*v-1),e=x?t:0,i=x?0:t;if(f&&this.addCurrentVertex(c,d,e,i,g),"fakeround"===z){let t=Math.round(180*w/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){let t=i-.5;i+=i*t*(i-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*t*t+(.848013+a*(.215638*a-1.06021)))}let r=m.sub(d)._mult(i)._add(d)._unit()._mult(x?-1:1);this.addHalfVertex(c,r.x,r.y,!1,x,0,g)}}p&&this.addCurrentVertex(c,m,-e,-i,g)}else if("butt"===z)this.addCurrentVertex(c,o,0,0,g);else if("square"===z){let t=f?1:-1;this.addCurrentVertex(c,o,t,t,g)}else"round"===z&&(f&&(this.addCurrentVertex(c,d,0,0,g),this.addCurrentVertex(c,d,1,1,g,!0)),p&&(this.addCurrentVertex(c,m,-1,-1,g,!0),this.addCurrentVertex(c,m,0,0,g)));if(b&&e<h-1){let t=c.dist(p);if(t>2*_){let e=c.add(p.sub(c)._mult(_/t)._round());this.updateDistance(c,e),this.addCurrentVertex(e,m,0,0,g),c=e}}}}addCurrentVertex(t,e,i,r,s,n=!1){let o=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,s),this.addHalfVertex(t,o,a,n,!0,-r,s),this.distance>16384&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,s,n))}addHalfVertex({x:t,y:e},i,r,s,n,o,a){let l=.5*(this.lineClips?32767*this.scaledDistance:this.scaledDistance);this.layoutVertexArray.emplaceBack(+!!s+(t<<1),+!!n+(e<<1),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let h=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,h,this.e2),a.primitiveLength++),n?this.e2=h:this.e1=h}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}hasLineDasharray(t){for(let e of t){let t=e.paint.get("line-dasharray");if(t&&!t.isConstant())return!0}return!1}addLineDashDependencies(t,e,i,r){for(let s of t){let t=s.paint.get("line-dasharray");if(!t||"constant"===t.value.kind)continue;let n="round"===s.layout.get("line-cap").evaluate(e,{}),o={dasharray:t.value.evaluate({zoom:i-1},e,{}),round:n},a={dasharray:t.value.evaluate({zoom:i},e,{}),round:n},l={dasharray:t.value.evaluate({zoom:i+1},e,{}),round:n},h=`${o.dasharray.join(",")},${o.round}`,u=`${a.dasharray.join(",")},${a.round}`,c=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[h]=o,r.dashDependencies[u]=a,r.dashDependencies[c]=l,e.dashes[s.id]={min:h,mid:u,max:c}}}};let Ic,Cc;so("LineBucket",Pc,{omit:["layers","patternFeatures"]});var kc={get paint(){return Cc||=new Ro({"line-opacity":new Do(ye.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new ko(ye.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new Do(ye.paint_line["line-color"],"line-color"),"line-translate":new ko(ye.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new ko(ye.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new Do(ye.paint_line["line-width"],"line-width"),"line-gap-width":new Do(ye.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new Do(ye.paint_line["line-offset"],"line-offset"),"line-blur":new Do(ye.paint_line["line-blur"],"line-blur"),"line-dasharray":new Fo(ye.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new Fo(ye.paint_line["line-pattern"],"line-pattern"),"line-gradient":new jo(ye.paint_line["line-gradient"],"line-gradient")})},get layout(){return Ic||=new Ro({"line-cap":new Do(ye.layout_line["line-cap"],"line-cap"),"line-join":new Do(ye.layout_line["line-join"],"line-join"),"line-miter-limit":new Do(ye.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new Do(ye.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new Do(ye.layout_line["line-sort-key"],"line-sort-key")})}},Dc=class extends Do{possiblyEvaluate(t,e){return e=new wo(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=zt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}};let Fc;var $c=class extends Bo{constructor(t,e){super(t,kc,e),this.gradientVersion=0,Fc||(Fc=new Dc(kc.paint.properties["line-width"].specification,"line-floorwidth"),Fc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){let t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Qi,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Fc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Pc(t)}queryRadius(t){let e=t,i=jc(Jl("line-width",this,e),Jl("line-gap-width",this,e)),r=Jl("line-offset",this,e);return i/2+Math.abs(r)+Kl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:s,pixelsToTileUnits:n}){let o=Ql(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-s.bearingInRadians,n),a=n/2*jc(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),h=this.paint.get("line-offset").evaluate(e,i);return h&&(r=function(t,e){let i=[];for(let r of t){let t=th(r),s=[];for(let i=0;i<t.length;i++){let r=t[i],n=t[i-1],o=t[i+1],a=0===i?new l(0,0):r.sub(n)._unit()._perp(),h=i===t.length-1?new l(0,0):o.sub(r)._unit()._perp(),u=a._add(h)._unit(),c=u.x*h.x+u.y*h.y;0!==c&&u._mult(1/c),s.push(u._mult(e)._add(r))}i.push(s)}return i}(r,h*n)),function(t,e,i){for(let r of e){if(t.length>=3)for(let e of r)if(Hl(t,e))return!0;if(Ul(t,r,i))return!0}return!1}(o,r,a)}isTileClipped(){return!0}};function jc(t,e){return e>0?e+2*t:t}const Rc=Ho([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Oc=Ho([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ho([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Lc=Ho([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ho([{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 Bc=Ho([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Nc=Ho([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Uc(t,e,i){let r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),vo.applyArabicShaping&&(t=vo.applyArabicShaping(t)),t}function Gc(t,e,i){for(let r of t.sections)r.text=Uc(r.text,e,i);return t}Ho([{name:"triangle",components:3,type:"Uint16"}]),Ho([{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"}]),Ho([{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"}]),Ho([{type:"Float32",name:"offsetX"}]),Ho([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ho([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const qc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Vc=4294967296,Zc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var Wc=class{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(t,e,i=this.length){let r;for(;r=this.nextField(i);)t(r,e,this);return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){let t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Vc;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Vc;return this.pos+=8,t}readFloat(){let t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let e=this.buf,i=e[this.pos++];if(i<128)return i;let r,s=127&i;return r=e[this.pos++],s|=(127&r)<<7,r<128||(r=e[this.pos++],s|=(127&r)<<14,r<128)||(r=e[this.pos++],s|=(127&r)<<21,r<128)?s:(r=e[this.pos],s|=(15&r)<<28,function(t,e,i){let r,s,n=i.buf;if(s=n[i.pos++],r=(112&s)>>4,s<128||(s=n[i.pos++],r|=(127&s)<<3,s<128)||(s=n[i.pos++],r|=(127&s)<<10,s<128)||(s=n[i.pos++],r|=(127&s)<<17,s<128)||(s=n[i.pos++],r|=(127&s)<<24,s<128)||(s=n[i.pos++],r|=(1&s)<<31,s<128))return function(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}(t,r,e);throw Error("Expected varint not more than 10 bytes")}(s,t,this))}readSVarint(){let t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){let t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Zc?Zc.decode(this.buf.subarray(e,t)):function(t,e,i){let r="",s=e;for(;s<i;){let e,n,o,a=t[s],l=null,h=a>239?4:a>223?3:a>191?2:1;if(s+h>i)break;1===h?a<128&&(l=a):2===h?(e=t[s+1],128==(192&e)&&(l=(31&a)<<6|63&e,l<=127&&(l=null))):3===h?(e=t[s+1],n=t[s+2],128==(192&e)&&128==(192&n)&&(l=(15&a)<<12|(63&e)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(e=t[s+1],n=t[s+2],o=t[s+3],128==(192&e)&&128==(192&n)&&128==(192&o)&&(l=(15&a)<<18|(63&e)<<12|(63&n)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),s+=h}return r}(this.buf,e,t)}readBytes(){let t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}nextField(t=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=t)return 0;let e=this.readVarint();return this.type=7&e,this._valueStart=this.pos,e>>>3}skip(t){let e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw Error(`Unimplemented type: ${e}`);this.pos+=8}}};function Hc(t,e,i){1===t&&i.readMessage(Yc,e)}function Yc(t,e,i){if(3===t){let{id:t,bitmap:r,width:s,height:n,left:o,top:a,advance:l}=i.readMessage(Xc,{});e.push({id:t,bitmap:new gh({width:s+6,height:n+6},r),metrics:{width:s,height:n,left:o,top:a,advance:l}})}}function Xc(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Jc(t){let{userImage:e}=t;return!(!e?.render||!e.render()||(t.data.replace(new Uint8Array(e.data.buffer)),0))}function Kc(t){let e=0,i=0;for(let r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}],s=0,n=0;for(let e of t)for(let t=r.length-1;t>=0;t--){let i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===i.w&&e.h===i.h){let e=r.pop();e&&t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:s,h:n,fill:e/(s*n)||0}}var Qc=class{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:s,content:n,textFitWidth:o,textFitHeight:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=s,this.content=n,this.version=i,this.textFitWidth=o,this.textFitHeight=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}};so("ImagePosition",Qc),so("ImageAtlas",class{constructor(t,e){let i={},r={};this.haveRenderCallbacks=[];let s=[];this.addImages(t,i,s),this.addImages(e,r,s);let{w:n,h:o}=Kc(s),a=new yh({width:n||1,height:o||1});for(let e in t){let r=t[e],s=i[e].paddedRect;yh.copy(r.data,a,{x:0,y:0},{x:s.x+1,y:s.y+1},r.data)}for(let t in e){let i=e[t],s=r[t].paddedRect,n=s.x+1,o=s.y+1,l=i.data.width,h=i.data.height;yh.copy(i.data,a,{x:0,y:0},{x:n,y:o},i.data),yh.copy(i.data,a,{x:0,y:h-1},{x:n,y:o-1},{width:l,height:1}),yh.copy(i.data,a,{x:0,y:0},{x:n,y:o+h},{width:l,height:1}),yh.copy(i.data,a,{x:l-1,y:0},{x:n-1,y:o},{width:1,height:h}),yh.copy(i.data,a,{x:0,y:0},{x:n+l,y:o},{width:1,height:h})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(let r in t){let s=t[r],n={x:0,y:0,w:s.data.width+2,h:s.data.height+2};i.push(n),e[r]=new Qc(n,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e||t.version===e.version)return;t.version=e.version;let[r,s]=t.tl;i.update(e.data,void 0,{x:r,y:s})}});var tf=function(t){return t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly",t}(tf||{});function ef(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function rf(t,e){let{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new wo(t+1))};if("source"===i.kind)return{kind:"source"};{let{zoomStops:e,interpolationType:r}=i,s=0;for(;s<e.length&&e[s]<=t;)s++;s=Math.max(0,s-1);let n=s;for(;n<e.length&&e[n]<t+1;)n++;n=Math.min(e.length-1,n);let o=e[s],a=e[n];return"composite"===i.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:o,maxZoom:a,minSize:i.evaluate(new wo(o)),maxSize:i.evaluate(new wo(a)),interpolationType:r}}}function sf(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return"source"===t.kind?r/128:"composite"===t.kind?ir.number(r/128,s/128,i):e}function nf(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){let{interpolationType:s,minZoom:n,maxZoom:o}=t,a=s?xt(tr.interpolationFactor(s,e,n,o),0,1):0;"camera"===t.kind?r=ir.number(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}}function of(t,e,i){let r="never",s=t.get(e);return s?r=s:t.get(i)&&(r="always"),r}const af=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lf(t,e,i,r,s,n,o,a,l,h,u,c,f){let p=a?Math.min(32640,Math.round(a[0])):0,d=a?Math.min(32640,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*s),n,o,+!!l+(p<<1),d,16*h,16*u,256*c,256*f)}function hf(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function uf(t){for(let e of t.sections)if(yo(e.text))return!0;return!1}var cf=class{constructor(t){this.layoutVertexArray=new Ua,this.indexArray=new Ya,this.programConfigurations=t,this.segments=new Qa,this.dynamicLayoutVertexArray=new Ga,this.opacityVertexArray=new qa,this.hasVisibleVertices=!1,this.placedSymbolArray=new Ma}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Rc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Oc.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,af,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}};so("SymbolBuffers",cf);var ff=class{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new Qa,this.collisionVertexArray=new Wa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Lc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};so("CollisionBuffers",ff);var pf=class{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];let e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=rf(this.zoom,e["text-size"]),this.iconSizeData=rf(this.zoom,e["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),s=i.get("symbol-z-order");this.canOverlap="never"!==of(i,"text-overlap","text-allow-overlap")||"never"!==of(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((t=>tf[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new cf(new Il(this.layers,this.zoom,(t=>t.startsWith("text")))),this.icon=new cf(new Il(this.layers,this.zoom,(t=>t.startsWith("icon")))),this.glyphOffsetArray=new Ta,this.lineVertexArray=new Ea,this.symbolInstances=new Sa,this.textAnchorOffsets=new Pa}calculateGlyphDependencies(t,e,i,r,s){for(let n of t)if(e[n.codePointAt(0)]=!0,(i||r)&&s){let t=qc[n];t&&(e[t.codePointAt(0)]=!0)}}populate(t,e,i){let r=this.layers[0],s=r.layout,n=s.get("text-font"),o=s.get("text-field"),a=s.get("icon-image"),l=("constant"!==o.value.kind||o.value.value instanceof Pi&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&("constant"!==n.value.kind||n.value.value.length>0),h="constant"!==a.value.kind||!!a.value.value||Object.keys(a.parameters).length>0,u=s.get("symbol-sort-key");if(this.features=[],!l&&!h)return;let c=e.iconDependencies,f=e.glyphDependencies,p=e.availableImages,d=new wo(this.zoom);for(let{feature:e,id:o,index:a,sourceLayerIndex:m}of t){let t,_,g=r._featureFilter.needGeometry,y=$l(e,g);if(!r._featureFilter.filter(d,y,i))continue;if(g||(y.geometry=Fl(e)),l){let e=r.getValueAndResolveTokens("text-field",y,i,p),s=Pi.factory(e);this.hasRTLText||=uf(s),(!this.hasRTLText||"unavailable"===vo.getRTLTextPluginStatus()||this.hasRTLText&&vo.isParsed())&&(t=Gc(s,r,y))}if(h){let t=r.getValueAndResolveTokens("icon-image",y,i,p);_=t instanceof ji?t:ji.fromString(t)}if(!t&&!_)continue;let v=this.sortFeaturesByKey?u.evaluate(y,{},i):void 0;if(this.features.push({id:o,text:t,icon:_,index:a,sourceLayerIndex:m,geometry:y.geometry,properties:e.properties,type:Lu.types[e.type],sortKey:v}),_&&(c[_.name]=!0),t){let e=n.evaluate(y,{},i).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes?.includes(2);for(let i of t.sections)if(i.image)c[i.image.name]=!0;else{let s=fo(t.toString()),n=i.fontStack||e;f[n]||={},this.calculateGlyphDependencies(i.text,f[n],r,this.allowVerticalPlacement,s)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){let e={},i={},r=[],s=0;function n(e){r.push(t[e]),s++}function o(t,e,s){let n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(s[0]),n}function a(t,i,s){let n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=s[0].concat(r[n].geometry[0]),n}function l(t,e,i){let r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let h=0;h<t.length;h++){let u=t[h],c=u.geometry,f=u.text?u.text.toString():null;if(!f){n(h);continue}let p=l(f,c),d=l(f,c,!0);if(p in i&&d in e&&i[p]!==e[d]){let t=a(p,d,c),s=o(p,d,r[t].geometry);delete e[p],delete i[d],i[l(f,r[s].geometry,!0)]=s,r[t].geometry=null}else p in i?o(p,d,c):d in e?a(p,d,c):(n(h),e[p]=s-1,i[d]=s-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){let i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]),s={};for(let r=t.segment+1;r<e.length;r++)s[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)s[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){let e=s[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,s,n,o,a,l,h,u,c){let f=t.indexArray,p=t.layoutVertexArray,d=t.segments.prepareSegment(4*e.length,p,f,this.canOverlap?n.sortKey:void 0),m=this.glyphOffsetArray.length,_=d.vertexLength,g=this.allowVerticalPlacement&&2===o?Math.PI/2:0,y=n.text&&n.text.sections;for(let r=0;r<e.length;r++){let{tl:s,tr:o,bl:l,br:h,tex:u,pixelOffsetTL:m,pixelOffsetBR:_,minFontScaleX:v,minFontScaleY:w,glyphOffset:b,isSDF:x,sectionIndex:M}=e[r],z=d.vertexLength,S=b[1];lf(p,a.x,a.y,s.x,S+s.y,u.x,u.y,i,x,m.x,m.y,v,w),lf(p,a.x,a.y,o.x,S+o.y,u.x+u.w,u.y,i,x,_.x,m.y,v,w),lf(p,a.x,a.y,l.x,S+l.y,u.x,u.y+u.h,i,x,m.x,_.y,v,w),lf(p,a.x,a.y,h.x,S+h.y,u.x+u.w,u.y+u.h,i,x,_.x,_.y,v,w),hf(t.dynamicLayoutVertexArray,a,g),f.emplaceBack(z,z+2,z+1),f.emplaceBack(z+1,z+2,z+3),d.vertexLength+=4,d.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),(r===e.length-1||M!==e[r+1].sectionIndex)&&t.programConfigurations.populatePaintArrays(p.length,n,n.index,{imagePositions:{},canonical:c,formattedSection:y?.[M]})}t.placedSymbolArray.emplaceBack(a.x,a.y,m,this.glyphOffsetArray.length-m,_,l,h,a.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,u)}_addCollisionDebugVertex(t,e,i,r,s,n){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,s,Math.round(n.x),Math.round(n.y))}addCollisionDebugVertices(t,e,i,r,s,n,o){let a=s.segments.prepareSegment(4,s.layoutVertexArray,s.indexArray),h=a.vertexLength,u=s.layoutVertexArray,c=s.collisionVertexArray,f=o.anchorX,p=o.anchorY;this._addCollisionDebugVertex(u,c,n,f,p,new l(t,e)),this._addCollisionDebugVertex(u,c,n,f,p,new l(i,e)),this._addCollisionDebugVertex(u,c,n,f,p,new l(i,r)),this._addCollisionDebugVertex(u,c,n,f,p,new l(t,r)),a.vertexLength+=4;let d=s.indexArray;d.emplaceBack(h,h+1),d.emplaceBack(h+1,h+2),d.emplaceBack(h+2,h+3),d.emplaceBack(h+3,h),a.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let s=t;s<e;s++){let t=this.collisionBoxArray.get(s);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ff(Va,Bc.members,Xa),this.iconCollisionBox=new ff(Va,Bc.members,Xa);for(let t=0;t<this.symbolInstances.length;t++){let e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,r,s,n,o,a,l){let h={};for(let r=e;r<i;r++){let e=t.get(r);h.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},h.textFeatureIndex=e.featureIndex;break}for(let e=r;e<s;e++){let i=t.get(e);h.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},h.verticalTextFeatureIndex=i.featureIndex;break}for(let e=n;e<o;e++){let i=t.get(e);h.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},h.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<l;e++){let i=t.get(e);h.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},h.verticalIconFeatureIndex=i.featureIndex;break}return h}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){let i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){let i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+2,e+1),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;let e=Math.sin(t),i=Math.cos(t),r=[],s=[],n=[];for(let t=0;t<this.symbolInstances.length;++t){n.push(t);let o=this.symbolInstances.get(t);r.push(0|Math.round(e*o.anchorX+i*o.anchorY)),s.push(o.featureIndex)}return n.sort(((t,e)=>r[t]-r[e]||s[e]-s[t])),n}addToSortKeyRanges(t,e){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];i?.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let t of this.symbolInstanceIndexes){let e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);let i=[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex];for(let t=0;t<i.length;t++){let e=i[t];e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}};let df,mf;so("SymbolBucket",pf,{omit:["layers","collisionBoxArray","features","compareText"]}),pf.MAX_GLYPHS=65535,pf.addDynamicAttributes=hf;var _f={get paint(){return mf||=new Ro({"icon-opacity":new Do(ye.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new Do(ye.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new Do(ye.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new Do(ye.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new Do(ye.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new ko(ye.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new ko(ye.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new Do(ye.paint_symbol["text-opacity"],"text-opacity"),"text-color":new Do(ye.paint_symbol["text-color"],"text-color",{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Do(ye.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new Do(ye.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new Do(ye.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new ko(ye.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new ko(ye.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return df||=new Ro({"symbol-placement":new ko(ye.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new ko(ye.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new ko(ye.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new Do(ye.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new ko(ye.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new ko(ye.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new ko(ye.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new ko(ye.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new ko(ye.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new ko(ye.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new Do(ye.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new ko(ye.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new ko(ye.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new Do(ye.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new Do(ye.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new Do(ye.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new ko(ye.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new Do(ye.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new Do(ye.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new ko(ye.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new ko(ye.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new ko(ye.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new Do(ye.layout_symbol["text-field"],"text-field"),"text-font":new Do(ye.layout_symbol["text-font"],"text-font"),"text-size":new Do(ye.layout_symbol["text-size"],"text-size"),"text-max-width":new Do(ye.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new ko(ye.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new Do(ye.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new Do(ye.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new Do(ye.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new ko(ye.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new Do(ye.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new Do(ye.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new ko(ye.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new ko(ye.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new Do(ye.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new ko(ye.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new ko(ye.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new Do(ye.layout_symbol["text-transform"],"text-transform"),"text-offset":new Do(ye.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new ko(ye.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new ko(ye.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new ko(ye.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new ko(ye.layout_symbol["text-optional"],"text-optional")})}},gf=class{constructor(t){if(void 0===t.property.overrides)throw 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){let e=this.defaultValue.property.overrides;if(e?.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}};so("FormatSectionOverride",gf,{omit:["defaultValue"]});const yf=t=>"symbol"===t.type;var vf=class t extends Bo{constructor(t,e){super(t,_f,e)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"===this.layout.get("symbol-placement")?"viewport":"map"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"===this.layout.get("symbol-placement")?"viewport":"map"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){let t=this.layout.get("text-writing-mode");if(t){let e=[];for(let i of t)e.includes(i)||e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){let s=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||Gs(n.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,s)}createBucket(t){return new pf(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of _f.paint.overridableProperties){if(!t.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new Bs(new gf(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),s=null;s="constant"===i.value.kind||"source"===i.value.kind?new Vs("source",r):new Zs("composite",r,i.value.zoomStops),this.paint._values[e]=new Ao(i.property,s,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&t.hasPaintOverride(this.layout,e)}static hasPaintOverride(t,e){let i=t.get("text-field"),r=_f.paint.properties[e],s=!1,n=t=>{for(let e of t)if(r.overrides?.hasOverride(e))return void(s=!0)};if("constant"===i.value.kind&&i.value.value instanceof Pi)n(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let t=e=>{s||(e instanceof Ui&&Bi(e.value)===Ge?n(e.value.sections):e instanceof dr?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}};let wf;var bf={get paint(){return wf||=new Ro({"background-color":new ko(ye.paint_background["background-color"],"background-color"),"background-pattern":new $o(ye.paint_background["background-pattern"],"background-pattern"),"background-opacity":new ko(ye.paint_background["background-opacity"],"background-opacity")})}},xf=class extends Bo{constructor(t,e){super(t,bf,e)}},Mf=class extends Bo{constructor(t,e){super(t,{},e),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw Error("Custom layers cannot be serialized")}};function zf(t,e){if("custom"===t.type)return new Mf(t,e);switch(t.type){case"background":return new xf(t,e);case"circle":return new uh(t,e);case"color-relief":return new kh(t,e);case"fill":return new $u(t,e);case"fill-extrusion":return new bc(t,e);case"heatmap":return new xh(t,e);case"hillshade":return new Sh(t,e);case"line":return new $c(t,e);case"raster":return new qo(t,e);case"symbol":return new vf(t,e)}}var Sf=class{constructor(t){this._methodToThrottle=t,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const Tf={once:!0};var Ef=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Sf((()=>this.process())),this.subscription=Gt(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=Lt(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}unregisterMessageHandler(t){delete this.messageHandlers[t]}sendAsync(t,e){return new Promise(((i,r)=>{let s=Math.round(1e18*Math.random()).toString(36).substring(0,10),n=e?Gt(e.signal,"abort",(()=>{n?.unsubscribe(),delete this.resolveRejects[s];let i={id:s,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(i),r(new ie(e.signal.reason))}),Tf):null;this.resolveRejects[s]={resolve:t=>{n?.unsubscribe(),i(t)},reject:t=>{n?.unsubscribe(),r(t)}};let o=[],a={...t,id:s,sourceMapId:this.mapId,origin:location.origin,data:lo(t.data,o)};this.target.postMessage(a,{transfer:o})}))}receive(t){let e=t.data,i=e.id,r=["file://","resource://android","null"],s=[e.origin,location.origin],n=e.origin===location.origin,o=s.some((t=>r.includes(t)));if((n||o)&&(!e.targetMapId||this.mapId===e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[i];let t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(Lt(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(0===this.taskQueue.length)return;let t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}async processTask(t,e){if("<response>"===e.type){let i=this.resolveRejects[t];if(delete this.resolveRejects[t],!i)return;return void(e.error?i.reject(rt(ho(e.error))):i.resolve(ho(e.data)))}if(!this.messageHandlers[e.type])return void this.completeTask(t,null,null);let i=ho(e.data),r=new AbortController;this.abortControllers[t]=r;try{let s=await this.messageHandlers[e.type](e.sourceMapId,i,r);this.completeTask(t,null,s)}catch(e){this.completeTask(t,rt(e))}}completeTask(t,e,i){let r=[];delete this.abortControllers[t];let s={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?lo(e):null,data:lo(i,r)};this.target.postMessage(s,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function Af(t,e){let{x:i,y:r}=ec.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)}var Pf=class{constructor(t,e,i){if(!function(t,e,i){return!(t<0||t>25||i<0||i>=2**t||e<0||e>=2**t)}(t,e,i))throw Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${2**t}, 0<=y<${2**t} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=kf(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){let r=function(t,e,i){let r=Ff(256*t,256*(e=2**i-e-1),i),s=Ff(256*(t+1),256*(e+1),i);return`${r[0]},${r[1]},${s[0]},${s[1]}`}(this.x,this.y,this.z),s=function(t,e,i){let r="";for(let s=t;s>0;s--){let t=1<<s-1;r+=(e&t?1:0)+(i&t?2:0)}return r}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,s).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){let e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){let e=2**this.z;return new l((t.x*e-this.x)*et,(t.y*e-this.y)*et)}toString(){return`${this.z}/${this.x}/${this.y}`}},If=class{constructor(t,e){this.wrap=t,this.canonical=e,this.key=kf(t,e.z,e.z,e.x,e.y)}},Cf=class t{constructor(t,e,i,r,s){if(this.terrainRttPosMatrix32f=null,t<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Pf(i,+r,+s),this.key=kf(e,t,i,r,s)}clone(){return new t(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(e){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-e;return e>this.canonical.z?new t(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new t(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,e){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-t;return t>this.canonical.z?kf(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):kf(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(0===t.overscaledZ)return this.overscaledZ>0;let e=this.canonical.z-t.canonical.z;return!(e<0)&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(e){if(this.overscaledZ>=e)return[new t(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=2*this.canonical.x,s=2*this.canonical.y;return[new t(i,this.wrap,i,r,s),new t(i,this.wrap,i,r+1,s),new t(i,this.wrap,i,r,s+1),new t(i,this.wrap,i,r+1,s+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new t(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new t(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new If(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new ec(t.x-this.wrap,t.y))}normalizeCoordinates(e,i,r=et){if(e>=0&&e<r&&i>=0&&i<r)return{tileID:this,x:e,y:i};let s=Math.floor(e/r),n=Math.floor(i/r),o=e-s*r,a=i-n*r,l=this.canonical.z,h=1<<l,u=this.canonical.y+n;if(u<0||u>=h)return null;let c=this.canonical.x+s,f=this.wrap;return c<0?(f-=Math.ceil(-c/h),c=(c%h+h)%h):c>=h&&(f+=Math.floor(c/h),c%=h),{tileID:new t(this.overscaledZ,f,l,c,u),x:o,y:a}}};function kf(t,e,i,r,s){(t*=2)<0&&(t=-1*t-1);let n=1<<i;return(n*n*t+n*s+r).toString(36)+i.toString(36)+e.toString(36)}const Df=6378137*Math.PI;function Ff(t,e,i){let r=2*Df/256/2**i;return[t*r-Df,e*r-Df]}function $f(t,e){let i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}so("CanonicalTileID",Pf),so("OverscaledTileID",Cf,{omit:["terrainRttPosMatrix32f"]});var jf=class t{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(e){let i=new t;return i.extend(e(new l(this.minX,this.minY))),i.extend(e(new l(this.maxX,this.minY))),i.extend(e(new l(this.minX,this.maxY))),i.extend(e(new l(this.maxX,this.maxY))),i}static fromPoints(e){let i=new t;for(let t of e)i.extend(t);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 Rf="_geojsonTileLayer";var Of=class{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){let i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}},Lf=class{constructor(t,e,i,r,s){this.type="Feature",this._vectorTileFeature=t,this._x=i,this._y=r,this._z=e;for(let e in t.properties)"string"!=typeof t.properties[e]||!t.properties[e].startsWith("__$json__:")||(t.properties[e]=JSON.parse(t.properties[e].slice(10)));this.properties=t.properties,this.id=s}projectPoint(t,e,i,r){return[360*(t.x+e)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+i)/r)*Math.PI))-90]}projectLine(t,e,i,r){return t.map((t=>this.projectPoint(t,e,i,r)))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,e=t.extent*2**this._z,i=t.extent*this._x,r=t.extent*this._y,s=t.loadGeometry();switch(t.type){case 1:{let t=[];for(let e of s)t.push(e[0]);let n=this.projectLine(t,i,r,e);this._geometry=1===t.length?{type:"Point",coordinates:n[0]}:{type:"MultiPoint",coordinates:n};break}case 2:{let t=s.map((t=>this.projectLine(t,i,r,e)));this._geometry=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t};break}case 3:{let t=Bu(s),n=[];for(let s of t)n.push(s.map((t=>this.projectLine(t,i,r,e))));this._geometry=1===n.length?{type:"Polygon",coordinates:n[0]}:{type:"MultiPolygon",coordinates:n};break}default:throw Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&"_x"!==e&&"_y"!==e&&"_z"!==e&&(t[e]=this[e]);return t}},Bf=class{constructor(t,e,i){this._name=t,this.dataBuffer=e,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(t){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(t)?null:this.getValueFromBuffer(t)}has(t){return this.nullabilityBuffer?.get(t)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}},Nf=class extends Bf{},Uf=class extends Nf{getValueFromBuffer(t){return this.dataBuffer[t]}},Gf=class extends Nf{getValueFromBuffer(t){return this.dataBuffer[t]}},qf=class extends Bf{constructor(t,e,i,r){super(t,e,r),this.delta=i}},Vf=class extends qf{constructor(t,e,i,r){super(t,Int32Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}},Zf=class extends Bf{constructor(t,e,i,r){super(t,r?Int32Array.of(e):Uint32Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}},Wf=class{constructor(t,e,i,r,s=4096){if(this._name=t,this._geometryVector=e,this._idVector=i,this._propertyVectors=r,this._extent=s,0===t.length)throw Error("Missing layer name")}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||=new Map(this._propertyVectors.map((t=>[t.name,t]))),this.propertyVectorsMap.get(t)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){let t=[],e=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;if(this.idVector){let t=this.idVector.getValue(i);r=this.containsMaxSafeIntegerValues(this.idVector)&&null!==t?Number(t):t}let s={coordinates:e[i],type:this.geometryVector.geometryType(i)},n={};for(let t of this.propertyVectors){if(!t)continue;let e=t.name,r=t.getValue(i);null!==r&&(n[e]=r)}t.push({id:r,geometry:s,properties:n})}return t}containsMaxSafeIntegerValues(t){return t instanceof Uf||t instanceof Zf||t instanceof Vf||t instanceof Gf}};var Hf,Yf,Xf=class{constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}increment(){return this.value++}add(t){this.value+=t}};!function(t){t.NONE="NONE",t.DELTA="DELTA",t.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",t.RLE="RLE",t.MORTON="MORTON",t.PDE="PDE"}(Hf||={}),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT"}(Yf||={});const Jf=new Uint32Array(33);Jf[0]=0;for(let t=1;t<=32;t++)Jf[t]=32===t?4294967295:4294967295>>>32-t;const Kf=Jf;function Qf(t,e){return t-t%e}function tp(t){return Qf(t+31,32)}function ep(t){let e=t>>>0;return((255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255)>>>0}const ip=function(t){if(!Number.isFinite(t))return 65536;let e=Qf(Math.floor(t),256);return 0===e?256:e}(65536),rp=3*ip/256+ip|0;function sp(){let t=new Uint8Array(rp);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:t,byteContainerI32:new Int32Array(t.buffer,t.byteOffset,t.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function np(t,e,i,r,s){switch(s){case 1:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0;i[s++]=e>>>0&1,i[s++]=e>>>1&1,i[s++]=e>>>2&1,i[s++]=e>>>3&1,i[s++]=e>>>4&1,i[s++]=e>>>5&1,i[s++]=e>>>6&1,i[s++]=e>>>7&1,i[s++]=e>>>8&1,i[s++]=e>>>9&1,i[s++]=e>>>10&1,i[s++]=e>>>11&1,i[s++]=e>>>12&1,i[s++]=e>>>13&1,i[s++]=e>>>14&1,i[s++]=e>>>15&1,i[s++]=e>>>16&1,i[s++]=e>>>17&1,i[s++]=e>>>18&1,i[s++]=e>>>19&1,i[s++]=e>>>20&1,i[s++]=e>>>21&1,i[s++]=e>>>22&1,i[s++]=e>>>23&1,i[s++]=e>>>24&1,i[s++]=e>>>25&1,i[s++]=e>>>26&1,i[s++]=e>>>27&1,i[s++]=e>>>28&1,i[s++]=e>>>29&1,i[s++]=e>>>30&1,i[s++]=e>>>31&1}}(t,e,i,r);break;case 2:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0;i[s++]=e>>>0&3,i[s++]=e>>>2&3,i[s++]=e>>>4&3,i[s++]=e>>>6&3,i[s++]=e>>>8&3,i[s++]=e>>>10&3,i[s++]=e>>>12&3,i[s++]=e>>>14&3,i[s++]=e>>>16&3,i[s++]=e>>>18&3,i[s++]=e>>>20&3,i[s++]=e>>>22&3,i[s++]=e>>>24&3,i[s++]=e>>>26&3,i[s++]=e>>>28&3,i[s++]=e>>>30&3,i[s++]=r>>>0&3,i[s++]=r>>>2&3,i[s++]=r>>>4&3,i[s++]=r>>>6&3,i[s++]=r>>>8&3,i[s++]=r>>>10&3,i[s++]=r>>>12&3,i[s++]=r>>>14&3,i[s++]=r>>>16&3,i[s++]=r>>>18&3,i[s++]=r>>>20&3,i[s++]=r>>>22&3,i[s++]=r>>>24&3,i[s++]=r>>>26&3,i[s++]=r>>>28&3,i[s++]=r>>>30&3}}(t,e,i,r);break;case 3:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0,o=t[n++]>>>0;i[s++]=e>>>0&7,i[s++]=e>>>3&7,i[s++]=e>>>6&7,i[s++]=e>>>9&7,i[s++]=e>>>12&7,i[s++]=e>>>15&7,i[s++]=e>>>18&7,i[s++]=e>>>21&7,i[s++]=e>>>24&7,i[s++]=e>>>27&7,i[s++]=7&(e>>>30|(1&r)<<2),i[s++]=r>>>1&7,i[s++]=r>>>4&7,i[s++]=r>>>7&7,i[s++]=r>>>10&7,i[s++]=r>>>13&7,i[s++]=r>>>16&7,i[s++]=r>>>19&7,i[s++]=r>>>22&7,i[s++]=r>>>25&7,i[s++]=r>>>28&7,i[s++]=7&(r>>>31|(3&o)<<1),i[s++]=o>>>2&7,i[s++]=o>>>5&7,i[s++]=o>>>8&7,i[s++]=o>>>11&7,i[s++]=o>>>14&7,i[s++]=o>>>17&7,i[s++]=o>>>20&7,i[s++]=o>>>23&7,i[s++]=o>>>26&7,i[s++]=o>>>29&7}}(t,e,i,r);break;case 4:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0,o=t[n++]>>>0,a=t[n++]>>>0;i[s++]=e>>>0&15,i[s++]=e>>>4&15,i[s++]=e>>>8&15,i[s++]=e>>>12&15,i[s++]=e>>>16&15,i[s++]=e>>>20&15,i[s++]=e>>>24&15,i[s++]=e>>>28&15,i[s++]=r>>>0&15,i[s++]=r>>>4&15,i[s++]=r>>>8&15,i[s++]=r>>>12&15,i[s++]=r>>>16&15,i[s++]=r>>>20&15,i[s++]=r>>>24&15,i[s++]=r>>>28&15,i[s++]=o>>>0&15,i[s++]=o>>>4&15,i[s++]=o>>>8&15,i[s++]=o>>>12&15,i[s++]=o>>>16&15,i[s++]=o>>>20&15,i[s++]=o>>>24&15,i[s++]=o>>>28&15,i[s++]=a>>>0&15,i[s++]=a>>>4&15,i[s++]=a>>>8&15,i[s++]=a>>>12&15,i[s++]=a>>>16&15,i[s++]=a>>>20&15,i[s++]=a>>>24&15,i[s++]=a>>>28&15}}(t,e,i,r);break;case 5:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0,o=t[n++]>>>0,a=t[n++]>>>0,l=t[n++]>>>0;i[s++]=e>>>0&31,i[s++]=e>>>5&31,i[s++]=e>>>10&31,i[s++]=e>>>15&31,i[s++]=e>>>20&31,i[s++]=e>>>25&31,i[s++]=31&(e>>>30|(7&r)<<2),i[s++]=r>>>3&31,i[s++]=r>>>8&31,i[s++]=r>>>13&31,i[s++]=r>>>18&31,i[s++]=r>>>23&31,i[s++]=31&(r>>>28|(1&o)<<4),i[s++]=o>>>1&31,i[s++]=o>>>6&31,i[s++]=o>>>11&31,i[s++]=o>>>16&31,i[s++]=o>>>21&31,i[s++]=o>>>26&31,i[s++]=31&(o>>>31|(15&a)<<1),i[s++]=a>>>4&31,i[s++]=a>>>9&31,i[s++]=a>>>14&31,i[s++]=a>>>19&31,i[s++]=a>>>24&31,i[s++]=31&(a>>>29|(3&l)<<3),i[s++]=l>>>2&31,i[s++]=l>>>7&31,i[s++]=l>>>12&31,i[s++]=l>>>17&31,i[s++]=l>>>22&31,i[s++]=l>>>27&31}}(t,e,i,r);break;case 6:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0,o=t[n++]>>>0,a=t[n++]>>>0,l=t[n++]>>>0,h=t[n++]>>>0;i[s++]=e>>>0&63,i[s++]=e>>>6&63,i[s++]=e>>>12&63,i[s++]=e>>>18&63,i[s++]=e>>>24&63,i[s++]=63&(e>>>30|(15&r)<<2),i[s++]=r>>>4&63,i[s++]=r>>>10&63,i[s++]=r>>>16&63,i[s++]=r>>>22&63,i[s++]=63&(r>>>28|(3&o)<<4),i[s++]=o>>>2&63,i[s++]=o>>>8&63,i[s++]=o>>>14&63,i[s++]=o>>>20&63,i[s++]=o>>>26&63,i[s++]=a>>>0&63,i[s++]=a>>>6&63,i[s++]=a>>>12&63,i[s++]=a>>>18&63,i[s++]=a>>>24&63,i[s++]=63&(a>>>30|(15&l)<<2),i[s++]=l>>>4&63,i[s++]=l>>>10&63,i[s++]=l>>>16&63,i[s++]=l>>>22&63,i[s++]=63&(l>>>28|(3&h)<<4),i[s++]=h>>>2&63,i[s++]=h>>>8&63,i[s++]=h>>>14&63,i[s++]=h>>>20&63,i[s++]=h>>>26&63}}(t,e,i,r);break;case 7:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0,o=t[n++]>>>0,a=t[n++]>>>0,l=t[n++]>>>0,h=t[n++]>>>0,u=t[n++]>>>0;i[s++]=e>>>0&127,i[s++]=e>>>7&127,i[s++]=e>>>14&127,i[s++]=e>>>21&127,i[s++]=127&(e>>>28|(7&r)<<4),i[s++]=r>>>3&127,i[s++]=r>>>10&127,i[s++]=r>>>17&127,i[s++]=r>>>24&127,i[s++]=127&(r>>>31|(63&o)<<1),i[s++]=o>>>6&127,i[s++]=o>>>13&127,i[s++]=o>>>20&127,i[s++]=127&(o>>>27|(3&a)<<5),i[s++]=a>>>2&127,i[s++]=a>>>9&127,i[s++]=a>>>16&127,i[s++]=a>>>23&127,i[s++]=127&(a>>>30|(31&l)<<2),i[s++]=l>>>5&127,i[s++]=l>>>12&127,i[s++]=l>>>19&127,i[s++]=127&(l>>>26|(1&h)<<6),i[s++]=h>>>1&127,i[s++]=h>>>8&127,i[s++]=h>>>15&127,i[s++]=h>>>22&127,i[s++]=127&(h>>>29|(15&u)<<3),i[s++]=u>>>4&127,i[s++]=u>>>11&127,i[s++]=u>>>18&127,i[s++]=u>>>25&127}}(t,e,i,r);break;case 8:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<8;e++){let e=t[n++]>>>0,r=t[n++]>>>0,o=t[n++]>>>0,a=t[n++]>>>0,l=t[n++]>>>0,h=t[n++]>>>0,u=t[n++]>>>0,c=t[n++]>>>0;i[s++]=e>>>0&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=r>>>0&255,i[s++]=r>>>8&255,i[s++]=r>>>16&255,i[s++]=r>>>24&255,i[s++]=o>>>0&255,i[s++]=o>>>8&255,i[s++]=o>>>16&255,i[s++]=o>>>24&255,i[s++]=a>>>0&255,i[s++]=a>>>8&255,i[s++]=a>>>16&255,i[s++]=a>>>24&255,i[s++]=l>>>0&255,i[s++]=l>>>8&255,i[s++]=l>>>16&255,i[s++]=l>>>24&255,i[s++]=h>>>0&255,i[s++]=h>>>8&255,i[s++]=h>>>16&255,i[s++]=h>>>24&255,i[s++]=u>>>0&255,i[s++]=u>>>8&255,i[s++]=u>>>16&255,i[s++]=u>>>24&255,i[s++]=c>>>0&255,i[s++]=c>>>8&255,i[s++]=c>>>16&255,i[s++]=c>>>24&255}}(t,e,i,r);break;case 16:!function(t,e,i,r){let s=r,n=e;for(let e=0;e<128;e++){let e=t[n++]>>>0;i[s++]=65535&e,i[s++]=e>>>16&65535}}(t,e,i,r);break;default:!function(t,e,i,r,s){let n=Kf[s]>>>0,o=e,a=0,l=t[o]>>>0,h=r;for(let e=0;e<8;e++){for(let e=0;e<32;e++)if(a+s<=32)i[h+e]=l>>>a&n,a+=s,32===a&&(a=0,o++,31!==e&&(l=t[o]>>>0));else{let r=32-a,u=l>>>a;o++,l=t[o]>>>0;let c=s-r;i[h+e]=(u|(l&-1>>>32-c>>>0)<<r)&n,a=c}h+=32,a=0,e<7&&(l=t[o]>>>0)}}(t,e,i,r,s)}return e+(s<<3)|0}function op(t,e,i,r){if(i+2>e)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${e})`);let s=t[i++],n=t[i++];if(s>32)throw Error(`FastPFOR decode: invalid bitWidth=${s} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:s,exceptionCount:n,bytePosIn:i}}function ap(t,e,i,r,s,n,o,a,l){let{maxBits:h,exceptionBitWidth:u,bytePosIn:c}=function(t,e,i,r,s,n){if(i+1>e)throw Error(`FastPFOR decode: exception header underflow at block=${n} (need 1 byte for maxBits, bytePos=${i}, byteSize=${e})`);let o=t[i++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${n} (bitWidth=${r}, expected ${r}..32)`);let a=o-r|0;if(a<1||a>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${n} (bitWidth=${r}, maxBits=${o})`);if(i+s>e)throw Error(`FastPFOR decode: exception positions underflow at block=${n} (need=${s}, have=${e-i})`);return{maxBits:o,exceptionBitWidth:a,bytePosIn:i}}(s,n,o,i,r,l);if(o=c,1===u){let n=1<<i;for(let i=0;i<r;i=i+1|0)t[s[o++]+e|0]|=n;return o}let f=a.dataToBePacked[u];if(!f)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${u} (bitWidth=${i}, maxBits=${h}) at block ${l}`);let p=a.dataPointers,d=0|p[u],m=0|a.exceptionSizes[u];if(d+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${d}, need ${r}, size=${m}) at block ${l}`);for(let n=0;n<r;n=n+1|0){let r=s[o++],n=0|f[d++];t[r+e|0]|=n<<i}return p[u]=d,o}function lp(t,e,i,r,s,n){let o=0|i,a=0|t[o];if(a<=0||o+a>t.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${t.length})`);let l=o+1|0,h=o+a|0,u=t[h]>>>0,c=u+3>>>2,f=h+1,p=f+c;if(p>=t.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${c}, pageStart=${o}, packedEnd=${h}, byteContainerStart=${f}) causes bitmapPos=${p} out of bounds (encoded.length=${t.length})`);let d=function(t,e,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(2*i),r.byteContainerI32=void 0);let s=r.byteContainer,n=i>>>2;if(3&s.byteOffset)for(let i=0;i<n;i=i+1|0){let r=0|t[e+i|0],n=i<<2;s[n]=255&r,s[n+1|0]=r>>>8&255,s[n+2|0]=r>>>16&255,s[n+3|0]=r>>>24&255}else{let i=r.byteContainerI32;(!i||i.buffer!==s.buffer||i.byteOffset!==s.byteOffset||i.length<n)&&(i=r.byteContainerI32=new Int32Array(s.buffer,s.byteOffset,s.byteLength>>>2)),i.set(t.subarray(e,e+n))}let o=3&i;if(o>0){let i=0|t[e+n|0],r=n<<2;for(let t=0;t<o;t=t+1|0)s[r+t|0]=i>>>(t<<3)&255}return s}(t,f,u,n),m=u,_=function(t,e,i){let r=0|t[e++],s=i.dataToBePacked;for(let n=2;n<=32;n=n+1|0){if(!(r>>>n-1&1))continue;if(e>=t.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${n}, streamWordIndex=${e}, needWords=1, availableWords=${t.length-e}, encodedWords=${t.length})`);let o=t[e++]>>>0,a=tp(o),l=o*n+31>>>5;if(e+l>t.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${n}, size=${o}, streamWordIndex=${e}, needWords=${l}, availableWords=${t.length-e}, encodedWords=${t.length})`);let h=s[n];(!h||h.length<a)&&(h=s[n]=new Uint32Array(a));let u=0;for(;u<o;u=u+32|0)hp(t,e,h,u,n),e=e+n|0;e=e-((u-o|0)*n>>>5)|0,i.exceptionSizes[n]=o}return e}(t,p,n);return n.dataPointers.fill(0),function(t,e,i,r,s,n,o,a,l,h){let u=0|i,c=0;for(let e=0;e<o;e=e+1|0){let i=op(a,l,c,e);c=i.bytePosIn;let r=i.bitWidth,o=i.exceptionCount,f=n+256*e|0;switch(r){case 0:s.fill(0,f,f+256);break;case 32:for(let e=0;e<256;e=e+1|0)s[f+e|0]=0|t[u+e|0];u=u+256|0;break;default:u=np(t,u,s,f,r)}o>0&&(c=ap(s,f,r,o,a,l,c,h,e))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${e}, packedStart=${i}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${t.length})`)}(t,o,l,h,e,0|r,s/256|0,d,m,n),_}function hp(t,e,i,r,s){switch(s){case 2:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0;i[s++]=n>>>0&3,i[s++]=n>>>2&3,i[s++]=n>>>4&3,i[s++]=n>>>6&3,i[s++]=n>>>8&3,i[s++]=n>>>10&3,i[s++]=n>>>12&3,i[s++]=n>>>14&3,i[s++]=n>>>16&3,i[s++]=n>>>18&3,i[s++]=n>>>20&3,i[s++]=n>>>22&3,i[s++]=n>>>24&3,i[s++]=n>>>26&3,i[s++]=n>>>28&3,i[s++]=n>>>30&3,i[s++]=o>>>0&3,i[s++]=o>>>2&3,i[s++]=o>>>4&3,i[s++]=o>>>6&3,i[s++]=o>>>8&3,i[s++]=o>>>10&3,i[s++]=o>>>12&3,i[s++]=o>>>14&3,i[s++]=o>>>16&3,i[s++]=o>>>18&3,i[s++]=o>>>20&3,i[s++]=o>>>22&3,i[s++]=o>>>24&3,i[s++]=o>>>26&3,i[s++]=o>>>28&3,i[s]=o>>>30&3}(t,e,i,r);case 3:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0;i[s++]=n>>>0&7,i[s++]=n>>>3&7,i[s++]=n>>>6&7,i[s++]=n>>>9&7,i[s++]=n>>>12&7,i[s++]=n>>>15&7,i[s++]=n>>>18&7,i[s++]=n>>>21&7,i[s++]=n>>>24&7,i[s++]=n>>>27&7,i[s++]=7&(n>>>30|(1&o)<<2),i[s++]=o>>>1&7,i[s++]=o>>>4&7,i[s++]=o>>>7&7,i[s++]=o>>>10&7,i[s++]=o>>>13&7,i[s++]=o>>>16&7,i[s++]=o>>>19&7,i[s++]=o>>>22&7,i[s++]=o>>>25&7,i[s++]=o>>>28&7,i[s++]=7&(o>>>31|(3&a)<<1),i[s++]=a>>>2&7,i[s++]=a>>>5&7,i[s++]=a>>>8&7,i[s++]=a>>>11&7,i[s++]=a>>>14&7,i[s++]=a>>>17&7,i[s++]=a>>>20&7,i[s++]=a>>>23&7,i[s++]=a>>>26&7,i[s]=a>>>29&7}(t,e,i,r);case 4:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0;i[s++]=n>>>0&15,i[s++]=n>>>4&15,i[s++]=n>>>8&15,i[s++]=n>>>12&15,i[s++]=n>>>16&15,i[s++]=n>>>20&15,i[s++]=n>>>24&15,i[s++]=n>>>28&15,i[s++]=o>>>0&15,i[s++]=o>>>4&15,i[s++]=o>>>8&15,i[s++]=o>>>12&15,i[s++]=o>>>16&15,i[s++]=o>>>20&15,i[s++]=o>>>24&15,i[s++]=o>>>28&15,i[s++]=a>>>0&15,i[s++]=a>>>4&15,i[s++]=a>>>8&15,i[s++]=a>>>12&15,i[s++]=a>>>16&15,i[s++]=a>>>20&15,i[s++]=a>>>24&15,i[s++]=a>>>28&15,i[s++]=l>>>0&15,i[s++]=l>>>4&15,i[s++]=l>>>8&15,i[s++]=l>>>12&15,i[s++]=l>>>16&15,i[s++]=l>>>20&15,i[s++]=l>>>24&15,i[s]=l>>>28&15}(t,e,i,r);case 5:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0;i[s++]=n>>>0&31,i[s++]=n>>>5&31,i[s++]=n>>>10&31,i[s++]=n>>>15&31,i[s++]=n>>>20&31,i[s++]=n>>>25&31,i[s++]=31&(n>>>30|(7&o)<<2),i[s++]=o>>>3&31,i[s++]=o>>>8&31,i[s++]=o>>>13&31,i[s++]=o>>>18&31,i[s++]=o>>>23&31,i[s++]=31&(o>>>28|(1&a)<<4),i[s++]=a>>>1&31,i[s++]=a>>>6&31,i[s++]=a>>>11&31,i[s++]=a>>>16&31,i[s++]=a>>>21&31,i[s++]=a>>>26&31,i[s++]=31&(a>>>31|(15&l)<<1),i[s++]=l>>>4&31,i[s++]=l>>>9&31,i[s++]=l>>>14&31,i[s++]=l>>>19&31,i[s++]=l>>>24&31,i[s++]=31&(l>>>29|(3&h)<<3),i[s++]=h>>>2&31,i[s++]=h>>>7&31,i[s++]=h>>>12&31,i[s++]=h>>>17&31,i[s++]=h>>>22&31,i[s]=h>>>27&31}(t,e,i,r);case 6:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0;i[s++]=n>>>0&63,i[s++]=n>>>6&63,i[s++]=n>>>12&63,i[s++]=n>>>18&63,i[s++]=n>>>24&63,i[s++]=63&(n>>>30|(15&o)<<2),i[s++]=o>>>4&63,i[s++]=o>>>10&63,i[s++]=o>>>16&63,i[s++]=o>>>22&63,i[s++]=63&(o>>>28|(3&a)<<4),i[s++]=a>>>2&63,i[s++]=a>>>8&63,i[s++]=a>>>14&63,i[s++]=a>>>20&63,i[s++]=a>>>26&63,i[s++]=l>>>0&63,i[s++]=l>>>6&63,i[s++]=l>>>12&63,i[s++]=l>>>18&63,i[s++]=l>>>24&63,i[s++]=63&(l>>>30|(15&h)<<2),i[s++]=h>>>4&63,i[s++]=h>>>10&63,i[s++]=h>>>16&63,i[s++]=h>>>22&63,i[s++]=63&(h>>>28|(3&u)<<4),i[s++]=u>>>2&63,i[s++]=u>>>8&63,i[s++]=u>>>14&63,i[s++]=u>>>20&63,i[s]=u>>>26&63}(t,e,i,r);case 7:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0;i[s++]=n>>>0&127,i[s++]=n>>>7&127,i[s++]=n>>>14&127,i[s++]=n>>>21&127,i[s++]=127&(n>>>28|(7&o)<<4),i[s++]=o>>>3&127,i[s++]=o>>>10&127,i[s++]=o>>>17&127,i[s++]=o>>>24&127,i[s++]=127&(o>>>31|(63&a)<<1),i[s++]=a>>>6&127,i[s++]=a>>>13&127,i[s++]=a>>>20&127,i[s++]=127&(a>>>27|(3&l)<<5),i[s++]=l>>>2&127,i[s++]=l>>>9&127,i[s++]=l>>>16&127,i[s++]=l>>>23&127,i[s++]=127&(l>>>30|(31&h)<<2),i[s++]=h>>>5&127,i[s++]=h>>>12&127,i[s++]=h>>>19&127,i[s++]=127&(h>>>26|(1&u)<<6),i[s++]=u>>>1&127,i[s++]=u>>>8&127,i[s++]=u>>>15&127,i[s++]=u>>>22&127,i[s++]=127&(u>>>29|(15&c)<<3),i[s++]=c>>>4&127,i[s++]=c>>>11&127,i[s++]=c>>>18&127,i[s]=c>>>25&127}(t,e,i,r);case 8:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0;i[s++]=n>>>0&255,i[s++]=n>>>8&255,i[s++]=n>>>16&255,i[s++]=n>>>24&255,i[s++]=o>>>0&255,i[s++]=o>>>8&255,i[s++]=o>>>16&255,i[s++]=o>>>24&255,i[s++]=a>>>0&255,i[s++]=a>>>8&255,i[s++]=a>>>16&255,i[s++]=a>>>24&255,i[s++]=l>>>0&255,i[s++]=l>>>8&255,i[s++]=l>>>16&255,i[s++]=l>>>24&255,i[s++]=h>>>0&255,i[s++]=h>>>8&255,i[s++]=h>>>16&255,i[s++]=h>>>24&255,i[s++]=u>>>0&255,i[s++]=u>>>8&255,i[s++]=u>>>16&255,i[s++]=u>>>24&255,i[s++]=c>>>0&255,i[s++]=c>>>8&255,i[s++]=c>>>16&255,i[s++]=c>>>24&255,i[s++]=f>>>0&255,i[s++]=f>>>8&255,i[s++]=f>>>16&255,i[s]=f>>>24&255}(t,e,i,r);case 9:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0;i[s++]=n>>>0&511,i[s++]=n>>>9&511,i[s++]=n>>>18&511,i[s++]=511&(n>>>27|(15&o)<<5),i[s++]=o>>>4&511,i[s++]=o>>>13&511,i[s++]=o>>>22&511,i[s++]=511&(o>>>31|(255&a)<<1),i[s++]=a>>>8&511,i[s++]=a>>>17&511,i[s++]=511&(a>>>26|(7&l)<<6),i[s++]=l>>>3&511,i[s++]=l>>>12&511,i[s++]=l>>>21&511,i[s++]=511&(l>>>30|(127&h)<<2),i[s++]=h>>>7&511,i[s++]=h>>>16&511,i[s++]=511&(h>>>25|(3&u)<<7),i[s++]=u>>>2&511,i[s++]=u>>>11&511,i[s++]=u>>>20&511,i[s++]=511&(u>>>29|(63&c)<<3),i[s++]=c>>>6&511,i[s++]=c>>>15&511,i[s++]=511&(c>>>24|(1&f)<<8),i[s++]=f>>>1&511,i[s++]=f>>>10&511,i[s++]=f>>>19&511,i[s++]=511&(f>>>28|(31&p)<<4),i[s++]=p>>>5&511,i[s++]=p>>>14&511,i[s]=p>>>23&511}(t,e,i,r);case 10:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0;i[s++]=n>>>0&1023,i[s++]=n>>>10&1023,i[s++]=n>>>20&1023,i[s++]=1023&(n>>>30|(255&o)<<2),i[s++]=o>>>8&1023,i[s++]=o>>>18&1023,i[s++]=1023&(o>>>28|(63&a)<<4),i[s++]=a>>>6&1023,i[s++]=a>>>16&1023,i[s++]=1023&(a>>>26|(15&l)<<6),i[s++]=l>>>4&1023,i[s++]=l>>>14&1023,i[s++]=1023&(l>>>24|(3&h)<<8),i[s++]=h>>>2&1023,i[s++]=h>>>12&1023,i[s++]=h>>>22&1023,i[s++]=u>>>0&1023,i[s++]=u>>>10&1023,i[s++]=u>>>20&1023,i[s++]=1023&(u>>>30|(255&c)<<2),i[s++]=c>>>8&1023,i[s++]=c>>>18&1023,i[s++]=1023&(c>>>28|(63&f)<<4),i[s++]=f>>>6&1023,i[s++]=f>>>16&1023,i[s++]=1023&(f>>>26|(15&p)<<6),i[s++]=p>>>4&1023,i[s++]=p>>>14&1023,i[s++]=1023&(p>>>24|(3&d)<<8),i[s++]=d>>>2&1023,i[s++]=d>>>12&1023,i[s]=d>>>22&1023}(t,e,i,r);case 11:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0,m=t[e+10]>>>0;i[s++]=n>>>0&2047,i[s++]=n>>>11&2047,i[s++]=2047&(n>>>22|(1&o)<<10),i[s++]=o>>>1&2047,i[s++]=o>>>12&2047,i[s++]=2047&(o>>>23|(3&a)<<9),i[s++]=a>>>2&2047,i[s++]=a>>>13&2047,i[s++]=2047&(a>>>24|(7&l)<<8),i[s++]=l>>>3&2047,i[s++]=l>>>14&2047,i[s++]=2047&(l>>>25|(15&h)<<7),i[s++]=h>>>4&2047,i[s++]=h>>>15&2047,i[s++]=2047&(h>>>26|(31&u)<<6),i[s++]=u>>>5&2047,i[s++]=u>>>16&2047,i[s++]=2047&(u>>>27|(63&c)<<5),i[s++]=c>>>6&2047,i[s++]=c>>>17&2047,i[s++]=2047&(c>>>28|(127&f)<<4),i[s++]=f>>>7&2047,i[s++]=f>>>18&2047,i[s++]=2047&(f>>>29|(255&p)<<3),i[s++]=p>>>8&2047,i[s++]=p>>>19&2047,i[s++]=2047&(p>>>30|(511&d)<<2),i[s++]=d>>>9&2047,i[s++]=d>>>20&2047,i[s++]=2047&(d>>>31|(1023&m)<<1),i[s++]=m>>>10&2047,i[s]=m>>>21&2047}(t,e,i,r);case 12:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0,m=t[e+10]>>>0,_=t[e+11]>>>0;i[s++]=n>>>0&4095,i[s++]=n>>>12&4095,i[s++]=4095&(n>>>24|(15&o)<<8),i[s++]=o>>>4&4095,i[s++]=o>>>16&4095,i[s++]=4095&(o>>>28|(255&a)<<4),i[s++]=a>>>8&4095,i[s++]=a>>>20&4095,i[s++]=l>>>0&4095,i[s++]=l>>>12&4095,i[s++]=4095&(l>>>24|(15&h)<<8),i[s++]=h>>>4&4095,i[s++]=h>>>16&4095,i[s++]=4095&(h>>>28|(255&u)<<4),i[s++]=u>>>8&4095,i[s++]=u>>>20&4095,i[s++]=c>>>0&4095,i[s++]=c>>>12&4095,i[s++]=4095&(c>>>24|(15&f)<<8),i[s++]=f>>>4&4095,i[s++]=f>>>16&4095,i[s++]=4095&(f>>>28|(255&p)<<4),i[s++]=p>>>8&4095,i[s++]=p>>>20&4095,i[s++]=d>>>0&4095,i[s++]=d>>>12&4095,i[s++]=4095&(d>>>24|(15&m)<<8),i[s++]=m>>>4&4095,i[s++]=m>>>16&4095,i[s++]=4095&(m>>>28|(255&_)<<4),i[s++]=_>>>8&4095,i[s]=_>>>20&4095}(t,e,i,r);case 16:return void function(t,e,i,r){let s=r,n=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0,m=t[e+10]>>>0,_=t[e+11]>>>0,g=t[e+12]>>>0,y=t[e+13]>>>0,v=t[e+14]>>>0,w=t[e+15]>>>0;i[s++]=n>>>0&65535,i[s++]=n>>>16&65535,i[s++]=o>>>0&65535,i[s++]=o>>>16&65535,i[s++]=a>>>0&65535,i[s++]=a>>>16&65535,i[s++]=l>>>0&65535,i[s++]=l>>>16&65535,i[s++]=h>>>0&65535,i[s++]=h>>>16&65535,i[s++]=u>>>0&65535,i[s++]=u>>>16&65535,i[s++]=c>>>0&65535,i[s++]=c>>>16&65535,i[s++]=f>>>0&65535,i[s++]=f>>>16&65535,i[s++]=p>>>0&65535,i[s++]=p>>>16&65535,i[s++]=d>>>0&65535,i[s++]=d>>>16&65535,i[s++]=m>>>0&65535,i[s++]=m>>>16&65535,i[s++]=_>>>0&65535,i[s++]=_>>>16&65535,i[s++]=g>>>0&65535,i[s++]=g>>>16&65535,i[s++]=y>>>0&65535,i[s++]=y>>>16&65535,i[s++]=v>>>0&65535,i[s++]=v>>>16&65535,i[s++]=w>>>0&65535,i[s]=w>>>16&65535}(t,e,i,r);case 32:for(let s=0;s<32;s=s+1|0)i[r+s|0]=0|t[e+s|0];return}let n=Kf[s]>>>0,o=e,a=0,l=t[o]>>>0;for(let e=0;e<32;e++)if(a+s<=32)i[r+e]=l>>>a&n,a+=s,32===a&&(a=0,o++,31!==e&&(l=t[o]>>>0));else{let h=32-a,u=l>>>a;o++,l=t[o]>>>0,i[r+e]=(u|(l&Kf[s-h]>>>0)<<h)&n,a=s-h}}function up(t,e,i){let r=new Uint32Array(i),s=0,n=e.get();for(let e=0;e<r.length;e++){let e=t[n++],i=127&e;e<128||(e=t[n++],i|=(127&e)<<7,e<128||(e=t[n++],i|=(127&e)<<14,e<128||(e=t[n++],i|=(127&e)<<21,e<128||(e=t[n++],i|=(15&e)<<28)))),r[s++]=i}return e.set(n),r}function cp(t,e,i){let r=new BigUint64Array(i);for(let i=0;i<r.length;i++)r[i]=fp(t,e);return r}function fp(t,e){let i=0n,r=0,s=e.get();for(;s<t.length;){let e=t[s++];if(i|=BigInt(127&e)<<BigInt(r),!(128&e))break;if(r+=7,r>=64)throw Error("Varint too long")}return e.set(s),i}function pp(t,e){let i,r;return r=t[e.get()],e.increment(),i=127&r,r<128||(r=t[e.get()],e.increment(),i|=(127&r)<<7,r<128)||(r=t[e.get()],e.increment(),i|=(127&r)<<14,r<128)||(r=t[e.get()],e.increment(),i|=(127&r)<<21,r<128)?i:(r=t[e.get()],i|=(15&r)<<28,function(t,e,i){let r,s;if(s=e[i.get()],i.increment(),r=(112&s)>>4,s<128||(s=e[i.get()],i.increment(),r|=(127&s)<<3,s<128)||(s=e[i.get()],i.increment(),r|=(127&s)<<10,s<128)||(s=e[i.get()],i.increment(),r|=(127&s)<<17,s<128)||(s=e[i.get()],i.increment(),r|=(127&s)<<24,s<128)||(s=e[i.get()],i.increment(),r|=(1&s)<<31,s<128))return 4294967296*r+(t>>>0);throw Error("Expected varint not more than 10 bytes")}(i,t,e))}function dp(t,e,i,r){return function(t,e,i,r,s){let n=r.get();if(3&i)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${n} (encodedBytes.length=${t.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=i>>>2,a=function(t,e){if(e<=t.encodedWords.length)return t.encodedWords;let i=new Uint32Array(Math.max(16,2*e));return t.encodedWords=i,i}(s,o);!function(t,e,i,r){if(e<0||i<0||e+i>t.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${e}, byteLength=${i}, bytes.length=${t.length})`);let s=Math.floor(i/4),n=i%4!=0,o=n?s+1:s;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(s>0){let i=t.byteOffset+e;if(3&i)for(let i=0;i<s;i++){let s=e+4*i;r[i]=t[s]<<24|t[s+1]<<16|t[s+2]<<8|t[s+3]}else{let e=new Uint32Array(t.buffer,i,s);for(let t=0;t<s;t++)r[t]=0|ep(e[t])}}if(n){let n=e+4*s,o=i-4*s,a=0;for(let e=0;e<o;e++)a|=t[n+e]<<24-8*e;r[s]=0|a}}(t,n,i,a);let l=function(t,e,i){let r=0,s=0,n=new Uint32Array(e),o=i??sp();if(t.length>0){let e=0|t[r];if(r=r+1|0,255&e)throw Error(`FastPFOR decode: invalid alignedLength=${e} (expected multiple of 256)`);if(s+e>n.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${s}, alignedLength=${e}, out.length=${n.length})`);r=function(t,e,i,r,s,n){let o=r+Qf(s,256),a=r,l=i;for(;a!==o;){let i=Math.min(ip,o-a);l=lp(t,e,l,a,i,n),a=a+i|0}return l}(t,n,r,s,e,o),s=s+e|0}return function(t,e,i,r,s,n){if(0===n)return e;let o=0,a=e,l=e+i,h=s,u=s,c=s+n,f=0,p=0;for(;a<l&&u<c;){let e=t[a]>>>o&255;if(o+=8,a+=o>>>5,o&=31,f|=(127&e)<<p,128&e)r[u++]=0|f,f=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${f}, decoded=${u-h}/${n}, inPos=${a}, inEnd=${l})`)}if(u!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-h}, expected=${n}, consumedWords=${a-e}/${i}, vbyteStart=${e}, vbyteEnd=${l})`)}(t,r,t.length-r|0,n,s,e-s|0),n}(a.subarray(0,o),e,s.decoderWorkspace);return r.add(i),l}(t,e,i,r,function(t=16){if(t<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${t}`);let e=Math.max(16,0|t);return{encodedWords:new Uint32Array(e),decoderWorkspace:sp()}}(i>>>2))}function mp(t){return t>>>1^-(1&t)}function _p(t){return t>>1n^-(1n&t)}function gp(t){return t%2==1?(t+1)/-2:t/2}function yp(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=t[r]}let r=new Uint32Array(i),s=0;for(let i=0;i<e;i++){let n=t[i];r.fill(t[i+e],s,s+n),s+=n}return r}function vp(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=Number(t[r])}let r=new BigUint64Array(i),s=0;for(let i=0;i<e;i++){let n=Number(t[i]);r.fill(t[i+e],s,s+n),s+=n}return r}function wp(t,e,i){let r=new Float64Array(i),s=0;for(let i=0;i<e;i++){let n=t[i];r.fill(t[i+e],s,s+n),s+=n}return r}function bp(t){let e=new Int32Array(t.length);e[0]=mp(t[0]);let i=t.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=t[r+1],s=t[r+2],n=t[r+3];e[r]=mp(t[r])+e[r-1],e[r+1]=mp(i)+e[r],e[r+2]=mp(s)+e[r+1],e[r+3]=mp(n)+e[r+2]}for(;r!==t.length;++r)e[r]=mp(t[r])+e[r-1];return e}function xp(t){let e=new BigInt64Array(t.length);e[0]=_p(t[0]);let i=t.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=t[r+1],s=t[r+2],n=t[r+3];e[r]=_p(t[r])+e[r-1],e[r+1]=_p(i)+e[r],e[r+2]=_p(s)+e[r+1],e[r+3]=_p(n)+e[r+2]}for(;r!==e.length;++r)e[r]=_p(t[r])+e[r-1];return e}function Mp(t){let e=t.length/4*4,i=1;if(e>=4)for(let r=t[0];i<e-4;i+=4)r=t[i]+=r,r=t[i+1]+=r,r=t[i+2]+=r,r=t[i+3]+=r;for(;i!==t.length;)t[i]+=t[i-1],++i}function zp(t){let e=new Uint32Array(t.length);e[0]=mp(t[0])>>>0;for(let i=1;i<t.length;i++)e[i]=e[i-1]+mp(t[i])>>>0;return e}function Sp(t){let e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,_p(t[0]));for(let i=1;i<t.length;i++)e[i]=BigInt.asUintN(64,e[i-1]+_p(t[i]));return e}var Tp,Ep,Ap,Pp;!function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"}(Tp||={}),function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"}(Ep||={}),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"}(Ap||={}),function(t){t.VAR_BINARY="VAR_BINARY",t.GEOMETRIES="GEOMETRIES",t.PARTS="PARTS",t.RINGS="RINGS",t.TRIANGLES="TRIANGLES",t.SYMBOL="SYMBOL",t.DICTIONARY="DICTIONARY"}(Pp||={});const Ip=[Tp.PRESENT,Tp.DATA,Tp.OFFSET,Tp.LENGTH],Cp=[Hf.NONE,Hf.DELTA,Hf.COMPONENTWISE_DELTA,Hf.RLE,Hf.MORTON,Hf.PDE],kp=[Yf.NONE,Yf.FAST_PFOR,Yf.VARINT],Dp=[Ep.NONE,Ep.SINGLE,Ep.SHARED,Ep.VERTEX,Ep.MORTON,Ep.FSST],Fp=[Ap.VERTEX,Ap.INDEX,Ap.STRING,Ap.KEY],$p=[Pp.VAR_BINARY,Pp.GEOMETRIES,Pp.PARTS,Pp.RINGS,Pp.TRIANGLES,Pp.SYMBOL,Pp.DICTIONARY];function jp(t,e){let i=function(t,e){let i=t[e.get()],r=Ip[i>>4],s={};switch(r){case Tp.DATA:s={dictionaryType:Dp[15&i]};break;case Tp.OFFSET:s={offsetType:Fp[15&i]};break;case Tp.LENGTH:s={lengthType:$p[15&i]}}e.increment();let n=t[e.get()],o=Cp[n>>5],a=Cp[n>>2&7],l=kp[3&n];e.increment();let h=up(t,e,2),u=h[0];return{physicalStreamType:r,logicalStreamType:s,logicalLevelTechnique1:o,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:u,byteLength:h[1],decompressedCount:u}}(t,e);return i.logicalLevelTechnique1===Hf.MORTON?function(t,e,i){let r=up(e,i,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:t.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(i,t,e):Hf.RLE!==i.logicalLevelTechnique1&&Hf.RLE!==i.logicalLevelTechnique2||Yf.NONE===i.physicalLevelTechnique?i:function(t,e,i){let r=up(e,i,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(i,t,e)}var Rp;!function(t){t[t.FLAT=0]="FLAT",t[t.CONST=1]="CONST",t[t.SEQUENCE=2]="SEQUENCE",t[t.DICTIONARY=3]="DICTIONARY",t[t.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Rp||={});var Op=class{constructor(t,e){this.values=t,this._size=e}get(t){let e=Math.floor(t/8);return 1==(this.values[e]>>t%8&1)}set(t,e){let i=Math.floor(t/8);this.values[i]=this.values[i]|+!!e<<t%8}getInt(t){let e=Math.floor(t/8);return this.values[e]>>t%8&1}size(){return this._size}getBuffer(){return this.values}};function Lp(t,e,i){if(!e)return t;let r=e.size(),s=new(0,t.constructor)(r),n=0;for(let o=0;o<r;o++)s[o]=e.get(o)?t[n++]:i;return s}function Bp(t,e,i,r,s){return function(t,e,i,r){let s;switch(e.logicalLevelTechnique1){case Hf.DELTA:if(e.logicalLevelTechnique2===Hf.RLE){let i=e;if(!r)return function(t,e,i){let r=new Int32Array(i),s=0,n=0;for(let i=0;i<e;i++){let o=t[i],a=mp(t[i+e]);for(let t=0;t<o;t++)n+=a,r[s++]=n}return r}(t,i.runs,i.numRleValues);s=bp(t=yp(t,i.runs,i.numRleValues))}else s=bp(t);break;case Hf.RLE:s=function(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=t[r]}let r=new Int32Array(i),s=0;for(let i=0;i<e;i++){let n=t[i],o=t[i+e];o=mp(o),r.fill(o,s,s+n),s+=n}return r}(t,e.runs,e.numRleValues);break;case Hf.MORTON:Mp(t),s=new Int32Array(t);break;case Hf.COMPONENTWISE_DELTA:s=function(t){if(t.length<2)return new Int32Array(t);let e=new Int32Array(t.length);e[0]=mp(t[0]),e[1]=mp(t[1]);let i=t.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let i=t[r+1],s=t[r+2],n=t[r+3];e[r]=mp(t[r])+e[r-2],e[r+1]=mp(i)+e[r-1],e[r+2]=mp(s)+e[r],e[r+3]=mp(n)+e[r+1]}for(;r!==t.length;r+=2)e[r]=mp(t[r])+e[r-2],e[r+1]=mp(t[r+1])+e[r-1];return e}(t);break;case Hf.NONE:s=function(t){let e=new Int32Array(t.length);for(let i=0;i<t.length;i++)e[i]=mp(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Lp(s,r,0):s}(Gp(t,e,i),i,0,s)}function Np(t,e,i,r,s){return function(t,e,i,r){let s;switch(e.logicalLevelTechnique1){case Hf.DELTA:s=zp(e.logicalLevelTechnique2===Hf.RLE?yp(t,e.runs,e.numRleValues):t);break;case Hf.RLE:s=yp(t,e.runs,e.numRleValues);break;case Hf.MORTON:Mp(t),s=t;break;case Hf.COMPONENTWISE_DELTA:s=function(t){if(t.length<2)return new Uint32Array(t);let e=new Uint32Array(t.length);e[0]=mp(t[0])>>>0,e[1]=mp(t[1])>>>0;for(let i=2;i<t.length;i+=2)e[i]=e[i-2]+mp(t[i])>>>0,e[i+1]=e[i-1]+mp(t[i+1])>>>0;return e}(t);break;case Hf.NONE:s=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Lp(s,r,0):s}(Gp(t,e,i),i,0,s)}function Up(t,e,i){return function(t,e){if(e.logicalLevelTechnique1===Hf.DELTA&&e.logicalLevelTechnique2===Hf.NONE)return function(t){let e=new Int32Array(t.length+1);e[0]=0,e[1]=mp(t[0]);let i=e[1];for(let r=2;r!==e.length;++r)i+=mp(t[r-1]),e[r]=e[r-1]+i;return new Uint32Array(e)}(t);if(e.logicalLevelTechnique1===Hf.RLE&&e.logicalLevelTechnique2===Hf.NONE)return function(t,e,i){let r=new Uint32Array(i+1);r[0]=0;let s=1,n=r[0];for(let i=0;i<e;i++){let o=t[i],a=t[i+e];for(let t=s;t<s+o;t++)r[t]=a+n,n=r[t];s+=o}return r}(t,e.runs,e.numRleValues);if(e.logicalLevelTechnique1===Hf.NONE&&e.logicalLevelTechnique2===Hf.NONE){!function(t){let e=0;for(let i=0;i<t.length;i++)t[i]+=e,e=t[i]}(t);let i=new Uint32Array(e.numValues+1);return i[0]=0,i.set(t,1),i}if(e.logicalLevelTechnique1===Hf.DELTA&&e.logicalLevelTechnique2===Hf.RLE){let i=function(t,e,i){let r=new Int32Array(i+1);r[0]=0;let s=1,n=r[0];for(let i=0;i<e;i++){let o=t[i],a=t[i+e];a=mp(a);for(let t=s;t<s+o;t++)r[t]=a+n,n=r[t];s+=o}return r}(t,e.runs,e.numRleValues);return Mp(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Gp(t,e,i),i)}function Gp(t,e,i){let r=i.physicalLevelTechnique;switch(r){case Yf.FAST_PFOR:return dp(t,i.numValues,i.byteLength,e);case Yf.VARINT:return up(t,e,i.numValues);case Yf.NONE:{let r=e.get();e.add(i.byteLength);let s=t.subarray(r,e.get());return new Uint32Array(s)}default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function qp(t,e,i){let r=Gp(t,e,i);return 1===r.length?i.logicalLevelTechnique1===Hf.DELTA?mp(r[0]):r[0]:function(t){return t[1]}(r)}function Vp(t,e,i){return function(t){if(2===t.length){let e=mp(t[1]);return[e,e]}return[mp(t[2]),mp(t[3])]}(Gp(t,e,i))}function Zp(t,e,i){return function(t){if(2===t.length){let e=_p(t[1]);return[e,e]}return[_p(t[2]),_p(t[3])]}(cp(t,e,i.numValues))}function Wp(t,e,i,r){return function(t,e,i){let r;switch(e.logicalLevelTechnique1){case Hf.DELTA:r=Sp(e.logicalLevelTechnique2===Hf.RLE?vp(t,e.runs,e.numRleValues):t);break;case Hf.RLE:r=vp(t,e.runs,e.numRleValues);break;case Hf.NONE:r=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Lp(r,i,0n):r}(cp(t,e,i.numValues),i,r)}function Hp(t,e,i){let r=cp(t,e,i.numValues);return 1===r.length?i.logicalLevelTechnique1===Hf.DELTA?_p(r[0]):r[0]:function(t){return t[1]}(r)}function Yp(t,e,i,r,s="int32"){let n=t.logicalLevelTechnique1;if(n===Hf.RLE)return 1===t.runs?Rp.CONST:Rp.FLAT;if(n!==Hf.DELTA||t.logicalLevelTechnique2!==Hf.RLE)return 1===t.numValues?Rp.CONST:Rp.FLAT;let o=e instanceof Op?e.size():e;if(t.numRleValues!==o)return Rp.FLAT;if(1===t.runs)return Rp.SEQUENCE;if(2!==t.runs)return 1===t.numValues?Rp.CONST:Rp.FLAT;let a=r.get();if(t.physicalLevelTechnique===Yf.VARINT)return function(t,e,i){let r=new Xf(e.get());if("int64"===i){let e=cp(t,r,4);return 2n===e[2]&&2n===e[3]}let s=up(t,r,4);return 2===s[2]&&2===s[3]}(i,r,s)?Rp.SEQUENCE:1===t.numValues?Rp.CONST:Rp.FLAT;let l=r.get(),h=new Int32Array(i.buffer,i.byteOffset+l,4);return r.set(a),2===h[2]&&2===h[3]?Rp.SEQUENCE:1===t.numValues?Rp.CONST:Rp.FLAT}var Xp,Jp,Kp,Qp=class extends Nf{getValueFromBuffer(t){return this.dataBuffer[t]}},td=class extends qf{constructor(t,e,i,r){super(t,BigInt64Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}};function ed(t,e,i){return{x:id(t,e)-i,y:id(t>>1,e)-i}}function id(t,e){let i=0;for(let r=0;r<e;r++)i|=(t&1<<2*r)>>r;return i}function rd(t,e,i,r,s,n,o){return t===Kp.MORTON?function(t,e,i,r,s,n){let o=Array(s?r+1:r);for(let s=0;s<r;s++){let r=ed(t[e[i+s]],n.numBits,n.coordinateShift);o[s]=new l(r.x,r.y)}return s&&(o[o.length-1]=o[0]),o}(e,i,r,s,n,o):function(t,e,i,r,s){let n=Array(s?r+1:r);for(let s=0;s<2*r;s+=2){let r=2*e[i+s/2];n[s/2]=new l(t[r],t[r+1])}return s&&(n[n.length-1]=n[0]),n}(e,i,r,s,n)}function sd(t,e,i,r){let s=Array(r?i+1:i);for(let r=0;r<2*i;r+=2)s[r/2]=new l(t[e+r],t[e+r+1]);return r&&(s[s.length-1]=s[0]),s}!function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON",t[t.MULTIPOINT=3]="MULTIPOINT",t[t.MULTILINESTRING=4]="MULTILINESTRING",t[t.MULTIPOLYGON=5]="MULTIPOLYGON"}(Xp||={}),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"}(Jp||={}),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"}(Kp||={});var nd=class{constructor(t,e,i,r,s){this._vertexBufferType=t,this._topologyVector=e,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=s}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(t){let e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){let e=ed(this.vertexBuffer[this.vertexOffsets[t]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[e.x,e.y]}let e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getGeometries(){return function(t){let e=Array(t.numGeometries),i=1,r=1,s=1,n=0,o=0,a=0,h=t.mortonSettings,u=t.topologyVector,c=u.geometryOffsets,f=u.partOffsets,p=u.ringOffsets,d=t.vertexOffsets,m=!d||0===d.length,_=t.containsPolygonGeometry(),g=t.vertexBuffer;for(let u=0;u<t.numGeometries;u++){let y=t.geometryType(u);switch(y){case Xp.POINT:{let u,_;if(m)u=g[o++],_=g[o++];else if(t.vertexBufferType===Kp.MORTON){let t=ed(g[d[a++]],h.numBits,h.coordinateShift);u=t.x,_=t.y}else{let t=2*d[a++];u=g[t],_=g[t+1]}e[n++]=[[new l(u,_)]],c&&s++,f&&i++,p&&r++}break;case Xp.MULTIPOINT:{let t=c[s]-c[s-1];s++;let h=Array(t);if(m)for(let e=0;e<t;e++){let t=g[o++],i=g[o++];h[e]=new l(t,i)}else for(let e=0;e<t;e++){let t=2*d[a++];h[e]=new l(g[t],g[t+1])}e[n++]=h.map((t=>[t])),i+=t,r+=t}break;case Xp.LINESTRING:{let l,u;_?(l=p[r]-p[r-1],r++):l=f[i]-f[i-1],i++,m?(u=sd(g,o,l,!1),o+=2*l):(u=rd(t.vertexBufferType,g,d,a,l,!1,h),a+=l),e[n++]=[u],c&&s++}break;case Xp.POLYGON:{let l=f[i]-f[i-1];i++;let u,_=Array(l-1),y=p[r]-p[r-1];if(r++,m){u=sd(g,o,y,!0),o+=2*y;for(let t=0;t<_.length;t++)y=p[r]-p[r-1],r++,_[t]=sd(g,o,y,!0),o+=2*y}else{u=rd(t.vertexBufferType,g,d,a,y,!0,h),a+=y;for(let e=0;e<_.length;e++)y=p[r]-p[r-1],r++,_[e]=rd(t.vertexBufferType,g,d,a,y,!0,h),a+=y}e[n++]=[u].concat(_),c&&s++}break;case Xp.MULTILINESTRING:{let l=c[s]-c[s-1];s++;let u=Array(l);for(let e=0;e<l;e++){let s;if(_?(s=p[r]-p[r-1],r++):s=f[i]-f[i-1],i++,m)u[e]=sd(g,o,s,!1),o+=2*s;else{let i=rd(t.vertexBufferType,g,d,a,s,!1,h);u[e]=i,a+=s}}e[n++]=u}break;case Xp.MULTIPOLYGON:{let l=c[s]-c[s-1];s++;let u=Array(l);for(let e=0;e<l;e++){let s=f[i]-f[i-1];i++;let n,l=Array(s-1),c=p[r]-p[r-1];r++,m?(n=sd(g,o,c,!0),o+=2*c):(n=rd(t.vertexBufferType,g,d,a,c,!0,h),a+=c);for(let e=0;e<l.length;e++){let i=p[r]-p[r-1];r++,m?(l[e]=sd(g,o,i,!0),o+=2*i):(l[e]=rd(t.vertexBufferType,g,d,a,i,!0,h),a+=i)}u[e]=[n].concat(l)}e[n++]=u.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return e}(this)}get mortonSettings(){return this._mortonSettings}},od=class extends nd{constructor(t,e,i,r,s,n,o){super(i,r,s,n,o),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Xp.POLYGON||this._geometryType===Xp.MULTIPOLYGON}containsSingleGeometryType(){return!0}},ad=class extends nd{constructor(t,e,i,r,s,n){super(t,i,r,s,n),this._geometryTypes=e}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let t=0;t<this.numGeometries;t++)if(this.geometryType(t)===Xp.POLYGON||this.geometryType(t)===Xp.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},ld=class{constructor(t,e,i,r){this._triangleOffsets=t,this._indexBuffer=e,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw Error("Cannot convert GpuVector to coordinates without topology information");let t=Array(this.numGeometries),e=this._topologyVector,i=e.partOffsets,r=e.ringOffsets,s=e.geometryOffsets,n=0,o=1,a=1,h=1;for(let e=0;e<this.numGeometries;e++)switch(this.geometryType(e)){case Xp.POLYGON:{let u=i[o]-i[o-1];o++;let c=[];for(let t=0;t<u;t++){let t=r[a]-r[a-1];a++;let e=[];for(let i=0;i<t;i++){let t=this._vertexBuffer[n++],i=this._vertexBuffer[n++];e.push(new l(t,i))}e.length>0&&e.push(e[0]),c.push(e)}t[e]=c,s&&h++}break;case Xp.MULTIPOLYGON:{let u=s[h]-s[h-1];h++;let c=[];for(let t=0;t<u;t++){let t=i[o]-i[o-1];o++;for(let e=0;e<t;e++){let t=r[a]-r[a-1];a++;let e=[];for(let i=0;i<t;i++){let t=this._vertexBuffer[n++],i=this._vertexBuffer[n++];e.push(new l(t,i))}e.length>0&&e.push(e[0]),c.push(e)}}t[e]=c}}return t}[Symbol.iterator](){return null}};function hd(t,e,i,r,s,n){return new ud(t,e,i,r,s,n)}var ud=class extends ld{constructor(t,e,i,r,s,n){super(i,r,s,n),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function cd(t,e,i,r,s){return new fd(t,e,i,r,s)}var fd=class extends ld{constructor(t,e,i,r,s){super(e,i,r,s),this._geometryTypes=t}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function pd(t,e,i,r){let s,n,o,a,l=jp(t,i);if(Yp(l,r,t,i)===Rp.CONST){let h,u,c,f,p=qp(t,i,l);for(let r=0;r<e-1;r++){let e=jp(t,i);switch(e.physicalStreamType){case Tp.LENGTH:switch(e.logicalStreamType.lengthType){case Pp.GEOMETRIES:h=Up(t,i,e);break;case Pp.PARTS:u=Up(t,i,e);break;case Pp.RINGS:c=Up(t,i,e);break;case Pp.TRIANGLES:f=Up(t,i,e)}break;case Tp.OFFSET:switch(e.logicalStreamType.offsetType){case Ap.VERTEX:s=Np(t,i,e);break;case Ap.INDEX:a=Np(t,i,e)}break;case Tp.DATA:Ep.VERTEX===e.logicalStreamType.dictionaryType?n=Bp(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},n=Np(t,i,e))}}return a?void 0!==h||void 0!==u?hd(r,p,f,a,n,{geometryOffsets:h,partOffsets:u,ringOffsets:c}):hd(r,p,f,a,n):void 0===o?function(t,e,i,r,s){return new od(t,e,Kp.VEC_2,i,r,s)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},s,n):function(t,e,i,r,s,n){return new od(t,e,Kp.MORTON,i,r,s,n)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},s,n,o)}let h,u,c,f,p,d,m,_=Np(t,i,l);for(let r=0;r<e-1;r++){let e=jp(t,i);switch(e.physicalStreamType){case Tp.LENGTH:switch(e.logicalStreamType.lengthType){case Pp.GEOMETRIES:h=Np(t,i,e);break;case Pp.PARTS:u=Np(t,i,e);break;case Pp.RINGS:c=Np(t,i,e);break;case Pp.TRIANGLES:f=Up(t,i,e)}break;case Tp.OFFSET:switch(e.logicalStreamType.offsetType){case Ap.VERTEX:s=Np(t,i,e);break;case Ap.INDEX:a=Np(t,i,e)}break;case Tp.DATA:Ep.VERTEX===e.logicalStreamType.dictionaryType?n=Bp(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},n=Np(t,i,e))}}return h?(p=dd(_,h,2),u&&c?(d=md(_,p,u,!1),m=function(t,e,i,r){let s=new Uint32Array(i[i.length-1]+1),n=0;s[0]=n;let o=1,a=1,l=0;for(let h=0;h<t.length;h++){let u=t[h],c=e[h+1]-e[h];if(0!==u&&3!==u)for(let t=0;t<c;t++){let t=i[o]-i[o-1];o++;for(let e=0;e<t;e++)n=s[a++]=n+r[l++]}else for(let t=0;t<c;t++)s[a++]=++n,o++}return s}(_,p,d,c)):u&&(d=function(t,e,i){let r=new Uint32Array(e[e.length-1]+1),s=0;r[0]=s;let n=1,o=0;for(let a=0;a<t.length;a++){let l=t[a],h=e[a+1]-e[a];if(4===l||1===l)for(let t=0;t<h;t++)s=r[n++]=s+i[o++];else for(let t=0;t<h;t++)r[n++]=++s}return r}(_,p,u))):u&&c?(d=dd(_,u,1),m=md(_,d,c,!0)):u&&(d=dd(_,u,0)),a&&!d?cd(_,f,a,n):a?cd(_,f,a,n,{geometryOffsets:p,partOffsets:d,ringOffsets:m}):void 0===o?function(t,e,i,r){return new ad(Kp.VEC_2,t,e,i,r)}(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},s,n):function(t,e,i,r,s){return new ad(Kp.MORTON,t,e,i,r,s)}(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},s,n,o)}function dd(t,e,i){let r=new Uint32Array(t.length+1),s=0;r[0]=s;let n=0;for(let o=0;o<t.length;o++)s=r[o+1]=s+(t[o]>i?e[n++]:1);return r}function md(t,e,i,r){let s=new Uint32Array(e[e.length-1]+1),n=0;s[0]=n;let o=1,a=0;for(let l=0;l<t.length;l++){let h=t[l],u=e[l+1]-e[l];if(5===h||2===h||r&&(4===h||1===h))for(let t=0;t<u;t++)n=s[o++]=n+i[a++];else for(let t=0;t<u;t++)s[o++]=++n}return s}var _d=class extends Bf{constructor(t,e,i){super(t,e.getBuffer(),i),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}},gd=class extends Nf{getValueFromBuffer(t){return this.dataBuffer[t]}},yd=class extends Bf{constructor(t,e,i,r){super(t,r?BigInt64Array.of(e):BigUint64Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}};function vd(t,e,i,r,s){let n=function(t,e,i,r){let s=new Uint8Array(e),n=0,o=r.get()+i;for(;n<e&&!(r.get()>=o);){let i=t[r.increment()];if(i<=127){let o=i+3,a=t[r.increment()],l=Math.min(n+o,e);s.fill(a,n,l),n=l}else{let o=256-i;for(let i=0;i<o&&n<e;i++)s[n++]=t[r.increment()]}}return r.set(o),s}(t,Math.ceil(e/8),i,r);return s?function(t,e,i){if(!i)return t;let r=i.size(),s=new Op(t,e),n=new Op(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let t=0;t<r;t++){let e=!!i.get(t)&&s.get(o++);n.set(t,e)}return n.getBuffer()}(n,e,s):n}const wd=new TextDecoder;function bd(t,e,i){return i-e>=12?wd.decode(t.subarray(e,i)):function(t,e,i){let r="",s=e;for(;s<i;){let e,n,o,a=t[s],l=null,h=a>239?4:a>223?3:a>191?2:1;if(s+h>i)break;1===h?a<128&&(l=a):2===h?(e=t[s+1],128==(192&e)&&(l=(31&a)<<6|63&e,l<=127&&(l=null))):3===h?(e=t[s+1],n=t[s+2],128==(192&e)&&128==(192&n)&&(l=(15&a)<<12|(63&e)<<6|63&n,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(e=t[s+1],n=t[s+2],o=t[s+3],128==(192&e)&&128==(192&n)&&128==(192&o)&&(l=(15&a)<<18|(63&e)<<12|(63&n)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),s+=h}return r}(t,e,i)}var xd=class extends Bf{constructor(t,e,i,r){super(t,i,r),this.offsetBuffer=e}},Md=class extends xd{constructor(t,e,i,r){super(t,e,i,r??e.length-1)}getValueFromBuffer(t){return bd(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}},zd=class extends xd{constructor(t,e,i,r,s){super(t,i,r,s??e.length),this.indexBuffer=e,this.indexBuffer=e}getValueFromBuffer(t){let e=this.indexBuffer[t];return bd(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}},Sd=class extends xd{constructor(t,e,i,r,s,n,o){super(t,i,r,o??e.length),this.indexBuffer=e,this.symbolOffsetBuffer=s,this.symbolTableBuffer=n}getValueFromBuffer(t){this.decodedDictionary??=(this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(t,e,i){let r=[],s=Array(e.length).fill(0);for(let t=1;t<e.length;t++)s[t]=s[t-1]+e[t-1];for(let n=0;n<i.length;n++)if(255===i[n])r.push(i[++n]);else{let o=e[i[n]],a=s[i[n]];for(let e=0;e<o;e++)r.push(t[a+e])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));let e=this.indexBuffer[t];return bd(this.decodedDictionary,this.offsetBuffer[e],this.offsetBuffer[e+1])}offsetToLengthBuffer(t){let e=new Uint32Array(t.length-1),i=t[0];for(let r=1;r<t.length;r++){let s=t[r];e[r-1]=s-i,i=s}return e}};function Td(t,e,i,r,s){return"scalarType"===i.type?function(t,e,i,r,s,n){let o=null;if(0===t)return null;if(n.nullable){let t=jp(e,i),r=t.numValues,s=i.get(),n=vd(e,r,t.byteLength,i);i.set(s+t.byteLength),o=new Op(n,t.numValues)}let a=o??r;switch(s.physicalType){case 4:case 3:return function(t,e,i,r,s){let n=jp(t,e),o=Yp(n,s,t,e),a=3===r.physicalType;if(o===Rp.FLAT){let r=Ed(s)?s:void 0,o=a?Bp(t,e,n,0,r):Np(t,e,n,0,r);return new Uf(i.name,o,s)}if(o===Rp.SEQUENCE){let r=Vp(t,e,n);return new Vf(i.name,r[0],r[1],n.numRleValues)}let l=a?function(t,e,i){let r=Gp(t,e,i);return 1===r.length?mp(r[0]):function(t){return mp(t[1])}(r)}(t,e,n):qp(t,e,n);return new Zf(i.name,l,s,a)}(e,i,n,s,a);case 9:return function(t,e,i,r,s){let n=null,o=null,a=null,l=null,h=null,u=s??null,c=null,f=null;for(let t=0;t<r;t++){let t=jp(e,i);switch(t.physicalStreamType){case Tp.PRESENT:{let r=new Op(vd(e,t.numValues,t.byteLength,i),t.numValues);u=s??r;break}case Tp.OFFSET:o=Np(e,i,t,0,u);break;case Tp.LENGTH:{let r=Up(e,i,t);Pp.DICTIONARY===t.logicalStreamType.lengthType?n=r:Pp.SYMBOL===t.logicalStreamType.lengthType?l=r:c=r;break}case Tp.DATA:{let r=e.subarray(i.get(),i.get()+t.byteLength);i.add(t.byteLength);let s=t.logicalStreamType.dictionaryType;Ep.FSST===s?h=r:Ep.SINGLE===s||Ep.SHARED===s?a=r:Ep.NONE===s&&(f=r);break}}}return function(t,e,i,r,s,n,o){return e?new Sd(t,i,r,s,n,e,o):null}(t,h,o,n,a,l,u)??function(t,e,i,r,s){return e?s?new zd(t,i,r,e,s):new zd(t,i,r,e):null}(t,a,o,n,u)??function(t,e,i,r,s){if(!e||!i)return null;if(r)return s?new zd(t,r,e,i,s):new zd(t,r,e,i);if(s&&s.size()!==e.length-1){let r=new Uint32Array(s.size()),n=0;for(let t=0;t<s.size();t++)r[t]=s.get(t)?n++:0;return new zd(t,r,e,i,s)}return s?new Md(t,e,i,s):new Md(t,e,i)}(t,c,f,o,u)}(n.name,e,i,n.nullable?t-1:t,o);case 0:return function(t,e,i,r,s){let n=jp(t,e),o=n.numValues,a=e.get(),l=Ed(s)?s:void 0,h=vd(t,o,n.byteLength,e,l);e.set(a+n.byteLength);let u=new Op(h,o);return new _d(i.name,u,s)}(e,i,n,0,a);case 6:case 5:return function(t,e,i,r,s){let n=jp(t,e),o=Yp(n,r,t,e,"int64"),a=5===s.physicalType;if(o===Rp.FLAT){let s=Ed(r)?r:void 0,o=a?function(t,e,i,r){return function(t,e,i){let r;switch(e.logicalLevelTechnique1){case Hf.DELTA:if(e.logicalLevelTechnique2===Hf.RLE){let s=e;if(!i)return function(t,e,i){let r=new BigInt64Array(i),s=0,n=0n;for(let i=0;i<e;i++){let o=Number(t[i]),a=_p(t[i+e]);for(let t=0;t<o;t++)n+=a,r[s++]=n}return r}(t,s.runs,s.numRleValues);r=xp(t=vp(t,s.runs,s.numRleValues))}else r=xp(t);break;case Hf.RLE:r=function(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=Number(t[r])}let r=new BigInt64Array(i),s=0;for(let i=0;i<e;i++){let n=Number(t[i]),o=t[i+e];o=_p(o),r.fill(o,s,s+n),s+=n}return r}(t,e.runs,e.numRleValues);break;case Hf.NONE:r=function(t){let e=new BigInt64Array(t.length);for(let i=0;i<t.length;i++)e[i]=_p(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Lp(r,i,0n):r}(cp(t,e,i.numValues),i,r)}(t,e,n,s):Wp(t,e,n,s);return new Qp(i.name,o,r)}if(o===Rp.SEQUENCE){let r=Zp(t,e,n);return new td(i.name,r[0],r[1],n.numRleValues)}let l=a?function(t,e,i){let r=cp(t,e,i.numValues);return 1===r.length?_p(r[0]):function(t){return _p(t[1])}(r)}(t,e,n):Hp(t,e,n);return new yd(i.name,l,r,a)}(e,i,n,a,s);case 7:return function(t,e,i,r){let s=jp(t,e),n=Ed(r)?r:void 0,o=function(t,e,i,r){let s=e.get(),n=s+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(s,n)).buffer,a=new Float32Array(o);return e.set(n),r?Lp(a,r,0):a}(t,e,s.numValues,n);return new gd(i.name,o,r)}(e,i,n,a);case 8:return function(t,e,i,r){let s=jp(t,e),n=Ed(r)?r:void 0,o=function(t,e,i,r){let s=e.get(),n=s+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(s,n)).buffer,a=new Float64Array(o);return e.set(n),r?Lp(a,r,0):a}(t,e,s.numValues,n);return new Gf(i.name,o,r)}(e,i,n,a);default:throw Error(`The specified data type for the field is currently not supported: ${s}`)}}(r,t,e,s,i.scalarType,i):0===r?null:function(t,e,i){let r=null,s=null,n=null,o=null,a=!1;for(;!a;){let i=jp(t,e);switch(i.physicalStreamType){case Tp.LENGTH:Pp.DICTIONARY===i.logicalStreamType.lengthType?r=Up(t,e,i):n=Up(t,e,i);break;case Tp.DATA:Ep.SINGLE===i.logicalStreamType.dictionaryType||Ep.SHARED===i.logicalStreamType.dictionaryType?(s=t.subarray(e.get(),e.get()+i.byteLength),a=!0):o=t.subarray(e.get(),e.get()+i.byteLength),e.add(i.byteLength)}}let l=i.complexType.children,h=[],u=0;for(let a of l){let l=up(t,e,1)[0];if(0===l)continue;let c,f=a.name?`${i.name}${a.name}`:i.name;if("scalarField"!==a.type||9!==a.scalarField.physicalType)throw Error("Currently only scalar string fields are implemented for a struct.");if(l>1&&!a.nullable||1===l&&a.nullable)throw Error(`The number of streams for the child field ${a.name} does not match its nullability. nullibilty: ${a.nullable}, numStreams: ${l}`);if(a.nullable){let i=jp(t,e);c=new Op(vd(t,i.numValues,i.byteLength,e),i.numValues)}let p=Np(t,e,jp(t,e),0,c);h[u++]=o?new Sd(f,p,r,s,n,o,c):new zd(f,p,r,s,c)}return h}(t,e,i)}function Ed(t){return t instanceof Op}function Ad(t){switch(t){case 0:case 1:case 2:case 3:{let e={};e.nullable=!!(1&t),e.columnScope=0;let i={type:"logicalType",logicalType:0};return i.longID=!!(2&t),e.scalarType=i,e.type="scalarType",e}case 4:{let t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:0};return t.type="complexType",t.complexType=e,t}case 30:{let t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:1};return t.type="complexType",t.complexType=e,t}default:return function(t){let e;switch(t){case 10:case 11:e=0;break;case 12:case 13:e=1;break;case 14:case 15:e=2;break;case 16:case 17:e=3;break;case 18:case 19:e=4;break;case 20:case 21:e=5;break;case 22:case 23:e=6;break;case 24:case 25:e=7;break;case 26:case 27:e=8;break;case 28:case 29:e=9;break;default:return null}let i={};i.nullable=!!(1&t),i.columnScope=0;let r={type:"physicalType"};return r.physicalType=e,i.type="scalarType",i.scalarType=r,i}(t)}}function Pd(t){return t>=10}function Id(t){return 30===t}function Cd(t){if("scalarType"===t.type){let e=t.scalarType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if("logicalType"===e.type)return!1}else if("complexType"===t.type){let e=t.complexType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}function kd(t){return"scalarType"===t.type&&"logicalType"===t.scalarType?.type&&0===t.scalarType.logicalType}function Dd(t){return"complexType"===t.type&&"physicalType"===t.complexType?.type&&0===t.complexType.physicalType}const Fd=new TextDecoder;function $d(t,e){let i=up(t,e,1)[0];if(0===i)return"";let r=e.get(),s=t.subarray(r,r+i);return e.add(i),Fd.decode(s)}function jd(t,e){let i=up(t,e,1)[0]>>>0;if(i<10||i>30)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);let r=Ad(i);if(Pd(i)&&(r.name=$d(t,e)),Id(i)){let i=up(t,e,1)[0]>>>0;r.complexType.children=Array(i);for(let s=0;s<i;s++)r.complexType.children[s]=jd(t,e)}return function(t){return{name:t.name,nullable:t.nullable,scalarField:t.scalarType,complexField:t.complexType,type:"scalarType"===t.type?"scalarField":"complexField"}}(r)}function Rd(t,e){let i=up(t,e,1)[0]>>>0,r=Ad(i);if(!r)throw Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Pd(i)?r.name=$d(t,e):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),Id(i)){let i=up(t,e,1)[0]>>>0,s=r.complexType;s.children=Array(i);for(let r=0;r<i;r++)s.children[r]=jd(t,e)}return r}function Od(t,e){let i={featureTables:[]},r={};if(r.name=$d(t,e),0===r.name.length)throw Error("Missing layer name");let s=up(t,e,1)[0]>>>0,n=up(t,e,1)[0]>>>0;r.columns=Array(n);for(let i=0;i<n;i++)r.columns[i]=Rd(t,e);return i.featureTables.push(r),[i,s]}function Ld(t,e,i,r,s,n,o=!1){let a=e.scalarType;if("logicalType"!==a?.type||0!==a.logicalType)throw Error(`ID column must be a logical ID scalar type: ${r}`);let l=a.longID?6:4,h="number"==typeof n?void 0:n,u=Yp(s,n,t,i,6===l?"int64":"int32");if(4===l)switch(u){case Rp.FLAT:return new Uf(r,Np(t,i,s,0,h),n);case Rp.SEQUENCE:{let e=Vp(t,i,s);return new Vf(r,e[0],e[1],s.numRleValues)}case Rp.CONST:return new Zf(r,qp(t,i,s),n,!1)}switch(u){case Rp.FLAT:return o?new Gf(r,function(t,e,i){return function(t,e){switch(e.logicalLevelTechnique1){case Hf.DELTA:return e.logicalLevelTechnique2===Hf.RLE&&(t=wp(t,e.runs,e.numRleValues)),function(t){t[0]=gp(t[0]);let e=t.length/4*4,i=1;if(e>=4)for(;i<e-4;i+=4){let e=t[i+1],r=t[i+2],s=t[i+3];t[i]=gp(t[i])+t[i-1],t[i+1]=gp(e)+t[i],t[i+2]=gp(r)+t[i+1],t[i+3]=gp(s)+t[i+2]}for(;i!==t.length;++i)t[i]=gp(t[i])+t[i-1]}(t),t;case Hf.RLE:return function(t,e){return wp(t,e.runs,e.numRleValues)}(t,e);case Hf.NONE:return t;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(function(t,e,i){let r=new Float64Array(i);for(let s=0;s<i;s++)r[s]=pp(t,e);return r}(t,e,i.numValues),i)}(t,i,s),n):new Qp(r,Wp(t,i,s,h),n);case Rp.SEQUENCE:{let e=Zp(t,i,s);return new td(r,e[0],e[1],s.numRleValues)}case Rp.CONST:return new yd(r,Hp(t,i,s),n,!1)}throw Error("Vector type not supported for id column.")}var Bd=class{constructor(t,e){switch(this._featureData=t,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Xp.POINT:case Xp.MULTIPOINT:this.type=1;break;case Xp.LINESTRING:case Xp.MULTILINESTRING:this.type=2;break;case Xp.POLYGON:case Xp.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=e,this.id=Number(this._featureData.id)}loadGeometry(){let t=[];for(let e of this._featureData.geometry.coordinates){let i=[];for(let t of e)i.push(new l(t.x,t.y));t.push(i)}return t}},Nd=class{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 Bd(this.features[t],this.extent)}},Ud=class{constructor(t){this.layers={};let e=function(t,e,i=!0){let r=new Xf(0),s=[];for(;r.get()<t.length;){let e=up(t,r,1)[0]>>>0,n=r.get()+e;if(n>t.length)throw Error(`Block overruns tile: ${n} > ${t.length}`);if(up(t,r,1)[0]>>>0!=1){r.set(n);continue}let[o,a]=Od(t,r),l=o.featureTables[0],h=null,u=null,c=[],f=0;for(let e of l.columns){let s=e.name;if(kd(e)){let n=null;if(e.nullable){let e=jp(t,r),i=r.get(),s=vd(t,e.numValues,e.byteLength,r);r.set(i+e.byteLength),n=new Op(s,e.numValues)}let o=jp(t,r);f=n?n.size():o.decompressedCount,h=Ld(t,e,r,s,o,n??f,i)}else if(Dd(e)){let e=up(t,r,1)[0];if(0===f){let e=r.get();f=jp(t,r).decompressedCount,r.set(e)}u=pd(t,e,r,f)}else{let i=Cd(e)?up(t,r,1)[0]:1;if(0===i)continue;let s=Td(t,r,e,i,f);if(s)if(Array.isArray(s))for(let t of s)c.push(t);else c.push(s)}}let p=new Wf(l.name,u,h,c,a);s.push(p),r.set(n)}return s}(new Uint8Array(t));this.layers=e.reduce(((t,e)=>({...t,[e.name]:new Nd(e)})),{})}};function Gd(t,e,i,r,s){return Ct(t,((t,n)=>{let o=e instanceof Po?e.get(n):null;return o?.evaluate?o.evaluate(i,r,s):o}))}function qd(t,e){return e-t}so("FeatureIndex",class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new io(et,16,0),this.grid3D=new io(et,16,0),this.featureIndexArray=new Ca,this.promoteId=e}insert(t,e,i,r,s,n){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,s);let a=n?this.grid3D:this.grid;for(let t of e){let e=[1/0,1/0,-1/0,-1/0];for(let i of t)e[0]=Math.min(e[0],i.x),e[1]=Math.min(e[1],i.y),e[2]=Math.max(e[2],i.x),e[3]=Math.max(e[3],i.y);e[0]<8192&&e[1]<8192&&e[2]>=0&&e[3]>=0&&a.insert(o,e[0],e[1],e[2],e[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"===this.encoding?new Ud(this.rawTileData).layers:new qu(new Wc(this.rawTileData)).layers,this.sourceLayerCoder=new Of(this.vtLayers?Object.keys(this.vtLayers).sort():[Rf])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();let s=t.params,n=et/t.tileSize/t.scale,o=an(s.filter,"queryRenderedFeatures filter",s.globalState),a=t.queryGeometry,l=t.queryPadding*n,h=jf.fromPoints(a),u=this.grid.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l),c=jf.fromPoints(t.cameraQueryGeometry).expandBy(l),f=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,((e,i,r,s)=>Yl(t.cameraQueryGeometry,e-l,i-l,r+l,s+l)));for(let t of f)u.push(t);u.sort(qd);let p,d={};for(let l of u){if(l===p)continue;p=l;let h=this.featureIndexArray.get(l),u=null;this.loadMatchingFeature(d,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,o,s.layers,s.availableImages,e,i,r,((e,i,r)=>(u||=Fl(e),i.queryIntersectsFeature({queryGeometry:a,feature:e,featureState:r,geometry:u,zoom:this.z,transform:t.transform,pixelsToTileUnits:n,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))))}return d}loadMatchingFeature(t,e,i,r,s,n,o,a,l,h,u){let c=this.bucketLayerIDs[e];if(n&&!c.some((t=>n.has(t))))return;let f=this.sourceLayerCoder.decode(i),p=this.vtLayers[f].feature(r);if(s.needGeometry){let t=$l(p,!0);if(!s.filter(new wo(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new wo(this.tileID.overscaledZ),p))return;let d=this.getId(p,f);for(let e of c){if(n&&!n.has(e))continue;let i=a[e];if(!i)continue;let s={};d&&h&&(s=h.getState(i.sourceLayer||"_geojsonTileLayer",d));let c=zt({},l[e]);c.paint=Gd(c.paint,i.paint,p,s,o),c.layout=Gd(c.layout,i.layout,p,s,o);let f=!u||u(p,i,s);if(!f)continue;let m=new Lf(p,this.z,this.x,this.y,d);m.layer=c;let _=t[e];void 0===_&&(_=t[e]=[]),_.push({featureIndex:r,feature:m,intersectionZ:f})}}lookupSymbolFeatures(t,e,i,r,s,n,o,a){let l={};this.loadVTLayers();let h=an(s.filterSpec,"queryRenderedFeatures symbol filter",s.globalState);for(let s of t)this.loadMatchingFeature(l,i,r,s,h,n,o,a,e);return l}hasLayer(t){for(let e of this.bucketLayerIDs)for(let i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i)),void 0===i&&t.properties?.cluster&&this.promoteId&&(i=Number(t.properties.cluster_id))),i}},{omit:["rawTileData","sourceLayerCoder"]});var Vd=class{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(let t in this.data)for(let e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){let r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);let s={value:e,timeout:void 0};if(void 0!==i&&(s.timeout=setTimeout((()=>{this.remove(t,s)}),i)),this.data[r].push(s),this.order.push(r),this.order.length>this.max){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){let e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){let e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;let i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][r];return this.data[i].splice(r,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){let e=[];for(let i in this.data)for(let r of this.data[i])t(r.value)||e.push(r);for(let t of e)this.remove(t.value.tileID,t)}};so("Anchor",class t extends l{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new t(this.x,this.y,this.angle,this.segment)}});let Zd,Wd,Hd,Yd=function(t){return t[t.center=1]="center",t[t.left=2]="left",t[t.right=3]="right",t[t.top=4]="top",t[t.bottom=5]="bottom",t[t["top-left"]=6]="top-left",t[t["top-right"]=7]="top-right",t[t["bottom-left"]=8]="bottom-left",t[t["bottom-right"]=9]="bottom-right",t}({});function Xd(){var t=new f(4);return f!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}const Jd={frame(t,e,i,r){let s=r||window,n=s.requestAnimationFrame((t=>{o(),e(t)})),{unsubscribe:o}=Gt(t.signal,"abort",(()=>{o(),s.cancelAnimationFrame(n),i(new ie(t.signal.reason))}),!1)},frameAsync(t,e){return new Promise(((i,r)=>{this.frame(t,i,r,e)}))},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){let e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(Zd||=document.createElement("a"),Zd.href=t,Zd.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===Hd?!!matchMedia&&(Wd??=matchMedia("(prefers-reduced-motion: reduce)"),Wd.matches):Hd},set prefersReducedMotion(t){Hd=t}},Kd=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null===this._frozenAt?performance.now():this._frozenAt}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function Qd(){return Kd.getCurrentTime()}var tm=class t{static{this.docStyle=typeof window<"u"&&window.document?.documentElement.style}static{this.selectProp=!t.docStyle||"userSelect"in t.docStyle?"userSelect":"webkitUserSelect"}static create(t,e,i){let r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){t.docStyle&&t.selectProp&&(t.userSelect=t.docStyle[t.selectProp],t.docStyle[t.selectProp]="none")}static enableDrag(){t.docStyle&&t.selectProp&&(t.docStyle[t.selectProp]=t.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",t.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",t.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",t.suppressClickInternal,!0)}),0)}static getScale(t){let e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,e,i){let r=e.boundingClientRect;return new l((i.clientX-r.left)/e.x-t.clientLeft,(i.clientY-r.top)/e.y-t.clientTop)}static mousePos(e,i){let r=t.getScale(e);return t.getPoint(e,r,i)}static touchPos(e,i){let r=[],s=t.getScale(e);for(let n of i)r.push(t.getPoint(e,s,n));return r}static sanitize(e){let i=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body"),r=i.querySelectorAll("script");for(let t of r)t.remove();return t.clean(i),i.innerHTML}static isPossiblyDangerous(t,e){let i=e.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(t)&&(i.includes("javascript:")||i.includes("data:"))||t.startsWith("on"))return!0}static clean(e){let i=e.children;for(let e of i)t.removeAttributes(e),t.clean(e)}static removeAttributes(e){for(let{name:i,value:r}of e.attributes)t.isPossiblyDangerous(i,r)&&e.removeAttribute(i)}};let em;(function(t){let e,i,r,s;t.resetRequestQueue=()=>{e=[],i=0,r=0,s={}},t.addThrottleControl=t=>{let e=r++;return s[e]=t,e},t.removeThrottleControl=t=>{delete s[t],a()},t.getImage=(t,i,r=!0,s)=>new Promise(((n,o)=>{t.headers||={},t.headers.accept="image/webp,*/*",zt(t,{type:"image"});let l={abortController:i,requestParameters:t,supportImageRefresh:r,imageBitmapOptions:s,state:"queued",onError:t=>{o(t)},onSuccess:t=>{n(t)}};e.push(l),a()}));let n=(t,e)=>"function"==typeof createImageBitmap?(async(t,e)=>{if(0===t.byteLength)return createImageBitmap(new ImageData(1,1),e);let i=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(i,e)}catch(t){throw Error(`Could not load image because of ${rt(t).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})(t,e):(t=>new Promise(((e,i)=>{let r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>r.src=Ut))},r.onerror=()=>i(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."));let s=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(s):Ut})))(t),o=async t=>{t.state="running";let{requestParameters:e,supportImageRefresh:r,imageBitmapOptions:s,onError:o,onSuccess:h,abortController:u}=t,c=!1===r&&!s&&!Lt(self)&&!oe(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((t,e)=>t&&"accept"===e),!0));i++;let f=c?l(e,u):ue(e,u);try{let e=await f;delete t.abortController,t.state="completed",e.data instanceof HTMLImageElement||Nt(e.data)?h(e):e.data&&h({data:await n(e.data,s),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete t.abortController,o(rt(e))}finally{i--,a()}},a=()=>{let t=(()=>{for(let t of Object.keys(s))if(s[t]())return!0;return!1})()?ne.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:ne.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r<t&&e.length>0;r++){let t=e.shift();t.abortController.signal.aborted?r--:o(t)}},l=(t,e)=>new Promise(((i,r)=>{let s=new Image,n=t.url,o=t.credentials;o&&"include"===o?s.crossOrigin="use-credentials":(o&&"same-origin"===o||!fe(n))&&(s.crossOrigin="anonymous"),e.signal.addEventListener("abort",(()=>{s.src="",r(new ie(e.signal.reason))})),s.fetchPriority="high",s.onload=()=>{s.onerror=s.onload=null,i({data:s})},s.onerror=()=>{s.onerror=s.onload=null,!e.signal.aborted&&r(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},s.src=n}))})(em||={}),em.resetRequestQueue();var im=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}},rm=class extends me{},sm=class extends rm{},nm=class extends rm{constructor(t={}){super("style.load",t)}},om=class extends rm{constructor(t,e={}){super(t,e),this.dataType="style"}},am=class extends rm{constructor(t,e={}){super(t,e),this.dataType="source"}},lm=class extends rm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(t,i);let s=tm.mousePos(e.getCanvas(),i);super(t,zt({point:s,lngLat:e.unproject(s),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}},hm=class extends rm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){let r="touchend"===t?i.changedTouches:i.touches,s=tm.touchPos(e.getCanvasContainer(),r),n=s.map((t=>e.unproject(t))),o=s.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new l(0,0));super(t,{points:s,point:o,lngLats:n,lngLat:e.unproject(o),originalEvent:i}),this._defaultPrevented=!1}},um=class extends rm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e){super("wheel",{originalEvent:e}),this._defaultPrevented=!1}},cm=class extends rm{},fm=class extends rm{constructor(t={}){super("terrain",t)}},pm=class extends rm{constructor(t={}){super("projectiontransition",t)}},dm=class extends rm{},mm=class extends rm{constructor(t={}){super("styleimagemissing",t)}};function _m(t){let e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){let i=[];for(let{id:r,url:s}of t){let t=`${r}${s}`;i.includes(t)||(i.push(t),e.push({id:r,url:s}))}}return e}function gm(t,e,i){try{let r=new URL(t);return r.pathname+=`${e}${i}`,r.toString()}catch{throw Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}var ym=class extends ge{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this.patterns={},this.atlasImage=new yh({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&=(this.atlasTexture.destroy(),null);for(let t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new yh({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(let{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){let e=this.images[t];if(e&&!e.data&&e.spriteData){let t=e.spriteData;e.data=new yh({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),e.spriteData=null}return e}addImage(t,e){if(this.images[t])throw Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,e){let i=!0,r=e.data||e.spriteData;return this._validateStretch(e.stretchX,r?.width)||(this.fire(new _e(Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,r?.height)||(this.fire(new _e(Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new _e(Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(let r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){if(!t)return!0;if(4!==t.length)return!1;let i=e.spriteData,r=i?.width||e.data.width,s=i?.height||e.data.height;return!(t[0]<0||r<t[0]||t[1]<0||s<t[1]||t[2]<0||r<t[2]||t[3]<0||s<t[3]||t[2]<t[0])&&t[3]>=t[1]}updateImage(t,e,i=!0){let r=this.getImage(t);if(i&&(r.data.width!==e.data.width||r.data.height!==e.data.height))throw Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${e.data.width}x${e.data.height}).`);e.version=r.version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){let e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage?.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}setMissingImageResolver(t){this.missingImageResolver=t}getImages(t){return new Promise((e=>{let i=!0;if(!this.isLoaded())for(let e of t)this.images[e]||(i=!1);this.isLoaded()||i?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}async _getImagesForIds(t){let e=new Set(t.filter((t=>!this.getImage(t)))),i=this.missingImageResolver;i&&await Promise.all(Array.from(e,(t=>i(t))));let r={};for(let i of t){let t=this.getImage(i);t&&(e.delete(i),r[i]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:!!t.userImage?.render})}for(let t of e)this.fire(new mm({id:t})),jt(`Image "${t}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return r}getPixelSize(){let{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){let e=this.patterns[t],i=this.getImage(t);if(!i)return null;if(e&&e.position.version===i.version)return e.position;if(e)e.position.version=i.version;else{let e={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new Qc(e,i);this.patterns[t]={bin:e,position:r}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){let e=t.gl;this.atlasTexture?this.dirty&&=(this.atlasTexture.update(this.atlasImage),!1):this.atlasTexture=new Ph(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){let t=[];for(let e in this.patterns)t.push(this.patterns[e].bin);let{w:e,h:i}=Kc(t),r=this.atlasImage;r.resize({width:e||1,height:i||1});for(let t in this.patterns){let{bin:e}=this.patterns[t],i=e.x+1,s=e.y+1,n=this.getImage(t).data,o=n.width,a=n.height;yh.copy(n,r,{x:0,y:0},{x:i,y:s},{width:o,height:a}),yh.copy(n,r,{x:0,y:a-1},{x:i,y:s-1},{width:o,height:1}),yh.copy(n,r,{x:0,y:0},{x:i,y:s+a},{width:o,height:1}),yh.copy(n,r,{x:o-1,y:0},{x:i-1,y:s},{width:1,height:a}),yh.copy(n,r,{x:0,y:0},{x:i+o,y:s},{width:1,height:a})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(let e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;let t=this.getImage(e);t||jt(`Image with ID: "${e}" was not found`),Jc(t)&&this.updateImage(e,t)}}cloneImages(){let t={};for(let e in this.images){let i=this.images[e];t[e]={...i,data:i.data?i.data.clone():null}}return t}};async function vm(t,e,i,r){let s=256*e,n=s+255,o=await r.transformRequest(i.replace("{fontstack}",t).replace("{range}",`${s}-${n}`),"Glyphs"),a=await((t,e)=>ue(zt(t,{type:"arrayBuffer"}),e))(o,new AbortController);if(!a?.data)throw Error(`Could not load glyph range. range: ${e}, ${s}-${n}`);let l={};for(let t of function(t){return new Wc(t).readFields(Hc,[])}(a.data))l[t.id]=t;return l}const wm=1e20,bm=new Float64Array(256);for(let t=0;t<256;t++){let e=.5-(t/255)**(1/2.2);bm[t]=e*Math.abs(e)}bm[255]=-1e20;var xm=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:n="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=e,this.radius=i,this.cutoff=r,this.lang=a;let l=this.size=t+4*e,h=this._createCanvas(l),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${o} ${n} ${t}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,t);let e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:n}=this.ctx.measureText(t),o=Math.ceil(i),a=Math.floor(-s),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n)-a)),h=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),u=l+2*this.buffer,c=h+2*this.buffer,f=Math.max(u*c,0),p=new Uint8ClampedArray(f),d={data:p,width:u,height:c,glyphWidth:l,glyphHeight:h,glyphTop:o,glyphLeft:a,glyphAdvance:e};if(0===l||0===h)return d;let{ctx:m,buffer:_,gridInner:g,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(_,_,l,h),m.fillText(t,_-a,_+o);let v=m.getImageData(_,_,l,h);y.fill(wm,0,f),g.fill(0,0,f);let w=3;for(let t=0;t<h;t++){let e=(t+_)*u+_;for(let t=0;t<l;t++,w+=4,e++){let t=v.data[w];if(0===t)continue;let i=bm[t];y[e]=Math.max(0,i),g[e]=Math.max(0,-i)}}Mm(y,0,0,u,c,u,this.f,this.v,this.z);let b=Math.min(_,1);Mm(g,_-b,_-b,l+2*b,h+2*b,u,this.f,this.v,this.z);let x=255/this.radius,M=255*(1-this.cutoff);for(let t=0;t<f;t++){let e=Math.sqrt(y[t])-Math.sqrt(g[t]);p[t]=Math.round(M-x*e)}return d}};function Mm(t,e,i,r,s,n,o,a,l){for(let h=e;h<e+r;h++)zm(t,i*n+h,n,s,o,a,l);for(let h=i;h<i+s;h++)zm(t,h*n+e,1,r,o,a,l)}function zm(t,e,i,r,s,n,o){n[0]=0,o[0]=-1e20,o[1]=wm,s[0]=t[e];for(let a=1,l=0,h=0;a<r;a++){s[a]=t[e+a*i];let r=a*a;do{let t=n[l];h=(s[a]-s[t]+r-t*t)/(a-t)/2}while(h<=o[l]&&--l>-1);l++,n[l]=a,o[l]=h,o[l+1]=wm}for(let a=0,l=0;a<r;a++){for(;o[l+1]<a;)l++;let r=n[l],h=a-r;t[e+a*i]=s[r]+h*h}}const Sm=ye.layout_symbol["text-font"].default.join(",");var Tm=class t{static{this.loadGlyphRange=vm}static{this.TinySDF=xm}constructor(t,e,i){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={},this.lang=i}setURL(t){this.url=t}async getGlyphs(t){let e=[];for(let i in t)for(let r of t[i])e.push(this._getAndCacheGlyphsPromise(i,r));let i=await Promise.all(e),r={};for(let{stack:t,id:e,glyph:s}of i)r[t]||={},r[t][e]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return r}async _getAndCacheGlyphsPromise(t,e){this.entries[t]??={glyphs:{},requests:{},ranges:{}};let i=this.entries[t],r=i.glyphs[e];return void 0===r?!this.url||this._charUsesLocalIdeographFontFamily(e)?(r=i.glyphs[e]=await this._drawGlyph(i,t,e),{stack:t,id:e,glyph:r}):await this._downloadAndCacheRangePromise(t,e):{stack:t,id:e,glyph:r}}async _downloadAndCacheRangePromise(e,i){let r=this.entries[e],s=Math.floor(i/256);if(r.ranges[s])return{stack:e,id:i,glyph:null};r.requests[s]||=t.loadGlyphRange(e,s,this.url,this.requestManager);try{let t=await r.requests[s];for(let e in t)r.glyphs[+e]=t[+e];return r.ranges[s]=!0,{stack:e,id:i,glyph:t[i]||null}}catch(t){let n=r.glyphs[i]=await this._drawGlyph(r,e,i);return this._warnOnMissingGlyphRange(n,s,i,rt(t)),{stack:e,id:i,glyph:n}}}_warnOnMissingGlyphRange(t,e,i,r){let s=256*e;jt(`Unable to load glyph range ${e}, ${s}-${s+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&function(t){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}(t)}async _drawGlyph(t,e,i){let r=e===Sm&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(i),s=r?"ideographTinySDF":"tinySDF";t[s]||=this._createTinySDF(r?this.localIdeographFontFamily:e);let n=(await t[s]).draw(String.fromCodePoint(i)),o=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(i));return{id:i,bitmap:new gh({width:n.width||60,height:n.height||60},n.data),metrics:{width:o?0:n.glyphWidth/2||24,height:n.glyphHeight/2||24,left:n.glyphLeft/2+.5||0,top:n.glyphTop/2-27.5||-8,advance:o?0:n.glyphAdvance/2||24,isDoubleResolution:!0}}}async _createTinySDF(e){let i=e?e.split(","):[];i.push("sans-serif");let r=i.map((t=>/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`)).join(","),s=this._fontWeight(i[0]),n=this._fontStyle(i[0]);if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${n} ${s||"normal"} 48px ${r}`)}catch(t){jt(`Failed to load font "${r}": ${rt(t).message}`)}return new t.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:s,fontStyle:n,lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){let e,i={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};for(let[r,s]of Object.entries(i))RegExp(`\\b${r}\\b`,"i").test(t)&&(e=`${s}`);return e}destroy(){for(let t in this.entries){let e=this.entries[t];e.tinySDF=null,e.ideographTinySDF=null,e.glyphs={},e.requests={},e.ranges={}}this.entries={}}};let Em;var Am=class extends ge{constructor(t,e){super(),this._transitionable=new zo(Em||=new Ro({anchor:new ko(ye.light.anchor,"anchor"),position:new ko(ye.light.position,"position"),color:new ko(ye.light.color,"color"),intensity:new ko(ye.light.intensity,"intensity")}),"light",e),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,[t*Math.cos(e)*Math.sin(i),t*Math.sin(e)*Math.sin(i),t*Math.cos(i)]}(this.properties.get("position"))}setLight(t,e={}){if(!this._validate(Jn.light,t,e))for(let e in t){let i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return eo(this,t,{value:e},i)}};let Pm;var Im=class extends ge{constructor(t,e){super(),this._transitionable=new zo(Pm||=new Ro({"sky-color":new ko(ye.sky["sky-color"],"sky-color"),"horizon-color":new ko(ye.sky["horizon-color"],"horizon-color"),"fog-color":new ko(ye.sky["fog-color"],"fog-color"),"fog-ground-blend":new ko(ye.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new ko(ye.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new ko(ye.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new ko(ye.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",e),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new wo(0))}setSky(t,e={}){if(!this._validate(Jn.sky,t,e)){t||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0};for(let e in t){let i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i={}){return eo(this,t,{value:e},i)}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}},Cm=class{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){let i=t.join(",")+String(e);return this.dashEntry[i]||=this.addDash(t,e),this.dashEntry[i]}getDashRanges(t,e,i){let r=[],s=t.length%2==1?-t[t.length-1]*i:0,n=t[0]*i,o=!0;r.push({left:s,right:n,isDash:o,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){o=!o;let l=t[e];s=a*i,a+=l,n=a*i,r.push({left:s,right:n,isDash:o,zeroLength:0===l})}return r}addRoundDash(t,e,i){let r=e/2;for(let e=-i;e<=i;e++){let s=this.width*(this.nextRow+i+e),n=0,o=t[n];for(let a=0;a<this.width;a++){a/o.right>1&&(o=t[++n]);let l,h=Math.abs(a-o.left),u=Math.abs(a-o.right),c=Math.min(h,u),f=e/i*(r+1);if(o.isDash){let t=r-Math.abs(f);l=Math.sqrt(c*c+t*t)}else l=r-Math.sqrt(c*c+f*f);this.data[s+a]=Math.max(0,Math.min(255,l+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){let i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r?.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}let e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);let r=this.width*this.nextRow,s=0,n=t[s];for(let e=0;e<this.width;e++){e/n.right>1&&(n=t[++s]);let i=Math.abs(e-n.left),o=Math.abs(e-n.right),a=Math.min(i,o);this.data[r+e]=Math.max(0,Math.min(255,(n.isDash?a:-a)+128))}}addDash(t,e){let i=e?7:0,r=2*i+1;if(this.nextRow+r>this.height)return jt("LineAtlas out of space"),null;let s=0;for(let e of t)s+=e;if(0!==s){let r=this.width/s,n=this.getDashRanges(t,this.width,r);e?this.addRoundDash(n,r,i):this.addRegularDash(n)}let n={y:this.nextRow+i,height:2*i,width:s};return this.nextRow+=r,this.dirty=!0,n}bind(t){let e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}};function km(t,e){if(e)try{return new Worker(t,{type:"module"})}catch(t){console.warn("Module worker not supported, falling back to classic worker",t)}return new Worker(t)}async function Dm(){let t=function(){let t=import.meta.url;if(!/^https?:/.test(t))return"";let e=t.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${e}`,t).href}(),e=!t?.endsWith(".cjs");if(!function(t){if(!t)return!1;let e=globalThis.location;if(!e)return!1;try{return new URL(t,e.href).origin!==e.origin}catch{return!1}}(t))return km(t,e);if(e){let i=function(t){let e=new Blob([`import ${JSON.stringify(new URL(t,import.meta.url).href)}`],{type:"text/javascript"});return URL.createObjectURL(e)}(t);try{return km(i,e)}finally{URL.revokeObjectURL(i)}}let i=await async function(t){let e=await fetch(t);if(!e.ok)throw Error(`Failed to fetch worker script (${e.status}): ${t}`);let i=await e.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}(t);try{return km(i,e)}finally{URL.revokeObjectURL(i)}}var Fm=class t{constructor(){this.active={},this.workersPromise=null}async acquire(e){if(this.active[e]=!0,!this.workersPromise){let e=[];for(;e.length<t.workerCount;)e.push(Dm());this.workersPromise=Promise.all(e)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],0===this.numActive()&&this.workersPromise){let t=this.workersPromise;this.workersPromise=null,t.then((t=>{for(let e of t)e.terminate()}))}}isPreloaded(){return!!this.active.maplibre_preloaded_worker_pool}numActive(){return Object.keys(this.active).length}};const $m=Math.floor(Jd.hardwareConcurrency/2);let jm;function Rm(){return jm||=new Fm,jm}Fm.workerCount=function(t){if(null==Bt){let e=t.navigator?t.navigator.userAgent:null;Bt=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Bt}(globalThis)?Math.max(Math.min($m,3),1):1;var Om=class{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e,this.removed=!1,this.actorsPromise=this.initActors(e)}async initActors(t){let e=await this.workerPool.acquire(t);if(this.removed)return[];if(this.actors=e.map(((e,i)=>{let r=new Ef(e,t);return r.name=`Worker ${i}`,r})),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(t,e){let i=await this.actorsPromise;return Promise.all(i.map((i=>i.sendAsync({type:t,data:e}))))}async getActor(){let t=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%t.length,t[this.currentActor]}async waitForInitComplete(){0===this.actors.length&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.removed=!0;for(let t of this.actors)t.remove();this.actors=[],t&&this.workerPool.release(this.id)}async registerMessageHandler(t,e){let i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(t,e)}async unregisterMessageHandler(t){let e=await this.actorsPromise;for(let i of e)i.unregisterMessageHandler(t)}};let Lm;function Bm(){return Lm||(Lm=new Om(Rm(),ae),Lm.registerMessageHandler("GR",((t,e,i)=>ue(e,i)))),Lm}function Nm(t,e){let i=d();return v(i,i,[1,1,0]),w(i,i,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?y(i,i,t.calculatePosMatrix(e.toUnwrapped())):i}function Um(t,e,i,r,s,n,o){let a=function(t,e,i){if(t)for(let r of t){let t=e[r];if(t?.source===i&&"fill-extrusion"===t.type)return!0}else for(let t in e){let r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(s?.layers??null,e,t.id),l=n.maxPitchScaleFactor(),h=t.tilesIn(r,l,a);h.sort(Gm);let u=[];for(let r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,s,n,l,Nm(n,r.tileID),o?(t,e)=>o(r.tileID,t,e):void 0)});return function(t,e){for(let i in t)for(let r of t[i])qm(r,e);return t}(function(t){let e={},i={};for(let{queryResults:r,wrappedTileID:s}of t){i[s]||={};let t=i[s];for(let i in r){let s=r[i];t[i]||={};let n=t[i];e[i]||=[];for(let t of s)n[t.featureIndex]||(n[t.featureIndex]=!0,e[i].push(t))}}return e}(u),t)}function Gm(t,e){let i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function qm(t,e){let i=t.feature,r=e.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}async function Vm(t,e,i,r){let s=t;if(t.url?s=(await ce(await e.transformRequest(t.url,"Source"),i)).data:await Jd.frameAsync(i,r),!s)return null;let n=St(zt(s,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in s&&s.vector_layers&&(n.vectorLayerIds=s.vector_layers.map((t=>t.id))),n}var Zm=class t{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof Zu?new Zu(t.lng,t.lat):Zu.convert(t),this}setSouthWest(t){return this._sw=t instanceof Zu?new Zu(t.lng,t.lat):Zu.convert(t),this}extend(e){let i,r,s=this._sw,n=this._ne;if(e instanceof Zu)i=e,r=e;else{if(!(e instanceof t))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(t.convert(e)):this.extend(Zu.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(Zu.convert(e)):this;if(i=e._sw,r=e._ne,!i||!r)return this}return s||n?(s.lng=Math.min(i.lng,s.lng),s.lat=Math.min(i.lat,s.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new Zu(i.lng,i.lat),this._ne=new Zu(r.lng,r.lat)),this}getCenter(){return new Zu((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 Zu(this.getWest(),this.getNorth())}getSouthEast(){return new Zu(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){let{lng:e,lat:i}=Zu.convert(t),r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}intersects(e){if(!((e=t.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(e.getEast()-e.getWest());if(i>=360||r>=360)return!0;let s=Mt(this.getWest(),-180,180),n=Mt(this.getEast(),-180,180),o=Mt(e.getWest(),-180,180),a=Mt(e.getEast(),-180,180),l=s>n,h=o>a;return!(!l||!h)||(l?a>=s||o<=n:h?n>=o||s<=a:o<=n&&a>=s)}static convert(e){return e instanceof t||!e?e:new t(e)}static fromLngLat(e,i=0){let r=360*i/40075017,s=r/Math.cos(Math.PI/180*e.lat);return new t(new Zu(e.lng-s,e.lat-r),new Zu(e.lng+s,e.lat+r))}adjustAntiMeridian(){let e=new Zu(this._sw.lng,this._sw.lat),i=new Zu(this._ne.lng,this._ne.lat);return new t(e,e.lng>i.lng?new Zu(i.lng+360,i.lat):i)}},Wm=class{constructor(t,e,i){this.bounds=Zm.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){let e=2**t.z,i=Math.floor(Yu(this.bounds.getWest())*e),r=Math.floor(Xu(this.bounds.getNorth())*e),s=Math.ceil(Yu(this.bounds.getEast())*e),n=Math.ceil(Xu(this.bounds.getSouth())*e);return t.x>=i&&t.x<s&&t.y>=r&&t.y<n}},Hm=class extends ge{constructor(t,e,i,r){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,zt(this,St(e,["url","scheme","tileSize","promoteId","encoding"])),this._options=zt({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(t=!1){this._loaded=!1,this.fire(new am("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await Vm(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(zt(this,e),e.bounds&&(this.tileBounds=new Wm(e.bounds,this.minzoom,this.maxzoom)),this.fire(new am("data",{sourceDataType:"metadata"})),this.fire(new am("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,re(t)||this.fire(new _e(rt(t)))}}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return zt({},this._options)}async loadTile(t){let e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:await this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(t),etag:t.etag};i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let r="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,i)=>{t.reloadPromise={resolve:e,reject:i}}))}else t.actor=this.dispatcher.getReadyActor(),r="LT";t.abortController=new AbortController;try{let e=await t.actor.sendAsync({type:r,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e);let s={};return e?.etagUnmodified&&(s.unmodified=!0),s}catch(e){if(delete t.abortController,t.aborted||re(e))return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}async _getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||void 0===this.map._zoomLevelsToOverscale)return;let e=t.tileID.scaledTo(this.maxzoom).canonical,i=e.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:e,overzoomRequest:await this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(t,e){if(e?.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.etag=e?.etag,t.loadVectorData(e,this.map.painter),t.reloadPromise){let e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&await t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}})}async unloadTile(t){t.unloadVectorData(),t.actor&&await t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},Ym=class extends ge{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=zt({type:"raster"},e),zt(this,St(e,["url","scheme","tileSize"]))}async load(t=!1){this._loaded=!1,this.fire(new am("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await Vm(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(zt(this,e),e.bounds&&(this.tileBounds=new Wm(e.bounds,this.minzoom,this.maxzoom)),this.fire(new am("data",{sourceDataType:"metadata"})),this.fire(new am("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,re(t)||this.fire(new _e(rt(t)))}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(t){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return zt({},this._options)}setPremultiplyAlpha(t){return this._premultiplyAlpha===t||this.setSourceProperty((()=>{this._premultiplyAlpha=t})),this}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t){let e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"},s=await this.map._requestManager.transformRequest(e,"Tile");t.abortController=new AbortController;try{let e=await em.getImage(s,t.abortController,this.map._refreshExpiredTiles,r);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(e?.data){this.map._refreshExpiredTiles&&(e.cacheControl||e.expires)&&t.setExpiryData({cacheControl:e.cacheControl,expires:e.expires});let r=this.map.painter.context,s=r.gl,n=e.data;t.texture=this.map.painter.getTileTexture(n.width),t.texture?t.texture.update(n,{useMipmap:!0,premultiply:i}):(t.texture=new Ph(r,n,s.RGBA,{useMipmap:!0,premultiply:i}),t.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController)}async unloadTile(t){t.texture&&this.map.painter.saveTileTexture(t.texture)}hasTransition(){return!1}},Xm=class extends Ym{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=zt({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox",this.redFactor=e.redFactor,this.greenFactor=e.greenFactor,this.blueFactor=e.blueFactor,this.baseShift=e.baseShift}async loadTile(t){let e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=await this.map._requestManager.transformRequest(e,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{let e=await em.getImage(i,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(e?.data){let i=e.data;this.map._refreshExpiredTiles&&(e.cacheControl||e.expires)&&t.setExpiryData({cacheControl:e.cacheControl,expires:e.expires});let r=Nt(i)&&c()?i:await this.readImageNow(i),s={type:this.type,uid:t.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(t.actor&&"expired"!==t.state&&"reloading"!==t.state)return;await this.dispatcher.waitForInitComplete(),(!t.actor||"expired"===t.state)&&(t.actor=this.dispatcher.getReadyActor()),t.dem=await t.actor.sendAsync({type:"LDT",data:s}),t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}async readImageNow(t){if(typeof VideoFrame<"u"&&function(){if(null==u&&(u=!1,c())){let t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let e=0;e<25;e++){let i=4*e;t.fillStyle=`rgb(${i},${i+1},${i+2})`,t.fillRect(e%5,Math.floor(e/5),1,1)}let e=t.getImageData(0,0,5,5).data;for(let t=0;t<100;t++)if(t%4!=3&&e[t]!==t){u=!0;break}}}return u||!1}()){let e=t.width+2,i=t.height+2;try{return new yh({width:e,height:i},await async function(t,e,i,r,s){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let n=new VideoFrame(t,{timestamp:0});try{let o=n?.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw Error(`Unrecognized format ${o}`);let a=o.startsWith("BGR"),l=new Uint8ClampedArray(r*s*4);if(await n.copyTo(l,function(t,e,i,r,s){let n=4*Math.max(1,0),o=(Math.max(0,i)-i)*r*4+n,a=4*r,l=Math.max(0,e),h=Math.max(0,i);return{rect:{x:l,y:h,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,i+s)-h},layout:[{offset:o,stride:a}]}}(t,e,i,r,s)),a)for(let t=0;t<l.length;t+=4){let e=l[t];l[t]=l[t+2],l[t+2]=e}return l}finally{n.close()}}(t,-1,-1,e,i))}catch{}}return Jd.getImageData(t,1)}_getNeighboringTiles(t){let e=t.canonical,i=2**e.z,r=(e.x-1+i)%i,s=0===e.x?t.wrap-1:t.wrap,n=(e.x+1+i)%i,o=e.x+1===i?t.wrap+1:t.wrap,a={};return a[new Cf(t.overscaledZ,s,e.z,r,e.y).key]={backfilled:!1},a[new Cf(t.overscaledZ,o,e.z,n,e.y).key]={backfilled:!1},e.y>0&&(a[new Cf(t.overscaledZ,s,e.z,r,e.y-1).key]={backfilled:!1},a[new Cf(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new Cf(t.overscaledZ,o,e.z,n,e.y-1).key]={backfilled:!1}),e.y+1<i&&(a[new Cf(t.overscaledZ,s,e.z,r,e.y+1).key]={backfilled:!1},a[new Cf(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new Cf(t.overscaledZ,o,e.z,n,e.y+1).key]={backfilled:!1}),a}async unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&await t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}})}};function Jm(t,e){return e?t.properties[e]:t.id}function Km(t,e){let i={id:t.id};if(e.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(let i of e.removeProperties){let e=t.addOrUpdateProperties.findIndex((t=>t.key===i));e>-1&&t.addOrUpdateProperties.splice(e,1)}return(t.removeAllProperties||e.removeAllProperties)&&(i.removeAllProperties=!0),(t.removeProperties||e.removeProperties)&&(i.removeProperties=[...t.removeProperties||[],...e.removeProperties||[]]),(t.addOrUpdateProperties||e.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...t.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(t.newGeometry||e.newGeometry)&&(i.newGeometry=e.newGeometry||t.newGeometry),i}function Qm(t){if(!t)return{};let e={};return e.removeAll=t.removeAll,e.remove=new Set(t.remove||[]),e.add=new Map(t.add?.map((t=>[t.id,t]))),e.update=new Map(t.update?.map((t=>[t.id,t]))),e}function t_(t){return t&&0!==t.length?"number"==typeof t[0]?[t]:t.flatMap((t=>t_(t))):[]}function e_(t){return"GeometryCollection"===t.type?t.geometries.flatMap((t=>e_(t))):t_(t.coordinates)}function i_(t){let e,i=new Zm;switch(t.type){case"FeatureCollection":e=t.features.flatMap((t=>e_(t.geometry)));break;case"Feature":e=e_(t.geometry);break;default:e=e_(t)}if(0===e.length)return i;for(let t of e){let[e,r]=t;i.extend([e,r])}return i}var r_=class extends ge{constructor(t,e,i,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:e.data},this.actorPromise=i.getActor(),this.setEventedParent(r),this._data="string"==typeof e.data?{url:e.data}:{geojson:e.data},this._options=zt({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId,void 0!==e.clusterMaxZoom&&this.maxzoom<=e.clusterMaxZoom&&jt(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${e.clusterMaxZoom}".`),this.workerOptions=zt({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0===e.buffer?128:e.buffer),tolerance:this._pixelsToTileUnits(void 0===e.tolerance?.375:e.tolerance),extent:et,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1,promoteId:"string"==typeof e.promoteId?e.promoteId:void 0,cluster:e.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(e.clusterMaxZoom),minPoints:Math.max(2,e.clusterMinPoints||2),extent:et,radius:this._pixelsToTileUnits(e.clusterRadius||50),log:!1,generateId:e.generateId||!1}},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(t){return t*(et/this.tileSize)}_tileUnitsToPixels(t){return t/(et/this.tileSize)}_getClusterMaxZoom(t){let e=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||void 0===t||jt(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${e}"`),e}async load(){await this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data="string"==typeof t?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t},this._updateWorkerData()}updateData(t){return this._pendingWorkerUpdate.diff=function(t,e){if(!t)return e||{};if(!e)return t||{};let i=Qm(t),r=Qm(e);!function(t,e){e.removeAll&&(t.add.clear(),t.update.clear(),t.remove.clear(),e.remove.clear());for(let i of e.remove)t.add.delete(i),t.update.delete(i);for(let[i,r]of e.update){let s=t.update.get(i);s&&(e.update.set(i,Km(s,r)),t.update.delete(i))}}(i,r);let s={};if((i.removeAll||r.removeAll)&&(s.removeAll=!0),s.remove=new Set([...i.remove,...r.remove]),s.add=new Map([...i.add,...r.add]),s.update=new Map([...i.update,...r.update]),s.remove.size&&s.add.size)for(let t of s.add.keys())s.remove.delete(t);let n=function(t){let e={};return t.removeAll&&(e.removeAll=t.removeAll),t.remove&&(e.remove=Array.from(t.remove)),t.add&&(e.add=Array.from(t.add.values())),t.update&&(e.update=Array.from(t.update.values())),e}(s);return n}(this._pendingWorkerUpdate.diff,t),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return i_(await this.getData())}setClusterOptions(t){return this.workerOptions.geojsonVtOptions.cluster=t.cluster,void 0!==t.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:t,clusterOptions:e}=this.workerOptions.geojsonVtOptions;return{cluster:t,clusterMaxZoom:e.maxZoom,clusterRadius:this._tileUnitsToPixels(e.radius)}}async getClusterExpansionZoom(t){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}async getClusterChildren(t){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}async getClusterLeaves(t,e,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:e,offset:i}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate())return void jt(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:t,diff:e,updateCluster:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(t,e,i);void 0===t?e?this._pendingWorkerUpdate.diff=void 0:i&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(r),await this._updatePromise}async _getLoadGeoJSONParameters(t,e,i){let r=zt({type:this.type,source:this.id},this.workerOptions);return"string"==typeof t?(r.request=await this.map._requestManager.transformRequest(Jd.resolveURL(t),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r):void 0!==t?(r.data=t,r):e?(r.dataDiff=e,r):i?(r.updateCluster=!0,r):void 0}async _dispatchWorkerUpdate(t){this._isUpdatingWorker=!0,this.fire(new am("dataloading"));try{let e=await t,i=await(await this.actorPromise).sendAsync({type:"LD",data:e});if(this._isUpdatingWorker=!1,this._removed||i.abandoned)return void this.fire(new am("dataabort"));i.data&&(this._data={geojson:i.data});let r=this._applyDiffToSource(e.dataDiff),s=this._getShouldReloadTileOptions(r),n={};this._applyResourceTiming(n,i),this.fire(new am("data",{...n,sourceDataType:"metadata"})),this.fire(new am("data",{...n,sourceDataType:"content",shouldReloadTileOptions:s}))}catch(t){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new am("dataabort"));this.fire(new _e(rt(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(t,e){if(!this._collectResourceTiming)return;let i=e.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&zt(t,{resourceTiming:r})}_applyDiffToSource(t){if(!t)return;let e="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let t=function(t,e){let i=new Map;if(null==t||null==t.type)return i;if("Feature"===t.type){let r=Jm(t,e);return null==r?void 0:(i.set(r,t),i)}if("FeatureCollection"===t.type){let r=new Set;for(let s of t.features){let t=Jm(s,e);if(null==t||r.has(t))return;r.add(t),i.set(t,s)}return i}}(this._data.geojson,e);if(!t)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;let i=function(t,e,i){let r=[];if(e.removeAll)t.clear();else if(e.remove)for(let i of e.remove){let e=t.get(i);e&&(r.push(e.geometry),t.delete(i))}if(e.add)for(let s of e.add){let e=Jm(s,i);if(null==e)continue;let n=t.get(e);n&&r.push(n.geometry),r.push(s.geometry),t.set(e,s)}if(e.update)for(let i of e.update){let e=t.get(i.id);if(!e)continue;let s=!!i.newGeometry,n=i.removeAllProperties||i.removeProperties?.length>0||i.addOrUpdateProperties?.length>0;if(!s&&!n)continue;r.push(e.geometry);let o={...e};if(t.set(i.id,o),s&&(r.push(i.newGeometry),o.geometry=i.newGeometry),n){if(o.properties=i.removeAllProperties?{}:{...o.properties||{}},i.removeProperties)for(let t of i.removeProperties)delete o.properties[t];if(i.addOrUpdateProperties)for(let{key:t,value:e}of i.addOrUpdateProperties)o.properties[t]=e}}return r}(this._data.updateable,t,e);return t.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((t=>i_(t)))}}shouldReloadTile(t,{affectedBounds:e}){if("loading"===t.state)return!0;if("unloaded"===t.state)return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,s=function({x:t,y:e,z:i},r=0){let s=Ku((t-r)/2**i),n=Qu((e+1+r)/2**i),o=Ku((t+1+r)/2**i),a=Qu((e-r)/2**i);return new Zm([s,n],[o,a])}(t.tileID.canonical,i/r);for(let t of e)if(s.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(t){let e=t.actor?"RT":"LT";t.actor=await this.actorPromise;let i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;try{let r=await(await this.actorPromise).sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(r,this.map.painter,"RT"===e)}catch(e){if(delete t.abortController,t.aborted||re(e))return;throw e}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}async unloadTile(t){t.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then((t=>t.sendAsync({type:"RS",data:{type:this.type,source:this.id}})))}serialize(){return zt({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}},s_=class extends ge{constructor(t,e,i,r){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}async load(t){this._loaded=!1,this.fire(new am("dataloading")),this.url=this.options.url;let e=await this.map._requestManager.transformRequest(this.url,"Image");this._request=new AbortController;try{let i=await em.getImage(e,this._request);this._request=null,this._loaded=!0,i?.data&&(this.image=i.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,re(t)||this.fire(new _e(rt(t)))}}loaded(){return this._loaded}updateImage(t){return this._request&&=(this._request.abort(),null),"image"in t?(this._loaded=!0,this.image=t.image,t.coordinates&&(this.coordinates=t.coordinates),this.texture=null,this._finishLoading(),this):t.url?(this.options.url=t.url,this.load(t.coordinates).finally((()=>this.texture=null)),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new am("data",{sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&=(this._request.abort(),null)}setCoordinates(t){this.coordinates=t;let e=t.map(ec.fromLngLat);return this.tileID=function(t){let e=jf.fromPoints(t),i=e.width(),r=e.height(),s=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),n=2**s;return new Pf(s,Math.floor((e.minX+e.maxX)/2*n),Math.floor((e.minY+e.maxY)/2*n))}(e),this.terrainTileRanges=this._getOverlappingTileRanges(e),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=e.map((t=>this.tileID.getTilePoint(t)._round())),this.flippedWindingOrder=function(t){return(t[1].x-t[0].x)*(t[2].y-t[0].y)-(t[1].y-t[0].y)*(t[2].x-t[0].x)<0}(this.tileCoords),this.fire(new am("data",{sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;let t=this.map.painter.context,e=t.gl;this.texture||(this.texture=new Ph(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));let i=!1;for(let t in this.tiles){let e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new am("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(t){this.tileID?.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){let{minX:e,minY:i,maxX:r,maxY:s}=jf.fromPoints(t),n={};for(let t=0;t<=25;t++){let o=2**t,a=Math.floor(e*o),l=Math.floor(i*o),h=Math.floor(r*o),u=Math.floor(s*o),c=(a%o+o)%o,f=h%o,p=Math.floor(a/o),d=Math.floor(h/o);n[t]={minWrap:p,maxWrap:d,minTileXWrapped:c,maxTileXWrapped:f,minTileY:l,maxTileY:u}}return n}},n_=class extends s_{constructor(t,e,i,r){super(t,e,i,r),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=e}async load(){this._loaded=!1;let t=this.options;this.urls=[];for(let e of t.urls)this.urls.push((await this.map._requestManager.transformRequest(e,"Source")).url);try{let t=await(t=>{let e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(let i of t){let t=window.document.createElement("source");fe(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}}))})(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new _e(rt(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){let e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new _e(new Ce(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;let t=this.map.painter.context,e=t.gl;this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new Ph(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));let i=!1;for(let t in this.tiles){let e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new am("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},o_=class extends s_{constructor(t,e,i,r){super(t,e,i,r),e.coordinates?(!Array.isArray(e.coordinates)||4!==e.coordinates.length||e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t)))))&&this.fire(new _e(new Ce(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new _e(new Ce(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new _e(new Ce(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"!=typeof e.canvas&&!(e.canvas instanceof HTMLCanvasElement)&&this.fire(new _e(new Ce(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new _e(new Ce(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}async load(){this._loaded=!0,this.canvas||=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new _e(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(),!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;let e=this.map.painter.context,i=e.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new Ph(e,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new am("data",{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(let t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}};const a_={},l_="RTLPluginLoaded";var h_=class extends ge{constructor(...t){super(...t),this.status="unavailable",this.url=null,this.dispatcher=Bm()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}async setRTLTextPlugin(t,e=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Jd.resolveURL(t),!this.url)throw Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new me(l_))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let u_=null;function c_(){return u_||=new h_,u_}var f_=class{constructor(t,e){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=Et(),this.uses=0,this.tileSize=e,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:e,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=e,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=Qd(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(t){return this.rttObjects[t]}acquireRTT(t,e,i){return this.rttObjects[e]=t.acquireRTT(i)}releaseRTT(t){if(0!==this.rttObjects.length){for(let e of this.rttObjects)e&&t.releaseRTT(e);this.rttObjects.length=0}}loadVectorData(t,e,i){if(!0!==t?.etagUnmodified)if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestEncoding=t.encoding,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){let i={};if(!e)return i;for(let r of t){let t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(let e of t)i[e.id]=r}}return i}(t.buckets,e?.style),this.hasSymbolBuckets=!1;for(let t in this.buckets){let e=this.buckets[t];if(e instanceof pf){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let t in this.buckets){let e=this.buckets[t];if(e instanceof pf&&e.hasRTLText){this.hasRTLText=!0,c_().lazyLoad();break}}this.queryPadding=0;for(let t in this.buckets){let i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new ba;else this.state="loaded"}unloadVectorData(){for(let t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(let e in this.buckets){let i=this.buckets[e];i.uploadPending()&&i.upload(t)}let e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ph(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new Ph(t,this.glyphAtlasImage,e.ALPHA),null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,s,n,o,a,l,h,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:s,scale:n,tileSize:this.tileSize,pixelPosMatrix:h,transform:a,params:o,queryPadding:this.queryPadding*l,getElevation:u},t,e,i):{}}querySourceFeatures(t,e){let i=this.latestFeatureIndex;if(!i?.rawTileData)return;let r=i.loadVTLayers(),s=e?.sourceLayer?e.sourceLayer:"",n=r._geojsonTileLayer||r[s];if(!n)return;let o=an(e?.filter,`querySourceFeatures[${s}].filter`,e?.globalState),{z:a,x:l,y:h}=this.tileID.canonical,u={z:a,x:l,y:h};for(let e=0;e<n.length;e++){let r=n.feature(e);if(o.needGeometry){let t=$l(r,!0);if(!o.filter(new wo(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!o.filter(new wo(this.tileID.overscaledZ),r))continue;let c=i.getId(r,s),f=new Lf(r,a,l,h,c);f.tile=u,t.push(f)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){let e=this.expirationTime;if(t.cacheControl){let e=function(t){let e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,s)=>{let n=r||s;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){let t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){let t=Date.now(),i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{let r=this.expirationTime-e;r?this.expirationTime=t+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),2**31-1)}setFeatureState(t,e,i){if(!this.latestFeatureIndex?.rawTileData||0===Object.keys(t).length||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=this.latestFeatureIndex.loadVTLayers();for(let i in this.buckets){if(!e.style.hasLayer(i))continue;let s=this.buckets[i],n=s.layers[0].sourceLayer||"_geojsonTileLayer",o=r[n],a=t[n];if(!o||!a||0===a.length)continue;s.update(a,o,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=e?.style?.getLayer(i);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(s)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Qd()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=Qd()+t}setDependencies(t,e){let i={};for(let t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(let i of t){let t=this.dependencies[i];if(t)for(let i of e)if(t[i])return!0}return!1}};function p_(t){let e=[];for(let i in t)e.push({id:i,state:t[i]});return e}var d_=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(t,e,i){let r=String(e);if(this.stateChanges[t]||={},this.stateChanges[t][r]||={},zt(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(let e in this.state[t])if(e===r){this.deletedStates[t][r]={};for(let s in this.state[t][e])void 0===i[s]&&(this.deletedStates[t][r][s]=null)}else this.deletedStates[t][e]=null}else if(null===this.deletedStates[t]?.[r]){this.deletedStates[t][r]={};for(let e in this.state[t][r])void 0===i[e]&&(this.deletedStates[t][r][e]=null)}else for(let e in i)null===this.deletedStates[t]?.[r]?.[e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;let r=String(e);if(this.deletedStates[t]||={},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]||={},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]?.[r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){let i=String(e),r=zt({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){let i=this.deletedStates[t][e];if(null===i)return{};for(let t in i)delete r[t]}return r}initializeTileState(t,e){let i={};for(let t in this.state)i[t]=p_(this.state[t]);t.setFeatureState(i,e,this.revision)}coalesceChanges(t,e){let i={};for(let t in this.stateChanges){this.state[t]||={},i[t]||={};for(let e in this.stateChanges[t])this.state[t][e]||={},zt(this.state[t][e],this.stateChanges[t][e]),i[t][e]=this.state[t][e]}for(let t in this.deletedStates)if(this.state[t]||={},i[t]||={},null===this.deletedStates[t])for(let e in this.state[t])this.state[t][e]={},i[t][e]={};else for(let e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(let i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[t][e]=this.state[t][e]}if(this.stateChanges={},this.deletedStates={},0===Object.keys(i).length)return;this.revision++;let r={};for(let t in i)r[t]=p_(i[t]);t.setFeatureState(r,e,this.revision)}};function m_(t,e,i){let r=e.intersectsFrustum(t);if(!i||0===r)return r;let s=e.intersectsPlane(i);return 0===s?0:2===r&&2===s?2:1}function __(t,e,i){let r=0,s=(i-e)/10;for(let n=0;n<10;n++)r+=s*Math.cos(e+(n+.5)/10*(i-e))**+t;return r}function g_(t,e){return function(i,r,s,n,o){let a=2*((t-1)/Pt(Math.cos(qt(ic-o))/Math.cos(qt(ic)))-1),l=Math.acos(s/n),h=2*__(a-1,0,qt(o/2)),u=Math.min(qt(ic),l+qt(o/2)),c=__(a-1,Math.min(u,l-qt(o/2)),u),f=Math.atan(r/s),p=i;return p+=Pt(n/Math.hypot(r,s)/Math.max(.5,Math.cos(qt(o/2)))),p+=a*Pt(Math.cos(f))/2,p-=Pt(Math.max(1,c/h/e))/2,p}}const y_=g_(9.314,3);function v_(t,e){let i=(e.roundZoom?Math.round:Math.floor)(t.zoom+Pt(t.tileSize/e.tileSize));return Math.max(0,i)}function w_(t,e){let i=t.getCameraFrustum(),r=t.getClippingPlane(),s=t.screenPointToMercatorCoordinate(t.getCameraPoint()),n=ec.fromLngLat(t.center,t.elevation);s.z=n.z+Math.cos(t.pitchInRadians)*t.cameraToCenterDistance/t.worldSize;let o=function(t){let e=xt((15-(ic-t.pitch-t.fov/2))/15,0,1);return t.elevation+500*e}(t),a=t.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(t,e),h=v_(t,e),u=e.minzoom||0,c=void 0===e.maxzoom?t.maxZoom:e.maxzoom,f=Math.min(Math.max(0,h),c),p=2**f,d=[p*s.x,p*s.y,0],m=[p*n.x,p*n.y,0],_=Math.hypot(n.x-s.x,n.y-s.y),g=Math.abs(n.z-s.z),y=Math.hypot(_,g),v=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),w=[],b=[];if(t.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)w.push(v(-t)),w.push(v(t));for(w.push(v(0));w.length>0;){let p=w.pop(),_=p.x,v=p.y,x=p.fullyVisible,M={x:_,y:v,z:p.zoom},z=a.getTileBoundingVolume(M,p.wrap,o,e);if(!x){let t=m_(i,z,r);if(0===t)continue;x=2===t}let S=a.distanceToTile2d(s.x,s.y,M,z),T=h;l&&(T=(e.calculateTileZoom||y_)(t.zoom+Pt(t.tileSize/e.tileSize),S,g,y,t.fov)),T=(e.roundZoom?Math.round:Math.floor)(T),T=Math.max(0,T);let E=Math.min(T,c);if(p.wrap=a.getWrap(n,M,p.wrap),p.zoom>=E){if(p.zoom<u)continue;let t=f-p.zoom,i=d[0]-.5-(_<<t),r=d[1]-.5-(v<<t),s=e.reparseOverscaled?Math.max(p.zoom,T):p.zoom;b.push({tileID:new Cf(p.zoom===c?s:p.zoom,p.wrap,p.zoom,_,v),distanceSq:tt([m[0]-.5-_,m[1]-.5-v]),tileDistanceToCamera:Math.sqrt(i*i+r*r)})}else for(let t=0;t<4;t++)w.push({zoom:p.zoom+1,x:(_<<1)+t%2,y:(v<<1)+(t>>1),wrap:p.wrap,fullyVisible:x})}return b.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}const b_=jf.fromPoints([new l(0,0),new l(et,et)]);function x_(t){return"raster"===t||"image"===t||"video"===t}function M_(t,e,i,r,s,n,o){if(!e.hasData())return!1;let{tileID:a,fadingRole:l,fadingDirection:h,fadingParentID:u}=e;if(0===l&&1===h&&u)return i[u.key]=u,!0;let c=Math.max(a.overscaledZ-s,n);for(let s=a.overscaledZ-1;s>=c;s--){let n=a.scaledTo(s),l=t.getLoadedTile(n);if(l)return e.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:l.tileID,fadeEndTime:r+o}),l.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),i[n.key]=n,!0}return!1}function z_(t,e,i,r,s,n){if(!e.hasData())return!1;let o=e.tileID.children(s),a=S_(t,e,o,i,r,s,n);if(a)return!0;for(let l of o)S_(t,e,l.children(s),i,r,s,n)&&(a=!0);return a}function S_(t,e,i,r,s,n,o){if(i[0].overscaledZ>=n)return!1;let a=!1;for(let n of i){let i=t.getLoadedTile(n);if(!i)continue;let{fadingRole:l,fadingDirection:h,fadingParentID:u}=i;(0!==l||0!==h||!u)&&(i.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:e.tileID,fadeEndTime:s+o}),e.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:s+o})),r[n.key]=n,a=!0}return a}function T_(t,e,i,r){let s=t.tileID;return!!t.selfFading||!t.hasData()&&(!!e.has(s)&&(t.setSelfFadeLogic(i+r),!0))}function E_(t,e){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x,r=e.tileID.canonical.y-t.tileID.canonical.y,s=2**t.tileID.canonical.z,n=e.tileID.key;(0!==i||0!==r)&&(Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles?.[n]&&(t.neighboringTiles[n].backfilled=!0))))}var A_=class{constructor(){this._tiles={}}handleWrapJump(t){let e={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e}setFeatureState(t,e,i){for(let r in this._tiles)this._tiles[r].setFeatureState(t,e,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((t=>t.tileID)).sort($f).map((t=>t.key)):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,e){this._tiles[t]=e}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){let e=this.getTileById(t.key);return e?.hasData()?e:null}isIdRenderable(t,e=!1){return this.getTileById(t)?.isRenderable(e)}getRenderableIds(t=0,e){let i=[];for(let t of this.getAllIds())this.isIdRenderable(t,e)&&i.push(this.getTileById(t));return e?i.sort(((e,i)=>{let r=e.tileID,s=i.tileID,n=new l(r.canonical.x,r.canonical.y)._rotate(-t),o=new l(s.canonical.x,s.canonical.y)._rotate(-t);return r.overscaledZ-s.overscaledZ||o.y-n.y||o.x-n.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort($f).map((t=>t.key))}},P_=class t extends ge{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>{this._dataHandler(t)})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((t,e,i,r)=>{let s=new((t=>{switch(t){case"geojson":return r_;case"image":return s_;case"raster":return Ym;case"raster-dem":return Xm;case"vector":return Hm;case"video":return n_;case"canvas":return o_}return a_[t]})(e.type))(t,e,i,r);if(s.id!==t)throw Error(`Expected Source id to be ${t} instead of ${s.id}`);return s})(t,e,i,this),this._inViewTiles=new A_,this._outOfViewCache=new Vd(0,(t=>this._unloadTile(t))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new d_,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(t)}onRemove(t){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(t),this._inViewTiles=new A_}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(let t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(t,e,i){try{let r=await this._source.loadTile(t);this._tileLoaded(t,e,i,r)}catch(e){t.state="errored",404===e.status?this.update(this.transform,this.terrain):this._source.fire(new _e(rt(e),{tile:t}))}}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new am("dataabort",{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(let e of this._inViewTiles.getAllTiles())e.upload(t),e.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,t)}hasRenderableParent(t){let e=t.overscaledZ-1;if(e>=this._source.minzoom){let i=this.getLoadedTile(t.scaledTo(e));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(t,e){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);e&&!this._source.shouldReloadTile(r,e)||(t?this._reloadTile(i,"errored"===r.state?"loading":"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}async _reloadTile(t,e){let i=this._inViewTiles.getTileById(t);i&&("loading"!==i.state&&(i.state=e),await this._loadTile(i,t,e))}_tileLoaded(t,e,i,r){t.timeAdded=Qd(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),!r?.unmodified&&("raster-dem"===this.getSource().type&&t.dem&&function(t,e){let i=e.getRenderableIds();for(let r of i){if(!t.neighboringTiles?.[r])continue;let i=e.getTileById(r);t.neighboringTiles[r].backfilled||E_(t,i),!i.neighboringTiles?.[t.tileID.key]?.backfilled&&E_(i,t)}}(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new am("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(e,i){let r=this._getLoadedDescendents(i),s=new Set;for(let n of i){let i=r[n.key];if(!i?.length){s.add(n);continue}let o=n.overscaledZ+t.maxOverzooming,a=i.filter((t=>t.tileID.overscaledZ<=o));if(!a.length){s.add(n);continue}let l=Math.min(...a.map((t=>t.tileID.overscaledZ))),h=a.filter((t=>t.tileID.overscaledZ===l)).map((t=>t.tileID));for(let t of h)e[t.key]=t;this._areDescendentsComplete(h,l,n.overscaledZ)||s.add(n)}return s}_getLoadedDescendents(t){let e={};for(let i of this._inViewTiles.getAllTiles().filter((t=>t.hasData())))for(let r of t)i.tileID.isChildOf(r)&&(e[r.key]||=[],e[r.key].push(i));return e}_areDescendentsComplete(t,e,i){return 1===t.length&&t[0].isOverscaled()?t[0].overscaledZ===e:4**(e-i)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),i=Math.floor(e*(null===this._maxTileCacheZoomLevels?ne.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(r)}handleWrapJump(t){let e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);this._prevLng=t,e&&(this._inViewTiles.handleWrapJump(e),this._resetTileReloadTimers())}update(t,e){if(!this._sourceLoaded||this._paused)return;let i;this.transform=t,this.terrain=e,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Cf(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=w_(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?Math.max(this._source.maxzoom,t.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:e,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(i=i.filter((t=>this._source.hasTile(t))))):i=[],this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));let r=0===i.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new am("data",{sourceDataType:"idle",sourceId:this.id}));let s=v_(t,this._source),n=this._updateRetainedTiles(i,s),o=x_(this._source.type);o&&this._rasterFadeDuration>0&&!e&&function(t,e,i,r,s,n,o){let a=Qd(),l=function(t){if(!t.length)return new Set;let e=Math.max(...t.map((t=>t.canonical.z))),i=1/0,r=-1/0,s=1/0,n=-1/0,o=[];for(let a of t){let{x:t,y:l,z:h}=a.canonical,u=2**(e-h),c=t*u,f=l*u;o.push({id:a,x:c,y:f}),c<i&&(i=c),c>r&&(r=c),f<s&&(s=f),f>n&&(n=f)}let a=new Set;for(let t of o)(t.x===i||t.x===r||t.y===s||t.y===n)&&a.add(t.id);return a}(e);for(let h of e){let e=t.getTileById(h.key);(0===e.fadingDirection||0===e.fadeOpacity)&&e.resetFadeLogic(),!M_(t,e,i,a,r,s,o)&&(z_(t,e,i,a,n,o)||T_(e,l,a,o)||e.resetFadeLogic())}}(this._inViewTiles,i,n,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?this._cleanUpRasterTiles(n):this._cleanUpVectorTiles(n)}_cleanUpRasterTiles(t){for(let e of this._inViewTiles.getAllIds())t[e]||this._removeTile(e)}_cleanUpVectorTiles(t){for(let e of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(e);t[e]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(e):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(e)}}_addTerrainIdealTiles(t){let e=[];for(let i of t)if(i.canonical.z>this._source.minzoom){let t=i.scaledTo(i.canonical.z-1);e.push(t);let r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));e.push(r)}return t.concat(e)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(e,i){let r=new Set;for(let t of e)this._addTile(t).hasData()||r.add(t);let s=e.reduce(((t,e)=>(t[e.key]=e,t)),{}),n=this._retainLoadedChildren(s,r),o={},a=Math.max(i-t.maxUnderzooming,this._source.minzoom);for(let t of n){let e=this._inViewTiles.getTileById(t.key),i=e?.wasRequested();for(let r=t.overscaledZ-1;r>=a;--r){let n=t.scaledTo(r);if(o[n.key])break;if(o[n.key]=!0,e=this.getTile(n),!e&&i&&(e=this._addTile(n)),e){let t=e.hasData();if((t||!this.map?.cancelPendingTileRequestsWhileZooming||i)&&(s[n.key]=n),i=e.wasRequested(),t)break}}}return s}_addTile(t){let e=this._inViewTiles.getTileById(t.key);if(e)return e;e=this._outOfViewCache.getAndRemove(t),e&&(e.resetFadeLogic(),this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null));let i=e;return e||(e=new f_(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(e,t.key,e.state)),e.uses++,this._inViewTiles.setTile(t.key,e),i||this._source.fire(new am("dataloading",{tile:e,coord:e.tileID})),e}_setTileReloadTimer(t,e){this._clearTileReloadTimer(t);let i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_clearTileReloadTimer(t){let e=this._timers[t];e&&(clearTimeout(e),delete this._timers[t])}_resetTileReloadTimers(){for(let t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(let t of this._inViewTiles.getAllIds()){let e=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,e)}}refreshTiles(t){for(let e of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(e);!this._inViewTiles.isIdRenderable(e)&&"errored"!=i.state||t.some((t=>t.equals(i.tileID.canonical)))&&this._reloadTile(e,"expired")}}_removeTile(t){let e=this._inViewTiles.getTileById(t);e&&(e.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),!(e.uses>0)&&(e.hasData()&&"reloading"!==e.state?this._outOfViewCache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){if("source"===t.dataType){if("metadata"===t.sourceDataType)return void(this._sourceLoaded=!0);"content"!==t.sourceDataType||!this._sourceLoaded||this._paused||(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,e,i){let r=[],s=this.transform;if(!s)return r;let n=s.getCoveringTilesDetailsProvider().allowWorldCopies(),o=i?s.getCameraQueryGeometry(t):t,a=t=>s.screenPointToMercatorCoordinate(t,this.terrain),l=this.transformBbox(t,a,!n),h=this.transformBbox(o,a,!n),u=this.getIds(),c=jf.fromPoints(h);for(let t of u){let i=this._inViewTiles.getTileById(t);if(i.holdingForSymbolFade())continue;let o=n?[i.tileID]:[i.tileID.unwrapTo(-1),i.tileID.unwrapTo(0)],a=2**(s.zoom-i.tileID.overscaledZ),u=e*i.queryPadding*et/i.tileSize/a;for(let t of o){let e=c.map((e=>t.getTilePoint(new ec(e.x,e.y))));if(e.expandBy(u),e.intersects(b_)){let e=l.map((e=>t.getTilePoint(e))),s=h.map((e=>t.getTilePoint(e)));r.push({tile:i,tileID:n?t:t.unwrapTo(0),queryGeometry:e,cameraQueryGeometry:s,scale:a})}}}return r}transformBbox(t,e,i){let r=t.map(e);if(i){let i=jf.fromPoints(t);i.shrinkBy(.001*Math.min(i.width(),i.height()));let s=i.map(e);jf.fromPoints(r).covers(s)||(r=r.map((t=>t.x>.5?new ec(t.x-1,t.y,t.z):t)))}return r}getVisibleCoordinates(t){let e=this.getRenderableIds(t).map((t=>this._inViewTiles.getTileById(t).tileID));return this.transform&&this.transform.populateCache(e),e}hasTransition(){return!!this._source.hasTransition()||x_(this._source.type)&&function(t,e){if(e<=0)return!1;let i=Qd();for(let e of t.getAllTiles())if(e.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,e,i){t||=Rf,this._state.updateState(t,e,i)}removeFeatureState(t,e,i){t||=Rf,this._state.removeFeatureState(t,e,i)}getFeatureState(t,e){return t||=Rf,this._state.getState(t,e)}setDependencies(t,e,i){let r=this._inViewTiles.getTileById(t);r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(let i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(t,e)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter((i=>!i.hasDependency(t,e)))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}},I_=class{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=xt(t,0,1);let e=1,i=this._distances[e],r=t*this.paddedLength+this.padding;for(;i<r&&e<this._distances.length;)i=this._distances[++e];let s=e-1,n=this._distances[s],o=i-n,a=o>0?(r-n)/o:0;return this.points[s].mult(1-a).add(this.points[e].mult(a))}};function C_(t,e){let i=!0;return"always"===t||("never"===t||"never"===e)&&(i=!1),i}var k_=class{constructor(t,e,i){let r=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,s){this._forEachCell(e,i,r,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(s)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,s,n){this.boxCells[s].push(n)}_insertCircleCell(t,e,i,r,s,n){this.circleCells[s].push(n)}_query(t,e,i,r,s,n,o){if(i<0||t>this.width||r<0||e>this.height)return[];let a=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(s)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t<this.boxKeys.length;t++)a.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){let e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];a.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,a,{hitTest:s,overlapMode:n,seenUids:{box:{},circle:{}}},o);return a}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,s,n){return this._query(t,e,i,r,!0,s,n).length>0}hitTestCircle(t,e,i,r,s){let n=t-i,o=t+i,a=e-i,l=e+i;if(o<0||n>this.width||l<0||a>this.height)return!1;let h=[];return this._forEachCell(n,a,o,l,this._queryCellCircle,h,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),h.length>0}_queryCell(t,e,i,r,s,n,o,a){let{seenUids:l,hitTest:h,overlapMode:u}=o,c=this.boxCells[s],f=1e-6;if(null!==c){let s=this.bboxes;for(let o of c)if(!l.box[o]){l.box[o]=!0;let c=4*o,p=this.boxKeys[o];if(t<=s[c+2]+f&&e<=s[c+3]+f&&i>=s[c+0]-f&&r>=s[c+1]-f&&(!a||a(p))&&(!h||!C_(u,p.overlapMode))&&(n.push({key:p,x1:s[c],y1:s[c+1],x2:s[c+2],y2:s[c+3]}),h))return!0}}let p=this.circleCells[s];if(null!==p){let s=this.circles;for(let o of p)if(!l.circle[o]){l.circle[o]=!0;let c=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(s[c],s[c+1],s[c+2],t,e,i,r)&&(!a||a(f))&&(!h||!C_(u,f.overlapMode))){let t=s[c],e=s[c+1],i=s[c+2];if(n.push({key:f,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),h)return!0}}}return!1}_queryCellCircle(t,e,i,r,s,n,o,a){let{circle:l,seenUids:h,overlapMode:u}=o,c=this.boxCells[s];if(null!==c){let t=this.bboxes;for(let e of c)if(!h.box[e]){h.box[e]=!0;let i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(r))&&!C_(u,r.overlapMode))return n.push(!0),!0}}let f=this.circleCells[s];if(null!==f){let t=this.circles;for(let e of f)if(!h.circle[e]){h.circle[e]=!0;let i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!C_(u,r.overlapMode))return n.push(!0),!0}}}_forEachCell(t,e,i,r,s,n,o,a){let l=this._convertToXCellCoord(t),h=this._convertToYCellCoord(e),u=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let f=l;f<=u;f++)for(let l=h;l<=c;l++)if(s.call(this,t,e,i,r,this.xCellCount*l+f,n,o,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,s,n){let o=r-t,a=s-e,l=i+n;return l*l>o*o+a*a}_circleAndRectCollide(t,e,i,r,s,n,o){let a=(n-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;let h=(o-s)/2,u=Math.abs(e-(s+h));if(u>h+i)return!1;if(l<=a||u<=h)return!0;let c=l-a,f=u-h;return c*c+f*f<=i*i}};function D_(t,e){let i=1/(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),r=1/(e[8]*e[8]+e[9]*e[9]+e[10]*e[10]),s=e[0]*i,n=e[4]*i,o=e[8]*r,a=e[1]*i,l=e[5]*i,h=e[9]*r,u=e[2]*i,c=e[6]*i,f=e[10]*r;t[0]=s,t[1]=n,t[2]=o,t[4]=a,t[5]=l,t[6]=h,t[8]=u,t[9]=c,t[10]=f;let p=e[12],d=e[13],m=e[14];return t[12]=-s*p-a*d-u*m,t[13]=-n*p-l*d-c*m,t[14]=-o*p-h*d-f*m,t[3]=0,t[7]=0,t[11]=0,t[15]=1,t}const F_=d();function $_(t,e,i){let r=d();if(!t){let{vecSouth:t,vecEast:i}=R_(e),s=Xd();s[0]=i[0],s[1]=i[1],s[2]=t[0],s[3]=t[1],function(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=i*n-s*r;o&&(t[0]=n*(o=1/o),t[1]=-r*o,t[2]=-s*o,t[3]=i*o)}(s,s),r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3]}return w(r,r,[1/i,1/i,1]),r}function j_(t,e,i,r){if(t){let t=d();if(!e){let{vecSouth:e,vecEast:r}=R_(i);t[0]=r[0],t[1]=r[1],t[4]=e[0],t[5]=e[1]}return w(t,t,[r,r,1]),t}return i.pixelsToClipSpaceMatrix}function R_(t){let e=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),r=Math.cos(t.pitchInRadians),s=Math.cos(t.bearingInRadians),n=Math.sin(t.bearingInRadians),o=q();o[0]=-s*r*i-n*e,o[1]=-n*r*i+s*e;let a=Y(o);a<1e-9?K(o):W(o,o,1/a);let l=q();l[0]=s*r*e-n*i,l[1]=n*r*e+s*i;let h=Y(l);return h<1e-9?K(l):W(l,l,1/h),{vecEast:l,vecSouth:o}}function O_(t,e,i,r){let s;r?(s=[t,e,r(t,e),1],N(s,s,i)):(s=[t,e,0,1],eg(s,s,i));let n=s[3];return{point:new l(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function L_(t,e){return.5+t/e*.5}function B_(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function N_(t,e,i,r,s,n,o,a,h,u,c,f,p){let d=i?t.textSizeData:t.iconSizeData,m=nf(d,e.transform.zoom),_=[256/e.width*2+1,256/e.height*2+1],g=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=e.transform.width/e.transform.height,b=!1;for(let i=0;i<v.length;i++){let x=v.get(i);if(x.hidden||2===x.writingMode&&!b){tg(x.numGlyphs,g);continue}b=!1;let M=new l(x.anchorX,x.anchorY),z={getElevation:p,pitchedLabelPlaneMatrix:r,lineVertexArray:y,pitchWithMap:n,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:M,unwrappedTileID:h,width:u,height:c,translation:f},S=Y_(x.anchorX,x.anchorY,z);if(!B_(S.point,_)){tg(x.numGlyphs,g);continue}let T=L_(e.transform.cameraToCenterDistance,S.signedDistanceFromCamera),E=sf(d,m,x),A=n?E*e.transform.getPitchedTextCorrection(x.anchorX,x.anchorY,h)/T:E*T,P=q_({projectionContext:z,pitchedLabelPlaneMatrixInverse:s,symbol:x,fontSize:A,flip:!1,keepUpright:o,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:a});b=P.useVertical,(P.notEnoughRoom||b||P.needsFlipping&&q_({projectionContext:z,pitchedLabelPlaneMatrixInverse:s,symbol:x,fontSize:A,flip:!0,keepUpright:o,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:a}).notEnoughRoom)&&tg(x.numGlyphs,g)}i?t.text.dynamicLayoutVertexBuffer.updateData(g):t.icon.dynamicLayoutVertexBuffer.updateData(g)}function U_(t,e,i,r,s,n,o,a){let l=n.glyphStartIndex+n.numGlyphs,h=n.lineStartIndex,u=n.lineStartIndex+n.lineLength,c=e.getoffsetX(n.glyphStartIndex),f=e.getoffsetX(l-1),p=K_(t*c,i,r,s,n.segment,h,u,a,o);if(!p)return null;let d=K_(t*f,i,r,s,n.segment,h,u,a,o);return!d||a.projectionCache.anyProjectionOccluded?null:{first:p,last:d}}function G_(t,e,i,r){return 1===t&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:(2===t?e.y<i.y:e.x>i.x)?{needsFlipping:!0}:null}function q_(t){let e,{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:s,fontSize:n,flip:o,keepUpright:a,glyphOffsetArray:h,dynamicLayoutVertexArray:u,aspectRatio:c,rotateToLine:f}=t,p=n/24,d=s.lineOffsetX*p,m=s.lineOffsetY*p;if(s.numGlyphs>1){let t=s.glyphStartIndex+s.numGlyphs,n=s.lineStartIndex,l=s.lineStartIndex+s.lineLength,u=U_(p,h,d,m,o,s,f,i);if(!u)return{notEnoughRoom:!0};let _=H_(u.first.point.x,u.first.point.y,i,r),g=H_(u.last.point.x,u.last.point.y,i,r);if(a&&!o){let t=G_(s.writingMode,_,g,c);if(t)return t}e=[u.first];for(let r=s.glyphStartIndex+1;r<t-1;r++){let t=K_(p*h.getoffsetX(r),d,m,o,s.segment,n,l,i,f);if(!t)return{notEnoughRoom:!0};e.push(t)}e.push(u.last)}else{if(a&&!o){let t=W_(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,e=s.lineStartIndex+s.segment+1,n=new l(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),o=W_(n.x,n.y,i),a=o.signedDistanceFromCamera>0?o.point:V_(i.tileAnchorPoint,n,t,1,i),h=H_(t.x,t.y,i,r),u=H_(a.x,a.y,i,r),f=G_(s.writingMode,h,u,c);if(f)return f}let t=K_(p*h.getoffsetX(s.glyphStartIndex),d,m,o,s.segment,s.lineStartIndex,s.lineStartIndex+s.lineLength,i,f);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};e=[t]}for(let t of e)hf(u,t.point,t.angle);return{}}function V_(t,e,i,r,s){let n=t.add(t.sub(e)._unit()),o=W_(n.x,n.y,s).point,a=i.sub(o);return i.add(a._mult(r/a.mag()))}function Z_(t,e,i){let r=e.projectionCache;if(r.projections[t])return r.projections[t];let s=new l(e.lineVertexArray.getx(t),e.lineVertexArray.gety(t)),n=W_(s.x,s.y,e);if(n.signedDistanceFromCamera>0)return r.projections[t]=n.point,r.anyProjectionOccluded||=n.isOccluded,n.point;let o=t-i.direction;return V_(0===i.distanceFromAnchor?e.tileAnchorPoint:new l(e.lineVertexArray.getx(o),e.lineVertexArray.gety(o)),s,i.previousVertex,i.absOffsetX-i.distanceFromAnchor+1,e)}function W_(t,e,i){let r,s=t+i.translation[0],n=e+i.translation[1];return i.pitchWithMap?(r=O_(s,n,i.pitchedLabelPlaneMatrix,i.getElevation),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(s,n,i.unwrappedTileID,i.getElevation),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function H_(t,e,i,r){if(i.pitchWithMap){let s=[t,e,0,1];return N(s,s,r),i.transform.projectTileCoordinates(s[0]/s[3],s[1]/s[3],i.unwrappedTileID,i.getElevation).point}return{x:t/i.width*2-1,y:1-e/i.height*2}}function Y_(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,i.getElevation)}function X_(t,e,i){return t._unit()._perp()._mult(e*i)}function J_(t,e,i,r,s,n,o,a,l){if(a.projectionCache.offsets[t])return a.projectionCache.offsets[t];let h=i.add(e);if(t+l.direction<r||t+l.direction>=s)return a.projectionCache.offsets[t]=h,h;let u=Z_(t+l.direction,a,l),c=X_(u.sub(i),o,l.direction),f=i.add(c),p=u.add(c);return a.projectionCache.offsets[t]=Ot(n,h,f,p)||h,a.projectionCache.offsets[t]}function K_(t,e,i,r,s,n,o,a,l){let h=r?t-e:t+e,u=h>0?1:-1,c=0;r&&(u*=-1,c=Math.PI),u<0&&(c+=Math.PI);let f,p=u>0?n+s:n+s+1;a.projectionCache.cachedAnchorPoint?f=a.projectionCache.cachedAnchorPoint:(f=W_(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=f);let d,m,_,g=f,y=f,v=0,w=0,b=Math.abs(h),x=[];for(;v+w<=b;){if(p+=u,p<n||p>=o)return null;v+=w,y=g,m=d;let t={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:y};if(g=Z_(p,a,t),0===i)x.push(y),_=g.sub(y);else{let e,r=g.sub(y);e=0===r.mag()?X_(Z_(p+u,a,t).sub(g),i,u):X_(r,i,u),m||=y.add(e),d=J_(p,e,g,n,o,m,i,a,t),x.push(m),_=d.sub(m)}w=_.mag()}let M=_._mult((b-v)/w)._add(m||y),z=c+Math.atan2(g.y-y.y,g.x-y.x);return x.push(M),{point:M,angle:l?z:0,path:x}}const Q_=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function tg(t,e){for(let i=0;i<t;i++){let t=e.length;e.resize(t+4),e.float32.set(Q_,3*t)}}function eg(t,e,i){let r=e[0],s=e[1];return t[0]=i[0]*r+i[4]*s+i[12],t[1]=i[1]*r+i[5]*s+i[13],t[3]=i[3]*r+i[7]*s+i[15],t}var ig=class{constructor(t,e=new k_(t.width+200,t.height+200,25),i=new k_(t.width+200,t.height+200,25)){this.transform=t,this.grid=e,this.ignoredGrid=i,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,r,s,n,o,a,l,h,u,c){let f,p=this.projectAndGetPerspectiveRatio(t.anchorPointX+a[0],t.anchorPointY+a[1],s,h,c),d=i*p.perspectiveRatio;if(n||o)f=this._projectCollisionBox(t,d,r,s,n,o,a,p,h,u,c);else{let e=p.x+(u?u.x*d:0),i=p.y+(u?u.y*d:0);f={allPointsOccluded:!1,box:[e+t.x1*d,i+t.y1*d,e+t.x2*d,i+t.y2*d]}}let[m,_,g,y]=f.box,v=n?f.allPointsOccluded:p.isOccluded,w=v;return w||=p.perspectiveRatio<this.perspectiveRatioCutoff,w||=!this.isInsideGrid(m,_,g,y),w||"always"!==e&&this.grid.hitTest(m,_,g,y,e,l)?{box:[m,_,g,y],placeable:!1,offscreen:!1,occluded:v}:{box:[m,_,g,y],placeable:!0,offscreen:this.isOffscreen(m,_,g,y),occluded:v}}placeCollisionCircles(t,e,i,r,s,n,o,a,h,u,c,f,p,d){let m=[],_=new l(e.anchorX,e.anchorY),g=this.getPerspectiveRatio(_.x,_.y,n,d),y=(h?s*this.transform.getPitchedTextCorrection(e.anchorX,e.anchorY,n)/g:s*g)/24,v={getElevation:d,pitchedLabelPlaneMatrix:o,lineVertexArray:i,pitchWithMap:h,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:_,unwrappedTileID:n,width:this.transform.width,height:this.transform.height,translation:p},w=U_(y,r,e.lineOffsetX*y,e.lineOffsetY*y,!1,e,!1,v),b=!1,x=!1,M=!0;if(w){let e=.5*c*g+f,i=new l(-100,-100),r=new l(this.screenRightBoundary,this.screenBottomBoundary),s=new I_,n=w.first,o=w.last,p=[];for(let t=n.path.length-1;t>=1;t--)p.push(n.path[t]);for(let t=1;t<o.path.length;t++)p.push(o.path[t]);let d=2.5*e;if(h){let t=this.projectPathToScreenSpace(p,v);p=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(p.length>0){let t=p[0].clone(),e=p[0].clone();for(let i=1;i<p.length;i++)t.x=Math.min(t.x,p[i].x),t.y=Math.min(t.y,p[i].y),e.x=Math.max(e.x,p[i].x),e.y=Math.max(e.y,p[i].y);_=t.x>=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[p]:e.x<i.x||t.x>r.x||e.y<i.y||t.y>r.y?[]:function(t,e,i,r,s){let n=[];for(let o of t){let t;for(let a=0;a<o.length-1;a++){let h=o[a],u=o[a+1];h.x<e&&u.x<e||(h.x<e?h=new l(e,h.y+(e-h.x)/(u.x-h.x)*(u.y-h.y))._round():u.x<e&&(u=new l(e,h.y+(e-h.x)/(u.x-h.x)*(u.y-h.y))._round()),!(h.y<i&&u.y<i)&&(h.y<i?h=new l(h.x+(i-h.y)/(u.y-h.y)*(u.x-h.x),i)._round():u.y<i&&(u=new l(h.x+(i-h.y)/(u.y-h.y)*(u.x-h.x),i)._round()),!(h.x>=r&&u.x>=r)&&(h.x>=r?h=new l(r,h.y+(r-h.x)/(u.x-h.x)*(u.y-h.y))._round():u.x>=r&&(u=new l(r,h.y+(r-h.x)/(u.x-h.x)*(u.y-h.y))._round()),!(h.y>=s&&u.y>=s)&&(h.y>=s?h=new l(h.x+(s-h.y)/(u.y-h.y)*(u.x-h.x),s)._round():u.y>=s&&(u=new l(h.x+(s-h.y)/(u.y-h.y)*(u.x-h.x),s)._round()),(!t||!h.equals(t[t.length-1]))&&(t=[h],n.push(t)),t.push(u)))))}}return n}([p],i.x,i.y,r.x,r.y)}for(let i of _){s.reset(i,.25*e);let r=0;r=s.length<=.5*e?1:Math.ceil(s.paddedLength/d)+1;for(let i=0;i<r;i++){let n=i/Math.max(r-1,1),o=s.lerp(n),l=o.x+100,h=o.y+100;m.push(l,h,e,0);let c=l-e,f=h-e,p=l+e,d=h+e;if(M&&=this.isOffscreen(c,f,p,d),x||=this.isInsideGrid(c,f,p,d),"always"!==t&&this.grid.hitTestCircle(l,h,e,t,u)&&(b=!0,!a))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!a&&b||!x||g<this.perspectiveRatioCutoff?[]:m,offscreen:M,collisionDetected:b}}projectPathToScreenSpace(t,e){return function(t){let e=0,i=0,r=0,s=0;for(let n=0;n<t.length;n++)t[n].isOccluded?(r=n+1,s=0):(s++,s>i&&(i=s,e=r));return t.slice(e,e+i)}(function(t,e){let i=F_;return function(t,e){let i=1/(e[0]*e[5]-e[1]*e[4]);t[0]=e[5]*i,t[1]=-e[1]*i,t[2]=0,t[3]=0,t[4]=-e[4]*i,t[5]=e[0]*i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1/e[10],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1/e[15]}(i,e.pitchedLabelPlaneMatrix),t.map((t=>{let r=O_(t.x,t.y,i,e.getElevation),s=e.transform.projectTileCoordinates(r.point.x,r.point.y,e.unwrappedTileID,e.getElevation);return s.point.x=(.5*s.point.x+.5)*e.width,s.point.y=(.5*-s.point.y+.5)*e.height,s}))}(t,e))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let e=[],i=new jf;for(let r of t){let t=new l(r.x+100,r.y+100);i.extend(t),e.push(t)}let{minX:r,minY:s,maxX:n,maxY:o}=i,a=this.grid.query(r,s,n,o).concat(this.ignoredGrid.query(r,s,n,o)),h={},u={};for(let t of a){let i=t.key;void 0===h[i.bucketInstanceId]&&(h[i.bucketInstanceId]={}),h[i.bucketInstanceId][i.featureIndex]||Ll(e,[new l(t.x1,t.y1),new l(t.x2,t.y1),new l(t.x2,t.y2),new l(t.x1,t.y2)])&&(h[i.bucketInstanceId][i.featureIndex]=!0,void 0===u[i.bucketInstanceId]&&(u[i.bucketInstanceId]=[]),u[i.bucketInstanceId].push(i.featureIndex))}return u}insertCollisionBox(t,e,i,r,s,n){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,s,n){let o=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e};for(let e=0;e<t.length;e+=4)o.insertCircle(a,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,e,i,r,s){if(s){let i;r?(i=[t,e,r(t,e),1],N(i,i,s)):(i=[t,e,0,1],eg(i,i,s));let n=i[3];return{x:(i[0]/n+1)/2*this.transform.width+100,y:(-i[1]/n+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/n*.5,isOccluded:!1,signedDistanceFromCamera:n}}{let s=this.transform.projectTileCoordinates(t,e,i,r);return{x:(s.point.x+1)/2*this.transform.width+100,y:(1-s.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/s.signedDistanceFromCamera*.5,isOccluded:s.isOccluded,signedDistanceFromCamera:s.signedDistanceFromCamera}}}getPerspectiveRatio(t,e,i,r){let s=this.transform.projectTileCoordinates(t,e,i,r);return.5+this.transform.cameraToCenterDistance/s.signedDistanceFromCamera*.5}isOffscreen(t,e,i,r){return i<100||t>=this.screenRightBoundary||r<100||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){let t=_([]);return v(t,t,[-100,-100,0]),t}_projectCollisionBox(t,e,i,r,s,n,o,a,h,u,c){let f=1,p=0,d=0,m=1,_=t.anchorPointX+o[0],g=t.anchorPointY+o[1];if(n&&!s){let t=this.projectAndGetPerspectiveRatio(_+1,g,r,h,c),e=t.x-a.x,i=Math.atan((t.y-a.y)/e)+(e<0?Math.PI:0),s=Math.sin(i),n=Math.cos(i);f=n,p=s,d=-s,m=n}else if(!n&&s){let t=R_(this.transform);f=t.vecEast[0],p=t.vecEast[1],d=t.vecSouth[0],m=t.vecSouth[1]}let y=a.x,v=a.y,w=e;s&&(y=_,v=g,w=2**-(this.transform.zoom-i.overscaledZ),w*=this.transform.getPitchedTextCorrection(_,g,r),!u)&&(w*=xt(.5+a.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4)),u&&(y+=f*u.x*w+d*u.y*w,v+=p*u.x*w+m*u.y*w);let b=t.x1*w,x=t.x2*w,M=(b+x)/2,z=t.y1*w,S=t.y2*w,T=(z+S)/2,E=[{offsetX:b,offsetY:z},{offsetX:M,offsetY:z},{offsetX:x,offsetY:z},{offsetX:x,offsetY:T},{offsetX:x,offsetY:S},{offsetX:M,offsetY:S},{offsetX:b,offsetY:S},{offsetX:b,offsetY:T}],A=[];for(let{offsetX:t,offsetY:e}of E)A.push(new l(y+f*t+d*e,v+p*t+m*e));let P=!1;if(s){let t=A.map((t=>this.projectAndGetPerspectiveRatio(t.x,t.y,r,h,c)));P=t.some((t=>!t.isOccluded)),A=t.map((t=>new l(t.x,t.y)))}else P=!0;return{box:vt(A),allPointsOccluded:!P}}},rg=class{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}},sg=class{constructor(t,e,i,r,s){this.text=new rg(t?t.text:null,e,i,s),this.icon=new rg(t?t.icon:null,e,r,s)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},ng=class{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}},og=class{constructor(t,e,i,r,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=s}},ag=class{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}};function lg(t,e,i,r,s){let{horizontalAlign:n,verticalAlign:o}=ef(t);return new l(-(n-.5)*e+r[0]*s,-(o-.5)*i+r[1]*s)}var hg=class{constructor(t,e,i,r,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new ig(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new ag(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){let e=this.terrain;return e?(i,r)=>e.getElevation(t,i,r):null}getBucketParts(t,e,i,r){let s=i.getBucket(e),n=i.latestFeatureIndex;if(!s||!n||e.id!==s.layerIds[0])return;let o=i.collisionBoxArray,a=s.layers[0].layout,l=s.layers[0].paint,h=2**(this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/et,c=i.tileID.toUnwrapped(),f="map"===a.get("text-rotation-alignment"),p=it(i,1,this.transform.zoom),d=ht(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=ht(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),_=$_(f,this.transform,p);this.retainedQueryData[s.bucketInstanceId]=new og(s.bucketInstanceId,n,s.sourceLayerIndex,s.index,i.tileID);let g={bucket:s,layout:a,translationText:d,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:_,scale:h,textPixelRatio:u,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:nf(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(r)for(let e of s.sortKeyRanges){let{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s,parameters:g})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:g})}attemptAnchorPlacement(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_,g,y,v){let w=Yd[t.textAnchor],b=[t.textOffset0,t.textOffset1],x=lg(w,i,r,b,s),M=this.collisionIndex.placeCollisionBox(e,c,a,l,h,o,n,m,u.predicate,y,x,v);if((!g||this.collisionIndex.placeCollisionBox(g,c,a,l,h,o,n,_,u.predicate,y,x,v).placeable)&&M.placeable){let t;if(this.prevPlacement?.variableOffsets[f.crossTileID]&&this.prevPlacement?.placements[f.crossTileID]?.text&&(t=this.prevPlacement.variableOffsets[f.crossTileID].anchor),0===f.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[f.crossTileID]={textOffset:b,width:i,height:r,anchor:w,textBoxScale:s,prevAnchor:t},this.markUsedJustification(p,w,f,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,f),this.placedOrientations[f.crossTileID]=d),{shift:x,placedGlyphBoxes:M}}}placeLayerBucketPart(t,e,i){let{bucket:r,layout:s,translationText:n,translationIcon:o,unwrappedTileID:a,pitchedLabelPlaneMatrix:l,textPixelRatio:h,holdingForFade:u,collisionBoxArray:c,partiallyEvaluatedTextSize:f,collisionGroup:p}=t.parameters,d=s.get("text-optional"),m=s.get("icon-optional"),_=of(s,"text-overlap","text-allow-overlap"),g="always"===_,y=of(s,"icon-overlap","icon-allow-overlap"),v="always"===y,w="map"===s.get("text-rotation-alignment"),b="map"===s.get("text-pitch-alignment"),x="none"!==s.get("icon-text-fit"),M="viewport-y"===s.get("symbol-z-order"),z=g&&(v||!r.hasIconData()||m),S=v&&(g||!r.hasTextData()||d);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let T=this.retainedQueryData[r.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(T),A=this.transform.getFastPathSimpleProjectionMatrix(T),P=(t,c,v)=>{if(e[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new ng(!1,!1,!1));let M=!1,P=!1,I=!0,C=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},F=null,$=null,j=null,R=0,O=0,L=0;c.textFeatureIndex?R=c.textFeatureIndex:t.useRuntimeCollisionCircles&&(R=t.featureIndex),c.verticalTextFeatureIndex&&(O=c.verticalTextFeatureIndex);let B=c.textBox;if(B){let e=e=>{let i=1;if(r.allowVerticalPlacement&&!e&&this.prevPlacement){let e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(r,i,t))}return i},s=(e,i)=>{if(r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&c.verticalTextBox){for(let t of r.writingModes)if(2===t?(k=i(),D=k):k=e(),k?.placeable)break}else k=e()},l=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===l){let i=(e,i)=>{let s=this.collisionIndex.placeCollisionBox(e,_,h,T,a,b,w,n,p.predicate,E,void 0,A);return s?.placeable&&(this.markUsedOrientation(r,i,t),this.placedOrientations[t.crossTileID]=i),s};s((()=>i(B,1)),(()=>{let e=c.verticalTextBox;return r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?i(e,2):{box:null,offscreen:null}})),e(k?.placeable)}else{let f=Yd[this.prevPlacement?.variableOffsets[t.crossTileID]?.anchor],d=(e,s,c)=>{let d=e.x2-e.x1,m=e.y2-e.y1,g=t.textBoxScale,v=x&&"never"===y?s:null,z=null,S="never"===_?1:2,P="never";f&&S++;for(let i=0;i<S;i++){for(let i=l;i<u;i++){let s=r.textAnchorOffsets.get(i);if(f&&s.textAnchor!==f)continue;let l=this.attemptAnchorPlacement(s,e,d,m,g,w,b,h,T,a,p,P,t,r,c,n,o,v,E);if(l&&(z=l.placedGlyphBoxes,z?.placeable))return M=!0,C=l.shift,z}f?f=null:P=_}return i&&!z&&(z={box:this.collisionIndex.placeCollisionBox(B,"always",h,T,a,b,w,n,p.predicate,E,void 0,A).box,offscreen:!1,placeable:!1,occluded:!1}),z};s((()=>d(B,c.iconBox,1)),(()=>{let e=c.verticalTextBox,i=k?.placeable;return r.allowVerticalPlacement&&!i&&t.numVerticalGlyphVertices>0&&e?d(e,c.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}})),k&&(M=k.placeable,I=k.offscreen);let m=e(k?.placeable);if(!M&&this.prevPlacement){let e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(r,e.anchor,t,m))}}}if(F=k,M=F?.placeable,I=F?.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){let e=r.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),o=sf(r.textSizeData,f,e),h=s.get("text-padding");$=this.collisionIndex.placeCollisionCircles(_,e,r.lineVertexArray,r.glyphOffsetArray,o,a,l,i,b,p.predicate,t.collisionCircleDiameter,h,n,E),$.circles.length&&$.collisionDetected&&!i&&jt("Collisions detected, but collision boxes are not shown"),M=g||$.circles.length>0&&!$.collisionDetected,I&&=$.offscreen}if(c.iconFeatureIndex&&(L=c.iconFeatureIndex),c.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,y,h,T,a,b,w,o,p.predicate,E,x&&C?C:void 0,A);D&&D.placeable&&c.verticalIconBox?(j=t(c.verticalIconBox),P=j.placeable):(j=t(c.iconBox),P=j.placeable),I&&=j.offscreen}let N=d||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,U=m||0===t.numIconVertices;N||U?U?N||(P&&=M):M=P&&M:P=M=P&&M;let G=P&&j.placeable;if(M&&F.placeable&&this.collisionIndex.insertCollisionBox(F.box,_,s.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&O?O:R,p.ID),G&&this.collisionIndex.insertCollisionBox(j.box,y,s.get("icon-ignore-placement"),r.bucketInstanceId,L,p.ID),$&&M&&this.collisionIndex.insertCollisionCircles($.circles,_,s.get("text-ignore-placement"),r.bucketInstanceId,R,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,v,c,F,j,$),0===t.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new ng((M||z)&&!F?.occluded,(P||S)&&!j?.occluded,I||r.justReloaded),e[t.crossTileID]=!0};if(M){if(0!==t.symbolInstanceStart)throw Error("bucket.bucketInstanceId should be 0");let e=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=e.length-1;t>=0;--t){let i=e[t];P(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)P(r.symbolInstances.get(e),r.collisionArrays[e],e);r.justReloaded=!1}storeCollisionData(t,e,i,r,s,n){if(i.textBox||i.iconBox){let n,o;this.collisionBoxArrays.has(t)?n=this.collisionBoxArrays.get(t):(n=new Map,this.collisionBoxArrays.set(t,n)),n.has(e)?o=n.get(e):(o={text:null,icon:null},n.set(e,o)),i.textBox&&(o.text=r.box),i.iconBox&&(o.icon=s.box)}if(n){let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=[]);for(let t=0;t<n.circles.length;t+=4)e.push(n.circles[t+0]-100),e.push(n.circles[t+1]-100),e.push(n.circles[t+2]),e.push(+!!n.collisionDetected)}}markUsedJustification(t,e,i,r){let s;s=2===r?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}
6
+ /**
7
+ * MapLibre GL JS
8
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.2.0/LICENSE.txt
9
+ */(e)];let n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let e of n)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=s>=0&&e!==s?0:i.crossTileID)}markUsedOrientation(t,e,i){let r=1===e||3===e?e:0,s=2===e?e:0,n=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let e of n)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=s)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let e=this.prevPlacement,i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;let r=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},n=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(let t in this.placements){let e=this.placements[t],n=s[t];n?(this.opacities[t]=new sg(n,r,e.text,e.icon),i||=e.text!==n.text.placed,i||=e.icon!==n.icon.placed):(this.opacities[t]=new sg(null,r,e.text,e.icon,e.skipFade),i||=e.text||e.icon)}for(let t in s){let e=s[t];if(!this.opacities[t]){let s=new sg(e,r,!1,!1);s.isHidden()||(this.opacities[t]=s,i||=e.text.placed,i||=e.icon.placed)}}for(let t in n)!this.variableOffsets[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.variableOffsets[t]=n[t]);for(let t in o)!this.placedOrientations[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.placedOrientations[t]=o[t]);if(e&&void 0===e.lastPlacementChangeTime)throw Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){let i={};for(let r of e){let e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(t,e,i,r){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let s=t.layers[0],n=s.layout,o=new sg(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),h=n.get("icon-allow-overlap"),u=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),c="map"===n.get("text-rotation-alignment"),f="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),d=new sg(null,0,a&&(h||!t.hasIconData()||n.get("icon-optional")),h&&(a||!t.hasTextData()||n.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);let m=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i);t.hasVisibleVertices||=i!==_g},_=this.collisionBoxArrays.get(t.bucketInstanceId);for(let e=0;e<t.symbolInstances.length;e++){let r=t.symbolInstances.get(e),{numHorizontalGlyphVertices:s,numVerticalGlyphVertices:n,crossTileID:a}=r,h=this.opacities[a];i[a]?h=o:h||(h=d,this.opacities[a]=h),i[a]=!0;let g=r.numIconVertices>0,y=this.placedOrientations[r.crossTileID],v=2===y,w=1===y||3===y;if(s>0||n>0){let e=mg(h.text);m(t.text,s,v?_g:e),m(t.text,n,w?_g:e);let i=h.text.isHidden(),o=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let e of o)e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||v?1:0);r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);let a=this.variableOffsets[r.crossTileID];a&&this.markUsedJustification(t,a.anchor,r,y);let l=this.placedOrientations[r.crossTileID];l&&(this.markUsedJustification(t,"left",r,l),this.markUsedOrientation(t,l,r))}if(g){let e=mg(h.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&v);r.placedIconSymbolIndex>=0&&(m(t.icon,r.numIconVertices,i?e:_g),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=h.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,r.numVerticalIconVertices,i?_g:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=h.icon.isHidden())}let b=_?.has(e)?_.get(e):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let i=t.collisionArrays[e];if(i){let e=new l(0,0);if(i.textBox||i.verticalTextBox){let r=!0;if(u){let t=this.variableOffsets[a];t?(e=lg(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),c&&e._rotate(f?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(i.textBox||i.verticalTextBox){let s;i.textBox&&(s=v),i.verticalTextBox&&(s=w),ug(t.textCollisionBox.collisionVertexArray,h.text.placed,!r||s,b.text,e.x,e.y)}}if(i.iconBox||i.verticalIconBox){let r,s=!(w||!i.verticalIconBox);i.iconBox&&(r=s),i.verticalIconBox&&(r=!s),ug(t.iconCollisionBox.collisionVertexArray,h.icon.placed,r,b.icon,p?e.x:0,p?e.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){let i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}};function ug(t,e,i,r,s,n){(!r||0===r.length)&&(r=[0,0,0,0]);let o=r[0]-100,a=r[1]-100,l=r[2]-100,h=r[3]-100;t.emplaceBack(+!!e,+!!i,s||0,n||0,o,a),t.emplaceBack(+!!e,+!!i,s||0,n||0,l,a),t.emplaceBack(+!!e,+!!i,s||0,n||0,l,h),t.emplaceBack(+!!e,+!!i,s||0,n||0,o,h)}const cg=2**25,fg=2**24,pg=2**17,dg=65536;function mg(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;let e=+!!t.placed,i=Math.floor(127*t.opacity);return i*cg+e*fg+i*pg+e*dg+512*i+256*e+2*i+e}const _g=0;var gg=class{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,s){let n=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(n,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,s())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,n.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<n.length;)if(e.placeLayerBucketPart(n[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,s())return!0;return!1}},yg=class{constructor(t,e,i,r,s,n,o,a){this.placement=new hg(t,e,n,o,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=s,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){let r=Qd(),s=()=>!this._forceFullPlacement&&Qd()-r>2;for(;this._currentPlacementIndex>=0;){let r=e[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if(yf(r)&&r.layout&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||=new gg(r),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}};const vg=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],wg=new Uint32Array(96);var bg=class t{static from(e){if(!e||void 0===e.byteLength||e.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(e,0,2);if(219!==i)throw Error("Data does not appear to be in a KDBush format.");let s=r>>4;if(1!==s)throw Error(`Got v${s} data when expected v1.`);let n=vg[15&r];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new t(a,o,n,void 0,e)}constructor(t,e=64,i=Float64Array,r=ArrayBuffer,s){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let n=vg.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(n<0)throw Error(`Unexpected typed array class: ${i}.`);if(s)this.data=s,this.ids=new this.IndexArrayType(s,8,t),this.coords=new i(s,8+a+l,2*t),this._pos=2*t,this._finished=!0;else{let s=this.data=new r(8+o+a+l);this.ids=new this.IndexArrayType(s,8,t),this.coords=new i(s,8+a+l,2*t),this._pos=0,this._finished=!1,new Uint8Array(s,0,2).set([219,16+n]),new Uint16Array(s,2,1)[0]=e,new Uint32Array(s,4,1)[0]=t}}add(t,e){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return xg(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:s,coords:n,nodeSize:o}=this;wg[0]=0,wg[1]=s.length-1,wg[2]=0;let a=3,l=[];for(;a>0;){let h=wg[--a],u=wg[--a],c=wg[--a];if(u-c<=o){for(let o=c;o<=u;o++){let a=n[2*o],h=n[2*o+1];a>=t&&a<=i&&h>=e&&h<=r&&l.push(s[o])}continue}let f=c+u>>1,p=n[2*f],d=n[2*f+1];p>=t&&p<=i&&d>=e&&d<=r&&l.push(s[f]),(0===h?t<=p:e<=d)&&(wg[a++]=c,wg[a++]=f-1,wg[a++]=1-h),(0===h?i>=p:r>=d)&&(wg[a++]=f+1,wg[a++]=u,wg[a++]=1-h)}return l}within(t,e,i){let r=[];return this.withinInto(t,e,i,r),r}withinInto(t,e,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:s,coords:n,nodeSize:o}=this;wg[0]=0,wg[1]=s.length-1,wg[2]=0;let a=3,l=0,h=i*i;for(;a>0;){let u=wg[--a],c=wg[--a],f=wg[--a];if(c-f<=o){for(let i=f;i<=c;i++)Tg(n[2*i],n[2*i+1],t,e)<=h&&(r[l++]=s[i]);continue}let p=f+c>>1,d=n[2*p],m=n[2*p+1];Tg(d,m,t,e)<=h&&(r[l++]=s[p]),(0===u?t-i<=d:e-i<=m)&&(wg[a++]=f,wg[a++]=p-1,wg[a++]=1-u),(0===u?t+i>=d:e+i>=m)&&(wg[a++]=p+1,wg[a++]=c,wg[a++]=1-u)}return l}};function xg(t,e,i,r,s,n){if(s-r<=i)return;let o=r+s>>1;Mg(t,e,o,r,s,n),xg(t,e,i,r,o-1,1-n),xg(t,e,i,o+1,s,1-n)}function Mg(t,e,i,r,s,n){for(;s>r;){if(s-r>600){let o=s-r+1,a=i-r+1,l=Math.log(o),h=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*h*(o-h)/o)*(a-o/2<0?-1:1);Mg(t,e,i,Math.max(r,Math.floor(i-a*h/o+u)),Math.min(s,Math.floor(i+(o-a)*h/o+u)),n)}let o=e[2*i+n],a=r,l=s;for(zg(t,e,r,i),e[2*s+n]>o&&zg(t,e,r,s);a<l;){for(zg(t,e,a,l),a++,l--;e[2*a+n]<o;)a++;for(;e[2*l+n]>o;)l--}e[2*r+n]===o?zg(t,e,r,l):(l++,zg(t,e,l,s)),l<=i&&(r=l+1),i<=l&&(s=l-1)}}function zg(t,e,i,r){Sg(t,i,r),Sg(e,2*i,2*r),Sg(e,2*i+1,2*r+1)}function Sg(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function Tg(t,e,i,r){let s=t-i,n=e-r;return s*s+n*n}const Eg=.03125;var Ag=class{constructor(t,e,i){this.tileID=t,this.bucketInstanceId=i,this._symbolsByKey={};let r=new Map;for(let t=0;t<e.length;t++){let i=e.get(t),s=i.key,n=r.get(s);n?n.push(i):r.set(s,[i])}for(let[t,e]of r){let i={positions:e.map((t=>({x:Math.floor(t.anchorX*Eg),y:Math.floor(t.anchorY*Eg)}))),crossTileIDs:e.map((t=>t.crossTileID))};if(i.positions.length>128){let t=new bg(i.positions.length,16,Uint16Array);for(let{x:e,y:r}of i.positions)t.add(e,r);t.finish(),delete i.positions,i.index=t}this._symbolsByKey[t]=i}}getScaledCoordinates(t,e){let{x:i,y:r,z:s}=this.tileID.canonical,{x:n,y:o,z:a}=e.canonical,l=Eg/2**(a-s),h=(o*et+t.anchorY)*l,u=r*et*Eg;return{x:Math.floor((n*et+t.anchorX)*l-i*et*Eg),y:Math.floor(h-u)}}findMatches(t,e,i){let r=this.tileID.canonical.z<e.canonical.z?1:2**(this.tileID.canonical.z-e.canonical.z);for(let s=0;s<t.length;s++){let n=t.get(s);if(n.crossTileID)continue;let o=this._symbolsByKey[n.key];if(!o)continue;let a=this.getScaledCoordinates(n,e);if(o.index){let t=o.index.range(a.x-r,a.y-r,a.x+r,a.y+r).sort();for(let e of t){let t=o.crossTileIDs[e];if(!i[t]){i[t]=!0,n.crossTileID=t;break}}}else if(o.positions)for(let t=0;t<o.positions.length;t++){let e=o.positions[t],s=o.crossTileIDs[t];if(Math.abs(e.x-a.x)<=r&&Math.abs(e.y-a.y)<=r&&!i[s]){i[s]=!0,n.crossTileID=s;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}},Pg=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Ig=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let e=Math.round((t-this.lng)/360);if(0!==e)for(let t in this.indexes){let i=this.indexes[t],r={};for(let t in i){let s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),r[s.tileID.key]=s}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]?.[t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||={};let r=this.usedCrossTileIDs[t.overscaledZ];for(let i in this.indexes){let s=this.indexes[i];if(Number(i)>t.overscaledZ)for(let i in s){let n=s[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{let n=s[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){let s=e.symbolInstances.get(t);s.crossTileID||(s.crossTileID=i.generate(),r[s.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ag(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(let i of e.getCrossTileIDsLists())for(let e of i)delete this.usedCrossTileIDs[t][e]}removeStaleBuckets(t){let e=!1;for(let i in this.indexes){let r=this.indexes[i];for(let s in r)t[r[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[s]),delete r[s],e=!0)}return e}},Cg=class{constructor(){this.layerIndexes={},this.crossTileIDs=new Pg,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Ig);let s=!1,n={};r.handleWrapJump(i);for(let i of e){let e=i.getBucket(t);t.id===e?.layerIds[0]&&(e.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(s=!0),n[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(n)&&(s=!0),s}pruneUnusedLayers(t){let e={};for(let i of t)e[i]=!0;for(let t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}},kg="void main() {fragColor=vec4(1.0);}";const Dg={prelude:Fg("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Fg("\nvoid clipAntimeridian() {}","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:Fg("uniform bool u_projection_clip_antimeridian;in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}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;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;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) {v_projection_tile_x=posInTile.x;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:Fg("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Fg("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) 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:Fg("in vec3 v_data;flat in float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;layout(location=0) in vec2 a_pos;out vec3 v_data;flat out float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main(void) {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Fg(kg,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Fg("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in vec2 a_pos;out vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#pragma maplibre: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma maplibre: initialize highp float weight\n#pragma maplibre: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Fg("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;layout(location=0) 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:Fg("flat in float v_placed;flat 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;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;flat out float v_placed;flat 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:Fg("flat in float v_radius;in vec2 v_extrude;flat 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;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;uniform vec2 u_viewport_size;flat out float v_radius;out vec2 v_extrude;flat 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:Fg("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;layout(location=0) 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:Fg("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);}","layout(location=0) 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:Fg(kg,"layout(location=0) in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Fg("#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Fg("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Fg("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Fg("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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:Fg("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma maplibre: define highp float base\n#pragma maplibre: define highp float height\n#pragma maplibre: define highp vec4 color\nvoid main() {\n#pragma maplibre: initialize highp float base\n#pragma maplibre: initialize highp float height\n#pragma maplibre: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Fg("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Fg("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) 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:Fg("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;layout(location=0) 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:Fg("uniform lowp float u_device_pixel_ratio;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in vec2 a_pos_normal;layout(location=1) 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;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Fg("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nlayout(location=0) in vec2 a_pos_normal;layout(location=1) in vec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) 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;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Fg("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in vec2 a_pos_normal;layout(location=1) 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;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Fg("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;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in vec2 a_pos_normal;layout(location=1) 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;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Fg("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;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nlayout(location=0) in vec2 a_pos_normal;layout(location=1) in vec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) 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;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),layerOpacity:Fg("uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:Fg("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Fg("uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in vec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) 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;uniform bool u_is_offset;out vec2 v_tex;flat out float v_total_opacity;\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),symbolSDF:Fg("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in vec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) 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;uniform bool u_is_offset;out vec2 v_data0;out vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;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);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));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),symbolTextAndIcon:Fg("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;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 vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in vec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) 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;uniform bool u_is_offset;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);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));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}"),terrain:Fg("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 && u_fog_ground_blend_opacity > 0.0 && 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;}}","layout(location=0) 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,ele-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:Fg("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);}","layout(location=0) 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:Fg("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);}","layout(location=0) 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);}"),atmosphere:Fg("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","layout(location=0) 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:Fg("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);}","layout(location=0) in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Fg(t,e){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/in ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=n?n.concat(s):s,a=r?r.length:0,l={};return t=t.replace(i,((t,e,i,r,s)=>(l[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nin ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = u_${s};\n#endif\n`))),e=e.replace(i,((t,e,i,r,s)=>{let n="float"===r?"vec2":"vec4",o=s.match(/color/)?"color":n;return l[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nlayout(location = ${a++}) in ${i} ${n} a_${s};\nout ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${o}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nlayout(location = ${a++}) in ${i} ${n} a_${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = unpack_mix_${o}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`})),{fragmentSource:t,vertexSource:e,staticAttributes:r,staticUniforms:o}}var $g=class{constructor(t,e,i){this.vertexBuffer=t,this.indexBuffer=e,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};const jg=Ho([{name:"a_pos",type:"Int16",components:2}]),Rg="#define PROJECTION_MERCATOR",Og="mercator";var Lg=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Og}get shaderDefine(){return Rg}get shaderPreludeCode(){return Dg.projectionMercator}get vertexShaderPreludeCode(){return Dg.projectionMercator.vertexSource}get subdivisionGranularity(){return xu.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(t,e,i,r,s){if(this._cachedMesh)return this._cachedMesh;let n=new ka;n.emplaceBack(0,0),n.emplaceBack(et,0),n.emplaceBack(0,et),n.emplaceBack(et,et);let o=t.createVertexBuffer(n,jg.members),a=Qa.simpleSegment(0,0,4,2),l=new Ya;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let h=t.createIndexBuffer(l);return this._cachedMesh=new $g(o,h,a),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Bg=class t{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=ir.number(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=ir.number(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=ir.number(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=ir.number(t.right,e.right,i)),this}getCenter(t,e){return new l(xt((this.left+t-this.right)/2,0,t),xt((this.top+e-this.bottom)/2,0,e))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new t(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function Ng(t,e){if(!t.renderWorldCopies||t.lngRange)return;let i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}function Ug(t){return Math.max(0,Math.floor(t))}var Gg=class{constructor(t,e){this.applyConstrain=(t,e)=>null===this._constrainOverride?this._callbacks.defaultConstrain(t,e):this._constrainOverride(t,e),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=void 0===e?.renderWorldCopies||!!e?.renderWorldCopies,this._minZoom=e?.minZoom||0,this._maxZoom=e?.maxZoom||22,this._minPitch=null==e?.minPitch?0:e?.minPitch,this._maxPitch=null==e?.maxPitch?60:e?.maxPitch,this._constrainOverride=e?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new Zu(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ug(this._zoom),this._scale=At(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Bg,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,e,i){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=Ug(this._zoom),this._scale=At(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new Bg(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!i&&t.autoCalculateNearFarZ,e&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){void 0===t&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new l(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){let e=Mt(t,-180,180)*Math.PI/180;this._bearingInRadians!==e&&(this._unmodified=!1,this._bearingInRadians=e,this._calcMatrices(),this._rotationMatrix=Xd(),function(t,e,i){var r=e[0],s=e[1],n=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*a,t[1]=s*l+o*a,t[2]=r*-a+n*l,t[3]=s*-a+o*l}(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){let e=xt(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==e&&(this._unmodified=!1,this._pitchInRadians=e,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){let e=t/180*Math.PI;this._rollInRadians!==e&&(this._unmodified=!1,this._rollInRadians=e,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return Vt(this._fovInRadians)}setFov(t){t=xt(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=qt(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){let e=this.applyConstrain(this._center,t).zoom;this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this._tileZoom=Math.max(0,Math.floor(e)),this._scale=At(e),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){(t.lat!==this._center.lat||t.lng!==this._center.lng)&&(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,e){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=e,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this.constrainInternal(),this._calcMatrices()}resize(t,e,i=!0){this._width=t,this._height=e,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return 2!==this._latRange?.length||2!==this._lngRange?.length?null:new Zm([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-85.051129,Yt])}getCameraQueryGeometry(t,e){if(1===e.length)return[e[0],t];{let{minX:i,minY:r,maxX:s,maxY:n}=jf.fromPoints(e).extend(t);return[new l(i,r),new l(s,r),new l(s,n),new l(i,n),new l(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:e,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(e),this.setZoom(i),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=_(new Float64Array(16));w(t,t,[this._width/2,-this._height/2,1]),v(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=_(new Float64Array(16)),w(t,t,[1,-1,1]),v(t,t,[-1,-1,0]),w(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,e,i,r){let s,n,o=void 0===i?this.bearing:i,a=r=void 0===r?this.pitch:r,{distanceToCenter:l,clampedElevation:h}=this._distanceToCenterFromAltElevationPitch(e,this.elevation,a),{x:u,y:c}=hc(a,o),f=ec.fromLngLat(t,e),p=tc(1,f.y),d=0;do{if(d+=1,d>10)break;n=l/p,s=new ec(f.x+u*n,f.y+c*n),p=1/s.meterInMercatorCoordinateUnits()}while(Math.abs(l-n*p)>1e-12);return{center:s.toLngLat(),elevation:h,zoom:Pt(this.height/2/Math.tan(this.fovInRadians/2)/n/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;let e=1/this.worldSize,i=Ju(1,this.center.lat)*this.worldSize,r=ec.fromLngLat(this.center,this.elevation),s=r.x/e,n=r.y/e,o=r.z/e,a=this.pitch,l=this.bearing,{x:h,y:u,z:c}=hc(a,l),f=this.cameraToCenterDistance,p=s+f*-h,d=n+f*-u,m=o+f*c,{distanceToCenter:_,clampedElevation:g}=this._distanceToCenterFromAltElevationPitch(m/i,t,a),y=_*i,v=new ec((p+h*y)*e,(d+u*y)*e,0).toLngLat(),w=Ju(1,v.lat),b=Pt(this.height/2/Math.tan(this.fovInRadians/2)/_/w/this.tileSize);this._elevation=g,this._center=v,this.setZoom(b)}_distanceToCenterFromAltElevationPitch(t,e,i){let r,s=-Math.cos(qt(i)),n=t-e,o=e;return s*n>=0||Math.abs(s)<.1?(r=1e4,o=t+r*s):r=-n/s,{distanceToCenter:r,clampedElevation:o}}getCameraPoint(){let t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let t=Ju(1,this.center.lat)*this.worldSize;return lc(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];let e=t.canonical.z>=0?1<<t.canonical.z:2**t.canonical.z;return[t.canonical.x/e,t.canonical.y/e,1/e/et,1/e/et]}},qg=class t{constructor(t,e){this.min=t,this.max=e,this.center=C([],I([],this.min,this.max),.5)}quadrant(e){let i=[e%2==0,e<2],r=E(this.min),s=E(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],s[t]=i[t]?this.center[t]:this.max[t];return s[2]=this.max[2],new t(r,s)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let e=!0;for(let i of t.planes){let t=this.intersectsPlane(i);if(0===t)return 0;1===t&&(e=!1)}return e?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let e=t[3],i=t[3];for(let r=0;r<3;r++)t[r]>0?(e+=t[r]*this.min[r],i+=t[r]*this.max[r]):(i+=t[r]*this.min[r],e+=t[r]*this.max[r]);return e>=0?2:i<0?0:1}},Vg=class{distanceToTile2d(t,e,i,r){let s=r,n=s.distanceX([t,e]),o=s.distanceY([t,e]);return Math.hypot(n,o)}getWrap(t,e,i){return i}getTileBoundingVolume(t,e,i,r){let s=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let i=new Cf(t.z,e,t.z,t.x,t.y),o=r.terrain.getMinMaxElevation(i);s=o.minElevation??s,n=o.maxElevation??n}let o=1<<t.z;return new qg([e+t.x/o,t.y/o,s],[e+(t.x+1)/o,(t.y+1)/o,n])}allowVariableZoom(t,e){let i=xt(78.5-t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height/2,0,60);return!!e.terrain||t.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}},Zg=class t{constructor(t,e,i){this.points=t,this.planes=e,this.aabb=i}static fromInvProjectionMatrix(e,i=1,r=0,s,n){let o=n?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=2**r,l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((t=>function(t,e,i,r){let s=N([],t,e),n=1/s[3]/i*r;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(s,s,[n,n,1/s[3],n])}(t,e,i,a)));s&&function(t,e,i,r){let s=r?4:0,n=r?0:4,o=0,a=[],l=[];for(let e=0;e<4;e++){let i=L([],t[e+n],t[e+s]),r=A(i);C(i,i,1/r),a.push(r),l.push(i)}for(let e=0;e<4;e++){let r=ft(t[e+s],l[e],i);o=null!==r&&r>=0?Math.max(o,r):Math.max(o,a[e])}let h=function(t,e){let i=[0,0,0,0];return k(i,F([],L([],t[e[0]],t[e[1]]),L([],t[e[2]],t[e[1]]))),i[3]=-D(i,t[e[0]]),i}(t,e),u=function(t,e){let i=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}([],t,1/B(t)),r=L([],e,C([],i,D(e,i))),s=B(r);if(s>0){let t=Math.sqrt(1-i[3]*i[3]);return ut(e,I([],C([],i,-i[3]),C([],r,t/s)))}return null}(i,h);if(null!==u){let t=u/D(l[0],h);o=Math.min(o,t)}for(let e=0;e<4;e++){let i=Math.min(o,a[e]);t[e+n]=[t[e+s][0]+l[e][0]*i,t[e+s][1]+l[e][1]*i,t[e+s][2]+l[e][2]*i,1]}}(l,o[0],s,n);let h=o.map((t=>{let e=k([],F([],L([],l[t[0]],l[t[1]]),L([],l[t[2]],l[t[1]]))),i=-D(e,l[t[1]]);return e.concat(i)})),u=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];for(let t of l)for(let e=0;e<3;e++)u[e]=Math.min(u[e],t[e]),c[e]=Math.max(c[e],t[e]);return new t(l,h,new qg(u,c))}},Wg=class t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(t,e)=>{e=xt(+e,this.minZoom,this.maxZoom);let i={center:new Zu(t.lng,t.lat),zoom:e},r=this._helper._lngRange;!this._helper._renderWorldCopies&&null===r&&(r=[-179.9999999999,180-1e-10]);let s=this.tileSize*At(i.zoom),n=0,o=s,a=0,h=s,u=0,c=0,{x:f,y:p}=this.size;if(this._helper._latRange){let t=this._helper._latRange;n=Xu(t[1])*s,o=Xu(t[0])*s,o-n<p&&(u=p/(o-n))}r&&(a=Mt(Yu(r[0])*s,0,s),h=Mt(Yu(r[1])*s,0,s),h<a&&(h+=s),h-a<f&&(c=f/(h-a)));let d,m,{x:_,y:g}=sc(s,t),y=Math.max(c||0,u||0);if(y){let t=new l(c?(h+a)/2:_,u?(o+n)/2:g);return i.center=nc(s,t).wrap(),i.zoom+=Pt(y),i}if(this._helper._latRange){let t=p/2;g-t<n&&(m=n+t),g+t>o&&(m=o-t)}if(r){let t=(a+h)/2,e=_;this._helper._renderWorldCopies&&(e=Mt(_,t-s/2,t+s/2));let i=f/2;e-i<a&&(d=a+i),e+i>h&&(d=h-i)}if(void 0!==d||void 0!==m){let t=new l(d??_,m??g);i.center=nc(s,t).wrap()}return i},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Gg({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new Vg}clone(){let e=new t;return e.apply(this,!1),e}apply(t,e,i){this._helper.apply(t,e,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let e=[new If(0,t)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new l(0,0)),r=this.screenPointToMercatorCoordinate(new l(this._helper._width,0)),s=this.screenPointToMercatorCoordinate(new l(this._helper._width,this._helper._height)),n=this.screenPointToMercatorCoordinate(new l(0,this._helper._height)),o=Math.floor(Math.min(i.x,r.x,s.x,n.x)),a=Math.floor(Math.max(i.x,r.x,s.x,n.x));for(let i=o-1;i<=a+1;i++)0!==i&&e.push(new If(i,t))}return e}getCameraFrustum(){return Zg.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let e=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLatZoom(e,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,e){let i=Ju(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(e,i),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,i),n=ec.fromLngLat(t),o=new ec(n.x-(r.x-s.x),n.y-(r.y-s.y));this.setCenter(o?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,e){return e?this.coordinatePoint(ec.fromLngLat(t),e.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(ec.fromLngLat(t))}screenPointToLocation(t,e){return this.screenPointToMercatorCoordinate(t,e)?.toLngLat()}screenPointToMercatorCoordinate(t,e){if(e){let i=e.pointCoordinate(t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,e){let i=e||0,r=[t.x,t.y,0,1],s=[t.x,t.y,1,1];N(r,r,this._pixelMatrixInverse),N(s,s,this._pixelMatrixInverse);let n=r[3],o=s[3],a=r[1]/n,l=s[1]/o,h=r[2]/n,u=s[2]/o,c=h===u?0:(i-h)/(u-h);return new ec(ir.number(r[0]/n,s[0]/o,c)/this.worldSize,ir.number(a,l,c)/this.worldSize,i)}coordinatePoint(t,e=0,i=this._pixelMatrix){let r=[t.x*this.worldSize,t.y*this.worldSize,e,1];return N(r,r,i),new l(r[0]/r[3],r[1]/r[3])}getBounds(){let t=Math.max(0,this._helper._height/2-oc(this));return(new Zm).extend(this.screenPointToLocation(new l(0,t))).extend(this.screenPointToLocation(new l(this._helper._width,t))).extend(this.screenPointToLocation(new l(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new l(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=e.pointCoordinate(t):t.y>this.height/2-oc(this)}calculatePosMatrix(t,e=!1,i=!1){let r=t.key??kf(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),s=e?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(r)){let t=s.get(r);return i?t.f32:t.f64}let n=ac(t,this.worldSize);y(n,e?this._alignedProjMatrix:this._viewProjMatrix,n);let o={f64:n,f32:new Float32Array(n)};return s.set(r,o),i?o.f32:o.f64}calculateFogMatrix(t){let e=t.key,i=this._fogMatrixCacheF32;if(i.has(e))return i.get(e);let r=ac(t,this.worldSize);return y(r,this._fogMatrix,r),i.set(e,new Float32Array(r)),i.get(e)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}_calculateNearFarZIfNeeded(t,e,i){if(!this._helper.autoCalculateNearFarZ)return;let r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),s=t-r*this._helper._pixelPerMeter/Math.cos(e),n=r<0?s:t,o=Math.PI/2+this.pitchInRadians,a=qt(this.fov)*(Math.abs(Math.cos(qt(this.roll)))*this.height+Math.abs(Math.sin(qt(this.roll)))*this.width)/this.height*(.5+i.y/this.height),l=Math.sin(a)*n/Math.sin(xt(Math.PI-o-a,.01,Math.PI-.01)),h=oc(this),u=Math.atan(h/this._helper.cameraToCenterDistance),c=qt(.75),f=u>c?2*u*(.5+i.y/(2*h)):c,p=Math.sin(f)*n/Math.sin(xt(Math.PI-o-f,.01,Math.PI-.01)),d=Math.min(l,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-e)*d+n),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let t=this.centerOffset,e=sc(this.worldSize,this.center),i=e.x,r=e.y;this._helper._pixelPerMeter=Ju(1,this.center.lat)*this.worldSize;let s,n=qt(Math.min(this.pitch,ic)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(n));this._calculateNearFarZIfNeeded(o,n,t),s=new Float64Array(16),z(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),function(t,e){t[0]=1/e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1/e[5],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=1/e[14],t[12]=0,t[13]=0,t[14]=-1,t[15]=e[10]/e[14]}(this._invProjMatrix,s),s[8]=2*-t.x/this._helper._width,s[9]=2*t.y/this._helper._height,this._projectionMatrix=m(s),w(s,s,[1,-1,1]),v(s,s,[0,0,-this._helper.cameraToCenterDistance]),M(s,s,-this.rollInRadians),b(s,s,this.pitchInRadians),M(s,s,-this.bearingInRadians),v(s,s,[-i,-r,0]),this._mercatorMatrix=w([],s,[this.worldSize,this.worldSize,this.worldSize]),w(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=y(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),v(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=g([],s);let a=[0,0,-1,1];N(a,a,this._invViewProjMatrix),this._cameraPosition=[a[0]/a[3],a[1]/a[3],a[2]/a[3]],this._fogMatrix=new Float64Array(16),z(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,w(this._fogMatrix,this._fogMatrix,[1,-1,1]),v(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),M(this._fogMatrix,this._fogMatrix,-this.rollInRadians),b(this._fogMatrix,this._fogMatrix,this.pitchInRadians),M(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),v(this._fogMatrix,this._fogMatrix,[-i,-r,0]),w(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),v(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=y(new Float64Array(16),this.clipSpaceToPixelsMatrix,s);let l=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),c=Math.sin(-this.bearingInRadians),f=i-Math.round(i)+u*l+c*h,p=r-Math.round(r)+u*h+c*l,d=new Float64Array(s);if(v(d,d,[f>.5?f-1:f,p>.5?p-1:p,0]),this._alignedProjMatrix=d,s=g(new Float64Array(16),this._pixelMatrix),!s)throw Error("failed to invert matrix");this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new l(0,0)),e=[t.x*this.worldSize,t.y*this.worldSize,0,1];return N(e,e,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let t=Ju(1,this.center.lat)*this.worldSize;return lc(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,e){let i=ec.fromLngLat(t),r=[i.x*this.worldSize,i.y*this.worldSize,e,1];return N(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(t){let e,{overscaledTileID:i,aligned:r,applyTerrainMatrix:s}=t,n=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null;return e=i?.terrainRttPosMatrix32f&&s?i.terrainRttPosMatrix32f:o||lt(),{mainMatrix:e,tileMercatorCoords:n,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:e,clipAntimeridian:!1}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return E(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,e,i,r){let s,n=this.calculatePosMatrix(i);r?(s=[t,e,r(t,e),1],N(s,s,n)):(s=[t,e,0,1],eg(s,s,n));let o=s[3];return{point:new l(s[0]/o,s[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(t){for(let e of t)this.calculatePosMatrix(e)}getProjectionDataForCustomLayer(t=!0){let e=new Cf(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:e,applyGlobeMatrix:t}),r=ac(e,this.worldSize);y(r,this._viewProjMatrix,r);let s=[et,et,this.worldSize/this._helper.pixelsPerMeter],n=ot();return w(n,r,s),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:n,mainMatrix:n}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function Hg(){jt("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Yg(t){if(t.useSlerp)if(t.k<1){let e=Ht(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),i=Ht(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),r=new Float64Array(4);!function(t,e,i,r){var s,n,o,a,l=e[0],h=e[1],u=e[2],c=e[3],f=i[0],p=i[1],d=i[2],m=i[3],_=l*f+h*p+u*d+c*m;_<0&&(_=-_,f=-f,p=-p,d=-d,m=-m),1-_>1e-6?(s=Math.acos(_),n=Math.sin(s),o=Math.sin((1-r)*s)/n,a=Math.sin(r*s)/n):(o=1-r,a=r),t[0]=o*l+a*f,t[1]=o*h+a*p,t[2]=o*u+a*d,t[3]=o*c+a*m}(r,e,i,t.k);let s=function(t){let e=new Float64Array(9);!function(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],o=i+i,a=r+r,l=s+s,h=i*o,u=r*o,c=r*a,f=s*o,p=s*a,d=s*l,m=n*o,_=n*a,g=n*l;t[0]=1-c-d,t[3]=u-g,t[6]=f+_,t[1]=u+g,t[4]=1-h-d,t[7]=p-m,t[2]=f-_,t[5]=p+m,t[8]=1-h-c}(e,t);let i,r,s=Vt(-Math.asin(xt(e[2],-1,1)));return Math.hypot(e[5],e[8])<.001?(i=0,r=-Vt(Math.atan2(e[3],e[4]))):(i=Vt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),r=Vt(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:i,pitch:s+90,bearing:r}}(r);t.tr.setRoll(s.roll),t.tr.setPitch(s.pitch),t.tr.setBearing(s.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(ir.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(ir.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(ir.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Xg(t,e,i,r,s){let n=s.padding,o=sc(s.worldSize,i.getNorthWest()),a=sc(s.worldSize,i.getNorthEast()),h=sc(s.worldSize,i.getSouthEast()),u=sc(s.worldSize,i.getSouthWest()),c=qt(-r),f=o.rotate(c),p=a.rotate(c),d=h.rotate(c),m=u.rotate(c),_=new l(Math.max(f.x,p.x,m.x,d.x),Math.max(f.y,p.y,m.y,d.y)),g=new l(Math.min(f.x,p.x,m.x,d.x),Math.min(f.y,p.y,m.y,d.y)),y=_.sub(g),v=(s.width-(n.left+n.right+e.left+e.right))/y.x,w=(s.height-(n.top+n.bottom+e.top+e.bottom))/y.y;if(w<0||v<0)return void Hg();let b=Math.min(Pt(s.scale*Math.min(v,w)),t.maxZoom),x=l.convert(t.offset),M=new l((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(qt(r)),z=x.add(M).mult(s.scale/At(b));return{center:nc(s.worldSize,o.add(h).div(2).sub(z)),zoom:b,bearing:r}}var Jg=class{get useGlobeControls(){return!1}handlePanInertia(t,e){let i=t.mag(),r=Math.abs(oc(e));return{easingOffset:t.mult(Math.min(.75*r/i,1)),easingCenter:e.center}}handleMapControlsRollPitchBearingZoom(t,e){t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta),t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta)}handleMapControlsPan(t,e,i){t.around.distSqr(e.centerPoint)<.01||e.setLocationAtPoint(i,t.around)}cameraForBoxAndBearing(t,e,i,r,s){return Xg(t,e,i,r,s)}handleJumpToCenterZoom(t,e){t.zoom!==(void 0===e.zoom?t.zoom:+e.zoom)&&t.setZoom(+e.zoom),void 0!==e.center&&t.setCenter(Zu.convert(e.center))}handleEaseTo(t,e){let i=t.zoom,r=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},n={roll:void 0===e.roll?t.roll:e.roll,pitch:void 0===e.pitch?t.pitch:e.pitch,bearing:void 0===e.bearing?t.bearing:e.bearing},o=void 0!==e.zoom,a=!t.isPaddingEqual(e.padding),l=!1,h=o?+e.zoom:t.zoom,u=t.centerPoint.add(e.offsetAsPoint),c=t.screenPointToLocation(u),{center:f,zoom:p}=t.applyConstrain(Zu.convert(e.center||c),h??i);Ng(t,f);let d=sc(t.worldSize,c),m=sc(t.worldSize,f).sub(d),_=At(p-i);return l=p!==i,{easeFunc:o=>{if(l&&t.setZoom(ir.number(i,p,o)),Zt(s,n)||Yg({startEulerAngles:s,endEulerAngles:n,tr:t,k:o,useSlerp:s.roll!=n.roll}),a&&(t.interpolatePadding(r,e.padding,o),u=t.centerPoint.add(e.offsetAsPoint)),e.around)t.setLocationAtPoint(e.around,e.aroundPoint);else{let e=At(t.zoom-i),r=(p>i?Math.min(2,_):Math.max(.5,_))**(1-o),s=nc(t.worldSize,d.add(m.mult(o*r)).mult(e));t.setLocationAtPoint(t.renderWorldCopies?s.wrap():s,u)}},isZooming:l,elevationCenter:f}}handleFlyTo(t,e){let i=void 0!==e.zoom,r=t.zoom,s=t.applyConstrain(Zu.convert(e.center||e.locationAtOffset),i?+e.zoom:r),n=s.center,o=s.zoom;Ng(t,n);let a=t.worldSize,l=sc(a,e.locationAtOffset),h=sc(a,n).sub(l),u=h.mag(),c=At(o-r),f=Math.max(void 0===e.minZoom?t.minZoom:+e.minZoom,t.minZoom),p=Math.min(f,r,o),d=t.applyConstrain(n,p).zoom;return{easeFunc:(e,i,s,u)=>{t.setZoom(1===e?o:r+Pt(i));let c=1===e?n:nc(a,l.add(h.mult(s)));t.setLocationAtPoint(t.renderWorldCopies?c.wrap():c,u)},scaleOfZoom:c,targetCenter:n,scaleOfMinZoom:At(d-r),pixelPathLength:u}}};let Kg;function Qg(t,e){let i=void 0===t.granularity?1:Math.max(t.granularity,1),r=i+(t.generateBorders?2:0),s=i+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),n=r+1,o=s+1,a=t.generateBorders?-1:0,l=t.generateBorders||t.extendToNorthPole?-1:0,h=i+ +!!t.generateBorders,u=i+(t.generateBorders||t.extendToSouthPole?1:0),c=n*o,f=r*s*6,p=n*o>65536;if(p&&"16bit"===e)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let d=p||"32bit"===e,m=new Int16Array(2*c),_=0;for(let e=l;e<=u;e++)for(let r=a;r<=h;r++){let s=r/i*et;-1===r&&(s=-64),r===i+1&&(s=8256);let n=e/i*et;-1===e&&(n=t.extendToNorthPole?Mu:-64),e===i+1&&(n=t.extendToSouthPole?zu:8256),m[_++]=s,m[_++]=n}let g=d?new Uint32Array(f):new Uint16Array(f),y=0;for(let t=0;t<s;t++)for(let e=0;e<r;e++){let i=e+1+t*n,r=e+(t+1)*n,s=e+1+(t+1)*n;g[y++]=e+t*n,g[y++]=r,g[y++]=i,g[y++]=i,g[y++]=r,g[y++]=s}return{vertices:m.buffer.slice(0),indices:g.buffer.slice(0),uses32bitIndices:d}}const ty=new xu({fill:new bu(128,2),line:new bu(512,0),tile:new bu(128,32),stencil:new bu(128,1),circle:3});var ey=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Dg.projectionGlobe}get vertexShaderPreludeCode(){return Dg.projectionMercator.vertexSource}get subdivisionGranularity(){return ty}get useGlobeControls(){return!0}destroy(){}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,e,i,r,s){let n=("stencil"===s?ty.stencil:ty.tile).getGranularityForZoomLevel(e.z);return this._getMesh(t,{granularity:n,generateBorders:i,extendToNorthPole:0===e.y&&r,extendToSouthPole:e.y===(1<<e.z)-1&&r})}_getMesh(t,e){let i=this._getMeshKey(e);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=function(t,e){let i=Qg(e,"16bit"),r=ka.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),s=Ya.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new $g(t.createVertexBuffer(r,jg.members),t.createIndexBuffer(s),Qa.simpleSegment(0,0,r.length,s.length))}(t,e);return this._tileMeshCache[i]=r,r}recalculate(t){}hasTransition(){return!1}},iy=class extends ge{constructor(t,e){super(),this._transitionable=new zo(Kg||=new Ro({type:new ko(ye.projection.type,"type")}),"projection",e),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new wo(0)),this._mercatorProjection=new Lg,this._verticalPerspectiveProjection=new ey}get transitionState(){let t=this.properties.get("type");if("string"==typeof t&&"mercator"===t)return 0;if("string"==typeof t&&"vertical-perspective"===t)return 1;if(t instanceof Ri){if(t.from===t.to)return"mercator"===t.from?0:1;if("vertical-perspective"===t.from&&"mercator"===t.to)return 1-t.transition;if("mercator"===t.from&&"vertical-perspective"===t.to)return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get 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()}getMeshFromTileID(t,e,i,r,s){return this.currentProjection.getMeshFromTileID(t,e,i,r,s)}setProjection(t){this._transitionable.setValue("type",t?.type||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}};function ry(t){let e=oy(t.worldSize,t.center.lat);return 2*Math.PI*e}function sy(t,e,i,r,s){let n=1/(1<<s),o=e/et*n+r*n,a=_t((t/et*n+i*n)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI,h=Math.cos(l),u=new Float64Array(3);return u[0]=Math.sin(a)*h,u[1]=Math.sin(l),u[2]=Math.cos(a)*h,u}function ny(t){return function(t,e){let i=Math.cos(e),r=new Float64Array(3);return r[0]=Math.sin(t)*i,r[1]=Math.sin(e),r[2]=Math.cos(t)*i,r}(t.lng*Math.PI/180,t.lat*Math.PI/180)}function oy(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function ay(t){let e=Math.asin(t[1])/Math.PI*180,i=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(i>1e-6){let r=t[0]/i,s=Math.acos(t[2]/i),n=(r>0?s:-s)/Math.PI*180;return new Zu(Mt(n,-180,180),e)}return new Zu(0,e)}function ly(t){return Math.cos(t*Math.PI/180)}function hy(t,e){let i=ly(t);return Pt(ly(e)/i)}function uy(t,e){let i=t.rotate(e.bearingInRadians),r=e.zoom+hy(e.center.lat,0),s=yt(1/ly(e.center.lat),1/ly(Math.min(Math.abs(e.center.lat),60)),gt(r,7,3,0,1)),n=function(t,e){return 360/ry({worldSize:t,center:{lat:e}})}(e.worldSize,e.center.lat);return new Zu(e.center.lng-i.x*n*s,xt(e.center.lat+i.y*n,-85.051129,Yt))}function cy(t){let e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function fy(t,e,i,r){let s=t.lat+i*r;if(Math.abs(i)>1){let n=(Math.sign(t.lat+i)===Math.sign(t.lat)?Math.abs(t.lat):-Math.abs(t.lat))*Math.PI/180,o=Math.abs(t.lat+i)*Math.PI/180,a=cy(n+r*(o-n)),l=cy(n),h=cy(o);return new Zu(t.lng+e*((a-l)/(h-l)),s)}return new Zu(t.lng+e*r,s)}var py=class{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;let t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,e,i,r){let s=`${t.z}_${t.x}_${t.y}_${r?.terrain?"t":""}_${Math.round(i)}`,n=this._cache.get(s);if(n)return n;let o=this._cachePrevious.get(s);if(o)return this._cache.set(s,o),o;let a=this._boundingVolumeFactory(t,e,i,r);return this._cache.set(s,a),this._hadAnyChanges=!0,a}},dy=class t{constructor(t,e,i,r){this.min=i,this.max=r,this.points=t,this.planes=e}static fromAabb(e,i){let r=[];for(let t=0;t<8;t++)r.push([1&~t?e[0]:i[0],1==(t>>1&1)?i[1]:e[1],1==(t>>2&1)?i[2]:e[2]]);return new t(r,[[-1,0,0,i[0]],[1,0,0,-e[0]],[0,-1,0,i[1]],[0,1,0,-e[1]],[0,0,-1,i[2]],[0,0,1,-e[2]]],e,i)}static fromCenterSizeAngles(e,i,r){let s=G([],r[0],r[1],r[2]),n=$([],[i[0],0,0],s),o=$([],[0,i[1],0],s),a=$([],[0,0,i[2]],s),l=[...e],h=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){let r=e[i]+n[i]*(1&~t?-1:1)+o[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],r),h[i]=Math.max(h[i],r)}let u=[];for(let t=0;t<8;t++){let i=[...e];I(i,i,C([],n,1&~t?-1:1)),I(i,i,C([],o,1==(t>>1&1)?1:-1)),I(i,i,C([],a,1==(t>>2&1)?1:-1)),u.push(i)}return new t(u,[[...n,-D(n,u[0])],[...o,-D(o,u[0])],[...a,-D(a,u[0])],[-n[0],-n[1],-n[2],-D(n,u[7])],[-o[0],-o[1],-o[2],-D(o,u[7])],[-a[0],-a[1],-a[2],-D(a,u[7])]],l,h)}intersectsFrustum(t){let e=!0,i=this.points.length,r=this.planes.length,s=t.planes.length,n=t.points.length;for(let r=0;r<s;r++){let s=t.planes[r],n=0;for(let t=0;t<i;t++){let e=this.points[t];s[0]*e[0]+s[1]*e[1]+s[2]*e[2]+s[3]>=0&&n++}if(0===n)return 0;n<i&&(e=!1)}if(e)return 2;for(let e=0;e<r;e++){let i=this.planes[e],r=0;for(let e=0;e<n;e++){let s=t.points[e];i[0]*s[0]+i[1]*s[1]+i[2]*s[2]+i[3]>=0&&r++}if(0===r)return 0}return 1}intersectsPlane(t){let e=this.points.length,i=0;for(let r=0;r<e;r++){let e=this.points[r];t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0&&i++}return i===e?2:0===i?0:1}};function my(t,e,i){let r=t-e;return r<0?-r:Math.max(0,r-i)}function _y(t,e,i,r,s){let n,o=t-i;return n=o<0?Math.min(-o,1+o-s):o>s?Math.min(Math.max(o-s,0),1-o):0,Math.max(n,my(e,r,s))}var gy=class{constructor(){this._boundingVolumeCache=new py(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,e,i,r){let s=1<<i.z,n=1/s,o=i.x/s,a=i.y/s,l=2;return l=Math.min(l,_y(t,e,o,a,n)),l=Math.min(l,_y(t,e,o+.5,-a-n,n)),l=Math.min(l,_y(t,e,o+.5,2-a-n,n)),l}getWrap(t,e,i){let r=1<<e.z,s=1/r,n=e.x/r,o=my(t.x,n,s),a=my(t.x,n-1,s),l=my(t.x,n+1,s),h=Math.min(o,a,l);return h===l?1:h===a?-1:0}allowVariableZoom(t,e){return v_(t,e)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,e,i,r){return this._boundingVolumeCache.getTileBoundingVolume(t,e,i,r)}_computeTileBoundingVolume(t,e,i,r){let s=Math.min(0,i),n=Math.max(0,i);if(r?.terrain){let i=new Cf(t.z,e,t.z,t.x,t.y),o=r.terrain.getMinMaxElevation(i);s=o.minElevation??s,n=o.maxElevation??n}if(s/=Vu,n/=Vu,s+=1,n+=1,t.z<=0)return dy.fromAabb([-n,-n,-n],[n,n,n]);if(1===t.z)return dy.fromAabb([0===t.x?-n:0,0===t.y?0:-n,-n],[0===t.x?0:n,0===t.y?n:0,n]);{let e=[sy(0,0,t.x,t.y,t.z),sy(et,0,t.x,t.y,t.z),sy(et,et,t.x,t.y,t.z),sy(0,et,t.x,t.y,t.z)],i=[];for(let t of e)i.push(C([],t,n));if(n!==s)for(let t of e)i.push(C([],t,s));0===t.y&&i.push([0,1,0]),t.y===(1<<t.z)-1&&i.push([0,-1,0]);let r=[1,1,1],o=[-1,-1,-1];for(let t of i)for(let e=0;e<3;e++)r[e]=Math.min(r[e],t[e]),o[e]=Math.max(o[e],t[e]);let a=sy(et/2,et/2,t.x,t.y,t.z),l=F([],[0,1,0],a);k(l,l);let h=F([],a,l);k(h,h);let u=F([],e[2],e[1]);k(u,u);let c=F([],e[0],e[3]);k(c,c),i.push(C([],a,n)),t.y>=(1<<t.z)/2&&i.push(C([],sy(et/2,0,t.x,t.y,t.z),n)),t.y<(1<<t.z)/2&&i.push(C([],sy(et/2,et,t.x,t.y,t.z),n));let f=yy(a,i),p=yy(h,i),d=[-a[0],-a[1],-a[2],f.max],m=[a[0],a[1],a[2],-f.min],_=[-h[0],-h[1],-h[2],p.max],g=[h[0],h[1],h[2],-p.min],y=[...u,0],v=[...c,0],w=[];return 0===t.y?w.push(ct(v,y,d),ct(v,y,m)):w.push(ct(_,y,d),ct(_,y,m),ct(_,v,d),ct(_,v,m)),t.y===(1<<t.z)-1?w.push(ct(v,y,d),ct(v,y,m)):w.push(ct(g,y,d),ct(g,y,m),ct(g,v,d),ct(g,v,m)),new dy(w,[d,m,_,g,y,v],r,o)}}};function yy(t,e){let i=1/0,r=-1/0;for(let s of e){let e=D(t,s);i=Math.min(i,e),r=Math.max(r,e)}return{min:i,max:r}}var vy=class t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e){this._helper.resize(t,e)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t){this._cachedClippingPlane=st(),this._projectionMatrix=at(),this._globeViewProjMatrix32f=lt(),this._globeViewProjMatrixF64=at(),this._globeViewProjMatrixF64Inverted=at(),this._globeProjMatrixInverted=at(),this._cameraPosition=nt(),this.defaultConstrain=(t,e)=>{let i=xt(t.lat,-85.051129,Yt),r=xt(+e,this.minZoom+hy(0,i),this.maxZoom);return{center:new Zu(t.lng,i),zoom:r}},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Gg({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new gy}clone(){let e=new t;return e.apply(this,!1),e}apply(t,e){this._helper.apply(t,e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=nt();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){let{overscaledTileID:e,applyGlobeMatrix:i}=t,r=this._helper.getMercatorTileCoordinates(e);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!i,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:0===e?.canonical.z}}_computeClippingPlane(t){let e=this.pitchInRadians,i=this.cameraToCenterDistance/t,r=Math.sin(e)*i,s=Math.cos(e)*i+1,n=1/Math.sqrt(r*r+s*s)*1,o=-r,a=s,l=Math.sqrt(o*o+a*a);o/=l,a/=l;let h=[0,o,a];O(h,h,[0,0,0],-this.bearingInRadians),j(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),R(h,h,[0,0,0],this.center.lng*Math.PI/180);let u=1/A(h);return C(h,h,u),[...h,-n*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(ny(t))}transformLightDirection(t){let e=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,r=Math.cos(i),s=[Math.sin(e)*r,Math.sin(i),Math.cos(e)*r],n=[s[2],0,-s[0]],o=[0,0,0];F(o,n,s),k(n,n),k(o,o);let a=[0,0,0];return k(a,[n[0]*t[0]+o[0]*t[1]+s[0]*t[2],n[1]*t[0]+o[1]*t[1]+s[1]*t[2],n[2]*t[0]+o[2]*t[1]+s[2]*t[2]]),a}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,e,i){let r=rc(t,e,i.canonical),s=function(t,e){return[_t(t*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-e*Math.PI*2))-.5*Math.PI]}(r.x,r.y);return this.getCircleRadiusCorrection()/Math.cos(s[1])}projectTileCoordinates(t,e,i,r){let s=i.canonical,n=sy(t,e,s.x,s.y,s.z),o=1+(r?r(t,e):0)/Vu,a=[n[0]*o,n[1]*o,n[2]*o,1];N(a,a,this._globeViewProjMatrixF64);let h=this._cachedClippingPlane,u=h[0]*n[0]+h[1]*n[1]+h[2]*n[2]+h[3]<0;return{point:new l(a[0]/a[3],a[1]/a[3]),signedDistanceFromCamera:a[3],isOccluded:u}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let t=oy(this.worldSize,this.center.lat),e=ot();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),z(e,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;e[8]=2*-i.x/this._helper._width,e[9]=2*i.y/this._helper._height,this._projectionMatrix=m(e),this._globeProjMatrixInverted=ot(),g(this._globeProjMatrixInverted,e),v(e,e,[0,0,-this.cameraToCenterDistance]),M(e,e,this.rollInRadians),b(e,e,-this.pitchInRadians),M(e,e,this.bearingInRadians),v(e,e,[0,0,-t]);let r=nt();r[0]=t,r[1]=t,r[2]=t,b(e,e,this.center.lat*Math.PI/180),x(e,e,-this.center.lng*Math.PI/180),w(e,e,r),this._globeViewProjMatrixF64=e,this._globeViewProjMatrix32f=new Float32Array(e),this._globeViewProjMatrixF64Inverted=ot(),g(this._globeViewProjMatrixF64Inverted,e);let s=nt();this._cameraPosition=nt(),this._cameraPosition[2]=this.cameraToCenterDistance/t,O(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),j(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),O(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),I(this._cameraPosition,this._cameraPosition,[0,0,1]),j(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),R(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);let n=m(this._globeViewProjMatrixF64Inverted);w(n,n,[1,1,-1]),this._cachedFrustum=Zg.fromInvProjectionMatrix(n,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){jt("calculateFogMatrix is not supported on globe projection.");let e=ot();return _(e),e}getVisibleUnwrappedCoordinates(t){return[new If(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t?jt("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,e){if(!this._globeViewProjMatrixF64)return 1;let i=ny(t);C(i,i,1+e/Vu);let r=st();return N(r,[i[0],i[1],i[2],1],this._globeViewProjMatrixF64),r[2]/r[3]}populateCache(t){}getBounds(){let t=.5*this.width,e=.5*this.height,i=[new l(0,0),new l(t,0),new l(this.width,0),new l(this.width,e),new l(this.width,this.height),new l(t,this.height),new l(0,this.height),new l(0,e)],r=[];for(let t of i)r.push(this.unprojectScreenPoint(t));let s=0,n=0,o=0,a=0,h=this.center;for(let t of r){let e=dt(h.lng,t.lng),i=dt(h.lat,t.lat);e<n&&(n=e),e>s&&(s=e),i<a&&(a=i),i>o&&(o=i)}let u=[h.lng+n,h.lat+a,h.lng+s,h.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new Zm(u)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,e){let i=ny(this.unprojectScreenPoint(e)),r=ny(t),s=nt();!function(t){t[0]=0,t[1]=0,t[2]=0}(s);let n=nt();R(n,i,s,-this.center.lng*Math.PI/180),j(n,n,s,this.center.lat*Math.PI/180);let o=r[0]*r[0]+r[2]*r[2],a=n[0]*n[0];if(o<a)return;let l=Math.sqrt(o-a),h=-l,u=pt(r[0],r[2],n[0],l),c=pt(r[0],r[2],n[0],h),f=nt();R(f,r,s,-u);let p=pt(f[1],f[2],n[1],n[2]),d=nt();R(d,r,s,-c);let m,_,g=pt(d[1],d[2],n[1],n[2]),y=.5*Math.PI,v=p>=-y&&p<=y,w=g>=-y&&g<=y;if(v&&w){let t=this.center.lng*Math.PI/180,e=this.center.lat*Math.PI/180;mt(u,t)+mt(p,e)<mt(c,t)+mt(g,e)?(m=u,_=p):(m=c,_=g)}else if(v)m=u,_=p;else{if(!w)return;m=c,_=g}let b=m/Math.PI*180,x=_/Math.PI*180,M=this.center.lat;this.setCenter(new Zu(b,xt(x,-90,90))),this.setZoom(this.zoom+hy(M,this.center.lat))}locationToScreenPoint(t,e){let i=ny(t);return e&&C(i,i,1+e.getElevationForLngLatZoom(t,this._helper._tileZoom)/Vu),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(t){let e=st();return N(e,[...t,1],this._globeViewProjMatrixF64),e[0]/=e[3],e[1]/=e[3],new l((.5*e[0]+.5)*this.width,(.5*-e[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,e){if(e){let i=e.pointCoordinate(t);if(i)return i}return ec.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,e){return this.screenPointToMercatorCoordinate(t,e)?.toLngLat()}isPointOnMapSurface(t,e){let i=this._cameraPosition,r=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(t){let e=st();e[0]=t.x/this.width*2-1,e[1]=-1*(t.y/this.height*2-1),e[2]=1,e[3]=1,N(e,e,this._globeViewProjMatrixF64Inverted),e[0]/=e[3],e[1]/=e[3],e[2]/=e[3];let i=nt();i[0]=e[0]-this._cameraPosition[0],i[1]=e[1]-this._cameraPosition[1],i[2]=e[2]-this._cameraPosition[2];let r=nt();return k(r,i),r}isSurfacePointVisible(t){let e=this._cachedClippingPlane;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let e=st();return N(e,[...t,1],this._globeViewProjMatrixF64),e[0]/=e[3],e[1]/=e[3],e[2]/=e[3],e[0]>-1&&e[0]<1&&e[1]>-1&&e[1]<1&&e[2]>-1&&e[2]<1}rayPlanetIntersection(t,e){let i=D(t,e),r=nt(),s=nt();C(s,e,i),L(r,t,s);let n=1-D(r,r);if(n<0)return null;let o=D(t,t)-1,a=-i+(i<0?1:-1)*Math.sqrt(n),l=o/a,h=a;return{tMin:Math.min(l,h),tMax:Math.max(l,h)}}unprojectScreenPoint(t){let e=this._cameraPosition,i=this.getRayDirectionFromPixel(t),r=this.rayPlanetIntersection(e,i);if(r){let t=nt();I(t,e,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let s=nt();return k(s,t),ay(s)}let s=this._cachedClippingPlane,n=s[0]*i[0]+s[1]*i[1]+s[2]*i[2],o=-ut(s,e)/n,a=nt();if(o>0)I(a,e,[i[0]*o,i[1]*o,i[2]*o]);else{let t=nt();I(t,e,[2*i[0],2*i[1],2*i[2]]);let r=ut(this._cachedClippingPlane,t);L(a,t,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}let l=function(t){let e=nt();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])}}(s);return ay(function(t,e,i){let r=nt();L(r,i,t);let s=nt();return function(t,e,i,r){t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r}(s,t,r,e/B(r)),s}(l.center,l.radius,a))}getProjectionDataForCustomLayer(t=!0){let e=this.getProjectionData({overscaledTileID:new Cf(0,0,0,0,0),applyGlobeMatrix:t});return e.tileMercatorCoords=[0,0,1,1],e}getFastPathSimpleProjectionMatrix(t){}},wy=class t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t){this._globeness=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeness=1,this.defaultConstrain=(t,e)=>this.currentTransform.defaultConstrain(t,e),this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Gg({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._globeness=1,this._mercatorTransform=new Wg,this._verticalPerspectiveTransform=new vy}clone(){let e=new t;return e._globeness=this._globeness,e.apply(this,!1),e}apply(t,e){this._helper.apply(t,e),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){let e=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:e.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:e.fallbackMatrix,clipAntimeridian:i.clipAntimeridian}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return yt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return yt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,e,i){return yt(this._mercatorTransform.getPitchedTextCorrection(t,e,i),this._verticalPerspectiveTransform.getPitchedTextCorrection(t,e,i),this._globeness)}projectTileCoordinates(t,e,i,r){return this.currentTransform.projectTileCoordinates(t,e,i,r)}_calcMatrices(){!this._helper._width||!this._helper._height||(this._verticalPerspectiveTransform.apply(this,!1),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,e){return this.currentTransform.lngLatToCameraDepth(t,e)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,e){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,e),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,e),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,e){return this.currentTransform.locationToScreenPoint(t,e)}screenPointToMercatorCoordinate(t,e){return this.currentTransform.screenPointToMercatorCoordinate(t,e)}screenPointToLocation(t,e){return this.currentTransform.screenPointToLocation(t,e)}isPointOnMapSurface(t,e){return this.currentTransform.isPointOnMapSurface(t,e)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let e=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return e;let i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=e.mainMatrix,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},by=class t{get useGlobeControls(){return!0}handlePanInertia(t,e){let i=uy(t,e);return Math.abs(i.lng-e.center.lng)>180&&(i.lng=e.center.lng+179.5*Math.sign(i.lng-e.center.lng)),{easingCenter:i,easingOffset:new l(0,0)}}handleMapControlsRollPitchBearingZoom(t,e){let i=t.around,r=e.screenPointToLocation(i);t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta);let s=e.zoom;t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta);let n=e.zoom-s;if(0===n)return;let o=dt(e.center.lng,r.lng),a=o/(Math.abs(o/180)+1),l=dt(e.center.lat,r.lat),h=e.getRayDirectionFromPixel(i),u=e.cameraPosition,c=-1*D(u,h),f=nt();I(f,u,[h[0]*c,h[1]*c,h[2]*c]);let p=A(f)-1,d=Math.exp(.5*-Math.max(p-.3,0)),m=oy(e.worldSize,e.center.lat)/Math.min(e.width,e.height),_=gt(m,.9,.5,1,.25),g=(1-At(-n))*Math.min(d,_),y=e.center.lat,v=e.zoom,w=new Zu(e.center.lng+a*g,xt(e.center.lat+l*g,-85.051129,Yt));e.setLocationAtPoint(r,i);let b=e.center,x=gt(Math.abs(o),45,85,0,1),M=gt(m,.75,.35,0,1),z=Math.max(x,M)**.25,S=dt(b.lng,w.lng),T=dt(b.lat,w.lat);e.setCenter(new Zu(b.lng+S*z,b.lat+T*z).wrap()),e.setZoom(v+hy(y,e.center.lat))}handleMapControlsPan(t,e,i){if(!t.panDelta)return;let r=e.center.lat,s=e.zoom;e.setCenter(uy(t.panDelta,e).wrap()),e.setZoom(s+hy(r,e.center.lat))}cameraForBoxAndBearing(e,i,r,s,n){let o=Xg(e,i,r,s,n),a=i.left/n.width*2-1,l=(n.width-i.right)/n.width*2-1,h=i.top/n.height*-2+1,u=(n.height-i.bottom)/n.height*-2+1,c=dt(r.getWest(),r.getEast())<0,f=c?r.getEast():r.getWest(),p=c?r.getWest():r.getEast(),d=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),_=f+.5*dt(f,p),g=d+.5*dt(d,m),y=n.clone();y.setCenter(o.center),y.setBearing(o.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(o.zoom);let v=y.modelViewProjectionMatrix,w=[ny(r.getNorthWest()),ny(r.getNorthEast()),ny(r.getSouthWest()),ny(r.getSouthEast()),ny(new Zu(p,g)),ny(new Zu(f,g)),ny(new Zu(_,d)),ny(new Zu(_,m))],b=ny(o.center),x=1/0;for(let e of w)a<0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"x",a))),l>0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"x",l))),h>0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"y",h))),u<0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"y",u)));if(Number.isFinite(x)&&0!==x)return o.zoom=Math.min(y.zoom+Pt(x),e.maxZoom),o;Hg()}handleJumpToCenterZoom(t,e){let i=t.center.lat,r=t.applyConstrain(e.center?Zu.convert(e.center):t.center,t.zoom).center;t.setCenter(r.wrap());let s=void 0===e.zoom?t.zoom+hy(i,r.lat):+e.zoom;t.zoom!==s&&t.setZoom(s)}handleEaseTo(t,e){let i=t.zoom,r=t.center,s=t.padding,n={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:void 0===e.roll?t.roll:e.roll,pitch:void 0===e.pitch?t.pitch:e.pitch,bearing:void 0===e.bearing?t.bearing:e.bearing},a=void 0!==e.zoom,h=!t.isPaddingEqual(e.padding),u=!1,c=e.center?Zu.convert(e.center):r,f=t.applyConstrain(c,i).center;Ng(t,f);let p=t.clone();p.setCenter(f),p.setZoom(a?+e.zoom:i+hy(r.lat,c.lat)),p.setBearing(e.bearing);let d=new l(xt(t.centerPoint.x+e.offsetAsPoint.x,0,t.width),xt(t.centerPoint.y+e.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(f,d);let m=(e.offset&&e.offsetAsPoint.mag())>0?p.center:f,_=a?+e.zoom:i+hy(r.lat,m.lat),g=i+hy(r.lat,0),y=_+hy(m.lat,0),v=dt(r.lng,m.lng),w=dt(r.lat,m.lat),b=At(y-g);return u=_!==i,{easeFunc:i=>{if(Zt(n,o)||Yg({startEulerAngles:n,endEulerAngles:o,tr:t,k:i,useSlerp:n.roll!=o.roll}),h&&t.interpolatePadding(s,e.padding,i),e.around)jt("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(e.around,e.aroundPoint);else{let e=i*(y>g?Math.min(2,b):Math.max(.5,b))**(1-i),s=fy(r,v,w,e);t.setCenter(s.wrap())}if(u){let e=ir.number(g,y,i)+hy(0,t.center.lat);t.setZoom(e)}},isZooming:u,elevationCenter:m}}handleFlyTo(t,e){let i=void 0!==e.zoom,r=t.center,s=t.zoom,n=t.padding,o=!t.isPaddingEqual(e.padding),a=t.applyConstrain(Zu.convert(e.center||e.locationAtOffset),s).center,h=i?+e.zoom:t.zoom+hy(t.center.lat,a.lat),u=t.clone();u.setCenter(a),u.setZoom(h),u.setBearing(e.bearing);let c=new l(xt(t.centerPoint.x+e.offsetAsPoint.x,0,t.width),xt(t.centerPoint.y+e.offsetAsPoint.y,0,t.height));u.setLocationAtPoint(a,c);let f=u.center;Ng(t,f);let p=function(t,e,i){let r=D(ny(e),ny(i)),s=Math.acos(r),n=ry(t);return s/(2*Math.PI)*n}(t,r,f),d=s+hy(r.lat,0),m=h+hy(f.lat,0),_=At(m-d),g=Math.max("number"==typeof e.minZoom?+e.minZoom:t.minZoom,t.minZoom)+hy(f.lat,0),y=Math.min(g,d,m)+hy(0,f.lat),v=At(t.applyConstrain(f,y).zoom+hy(f.lat,0)-d),w=dt(r.lng,f.lng),b=dt(r.lat,f.lat);return{easeFunc:(i,s,a)=>{let l=fy(r,w,b,a);o&&t.interpolatePadding(n,e.padding,i);let u=1===i?f:l;t.setCenter(u.wrap());let c=d+Pt(s);t.setZoom(1===i?h:c+hy(0,u.lat))},scaleOfZoom:_,targetCenter:f,scaleOfMinZoom:v,pixelPathLength:p}}static solveVectorScale(t,e,i,r,s){let n="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],o=[i[3],i[7],i[11],i[15]],a=t[0]*n[0]+t[1]*n[1]+t[2]*n[2],l=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],h=e[0]*n[0]+e[1]*n[1]+e[2]*n[2],u=e[0]*o[0]+e[1]*o[1]+e[2]*o[2];return h+s*l===a+s*u||o[3]*(a-h)+n[3]*(u-l)+a*u==h*l?null:(h+n[3]-s*u-s*o[3])/(h-a-s*u+s*l)}static getLesserNonNegativeNonNull(t,e){return null!==e&&e>=0&&e<t?e:t}},xy=class{constructor(t){this._globe=t,this._mercatorCameraHelper=new Jg,this._verticalPerspectiveCameraHelper=new by}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,e){return this.currentHelper.handlePanInertia(t,e)}handleMapControlsRollPitchBearingZoom(t,e){this.currentHelper.handleMapControlsRollPitchBearingZoom(t,e)}handleMapControlsPan(t,e,i){this.currentHelper.handleMapControlsPan(t,e,i)}cameraForBoxAndBearing(t,e,i,r,s){return this.currentHelper.cameraForBoxAndBearing(t,e,i,r,s)}handleJumpToCenterZoom(t,e){this.currentHelper.handleJumpToCenterZoom(t,e)}handleEaseTo(t,e){return this.currentHelper.handleEaseTo(t,e)}handleFlyTo(t,e){return this.currentHelper.handleFlyTo(t,e)}};const My=function(){let t={},e=ye.$version;for(let i in ye.$root){let r=ye.$root[i];if(r.required){let s=null;s="version"===i?e:"array"===r.type?[]:{},null!=s&&(t[i]=s)}}return t}();var zy=class extends ge{constructor(t,e={}){super(),this._rtlPluginLoaded=()=>{for(let t in this.tileManagers){let e=this.tileManagers[t].getSource().type;("vector"===e||"geojson"===e)&&this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new Om(Rm(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.dispatcher.registerMessageHandler("GDA",((t,e)=>this.getDashes(t,e))),this.imageManager=new ym,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(t._missingStyleImageResolver);let i=t._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new Tm(t._requestManager,e.localIdeographFontFamily,i),this.lineAtlas=new Cm(256,512),this.crossTileSymbolIndex=new Cg,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",he()),c_().on(l_,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;let e=this.tileManagers[t.sourceId];if(!e)return;let i=e.getSource();if(i?.vectorLayerIds)for(let t in this._layers){let e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}_setInitialValues(){this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new uo,this._availableImages=[],this._imagesListDirty=!1,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(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,e){this._checkLoaded();let i=null===e?this.stylesheet.state?.[t]?.default??null:e;if(Dt(i,this._globalState[t]))return this;this._globalState[t]=i,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();let e=[];for(let i in t)Dt(this._globalState[i],t[i].default)||(e.push(i),this._globalState[i]=t[i].default);this._applyGlobalStateChanges(e)}_applyGlobalStateChanges(t){if(0===t.length)return;let e=new Set,i={};for(let r of t){i[r]=this._globalState[r];for(let t in this._layers){let i=this._layers[t],s=i.getLayoutAffectingGlobalStateRefs(),n=i.getPaintAffectingGlobalStateRefs(),o=i.getVisibilityAffectingGlobalStateRefs();if(s.has(r)&&e.add(i.source),n.has(r))for(let{name:t,value:e}of n.get(r))this._updatePaintProperty(i,t,e);o?.has(r)&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(let t in this.tileManagers)e.has(t)&&(this._reloadSource(t),this._changed=!0)}async loadURL(t,e={},i){this.fire(new om("dataloading")),e.validate="boolean"!=typeof e.validate||e.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let s=await this.map._requestManager.transformRequest(t,"Style");se(r.signal);let n=await ce(s,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(n.data,e,i)}catch(t){this._loadStyleRequest===r&&(this._loadStyleRequest=null),t&&!r.signal.aborted&&this.fire(new _e(rt(t)))}}loadJSON(t,e={},i){this.fire(new om("dataloading")),this._frameRequest=new AbortController,Jd.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,e.validate=!1!==e.validate,this._load(t,e,i)})).catch((()=>{}))}loadEmpty(){this.fire(new om("dataloading")),this._load(My,{validate:!1})}_load(t,e,i){let r=e.transformStyle?e.transformStyle(i,t):t;if(!e.validate||!Qn(this,r)){r={...r},this._loaded=!0,this.stylesheet=r;for(let t in r.sources)this.addSource(t,r.sources[t],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this._createLayers(),this.light=new Am(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new Im(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new om("data")),this.fire(new nm)}}_createLayers(){let t=be(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(let e of t){let t=zf(e,this._globalState);if(t.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=t,Go(t)&&this.tileManagers[t.source]){let i=e.paint?.["raster-fade-duration"]??t.paint.get("raster-fade-duration");this.tileManagers[t.source].setRasterFadeDuration(i)}}}_loadSprite(t,e=!1,i){this.imageManager.setLoaded(!1);let r,s=new AbortController;this._spriteRequest=s,async function(t,e,i,r){let s=_m(t),n=i>1?"@2x":"",o={},a={};for(let{id:t,url:i}of s){let s=await e.transformRequest(gm(i,n,".json"),"SpriteJSON");o[t]=ce(s,r);let l=await e.transformRequest(gm(i,n,".png"),"SpriteImage");a[t]=em.getImage(l,r)}return await Promise.all([...Object.values(o),...Object.values(a)]),async function(t,e){let i={};for(let r in t){i[r]={};let s=Jd.getImageCanvasContext((await e[r]).data),n=(await t[r]).data;for(let t in n){let{width:e,height:o,x:a,y:l,sdf:h,pixelRatio:u,stretchX:c,stretchY:f,content:p,textFitWidth:d,textFitHeight:m}=n[t];i[r][t]={data:null,pixelRatio:u,sdf:h,stretchX:c,stretchY:f,content:p,textFitWidth:d,textFitHeight:m,spriteData:{width:e,height:o,x:a,y:l,context:s}}}}return i}(o,a)}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(let i in t){this._spritesImagesIds[i]=[];let r=this._spritesImagesIds[i]?this._spritesImagesIds[i].filter((e=>!(e in t))):[];for(let t of r)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(let r in t[i]){let s="default"===i?r:`${i}:${r}`;this._spritesImagesIds[i].push(s),s in this.imageManager.images?this.imageManager.updateImage(s,t[i][r],!1):this.imageManager.addImage(s,t[i][r]),e&&(this._changedImages[s]=!0)}}})).catch((t=>{this._spriteRequest=null,r=t,s.signal.aborted||this.fire(new _e(r))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),e&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new om("data")),i&&i(r)}))}_unloadSprite(){for(let t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._imagesListDirty=!0,this._changed=!0,this.fire(new om("data"))}_validateLayer(t){let e=this.tileManagers[t.source];if(!e)return;let i=t.sourceLayer;if(!i)return;let r=e.getSource();("geojson"===r.type||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new _e(Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(t,e=!1){let i=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e?Ft(i):i);let r=[];for(let s of t)if(i[s]){let t=e?Ft(i[s]):i[s];r.push(t)}return r}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};let e=Object.keys(this._layers);for(let i of e){let e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(t){if(!this._loaded)return;let e=this._changed;if(e){this._imagesListDirty&&=(this.dispatcher.broadcast("SI",this._availableImages),!1);let e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(let t in this._updatedSources){let e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}let i={};for(let t in this.tileManagers){let e=this.tileManagers[t];i[t]=e.used,e.used=!1}for(let e of this._order){let i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(let t in i){let e=this.tileManagers[t];!!i[t]!=!!e.used&&e.fire(new am("data",{sourceDataType:"visibility",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,e&&this.fire(new om("data"))}_updateTilesForChangedImages(){let t=Object.keys(this._changedImages);if(t.length){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,e={}){this._checkLoaded();let i=this.serialize();if(t=e.transformStyle?e.transformStyle(i,t):t,(e.validate??1)&&Qn(this,t))return!1;(t=Ft(t)).layers=be(t.layers);let r=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!xe(t.version,e.version))return[{command:"setStyle",args:[e]}];xe(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),xe(t.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),xe(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),xe(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),xe(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),xe(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),xe(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),xe(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),xe(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),xe(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),xe(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),xe(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),xe(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),xe(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});let r={},s=[];!function(t,e,i,r){let s;for(s in t||={},e||={},t)Object.prototype.hasOwnProperty.call(t,s)&&(Object.prototype.hasOwnProperty.call(e,s)||Se(s,i,r));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?xe(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&&Ee(t,e,s)?Me(i,{command:"setGeoJSONSourceData",args:[s,e[s].data]}):Te(s,e,i,r)):ze(s,e,i))}(t.sources,e.sources,s,r);let n=[];t.layers&&t.layers.forEach((t=>{"source"in t&&r[t.source]?i.push({command:"removeLayer",args:[t.id]}):n.push(t)})),i=i.concat(s),function(t,e,i){t||=[],e||=[];let r,s,n,o,a,l=t.map(Pe),h=e.map(Pe),u=t.reduce(Ie,{}),c=e.reduce(Ie,{}),f=l.slice(),p=Object.create(null);for(let t=0,e=0;t<l.length;t++)r=l[t],Object.prototype.hasOwnProperty.call(c,r)?e++:(Me(i,{command:"removeLayer",args:[r]}),f.splice(f.indexOf(r,e),1));for(let t=0,e=0;t<h.length;t++)r=h[h.length-1-t],f[f.length-1-t]!==r&&(Object.prototype.hasOwnProperty.call(u,r)?(Me(i,{command:"removeLayer",args:[r]}),f.splice(f.lastIndexOf(r,f.length-e),1)):e++,o=f[f.length-t],Me(i,{command:"addLayer",args:[c[r],o]}),f.splice(f.length-t,0,r),p[r]=!0);for(let t=0;t<h.length;t++)if(r=h[t],s=u[r],n=c[r],!p[r]&&!xe(s,n)){if(!xe(s.source,n.source)||!xe(s["source-layer"],n["source-layer"])||!xe(s.type,n.type)){Me(i,{command:"removeLayer",args:[r]}),o=f[f.lastIndexOf(r)+1],Me(i,{command:"addLayer",args:[n,o]});continue}for(a in Ae(s.layout,n.layout,i,r,null,"setLayoutProperty"),Ae(s.paint,n.paint,i,r,null,"setPaintProperty"),xe(s.filter,n.filter)||Me(i,{command:"setFilter",args:[r,n.filter]}),(!xe(s.minzoom,n.minzoom)||!xe(s.maxzoom,n.maxzoom))&&Me(i,{command:"setLayerZoomRange",args:[r,n.minzoom,n.maxzoom]}),s)Object.prototype.hasOwnProperty.call(s,a)&&"layout"!==a&&"paint"!==a&&"filter"!==a&&"metadata"!==a&&"minzoom"!==a&&"maxzoom"!==a&&(0===a.indexOf("paint.")?Ae(s[a],n[a],i,r,a.slice(6),"setPaintProperty"):xe(s[a],n[a])||Me(i,{command:"setLayerProperty",args:[r,a,n[a]]}));for(a in n)!Object.prototype.hasOwnProperty.call(n,a)||Object.prototype.hasOwnProperty.call(s,a)||"layout"!==a&&"paint"!==a&&"filter"!==a&&"metadata"!==a&&"minzoom"!==a&&"maxzoom"!==a&&(0===a.indexOf("paint.")?Ae(s[a],n[a],i,r,a.slice(6),"setPaintProperty"):xe(s[a],n[a])||Me(i,{command:"setLayerProperty",args:[r,a,n[a]]}))}}(n,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:"setStyle",args:[e]}]}return i}(i,t),s=this._getOperationsToPerform(r);if(s.unimplemented.length>0)throw Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(let t of s.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new nm({style:this})),!0}_getOperationsToPerform(t){let e=[],i=[];for(let r of t)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,r.args)));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":e.push((()=>this.setGlobalState.apply(this,r.args)));break;case"setTransition":e.push((()=>{}));break;default:i.push(r.command)}return{operations:e,unimplemented:i}}addImage(t,e){this.getImage(t)?this.fire(new _e(Error(`An image named "${t}" already exists.`))):(this.imageManager.addImage(t,e),this._afterImageUpdated(t))}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}setMissingImageResolver(t){this.imageManager.setMissingImageResolver(t)}removeImage(t){this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t)):this.fire(new _e(Error(`An image named "${t}" does not exist.`)))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new om("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.tileManagers[t])throw Error(`Source "${t}" already exists.`);if(!e.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(Kn.has(e.type)&&this._validate(Jn.source,`sources.${t}`,e,null,i))return;this.map?._collectResourceTiming&&(e.collectResourceTiming=!0);let r=this.tileManagers[t]=new P_(t,e,this.dispatcher);r.style=this,r.setEventedParent(this,(()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:t}))),r.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.tileManagers[t])throw Error(`There is no source with this ID=${t}`);for(let e in this._layers)if(this._layers[e].source===t)return this.fire(new _e(Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));let e=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],e.fire(new am("data",{sourceDataType:"metadata",sourceId:t})),e.setEventedParent(null),e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.tileManagers[t])throw Error(`There is no source with this ID=${t}`);let i=this.tileManagers[t].getSource();if("geojson"!==i.type)throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.tileManagers[t]?.getSource()}addLayer(t,e,i={}){this._checkLoaded();let r,s=t.id;if(this.getLayer(s))return void this.fire(new _e(Error(`Layer "${s}" already exists on this map.`)));if("custom"===t.type){if(to(this,function(t){let e=[],i=t.id;return void 0===i&&e.push(new Ce(`layers.${i}`,null,'missing required property "id"')),void 0===t.render&&e.push(new Ce(`layers.${i}`,null,'missing required method "render"')),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push(new Ce(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),e}(t)))return;r=zf(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(s,t.source),t=zt(t=Ft(t),{source:s})),this._validate(Jn.layer,`layers.${s}`,t,{arrayIndex:-1},i))return;r=zf(t,this._globalState),this._validateLayer(r),r.setEventedParent(this,{layer:{id:s}})}let n=e?this._order.indexOf(e):this._order.length;if(e&&-1===n)this.fire(new _e(Error(`Cannot add layer "${s}" before non-existing layer "${e}".`)));else{if(this._order.splice(n,0,s),this._layerOrderChanged=!0,this._layers[s]=r,this._removedLayers[s]&&r.source&&"custom"!==r.type){let t=this._removedLayers[s];delete this._removedLayers[s],t.type===r.type?(this._updatedSources[r.source]="reload",this.tileManagers[r.source].pause()):this._updatedSources[r.source]="clear"}this._updateLayer(r),r.onAdd&&r.onAdd(this.map)}}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new _e(Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;let i=this._order.indexOf(t);this._order.splice(i,1);let r=e?this._order.indexOf(e):this._order.length;e&&-1===r?this.fire(new _e(Error(`Cannot move layer "${t}" before non-existing layer "${e}".`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();let e=this._layers[t];if(!e)return void this.fire(new _e(Error(`Cannot remove non-existing layer "${t}".`)));e.setEventedParent(null);let i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],e.onRemove&&e.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,e,i){this._checkLoaded();let r=this.getLayer(t);r?(r.minzoom!==e||r.maxzoom!==i)&&(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new _e(Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,e,i={}){this._checkLoaded();let r=this.getLayer(t);if(r){if(!Dt(r.filter,e)){if(null==e)return r.setFilter(void 0),void this._updateLayer(r);this._validate(Jn.filter,`layers.${r.id}.filter`,e,null,i)||(r.setFilter(Ft(e)),this._updateLayer(r))}}else this.fire(new _e(Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return Ft(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();let s=this.getLayer(t);s?Dt(s.getLayoutProperty(e),i)||(s.setLayoutProperty(e,i,r),this._updateLayer(s)):this.fire(new _e(Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){let i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new _e(Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();let s=this.getLayer(t);s?Dt(s.getPaintProperty(e),i)||this._updatePaintProperty(s,e,i,r):this.fire(new _e(Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,e,i,r={}){t.setPaintProperty(e,i,r)&&this._updateLayer(t),Go(t)&&"raster-fade-duration"===e&&this.tileManagers[t.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();let i=t.source,r=t.sourceLayer,s=this.tileManagers[i];if(void 0===s)return void this.fire(new _e(Error(`The source '${i}' does not exist in the map's style.`)));let n=s.getSource().type;if("geojson"===n&&r)return void this.fire(new _e(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new _e(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===t.id)return void this.fire(new _e(Error("The feature id parameter must be provided.")));let o=["__proto__","constructor","prototype"];e&&Object.keys(e).some((t=>o.includes(t)))?this.fire(new _e(Error(`The feature state should not include one of the following keys: ${o}`))):s.setFeatureState(r,t.id,e)}removeFeatureState(t,e){this._checkLoaded();let i=t.source,r=this.tileManagers[i];if(void 0===r)return void this.fire(new _e(Error(`The source '${i}' does not exist in the map's style.`)));let s=r.getSource().type,n="vector"===s?t.sourceLayer:void 0;"vector"!==s||n?e&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new _e(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,t.id,e):this.fire(new _e(Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();let e=t.source,i=t.sourceLayer,r=this.tileManagers[e];if(void 0!==r){if("vector"!==r.getSource().type||i)return void 0===t.id&&this.fire(new _e(Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id);this.fire(new _e(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new _e(Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return zt({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=Ct(this.tileManagers,(t=>t.serialize())),e=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return kt({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:t,layers:e,terrain:i},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.tileManagers[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){let e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let s=this._order.length-1;s>=0;s--){let n=this._order[s];if(e(n)){i[n]=s;for(let e of t){let t=e[n];if(t)for(let e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));let s=[];for(let n=this._order.length-1;n>=0;n--){let o=this._order[n];if(e(o))for(let t=r.length-1;t>=0;t--){let e=r[t].feature;if(i[e.layer.id]<n)break;s.push(e),r.pop()}else for(let e of t){let t=e[o];if(t)for(let e of t)s.push(e.feature)}}return s}queryRenderedFeatures(t,e,i){e?.filter&&this._validate(Jn.filter,"queryRenderedFeatures.filter",e.filter,null,e);let r={};if(e?.layers){if(!(Array.isArray(e.layers)||e.layers instanceof Set))return this.fire(new _e(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let t of e.layers){let e=this._layers[t];if(!e)return this.fire(new _e(Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[e.source]=!0}}let s=[];e.availableImages=this._availableImages;let n=this._serializedAllLayers(),o=e.layers instanceof Set?e.layers:Array.isArray(e.layers)?new Set(e.layers):null,a={...e,layers:o,globalState:this._globalState};for(let o in this.tileManagers)e.layers&&!r[o]||s.push(Um(this.tileManagers[o],this._layers,n,t,a,i,this.map.terrain?(t,e,i)=>this.map.terrain.getElevation(t,e,i):void 0));return this.placement&&s.push(function(t,e,i,r,s,n,o){let a={},l=n.queryRenderedSymbols(r),h=[];for(let t of Object.keys(l).map(Number))h.push(o[t]);h.sort(Gm);for(let i of h){let r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,{filterSpec:s.filter,globalState:s.globalState},s.layers,s.availableImages,t);for(let t in r){a[t]||=[];let e=r[t];e.sort(((t,e)=>{let r=i.featureSortOrder;if(r){let i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(let i of e)a[t].push(i)}}return function(t,e,i){for(let r in t)for(let s of t[r])qm(s,i[e[r].source]);return t}(a,t,i)}(this._layers,n,this.tileManagers,t,a,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(t,e){e?.filter&&this._validate(Jn.filter,"querySourceFeatures.filter",e.filter,null,e);let i=this.tileManagers[t];return i?function(t,e){let i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],s={};for(let t of i){let i=t.tileID.canonical.key;s[i]||(s[i]=!0,t.querySourceFeatures(r,e))}return r}(i,e?{...e,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let e in t)if(!Dt(t[e],i[e])){r=!0;break}if(!r)return;let s={now:Qd(),transition:zt({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(s)}getProjection(){return this.stylesheet?.projection}setProjection(t){this._checkLoaded();let e=t??{type:"mercator"};if(this.stylesheet.projection=t,this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(e.type)}getSky(){return this.stylesheet?.sky}setSky(t,e={}){this._checkLoaded();let i=this.getSky(),r=!1;if(!t&&!i)return;if(t&&!i)r=!0;else if(!t&&i)r=!0;else for(let e in t)if(!Dt(t[e],i[e])){r=!0;break}if(!r)return;let s={now:Qd(),transition:zt({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,e),this.sky.updateTransitions(s)}_setProjectionInternal(t){let e=function(t,e,i){let r={constrainOverride:e};if(Array.isArray(t)){let e=new iy({type:t},i);return{projection:e,transform:new wy(r),cameraHelper:new xy(e)}}switch(t){case"mercator":return{projection:new Lg,transform:new Wg(r),cameraHelper:new Jg};case"globe":{let t=new iy({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:t,transform:new wy(r),cameraHelper:new xy(t)}}case"vertical-perspective":return{projection:new ey,transform:new vy(r),cameraHelper:new by};default:return jt(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Lg,transform:new Wg(r),cameraHelper:new Jg}}}(t,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=e.projection,this.map.migrateProjection(e.transform,e.cameraHelper);for(let t in this.tileManagers)this.tileManagers[t].reload()}_validate(t,e,i,r,s={}){return eo(this,t,{key:e,style:this.serialize(),value:i,...r},s)}_remove(t=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),c_().off(l_,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(let e in this.tileManagers)this.tileManagers[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(let t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,e,i,r,s=!1){let n=!1,o=!1,a={};for(let e of this._order){let i=this._layers[e];if("symbol"!==i.type)continue;if(!a[i.source]){let t=this.tileManagers[i.source];a[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}let r=this.crossTileSymbolIndex.addLayer(i,a[i.source],t.center.lng);n||=r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),s||=this._layerOrderChanged||0===i,(s||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Qd(),t.zoom))&&(this.pauseablePlacement=new yg(t,this.map.terrain,this._order,s,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Qd()),o=!0),n&&this.pauseablePlacement.placement.setStale()),o||n)for(let t of this._order){let e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Qd())}_releaseSymbolFadeTiles(){for(let t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}async getImages(t,e){let i=await this.imageManager.getImages(e.icons);this._updateTilesForChangedImages();let r=this.tileManagers[e.source];return r&&r.setDependencies(e.tileID.key,e.type,e.icons),i}async getGlyphs(t,e){let i=await this.glyphManager.getGlyphs(e.stacks),r=this.tileManagers[e.source];return r&&r.setDependencies(e.tileID.key,e.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,e={}){this._checkLoaded(),(!t||!this._validate(Jn.glyphs,"glyphs",t,null,e))&&(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}async getDashes(t,e){let i={};for(let[t,r]of Object.entries(e.dashes))i[t]=this.lineAtlas.getDash(r.dasharray,r.round);return i}addSprite(t,e,i={},r){this._checkLoaded();let s=[{id:t,url:e}],n=[..._m(this.stylesheet.sprite),...s];this._validate(Jn.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(s,!0,r))}removeSprite(t){this._checkLoaded();let e=_m(this.stylesheet.sprite);if(e.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(let e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;e.splice(e.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=e.length>0?e:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._imagesListDirty=!0,this._changed=!0,this.fire(new om("data"))}else this.fire(new _e(Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return _m(this.stylesheet.sprite)}setSprite(t,e={},i){this._checkLoaded(),(!t||!this._validate(Jn.sprite,"sprite",t,null,e))&&(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,i):(this._unloadSprite(),i&&i(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let t in this.tileManagers){let e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(let t in this._layers){let e=this._layers[t];e.setEventedParent(null),e.onRemove&&e.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}};const Sy=Ho([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var Ty=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,s,n,o,a,l){this.context=t;let h=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!h&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(h=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||h||this.boundIndexBuffer!==s||this.boundVertexOffset!==n||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,r,s,n,o,a,l):(t.bindVertexArray.set(this.vao),o&&o.bind(),s?.dynamicDraw&&s.bind(),a&&a.bind(),l&&l.bind())}freshBind(t,e,i,r,s,n,o,a){let l=t.numAttributes,h=this.context,u=h.gl;this.vao&&this.destroy(),this.vao=h.createVertexArray(),h.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=s,this.boundDynamicVertexBuffer=n,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=a,e.enableAttributes(u,t);for(let e of i)e.enableAttributes(u,t);n&&n.enableAttributes(u,t),o&&o.enableAttributes(u,t),a&&a.enableAttributes(u,t),e.bind(),e.setVertexAttribPointers(u,t,s);for(let e of i)e.bind(),e.setVertexAttribPointers(u,t,s);n&&(n.bind(),n.setVertexAttribPointers(u,t,s)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(u,t,s)),a&&(a.bind(),a.setVertexAttribPointers(u,t,s)),h.currentNumAttributes=l}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}};const Ey=(t,e,i,r,s)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:e,u_fog_color:i?i.properties.get("fog-color"):Si.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:s?0:i?i.calculateFogBlendOpacity(r):0,u_horizon_color:i?i.properties.get("horizon-color"):Si.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!s}),Ay=t=>({u_ele_delta:t}),Py=(t,e)=>({u_terrain_coords_id:t/255,u_texture:0,u_ele_delta:e});function Iy(t){let e=[];for(let i of t){if(null===i)continue;let t=i.split(" ");e.push(t.pop())}return e}var Cy=class{constructor(t,e,i,r,s,n,o,a,l=[]){let h=t.gl;this.program=h.createProgram();let u=Iy(e.staticAttributes),c=i?i.getBinderAttributes():[],f=u.concat(c),p=Dg.prelude.staticUniforms?Iy(Dg.prelude.staticUniforms):[],d=o.staticUniforms?Iy(o.staticUniforms):[],m=e.staticUniforms?Iy(e.staticUniforms):[],_=i?i.getBinderUniforms():[],g=p.concat(d).concat(m).concat(_),y=[];for(let t of g)y.includes(t)||y.push(t);let v=i?i.defines():[];v.unshift("#version 300 es"),s&&v.push("#define OVERDRAW_INSPECTOR;"),n&&v.push("#define TERRAIN3D;"),a&&v.push(a),l&&v.push(...l);let w=v.concat(Dg.prelude.fragmentSource,o.fragmentSource,e.fragmentSource).join("\n"),b=v.concat(Dg.prelude.vertexSource,o.vertexSource,e.vertexSource).join("\n"),x=h.createShader(h.FRAGMENT_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(x,w),h.compileShader(x),!h.getShaderParameter(x,h.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${h.getShaderInfoLog(x)}`);h.attachShader(this.program,x);let M=h.createShader(h.VERTEX_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(M,b),h.compileShader(M),!h.getShaderParameter(M,h.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${h.getShaderInfoLog(M)}`);h.attachShader(this.program,M),this.attributes={};let z={};this.numAttributes=f.length;for(let t=0;t<this.numAttributes;t++)f[t]&&(this.attributes[f[t]]=t);h.linkProgram(this.program);for(let t in this.attributes){let e=h.getAttribLocation(this.program,t);e>=0?this.attributes[t]=e:delete this.attributes[t]}if(!h.getProgramParameter(this.program,h.LINK_STATUS))throw Error(`Program failed to link: ${h.getProgramInfoLog(this.program)}`);h.deleteShader(M),h.deleteShader(x);for(let t of y)if(t&&!z[t]){let e=h.getUniformLocation(this.program,t);e&&(z[t]=e)}this.fixedUniforms=r(t,z),this.terrainUniforms=((t,e)=>({u_depth:new cl(t,e.u_depth),u_terrain:new cl(t,e.u_terrain),u_terrain_dim:new fl(t,e.u_terrain_dim),u_terrain_matrix:new wl(t,e.u_terrain_matrix),u_terrain_unpack:new ml(t,e.u_terrain_unpack),u_terrain_exaggeration:new fl(t,e.u_terrain_exaggeration)}))(t,z),this.projectionUniforms=((t,e)=>({u_projection_matrix:new wl(t,e.u_projection_matrix),u_projection_tile_mercator_coords:new ml(t,e.u_projection_tile_mercator_coords),u_projection_clipping_plane:new ml(t,e.u_projection_clipping_plane),u_projection_transition:new fl(t,e.u_projection_transition),u_projection_fallback_matrix:new wl(t,e.u_projection_fallback_matrix),u_projection_clip_antimeridian:new cl(t,e.u_projection_clip_antimeridian)}))(t,z),this.binderUniforms=i?i.getUniforms(t,z):[]}draw(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d,m,_,g,y){let v=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(s),t.setCullFace(n),a){t.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,a.depthTexture),t.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,a.texture);for(let t in this.terrainUniforms)this.terrainUniforms[t].set(a[t])}if(l){let t=(t=>({u_projection_matrix:t.mainMatrix,u_projection_tile_mercator_coords:t.tileMercatorCoords,u_projection_clipping_plane:t.clippingPlane,u_projection_transition:t.projectionTransition,u_projection_fallback_matrix:t.fallbackMatrix,u_projection_clip_antimeridian:+!!t.clipAntimeridian}))(l);for(let e in this.projectionUniforms)this.projectionUniforms[e].set(t[e])}if(o)for(let t in this.fixedUniforms)this.fixedUniforms[t].set(o[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});let w=0;switch(e){case v.LINES:w=2;break;case v.TRIANGLES:w=3;break;case v.LINE_STRIP:w=1}for(let i of f.get())i.vaos||={},i.vaos[h]||=new Ty,i.vaos[h].bind(t,this,u,m?m.getPaintVertexBuffers():[],c,i.vertexOffset,_,g,y),v.drawElements(e,i.primitiveLength*w,v.UNSIGNED_SHORT,i.primitiveOffset*w*2)}};function ky(t,e,i){let r=1/it(i,1,e.transform.tileZoom),s=2**i.tileID.overscaledZ,n=i.tileSize*2**e.transform.tileZoom/s,o=n*(i.tileID.canonical.x+i.tileID.wrap*s),a=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a]}}const Dy=(t,e,i,r)=>{let s=t.style.light,n=s.getCartesianPosition(),o=p();"viewport"===s.properties.get("anchor")&&function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(o,t.transform.bearingInRadians),function(t,e,i){var r=e[0],s=e[1],n=e[2];t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8]}(n,n,o);let a=t.transform.transformLightDirection(n),l=s.properties.get("color");return{u_lightpos:n,u_lightpos_globe:a,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+e,u_opacity:i,u_fill_translate:r}},Fy=(t,e,i,r,s,n,o)=>zt(Dy(t,e,i,r),ky(n,t,o),{u_height_factor:-(2**s.overscaledZ)/o.tileSize/8}),$y=(t,e,i,r)=>zt(ky(e,t,i),{u_fill_translate:r}),jy=t=>({u_fill_translate:t}),Ry=(t,e)=>({u_world:t,u_fill_translate:e}),Oy=(t,e,i,r,s)=>zt($y(t,e,i,s),{u_world:r}),Ly=(t,e,i,r,s)=>{let n,o,a=t.transform,l=0;if("map"===i.paint.get("circle-pitch-alignment")){let t=it(e,1,a.zoom);n=!0,o=[t,t],l=t/(et*2**e.tileID.overscaledZ)*2*Math.PI*s}else n=!1,o=a.pixelsToGLUnits;return{u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:o,u_globe_extrude_scale:l,u_translate:r}},By=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Ny=t=>({u_viewport_size:[t.width,t.height]}),Uy=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),Gy=(t,e,i,r)=>{let s=it(t,1,e)/(et*2**t.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:it(t,1,e),u_intensity:i,u_globe_extrude_scale:s}},qy=(t,e,i,r)=>{let s=d();S(s,0,t.width,t.height,0,0,1);let n=t.context.gl;return{u_matrix:s,u_world:[n.drawingBufferWidth,n.drawingBufferHeight],u_image:i,u_color_ramp:r,u_opacity:e.paint.get("heatmap-opacity")}},Vy=(t,e,i)=>{let r,s=i.paint.get("hillshade-accent-color");switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}let n=i.getIlluminationProperties();for(let e=0;e<n.directionRadians.length;e++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(n.directionRadians[e]+=t.transform.bearingInRadians);return{u_image:0,u_latrange:Wy(0,e.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:n.altitudeRadians,u_azimuths:n.directionRadians,u_accent:s,u_method:r,u_highlights:n.highlightColor,u_shadows:n.shadowColor}},Zy=(t,e)=>{let i=e.stride,r=d();return S(r,0,et,-8192,0,0,1),v(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.getUnpackVector()}};function Wy(t,e){let i=2**e.canonical.z,r=e.canonical.y;return[new ec(0,r/i).toLngLat().lat,new ec(0,(r+1)/i).toLngLat().lat]}const Hy=(t,e,i=0)=>({u_image:0,u_unpack:e.getUnpackVector(),u_dimension:[e.stride,e.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:t.paint.get("color-relief-opacity")}),Yy=(t,e,i,r)=>{let s=t.transform;return{u_translation:ev(t,e,i),u_ratio:r/it(e,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Xy=(t,e,i,r,s)=>zt(Yy(t,e,i,r),{u_image:0,u_image_height:s}),Jy=(t,e,i,r,s)=>{let n=t.transform,o=tv(e,n);return{u_translation:ev(t,e,i),u_texsize:e.imageAtlasTexture.size,u_ratio:r/it(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[o,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},Ky=(t,e,i,r,s)=>{let n=tv(e,t.transform);return zt(Yy(t,e,i,r),{u_tileratio:n,u_crossfade_from:s.fromScale,u_crossfade_to:s.toScale,u_image:0,u_mix:s.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},Qy=(t,e,i,r,s,n)=>{let o=tv(e,t.transform);return zt(Yy(t,e,i,r),{u_image:0,u_image_height:n,u_tileratio:o,u_crossfade_from:s.fromScale,u_crossfade_to:s.toScale,u_image_dash:1,u_mix:s.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function tv(t,e){return 1/it(t,1,e.tileZoom)}function ev(t,e,i){return ht(t.transform,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const iv=(t,e,i,r,s)=>({u_tl_parent:t,u_scale_parent:e,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:nv(r.paint.get("raster-saturation")),u_contrast_factor:sv(r.paint.get("raster-contrast")),u_spin_weights:rv(r.paint.get("raster-hue-rotate")),u_coords_top:[s[0].x,s[0].y,s[1].x,s[1].y],u_coords_bottom:[s[3].x,s[3].y,s[2].x,s[2].y]});function rv(t){t*=Math.PI/180;let e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}function sv(t){return t>0?1/(1-t):1+t}function nv(t){return t>0?1-1/(1.001-t):-t}const ov=(t,e,i,r,s,n,o,a,l,h,u,c,f,p)=>{let d=o.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:d.width/d.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:s,u_is_variable_anchor:n,u_texsize:c,u_texture:0,u_translation:h,u_pitched_scale:f,u_is_offset:p}},av=(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d)=>{let m=o.transform;return zt(ov(t,e,i,r,s,n,o,a,l,h,u,c,p,d),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:o.pixelRatio,u_is_halo:+!!f,u_is_plain:1})},lv=(t,e,i,r,s,n,o,a,l,h,u,c,f,p)=>zt(av(t,e,i,r,s,n,o,a,l,h,!0,u,!0,f,p),{u_texsize_icon:c,u_texture_icon:1}),hv=(t,e)=>({u_opacity:t,u_color:e}),uv=(t,e,i,r,s)=>zt(function(t,e,i,r){let s=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:o,height:a}=i.imageManager.getPixelSize(),l=2**r.tileID.overscaledZ,h=r.tileSize*2**i.transform.tileZoom/l,u=h*(r.tileID.canonical.x+r.tileID.wrap*l),c=h*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[o,a],u_mix:e.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/it(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,c>>16],u_pixel_coord_lower:[65535&u,65535&c]}}(i,s,e,r),{u_opacity:t}),cv=()=>{},fv={fillExtrusion:(t,e)=>({u_lightpos:new dl(t,e.u_lightpos),u_lightpos_globe:new dl(t,e.u_lightpos_globe),u_lightintensity:new fl(t,e.u_lightintensity),u_lightcolor:new dl(t,e.u_lightcolor),u_vertical_gradient:new fl(t,e.u_vertical_gradient),u_opacity:new fl(t,e.u_opacity),u_fill_translate:new pl(t,e.u_fill_translate)}),fillExtrusionPattern:(t,e)=>({u_lightpos:new dl(t,e.u_lightpos),u_lightpos_globe:new dl(t,e.u_lightpos_globe),u_lightintensity:new fl(t,e.u_lightintensity),u_lightcolor:new dl(t,e.u_lightcolor),u_vertical_gradient:new fl(t,e.u_vertical_gradient),u_height_factor:new fl(t,e.u_height_factor),u_opacity:new fl(t,e.u_opacity),u_fill_translate:new pl(t,e.u_fill_translate),u_image:new cl(t,e.u_image),u_texsize:new pl(t,e.u_texsize),u_pixel_coord_upper:new pl(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new pl(t,e.u_pixel_coord_lower),u_scale:new dl(t,e.u_scale),u_fade:new fl(t,e.u_fade)}),fill:(t,e)=>({u_fill_translate:new pl(t,e.u_fill_translate)}),fillPattern:(t,e)=>({u_image:new cl(t,e.u_image),u_texsize:new pl(t,e.u_texsize),u_pixel_coord_upper:new pl(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new pl(t,e.u_pixel_coord_lower),u_scale:new dl(t,e.u_scale),u_fade:new fl(t,e.u_fade),u_fill_translate:new pl(t,e.u_fill_translate)}),fillOutline:(t,e)=>({u_world:new pl(t,e.u_world),u_fill_translate:new pl(t,e.u_fill_translate)}),fillOutlinePattern:(t,e)=>({u_world:new pl(t,e.u_world),u_image:new cl(t,e.u_image),u_texsize:new pl(t,e.u_texsize),u_pixel_coord_upper:new pl(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new pl(t,e.u_pixel_coord_lower),u_scale:new dl(t,e.u_scale),u_fade:new fl(t,e.u_fade),u_fill_translate:new pl(t,e.u_fill_translate)}),circle:(t,e)=>({u_camera_to_center_distance:new fl(t,e.u_camera_to_center_distance),u_scale_with_map:new cl(t,e.u_scale_with_map),u_pitch_with_map:new cl(t,e.u_pitch_with_map),u_extrude_scale:new pl(t,e.u_extrude_scale),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_globe_extrude_scale:new fl(t,e.u_globe_extrude_scale),u_translate:new pl(t,e.u_translate)}),collisionBox:(t,e)=>({u_pixel_extrude_scale:new pl(t,e.u_pixel_extrude_scale)}),collisionCircle:(t,e)=>({u_viewport_size:new pl(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new _l(t,e.u_color),u_overlay:new cl(t,e.u_overlay),u_overlay_scale:new fl(t,e.u_overlay_scale)}),depth:cv,clippingMask:cv,heatmap:(t,e)=>({u_extrude_scale:new fl(t,e.u_extrude_scale),u_intensity:new fl(t,e.u_intensity),u_globe_extrude_scale:new fl(t,e.u_globe_extrude_scale)}),heatmapTexture:(t,e)=>({u_matrix:new wl(t,e.u_matrix),u_world:new pl(t,e.u_world),u_image:new cl(t,e.u_image),u_color_ramp:new cl(t,e.u_color_ramp),u_opacity:new fl(t,e.u_opacity)}),hillshade:(t,e)=>({u_image:new cl(t,e.u_image),u_latrange:new pl(t,e.u_latrange),u_exaggeration:new fl(t,e.u_exaggeration),u_altitudes:new yl(t,e.u_altitudes),u_azimuths:new yl(t,e.u_azimuths),u_accent:new _l(t,e.u_accent),u_method:new cl(t,e.u_method),u_shadows:new gl(t,e.u_shadows),u_highlights:new gl(t,e.u_highlights)}),hillshadePrepare:(t,e)=>({u_matrix:new wl(t,e.u_matrix),u_image:new cl(t,e.u_image),u_dimension:new pl(t,e.u_dimension),u_zoom:new fl(t,e.u_zoom),u_unpack:new ml(t,e.u_unpack)}),colorRelief:(t,e)=>({u_image:new cl(t,e.u_image),u_unpack:new ml(t,e.u_unpack),u_dimension:new pl(t,e.u_dimension),u_elevation_stops:new cl(t,e.u_elevation_stops),u_color_stops:new cl(t,e.u_color_stops),u_color_ramp_size:new cl(t,e.u_color_ramp_size),u_opacity:new fl(t,e.u_opacity)}),line:(t,e)=>({u_translation:new pl(t,e.u_translation),u_ratio:new fl(t,e.u_ratio),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_units_to_pixels:new pl(t,e.u_units_to_pixels)}),lineGradient:(t,e)=>({u_translation:new pl(t,e.u_translation),u_ratio:new fl(t,e.u_ratio),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_units_to_pixels:new pl(t,e.u_units_to_pixels),u_image:new cl(t,e.u_image),u_image_height:new fl(t,e.u_image_height)}),linePattern:(t,e)=>({u_translation:new pl(t,e.u_translation),u_texsize:new pl(t,e.u_texsize),u_ratio:new fl(t,e.u_ratio),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_image:new cl(t,e.u_image),u_units_to_pixels:new pl(t,e.u_units_to_pixels),u_scale:new dl(t,e.u_scale),u_fade:new fl(t,e.u_fade)}),lineSDF:(t,e)=>({u_translation:new pl(t,e.u_translation),u_ratio:new fl(t,e.u_ratio),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_units_to_pixels:new pl(t,e.u_units_to_pixels),u_image:new cl(t,e.u_image),u_mix:new fl(t,e.u_mix),u_tileratio:new fl(t,e.u_tileratio),u_crossfade_from:new fl(t,e.u_crossfade_from),u_crossfade_to:new fl(t,e.u_crossfade_to),u_lineatlas_width:new fl(t,e.u_lineatlas_width),u_lineatlas_height:new fl(t,e.u_lineatlas_height)}),lineGradientSDF:(t,e)=>({u_translation:new pl(t,e.u_translation),u_ratio:new fl(t,e.u_ratio),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_units_to_pixels:new pl(t,e.u_units_to_pixels),u_image:new cl(t,e.u_image),u_image_height:new fl(t,e.u_image_height),u_tileratio:new fl(t,e.u_tileratio),u_crossfade_from:new fl(t,e.u_crossfade_from),u_crossfade_to:new fl(t,e.u_crossfade_to),u_image_dash:new cl(t,e.u_image_dash),u_mix:new fl(t,e.u_mix),u_lineatlas_width:new fl(t,e.u_lineatlas_width),u_lineatlas_height:new fl(t,e.u_lineatlas_height)}),layerOpacity:(t,e)=>({u_image:new cl(t,e.u_image),u_opacity:new fl(t,e.u_opacity)}),raster:(t,e)=>({u_tl_parent:new pl(t,e.u_tl_parent),u_scale_parent:new fl(t,e.u_scale_parent),u_buffer_scale:new fl(t,e.u_buffer_scale),u_fade_t:new fl(t,e.u_fade_t),u_opacity:new fl(t,e.u_opacity),u_image0:new cl(t,e.u_image0),u_image1:new cl(t,e.u_image1),u_brightness_low:new fl(t,e.u_brightness_low),u_brightness_high:new fl(t,e.u_brightness_high),u_saturation_factor:new fl(t,e.u_saturation_factor),u_contrast_factor:new fl(t,e.u_contrast_factor),u_spin_weights:new dl(t,e.u_spin_weights),u_coords_top:new ml(t,e.u_coords_top),u_coords_bottom:new ml(t,e.u_coords_bottom)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new cl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new cl(t,e.u_is_size_feature_constant),u_size_t:new fl(t,e.u_size_t),u_size:new fl(t,e.u_size),u_camera_to_center_distance:new fl(t,e.u_camera_to_center_distance),u_pitch:new fl(t,e.u_pitch),u_rotate_symbol:new cl(t,e.u_rotate_symbol),u_aspect_ratio:new fl(t,e.u_aspect_ratio),u_fade_change:new fl(t,e.u_fade_change),u_label_plane_matrix:new wl(t,e.u_label_plane_matrix),u_coord_matrix:new wl(t,e.u_coord_matrix),u_is_text:new cl(t,e.u_is_text),u_pitch_with_map:new cl(t,e.u_pitch_with_map),u_is_along_line:new cl(t,e.u_is_along_line),u_is_variable_anchor:new cl(t,e.u_is_variable_anchor),u_texsize:new pl(t,e.u_texsize),u_texture:new cl(t,e.u_texture),u_translation:new pl(t,e.u_translation),u_pitched_scale:new fl(t,e.u_pitched_scale),u_is_offset:new cl(t,e.u_is_offset)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new cl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new cl(t,e.u_is_size_feature_constant),u_size_t:new fl(t,e.u_size_t),u_size:new fl(t,e.u_size),u_camera_to_center_distance:new fl(t,e.u_camera_to_center_distance),u_pitch:new fl(t,e.u_pitch),u_rotate_symbol:new cl(t,e.u_rotate_symbol),u_aspect_ratio:new fl(t,e.u_aspect_ratio),u_fade_change:new fl(t,e.u_fade_change),u_label_plane_matrix:new wl(t,e.u_label_plane_matrix),u_coord_matrix:new wl(t,e.u_coord_matrix),u_is_text:new cl(t,e.u_is_text),u_pitch_with_map:new cl(t,e.u_pitch_with_map),u_is_along_line:new cl(t,e.u_is_along_line),u_is_variable_anchor:new cl(t,e.u_is_variable_anchor),u_texsize:new pl(t,e.u_texsize),u_texture:new cl(t,e.u_texture),u_gamma_scale:new fl(t,e.u_gamma_scale),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_is_halo:new cl(t,e.u_is_halo),u_is_plain:new cl(t,e.u_is_plain),u_translation:new pl(t,e.u_translation),u_pitched_scale:new fl(t,e.u_pitched_scale),u_is_offset:new cl(t,e.u_is_offset)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new cl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new cl(t,e.u_is_size_feature_constant),u_size_t:new fl(t,e.u_size_t),u_size:new fl(t,e.u_size),u_camera_to_center_distance:new fl(t,e.u_camera_to_center_distance),u_pitch:new fl(t,e.u_pitch),u_rotate_symbol:new cl(t,e.u_rotate_symbol),u_aspect_ratio:new fl(t,e.u_aspect_ratio),u_fade_change:new fl(t,e.u_fade_change),u_label_plane_matrix:new wl(t,e.u_label_plane_matrix),u_coord_matrix:new wl(t,e.u_coord_matrix),u_is_text:new cl(t,e.u_is_text),u_pitch_with_map:new cl(t,e.u_pitch_with_map),u_is_along_line:new cl(t,e.u_is_along_line),u_is_variable_anchor:new cl(t,e.u_is_variable_anchor),u_texsize:new pl(t,e.u_texsize),u_texsize_icon:new pl(t,e.u_texsize_icon),u_texture:new cl(t,e.u_texture),u_texture_icon:new cl(t,e.u_texture_icon),u_gamma_scale:new fl(t,e.u_gamma_scale),u_device_pixel_ratio:new fl(t,e.u_device_pixel_ratio),u_is_halo:new cl(t,e.u_is_halo),u_translation:new pl(t,e.u_translation),u_pitched_scale:new fl(t,e.u_pitched_scale),u_is_offset:new cl(t,e.u_is_offset)}),background:(t,e)=>({u_opacity:new fl(t,e.u_opacity),u_color:new _l(t,e.u_color)}),backgroundPattern:(t,e)=>({u_opacity:new fl(t,e.u_opacity),u_image:new cl(t,e.u_image),u_pattern_tl_a:new pl(t,e.u_pattern_tl_a),u_pattern_br_a:new pl(t,e.u_pattern_br_a),u_pattern_tl_b:new pl(t,e.u_pattern_tl_b),u_pattern_br_b:new pl(t,e.u_pattern_br_b),u_texsize:new pl(t,e.u_texsize),u_mix:new fl(t,e.u_mix),u_pattern_size_a:new pl(t,e.u_pattern_size_a),u_pattern_size_b:new pl(t,e.u_pattern_size_b),u_scale_a:new fl(t,e.u_scale_a),u_scale_b:new fl(t,e.u_scale_b),u_pixel_coord_upper:new pl(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new pl(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new fl(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_texture:new cl(t,e.u_texture),u_ele_delta:new fl(t,e.u_ele_delta),u_fog_matrix:new wl(t,e.u_fog_matrix),u_fog_color:new _l(t,e.u_fog_color),u_fog_ground_blend:new fl(t,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new fl(t,e.u_fog_ground_blend_opacity),u_horizon_color:new _l(t,e.u_horizon_color),u_horizon_fog_blend:new fl(t,e.u_horizon_fog_blend),u_is_globe_mode:new fl(t,e.u_is_globe_mode)}),terrainDepth:(t,e)=>({u_ele_delta:new fl(t,e.u_ele_delta)}),terrainCoords:(t,e)=>({u_texture:new cl(t,e.u_texture),u_terrain_coords_id:new fl(t,e.u_terrain_coords_id),u_ele_delta:new fl(t,e.u_ele_delta)}),atmosphere:(t,e)=>({u_sun_pos:new dl(t,e.u_sun_pos),u_atmosphere_blend:new fl(t,e.u_atmosphere_blend),u_globe_position:new dl(t,e.u_globe_position),u_globe_radius:new fl(t,e.u_globe_radius),u_inv_proj_matrix:new wl(t,e.u_inv_proj_matrix)}),sky:(t,e)=>({u_sky_color:new _l(t,e.u_sky_color),u_horizon_color:new _l(t,e.u_horizon_color),u_horizon:new pl(t,e.u_horizon),u_horizon_normal:new pl(t,e.u_horizon_normal),u_sky_horizon_blend:new fl(t,e.u_sky_horizon_blend),u_sky_blend:new fl(t,e.u_sky_blend)})};var pv=class{constructor(t,e,i){this.context=t;let r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||e.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let e=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}};const dv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var mv=class{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;let s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||e.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i of this.attributes){let r=e.attributes[i.name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r of this.attributes){let s=e.attributes[r.name];void 0!==s&&t.vertexAttribPointer(s,r.components,t[dv[r.type]],!1,this.itemSize,r.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}},_v=class{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}},gv=class extends _v{getDefault(){return Si.transparent}set(t){let e=this.current;t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a&&!this.dirty||(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},yv=class extends _v{getDefault(){return 1}set(t){t===this.current&&!this.dirty||(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},vv=class extends _v{getDefault(){return 0}set(t){t===this.current&&!this.dirty||(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},wv=class extends _v{getDefault(){return[!0,!0,!0,!0]}set(t){let e=this.current;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&!this.dirty||(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},bv=class extends _v{getDefault(){return!0}set(t){t===this.current&&!this.dirty||(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},xv=class extends _v{getDefault(){return 255}set(t){t===this.current&&!this.dirty||(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},Mv=class extends _v{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let e=this.current;t.func===e.func&&t.ref===e.ref&&t.mask===e.mask&&!this.dirty||(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}},zv=class extends _v{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let e=this.current;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&!this.dirty||(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}},Sv=class extends _v{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}},Tv=class extends _v{getDefault(){return[0,1]}set(t){let e=this.current;t[0]===e[0]&&t[1]===e[1]&&!this.dirty||(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}},Ev=class extends _v{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}},Av=class extends _v{getDefault(){return this.gl.LESS}set(t){t===this.current&&!this.dirty||(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},Pv=class extends _v{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}},Iv=class extends _v{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let e=this.current;t[0]===e[0]&&t[1]===e[1]&&!this.dirty||(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}},Cv=class extends _v{getDefault(){return Si.transparent}set(t){let e=this.current;t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a&&!this.dirty||(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},kv=class extends _v{getDefault(){return this.gl.FUNC_ADD}set(t){t===this.current&&!this.dirty||(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},Dv=class extends _v{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}},Fv=class extends _v{getDefault(){return this.gl.BACK}set(t){t===this.current&&!this.dirty||(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},$v=class extends _v{getDefault(){return this.gl.CCW}set(t){t===this.current&&!this.dirty||(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},jv=class extends _v{getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},Rv=class extends _v{getDefault(){return this.gl.TEXTURE0}set(t){t===this.current&&!this.dirty||(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},Ov=class extends _v{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let e=this.current;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&!this.dirty||(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},Lv=class extends _v{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}},Bv=class extends _v{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},Nv=class extends _v{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}},Uv=class extends _v{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},Gv=class extends _v{getDefault(){return null}set(t){let e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},qv=class extends _v{getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},Vv=class extends _v{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}},Zv=class extends _v{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}},Wv=class extends _v{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}},Hv=class extends _v{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}},Yv=class extends Hv{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}},Xv=class extends Hv{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},Jv=class extends Hv{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},Kv=class{constructor(t,e,i,r,s){this.context=t,this.width=e,this.height=i;let n=this.framebuffer=t.gl.createFramebuffer();if(this.colorAttachment=new Yv(t,n),r)this.depthAttachment=s?new Jv(t,n):new Xv(t,n);else if(s)throw Error("Stencil cannot be set without depth")}destroy(){let t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){let e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}},Qv=class{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}};Qv.Replace=[1,0],Qv.disabled=new Qv(Qv.Replace,Si.transparent,[!1,!1,!1,!1]),Qv.unblended=new Qv(Qv.Replace,Si.transparent,[!0,!0,!0,!0]),Qv.alphaBlended=new Qv([1,771],Si.transparent,[!0,!0,!0,!0]);var tw=class{constructor(t){this.gl=t,this.clearColor=new gv(this),this.clearDepth=new yv(this),this.clearStencil=new vv(this),this.colorMask=new wv(this),this.depthMask=new bv(this),this.stencilMask=new xv(this),this.stencilFunc=new Mv(this),this.stencilOp=new zv(this),this.stencilTest=new Sv(this),this.depthRange=new Tv(this),this.depthTest=new Ev(this),this.depthFunc=new Av(this),this.blend=new Pv(this),this.blendFunc=new Iv(this),this.blendColor=new Cv(this),this.blendEquation=new kv(this),this.cullFace=new Dv(this),this.cullFaceSide=new Fv(this),this.frontFace=new $v(this),this.program=new jv(this),this.activeTexture=new Rv(this),this.viewport=new Ov(this),this.bindFramebuffer=new Lv(this),this.bindRenderbuffer=new Bv(this),this.bindTexture=new Nv(this),this.bindVertexBuffer=new Uv(this),this.bindElementBuffer=new Gv(this),this.bindVertexArray=new qv(this),this.pixelStoreUnpack=new Vv(this),this.pixelStoreUnpackPremultiplyAlpha=new Zv(this),this.pixelStoreUnpackFlipY=new Wv(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),t.getExtension("EXT_color_buffer_half_float"),t.getExtension("EXT_color_buffer_float")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new pv(this,t,e)}createVertexBuffer(t,e,i){return new mv(this,t,e,i)}createRenderbuffer(t,e,i){let r=this.gl,s=r.createRenderbuffer();return this.bindRenderbuffer.set(s),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),s}createFramebuffer(t,e,i,r){return new Kv(this,t,e,i,r)}clear({color:t,depth:e,stencil:i}){let r=this.gl,s=0;t&&(s|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(s|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(s|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(s)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){Dt(t.blendFunction,Qv.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(t){this.gl.deleteVertexArray(t)}unbindVAO(){this.bindVertexArray.set(null)}},ew=class{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}};ew.ReadOnly=!1,ew.ReadWrite=!0,ew.disabled=new ew(519,ew.ReadOnly,[0,1]);const iw=7680;var rw=class{constructor(t,e,i,r,s,n){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=s,this.pass=n}};rw.disabled=new rw({func:519,mask:0},0,0,iw,iw,iw);const sw=2305;var nw=class{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}};let ow;function aw(t,e,i,r,s){let n=t.context,o=t.transform,a=n.gl,l=t.useProgram("collisionBox"),h=[],u=0,c=0;for(let f of r){let r=e.getTile(f).getBucket(i);if(!r)continue;let p=s?r.textCollisionBox:r.iconCollisionBox,d=r.collisionCircleArray;d.length>0&&(h.push({circleArray:d,circleOffset:c,coord:f}),u+=d.length/4,c=u),p&&l.draw(n,a.LINES,ew.disabled,rw.disabled,t.colorModeForRenderPass(),nw.disabled,By(t.transform),t.style.map.terrain?.getTerrainData(f),o.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,t.transform.zoom,null,null,p.collisionVertexBuffer)}if(!s||!h.length)return;let f=t.useProgram("collisionCircle"),p=new Za;p.resize(4*u),p._trim();let d=0;for(let t of h)for(let e=0;e<t.circleArray.length/4;e++){let i=4*e,r=t.circleArray[i+0],s=t.circleArray[i+1],n=t.circleArray[i+2],o=t.circleArray[i+3];p.emplace(d++,r,s,n,o,0),p.emplace(d++,r,s,n,o,1),p.emplace(d++,r,s,n,o,2),p.emplace(d++,r,s,n,o,3)}(!ow||ow.length<2*u)&&(ow=function(t){let e=2*t,i=new Ha;i.resize(e),i._trim();for(let t=0;t<e;t++){let e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(u));let m=n.createIndexBuffer(ow,!0),_=n.createVertexBuffer(p,Nc.members,!0);for(let e of h){let r=Ny(t.transform);f.draw(n,a.TRIANGLES,ew.disabled,rw.disabled,t.colorModeForRenderPass(),nw.disabled,r,t.style.map.terrain?.getTerrainData(e.coord),null,i.id,_,m,Qa.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null)}_.destroy(),m.destroy()}nw.disabled=new nw(!1,1029,sw),nw.backCCW=new nw(!0,1029,sw),nw.frontCCW=new nw(!0,1028,sw);const lw=_(new Float32Array(16));function hw(t,e,i,r,s,n){let{horizontalAlign:o,verticalAlign:a}=ef(t);return new l((-(o-.5)*e/s+r[0])*n,(-(a-.5)*i/s+r[1])*n)}function uw(t,e,i,r,s,n){let o=e.tileAnchorPoint.add(new l(e.translation[0],e.translation[1]));if(e.pitchWithMap){let t=r.mult(n);i||(t=t.rotate(-s));let a=o.add(t);return O_(a.x,a.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(i){let i=W_(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(t),s=Math.atan(i.y/i.x)+(i.x<0?Math.PI:0);return t.add(r.rotate(s))}return t.add(r)}function cw(t,e,i,r,s,n,o,a,h,u,c,f){let p=t.text.placedSymbolArray,d=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,_={};d.clear();for(let m=0;m<p.length;m++){let g=p.get(m),y=g.hidden||!g.crossTileID||t.allowVerticalPlacement&&!g.placedOrientation?null:r[g.crossTileID];if(y){let r=new l(g.anchorX,g.anchorY),p={getElevation:f,width:s.width,height:s.height,pitchedLabelPlaneMatrix:n,pitchWithMap:i,transform:s,tileAnchorPoint:r,translation:u,unwrappedTileID:c},m=i?Y_(r.x,r.y,p):W_(r.x,r.y,p),v=L_(s.cameraToCenterDistance,m.signedDistanceFromCamera),w=sf(t.textSizeData,a,g)*v/24;i&&(w*=t.tilePixelRatio/o);let{width:b,height:x,anchor:M,textOffset:z,textBoxScale:S}=y,T=hw(M,b,x,z,S,w),E=s.getPitchedTextCorrection(r.x+u[0],r.y+u[1],c),A=uw(m.point,p,e,T,-s.bearingInRadians,E),P=t.allowVerticalPlacement&&2===g.placedOrientation?Math.PI/2:0;for(let t=0;t<g.numGlyphs;t++)hf(d,A,P);h&&g.associatedIconIndex>=0&&(_[g.associatedIconIndex]={shiftedAnchor:A,angle:P})}else tg(g.numGlyphs,d)}if(h){m.clear();let e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){let i=e.get(t);if(i.hidden)tg(i.numGlyphs,m);else{let e=_[t];if(e)for(let t=0;t<i.numGlyphs;t++)hf(m,e.shiftedAnchor,e.angle);else tg(i.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(d)}function fw(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function pw(t,e,i,r,s,n,o,a,l,h,u,c,f){let p=t.context,m=p.gl,_=t.transform,g="map"===a,y="map"===l,v="viewport"!==a&&"point"!==i.layout.get("symbol-placement"),w=g&&!y&&!v,b=!i.layout.get("symbol-sort-key").isConstant(),x=!1,M=t.getDepthModeForSublayer(0,ew.ReadOnly),z=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=[],T=_.getCircleRadiusCorrection();for(let a of r){let r=e.getTile(a),l=r.getBucket(i);if(!l)continue;let u=s?l.text:l.icon;if(!u?.segments.get().length||!u.hasVisibleVertices)continue;let c,p,M,E,A=u.programConfigurations.get(i.id),P=s||l.sdfIcons,I=s?l.textSizeData:l.iconSizeData,C=y||0!==_.pitch,k=t.useProgram(fw(P,s,l),A),D=nf(I,_.zoom),F=t.style.map.terrain?.getTerrainData(a),$=[0,0],j=null;if(s)p=r.glyphAtlasTexture,M=m.LINEAR,c=r.glyphAtlasTexture.size,l.iconsInText&&($=r.imageAtlasTexture.size,j=r.imageAtlasTexture,E=C||t.options.rotating||t.options.zooming||"composite"===I.kind||"camera"===I.kind?m.LINEAR:m.NEAREST);else{let e=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;p=r.imageAtlasTexture,M=P||t.options.rotating||t.options.zooming||e||C?m.LINEAR:m.NEAREST,c=r.imageAtlasTexture.size}let R=it(r,1,t.transform.zoom),O=$_(g,t.transform,R),L=j_(y,g,t.transform,R),B=ht(_,r,n,o),N=_.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!f,applyTerrainMatrix:!0}),U=z&&l.hasTextData(),G="none"!==i.layout.get("icon-text-fit")&&U&&l.hasIconData(),q=i._unevaluatedLayout.hasValue("icon-offset");if(v){let e=d();D_(e,O);let r=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(a,e,i):null;N_(l,t,s,O,e,y,h,"map"===i.layout.get("text-rotation-alignment"),a.toUnwrapped(),_.width,_.height,B,r)}let V,Z=s&&z||G,W=v||Z?lw:y?O:t.transform.clipSpaceToPixelsMatrix,H=P&&0!==i.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);V=P?l.iconsInText?lv(I.kind,D,w,y,v,Z,t,W,L,B,c,$,T,q):av(I.kind,D,w,y,v,Z,t,W,L,B,s,c,H,T,q):ov(I.kind,D,w,y,v,Z,t,W,L,B,s,c,T,q);let Y={program:k,buffers:u,uniformValues:V,projectionData:N,atlasTexture:p,atlasTextureIcon:j,atlasInterpolation:M,atlasInterpolationIcon:E,isSDF:P,hasHalo:H};if(b&&l.canOverlap){x=!0;let t=u.segments.get();for(let e of t)S.push({segments:new Qa([e]),sortKey:e.sortKey,state:Y,terrainData:F})}else S.push({segments:u.segments,sortKey:0,state:Y,terrainData:F})}x&&S.sort(((t,e)=>t.sortKey-e.sortKey));let E=i.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,A=24*i.layout.get("text-letter-spacing").constantOr(0)<0||E>1;for(let e of S){let r=e.state;p.activeTexture.set(m.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,m.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,m.CLAMP_TO_EDGE));let s=r.isSDF&&r.hasHalo;if(s){let s=r.uniformValues;s.u_is_halo=1,A&&(s.u_is_plain=0,dw(r.buffers,e.segments,i,t,r.program,M,u,c,s,r.projectionData,e.terrainData),s.u_is_halo=0,s.u_is_plain=1)}dw(r.buffers,e.segments,i,t,r.program,M,u,c,r.uniformValues,r.projectionData,e.terrainData),s&&!A&&(r.uniformValues.u_is_halo=0)}}function dw(t,e,i,r,s,n,o,a,l,h,u){let c=r.context;s.draw(c,c.gl.TRIANGLES,n,o,a,nw.backCCW,l,u,h,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function mw(t,e,i,r,s){let n=t.context,o=n.gl,a=rw.disabled,l=new Qv([o.ONE,o.ONE],Si.transparent,[!0,!0,!0,!0]),h=e.getBucket(i);if(!h)return;let u=r.key,c=i.heatmapFbos.get(u);c||(c=gw(n,e.tileSize,e.tileSize),i.heatmapFbos.set(u,c)),n.bindFramebuffer.set(c.framebuffer),n.viewport.set([0,0,e.tileSize,e.tileSize]),n.clear({color:Si.transparent});let f=h.programConfigurations.get(i.id),p=t.useProgram("heatmap",f,!s),d=t.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=t.style.map.terrain.getTerrainData(r);p.draw(n,o.TRIANGLES,ew.disabled,a,l,nw.disabled,Gy(e,t.transform.zoom,i.paint.get("heatmap-intensity"),1),m,d,i.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,i.paint,t.transform.zoom,f)}function _w(t,e,i,r,s){let n=t.context,o=n.gl,a=t.transform;n.setColorMode(t.colorModeForRenderPass());let l=yw(n,e),h=i.key,u=e.heatmapFbos.get(h);if(!u)return;n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.colorAttachment.get()),n.activeTexture.set(o.TEXTURE1),l.bind(o.LINEAR,o.CLAMP_TO_EDGE);let c=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:s,applyGlobeMatrix:!r});t.useProgram("heatmapTexture").draw(n,o.TRIANGLES,ew.disabled,rw.disabled,t.colorModeForRenderPass(),nw.disabled,qy(t,e,0,1),null,c,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,a.zoom),u.destroy(),e.heatmapFbos.delete(h)}function gw(t,e,i){let r=t.gl,s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,e,i);let n=t.createFramebuffer(e,i,!1,!1);return n.colorAttachment.set(s),n}function yw(t,e){return e.colorRampTexture||=new Ph(t,e.colorRamp,t.gl.RGBA),e.colorRampTexture}function vw(t,e,i,r){let s=t.context,n=s.bindFramebuffer.get(),o=s.viewport.get(),[,,a,l]=o;return function(t,e,i){let r=t.context.gl;if(!t.layerOpacityFbo){let s=t.context.createFramebuffer(e,i,!0,!0),n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,i,0,r.RGBA,r.UNSIGNED_BYTE,null),s.colorAttachment.set(n),s.depthAttachment.set(t.context.createRenderbuffer(r.DEPTH_STENCIL,e,i)),t.layerOpacityFbo=s,void t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer)}if(t.layerOpacityFbo.width===e&&t.layerOpacityFbo.height===i)return void t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);let s=t.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,i,0,r.RGBA,r.UNSIGNED_BYTE,null),t.context.bindRenderbuffer.set(s.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,e,i),t.context.bindRenderbuffer.set(null),s.width=e,s.height=i,t.context.bindFramebuffer.set(s.framebuffer)}(t,a,l),s.viewport.set([0,0,a,l]),s.clear({color:Si.transparent,depth:1,stencil:0}),t.currentStencilSource=void 0,t.renderTileClippingMasks(e,i,r),{compositeTarget:n,compositeViewport:o}}function ww(t,e,i,r){let s=t.context,n=s.gl;s.bindFramebuffer.set(i.compositeTarget),s.viewport.set(i.compositeViewport),s.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,t.layerOpacityFbo.colorAttachment.get()),t.useProgram("layerOpacity").draw(s,n.TRIANGLES,ew.disabled,rw.disabled,t.colorModeForRenderPass(),nw.disabled,(t=>({u_image:0,u_opacity:t}))(e),null,null,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,r.paint,t.transform.zoom),t.currentStencilSource=void 0}function bw(t,e,i,r,s,n,o,a){let l=256;if(s.stepInterpolant){let r=e.getSource().maxzoom,s=o.canonical.z===r?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;l=xt(function(t){return t<=1?1:2**Math.ceil(Math.log(t)/Math.LN2)}(n.maxLineLength/et*1024*s),256,i.maxTextureSize)}return a.gradient=wh({expression:s.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:a.gradient||void 0,clips:n.lineClipsArray}),a.texture?a.texture.update(a.gradient):a.texture=new Ph(i,a.gradient,r.RGBA),a.version=s.gradientVersion,a.texture}function xw(t,e,i,r,s){t.activeTexture.set(e.TEXTURE0),i.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),r.updatePaintBuffers(s)}function Mw(t,e,i,r,s,n){(s||t.lineAtlas.dirty)&&(e.activeTexture.set(i.TEXTURE0),t.lineAtlas.bind(e)),r.updatePaintBuffers(n)}function zw(t,e,i,r,s,n,o){let a=n.gradients[s.id],l=a.texture;s.gradientVersion!==a.version&&(l=bw(t,e,i,r,s,n,o,a)),i.activeTexture.set(r.TEXTURE0),l.bind(s.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Sw(t,e,i,r,s,n,o,a,l){let h=n.gradients[s.id],u=h.texture;s.gradientVersion!==h.version&&(u=bw(t,e,i,r,s,n,o,h)),i.activeTexture.set(r.TEXTURE0),u.bind(s.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),t.lineAtlas.bind(i),a.updatePaintBuffers(l)}function Tw(t,e,i,r,s,n){let o,{isRenderingToTexture:a}=s,l=t.getDepthModeForSublayer(0,ew.ReadOnly),h=t.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),c=u.constantOr(1),f=i.paint.get("line-pattern"),p=f.constantOr(1),d=i.paint.get("line-gradient"),m=i.getCrossfadeParameters();o=p?"linePattern":c&&d?"lineGradientSDF":c?"lineSDF":d?"lineGradient":"line";let _=t.context,g=_.gl,y=t.transform,v=!0;for(let s of r){let r=e.getTile(s);if(p&&!r.patternsLoaded())continue;let w=r.getBucket(i);if(!w)continue;let b=w.programConfigurations.get(i.id),x=t.context.program.get(),M=t.useProgram(o,b),z=v||M.program!==x,S=n?t.getTerrainDataForTile(s,a):null,T=f.constantOr(null),E=u?.constantOr(null);if(T&&r.imageAtlas){let t=r.imageAtlas,e=t.patternPositions[T.to.toString()],i=t.patternPositions[T.from.toString()];e&&i&&b.setConstantPatternPositions(e,i)}else if(E){let e="round"===i.layout.get("line-cap").constantOr(null),r=t.lineAtlas.getDash(E.to,e),s=t.lineAtlas.getDash(E.from,e);b.setConstantDashPositions(r,s)}let A,P=y.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),I=y.getPixelScale();p?(A=Jy(t,r,i,I,m),xw(_,g,r,b,m)):c&&d?(A=Qy(t,r,i,I,m,w.lineClipsArray.length),Sw(t,e,_,g,i,w,s,b,m)):c?(A=Ky(t,r,i,I,m),Mw(t,_,g,b,z,m)):d?(A=Xy(t,r,i,I,w.lineClipsArray.length),zw(t,e,_,g,i,w,s)):A=Yy(t,r,i,I);let C=t.stencilModeForClipping(s);M.draw(_,g.TRIANGLES,l,C,h,nw.disabled,A,S,P,i.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,i.paint,t.transform.zoom,b,w.layoutVertexBuffer2),v=!1}}function Ew(t,e,i,r,s){if(!i||!r?.imageAtlas)return;let n=r.imageAtlas.patternPositions,o=n[i.to.toString()],a=n[i.from.toString()];if(!o&&a&&(o=a),!a&&o&&(a=o),!o||!a){let t=s.getPaintProperty(e);o=n[t],a=n[t]}o&&a&&t.setConstantPatternPositions(o,a)}function Aw(t,e,i,r,s){let{isRenderingToTexture:n}=s,o=t.colorModeForRenderPass();Iw(t,e,i,r,t.getDepthModeForSublayer(1,ew.ReadOnly),o,!1,n),Pw(t,e,i,r,s)}function Pw(t,e,i,r,s){if(!i.paint.get("fill-antialias"))return;let{isRenderingToTexture:n}=s,o=t.colorModeForRenderPass();Iw(t,e,i,r,t.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,ew.ReadOnly),o,!0,n)}function Iw(t,e,i,r,s,n,o,a){let l,h,u,c,f,p=t.context.gl,d="fill-pattern",m=i.paint.get(d),_=m?.constantOr(1),g=i.getCrossfadeParameters(),y=t.transform,v=i.paint.get("fill-translate"),w=i.paint.get("fill-translate-anchor");o?(h=_&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",l=p.LINES):(h=_?"fillPattern":"fill",l=p.TRIANGLES);let b=m.constantOr(null);for(let m of r){let r=e.getTile(m);if(_&&!r.patternsLoaded())continue;let x=r.getBucket(i);if(!x)continue;let M=x.programConfigurations.get(i.id),z=t.useProgram(h,M),S=t.getTerrainDataForTile(m,a);_&&(t.context.activeTexture.set(p.TEXTURE0),r.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),M.updatePaintBuffers(g)),Ew(M,d,b,r,i);let T=y.getProjectionData({overscaledTileID:m,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),E=ht(y,r,v,w);if(o){c=x.indexBuffer2,f=x.segments2;let e=[p.drawingBufferWidth,p.drawingBufferHeight];u="fillOutlinePattern"===h&&_?Oy(t,g,r,e,E):Ry(e,E)}else c=x.indexBuffer,f=x.segments,u=_?$y(t,g,r,E):jy(E);let A=t.stencilModeForClipping(m);z.draw(t.context,l,s,A,n,nw.backCCW,u,S,T,i.id,x.layoutVertexBuffer,c,f,i.paint,t.transform.zoom,M)}}function Cw(t,e,i,r,s,n,o,a){let l=t.context,h=l.gl,u="fill-extrusion-pattern",c=i.paint.get(u),f=c.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),_=t.transform;for(let c of r){let r=e.getTile(c),g=r.getBucket(i);if(!g)continue;let y=t.style.map.terrain?.getTerrainData(c),v=g.programConfigurations.get(i.id),w=t.useProgram(f?"fillExtrusionPattern":"fillExtrusion",v);f&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),v.updatePaintBuffers(p));let b=_.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!a,applyTerrainMatrix:!0});Ew(v,u,m,r,i);let x=ht(_,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),M=i.paint.get("fill-extrusion-vertical-gradient"),z=f?Fy(t,M,d,x,c,p,r):Dy(t,M,d,x);w.draw(l,l.gl.TRIANGLES,s,n,o,nw.backCCW,z,y,b,i.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,i.paint,t.transform.zoom,v,t.style.map.terrain&&g.centroidVertexBuffer)}}function kw(t,e,i,r,s,n,o,a,l){let h=t.style.projection,u=t.context,c=t.transform,f=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],d=t.useProgram("hillshade",null,!1,p),m=!t.options.moving;for(let p of r){let r=e.getTile(p),_=r.fbo;if(!_)continue;let g=h.getMeshFromTileID(u,p.canonical,a,!0,"raster"),y=t.getTerrainDataForTile(p,l);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,_.colorAttachment.get());let v=c.getProjectionData({overscaledTileID:p,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});d.draw(u,f.TRIANGLES,n,s[p.overscaledZ],o,nw.backCCW,Vy(t,r,i),y,v,i.id,g.vertexBuffer,g.indexBuffer,g.segments)}}let Dw=0;function Fw(t,e,i,r,s,n,o,a,l){let h=t.style.projection,u=t.context,c=t.transform,f=u.gl,p=t.useProgram("colorRelief"),d=!t.options.moving,m="nearest"===i.paint.get("resampling")?f.NEAREST:f.LINEAR,_=!0,g=0;for(let y of r){let r=e.getTile(y),v=r.dem;if(_){Dw||=f.getParameter(f.MAX_TEXTURE_SIZE);let t=Dw,{elevationTexture:e,colorTexture:r}=i.getColorRampTextures(u,t,v.getUnpackVector());u.activeTexture.set(f.TEXTURE1),e.bind(f.NEAREST,f.CLAMP_TO_EDGE),u.activeTexture.set(f.TEXTURE4),r.bind(f.LINEAR,f.CLAMP_TO_EDGE),_=!1,g=e.size[0]}if(!v?.data)continue;let w=v.stride,b=v.getPixels();if(u.activeTexture.set(f.TEXTURE0),u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=t.getTileTexture(w),r.demTexture){let t=r.demTexture;t.update(b,{premultiply:!1}),t.bind(m,f.CLAMP_TO_EDGE)}else r.demTexture=new Ph(u,b,f.RGBA,{premultiply:!1}),r.demTexture.bind(m,f.CLAMP_TO_EDGE);let x=h.getMeshFromTileID(u,y.canonical,a,!0,"raster"),M=t.getTerrainDataForTile(y,l),z=c.getProjectionData({overscaledTileID:y,aligned:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,f.TRIANGLES,n,s[y.overscaledZ],o,nw.backCCW,Hy(i,r.dem,g),M,z,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}}const $w=[new l(0,0),new l(et,0),new l(et,et),new l(0,et)];function jw(t,e,i,r,s,n,o,a,l=!1,h=!1){let u=r[r.length-1].overscaledZ,c=t.context,f=c.gl,p=t.useProgram("raster"),d=t.transform,m=t.style.projection,_=t.colorModeForRenderPass(),g=!t.options.moving,y=i.paint.get("raster-opacity"),v="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?f.NEAREST:f.LINEAR,w=i.paint.get("raster-fade-duration"),b=!!t.style.map.terrain;for(let x of r){let r=t.getDepthModeForSublayer(x.overscaledZ-u,1===y?ew.ReadWrite:ew.ReadOnly,f.LESS),M=e.getTile(x);c.activeTexture.set(f.TEXTURE0),M.texture.bind(v,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),c.activeTexture.set(f.TEXTURE1);let{parentTile:z,parentScaleBy:S,parentTopLeft:T,fadeValues:E}=Rw(M,e,w,b);M.fadeOpacity=E.tileOpacity,z?(z.fadeOpacity=E.parentTileOpacity,z.texture.bind(v,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):M.texture.bind(v,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),M.texture.useMipmap&&c.extTextureFilterAnisotropic&&t.transform.pitch>t.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax);let A=t.getTerrainDataForTile(x,h),P=d.getProjectionData({overscaledTileID:x,aligned:g,applyGlobeMatrix:!h,applyTerrainMatrix:!0}),I=iv(T,S,E.fadeMix,i,a),C=m.getMeshFromTileID(c,x.canonical,n,o,"raster");p.draw(c,f.TRIANGLES,r,s?s[x.overscaledZ]:rw.disabled,_,l?nw.frontCCW:nw.backCCW,I,A,P,i.id,C.vertexBuffer,C.indexBuffer,C.segments)}}function Rw(t,e,i,r){let s={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===i||r)return s;if(t.fadingParentID){let r=e.getLoadedTile(t.fadingParentID);if(!r)return s;let n=2**(r.tileID.overscaledZ-t.tileID.overscaledZ);return{parentTile:r,parentScaleBy:n,parentTopLeft:[t.tileID.canonical.x*n%1,t.tileID.canonical.y*n%1],fadeValues:Ow(t,r,i)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:Lw(t,i)}:s}function Ow(t,e,i){let r=Qd(),s=(r-e.timeAdded)/i,n=1===t.fadingDirection,o=xt((r-t.timeAdded)/i,0,1),a=xt(1-s,0,1),l=n?o:a;return{tileOpacity:l,parentTileOpacity:n?a:o,fadeMix:{opacity:1,mix:1-l}}}function Lw(t,e){let i=xt((Qd()-t.timeAdded)/e,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}const Bw=new Si(1,0,0,1),Nw=new Si(0,1,0,1),Uw=new Si(0,0,1,1),Gw=new Si(1,0,1,1),qw=new Si(0,1,1,1);function Vw(t,e,i,r){Ww(t,0,e+i/2,t.transform.width,i,r)}function Zw(t,e,i,r){Ww(t,e-i/2,0,i,t.transform.height,r)}function Ww(t,e,i,r,s,n){let o=t.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,s*t.pixelRatio),o.clear({color:n}),a.disable(a.SCISSOR_TEST)}function Hw(t,e,i){let r=t.context,s=r.gl,n=t.useProgram("debug"),o=ew.disabled,a=rw.disabled,l=t.colorModeForRenderPass(),h="$debug",u=t.style.map.terrain?.getTerrainData(i);r.activeTexture.set(s.TEXTURE0);let c=e.getTileByID(i.key).latestRawTileData?.byteLength||0,f=Math.floor(c/1024),p=e.getTile(i).tileSize,d=512/Math.min(p,512)*(i.overscaledZ/t.transform.zoom)*.5,m=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(m+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();let i=t.debugOverlayCanvas,r=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${m} ${f}kB`);let _=t.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(r,s.TRIANGLES,o,a,Qv.alphaBlended,nw.disabled,Uy(Si.transparent,d),null,_,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),n.draw(r,s.LINE_STRIP,o,a,l,nw.disabled,Uy(Si.red),u,_,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Yw(t,e){if(!e.mesh){let i=new ka;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);let r=new Ya;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),e.mesh=new $g(t.createVertexBuffer(i,jg.members),t.createIndexBuffer(r),Qa.simpleSegment(0,0,i.length,r.length))}return e.mesh}const Xw={symbol:function(t,e,i,r,s,n){if("translucent"!==t.renderPass)return;let{isRenderingToTexture:o}=n,a=rw.disabled,l=t.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,e,i,r,s,n,o,a,l){let h=e.transform,u=e.style.map.terrain,c="map"===s,f="map"===n;for(let s of t){let t=r.getTile(s),n=t.getBucket(i);if(!n?.text?.segments.get().length)continue;let p=nf(n.textSizeData,h.zoom),d=it(t,1,e.transform.zoom),m=$_(c,e.transform,d),_="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(p){let e=u?(t,e)=>u.getElevation(s,t,e):null;cw(n,c,f,l,h,m,2**(h.zoom-t.tileID.overscaledZ),p,_,ht(h,t,o,a),s.toUnwrapped(),e)}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),s),0!==i.paint.get("icon-opacity").constantOr(1)&&pw(t,e,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),a,l,o),0!==i.paint.get("text-opacity").constantOr(1)&&pw(t,e,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),a,l,o),e.map.showCollisionBoxes&&(aw(t,e,i,r,!0),aw(t,e,i,r,!1))},circle:function(t,e,i,r,s){if("translucent"!==t.renderPass)return;let{isRenderingToTexture:n}=s,o=i.paint.get("circle-opacity"),a=i.paint.get("circle-stroke-width"),l=i.paint.get("circle-stroke-opacity"),h=!i.layout.get("circle-sort-key").isConstant();if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===l.constantOr(1)))return;let u=t.context,c=u.gl,f=t.transform,p=t.getDepthModeForSublayer(0,ew.ReadOnly),d=rw.disabled,m=t.colorModeForRenderPass(),_=[],g=f.getCircleRadiusCorrection();for(let s of r){let r=e.getTile(s),o=r.getBucket(i);if(!o)continue;let a=ht(f,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),l=o.programConfigurations.get(i.id),u=t.useProgram("circle",l),c=o.layoutVertexBuffer,p=o.indexBuffer,d=t.style.map.terrain?.getTerrainData(s),m={programConfiguration:l,program:u,layoutVertexBuffer:c,indexBuffer:p,uniformValues:Ly(t,r,i,a,g),terrainData:d,projectionData:f.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!n,applyTerrainMatrix:!0})};if(h){let t=o.segments.get();for(let e of t)_.push({segments:new Qa([e]),sortKey:e.sortKey,state:m})}else _.push({segments:o.segments,sortKey:0,state:m})}h&&_.sort(((t,e)=>t.sortKey-e.sortKey));for(let e of _){let{programConfiguration:r,program:s,layoutVertexBuffer:n,indexBuffer:o,uniformValues:a,terrainData:l,projectionData:h}=e.state;s.draw(u,c.TRIANGLES,p,d,m,nw.backCCW,a,l,h,i.id,n,o,e.segments,i.paint,t.transform.zoom,r)}},heatmap:function(t,e,i,r,s){if(0===i.paint.get("heatmap-opacity"))return;let n=t.context,{isRenderingToTexture:o,isRenderingGlobe:a}=s;if(t.style.map.terrain){for(let s of r){let r=e.getTile(s);e.hasRenderableParent(s)||("offscreen"===t.renderPass?mw(t,r,i,s,a):"translucent"===t.renderPass&&_w(t,i,s,o,a))}n.viewport.set([0,0,t.width,t.height])}else"offscreen"===t.renderPass?function(t,e,i,r){let s=t.context,n=s.gl,o=t.transform,a=rw.disabled,l=new Qv([n.ONE,n.ONE],Si.transparent,[!0,!0,!0,!0]);(function(t,e,i){let r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let s=i.heatmapFbos.get(bh);s?(r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer)):(s=gw(t,e.width/4,e.height/4),i.heatmapFbos.set(bh,s))})(s,t,i),s.clear({color:Si.transparent});for(let h of r){if(e.hasRenderableParent(h))continue;let r=e.getTile(h),u=r.getBucket(i);if(!u)continue;let c=u.programConfigurations.get(i.id),f=t.useProgram("heatmap",c),p=o.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),d=o.getCircleRadiusCorrection();f.draw(s,n.TRIANGLES,ew.disabled,a,l,nw.backCCW,Gy(r,o.zoom,i.paint.get("heatmap-intensity"),d),null,p,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,o.zoom,c)}s.viewport.set([0,0,t.width,t.height])}(t,e,i,r):"translucent"===t.renderPass&&function(t,e){let i=t.context,r=i.gl;i.setColorMode(t.colorModeForRenderPass());let s=e.heatmapFbos.get(bh);s&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),yw(i,e).bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,ew.disabled,rw.disabled,t.colorModeForRenderPass(),nw.disabled,qy(t,e,0,1),null,null,e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.transform.zoom))}(t,i)},line:function(t,e,i,r,s){if("translucent"!==t.renderPass)return;let n=i.paint.get("line-opacity"),o=i.paint.get("line-width"),a=i.paint.get("line-layer-opacity");if(0===n.constantOr(1)||0===o.constantOr(1)||0===a)return;let l=!!t.style.map.terrain;if(a<1){let n=vw(t,i,r,l);return Tw(t,e,i,r,s,l),void ww(t,a,n,i)}Tw(t,e,i,r,s,l)},fill:function(t,e,i,r,s){let n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity"),a=i.paint.get("fill-layer-opacity");if(0===o.constantOr(1)||0===a)return;if(a<1){if("translucent"!==t.renderPass)return;let n=vw(t,i,r,!!t.style.map.terrain);return Aw(t,e,i,r,s),void ww(t,a,n,i)}let l=i.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(Si.transparent).a&&1===o.constantOr(0);if(h&&"opaque"===t.renderPass){let{isRenderingToTexture:n}=s,o=t.colorModeForRenderPass();Iw(t,e,i,r,t.getDepthModeForSublayer(1,ew.ReadWrite),o,!1,n)}else h&&"translucent"===t.renderPass?Pw(t,e,i,r,s):"translucent"===t.renderPass&&Aw(t,e,i,r,s)},fillExtrusion:function(t,e,i,r,s){let n=i.paint.get("fill-extrusion-opacity");if(0===n)return;let{isRenderingToTexture:o}=s;if("translucent"===t.renderPass){let s=new ew(t.context.gl.LEQUAL,ew.ReadWrite,t.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))Cw(t,e,i,r,s,rw.disabled,Qv.disabled,o),Cw(t,e,i,r,s,t.stencilModeFor3D(),t.colorModeForRenderPass(),o);else{let n=t.colorModeForRenderPass();Cw(t,e,i,r,s,rw.disabled,n,o)}}},hillshade:function(t,e,i,r,s){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;let{isRenderingToTexture:n}=s,o=t.context,a=t.style.projection.useSubdivision,l=t.getDepthModeForSublayer(0,ew.ReadOnly),h=t.colorModeForRenderPass();if("offscreen"===t.renderPass)(function(t,e,i,r,s,n,o){let a=t.context,l=a.gl,h="nearest"===r.paint.get("resampling")?l.NEAREST:l.LINEAR;for(let u of i){let i=e.getTile(u),c=i.dem;if(!c?.data||!i.needsHillshadePrepare)continue;let f=c.dim,p=c.stride,d=c.getPixels();if(a.activeTexture.set(l.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=t.getTileTexture(p),i.demTexture){let t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new Ph(a,d,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);a.activeTexture.set(l.TEXTURE0);let m=i.fbo;if(!m){let t=new Ph(a,{width:f,height:f,data:null},l.RGBA);t.bind(h,l.CLAMP_TO_EDGE),m=i.fbo=a.createFramebuffer(f,f,!0,!1),m.colorAttachment.set(t.texture)}a.bindFramebuffer.set(m.framebuffer),a.viewport.set([0,0,f,f]),t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,s,n,o,nw.disabled,Zy(i.tileID,c),null,null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(t,e,r,i,l,rw.disabled,h),o.viewport.set([0,0,t.width,t.height]);else if("translucent"===t.renderPass)if(a){let[s,o,a]=t.stencilConfigForOverlapTwoPass(r);kw(t,e,i,a,s,l,h,!1,n),kw(t,e,i,a,o,l,h,!0,n)}else{let[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);kw(t,e,i,o,s,l,h,!1,n)}},colorRelief:function(t,e,i,r,s){if("translucent"!==t.renderPass||!r.length)return;let{isRenderingToTexture:n}=s,o=t.style.projection.useSubdivision,a=t.getDepthModeForSublayer(0,ew.ReadOnly),l=t.colorModeForRenderPass();if(o){let[s,o,h]=t.stencilConfigForOverlapTwoPass(r);Fw(t,e,i,h,s,a,l,!1,n),Fw(t,e,i,h,o,a,l,!0,n)}else{let[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);Fw(t,e,i,o,s,a,l,!1,n)}},raster:function(t,e,i,r,s){if("translucent"!==t.renderPass||0===i.paint.get("raster-opacity")||!r.length)return;let{isRenderingToTexture:n}=s,o=e.getSource(),a=t.style.projection.useSubdivision;if(o instanceof s_)jw(t,e,i,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,n);else if(a){let[s,o,a]=t.stencilConfigForOverlapTwoPass(r);jw(t,e,i,a,s,!1,!0,$w,!1,n),jw(t,e,i,a,o,!0,!0,$w,!1,n)}else{let[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);jw(t,e,i,o,s,!1,!0,$w,!1,n)}},background:function(t,e,i,r,s){let n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;let{isRenderingToTexture:a}=s,l=t.context,h=l.gl,u=t.style.projection,c=t.transform,f=c.tileSize,p=i.paint.get("background-pattern");if(t.isPatternMissing(p))return;let d=!p&&1===n.a&&1===o&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==d)return;let m=rw.disabled,_=t.getDepthModeForSublayer(0,"opaque"===d?ew.ReadWrite:ew.ReadOnly),g=t.colorModeForRenderPass(),y=t.useProgram(p?"backgroundPattern":"background"),v=r||w_(c,{tileSize:f,terrain:t.style.map.terrain});p&&(l.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context));let w=i.getCrossfadeParameters();for(let e of v){let r=c.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),s=p?uv(o,t,p,{tileID:e,tileSize:f},w):hv(o,n),d=t.getTerrainDataForTile(e,a),v=u.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,h.TRIANGLES,_,m,g,nw.backCCW,s,d,r,i.id,v.vertexBuffer,v.indexBuffer,v.segments)}},sky:function(t,e){let i=t.context,r=i.gl,s=((t,e,i)=>{let r=Math.cos(e.rollInRadians),s=Math.sin(e.rollInRadians),n=oc(e),o=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:[(e.width/2-n*s)*i,(e.height/2+n*r)*i],u_horizon_normal:[-s,r],u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i,u_sky_blend:o}})(e,t.transform,t.pixelRatio),n=new ew(r.LEQUAL,ew.ReadWrite,[0,1]),o=rw.disabled,a=t.colorModeForRenderPass(),l=t.useProgram("sky"),h=Yw(i,e);l.draw(i,r.TRIANGLES,n,o,a,nw.disabled,s,null,void 0,"sky",h.vertexBuffer,h.indexBuffer,h.segments)},atmosphere:function(t,e,i){let r=t.context,s=r.gl,n=t.useProgram("atmosphere"),o=new ew(s.LEQUAL,ew.ReadOnly,[0,1]),a=t.transform,l=function(t,e){let i=t.getCartesianPosition();!function(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}(i,i);let r=_(new Float64Array(16));return"map"===t.properties.get("anchor")&&(M(r,r,e.rollInRadians),b(r,r,-e.pitchInRadians),M(r,r,e.bearingInRadians),b(r,r,e.center.lat*Math.PI/180),x(r,r,-e.center.lng*Math.PI/180)),function(t,e,i){var r=e[0],s=e[1],n=e[2],o=i[3]*r+i[7]*s+i[11]*n+i[15];o||=1,t[0]=(i[0]*r+i[4]*s+i[8]*n+i[12])/o,t[1]=(i[1]*r+i[5]*s+i[9]*n+i[13])/o,t[2]=(i[2]*r+i[6]*s+i[10]*n+i[14])/o}(i,i,r),i}(i,t.transform),h=a.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=e.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;let c=oy(a.worldSize,a.center.lat),f=a.inverseProjectionMatrix,p=new Float64Array(4);p[3]=1,N(p,p,a.modelViewProjectionMatrix),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1,N(p,p,f),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1;let d=((t,e,i,r,s)=>({u_sun_pos:t,u_atmosphere_blend:e,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:s}))(l,u,[p[0],p[1],p[2]],c,f),m=Yw(r,e);n.draw(r,s.TRIANGLES,o,rw.disabled,Qv.alphaBlended,nw.disabled,d,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)},custom:function(t,e,i,r){let{isRenderingGlobe:s}=r,n=t.context,o=i.implementation,a=t.style.projection,l=t.transform,h=l.getProjectionDataForCustomLayer(s),u={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:h,getProjectionData:t=>l.getProjectionData({overscaledTileID:new Cf(t.tileID.canonical.z,t.tileID.wrap??0,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),aligned:t.aligned,applyGlobeMatrix:t.applyGlobeMatrix,applyTerrainMatrix:t.applyTerrainMatrix})},c=o.renderingMode?o.renderingMode:"2d";if("offscreen"===t.renderPass){let e=o.prerender;e&&(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),e.call(o,n.gl,u),n.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(rw.disabled);let e="3d"===c?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,ew.ReadOnly);n.setDepthMode(e),o.render(n.gl,u),n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null)}},debug:function(t,e,i){for(let r of i)Hw(t,e,r)},debugPadding:function(t){let e=t.transform.padding;Vw(t,t.transform.height-(e.top||0),3,Bw),Vw(t,e.bottom||0,3,Nw),Zw(t,e.left||0,3,Uw),Zw(t,t.transform.width-(e.right||0),3,Gw);let i=t.transform.centerPoint;!function(t,e,i,r){Ww(t,e-1,i-10,2,20,r),Ww(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,qw)},terrainDepth:function(t,e){let i=t.context,r=i.gl,s=t.transform,n=Qv.unblended,o=new ew(r.LEQUAL,ew.ReadWrite,[0,1]),a=e.tileManager.getRenderableTiles(),l=t.useProgram("terrainDepth");i.bindFramebuffer.set(e.getFramebuffer("depth").framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:Si.transparent,depth:1});for(let t of a){let a=e.getTerrainMesh(t.tileID),h=e.getTerrainData(t.tileID),u=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),c=Ay(e.getSkirtLength(s.zoom));l.draw(i,r.TRIANGLES,o,rw.disabled,n,nw.backCCW,c,h,u,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])},terrainCoords:function(t,e){let i=t.context,r=i.gl,s=t.transform,n=Qv.unblended,o=new ew(r.LEQUAL,ew.ReadWrite,[0,1]),a=e.getCoordsTexture(),l=e.tileManager.getRenderableTiles(),h=t.useProgram("terrainCoords");i.bindFramebuffer.set(e.getFramebuffer("coords").framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:Si.transparent,depth:1}),e.coordsIndex=[];for(let t of l){let l=e.getTerrainMesh(t.tileID),u=e.getTerrainData(t.tileID);i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.texture);let c=Py(255-e.coordsIndex.length,e.getSkirtLength(s.zoom)),f=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(i,r.TRIANGLES,o,rw.disabled,n,nw.backCCW,c,u,f,"terrain",l.vertexBuffer,l.indexBuffer,l.segments),e.coordsIndex.push(t.tileID.key)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])}};var Jw=class t{constructor(t,e){this.drawFunctions=Xw,this.context=new tw(t),this.transform=e,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:_(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=P_.maxOverzooming+P_.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new Cg}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,e=new ka;e.emplaceBack(0,0),e.emplaceBack(et,0),e.emplaceBack(0,et),e.emplaceBack(et,et),this.tileExtentBuffer=t.createVertexBuffer(e,jg.members),this.tileExtentSegments=Qa.simpleSegment(0,0,4,2);let i=new ka;i.emplaceBack(0,0),i.emplaceBack(et,0),i.emplaceBack(0,et),i.emplaceBack(et,et),this.debugBuffer=t.createVertexBuffer(i,jg.members),this.debugSegments=Qa.simpleSegment(0,0,4,5);let r=new Fa;r.emplaceBack(0,0,0,0),r.emplaceBack(et,0,et,0),r.emplaceBack(0,et,0,et),r.emplaceBack(et,et,et,et),this.rasterBoundsBuffer=t.createVertexBuffer(r,Sy.members),this.rasterBoundsSegments=Qa.simpleSegment(0,0,4,2);let s=new ka;s.emplaceBack(0,0),s.emplaceBack(et,0),s.emplaceBack(0,et),s.emplaceBack(et,et),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(s,jg.members),this.rasterBoundsSegmentsPosOnly=Qa.simpleSegment(0,0,4,5);let n=new ka;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,jg.members),this.viewportSegments=Qa.simpleSegment(0,0,4,2);let o=new Ja;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let a=new Ya;a.emplaceBack(1,0,2),a.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);let l=this.context.gl;this.stencilClearMode=new rw({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new $g(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=d();S(i,0,this.width,this.height,0,0,1),w(i,i,[e.drawingBufferWidth,e.drawingBufferHeight,0]);let r={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(t,e.TRIANGLES,ew.disabled,this.stencilClearMode,Qv.disabled,nw.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,e,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e?.length)return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();let r=this.context;r.setColorMode(Qv.disabled),r.setDepthMode(ew.disabled);let s={};for(let t of e)s[t.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(s,e,i,!0),this._renderTileMasks(s,e,i,!1),this._tileClippingMaskIDs=s}_renderTileMasks(t,e,i,r){let s=this.context,n=s.gl,o=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(let h of e){let e=t[h.key],u=this.getTerrainDataForTile(h,i),c=o.getMeshFromTileID(this.context,h.canonical,r,!0,"stencil"),f=a.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(s,n.TRIANGLES,ew.disabled,new rw({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Qv.disabled,i?nw.disabled:nw.backCCW,null,u,f,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}getTerrainDataForTile(t,e){return e&&"mercator"===this.style.projection?.name?null:this.style.map.terrain?.getTerrainData(t)||null}_renderTilesDepthBuffer(){let t=this.context,e=t.gl,i=this.style.projection,r=this.transform,s=this.useProgram("depth"),n=this.getDepthModeFor3D(),o=w_(r,{tileSize:r.tileSize});for(let a of o){let o=this.style.map.terrain?.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),h=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(t,e.TRIANGLES,n,rw.disabled,Qv.disabled,nw.backCCW,null,o,h,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,e=this.context.gl;return new rw({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){let e=this.context.gl;return new rw({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,s=i[0].overscaledZ-r+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();let t={};for(let i=0;i<s;i++)t[i+r]=new rw({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=s,[t,i]}return[{[r]:rw.disabled},i]}stencilConfigForOverlapTwoPass(t){let e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,s=i[0].overscaledZ-r+1;if(this.clearStencil(),s>1){let t={},n={};for(let i=0;i<s;i++)t[i+r]=new rw({func:e.GREATER,mask:255},s+1+i,255,e.KEEP,e.KEEP,e.REPLACE),n[i+r]=new rw({func:e.GREATER,mask:255},1+i,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID=2*s+1,[t,n,i]}return this.nextStencilID=3,[{[r]:new rw({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new rw({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let e=1/8;return new Qv([t.CONSTANT_COLOR,t.ONE],new Si(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Qv.unblended:Qv.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return ew.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ew(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new ew(this.context.gl.LEQUAL,ew.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,e){this.style=t,this.options=e,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Qd()),this.imageManager.beginFrame();let i=this.style._order,r=this.style.tileManagers,s={},n={},o={},a={isRenderingToTexture:!1,isRenderingGlobe:t.projection?.transitionState>0};for(let t in r){let e=r[t];e.used&&e.prepare(this.context),s[t]=e.getVisibleCoordinates(!1),n[t]=s[t].slice().reverse(),o[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<i.length;t++)if(this.style._layers[i[t]].is3D()){this.opaquePassCutoff=t;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(let t of i){let e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let i=n[e.source];"custom"!==e.type&&!i.length||this.renderLayer(this,r[e.source],e,i,a)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:e.showOverdrawInspector?Si.black:Si.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=e.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){let t=this.style._layers[i[this.currentLayer]],e=r[t.source],n=s[t.source];this.renderTileClippingMasks(t,n,!1),this.renderLayer(this,e,t,n,a)}this.renderPass="translucent";let l=!1;for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){let t=this.style._layers[i[this.currentLayer]],e=r[t.source];if(this.renderToTexture?.renderLayer(t,a))continue;!this.opaquePassEnabledForLayer()&&!l&&(l=!0,a.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let h=("symbol"===t.type?o:n)[t.source];this.renderTileClippingMasks(t,s[t.source],!!this.renderToTexture),this.renderLayer(this,e,t,h,a)}if(a.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let t=function(t,e){let i=null,r=Object.values(t._layers).flatMap((i=>i.source&&!i.isHidden(e)?[t.tileManagers[i.source]]:[])),s=r.filter((t=>"vector"===t.getSource().type)),n=r.filter((t=>"vector"!==t.getSource().type)),o=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};for(let t of s)o(t);if(!i)for(let t of n)o(t);return i}(this.style,this.transform.zoom);t&&this.drawFunctions.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(t){if(!this.style?.map?.terrain)return;let e=this.terrainFacilitator.matrix,i=this.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||=t?!function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}(e,i):!function(t,e){var i=t[0],r=t[1],s=t[2],n=t[3],o=t[4],a=t[5],l=t[6],h=t[7],u=t[8],c=t[9],f=t[10],p=t[11],d=t[12],m=t[13],_=t[14],g=t[15],y=e[0],v=e[1],w=e[2],b=e[3],x=e[4],M=e[5],z=e[6],S=e[7],T=e[8],E=e[9],A=e[10],P=e[11],I=e[12],C=e[13],k=e[14],D=e[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(s-w)<=1e-6*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-x)<=1e-6*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(a-M)<=1e-6*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(l-z)<=1e-6*Math.max(1,Math.abs(l),Math.abs(z))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(u-T)<=1e-6*Math.max(1,Math.abs(u),Math.abs(T))&&Math.abs(c-E)<=1e-6*Math.max(1,Math.abs(c),Math.abs(E))&&Math.abs(f-A)<=1e-6*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-P)<=1e-6*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(d-I)<=1e-6*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(_-k)<=1e-6*Math.max(1,Math.abs(_),Math.abs(k))&&Math.abs(g-D)<=1e-6*Math.max(1,Math.abs(g),Math.abs(D))}(e,i),r||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),r&&(function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]}(e,i),this.terrainFacilitator.renderTime=Qd(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){!this.style?.map?.terrain||!this.terrainFacilitator.coordsDirty||(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(t,e,i,r,s){if(i.isHidden(this.transform.zoom)||"background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;this.id=i.id;let n=this.drawFunctions;yf(i)?n.symbol(t,e,i,r,this.style.placement.variableOffsets,s):(t=>"circle"===t.type)(i)?n.circle(t,e,i,r,s):(t=>"heatmap"===t.type)(i)?n.heatmap(t,e,i,r,s):(t=>"line"===t.type)(i)?n.line(t,e,i,r,s):(t=>"fill"===t.type)(i)?n.fill(t,e,i,r,s):(t=>"fill-extrusion"===t.type)(i)?n.fillExtrusion(t,e,i,r,s):(t=>"hillshade"===t.type)(i)?n.hillshade(t,e,i,r,s):(t=>"color-relief"===t.type)(i)?n.colorRelief(t,e,i,r,s):Go(i)?n.raster(t,e,i,r,s):(t=>"background"===t.type)(i)?n.background(t,e,i,r,s):(t=>"custom"===t.type)(i)&&n.custom(t,e,i,s)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(e){let i=this._tileTextures[e.size[0]];i?i.length<t.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(t){let e=this._tileTextures[t];return e&&e.length>0?e.pop():null}acquireRTT(t){let e=this.context.gl,i=this._rttObjectRecyclePool.pop();if(i)return i.size!==t&&(e.bindTexture(e.TEXTURE_2D,i.texture.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,t,0,e.RGBA,e.UNSIGNED_BYTE,null),i.texture.size=[t,t],i.size=t),i;let r=new Ph(this.context,{width:t,height:t,data:null},e.RGBA);return r.bind(e.LINEAR,e.CLAMP_TO_EDGE),this.context.extTextureFilterAnisotropic&&e.texParameterf(e.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:r,size:t}}bindRTT(t){let e=this.context.gl,i=t.size;if(!this._rttSharedFbo){let t=this.context.createFramebuffer(i,i,!0,!0),r=this.context.createRenderbuffer(e.DEPTH_STENCIL,i,i);t.depthAttachment.set(r),this._rttSharedFbo={fbo:t,depthRenderbuffer:r,size:i}}this._rttSharedFbo.size!==i&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i,i),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=i,this._rttSharedFbo.fbo.height=i,this._rttSharedFbo.size=i),this._rttSharedFbo.fbo.colorAttachment.set(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e,i=!1,r=[]){this.cache||={};let s=!!this.style.map.terrain,n=this.style.projection,o=i?Dg.projectionMercator:n.shaderPreludeCode,a=i?Rg:n.shaderDefine,l=t+(e?e.cacheKey:"")+`/${i?Og:n.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(s?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||=new Cy(this.context,Dg[t],e,fv[t],this._showOverdrawInspector,s,o,a,r),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ph(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){if(this._tileTextures){for(let t in this._tileTextures){let e=this._tileTextures[t];if(e)for(let t of e)t.destroy()}this._tileTextures={}}for(let t of this._rttObjectRecyclePool)t.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let t=this.context.gl;t.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),t.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}if(this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,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&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(let t in this.cache){let e=this.cache[t];e?.program&&this.context.gl.deleteProgram(e.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}},Kw=class extends Error{constructor(t,e){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=t,this.statusMessage=e?.statusMessage??null}};function Qw(t,e){let i,r=!1,s=null,n=()=>{s=null,r&&=(t(...i),s=setTimeout(n,e),!1)};return(...t)=>(r=!0,i=t,s||n(),s)}var tb=class{constructor(t){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):([...t.keys()][0]??"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{let t=this._getHashParams();if(this._hashName)t.delete(this._hashName);else{let e=Array.from(t.keys());e.length>0&&t.delete(e[0])}let e=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),i=window.location.href.replace(/(#.+)?$/,e?`#${e}`:"");i=i.replace("&&","&"),window.history.replaceState(window.history.state,null,i)},this._updateHash=Qw(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){let e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.round(e.lng*r)/r,n=Math.round(e.lat*r)/r,o=this._map.getBearing(),a=this._map.getPitch(),l="";if(l+=t?`/${s}/${n}/${i}`:`${i}/${n}/${s}`,(o||a)&&(l+="/"+Math.round(10*o)/10),a&&(l+=`/${Math.round(a)}`),this._hashName){let t=this._getHashParams();return t.set(this._hashName,l),`#${decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(t){if(t.length<3||t.some((t=>isNaN(+t))))return!1;try{new Zu(+t[2],+t[1])}catch{return!1}let e=+t[0],i=+(t[3]||0),r=+(t[4]||0);return e>=this._map.getMinZoom()&&e<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}};const eb={linearity:.3,easing:wt(0,0,.3,1)},ib=zt({deceleration:2500,maxSpeed:1400},eb),rb=zt({deceleration:20,maxSpeed:1400},eb),sb=zt({deceleration:1e3,maxSpeed:360},eb),nb=zt({deceleration:1e3,maxSpeed:90},eb),ob=zt({deceleration:1e3,maxSpeed:360},eb);var ab=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Qd(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,e=Qd();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let e={zoom:0,bearing:0,pitch:0,roll:0,pan:new l(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of this._inertiaBuffer)e.zoom+=t.zoomDelta||0,e.bearing+=t.bearingDelta||0,e.pitch+=t.pitchDelta||0,e.roll+=t.rollDelta||0,t.panDelta&&e.pan._add(t.panDelta),t.around&&(e.around=t.around),t.pinchAround&&(e.pinchAround=t.pinchAround);let i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(e.pan.mag()){let s=hb(e.pan.mag(),i,zt({},ib,t||{})),n=e.pan.mult(s.amount/e.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(n,this._map._camera.transform);r.center=o.easingCenter,r.offset=o.easingOffset,lb(r,s)}if(e.zoom){let t=hb(e.zoom,i,rb);r.zoom=It(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),lb(r,t)}if(e.bearing){let t=hb(e.bearing,i,sb);r.bearing=this._map.getBearing()+xt(t.amount,-179,179),lb(r,t)}if(e.pitch){let t=hb(e.pitch,i,nb);r.pitch=this._map.getPitch()+t.amount,lb(r,t)}if(e.roll){let t=hb(e.roll,i,ob);r.roll=this._map.getRoll()+xt(t.amount,-179,179),lb(r,t)}if(r.zoom||r.bearing){let t=void 0===e.pinchAround?e.around:e.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),zt(r,{noMoveStart:!0})}};function lb(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function hb(t,e,i){let{maxSpeed:r,linearity:s,deceleration:n}=i,o=xt(t*s/(e/1e3),-r,r),a=Math.abs(o)/(n*s);return{easing:i.easing,duration:1e3*a,amount:a/2*o}}var ub=class{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new um(this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new lm(t.type,this._map,t))}mouseup(t){this._map.fire(new lm(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new lm(t.type,this._map,t))}dblclick(t){return this._firePreventable(new lm(t.type,this._map,t))}mouseover(t){this._map.fire(new lm(t.type,this._map,t))}mouseout(t){this._map.fire(new lm(t.type,this._map,t))}touchstart(t){return this._firePreventable(new hm(t.type,this._map,t))}touchmove(t){this._map.fire(new hm(t.type,this._map,t))}touchend(t){this._map.fire(new hm(t.type,this._map,t))}touchcancel(t){this._map.fire(new hm(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},cb=class{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new lm(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new lm("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new lm(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},fb=class{constructor(t,e,i){this._map=t,this._tr=i,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1,e.boxZoom&&"object"==typeof e.boxZoom&&(this._boxZoomEnd=e.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(tm.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;let i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=tm.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let s=Math.min(r.x,i.x),n=Math.max(r.x,i.x),o=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._box.style.transform=`translate(${s}px,${o}px)`,this._box.style.width=n-s+"px",this._box.style.height=a-o+"px"}mouseupWindow(t,e){if(!this._active||0!==t.button)return;let i=this._startPos,r=e;if(this.reset(),tm.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new cm("boxzoomend",{originalEvent:t})),this._boxZoomEnd?void this._boxZoomEnd(this._map,i,r,t):{cameraAnimation:t=>t.fitScreenCoordinates(i,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&=(this._box.remove(),null),tm.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new cm(t,{originalEvent:e}))}};function pb(t,e){if(t.length!==e.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);let i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}var db=class{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,e,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(void 0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){let e=new l(0,0);for(let i of t)e._add(i);return e.div(t.length)}(e),this.touches=pb(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;let r=pb(i,e);for(let t in this.touches){let e=r[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}},mb=class{constructor(t){this.singleTap=new db(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){let r=this.singleTap.touchend(t,e,i);if(r){let e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if((!e||!i)&&this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},_b=class{constructor(t,e){this._tr=e,this._zoomIn=new mb({numTouches:1,numTaps:2}),this._zoomOut=new mb({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){let r=this._zoomIn.touchend(t,e,i),s=this._zoomOut.touchend(t,e,i),n=this._tr;return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:It(n.zoom+1,e.getZoomSnap()),around:n.unproject(r)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:It(n.zoom-1,e.getZoomSnap()),around:n.unproject(s)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},gb=class{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){let e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.rollDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){!this.isEnabled()||this._lastPoint||this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(e)?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let r=Array.isArray(e)?e[0]:e;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(t){!this.isEnabled()||!this._lastPoint||this._moveStateManager.isValidEndEvent(t)&&(this._moved&&tm.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}};const yb={0:1,2:2};var vb=class{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){this._eventButton=t.button}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){let i=yb[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return t.button===this._eventButton}},wb=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}},bb=class{constructor(t=new vb({checkCorrectEvent:()=>!0}),e=new wb){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=e}_executeRelevantHandler(t,e,i){return t instanceof MouseEvent?e(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?i(t):void 0}startMove(t){this._executeRelevantHandler(t,(t=>{this.mouseMoveStateManager.startMove(t)}),(t=>{this.oneFingerTouchMoveStateManager.startMove(t)}))}endMove(t){this._executeRelevantHandler(t,(t=>{this.mouseMoveStateManager.endMove(t)}),(t=>{this.oneFingerTouchMoveStateManager.endMove(t)}))}isValidStartEvent(t){return!!this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidStartEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t)))}isValidMoveEvent(t){return!!this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidMoveEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t)))}isValidEndEvent(t){return!!this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidEndEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t)))}};const xb=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};function Mb({enable:t,clickTolerance:e,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:s=.8},n){return new gb({clickTolerance:e,move:(t,e)=>{let o=n();if(i&&Math.abs(o.y-t.y)>r)return{bearingDelta:Wt(new l(t.x,e.y),e,o)};let a=(e.x-t.x)*s;return i&&e.y<o.y&&(a=-a),{bearingDelta:a}},moveStateManager:new vb({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button&&!t.ctrlKey}),enable:t,assignEvents:xb})}var zb=class{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active)return this._shouldBePrevented(i.length)?void this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t):(t.preventDefault(),this._calculateTransform(t,e,i))}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,e,i){i.length>0&&(this._active=!0);let r=pb(i,e),s=new l(0,0),n=new l(0,0),o=0;for(let t in r){let e=r[t],i=this._touches[t];i&&(s._add(e),n._add(e.sub(i)),o++,r[t]=e)}if(this._touches=r,this._shouldBePrevented(o)||!n.mag())return;let a=n.div(o);return this._sum._add(a),this._sum.mag()<this._clickTolerance?void 0:{around:s.div(o),panDelta:a}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Sb=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();let[r,s]=this._firstTwoTouches,n=Tb(i,e,r),o=Tb(i,e,s);if(!n||!o)return;let a=this._aroundCenter?null:n.add(o).div(2);return this._move([n,o],a,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;let[r,s]=this._firstTwoTouches,n=Tb(i,e,r),o=Tb(i,e,s);n&&o||(this._active&&tm.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function Tb(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Eb(t,e){return Math.log(t/e)/Math.LN2}var Ab=class extends Sb{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(t){this._zoomRate=t??1}setZoomThreshold(t){this._zoomThreshold=t??.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){let i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Eb(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Eb(this._distance,i)*this._zoomRate,pinchAround:e}}};function Pb(t,e){return 180*t.angleWith(e)/Math.PI}var Ib=class extends Sb{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e,i){let r=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Pb(this._vector,r),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let e=25/(Math.PI*this._minDiameter)*360,i=Pb(t,this._startVector);return Math.abs(i)<e}};function Cb(t){return Math.abs(t.y)>Math.abs(t.x)}var kb=class extends Sb{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Cb(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,s,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+s.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;let r=t.mag()>=2,s=e.mag()>=2;if(!r&&!s)return;if(!r||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;let n=t.y>0==e.y>0;return Cb(t)&&Cb(e)&&n}};const Db={panStep:100,bearingStep:15,pitchStep:10};var Fb=class{constructor(t,e){this._tr=e;let i=Db;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,s=0,n=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{let a=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:$b,zoom:e?It(a.zoom+e*(t.shiftKey?2:1),o.getZoomSnap()):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+r*this._pitchStep,offset:[-s*this._panStep,-n*this._panStep],center:a.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function $b(t){return t*(2-t)}const jb=4.000244140625;var Rb=class{constructor(t,e,i){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=i,this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,i=Qd(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%jb==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let e=tm.mousePos(this._map.getCanvas(),t),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(Zu.convert(i.center)):e,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){let e=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=e),"number"==typeof this._targetZoom&&(this._targetZoom+=e)}if(0!==this._delta){let e="wheel"===this._type&&Math.abs(this._delta)>jb?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);let r="number"==typeof this._targetZoom?At(this._targetZoom):t.scale,s=t.applyConstrain(t.getCameraLngLat(),Pt(r*i)).zoom,n=this._map.getZoomSnap();if("wheel"===this._type&&n>0){let e=It(t.zoom,n);this._targetZoom=It(s,n,s-e)}else this._targetZoom=s;"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let e,i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,r=this._startZoom,s=this._easing,n=!1;if("wheel"===this._type&&r&&s){let t=Qd()-this._lastWheelEventTime,o=Math.min((t+5)/200,1),a=s(o);e=ir.number(r,i,a),o<1?this._needsRerender=!0:n=!0}else e=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=e,{noInertia:!0,needsRenderFrame:!n,zoomDelta:e-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=bt;if(this._prevEase){let t=this._prevEase,i=(Qd()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),s=.27/Math.sqrt(r*r+1e-4)*.01;e=wt(s,Math.sqrt(.0729-s*s),.25,1)}return this._prevEase={start:Qd(),duration:t,easing:e},e}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},Ob=class{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}},Lb=class{constructor(t,e){this._tr=e,this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:It(this._tr.zoom+(t.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Bb=class{constructor(){this._tap=new mb({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(t){this._zoomRate=t??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){let r=e[0],s=t.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;s&&n?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let r=e[0],s=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:s/128*this._zoomRate}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{let r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},Nb=class{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},Ub=class{constructor(t,e,i,r){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=e,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},Gb=class{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(t){this._touchZoom.setZoomRate(t),this._tapDragZoom.setZoomRate(t)}setZoomThreshold(t){this._touchZoom.setZoomThreshold(t)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},qb=class{constructor(t,e){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=tm.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=e,this._container.appendChild(r);let s=document.createElement("div");s.className="maplibregl-mobile-message",s.textContent=i,this._container.appendChild(s),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,e){this._enabled&&(this._map.fire(new rm("cooperativegestureprevented",{gestureType:t,originalEvent:e})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}},Vb=class{constructor(t){this._camera=t}get transform(){return this._camera._requestedCameraState||this._camera.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(l.convert(t),this._camera.terrain)}};const Zb=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var Wb=class extends me{};function Hb(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var Yb=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(t,e,i){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;let i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},s={},n={};for(let{handlerName:o,handler:a,allowed:l}of this._handlers){if(!a.isEnabled())continue;let h;if(this._blockedByActive(n,l,o))a.reset();else if(a[e||t.type]){if(Qt(t,e||t.type)){let i=tm.mousePos(this._map.getCanvas(),t);h=a[e||t.type](t,i)}else if(Kt(t,e||t.type)){let i=this._getMapTouches(t.touches),r=tm.touchPos(this._map.getCanvas(),i);h=a[e||t.type](t,r,i)}else te(e||t.type)||(h=a[e||t.type](t));this.mergeHandlerResult(r,s,h,o,i),h?.needsRenderFrame&&this._triggerRenderFrame()}(h||a.isActive())&&(n[o]=a)}let o={};for(let t in this._previousActiveHandlers)n[t]||(o[t]=i);this._previousActiveHandlers=n,(Object.keys(o).length||Hb(r))&&(this._changes.push([r,s,o]),this._triggerRenderFrame()),(Object.keys(n).length||Hb(r))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:a}=r;a&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],a(this._map))},this._map=t,this._camera=e,this._transformProvider=new Vb(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ab(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[t,e,i]of this._listeners)t.addEventListener(e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(let[t,e,i]of this._listeners)t.removeEventListener(e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){let e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new ub(e,t));let r=e.boxZoom=new fb(e,t,this._transformProvider);this._add("boxZoom",r),t.interactive&&t.boxZoom&&r.enable();let s=e.cooperativeGestures=new qb(e,t.cooperativeGestures);this._add("cooperativeGestures",s),t.cooperativeGestures&&s.enable();let n=new _b(e,this._transformProvider),o=new Lb(e,this._transformProvider);e.doubleClickZoom=new Ob(o,n),this._add("tapZoom",n),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();let a=new Bb;this._add("tapDragZoom",a);let l=e.touchPitch=new kb(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);let h=()=>e.project(e.getCenter()),u=Mb(t,h),c=function({enable:t,clickTolerance:e,pitchSpeed:i=-.5}){return new gb({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new vb({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button}),enable:t,assignEvents:xb})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){return new gb({clickTolerance:e,move:(t,e)=>{let s=r(),n=(e.x-t.x)*i;return e.y<s.y&&(n=-n),{rollDelta:n}},moveStateManager:new vb({checkCorrectEvent:t=>2===t.button&&t.ctrlKey}),enable:t,assignEvents:xb})}(t,h);e.dragRotate=new Ub(t,u,c,f),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",c,["mouseRotate","mouseRoll"]),this._add("mouseRoll",f,["mousePitch"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();let p=function({enable:t,clickTolerance:e}){return new gb({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:new vb({checkCorrectEvent:t=>0===t.button&&!t.ctrlKey}),enable:t,assignEvents:xb})}(t),d=new zb(t,e);e.dragPan=new Nb(i,p,d),this._add("mousePan",p),this._add("touchPan",d,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);let m=new Ib,_=new Ab;e.touchZoomRotate=new Gb(i,_,m,a),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new cb(e));let g=e.scrollZoom=new Rb(e,(()=>this._triggerRenderFrame()),this._transformProvider);this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);let y=e.keyboard=new Fb(e,this._transformProvider);this._add("keyboard",y),t.interactive&&t.keyboard&&e.keyboard.enable()}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Zb(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(let r in t)if(r!==i&&!e?.includes(r))return!0;return!1}_getMapTouches(t){let e=[];for(let i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,e,i,r,s){if(!i)return;zt(t,i);let n={handlerName:r,originalEvent:i.originalEvent||s};void 0!==i.zoomDelta&&(e.zoom=n),void 0!==i.panDelta&&(e.drag=n),void 0!==i.rollDelta&&(e.roll=n),void 0!==i.pitchDelta&&(e.pitch=n),void 0!==i.bearingDelta&&(e.rotate=n)}_applyChanges(){let t={},e={},i={};for(let[r,s,n]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new l(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(t.rollDelta=(t.rollDelta||0)+r.rollDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),zt(e,s),zt(i,n);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){let r=this._map,s=this._camera.getTransformForUpdate(),n=r.terrain;if(!(Hb(t)||n&&this._terrainMovement))return void this._fireEvents(e,i,!0);this._camera.stop(!0);let{panDelta:o,zoomDelta:a,bearingDelta:l,pitchDelta:h,rollDelta:u,around:c,pinchAround:f}=t;void 0!==f&&(c=f),c||=this._camera.transform.centerPoint,n&&!s.isPointOnMapSurface(c)&&(c=s.centerPoint);let p={panDelta:o,zoomDelta:a,rollDelta:u,pitchDelta:h,bearingDelta:l,around:c};this._camera.cameraHelper.useGlobeControls&&!s.isPointOnMapSurface(c)&&(c=s.centerPoint);let d=c.distSqr(s.centerPoint)<.01?s.center:s.screenPointToLocation(o?c.sub(o):c);this._handleMapControls({terrain:n,tr:s,deltasForHelper:p,preZoomAroundLoc:d,combinedEventsInProgress:e,panDelta:o}),this._camera.applyUpdatedTransform(s),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_handleMapControls({terrain:t,tr:e,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:s,panDelta:n}){let o=this._camera.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,e),t)return o.useGlobeControls?(!this._terrainMovement&&(s.drag||s.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),void o.handleMapControlsPan(i,e,r)):this._terrainMovement||!s.drag&&!s.zoom?void(s.drag&&this._terrainMovement&&n?e.setCenter(e.screenPointToLocation(e.centerPoint.sub(n))):o.handleMapControlsPan(i,e,r)):(this._terrainMovement=!0,this._camera.elevationFreeze=!0,void o.handleMapControlsPan(i,e,r));o.handleMapControlsPan(i,e,r)}_fireEvents(t,e,i){let r=Zb(this._eventsInProgress),s=Zb(t),n={};for(let e in t){let{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&s&&this._fireEvent("movestart",s.originalEvent);for(let t in n)this._fireEvent(t,n[t]);s&&this._fireEvent("move",s.originalEvent);for(let e in t){let{originalEvent:i}=t[e];this._fireEvent(e,i)}let o,a={};for(let t in this._eventsInProgress){let{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],o=e[i]||r,a[`${t}end`]=o)}for(let t in a)this._fireEvent(t,a[t]);let l=Zb(this._eventsInProgress),h=(r||s)&&!l;if(h&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1;let t=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(t)}if(i&&h){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;!t||!t.essential&&Jd.prefersReducedMotion?(this._map.fire(new sm("moveend",{originalEvent:o})),e(this._map.getBearing())&&this._map.resetNorth()):(e(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:o})),this._updatingCamera=!1}}_fireEvent(t,e){this._map.fire(new sm(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Wb("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},Xb=class extends ge{constructor(t){super(),this._renderFrameCallback=()=>{let t=Math.min((Qd()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new Wg,this.cameraHelper=new Jg,void 0!==t.minZoom&&this.transform.setMinZoom(t.minZoom),void 0!==t.maxZoom&&this.transform.setMaxZoom(t.maxZoom),void 0!==t.minPitch&&this.transform.setMinPitch(t.minPitch),void 0!==t.maxPitch&&this.transform.setMaxPitch(t.maxPitch),void 0!==t.renderWorldCopies&&this.transform.setRenderWorldCopies(t.renderWorldCopies),null!==t.transformConstrain&&this.transform.setConstrainOverride(t.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=t.bearingSnap,this._zoomSnap=t.zoomSnap,this._requestRenderFrame=t.requestRenderFrame,this._cancelRenderFrame=t.cancelRenderFrame,this.terrain=t.terrain,this._centerClampedToGround=t.centerClampedToGround??!0,this.transformCameraUpdate=t.transformCameraUpdate??null,this._stopHandlers=t.stopHandlers??(()=>{}),this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,e){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=e}getCenter(){return new Zu(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,e){return this.jumpTo({elevation:t},e),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,e,i){return t=l.convert(t).mult(-1),this.panTo(this.transform.center,zt({offset:t},e),i)}panTo(t,e,i){return this.easeTo(zt({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(zt({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(It(this.getZoom()+1,this._zoomSnap),t,e),this}zoomOut(t,e){return this.zoomTo(It(this.getZoom()-1,this._zoomSnap),t,e),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,e){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new sm("movestart",e)).fire(new sm("move",e)).fire(new sm("moveend",e))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,e,i){return this.easeTo(zt({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,zt({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(zt({bearing:0,pitch:0,roll:0,duration:1e3},t),e),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}getRoll(){return this.transform.roll}setRoll(t,e){return this.jumpTo({roll:t},e),this}cameraForBounds(t,e){t=Zm.convert(t).adjustAntiMeridian();let i=e?.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,e,i,r){let s={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=zt({padding:s,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){let t=r.padding;r.padding={top:t,bottom:t,right:t,left:t}}let n=zt(s,r.padding);r.padding=n;let o=this.transform,a=new Zm(t,e),l=this.cameraHelper.cameraForBoxAndBearing(r,n,a,i,o);return l&&this._zoomSnap&&(l.zoom=It(l.zoom,this._zoomSnap,-1)),l}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,e,i,r,s){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(l.convert(t)),this.transform.screenPointToLocation(l.convert(e)),i,r),r,s)}_fitInternal(t,e,i){return t?(delete(e=zt(t,e)).padding,e.linear?this.easeTo(e,i):this.flyTo(e,i)):this}jumpTo(t,e){this.stop(),"zoom"in t&&this._zoomSnap&&(t.zoom=It(t.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,s=!1,n=!1,o=i.zoom;this.terrain&&i.setElevation(this.terrain.getElevationForLngLatZoom(t.center?Zu.convert(t.center):i.center,t.zoom||i.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(i,t);let a=i.zoom!==o;return"elevation"in t&&i.elevation!==+t.elevation&&i.setElevation(+t.elevation),"bearing"in t&&i.bearing!==+t.bearing&&(r=!0,i.setBearing(+t.bearing)),"pitch"in t&&i.pitch!==+t.pitch&&(s=!0,i.setPitch(+t.pitch)),"roll"in t&&i.roll!==+t.roll&&(n=!0,i.setRoll(+t.roll)),null!=t.padding&&!i.isPaddingEqual(t.padding)&&i.setPadding(t.padding),this.applyUpdatedTransform(i),this.fire(new sm("movestart",e)).fire(new sm("move",e)),a&&this.fire(new sm("zoomstart",e)).fire(new sm("zoom",e)).fire(new sm("zoomend",e)),r&&this.fire(new sm("rotatestart",e)).fire(new sm("rotate",e)).fire(new sm("rotateend",e)),s&&this.fire(new sm("pitchstart",e)).fire(new sm("pitch",e)).fire(new sm("pitchend",e)),n&&this.fire(new sm("rollstart",e)).fire(new sm("roll",e)).fire(new sm("rollend",e)),this.fire(new sm("moveend",e))}calculateCameraOptionsFromTo(t,e,i,r=0){let s=ec.fromLngLat(t,e),n=ec.fromLngLat(i,r),o=n.x-s.x,a=n.y-s.y,l=n.z-s.z,h=Math.hypot(o,a,l);if(0===h)throw Error("Can't calculate camera options with same From and To");let u=Math.hypot(o,a),c=Pt(this.transform.cameraToCenterDistance/h/this.transform.tileSize),f=180*Math.atan2(o,-a)/Math.PI,p=180*Math.acos(u/h)/Math.PI;return p=l<0?90-p:90+p,{center:n.toLngLat(),elevation:r,zoom:c,pitch:p,bearing:f}}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,s){let n=this.transform.calculateCenterFromCameraLngLatAlt(t,e,i,r);return{center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:i,pitch:r,roll:s}}easeTo(t,e){this._stop(!1,t.easeId),"zoom"in(t=zt({offset:[0,0],duration:500,easing:bt},t))&&this._zoomSnap&&(t.zoom=It(t.zoom,this._zoomSnap)),(!1===t.animate||!t.essential&&Jd.prefersReducedMotion)&&(t.duration=0);let i,r,s=this.getTransformForUpdate(),n=this.getBearing(),o=s.pitch,a=s.roll,h="bearing"in t?this._normalizeBearing(t.bearing,n):n,u="pitch"in t?+t.pitch:o,c="roll"in t?this._normalizeBearing(t.roll,a):a,f="padding"in t?t.padding:s.padding,p=l.convert(t.offset);t.around&&(i=Zu.convert(t.around),r=s.locationToScreenPoint(i));let d={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},m=this.cameraHelper.handleEaseTo(s,{bearing:h,pitch:u,roll:c,padding:f,around:i,aroundPoint:r,offsetAsPoint:p,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating||=n!==h,this._pitching||=u!==o,this._rolling||=c!==a,this._padding=!s.isPaddingEqual(f),this._zooming||=m.isZooming,this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,d),this.terrain&&this._prepareElevation(m.elevationCenter),this._ease((i=>{m.easeFunc(i),this.terrain&&!t.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(s),this._fireMoveEvents(e)}),(i=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(e,i)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,!e&&!i.moving&&this.fire(new sm("movestart",t)),this._zooming&&!i.zooming&&this.fire(new sm("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new sm("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new sm("pitchstart",t)),this._rolling&&!i.rolling&&this.fire(new sm("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this.elevationFreeze=!0}_updateElevation(t){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let e=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&e!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(i-(e-(i*t+this._elevationStart))/(1-t)),this._elevationTarget=e}this.transform.setElevation(ir.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};let e=t.getCameraLngLat(),i=t.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(e,t.zoom):0;if(i<r){let i=this.calculateCameraOptionsFromTo(e,r,t.center,t.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}applyUpdatedTransform(t){let e=[];if(e.push((t=>this._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;let i=t.clone();for(let t of e){let e=i.clone(),{center:r,zoom:s,roll:n,pitch:o,bearing:a,elevation:l}=t(e);r&&e.setCenter(r),void 0!==l&&e.setElevation(l),void 0!==s&&e.setZoom(s),void 0!==n&&e.setRoll(n),void 0!==o&&e.setPitch(o),void 0!==a&&e.setBearing(a),i.apply(e,!1)}this.transform.apply(i,!1)}_fireMoveEvents(t){this.fire(new sm("move",t)),this._zooming&&this.fire(new sm("zoom",t)),this._rotating&&this.fire(new sm("rotate",t)),this._pitching&&this.fire(new sm("pitch",t)),this._rolling&&this.fire(new sm("roll",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)return;delete this._easeId;let i=this._zooming,r=this._rotating,s=this._pitching,n=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,i&&this.fire(new sm("zoomend",t)),r&&this.fire(new sm("rotateend",t)),s&&this.fire(new sm("pitchend",t)),n&&this.fire(new sm("rollend",t)),this.fire(new sm("moveend",t))}flyTo(t,e){if(!t.essential&&Jd.prefersReducedMotion){let i=St(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,e)}this.stop(),"zoom"in(t=zt({offset:[0,0],speed:1.2,curve:1.42,easing:bt},t))&&this._zoomSnap&&(t.zoom=It(t.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,s=i.pitch,n=i.roll,o=i.padding,a="bearing"in t?this._normalizeBearing(t.bearing,r):r,h="pitch"in t?+t.pitch:s,u="roll"in t?this._normalizeBearing(t.roll,n):n,c="padding"in t?t.padding:i.padding,f=l.convert(t.offset),p=i.centerPoint.add(f),d=i.screenPointToLocation(p),m=this.cameraHelper.handleFlyTo(i,{bearing:a,pitch:h,roll:u,padding:c,locationAtOffset:d,offsetAsPoint:f,center:t.center,minZoom:t.minZoom,zoom:t.zoom}),_=t.curve,g=Math.max(i.width,i.height),y=g/m.scaleOfZoom,v=m.pixelPathLength;_=Math.min(_,Math.sqrt(g/m.scaleOfMinZoom/v*2));let w=_*_;function b(t){let e=(y*y-g*g+(t?-1:1)*w*w*v*v)/(2*(t?y:g)*w*v);return Math.log(Math.sqrt(e*e+1)-e)}function x(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}let z=b(!1),S=function(t){return M(z)/M(z+_*t)},T=function(t){return g*((M(z)*function(t){return x(t)/M(t)}(z+_*t)-x(z))/w)/v},E=(b(!0)-z)/_;if(Math.abs(v)<2e-6||!isFinite(E)){if(Math.abs(g-y)<1e-6)return this.easeTo(t,e);let i=y<g?-1:1;E=Math.abs(Math.log(y/g))/_,T=()=>0,S=t=>Math.exp(i*_*t)}return t.duration="duration"in t?+t.duration:1e3*E/("screenSpeed"in t?+t.screenSpeed/_:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=r!==a,this._pitching=h!==s,this._rolling=u!==n,this._padding=!i.isPaddingEqual(c),this._prepareEase(e,!1),this.terrain&&this._prepareElevation(m.targetCenter),this._ease((l=>{let d=l*E,_=1/S(d),g=T(d);this._rotating&&i.setBearing(ir.number(r,a,l)),this._pitching&&i.setPitch(ir.number(s,h,l)),this._rolling&&i.setRoll(ir.number(n,u,l)),this._padding&&(i.interpolatePadding(o,c,l),p=i.centerPoint.add(f)),m.easeFunc(l,_,g,p),this.terrain&&!t.freezeElevation&&this._updateElevation(l),this.applyUpdatedTransform(i),this._fireMoveEvents(e)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(e)}),t),this}isEasing(){return!!this._easeFrameId}stop(t){return this._stop(t)}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||this._stopHandlers(),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=Qd(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,e){t=Mt(t,-180,180);let i=Math.abs(t-e);return Math.abs(t-360-e)<i&&(t-=360),Math.abs(t+360-e)<i&&(t+=360),t}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const Jb={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var Kb=class{constructor(t=Jb){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{t&&("terrain"===t.type||"style"===t.dataType||"source"===t.dataType&&("metadata"===t.sourceDataType||"visibility"===t.sourceDataType))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):!this._container.classList.contains("maplibregl-compact")&&!this._container.classList.contains("maplibregl-attrib-empty")&&(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=tm.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=tm.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=tm.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(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){let i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"==typeof t?t:""))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let e=this._map.style.tileManagers;for(let i in e){let r=e[i];if(r.used||r.usedForTerrain){let e=r.getSource();e.attribution&&!t.includes(e.attribution)&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].includes(e))return!1;return!0}));let i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=tm.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},Qb=class{constructor(t={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options?.compact,this._container=tm.create("div","maplibregl-ctrl");let e=tm.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},tx=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){let e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(let e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let e=this._currentlyRunning=this._queue;this._queue=[];for(let i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const ex=Ho([{name:"a_pos3d",type:"Int16",components:3}]);var ix=class extends ge{constructor(t){super(),this._lastTilesetChange=Qd(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(t,e){this.tileManager.update(t,e),this._renderableTilesKeys=[];let i={};for(let r of w_(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:e,calculateTileZoom:this.tileManager._source.calculateTileZoom}))i[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float32Array(16),S(r.terrainRttPosMatrix32f,0,et,et,0,0,1),this._tiles[r.key]=new f_(r,this.tileSize),this._lastTilesetChange=Qd());for(let t in this._tiles)i[t]||(this._tiles[t].releaseRTT(this.tileManager.map.painter),delete this._tiles[t])}releaseRTT(t){for(let e in this._tiles){let i=this._tiles[e];(i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&i.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let t in this._tiles)this._tiles[t].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,e){return e?this._getTerrainCoordsForTileRanges(t,e):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){let e={};for(let i of this._renderableTilesKeys){let r=this._tiles[i].tileID,s=t.clone(),n=ot();if(r.canonical.equals(t.canonical))S(n,0,et,et,0,0,1);else if(r.canonical.isChildOf(t.canonical)){let e=r.canonical.z-t.canonical.z,i=r.canonical.x-(r.canonical.x>>e<<e),s=r.canonical.y-(r.canonical.y>>e<<e),o=et>>e;S(n,0,o,o,0,0,1),v(n,n,[-i*o,-s*o,0])}else{if(!t.canonical.isChildOf(r.canonical))continue;{let e=t.canonical.z-r.canonical.z,i=t.canonical.x-(t.canonical.x>>e<<e),s=t.canonical.y-(t.canonical.y>>e<<e),o=et>>e;S(n,0,et,et,0,0,1),v(n,n,[i*o,s*o,0]),w(n,n,[1/2**e,1/2**e,0])}}s.terrainRttPosMatrix32f=new Float32Array(n),e[i]=s}return e}_getTerrainCoordsForTileRanges(t,e){let i={};for(let r of this._renderableTilesKeys){let s=this._tiles[r].tileID;if(!this._isWithinTileRanges(s,e))continue;let n=t.clone(),o=ot();if(s.canonical.z===t.canonical.z){let e=t.canonical.x-s.canonical.x+t.wrap*(1<<t.canonical.z),i=t.canonical.y-s.canonical.y;S(o,0,et,et,0,0,1),v(o,o,[e*et,i*et,0])}else if(s.canonical.z>t.canonical.z){let e=s.canonical.z-t.canonical.z,i=s.canonical.x-(s.canonical.x>>e<<e)+t.wrap*(1<<s.canonical.z),r=s.canonical.y-(s.canonical.y>>e<<e),n=t.canonical.x-(s.canonical.x>>e),a=t.canonical.y-(s.canonical.y>>e),l=et>>e;S(o,0,l,l,0,0,1),v(o,o,[-i*l+n*et,-r*l+a*et,0])}else{let e=t.canonical.z-s.canonical.z,i=t.canonical.x-(t.canonical.x>>e<<e)+t.wrap*(1<<t.canonical.z),r=t.canonical.y-(t.canonical.y>>e<<e),n=(t.canonical.x>>e)-s.canonical.x,a=(t.canonical.y>>e)-s.canonical.y,l=et<<e;S(o,0,l,l,0,0,1),v(o,o,[i*et+n*l,r*et+a*l,0])}n.terrainRttPosMatrix32f=new Float32Array(o),i[r]=n}return i}getSourceTile(t,e){let i=this.tileManager._source,r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;this._sourceTileCache[t.key]||=t.scaledTo(r).key;let s=this.findTileInCaches(this._sourceTileCache[t.key]);if(!s?.dem&&e)for(;r>=i.minzoom&&!s?.dem;)s=this.findTileInCaches(t.scaledTo(r--).key);return s}findTileInCaches(t){let e=this.tileManager.getTileByID(t);return e||(e=this.tileManager._outOfViewCache.getByKey(t),e)}anyTilesAfterTime(t=Qd()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,e){let i=e[t.canonical.z];return!!i&&(t.wrap>i.minWrap||t.wrap<i.maxWrap||t.canonical.x>=i.minTileXWrapped&&t.canonical.x<=i.maxTileXWrapped&&t.canonical.y>=i.minTileY&&t.canonical.y<=i.maxTileY)}},rx=class{constructor(t,e,i,r="auto"){this._meshCache={},this.painter=t,this.tileManager=new ix(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this._terrainSkirtLength=r,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._elevationSamplerCache=new Map,this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._fboCoordsTexture&&=(this._fboCoordsTexture.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._coordsTexture&&=(this._coordsTexture.destroy(),null);for(let t in this._meshCache)this._meshCache[t].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(t,e,i,r=et){let s=t.normalizeCoordinates(e,i,r);if(!s)return 0;let n=this._getElevationSampler(s.tileID);return n?n(s.x,s.y,r):0}getElevationForLngLatZoom(t,e){if(!Af(e,t.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:s}=this._getOverscaledTileIDFromLngLatZoom(t,e);return this.getElevation(i,r%et,s%et,et)}getElevationForLngLat(t,e){let i=w_(e,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),r=0;for(let t of i)t.canonical.z>r&&(r=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,r)}getElevation(t,e,i,r=et){return this.getDEMElevation(t,e,i,r)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear()}_getElevationSampler(t){let e=t.key,i=this._elevationSamplerCache.get(e);if(i)return i;let r=this.tileManager.getSourceTile(t,!0),s=r?.dem;if(!r||!s)return null;let n=this._getDEMTileMatrix(t,r),o=n[0]*s.dim,a=n[5]*s.dim,l=n[12]*s.dim,h=n[13]*s.dim,u=(t,e,i)=>{let r=8192===i?1:et/i;return s.sampleBilinear(t*r*o+l,e*r*a+h)};return this._elevationSamplerCache.set(e,u),u}_getDEMTileMatrix(t,e){let i=`${e.tileID.key}/${t.key}`,r=this._demMatrixCache.get(i);if(r)return r;let s=this.tileManager.getSource().maxzoom,n=t.canonical.z-e.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=s?n=t.canonical.z-s:jt("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let o=t.canonical.x-(t.canonical.x>>n<<n),a=t.canonical.y-(t.canonical.y>>n<<n),l=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(new Float64Array(16),[1/(et<<n),1/(et<<n),0]);return v(l,l,[o*et,a*et,0]),this._demMatrixCache.set(i,l),l}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,e=new yh({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ph(t,e,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ph(t,new yh({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=_([])}let e=this.tileManager.getSourceTile(t,!0);if(e?.dem&&(!e.demTexture||e.needsTerrainPrepare)){let t=this.painter.context;e.demTexture||=this.painter.getTileTexture(e.dem.stride),e.demTexture?e.demTexture.update(e.dem.getPixels(),{premultiply:!1}):e.demTexture=new Ph(t,e.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),e.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),e.needsTerrainPrepare=!1}let i=e?this._getDEMTileMatrix(t,e):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:e?.dem?.dim||1,u_terrain_matrix:i,u_terrain_unpack:e?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(e?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:e}}getFramebuffer(t){let e=this.painter,i=e.width/devicePixelRatio,r=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==i||this._fbo.height!==r)&&(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ph(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ph(e.context,{width:i,height:r,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,r,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let e=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,i=0;t<this._coordsTextureSize;t++)for(let r=0;r<this._coordsTextureSize;r++,i+=4)e[i+0]=255&r,e[i+1]=255&t,e[i+2]=r>>8<<4|t>>8,e[i+3]=0;let i=new yh({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(e.buffer)),r=new Ph(t,i,t.gl.RGBA,{premultiply:!1});return r.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(t){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();let e=new Uint8Array(4),i=this.painter.context,r=i.gl,s=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),n=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),o=Math.round(this.painter.height/devicePixelRatio);i.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(s,o-n-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null);let a=e[0]+(e[2]>>4<<8),l=e[1]+((15&e[2])<<8),h=this.coordsIndex[255-e[3]],u=h&&this.tileManager.getTileByID(h);if(!u)return null;let c=this._coordsTextureSize,f=(1<<u.tileID.canonical.z)*c;return new ec((u.tileID.canonical.x*c+a)/f+u.tileID.wrap,(u.tileID.canonical.y*c+l)/f,this.getElevation(u.tileID,a,l,c))}depthAtPoint(t){let e=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/16777216+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(t){let e=this.painter.style.projection?.transitionState>0,i=e&&0===t.canonical.y,r=e&&t.canonical.y===(1<<t.canonical.z)-1,s=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[s])return this._meshCache[s];let n=this.painter.context,o=new Da,a=new Ya,l=this.meshSize,h=et/l,u=l*l;for(let t=0;t<=l;t++)for(let e=0;e<=l;e++)o.emplaceBack(e*h,t*h,0);for(let t=0;t<u;t+=l+1)for(let e=0;e<l;e++)a.emplaceBack(e+t,l+e+t+1,l+e+t+2),a.emplaceBack(e+t,l+e+t+2,e+t+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(o,a,l,h,i,r);let c=new $g(n.createVertexBuffer(o,ex.members),n.createIndexBuffer(a),Qa.simpleSegment(0,0,o.length,a.length));return this._meshCache[s]=c,c}getSkirtLength(t){return 2*Math.PI*Vu/2**Math.max(t,0)/5}getMinTileElevationForLngLatZoom(t,e){if(!Af(e,t.wrap()))return 0;let{tileID:i}=this._getOverscaledTileIDFromLngLatZoom(t,e);return this.getMinMaxElevation(i).minElevation??0}getMinMaxElevation(t){let e=this.tileManager.getSourceTile(t,!0),i={minElevation:null,maxElevation:null};return e?.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,e){let i=ec.fromLngLat(t.wrap()),r=(1<<e)*et,s=i.x*r,n=i.y*r,o=Math.floor(s/et),a=Math.floor(n/et);return{tileID:new Cf(e,0,e,o,a),mercatorX:s,mercatorY:n}}_buildSkirts(t,e,i,r,s,n){let o=t.length,a=o+(i+1),l=(i+1)*i,h=s?Mu:0,u=+!s,c=n?zu:et,f=+!n;for(let e=0;e<=i;e++)t.emplaceBack(e*r,h,u);for(let e=0;e<=i;e++)t.emplaceBack(e*r,c,f);for(let t=0;t<i;t++)e.emplaceBack(l+t,a+t,a+t+1),e.emplaceBack(l+t,a+t+1,l+t+1),e.emplaceBack(0+t,o+t+1,o+t),e.emplaceBack(0+t,0+t+1,o+t+1);let p=t.length,d=p+2*(i+1);for(let e of[0,1])for(let s=0;s<=i;s++)for(let i of[0,1])t.emplaceBack(e*et,s*r,i);for(let t=0;t<2*i;t+=2)e.emplaceBack(p+t,p+t+1,p+t+3),e.emplaceBack(p+t,p+t+3,p+t+2),e.emplaceBack(d+t,d+t+3,d+t+1),e.emplaceBack(d+t,d+t+2,d+t+3)}};const sx={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var nx=class{constructor(t,e){this.painter=t,this.terrain=e,this.rttSize=e.tileManager.tileSize*e.qualityFactor}getTexture(t){return t.getRTT(this._stacks.length-1).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e)));let i=new Set;for(let e of this._renderableLayerIds){let r=t._layers[e],s=r.source;s&&sx[r.type]&&i.add(s)}this._coordsAscending={},this._rttFingerprints={};for(let e of i){let i=t.tileManagers[e];if(!i)continue;this._coordsAscending[e]={};let r=this._coordsAscending[e],s=i.getSource(),n=s instanceof s_?s.terrainTileRanges:null;for(let t of i.getVisibleCoordinates()){let e=this.terrain.tileManager.getTerrainCoords(t,n);for(let t in e)r[t]||=[],r[t].push(e[t])}this._rttFingerprints[e]={};let o=this._rttFingerprints[e],a=i.getState().revision;for(let t in r)o[t]=`${r[t].map((t=>t.key)).sort().join()}#${a}`}for(let t of this._renderableTiles)for(let e in this._rttFingerprints){let i=this._rttFingerprints[e][t.tileID.key];i&&i!==t.rttFingerprint[e]&&t.releaseRTT(this.painter)}}renderLayer(t,e){if(t.isHidden(this.painter.transform.zoom))return!1;let i={...e,isRenderingToTexture:!0},r=t.type,s=this.painter,n=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(sx[r]&&((!this._prevType||!sx[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(t.id),!n))return!0;if(sx[this._prevType]||sx[r]&&n){this._prevType=r;let t=this._stacks.length-1,e=this._stacks[t]||[];for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(t))continue;let n=r.acquireRTT(s,t,this.rttSize);s.bindRTT(n),s.context.clear({color:Si.transparent,stencil:0}),s.currentStencilSource=void 0;for(let t of e){let e=s.style._layers[t],n=e.source?this._coordsAscending[e.source][r.tileID.key]:[r.tileID];s.context.viewport.set([0,0,this.rttSize,this.rttSize]),s.renderTileClippingMasks(e,n,!0),s.renderLayer(s,s.style.tileManagers[e.source],e,n,i),e.source&&(r.rttFingerprint[e.source]=this._rttFingerprints[e.source][r.tileID.key])}}return function(t,e,i,r){let{isRenderingGlobe:s}=r,n=t.context,o=n.gl,a=t.transform,l=t.colorModeForRenderPass(),h=t.getDepthModeFor3D(),u=t.useProgram("terrain");n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]);for(let r of i){let i=e.getTerrainMesh(r.tileID),c=t.renderToTexture.getTexture(r),f=e.getTerrainData(r.tileID);n.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,c.texture);let p=e.getSkirtLength(a.zoom),d=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=Ey(p,d,t.style.sky,a.pitch,s),_=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(n,o.TRIANGLES,h,rw.disabled,l,nw.backCCW,m,f,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],sx[r]}return!1}};const ox={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},ax={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Jb,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:ne.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var lx=class extends ge{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new tx,this._controls=[],this._mapId=Et(),this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=t=>{if(t.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let t of Object.values(this.style._layers))if("custom"===t.type&&console.warn(`Custom layer with id '${t.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),t._listeners)for(let[e]of Object.entries(t._listeners))console.warn(`Custom layer with id '${t.id}' had event listeners for event '${e}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new dm("webglcontextlost",{originalEvent:t}))}else this.fire(new dm("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.painter&&(this.resize(),this._update(),this._resizeInternal(),this.fire(new dm("webglcontextrestored",{originalEvent:t})))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let e={...ax,...t,canvasContextAttributes:{...ax.canvasContextAttributes,...t.canvasContextAttributes}};if(null!=e.minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");if(this._camera=new Xb({minZoom:e.minZoom,maxZoom:e.maxZoom,minPitch:e.minPitch,maxPitch:e.maxPitch,bearingSnap:e.bearingSnap,zoomSnap:e.zoomSnap,renderWorldCopies:e.renderWorldCopies,centerClampedToGround:e.centerClampedToGround,terrain:this.terrain,transformConstrain:e.transformConstrain,requestRenderFrame:t=>this._requestRenderFrame(t),cancelRenderFrame:t=>this._cancelRenderFrame(t),transformCameraUpdate:e.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._canvasContextAttributes={...e.canvasContextAttributes},this._trackResize=!0===e.trackResize,this._terrainSkirtLength=e.terrainSkirtLength,this._refreshExpiredTiles=!0===e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=!0===e.crossSourceCollisions,this._collectResourceTiming=!0===e.collectResourceTiming,this._locale={...ox,...e.locale},this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this._zoomLevelsToOverscale=e.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=!0===e.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(e.anisotropicFilterPitch),void 0!==e.reduceMotion&&(Jd.prefersReducedMotion=e.reduceMotion),this._imageQueueHandle=em.addThrottleControl((()=>this.isMoving())),this._requestManager=new im(e.transformRequest),this._container=this._resolveContainer(e.container),e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),!this.painter)return;this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)})),this.once("idle",(()=>this._idleTriggered=!0)),this._handlers=new Yb(this,this._camera,e),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this._hash=e.hash?new tb("string"==typeof e.hash&&e.hash||void 0).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:e.center,elevation:e.elevation,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch,roll:e.roll}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,zt({},e.fitBoundsOptions,{duration:0}))));let i="string"==typeof e.style||"globe"!==e.style?.projection?.type;this.resize(null,i),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new Kb("boolean"==typeof e.attributionControl?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new Qb,e.logoPosition),this.on("style.load",(()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let t=St(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire("style"===t.dataType?new om("styledata",t):new am("sourcedata",t))})),this.on("dataloading",(t=>{this.fire("style"===t.dataType?new om("styledataloading",t):new am("sourcedataloading",t))})),this.on("dataabort",(t=>{this.fire(new am("sourcedataabort",t))}))}_getMapId(){return this._mapId}setGlobalStateProperty(t,e){return this.style.setGlobalStateProperty(t,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(t,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t?.onAdd)return this.fire(new _e(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=t.onAdd(this);this._controls.push(t);let r=this._controlPositions[e];return e.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t?.onRemove)return this.fire(new _e(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}coveringTiles(t){return w_(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new Zu(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(t,e){return this._camera.setCenter(t,e),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(t,e){return this._camera.setCenterElevation(t,e),this}setCenterClampedToGround(t){this._camera.setCenterClampedToGround(t)}panBy(t,e,i){return this._camera.panBy(t,e,i),this}panTo(t,e,i){return this._camera.panTo(t,e,i),this}getZoom(){return this._camera.transform.zoom}setZoom(t,e){return this._camera.setZoom(t,e),this}zoomTo(t,e,i){return this._camera.zoomTo(t,e,i),this}zoomIn(t,e){return this._camera.zoomIn(t,e),this}zoomOut(t,e){return this._camera.zoomOut(t,e),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(t,e){return this._camera.setVerticalFieldOfView(t,e),this}getBearing(){return this._camera.transform.bearing}setBearing(t,e){return this._camera.setBearing(t,e),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(t){return this._camera.setZoomSnap(t),this}getPadding(){return this._camera.transform.padding}setPadding(t,e){return this._camera.setPadding(t,e),this}rotateTo(t,e,i){return this._camera.rotateTo(t,e,i),this}resetNorth(t,e){return this._camera.resetNorth(t,e),this}resetNorthPitch(t,e){return this._camera.resetNorthPitch(t,e),this}snapToNorth(t,e){return this._camera.snapToNorth(t,e),this}getPitch(){return this._camera.transform.pitch}setPitch(t,e){return this._camera.setPitch(t,e),this}getRoll(){return this._camera.transform.roll}setRoll(t,e){return this._camera.setRoll(t,e),this}cameraForBounds(t,e){return this._camera.cameraForBounds(t,e)}fitBounds(t,e,i){return this._camera.fitBounds(t,e,i),this}fitScreenCoordinates(t,e,i,r,s){return this._camera.fitScreenCoordinates(t,e,i,r,s),this}jumpTo(t,e){return this._camera.jumpTo(t,e),this}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,s){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,s)}easeTo(t,e){return this._camera.easeTo(t,e),this}flyTo(t,e){return this._camera.flyTo(t,e),this}stop(){return this._camera.stop(),this}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(Zu.convert(t),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.calculateCameraOptionsFromTo(t,e,i,r)}resize(t,e=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(e);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new sm("movestart",t)).fire(new sm("move",t))),this.fire(new rm("resize",t)),i&&this.fire(new sm("moveend",t)),this}_resizeInternal(t=!0){let[e,i]=this._containerDimensions(),r=this._getClampedPixelRatio(e,i);if(this._resizeCanvas(e,i,r),this.painter.resize(e,i,r),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let r=this._getClampedPixelRatio(e,i);this._resizeCanvas(e,i,r),this.painter.resize(e,i,r)}this._resizeTransform(t)}_resizeTransform(t=!0){let[e,i]=this._containerDimensions();this._camera.transform.resize(e,i,t),this._camera._requestedCameraState?.resize(e,i,t)}_getClampedPixelRatio(t,e){let{0:i,1:r}=this._maxCanvasSize,s=this.getPixelRatio(),n=t*s,o=e*s;return Math.min(n>i?i/n:1,o>r?r/o:1)*s}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(t){return this._camera.transform.setMaxBounds(Zm.convert(t)),this._update()}setMinZoom(t){if(t??=-2,t>=-2&&t<=this._camera.transform.maxZoom){let e=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMinZoom(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.zoom&&this.fire(new sm("zoomstart")).fire(new sm("zoom")).fire(new sm("zoomend")).fire(new sm("movestart")).fire(new sm("move")).fire(new sm("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this._camera.transform.minZoom}setMaxZoom(t){if(t??=22,t>=this._camera.transform.minZoom){let e=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMaxZoom(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.zoom&&this.fire(new sm("zoomstart")).fire(new sm("zoom")).fire(new sm("zoomend")).fire(new sm("movestart")).fire(new sm("move")).fire(new sm("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(t){if(t??=0,t<0)throw Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this._camera.transform.maxPitch){let e=this._camera.transform.pitch,i=this._camera.getTransformForUpdate();return i.setMinPitch(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.pitch&&this.fire(new sm("pitchstart")).fire(new sm("pitch")).fire(new sm("pitchend")).fire(new sm("movestart")).fire(new sm("move")).fire(new sm("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(t){if(t??=60,t>180)throw Error("maxPitch must be less than or equal to 180");if(t>=this._camera.transform.minPitch){let e=this._camera.transform.pitch,i=this._camera.getTransformForUpdate();return i.setMaxPitch(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.pitch&&this.fire(new sm("pitchstart")).fire(new sm("pitch")).fire(new sm("pitchend")).fire(new sm("movestart")).fire(new sm("move")).fire(new sm("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(t){if(t??=20,t>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(t<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=t,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(t){return this._camera.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this._camera.transform.setConstrainOverride(t),this._update()}project(t){return this._camera.transform.locationToScreenPoint(Zu.convert(t),this.style&&this.terrain)}unproject(t){return this._camera.transform.screenPointToLocation(l.convert(t),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;return{layers:e,listener:i,delegates:{mousemove:s=>{let n=e.filter((t=>this.getLayer(t))),o=0===n.length?[]:this.queryRenderedFeatures(s.point,{layers:n});o.length?r||(r=!0,i.call(this,new lm(t,this,s.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;return{layers:e,listener:i,delegates:{mousemove:s=>{let n=e.filter((t=>this.getLayer(t)));(0===n.length?[]:this.queryRenderedFeatures(s.point,{layers:n})).length?r=!0:r&&(r=!1,i.call(this,new lm(t,this,s.originalEvent)))},mouseout:e=>{r&&(r=!1,i.call(this,new lm(t,this,e.originalEvent)))}}}}{let r=t=>{let r=e.filter((t=>this.getLayer(t))),s=0===r.length?[]:this.queryRenderedFeatures(t.point,{layers:r});s.length&&(t.features=s,i.call(this,t),delete t.features)};return{layers:e,listener:i,delegates:{[t]:r}}}}_saveDelegatedListener(t,e){this._delegatedListeners||={},this._delegatedListeners[t]||=[],this._delegatedListeners[t].push(e)}_removeDelegatedListener(t,e,i){if(!this._delegatedListeners?.[t])return;let r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){let s=r[t];if(s.listener===i&&s.layers.length===e.length&&s.layers.every((t=>e.includes(t)))){for(let t in s.delegates)this.off(t,s.delegates[t]);return void r.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);let r="string"==typeof e?[e]:e,s=this._createDelegatedListener(t,r,i);this._saveDelegatedListener(t,s);for(let t in s.delegates)this.on(t,s.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,r,i)}}}once(t,e,i){if(void 0===i)return super.once(t,e);let r="string"==typeof e?[e]:e,s=this._createDelegatedListener(t,r,i);for(let e in s.delegates){let n=s.delegates[e];s.delegates[e]=(...e)=>{this._removeDelegatedListener(t,r,i),n(...e)}}this._saveDelegatedListener(t,s);for(let t in s.delegates)this.once(t,s.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,e){if(!this.style)return[];let i,r=t instanceof l||Array.isArray(t),s=r?t:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(e||=(r?{}:t)||{},s instanceof l||"number"==typeof s[0])i=[l.convert(s)];else{let t=l.convert(s[0]),e=l.convert(s[1]);i=[t,new l(e.x,t.y),e,new l(t.x,e.y),t]}return this.style.queryRenderedFeatures(i,e,this._camera.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,e){return!1!==(e=zt({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(t,e))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let e=this._locale[t];if(null==e)throw Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(t,e)));let i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new zy(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i),this):(this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new zy(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(t,e){if(this._diffStyleRequest?.abort(),"string"==typeof t){let i=t;this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let t=await this._requestManager.transformRequest(i,"Style");if(r.signal.aborted)return void(this._diffStyleRequest=null);let s=await ce(t,r);this._diffStyleRequest=null,this._updateDiff(s.data,e)}catch(t){this._diffStyleRequest=null,re(t)||this.fire(new _e(rt(t)))}}else"object"==typeof t&&(this._diffStyleRequest=null,this._updateDiff(t,e))}_updateDiff(t,e){try{this.style.setState(t,e)&&this._update(!0)}catch(i){jt(`Unable to perform style diff: ${rt(i).message}. Rebuilding the style from scratch.`),this._updateStyle(t,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(){if(this.style)return this.style.loaded();jt("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){let e=this.style?.tileManagers[t];if(void 0!==e)return e.loaded();this.fire(new _e(Error(`There is no tile manager with ID '${t}'`)))}setTerrain(t,e={}){if(this.style._checkLoaded(),t&&eo(this,Jn.terrain,{value:t},e))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){let e=this.style.tileManagers[t.source];if(!e)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&e.reload();for(let e in this.style._layers){let i=this.style._layers[e];"hillshade"===i.type&&i.source===t.source&&jt("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===i.type&&i.source===t.source&&jt("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&&this.terrain.destroy(),this.terrain=new rx(this.painter,e,t,this._terrainSkirtLength),this.painter.renderToTexture=new nx(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._terrainDataCallback=e=>this._handleTerrainDataEvent(e,t.source),this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);return this.fire(new fm({terrain:t})),this}_handleTerrainDataEvent(t,e){if("style"===t.dataType)return void this.terrain.tileManager.releaseAllRTT();let i=t.sourceId===e;if(i&&this.terrain.resetElevationCache(),i&&t.tile&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))),t.tile){if("image"===t.source?.type)return void this.terrain.tileManager.releaseAllRTT();this.terrain.tileManager.releaseRTT(t.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let t=this.style?.tileManagers;for(let e of Object.values(t))if(!e.areTilesLoaded())return!1;return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style?.getSource(t)}setSourceTileLodParams(t,e,i){if(i){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=g_(Math.max(1,t),Math.max(1,e))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=g_(Math.max(1,t),Math.max(1,e));return this._update(!0),this}refreshTiles(t,e){let i=this.style.tileManagers[t];if(!i)throw Error(`There is no tile manager with ID "${t}", cannot refresh tile`);void 0===e?i.reload(!0):i.refreshTiles(e.map((t=>new Pf(t.z,t.x,t.y))))}addImage(t,e,i={}){this._lazyInitEmptyStyle();let r=this._createStyleImage(e,i);return r?(this.style.addImage(t,r),r.userImage?.onAdd&&r.userImage.onAdd(this,t),this):this}setMissingStyleImageResolver(t){return this._missingStyleImageResolver=t,this.style?.setMissingImageResolver(t),this}_createStyleImage(t,e={}){let{pixelRatio:i=1,sdf:r=!1,stretchX:s,stretchY:n,content:o,textFitWidth:a,textFitHeight:l}=e;if(t instanceof HTMLImageElement||Nt(t)){let{width:e,height:h,data:u}=Jd.getImageData(t);return{data:new yh({width:e,height:h},u),pixelRatio:i,stretchX:s,stretchY:n,content:o,textFitWidth:a,textFitHeight:l,sdf:r,version:0}}if(void 0===t.width||void 0===t.height)return this.fire(new _e(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`"))),null;{let{width:e,height:h,data:u}=t,c=t;return{data:new yh({width:e,height:h},new Uint8Array(u)),pixelRatio:i,stretchX:s,stretchY:n,content:o,textFitWidth:a,textFitHeight:l,sdf:r,version:0,userImage:c}}}updateImage(t,e){let i=this.style.getImage(t);if(!i)return this.fire(new _e(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:s,data:n}=e instanceof HTMLImageElement||Nt(e)?Jd.getImageData(e):e;if(void 0===r||void 0===s)return this.fire(new _e(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(r!==i.data.width||s!==i.data.height)return this.fire(new _e(Error("The width and height of the updated image must be that same as the previous version of the image")));let o=!(e instanceof HTMLImageElement||Nt(e));return i.data.replace(n,o),this.style.updateImage(t,i),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new _e(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){return em.getImage(await this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style?.listImages()??[]}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style?.getLayer(t)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style?.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style?.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupResizeObserver(){let t=!1,e=Qw((t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())}),50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i((i=>{t?e(i):t=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(t){if("string"==typeof t){let e=document.getElementById(t);if(!e)throw Error(`Container '${t}' not found.`);return e}if(t instanceof HTMLElement||t&&"object"==typeof t&&1===t.nodeType)return t;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let t=this._container;t.classList.add("maplibregl-map");let e=this._canvasContainer=tm.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=tm.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");let i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);let s=this._controlContainer=tm.create("div","maplibregl-control-container",t),n=this._controlPositions={};for(let t of["top-left","top-right","bottom-left","bottom-right"])n[t]=tm.create("div",`maplibregl-ctrl-${t} `,s);this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){let t={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},e=null;this._canvas.addEventListener("webglcontextcreationerror",(t=>{e=t}),{once:!0});let i=this._canvas.getContext("webgl2",t);i?this.painter=new Jw(i,this._camera.transform):this.fire(new _e(new Kw(t,e)))}migrateProjection(t,e){this._camera.migrateProjection(t,e),this.painter.transform=t,this.fire(new pm({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?._loaded?(this._styleDirty||=t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){let e=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this._camera.transform.zoom,i=Qd();this.style.zoomHistory.update(t,i);let s=new wo(t,{now:i,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=s.crossFadingFactor();(1!==n||n!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=n),this.style.update(s)}let s=this.style.projection?.transitionState>0!==i;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||s)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain),this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,e,this._crossSourceCollisions,s),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new rm("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new rm("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let n=this._sourcesDirty||this._styleDirty||this._placementDirty;return n||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new rm("idle")),this._loaded&&!this._fullyLoaded&&!n&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),em.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),this._removed=!0,this.fire(new rm("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Jd.frame(this._frameRequest,(t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!re(t))throw t}}),(()=>{}),this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return"6.2.0"}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};const hx={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var ux=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),e=this._map.getRoll(),i=this._map.getBearing(),r=1/Math.cos(qt(t))**.5;this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${r}) rotateZ(${-e}deg) rotateX(${t}deg) rotateZ(${-i}deg)`:this.options.visualizePitch?`scale(${r}) rotateX(${t}deg) rotateZ(${-i}deg)`:this.options.visualizeRoll?`rotate(${-i-e}deg)`:`rotate(${-i}deg)`},this._setButtonTitle=(t,e)=>{let i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=zt({},hx,t),this._container=tm.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),tm.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),tm.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=tm.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new cx(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){let i=tm.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},cx=class{constructor(t,e,i=!1){this.mousedown=t=>{this.startMove(t,tm.mousePos(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,tm.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{1===t.targetTouches.length?(this._startPos=this._lastPos=tm.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=t=>{1===t.targetTouches.length?(this._lastPos=tm.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos)):this.reset()},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=e;let r=new bb;this._rotatePitchHandler=new gb({clickTolerance:3,move:(t,r)=>{let s=e.getBoundingClientRect(),n=new l((s.bottom-s.top)/2,(s.right-s.left)/2);return{bearingDelta:Wt(new l(t.x,r.y),r,n),pitchDelta:i?-.5*(r.y-t.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=t,e.addEventListener("mousedown",this.mousedown),e.addEventListener("touchstart",this.touchstart,{passive:!1}),e.addEventListener("touchcancel",this.reset)}startMove(t,e){this._rotatePitchHandler.dragStart(t,e),tm.disableDrag()}move(t,e){let i=this.map,{bearingDelta:r,pitchDelta:s}=this._rotatePitchHandler.dragMove(t,e)||{};r&&i.setBearing(i.getBearing()+r),s&&i.setPitch(i.getPitch()+s)}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){tm.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};const fx={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%)"},px={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},dx=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");var mx=class extends me{},_x=class extends ge{constructor(t){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map._camera.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),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("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new mx("close"))),this),this._update=t=>{let e;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=tm.create("div","maplibregl-popup",this._map.getContainer()),this._tip=tm.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=function(t,e,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return t?.wrap();let s=new Zu(t.lng,t.lat);if(t=new Zu(t.lng,t.lat),e){let r=new Zu(t.lng-360,t.lat),s=new Zu(t.lng+360,t.lat),n=i.locationToScreenPoint(t).distSqr(e);i.locationToScreenPoint(r).distSqr(e)<n?t=r:i.locationToScreenPoint(s).distSqr(e)<n&&(t=s)}for(;Math.abs(t.lng-i.center.lng)>180;){let e=i.locationToScreenPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t.lng!==s.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(t))?t:s}(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer),t&&"point"in t&&t.point&&(e=t.point),this._trackPointer&&!e)return;let i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map._camera.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor,s=gx(this.options.offset);if(!r){let t,e=this._container.offsetWidth,n=this._container.offsetHeight,o=function(t){return t?{top:t.top??0,right:t.right??0,bottom:t.bottom??0,left:t.left??0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);t=i.y+s.bottom.y<n+o.top?["top"]:i.y>this._map._camera.transform.height-n-o.bottom?["bottom"]:[],i.x<e/2+o.left?t.push("left"):i.x>this._map._camera.transform.width-e/2-o.right&&t.push("right"),r=0===t.length?"bottom":t.join("-")}let n=i.add(s[r]);this.options.subpixelPositioning||(n=n.round()),this._container.style.transform=`${fx[r]} translate(${n.x}px,${n.y}px)`,function(t,e,i){let r=t.classList;for(let t in fx)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}(this._container,r,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=zt(Object.create(px),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),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 mx("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Zu.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),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._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let e,i=document.createDocumentFragment(),r=document.createElement("body");for(r.innerHTML=t;e=r.firstChild,e;)i.appendChild(e);return this.setDOMContent(i)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=tm.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}setPadding(t){this.options.padding=t,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=tm.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let t=this._container.querySelector(dx);t&&t.focus()}};function gx(t){if(!t)return gx(new l(0,0));if("number"==typeof t){let e=Math.round(Math.abs(t)/Math.SQRT2);return{center:new l(0,0),top:new l(0,t),"top-left":new l(e,e),"top-right":new l(-e,e),bottom:new l(0,-t),"bottom-left":new l(e,-e),"bottom-right":new l(-e,-e),left:new l(t,0),right:new l(-t,0)}}if(t instanceof l||Array.isArray(t)){let e=l.convert(t);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:l.convert(t.center||[0,0]),top:l.convert(t.top||[0,0]),"top-left":l.convert(t["top-left"]||[0,0]),"top-right":l.convert(t["top-right"]||[0,0]),bottom:l.convert(t.bottom||[0,0]),"bottom-left":l.convert(t["bottom-left"]||[0,0]),"bottom-right":l.convert(t["bottom-right"]||[0,0]),left:l.convert(t.left||[0,0]),right:l.convert(t.right||[0,0])}}export{le as AJAXError,Kb as AttributionControl,fb as BoxZoomHandler,o_ as CanvasSource,qb as CooperativeGesturesHandler,Ob as DoubleClickZoomHandler,Nb as DragPanHandler,Ub as DragRotateHandler,et as EXTENT,Bg as EdgeInsets,_e as ErrorEvent,me as Event,ge as Evented,Kw as GPUInitializationError,r_ as GeoJSONSource,tb as Hash,s_ as ImageSource,Fb as KeyboardHandler,Zu as LngLat,Zm as LngLatBounds,Qb as LogoControl,lx as Map,cm as MapBoxZoomEvent,dm as MapContextEvent,rm as MapLibreEvent,lx as MapLibreMap,lm as MapMouseEvent,sm as MapMovementEvent,pm as MapProjectionEvent,am as MapSourceDataEvent,om as MapStyleDataEvent,mm as MapStyleImageMissingEvent,nm as MapStyleLoadEvent,fm as MapTerrainEvent,hm as MapTouchEvent,um as MapWheelEvent,ec as MercatorCoordinate,ux as NavigationControl,l as Point,_x as Popup,mx as PopupEvent,Xm as RasterDEMTileSource,Ym as RasterTileSource,Rb as ScrollZoomHandler,zy as Style,kb as TwoFingersTouchPitchHandler,Ib as TwoFingersTouchRotateHandler,Ab as TwoFingersTouchZoomHandler,Gb as TwoFingersTouchZoomRotateHandler,Hm as VectorTileSource,n_ as VideoSource,ne as config,Qg as createTileMesh,Bm as getGlobalDispatcher,Qd as now}