xv-webcomponents 1.22.2 → 1.22.3-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 (75) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/maplibre-gl-CCZS3Rg5.js +900 -0
  3. package/dist/cjs/{xv-accordion-v2_48.cjs.entry.js → xv-accordion-v2_49.cjs.entry.js} +699 -72
  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 +24 -4
  9. package/dist/collection/components/xv-accordion-item/xv-accordion-item.js +11 -5
  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 +63 -5
  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.css +39 -1
  25. package/dist/collection/components/xv-file-uploader/xv-file-uploader.js +57 -7
  26. package/dist/collection/components/xv-footer/xv-footer.js +1 -1
  27. package/dist/collection/components/xv-geo-map/xv-geo-map.css +907 -0
  28. package/dist/collection/components/xv-geo-map/xv-geo-map.js +1052 -0
  29. package/dist/collection/components/xv-header/xv-header.js +1 -1
  30. package/dist/collection/components/xv-header-next/xv-header-next.js +1 -1
  31. package/dist/collection/components/xv-image-viewer/xv-image-viewer.js +1 -1
  32. package/dist/collection/components/xv-link/xv-link.js +1 -1
  33. package/dist/collection/components/xv-mega-menu/xv-mega-menu.js +2 -2
  34. package/dist/collection/components/xv-mega-menu-next/xv-mega-menu-next.js +2 -2
  35. package/dist/collection/components/xv-modal/xv-modal.js +1 -1
  36. package/dist/collection/components/xv-notification/xv-notification.js +1 -1
  37. package/dist/collection/components/xv-number-input/xv-number-input.js +2 -2
  38. package/dist/collection/components/xv-pagination/xv-pagination.js +1 -1
  39. package/dist/collection/components/xv-progress-indicator/xv-progress-indicator-item/xv-progress-indicator-item.js +1 -1
  40. package/dist/collection/components/xv-progress-indicator/xv-progress-indicator.js +1 -1
  41. package/dist/collection/components/xv-radio/xv-radio.js +2 -2
  42. package/dist/collection/components/xv-slider/xv-slider.js +1 -1
  43. package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.js +1 -1
  44. package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.js +1 -1
  45. package/dist/collection/components/xv-table/xv-table-row/xv-table-row.js +1 -1
  46. package/dist/collection/components/xv-table/xv-table.js +1 -1
  47. package/dist/collection/components/xv-tabs/xv-tab/xv-tab.js +1 -1
  48. package/dist/collection/components/xv-tag/xv-tag.js +1 -1
  49. package/dist/collection/components/xv-tag-combobox/xv-tag-combobox.js +2 -2
  50. package/dist/collection/components/xv-text-input/xv-text-input.js +2 -2
  51. package/dist/collection/components/xv-textarea/xv-textarea.js +2 -2
  52. package/dist/collection/components/xv-tile/xv-tile.js +2 -2
  53. package/dist/collection/components/xv-toggle/xv-toggle.js +1 -1
  54. package/dist/collection/components/xv-toggle-tip/xv-toggle-tip.js +1 -1
  55. package/dist/collection/components/xv-tooltip/xv-tooltip.js +2 -2
  56. package/dist/esm/loader.js +1 -1
  57. package/dist/esm/maplibre-gl-CS4Eagm9.js +813 -0
  58. package/dist/esm/maplibre-gl-shared.mjs +6 -0
  59. package/dist/esm/maplibre-gl-worker.mjs +6 -0
  60. package/dist/esm/{xv-accordion-v2_48.entry.js → xv-accordion-v2_49.entry.js} +699 -73
  61. package/dist/esm/xv-header-next.entry.js +1 -1
  62. package/dist/esm/xv-mega-menu-next.entry.js +2 -2
  63. package/dist/esm/xv-webcomponents.js +1 -1
  64. package/dist/types/components/xv-accordion/xv-accordion.d.ts +5 -4
  65. package/dist/types/components/xv-accordion-item/xv-accordion-item.d.ts +3 -0
  66. package/dist/types/components/xv-datepicker/xv-datepicker.d.ts +12 -0
  67. package/dist/types/components/xv-file-uploader/xv-file-uploader.d.ts +3 -0
  68. package/dist/types/components/xv-geo-map/xv-geo-map.d.ts +126 -0
  69. package/dist/types/components.d.ts +241 -0
  70. package/dist/xv-webcomponents/{p-7e05cb50.entry.js → p-71205fad.entry.js} +1 -1
  71. package/dist/xv-webcomponents/{p-38e5f1e1.entry.js → p-9bd6edd0.entry.js} +1 -1
  72. package/dist/xv-webcomponents/p-CS4Eagm9.js +10 -0
  73. package/dist/xv-webcomponents/{p-511519a7.entry.js → p-efa0ceeb.entry.js} +2 -2
  74. package/dist/xv-webcomponents/xv-webcomponents.esm.js +1 -1
  75. package/package.json +2 -1
@@ -0,0 +1,10 @@
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,T=u*m-c*d,z=u*_-f*d,S=u*g-p*d,E=c*_-f*m,A=c*g-p*m,P=f*g-p*_,C=y*P-v*A+w*E+b*S-x*z+M*T;return C?(t[0]=(a*P-l*A+h*E)*(C=1/C),t[1]=(s*A-r*P-n*E)*C,t[2]=(m*M-_*x+g*b)*C,t[3]=(f*x-c*M-p*b)*C,t[4]=(l*S-o*P-h*z)*C,t[5]=(i*P-s*S+n*z)*C,t[6]=(_*w-d*M-g*v)*C,t[7]=(u*M-f*w+p*v)*C,t[8]=(o*A-a*S+h*T)*C,t[9]=(r*S-i*A-n*T)*C,t[10]=(d*x-m*w+g*y)*C,t[11]=(c*w-u*x-p*y)*C,t[12]=(a*z-o*E-l*T)*C,t[13]=(i*E-r*z+s*T)*C,t[14]=(m*v-d*b-_*y)*C,t[15]=(u*b-c*v+f*y)*C,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 T=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},z=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 S(){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 C(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function I(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 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[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 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[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}S();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 V(){var t=new f(2);return f!=Float32Array&&(t[0]=0,t[1]=0),t}function q(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)}(),S(),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};V();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=I([],s,-t[3]);return C(a,a,I([],n,-e[3])),C(a,a,I([],o,-i[3])),I(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 Tt(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function zt(t,e){let i={};for(let r of e)r in t&&(i[r]=t[r]);return i}let St=1;function Et(){return St++}function At(t){return 2**t}function Pt(t){return Math.log(t)/Math.LN2}function Ct(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 It(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?It(t,Ft):t}const $t={};function Rt(t){$t[t]||(typeof console<"u"&&console.warn(t),$t[t]=!0)}function jt(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 Vt(t){return t*Math.PI/180}function qt(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 qt(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:{},WORKER_URL:""};function oe(t){return ne.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}function ae(t,e){ne.REGISTERED_PROTOCOLS[t]=e}function le(t){delete ne.REGISTERED_PROTOCOLS[t]}const he="global-dispatcher";var ue=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 ce(){if(Lt(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}const fe=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:Tt(r,{data:new ArrayBuffer(0)})}if(Lt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:he},e)}if(!(t=>t.startsWith("file:")||ce()?.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:ce(),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 ue(0,rt(e).message,t.url,new Blob)}if(!i.ok){let e=await i.blob();throw new ue(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:he},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 ue(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)},pe=(t,e)=>fe(Tt(t,{type:"json"}),e);function de(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 me(t,e,i){i[t]?.includes(e)||(i[t]||=[],i[t].push(e))}function _e(t,e,i){if(i?.[t]){let r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}var ge=class{constructor(t,e={}){Tt(this,e),this.type=t}},ye=class extends ge{constructor(t,e={}){super("error",Tt({error:t},e))}},ve=class{on(t,e){return this._listeners||={},me(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return _e(t,e,this._listeners),_e(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||={},me(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new ge(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)_e(i,e,this._oneTimeListeners),e.call(this,t);let s=this._eventedParent;s&&(Tt(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof ye&&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 we={$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"}]}}}}},be=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function xe(t,e){let i={};for(let e in t)"ref"!==e&&(i[e]=t[e]);return be.forEach((t=>{t in e&&(i[t]=e[t])})),i}function Me(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]=xe(t[i],e[t[i].ref]));return t}function Te(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(!Te(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(!Te(t[i],e[i]))return!1;return!0}return t===e}function ze(t,e){t.push(e)}function Se(t,e,i){ze(i,{command:"addSource",args:[t,e[t]]})}function Ee(t,e,i){ze(e,{command:"removeSource",args:[t]}),i[t]=!0}function Ae(t,e,i,r){Ee(t,i,r),Se(t,e,i)}function Pe(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!Te(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!Te(t[i][r],e[i][r]))return!1;return!0}function Ce(t,e,i,r,s,n){t||={},e||={};for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(Te(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)||Te(t[o],e[o])||i.push({command:n,args:[r,o,e[o],s]})}function Ie(t){return t.id}function ke(t,e){return t[e.id]=e,t}var De=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__)}},Fe=class extends Error{constructor(t,e){super(e),this.message=e,this.key=t}},$e=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 Re={kind:"null"},je={kind:"number"},Oe={kind:"string"},Le={kind:"boolean"},Be={kind:"color"},Ne={kind:"projectionDefinition"},Ue={kind:"object"},Ge={kind:"value"},Ve={kind:"collator"},qe={kind:"formatted"},Ze={kind:"padding"},We={kind:"colorArray"},He={kind:"numberArray"},Ye={kind:"resolvedImage"},Xe={kind:"variableAnchorOffsetCollection"};function Je(t,e){return{kind:"array",itemType:t,N:e}}function Ke(t){if("array"===t.kind){let e=Ke(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Qe=[Re,je,Oe,Le,Be,Ne,qe,Ue,Je(Ge),Ze,He,We,Ye,Xe];function ti(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!ti(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 Qe)if(!ti(t,e))return null}return`Expected ${Ke(t)} but found ${Ke(e)} instead.`}function ei(t,e){return e.some((e=>e.kind===t.kind))}function ii(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 ri(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const si=.96422,ni=.82521,oi=4/29,ai=6/29,li=3*ai*ai,hi=Math.PI/180,ui=180/Math.PI;function ci(t){return(t%=360)<0&&(t+=360),t}function fi([t,e,i,r]){let s,n,o=di((.2225045*(t=pi(t))+.7168786*(e=pi(e))+.0606169*(i=pi(i)))/1);t===e&&e===i?s=n=o:(s=di((.4360747*t+.3850649*e+.1430804*i)/si),n=di((.0139322*t+.0971045*e+.7141733*i)/ni));let a=116*o-16;return[a<0?0:a,500*(s-o),200*(o-n),r]}function pi(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function di(t){return t>.008856451679035631?t**(1/3):t/li+oi}function mi([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*gi(s),n=si*gi(n),o=ni*gi(o),[_i(3.1338561*n-1.6168667*s-.4906146*o),_i(-.9787684*n+1.9161415*s+.033454*o),_i(.0719453*n-.2289914*s+1.4052427*o),r]}function _i(t){return(t=t<=.00304?12.92*t:1.055*t**(1/2.4)-.055)<0?0:t>1?1:t}function gi(t){return t>ai?t*t*t:li*(t-oi)}const yi=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function vi(t,e){return yi(t,e)?t[e]:void 0}function wi(t){return parseInt(t.padEnd(2,t),16)/255}function bi(t,e){return xi(e?t/100:t,0,1)}function xi(t,e,i){return Math.min(Math.max(e,t),i)}function Mi(t){return!t.some(Number.isNaN)}const Ti={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 zi(t,e,i){return t+i*(e-t)}function Si(t,e,i){return t.map(((t,r)=>zi(t,e[r],i)))}var Ei=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=vi(Ti,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[wi(t.slice(i,i+=e)),wi(t.slice(i,i+=e)),wi(t.slice(i,i+=e)),wi(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=[xi(+i/e,0,1),xi(+n/e,0,1),xi(+l/e,0,1),c?bi(+c,f):1];if(Mi(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,xi(+s,0,100),xi(+o,0,100),l?bi(+l,h):1];if(Mi(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=ci(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]=fi(t),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?ci(Math.atan2(r,i)*ui):NaN,n,e,s]}(this.rgb))}get lab(){return this.overwriteGetter("lab",fi(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]=Si(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*hi,mi([i,Math.cos(t)*e,Math.sin(t)*e,r])}([s,n??zi(a,c,r),zi(l,f,r),zi(h,p,r)]);return new t(d,m,_,g,!1)}case"lab":{let[s,n,o,a]=mi(Si(e.lab,i.lab,r));return new t(s,n,o,a,!1)}}}},Ai=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 Pi=["bottom","center","top"];var Ci=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}},Ii=class t{constructor(t){this.sections=t}static fromString(e){return new t([new Ci(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("")}},ki=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(Si(e.values,i.values,r))}},Di=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(Si(e.values,i.values,r))}},Fi=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){let i=Ei.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=Ei.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(Ei.interpolate(e.values[t],i.values[t],r,s));return new t(n)}},$i=class extends Error{constructor(t,e){super(t),this.name="RuntimeError",this.path=e}toJSON(){return this.message}};const Ri=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var ji=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||!Ri.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 $i(`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 $i(`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([zi(e,l,r),zi(i,h,r)])}return new t(a)}},Oi=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}},Li=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 Bi(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 Ni(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Li||t instanceof Ei||t instanceof Ai||t instanceof Ii||t instanceof ki||t instanceof Di||t instanceof Fi||t instanceof ji||t instanceof Oi)return!0;if(Array.isArray(t)){for(let e of t)if(!Ni(e))return!1;return!0}if("object"==typeof t){for(let e in t)if(!Ni(t[e]))return!1;return!0}return!1}function Ui(t){if(null===t)return Re;if("string"==typeof t)return Oe;if("boolean"==typeof t)return Le;if("number"==typeof t)return je;if(t instanceof Ei)return Be;if(t instanceof Li)return Ne;if(t instanceof Ai)return Ve;if(t instanceof Ii)return qe;if(t instanceof ki)return Ze;if(t instanceof Di)return He;if(t instanceof Fi)return We;if(t instanceof ji)return Xe;if(t instanceof Oi)return Ye;if(Array.isArray(t)){let e,i=t.length;for(let i of t){let t=Ui(i);if(e){if(e===t)continue;e=Ge;break}e=t}return Je(e||Ge,i)}return Ue}function Gi(t){let e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Ei||t instanceof Li||t instanceof Ii||t instanceof ki||t instanceof Di||t instanceof Fi||t instanceof ji||t instanceof Oi?t.toString():JSON.stringify(t)}var Vi=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(!Ni(e[1]))return i.error("invalid value");let r=e[1],s=Ui(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 qi={string:Oe,number:je,boolean:Le,object:Ue};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,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 qi)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);t=qi[r],s++}else t=Ge;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=Je(t,n)}else{if(!qi[n])throw Error(`Types doesn't contain name = ${n}`);r=qi[n]}let o=[];for(;s<e.length;s++){let t=i.parse(e[s],s,Ge);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(!ti(this.type,Ui(i)))return i;if(e===this.args.length-1)throw new $i(`Expected value to be of type ${Ke(this.type)}, but found ${Ke(Ui(i))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};const Wi={"to-boolean":Le,"to-color":Be,"to-number":je,"to-string":Oe};var Hi=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(!Wi[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=Wi[r],n=[];for(let t=1;t<e.length;t++){let r=i.parse(e[t],t,Ge);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 Ei)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.`:Bi(e[0],e[1],e[2],e[3]),!i))return new Ei(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new $i(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=ki.parse(e);if(r)return r}throw new $i(`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=Di.parse(e);if(r)return r}throw new $i(`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=Fi.parse(e);if(r)return r}throw new $i(`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=ji.parse(e);if(r)return r}throw new $i(`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 $i(`Could not convert ${JSON.stringify(e)} to number.`,this.key)}case"formatted":return Ii.fromString(Gi(this.args[0].evaluate(t)));case"resolvedImage":return Oi.fromString(Gi(this.args[0].evaluate(t)));case"projectionDefinition":{let e=this.args[0].evaluate(t);if(Li.parse(e))return e;throw new $i(`Could not parse projectionDefinition from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}default:return Gi(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};const Yi=["Unknown","Point","LineString","Polygon"];var Xi=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?Yi[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=Ei.parse(t),this._parseColorCache.set(t,e)),e}},Ji=class t{constructor(t,e,i=[],r,s=new $e,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 Zi(e,[t],i):"coerce"===r?new Hi(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 Vi)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let e=new Xi;try{i=new Vi(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 Fe(i,t))}checkSubtype(t,e){let i=ti(t,e);return i&&this.error(i),i}},Ki=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()}},Qi=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 tr(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 $i("Input is not a number.",i);a=l-1}return 0}var er=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,je);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[tr(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()))}},ir=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=rr(e,t.base,i,r);else if("linear"===t.name)s=rr(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])(rr(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,je),!n)return null;let a=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==We?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=Be;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 ri(l,je)||ri(l,Ne)||ri(l,Be)||ri(l,Ze)||ri(l,He)||ri(l,We)||ri(l,Xe)||ri(l,Je(je))?new t(l,r,s,n,a,i.key):i.error(`Type ${Ke(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=tr(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 zi(l,h,a);case"color":return Ei.interpolate(l,h,a);case"padding":return ki.interpolate(l,h,a);case"colorArray":return Fi.interpolate(l,h,a);case"numberArray":return Di.interpolate(l,h,a);case"variableAnchorOffsetCollection":return ji.interpolate(l,h,a,this.key);case"array":return Si(l,h,a);case"projectionDefinition":return Li.interpolate(l,h,a)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ei.interpolate(l,h,a,"hcl");case"colorArray":return Fi.interpolate(l,h,a,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ei.interpolate(l,h,a,"lab");case"colorArray":return Fi.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 rr(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 sr={color:Ei.interpolate,number:zi,padding:ki.interpolate,numberArray:Di.interpolate,colorArray:Fi.interpolate,variableAnchorOffsetCollection:ji.interpolate,array:Si};var nr=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=>ti(s,t.type)))?new t(Ge,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 Oi&&!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 or(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 ar(t,e,i,r){return 0===r.compare(e,i)}function lr(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=Le,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,Ge);if(!n)return null;if(!or(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(n.type)}'.`);let o=e.parse(t[2],2,Ge);if(!o)return null;if(!or(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Ke(n.type)}' and '${Ke(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new Zi(o.type,[n],e.key):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new Zi(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,Ve),!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=Ui(n),i=Ui(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new $i(`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=Ui(n),i=Ui(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 hr=lr("==",(function(t,e,i){return e===i}),ar),ur=lr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!ar(0,e,i,r)})),cr=lr("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),fr=lr(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),pr=lr("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),dr=lr(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));var mr=class t{constructor(t,e,i){this.type=Ve,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,Le);if(!s)return null;let n=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Le);if(!n)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,Oe),!o)?null:new t(s,n,o)}evaluate(t){return new Ai(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}},_r=class t{constructor(t){this.type=qe,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,je),!t))return null;let e=null;if(r["text-font"]&&(e=i.parse(r["text-font"],1,Je(Oe)),!e))return null;let o=null;if(r["text-color"]&&(o=i.parse(r["text-color"],1,Be),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!Pi.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,Oe),!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,Ge);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 Ii(this.sections.map((e=>{let i=e.content.evaluate(t);return Ui(i)===Ye?new Ci("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new Ci(Gi(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 gr=8192;function yr(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*gr),Math.round(r*s*gr)]}function vr(t,e){let i=2**e.z,r=(t[1]/gr+e.y)/i;return[wr((t[0]/gr+e.x)/i),br(r)]}function wr(t){return 360*t-180}function br(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function xr(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 Mr(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Tr(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 zr(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 Sr(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]])&&!(!kr(t,e,i,r)||!kr(i,r,t,e))}function Er(t,e,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(Sr(t,e,r[i],r[i+1]))return!0;return!1}function Ar(t,e,i=!1){let r=!1;for(let s of e)for(let e=0;e<s.length-1;e++){if(zr(t,s[e],s[e+1]))return i;Tr(t,s[e],s[e+1])&&(r=!r)}return r}function Pr(t,e){for(let i of e)if(Ar(t,i))return!0;return!1}function Cr(t,e){for(let i of t)if(!Ar(i,e))return!1;for(let i=0;i<t.length-1;++i)if(Er(t[i],t[i+1],e))return!1;return!0}function Ir(t,e){for(let i of e)if(Cr(t,i))return!0;return!1}function kr(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 Dr(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=yr(t[s][r],i);xr(e,o),n.push(o)}r.push(n)}return r}function Fr(t,e,i){let r=[];for(let s=0;s<t.length;s++){let n=Dr(t[s],e,i);r.push(n)}return r}function $r(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}xr(e,t)}function Rr(t,e,i,r){let s=2**r.z*gr,n=[r.x*gr,r.y*gr],o=[];for(let r of t)for(let t of r){let r=[t.x+n[0],t.y+n[1]];$r(r,e,i,s),o.push(r)}return o}function jr(t,e,i,r){let s=2**r.z*gr,n=[r.x*gr,r.y*gr],o=[];for(let i of t){let t=[];for(let r of i){let i=[r.x+n[0],r.y+n[1]];xr(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)$r(r,e,i,s)}return o}var Or=class t{constructor(t,e){this.type=Le,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(Ni(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=Dr(e.coordinates,r,s),o=Rr(t.geometry(),i,r,s);if(!Mr(i,r))return!1;for(let t of o)if(!Ar(t,n))return!1}if("MultiPolygon"===e.type){let n=Fr(e.coordinates,r,s),o=Rr(t.geometry(),i,r,s);if(!Mr(i,r))return!1;for(let t of o)if(!Pr(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=Dr(e.coordinates,r,s),o=jr(t.geometry(),i,r,s);if(!Mr(i,r))return!1;for(let t of o)if(!Cr(t,n))return!1}if("MultiPolygon"===e.type){let n=Fr(e.coordinates,r,s),o=jr(t.geometry(),i,r,s);if(!Mr(i,r))return!1;for(let t of o)if(!Ir(t,n))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Lr=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 Br(t,e,i=0,r=t.length-1,s=Ur){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);Br(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(Nr(t,i,e),s(t[r],n)>0&&Nr(t,i,r);o<a;){for(Nr(t,o,a),o++,a--;s(t[o],n)<0;)o++;for(;s(t[a],n)>0;)a--}0===s(t[i],n)?Nr(t,i,a):(a++,Nr(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Nr(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function Ur(t,e){return t<e?-1:+(t>e)}function Gr(t,e){if(t.length<=1)return[t];let i,r,s=[];for(let e of t){let t=qr(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||(Br(s[t],e,1,s[t].length-1,Vr),s[t]=s[t].slice(0,e));return s}function Vr(t,e){return e.area-t.area}function qr(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 Zr=Math.PI/180;var Wr=class{constructor(t){let e=6378.137*Zr*1e3,i=Math.cos(t*Zr),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 Hr(t,e){return e[0]-t[0]}function Yr(t){return t[1]-t[0]+1}function Xr(t,e){return t[1]>=t[0]&&t[1]<e}function Jr(t,e){if(t[0]>t[1])return[null,null];let i=Yr(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 Kr(t,e){if(!Xr(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)xr(i,t[r]);return i}function Qr(t){let e=[1/0,1/0,-1/0,-1/0];for(let i of t)for(let t of i)xr(e,t);return e}function ts(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function es(t,e,i){if(!ts(t)||!ts(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 is(t,e,i){let r=i.pointOnLine(e,t);return i.distance(t,r.point)}function rs(t,e,i,r,s){let n=Math.min(is(t,[i,r],s),is(e,[i,r],s)),o=Math.min(is(i,[t,e],s),is(r,[t,e],s));return Math.min(n,o)}function ss(t,e,i,r,s){if(!Xr(e,t.length)||!Xr(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(Sr(e,a,r,o))return 0;n=Math.min(n,rs(e,a,r,o,s))}}return n}function ns(t,e,i,r,s){if(!Xr(e,t.length)||!Xr(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 os(t,e,i){if(Ar(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,is(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 as(t,e,i,r){if(!Xr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(Ar(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(Sr(e,o,n,l))return 0;s=Math.min(s,rs(e,o,n,l,r))}}return s}function ls(t,e){for(let i of t)for(let t of i)if(Ar(t,e,!0))return!0;return!1}function hs(t,e,i,r=1/0){let s=Qr(t),n=Qr(e);if(r!==1/0&&es(s,n,i)>=r)return r;if(Mr(s,n)){if(ls(t,e))return 0}else if(ls(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(Sr(s,a,r,l))return 0;o=Math.min(o,rs(s,a,r,l,i))}}return o}function us(t,e,i,r,s,n){if(!n)return;let o=es(Kr(r,n),s,i);o<e&&t.push([o,n,[0,0]])}function cs(t,e,i,r,s,n,o){if(!n||!o)return;let a=es(Kr(r,n),Kr(s,o),i);a<e&&t.push([a,n,o])}function fs(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 Lr([[0,[0,t.length-1],[0,0]]],Hr),a=Qr(i);for(;o.length>0;){let s=o.pop();if(s[0]>=n)continue;let l=s[1],h=e?50:100;if(Yr(l)<=h){if(!Xr(l,t.length))return NaN;if(e){let e=as(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=os(t[e],i,r);if(n=Math.min(n,s),0===n)return 0}}else{let i=Jr(l,e);us(o,n,r,t,a,i[0]),us(o,n,r,t,a,i[1])}}return n}function ps(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 Lr([[0,[0,t.length-1],[0,i.length-1]]],Hr);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(Yr(l)<=u&&Yr(h)<=c){if(!Xr(l,t.length)&&Xr(h,i.length))return NaN;let n;if(e&&r)n=ss(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=is(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=is(t[i],e,s),o=Math.min(o,n),0===o)return o}else n=ns(t,l,i,h,s),o=Math.min(o,n)}else{let n=Jr(l,e),u=Jr(h,r);cs(a,o,s,t,i,n[0],u[0]),cs(a,o,s,t,i,n[0],u[1]),cs(a,o,s,t,i,n[1],u[0]),cs(a,o,s,t,i,n[1],u[1])}}return o}function ds(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 ms=class t{constructor(t,e){this.type=je,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(Ni(e[1])){let i=e[1];if("FeatureCollection"===i.type)return new t(i,i.features.map((t=>ds(t.geometry))).flat());if("Feature"===i.type)return new t(i,ds(i.geometry));if("type"in i&&"coordinates"in i)return new t(i,ds(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=>vr([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let s=new Wr(r[0][1]),n=1/0;for(let t of e){switch(t.type){case"Point":n=Math.min(n,ps(r,!1,[t.coordinates],!1,s,n));break;case"LineString":n=Math.min(n,ps(r,!1,t.coordinates,!0,s,n));break;case"Polygon":n=Math.min(n,fs(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=>vr([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let s=new Wr(r[0][1]),n=1/0;for(let t of e){switch(t.type){case"Point":n=Math.min(n,ps(r,!0,[t.coordinates],!1,s,n));break;case"LineString":n=Math.min(n,ps(r,!0,t.coordinates,!0,s,n));break;case"Polygon":n=Math.min(n,fs(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=Gr(i,0).map((e=>e.map((e=>e.map((e=>vr([e.x,e.y],t.canonical))))))),s=new Wr(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,fs([t.coordinates],!1,e,s,n));break;case"LineString":n=Math.min(n,fs(t.coordinates,!0,e,s,n));break;case"Polygon":n=Math.min(n,hs(e,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},_s=class t{constructor(t){this.key=t,this.type=Ge}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?vi(e,this.key)??null:null}eachChild(){}outputDefined(){return!1}};const gs={"==":hr,"!=":ur,">":fr,"<":cr,">=":dr,"<=":pr,array:Zi,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,je),s=i.parse(e[2],2,Je(i.expectedType||Ge));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 $i(`Array index out of bounds: ${e} < 0.`,this.key);if(e>=i.length)throw new $i(`Array index out of bounds: ${e} > ${i.length-1}.`,this.key);if(e!==Math.floor(e))throw new $i(`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:Zi,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,Le);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:nr,collator:mr,format:_r,image:class t{constructor(t){this.type=Ye,this.input=t}static parse(e,i){if(2!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,Oe);return r?new t(r):i.error("No image name provided.")}evaluate(t){let e=this.input.evaluate(t),i=Oi.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=Le}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,Ge),s=i.parse(e[2],2,Ge);return r&&s?ei(r.type,[Le,Oe,je,Re,Ge])?new t(r,s,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(r.type)} instead`):null}evaluate(t){let e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!ii(e,["boolean","string","number","null"]))throw new $i(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Ui(e))} instead.`,this.key);if(!ii(i,["string","array"]))throw new $i(`Expected second argument to be of type array or string, but found ${Ke(Ui(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=je}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,Ge),s=i.parse(e[2],2,Ge);if(!r||!s)return null;if(!ei(r.type,[Le,Oe,je,Re,Ge]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(r.type)} instead`);if(4===e.length){let n=i.parse(e[3],3,je);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(!ii(i,["boolean","string","number","null"]))throw new $i(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Ui(i))} instead.`,this.key);if(this.fromIndex&&(e=this.fromIndex.evaluate(t)),ii(r,["string"])){let t=r.indexOf(i,e);return-1===t?-1:[...r.slice(0,t)].length}if(ii(r,["array"]))return r.indexOf(i,e);throw new $i(`Expected second argument to be of type array or string, but found ${Ke(Ui(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:ir,"interpolate-hcl":ir,"interpolate-lab":ir,length:class t{constructor(t,e){this.input=t,this.key=e,this.type=je}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 ${Ke(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 $i(`Expected value to be of type string or array, but found ${Ke(Ui(e))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:Ki,literal:Vi,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,Ui(t)))return null}else r=Ui(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,Ge);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(Ui(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:Zi,"number-format":class t{constructor(t,e,i,r,s,n){this.type=Oe,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,je);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,Oe),!n))return null;let o=null;if(s.currency&&(o=i.parse(s.currency,1,Oe),!o))return null;let a=null;if(s.unit&&(a=i.parse(s.unit,1,Oe),!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,je),!l))return null;let h=null;return s["max-fraction-digits"]&&(h=i.parse(s["max-fraction-digits"],1,je),!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:Zi,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,Ge),s=i.parse(e[2],2,je);if(!r||!s)return null;if(!ei(r.type,[Je(Ge),Oe,Ge]))return i.error(`Expected first argument to be of type array or string, but found ${Ke(r.type)} instead`);if(4===e.length){let n=i.parse(e[3],3,je);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)),ii(i,["string"]))return[...i].slice(r,e).join("");if(ii(i,["array"]))return i.slice(r,e);throw new $i(`Expected first argument to be of type array or string, but found ${Ke(Ui(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:er,string:Zi,"to-boolean":Hi,"to-color":Hi,"to-number":Hi,"to-string":Hi,var:Qi,within:Or,distance:ms,"global-state":_s};var ys=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 Ji(i.registry,Ms,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(Ke).join(", ")})`:`(${Ke(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(Ke(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 vs(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=Bi(e,i,r,o);if(a)throw new $i(a,n);return new Ei(e/255,i/255,r/255,o,!1)}function ws(t,e){return t in e&&void 0!==e[t]}function bs(t,e){let i=e[t];return void 0===i?null:i}function xs(t){return{type:t}}function Ms(t){if(t instanceof Qi)return Ms(t.boundExpression);if(t instanceof ys&&"error"===t.name||t instanceof mr||t instanceof Or||t instanceof ms||t instanceof _s)return!1;let e=t instanceof Hi||t instanceof Zi,i=!0;return t.eachChild((t=>{i&&=e?Ms(t):t instanceof Vi})),!!i&&Ts(t)&&Ss(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Ts(t){if(t instanceof ys&&("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 Or||t instanceof ms)return!1;let e=!0;return t.eachChild((t=>{e&&!Ts(t)&&(e=!1)})),e}function zs(t){if(t instanceof ys&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!zs(t)&&(e=!1)})),e}function Ss(t,e){if(t instanceof ys&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ss(t,e)&&(i=!1)})),i}function Es(t){return{result:"success",value:t}}function As(t){return{result:"error",value:t}}function Ps(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Cs(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Is(t){return!!t.expression&&t.expression.interpolated}function ks(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function Ds(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Fs(t){return"object"==typeof t&&!!t&&!Array.isArray(t)&&Ui(t)===Ue}function $s(t){return t}function Rs(t,e){let i=t.stops&&"object"==typeof t.stops[0][0],r=i||!(i||void 0!==t.property),s=t.type||(Is(e)?"exponential":"interval"),n=function(t){switch(t.type){case"color":return Ei.parse;case"padding":return ki.parse;case"numberArray":return Di.parse;case"colorArray":return Fi.parse;default:return null}}(e);if(n&&((t=ks({},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 Bs;case"interval":return Ls;case"categorical":return Os;case"identity":return Ns;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,Rs(i[t],e)]);let n={name:"linear"};return{kind:"composite",interpolationType:n,interpolationFactor:ir.interpolationFactor.bind(void 0,n),zoomStops:s.map((t=>t[0])),evaluate:({zoom:i},r)=>Bs({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:ir.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?js(t.default,e.default):l(t,e,s,o,a)}}}function js(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Os(t,e,i,r,s){return js(typeof i===s?r[i]:void 0,t.default,e.default)}function Ls(t,e,i){if("number"!==Ds(i))return js(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=tr(t.stops.map((t=>t[0])),i,"");return t.stops[s][1]}function Bs(t,e,i){let r=void 0===t.base?1:t.base;if("number"!==Ds(i))return js(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=tr(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=sr[e.type]||$s;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 Ns(t,e,i){switch(e.type){case"color":i=Ei.parse(i);break;case"formatted":i=Ii.fromString(i.toString());break;case"resolvedImage":i=Oi.fromString(i.toString());break;case"padding":i=ki.parse(i);break;case"colorArray":i=Fi.parse(i);break;case"numberArray":i=Di.parse(i);break;default:Ds(i)!==e.type&&("enum"!==e.type||!e.values[i])&&(i=void 0)}return js(i,t.default,e.default)}ys.register(gs,{error:[{kind:"error"},[Oe],(t,[e],i)=>{throw new $i(e.evaluate(t),i)}],typeof:[Oe,[Ge],(t,[e])=>Ke(Ui(e.evaluate(t)))],"to-rgba":[Je(je,4),[Be],(t,[e])=>{let[i,r,s,n]=e.evaluate(t).rgb;return[255*i,255*r,255*s,n]}],rgb:[Be,[je,je,je],vs],rgba:[Be,[je,je,je,je],vs],has:{type:Le,overloads:[[[Oe],(t,[e])=>ws(e.evaluate(t),t.properties())],[[Oe,Ue],(t,[e,i])=>ws(e.evaluate(t),i.evaluate(t))]]},get:{type:Ge,overloads:[[[Oe],(t,[e])=>bs(e.evaluate(t),t.properties())],[[Oe,Ue],(t,[e,i])=>bs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Ge,[Oe],(t,[e])=>bs(e.evaluate(t),t.featureState||{})],properties:[Ue,[],t=>t.properties()],"geometry-type":[Oe,[],t=>t.geometryType()],id:[Ge,[],t=>t.id()],zoom:[je,[],t=>t.globals.zoom],"heatmap-density":[je,[],t=>t.globals.heatmapDensity||0],elevation:[je,[],t=>t.globals.elevation||0],"line-progress":[je,[],t=>t.globals.lineProgress||0],accumulated:[Ge,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[je,xs(je),(t,e)=>{let i=0;for(let r of e)i+=r.evaluate(t);return i}],"*":[je,xs(je),(t,e)=>{let i=1;for(let r of e)i*=r.evaluate(t);return i}],"-":{type:je,overloads:[[[je,je],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[je],(t,[e])=>-e.evaluate(t)]]},"/":[je,[je,je],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[je,[je,je],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[je,[],()=>Math.LN2],pi:[je,[],()=>Math.PI],e:[je,[],()=>Math.E],"^":[je,[je,je],(t,[e,i])=>e.evaluate(t)**+i.evaluate(t)],sqrt:[je,[je],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[je,[je],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[je,[je],(t,[e])=>Math.log(e.evaluate(t))],log2:[je,[je],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[je,[je],(t,[e])=>Math.sin(e.evaluate(t))],cos:[je,[je],(t,[e])=>Math.cos(e.evaluate(t))],tan:[je,[je],(t,[e])=>Math.tan(e.evaluate(t))],asin:[je,[je],(t,[e])=>Math.asin(e.evaluate(t))],acos:[je,[je],(t,[e])=>Math.acos(e.evaluate(t))],atan:[je,[je],(t,[e])=>Math.atan(e.evaluate(t))],min:[je,xs(je),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[je,xs(je),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[je,[je],(t,[e])=>Math.abs(e.evaluate(t))],round:[je,[je],(t,[e])=>{let i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[je,[je],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[je,[je],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Le,[Oe,Ge],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Le,[Ge],(t,[e])=>t.id()===e.value],"filter-type-==":[Le,[Oe],(t,[e])=>t.geometryType()===e.value],"filter-<":[Le,[Oe,Ge],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<s}],"filter-id-<":[Le,[Ge],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Le,[Oe,Ge],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[Le,[Ge],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Le,[Oe,Ge],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[Le,[Ge],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Le,[Oe,Ge],(t,[e,i])=>{let r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[Le,[Ge],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Le,[Ge],(t,[e])=>{let i=e.value,r=t.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[Le,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Le,[Je(Oe)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Le,[Je(Ge)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Le,[Oe,Je(Ge)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Le,[Oe,Je(Ge)],(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:Le,overloads:[[[Le,Le],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[xs(Le),(t,e)=>{for(let i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Le,overloads:[[[Le,Le],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[xs(Le),(t,e)=>{for(let i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Le,[Le],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Le,[Oe],(t,[e])=>{let i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Oe,[Oe],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Oe,[Oe],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Oe,xs(Ge),(t,e)=>e.map((e=>Gi(e.evaluate(t)))).join("")],split:[Je(Oe),[Oe,Oe],(t,[e,i])=>e.evaluate(t).split(i.evaluate(t))],join:[Oe,[Je(Oe),Oe],(t,[e,i])=>e.evaluate(t).join(i.evaluate(t))],"resolved-locale":[Oe,[Ve],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Us=class{constructor(t,e,i,r){this.expression=t,this._warningHistory={},this._evaluator=new Xi,this._defaultValue=i?Qs(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=tn(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=tn(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 $i(`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 $i?t.path:"",i=`${e}|${t.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Gs(this._rootKey,e,t.message,this._defaultValue))),this._defaultValue}}};function Gs(t,e,i,r){return`${t}${e}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function Vs(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 qs(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in gs}function Zs(t,e,i,r){Vs(e);let s=new Ji(gs,Ms,[],i?function(t){let e={color:Be,string:Oe,number:je,enum:Oe,boolean:Le,formatted:qe,padding:Ze,numberArray:He,colorArray:We,projectionDefinition:Ne,resolvedImage:Ye,variableAnchorOffsetCollection:Xe};return"array"===t.type?Je(e[t.value]||Ge,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?Es(new Us(n,e,i,r)):As(s.errors)}var Ws=class{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!zs(e.expression),this.globalStateRefs=Ks(e.expression),this._globalState=i}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._globalState&&(t=tn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._globalState&&(t=tn(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,s,n)}},Hs=class{constructor(t,e,i,r,s){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!zs(e.expression),this.globalStateRefs=Ks(e.expression),this.interpolationType=r,this._globalState=s}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._globalState&&(t=tn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._globalState&&(t=tn(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,s,n)}interpolationFactor(t,e,i){return this.interpolationType?ir.interpolationFactor(this.interpolationType,t,e,i):0}};function Ys(t,e,i,r){let s=Zs(t,e,i,r);if("error"===s.result)return s;let n=s.value.expression,o=Ts(n);if(!o&&!Ps(i))return As([new Fe("","data expressions not supported")]);let a=Ss(n,["zoom"]);if(!a&&!Cs(i))return As([new Fe("","zoom expressions not supported")]);let l=Js(n);return l||a?l instanceof Fe?As([l]):l instanceof ir&&!Is(i)?As([new Fe("",'"interpolate" expressions cannot be used with this property')]):Es(l?new Hs(o?"camera":"composite",s.value,l.labels,l instanceof ir?l.interpolation:void 0,r):new Ws(o?"constant":"source",s.value,r)):As([new Fe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}var Xs=class t{constructor(t,e,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Vs(e),this._parameters=t,this._specification=i,this._rootKey=e,this._defaultValue=Qs(i),this._warningHistory={};let r=Rs(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(Gs(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 Js(t){let e=null;if(t instanceof Ki)e=Js(t.result);else if(t instanceof nr){for(let i of t.args)if(e=Js(i),e)break}else(t instanceof er||t instanceof ir)&&t.input instanceof ys&&"zoom"===t.input.name&&(e=t);return e instanceof Fe||t.eachChild((t=>{let i=Js(t);i instanceof Fe?e=i:!e&&i?e=new Fe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Fe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Ks(t,e=new Set){return t instanceof _s&&e.add(t.key),t.eachChild((t=>{Ks(t,e)})),e}function Qs(t){if("color"===t.type&&Fs(t.default))return new Ei(0,0,0,0);switch(t.type){case"color":return Ei.parse(t.default)||null;case"padding":return ki.parse(t.default)||null;case"numberArray":return Di.parse(t.default)||null;case"colorArray":return Fi.parse(t.default)||null;case"variableAnchorOffsetCollection":return ji.parse(t.default)||null;case"projectionDefinition":return Li.parse(t.default)||null;default:return void 0===t.default?null:t.default}}function tn(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 en(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=en(i);if("expression"===t)return"expression";"legacy"===t&&(e=!0)}return e?"legacy":"neutral"}(t.slice(1));default:return"expression"}}function rn(t){return"legacy"!==en(t)}function sn(t){return"$type"===t?["geometry-type"]:"$id"===t?["id"]:["get",t]}function nn(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],sn(t[1]),t[2]];case"in":case"!in":{if(t.length<2||"string"!=typeof t[1])return null;let e=["in",sn(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 on(t,e,i){let r=i[t];return Array.isArray(r)?rn(r)?an(r,e.concat(t)):{path:e.concat(t),legacyFilter:r}:null}function an(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=on(i,e,t);if(r)return r}break;case"!":{let i=on(1,e,t);if(i)return i;break}case"case":for(let i=1;i<t.length-1;i+=2){let r=on(i,e,t);if(r)return r}}return null}const ln={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function hn(t,e,i){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};rn(t)?function(t,e){let i=an(t);if(!i||typeof console>"u")return;let r=i.path.map((t=>`[${t}]`)).join("");console.warn(`${e}${r}: ${nn(i.legacyFilter)}`)}(t,e):t=fn(t);let r=Zs(t,e,ln,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:cn(t),getGlobalStateRefs:()=>Ks(r.value.expression)}}function un(t,e){return t<e?-1:+(t>e)}function cn(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(cn(t[e]))return!0;return!1}function fn(t){if(!t)return!0;let e=t[0];return t.length<=1?"any"!==e:"=="===e?pn(t[1],t[2],"=="):"!="===e?_n(pn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?pn(t[1],t[2],e):"any"===e?function(t){return["any"].concat(t.map(fn))}(t.slice(1)):"all"===e?["all"].concat(t.slice(1).map(fn)):"none"===e?["all"].concat(t.slice(1).map(fn).map(_n)):"in"===e?dn(t[1],t.slice(2)):"!in"===e?_n(dn(t[1],t.slice(2))):"has"===e?mn(t[1]):"!has"!==e||_n(mn(t[1]))}function pn(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 dn(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(un)]]:["filter-in-small",t,["literal",e]]}}function mn(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function _n(t){return["!",t]}function gn(t){let e=t.value;return e?[new De(t.key,e,"constants have been deprecated as of v8")]:[]}function yn(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function vn(t){if(Array.isArray(t))return t.map(vn);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let e={};for(let i in t)e[i]=vn(t[i]);return e}return yn(t)}function wn(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=Ds(i);if("object"!==h)return[new De(e,i,`object expected, ${h} found`)];for(let t in i){let h,u=t.split(".")[0],c=vi(r,u)||r["*"];if(vi(s,u))h=s[u];else if(vi(r,u)){if(void 0===i[t])continue;h=a}else if(s["*"])h=s["*"];else{if(!r["*"]){l.push(new De(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 De(e,i,`missing required property "${t}"`));return l}function bn(t){let e=t.value,i=t.valueSpec,r=t.style,s=t.styleSpec,n=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==Ds(e))return[new De(n,e,`array expected, ${Ds(e)} found`)];if(i.length&&e.length!==i.length)return[new De(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"===Ds(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 xn(t){let e=t.key,i=t.value,r=t.valueSpec,s=Ds(i);return"number"===s&&i!=i&&(s="NaN"),"number"===s?"minimum"in r&&i<r.minimum?[new De(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new De(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new De(e,i,`number expected, ${s} found`)]}function Mn(t){let e,i,r,s=t.valueSpec,n=yn(t.value.type),o={},a="categorical"!==n&&void 0===t.value.property,l=!a,h="array"===Ds(t.value.stops)&&"array"===Ds(t.value.stops[0])&&"object"===Ds(t.value.stops[0][0]),u=wn({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 De(t.key,t.value,'identity function may not have a "stops" property')];let e=[],i=t.value;return e=e.concat(bn({key:t.key,value:i,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:c})),"array"===Ds(i)&&0===i.length&&e.push(new De(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 De(t.key,t.value,'missing required property "property"')),"identity"!==n&&!t.value.stops&&u.push(new De(t.key,t.value,'missing required property "stops"')),"exponential"===n&&t.valueSpec.expression&&!Is(t.valueSpec)&&u.push(new De(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Ps(t.valueSpec)?u.push(new De(t.key,t.value,"property functions not supported")):a&&!Cs(t.valueSpec)&&u.push(new De(t.key,t.value,"zoom functions not supported"))),("categorical"===n||h)&&void 0===t.value.property&&u.push(new De(t.key,t.value,'"property" property is required')),u;function c(t){let e=[],n=t.value,a=t.key;if("array"!==Ds(n))return[new De(a,n,`array expected, ${Ds(n)} found`)];if(2!==n.length)return[new De(a,n,`array length 2 expected, length ${n.length} found`)];if(h){if("object"!==Ds(n[0]))return[new De(a,n,`object expected, ${Ds(n[0])} found`)];if(void 0===n[0].zoom)return[new De(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new De(a,n,"object stop key must have value")];if(r&&r>yn(n[0].zoom))return[new De(a,n[0].zoom,"stop zoom values must appear in ascending order")];yn(n[0].zoom)!==r&&(r=yn(n[0].zoom),i=void 0,o={}),e=e.concat(wn({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:xn,value:f}}))}else e=e.concat(f({key:`${a}[0]`,value:n[0]},n));return qs(vn(n[1]))?e.concat([new De(`${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=Ds(t.value),l=yn(t.value),h=null===t.value?r:t.value;if(e){if(a!==e)return[new De(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 De(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 Ps(s)&&void 0===n&&(e+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new De(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 De(t.key,h,"stop domain values must appear in ascending order")]:(i=l,"categorical"===n&&l in o?[new De(t.key,h,"stop domain values must be unique")]:(o[l]=!0,[])):[new De(t.key,h,`integer expected, found ${l}`)]}}function Tn(t){let e=("property"===t.expressionContext?Ys:Zs)(vn(t.value),t.key,t.valueSpec);if("error"===e.result)return e.value.map((e=>new De(`${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 De(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&&!zs(i))return[new De(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!zs(i))return[new De(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Ss(i,["zoom","feature-state"]))return[new De(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Ts(i))return[new De(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function zn(t){let e=t.key,i=t.value,r=Ds(i);return"string"===r?Ei.parse(String(i))?[]:[new De(e,i,`color expected, "${i}" found`)]:[new De(e,i,`color expected, ${r} found`)]}function Sn(t){let e=t.key,i=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(yn(i))&&s.push(new De(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(yn(i))&&s.push(new De(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function En(t,e){let i=t;for(let t of e)i=i[t];return i}function An(t,e){let i=an(e);return i?[new De(`${t.key}${i.path.map((t=>`[${t}]`)).join("")}`,En(t.value,i.path),nn(i.legacyFilter),null,"warning")]:[]}function Pn(t){let e=vn(t.value);return rn(e)?[...An(t,e),...Tn(ks({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:Cn(t)}function Cn(t){let e=t.value,i=t.key;if("array"!==Ds(e))return[new De(i,e,`array expected, ${Ds(e)} found`)];let r,s=t.styleSpec,n=[];if(e.length<1)return[new De(i,e,"filter array must have at least 1 element")];switch(n=n.concat(Sn({key:`${i}[0]`,value:e[0],valueSpec:s.filter_operator})),yn(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===yn(e[1])&&n.push(new De(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new De(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(r=Ds(e[1]),"string"!==r&&n.push(new De(`${i}[1]`,e[1],`string expected, ${r} found`)));for(let t=2;t<e.length;t++)r=Ds(e[t]),"$type"===yn(e[1])?n=n.concat(Sn({key:`${i}[${t}]`,value:e[t],valueSpec:s.geometry_type})):"string"!==r&&"number"!==r&&"boolean"!==r&&n.push(new De(`${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(Cn({key:`${i}[${r}]`,value:e[r],styleSpec:t.styleSpec}));break;case"has":case"!has":r=Ds(e[1]),2===e.length?"string"!==r&&n.push(new De(`${i}[1]`,e[1],`string expected, ${r} found`)):n.push(new De(i,e,`filter array for "${e[0]}" operator must have 2 elements`))}return n}function In(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 De(i,o,`unknown property "${a}"`)];if("string"===Ds(o)&&Ps(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new De(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&&Fs(vn(o))&&"identity"===yn(o.type)&&f.push(new De(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 kn(t){return In(t,"paint")}function Dn(t){return In(t,"layout")}function Fn(t){let e=[],i=t.value,r=t.key,s=t.style,n=t.styleSpec;if("object"!==Ds(i))return[new De(r,i,`object expected, ${Ds(i)} found`)];!i.type&&!i.ref&&e.push(new De(r,i,'either "type" or "ref" is required'));let o=yn(i.type),a=yn(i.ref);if(i.id){let n=yn(i.id);for(let o=0;o<t.arrayIndex;o++){let t=s.layers[o];yn(t.id)===n&&e.push(new De(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 De(r,i[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{yn(e.id)===a&&(t=e)})),t?t.ref?e.push(new De(r,i.ref,"ref cannot reference another ref layer")):o=yn(t.type):e.push(new De(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&&yn(t.type);t?"vector"===n&&"raster"===o?e.push(new De(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===o||"raster-dem"!==n&&"color-relief"===o?e.push(new De(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==o?e.push(new De(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 De(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 De(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new De(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new De(r,i.source,`source "${i.source}" not found`))}else e.push(new De(r,i,'missing required property "source"'));return"raster"===o&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&e.push(new De(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(wn({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:Pn,layout:t=>wn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Dn(ks({layerType:o},t))}}),paint:t=>wn({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>kn(ks({layerType:o},t))}})}})),e}function $n(t){let e=t.value,i=t.key,r=Ds(e);return"string"===r?[]:[new De(i,e,`string expected, ${r} found`)]}const Rn={promoteId:function({key:t,value:e}){if("string"===Ds(e))return $n({key:t,value:e});{let i=[];for(let r in e)i.push(...$n({key:`${t}.${r}`,value:e[r]}));return i}}};function jn(t){let e=t.value,i=t.key,r=t.styleSpec,s=t.style,n=t.validateSpec;if(!e.type)return[new De(i,e,'"type" is required')];let o,a=yn(e.type);switch(a){case"vector":case"raster":return o=wn({key:i,value:e,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Rn,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=Ds(i);if(void 0===i)return o;if("object"!==a)return o.push(new De("source_raster_dem",i,`object expected, ${a} found`)),o;let l="custom"===yn(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 De(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 De(a,i[a],`unknown property "${a}"`));return o}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=wn({key:i,value:e,valueSpec:r.source_geojson,style:s,styleSpec:r,validateSpec:n,objectElementValidators:Rn}),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(...Tn({key:`${i}.${t}.map`,value:s,expressionContext:"cluster-map"})),o.push(...Tn({key:`${i}.${t}.reduce`,value:n,expressionContext:"cluster-reduce"}))}return o;case"video":return wn({key:i,value:e,valueSpec:r.source_video,style:s,validateSpec:n,styleSpec:r});case"image":return wn({key:i,value:e,valueSpec:r.source_image,style:s,validateSpec:n,styleSpec:r});case"canvas":return[new De(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Sn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function On(t){let e=t.value,i=t.styleSpec,r=i.light,s=t.style,n=[],o=Ds(e);if(void 0===e)return n;if("object"!==o)return n=n.concat([new De("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 De(o,e[o],`unknown property "${o}"`)])}return n}function Ln(t){let e=t.value,i=t.styleSpec,r=i.sky,s=t.style,n=Ds(e);if(void 0===e)return[];if("object"!==n)return[new De("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 De(n,e[n],`unknown property "${n}"`)]);return o}function Bn(t){let e=t.value,i=t.styleSpec,r=i.terrain,s=t.style,n=[],o=Ds(e);if(void 0===e)return n;if("object"!==o)return n=n.concat([new De("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 De(o,e[o],`unknown property "${o}"`)]);return n}function Nn(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 De(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 De(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),n.push(i[o].url),e=e.concat(wn({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return $n({key:r,value:i})}function Un(t){return!!t&&t.constructor===Object}function Gn(t){return Un(t.value)?[]:[new De(t.key,t.value,`object expected, ${Ds(t.value)} found`)]}const Vn={"*":()=>[],array:bn,boolean:function(t){let e=t.value,i=t.key,r=Ds(e);return"boolean"===r?[]:[new De(i,e,`boolean expected, ${r} found`)]},number:xn,color:zn,constants:gn,enum:Sn,filter:Pn,function:Mn,layer:Fn,object:wn,source:jn,light:On,sky:Ln,terrain:Bn,projection:function(t){let e=t.value,i=t.styleSpec,r=i.projection,s=t.style,n=Ds(e);if(void 0===e)return[];if("object"!==n)return[new De("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 De(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=Ds(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 De(e,i,`projection expected, invalid type "${r}" found`)]:[new De(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:$n,formatted:function(t){return 0===$n(t).length?[]:Tn(t)},resolvedImage:function(t){return 0===$n(t).length?[]:Tn(t)},padding:function(t){let e=t.key,i=t.value;if("array"===Ds(i)){if(i.length<1||i.length>4)return[new De(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 xn({key:e,value:i,valueSpec:{}})},numberArray:function(t){let e=t.key,i=t.value;if("array"===Ds(i)){let r={type:"number"};if(i.length<1)return[new De(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 xn({key:e,value:i,valueSpec:{}})},colorArray:function(t){let e=t.key,i=t.value;if("array"===Ds(i)){if(i.length<1)return[new De(e,i,"array length at least 1 expected, length 0 found")];let t=[];for(let r=0;r<i.length;r++)t=t.concat(zn({key:`${e}[${r}]`,value:i[r]}));return t}return zn({key:e,value:i})},variableAnchorOffsetCollection:function(t){let e=t.key,i=t.value,r=Ds(i),s=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new De(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(Sn({key:`${e}[${r}]`,value:i[r],valueSpec:s.layout_symbol["text-anchor"]})),n=n.concat(bn({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:s}));return n},sprite:Nn,state:Gn,fontFaces:function(t){let e=t.key,i=t.value,r=t.validateSpec,s=t.styleSpec,n=t.style;if(!Un(i))return[new De(e,i,`object expected, ${Ds(i)} found`)];let o=[];for(let t in i){let a=i[t],l=Ds(a);if("string"===l)o.push(...$n({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(...wn({key:`${e}.${t}[${l}]`,value:h,valueSpec:i,styleSpec:s,style:n,validateSpec:r}))}else o.push(new De(`${e}.${t}`,a,`string or array expected, ${l} found`))}return o}};function qn(t){let e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=qn,i.expression&&Fs(yn(e))?Mn(t):i.expression&&qs(vn(e))?Tn(t):i.type&&Vn[i.type]?Vn[i.type](t):wn(ks({},t,{valueSpec:i.type?r[i.type]:i}))}function Zn(t){let e=t.value,i=t.key,r=$n(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new De(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new De(i,e,'"glyphs" url must include a "{range}" token'))),r}function Wn(t,e=we){let i=[];return i=i.concat(qn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:qn,objectElementValidators:{glyphs:Zn,"*":()=>[]}})),t.constants&&(i=i.concat(gn({key:"constants",value:t.constants}))),Yn(i)}function Hn(t){return function(e){return t(Object.assign({},e,{validateSpec:qn}))}}function Yn(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Xn(t){return function(...e){return Yn(t.apply(this,e))}}Wn.source=Xn(Hn(jn)),Wn.sprite=Xn(Hn(Nn)),Wn.glyphs=Xn(Hn(Zn)),Wn.light=Xn(Hn(On)),Wn.sky=Xn(Hn(Ln)),Wn.terrain=Xn(Hn(Bn)),Wn.state=Xn(Hn(Gn)),Wn.layer=Xn(Hn(Fn)),Wn.filter=Xn(Hn(Pn)),Wn.paintProperty=Xn(Hn(kn)),Wn.layoutProperty=Xn(Hn(Dn));const Jn={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var Kn=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=Zs(t,this._rootKey,Jn,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=Ks(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};const Qn=Wn,to=new Set(Object.keys(we).filter((t=>t.startsWith("source_"))).map((t=>t.slice(7).replaceAll("_","-"))));function eo(t,e){let i=function(t){return Object.entries(t.sources??{}).filter((([,t])=>!to.has(t.type))).map((([t])=>`sources.${t}`))}(e);return io(t,Qn(e).filter((({message:t})=>!i.some((e=>t.startsWith(`${e}:`)||t.startsWith(`${e}.`))))))}function io(t,e){let i=!1;for(let r of e)"warning"!==r.severity?(t.fire(new ye(Error(r.message))),i=!0):Rt(r.message);return i}function ro(t,e,i,r){return!1!==r?.validate&&io(t,e({styleSpec:we,...i}))}var so=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 no={};function oo(t,e,i={}){if(no[t])throw Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),no[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}oo("Object",Object),oo("Set",Set),oo("TransferableGridIndex",so),oo("Color",Ei),oo("Error",Error),oo("AJAXError",ue),oo("ResolvedImage",Oi),oo("StylePropertyFunction",Xs),oo("StyleExpression",Us,{omit:["_evaluator"]}),oo("ZoomDependentExpression",Hs),oo("ZoomConstantExpression",Ws),oo("CompoundExpression",ys,{omit:["_evaluate"]});for(let t in gs)gs[t]._classRegistryKey||oo(`Expression_${t}`,gs[t]);function ao(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||"ArrayBuffer"===t.constructor?.name)}function lo(t){return t.$name||t.constructor._classRegistryKey}function ho(t){return!function(t){if("object"!=typeof t||!t)return!1;let e=lo(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||ao(t)||Nt(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function uo(t,e){if(ho(t))return(ao(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(uo(r,e));return i}if("object"!=typeof t)throw Error("can't serialize object of type "+typeof t);let i=lo(t);if(!i)throw Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!no[i])throw Error(`${i} is not registered.`);let{klass:r}=no[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)||no[i].omit.includes(r))continue;let n=t[r];void 0!==n&&(s[r]=no[i].shallow.includes(r)?n:uo(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 co(t){if(ho(t))return t;if(Array.isArray(t))return t.map(co);if("object"!=typeof t)throw Error("can't deserialize object of type "+typeof t);let e=lo(t)||"Object";if(!no[e])throw Error(`can't deserialize unregistered class ${e}`);let{klass:i}=no[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]=no[e].shallow.includes(i)?s:co(s)}return r}var fo=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 po(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 mo(t){for(let e of t)if(po(e.codePointAt(0)))return!0;return!1}function _o(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")}_o(["Arab","Dupl","Mong","Ougr","Syrc"]);const go=_o("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 yo(t){return go.test(String.fromCodePoint(t))}function vo(t,e){return!(!e&&yo(t)||function(t){return/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(t))}(t))}function wo(t){for(let e of t)if(yo(e.codePointAt(0)))return!0;return!1}const bo=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(bo.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 xo=class{constructor(t,e){this.isSupportedScript=Mo,this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new fo,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new fo,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 Mo(t){return function(t,e){for(let i of t)if(!vo(i.codePointAt(0),e))return!1;return!0}(t,"loaded"===bo.getRTLTextPluginStatus())}var To=class{constructor(t,e,i,r){this.property=t,this.value=e,this.expression=function(t,e,i,r){if(Fs(t))return new Xs(t,e,i);if(qs(t)){let s=Ys(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=Ei.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=ji.parse(t):"projectionDefinition"===i.type&&"string"==typeof t&&(e=Li.parse(t)):e=Fi.parse(t):e=Di.parse(t):e=ki.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)}},zo=class{constructor(t,e,i){this.property=t,this.value=new To(t,void 0,e,i)}transitioned(t,e){return new Eo(this.property,this.value,e,Tt({},t.transition,this.transition),t.now)}untransitioned(){return new Eo(this.property,this.value,null,{},0)}},So=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 zo(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new To(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 zo(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 Ao(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 Ao(this._properties);for(let e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}},Eo=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))}}},Ao=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){let r=new Io(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}},Po=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 To(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 Io(this._properties);for(let s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}},Co=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)}},Io=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function ko(t){if(Array.isArray(t))return t.length;let e=t?.values;return Array.isArray(e)?e.length:void 0}function Do(t,e){let i=ko(t),r=ko(e);return void 0!==i&&void 0!==r&&i!==r}var Fo=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(Do(t,e))return Rt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=sr[this.specification.type];return r?r(t,e,i):t}},$o=class{constructor(t,e,i){this.specification=t,this.name=e,this.overrides=i}possiblyEvaluate(t,e,i,r){return new Co(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 Co(this,{kind:"constant",value:void 0},t.parameters);if(Do(t.value.value,e.value.value))return Rt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=sr[this.specification.type];if(r){let s=r(t.value.value,e.value.value,i);return new Co(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)}},Ro=class extends $o{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new Co(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 Co(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 Co(this,{kind:"constant",value:i},e)}return new Co(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}},jo=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 xo(Math.floor(e.zoom-1),e)),t.expression.evaluate(new xo(Math.floor(e.zoom),e)),t.expression.evaluate(new xo(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}},Oo=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}},Lo=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 To(i,void 0,i.name,void 0),s=this.defaultTransitionablePropertyValues[e]=new zo(i,i.name,void 0);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}};oo("DataDrivenProperty",$o),oo("DataConstantProperty",Fo),oo("CrossFadedDataDrivenProperty",Ro),oo("CrossFadedProperty",jo),oo("ColorRampProperty",Oo);const Bo=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",No=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Uo=class extends ve{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 Kn(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=hn(t.filter,`layers[${this.id}].filter`,i)),e.layout&&(this._unevaluatedLayout=new Po(e.layout,`layers[${this.id}].layout`,i)),e.paint)){this._transitionablePaint=new So(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 Io(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=hn(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+Bo);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 ye(Error(t+Bo))):null!=e&&this._validate(Qn.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+No);return this._transitionablePaint.getTransition(e)}if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))throw Error(t+No);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))return this.fire(new ye(Error(t+No))),!1;if(null!=e&&this._validate(Qn.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 ro(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 Co&&Ps(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}};let Go;var Vo={get paint(){return Go||=new Lo({"raster-opacity":new Fo(we.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new Fo(we.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new Fo(we.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new Fo(we.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new Fo(we.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new Fo(we.paint_raster["raster-contrast"],"raster-contrast"),resampling:new Fo(we.paint_raster.resampling,"resampling"),"raster-resampling":new Fo(we.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new Fo(we.paint_raster["raster-fade-duration"],"raster-fade-duration")})}};const qo=t=>"raster"===t.type;var Zo=class extends Uo{constructor(t,e){super(t,Vo,e)}};const Wo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Ho=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}},Yo=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 Xo(t,e=1){let i=0,r=0;return{members:t.map((t=>{let s=function(t){return Wo[t].BYTES_PER_ELEMENT}(t.type),n=i=Jo(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:Jo(i,Math.max(r,e)),alignment:e}}function Jo(t,e){return Math.ceil(t/e)*e}var Ko=class extends Yo{_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}};Ko.prototype.bytesPerElement=4,oo("StructArrayLayout2i4",Ko);var Qo=class extends Yo{_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}};Qo.prototype.bytesPerElement=6,oo("StructArrayLayout3i6",Qo);var ta=class extends Yo{_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}};ta.prototype.bytesPerElement=8,oo("StructArrayLayout4i8",ta);var ea=class extends Yo{_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}};ea.prototype.bytesPerElement=12,oo("StructArrayLayout2i4i12",ea);var ia=class extends Yo{_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}};ia.prototype.bytesPerElement=8,oo("StructArrayLayout2i4ub8",ia);var ra=class extends Yo{_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}};ra.prototype.bytesPerElement=8,oo("StructArrayLayout2f8",ra);var sa=class extends Yo{_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}};sa.prototype.bytesPerElement=20,oo("StructArrayLayout10ui20",sa);var na=class extends Yo{_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}};na.prototype.bytesPerElement=16,oo("StructArrayLayout8ui16",na);var oa=class extends Yo{_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}};oa.prototype.bytesPerElement=24,oo("StructArrayLayout4i4ui4i24",oa);var aa=class extends Yo{_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}};aa.prototype.bytesPerElement=12,oo("StructArrayLayout3f12",aa);var la=class extends Yo{_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}};la.prototype.bytesPerElement=4,oo("StructArrayLayout1ul4",la);var ha=class extends Yo{_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}};ha.prototype.bytesPerElement=20,oo("StructArrayLayout6i1ul2ui20",ha);var ua=class extends Yo{_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}};ua.prototype.bytesPerElement=12,oo("StructArrayLayout2i2i2i12",ua);var ca=class extends Yo{_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}};ca.prototype.bytesPerElement=16,oo("StructArrayLayout2f1f2i16",ca);var fa=class extends Yo{_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}};fa.prototype.bytesPerElement=16,oo("StructArrayLayout2ub2f2i16",fa);var pa=class extends Yo{_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}};pa.prototype.bytesPerElement=6,oo("StructArrayLayout3ui6",pa);var da=class extends Yo{_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}};da.prototype.bytesPerElement=48,oo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",da);var ma=class extends Yo{_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,T,z,S,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,T,z,S,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,T,z,S,E,A){let P=32*t,C=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[C+12]=T,this.float32[C+13]=z,this.float32[C+14]=S,this.uint16[P+30]=E,this.uint16[P+31]=A,t}};ma.prototype.bytesPerElement=64,oo("StructArrayLayout8i15ui1ul2f2ui64",ma);var _a=class extends Yo{_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}};_a.prototype.bytesPerElement=4,oo("StructArrayLayout1f4",_a);var ga=class extends Yo{_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}};ga.prototype.bytesPerElement=12,oo("StructArrayLayout1ui2f12",ga);var ya=class extends Yo{_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}};ya.prototype.bytesPerElement=8,oo("StructArrayLayout1ul2ui8",ya);var va=class extends Yo{_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}};va.prototype.bytesPerElement=4,oo("StructArrayLayout2ui4",va);var wa=class extends Yo{_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}};wa.prototype.bytesPerElement=2,oo("StructArrayLayout1ui2",wa);var ba=class extends Yo{_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}};ba.prototype.bytesPerElement=16,oo("StructArrayLayout4f16",ba);var xa=class extends Ho{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)}};xa.prototype.size=20;var Ma=class extends ha{get(t){return new xa(this,t)}};oo("CollisionBoxArray",Ma);var Ta=class extends Ho{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]}};Ta.prototype.size=48;var za=class extends da{get(t){return new Ta(this,t)}};oo("PlacedSymbolArray",za);var Sa=class extends Ho{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]}};Sa.prototype.size=64;var Ea=class extends ma{get(t){return new Sa(this,t)}};oo("SymbolInstanceArray",Ea);var Aa=class extends _a{getoffsetX(t){return this.float32[1*t+0]}};oo("GlyphOffsetArray",Aa);var Pa=class extends Qo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}};oo("SymbolLineVertexArray",Pa);var Ca=class extends Ho{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]}};Ca.prototype.size=12;var Ia=class extends ga{get(t){return new Ca(this,t)}};oo("TextAnchorOffsetArray",Ia);var ka=class extends Ho{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]}};ka.prototype.size=8;var Da=class extends ya{get(t){return new ka(this,t)}};oo("FeatureIndexArray",Da);var Fa=class extends Ko{},$a=class extends Qo{},Ra=class extends ta{},ja=class extends Ko{},Oa=class extends Ko{},La=class extends ea{},Ba=class extends ia{},Na=class extends ra{},Ua=class extends sa{},Ga=class extends na{},Va=class extends oa{},qa=class extends aa{},Za=class extends la{},Wa=class extends ua{},Ha=class extends ca{},Ya=class extends fa{},Xa=class extends pa{},Ja=class extends pa{},Ka=class extends va{},Qa=class extends wa{};const tl=Xo([{name:"a_pos",components:2,type:"Int16"}],4).members;var el=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&&Rt(`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 il(t,e){return 256*(t=xt(Math.floor(t),0,255))+xt(Math.floor(e),0,255)}el.MAX_VERTEX_ARRAY_LENGTH=65535,oo("SegmentVector",el);const rl=Xo([{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"}]),sl=Xo([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var nl=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})})),ol=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}})),al=((i,r,n)=>(n=null==i?{}:t(s(i)),a(e(n,"default",{value:i,enumerable:!0}),i)))(o(((t,e)=>{var i=nl(),r=ol();e.exports=i,e.exports.murmur3=i,e.exports.murmur2=r}))()),ll=class t{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(hl(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=hl(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 ul(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 hl(t){let e=+t;return!isNaN(e)&&e<=2**53-1?e:(0,al.default)(String(t))}function ul(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;cl(t,n,o),cl(e,3*n,3*o),cl(e,3*n+1,3*o+1),cl(e,3*n+2,3*o+2)}o-i<r-o?(ul(t,e,i,o),i=o+1):(ul(t,e,o+1,r),r=o)}}function cl(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}oo("FeaturePositionMap",ll);var fl=class{constructor(t,e){this.gl=t.gl,this.location=e}},pl=class extends fl{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},dl=class extends fl{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},ml=class extends fl{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]))}},_l=class extends fl{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]))}},gl=class extends fl{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]))}},yl=class extends fl{constructor(t,e){super(t,e),this.current=Ei.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))}},vl=class extends fl{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)}}},wl=class extends fl{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 bl=new Float32Array(16);var xl=class extends fl{constructor(t,e){super(t,e),this.current=bl}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 Ml(t){return[il(255*t.r,255*t.g),il(255*t.b,255*t.a)]}var Tl=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 yl(t,e):new dl(t,e)}},zl=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 gl(t,e):new dl(t,e)}},Sl=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 xo(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 xo(0,s),i,r);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){let r=Ml(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()}},El=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 xo(this.zoom,i),e,{},i.canonical,[],i.formattedSection),s=this.expression.evaluate(new xo(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 xo(this.zoom,s),i,r),o=this.expression.evaluate(new xo(this.zoom+1,s),i,r);this._setPaintValue(t,e,n,o)}_setPaintValue(t,e,i,r){if("color"===this.type){let s=Ml(i),n=Ml(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 dl(t,e)}},Al=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()}},Pl=class extends Al{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns?.[this.layerId]}getVertexAttributes(){return rl.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)}},Cl=class extends Al{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes?.[this.layerId]}getVertexAttributes(){return sl.members}emplace(t,e,i,r){t.emplace(e,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},Il=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 Co&&Ps(n.property.specification)))continue;let o=Dl(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 zl(a.value,o):new Tl(a.value,o,l),r.push(`/u_${s}`);else if("source"===a.kind||c){let i=Fl(s,l,"source");this.binders[s]=c?"line-dasharray"===s?new Cl(a,l,h,e,i,t.id):new Pl(a,l,h,e,i,t.id):new Sl(a,o,l,i),r.push(`/a_${s}`)}else{let t=Fl(s,l,"composite");this.binders[s]=new El(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 Sl||e instanceof El?e.maxValue:0}populatePaintArrays(t,e,i){for(let r in this.binders){let s=this.binders[r];(s instanceof Sl||s instanceof El||s instanceof Al)&&s.populatePaintArray(t,e,i)}}setConstantPatternPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof zl&&r.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof zl&&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 Sl||a instanceof El||a instanceof Al)&&!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 Tl||i instanceof zl)&&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 Sl||i instanceof El)for(let e of i.paintVertexAttributes)t.push(e.name);else if(i instanceof Al){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 Tl||i instanceof zl||i instanceof El)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 Tl||s instanceof zl||s instanceof El)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 Al){let e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Sl||i instanceof El)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(let e in this.binders){let i=this.binders[e];(i instanceof Sl||i instanceof El||i instanceof Al)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let e=this.binders[t];(e instanceof Sl||e instanceof El||e instanceof Al)&&e.destroy()}}},kl=class{constructor(t,e,i=()=>!0){this.programConfigurations={};for(let r of t)this.programConfigurations[r.id]=new Il(r,e,i);this.needsUpload=!1,this._featureMap=new ll,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 Dl(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 Fl(t,e,i){let r={color:{source:ra,composite:ba},number:{source:_a,composite:ra}};return function(t){return{"line-pattern":{source:Ua,composite:Ua},"fill-pattern":{source:Ua,composite:Ua},"fill-extrusion-pattern":{source:Ua,composite:Ua},"line-dasharray":{source:Ga,composite:Ga}}[t]}(t)?.[i]||r[e][i]}oo("ConstantBinder",Tl),oo("CrossFadedConstantBinder",zl),oo("SourceExpressionBinder",Sl),oo("CrossFadedPatternBinder",Pl),oo("CrossFadedDasharrayBinder",Cl),oo("CompositeExpressionBinder",El),oo("ProgramConfiguration",Il,{omit:["_buffers"]}),oo("ProgramConfigurationSet",kl);const $l=-16384;function Rl(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,$l,16383),i.y=xt(r,$l,16383),(t<i.x||t>i.x+1||r<i.y||r>i.y+1)&&Rt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function jl(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Rl(t):[]}}const Ol=-32768;function Ll(t,e,i,r,s){t.emplaceBack(Ol+8*e+r,Ol+8*i+s)}var Bl=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 ja,this.indexArray=new Ja,this.segments=new el,this.programConfigurations=new kl(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 xo(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:r,index:a,sourceLayerIndex:l}of t){let t=jl(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:Rl(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,tl),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++)Ll(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 Nl(t,e){for(let i of t)if(Xl(e,i))return!0;for(let i of e)if(Xl(t,i))return!0;return ql(t,e)}function Ul(t,e,i){return!!Xl(t,e)||Wl(e,t,i)}function Gl(t,e){if(1===t.length)return Yl(e,t[0]);for(let i of e)for(let e of i)if(Xl(t,e))return!0;for(let i of t)if(Yl(e,i))return!0;for(let i of e)if(ql(t,i))return!0;return!1}function Vl(t,e,i){if(t.length>1){if(ql(t,e))return!0;for(let r of e)if(Wl(r,t,i))return!0}for(let r of t)if(Wl(r,e,i))return!0;return!1}function ql(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(Zl(r,s,e[t],e[t+1]))return!0}return!1}function Zl(t,e,i,r){return jt(t,i,r)!==jt(e,i,r)&&jt(t,e,i)!==jt(t,e,r)}function Wl(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(Hl(t,e[i-1],e[i])<r)return!0;return!1}function Hl(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 Yl(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 Xl(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 Jl(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(Xl(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Kl(t[e],t[e+1],n))return!0;return!1}function Kl(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=jt(t,e,i[0]);return n!==jt(t,e,i[1])||n!==jt(t,e,i[2])||n!==jt(t,e,i[3])}function Ql(t,e,i){let r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function th(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function eh(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 ih(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 rh({queryGeometry:t,size:e},i){return Ul(t,i,e)}function sh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s},n){return Ul(t,n,e*(i.projectTileCoordinates(n.x,n.y,r,s).signedDistanceFromCamera/i.cameraToCenterDistance))}function nh({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 Ul(t,lh(n,i,r,s),a)}function oh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s},n){return Ul(t,lh(n,i,r,s),e)}function ah({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:s,pitchAlignment:n="map",pitchScale:o="map"},a){let l="map"===n?"map"===o?rh:sh:"map"===o?nh:oh,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 lh(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 hh,uh;oo("CircleBucket",Bl,{omit:["layers"]});var ch={get paint(){return uh||=new Lo({"circle-radius":new $o(we.paint_circle["circle-radius"],"circle-radius"),"circle-color":new $o(we.paint_circle["circle-color"],"circle-color"),"circle-blur":new $o(we.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new $o(we.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new Fo(we.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new Fo(we.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new Fo(we.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new Fo(we.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new $o(we.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new $o(we.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new $o(we.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return hh||=new Lo({"circle-sort-key":new $o(we.layout_circle["circle-sort-key"],"circle-sort-key")})}},fh=class extends Uo{constructor(t,e){super(t,ch,e)}createBucket(t){return new Bl(t)}queryRadius(t){let e=t;return Ql("circle-radius",this,e)+Ql("circle-stroke-width",this,e)+th(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=eh(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=>lh(t,e,i,r)))}(u,s,o,a),h=c),ah({queryGeometry:l,size:h,transform:s,unwrappedTileID:o,getElevation:a,pitchAlignment:p,pitchScale:f},r)}},ph=class extends Bl{};let dh;oo("HeatmapBucket",ph,{omit:["layers"]});var mh={get paint(){return dh||=new Lo({"heatmap-radius":new $o(we.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new $o(we.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new Fo(we.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new Oo(we.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new Fo(we.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function _h(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 gh(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;let s=_h({},{width:e,height:i},r);yh(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 yh(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 vh=class t{constructor(t,e){_h(this,t,1,e)}resize(t){gh(this,t,1)}clone(){return new t({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,s){yh(t,e,i,r,s,1)}},wh=class t{constructor(t,e){_h(this,t,4,e)}resize(t){gh(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){yh(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 bh(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 xh(t){let e={},i=t.resolution||256,r=t.clips?t.clips.length:1,s=t.image||new wh({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}oo("AlphaImage",vh),oo("RGBAImage",wh);const Mh="big-fb";var Th=class extends Uo{createBucket(t){return new ph(t)}constructor(t,e){super(t,mh,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=xh({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(Mh)}queryRadius(t){return Ql("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:s,pixelsToTileUnits:n,unwrappedTileID:o,getElevation:a}){return ah({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 zh;var Sh={get paint(){return zh||=new Lo({"hillshade-illumination-direction":new Fo(we.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new Fo(we.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new Fo(we.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new Fo(we.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new Fo(we.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new Fo(we.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new Fo(we.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new Fo(we.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new Fo(we.paint_hillshade.resampling,"resampling")})}},Eh=class extends Uo{constructor(t,e){super(t,Sh,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(Vt);return{directionRadians:t.map(Vt),altitudeRadians:n,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}};let Ah;var Ph={get paint(){return Ah||=new Lo({"color-relief-opacity":new Fo(we["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new Oo(we["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new Fo(we["paint_color-relief"].resampling,"resampling")})}};function Ch(t){return"data"in t}var Ih=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),Ch(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:e}=t;l&&e&&(e=bh(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 Ch(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};Ch(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=bh(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=bh(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}},kh=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 Rt(`"${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 Dh(t,this.getUnpackVector())}getPixels(){return new wh({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 Dh(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}}oo("DEMData",kh);var Fh=class extends Uo{constructor(t,e){super(t,Ph,e)}_createColorRamp(t){let e={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof Ws&&i._styleExpression.expression instanceof ir){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=[Ei.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 Rt(`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 wh({width:r.colorStops.length,height:1}),n=new wh({width:r.colorStops.length,height:1});for(let t=0;t<r.elevationStops.length;t++){let e=Dh(r.elevationStops[t],i);n.setPixel(0,t,new Ei(e.r/255,e.g/255,e.b/255,1)),s.setPixel(0,t,r.colorStops[t])}return this.colorRampTextures={elevationTexture:new Ih(t,n,t.gl.RGBA),colorTexture:new Ih(t,s,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const $h=Xo([{name:"a_pos",components:2,type:"Int16"}],4).members;function Rh(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 jh(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 Oh=new Set;let Lh=!1;function Bh(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=wu(s/r|0,t[s],t[s+1],n);else for(let s=i-r;s>=e;s-=r)n=wu(s/r|0,t[s],t[s+1],n);return n&&mu(n,n.next)&&(bu(n),n=n.next),n}function Nh(t,e=t){let i,r=e===t,s=t;do{i=!1,s===s.next||0!==Oh.size&&Oh.has(s)||!mu(s,s.next)&&0!==du(s.prev,s,s.next)?(r||s!==e)&&(s=s.next,i=!r):((r||s===e)&&(e=s.prev),Lh=!0,bu(s),s=s.prev,i=!0)}while(i||s!==e);return e}function Uh(t,e,i,r,s){s&&function(t,e,i,r){let s=t,n=0;do{s.z=uu(s.x,s.y,e,i,r),su[n++]=s,s=s.next}while(s!==t);!function(t){if(t<=32)for(let e=1;e<t;e++){let t=su[e],i=t.z,r=e-1;for(;r>=0&&su[r].z>i;)su[r+1]=su[r],r--;su[r+1]=t}else{ou.length<t&&(ou=new Uint32Array(t),au=new Uint32Array(t),nu=Array(t));for(let e=0;e<t;e++)ou[e]=su[e].z;hu(t,su,ou,nu,au,0),hu(t,nu,au,su,ou,8),hu(t,su,ou,nu,au,16),hu(t,nu,au,su,ou,24)}}(n);let o=null;for(let t=0;t<n;t++){let e=su[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(du(a,t,l)<0&&(s?Vh(t,i,r,s):Gh(t)))e.push(a.i,t.i,l.i),bu(t),t=l,n=l;else if((t=l)===n){if(Lh=!1,t=Nh(t),Lh){n=t;continue}if(!o){n=t=qh(t,e),o=!0;continue}Zh(t,e,i,r,s);break}}}function Gh(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)&&fu(r,o,s,a,n,l,p.x,p.y)&&du(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Vh(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),_=uu(f,p,e,i,r),g=uu(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)&&fu(o,h,a,u,l,c,y.x,y.y)&&du(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)&&fu(o,h,a,u,l,c,v.x,v.y)&&du(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function qh(t,e){let i=t,r=!1;do{let s=i.prev,n=i.next.next;_u(s,i,i.next,n,!1)&&yu(s,n)&&yu(n,s)&&(e.push(s.i,i.i,n.i),bu(i),bu(i.next),i=t=n,r=!0),i=i.next}while(i!==t);return r?Nh(i):i}function Zh(t,e,i,r,s){let n=t;do{let t=n.next.next;for(;t!==n.prev;){if(n.i!==t.i&&pu(n,t)){let o=vu(n,t);return n=Nh(n,n.next),o=Nh(o,o.next),Uh(n,e,i,r,s),void Uh(o,e,i,r,s)}t=t.next}n=n.next}while(n!==t)}let Wh=!1;function Hh(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 Yh(t,e){let i=function(t,e){let i,r=e,s=t.x,n=t.y,o=-1/0;if(mu(t,r))return r;for(let e=0,a=0;e<Jh;e++,a+=4){if(n<Xh[a+1]||n>Xh[a+3]||Xh[a]>s||Xh[a+2]<=o)continue;let l=eu(e);r=iu(e);do{if(r.prev.next===r){if(mu(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<Jh;e++,f+=4){if(Xh[f+2]<a||Xh[f]>s||Xh[f+3]<h||Xh[f+1]>u)continue;let p=eu(e);r=iu(e);do{if(r.prev.next===r&&s>=r.x&&r.x>=a&&s!==r.x&&fu(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);(yu(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&&ru(i,r)))&&(i=r,c=e)}r=r.next}while(r!==p)}return i}(t,e);if(!i)return e;let r=vu(i,t);return tu(i,r.next.next),Nh(r,r.next),Nh(i,i.next)}let Xh=new Float64Array,Jh=0;const Kh=[],Qh=[];function tu(t,e){let i=t;do{let t=Jh++;Kh[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);Qh[t]=i;let l=4*t;Xh[l]=r,Xh[l+1]=s,Xh[l+2]=n,Xh[l+3]=o}while(i!==e)}function eu(t){let e=Qh[t];for(;e.prev.next!==e;)e=e.next;return Qh[t]=e,e}function iu(t){let e=Kh[t];for(;e.prev.next!==e;)e=e.next;return Kh[t]=e,e}function ru(t,e){return du(t.prev,t,e.prev)<0&&du(e.next,t,t.next)<0}const su=[];let nu=[],ou=new Uint32Array,au=new Uint32Array;const lu=new Uint32Array(256);function hu(t,e,i,r,s,n){lu.fill(0);for(let e=0;e<t;e++)lu[i[e]>>>n&255]++;let o=0;for(let t=0;t<256;t++){let e=lu[t];lu[t]=o,o+=e}for(let o=0;o<t;o++){let t=i[o],a=lu[t>>>n&255]++;r[a]=e[o],s[a]=t}}function uu(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 cu(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 fu(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 pu(t,e){let i=mu(t,e)&&du(t.prev,t,t.next)>0&&du(e.prev,e,e.next)>0;return t.next.i!==e.i&&(i||yu(t,e)&&yu(e,t)&&(0!==du(t.prev,t,e.prev)||0!==du(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&&_u(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 du(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function mu(t,e){return t.x===e.x&&t.y===e.y}function _u(t,e,i,r,s=!0){let n=du(t,e,i),o=du(t,e,r),a=du(i,r,t),l=du(i,r,e);return(n>0&&o<0||n<0&&o>0)&&(a>0&&l<0||a<0&&l>0)||!!s&&!!(0===n&&gu(t,i,e)||0===o&&gu(t,r,e)||0===a&&gu(i,t,r)||0===l&&gu(i,e,r))}function gu(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 yu(t,e){return du(t.prev,t,t.next)<0?du(t,e,t.next)>=0&&du(t,t.prev,e)>=0:du(t,e,t.prev)<0||du(t,t.next,e)<0}function vu(t,e){let i=xu(t.i,t.x,t.y),r=xu(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 wu(t,e,i,r){let s=xu(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 bu(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),Wh&&function(t,e){let i=4*t.z;e.x<Xh[i]&&(Xh[i]=e.x),e.y<Xh[i+1]&&(Xh[i+1]=e.y),e.x>Xh[i+2]&&(Xh[i+2]=e.x),e.y>Xh[i+3]&&(Xh[i+3]=e.y)}(t.prev,t.next)}function xu(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var Mu=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)}},Tu=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 Mu(0,0),line:new Mu(0,0),tile:new Mu(0,0),stencil:new Mu(0,0),circle:1})}};oo("SubdivisionGranularityExpression",Mu),oo("SubdivisionGranularitySetting",Tu);const zu=-32768,Su=32767;var Eu=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);Cu(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=Pu(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,zu),0===f&&0===d&&this._generatePoleQuad(t,a,l,c,p,zu),0===d&&0===u&&this._generatePoleQuad(t,l,n,p,h,zu)),i&&(u===s&&f===s&&this._generatePoleQuad(t,n,a,h,c,Su),f===s&&d===s&&this._generatePoleQuad(t,a,l,c,p,Su),d===s&&u===s&&this._generatePoleQuad(t,l,n,p,h,Su))}}_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;Oh.size&&Oh.clear();let n=Bh(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=Bh(t,e[i]*r,i<n-1?e[i+1]*r:t.length,r,!1);o===o.next&&Oh.add(o),s.push(cu(o))}s.sort(Hh),function(t,e){let i=Math.ceil((t+2*e)/16)+e+2;Xh.length<4*i&&(Xh=new Float64Array(4*i)),Jh=0}(t.length/r,e.length),tu(i,i),Wh=!0;for(let t=0;t<s.length;t++)i=Yh(s[t],i);return Wh=!1,Nh(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 Uh(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 Au(t,e,i,r=!0){return new Eu(i,e).subdividePolygonInternal(t,r)}function Pu(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 Cu(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 Iu(t,e,i,r,s,n,o,a,l){let h=s.length/2,u=o&&a&&l;if(h<el.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)>el.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,m=!0,_=!0,g=!0,u=0);let y=ku(o,r,n,a,f,m,h),v=ku(o,r,n,a,p,_,h),w=ku(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)>el.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,d=!0,m=!0,u=0);let _=ku(o,r,n,a,f,d,h),g=ku(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 ku(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 Du=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 Oa,this.indexArray=new Ja,this.indexArray2=new Ka,this.programConfigurations=new kl(t.layers,t.zoom),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=Rh("fill",this.layers,e);let r=this.layers[0].layout.get("fill-sort-key"),s=!r.isConstant(),n=[],o=new xo(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of t){let t=jl(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:Rl(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=jh("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,$h),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 Gr(e,500)){let e=Au(t,r,n.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;Iu(((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 Fu,$u;oo("FillBucket",Du,{omit:["layers","patternFeatures"]});var Ru={get paint(){return $u||=new Lo({"fill-antialias":new Fo(we.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new $o(we.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new Fo(we.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new $o(we.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new $o(we.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new Fo(we.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new Fo(we.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new Ro(we.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return Fu||=new Lo({"fill-sort-key":new $o(we.layout_fill["fill-sort-key"],"fill-sort-key")})}},ju=class extends Uo{constructor(t,e){super(t,Ru,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 Du(t)}queryRadius(){return th(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return Gl(eh(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}};const Ou=Xo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Lu=Xo([{name:"a_centroid",components:2,type:"Int16"}],4),Bu=Ou.members;var Nu=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=Uu(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 Uu(t){let e=t.length;if(e<=1)return[t];let i,r,s=[];for(let n=0;n<e;n++){let e=Gu(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 Gu(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}Nu.types=["Unknown","Point","LineString","Polygon"];var Vu=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(qu(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 Nu(this._pbf,e,this.extent,this._keys,this._values)}};function qu(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 Zu=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 Vu(t,t.readVarint()+t.pos);e.length&&(i[e.name]=e)}else t.skip(e)}this.layers=i}};const Wu=6371008.8;var Hu=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 Wu*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 Yu=2*Math.PI*Wu;function Xu(t){return Yu*Math.cos(t*Math.PI/180)}function Ju(t){return(180+t)/360}function Ku(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Qu(t,e){return t/Xu(e)}function tc(t){return 360*t-180}function ec(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function ic(t,e){return t*Xu(ec(e))}var rc=class t{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(e,i=0){let r=Hu.convert(e);return new t(Ju(r.lng),Ku(r.lat),Qu(i,r.lat))}toLngLat(){return new Hu(tc(this.x),ec(this.y))}toAltitude(){return ic(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Yu*function(t){return 1/Math.cos(t*Math.PI/180)}(ec(this.y))}};const sc=89.25;function nc(t,e,i){let r=1/(1<<i.z);return new rc(t/et*r+i.x*r,e/et*r+i.y*r)}function oc(t,e){let i=xt(e.lat,-85.051129,Yt);return new l(Ju(e.lng)*t,Ku(i)*t)}function ac(t,e){return new rc(e.x/t,e.y/t).toLngLat()}function lc(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(Vt(90-t.pitch)),Math.tan(Vt(sc-t.pitch)))}function hc(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 uc(t,e,i,r,s){let n=rc.fromLngLat(t,e),o=s*Qu(1,t.lat),{x:a,y:l,z:h}=cc(i,r);return new rc(n.x+o*-a,n.y+o*-l,n.z+o*-h)}function cc(t,e){let i=Vt(t),r=Vt(e),s=Math.cos(-i),n=Math.sin(i);return{x:n*Math.sin(r),y:-n*Math.cos(r),z:s}}function fc(t,e,i){if(e<=0||!t||0===t.length)return t;let r=function(t,e){let i=function(t,e,i){return nc(4096,4096,i).toLngLat()}(0,0,e);return t*rc.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++)pc(n,s[(t-1+r)%r],s[t],s[(t+1)%r],e);return i&&n.length>0&&n.push(q(n[0])),n.map((t=>new l(t[0],t[1])))}(t,r)))}function pc(t,e,i,r,s){let n=Q(V(),e,i),o=Q(V(),r,i),a=Y(n),l=Y(o);if(a<1e-6||l<1e-6)return void t.push(q(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(q(i));let u=Math.min(s,.2*a,.2*l),c=H(V(),i,n,u),f=H(V(),i,o,u),p=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t}(V(),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(V(),i,p,u/d),_=Q(V(),c,m),g=Q(V(),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(V(),c,m,i))}}const dc=8192;function mc(t,e,i,r,s,n,o,a){t.emplaceBack(e,i,2*Math.floor(r*dc)+o,s*dc*2,n*dc*2,Math.round(a))}var _c=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 La,this.centroidVertexArray=new Fa,this.indexArray=new Ja,this.programConfigurations=new kl(t.layers,t.zoom),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasDependencies=Rh("fill-extrusion",this.layers,e);let r=new xo(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=jl(a,o);if(!s._featureFilter.filter(r,t,i))continue;let c=o?t.geometry:Rl(a),f={id:l,sourceLayerIndex:u,index:h,geometry:n>0?fc(c,n,i):c,properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(jh("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,Bu),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Lu.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?fc(e,a,r):e;for(let e of Gr(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||vc(r[0]))return;for(let e of r)0!==e.length&&gc(t,e);let n={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=s.fill.getGranularityForZoomLevel(e.z),a="Polygon"===Nu.types[i.type];for(let t of r){if(0===t.length||vc(t))continue;let e=Pu(t,o,a);this._generateSideFaces(e,n)}if(!a)return;let l=Au(r,e,o,!1),h=this.layoutVertexArray;Iu(((t,e)=>{mc(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(yc(s,n))continue;e.segment.vertexLength+4>el.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),mc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),mc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i),i+=a,mc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),mc(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 gc(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 yc(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}function vc(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 wc,bc;oo("FillExtrusionBucket",_c,{omit:["layers","features"]});var xc={get paint(){return bc||=new Lo({"fill-extrusion-opacity":new Fo(we["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new $o(we["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new Fo(we["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new Fo(we["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new Ro(we["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new $o(we["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new $o(we["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new Fo(we["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return wc||=new Lo({"fill-extrusion-rounded-corner-distance":new Fo(we["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},Mc=class extends Uo{constructor(t,e){super(t,xc,e)}createBucket(t){return new _c(t)}queryRadius(){return th(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=eh(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=Ec(a,o,0),c=Sc(r,h,l,o);return function(t,e,i){let r=1/0;Gl(i,e)&&(r=zc(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];Nl(i,s)&&(r=Math.min(r,zc(i,s)))}}return r!==1/0&&r}(c[0],c[1],u)}};function Tc(t,e){return t.x*e.x+t.y*e.y}function zc(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=Tc(a,a),c=Tc(a,l),f=Tc(l,l),p=Tc(h,a),d=Tc(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 Sc(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,T=y+d,z=new l((m+o)/w,(_+a)/w);z.z=v/w,t.push(z);let S=new l(b/T,x/T);S.z=M/T,i.push(S)}s.push(t),n.push(i)}return[s,n]}function Ec(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 Ac=Xo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4).members,Pc=Xo([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]).members,Cc=Math.cos(Math.PI/180*37.5);var Ic=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 Ba,this.layoutVertexArray2=new Na,this.indexArray=new Ja,this.programConfigurations=new kl(t.layers,t.zoom),this.segments=new el,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=Rh("line",this.layers,e)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),s=!r.isConstant(),n=[],o=new xo(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:l,index:h,sourceLayerIndex:u}of t){let t=jl(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:Rl(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?(Rh("line",this.layers,e)?jh("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,Pc)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ac),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=Pu(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"===Nu.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<Cc&&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,T=M?i:l?"butt":r;if(M&&"round"===T&&(v<n?T="miter":v<=2&&(T="fakeround")),"miter"===T&&v>s&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v<s&&(T="miter")),f&&this.updateDistance(f,c),"miter"===T)o._mult(v),this.addCurrentVertex(c,o,0,0,g);else if("flipbevel"===T){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"===T||"fakeround"===T){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"===T){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"===T)this.addCurrentVertex(c,o,0,0,g);else if("square"===T){let t=f?1:-1;this.addCurrentVertex(c,o,t,t,g)}else"round"===T&&(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 kc,Dc;oo("LineBucket",Ic,{omit:["layers","patternFeatures"]});var Fc={get paint(){return Dc||=new Lo({"line-opacity":new $o(we.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new Fo(we.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new $o(we.paint_line["line-color"],"line-color"),"line-translate":new Fo(we.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new Fo(we.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new $o(we.paint_line["line-width"],"line-width"),"line-gap-width":new $o(we.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new $o(we.paint_line["line-offset"],"line-offset"),"line-blur":new $o(we.paint_line["line-blur"],"line-blur"),"line-dasharray":new Ro(we.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new Ro(we.paint_line["line-pattern"],"line-pattern"),"line-gradient":new Oo(we.paint_line["line-gradient"],"line-gradient")})},get layout(){return kc||=new Lo({"line-cap":new $o(we.layout_line["line-cap"],"line-cap"),"line-join":new $o(we.layout_line["line-join"],"line-join"),"line-miter-limit":new $o(we.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new $o(we.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new $o(we.layout_line["line-sort-key"],"line-sort-key")})}},$c=class extends $o{possiblyEvaluate(t,e){return e=new xo(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=Tt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}};let Rc;var jc=class extends Uo{constructor(t,e){super(t,Fc,e),this.gradientVersion=0,Rc||(Rc=new $c(Fc.paint.properties["line-width"].specification,"line-floorwidth"),Rc.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 er,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"]=Rc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Ic(t)}queryRadius(t){let e=t,i=Oc(Ql("line-width",this,e),Ql("line-gap-width",this,e)),r=Ql("line-offset",this,e);return i/2+Math.abs(r)+th(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:s,pixelsToTileUnits:n}){let o=eh(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-s.bearingInRadians,n),a=n/2*Oc(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=ih(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(Xl(t,e))return!0;if(Vl(t,r,i))return!0}return!1}(o,r,a)}isTileClipped(){return!0}};function Oc(t,e){return e>0?e+2*t:t}const Lc=Xo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Bc=Xo([{name:"a_projected_pos",components:3,type:"Float32"}],4);Xo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Nc=Xo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Xo([{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 Uc=Xo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Gc=Xo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Vc(t,e,i){let r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),bo.applyArabicShaping&&(t=bo.applyArabicShaping(t)),t}function qc(t,e,i){for(let r of t.sections)r.text=Vc(r.text,e,i);return t}Xo([{name:"triangle",components:3,type:"Uint16"}]),Xo([{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"}]),Xo([{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"}]),Xo([{type:"Float32",name:"offsetX"}]),Xo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Xo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Zc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Wc=4294967296,Hc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var Yc=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)*Wc;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Wc;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&&Hc?Hc.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 Xc(t,e,i){1===t&&i.readMessage(Jc,e)}function Jc(t,e,i){if(3===t){let{id:t,bitmap:r,width:s,height:n,left:o,top:a,advance:l}=i.readMessage(Kc,{});e.push({id:t,bitmap:new vh({width:s+6,height:n+6},r),metrics:{width:s,height:n,left:o,top:a,advance:l}})}}function Kc(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 Qc(t){let{userImage:e}=t;return!(!e?.render||!e.render()||(t.data.replace(new Uint8Array(e.data.buffer)),0))}function tf(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 ef=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]}};oo("ImagePosition",ef),oo("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}=tf(s),a=new wh({width:n||1,height:o||1});for(let e in t){let r=t[e],s=i[e].paddedRect;wh.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;wh.copy(i.data,a,{x:0,y:0},{x:n,y:o},i.data),wh.copy(i.data,a,{x:0,y:h-1},{x:n,y:o-1},{width:l,height:1}),wh.copy(i.data,a,{x:0,y:0},{x:n,y:o+h},{width:l,height:1}),wh.copy(i.data,a,{x:l-1,y:0},{x:n-1,y:o},{width:1,height:h}),wh.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 ef(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 rf=function(t){return t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly",t}(rf||{});function sf(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 nf(t,e){let{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new xo(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 xo(o)),maxSize:i.evaluate(new xo(a)),interpolationType:r}}}function of(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return"source"===t.kind?r/128:"composite"===t.kind?sr.number(r/128,s/128,i):e}function af(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(ir.interpolationFactor(s,e,n,o),0,1):0;"camera"===t.kind?r=sr.number(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}}function lf(t,e,i){let r="never",s=t.get(e);return s?r=s:t.get(i)&&(r="always"),r}const hf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function uf(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 cf(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 ff(t){for(let e of t.sections)if(wo(e.text))return!0;return!1}var pf=class{constructor(t){this.layoutVertexArray=new Va,this.indexArray=new Ja,this.programConfigurations=t,this.segments=new el,this.dynamicLayoutVertexArray=new qa,this.opacityVertexArray=new Za,this.hasVisibleVertices=!1,this.placedSymbolArray=new za}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,Lc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Bc.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,hf,!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())}};oo("SymbolBuffers",pf);var df=class{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ya}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Nc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};oo("CollisionBuffers",df);var mf=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=nf(this.zoom,e["text-size"]),this.iconSizeData=nf(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"!==lf(i,"text-overlap","text-allow-overlap")||"never"!==lf(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=>rf[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new pf(new kl(this.layers,this.zoom,(t=>t.startsWith("text")))),this.icon=new pf(new kl(this.layers,this.zoom,(t=>t.startsWith("icon")))),this.glyphOffsetArray=new Aa,this.lineVertexArray=new Pa,this.symbolInstances=new Ea,this.textAnchorOffsets=new Ia}calculateGlyphDependencies(t,e,i,r,s){for(let n of t)if(e[n.codePointAt(0)]=!0,(i||r)&&s){let t=Zc[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 Ii&&!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 xo(this.zoom);for(let{feature:e,id:o,index:a,sourceLayerIndex:m}of t){let t,_,g=r._featureFilter.needGeometry,y=jl(e,g);if(!r._featureFilter.filter(d,y,i))continue;if(g||(y.geometry=Rl(e)),l){let e=r.getValueAndResolveTokens("text-field",y,i,p),s=Ii.factory(e);this.hasRTLText||=ff(s),(!this.hasRTLText||"unavailable"===bo.getRTLTextPluginStatus()||this.hasRTLText&&bo.isParsed())&&(t=qc(s,r,y))}if(h){let t=r.getValueAndResolveTokens("icon-image",y,i,p);_=t instanceof Oi?t:Oi.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:Nu.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=mo(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],T=d.vertexLength,z=b[1];uf(p,a.x,a.y,s.x,z+s.y,u.x,u.y,i,x,m.x,m.y,v,w),uf(p,a.x,a.y,o.x,z+o.y,u.x+u.w,u.y,i,x,_.x,m.y,v,w),uf(p,a.x,a.y,l.x,z+l.y,u.x,u.y+u.h,i,x,m.x,_.y,v,w),uf(p,a.x,a.y,h.x,z+h.y,u.x+u.w,u.y+u.h,i,x,_.x,_.y,v,w),cf(t.dynamicLayoutVertexArray,a,g),f.emplaceBack(T,T+2,T+1),f.emplaceBack(T+1,T+2,T+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 df(Wa,Uc.members,Ka),this.iconCollisionBox=new df(Wa,Uc.members,Ka);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 _f,gf;oo("SymbolBucket",mf,{omit:["layers","collisionBoxArray","features","compareText"]}),mf.MAX_GLYPHS=65535,mf.addDynamicAttributes=cf;var yf={get paint(){return gf||=new Lo({"icon-opacity":new $o(we.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new $o(we.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new $o(we.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new $o(we.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new $o(we.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new Fo(we.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new Fo(we.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new $o(we.paint_symbol["text-opacity"],"text-opacity"),"text-color":new $o(we.paint_symbol["text-color"],"text-color",{runtimeType:Be,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new $o(we.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new $o(we.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new $o(we.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new Fo(we.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new Fo(we.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return _f||=new Lo({"symbol-placement":new Fo(we.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new Fo(we.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new Fo(we.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new $o(we.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new Fo(we.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new Fo(we.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new Fo(we.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new Fo(we.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new Fo(we.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new Fo(we.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new $o(we.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new Fo(we.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new Fo(we.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new $o(we.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new $o(we.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new $o(we.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new Fo(we.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new $o(we.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new $o(we.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new Fo(we.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new Fo(we.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new Fo(we.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new $o(we.layout_symbol["text-field"],"text-field"),"text-font":new $o(we.layout_symbol["text-font"],"text-font"),"text-size":new $o(we.layout_symbol["text-size"],"text-size"),"text-max-width":new $o(we.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new Fo(we.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new $o(we.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new $o(we.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new $o(we.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new Fo(we.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new $o(we.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new $o(we.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new Fo(we.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new Fo(we.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new $o(we.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new Fo(we.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new Fo(we.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new $o(we.layout_symbol["text-transform"],"text-transform"),"text-offset":new $o(we.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new Fo(we.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new Fo(we.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new Fo(we.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new Fo(we.layout_symbol["text-optional"],"text-optional")})}},vf=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:Re,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}};oo("FormatSectionOverride",vf,{omit:["defaultValue"]});const wf=t=>"symbol"===t.type;var bf=class t extends Uo{constructor(t,e){super(t,yf,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()||qs(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 mf(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of yf.paint.overridableProperties){if(!t.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new Us(new vf(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),s=null;s="constant"===i.value.kind||"source"===i.value.kind?new Ws("source",r):new Hs("composite",r,i.value.zoomStops),this.paint._values[e]=new Co(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=yf.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 Ii)n(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let t=e=>{s||(e instanceof Vi&&Ui(e.value)===qe?n(e.value.sections):e instanceof _r?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}};let xf;var Mf={get paint(){return xf||=new Lo({"background-color":new Fo(we.paint_background["background-color"],"background-color"),"background-pattern":new jo(we.paint_background["background-pattern"],"background-pattern"),"background-opacity":new Fo(we.paint_background["background-opacity"],"background-opacity")})}},Tf=class extends Uo{constructor(t,e){super(t,Mf,e)}},zf=class extends Uo{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 Sf(t,e){if("custom"===t.type)return new zf(t,e);switch(t.type){case"background":return new Tf(t,e);case"circle":return new fh(t,e);case"color-relief":return new Fh(t,e);case"fill":return new ju(t,e);case"fill-extrusion":return new Mc(t,e);case"heatmap":return new Th(t,e);case"hillshade":return new Eh(t,e);case"line":return new jc(t,e);case"raster":return new Zo(t,e);case"symbol":return new bf(t,e)}}var Ef=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 Af={once:!0};var Pf=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Ef((()=>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))}),Af):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:uo(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(co(e.error))):i.resolve(co(e.data)))}if(!this.messageHandlers[e.type])return void this.completeTask(t,null,null);let i=co(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?uo(e):null,data:uo(i,r)};this.target.postMessage(s,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function Cf(t,e){let{x:i,y:r}=rc.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)}var If=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=Ff(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=Rf(256*t,256*(e=2**i-e-1),i),s=Rf(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}`}},kf=class{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Ff(t,e.z,e.z,e.x,e.y)}},Df=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 If(i,+r,+s),this.key=Ff(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?Ff(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ff(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 kf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new rc(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 Ff(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 $f=6378137*Math.PI;function Rf(t,e,i){let r=2*$f/256/2**i;return[t*r-$f,e*r-$f]}function jf(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}oo("CanonicalTileID",If),oo("OverscaledTileID",Df,{omit:["terrainRttPosMatrix32f"]});var Of=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 Lf="_geojsonTileLayer";var Bf=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]}},Nf=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=Uu(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}},Uf=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}},Gf=class extends Uf{},Vf=class extends Gf{getValueFromBuffer(t){return this.dataBuffer[t]}},qf=class extends Gf{getValueFromBuffer(t){return this.dataBuffer[t]}},Zf=class extends Uf{constructor(t,e,i,r){super(t,e,r),this.delta=i}},Wf=class extends Zf{constructor(t,e,i,r){super(t,Int32Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}},Hf=class extends Uf{constructor(t,e,i,r){super(t,r?Int32Array.of(e):Uint32Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}},Yf=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 Vf||t instanceof Hf||t instanceof Wf||t instanceof qf}};var Xf,Jf,Kf=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"}(Xf||={}),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT"}(Jf||={});const Qf=new Uint32Array(33);Qf[0]=0;for(let t=1;t<=32;t++)Qf[t]=32===t?4294967295:4294967295>>>32-t;const tp=Qf;function ep(t,e){return t-t%e}function ip(t){return ep(t+31,32)}function rp(t){let e=t>>>0;return((255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255)>>>0}const sp=function(t){if(!Number.isFinite(t))return 65536;let e=ep(Math.floor(t),256);return 0===e?256:e}(65536),np=3*sp/256+sp|0;function op(){let t=new Uint8Array(np);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 ap(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=tp[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 lp(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 hp(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 up(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=ip(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)cp(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=lp(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=ap(t,u,s,f,r)}o>0&&(c=hp(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 cp(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=tp[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&tp[s-h]>>>0)<<h)&n,a=s-h}}function fp(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 pp(t,e,i){let r=new BigUint64Array(i);for(let i=0;i<r.length;i++)r[i]=dp(t,e);return r}function dp(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 mp(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 _p(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|rp(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??op();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+ep(s,256),a=r,l=i;for(;a!==o;){let i=Math.min(sp,o-a);l=up(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:op()}}(i>>>2))}function gp(t){return t>>>1^-(1&t)}function yp(t){return t>>1n^-(1n&t)}function vp(t){return t%2==1?(t+1)/-2:t/2}function wp(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 bp(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 xp(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 Mp(t){let e=new Int32Array(t.length);e[0]=gp(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]=gp(t[r])+e[r-1],e[r+1]=gp(i)+e[r],e[r+2]=gp(s)+e[r+1],e[r+3]=gp(n)+e[r+2]}for(;r!==t.length;++r)e[r]=gp(t[r])+e[r-1];return e}function Tp(t){let e=new BigInt64Array(t.length);e[0]=yp(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]=yp(t[r])+e[r-1],e[r+1]=yp(i)+e[r],e[r+2]=yp(s)+e[r+1],e[r+3]=yp(n)+e[r+2]}for(;r!==e.length;++r)e[r]=yp(t[r])+e[r-1];return e}function zp(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 Sp(t){let e=new Uint32Array(t.length);e[0]=gp(t[0])>>>0;for(let i=1;i<t.length;i++)e[i]=e[i-1]+gp(t[i])>>>0;return e}function Ep(t){let e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,yp(t[0]));for(let i=1;i<t.length;i++)e[i]=BigInt.asUintN(64,e[i-1]+yp(t[i]));return e}var Ap,Pp,Cp,Ip;!function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"}(Ap||={}),function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"}(Pp||={}),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"}(Cp||={}),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"}(Ip||={});const kp=[Ap.PRESENT,Ap.DATA,Ap.OFFSET,Ap.LENGTH],Dp=[Xf.NONE,Xf.DELTA,Xf.COMPONENTWISE_DELTA,Xf.RLE,Xf.MORTON,Xf.PDE],Fp=[Jf.NONE,Jf.FAST_PFOR,Jf.VARINT],$p=[Pp.NONE,Pp.SINGLE,Pp.SHARED,Pp.VERTEX,Pp.MORTON,Pp.FSST],Rp=[Cp.VERTEX,Cp.INDEX,Cp.STRING,Cp.KEY],jp=[Ip.VAR_BINARY,Ip.GEOMETRIES,Ip.PARTS,Ip.RINGS,Ip.TRIANGLES,Ip.SYMBOL,Ip.DICTIONARY];function Op(t,e){let i=function(t,e){let i=t[e.get()],r=kp[i>>4],s={};switch(r){case Ap.DATA:s={dictionaryType:$p[15&i]};break;case Ap.OFFSET:s={offsetType:Rp[15&i]};break;case Ap.LENGTH:s={lengthType:jp[15&i]}}e.increment();let n=t[e.get()],o=Dp[n>>5],a=Dp[n>>2&7],l=Fp[3&n];e.increment();let h=fp(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===Xf.MORTON?function(t,e,i){let r=fp(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):Xf.RLE!==i.logicalLevelTechnique1&&Xf.RLE!==i.logicalLevelTechnique2||Jf.NONE===i.physicalLevelTechnique?i:function(t,e,i){let r=fp(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 Lp;!function(t){t[t.FLAT=0]="FLAT",t[t.CONST=1]="CONST",t[t.SEQUENCE=2]="SEQUENCE",t[t.DICTIONARY=3]="DICTIONARY",t[t.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Lp||={});var Bp=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 Np(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 Up(t,e,i,r,s){return function(t,e,i,r){let s;switch(e.logicalLevelTechnique1){case Xf.DELTA:if(e.logicalLevelTechnique2===Xf.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=gp(t[i+e]);for(let t=0;t<o;t++)n+=a,r[s++]=n}return r}(t,i.runs,i.numRleValues);s=Mp(t=wp(t,i.runs,i.numRleValues))}else s=Mp(t);break;case Xf.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=gp(o),r.fill(o,s,s+n),s+=n}return r}(t,e.runs,e.numRleValues);break;case Xf.MORTON:zp(t),s=new Int32Array(t);break;case Xf.COMPONENTWISE_DELTA:s=function(t){if(t.length<2)return new Int32Array(t);let e=new Int32Array(t.length);e[0]=gp(t[0]),e[1]=gp(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]=gp(t[r])+e[r-2],e[r+1]=gp(i)+e[r-1],e[r+2]=gp(s)+e[r],e[r+3]=gp(n)+e[r+1]}for(;r!==t.length;r+=2)e[r]=gp(t[r])+e[r-2],e[r+1]=gp(t[r+1])+e[r-1];return e}(t);break;case Xf.NONE:s=function(t){let e=new Int32Array(t.length);for(let i=0;i<t.length;i++)e[i]=gp(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Np(s,r,0):s}(qp(t,e,i),i,0,s)}function Gp(t,e,i,r,s){return function(t,e,i,r){let s;switch(e.logicalLevelTechnique1){case Xf.DELTA:s=Sp(e.logicalLevelTechnique2===Xf.RLE?wp(t,e.runs,e.numRleValues):t);break;case Xf.RLE:s=wp(t,e.runs,e.numRleValues);break;case Xf.MORTON:zp(t),s=t;break;case Xf.COMPONENTWISE_DELTA:s=function(t){if(t.length<2)return new Uint32Array(t);let e=new Uint32Array(t.length);e[0]=gp(t[0])>>>0,e[1]=gp(t[1])>>>0;for(let i=2;i<t.length;i+=2)e[i]=e[i-2]+gp(t[i])>>>0,e[i+1]=e[i-1]+gp(t[i+1])>>>0;return e}(t);break;case Xf.NONE:s=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Np(s,r,0):s}(qp(t,e,i),i,0,s)}function Vp(t,e,i){return function(t,e){if(e.logicalLevelTechnique1===Xf.DELTA&&e.logicalLevelTechnique2===Xf.NONE)return function(t){let e=new Int32Array(t.length+1);e[0]=0,e[1]=gp(t[0]);let i=e[1];for(let r=2;r!==e.length;++r)i+=gp(t[r-1]),e[r]=e[r-1]+i;return new Uint32Array(e)}(t);if(e.logicalLevelTechnique1===Xf.RLE&&e.logicalLevelTechnique2===Xf.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===Xf.NONE&&e.logicalLevelTechnique2===Xf.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===Xf.DELTA&&e.logicalLevelTechnique2===Xf.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=gp(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 zp(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(qp(t,e,i),i)}function qp(t,e,i){let r=i.physicalLevelTechnique;switch(r){case Jf.FAST_PFOR:return _p(t,i.numValues,i.byteLength,e);case Jf.VARINT:return fp(t,e,i.numValues);case Jf.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 Zp(t,e,i){let r=qp(t,e,i);return 1===r.length?i.logicalLevelTechnique1===Xf.DELTA?gp(r[0]):r[0]:function(t){return t[1]}(r)}function Wp(t,e,i){return function(t){if(2===t.length){let e=gp(t[1]);return[e,e]}return[gp(t[2]),gp(t[3])]}(qp(t,e,i))}function Hp(t,e,i){return function(t){if(2===t.length){let e=yp(t[1]);return[e,e]}return[yp(t[2]),yp(t[3])]}(pp(t,e,i.numValues))}function Yp(t,e,i,r){return function(t,e,i){let r;switch(e.logicalLevelTechnique1){case Xf.DELTA:r=Ep(e.logicalLevelTechnique2===Xf.RLE?bp(t,e.runs,e.numRleValues):t);break;case Xf.RLE:r=bp(t,e.runs,e.numRleValues);break;case Xf.NONE:r=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Np(r,i,0n):r}(pp(t,e,i.numValues),i,r)}function Xp(t,e,i){let r=pp(t,e,i.numValues);return 1===r.length?i.logicalLevelTechnique1===Xf.DELTA?yp(r[0]):r[0]:function(t){return t[1]}(r)}function Jp(t,e,i,r,s="int32"){let n=t.logicalLevelTechnique1;if(n===Xf.RLE)return 1===t.runs?Lp.CONST:Lp.FLAT;if(n!==Xf.DELTA||t.logicalLevelTechnique2!==Xf.RLE)return 1===t.numValues?Lp.CONST:Lp.FLAT;let o=e instanceof Bp?e.size():e;if(t.numRleValues!==o)return Lp.FLAT;if(1===t.runs)return Lp.SEQUENCE;if(2!==t.runs)return 1===t.numValues?Lp.CONST:Lp.FLAT;let a=r.get();if(t.physicalLevelTechnique===Jf.VARINT)return function(t,e,i){let r=new Kf(e.get());if("int64"===i){let e=pp(t,r,4);return 2n===e[2]&&2n===e[3]}let s=fp(t,r,4);return 2===s[2]&&2===s[3]}(i,r,s)?Lp.SEQUENCE:1===t.numValues?Lp.CONST:Lp.FLAT;let l=r.get(),h=new Int32Array(i.buffer,i.byteOffset+l,4);return r.set(a),2===h[2]&&2===h[3]?Lp.SEQUENCE:1===t.numValues?Lp.CONST:Lp.FLAT}var Kp,Qp,td,ed=class extends Gf{getValueFromBuffer(t){return this.dataBuffer[t]}},id=class extends Zf{constructor(t,e,i,r){super(t,BigInt64Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}};function rd(t,e,i){return{x:sd(t,e)-i,y:sd(t>>1,e)-i}}function sd(t,e){let i=0;for(let r=0;r<e;r++)i|=(t&1<<2*r)>>r;return i}function nd(t,e,i,r,s,n,o){return t===td.MORTON?function(t,e,i,r,s,n){let o=Array(s?r+1:r);for(let s=0;s<r;s++){let r=rd(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 od(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"}(Kp||={}),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"}(Qp||={}),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"}(td||={});var ad=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=rd(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 Kp.POINT:{let u,_;if(m)u=g[o++],_=g[o++];else if(t.vertexBufferType===td.MORTON){let t=rd(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 Kp.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 Kp.LINESTRING:{let l,u;_?(l=p[r]-p[r-1],r++):l=f[i]-f[i-1],i++,m?(u=od(g,o,l,!1),o+=2*l):(u=nd(t.vertexBufferType,g,d,a,l,!1,h),a+=l),e[n++]=[u],c&&s++}break;case Kp.POLYGON:{let l=f[i]-f[i-1];i++;let u,_=Array(l-1),y=p[r]-p[r-1];if(r++,m){u=od(g,o,y,!0),o+=2*y;for(let t=0;t<_.length;t++)y=p[r]-p[r-1],r++,_[t]=od(g,o,y,!0),o+=2*y}else{u=nd(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]=nd(t.vertexBufferType,g,d,a,y,!0,h),a+=y}e[n++]=[u].concat(_),c&&s++}break;case Kp.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]=od(g,o,s,!1),o+=2*s;else{let i=nd(t.vertexBufferType,g,d,a,s,!1,h);u[e]=i,a+=s}}e[n++]=u}break;case Kp.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=od(g,o,c,!0),o+=2*c):(n=nd(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]=od(g,o,i,!0),o+=2*i):(l[e]=nd(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}},ld=class extends ad{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===Kp.POLYGON||this._geometryType===Kp.MULTIPOLYGON}containsSingleGeometryType(){return!0}},hd=class extends ad{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)===Kp.POLYGON||this.geometryType(t)===Kp.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},ud=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 Kp.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 Kp.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 cd(t,e,i,r,s,n){return new fd(t,e,i,r,s,n)}var fd=class extends ud{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 pd(t,e,i,r,s){return new dd(t,e,i,r,s)}var dd=class extends ud{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 md(t,e,i,r){let s,n,o,a,l=Op(t,i);if(Jp(l,r,t,i)===Lp.CONST){let h,u,c,f,p=Zp(t,i,l);for(let r=0;r<e-1;r++){let e=Op(t,i);switch(e.physicalStreamType){case Ap.LENGTH:switch(e.logicalStreamType.lengthType){case Ip.GEOMETRIES:h=Vp(t,i,e);break;case Ip.PARTS:u=Vp(t,i,e);break;case Ip.RINGS:c=Vp(t,i,e);break;case Ip.TRIANGLES:f=Vp(t,i,e)}break;case Ap.OFFSET:switch(e.logicalStreamType.offsetType){case Cp.VERTEX:s=Gp(t,i,e);break;case Cp.INDEX:a=Gp(t,i,e)}break;case Ap.DATA:Pp.VERTEX===e.logicalStreamType.dictionaryType?n=Up(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},n=Gp(t,i,e))}}return a?void 0!==h||void 0!==u?cd(r,p,f,a,n,{geometryOffsets:h,partOffsets:u,ringOffsets:c}):cd(r,p,f,a,n):void 0===o?function(t,e,i,r,s){return new ld(t,e,td.VEC_2,i,r,s)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},s,n):function(t,e,i,r,s,n){return new ld(t,e,td.MORTON,i,r,s,n)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},s,n,o)}let h,u,c,f,p,d,m,_=Gp(t,i,l);for(let r=0;r<e-1;r++){let e=Op(t,i);switch(e.physicalStreamType){case Ap.LENGTH:switch(e.logicalStreamType.lengthType){case Ip.GEOMETRIES:h=Gp(t,i,e);break;case Ip.PARTS:u=Gp(t,i,e);break;case Ip.RINGS:c=Gp(t,i,e);break;case Ip.TRIANGLES:f=Vp(t,i,e)}break;case Ap.OFFSET:switch(e.logicalStreamType.offsetType){case Cp.VERTEX:s=Gp(t,i,e);break;case Cp.INDEX:a=Gp(t,i,e)}break;case Ap.DATA:Pp.VERTEX===e.logicalStreamType.dictionaryType?n=Up(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},n=Gp(t,i,e))}}return h?(p=_d(_,h,2),u&&c?(d=gd(_,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=_d(_,u,1),m=gd(_,d,c,!0)):u&&(d=_d(_,u,0)),a&&!d?pd(_,f,a,n):a?pd(_,f,a,n,{geometryOffsets:p,partOffsets:d,ringOffsets:m}):void 0===o?function(t,e,i,r){return new hd(td.VEC_2,t,e,i,r)}(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},s,n):function(t,e,i,r,s){return new hd(td.MORTON,t,e,i,r,s)}(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},s,n,o)}function _d(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 gd(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 yd=class extends Uf{constructor(t,e,i){super(t,e.getBuffer(),i),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}},vd=class extends Gf{getValueFromBuffer(t){return this.dataBuffer[t]}},wd=class extends Uf{constructor(t,e,i,r){super(t,r?BigInt64Array.of(e):BigUint64Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}};function bd(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 Bp(t,e),n=new Bp(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 xd=new TextDecoder;function Md(t,e,i){return i-e>=12?xd.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 Td=class extends Uf{constructor(t,e,i,r){super(t,i,r),this.offsetBuffer=e}},zd=class extends Td{constructor(t,e,i,r){super(t,e,i,r??e.length-1)}getValueFromBuffer(t){return Md(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}},Sd=class extends Td{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 Md(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}},Ed=class extends Td{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 Md(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 Ad(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=Op(e,i),r=t.numValues,s=i.get(),n=bd(e,r,t.byteLength,i);i.set(s+t.byteLength),o=new Bp(n,t.numValues)}let a=o??r;switch(s.physicalType){case 4:case 3:return function(t,e,i,r,s){let n=Op(t,e),o=Jp(n,s,t,e),a=3===r.physicalType;if(o===Lp.FLAT){let r=Pd(s)?s:void 0,o=a?Up(t,e,n,0,r):Gp(t,e,n,0,r);return new Vf(i.name,o,s)}if(o===Lp.SEQUENCE){let r=Wp(t,e,n);return new Wf(i.name,r[0],r[1],n.numRleValues)}let l=a?function(t,e,i){let r=qp(t,e,i);return 1===r.length?gp(r[0]):function(t){return gp(t[1])}(r)}(t,e,n):Zp(t,e,n);return new Hf(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=Op(e,i);switch(t.physicalStreamType){case Ap.PRESENT:{let r=new Bp(bd(e,t.numValues,t.byteLength,i),t.numValues);u=s??r;break}case Ap.OFFSET:o=Gp(e,i,t,0,u);break;case Ap.LENGTH:{let r=Vp(e,i,t);Ip.DICTIONARY===t.logicalStreamType.lengthType?n=r:Ip.SYMBOL===t.logicalStreamType.lengthType?l=r:c=r;break}case Ap.DATA:{let r=e.subarray(i.get(),i.get()+t.byteLength);i.add(t.byteLength);let s=t.logicalStreamType.dictionaryType;Pp.FSST===s?h=r:Pp.SINGLE===s||Pp.SHARED===s?a=r:Pp.NONE===s&&(f=r);break}}}return function(t,e,i,r,s,n,o){return e?new Ed(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 Sd(t,i,r,e,s):new Sd(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 Sd(t,r,e,i,s):new Sd(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 Sd(t,r,e,i,s)}return s?new zd(t,e,i,s):new zd(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=Op(t,e),o=n.numValues,a=e.get(),l=Pd(s)?s:void 0,h=bd(t,o,n.byteLength,e,l);e.set(a+n.byteLength);let u=new Bp(h,o);return new yd(i.name,u,s)}(e,i,n,0,a);case 6:case 5:return function(t,e,i,r,s){let n=Op(t,e),o=Jp(n,r,t,e,"int64"),a=5===s.physicalType;if(o===Lp.FLAT){let s=Pd(r)?r:void 0,o=a?function(t,e,i,r){return function(t,e,i){let r;switch(e.logicalLevelTechnique1){case Xf.DELTA:if(e.logicalLevelTechnique2===Xf.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=yp(t[i+e]);for(let t=0;t<o;t++)n+=a,r[s++]=n}return r}(t,s.runs,s.numRleValues);r=Tp(t=bp(t,s.runs,s.numRleValues))}else r=Tp(t);break;case Xf.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=yp(o),r.fill(o,s,s+n),s+=n}return r}(t,e.runs,e.numRleValues);break;case Xf.NONE:r=function(t){let e=new BigInt64Array(t.length);for(let i=0;i<t.length;i++)e[i]=yp(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Np(r,i,0n):r}(pp(t,e,i.numValues),i,r)}(t,e,n,s):Yp(t,e,n,s);return new ed(i.name,o,r)}if(o===Lp.SEQUENCE){let r=Hp(t,e,n);return new id(i.name,r[0],r[1],n.numRleValues)}let l=a?function(t,e,i){let r=pp(t,e,i.numValues);return 1===r.length?yp(r[0]):function(t){return yp(t[1])}(r)}(t,e,n):Xp(t,e,n);return new wd(i.name,l,r,a)}(e,i,n,a,s);case 7:return function(t,e,i,r){let s=Op(t,e),n=Pd(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?Np(a,r,0):a}(t,e,s.numValues,n);return new vd(i.name,o,r)}(e,i,n,a);case 8:return function(t,e,i,r){let s=Op(t,e),n=Pd(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?Np(a,r,0):a}(t,e,s.numValues,n);return new qf(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=Op(t,e);switch(i.physicalStreamType){case Ap.LENGTH:Ip.DICTIONARY===i.logicalStreamType.lengthType?r=Vp(t,e,i):n=Vp(t,e,i);break;case Ap.DATA:Pp.SINGLE===i.logicalStreamType.dictionaryType||Pp.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=fp(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=Op(t,e);c=new Bp(bd(t,i.numValues,i.byteLength,e),i.numValues)}let p=Gp(t,e,Op(t,e),0,c);h[u++]=o?new Ed(f,p,r,s,n,o,c):new Sd(f,p,r,s,c)}return h}(t,e,i)}function Pd(t){return t instanceof Bp}function Cd(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 Id(t){return t>=10}function kd(t){return 30===t}function Dd(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 Fd(t){return"scalarType"===t.type&&"logicalType"===t.scalarType?.type&&0===t.scalarType.logicalType}function $d(t){return"complexType"===t.type&&"physicalType"===t.complexType?.type&&0===t.complexType.physicalType}const Rd=new TextDecoder;function jd(t,e){let i=fp(t,e,1)[0];if(0===i)return"";let r=e.get(),s=t.subarray(r,r+i);return e.add(i),Rd.decode(s)}function Od(t,e){let i=fp(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=Cd(i);if(Id(i)&&(r.name=jd(t,e)),kd(i)){let i=fp(t,e,1)[0]>>>0;r.complexType.children=Array(i);for(let s=0;s<i;s++)r.complexType.children[s]=Od(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 Ld(t,e){let i=fp(t,e,1)[0]>>>0,r=Cd(i);if(!r)throw Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Id(i)?r.name=jd(t,e):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),kd(i)){let i=fp(t,e,1)[0]>>>0,s=r.complexType;s.children=Array(i);for(let r=0;r<i;r++)s.children[r]=Od(t,e)}return r}function Bd(t,e){let i={featureTables:[]},r={};if(r.name=jd(t,e),0===r.name.length)throw Error("Missing layer name");let s=fp(t,e,1)[0]>>>0,n=fp(t,e,1)[0]>>>0;r.columns=Array(n);for(let i=0;i<n;i++)r.columns[i]=Ld(t,e);return i.featureTables.push(r),[i,s]}function Nd(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=Jp(s,n,t,i,6===l?"int64":"int32");if(4===l)switch(u){case Lp.FLAT:return new Vf(r,Gp(t,i,s,0,h),n);case Lp.SEQUENCE:{let e=Wp(t,i,s);return new Wf(r,e[0],e[1],s.numRleValues)}case Lp.CONST:return new Hf(r,Zp(t,i,s),n,!1)}switch(u){case Lp.FLAT:return o?new qf(r,function(t,e,i){return function(t,e){switch(e.logicalLevelTechnique1){case Xf.DELTA:return e.logicalLevelTechnique2===Xf.RLE&&(t=xp(t,e.runs,e.numRleValues)),function(t){t[0]=vp(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]=vp(t[i])+t[i-1],t[i+1]=vp(e)+t[i],t[i+2]=vp(r)+t[i+1],t[i+3]=vp(s)+t[i+2]}for(;i!==t.length;++i)t[i]=vp(t[i])+t[i-1]}(t),t;case Xf.RLE:return function(t,e){return xp(t,e.runs,e.numRleValues)}(t,e);case Xf.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]=mp(t,e);return r}(t,e,i.numValues),i)}(t,i,s),n):new ed(r,Yp(t,i,s,h),n);case Lp.SEQUENCE:{let e=Hp(t,i,s);return new id(r,e[0],e[1],s.numRleValues)}case Lp.CONST:return new wd(r,Xp(t,i,s),n,!1)}throw Error("Vector type not supported for id column.")}var Ud=class{constructor(t,e){switch(this._featureData=t,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Kp.POINT:case Kp.MULTIPOINT:this.type=1;break;case Kp.LINESTRING:case Kp.MULTILINESTRING:this.type=2;break;case Kp.POLYGON:case Kp.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}},Gd=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 Ud(this.features[t],this.extent)}},Vd=class{constructor(t){this.layers={};let e=function(t,e,i=!0){let r=new Kf(0),s=[];for(;r.get()<t.length;){let e=fp(t,r,1)[0]>>>0,n=r.get()+e;if(n>t.length)throw Error(`Block overruns tile: ${n} > ${t.length}`);if(fp(t,r,1)[0]>>>0!=1){r.set(n);continue}let[o,a]=Bd(t,r),l=o.featureTables[0],h=null,u=null,c=[],f=0;for(let e of l.columns){let s=e.name;if(Fd(e)){let n=null;if(e.nullable){let e=Op(t,r),i=r.get(),s=bd(t,e.numValues,e.byteLength,r);r.set(i+e.byteLength),n=new Bp(s,e.numValues)}let o=Op(t,r);f=n?n.size():o.decompressedCount,h=Nd(t,e,r,s,o,n??f,i)}else if($d(e)){let e=fp(t,r,1)[0];if(0===f){let e=r.get();f=Op(t,r).decompressedCount,r.set(e)}u=md(t,e,r,f)}else{let i=Dd(e)?fp(t,r,1)[0]:1;if(0===i)continue;let s=Ad(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 Yf(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 Gd(e)})),{})}};function qd(t,e,i,r,s){return It(t,((t,n)=>{let o=e instanceof Io?e.get(n):null;return o?.evaluate?o.evaluate(i,r,s):o}))}function Zd(t,e){return e-t}oo("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 so(et,16,0),this.grid3D=new so(et,16,0),this.featureIndexArray=new Da,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 Vd(this.rawTileData).layers:new Zu(new Yc(this.rawTileData)).layers,this.sourceLayerCoder=new Bf(this.vtLayers?Object.keys(this.vtLayers).sort():[Lf])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();let s=t.params,n=et/t.tileSize/t.scale,o=hn(s.filter,"queryRenderedFeatures filter",s.globalState),a=t.queryGeometry,l=t.queryPadding*n,h=Of.fromPoints(a),u=this.grid.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l),c=Of.fromPoints(t.cameraQueryGeometry).expandBy(l),f=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,((e,i,r,s)=>Jl(t.cameraQueryGeometry,e-l,i-l,r+l,s+l)));for(let t of f)u.push(t);u.sort(Zd);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||=Rl(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=jl(p,!0);if(!s.filter(new xo(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new xo(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=Tt({},l[e]);c.paint=qd(c.paint,i.paint,p,s,o),c.layout=qd(c.layout,i.layout,p,s,o);let f=!u||u(p,i,s);if(!f)continue;let m=new Nf(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=hn(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 Wd=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)}};oo("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 Hd=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}({});
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
+ */
10
+ var Yd="6.2.0";function Xd(){var t=new f(4);return f!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let Jd,Kd,Qd;const tm={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=>(Jd||=document.createElement("a"),Jd.href=t,Jd.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===Qd?!!matchMedia&&(Kd??=matchMedia("(prefers-reduced-motion: reduce)"),Kd.matches):Qd},set prefersReducedMotion(t){Qd=t}},em=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 im(){return em.getCurrentTime()}function rm(t){em.setNow(t)}function sm(){em.restoreNow()}function nm(){return em.isFrozen()}var om=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 am;(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,*/*",Tt(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):fe(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||!de(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}))})(am||={}),am.resetRequestQueue();var lm=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}},hm=class extends ge{},um=class extends hm{},cm=class extends hm{constructor(t={}){super("style.load",t)}},fm=class extends hm{constructor(t,e={}){super(t,e),this.dataType="style"}},pm=class extends hm{constructor(t,e={}){super(t,e),this.dataType="source"}},dm=class extends hm{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=om.mousePos(e.getCanvas(),i);super(t,Tt({point:s,lngLat:e.unproject(s),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}},mm=class extends hm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){let r="touchend"===t?i.changedTouches:i.touches,s=om.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}},_m=class extends hm{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e){super("wheel",{originalEvent:e}),this._defaultPrevented=!1}},gm=class extends hm{},ym=class extends hm{constructor(t={}){super("terrain",t)}},vm=class extends hm{constructor(t={}){super("projectiontransition",t)}},wm=class extends hm{},bm=class extends hm{constructor(t={}){super("styleimagemissing",t)}};function xm(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 Mm(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 Tm=class extends ve{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this.patterns={},this.atlasImage=new wh({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 wh({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 wh({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 ye(Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,r?.height)||(this.fire(new ye(Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new ye(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 bm({id:t})),Rt(`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 ef(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 Ih(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}=tf(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;wh.copy(n,r,{x:0,y:0},{x:i,y:s},{width:o,height:a}),wh.copy(n,r,{x:0,y:a-1},{x:i,y:s-1},{width:o,height:1}),wh.copy(n,r,{x:0,y:0},{x:i,y:s+a},{width:o,height:1}),wh.copy(n,r,{x:o-1,y:0},{x:i-1,y:s},{width:1,height:a}),wh.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||Rt(`Image with ID: "${e}" was not found`),Qc(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 zm(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)=>fe(Tt(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 Yc(t).readFields(Xc,[])}(a.data))l[t.id]=t;return l}const Sm=1e20,Em=new Float64Array(256);for(let t=0;t<256;t++){let e=.5-(t/255)**(1/2.2);Em[t]=e*Math.abs(e)}Em[255]=-1e20;var Am=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(Sm,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=Em[t];y[e]=Math.max(0,i),g[e]=Math.max(0,-i)}}Pm(y,0,0,u,c,u,this.f,this.v,this.z);let b=Math.min(_,1);Pm(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 Pm(t,e,i,r,s,n,o,a,l){for(let h=e;h<e+r;h++)Cm(t,i*n+h,n,s,o,a,l);for(let h=i;h<i+s;h++)Cm(t,h*n+e,1,r,o,a,l)}function Cm(t,e,i,r,s,n,o){n[0]=0,o[0]=-1e20,o[1]=Sm,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]=Sm}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 Im=we.layout_symbol["text-font"].default.join(",");var km=class t{static{this.loadGlyphRange=zm}static{this.TinySDF=Am}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;Rt(`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===Im&&""!==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 vh({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){Rt(`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 Dm;var Fm=class extends ve{constructor(t,e){super(),this._transitionable=new So(Dm||=new Lo({anchor:new Fo(we.light.anchor,"anchor"),position:new Fo(we.light.position,"position"),color:new Fo(we.light.color,"color"),intensity:new Fo(we.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(Qn.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 ro(this,t,{value:e},i)}};let $m;var Rm=class extends ve{constructor(t,e){super(),this._transitionable=new So($m||=new Lo({"sky-color":new Fo(we.sky["sky-color"],"sky-color"),"horizon-color":new Fo(we.sky["horizon-color"],"horizon-color"),"fog-color":new Fo(we.sky["fog-color"],"fog-color"),"fog-ground-blend":new Fo(we.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new Fo(we.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new Fo(we.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new Fo(we.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",e),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new xo(0))}setSky(t,e={}){if(!this._validate(Qn.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 ro(this,t,{value:e},i)}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}},jm=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 Rt("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 Om(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 Lm(){let t=ne.WORKER_URL||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 Om(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 Om(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 Om(i,e)}finally{URL.revokeObjectURL(i)}}const Bm="maplibre_preloaded_worker_pool";var Nm=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(Lm());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[Bm]}numActive(){return Object.keys(this.active).length}};const Um=Math.floor(tm.hardwareConcurrency/2);let Gm;function Vm(){return Gm||=new Nm,Gm}function qm(){Vm().acquire(Bm)}function Zm(){let t=Gm;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Bm),Gm=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))}Nm.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(Um,3),1):1;var Wm=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 Pf(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 Hm;function Ym(){return Hm||(Hm=new Wm(Vm(),he),Hm.registerMessageHandler("GR",((t,e,i)=>fe(e,i)))),Hm}function Xm(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 Jm(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(Km);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,Xm(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 Km(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 t_(t,e,i,r){let s=t;if(t.url?s=(await pe(await e.transformRequest(t.url,"Source"),i)).data:await tm.frameAsync(i,r),!s)return null;let n=zt(Tt(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 e_=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 Hu?new Hu(t.lng,t.lat):Hu.convert(t),this}setSouthWest(t){return this._sw=t instanceof Hu?new Hu(t.lng,t.lat):Hu.convert(t),this}extend(e){let i,r,s=this._sw,n=this._ne;if(e instanceof Hu)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(Hu.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(Hu.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 Hu(i.lng,i.lat),this._ne=new Hu(r.lng,r.lat)),this}getCenter(){return new Hu((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 Hu(this.getWest(),this.getNorth())}getSouthEast(){return new Hu(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}=Hu.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 Hu(e.lng-s,e.lat-r),new Hu(e.lng+s,e.lat+r))}adjustAntiMeridian(){let e=new Hu(this._sw.lng,this._sw.lat),i=new Hu(this._ne.lng,this._ne.lat);return new t(e,e.lng>i.lng?new Hu(i.lng+360,i.lat):i)}},i_=class{constructor(t,e,i){this.bounds=e_.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(Ju(this.bounds.getWest())*e),r=Math.floor(Ku(this.bounds.getNorth())*e),s=Math.ceil(Ju(this.bounds.getEast())*e),n=Math.ceil(Ku(this.bounds.getSouth())*e);return t.x>=i&&t.x<s&&t.y>=r&&t.y<n}},r_=class extends ve{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,Tt(this,zt(e,["url","scheme","tileSize","promoteId","encoding"])),this._options=Tt({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 pm("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await t_(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(Tt(this,e),e.bounds&&(this.tileBounds=new i_(e.bounds,this.minzoom,this.maxzoom)),this.fire(new pm("data",{sourceDataType:"metadata"})),this.fire(new pm("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,re(t)||this.fire(new ye(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 Tt({},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}},s_=class extends ve{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=Tt({type:"raster"},e),Tt(this,zt(e,["url","scheme","tileSize"]))}async load(t=!1){this._loaded=!1,this.fire(new pm("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await t_(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(Tt(this,e),e.bounds&&(this.tileBounds=new i_(e.bounds,this.minzoom,this.maxzoom)),this.fire(new pm("data",{sourceDataType:"metadata"})),this.fire(new pm("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,re(t)||this.fire(new ye(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 Tt({},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 am.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 Ih(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}},n_=class extends s_{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Tt({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 am.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 wh({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 tm.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 Df(t.overscaledZ,s,e.z,r,e.y).key]={backfilled:!1},a[new Df(t.overscaledZ,o,e.z,n,e.y).key]={backfilled:!1},e.y>0&&(a[new Df(t.overscaledZ,s,e.z,r,e.y-1).key]={backfilled:!1},a[new Df(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new Df(t.overscaledZ,o,e.z,n,e.y-1).key]={backfilled:!1}),e.y+1<i&&(a[new Df(t.overscaledZ,s,e.z,r,e.y+1).key]={backfilled:!1},a[new Df(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new Df(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 o_(t,e){return e?t.properties[e]:t.id}function a_(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 l_(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 h_(t){return t&&0!==t.length?"number"==typeof t[0]?[t]:t.flatMap((t=>h_(t))):[]}function u_(t){return"GeometryCollection"===t.type?t.geometries.flatMap((t=>u_(t))):h_(t.coordinates)}function c_(t){let e,i=new e_;switch(t.type){case"FeatureCollection":e=t.features.flatMap((t=>u_(t.geometry)));break;case"Feature":e=u_(t.geometry);break;default:e=u_(t)}if(0===e.length)return i;for(let t of e){let[e,r]=t;i.extend([e,r])}return i}var f_=class extends ve{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=Tt({},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&&Rt(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${e.clusterMaxZoom}".`),this.workerOptions=Tt({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||Rt(`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=l_(t),r=l_(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,a_(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 c_(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 Rt(`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=Tt({type:this.type,source:this.id},this.workerOptions);return"string"==typeof t?(r.request=await this.map._requestManager.transformRequest(tm.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 pm("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 pm("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 pm("data",{...n,sourceDataType:"metadata"})),this.fire(new pm("data",{...n,sourceDataType:"content",shouldReloadTileOptions:s}))}catch(t){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new pm("dataabort"));this.fire(new ye(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&&Tt(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=o_(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=o_(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=o_(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=>c_(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=tc((t-r)/2**i),n=ec((e+1+r)/2**i),o=tc((t+1+r)/2**i),a=ec((e-r)/2**i);return new e_([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 Tt({},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}},p_=class extends ve{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 pm("dataloading")),this.url=this.options.url;let e=await this.map._requestManager.transformRequest(this.url,"Image");this._request=new AbortController;try{let i=await am.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 ye(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 pm("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(rc.fromLngLat);return this.tileID=function(t){let e=Of.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 If(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 pm("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 Ih(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 pm("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}=Of.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}},d_=class extends p_{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");de(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 ye(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 ye(new De(`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 Ih(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 pm("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},m_=class extends p_{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 ye(new De(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new ye(new De(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new ye(new De(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"!=typeof e.canvas&&!(e.canvas instanceof HTMLCanvasElement)&&this.fire(new ye(new De(`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 ye(new De(`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 ye(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 Ih(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 pm("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 __={},g_=t=>{switch(t){case"geojson":return f_;case"image":return p_;case"raster":return s_;case"raster-dem":return n_;case"vector":return r_;case"video":return d_;case"canvas":return m_}return __[t]},y_=async(t,e)=>{if(g_(t))throw Error(`A source type called "${t}" already exists.`);((t,e)=>{__[t]=e})(t,e)},v_="RTLPluginLoaded";var w_=class extends ve{constructor(...t){super(...t),this.status="unavailable",this.url=null,this.dispatcher=Ym()}_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=tm.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 ge(v_))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let b_=null;function x_(){return b_||=new w_,b_}var M_=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=im(),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 mf){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 mf&&e.hasRTLText){this.hasRTLText=!0,x_().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 Ma;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 Ih(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new Ih(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=hn(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=jl(r,!0);if(!o.filter(new xo(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!o.filter(new xo(this.tileID.overscaledZ),r))continue;let c=i.getId(r,s),f=new Nf(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<im()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=im()+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 T_(t){let e=[];for(let i in t)e.push({id:i,state:t[i]});return e}var z_=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]||={},Tt(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=Tt({},(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]=T_(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]||={},Tt(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]=T_(i[t]);t.setFeatureState(r,e,this.revision)}};function S_(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 E_(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 A_(t,e){return function(i,r,s,n,o){let a=2*((t-1)/Pt(Math.cos(Vt(sc-o))/Math.cos(Vt(sc)))-1),l=Math.acos(s/n),h=2*E_(a-1,0,Vt(o/2)),u=Math.min(Vt(sc),l+Vt(o/2)),c=E_(a-1,Math.min(u,l-Vt(o/2)),u),f=Math.atan(r/s),p=i;return p+=Pt(n/Math.hypot(r,s)/Math.max(.5,Math.cos(Vt(o/2)))),p+=a*Pt(Math.cos(f))/2,p-=Pt(Math.max(1,c/h/e))/2,p}}const P_=A_(9.314,3);function C_(t,e){let i=(e.roundZoom?Math.round:Math.floor)(t.zoom+Pt(t.tileSize/e.tileSize));return Math.max(0,i)}function I_(t,e){let i=t.getCameraFrustum(),r=t.getClippingPlane(),s=t.screenPointToMercatorCoordinate(t.getCameraPoint()),n=rc.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-(sc-t.pitch-t.fov/2))/15,0,1);return t.elevation+500*e}(t),a=t.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(t,e),h=C_(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},T=a.getTileBoundingVolume(M,p.wrap,o,e);if(!x){let t=S_(i,T,r);if(0===t)continue;x=2===t}let z=a.distanceToTile2d(s.x,s.y,M,T),S=h;l&&(S=(e.calculateTileZoom||P_)(t.zoom+Pt(t.tileSize/e.tileSize),z,g,y,t.fov)),S=(e.roundZoom?Math.round:Math.floor)(S),S=Math.max(0,S);let E=Math.min(S,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,S):p.zoom;b.push({tileID:new Df(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 k_=Of.fromPoints([new l(0,0),new l(et,et)]);function D_(t){return"raster"===t||"image"===t||"video"===t}function F_(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 $_(t,e,i,r,s,n){if(!e.hasData())return!1;let o=e.tileID.children(s),a=R_(t,e,o,i,r,s,n);if(a)return!0;for(let l of o)R_(t,e,l.children(s),i,r,s,n)&&(a=!0);return a}function R_(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 j_(t,e,i,r){let s=t.tileID;return!!t.selfFading||!t.hasData()&&(!!e.has(s)&&(t.setSelfFadeLogic(i+r),!0))}function O_(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 L_=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(jf).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(jf).map((t=>t.key))}},B_=class t extends ve{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(g_(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 L_,this._outOfViewCache=new Wd(0,(t=>this._unloadTile(t))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new z_,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 L_}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 ye(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 pm("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=im(),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||O_(t,i),!i.neighboringTiles?.[t.tileID.key]?.backfilled&&O_(i,t)}}(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new pm("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 Df(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=I_(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 pm("data",{sourceDataType:"idle",sourceId:this.id}));let s=C_(t,this._source),n=this._updateRetainedTiles(i,s),o=D_(this._source.type);o&&this._rasterFadeDuration>0&&!e&&function(t,e,i,r,s,n,o){let a=im(),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(),!F_(t,e,i,a,r,s,o)&&($_(t,e,i,a,n,o)||j_(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 M_(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 pm("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=Of.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 rc(e.x,e.y))));if(e.expandBy(u),e.intersects(k_)){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=Of.fromPoints(t);i.shrinkBy(.001*Math.min(i.width(),i.height()));let s=i.map(e);Of.fromPoints(r).covers(s)||(r=r.map((t=>t.x>.5?new rc(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()||D_(this._source.type)&&function(t,e){if(e<=0)return!1;let i=im();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||=Lf,this._state.updateState(t,e,i)}removeFeatureState(t,e,i){t||=Lf,this._state.removeFeatureState(t,e,i)}getFeatureState(t,e){return t||=Lf,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}},N_=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 U_(t,e){let i=!0;return"always"===t||("never"===t||"never"===e)&&(i=!1),i}var G_=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||!U_(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||!U_(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))&&!U_(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))&&!U_(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 V_(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 q_=d();function Z_(t,e,i){let r=d();if(!t){let{vecSouth:t,vecEast:i}=H_(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 W_(t,e,i,r){if(t){let t=d();if(!e){let{vecSouth:e,vecEast:r}=H_(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 H_(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=V();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=V();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 Y_(t,e,i,r){let s;r?(s=[t,e,r(t,e),1],N(s,s,i)):(s=[t,e,0,1],fg(s,s,i));let n=s[3];return{point:new l(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function X_(t,e){return.5+t/e*.5}function J_(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function K_(t,e,i,r,s,n,o,a,h,u,c,f,p){let d=i?t.textSizeData:t.iconSizeData,m=af(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){cg(x.numGlyphs,g);continue}b=!1;let M=new l(x.anchorX,x.anchorY),T={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},z=og(x.anchorX,x.anchorY,T);if(!J_(z.point,_)){cg(x.numGlyphs,g);continue}let S=X_(e.transform.cameraToCenterDistance,z.signedDistanceFromCamera),E=of(d,m,x),A=n?E*e.transform.getPitchedTextCorrection(x.anchorX,x.anchorY,h)/S:E*S,P=eg({projectionContext:T,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&&eg({projectionContext:T,pitchedLabelPlaneMatrixInverse:s,symbol:x,fontSize:A,flip:!0,keepUpright:o,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:a}).notEnoughRoom)&&cg(x.numGlyphs,g)}i?t.text.dynamicLayoutVertexBuffer.updateData(g):t.icon.dynamicLayoutVertexBuffer.updateData(g)}function Q_(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=hg(t*c,i,r,s,n.segment,h,u,a,o);if(!p)return null;let d=hg(t*f,i,r,s,n.segment,h,u,a,o);return!d||a.projectionCache.anyProjectionOccluded?null:{first:p,last:d}}function tg(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 eg(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=Q_(p,h,d,m,o,s,f,i);if(!u)return{notEnoughRoom:!0};let _=ng(u.first.point.x,u.first.point.y,i,r),g=ng(u.last.point.x,u.last.point.y,i,r);if(a&&!o){let t=tg(s.writingMode,_,g,c);if(t)return t}e=[u.first];for(let r=s.glyphStartIndex+1;r<t-1;r++){let t=hg(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=sg(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=sg(n.x,n.y,i),a=o.signedDistanceFromCamera>0?o.point:ig(i.tileAnchorPoint,n,t,1,i),h=ng(t.x,t.y,i,r),u=ng(a.x,a.y,i,r),f=tg(s.writingMode,h,u,c);if(f)return f}let t=hg(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)cf(u,t.point,t.angle);return{}}function ig(t,e,i,r,s){let n=t.add(t.sub(e)._unit()),o=sg(n.x,n.y,s).point,a=i.sub(o);return i.add(a._mult(r/a.mag()))}function rg(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=sg(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 ig(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 sg(t,e,i){let r,s=t+i.translation[0],n=e+i.translation[1];return i.pitchWithMap?(r=Y_(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 ng(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 og(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,i.getElevation)}function ag(t,e,i){return t._unit()._perp()._mult(e*i)}function lg(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=rg(t+l.direction,a,l),c=ag(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 hg(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=sg(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=rg(p,a,t),0===i)x.push(y),_=g.sub(y);else{let e,r=g.sub(y);e=0===r.mag()?ag(rg(p+u,a,t).sub(g),i,u):ag(r,i,u),m||=y.add(e),d=lg(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),T=c+Math.atan2(g.y-y.y,g.x-y.x);return x.push(M),{point:M,angle:l?T:0,path:x}}const ug=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function cg(t,e){for(let i=0;i<t;i++){let t=e.length;e.resize(t+4),e.float32.set(ug,3*t)}}function fg(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 pg=class{constructor(t,e=new G_(t.width+200,t.height+200,25),i=new G_(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=Q_(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 N_,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=q_;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=Y_(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 Of;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]||Nl(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],fg(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=H_(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,T=t.y1*w,z=t.y2*w,S=(T+z)/2,E=[{offsetX:b,offsetY:T},{offsetX:M,offsetY:T},{offsetX:x,offsetY:T},{offsetX:x,offsetY:S},{offsetX:x,offsetY:z},{offsetX:M,offsetY:z},{offsetX:b,offsetY:z},{offsetX:b,offsetY:S}],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}}},dg=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}},mg=class{constructor(t,e,i,r,s){this.text=new dg(t?t.text:null,e,i,s),this.icon=new dg(t?t.icon:null,e,r,s)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},_g=class{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}},gg=class{constructor(t,e,i,r,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=s}},yg=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 vg(t,e,i,r,s){let{horizontalAlign:n,verticalAlign:o}=sf(t);return new l(-(n-.5)*e+r[0]*s,-(o-.5)*i+r[1]*s)}var wg=class{constructor(t,e,i,r,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new pg(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new yg(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")),_=Z_(f,this.transform,p);this.retainedQueryData[s.bucketInstanceId]=new gg(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:af(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=Hd[t.textAnchor],b=[t.textOffset0,t.textOffset1],x=vg(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"),_=lf(s,"text-overlap","text-allow-overlap"),g="always"===_,y=lf(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"),T=g&&(v||!r.hasIconData()||m),z=v&&(g||!r.hasTextData()||d);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let S=this.retainedQueryData[r.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(S),A=this.transform.getFastPathSimpleProjectionMatrix(S),P=(t,c,v)=>{if(e[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new _g(!1,!1,!1));let M=!1,P=!1,C=!0,I=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},F=null,$=null,R=null,j=0,O=0,L=0;c.textFeatureIndex?j=c.textFeatureIndex:t.useRuntimeCollisionCircles&&(j=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,S,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=Hd[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,T=null,z="never"===_?1:2,P="never";f&&z++;for(let i=0;i<z;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,S,a,p,P,t,r,c,n,o,v,E);if(l&&(T=l.placedGlyphBoxes,T?.placeable))return M=!0,I=l.shift,T}f?f=null:P=_}return i&&!T&&(T={box:this.collisionIndex.placeCollisionBox(B,"always",h,S,a,b,w,n,p.predicate,E,void 0,A).box,offscreen:!1,placeable:!1,occluded:!1}),T};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,C=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,C=F?.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){let e=r.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),o=of(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&&Rt("Collisions detected, but collision boxes are not shown"),M=g||$.circles.length>0&&!$.collisionDetected,C&&=$.offscreen}if(c.iconFeatureIndex&&(L=c.iconFeatureIndex),c.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,y,h,S,a,b,w,o,p.predicate,E,x&&I?I:void 0,A);D&&D.placeable&&c.verticalIconBox?(R=t(c.verticalIconBox),P=R.placeable):(R=t(c.iconBox),P=R.placeable),C&&=R.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&&R.placeable;if(M&&F.placeable&&this.collisionIndex.insertCollisionBox(F.box,_,s.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&O?O:j,p.ID),G&&this.collisionIndex.insertCollisionBox(R.box,y,s.get("icon-ignore-placement"),r.bucketInstanceId,L,p.ID),$&&M&&this.collisionIndex.insertCollisionCircles($.circles,_,s.get("text-ignore-placement"),r.bucketInstanceId,j,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,v,c,F,R,$),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 _g((M||T)&&!F?.occluded,(P||z)&&!R?.occluded,C||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"}(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 mg(n,r,e.text,e.icon),i||=e.text!==n.text.placed,i||=e.icon!==n.icon.placed):(this.opacities[t]=new mg(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 mg(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 mg(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 mg(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!==Eg},_=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=Sg(h.text);m(t.text,s,v?Eg:e),m(t.text,n,w?Eg: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=Sg(h.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&v);r.placedIconSymbolIndex>=0&&(m(t.icon,r.numIconVertices,i?e:Eg),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=h.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,r.numVerticalIconVertices,i?Eg: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=vg(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),bg(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),bg(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 bg(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 xg=2**25,Mg=2**24,Tg=2**17,zg=65536;function Sg(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*xg+e*Mg+i*Tg+e*zg+512*i+256*e+2*i+e}const Eg=0;var Ag=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}},Pg=class{constructor(t,e,i,r,s,n,o,a){this.placement=new wg(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=im(),s=()=>!this._forceFullPlacement&&im()-r>2;for(;this._currentPlacementIndex>=0;){let r=e[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if(wf(r)&&r.layout&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||=new Ag(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 Cg=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ig=new Uint32Array(96);var kg=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=Cg[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=Cg.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 Dg(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;Ig[0]=0,Ig[1]=s.length-1,Ig[2]=0;let a=3,l=[];for(;a>0;){let h=Ig[--a],u=Ig[--a],c=Ig[--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)&&(Ig[a++]=c,Ig[a++]=f-1,Ig[a++]=1-h),(0===h?i>=p:r>=d)&&(Ig[a++]=f+1,Ig[a++]=u,Ig[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;Ig[0]=0,Ig[1]=s.length-1,Ig[2]=0;let a=3,l=0,h=i*i;for(;a>0;){let u=Ig[--a],c=Ig[--a],f=Ig[--a];if(c-f<=o){for(let i=f;i<=c;i++)jg(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];jg(d,m,t,e)<=h&&(r[l++]=s[p]),(0===u?t-i<=d:e-i<=m)&&(Ig[a++]=f,Ig[a++]=p-1,Ig[a++]=1-u),(0===u?t+i>=d:e+i>=m)&&(Ig[a++]=p+1,Ig[a++]=c,Ig[a++]=1-u)}return l}};function Dg(t,e,i,r,s,n){if(s-r<=i)return;let o=r+s>>1;Fg(t,e,o,r,s,n),Dg(t,e,i,r,o-1,1-n),Dg(t,e,i,o+1,s,1-n)}function Fg(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);Fg(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($g(t,e,r,i),e[2*s+n]>o&&$g(t,e,r,s);a<l;){for($g(t,e,a,l),a++,l--;e[2*a+n]<o;)a++;for(;e[2*l+n]>o;)l--}e[2*r+n]===o?$g(t,e,r,l):(l++,$g(t,e,l,s)),l<=i&&(r=l+1),i<=l&&(s=l-1)}}function $g(t,e,i,r){Rg(t,i,r),Rg(e,2*i,2*r),Rg(e,2*i+1,2*r+1)}function Rg(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function jg(t,e,i,r){let s=t-i,n=e-r;return s*s+n*n}const Og=.03125;var Lg=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*Og),y:Math.floor(t.anchorY*Og)}))),crossTileIDs:e.map((t=>t.crossTileID))};if(i.positions.length>128){let t=new kg(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=Og/2**(a-s),h=(o*et+t.anchorY)*l,u=r*et*Og;return{x:Math.floor((n*et+t.anchorX)*l-i*et*Og),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))}},Bg=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Ng=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 Lg(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}},Ug=class{constructor(){this.layerIndexes={},this.crossTileIDs=new Bg,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Ng);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]}},Gg="void main() {fragColor=vec4(1.0);}";const Vg={prelude:qg("#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:qg("\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:qg("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:qg("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:qg("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:qg("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:qg(Gg,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:qg("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:qg("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:qg("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:qg("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:qg("#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:qg("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:qg(Gg,"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:qg("#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:qg("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:qg("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:qg("#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:qg("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:qg("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:qg("#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:qg("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:qg("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:qg("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:qg("#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:qg("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:qg("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:qg("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:qg("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:qg("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:qg("#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:qg("#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:qg("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:qg("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:qg("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:qg("#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:qg("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 qg(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 Zg=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 Wg=Xo([{name:"a_pos",type:"Int16",components:2}]),Hg="#define PROJECTION_MERCATOR",Yg="mercator";var Xg=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Yg}get shaderDefine(){return Hg}get shaderPreludeCode(){return Vg.projectionMercator}get vertexShaderPreludeCode(){return Vg.projectionMercator.vertexSource}get subdivisionGranularity(){return Tu.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 Fa;n.emplaceBack(0,0),n.emplaceBack(et,0),n.emplaceBack(0,et),n.emplaceBack(et,et);let o=t.createVertexBuffer(n,Wg.members),a=el.simpleSegment(0,0,4,2),l=new Ja;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let h=t.createIndexBuffer(l);return this._cachedMesh=new Zg(o,h,a),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Jg=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=sr.number(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=sr.number(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=sr.number(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=sr.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 Kg(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 Qg(t){return Math.max(0,Math.floor(t))}var ty=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 Hu(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Qg(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 Jg,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=Qg(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 Jg(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 qt(this._fovInRadians)}setFov(t){t=xt(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=Vt(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 e_([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}=Of.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}=cc(a,o),f=rc.fromLngLat(t,e),p=ic(1,f.y),d=0;do{if(d+=1,d>10)break;n=l/p,s=new rc(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=Qu(1,this.center.lat)*this.worldSize,r=rc.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}=cc(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 rc((p+h*y)*e,(d+u*y)*e,0).toLngLat(),w=Qu(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(Vt(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=Qu(1,this.center.lat)*this.worldSize;return uc(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]}},ey=class t{constructor(t,e){this.min=t,this.max=e,this.center=I([],C([],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}},iy=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 Df(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 ey([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(){}},ry=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);I(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,I([],i,D(e,i))),s=B(r);if(s>0){let t=Math.sqrt(1-i[3]*i[3]);return ut(e,C([],I([],i,-i[3]),I([],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 ey(u,c))}},sy=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 Hu(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=Ku(t[1])*s,o=Ku(t[0])*s,o-n<p&&(u=p/(o-n))}r&&(a=Mt(Ju(r[0])*s,0,s),h=Mt(Ju(r[1])*s,0,s),h<a&&(h+=s),h-a<f&&(c=f/(h-a)));let d,m,{x:_,y:g}=oc(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=ac(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=ac(s,t).wrap()}return i},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new ty({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new iy}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 kf(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 kf(i,t))}return e}getCameraFrustum(){return ry.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=Qu(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(e,i),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,i),n=rc.fromLngLat(t),o=new rc(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(rc.fromLngLat(t),e.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(rc.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 rc(sr.number(r[0]/n,s[0]/o,c)/this.worldSize,sr.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-lc(this));return(new e_).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-lc(this)}calculatePosMatrix(t,e=!1,i=!1){let r=t.key??Ff(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=hc(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=hc(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=Vt(this.fov)*(Math.abs(Math.cos(Vt(this.roll)))*this.height+Math.abs(Math.sin(Vt(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=lc(this),u=Math.atan(h/this._helper.cameraToCenterDistance),c=Vt(.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=oc(this.worldSize,this.center),i=e.x,r=e.y;this._helper._pixelPerMeter=Qu(1,this.center.lat)*this.worldSize;let s,n=Vt(Math.min(this.pitch,sc)),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),T(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),T(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=Qu(1,this.center.lat)*this.worldSize;return uc(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,e){let i=rc.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],fg(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 Df(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:e,applyGlobeMatrix:t}),r=hc(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 ny(){Rt("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function oy(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=qt(-Math.asin(xt(e[2],-1,1)));return Math.hypot(e[5],e[8])<.001?(i=0,r=-qt(Math.atan2(e[3],e[4]))):(i=qt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),r=qt(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(sr.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(sr.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(sr.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function ay(t,e,i,r,s){let n=s.padding,o=oc(s.worldSize,i.getNorthWest()),a=oc(s.worldSize,i.getNorthEast()),h=oc(s.worldSize,i.getSouthEast()),u=oc(s.worldSize,i.getSouthWest()),c=Vt(-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 ny();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(Vt(r)),T=x.add(M).mult(s.scale/At(b));return{center:ac(s.worldSize,o.add(h).div(2).sub(T)),zoom:b,bearing:r}}var ly=class{get useGlobeControls(){return!1}handlePanInertia(t,e){let i=t.mag(),r=Math.abs(lc(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 ay(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(Hu.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(Hu.convert(e.center||c),h??i);Kg(t,f);let d=oc(t.worldSize,c),m=oc(t.worldSize,f).sub(d),_=At(p-i);return l=p!==i,{easeFunc:o=>{if(l&&t.setZoom(sr.number(i,p,o)),Zt(s,n)||oy({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=ac(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(Hu.convert(e.center||e.locationAtOffset),i?+e.zoom:r),n=s.center,o=s.zoom;Kg(t,n);let a=t.worldSize,l=oc(a,e.locationAtOffset),h=oc(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:ac(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 hy;function uy(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?zu:-64),e===i+1&&(n=t.extendToSouthPole?Su: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 cy=new Tu({fill:new Mu(128,2),line:new Mu(512,0),tile:new Mu(128,32),stencil:new Mu(128,1),circle:3});var fy=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 Vg.projectionGlobe}get vertexShaderPreludeCode(){return Vg.projectionMercator.vertexSource}get subdivisionGranularity(){return cy}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?cy.stencil:cy.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=uy(e,"16bit"),r=Fa.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),s=Ja.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new Zg(t.createVertexBuffer(r,Wg.members),t.createIndexBuffer(s),el.simpleSegment(0,0,r.length,s.length))}(t,e);return this._tileMeshCache[i]=r,r}recalculate(t){}hasTransition(){return!1}},py=class extends ve{constructor(t,e){super(),this._transitionable=new So(hy||=new Lo({type:new Fo(we.projection.type,"type")}),"projection",e),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new xo(0)),this._mercatorProjection=new Xg,this._verticalPerspectiveProjection=new fy}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 Li){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 dy(t){let e=gy(t.worldSize,t.center.lat);return 2*Math.PI*e}function my(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 _y(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 gy(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function yy(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 Hu(Mt(n,-180,180),e)}return new Hu(0,e)}function vy(t){return Math.cos(t*Math.PI/180)}function wy(t,e){let i=vy(t);return Pt(vy(e)/i)}function by(t,e){let i=t.rotate(e.bearingInRadians),r=e.zoom+wy(e.center.lat,0),s=yt(1/vy(e.center.lat),1/vy(Math.min(Math.abs(e.center.lat),60)),gt(r,7,3,0,1)),n=function(t,e){return 360/dy({worldSize:t,center:{lat:e}})}(e.worldSize,e.center.lat);return new Hu(e.center.lng-i.x*n*s,xt(e.center.lat+i.y*n,-85.051129,Yt))}function xy(t){let e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function My(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=xy(n+r*(o-n)),l=xy(n),h=xy(o);return new Hu(t.lng+e*((a-l)/(h-l)),s)}return new Hu(t.lng+e*r,s)}var Ty=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}},zy=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];C(i,i,I([],n,1&~t?-1:1)),C(i,i,I([],o,1==(t>>1&1)?1:-1)),C(i,i,I([],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 Sy(t,e,i){let r=t-e;return r<0?-r:Math.max(0,r-i)}function Ey(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,Sy(e,r,s))}var Ay=class{constructor(){this._boundingVolumeCache=new Ty(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,Ey(t,e,o,a,n)),l=Math.min(l,Ey(t,e,o+.5,-a-n,n)),l=Math.min(l,Ey(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=Sy(t.x,n,s),a=Sy(t.x,n-1,s),l=Sy(t.x,n+1,s),h=Math.min(o,a,l);return h===l?1:h===a?-1:0}allowVariableZoom(t,e){return C_(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 Df(t.z,e,t.z,t.x,t.y),o=r.terrain.getMinMaxElevation(i);s=o.minElevation??s,n=o.maxElevation??n}if(s/=Wu,n/=Wu,s+=1,n+=1,t.z<=0)return zy.fromAabb([-n,-n,-n],[n,n,n]);if(1===t.z)return zy.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=[my(0,0,t.x,t.y,t.z),my(et,0,t.x,t.y,t.z),my(et,et,t.x,t.y,t.z),my(0,et,t.x,t.y,t.z)],i=[];for(let t of e)i.push(I([],t,n));if(n!==s)for(let t of e)i.push(I([],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=my(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(I([],a,n)),t.y>=(1<<t.z)/2&&i.push(I([],my(et/2,0,t.x,t.y,t.z),n)),t.y<(1<<t.z)/2&&i.push(I([],my(et/2,et,t.x,t.y,t.z),n));let f=Py(a,i),p=Py(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 zy(w,[d,m,_,g,y,v],r,o)}}};function Py(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 Cy=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+wy(0,i),this.maxZoom);return{center:new Hu(t.lng,i),zoom:r}},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new ty({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new Ay}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),R(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),j(h,h,[0,0,0],this.center.lng*Math.PI/180);let u=1/A(h);return I(h,h,u),[...h,-n*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(_y(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=nc(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=my(t,e,s.x,s.y,s.z),o=1+(r?r(t,e):0)/Wu,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=gy(this.worldSize,this.center.lat),e=ot();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),T(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),R(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),O(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),C(this._cameraPosition,this._cameraPosition,[0,0,1]),R(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),j(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=ry.fromInvProjectionMatrix(n,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){Rt("calculateFogMatrix is not supported on globe projection.");let e=ot();return _(e),e}getVisibleUnwrappedCoordinates(t){return[new kf(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t?Rt("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=_y(t);I(i,i,1+e/Wu);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 e_(u)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}setLocationAtPoint(t,e){let i=_y(this.unprojectScreenPoint(e)),r=_y(t),s=nt();!function(t){t[0]=0,t[1]=0,t[2]=0}(s);let n=nt();j(n,i,s,-this.center.lng*Math.PI/180),R(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();j(f,r,s,-u);let p=pt(f[1],f[2],n[1],n[2]),d=nt();j(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 Hu(b,xt(x,-90,90))),this.setZoom(this.zoom+wy(M,this.center.lat))}locationToScreenPoint(t,e){let i=_y(t);return e&&I(i,i,1+e.getElevationForLngLatZoom(t,this._helper._tileZoom)/Wu),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 rc.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();I(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();C(t,e,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let s=nt();return k(s,t),yy(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)C(a,e,[i[0]*o,i[1]*o,i[2]*o]);else{let t=nt();C(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 yy(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 Df(0,0,0,0,0),applyGlobeMatrix:t});return e.tileMercatorCoords=[0,0,1,1],e}getFastPathSimpleProjectionMatrix(t){}},Iy=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 ty({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._globeness=1,this._mercatorTransform=new sy,this._verticalPerspectiveTransform=new Cy}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)}},ky=class t{get useGlobeControls(){return!0}handlePanInertia(t,e){let i=by(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();C(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=gy(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 Hu(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),T=Math.max(x,M)**.25,z=dt(b.lng,w.lng),S=dt(b.lat,w.lat);e.setCenter(new Hu(b.lng+z*T,b.lat+S*T).wrap()),e.setZoom(v+wy(y,e.center.lat))}handleMapControlsPan(t,e,i){if(!t.panDelta)return;let r=e.center.lat,s=e.zoom;e.setCenter(by(t.panDelta,e).wrap()),e.setZoom(s+wy(r,e.center.lat))}cameraForBoxAndBearing(e,i,r,s,n){let o=ay(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=[_y(r.getNorthWest()),_y(r.getNorthEast()),_y(r.getSouthWest()),_y(r.getSouthEast()),_y(new Hu(p,g)),_y(new Hu(f,g)),_y(new Hu(_,d)),_y(new Hu(_,m))],b=_y(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;ny()}handleJumpToCenterZoom(t,e){let i=t.center.lat,r=t.applyConstrain(e.center?Hu.convert(e.center):t.center,t.zoom).center;t.setCenter(r.wrap());let s=void 0===e.zoom?t.zoom+wy(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?Hu.convert(e.center):r,f=t.applyConstrain(c,i).center;Kg(t,f);let p=t.clone();p.setCenter(f),p.setZoom(a?+e.zoom:i+wy(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+wy(r.lat,m.lat),g=i+wy(r.lat,0),y=_+wy(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)||oy({startEulerAngles:n,endEulerAngles:o,tr:t,k:i,useSlerp:n.roll!=o.roll}),h&&t.interpolatePadding(s,e.padding,i),e.around)Rt("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=My(r,v,w,e);t.setCenter(s.wrap())}if(u){let e=sr.number(g,y,i)+wy(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(Hu.convert(e.center||e.locationAtOffset),s).center,h=i?+e.zoom:t.zoom+wy(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;Kg(t,f);let p=function(t,e,i){let r=D(_y(e),_y(i)),s=Math.acos(r),n=dy(t);return s/(2*Math.PI)*n}(t,r,f),d=s+wy(r.lat,0),m=h+wy(f.lat,0),_=At(m-d),g=Math.max("number"==typeof e.minZoom?+e.minZoom:t.minZoom,t.minZoom)+wy(f.lat,0),y=Math.min(g,d,m)+wy(0,f.lat),v=At(t.applyConstrain(f,y).zoom+wy(f.lat,0)-d),w=dt(r.lng,f.lng),b=dt(r.lat,f.lat);return{easeFunc:(i,s,a)=>{let l=My(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+wy(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}},Dy=class{constructor(t){this._globe=t,this._mercatorCameraHelper=new ly,this._verticalPerspectiveCameraHelper=new ky}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 Fy=function(){let t={},e=we.$version;for(let i in we.$root){let r=we.$root[i];if(r.required){let s=null;s="version"===i?e:"array"===r.type?[]:{},null!=s&&(t[i]=s)}}return t}();var $y=class extends ve{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 Wm(Vm(),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 Tm,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 km(t._requestManager,e.localIdeographFontFamily,i),this.lineAtlas=new jm(256,512),this.crossTileSymbolIndex=new Ug,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",ce()),x_().on(v_,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 fo,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 fm("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 pe(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 ye(rt(t)))}}loadJSON(t,e={},i){this.fire(new fm("dataloading")),this._frameRequest=new AbortController,tm.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 fm("dataloading")),this._load(Fy,{validate:!1})}_load(t,e,i){let r=e.transformStyle?e.transformStyle(i,t):t;if(!e.validate||!eo(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 Fm(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new Rm(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new fm("data")),this.fire(new cm)}}_createLayers(){let t=Me(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=Sf(e,this._globalState);if(t.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=t,qo(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=xm(t),n=i>1?"@2x":"",o={},a={};for(let{id:t,url:i}of s){let s=await e.transformRequest(Mm(i,n,".json"),"SpriteJSON");o[t]=pe(s,r);let l=await e.transformRequest(Mm(i,n,".png"),"SpriteImage");a[t]=am.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=tm.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 ye(r))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),e&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new fm("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 fm("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 ye(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 pm("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 fm("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)&&eo(this,t))return!1;(t=Ft(t)).layers=Me(t.layers);let r=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!Te(t.version,e.version))return[{command:"setStyle",args:[e]}];Te(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),Te(t.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),Te(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),Te(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),Te(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),Te(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),Te(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),Te(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),Te(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),Te(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),Te(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),Te(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),Te(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),Te(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)||Ee(s,i,r));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?Te(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&&Pe(t,e,s)?ze(i,{command:"setGeoJSONSourceData",args:[s,e[s].data]}):Ae(s,e,i,r)):Se(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(Ie),h=e.map(Ie),u=t.reduce(ke,{}),c=e.reduce(ke,{}),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++:(ze(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)?(ze(i,{command:"removeLayer",args:[r]}),f.splice(f.lastIndexOf(r,f.length-e),1)):e++,o=f[f.length-t],ze(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]&&!Te(s,n)){if(!Te(s.source,n.source)||!Te(s["source-layer"],n["source-layer"])||!Te(s.type,n.type)){ze(i,{command:"removeLayer",args:[r]}),o=f[f.lastIndexOf(r)+1],ze(i,{command:"addLayer",args:[n,o]});continue}for(a in Ce(s.layout,n.layout,i,r,null,"setLayoutProperty"),Ce(s.paint,n.paint,i,r,null,"setPaintProperty"),Te(s.filter,n.filter)||ze(i,{command:"setFilter",args:[r,n.filter]}),(!Te(s.minzoom,n.minzoom)||!Te(s.maxzoom,n.maxzoom))&&ze(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.")?Ce(s[a],n[a],i,r,a.slice(6),"setPaintProperty"):Te(s[a],n[a])||ze(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.")?Ce(s[a],n[a],i,r,a.slice(6),"setPaintProperty"):Te(s[a],n[a])||ze(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 cm({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 ye(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 ye(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 fm("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(to.has(e.type)&&this._validate(Qn.source,`sources.${t}`,e,null,i))return;this.map?._collectResourceTiming&&(e.collectResourceTiming=!0);let r=this.tileManagers[t]=new B_(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 ye(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 pm("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 ye(Error(`Layer "${s}" already exists on this map.`)));if("custom"===t.type){if(io(this,function(t){let e=[],i=t.id;return void 0===i&&e.push(new De(`layers.${i}`,null,'missing required property "id"')),void 0===t.render&&e.push(new De(`layers.${i}`,null,'missing required method "render"')),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push(new De(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),e}(t)))return;r=Sf(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(s,t.source),t=Tt(t=Ft(t),{source:s})),this._validate(Qn.layer,`layers.${s}`,t,{arrayIndex:-1},i))return;r=Sf(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 ye(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 ye(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 ye(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 ye(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 ye(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(Qn.filter,`layers.${r.id}.filter`,e,null,i)||(r.setFilter(Ft(e)),this._updateLayer(r))}}else this.fire(new ye(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 ye(Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){let i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new ye(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 ye(Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,e,i,r={}){t.setPaintProperty(e,i,r)&&this._updateLayer(t),qo(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 ye(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 ye(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new ye(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===t.id)return void this.fire(new ye(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 ye(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 ye(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 ye(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(n,t.id,e):this.fire(new ye(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 ye(Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id);this.fire(new ye(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new ye(Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return Tt({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=It(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(Qn.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 ye(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 ye(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(Jm(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(Km);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(Qn.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:im(),transition:Tt({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:im(),transition:Tt({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 py({type:t},i);return{projection:e,transform:new Iy(r),cameraHelper:new Dy(e)}}switch(t){case"mercator":return{projection:new Xg,transform:new sy(r),cameraHelper:new ly};case"globe":{let t=new py({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:t,transform:new Iy(r),cameraHelper:new Dy(t)}}case"vertical-perspective":return{projection:new fy,transform:new Cy(r),cameraHelper:new ky};default:return Rt(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Xg,transform:new sy(r),cameraHelper:new ly}}}(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 ro(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),x_().off(v_,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(im(),t.zoom))&&(this.pauseablePlacement=new Pg(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(im()),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(im())}_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(Qn.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=[...xm(this.stylesheet.sprite),...s];this._validate(Qn.sprite,"sprite",n,null,i)||(this.stylesheet.sprite=n,this._loadSprite(s,!0,r))}removeSprite(t){this._checkLoaded();let e=xm(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 fm("data"))}else this.fire(new ye(Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return xm(this.stylesheet.sprite)}setSprite(t,e={},i){this._checkLoaded(),(!t||!this._validate(Qn.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 Ry=Xo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var jy=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 Oy=(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"):Ei.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"):Ei.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!s}),Ly=t=>({u_ele_delta:t}),By=(t,e)=>({u_terrain_coords_id:t/255,u_texture:0,u_ele_delta:e});function Ny(t){let e=[];for(let i of t){if(null===i)continue;let t=i.split(" ");e.push(t.pop())}return e}var Uy=class{constructor(t,e,i,r,s,n,o,a,l=[]){let h=t.gl;this.program=h.createProgram();let u=Ny(e.staticAttributes),c=i?i.getBinderAttributes():[],f=u.concat(c),p=Vg.prelude.staticUniforms?Ny(Vg.prelude.staticUniforms):[],d=o.staticUniforms?Ny(o.staticUniforms):[],m=e.staticUniforms?Ny(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(Vg.prelude.fragmentSource,o.fragmentSource,e.fragmentSource).join("\n"),b=v.concat(Vg.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 T={};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&&!T[t]){let e=h.getUniformLocation(this.program,t);e&&(T[t]=e)}this.fixedUniforms=r(t,T),this.terrainUniforms=((t,e)=>({u_depth:new pl(t,e.u_depth),u_terrain:new pl(t,e.u_terrain),u_terrain_dim:new dl(t,e.u_terrain_dim),u_terrain_matrix:new xl(t,e.u_terrain_matrix),u_terrain_unpack:new gl(t,e.u_terrain_unpack),u_terrain_exaggeration:new dl(t,e.u_terrain_exaggeration)}))(t,T),this.projectionUniforms=((t,e)=>({u_projection_matrix:new xl(t,e.u_projection_matrix),u_projection_tile_mercator_coords:new gl(t,e.u_projection_tile_mercator_coords),u_projection_clipping_plane:new gl(t,e.u_projection_clipping_plane),u_projection_transition:new dl(t,e.u_projection_transition),u_projection_fallback_matrix:new xl(t,e.u_projection_fallback_matrix),u_projection_clip_antimeridian:new pl(t,e.u_projection_clip_antimeridian)}))(t,T),this.binderUniforms=i?i.getUniforms(t,T):[]}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 jy,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 Gy(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 Vy=(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}},qy=(t,e,i,r,s,n,o)=>Tt(Vy(t,e,i,r),Gy(n,t,o),{u_height_factor:-(2**s.overscaledZ)/o.tileSize/8}),Zy=(t,e,i,r)=>Tt(Gy(e,t,i),{u_fill_translate:r}),Wy=t=>({u_fill_translate:t}),Hy=(t,e)=>({u_world:t,u_fill_translate:e}),Yy=(t,e,i,r,s)=>Tt(Zy(t,e,i,s),{u_world:r}),Xy=(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}},Jy=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Ky=t=>({u_viewport_size:[t.width,t.height]}),Qy=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),tv=(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}},ev=(t,e,i,r)=>{let s=d();z(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")}},iv=(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:sv(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}},rv=(t,e)=>{let i=e.stride,r=d();return z(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 sv(t,e){let i=2**e.canonical.z,r=e.canonical.y;return[new rc(0,r/i).toLngLat().lat,new rc(0,(r+1)/i).toLngLat().lat]}const nv=(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")}),ov=(t,e,i,r)=>{let s=t.transform;return{u_translation:fv(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]]}},av=(t,e,i,r,s)=>Tt(ov(t,e,i,r),{u_image:0,u_image_height:s}),lv=(t,e,i,r,s)=>{let n=t.transform,o=cv(e,n);return{u_translation:fv(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]]}},hv=(t,e,i,r,s)=>{let n=cv(e,t.transform);return Tt(ov(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})},uv=(t,e,i,r,s,n)=>{let o=cv(e,t.transform);return Tt(ov(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 cv(t,e){return 1/it(t,1,e.tileZoom)}function fv(t,e,i){return ht(t.transform,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const pv=(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:_v(r.paint.get("raster-saturation")),u_contrast_factor:mv(r.paint.get("raster-contrast")),u_spin_weights:dv(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 dv(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 mv(t){return t>0?1/(1-t):1+t}function _v(t){return t>0?1-1/(1.001-t):-t}const gv=(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}},yv=(t,e,i,r,s,n,o,a,l,h,u,c,f,p,d)=>{let m=o.transform;return Tt(gv(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})},vv=(t,e,i,r,s,n,o,a,l,h,u,c,f,p)=>Tt(yv(t,e,i,r,s,n,o,a,l,h,!0,u,!0,f,p),{u_texsize_icon:c,u_texture_icon:1}),wv=(t,e)=>({u_opacity:t,u_color:e}),bv=(t,e,i,r,s)=>Tt(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}),xv=()=>{},Mv={fillExtrusion:(t,e)=>({u_lightpos:new _l(t,e.u_lightpos),u_lightpos_globe:new _l(t,e.u_lightpos_globe),u_lightintensity:new dl(t,e.u_lightintensity),u_lightcolor:new _l(t,e.u_lightcolor),u_vertical_gradient:new dl(t,e.u_vertical_gradient),u_opacity:new dl(t,e.u_opacity),u_fill_translate:new ml(t,e.u_fill_translate)}),fillExtrusionPattern:(t,e)=>({u_lightpos:new _l(t,e.u_lightpos),u_lightpos_globe:new _l(t,e.u_lightpos_globe),u_lightintensity:new dl(t,e.u_lightintensity),u_lightcolor:new _l(t,e.u_lightcolor),u_vertical_gradient:new dl(t,e.u_vertical_gradient),u_height_factor:new dl(t,e.u_height_factor),u_opacity:new dl(t,e.u_opacity),u_fill_translate:new ml(t,e.u_fill_translate),u_image:new pl(t,e.u_image),u_texsize:new ml(t,e.u_texsize),u_pixel_coord_upper:new ml(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ml(t,e.u_pixel_coord_lower),u_scale:new _l(t,e.u_scale),u_fade:new dl(t,e.u_fade)}),fill:(t,e)=>({u_fill_translate:new ml(t,e.u_fill_translate)}),fillPattern:(t,e)=>({u_image:new pl(t,e.u_image),u_texsize:new ml(t,e.u_texsize),u_pixel_coord_upper:new ml(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ml(t,e.u_pixel_coord_lower),u_scale:new _l(t,e.u_scale),u_fade:new dl(t,e.u_fade),u_fill_translate:new ml(t,e.u_fill_translate)}),fillOutline:(t,e)=>({u_world:new ml(t,e.u_world),u_fill_translate:new ml(t,e.u_fill_translate)}),fillOutlinePattern:(t,e)=>({u_world:new ml(t,e.u_world),u_image:new pl(t,e.u_image),u_texsize:new ml(t,e.u_texsize),u_pixel_coord_upper:new ml(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ml(t,e.u_pixel_coord_lower),u_scale:new _l(t,e.u_scale),u_fade:new dl(t,e.u_fade),u_fill_translate:new ml(t,e.u_fill_translate)}),circle:(t,e)=>({u_camera_to_center_distance:new dl(t,e.u_camera_to_center_distance),u_scale_with_map:new pl(t,e.u_scale_with_map),u_pitch_with_map:new pl(t,e.u_pitch_with_map),u_extrude_scale:new ml(t,e.u_extrude_scale),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_globe_extrude_scale:new dl(t,e.u_globe_extrude_scale),u_translate:new ml(t,e.u_translate)}),collisionBox:(t,e)=>({u_pixel_extrude_scale:new ml(t,e.u_pixel_extrude_scale)}),collisionCircle:(t,e)=>({u_viewport_size:new ml(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new yl(t,e.u_color),u_overlay:new pl(t,e.u_overlay),u_overlay_scale:new dl(t,e.u_overlay_scale)}),depth:xv,clippingMask:xv,heatmap:(t,e)=>({u_extrude_scale:new dl(t,e.u_extrude_scale),u_intensity:new dl(t,e.u_intensity),u_globe_extrude_scale:new dl(t,e.u_globe_extrude_scale)}),heatmapTexture:(t,e)=>({u_matrix:new xl(t,e.u_matrix),u_world:new ml(t,e.u_world),u_image:new pl(t,e.u_image),u_color_ramp:new pl(t,e.u_color_ramp),u_opacity:new dl(t,e.u_opacity)}),hillshade:(t,e)=>({u_image:new pl(t,e.u_image),u_latrange:new ml(t,e.u_latrange),u_exaggeration:new dl(t,e.u_exaggeration),u_altitudes:new wl(t,e.u_altitudes),u_azimuths:new wl(t,e.u_azimuths),u_accent:new yl(t,e.u_accent),u_method:new pl(t,e.u_method),u_shadows:new vl(t,e.u_shadows),u_highlights:new vl(t,e.u_highlights)}),hillshadePrepare:(t,e)=>({u_matrix:new xl(t,e.u_matrix),u_image:new pl(t,e.u_image),u_dimension:new ml(t,e.u_dimension),u_zoom:new dl(t,e.u_zoom),u_unpack:new gl(t,e.u_unpack)}),colorRelief:(t,e)=>({u_image:new pl(t,e.u_image),u_unpack:new gl(t,e.u_unpack),u_dimension:new ml(t,e.u_dimension),u_elevation_stops:new pl(t,e.u_elevation_stops),u_color_stops:new pl(t,e.u_color_stops),u_color_ramp_size:new pl(t,e.u_color_ramp_size),u_opacity:new dl(t,e.u_opacity)}),line:(t,e)=>({u_translation:new ml(t,e.u_translation),u_ratio:new dl(t,e.u_ratio),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_units_to_pixels:new ml(t,e.u_units_to_pixels)}),lineGradient:(t,e)=>({u_translation:new ml(t,e.u_translation),u_ratio:new dl(t,e.u_ratio),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_units_to_pixels:new ml(t,e.u_units_to_pixels),u_image:new pl(t,e.u_image),u_image_height:new dl(t,e.u_image_height)}),linePattern:(t,e)=>({u_translation:new ml(t,e.u_translation),u_texsize:new ml(t,e.u_texsize),u_ratio:new dl(t,e.u_ratio),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_image:new pl(t,e.u_image),u_units_to_pixels:new ml(t,e.u_units_to_pixels),u_scale:new _l(t,e.u_scale),u_fade:new dl(t,e.u_fade)}),lineSDF:(t,e)=>({u_translation:new ml(t,e.u_translation),u_ratio:new dl(t,e.u_ratio),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_units_to_pixels:new ml(t,e.u_units_to_pixels),u_image:new pl(t,e.u_image),u_mix:new dl(t,e.u_mix),u_tileratio:new dl(t,e.u_tileratio),u_crossfade_from:new dl(t,e.u_crossfade_from),u_crossfade_to:new dl(t,e.u_crossfade_to),u_lineatlas_width:new dl(t,e.u_lineatlas_width),u_lineatlas_height:new dl(t,e.u_lineatlas_height)}),lineGradientSDF:(t,e)=>({u_translation:new ml(t,e.u_translation),u_ratio:new dl(t,e.u_ratio),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_units_to_pixels:new ml(t,e.u_units_to_pixels),u_image:new pl(t,e.u_image),u_image_height:new dl(t,e.u_image_height),u_tileratio:new dl(t,e.u_tileratio),u_crossfade_from:new dl(t,e.u_crossfade_from),u_crossfade_to:new dl(t,e.u_crossfade_to),u_image_dash:new pl(t,e.u_image_dash),u_mix:new dl(t,e.u_mix),u_lineatlas_width:new dl(t,e.u_lineatlas_width),u_lineatlas_height:new dl(t,e.u_lineatlas_height)}),layerOpacity:(t,e)=>({u_image:new pl(t,e.u_image),u_opacity:new dl(t,e.u_opacity)}),raster:(t,e)=>({u_tl_parent:new ml(t,e.u_tl_parent),u_scale_parent:new dl(t,e.u_scale_parent),u_buffer_scale:new dl(t,e.u_buffer_scale),u_fade_t:new dl(t,e.u_fade_t),u_opacity:new dl(t,e.u_opacity),u_image0:new pl(t,e.u_image0),u_image1:new pl(t,e.u_image1),u_brightness_low:new dl(t,e.u_brightness_low),u_brightness_high:new dl(t,e.u_brightness_high),u_saturation_factor:new dl(t,e.u_saturation_factor),u_contrast_factor:new dl(t,e.u_contrast_factor),u_spin_weights:new _l(t,e.u_spin_weights),u_coords_top:new gl(t,e.u_coords_top),u_coords_bottom:new gl(t,e.u_coords_bottom)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new pl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new pl(t,e.u_is_size_feature_constant),u_size_t:new dl(t,e.u_size_t),u_size:new dl(t,e.u_size),u_camera_to_center_distance:new dl(t,e.u_camera_to_center_distance),u_pitch:new dl(t,e.u_pitch),u_rotate_symbol:new pl(t,e.u_rotate_symbol),u_aspect_ratio:new dl(t,e.u_aspect_ratio),u_fade_change:new dl(t,e.u_fade_change),u_label_plane_matrix:new xl(t,e.u_label_plane_matrix),u_coord_matrix:new xl(t,e.u_coord_matrix),u_is_text:new pl(t,e.u_is_text),u_pitch_with_map:new pl(t,e.u_pitch_with_map),u_is_along_line:new pl(t,e.u_is_along_line),u_is_variable_anchor:new pl(t,e.u_is_variable_anchor),u_texsize:new ml(t,e.u_texsize),u_texture:new pl(t,e.u_texture),u_translation:new ml(t,e.u_translation),u_pitched_scale:new dl(t,e.u_pitched_scale),u_is_offset:new pl(t,e.u_is_offset)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new pl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new pl(t,e.u_is_size_feature_constant),u_size_t:new dl(t,e.u_size_t),u_size:new dl(t,e.u_size),u_camera_to_center_distance:new dl(t,e.u_camera_to_center_distance),u_pitch:new dl(t,e.u_pitch),u_rotate_symbol:new pl(t,e.u_rotate_symbol),u_aspect_ratio:new dl(t,e.u_aspect_ratio),u_fade_change:new dl(t,e.u_fade_change),u_label_plane_matrix:new xl(t,e.u_label_plane_matrix),u_coord_matrix:new xl(t,e.u_coord_matrix),u_is_text:new pl(t,e.u_is_text),u_pitch_with_map:new pl(t,e.u_pitch_with_map),u_is_along_line:new pl(t,e.u_is_along_line),u_is_variable_anchor:new pl(t,e.u_is_variable_anchor),u_texsize:new ml(t,e.u_texsize),u_texture:new pl(t,e.u_texture),u_gamma_scale:new dl(t,e.u_gamma_scale),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_is_halo:new pl(t,e.u_is_halo),u_is_plain:new pl(t,e.u_is_plain),u_translation:new ml(t,e.u_translation),u_pitched_scale:new dl(t,e.u_pitched_scale),u_is_offset:new pl(t,e.u_is_offset)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new pl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new pl(t,e.u_is_size_feature_constant),u_size_t:new dl(t,e.u_size_t),u_size:new dl(t,e.u_size),u_camera_to_center_distance:new dl(t,e.u_camera_to_center_distance),u_pitch:new dl(t,e.u_pitch),u_rotate_symbol:new pl(t,e.u_rotate_symbol),u_aspect_ratio:new dl(t,e.u_aspect_ratio),u_fade_change:new dl(t,e.u_fade_change),u_label_plane_matrix:new xl(t,e.u_label_plane_matrix),u_coord_matrix:new xl(t,e.u_coord_matrix),u_is_text:new pl(t,e.u_is_text),u_pitch_with_map:new pl(t,e.u_pitch_with_map),u_is_along_line:new pl(t,e.u_is_along_line),u_is_variable_anchor:new pl(t,e.u_is_variable_anchor),u_texsize:new ml(t,e.u_texsize),u_texsize_icon:new ml(t,e.u_texsize_icon),u_texture:new pl(t,e.u_texture),u_texture_icon:new pl(t,e.u_texture_icon),u_gamma_scale:new dl(t,e.u_gamma_scale),u_device_pixel_ratio:new dl(t,e.u_device_pixel_ratio),u_is_halo:new pl(t,e.u_is_halo),u_translation:new ml(t,e.u_translation),u_pitched_scale:new dl(t,e.u_pitched_scale),u_is_offset:new pl(t,e.u_is_offset)}),background:(t,e)=>({u_opacity:new dl(t,e.u_opacity),u_color:new yl(t,e.u_color)}),backgroundPattern:(t,e)=>({u_opacity:new dl(t,e.u_opacity),u_image:new pl(t,e.u_image),u_pattern_tl_a:new ml(t,e.u_pattern_tl_a),u_pattern_br_a:new ml(t,e.u_pattern_br_a),u_pattern_tl_b:new ml(t,e.u_pattern_tl_b),u_pattern_br_b:new ml(t,e.u_pattern_br_b),u_texsize:new ml(t,e.u_texsize),u_mix:new dl(t,e.u_mix),u_pattern_size_a:new ml(t,e.u_pattern_size_a),u_pattern_size_b:new ml(t,e.u_pattern_size_b),u_scale_a:new dl(t,e.u_scale_a),u_scale_b:new dl(t,e.u_scale_b),u_pixel_coord_upper:new ml(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ml(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new dl(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_texture:new pl(t,e.u_texture),u_ele_delta:new dl(t,e.u_ele_delta),u_fog_matrix:new xl(t,e.u_fog_matrix),u_fog_color:new yl(t,e.u_fog_color),u_fog_ground_blend:new dl(t,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new dl(t,e.u_fog_ground_blend_opacity),u_horizon_color:new yl(t,e.u_horizon_color),u_horizon_fog_blend:new dl(t,e.u_horizon_fog_blend),u_is_globe_mode:new dl(t,e.u_is_globe_mode)}),terrainDepth:(t,e)=>({u_ele_delta:new dl(t,e.u_ele_delta)}),terrainCoords:(t,e)=>({u_texture:new pl(t,e.u_texture),u_terrain_coords_id:new dl(t,e.u_terrain_coords_id),u_ele_delta:new dl(t,e.u_ele_delta)}),atmosphere:(t,e)=>({u_sun_pos:new _l(t,e.u_sun_pos),u_atmosphere_blend:new dl(t,e.u_atmosphere_blend),u_globe_position:new _l(t,e.u_globe_position),u_globe_radius:new dl(t,e.u_globe_radius),u_inv_proj_matrix:new xl(t,e.u_inv_proj_matrix)}),sky:(t,e)=>({u_sky_color:new yl(t,e.u_sky_color),u_horizon_color:new yl(t,e.u_horizon_color),u_horizon:new ml(t,e.u_horizon),u_horizon_normal:new ml(t,e.u_horizon_normal),u_sky_horizon_blend:new dl(t,e.u_sky_horizon_blend),u_sky_blend:new dl(t,e.u_sky_blend)})};var Tv=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 zv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var Sv=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[zv[r.type]],!1,this.itemSize,r.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}},Ev=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)}},Av=class extends Ev{getDefault(){return Ei.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)}},Pv=class extends Ev{getDefault(){return 1}set(t){t===this.current&&!this.dirty||(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},Cv=class extends Ev{getDefault(){return 0}set(t){t===this.current&&!this.dirty||(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},Iv=class extends Ev{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)}},kv=class extends Ev{getDefault(){return!0}set(t){t===this.current&&!this.dirty||(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},Dv=class extends Ev{getDefault(){return 255}set(t){t===this.current&&!this.dirty||(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},Fv=class extends Ev{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)}},$v=class extends Ev{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)}},Rv=class extends Ev{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}},jv=class extends Ev{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)}},Ov=class extends Ev{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}},Lv=class extends Ev{getDefault(){return this.gl.LESS}set(t){t===this.current&&!this.dirty||(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},Bv=class extends Ev{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}},Nv=class extends Ev{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)}},Uv=class extends Ev{getDefault(){return Ei.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)}},Gv=class extends Ev{getDefault(){return this.gl.FUNC_ADD}set(t){t===this.current&&!this.dirty||(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},Vv=class extends Ev{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}},qv=class extends Ev{getDefault(){return this.gl.BACK}set(t){t===this.current&&!this.dirty||(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},Zv=class extends Ev{getDefault(){return this.gl.CCW}set(t){t===this.current&&!this.dirty||(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},Wv=class extends Ev{getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},Hv=class extends Ev{getDefault(){return this.gl.TEXTURE0}set(t){t===this.current&&!this.dirty||(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},Yv=class extends Ev{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)}},Xv=class extends Ev{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}},Jv=class extends Ev{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}},Kv=class extends Ev{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}},Qv=class extends Ev{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}},tw=class extends Ev{getDefault(){return null}set(t){let e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},ew=class extends Ev{getDefault(){return null}set(t){t===this.current&&!this.dirty||(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},iw=class extends Ev{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}},rw=class extends Ev{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}},sw=class extends Ev{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}},nw=class extends Ev{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}},ow=class extends nw{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}},aw=class extends nw{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}},lw=class extends nw{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}},hw=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 ow(t,n),r)this.depthAttachment=s?new lw(t,n):new aw(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)}},uw=class{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}};uw.Replace=[1,0],uw.disabled=new uw(uw.Replace,Ei.transparent,[!1,!1,!1,!1]),uw.unblended=new uw(uw.Replace,Ei.transparent,[!0,!0,!0,!0]),uw.alphaBlended=new uw([1,771],Ei.transparent,[!0,!0,!0,!0]);var cw=class{constructor(t){this.gl=t,this.clearColor=new Av(this),this.clearDepth=new Pv(this),this.clearStencil=new Cv(this),this.colorMask=new Iv(this),this.depthMask=new kv(this),this.stencilMask=new Dv(this),this.stencilFunc=new Fv(this),this.stencilOp=new $v(this),this.stencilTest=new Rv(this),this.depthRange=new jv(this),this.depthTest=new Ov(this),this.depthFunc=new Lv(this),this.blend=new Bv(this),this.blendFunc=new Nv(this),this.blendColor=new Uv(this),this.blendEquation=new Gv(this),this.cullFace=new Vv(this),this.cullFaceSide=new qv(this),this.frontFace=new Zv(this),this.program=new Wv(this),this.activeTexture=new Hv(this),this.viewport=new Yv(this),this.bindFramebuffer=new Xv(this),this.bindRenderbuffer=new Jv(this),this.bindTexture=new Kv(this),this.bindVertexBuffer=new Qv(this),this.bindElementBuffer=new tw(this),this.bindVertexArray=new ew(this),this.pixelStoreUnpack=new iw(this),this.pixelStoreUnpackPremultiplyAlpha=new rw(this),this.pixelStoreUnpackFlipY=new sw(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 Tv(this,t,e)}createVertexBuffer(t,e,i){return new Sv(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 hw(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,uw.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)}},fw=class{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}};fw.ReadOnly=!1,fw.ReadWrite=!0,fw.disabled=new fw(519,fw.ReadOnly,[0,1]);const pw=7680;var dw=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}};dw.disabled=new dw({func:519,mask:0},0,0,pw,pw,pw);const mw=2305;var _w=class{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}};let gw;function yw(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,fw.disabled,dw.disabled,t.colorModeForRenderPass(),_w.disabled,Jy(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 Ha;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)}(!gw||gw.length<2*u)&&(gw=function(t){let e=2*t,i=new Xa;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(gw,!0),_=n.createVertexBuffer(p,Gc.members,!0);for(let e of h){let r=Ky(t.transform);f.draw(n,a.TRIANGLES,fw.disabled,dw.disabled,t.colorModeForRenderPass(),_w.disabled,r,t.style.map.terrain?.getTerrainData(e.coord),null,i.id,_,m,el.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null)}_.destroy(),m.destroy()}_w.disabled=new _w(!1,1029,mw),_w.backCCW=new _w(!0,1029,mw),_w.frontCCW=new _w(!0,1028,mw);const vw=_(new Float32Array(16));function ww(t,e,i,r,s,n){let{horizontalAlign:o,verticalAlign:a}=sf(t);return new l((-(o-.5)*e/s+r[0])*n,(-(a-.5)*i/s+r[1])*n)}function bw(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 Y_(a.x,a.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(i){let i=sg(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 xw(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?og(r.x,r.y,p):sg(r.x,r.y,p),v=X_(s.cameraToCenterDistance,m.signedDistanceFromCamera),w=of(t.textSizeData,a,g)*v/24;i&&(w*=t.tilePixelRatio/o);let{width:b,height:x,anchor:M,textOffset:T,textBoxScale:z}=y,S=ww(M,b,x,T,z,w),E=s.getPitchedTextCorrection(r.x+u[0],r.y+u[1],c),A=bw(m.point,p,e,S,-s.bearingInRadians,E),P=t.allowVerticalPlacement&&2===g.placedOrientation?Math.PI/2:0;for(let t=0;t<g.numGlyphs;t++)cf(d,A,P);h&&g.associatedIconIndex>=0&&(_[g.associatedIconIndex]={shiftedAnchor:A,angle:P})}else cg(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)cg(i.numGlyphs,m);else{let e=_[t];if(e)for(let t=0;t<i.numGlyphs;t++)cf(m,e.shiftedAnchor,e.angle);else cg(i.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(d)}function Mw(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function Tw(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,fw.ReadOnly),T=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),z=[],S=_.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,C=s?l.textSizeData:l.iconSizeData,I=y||0!==_.pitch,k=t.useProgram(Mw(P,s,l),A),D=af(C,_.zoom),F=t.style.map.terrain?.getTerrainData(a),$=[0,0],R=null;if(s)p=r.glyphAtlasTexture,M=m.LINEAR,c=r.glyphAtlasTexture.size,l.iconsInText&&($=r.imageAtlasTexture.size,R=r.imageAtlasTexture,E=I||t.options.rotating||t.options.zooming||"composite"===C.kind||"camera"===C.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||I?m.LINEAR:m.NEAREST,c=r.imageAtlasTexture.size}let j=it(r,1,t.transform.zoom),O=Z_(g,t.transform,j),L=W_(y,g,t.transform,j),B=ht(_,r,n,o),N=_.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!f,applyTerrainMatrix:!0}),U=T&&l.hasTextData(),G="none"!==i.layout.get("icon-text-fit")&&U&&l.hasIconData(),V=i._unevaluatedLayout.hasValue("icon-offset");if(v){let e=d();V_(e,O);let r=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(a,e,i):null;K_(l,t,s,O,e,y,h,"map"===i.layout.get("text-rotation-alignment"),a.toUnwrapped(),_.width,_.height,B,r)}let q,Z=s&&T||G,W=v||Z?vw:y?O:t.transform.clipSpaceToPixelsMatrix,H=P&&0!==i.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);q=P?l.iconsInText?vv(C.kind,D,w,y,v,Z,t,W,L,B,c,$,S,V):yv(C.kind,D,w,y,v,Z,t,W,L,B,s,c,H,S,V):gv(C.kind,D,w,y,v,Z,t,W,L,B,s,c,S,V);let Y={program:k,buffers:u,uniformValues:q,projectionData:N,atlasTexture:p,atlasTextureIcon:R,atlasInterpolation:M,atlasInterpolationIcon:E,isSDF:P,hasHalo:H};if(b&&l.canOverlap){x=!0;let t=u.segments.get();for(let e of t)z.push({segments:new el([e]),sortKey:e.sortKey,state:Y,terrainData:F})}else z.push({segments:u.segments,sortKey:0,state:Y,terrainData:F})}x&&z.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 z){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,zw(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)}zw(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 zw(t,e,i,r,s,n,o,a,l,h,u){let c=r.context;s.draw(c,c.gl.TRIANGLES,n,o,a,_w.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 Sw(t,e,i,r,s){let n=t.context,o=n.gl,a=dw.disabled,l=new uw([o.ONE,o.ONE],Ei.transparent,[!0,!0,!0,!0]),h=e.getBucket(i);if(!h)return;let u=r.key,c=i.heatmapFbos.get(u);c||(c=Aw(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:Ei.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,fw.disabled,a,l,_w.disabled,tv(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 Ew(t,e,i,r,s){let n=t.context,o=n.gl,a=t.transform;n.setColorMode(t.colorModeForRenderPass());let l=Pw(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,fw.disabled,dw.disabled,t.colorModeForRenderPass(),_w.disabled,ev(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 Aw(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 Pw(t,e){return e.colorRampTexture||=new Ih(t,e.colorRamp,t.gl.RGBA),e.colorRampTexture}function Cw(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:Ei.transparent,depth:1,stencil:0}),t.currentStencilSource=void 0,t.renderTileClippingMasks(e,i,r),{compositeTarget:n,compositeViewport:o}}function Iw(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,fw.disabled,dw.disabled,t.colorModeForRenderPass(),_w.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 kw(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=xh({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 Ih(i,a.gradient,r.RGBA),a.version=s.gradientVersion,a.texture}function Dw(t,e,i,r,s){t.activeTexture.set(e.TEXTURE0),i.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),r.updatePaintBuffers(s)}function Fw(t,e,i,r,s,n){(s||t.lineAtlas.dirty)&&(e.activeTexture.set(i.TEXTURE0),t.lineAtlas.bind(e)),r.updatePaintBuffers(n)}function $w(t,e,i,r,s,n,o){let a=n.gradients[s.id],l=a.texture;s.gradientVersion!==a.version&&(l=kw(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 Rw(t,e,i,r,s,n,o,a,l){let h=n.gradients[s.id],u=h.texture;s.gradientVersion!==h.version&&(u=kw(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 jw(t,e,i,r,s,n){let o,{isRenderingToTexture:a}=s,l=t.getDepthModeForSublayer(0,fw.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),T=v||M.program!==x,z=n?t.getTerrainDataForTile(s,a):null,S=f.constantOr(null),E=u?.constantOr(null);if(S&&r.imageAtlas){let t=r.imageAtlas,e=t.patternPositions[S.to.toString()],i=t.patternPositions[S.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}),C=y.getPixelScale();p?(A=lv(t,r,i,C,m),Dw(_,g,r,b,m)):c&&d?(A=uv(t,r,i,C,m,w.lineClipsArray.length),Rw(t,e,_,g,i,w,s,b,m)):c?(A=hv(t,r,i,C,m),Fw(t,_,g,b,T,m)):d?(A=av(t,r,i,C,w.lineClipsArray.length),$w(t,e,_,g,i,w,s)):A=ov(t,r,i,C);let I=t.stencilModeForClipping(s);M.draw(_,g.TRIANGLES,l,I,h,_w.disabled,A,z,P,i.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,i.paint,t.transform.zoom,b,w.layoutVertexBuffer2),v=!1}}function Ow(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 Lw(t,e,i,r,s){let{isRenderingToTexture:n}=s,o=t.colorModeForRenderPass();Nw(t,e,i,r,t.getDepthModeForSublayer(1,fw.ReadOnly),o,!1,n),Bw(t,e,i,r,s)}function Bw(t,e,i,r,s){if(!i.paint.get("fill-antialias"))return;let{isRenderingToTexture:n}=s,o=t.colorModeForRenderPass();Nw(t,e,i,r,t.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,fw.ReadOnly),o,!0,n)}function Nw(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),T=t.useProgram(h,M),z=t.getTerrainDataForTile(m,a);_&&(t.context.activeTexture.set(p.TEXTURE0),r.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),M.updatePaintBuffers(g)),Ow(M,d,b,r,i);let S=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&&_?Yy(t,g,r,e,E):Hy(e,E)}else c=x.indexBuffer,f=x.segments,u=_?Zy(t,g,r,E):Wy(E);let A=t.stencilModeForClipping(m);T.draw(t.context,l,s,A,n,_w.backCCW,u,z,S,i.id,x.layoutVertexBuffer,c,f,i.paint,t.transform.zoom,M)}}function Uw(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});Ow(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"),T=f?qy(t,M,d,x,c,p,r):Vy(t,M,d,x);w.draw(l,l.gl.TRIANGLES,s,n,o,_w.backCCW,T,y,b,i.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,i.paint,t.transform.zoom,v,t.style.map.terrain&&g.centroidVertexBuffer)}}function Gw(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,_w.backCCW,iv(t,r,i),y,v,i.id,g.vertexBuffer,g.indexBuffer,g.segments)}}let Vw=0;function qw(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(_){Vw||=f.getParameter(f.MAX_TEXTURE_SIZE);let t=Vw,{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 Ih(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),T=c.getProjectionData({overscaledTileID:y,aligned:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,f.TRIANGLES,n,s[y.overscaledZ],o,_w.backCCW,nv(i,r.dem,g),M,T,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}}const Zw=[new l(0,0),new l(et,0),new l(et,et),new l(0,et)];function Ww(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?fw.ReadWrite:fw.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:T,parentScaleBy:z,parentTopLeft:S,fadeValues:E}=Hw(M,e,w,b);M.fadeOpacity=E.tileOpacity,T?(T.fadeOpacity=E.parentTileOpacity,T.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}),C=pv(S,z,E.fadeMix,i,a),I=m.getMeshFromTileID(c,x.canonical,n,o,"raster");p.draw(c,f.TRIANGLES,r,s?s[x.overscaledZ]:dw.disabled,_,l?_w.frontCCW:_w.backCCW,C,A,P,i.id,I.vertexBuffer,I.indexBuffer,I.segments)}}function Hw(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:Yw(t,r,i)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:Xw(t,i)}:s}function Yw(t,e,i){let r=im(),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 Xw(t,e){let i=xt((im()-t.timeAdded)/e,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}const Jw=new Ei(1,0,0,1),Kw=new Ei(0,1,0,1),Qw=new Ei(0,0,1,1),tb=new Ei(1,0,1,1),eb=new Ei(0,1,1,1);function ib(t,e,i,r){sb(t,0,e+i/2,t.transform.width,i,r)}function rb(t,e,i,r){sb(t,e-i/2,0,i,t.transform.height,r)}function sb(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 nb(t,e,i){let r=t.context,s=r.gl,n=t.useProgram("debug"),o=fw.disabled,a=dw.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,uw.alphaBlended,_w.disabled,Qy(Ei.transparent,d),null,_,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),n.draw(r,s.LINE_STRIP,o,a,l,_w.disabled,Qy(Ei.red),u,_,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function ob(t,e){if(!e.mesh){let i=new Fa;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);let r=new Ja;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),e.mesh=new Zg(t.createVertexBuffer(i,Wg.members),t.createIndexBuffer(r),el.simpleSegment(0,0,i.length,r.length))}return e.mesh}const ab={symbol:function(t,e,i,r,s,n){if("translucent"!==t.renderPass)return;let{isRenderingToTexture:o}=n,a=dw.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=af(n.textSizeData,h.zoom),d=it(t,1,e.transform.zoom),m=Z_(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;xw(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)&&Tw(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)&&Tw(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&&(yw(t,e,i,r,!0),yw(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,fw.ReadOnly),d=dw.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:Xy(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 el([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,_w.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?Sw(t,r,i,s,a):"translucent"===t.renderPass&&Ew(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=dw.disabled,l=new uw([n.ONE,n.ONE],Ei.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(Mh);s?(r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer)):(s=Aw(t,e.width/4,e.height/4),i.heatmapFbos.set(Mh,s))})(s,t,i),s.clear({color:Ei.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,fw.disabled,a,l,_w.backCCW,tv(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(Mh);s&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),Pw(i,e).bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,fw.disabled,dw.disabled,t.colorModeForRenderPass(),_w.disabled,ev(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=Cw(t,i,r,l);return jw(t,e,i,r,s,l),void Iw(t,a,n,i)}jw(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=Cw(t,i,r,!!t.style.map.terrain);return Lw(t,e,i,r,s),void Iw(t,a,n,i)}let l=i.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(Ei.transparent).a&&1===o.constantOr(0);if(h&&"opaque"===t.renderPass){let{isRenderingToTexture:n}=s,o=t.colorModeForRenderPass();Nw(t,e,i,r,t.getDepthModeForSublayer(1,fw.ReadWrite),o,!1,n)}else h&&"translucent"===t.renderPass?Bw(t,e,i,r,s):"translucent"===t.renderPass&&Lw(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 fw(t.context.gl.LEQUAL,fw.ReadWrite,t.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))Uw(t,e,i,r,s,dw.disabled,uw.disabled,o),Uw(t,e,i,r,s,t.stencilModeFor3D(),t.colorModeForRenderPass(),o);else{let n=t.colorModeForRenderPass();Uw(t,e,i,r,s,dw.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,fw.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 Ih(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 Ih(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,_w.disabled,rv(i.tileID,c),null,null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(t,e,r,i,l,dw.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);Gw(t,e,i,a,s,l,h,!1,n),Gw(t,e,i,a,o,l,h,!0,n)}else{let[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);Gw(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,fw.ReadOnly),l=t.colorModeForRenderPass();if(o){let[s,o,h]=t.stencilConfigForOverlapTwoPass(r);qw(t,e,i,h,s,a,l,!1,n),qw(t,e,i,h,o,a,l,!0,n)}else{let[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);qw(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 p_)Ww(t,e,i,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,n);else if(a){let[s,o,a]=t.stencilConfigForOverlapTwoPass(r);Ww(t,e,i,a,s,!1,!0,Zw,!1,n),Ww(t,e,i,a,o,!0,!0,Zw,!1,n)}else{let[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);Ww(t,e,i,o,s,!1,!0,Zw,!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=dw.disabled,_=t.getDepthModeForSublayer(0,"opaque"===d?fw.ReadWrite:fw.ReadOnly),g=t.colorModeForRenderPass(),y=t.useProgram(p?"backgroundPattern":"background"),v=r||I_(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?bv(o,t,p,{tileID:e,tileSize:f},w):wv(o,n),d=t.getTerrainDataForTile(e,a),v=u.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,h.TRIANGLES,_,m,g,_w.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=lc(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 fw(r.LEQUAL,fw.ReadWrite,[0,1]),o=dw.disabled,a=t.colorModeForRenderPass(),l=t.useProgram("sky"),h=ob(i,e);l.draw(i,r.TRIANGLES,n,o,a,_w.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 fw(s.LEQUAL,fw.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=gy(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=ob(r,e);n.draw(r,s.TRIANGLES,o,dw.disabled,uw.alphaBlended,_w.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 Df(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(dw.disabled);let e="3d"===c?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,fw.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)nb(t,e,r)},debugPadding:function(t){let e=t.transform.padding;ib(t,t.transform.height-(e.top||0),3,Jw),ib(t,e.bottom||0,3,Kw),rb(t,e.left||0,3,Qw),rb(t,t.transform.width-(e.right||0),3,tb);let i=t.transform.centerPoint;!function(t,e,i,r){sb(t,e-1,i-10,2,20,r),sb(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,eb)},terrainDepth:function(t,e){let i=t.context,r=i.gl,s=t.transform,n=uw.unblended,o=new fw(r.LEQUAL,fw.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:Ei.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=Ly(e.getSkirtLength(s.zoom));l.draw(i,r.TRIANGLES,o,dw.disabled,n,_w.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=uw.unblended,o=new fw(r.LEQUAL,fw.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:Ei.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=By(255-e.coordsIndex.length,e.getSkirtLength(s.zoom)),f=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(i,r.TRIANGLES,o,dw.disabled,n,_w.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 lb=class t{constructor(t,e){this.drawFunctions=ab,this.context=new cw(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=B_.maxOverzooming+B_.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new Ug}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 Fa;e.emplaceBack(0,0),e.emplaceBack(et,0),e.emplaceBack(0,et),e.emplaceBack(et,et),this.tileExtentBuffer=t.createVertexBuffer(e,Wg.members),this.tileExtentSegments=el.simpleSegment(0,0,4,2);let i=new Fa;i.emplaceBack(0,0),i.emplaceBack(et,0),i.emplaceBack(0,et),i.emplaceBack(et,et),this.debugBuffer=t.createVertexBuffer(i,Wg.members),this.debugSegments=el.simpleSegment(0,0,4,5);let r=new Ra;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,Ry.members),this.rasterBoundsSegments=el.simpleSegment(0,0,4,2);let s=new Fa;s.emplaceBack(0,0),s.emplaceBack(et,0),s.emplaceBack(0,et),s.emplaceBack(et,et),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(s,Wg.members),this.rasterBoundsSegmentsPosOnly=el.simpleSegment(0,0,4,5);let n=new Fa;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,Wg.members),this.viewportSegments=el.simpleSegment(0,0,4,2);let o=new Qa;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let a=new Ja;a.emplaceBack(1,0,2),a.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);let l=this.context.gl;this.stencilClearMode=new dw({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new Zg(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=d();z(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,fw.disabled,this.stencilClearMode,uw.disabled,_w.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(uw.disabled),r.setDepthMode(fw.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,fw.disabled,new dw({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),uw.disabled,i?_w.disabled:_w.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=I_(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,dw.disabled,uw.disabled,_w.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 dw({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){let e=this.context.gl;return new dw({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 dw({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=s,[t,i]}return[{[r]:dw.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 dw({func:e.GREATER,mask:255},s+1+i,255,e.KEEP,e.KEEP,e.REPLACE),n[i+r]=new dw({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 dw({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new dw({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 uw([t.CONSTANT_COLOR,t.ONE],new Ei(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?uw.unblended:uw.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return fw.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new fw(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new fw(this.context.gl.LEQUAL,fw.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(im()),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?Ei.black:Ei.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],T=e[6],z=e[7],S=e[8],E=e[9],A=e[10],P=e[11],C=e[12],I=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-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(h-z)<=1e-6*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(u-S)<=1e-6*Math.max(1,Math.abs(u),Math.abs(S))&&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-C)<=1e-6*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(m-I)<=1e-6*Math.max(1,Math.abs(m),Math.abs(I))&&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=im(),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;wf(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):qo(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 Ih(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?Vg.projectionMercator:n.shaderPreludeCode,a=i?Hg:n.shaderDefine,l=t+(e?e.cacheKey:"")+`/${i?Yg:n.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(s?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||=new Uy(this.context,Vg[t],e,Mv[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 Ih(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}},hb=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 ub(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 cb=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=ub(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 Hu(+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 fb={linearity:.3,easing:wt(0,0,.3,1)},pb=Tt({deceleration:2500,maxSpeed:1400},fb),db=Tt({deceleration:20,maxSpeed:1400},fb),mb=Tt({deceleration:1e3,maxSpeed:360},fb),_b=Tt({deceleration:1e3,maxSpeed:90},fb),gb=Tt({deceleration:1e3,maxSpeed:360},fb);var yb=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:im(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,e=im();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=wb(e.pan.mag(),i,Tt({},pb,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,vb(r,s)}if(e.zoom){let t=wb(e.zoom,i,db);r.zoom=Ct(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),vb(r,t)}if(e.bearing){let t=wb(e.bearing,i,mb);r.bearing=this._map.getBearing()+xt(t.amount,-179,179),vb(r,t)}if(e.pitch){let t=wb(e.pitch,i,_b);r.pitch=this._map.getPitch()+t.amount,vb(r,t)}if(e.roll){let t=wb(e.roll,i,gb);r.roll=this._map.getRoll()+xt(t.amount,-179,179),vb(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(),Tt(r,{noMoveStart:!0})}};function vb(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function wb(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 bb=class{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new _m(this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new dm(t.type,this._map,t))}mouseup(t){this._map.fire(new dm(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new dm(t.type,this._map,t))}dblclick(t){return this._firePreventable(new dm(t.type,this._map,t))}mouseover(t){this._map.fire(new dm(t.type,this._map,t))}mouseout(t){this._map.fire(new dm(t.type,this._map,t))}touchstart(t){return this._firePreventable(new mm(t.type,this._map,t))}touchmove(t){this._map.fire(new mm(t.type,this._map,t))}touchend(t){this._map.fire(new mm(t.type,this._map,t))}touchcancel(t){this._map.fire(new mm(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},xb=class{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new dm(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new dm("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new dm(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},Mb=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&&(om.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=om.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(),om.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new gm("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),om.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new gm(t,{originalEvent:e}))}};function Tb(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 zb=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=Tb(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;let r=Tb(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}}},Sb=class{constructor(t){this.singleTap=new zb(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}}},Eb=class{constructor(t,e){this._tr=e,this._zoomIn=new Sb({numTouches:1,numTaps:2}),this._zoomOut=new Sb({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:Ct(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:Ct(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}},Ab=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&&om.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 Pb={0:1,2:2};var Cb=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=Pb[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return t.button===this._eventButton}},Ib=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)}},kb=class{constructor(t=new Cb({checkCorrectEvent:()=>!0}),e=new Ib){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 Db=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};function Fb({enable:t,clickTolerance:e,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:s=.8},n){return new Ab({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 Cb({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button&&!t.ctrlKey}),enable:t,assignEvents:Db})}var $b=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=Tb(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}},Rb=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=jb(i,e,r),o=jb(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=jb(i,e,r),o=jb(i,e,s);n&&o||(this._active&&om.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 jb(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Ob(t,e){return Math.log(t/e)/Math.LN2}var Lb=class extends Rb{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(Ob(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Ob(this._distance,i)*this._zoomRate,pinchAround:e}}};function Bb(t,e){return 180*t.angleWith(e)/Math.PI}var Nb=class extends Rb{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:Bb(this._vector,r),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let e=25/(Math.PI*this._minDiameter)*360,i=Bb(t,this._startVector);return Math.abs(i)<e}};function Ub(t){return Math.abs(t.y)>Math.abs(t.x)}var Gb=class extends Rb{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,Ub(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 Ub(t)&&Ub(e)&&n}};const Vb={panStep:100,bearingStep:15,pitchStep:10};var qb=class{constructor(t,e){this._tr=e;let i=Vb;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:Zb,zoom:e?Ct(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 Zb(t){return t*(2-t)}const Wb=4.000244140625;var Hb=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=im(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Wb==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=om.mousePos(this._map.getCanvas(),t),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(Hu.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)>Wb?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=Ct(t.zoom,n);this._targetZoom=Ct(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=im()-this._lastWheelEventTime,o=Math.min((t+5)/200,1),a=s(o);e=sr.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=(im()-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:im(),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)}},Yb=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()}},Xb=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:Ct(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}},Jb=class{constructor(){this._tap=new Sb({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}},Kb=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()}},Qb=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()}},tx=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()}},ex=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=om.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 hm("cooperativegestureprevented",{gestureType:t,originalEvent:e})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}},ix=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 rx=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var sx=class extends ge{};function nx(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var ox=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=om.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=om.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||nx(r))&&(this._changes.push([r,s,o]),this._triggerRenderFrame()),(Object.keys(n).length||nx(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 ix(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new yb(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 bb(e,t));let r=e.boxZoom=new Mb(e,t,this._transformProvider);this._add("boxZoom",r),t.interactive&&t.boxZoom&&r.enable();let s=e.cooperativeGestures=new ex(e,t.cooperativeGestures);this._add("cooperativeGestures",s),t.cooperativeGestures&&s.enable();let n=new Eb(e,this._transformProvider),o=new Xb(e,this._transformProvider);e.doubleClickZoom=new Yb(o,n),this._add("tapZoom",n),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();let a=new Jb;this._add("tapDragZoom",a);let l=e.touchPitch=new Gb(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);let h=()=>e.project(e.getCenter()),u=Fb(t,h),c=function({enable:t,clickTolerance:e,pitchSpeed:i=-.5}){return new Ab({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new Cb({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button}),enable:t,assignEvents:Db})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){return new Ab({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 Cb({checkCorrectEvent:t=>2===t.button&&t.ctrlKey}),enable:t,assignEvents:Db})}(t,h);e.dragRotate=new Qb(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 Ab({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:new Cb({checkCorrectEvent:t=>0===t.button&&!t.ctrlKey}),enable:t,assignEvents:Db})}(t),d=new $b(t,e);e.dragPan=new Kb(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 Nb,_=new Lb;e.touchZoomRotate=new tx(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 xb(e));let g=e.scrollZoom=new Hb(e,(()=>this._triggerRenderFrame()),this._transformProvider);this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);let y=e.keyboard=new qb(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!!rx(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;Tt(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),Tt(e,s),Tt(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(!(nx(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=rx(this._eventsInProgress),s=rx(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=rx(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&&tm.prefersReducedMotion?(this._map.fire(new um("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 um(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new sx("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},ax=class extends ve{constructor(t){super(),this._renderFrameCallback=()=>{let t=Math.min((im()-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 sy,this.cameraHelper=new ly,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 Hu(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,Tt({offset:t},e),i)}panTo(t,e,i){return this.easeTo(Tt({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(Tt({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(Ct(this.getZoom()+1,this._zoomSnap),t,e),this}zoomOut(t,e){return this.zoomTo(Ct(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 um("movestart",e)).fire(new um("move",e)).fire(new um("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(Tt({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,Tt({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(Tt({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=e_.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=Tt({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=Tt(s,r.padding);r.padding=n;let o=this.transform,a=new e_(t,e),l=this.cameraHelper.cameraForBoxAndBearing(r,n,a,i,o);return l&&this._zoomSnap&&(l.zoom=Ct(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=Tt(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=Ct(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?Hu.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 um("movestart",e)).fire(new um("move",e)),a&&this.fire(new um("zoomstart",e)).fire(new um("zoom",e)).fire(new um("zoomend",e)),r&&this.fire(new um("rotatestart",e)).fire(new um("rotate",e)).fire(new um("rotateend",e)),s&&this.fire(new um("pitchstart",e)).fire(new um("pitch",e)).fire(new um("pitchend",e)),n&&this.fire(new um("rollstart",e)).fire(new um("roll",e)).fire(new um("rollend",e)),this.fire(new um("moveend",e))}calculateCameraOptionsFromTo(t,e,i,r=0){let s=rc.fromLngLat(t,e),n=rc.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=Tt({offset:[0,0],duration:500,easing:bt},t))&&this._zoomSnap&&(t.zoom=Ct(t.zoom,this._zoomSnap)),(!1===t.animate||!t.essential&&tm.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=Hu.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 um("movestart",t)),this._zooming&&!i.zooming&&this.fire(new um("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new um("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new um("pitchstart",t)),this._rolling&&!i.rolling&&this.fire(new um("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(sr.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 um("move",t)),this._zooming&&this.fire(new um("zoom",t)),this._rotating&&this.fire(new um("rotate",t)),this._pitching&&this.fire(new um("pitch",t)),this._rolling&&this.fire(new um("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 um("zoomend",t)),r&&this.fire(new um("rotateend",t)),s&&this.fire(new um("pitchend",t)),n&&this.fire(new um("rollend",t)),this.fire(new um("moveend",t))}flyTo(t,e){if(!t.essential&&tm.prefersReducedMotion){let i=zt(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,e)}this.stop(),"zoom"in(t=Tt({offset:[0,0],speed:1.2,curve:1.42,easing:bt},t))&&this._zoomSnap&&(t.zoom=Ct(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 T=b(!1),z=function(t){return M(T)/M(T+_*t)},S=function(t){return g*((M(T)*function(t){return x(t)/M(t)}(T+_*t)-x(T))/w)/v},E=(b(!0)-T)/_;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))/_,S=()=>0,z=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/z(d),g=S(d);this._rotating&&i.setBearing(sr.number(r,a,l)),this._pitching&&i.setPitch(sr.number(s,h,l)),this._rolling&&i.setRoll(sr.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=im(),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 lx={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var hx=class{constructor(t=lx){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=om.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=om.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=om.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=om.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},ux=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=om.create("div","maplibregl-ctrl");let e=om.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}},cx=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 fx=Xo([{name:"a_pos3d",type:"Int16",components:3}]);var px=class extends ve{constructor(t){super(),this._lastTilesetChange=im(),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 I_(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),z(r.terrainRttPosMatrix32f,0,et,et,0,0,1),this._tiles[r.key]=new M_(r,this.tileSize),this._lastTilesetChange=im());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))z(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;z(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;z(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;z(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;z(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;z(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=im()){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)}},dx=class{constructor(t,e,i,r="auto"){this._meshCache={},this.painter=t,this.tileManager=new px(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(!Cf(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=I_(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:Rt("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 wh({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ih(t,e,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ih(t,new wh({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 Ih(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 Ih(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 Ih(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 wh({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(e.buffer)),r=new Ih(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 rc((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 $a,a=new Ja,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 Zg(n.createVertexBuffer(o,fx.members),n.createIndexBuffer(a),el.simpleSegment(0,0,o.length,a.length));return this._meshCache[s]=c,c}getSkirtLength(t){return 2*Math.PI*Wu/2**Math.max(t,0)/5}getMinTileElevationForLngLatZoom(t,e){if(!Cf(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=rc.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 Df(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?zu:0,u=+!s,c=n?Su: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 mx={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var _x=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&&mx[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 p_?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(mx[r]&&((!this._prevType||!mx[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(t.id),!n))return!0;if(mx[this._prevType]||mx[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:Ei.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=Oy(p,d,t.style.sky,a.pitch,s),_=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(n,o.TRIANGLES,h,dw.disabled,l,_w.backCCW,m,f,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],mx[r]}return!1}};const gx={"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"},yx=Yd,vx={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:lx,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 wx=class extends ve{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new cx,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 wm("webglcontextlost",{originalEvent:t}))}else this.fire(new wm("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 wm("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={...vx,...t,canvasContextAttributes:{...vx.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 ax({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={...gx,...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&&(tm.prefersReducedMotion=e.reduceMotion),this._imageQueueHandle=am.addThrottleControl((()=>this.isMoving())),this._requestManager=new lm(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 ox(this,this._camera,e),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this._hash=e.hash?new cb("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,Tt({},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 hx("boolean"==typeof e.attributionControl?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new ux,e.logoPosition),this.on("style.load",(()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let t=zt(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 fm("styledata",t):new pm("sourcedata",t))})),this.on("dataloading",(t=>{this.fire("style"===t.dataType?new fm("styledataloading",t):new pm("sourcedataloading",t))})),this.on("dataabort",(t=>{this.fire(new pm("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 ye(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 ye(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 I_(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new Hu(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(Hu.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 um("movestart",t)).fire(new um("move",t))),this.fire(new hm("resize",t)),i&&this.fire(new um("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(e_.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 um("zoomstart")).fire(new um("zoom")).fire(new um("zoomend")).fire(new um("movestart")).fire(new um("move")).fire(new um("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 um("zoomstart")).fire(new um("zoom")).fire(new um("zoomend")).fire(new um("movestart")).fire(new um("move")).fire(new um("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 um("pitchstart")).fire(new um("pitch")).fire(new um("pitchend")).fire(new um("movestart")).fire(new um("move")).fire(new um("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 um("pitchstart")).fire(new um("pitch")).fire(new um("pitchend")).fire(new um("movestart")).fire(new um("move")).fire(new um("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(Hu.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 dm(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 dm(t,this,s.originalEvent)))},mouseout:e=>{r&&(r=!1,i.call(this,new dm(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=Tt({},{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 $y(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 $y(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 pe(t,r);this._diffStyleRequest=null,this._updateDiff(s.data,e)}catch(t){this._diffStyleRequest=null,re(t)||this.fire(new ye(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){Rt(`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();Rt("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 ye(Error(`There is no tile manager with ID '${t}'`)))}setTerrain(t,e={}){if(this.style._checkLoaded(),t&&ro(this,Qn.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&&Rt("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&&Rt("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 dx(this.painter,e,t,this._terrainSkirtLength),this.painter.renderToTexture=new _x(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 ym({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=A_(Math.max(1,t),Math.max(1,e))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=A_(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 If(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}=tm.getImageData(t);return{data:new wh({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 ye(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 wh({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 ye(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)?tm.getImageData(e):e;if(void 0===r||void 0===s)return this.fire(new ye(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 ye(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 ye(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){return am.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=ub((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=om.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=om.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=om.create("div","maplibregl-control-container",t),n=this._controlPositions={};for(let t of["top-left","top-right","bottom-left","bottom-right"])n[t]=om.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 lb(i,this._camera.transform):this.fire(new ye(new hb(t,e)))}migrateProjection(t,e){this._camera.migrateProjection(t,e),this.painter.transform=t,this.fire(new vm({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=im();this.style.zoomHistory.update(t,i);let s=new xo(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 hm("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new hm("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 hm("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),am.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 hm("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,tm.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 yx}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};const bx={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var xx=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(Vt(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=Tt({},bx,t),this._container=om.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}))),om.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}))),om.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=om.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 Mx(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=om.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},Mx=class{constructor(t,e,i=!1){this.mousedown=t=>{this.startMove(t,om.mousePos(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,om.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{1===t.targetTouches.length?(this._startPos=this._lastPos=om.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=om.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 kb;this._rotatePitchHandler=new Ab({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),om.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(){om.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};let Tx;function zx(t,e,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return t?.wrap();let s=new Hu(t.lng,t.lat);if(t=new Hu(t.lng,t.lat),e){let r=new Hu(t.lng-360,t.lat),s=new Hu(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}const Sx={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ex(t,e,i){let r=t.classList;for(let t in Sx)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}var Ax=class extends ge{},Px=class extends ge{},Cx=class extends ve{constructor(t){if(super(),this._onClick=t=>{this.fire(new Px("click",{originalEvent:t}))},this._onKeyPress=t=>{("Space"===t.code||"Enter"===t.code)&&this.togglePopup()},this._onMapClick=t=>{let e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{if(!this._map)return;let e=this._map.loaded()&&!this._map.isMoving();("terrain"===t?.type||"render"===t?.type&&!e)&&this._map.once("render",this._update),this._lngLat=zx(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!t||"moveend"===t.type)&&(this._pos=this._pos.round()),this._element.style.transform=`${Sx[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`,tm.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity("moveend"===t?.type)})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){let e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new Ax("dragstart"))),this.fire(new Ax("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new Ax("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t?.anchor||"center",this._color=t?.color||"#3FB1CE",this._scale=t?.scale||1,this._draggable=t?.draggable||!1,this._clickTolerance=t?.clickTolerance||0,this._subpixelPositioning=t?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._state="inactive",this._rotation=t?.rotation||0,this._rotationAlignment=t?.rotationAlignment||"auto",this._pitchAlignment=t?.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t?.opacity,t?.opacityWhenCovered),t?.element)this._element=t.element,this._offset=l.convert(t?.offset||[0,0]);else{this._defaultMarker=!0,this._element=om.create("div");let e=om.createNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"display","block"),e.setAttributeNS(null,"height","41px"),e.setAttributeNS(null,"width","27px"),e.setAttributeNS(null,"viewBox","0 0 27 41");let i=om.createNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"stroke","none"),i.setAttributeNS(null,"stroke-width","1"),i.setAttributeNS(null,"fill","none"),i.setAttributeNS(null,"fill-rule","evenodd");let r=om.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"fill-rule","nonzero");let s=om.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"transform","translate(3.0, 29.0)"),s.setAttributeNS(null,"fill","#000000");for(let t of[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}]){let e=om.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),s.appendChild(e)}let n=om.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"fill",this._color);let o=om.createNS("http://www.w3.org/2000/svg","path");o.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),n.appendChild(o);let a=om.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"opacity","0.25"),a.setAttributeNS(null,"fill","#000000");let h=om.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),a.appendChild(h);let u=om.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"transform","translate(6.0, 7.0)"),u.setAttributeNS(null,"fill","#FFFFFF");let c=om.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"transform","translate(8.0, 8.0)");let f=om.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");let p=om.createNS("http://www.w3.org/2000/svg","circle");p.setAttributeNS(null,"fill","#FFFFFF"),p.setAttributeNS(null,"cx","5.5"),p.setAttributeNS(null,"cy","5.5"),p.setAttributeNS(null,"r","5.4999962"),c.appendChild(f),c.appendChild(p),r.appendChild(s),r.appendChild(n),r.appendChild(a),r.appendChild(u),r.appendChild(c),e.appendChild(r),e.setAttributeNS(null,"height",41*this._scale+"px"),e.setAttributeNS(null,"width",27*this._scale+"px"),this._element.appendChild(e),this._offset=l.convert(t?.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),Ex(this._element,this._anchor,"marker"),t?.className)for(let e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._updateAccessibilityRole(),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Hu.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){let e=13.5/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[e,-1*(24.6+e)],"bottom-right":[-e,-1*(24.6+e)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this._updateAccessibilityRole(),this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){let t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){let e=this._map?.terrain,i=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!e||i){let t=i?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==t&&(this._element.style.opacity=t,this._element.classList.toggle("maplibregl-marker-covered",i)))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let r=this._map,s=r.terrain.depthAtPoint(this._pos),n=r.terrain.getElevationForLngLat(this._lngLat,r._camera.transform);if(r._camera.transform.lngLatToCameraDepth(this._lngLat,n)-s<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("maplibregl-marker-covered");let o=-this._offset.y/r._camera.transform.pixelsPerMeter,a=Math.sin(r.getPitch()*Math.PI/180)*o,h=r.terrain.depthAtPoint(new l(this._pos.x,this._pos.y-this._offset.y)),u=r._camera.transform.lngLatToCameraDepth(this._lngLat,n+a)-h>.006;this._popup?.isOpen()&&u&&this._popup.remove(),this._element.style.opacity=u?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",u)}getOffset(){return this._offset}setOffset(t){return this._offset=l.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._element.classList.toggle("maplibregl-marker-draggable",this._draggable),this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateAccessibilityRole(){!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged||(this._element.setAttribute("role",this._draggable||this._popup?"button":"img"),this._roleManaged=!0)}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return(void 0===this._opacity||void 0===t&&void 0===e)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=String(t)),void 0!==e&&(this._opacityWhenCovered=String(e)),this._map&&this._updateOpacity(!0),this}};const Ix={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let kx=0,Dx=!1;var Fx=class extends ge{},$x=class extends ge{},Rx=class extends ge{},jx=class extends ve{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new $x("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new $x("geolocate",t)),this._finish()}},this._updateCamera=t=>{let e=new Hu(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,r=Tt({bearing:this._map.getBearing()},this.options.fitBoundsOptions),s=e_.fromLngLat(e,i);this._map.fitBounds(s,r,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let e=new Hu(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(e).addTo(this._map),this._userLocationDotMarker.setLngLat(e).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Dx)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new Rx("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=t=>{if(!this._map)return;let e=t?.[0]instanceof ResizeObserverEntry;!t.geolocateSource&&"ACTIVE_LOCK"===this._watchState&&!e&&!this._map.isZooming()&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Fx("trackuserlocationend")),this.fire(new Fx("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>{t.preventDefault()})),this._geolocateButton=om.create("button","maplibregl-ctrl-geolocate",this._container),om.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){Rt("Geolocation support is not available so the GeolocateControl will be disabled.");let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{let t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=om.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Cx({element:this._dotElement}),this._circleElement=om.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Cx({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=Tt({},Ix,t)}onAdd(t){return this._map=t,this._container=om.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),async function(t=!1){if(void 0!==Tx&&!t)return Tx;if(void 0===window.navigator.permissions)return Tx=!!window.navigator.geolocation,Tx;try{Tx="denied"!==(await window.navigator.permissions.query({name:"geolocation"})).state}catch{Tx=!!window.navigator.geolocation}return Tx}().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,kx=0,Dx=!1}_isOutOfMapMaxBounds(t){let e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){let t=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&t))return;let e=this._map.project(t),i=this._map.unproject([e.x+100,e.y]),r=t.distanceTo(i)/100,s=2*this._accuracy/r;this._circleElement.style.width=`${s.toFixed(2)}px`,this._circleElement.style.height=`${s.toFixed(2)}px`}trigger(){if(!this._setup)return Rt("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new Fx("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":kx--,Dx=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new Fx("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new Fx("trackuserlocationstart")),this.fire(new Fx("userlocationfocus"));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),kx++,kx>1?(t={maximumAge:6e5,timeout:0},Dx=!0):(t=this.options.positionOptions,Dx=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}};const Ox={maxWidth:100,unit:"metric"};var Lx=class{constructor(t){this._onMove=()=>{Bx(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Bx(this._map,this._container,this.options)},this.options={...Ox,...t}}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=om.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}};function Bx(t,e,i){let r=i?.maxWidth||100,s=t._container.clientHeight/2,n=t._container.clientWidth/2,o=t.unproject([n-r/2,s]),a=t.unproject([n+r/2,s]),l=Math.round(t.project(a).x-t.project(o).x),h=Math.min(r,l,t._container.clientWidth),u=o.distanceTo(a);if("imperial"===i?.unit){let i=3.2808*u;i>5280?Nx(e,h,i/5280,t._getUIString("ScaleControl.Miles")):Nx(e,h,i,t._getUIString("ScaleControl.Feet"))}else"nautical"===i?.unit?Nx(e,h,u/1852,t._getUIString("ScaleControl.NauticalMiles")):u>=1e3?Nx(e,h,u/1e3,t._getUIString("ScaleControl.Kilometers")):Nx(e,h,u,t._getUIString("ScaleControl.Meters"))}function Nx(t,e,i,r){let s=function(t){let e=10**(`${Math.floor(t)}`.length-1),i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){let e=10**Math.ceil(-Math.log(t)/Math.LN10);return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s}&nbsp;${r}`}var Ux=class extends ge{},Gx=class extends ve{constructor(t={}){super(),this._onFullscreenChange=()=>{let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;t?.shadowRoot?.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=t.pseudo??!1,t?.container&&(t.container instanceof HTMLElement?this._container=t.container:Rt("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||=this._map.getContainer(),this._controlContainer=om.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let t=this._fullscreenButton=om.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);om.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new Ux("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new Ux("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},Vx=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=om.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=om.create("button","maplibregl-ctrl-terrain",this._container),om.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},qx=class{constructor(){this._toggleProjection=()=>{let t=this._map.getProjection()?.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===this._map.getProjection()?.type?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(t){return this._map=t,this._container=om.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=om.create("button","maplibregl-ctrl-globe",this._container),om.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}};const Zx={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Wx=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");var Hx=class extends ge{},Yx=class extends ve{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 Hx("close"))),this),this._update=t=>{let e;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=om.create("div","maplibregl-popup",this._map.getContainer()),this._tip=om.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=zx(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=Xx(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=`${Sx[r]} translate(${n.x}px,${n.y}px)`,Ex(this._container,r,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=Tt(Object.create(Zx),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 Hx("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=Hu.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=om.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=om.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(Wx);t&&t.focus()}};function Xx(t){if(!t)return Xx(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])}}const Jx=Yd;function Kx(t,e){return x_().setRTLTextPlugin(t,e)}function Qx(){return x_().getRTLTextPluginStatus()}function tM(){return Jx}function eM(){return Nm.workerCount}function iM(t){Nm.workerCount=t}function rM(){return ne.MAX_PARALLEL_IMAGE_REQUESTS}function sM(t){ne.MAX_PARALLEL_IMAGE_REQUESTS=t}function nM(){return ne.WORKER_URL}function oM(t){ne.WORKER_URL=t}async function aM(t){await Ym().broadcast("IS",t)}export{ue as AJAXError,hx as AttributionControl,Mb as BoxZoomHandler,m_ as CanvasSource,ex as CooperativeGesturesHandler,Yb as DoubleClickZoomHandler,Kb as DragPanHandler,Qb as DragRotateHandler,et as EXTENT,Jg as EdgeInsets,ye as ErrorEvent,ge as Event,ve as Evented,Gx as FullscreenControl,Ux as FullscreenEvent,hb as GPUInitializationError,f_ as GeoJSONSource,jx as GeolocateControl,Rx as GeolocateErrorEvent,Fx as GeolocateEvent,$x as GeolocatePositionEvent,qx as GlobeControl,cb as Hash,p_ as ImageSource,qb as KeyboardHandler,Hu as LngLat,e_ as LngLatBounds,ux as LogoControl,wx as Map,gm as MapBoxZoomEvent,wm as MapContextEvent,hm as MapLibreEvent,wx as MapLibreMap,dm as MapMouseEvent,um as MapMovementEvent,vm as MapProjectionEvent,pm as MapSourceDataEvent,fm as MapStyleDataEvent,bm as MapStyleImageMissingEvent,cm as MapStyleLoadEvent,ym as MapTerrainEvent,mm as MapTouchEvent,_m as MapWheelEvent,Cx as Marker,Px as MarkerClickEvent,Ax as MarkerDragEvent,rc as MercatorCoordinate,xx as NavigationControl,l as Point,Yx as Popup,Hx as PopupEvent,n_ as RasterDEMTileSource,s_ as RasterTileSource,Lx as ScaleControl,Hb as ScrollZoomHandler,$y as Style,Vx as TerrainControl,Gb as TwoFingersTouchPitchHandler,Nb as TwoFingersTouchRotateHandler,Lb as TwoFingersTouchZoomHandler,tx as TwoFingersTouchZoomRotateHandler,r_ as VectorTileSource,d_ as VideoSource,ae as addProtocol,y_ as addSourceType,Zm as clearPrewarmedResources,ne as config,uy as createTileMesh,Ym as getGlobalDispatcher,rM as getMaxParallelImageRequests,Qx as getRTLTextPluginStatus,tM as getVersion,eM as getWorkerCount,nM as getWorkerUrl,aM as importScriptInWorkers,nm as isTimeFrozen,im as now,qm as prewarm,le as removeProtocol,sm as restoreNow,sM as setMaxParallelImageRequests,rm as setNow,Kx as setRTLTextPlugin,iM as setWorkerCount,oM as setWorkerUrl}