From 673aa91314774304b4cc4edb4671b4021e311319 Mon Sep 17 00:00:00 2001 From: Andrey Kuznecov Date: Mon, 6 Feb 2023 12:58:21 +0700 Subject: [PATCH 1/2] skipRenderResizeFrame --- demo/index.ts | 2 +- src/deckgl2gisLayer.ts | 53 +++++++++++++++++++++++------------------- src/types.ts | 7 ++++++ src/utils.ts | 18 ++++++++------ 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/demo/index.ts b/demo/index.ts index 2609af5..8b9ef8d 100644 --- a/demo/index.ts +++ b/demo/index.ts @@ -13,7 +13,7 @@ const map = new mapgl.Map('container', { key: '4970330e-7f1c-4921-808c-0eb7c4e63001', }); -const deck = new Deck(initDeck2gisProps(map)); +const deck = new Deck(initDeck2gisProps(map, { skipResizeRenderer: true })); map.once('ready', () => { initDeckGL(); }); diff --git a/src/deckgl2gisLayer.ts b/src/deckgl2gisLayer.ts index fc776d1..858158d 100644 --- a/src/deckgl2gisLayer.ts +++ b/src/deckgl2gisLayer.ts @@ -178,8 +178,7 @@ export class Deck2gisLayer implements DeckCustomLayer { ) { return; } - const { _2gisData } = this.deck.props as CustomRenderProps; - _2gisData._2gisCurrentViewport = undefined; + const { _2gisData, skipResizeRenderer } = this.deck.props as CustomRenderProps; const gl = this.gl; this.frameBuffer.bind(gl); gl.clearColor(1, 1, 1, 0); @@ -192,28 +191,34 @@ export class Deck2gisLayer implements DeckCustomLayer { } this.frameBuffer.unbind(gl); - drawLayer(this.deck, this.map, this); - - gl.bindFramebuffer(gl.FRAMEBUFFER, null); const mapSize = this.map.getSize(); - const texture = this.frameBuffer.getTexture(); - texture.enable(gl, 0); - this.program.enable(gl); - this.program.bind(gl, { - iResolution: [ - mapSize[0] * window.devicePixelRatio, - mapSize[1] * window.devicePixelRatio, - ], - iChannel0: 0, - enabled: Number(this.antialiasing), - }); - - this.vao.bind({ - gl, - extensions: { OES_vertex_array_object: gl.getExtension('OES_vertex_array_object') }, - }); - - gl.disable(gl.CULL_FACE); - gl.drawArrays(gl.TRIANGLES, 0, 6); + if ( + !skipResizeRenderer || + (this.deck.width === mapSize[0] && this.deck.height === mapSize[1]) + ) { + drawLayer(this.deck, this.map, this); + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + const texture = this.frameBuffer.getTexture(); + + texture.enable(gl, 0); + this.program.enable(gl); + this.program.bind(gl, { + iResolution: [ + mapSize[0] * window.devicePixelRatio, + mapSize[1] * window.devicePixelRatio, + ], + iChannel0: 0, + enabled: Number(this.antialiasing), + }); + + this.vao.bind({ + gl, + extensions: { OES_vertex_array_object: gl.getExtension('OES_vertex_array_object') }, + }); + + gl.disable(gl.CULL_FACE); + gl.drawArrays(gl.TRIANGLES, 0, 6); + } }; } diff --git a/src/types.ts b/src/types.ts index cb241be..f8100d5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -41,6 +41,7 @@ export type CustomRenderInternalProps = { _2gisFramestart: boolean; _customRender: (reason: string) => void; _2gisData?: any; + skipResizeRenderer?: boolean }; /** @@ -48,3 +49,9 @@ export type CustomRenderInternalProps = { * https://deck.gl/docs/api-reference/core/deck#properties */ export type CustomRenderProps = Partial & CustomRenderInternalProps; + +/** + * RenderProps is type extends from DeckProps: + * https://deck.gl/docs/api-reference/core/deck#properties + */ +export type RenderProps = Partial & { skipResizeRenderer?: boolean }; diff --git a/src/utils.ts b/src/utils.ts index 8855987..3267f2c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -12,7 +12,7 @@ import Shader from '2gl/Shader'; import fill_fsh from './optimized.fsh'; import fill_vsh from './optimized.vsh'; -import { CustomRenderProps } from './types'; +import { CustomRenderProps, RenderProps } from './types'; import { DeckProps } from '@deck.gl/core/typed'; /** @@ -81,6 +81,10 @@ export function prepareDeckInstance({ return null; } // todo use public methods after done TILES-4753 + (map as any)._impl.on( + 'frameend', + () => ((deckInstance as any).props._2gisData._2gisCurrentViewport = null), + ); (map as any)._impl.on( 'framestart', () => ((deck.props as CustomRenderProps)._2gisData._2gisFramestart = true), @@ -121,18 +125,18 @@ export function updateLayer(deck: Deck, _layer: Deck2gisLayer): void { * @internal */ export function drawLayer(deck: Deck, map: Map, layer: Deck2gisLayer): void { + if (!(deck as any).layerManager) { + return; + } + let currentViewport = (deck.props as CustomRenderProps)._2gisData._2gisCurrentViewport; + if (!currentViewport) { // This is the first layer drawn in this render cycle. // Generate viewport from the current map state. currentViewport = getViewport(map); (deck.props as CustomRenderProps)._2gisData._2gisCurrentViewport = currentViewport; } - - if (!(deck as any).layerManager) { - return; - } - stateBinder(map, layer); deck._drawLayers('2gis-repaint', { @@ -202,7 +206,7 @@ function updateLayers(deck: Deck): void { * @param map The map instance. * @param deckProps CustomRenderProps initialization options. */ -export function initDeck2gisProps(map: Map, deckProps?: CustomRenderProps): DeckProps { +export function initDeck2gisProps(map: Map, deckProps?: RenderProps | CustomRenderProps): DeckProps { const gl = map.getWebGLContext(); const deck2gisProps: any = { ...deckProps, From 89df16dec4bd9f052fbe3814eb4cdce80350e611 Mon Sep 17 00:00:00 2001 From: Andrey Kuznecov Date: Mon, 6 Feb 2023 13:38:38 +0700 Subject: [PATCH 2/2] add dist --- .gitignore | 1 - dist/deck2gislayer.js | 1 + dist/demo.js | 6 +++ dist/docs.json | 1 + dist/index.html | 23 ++++++++++++ dist/types/deckgl2gisLayer.d.ts | 66 +++++++++++++++++++++++++++++++++ dist/types/index.d.ts | 3 ++ dist/types/optimized.fsh.d.ts | 2 + dist/types/optimized.vsh.d.ts | 2 + dist/types/types.d.ts | 19 ++++++++++ dist/types/utils.d.ts | 9 +++++ dist/types/viewport.d.ts | 1 + 12 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 dist/deck2gislayer.js create mode 100644 dist/demo.js create mode 100644 dist/docs.json create mode 100644 dist/index.html create mode 100644 dist/types/deckgl2gisLayer.d.ts create mode 100644 dist/types/index.d.ts create mode 100644 dist/types/optimized.fsh.d.ts create mode 100644 dist/types/optimized.vsh.d.ts create mode 100644 dist/types/types.d.ts create mode 100644 dist/types/utils.d.ts create mode 100644 dist/types/viewport.d.ts diff --git a/.gitignore b/.gitignore index 50a53fe..68eb98d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .idea/ node_modules/ .vscode/ -dist/ .DS_Store npm-debug.log yarn.lock diff --git a/dist/deck2gislayer.js b/dist/deck2gislayer.js new file mode 100644 index 0000000..ec5e85e --- /dev/null +++ b/dist/deck2gislayer.js @@ -0,0 +1 @@ +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var r in i)("object"==typeof exports?exports:t)[r]=i[r]}}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i(i.s=10)}([function(t,e,i){"use strict";function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}i.d(e,"a",(function(){return r}))},function(t,e,i){"use strict";(function(t,r){i.d(e,"b",(function(){return s})),i.d(e,"a",(function(){return o}));const n={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document,process:"object"==typeof r&&r},s=(globalThis,n.window||n.self||n.global),o=n.process||{};console}).call(this,i(9),i(3))},,function(t,e){var i,r,n=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(t){i=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var h,c=[],u=!1,l=-1;function p(){u&&h&&(u=!1,h.length?c=h.concat(c):l=-1,c.length&&g())}function g(){if(!u){var t=a(p);u=!0;for(var e=c.length;e;){for(h=c,c=[];++l1)for(var i=1;i=0)}i.d(e,"a",(function(){return r}))}).call(this,i(3))},,function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";i.r(e),i.d(e,"Deck2gisLayer",(function(){return ye})),i.d(e,"initDeck2gisProps",(function(){return Ee}));var r=i(0),n=new(i(12).a)({id:"deck"});new class{constructor(t={}){Object(r.a)(this,"_pool",[]),Object(r.a)(this,"opts",{overAlloc:2,poolSize:100}),this.setOptions(t)}setOptions(t){Object.assign(this.opts,t)}allocate(t,e,{size:i=1,type:r,padding:n=0,copy:s=!1,initialize:o=!1,maxCount:a}){const h=r||t&&t.constructor||Float32Array,c=e*i+n;if(ArrayBuffer.isView(t)){if(c<=t.length)return t;if(c*t.BYTES_PER_ELEMENT<=t.buffer.byteLength)return new h(t.buffer,0,c)}let u=1/0;a&&(u=a*i+n);const l=this._allocate(h,c,o,u);return t&&s?l.set(t):o||l.fill(0,0,4),this._release(t),l}release(t){this._release(t)}_allocate(t,e,i,r){let n=Math.max(Math.ceil(e*this.opts.overAlloc),1);n>r&&(n=r);const s=this._pool,o=t.BYTES_PER_ELEMENT*n,a=s.findIndex(t=>t.byteLength>=o);if(a>=0){const e=new t(s.splice(a,1)[0],0,n);return i&&e.fill(0),e}return new t(n)}_release(t){if(!ArrayBuffer.isView(t))return;const e=this._pool,{buffer:i}=t,{byteLength:r}=i,n=e.findIndex(t=>t.byteLength>=r);n<0?e.push(i):(n>0||e.lengththis.opts.poolSize&&e.shift()}};function s(t,e){if(!t)throw new Error("math.gl assertion ".concat(e))}Math.PI,Math.PI;const o={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function a(t,{precision:e=o.precision}={}){return t=function(t){return Math.round(t/o.EPSILON)*o.EPSILON}(t),"".concat(parseFloat(t.toPrecision(e)))}function h(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function c(t,e,i){return p(t,t=>Math.max(e,Math.min(i,t)))}function u(t,e,i){return h(t)?t.map((t,r)=>u(t,e[r],i)):i*e+(1-i)*t}function l(t,e,i){const r=o.EPSILON;i&&(o.EPSILON=i);try{if(t===e)return!0;if(h(t)&&h(e)){if(t.length!==e.length)return!1;for(let i=0;i0?", ":"")+a(this[i],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e=0&&t=0&&t2*Math.PI)throw Error("expected radians")}function Q(t,e){const i=V([],e,t);return function(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i}(i,i,1/i[3]),i}function J(t,e){const i=t%e;return i<0?e+i:i}function $(t,e,i){return ti?i:t}const tt=Math.log2||function(t){return Math.log(t)*Math.LOG2E};function et(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}const it=Math.PI,rt=it/4,nt=it/180,st=180/it,ot=1.5;function at(t){return tt(t)}function ht(t){const[e,i]=t;et(Number.isFinite(e)),et(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const r=i*nt;return[512*(e*nt+it)/(2*it),512*(it+Math.log(Math.tan(rt+.5*r)))/(2*it)]}function ct(t){const[e,i]=t,r=e/512*(2*it)-it,n=2*(Math.atan(Math.exp(i/512*(2*it)-it))-rt);return[r*st,n*st]}function ut(t){const{latitude:e,longitude:i,highPrecision:r=!1}=t;et(Number.isFinite(e)&&Number.isFinite(i));const n=Math.cos(e*nt),s=512/360/n,o=512/4003e4/n,a={unitsPerMeter:[o,o,o],metersPerUnit:[1/o,1/o,1/o],unitsPerDegree:[512/360,s,o],degreesPerUnit:[.703125,1/s,1/o]};if(r){const t=nt*Math.tan(e*nt)/n,i=512/360*t/2,r=512/4003e4*t,h=r/s*o;a.unitsPerDegree2=[0,i,r],a.unitsPerMeter2=[h,0,h]}return a}function lt(t){const{height:e,pitch:i,bearing:r,altitude:n,scale:s,center:o}=t,a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];A(a,a,[0,0,-n]),F(a,a,-i*nt),C(a,a,r*nt);const h=s/e;return j(a,a,[h,h,h]),o&&A(a,a,function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}([],o)),a}function pt(t){const{width:e,height:i,altitude:r,pitch:n=0,offset:s,center:o,scale:a,nearZMultiplier:h=1,farZMultiplier:c=1}=t;let{fovy:u=gt(ot)}=t;void 0!==r&&(u=gt(r));const l=u*nt,p=n*nt,g=dt(u);let d=g;o&&(d+=o[2]*a/Math.cos(p)/i);const f=l*(.5+(s?s[1]:0)/i),m=Math.sin(f)*d/Math.sin($(Math.PI/2-p-f,.01,Math.PI-.01)),_=Math.sin(p)*m+d,b=10*d;return{fov:l,aspect:e/i,focalDistance:g,near:h,far:Math.min(_*c,b)}}function gt(t){return 2*Math.atan(.5/t)*st}function dt(t){return.5/Math.tan(.5*t*nt)}function ft(t,e){const[i,r,n=0]=t;return et(Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(n)),Q(e,[i,r,n,1])}function mt(t,e,i=0){const[r,n,s]=t;if(et(Number.isFinite(r)&&Number.isFinite(n),"invalid pixel coordinate"),Number.isFinite(s)){return Q(e,[r,n,s,1])}const o=Q(e,[r,n,0,1]),a=Q(e,[r,n,1,1]),h=o[2],c=a[2];return k([],o,a,h===c?0:((i||0)-h)/(c-h))}function _t(t){const{width:e,height:i,bounds:r,minExtent:n=0,maxZoom:s=24,offset:o=[0,0]}=t,[[a,h],[c,u]]=r,l=function(t=0){if("number"==typeof t)return{top:t,bottom:t,left:t,right:t};return et(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t}(t.padding),p=ht([a,$(u,-85.051129,85.051129)]),g=ht([c,$(h,-85.051129,85.051129)]),d=[Math.max(Math.abs(g[0]-p[0]),n),Math.max(Math.abs(g[1]-p[1]),n)],f=[e-l.left-l.right-2*Math.abs(o[0]),i-l.top-l.bottom-2*Math.abs(o[1])];et(f[0]>0&&f[1]>0);const m=f[0]/d[0],_=f[1]/d[1],b=(l.right-l.left)/2/m,v=(l.top-l.bottom)/2/_,E=ct([(g[0]+p[0])/2+b,(g[1]+p[1])/2+v]),w=Math.min(s,tt(Math.abs(Math.min(m,_))));return et(Number.isFinite(w)),{longitude:E[0],latitude:E[1],zoom:w}}const bt=Math.PI/180;function vt(t,e=0){const{width:i,height:r,unproject:n}=t,s={targetZ:e},o=n([0,r],s),a=n([i,r],s);let h,c;return(t.fovy?.5*t.fovy*bt:Math.atan(.5/t.altitude))>(90-t.pitch)*bt-.01?(h=Et(t,0,e),c=Et(t,i,e)):(h=n([0,0],s),c=n([i,0],s)),[o,a,c,h]}function Et(t,e,i){const{pixelUnprojectionMatrix:r}=t,n=Q(r,[e,0,1,1]),s=Q(r,[e,t.height,1,1]),o=ct(k([],n,s,(i*t.distanceScales.unitsPerMeter[2]-n[2])/(s[2]-n[2])));return o.push(i),o}Object.defineProperty({DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0},"IDENTITY",{get:()=>(n.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const wt=1,Pt=4,Mt=0,St=Math.PI/180,yt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Tt=[0,0,0],xt={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};class Ot{constructor(t={}){Object(r.a)(this,"id",void 0),Object(r.a)(this,"x",void 0),Object(r.a)(this,"y",void 0),Object(r.a)(this,"width",void 0),Object(r.a)(this,"height",void 0),Object(r.a)(this,"isGeospatial",void 0),Object(r.a)(this,"zoom",void 0),Object(r.a)(this,"focalDistance",void 0),Object(r.a)(this,"position",void 0),Object(r.a)(this,"modelMatrix",void 0),Object(r.a)(this,"distanceScales",void 0),Object(r.a)(this,"scale",void 0),Object(r.a)(this,"center",void 0),Object(r.a)(this,"cameraPosition",void 0),Object(r.a)(this,"projectionMatrix",void 0),Object(r.a)(this,"viewMatrix",void 0),Object(r.a)(this,"viewMatrixUncentered",void 0),Object(r.a)(this,"viewMatrixInverse",void 0),Object(r.a)(this,"viewProjectionMatrix",void 0),Object(r.a)(this,"pixelProjectionMatrix",void 0),Object(r.a)(this,"pixelUnprojectionMatrix",void 0),Object(r.a)(this,"resolution",void 0),Object(r.a)(this,"_frustumPlanes",{}),this.id=t.id||this.constructor.displayName||"viewport",this.x=t.x||0,this.y=t.y||0,this.width=t.width||1,this.height=t.height||1,this.zoom=t.zoom||0,this.distanceScales=t.distanceScales||xt,this.focalDistance=t.focalDistance||1,this.position=t.position||Tt,this.modelMatrix=t.modelMatrix||null;const{longitude:e,latitude:i}=t;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(e),this._initProps(t),this._initMatrices(t),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?wt:Pt:Mt}equals(t){return t instanceof Ot&&(this===t||t.width===this.width&&t.height===this.height&&t.scale===this.scale&&l(t.projectionMatrix,this.projectionMatrix)&&l(t.viewMatrix,this.viewMatrix))}project(t,{topLeft:e=!0}={}){const i=ft(this.projectPosition(t),this.pixelProjectionMatrix),[r,n]=i,s=e?n:this.height-n;return 2===t.length?[r,s]:[r,s,i[2]]}unproject(t,{topLeft:e=!0,targetZ:i}={}){const[r,n,s]=t,o=e?n:this.height-n,a=i&&i*this.distanceScales.unitsPerMeter[2],h=mt([r,o,s],this.pixelUnprojectionMatrix,a),[c,u,l]=this.unprojectPosition(h);return Number.isFinite(s)?[c,u,l]:Number.isFinite(i)?[c,u,i]:[c,u]}projectPosition(t){const[e,i]=this.projectFlat(t);return[e,i,(t[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(t){const[e,i]=this.unprojectFlat(t);return[e,i,(t[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(t){if(this.isGeospatial){const e=ht(t);return e[1]=c(e[1],-318,830),e}return t}unprojectFlat(t){return this.isGeospatial?ct(t):t}getBounds(t={}){const e={targetZ:t.z||0},i=this.unproject([0,0],e),r=this.unproject([this.width,0],e),n=this.unproject([0,this.height],e),s=this.unproject([this.width,this.height],e);return[Math.min(i[0],r[0],n[0],s[0]),Math.min(i[1],r[1],n[1],s[1]),Math.max(i[0],r[0],n[0],s[0]),Math.max(i[1],r[1],n[1],s[1])]}getDistanceScales(t){return t?ut({longitude:t[0],latitude:t[1],highPrecision:!0}):this.distanceScales}containsPixel({x:t,y:e,width:i=1,height:r=1}){return t=3){const t="%"===e[2],i=parseFloat(e[1]);return{position:t?i/100:i,relative:t}}default:throw new Error("Could not parse position string ".concat(t))}}function At(t,e){return t.relative?Math.round(t.position*e):t.position}function jt(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}const Ft=Math.PI/180;function Ct(t){return 512/4003e4/Math.cos(t*Ft)}class Nt extends Ot{constructor(t={}){const{latitude:e=0,longitude:i=0,zoom:n=0,pitch:s=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:h=1.01,orthographic:c=!1,projectionMatrix:u,repeat:l=!1,worldOffset:p=0,legacyMeterSizes:g=!1}=t;let{width:d,height:f,altitude:m=1.5}=t;const _=Math.pow(2,n);let b;d=d||1,f=f||1;let v=null;u?(m=u[5]/2,b=gt(m)):(t.fovy?(b=t.fovy,m=dt(b)):b=gt(m),v=pt({width:d,height:f,pitch:s,fovy:b,nearZMultiplier:a,farZMultiplier:h}));let E=lt({height:f,pitch:s,bearing:o,scale:_,altitude:m});if(p){E=(new X).translate([512*p,0,0]).multiplyLeft(E)}super({...t,width:d,height:f,viewMatrix:E,longitude:i,latitude:e,zoom:n,...v,fovy:b,focalDistance:m}),Object(r.a)(this,"longitude",void 0),Object(r.a)(this,"latitude",void 0),Object(r.a)(this,"pitch",void 0),Object(r.a)(this,"bearing",void 0),Object(r.a)(this,"altitude",void 0),Object(r.a)(this,"fovy",void 0),Object(r.a)(this,"orthographic",void 0),Object(r.a)(this,"_subViewports",void 0),Object(r.a)(this,"_pseudoMeters",void 0),this.latitude=e,this.longitude=i,this.zoom=n,this.pitch=s,this.bearing=o,this.altitude=m,this.fovy=b,this.orthographic=c,this._subViewports=l?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const t=this.getBounds(),e=Math.floor((t[0]+180)/360),i=Math.ceil((t[2]-180)/360);for(let t=e;t<=i;t++){const e=t?new Nt({...this,worldOffset:t}):this;this._subViewports.push(e)}}return this._subViewports}projectPosition(t){if(this._pseudoMeters)return super.projectPosition(t);const[e,i]=this.projectFlat(t);return[e,i,(t[2]||0)*Ct(t[1])]}unprojectPosition(t){if(this._pseudoMeters)return super.unprojectPosition(t);const[e,i]=this.unprojectFlat(t);return[e,i,(t[2]||0)/Ct(i)]}addMetersToLngLat(t,e){return function(t,e){const[i,r,n]=t,[s,o,a]=e,{unitsPerMeter:h,unitsPerMeter2:c}=ut({longitude:i,latitude:r,highPrecision:!0}),u=ht(t);u[0]+=s*(h[0]+c[0]*o),u[1]+=o*(h[1]+c[1]*o);const l=ct(u),p=(n||0)+(a||0);return Number.isFinite(n)||Number.isFinite(a)?[l[0],l[1],p]:l}(t,e)}panByPosition(t,e){const i=mt(e,this.pixelUnprojectionMatrix),r=D([],this.projectFlat(t),B([],i)),n=D([],this.center,r),[s,o]=this.unprojectFlat(n);return{longitude:s,latitude:o}}getBounds(t={}){const e=vt(this,t.z||0);return[Math.min(e[0][0],e[1][0],e[2][0],e[3][0]),Math.min(e[0][1],e[1][1],e[2][1],e[3][1]),Math.max(e[0][0],e[1][0],e[2][0],e[3][0]),Math.max(e[0][1],e[1][1],e[2][1],e[3][1])]}fitBounds(t,e={}){const{width:i,height:r}=this,{longitude:n,latitude:s,zoom:o}=_t({width:i,height:r,bounds:t,...e});return new Nt({width:i,height:r,longitude:n,latitude:s,zoom:o})}}Object(r.a)(Nt,"displayName","WebMercatorViewport");class It{constructor(t){Object(r.a)(this,"_inProgress",void 0),Object(r.a)(this,"_handle",void 0),Object(r.a)(this,"_timeline",void 0),Object(r.a)(this,"time",void 0),Object(r.a)(this,"settings",void 0),this._inProgress=!1,this._handle=null,this._timeline=t,this.time=0,this.settings={duration:0}}get inProgress(){return this._inProgress}start(t){var e,i;this.cancel(),this.settings=t,this._inProgress=!0,null===(e=(i=this.settings).onStart)||void 0===e||e.call(i,this)}end(){var t,e;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,null===(t=(e=this.settings).onEnd)||void 0===t||t.call(e,this))}cancel(){var t,e;this._inProgress&&(null===(t=(e=this.settings).onInterrupt)||void 0===t||t.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var t,e;if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:t,settings:e}=this;this._handle=t.addChannel({delay:t.getTime(),duration:e.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),null===(t=(e=this.settings).onUpdate)||void 0===t||t.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const Dt=()=>{},Bt=2,kt=3,Vt=t=>t,Ut=1;class zt{constructor(t){Object(r.a)(this,"getControllerState",void 0),Object(r.a)(this,"props",void 0),Object(r.a)(this,"propsInTransition",void 0),Object(r.a)(this,"transition",void 0),Object(r.a)(this,"onViewStateChange",void 0),Object(r.a)(this,"onStateChange",void 0),Object(r.a)(this,"_onTransitionUpdate",t=>{const{time:e,settings:{interpolator:i,startProps:r,endProps:n,duration:s,easing:o}}=t,a=o(e/s),h=i.interpolateProps(r,n,a);this.propsInTransition=this.getControllerState({...this.props,...h}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})}),this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new It(t.timeline),this.onViewStateChange=t.onViewStateChange||Dt,this.onStateChange=t.onStateChange||Dt}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let e=!1;const i=this.props;if(this.props=t,!i||this._shouldIgnoreViewportChange(i,t))return!1;if(this._isTransitionEnabled(t)){let r=i;if(this.transition.inProgress){const{interruption:t,endProps:e}=this.transition.settings;r={...i,...t===Bt?e:this.propsInTransition||i}}this._triggerTransition(r,t),e=!0}else this.transition.cancel();return e}updateTransition(){this.transition.update()}_isTransitionEnabled(t){const{transitionDuration:e,transitionInterpolator:i}=t;return(e>0||"auto"===e)&&Boolean(i)}_isUpdateDueToCurrentTransition(t){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(t,this.propsInTransition)}_shouldIgnoreViewportChange(t,e){return this.transition.inProgress?this.transition.settings.interruption===kt||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e)}_triggerTransition(t,e){const i=this.getControllerState(t),r=this.getControllerState(e).shortestPathFrom(i),n=e.transitionInterpolator,s=n.getDuration?n.getDuration(t,e):e.transitionDuration;if(0===s)return;const o=n.initializeProps(t,r);this.propsInTransition={};const a={duration:s,easing:e.transitionEasing||Vt,interpolator:n,interruption:e.transitionInterruption||Ut,startProps:o.start,endProps:o.end,onStart:e.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(e.onTransitionInterrupt),onEnd:this._onTransitionEnd(e.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(t){return e=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),null==t||t(e)}}}const Wt=["longitude","latitude","zoom","bearing","pitch"],Gt=["longitude","latitude","zoom"];class Zt extends class{constructor(t){Object(r.a)(this,"_propsToCompare",void 0),Object(r.a)(this,"_propsToExtract",void 0),Object(r.a)(this,"_requiredProps",void 0);const{compare:e,extract:i,required:n}=t;this._propsToCompare=e,this._propsToExtract=i||e,this._requiredProps=n}arePropsEqual(t,e){for(const i of this._propsToCompare)if(!(i in t)||!(i in e)||!l(t[i],e[i]))return!1;return!0}initializeProps(t,e){const i={},r={};for(const n of this._propsToExtract)(n in t||n in e)&&(i[n]=t[n],r[n]=e[n]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(t,e){return e.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach(e=>{const i=t[e];jt(Number.isFinite(i)||Array.isArray(i),"".concat(e," is required for transition"))})}}{constructor(t={}){const e=Array.isArray(t)?t:t.transitionProps,i=Array.isArray(t)?{}:t;i.transitionProps=Array.isArray(e)?{compare:e,required:e}:e||{compare:Wt,required:Gt},super(i.transitionProps),Object(r.a)(this,"opts",void 0),this.opts=i}initializeProps(t,e){const i=super.initializeProps(t,e),{makeViewport:r,around:n}=this.opts;if(r&&n){const s=r(t),o=r(e),a=s.unproject(n);i.start.around=n,Object.assign(i.end,{around:o.project(a),aroundPosition:a,width:e.width,height:e.height})}return i}interpolateProps(t,e,i){const r={};for(const n of this._propsToExtract)r[n]=u(t[n]||0,e[n]||0,i);if(e.aroundPosition&&this.opts.makeViewport){const n=this.opts.makeViewport({...e,...r});Object.assign(r,n.panByPosition(e.aroundPosition,u(t.around,e.around,i)))}return r}}const qt={transitionDuration:0},Xt=t=>1-(1-t)*(1-t),Yt=["wheel"],Ht=["panstart","panmove","panend"],Kt=["pinchstart","pinchmove","pinchend"],Qt=["tripanstart","tripanmove","tripanend"],Jt=["doubletap"],$t=["keydown"],te={};class ee extends class{constructor(t,e){Object(r.a)(this,"_viewportProps",void 0),Object(r.a)(this,"_state",void 0),this._viewportProps=this.applyConstraints(t),this._state=e}getViewportProps(){return this._viewportProps}getState(){return this._state}}{constructor(t){const{width:e,height:i,latitude:n,longitude:s,zoom:o,bearing:a=0,pitch:h=0,altitude:c=1.5,position:u=[0,0,0],maxZoom:l=20,minZoom:p=0,maxPitch:g=60,minPitch:d=0,startPanLngLat:f,startZoomLngLat:m,startRotatePos:_,startBearing:b,startPitch:v,startZoom:E,normalize:w=!0}=t;jt(Number.isFinite(s)),jt(Number.isFinite(n)),jt(Number.isFinite(o)),super({width:e,height:i,latitude:n,longitude:s,zoom:o,bearing:a,pitch:h,altitude:c,maxZoom:l,minZoom:p,maxPitch:g,minPitch:d,normalize:w,position:u},{startPanLngLat:f,startZoomLngLat:m,startRotatePos:_,startBearing:b,startPitch:v,startZoom:E}),Object(r.a)(this,"makeViewport",void 0),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanLngLat:this._unproject(t)})}pan({pos:t,startPos:e}){const i=this.getState().startPanLngLat||this._unproject(e);if(!i)return this;const r=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(r)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:e=0,deltaAngleY:i=0}){const{startRotatePos:r,startBearing:n,startPitch:s}=this.getState();if(!r||void 0===n||void 0===s)return this;let o;return o=t?this._getNewRotation(t,r,s,n):{bearing:n+e,pitch:s+i},this._getUpdatedState(o)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:t}){return this._getUpdatedState({startZoomLngLat:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:e,scale:i}){let{startZoom:r,startZoomLngLat:n}=this.getState();if(n||(r=this.getViewportProps().zoom,n=this._unproject(e)||this._unproject(t)),!n)return this;const{maxZoom:s,minZoom:o}=this.getViewportProps();let a=r+Math.log2(i);a=c(a,o,s);const h=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...h.panByPosition(n,t)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(t=2){return this._zoomFromCenter(t)}zoomOut(t=2){return this._zoomFromCenter(1/t)}moveLeft(t=100){return this._panFromCenter([t,0])}moveRight(t=100){return this._panFromCenter([-t,0])}moveUp(t=100){return this._panFromCenter([0,t])}moveDown(t=100){return this._panFromCenter([0,-t])}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}shortestPathFrom(t){const e=t.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:n}=i;return Math.abs(r-e.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(n-e.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(t){const{maxZoom:e,minZoom:i,zoom:r}=t;t.zoom=c(r,i,e);const{maxPitch:n,minPitch:s,pitch:o}=t;t.pitch=c(o,s,n);const{normalize:a=!0}=t;return a&&Object.assign(t,function(t){const{width:e,height:i,pitch:r=0}=t;let{longitude:n,latitude:s,zoom:o,bearing:a=0}=t;(n<-180||n>180)&&(n=J(n+180,360)-180),(a<-180||a>180)&&(a=J(a+180,360)-180);const h=tt(i/512);if(o<=h)o=h,s=0;else{const t=i/2/Math.pow(2,o),e=ct([0,t])[1];if(se&&(s=e)}}return{width:e,height:i,longitude:n,latitude:s,zoom:o,pitch:r,bearing:a}}(t)),t}_zoomFromCenter(t){const{width:e,height:i}=this.getViewportProps();return this.zoom({pos:[e/2,i/2],scale:t})}_panFromCenter(t){const{width:e,height:i}=this.getViewportProps();return this.pan({startPos:[e/2,i/2],pos:[e/2+t[0],i/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}_unproject(t){const e=this.makeViewport(this.getViewportProps());return t&&e.unproject(t)}_getNewRotation(t,e,i,r){const n=t[0]-e[0],s=t[1]-e[1],o=t[1],a=e[1],{width:h,height:u}=this.getViewportProps(),l=n/h;let p=0;s>0?Math.abs(u-a)>5&&(p=s/(a-u)*1.2):s<0&&a>5&&(p=1-o/a),p=c(p,-1,1);const{minPitch:g,maxPitch:d}=this.getViewportProps();let f=i;return p>0?f=i+p*(d-i):p<0&&(f=i-p*(g-i)),{pitch:f,bearing:r+180*l}}}class ie extends class{constructor(t){Object(r.a)(this,"props",void 0),Object(r.a)(this,"state",{}),Object(r.a)(this,"transitionManager",void 0),Object(r.a)(this,"eventManager",void 0),Object(r.a)(this,"onViewStateChange",void 0),Object(r.a)(this,"onStateChange",void 0),Object(r.a)(this,"makeViewport",void 0),Object(r.a)(this,"_controllerState",void 0),Object(r.a)(this,"_events",{}),Object(r.a)(this,"_interactionState",{isDragging:!1}),Object(r.a)(this,"_customEvents",[]),Object(r.a)(this,"_eventStartBlocked",null),Object(r.a)(this,"_panMove",!1),Object(r.a)(this,"invertPan",!1),Object(r.a)(this,"dragMode","rotate"),Object(r.a)(this,"inertia",0),Object(r.a)(this,"scrollZoom",!0),Object(r.a)(this,"dragPan",!0),Object(r.a)(this,"dragRotate",!0),Object(r.a)(this,"doubleClickZoom",!0),Object(r.a)(this,"touchZoom",!0),Object(r.a)(this,"touchRotate",!1),Object(r.a)(this,"keyboard",!0),this.transitionManager=new zt({...t,getControllerState:t=>new this.ControllerState(t),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=t.eventManager,this.onViewStateChange=t.onViewStateChange||(()=>{}),this.onStateChange=t.onStateChange||(()=>{}),this.makeViewport=t.makeViewport}set events(t){this.toggleEvents(this._customEvents,!1),this.toggleEvents(t,!0),this._customEvents=t,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events){var t;if(this._events[e])null===(t=this.eventManager)||void 0===t||t.off(e,this.handleEvent)}this.transitionManager.finalize()}handleEvent(t){this._controllerState=void 0;const e=this._eventStartBlocked;switch(t.type){case"panstart":return!e&&this._onPanStart(t);case"panmove":return this._onPan(t);case"panend":return this._onPanEnd(t);case"pinchstart":return!e&&this._onPinchStart(t);case"pinchmove":return this._onPinch(t);case"pinchend":return this._onPinchEnd(t);case"tripanstart":return!e&&this._onTriplePanStart(t);case"tripanmove":return this._onTriplePan(t);case"tripanend":return this._onTriplePanEnd(t);case"doubletap":return this._onDoubleTap(t);case"wheel":return this._onWheel(t);case"keydown":return this._onKeyDown(t);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(t){const{x:e,y:i}=this.props,{offsetCenter:r}=t;return[r.x-e,r.y-i]}isPointInBounds(t,e){const{width:i,height:r}=this.props;if(e&&e.handled)return!1;const n=t[0]>=0&&t[0]<=i&&t[1]>=0&&t[1]<=r;return n&&e&&e.stopPropagation(),n}isFunctionKeyPressed(t){const{srcEvent:e}=t;return Boolean(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(t){const e=setTimeout(()=>{this._eventStartBlocked===e&&(this._eventStartBlocked=null)},t);this._eventStartBlocked=e}setProps(t){t.dragMode&&(this.dragMode=t.dragMode),this.props=t,"transitionInterpolator"in t||(t.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(t);const{inertia:e}=t;this.inertia=Number.isFinite(e)?e:!0===e?300:0;const{scrollZoom:i=!0,dragPan:r=!0,dragRotate:n=!0,doubleClickZoom:s=!0,touchZoom:o=!0,touchRotate:a=!1,keyboard:h=!0}=t,c=Boolean(this.onViewStateChange);this.toggleEvents(Yt,c&&i),this.toggleEvents(Ht,c&&(r||n)),this.toggleEvents(Kt,c&&(o||a)),this.toggleEvents(Qt,c&&a),this.toggleEvents(Jt,c&&s),this.toggleEvents($t,c&&h),this.scrollZoom=i,this.dragPan=r,this.dragRotate=n,this.doubleClickZoom=s,this.touchZoom=o,this.touchRotate=a,this.keyboard=h}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,e){this.eventManager&&t.forEach(t=>{this._events[t]!==e&&(this._events[t]=e,e?this.eventManager.on(t,this.handleEvent):this.eventManager.off(t,this.handleEvent))})}updateViewport(t,e=null,i={}){const r={...t.getViewportProps(),...e},n=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(i),n){const t=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:t})}}_onTransition(t){this.onViewStateChange({...t,interactionState:this._interactionState})}_setInteractionState(t){Object.assign(this._interactionState,t),this.onStateChange(this._interactionState)}_onPanStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;let i=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const r=this.controllerState[i?"panStart":"rotateStart"]({pos:e});return this._panMove=i,this.updateViewport(r,qt,{isDragging:!0}),!0}_onPan(t){return!!this.isDragging()&&(this._panMove?this._onPanMove(t):this._onPanRotate(t))}_onPanEnd(t){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(t):this._onPanRotateEnd(t))}_onPanMove(t){if(!this.dragPan)return!1;const e=this.getCenter(t),i=this.controllerState.pan({pos:e});return this.updateViewport(i,qt,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){const{inertia:e}=this;if(this.dragPan&&e&&t.velocity){const i=this.getCenter(t),r=[i[0]+t.velocityX*e/2,i[1]+t.velocityY*e/2],n=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:Xt},{isDragging:!1,isPanning:!0})}else{const t=this.controllerState.panEnd();this.updateViewport(t,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;const e=this.getCenter(t),i=this.controllerState.rotate({pos:e});return this.updateViewport(i,qt,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){const{inertia:e}=this;if(this.dragRotate&&e&&t.velocity){const i=this.getCenter(t),r=[i[0]+t.velocityX*e/2,i[1]+t.velocityY*e/2],n=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:Xt},{isDragging:!1,isRotating:!0})}else{const t=this.controllerState.rotateEnd();this.updateViewport(t,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(t){if(!this.scrollZoom)return!1;t.srcEvent.preventDefault();const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const{speed:i=.01,smooth:r=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:n}=t;let s=2/(1+Math.exp(-Math.abs(n*i)));n<0&&0!==s&&(s=1/s);const o=this.controllerState.zoom({pos:e,scale:s});return this.updateViewport(o,{...this._getTransitionProps({around:e}),transitionDuration:r?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const i=this.controllerState.rotateStart({pos:e});return this.updateViewport(i,qt,{isDragging:!0}),!0}_onTriplePan(t){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const e=this.getCenter(t);e[0]-=t.deltaX;const i=this.controllerState.rotate({pos:e});return this.updateViewport(i,qt,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(t){if(!this.isDragging())return!1;const{inertia:e}=this;if(this.touchRotate&&e&&t.velocityY){const i=this.getCenter(t),r=[i[0],i[1]+=t.velocityY*e/2],n=this.controllerState.rotate({pos:r});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:Xt},{isDragging:!1,isRotating:!0}),this.blockEvents(e)}else{const t=this.controllerState.rotateEnd();this.updateViewport(t,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const i=this.controllerState.zoomStart({pos:e}).rotateStart({pos:e});return te._startPinchRotation=t.rotation,te._lastPinchEvent=t,this.updateViewport(i,qt,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let e=this.controllerState;if(this.touchZoom){const{scale:i}=t,r=this.getCenter(t);e=e.zoom({pos:r,scale:i})}if(this.touchRotate){const{rotation:i}=t;e=e.rotate({deltaAngleX:te._startPinchRotation-i})}return this.updateViewport(e,qt,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),te._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;const{inertia:e}=this,{_lastPinchEvent:i}=te;if(this.touchZoom&&e&&i&&t.scale!==i.scale){const r=this.getCenter(t);let n=this.controllerState.rotateEnd();const s=Math.log2(t.scale),o=(s-Math.log2(i.scale))/(t.deltaTime-i.deltaTime),a=Math.pow(2,s+o*e/2);n=n.zoom({pos:r,scale:a}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:r}),transitionDuration:e,transitionEasing:Xt},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(e)}else{const t=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(t,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return te._startPinchRotation=null,te._lastPinchEvent=null,!0}_onDoubleTap(t){if(!this.doubleClickZoom)return!1;const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const i=this.isFunctionKeyPressed(t),r=this.controllerState.zoom({pos:e,scale:i?.5:2});return this.updateViewport(r,this._getTransitionProps({around:e}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;const e=this.isFunctionKeyPressed(t),{zoomSpeed:i,moveSpeed:r,rotateSpeedX:n,rotateSpeedY:s}=!0===this.keyboard?{}:this.keyboard,{controllerState:o}=this;let a;const h={};switch(t.srcEvent.code){case"Minus":a=e?o.zoomOut(i).zoomOut(i):o.zoomOut(i),h.isZooming=!0;break;case"Equal":a=e?o.zoomIn(i).zoomIn(i):o.zoomIn(i),h.isZooming=!0;break;case"ArrowLeft":e?(a=o.rotateLeft(n),h.isRotating=!0):(a=o.moveLeft(r),h.isPanning=!0);break;case"ArrowRight":e?(a=o.rotateRight(n),h.isRotating=!0):(a=o.moveRight(r),h.isPanning=!0);break;case"ArrowUp":e?(a=o.rotateUp(s),h.isRotating=!0):(a=o.moveUp(r),h.isPanning=!0);break;case"ArrowDown":e?(a=o.rotateDown(s),h.isRotating=!0):(a=o.moveDown(r),h.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),h),!0}_getTransitionProps(t){const{transition:e}=this;return e&&e.transitionInterpolator?t?{...e,transitionInterpolator:new Zt({...t,...e.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:e:qt}}{constructor(...t){super(...t),Object(r.a)(this,"ControllerState",ee),Object(r.a)(this,"transition",{transitionDuration:300,transitionInterpolator:new Zt({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})}),Object(r.a)(this,"dragMode","pan")}setProps(t){t.position=t.position||[0,0,0];const e=this.props;super.setProps(t);(!e||e.height!==t.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...t,...this.state}))}}class re extends class{constructor(t){Object(r.a)(this,"id",void 0),Object(r.a)(this,"viewportInstance",void 0),Object(r.a)(this,"_x",void 0),Object(r.a)(this,"_y",void 0),Object(r.a)(this,"_width",void 0),Object(r.a)(this,"_height",void 0),Object(r.a)(this,"_padding",void 0),Object(r.a)(this,"props",void 0);const{id:e,x:i=0,y:n=0,width:s="100%",height:o="100%",padding:a=null,viewportInstance:h}=t||{};jt(!h||h instanceof Ot),this.viewportInstance=h,this.id=e||this.constructor.displayName||"view",this.props={...t,id:this.id},this._x=Lt(i),this._y=Lt(n),this._width=Lt(s),this._height=Lt(o),this._padding=a&&{left:Lt(a.left||0),right:Lt(a.right||0),top:Lt(a.top||0),bottom:Lt(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t||(this.viewportInstance?!!t.viewportInstance&&this.viewportInstance.equals(t.viewportInstance):this.ViewportType===t.ViewportType&&function t(e,i){if(e===i)return!0;if(!e||!i)return!1;for(const r in e){const n=e[r],s=i[r];if(!(n===s||Array.isArray(n)&&Array.isArray(s)&&t(n,s)))return!1}return!0}(this.props,t.props))}makeViewport({width:t,height:e,viewState:i}){if(this.viewportInstance)return this.viewportInstance;i=this.filterViewState(i);const r=this.getDimensions({width:t,height:e});return new this.ViewportType({...i,...this.props,...r})}getViewStateId(){const{viewState:t}=this.props;return"string"==typeof t?t:(null==t?void 0:t.id)||this.id}filterViewState(t){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const e={...t};for(const t in this.props.viewState)"id"!==t&&(e[t]=this.props.viewState[t]);return e}return t}getDimensions({width:t,height:e}){const i={x:At(this._x,t),y:At(this._y,e),width:At(this._width,t),height:At(this._height,e)};return this._padding&&(i.padding={left:At(this._padding.left,t),top:At(this._padding.top,e),right:At(this._padding.right,t),bottom:At(this._padding.bottom,e)}),i}get controller(){const t=this.props.controller;return t?!0===t?{type:this.ControllerType}:"function"==typeof t?{type:t}:{type:this.ControllerType,...t}:null}}{get ViewportType(){return Nt}get ControllerType(){return ie}}Object(r.a)(re,"displayName","MapView");class ne extends Nt{constructor(t){const[e,i]=t.getSize();super(Object.assign({id:"2gis",x:0,y:0,width:e,height:i},se(t),{nearZMultiplier:1/(i||1)}))}get projectionMode(){return 4}}function se(t){const[e,i]=t.getCenter();return{longitude:(e+540)%360-180,latitude:i,zoom:oe(t),bearing:ae(t),pitch:t.getPitch(),padding:t.getPadding(),repeat:!1,fovy:he(t,60,!0)}}function oe(t){return t.getZoom()-1}function ae(t){return-t.getRotation()}function he(t,e,i){if(!i)return e;const r={fov:e,near:1e3},{fov:n}=r,s=function(t){const{size:e,pitch:i,padding:r}=t,n=Math.max(0,r.top-r.bottom)*Math.tan(i),s=function(t){return Math.max(t,1e3)}(e[1])+n;return(r.bottom-r.top)/2+(s-e[1])/2}(t._impl.state);return s>100?100/s*n:e}var ce=class{constructor(t,e={}){this._vao=null,this._attributes=e,this._shaderProgram=t,this._ext=null}bind(t){const e=t.extensions.OES_vertex_array_object;return e?this._bind(t.gl,e):this._shaderProgram.bind(t.gl,null,this._attributes),this}unbind(){return this._ext&&this._ext.bindVertexArrayOES(null),this}remove(){return this._vao&&this._ext.deleteVertexArrayOES(this._vao),this}_bind(t,e){this._vao?e.bindVertexArrayOES(this._vao):this._prepare(t,e)}_prepare(t,e){this._ext=e,this._vao=e.createVertexArrayOES(),e.bindVertexArrayOES(this._vao);const i=this._shaderProgram.attributes,r=this._attributes;for(const e in r){const n=i[e];!0!==n.index&&t.enableVertexAttribArray(n.location),r[e].bind(t,n.location)}}};class ue{constructor(t,e){this._initData=t,this.byteLength=void 0!==t.byteLength?t.byteLength:t,this.type=ue.ArrayBuffer,this.drawType=ue.StaticDraw,this.options=Object.assign({},ue.defaultOptions,e),this._glBuffer=null,this._glContext=null}bind(t,e,i){return this._glBuffer||this.prepare(t),this.type===ue.ArrayBuffer?(t.bindBuffer(t.ARRAY_BUFFER,this._glBuffer),i=i||this.options,t.vertexAttribPointer(e,i.itemSize,this._toGlParam(t,i.dataType),i.normalized,i.stride,i.offset)):this.type===ue.ElementArrayBuffer&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._glBuffer),this}remove(){return this._unprepare(),this}subData(t,e,i){return t.bindBuffer(this._toGlParam(t,this.type),this._glBuffer),t.bufferSubData(this._toGlParam(t,this.type),e,i),this}prepare(t){return this._glContext=t,this._glBuffer=t.createBuffer(),t.bindBuffer(this._toGlParam(t,this.type),this._glBuffer),t.bufferData(this._toGlParam(t,this.type),this._initData,this._toGlParam(t,this.drawType)),this._initData=null,this}_unprepare(){this._glBuffer&&(this._glContext.deleteBuffer(this._glBuffer),this._glBuffer=null,this._glContext=null)}_toGlParam(t,e){return e===ue.ArrayBuffer?t.ARRAY_BUFFER:e===ue.ElementArrayBuffer?t.ELEMENT_ARRAY_BUFFER:e===ue.StaticDraw?t.STATIC_DRAW:e===ue.DynamicDraw?t.DYNAMIC_DRAW:e===ue.Byte?t.BYTE:e===ue.Short?t.SHORT:e===ue.Int?t.INT:e===ue.Float?t.FLOAT:e===ue.UnsignedByte?t.UNSIGNED_BYTE:e===ue.UnsignedShort?t.UNSIGNED_SHORT:e===ue.UnsignedInt?t.UNSIGNED_INT:null}}ue.ArrayBuffer=1,ue.ElementArrayBuffer=2,ue.StaticDraw=10,ue.DynamicDraw=11,ue.Float=20,ue.UnsignedByte=21,ue.UnsignedShort=22,ue.UnsignedInt=23,ue.Byte=24,ue.Short=25,ue.Int=26,ue.defaultOptions={itemSize:3,dataType:ue.Float,stride:0,offset:0,normalized:!1};var le=ue;var pe=class{constructor(t){this.name=t.name,this.index=t.index,this.location=void 0!==t.location?t.location:-1,this._enable=!1}bindLocation(t,e){return-1!==this.location&&!0!==this.index&&t.bindAttribLocation(e,this.location,this.name),this}getLocation(t,e){return-1===this.location&&!0!==this.index&&(this.location=t.getAttribLocation(e,this.name)),this}bind(t,e){return this._enable||!0===this.index||(t.enableVertexAttribArray(this.location),this._enable=!0),e.bind(t,this.location),this}disable(t){return this._enable&&!0!==this.index&&(t.disableVertexAttribArray(this.location),this._enable=!1),this}};var ge=class{constructor(t){this.name=t.name,this.type=t.type,this.location=-1}getLocation(t,e){return this.location=t.getUniformLocation(e,this.name),this}bind(t,e){const i=this.type;return"mat2"===i?t.uniformMatrix2fv(this.location,!1,e):"mat3"===i?t.uniformMatrix3fv(this.location,!1,e):"mat4"===i?t.uniformMatrix4fv(this.location,!1,e):"2f"===i?t.uniform2f(this.location,e[0],e[1]):"3f"===i?t.uniform3f(this.location,e[0],e[1],e[2]):"4f"===i?t.uniform4f(this.location,e[0],e[1],e[2],e[3]):"2i"===i?t.uniform2i(this.location,e[0],e[1]):"3i"===i?t.uniform3i(this.location,e[0],e[1],e[2]):"4i"===i?t.uniform4i(this.location,e[0],e[1],e[2],e[3]):t["uniform"+i](this.location,e),this}};var de=class{constructor(t){t=t||{},this._vertexShader=t.vertex,this._fragmentShader=t.fragment,this.uniforms={},t.uniforms=t.uniforms||[],t.uniforms.forEach(t=>{this.uniforms[t.name]=new ge(t)}),this.attributes={},t.attributes=t.attributes||[],t.attributes.forEach(t=>{this.attributes[t.name]=new pe(t)}),this._linked=!1,this._located=!1,this._error=!1}enable(t){return this._error?this:(this.link(t),this.locate(t),this._error||t.useProgram(this._webglProgram),this)}bind(t,e,i){if(this._error)return this;if(e)for(const i in e)this.uniforms[i].bind(t,e[i]);if(i)for(const e in i)this.attributes[e].bind(t,i[e]);return this}disable(t){if(this._error)return this;for(const e in this.attributes)this.attributes[e].disable(t);return this}link(t){if(this._linked||this._error)return this;try{this._webglProgram=t.createProgram(),this._vertexShader&&t.attachShader(this._webglProgram,this._vertexShader.get(t)),this._fragmentShader&&t.attachShader(this._webglProgram,this._fragmentShader.get(t));for(const e in this.attributes)this.attributes[e].bindLocation(t,this._webglProgram);if(t.linkProgram(this._webglProgram),!t.getProgramParameter(this._webglProgram,t.LINK_STATUS))throw new Error(t.getProgramInfoLog(this._webglProgram));this._linked=!0}catch(t){throw this._error=!0,t}return this}locate(t){if(this._located||this._error)return this;for(const e in this.attributes)this.attributes[e].getLocation(t,this._webglProgram);for(const e in this.uniforms)this.uniforms[e].getLocation(t,this._webglProgram);return this._located=!0,this}};class fe{constructor(t,e,i=[]){this.type="vertex"===t?fe.Vertex:fe.Fragment,this._code=Array.isArray(e)?e.join("\n"):e||"",this._code=i.map(t=>void 0!==t.value?"#define "+t.type+" "+t.value:"#define "+t.type).join("\n")+"\n"+this._code}get(t){return this._shader||this._compile(t),this._shader}remove(t){this._shader&&t.deleteShader(this._shader)}_compile(t){const e=this.type===fe.Vertex?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=this._shader=t.createShader(e);if(!i||t.isContextLost())throw new Error(`[2gl] Failed to create shader. Shader is null: ${!i}. Context is lost: ${t.isContextLost()}`);if(t.shaderSource(i,this._code),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw new Error(t.getShaderInfoLog(i))}}fe.Vertex=1,fe.Fragment=2;var me=fe;function _e({map:t,gl:e,deck:i,renderTarget:r}){var n;if(t.__deck)return t.__deck;const s=i&&(null===(n=null==i?void 0:i.props)||void 0===n?void 0:n._customRender),o=new de({vertex:new me("vertex","precision mediump float;\n#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\nuniform vec2 iResolution;\nattribute vec2 position;\nvarying vec2 vUv;\nvoid texcoords_1_0(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvoid main(void) {\n gl_Position = vec4(position, 1.0, 1.0);\n \n \n vUv = (position + 1.0) * 0.5;\n vUv.y = vUv.y;\n vec2 fragCoord = vUv * iResolution;\n texcoords_1_0(fragCoord, iResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}"),fragment:new me("fragment","precision mediump float;\n#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\nvarying vec2 vUv;\nuniform vec2 iResolution;\nuniform sampler2D iChannel0;\nuniform bool enabled;\n#ifndef FXAA_REDUCE_MIN\n #define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n #define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n #define FXAA_SPAN_MAX 8.0\n#endif\nvec4 fxaa_1_0(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE, \n vec2 v_rgbSW, vec2 v_rgbSE, \n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n \n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n \n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n \n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n \n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\nvoid main() {\n \n mediump vec2 fragCoord = vUv * iResolution; \n vec4 color;\n if (enabled) {\n color = fxaa_1_0(iChannel0, fragCoord, iResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n } else {\n color = texture2D(iChannel0, vUv);\n }\n gl_FragColor = color;\n}\n"),uniforms:[{name:"iResolution",type:"2f"},{name:"iChannel0",type:"1i"},{name:"enabled",type:"1i"}],attributes:[{name:"position",location:0}]}),a=function(t){return new ce(t,{position:new le(new Int8Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),{itemSize:2,dataType:le.Byte,stride:0,offset:0,normalized:!1})})}(o),h={useDevicePixels:!0,_2gisFramestart:!1,_2glRenderTarget:r,_2glProgram:o,_2glVao:a,_framebuffer:r._frameBuffer,_customRender:e=>{t.triggerRerender(),null==s||s(e)}},c=Ee(t,h);let u;return i&&i.props.gl!==e||(Object.assign(c,{gl:e,width:!1,height:!1,touchAction:"unset",viewState:se(t)}),t.on("move",()=>function(t,e){t.setProps({viewState:se(e)}),t.needsRedraw({clearRedrawFlags:!0})}(u,t))),i?(u=i,u.setProps(c),t._impl.on("frameend",()=>u.props._2gisData._2gisCurrentViewport=null),t._impl.on("framestart",()=>i.props._2gisData._2gisFramestart=!0),t.on("resize",()=>function(t,e,i){const r=t.getSize(),n=t.getWebGLContext(),s=[r[0]*window.devicePixelRatio,r[1]*window.devicePixelRatio];i.setSize(s),i.bind(n),e.props._framebuffer=i._frameBuffer,i.unbind(n)}(t,i,r)),t.__deck=u,u):null}function be(t,e,i){if(!t.layerManager)return;let r=t.props._2gisData._2gisCurrentViewport;r||(r=function(t){if(!t)return;return new ne(t)}(e),t.props._2gisData._2gisCurrentViewport=r),function(t,e){var i,r;const n=t.getWebGLContext();(null===(r=null===(i=e.props)||void 0===i?void 0:i.parameters)||void 0===r?void 0:r.cullFaceEnabled)||n.disable(n.CULL_FACE);n.clearDepth(1),n.clear(n.DEPTH_BUFFER_BIT)}(e,i),t._drawLayers("2gis-repaint",{viewports:[r],layerFilter:({layer:t})=>i.id===t.id,clearCanvas:!1})}function ve(t){const e=[];let i=0;t.props._2gisData._2gisCustomLayers.forEach(t=>{const r=new(0,t.props.type)(t.props,{_offset:i++});e.push(r)}),t.setProps({layers:e})}function Ee(t,e){const i=t.getWebGLContext(),r=Object.assign(Object.assign({},e),{parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],polygonOffsetFill:!0,depthFunc:i.LEQUAL,blendEquation:i.FUNC_ADD},_2gisData:{_2gisCustomLayers:new Set,_2gisMap:t},views:[new re({id:"2gis"})]});return Object.assign(r,{gl:i,width:null,height:null,touchAction:"unset",viewState:se(t)}),r}class we{constructor(t,e={}){this._src=t||null,this.options=Object.assign({},we.defaultOptions,e),this._glContext=null}enable(t,e){const i=void 0!==e?e:this.options.unit;return void 0!==i&&t.activeTexture(t.TEXTURE0+i),this._texture||this.prepare(t),t.bindTexture(t.TEXTURE_2D,this._texture),this}remove(){return this._texture&&(this._glContext.deleteTexture(this._texture),this._glContext=null,this._texture=null),this}getTexture(){return this._texture}subImage(t,e,i,r){return t.bindTexture(t.TEXTURE_2D,this._texture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.options.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha),t.texSubImage2D(t.TEXTURE_2D,0,i,r,this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.type),e),this}prepare(t){return this._glContext=t,this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.options.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha),this.options.size?t.texImage2D(t.TEXTURE_2D,0,this._toGlParam(t,this.options.format),this.options.size[0],this.options.size[1],0,this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.type),this._src):t.texImage2D(t.TEXTURE_2D,0,this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.type),this._src),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this._toGlParam(t,this.options.wrapS)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this._toGlParam(t,this.options.wrapT)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this._toGlParam(t,this.options.magFilter)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this._toGlParam(t,this.options.minFilter)),this.options.generateMipmaps&&this.options.minFilter!==we.NearestFilter&&this.options.minFilter!==we.LinearFilter&&t.generateMipmap(t.TEXTURE_2D),t.bindTexture(t.TEXTURE_2D,null),this}_toGlParam(t,e){return e===we.ClampToEdgeWrapping?t.CLAMP_TO_EDGE:e===we.Repeat?t.REPEAT:e===we.MirroredRepeat?t.MIRRORED_REPEAT:e===we.NearestFilter?t.NEAREST:e===we.NearestMipMapNearestFilter?t.NEAREST_MIPMAP_NEAREST:e===we.NearestMipMapLinearFilter?t.NEAREST_MIPMAP_LINEAR:e===we.LinearFilter?t.LINEAR:e===we.LinearMipMapNearestFilter?t.LINEAR_MIPMAP_NEAREST:e===we.LinearMipMapLinearFilter?t.LINEAR_MIPMAP_LINEAR:e===we.RgbaFormat?t.RGBA:e===we.AlphaFormat?t.ALPHA:e===we.RgbFormat?t.RGB:e===we.UnsignedByte?t.UNSIGNED_BYTE:e===we.Float?t.FLOAT:null}}we.ClampToEdgeWrapping=8,we.Repeat=9,we.MirroredRepeat=10,we.NearestFilter=1,we.NearestMipMapNearestFilter=2,we.NearestMipMapLinearFilter=3,we.LinearFilter=4,we.LinearMipMapNearestFilter=5,we.LinearMipMapLinearFilter=6,we.RgbaFormat=11,we.AlphaFormat=12,we.RgbFormat=13,we.UnsignedByte=14,we.Float=15,we.defaultOptions={magFilter:we.LinearFilter,minFilter:we.LinearMipMapLinearFilter,wrapS:we.ClampToEdgeWrapping,wrapT:we.ClampToEdgeWrapping,format:we.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:we.UnsignedByte};var Pe=we;class Me{constructor(t={}){this.options=Object.assign({},Me.defaultOptions,t),this._texture=new Pe(null,this.options),this._glContext=null}bind(t){return this._frameBuffer||this._prepare(t),t.bindFramebuffer(t.FRAMEBUFFER,this._frameBuffer),this}unbind(t){return t.bindFramebuffer(t.FRAMEBUFFER,null),this}remove(){return this._unprepare(),this}setSize(t){return this.options.size=t,this._unprepare(),this}getTexture(){return this._texture}_prepare(t){this._glContext=t,this._texture||(this._texture=new Pe(null,this.options)),this._texture.prepare(t),this._frameBuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,this._frameBuffer),this._renderBuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this._renderBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,this.options.size[0],this.options.size[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this._texture.getTexture(),0),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this._renderBuffer),this._checkComplete(t),t.bindRenderbuffer(t.RENDERBUFFER,null),t.bindFramebuffer(t.FRAMEBUFFER,null)}_unprepare(){this._texture&&(this._texture.remove(this._glContext),this._texture=null),this._frameBuffer&&(this._glContext.deleteFramebuffer(this._frameBuffer),this._glContext.deleteRenderbuffer(this._renderBuffer),this._frameBuffer=null,this._renderBuffer=null)}_checkComplete(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);e!==t.FRAMEBUFFER_COMPLETE&&(e===t.FRAMEBUFFER_UNSUPPORTED?console.log("Framebuffer is unsupported"):e===t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT?console.log("Framebuffer incomplete attachment"):e===t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS?console.log("Framebuffer incomplete dimensions"):e===t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT?console.log("Framebuffer incomplete missing attachment"):console.log("Unexpected framebuffer status: "+e))}}Me.defaultOptions=Object.assign({},Pe.defaultOptions,{size:[0,0],generateMipmaps:!1});var Se=Me;class ye{constructor(t){if(this.onAdd=()=>{if(!this.map&&this.props.deck){const t=this.props.deck.props._2gisData._2gisMap;this.map=t;const e=this.gl=t.getWebGLContext();if(t.__deck&&(this.deck=t.__deck,this.frameBuffer=this.deck.props._2glRenderTarget),!this.frameBuffer||!this.deck){const i=t.getSize();this.frameBuffer=new Se({size:[Math.ceil(i[0]*window.devicePixelRatio),Math.ceil(i[1]*window.devicePixelRatio)],magFilter:Pe.LinearFilter,minFilter:Pe.LinearFilter,wrapS:Pe.ClampToEdgeWrapping,wrapT:Pe.ClampToEdgeWrapping});const r=this.frameBuffer.bind(e);this.frameBuffer.unbind(e),this.deck=_e({map:t,gl:e,deck:this.props.deck,renderTarget:r})}this.program=this.deck.props._2glProgram,this.vao=this.deck.props._2glVao}var t,e;this.deck&&(t=this.deck,e=this,t.props._2gisData._2gisCustomLayers.add(e),ve(t))},this.onRemove=()=>{var t,e;this.deck&&(t=this.deck,e=this,t.props._2gisData._2gisCustomLayers.delete(e),ve(t))},this.render=()=>{if(!(this.deck&&this.map&&this.frameBuffer&&this.program&&this.vao&&this.gl))return;const{_2gisData:t,skipResizeRenderer:e}=this.deck.props,i=this.gl;this.frameBuffer.bind(i),i.clearColor(1,1,1,0),t._2gisFramestart?(i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),t._2gisFramestart=!1):i.clear(i.COLOR_BUFFER_BIT),this.frameBuffer.unbind(i);const r=this.map.getSize();if(!e||this.deck.width===r[0]&&this.deck.height===r[1]){be(this.deck,this.map,this),i.bindFramebuffer(i.FRAMEBUFFER,null);this.frameBuffer.getTexture().enable(i,0),this.program.enable(i),this.program.bind(i,{iResolution:[r[0]*window.devicePixelRatio,r[1]*window.devicePixelRatio],iChannel0:0,enabled:Number(this.antialiasing)}),this.vao.bind({gl:i,extensions:{OES_vertex_array_object:i.getExtension("OES_vertex_array_object")}}),i.disable(i.CULL_FACE),i.drawArrays(i.TRIANGLES,0,6)}},!t.id)throw new Error("Layer must have a unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t,this.antialiasing=Boolean(t.antialiasing)}setProps(t){Object.assign(this.props,t,{id:this.id}),this.antialiasing=Boolean(t.antialiasing),this.deck&&ve(this.deck)}}ye.initDeck2gisProps=(t,e)=>Ee(t,e),"undefined"!=typeof window&&("mapgl"in window?mapgl.Deck2gisLayer=ye:(window.__mapglPlugins||(window.__mapglPlugins={}),window.__mapglPlugins.Deck2gisLayer=ye))},,function(t,e,i){"use strict";i.d(e,"a",(function(){return v}));var r=i(0),n=i(6);const s="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";Object(n.a)();class o{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";Object(r.a)(this,"storage",void 0),Object(r.a)(this,"id",void 0),Object(r.a)(this,"config",{}),this.storage=function(t){try{const e=window[t],i="__storage_test__";return e.setItem(i,i),e.removeItem(i),e}catch(t){return null}}(i),this.id=t,this.config={},Object.assign(this.config,e),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){return this.config={},this.updateConfiguration(t)}updateConfiguration(t){if(Object.assign(this.config,t),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}_loadConfiguration(){let t={};if(this.storage){const e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}}function a(t,e,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const n=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>r&&(i=Math.min(i,r/t.width));const s=t.width*i,o=t.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(s/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(n,");"),"background-size:".concat(s,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}let h;function c(t){return"string"==typeof t?h[t.toUpperCase()]||h.WHITE:t}function u(t,e){if(!t)throw new Error(e||"Assertion failed")}!function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(h||(h={}));var l=i(1);function p(){let t;var e,i;if(n.a&&"performance"in l.b)t=null===l.b||void 0===l.b||null===(e=l.b.performance)||void 0===e||null===(i=e.now)||void 0===i?void 0:i.call(e);else if("hrtime"in l.a){var r;const e=null===l.a||void 0===l.a||null===(r=l.a.hrtime)||void 0===r?void 0:r.call(l.a);t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}var g=i(5);const d={debug:n.a&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},f={enabled:!0,level:0};function m(){}const _={},b={once:!0};class v{constructor(){let{id:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};Object(r.a)(this,"id",void 0),Object(r.a)(this,"VERSION",s),Object(r.a)(this,"_startTs",p()),Object(r.a)(this,"_deltaTs",p()),Object(r.a)(this,"_storage",void 0),Object(r.a)(this,"userData",{}),Object(r.a)(this,"LOG_THROTTLE_TIMEOUT",0),this.id=t,this._storage=new o("__probe-".concat(this.id,"__"),f),this.userData={},this.timeStamp("".concat(this.id," started")),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(t),r=Object.getOwnPropertyNames(i);for(const i of r)"function"==typeof t[i]&&(e.find(t=>i===t)||(t[i]=t[i].bind(t)))}(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((p()-this._startTs).toPrecision(10))}getDelta(){return Number((p()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:t}),this}setLevel(t){return this._storage.updateConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.updateConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){u(t,e)}warn(t){return this._getLogFunction(0,t,d.warn,arguments,b)}error(t){return this._getLogFunction(0,t,d.error,arguments)}deprecated(t,e){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(t,e){return this.error("`".concat(t,"` has been removed. Use `").concat(e,"` instead"))}probe(t,e){return this._getLogFunction(t,e,d.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,d.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n{const e=a(t,i,r);console.log(...e)},t.src=e,m}const n=e.nodeName||"";if("img"===n.toLowerCase())return console.log(...a(e,i,r)),m;if("canvas"===n.toLowerCase()){const t=new Image;return t.onload=()=>console.log(...a(t,i,r)),t.src=e.toDataURL(),m}return m}({image:r,message:s,scale:o}):function(t){let{image:e,message:i="",scale:r=1}=t;return g.nodeAsciifyImage({image:e,message:i,scale:r}),m}({image:r,message:s,scale:o}):m}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||m)}group(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const r=w({logLevel:t,message:e,opts:i}),{collapsed:n}=i;return r.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(t,e,Object.assign({},i,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||m)}withGroup(t,e,i){this.group(t,e)();try{i()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=E(t)}_getLogFunction(t,e,i,r,s){if(this._shouldLog(t)){s=w({logLevel:t,message:e,args:r,opts:s}),u(i=i||s.method),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=p();const o=s.tag||s.message;if(s.once){if(_[o])return m;_[o]=p()}return e=function(t,e,i){if("string"==typeof e){const a=i.time?function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const i=Math.max(e-t.length,0);return"".concat(" ".repeat(i)).concat(t)}(function(t){let e;return e=t<10?"".concat(t.toFixed(2),"ms"):t<100?"".concat(t.toFixed(1),"ms"):t<1e3?"".concat(t.toFixed(0),"ms"):"".concat((t/1e3).toFixed(2),"s"),e}(i.total)):"";e=i.time?"".concat(t,": ").concat(a," ").concat(e):"".concat(t,": ").concat(e),r=e,s=i.color,o=i.background,n.a||"string"!=typeof r||(s&&(s=c(s),r="[".concat(s,"m").concat(r,"")),o&&(s=c(o),r="[".concat(o+10,"m").concat(r,""))),e=r}var r,s,o;return e}(this.id,s.message,s),i.bind(console,e,...s.args)}return m}}function E(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return u(Number.isFinite(e)&&e>=0),e}function w(t){const{logLevel:e,message:i}=t;t.logLevel=E(e);const r=t.args?Array.from(t.args):[];for(;r.length&&r.shift()!==i;);switch(typeof e){case"string":case"function":void 0!==i&&r.unshift(i),t.message=e;break;case"object":Object.assign(t,e)}"function"==typeof t.message&&(t.message=t.message());const n=typeof t.message;return u("string"===n||"object"===n),Object.assign(t,{args:r},t.opts)}function P(t){for(const e in t)for(const i in t[e])return i||"untitled";return"empty"}Object(r.a)(v,"VERSION",s)}])})); \ No newline at end of file diff --git a/dist/demo.js b/dist/demo.js new file mode 100644 index 0000000..b02fe66 --- /dev/null +++ b/dist/demo.js @@ -0,0 +1,6 @@ +!function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i(i.s=36)}([,,,,function(t,e,i){"use strict";(function(t,n){i.d(e,"a",(function(){return r}));"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof document&&document;const r=Boolean("object"!=typeof n||"[object process]"!==String(n)||n.browser),s=void 0!==n&&n.version&&/v([0-9]*)/.exec(n.version);s&&parseFloat(s[1])}).call(this,i(14),i(8))},,function(t,e,i){"use strict";(function(t,n){i.d(e,"b",(function(){return s})),i.d(e,"a",(function(){return o}));const r={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document,process:"object"==typeof n&&n},s=(globalThis,r.window||r.self||r.global),o=r.process||{};console}).call(this,i(14),i(8))},function(t,e,i){"use strict";(function(t){i.d(e,"b",(function(){return n})),i.d(e,"c",(function(){return r})),i.d(e,"a",(function(){return s}));const n="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",r="undefined"!=typeof window?window:t;void 0!==t||window,"undefined"!=typeof document&&document;let s=!1;try{const t={get passive(){return s=!0,!0}};r.addEventListener("test",null,t),r.removeEventListener("test",null)}catch(t){s=!1}}).call(this,i(14))},function(t,e){var i,n,r=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(t){i=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var c,l=[],h=!1,u=-1;function d(){h&&c&&(h=!1,c.length?l=c.concat(l):u=-1,l.length&&f())}function f(){if(!h){var t=a(d);h=!0;for(var e=l.length;e;){for(c=l,l=[];++u1)for(var i=1;i\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",s=r.console&&(r.console.warn||r.console.log);return s&&s.call(r.console,n,i),t.apply(this,arguments)}}c="function"!=typeof Object.assign?function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),i=1;i-1}function M(t){return t.trim().split(/\s+/g)}function C(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var n=0;ni[e]})):n.sort()),n}function O(t,e){for(var i,n,r=e[0].toUpperCase()+e.slice(1),s=0;s1&&!i.firstMultiple?i.firstMultiple=V(e):1===r&&(i.firstMultiple=!1);var s=i.firstInput,o=i.firstMultiple,a=o?o.center:s.center,c=e.center=G(n);e.timeStamp=f(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=q(a,c),e.distance=X(a,c),function(t,e){var i=e.center,n=t.offsetDelta||{},r=t.prevDelta||{},s=t.prevInput||{};1!==e.eventType&&4!==s.eventType||(r=t.prevDelta={x:s.deltaX||0,y:s.deltaY||0},n=t.offsetDelta={x:i.x,y:i.y});e.deltaX=r.x+(i.x-n.x),e.deltaY=r.y+(i.y-n.y)}(i,e),e.offsetDirection=H(e.deltaX,e.deltaY);var l=W(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=l.x,e.overallVelocityY=l.y,e.overallVelocity=d(l.x)>d(l.y)?l.x:l.y,e.scale=o?(h=o.pointers,u=n,X(u[0],u[1],N)/X(h[0],h[1],N)):1,e.rotation=o?function(t,e){return q(e[1],e[0],N)+q(t[1],t[0],N)}(o.pointers,n):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length,function(t,e){var i,n,r,s,o=t.lastInterval||e,a=e.timeStamp-o.timeStamp;if(8!=e.eventType&&(a>25||void 0===o.velocity)){var c=e.deltaX-o.deltaX,l=e.deltaY-o.deltaY,h=W(a,c,l);n=h.x,r=h.y,i=d(h.x)>d(h.y)?h.x:h.y,s=H(c,l),t.lastInterval=e}else i=o.velocity,n=o.velocityX,r=o.velocityY,s=o.direction;e.velocity=i,e.velocityX=n,e.velocityY=r,e.direction=s}(i,e);var h,u;var p=t.element;P(e.srcEvent.target,p)&&(p=e.srcEvent.target);e.target=p}(t,i),t.emit("hammer.input",i),t.recognize(i),t.session.prevInput=i}function V(t){for(var e=[],i=0;i=d(e)?t<0?2:4:e<0?8:16}function X(t,e,i){i||(i=j);var n=e[i[0]]-t[i[0]],r=e[i[1]]-t[i[1]];return Math.sqrt(n*n+r*r)}function q(t,e,i){i||(i=j);var n=e[i[0]]-t[i[0]],r=e[i[1]]-t[i[1]];return 180*Math.atan2(r,n)/Math.PI}U.prototype={handler:function(){},init:function(){this.evEl&&T(this.element,this.evEl,this.domHandler),this.evTarget&&T(this.target,this.evTarget,this.domHandler),this.evWin&&T(k(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&A(this.element,this.evEl,this.domHandler),this.evTarget&&A(this.target,this.evTarget,this.domHandler),this.evWin&&A(k(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4};function Z(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,U.apply(this,arguments)}y(Z,U,{handler:function(t){var e=Y[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))}});var K={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:"touch",3:"pen",4:"mouse",5:"kinect"},J="pointerdown",$="pointermove pointerup pointercancel";function tt(){this.evEl=J,this.evWin=$,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}r.MSPointerEvent&&!r.PointerEvent&&(J="MSPointerDown",$="MSPointerMove MSPointerUp MSPointerCancel"),y(tt,U,{handler:function(t){var e=this.store,i=!1,n=t.type.toLowerCase().replace("ms",""),r=K[n],s=Q[t.pointerType]||t.pointerType,o="touch"==s,a=C(e,t.pointerId,"pointerId");1&r&&(0===t.button||o)?a<0&&(e.push(t),a=e.length-1):12&r&&(i=!0),a<0||(e[a]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:s,srcEvent:t}),i&&e.splice(a,1))}});var et={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function it(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,U.apply(this,arguments)}function nt(t,e){var i=L(t.touches),n=L(t.changedTouches);return 12&e&&(i=R(i.concat(n),"identifier",!0)),[i,n]}y(it,U,{handler:function(t){var e=et[t.type];if(1===e&&(this.started=!0),this.started){var i=nt.call(this,t,e);12&e&&i[0].length-i[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:"touch",srcEvent:t})}}});var rt={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function st(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},U.apply(this,arguments)}function ot(t,e){var i=L(t.touches),n=this.targetIds;if(3&e&&1===i.length)return n[i[0].identifier]=!0,[i,i];var r,s,o=L(t.changedTouches),a=[],c=this.target;if(s=i.filter((function(t){return P(t.target,c)})),1===e)for(r=0;r-1&&n.splice(t,1)}),2500)}}function ht(t){for(var e=t.srcEvent.clientX,i=t.srcEvent.clientY,n=0;n-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,i=this.state;function n(i){e.manager.emit(i,t)}i<8&&n(e.options.event+mt(i)),n(e.options.event),t.additionalEvent&&n(t.additionalEvent),i>=8&&n(e.options.event+mt(i))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=32},canEmit:function(){for(var t=0;te.threshold&&r&e.direction},attrTest:function(t){return bt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=vt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),y(wt,bt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return["none"]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),y(xt,gt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return["auto"]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distancee.time;if(this._input=t,!n||!i||12&t.eventType&&!r)this.reset();else if(1&t.eventType)this.reset(),this._timer=p((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return 32},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=f(),this.manager.emit(this.options.event,this._input)))}}),y(Et,bt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return["none"]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),y(Tt,bt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return yt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,i=this.options.direction;return 30&i?e=t.overallVelocity:6&i?e=t.overallVelocityX:24&i&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&i&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&d(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=vt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),y(At,gt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return["manipulation"]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distance=0)}i.d(e,"a",(function(){return n}))}).call(this,i(8))},,,,function(t,e){},,,,,,function(t,e){},function(t,e){},,,,,,,,function(t,e,i){"use strict";i.r(e);var n={};function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}i.r(n),i.d(n,"filename",(function(){return Uc})),i.d(n,"dirname",(function(){return zc})),i.d(n,"join",(function(){return Vc}));var s=i(16);const o="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";Object(s.a)();class a{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";r(this,"storage",void 0),r(this,"id",void 0),r(this,"config",{}),this.storage=function(t){try{const e=window[t],i="__storage_test__";return e.setItem(i,i),e.removeItem(i),e}catch(t){return null}}(i),this.id=t,this.config={},Object.assign(this.config,e),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){return this.config={},this.updateConfiguration(t)}updateConfiguration(t){if(Object.assign(this.config,t),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}_loadConfiguration(){let t={};if(this.storage){const e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}}function c(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>n&&(i=Math.min(i,n/t.width));const s=t.width*i,o=t.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(s/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(r,");"),"background-size:".concat(s,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}let l;function h(t){return"string"==typeof t?l[t.toUpperCase()]||l.WHITE:t}function u(t,e){if(!t)throw new Error(e||"Assertion failed")}!function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(l||(l={}));var d=i(6);function f(){let t;var e,i;if(s.a&&"performance"in d.b)t=null===d.b||void 0===d.b||null===(e=d.b.performance)||void 0===e||null===(i=e.now)||void 0===i?void 0:i.call(e);else if("hrtime"in d.a){var n;const e=null===d.a||void 0===d.a||null===(n=d.a.hrtime)||void 0===n?void 0:n.call(d.a);t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}var p=i(28);const g={debug:s.a&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},m={enabled:!0,level:0};function v(){}const _={},b={once:!0};class y{constructor(){let{id:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};r(this,"id",void 0),r(this,"VERSION",o),r(this,"_startTs",f()),r(this,"_deltaTs",f()),r(this,"_storage",void 0),r(this,"userData",{}),r(this,"LOG_THROTTLE_TIMEOUT",0),this.id=t,this._storage=new a("__probe-".concat(this.id,"__"),m),this.userData={},this.timeStamp("".concat(this.id," started")),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(i);for(const i of n)"function"==typeof t[i]&&(e.find(t=>i===t)||(t[i]=t[i].bind(t)))}(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((f()-this._startTs).toPrecision(10))}getDelta(){return Number((f()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:t}),this}setLevel(t){return this._storage.updateConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.updateConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){u(t,e)}warn(t){return this._getLogFunction(0,t,g.warn,arguments,b)}error(t){return this._getLogFunction(0,t,g.error,arguments)}deprecated(t,e){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(t,e){return this.error("`".concat(t,"` has been removed. Use `").concat(e,"` instead"))}probe(t,e){return this._getLogFunction(t,e,g.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,g.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r{const e=c(t,i,n);console.log(...e)},t.src=e,v}const r=e.nodeName||"";if("img"===r.toLowerCase())return console.log(...c(e,i,n)),v;if("canvas"===r.toLowerCase()){const t=new Image;return t.onload=()=>console.log(...c(t,i,n)),t.src=e.toDataURL(),v}return v}({image:n,message:r,scale:o}):function(t){let{image:e,message:i="",scale:n=1}=t;return p.nodeAsciifyImage({image:e,message:i,scale:n}),v}({image:n,message:r,scale:o}):v}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||v)}group(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const n=x({logLevel:t,message:e,opts:i}),{collapsed:r}=i;return n.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(t,e,Object.assign({},i,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||v)}withGroup(t,e,i){this.group(t,e)();try{i()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=w(t)}_getLogFunction(t,e,i,n,r){if(this._shouldLog(t)){r=x({logLevel:t,message:e,args:n,opts:r}),u(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=f();const o=r.tag||r.message;if(r.once){if(_[o])return v;_[o]=f()}return e=function(t,e,i){if("string"==typeof e){const a=i.time?function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const i=Math.max(e-t.length,0);return"".concat(" ".repeat(i)).concat(t)}(function(t){let e;return e=t<10?"".concat(t.toFixed(2),"ms"):t<100?"".concat(t.toFixed(1),"ms"):t<1e3?"".concat(t.toFixed(0),"ms"):"".concat((t/1e3).toFixed(2),"s"),e}(i.total)):"";e=i.time?"".concat(t,": ").concat(a," ").concat(e):"".concat(t,": ").concat(e),n=e,r=i.color,o=i.background,s.a||"string"!=typeof n||(r&&(r=h(r),n="[".concat(r,"m").concat(n,"")),o&&(r=h(o),n="[".concat(o+10,"m").concat(n,""))),e=n}var n,r,o;return e}(this.id,r.message,r),i.bind(console,e,...r.args)}return v}}function w(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return u(Number.isFinite(e)&&e>=0),e}function x(t){const{logLevel:e,message:i}=t;t.logLevel=w(e);const n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==i;);switch(typeof e){case"string":case"function":void 0!==i&&n.unshift(i),t.message=e;break;case"object":Object.assign(t,e)}"function"==typeof t.message&&(t.message=t.message());const r=typeof t.message;return u("string"===r||"object"===r),Object.assign(t,{args:n},t.opts)}function E(t){for(const e in t)for(const i in t[e])return i||"untitled";return"empty"}r(y,"VERSION",o);var T=new y({id:"deck"});var A=new class{constructor(t={}){r(this,"_pool",[]),r(this,"opts",{overAlloc:2,poolSize:100}),this.setOptions(t)}setOptions(t){Object.assign(this.opts,t)}allocate(t,e,{size:i=1,type:n,padding:r=0,copy:s=!1,initialize:o=!1,maxCount:a}){const c=n||t&&t.constructor||Float32Array,l=e*i+r;if(ArrayBuffer.isView(t)){if(l<=t.length)return t;if(l*t.BYTES_PER_ELEMENT<=t.buffer.byteLength)return new c(t.buffer,0,l)}let h=1/0;a&&(h=a*i+r);const u=this._allocate(c,l,o,h);return t&&s?u.set(t):o||u.fill(0,0,4),this._release(t),u}release(t){this._release(t)}_allocate(t,e,i,n){let r=Math.max(Math.ceil(e*this.opts.overAlloc),1);r>n&&(r=n);const s=this._pool,o=t.BYTES_PER_ELEMENT*r,a=s.findIndex(t=>t.byteLength>=o);if(a>=0){const e=new t(s.splice(a,1)[0],0,r);return i&&e.fill(0),e}return new t(r)}_release(t){if(!ArrayBuffer.isView(t))return;const e=this._pool,{buffer:i}=t,{byteLength:n}=i,r=e.findIndex(t=>t.byteLength>=n);r<0?e.push(i):(r>0||e.lengththis.opts.poolSize&&e.shift()}};function P(t,e){if(!t)throw new Error("math.gl assertion ".concat(e))}Math.PI,Math.PI;const S={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function M(t,{precision:e=S.precision}={}){return t=function(t){return Math.round(t/S.EPSILON)*S.EPSILON}(t),"".concat(parseFloat(t.toPrecision(e)))}function C(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function L(t,e,i){return I(t,t=>Math.max(e,Math.min(i,t)))}function R(t,e,i){return C(t)?t.map((t,n)=>R(t,e[n],i)):i*e+(1-i)*t}function O(t,e,i){const n=S.EPSILON;i&&(S.EPSILON=i);try{if(t===e)return!0;if(C(t)&&C(e)){if(t.length!==e.length)return!1;for(let i=0;i0?", ":"")+M(this[i],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e=0&&t=0&&t2*Math.PI)throw Error("expected radians")}function wt(t,e){const i=ht([],e,t);return function(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i}(i,i,1/i[3]),i}function xt(t,e){const i=t%e;return i<0?e+i:i}function Et(t,e,i){return ti?i:t}const Tt=Math.log2||function(t){return Math.log(t)*Math.LOG2E};function At(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}const Pt=Math.PI,St=Pt/4,Mt=Pt/180,Ct=180/Pt,Lt=1.5;function Rt(t){return Tt(t)}function Ot(t){const[e,i]=t;At(Number.isFinite(e)),At(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const n=i*Mt;return[512*(e*Mt+Pt)/(2*Pt),512*(Pt+Math.log(Math.tan(St+.5*n)))/(2*Pt)]}function It(t){const[e,i]=t,n=e/512*(2*Pt)-Pt,r=2*(Math.atan(Math.exp(i/512*(2*Pt)-Pt))-St);return[n*Ct,r*Ct]}function kt(t){const{latitude:e,longitude:i,highPrecision:n=!1}=t;At(Number.isFinite(e)&&Number.isFinite(i));const r=Math.cos(e*Mt),s=512/360/r,o=512/4003e4/r,a={unitsPerMeter:[o,o,o],metersPerUnit:[1/o,1/o,1/o],unitsPerDegree:[512/360,s,o],degreesPerUnit:[.703125,1/s,1/o]};if(n){const t=Mt*Math.tan(e*Mt)/r,i=512/360*t/2,n=512/4003e4*t,c=n/s*o;a.unitsPerDegree2=[0,i,n],a.unitsPerMeter2=[c,0,c]}return a}function Ft(t,e){const[i,n,r]=t,[s,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=kt({longitude:i,latitude:n,highPrecision:!0}),h=Ot(t);h[0]+=s*(c[0]+l[0]*o),h[1]+=o*(c[1]+l[1]*o);const u=It(h),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[u[0],u[1],d]:u}function Dt(t){const{height:e,pitch:i,bearing:n,altitude:r,scale:s,center:o}=t,a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];et(a,a,[0,0,-r]),nt(a,a,-i*Mt),rt(a,a,n*Mt);const c=s/e;return it(a,a,[c,c,c]),o&&et(a,a,function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}([],o)),a}function Bt(t){const{width:e,height:i,altitude:n,pitch:r=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t;let{fovy:h=jt(Lt)}=t;void 0!==n&&(h=jt(n));const u=h*Mt,d=r*Mt,f=Nt(h);let p=f;o&&(p+=o[2]*a/Math.cos(d)/i);const g=u*(.5+(s?s[1]:0)/i),m=Math.sin(g)*p/Math.sin(Et(Math.PI/2-d-g,.01,Math.PI-.01)),v=Math.sin(d)*m+p,_=10*p;return{fov:u,aspect:e/i,focalDistance:f,near:c,far:Math.min(v*l,_)}}function jt(t){return 2*Math.atan(.5/t)*Ct}function Nt(t){return.5/Math.tan(.5*t*Mt)}function Ut(t,e){const[i,n,r=0]=t;return At(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(r)),wt(e,[i,n,r,1])}function zt(t,e,i=0){const[n,r,s]=t;if(At(Number.isFinite(n)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(s)){return wt(e,[n,r,s,1])}const o=wt(e,[n,r,0,1]),a=wt(e,[n,r,1,1]),c=o[2],l=a[2];return lt([],o,a,c===l?0:((i||0)-c)/(l-c))}function Vt(t){const{width:e,height:i,bounds:n,minExtent:r=0,maxZoom:s=24,offset:o=[0,0]}=t,[[a,c],[l,h]]=n,u=function(t=0){if("number"==typeof t)return{top:t,bottom:t,left:t,right:t};return At(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t}(t.padding),d=Ot([a,Et(h,-85.051129,85.051129)]),f=Ot([l,Et(c,-85.051129,85.051129)]),p=[Math.max(Math.abs(f[0]-d[0]),r),Math.max(Math.abs(f[1]-d[1]),r)],g=[e-u.left-u.right-2*Math.abs(o[0]),i-u.top-u.bottom-2*Math.abs(o[1])];At(g[0]>0&&g[1]>0);const m=g[0]/p[0],v=g[1]/p[1],_=(u.right-u.left)/2/m,b=(u.top-u.bottom)/2/v,y=It([(f[0]+d[0])/2+_,(f[1]+d[1])/2+b]),w=Math.min(s,Tt(Math.abs(Math.min(m,v))));return At(Number.isFinite(w)),{longitude:y[0],latitude:y[1],zoom:w}}const Gt=Math.PI/180;function Wt(t,e=0){const{width:i,height:n,unproject:r}=t,s={targetZ:e},o=r([0,n],s),a=r([i,n],s);let c,l;return(t.fovy?.5*t.fovy*Gt:Math.atan(.5/t.altitude))>(90-t.pitch)*Gt-.01?(c=Ht(t,0,e),l=Ht(t,i,e)):(c=r([0,0],s),l=r([i,0],s)),[o,a,l,c]}function Ht(t,e,i){const{pixelUnprojectionMatrix:n}=t,r=wt(n,[e,0,1,1]),s=wt(n,[e,t.height,1,1]),o=It(lt([],r,s,(i*t.distanceScales.unitsPerMeter[2]-r[2])/(s[2]-r[2])));return o.push(i),o}const Xt={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Xt,"IDENTITY",{get:()=>(T.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const qt={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Yt={common:0,meters:1,pixels:2},Zt={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},Kt="draw",Qt="mask",Jt=Math.PI/180,$t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],te=[0,0,0],ee={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};class ie{constructor(t={}){r(this,"id",void 0),r(this,"x",void 0),r(this,"y",void 0),r(this,"width",void 0),r(this,"height",void 0),r(this,"isGeospatial",void 0),r(this,"zoom",void 0),r(this,"focalDistance",void 0),r(this,"position",void 0),r(this,"modelMatrix",void 0),r(this,"distanceScales",void 0),r(this,"scale",void 0),r(this,"center",void 0),r(this,"cameraPosition",void 0),r(this,"projectionMatrix",void 0),r(this,"viewMatrix",void 0),r(this,"viewMatrixUncentered",void 0),r(this,"viewMatrixInverse",void 0),r(this,"viewProjectionMatrix",void 0),r(this,"pixelProjectionMatrix",void 0),r(this,"pixelUnprojectionMatrix",void 0),r(this,"resolution",void 0),r(this,"_frustumPlanes",{}),this.id=t.id||this.constructor.displayName||"viewport",this.x=t.x||0,this.y=t.y||0,this.width=t.width||1,this.height=t.height||1,this.zoom=t.zoom||0,this.distanceScales=t.distanceScales||ee,this.focalDistance=t.focalDistance||1,this.position=t.position||te,this.modelMatrix=t.modelMatrix||null;const{longitude:e,latitude:i}=t;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(e),this._initProps(t),this._initMatrices(t),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?qt.WEB_MERCATOR:qt.WEB_MERCATOR_AUTO_OFFSET:qt.IDENTITY}equals(t){return t instanceof ie&&(this===t||t.width===this.width&&t.height===this.height&&t.scale===this.scale&&O(t.projectionMatrix,this.projectionMatrix)&&O(t.viewMatrix,this.viewMatrix))}project(t,{topLeft:e=!0}={}){const i=Ut(this.projectPosition(t),this.pixelProjectionMatrix),[n,r]=i,s=e?r:this.height-r;return 2===t.length?[n,s]:[n,s,i[2]]}unproject(t,{topLeft:e=!0,targetZ:i}={}){const[n,r,s]=t,o=e?r:this.height-r,a=i&&i*this.distanceScales.unitsPerMeter[2],c=zt([n,o,s],this.pixelUnprojectionMatrix,a),[l,h,u]=this.unprojectPosition(c);return Number.isFinite(s)?[l,h,u]:Number.isFinite(i)?[l,h,i]:[l,h]}projectPosition(t){const[e,i]=this.projectFlat(t);return[e,i,(t[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(t){const[e,i]=this.unprojectFlat(t);return[e,i,(t[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(t){if(this.isGeospatial){const e=Ot(t);return e[1]=L(e[1],-318,830),e}return t}unprojectFlat(t){return this.isGeospatial?It(t):t}getBounds(t={}){const e={targetZ:t.z||0},i=this.unproject([0,0],e),n=this.unproject([this.width,0],e),r=this.unproject([0,this.height],e),s=this.unproject([this.width,this.height],e);return[Math.min(i[0],n[0],r[0],s[0]),Math.min(i[1],n[1],r[1],s[1]),Math.max(i[0],n[0],r[0],s[0]),Math.max(i[1],n[1],r[1],s[1])]}getDistanceScales(t){return t?kt({longitude:t[0],latitude:t[1],highPrecision:!0}):this.distanceScales}containsPixel({x:t,y:e,width:i=1,height:n=1}){return t=3){const t="%"===e[2],i=parseFloat(e[1]);return{position:t?i/100:i,relative:t}}default:throw new Error("Could not parse position string ".concat(t))}}function se(t,e){return t.relative?Math.round(t.position*e):t.position}function oe(t,e){if(t===e)return!0;if(!t||!e)return!1;for(const i in t){const n=t[i],r=e[i];if(!(n===r||Array.isArray(n)&&Array.isArray(r)&&oe(n,r)))return!1}return!0}function ae(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}class ce{constructor(t){r(this,"id",void 0),r(this,"viewportInstance",void 0),r(this,"_x",void 0),r(this,"_y",void 0),r(this,"_width",void 0),r(this,"_height",void 0),r(this,"_padding",void 0),r(this,"props",void 0);const{id:e,x:i=0,y:n=0,width:s="100%",height:o="100%",padding:a=null,viewportInstance:c}=t||{};ae(!c||c instanceof ie),this.viewportInstance=c,this.id=e||this.constructor.displayName||"view",this.props={...t,id:this.id},this._x=re(i),this._y=re(n),this._width=re(s),this._height=re(o),this._padding=a&&{left:re(a.left||0),right:re(a.right||0),top:re(a.top||0),bottom:re(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t||(this.viewportInstance?!!t.viewportInstance&&this.viewportInstance.equals(t.viewportInstance):this.ViewportType===t.ViewportType&&oe(this.props,t.props))}makeViewport({width:t,height:e,viewState:i}){if(this.viewportInstance)return this.viewportInstance;i=this.filterViewState(i);const n=this.getDimensions({width:t,height:e});return new this.ViewportType({...i,...this.props,...n})}getViewStateId(){const{viewState:t}=this.props;return"string"==typeof t?t:(null==t?void 0:t.id)||this.id}filterViewState(t){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const e={...t};for(const t in this.props.viewState)"id"!==t&&(e[t]=this.props.viewState[t]);return e}return t}getDimensions({width:t,height:e}){const i={x:se(this._x,t),y:se(this._y,e),width:se(this._width,t),height:se(this._height,e)};return this._padding&&(i.padding={left:se(this._padding.left,t),top:se(this._padding.top,e),right:se(this._padding.right,t),bottom:se(this._padding.bottom,e)}),i}get controller(){const t=this.props.controller;return t?!0===t?{type:this.ControllerType}:"function"==typeof t?{type:t}:{type:this.ControllerType,...t}:null}}const le=Math.PI/180;function he(t){return 512/4003e4/Math.cos(t*le)}class ue extends ie{constructor(t={}){const{latitude:e=0,longitude:i=0,zoom:n=0,pitch:s=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,orthographic:l=!1,projectionMatrix:h,repeat:u=!1,worldOffset:d=0,legacyMeterSizes:f=!1}=t;let{width:p,height:g,altitude:m=1.5}=t;const v=Math.pow(2,n);let _;p=p||1,g=g||1;let b=null;h?(m=h[5]/2,_=jt(m)):(t.fovy?(_=t.fovy,m=Nt(_)):_=jt(m),b=Bt({width:p,height:g,pitch:s,fovy:_,nearZMultiplier:a,farZMultiplier:c}));let y=Dt({height:g,pitch:s,bearing:o,scale:v,altitude:m});if(d){y=(new vt).translate([512*d,0,0]).multiplyLeft(y)}super({...t,width:p,height:g,viewMatrix:y,longitude:i,latitude:e,zoom:n,...b,fovy:_,focalDistance:m}),r(this,"longitude",void 0),r(this,"latitude",void 0),r(this,"pitch",void 0),r(this,"bearing",void 0),r(this,"altitude",void 0),r(this,"fovy",void 0),r(this,"orthographic",void 0),r(this,"_subViewports",void 0),r(this,"_pseudoMeters",void 0),this.latitude=e,this.longitude=i,this.zoom=n,this.pitch=s,this.bearing=o,this.altitude=m,this.fovy=_,this.orthographic=l,this._subViewports=u?[]:null,this._pseudoMeters=f,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const t=this.getBounds(),e=Math.floor((t[0]+180)/360),i=Math.ceil((t[2]-180)/360);for(let t=e;t<=i;t++){const e=t?new ue({...this,worldOffset:t}):this;this._subViewports.push(e)}}return this._subViewports}projectPosition(t){if(this._pseudoMeters)return super.projectPosition(t);const[e,i]=this.projectFlat(t);return[e,i,(t[2]||0)*he(t[1])]}unprojectPosition(t){if(this._pseudoMeters)return super.unprojectPosition(t);const[e,i]=this.unprojectFlat(t);return[e,i,(t[2]||0)/he(i)]}addMetersToLngLat(t,e){return Ft(t,e)}panByPosition(t,e){const i=zt(e,this.pixelUnprojectionMatrix),n=at([],this.projectFlat(t),ct([],i)),r=at([],this.center,n),[s,o]=this.unprojectFlat(r);return{longitude:s,latitude:o}}getBounds(t={}){const e=Wt(this,t.z||0);return[Math.min(e[0][0],e[1][0],e[2][0],e[3][0]),Math.min(e[0][1],e[1][1],e[2][1],e[3][1]),Math.max(e[0][0],e[1][0],e[2][0],e[3][0]),Math.max(e[0][1],e[1][1],e[2][1],e[3][1])]}fitBounds(t,e={}){const{width:i,height:n}=this,{longitude:r,latitude:s,zoom:o}=Vt({width:i,height:n,bounds:t,...e});return new ue({width:i,height:n,longitude:r,latitude:s,zoom:o})}}r(ue,"displayName","WebMercatorViewport");class de{constructor(t){r(this,"_inProgress",void 0),r(this,"_handle",void 0),r(this,"_timeline",void 0),r(this,"time",void 0),r(this,"settings",void 0),this._inProgress=!1,this._handle=null,this._timeline=t,this.time=0,this.settings={duration:0}}get inProgress(){return this._inProgress}start(t){var e,i;this.cancel(),this.settings=t,this._inProgress=!0,null===(e=(i=this.settings).onStart)||void 0===e||e.call(i,this)}end(){var t,e;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,null===(t=(e=this.settings).onEnd)||void 0===t||t.call(e,this))}cancel(){var t,e;this._inProgress&&(null===(t=(e=this.settings).onInterrupt)||void 0===t||t.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var t,e;if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:t,settings:e}=this;this._handle=t.addChannel({delay:t.getTime(),duration:e.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),null===(t=(e=this.settings).onUpdate)||void 0===t||t.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const fe=()=>{},pe=2,ge=3,me=t=>t,ve=1;class _e{constructor(t){r(this,"getControllerState",void 0),r(this,"props",void 0),r(this,"propsInTransition",void 0),r(this,"transition",void 0),r(this,"onViewStateChange",void 0),r(this,"onStateChange",void 0),r(this,"_onTransitionUpdate",t=>{const{time:e,settings:{interpolator:i,startProps:n,endProps:r,duration:s,easing:o}}=t,a=o(e/s),c=i.interpolateProps(n,r,a);this.propsInTransition=this.getControllerState({...this.props,...c}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})}),this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new de(t.timeline),this.onViewStateChange=t.onViewStateChange||fe,this.onStateChange=t.onStateChange||fe}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let e=!1;const i=this.props;if(this.props=t,!i||this._shouldIgnoreViewportChange(i,t))return!1;if(this._isTransitionEnabled(t)){let n=i;if(this.transition.inProgress){const{interruption:t,endProps:e}=this.transition.settings;n={...i,...t===pe?e:this.propsInTransition||i}}this._triggerTransition(n,t),e=!0}else this.transition.cancel();return e}updateTransition(){this.transition.update()}_isTransitionEnabled(t){const{transitionDuration:e,transitionInterpolator:i}=t;return(e>0||"auto"===e)&&Boolean(i)}_isUpdateDueToCurrentTransition(t){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(t,this.propsInTransition)}_shouldIgnoreViewportChange(t,e){return this.transition.inProgress?this.transition.settings.interruption===ge||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e)}_triggerTransition(t,e){const i=this.getControllerState(t),n=this.getControllerState(e).shortestPathFrom(i),r=e.transitionInterpolator,s=r.getDuration?r.getDuration(t,e):e.transitionDuration;if(0===s)return;const o=r.initializeProps(t,n);this.propsInTransition={};const a={duration:s,easing:e.transitionEasing||me,interpolator:r,interruption:e.transitionInterruption||ve,startProps:o.start,endProps:o.end,onStart:e.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(e.onTransitionInterrupt),onEnd:this._onTransitionEnd(e.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(t){return e=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),null==t||t(e)}}}const be=["longitude","latitude","zoom","bearing","pitch"],ye=["longitude","latitude","zoom"];class we extends class{constructor(t){r(this,"_propsToCompare",void 0),r(this,"_propsToExtract",void 0),r(this,"_requiredProps",void 0);const{compare:e,extract:i,required:n}=t;this._propsToCompare=e,this._propsToExtract=i||e,this._requiredProps=n}arePropsEqual(t,e){for(const i of this._propsToCompare)if(!(i in t)||!(i in e)||!O(t[i],e[i]))return!1;return!0}initializeProps(t,e){const i={},n={};for(const r of this._propsToExtract)(r in t||r in e)&&(i[r]=t[r],n[r]=e[r]);return this._checkRequiredProps(i),this._checkRequiredProps(n),{start:i,end:n}}getDuration(t,e){return e.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach(e=>{const i=t[e];ae(Number.isFinite(i)||Array.isArray(i),"".concat(e," is required for transition"))})}}{constructor(t={}){const e=Array.isArray(t)?t:t.transitionProps,i=Array.isArray(t)?{}:t;i.transitionProps=Array.isArray(e)?{compare:e,required:e}:e||{compare:be,required:ye},super(i.transitionProps),r(this,"opts",void 0),this.opts=i}initializeProps(t,e){const i=super.initializeProps(t,e),{makeViewport:n,around:r}=this.opts;if(n&&r){const s=n(t),o=n(e),a=s.unproject(r);i.start.around=r,Object.assign(i.end,{around:o.project(a),aroundPosition:a,width:e.width,height:e.height})}return i}interpolateProps(t,e,i){const n={};for(const r of this._propsToExtract)n[r]=R(t[r]||0,e[r]||0,i);if(e.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...e,...n});Object.assign(n,r.panByPosition(e.aroundPosition,R(t.around,e.around,i)))}return n}}const xe={transitionDuration:0},Ee=t=>1-(1-t)*(1-t),Te=["wheel"],Ae=["panstart","panmove","panend"],Pe=["pinchstart","pinchmove","pinchend"],Se=["tripanstart","tripanmove","tripanend"],Me=["doubletap"],Ce=["keydown"],Le={};class Re{constructor(t){r(this,"props",void 0),r(this,"state",{}),r(this,"transitionManager",void 0),r(this,"eventManager",void 0),r(this,"onViewStateChange",void 0),r(this,"onStateChange",void 0),r(this,"makeViewport",void 0),r(this,"_controllerState",void 0),r(this,"_events",{}),r(this,"_interactionState",{isDragging:!1}),r(this,"_customEvents",[]),r(this,"_eventStartBlocked",null),r(this,"_panMove",!1),r(this,"invertPan",!1),r(this,"dragMode","rotate"),r(this,"inertia",0),r(this,"scrollZoom",!0),r(this,"dragPan",!0),r(this,"dragRotate",!0),r(this,"doubleClickZoom",!0),r(this,"touchZoom",!0),r(this,"touchRotate",!1),r(this,"keyboard",!0),this.transitionManager=new _e({...t,getControllerState:t=>new this.ControllerState(t),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=t.eventManager,this.onViewStateChange=t.onViewStateChange||(()=>{}),this.onStateChange=t.onStateChange||(()=>{}),this.makeViewport=t.makeViewport}set events(t){this.toggleEvents(this._customEvents,!1),this.toggleEvents(t,!0),this._customEvents=t,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events){var t;if(this._events[e])null===(t=this.eventManager)||void 0===t||t.off(e,this.handleEvent)}this.transitionManager.finalize()}handleEvent(t){this._controllerState=void 0;const e=this._eventStartBlocked;switch(t.type){case"panstart":return!e&&this._onPanStart(t);case"panmove":return this._onPan(t);case"panend":return this._onPanEnd(t);case"pinchstart":return!e&&this._onPinchStart(t);case"pinchmove":return this._onPinch(t);case"pinchend":return this._onPinchEnd(t);case"tripanstart":return!e&&this._onTriplePanStart(t);case"tripanmove":return this._onTriplePan(t);case"tripanend":return this._onTriplePanEnd(t);case"doubletap":return this._onDoubleTap(t);case"wheel":return this._onWheel(t);case"keydown":return this._onKeyDown(t);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(t){const{x:e,y:i}=this.props,{offsetCenter:n}=t;return[n.x-e,n.y-i]}isPointInBounds(t,e){const{width:i,height:n}=this.props;if(e&&e.handled)return!1;const r=t[0]>=0&&t[0]<=i&&t[1]>=0&&t[1]<=n;return r&&e&&e.stopPropagation(),r}isFunctionKeyPressed(t){const{srcEvent:e}=t;return Boolean(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(t){const e=setTimeout(()=>{this._eventStartBlocked===e&&(this._eventStartBlocked=null)},t);this._eventStartBlocked=e}setProps(t){t.dragMode&&(this.dragMode=t.dragMode),this.props=t,"transitionInterpolator"in t||(t.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(t);const{inertia:e}=t;this.inertia=Number.isFinite(e)?e:!0===e?300:0;const{scrollZoom:i=!0,dragPan:n=!0,dragRotate:r=!0,doubleClickZoom:s=!0,touchZoom:o=!0,touchRotate:a=!1,keyboard:c=!0}=t,l=Boolean(this.onViewStateChange);this.toggleEvents(Te,l&&i),this.toggleEvents(Ae,l&&(n||r)),this.toggleEvents(Pe,l&&(o||a)),this.toggleEvents(Se,l&&a),this.toggleEvents(Me,l&&s),this.toggleEvents(Ce,l&&c),this.scrollZoom=i,this.dragPan=n,this.dragRotate=r,this.doubleClickZoom=s,this.touchZoom=o,this.touchRotate=a,this.keyboard=c}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,e){this.eventManager&&t.forEach(t=>{this._events[t]!==e&&(this._events[t]=e,e?this.eventManager.on(t,this.handleEvent):this.eventManager.off(t,this.handleEvent))})}updateViewport(t,e=null,i={}){const n={...t.getViewportProps(),...e},r=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(i),r){const t=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:t})}}_onTransition(t){this.onViewStateChange({...t,interactionState:this._interactionState})}_setInteractionState(t){Object.assign(this._interactionState,t),this.onStateChange(this._interactionState)}_onPanStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;let i=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const n=this.controllerState[i?"panStart":"rotateStart"]({pos:e});return this._panMove=i,this.updateViewport(n,xe,{isDragging:!0}),!0}_onPan(t){return!!this.isDragging()&&(this._panMove?this._onPanMove(t):this._onPanRotate(t))}_onPanEnd(t){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(t):this._onPanRotateEnd(t))}_onPanMove(t){if(!this.dragPan)return!1;const e=this.getCenter(t),i=this.controllerState.pan({pos:e});return this.updateViewport(i,xe,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){const{inertia:e}=this;if(this.dragPan&&e&&t.velocity){const i=this.getCenter(t),n=[i[0]+t.velocityX*e/2,i[1]+t.velocityY*e/2],r=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:Ee},{isDragging:!1,isPanning:!0})}else{const t=this.controllerState.panEnd();this.updateViewport(t,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;const e=this.getCenter(t),i=this.controllerState.rotate({pos:e});return this.updateViewport(i,xe,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){const{inertia:e}=this;if(this.dragRotate&&e&&t.velocity){const i=this.getCenter(t),n=[i[0]+t.velocityX*e/2,i[1]+t.velocityY*e/2],r=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:Ee},{isDragging:!1,isRotating:!0})}else{const t=this.controllerState.rotateEnd();this.updateViewport(t,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(t){if(!this.scrollZoom)return!1;t.srcEvent.preventDefault();const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const{speed:i=.01,smooth:n=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=t;let s=2/(1+Math.exp(-Math.abs(r*i)));r<0&&0!==s&&(s=1/s);const o=this.controllerState.zoom({pos:e,scale:s});return this.updateViewport(o,{...this._getTransitionProps({around:e}),transitionDuration:n?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const i=this.controllerState.rotateStart({pos:e});return this.updateViewport(i,xe,{isDragging:!0}),!0}_onTriplePan(t){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const e=this.getCenter(t);e[0]-=t.deltaX;const i=this.controllerState.rotate({pos:e});return this.updateViewport(i,xe,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(t){if(!this.isDragging())return!1;const{inertia:e}=this;if(this.touchRotate&&e&&t.velocityY){const i=this.getCenter(t),n=[i[0],i[1]+=t.velocityY*e/2],r=this.controllerState.rotate({pos:n});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:e,transitionEasing:Ee},{isDragging:!1,isRotating:!0}),this.blockEvents(e)}else{const t=this.controllerState.rotateEnd();this.updateViewport(t,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(t){const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const i=this.controllerState.zoomStart({pos:e}).rotateStart({pos:e});return Le._startPinchRotation=t.rotation,Le._lastPinchEvent=t,this.updateViewport(i,xe,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let e=this.controllerState;if(this.touchZoom){const{scale:i}=t,n=this.getCenter(t);e=e.zoom({pos:n,scale:i})}if(this.touchRotate){const{rotation:i}=t;e=e.rotate({deltaAngleX:Le._startPinchRotation-i})}return this.updateViewport(e,xe,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Le._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;const{inertia:e}=this,{_lastPinchEvent:i}=Le;if(this.touchZoom&&e&&i&&t.scale!==i.scale){const n=this.getCenter(t);let r=this.controllerState.rotateEnd();const s=Math.log2(t.scale),o=(s-Math.log2(i.scale))/(t.deltaTime-i.deltaTime),a=Math.pow(2,s+o*e/2);r=r.zoom({pos:n,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:n}),transitionDuration:e,transitionEasing:Ee},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(e)}else{const t=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(t,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Le._startPinchRotation=null,Le._lastPinchEvent=null,!0}_onDoubleTap(t){if(!this.doubleClickZoom)return!1;const e=this.getCenter(t);if(!this.isPointInBounds(e,t))return!1;const i=this.isFunctionKeyPressed(t),n=this.controllerState.zoom({pos:e,scale:i?.5:2});return this.updateViewport(n,this._getTransitionProps({around:e}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;const e=this.isFunctionKeyPressed(t),{zoomSpeed:i,moveSpeed:n,rotateSpeedX:r,rotateSpeedY:s}=!0===this.keyboard?{}:this.keyboard,{controllerState:o}=this;let a;const c={};switch(t.srcEvent.code){case"Minus":a=e?o.zoomOut(i).zoomOut(i):o.zoomOut(i),c.isZooming=!0;break;case"Equal":a=e?o.zoomIn(i).zoomIn(i):o.zoomIn(i),c.isZooming=!0;break;case"ArrowLeft":e?(a=o.rotateLeft(r),c.isRotating=!0):(a=o.moveLeft(n),c.isPanning=!0);break;case"ArrowRight":e?(a=o.rotateRight(r),c.isRotating=!0):(a=o.moveRight(n),c.isPanning=!0);break;case"ArrowUp":e?(a=o.rotateUp(s),c.isRotating=!0):(a=o.moveUp(n),c.isPanning=!0);break;case"ArrowDown":e?(a=o.rotateDown(s),c.isRotating=!0):(a=o.moveDown(n),c.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),c),!0}_getTransitionProps(t){const{transition:e}=this;return e&&e.transitionInterpolator?t?{...e,transitionInterpolator:new we({...t,...e.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:e:xe}}class Oe{constructor(t,e){r(this,"_viewportProps",void 0),r(this,"_state",void 0),this._viewportProps=this.applyConstraints(t),this._state=e}getViewportProps(){return this._viewportProps}getState(){return this._state}}class Ie extends Oe{constructor(t){const{width:e,height:i,latitude:n,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:h=[0,0,0],maxZoom:u=20,minZoom:d=0,maxPitch:f=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:v,startBearing:_,startPitch:b,startZoom:y,normalize:w=!0}=t;ae(Number.isFinite(s)),ae(Number.isFinite(n)),ae(Number.isFinite(o)),super({width:e,height:i,latitude:n,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:u,minZoom:d,maxPitch:f,minPitch:p,normalize:w,position:h},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:v,startBearing:_,startPitch:b,startZoom:y}),r(this,"makeViewport",void 0),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanLngLat:this._unproject(t)})}pan({pos:t,startPos:e}){const i=this.getState().startPanLngLat||this._unproject(e);if(!i)return this;const n=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:e=0,deltaAngleY:i=0}){const{startRotatePos:n,startBearing:r,startPitch:s}=this.getState();if(!n||void 0===r||void 0===s)return this;let o;return o=t?this._getNewRotation(t,n,s,r):{bearing:r+e,pitch:s+i},this._getUpdatedState(o)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:t}){return this._getUpdatedState({startZoomLngLat:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:e,scale:i}){let{startZoom:n,startZoomLngLat:r}=this.getState();if(r||(n=this.getViewportProps().zoom,r=this._unproject(e)||this._unproject(t)),!r)return this;const{maxZoom:s,minZoom:o}=this.getViewportProps();let a=n+Math.log2(i);a=L(a,o,s);const c=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...c.panByPosition(r,t)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(t=2){return this._zoomFromCenter(t)}zoomOut(t=2){return this._zoomFromCenter(1/t)}moveLeft(t=100){return this._panFromCenter([t,0])}moveRight(t=100){return this._panFromCenter([-t,0])}moveUp(t=100){return this._panFromCenter([0,t])}moveDown(t=100){return this._panFromCenter([0,-t])}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}shortestPathFrom(t){const e=t.getViewportProps(),i={...this.getViewportProps()},{bearing:n,longitude:r}=i;return Math.abs(n-e.bearing)>180&&(i.bearing=n<0?n+360:n-360),Math.abs(r-e.longitude)>180&&(i.longitude=r<0?r+360:r-360),i}applyConstraints(t){const{maxZoom:e,minZoom:i,zoom:n}=t;t.zoom=L(n,i,e);const{maxPitch:r,minPitch:s,pitch:o}=t;t.pitch=L(o,s,r);const{normalize:a=!0}=t;return a&&Object.assign(t,function(t){const{width:e,height:i,pitch:n=0}=t;let{longitude:r,latitude:s,zoom:o,bearing:a=0}=t;(r<-180||r>180)&&(r=xt(r+180,360)-180),(a<-180||a>180)&&(a=xt(a+180,360)-180);const c=Tt(i/512);if(o<=c)o=c,s=0;else{const t=i/2/Math.pow(2,o),e=It([0,t])[1];if(se&&(s=e)}}return{width:e,height:i,longitude:r,latitude:s,zoom:o,pitch:n,bearing:a}}(t)),t}_zoomFromCenter(t){const{width:e,height:i}=this.getViewportProps();return this.zoom({pos:[e/2,i/2],scale:t})}_panFromCenter(t){const{width:e,height:i}=this.getViewportProps();return this.pan({startPos:[e/2,i/2],pos:[e/2+t[0],i/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}_unproject(t){const e=this.makeViewport(this.getViewportProps());return t&&e.unproject(t)}_getNewRotation(t,e,i,n){const r=t[0]-e[0],s=t[1]-e[1],o=t[1],a=e[1],{width:c,height:l}=this.getViewportProps(),h=r/c;let u=0;s>0?Math.abs(l-a)>5&&(u=s/(a-l)*1.2):s<0&&a>5&&(u=1-o/a),u=L(u,-1,1);const{minPitch:d,maxPitch:f}=this.getViewportProps();let p=i;return u>0?p=i+u*(f-i):u<0&&(p=i-u*(d-i)),{pitch:p,bearing:n+180*h}}}class ke extends Re{constructor(...t){super(...t),r(this,"ControllerState",Ie),r(this,"transition",{transitionDuration:300,transitionInterpolator:new we({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})}),r(this,"dragMode","pan")}setProps(t){t.position=t.position||[0,0,0];const e=this.props;super.setProps(t);(!e||e.height!==t.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...t,...this.state}))}}class Fe extends ce{get ViewportType(){return ue}get ControllerType(){return ke}}r(Fe,"displayName","MapView");class De extends ue{constructor(t){const[e,i]=t.getSize();super(Object.assign({id:"2gis",x:0,y:0,width:e,height:i},Be(t),{nearZMultiplier:1/(i||1)}))}get projectionMode(){return 4}}function Be(t){const[e,i]=t.getCenter();return{longitude:(e+540)%360-180,latitude:i,zoom:je(t),bearing:Ne(t),pitch:t.getPitch(),padding:t.getPadding(),repeat:!1,fovy:Ue(t,60,!0)}}function je(t){return t.getZoom()-1}function Ne(t){return-t.getRotation()}function Ue(t,e,i){if(!i)return e;const n={fov:e,near:1e3},{fov:r}=n,s=function(t){const{size:e,pitch:i,padding:n}=t,r=Math.max(0,n.top-n.bottom)*Math.tan(i),s=function(t){return Math.max(t,1e3)}(e[1])+r;return(n.bottom-n.top)/2+(s-e[1])/2}(t._impl.state);return s>100?100/s*r:e}var ze=class{constructor(t,e={}){this._vao=null,this._attributes=e,this._shaderProgram=t,this._ext=null}bind(t){const e=t.extensions.OES_vertex_array_object;return e?this._bind(t.gl,e):this._shaderProgram.bind(t.gl,null,this._attributes),this}unbind(){return this._ext&&this._ext.bindVertexArrayOES(null),this}remove(){return this._vao&&this._ext.deleteVertexArrayOES(this._vao),this}_bind(t,e){this._vao?e.bindVertexArrayOES(this._vao):this._prepare(t,e)}_prepare(t,e){this._ext=e,this._vao=e.createVertexArrayOES(),e.bindVertexArrayOES(this._vao);const i=this._shaderProgram.attributes,n=this._attributes;for(const e in n){const r=i[e];!0!==r.index&&t.enableVertexAttribArray(r.location),n[e].bind(t,r.location)}}};class Ve{constructor(t,e){this._initData=t,this.byteLength=void 0!==t.byteLength?t.byteLength:t,this.type=Ve.ArrayBuffer,this.drawType=Ve.StaticDraw,this.options=Object.assign({},Ve.defaultOptions,e),this._glBuffer=null,this._glContext=null}bind(t,e,i){return this._glBuffer||this.prepare(t),this.type===Ve.ArrayBuffer?(t.bindBuffer(t.ARRAY_BUFFER,this._glBuffer),i=i||this.options,t.vertexAttribPointer(e,i.itemSize,this._toGlParam(t,i.dataType),i.normalized,i.stride,i.offset)):this.type===Ve.ElementArrayBuffer&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this._glBuffer),this}remove(){return this._unprepare(),this}subData(t,e,i){return t.bindBuffer(this._toGlParam(t,this.type),this._glBuffer),t.bufferSubData(this._toGlParam(t,this.type),e,i),this}prepare(t){return this._glContext=t,this._glBuffer=t.createBuffer(),t.bindBuffer(this._toGlParam(t,this.type),this._glBuffer),t.bufferData(this._toGlParam(t,this.type),this._initData,this._toGlParam(t,this.drawType)),this._initData=null,this}_unprepare(){this._glBuffer&&(this._glContext.deleteBuffer(this._glBuffer),this._glBuffer=null,this._glContext=null)}_toGlParam(t,e){return e===Ve.ArrayBuffer?t.ARRAY_BUFFER:e===Ve.ElementArrayBuffer?t.ELEMENT_ARRAY_BUFFER:e===Ve.StaticDraw?t.STATIC_DRAW:e===Ve.DynamicDraw?t.DYNAMIC_DRAW:e===Ve.Byte?t.BYTE:e===Ve.Short?t.SHORT:e===Ve.Int?t.INT:e===Ve.Float?t.FLOAT:e===Ve.UnsignedByte?t.UNSIGNED_BYTE:e===Ve.UnsignedShort?t.UNSIGNED_SHORT:e===Ve.UnsignedInt?t.UNSIGNED_INT:null}}Ve.ArrayBuffer=1,Ve.ElementArrayBuffer=2,Ve.StaticDraw=10,Ve.DynamicDraw=11,Ve.Float=20,Ve.UnsignedByte=21,Ve.UnsignedShort=22,Ve.UnsignedInt=23,Ve.Byte=24,Ve.Short=25,Ve.Int=26,Ve.defaultOptions={itemSize:3,dataType:Ve.Float,stride:0,offset:0,normalized:!1};var Ge=Ve;var We=class{constructor(t){this.name=t.name,this.index=t.index,this.location=void 0!==t.location?t.location:-1,this._enable=!1}bindLocation(t,e){return-1!==this.location&&!0!==this.index&&t.bindAttribLocation(e,this.location,this.name),this}getLocation(t,e){return-1===this.location&&!0!==this.index&&(this.location=t.getAttribLocation(e,this.name)),this}bind(t,e){return this._enable||!0===this.index||(t.enableVertexAttribArray(this.location),this._enable=!0),e.bind(t,this.location),this}disable(t){return this._enable&&!0!==this.index&&(t.disableVertexAttribArray(this.location),this._enable=!1),this}};var He=class{constructor(t){this.name=t.name,this.type=t.type,this.location=-1}getLocation(t,e){return this.location=t.getUniformLocation(e,this.name),this}bind(t,e){const i=this.type;return"mat2"===i?t.uniformMatrix2fv(this.location,!1,e):"mat3"===i?t.uniformMatrix3fv(this.location,!1,e):"mat4"===i?t.uniformMatrix4fv(this.location,!1,e):"2f"===i?t.uniform2f(this.location,e[0],e[1]):"3f"===i?t.uniform3f(this.location,e[0],e[1],e[2]):"4f"===i?t.uniform4f(this.location,e[0],e[1],e[2],e[3]):"2i"===i?t.uniform2i(this.location,e[0],e[1]):"3i"===i?t.uniform3i(this.location,e[0],e[1],e[2]):"4i"===i?t.uniform4i(this.location,e[0],e[1],e[2],e[3]):t["uniform"+i](this.location,e),this}};var Xe=class{constructor(t){t=t||{},this._vertexShader=t.vertex,this._fragmentShader=t.fragment,this.uniforms={},t.uniforms=t.uniforms||[],t.uniforms.forEach(t=>{this.uniforms[t.name]=new He(t)}),this.attributes={},t.attributes=t.attributes||[],t.attributes.forEach(t=>{this.attributes[t.name]=new We(t)}),this._linked=!1,this._located=!1,this._error=!1}enable(t){return this._error?this:(this.link(t),this.locate(t),this._error||t.useProgram(this._webglProgram),this)}bind(t,e,i){if(this._error)return this;if(e)for(const i in e)this.uniforms[i].bind(t,e[i]);if(i)for(const e in i)this.attributes[e].bind(t,i[e]);return this}disable(t){if(this._error)return this;for(const e in this.attributes)this.attributes[e].disable(t);return this}link(t){if(this._linked||this._error)return this;try{this._webglProgram=t.createProgram(),this._vertexShader&&t.attachShader(this._webglProgram,this._vertexShader.get(t)),this._fragmentShader&&t.attachShader(this._webglProgram,this._fragmentShader.get(t));for(const e in this.attributes)this.attributes[e].bindLocation(t,this._webglProgram);if(t.linkProgram(this._webglProgram),!t.getProgramParameter(this._webglProgram,t.LINK_STATUS))throw new Error(t.getProgramInfoLog(this._webglProgram));this._linked=!0}catch(t){throw this._error=!0,t}return this}locate(t){if(this._located||this._error)return this;for(const e in this.attributes)this.attributes[e].getLocation(t,this._webglProgram);for(const e in this.uniforms)this.uniforms[e].getLocation(t,this._webglProgram);return this._located=!0,this}};class qe{constructor(t,e,i=[]){this.type="vertex"===t?qe.Vertex:qe.Fragment,this._code=Array.isArray(e)?e.join("\n"):e||"",this._code=i.map(t=>void 0!==t.value?"#define "+t.type+" "+t.value:"#define "+t.type).join("\n")+"\n"+this._code}get(t){return this._shader||this._compile(t),this._shader}remove(t){this._shader&&t.deleteShader(this._shader)}_compile(t){const e=this.type===qe.Vertex?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=this._shader=t.createShader(e);if(!i||t.isContextLost())throw new Error(`[2gl] Failed to create shader. Shader is null: ${!i}. Context is lost: ${t.isContextLost()}`);if(t.shaderSource(i,this._code),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw new Error(t.getShaderInfoLog(i))}}qe.Vertex=1,qe.Fragment=2;var Ye=qe;function Ze({map:t,gl:e,deck:i,renderTarget:n}){var r;if(t.__deck)return t.__deck;const s=i&&(null===(r=null==i?void 0:i.props)||void 0===r?void 0:r._customRender),o=new Xe({vertex:new Ye("vertex","precision mediump float;\n#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\nuniform vec2 iResolution;\nattribute vec2 position;\nvarying vec2 vUv;\nvoid texcoords_1_0(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvoid main(void) {\n gl_Position = vec4(position, 1.0, 1.0);\n \n \n vUv = (position + 1.0) * 0.5;\n vUv.y = vUv.y;\n vec2 fragCoord = vUv * iResolution;\n texcoords_1_0(fragCoord, iResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}"),fragment:new Ye("fragment","precision mediump float;\n#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\nvarying vec2 vUv;\nuniform vec2 iResolution;\nuniform sampler2D iChannel0;\nuniform bool enabled;\n#ifndef FXAA_REDUCE_MIN\n #define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n #define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n #define FXAA_SPAN_MAX 8.0\n#endif\nvec4 fxaa_1_0(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE, \n vec2 v_rgbSW, vec2 v_rgbSE, \n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n \n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n \n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n \n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n \n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\nvoid main() {\n \n mediump vec2 fragCoord = vUv * iResolution; \n vec4 color;\n if (enabled) {\n color = fxaa_1_0(iChannel0, fragCoord, iResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n } else {\n color = texture2D(iChannel0, vUv);\n }\n gl_FragColor = color;\n}\n"),uniforms:[{name:"iResolution",type:"2f"},{name:"iChannel0",type:"1i"},{name:"enabled",type:"1i"}],attributes:[{name:"position",location:0}]}),a=function(t){return new ze(t,{position:new Ge(new Int8Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),{itemSize:2,dataType:Ge.Byte,stride:0,offset:0,normalized:!1})})}(o),c={useDevicePixels:!0,_2gisFramestart:!1,_2glRenderTarget:n,_2glProgram:o,_2glVao:a,_framebuffer:n._frameBuffer,_customRender:e=>{t.triggerRerender(),null==s||s(e)}},l=Je(t,c);let h;return i&&i.props.gl!==e||(Object.assign(l,{gl:e,width:!1,height:!1,touchAction:"unset",viewState:Be(t)}),t.on("move",()=>function(t,e){t.setProps({viewState:Be(e)}),t.needsRedraw({clearRedrawFlags:!0})}(h,t))),i?(h=i,h.setProps(l),t._impl.on("frameend",()=>h.props._2gisData._2gisCurrentViewport=null),t._impl.on("framestart",()=>i.props._2gisData._2gisFramestart=!0),t.on("resize",()=>function(t,e,i){const n=t.getSize(),r=t.getWebGLContext(),s=[n[0]*window.devicePixelRatio,n[1]*window.devicePixelRatio];i.setSize(s),i.bind(r),e.props._framebuffer=i._frameBuffer,i.unbind(r)}(t,i,n)),t.__deck=h,h):null}function Ke(t,e,i){if(!t.layerManager)return;let n=t.props._2gisData._2gisCurrentViewport;n||(n=function(t){if(!t)return;return new De(t)}(e),t.props._2gisData._2gisCurrentViewport=n),function(t,e){var i,n;const r=t.getWebGLContext();(null===(n=null===(i=e.props)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.cullFaceEnabled)||r.disable(r.CULL_FACE);r.clearDepth(1),r.clear(r.DEPTH_BUFFER_BIT)}(e,i),t._drawLayers("2gis-repaint",{viewports:[n],layerFilter:({layer:t})=>i.id===t.id,clearCanvas:!1})}function Qe(t){const e=[];let i=0;t.props._2gisData._2gisCustomLayers.forEach(t=>{const n=new(0,t.props.type)(t.props,{_offset:i++});e.push(n)}),t.setProps({layers:e})}function Je(t,e){const i=t.getWebGLContext(),n=Object.assign(Object.assign({},e),{parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],polygonOffsetFill:!0,depthFunc:i.LEQUAL,blendEquation:i.FUNC_ADD},_2gisData:{_2gisCustomLayers:new Set,_2gisMap:t},views:[new Fe({id:"2gis"})]});return Object.assign(n,{gl:i,width:null,height:null,touchAction:"unset",viewState:Be(t)}),n}class $e{constructor(t,e={}){this._src=t||null,this.options=Object.assign({},$e.defaultOptions,e),this._glContext=null}enable(t,e){const i=void 0!==e?e:this.options.unit;return void 0!==i&&t.activeTexture(t.TEXTURE0+i),this._texture||this.prepare(t),t.bindTexture(t.TEXTURE_2D,this._texture),this}remove(){return this._texture&&(this._glContext.deleteTexture(this._texture),this._glContext=null,this._texture=null),this}getTexture(){return this._texture}subImage(t,e,i,n){return t.bindTexture(t.TEXTURE_2D,this._texture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.options.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha),t.texSubImage2D(t.TEXTURE_2D,0,i,n,this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.type),e),this}prepare(t){return this._glContext=t,this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.options.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha),this.options.size?t.texImage2D(t.TEXTURE_2D,0,this._toGlParam(t,this.options.format),this.options.size[0],this.options.size[1],0,this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.type),this._src):t.texImage2D(t.TEXTURE_2D,0,this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.format),this._toGlParam(t,this.options.type),this._src),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this._toGlParam(t,this.options.wrapS)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this._toGlParam(t,this.options.wrapT)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this._toGlParam(t,this.options.magFilter)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this._toGlParam(t,this.options.minFilter)),this.options.generateMipmaps&&this.options.minFilter!==$e.NearestFilter&&this.options.minFilter!==$e.LinearFilter&&t.generateMipmap(t.TEXTURE_2D),t.bindTexture(t.TEXTURE_2D,null),this}_toGlParam(t,e){return e===$e.ClampToEdgeWrapping?t.CLAMP_TO_EDGE:e===$e.Repeat?t.REPEAT:e===$e.MirroredRepeat?t.MIRRORED_REPEAT:e===$e.NearestFilter?t.NEAREST:e===$e.NearestMipMapNearestFilter?t.NEAREST_MIPMAP_NEAREST:e===$e.NearestMipMapLinearFilter?t.NEAREST_MIPMAP_LINEAR:e===$e.LinearFilter?t.LINEAR:e===$e.LinearMipMapNearestFilter?t.LINEAR_MIPMAP_NEAREST:e===$e.LinearMipMapLinearFilter?t.LINEAR_MIPMAP_LINEAR:e===$e.RgbaFormat?t.RGBA:e===$e.AlphaFormat?t.ALPHA:e===$e.RgbFormat?t.RGB:e===$e.UnsignedByte?t.UNSIGNED_BYTE:e===$e.Float?t.FLOAT:null}}$e.ClampToEdgeWrapping=8,$e.Repeat=9,$e.MirroredRepeat=10,$e.NearestFilter=1,$e.NearestMipMapNearestFilter=2,$e.NearestMipMapLinearFilter=3,$e.LinearFilter=4,$e.LinearMipMapNearestFilter=5,$e.LinearMipMapLinearFilter=6,$e.RgbaFormat=11,$e.AlphaFormat=12,$e.RgbFormat=13,$e.UnsignedByte=14,$e.Float=15,$e.defaultOptions={magFilter:$e.LinearFilter,minFilter:$e.LinearMipMapLinearFilter,wrapS:$e.ClampToEdgeWrapping,wrapT:$e.ClampToEdgeWrapping,format:$e.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:$e.UnsignedByte};var ti=$e;class ei{constructor(t={}){this.options=Object.assign({},ei.defaultOptions,t),this._texture=new ti(null,this.options),this._glContext=null}bind(t){return this._frameBuffer||this._prepare(t),t.bindFramebuffer(t.FRAMEBUFFER,this._frameBuffer),this}unbind(t){return t.bindFramebuffer(t.FRAMEBUFFER,null),this}remove(){return this._unprepare(),this}setSize(t){return this.options.size=t,this._unprepare(),this}getTexture(){return this._texture}_prepare(t){this._glContext=t,this._texture||(this._texture=new ti(null,this.options)),this._texture.prepare(t),this._frameBuffer=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,this._frameBuffer),this._renderBuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this._renderBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,this.options.size[0],this.options.size[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this._texture.getTexture(),0),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this._renderBuffer),this._checkComplete(t),t.bindRenderbuffer(t.RENDERBUFFER,null),t.bindFramebuffer(t.FRAMEBUFFER,null)}_unprepare(){this._texture&&(this._texture.remove(this._glContext),this._texture=null),this._frameBuffer&&(this._glContext.deleteFramebuffer(this._frameBuffer),this._glContext.deleteRenderbuffer(this._renderBuffer),this._frameBuffer=null,this._renderBuffer=null)}_checkComplete(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);e!==t.FRAMEBUFFER_COMPLETE&&(e===t.FRAMEBUFFER_UNSUPPORTED?console.log("Framebuffer is unsupported"):e===t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT?console.log("Framebuffer incomplete attachment"):e===t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS?console.log("Framebuffer incomplete dimensions"):e===t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT?console.log("Framebuffer incomplete missing attachment"):console.log("Unexpected framebuffer status: "+e))}}ei.defaultOptions=Object.assign({},ti.defaultOptions,{size:[0,0],generateMipmaps:!1});var ii=ei;class ni{constructor(t){if(this.onAdd=()=>{if(!this.map&&this.props.deck){const t=this.props.deck.props._2gisData._2gisMap;this.map=t;const e=this.gl=t.getWebGLContext();if(t.__deck&&(this.deck=t.__deck,this.frameBuffer=this.deck.props._2glRenderTarget),!this.frameBuffer||!this.deck){const i=t.getSize();this.frameBuffer=new ii({size:[Math.ceil(i[0]*window.devicePixelRatio),Math.ceil(i[1]*window.devicePixelRatio)],magFilter:ti.LinearFilter,minFilter:ti.LinearFilter,wrapS:ti.ClampToEdgeWrapping,wrapT:ti.ClampToEdgeWrapping});const n=this.frameBuffer.bind(e);this.frameBuffer.unbind(e),this.deck=Ze({map:t,gl:e,deck:this.props.deck,renderTarget:n})}this.program=this.deck.props._2glProgram,this.vao=this.deck.props._2glVao}var t,e;this.deck&&(t=this.deck,e=this,t.props._2gisData._2gisCustomLayers.add(e),Qe(t))},this.onRemove=()=>{var t,e;this.deck&&(t=this.deck,e=this,t.props._2gisData._2gisCustomLayers.delete(e),Qe(t))},this.render=()=>{if(!(this.deck&&this.map&&this.frameBuffer&&this.program&&this.vao&&this.gl))return;const{_2gisData:t,skipResizeRenderer:e}=this.deck.props,i=this.gl;this.frameBuffer.bind(i),i.clearColor(1,1,1,0),t._2gisFramestart?(i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),t._2gisFramestart=!1):i.clear(i.COLOR_BUFFER_BIT),this.frameBuffer.unbind(i);const n=this.map.getSize();if(!e||this.deck.width===n[0]&&this.deck.height===n[1]){Ke(this.deck,this.map,this),i.bindFramebuffer(i.FRAMEBUFFER,null);this.frameBuffer.getTexture().enable(i,0),this.program.enable(i),this.program.bind(i,{iResolution:[n[0]*window.devicePixelRatio,n[1]*window.devicePixelRatio],iChannel0:0,enabled:Number(this.antialiasing)}),this.vao.bind({gl:i,extensions:{OES_vertex_array_object:i.getExtension("OES_vertex_array_object")}}),i.disable(i.CULL_FACE),i.drawArrays(i.TRIANGLES,0,6)}},!t.id)throw new Error("Layer must have a unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t,this.antialiasing=Boolean(t.antialiasing)}setProps(t){Object.assign(this.props,t,{id:this.id}),this.antialiasing=Boolean(t.antialiasing),this.deck&&Qe(this.deck)}}ni.initDeck2gisProps=(t,e)=>Je(t,e),"undefined"!=typeof window&&("mapgl"in window?mapgl.Deck2gisLayer=ni:(window.__mapglPlugins||(window.__mapglPlugins={}),window.__mapglPlugins.Deck2gisLayer=ni));const ri=new y({id:"luma.gl"});function si(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}function oi(t){return"undefined"!=typeof WebGLRenderingContext&&t instanceof WebGLRenderingContext||("undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||Boolean(t&&Number.isFinite(t._version)))}function ai(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||Boolean(t&&2===t._version)}function ci(t){return si(oi(t),"Invalid WebGLRenderingContext"),t}function li(t){return si(ai(t),"Requires WebGL2"),t}const hi={};function ui(t,e){var i;hi[t]=!0,void 0!==e&&(i=e,globalThis.console&&globalThis.console.error&&globalThis.console.error(i))}const di=function t(e){const i=e.gl;this.ext=e,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(e.maxVertexAttribs);for(let e=0;e{var t;t="OESVertexArrayObject emulation library context restored",globalThis.console&&globalThis.console.log&&globalThis.console.log(t),e.reset_()},!0),this.reset_()};fi.prototype.VERTEX_ARRAY_BINDING_OES=34229,fi.prototype.reset_=function(){if(void 0!==this.vertexArrayObjects)for(let t=0;tai(t)?void 0:0,gi={3074:t=>ai(t)?void 0:36064,35723:t=>ai(t)?void 0:4352,35977:pi,32937:pi,36795:(t,e)=>{const i=ai(t)?t.getExtension("EXT_disjoint_timer_query_webgl2"):t.getExtension("EXT_disjoint_timer_query");return i&&i.GPU_DISJOINT_EXT?e(i.GPU_DISJOINT_EXT):0},37445:(t,e)=>{const i=t.getExtension("WEBGL_debug_renderer_info");return e(i&&i.UNMASKED_VENDOR_WEBGL||7936)},37446:(t,e)=>{const i=t.getExtension("WEBGL_debug_renderer_info");return e(i&&i.UNMASKED_RENDERER_WEBGL||7937)},34047:(t,e)=>{const i=t.luma.extensions.EXT_texture_filter_anisotropic;return i?e(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1},32883:pi,35071:pi,37447:pi,36063:(t,e)=>{if(!ai(t)){const i=t.getExtension("WEBGL_draw_buffers");return i?e(i.MAX_COLOR_ATTACHMENTS_WEBGL):0}},35379:pi,35374:pi,35377:pi,34852:t=>{if(!ai(t)){const e=t.getExtension("WEBGL_draw_buffers");return e?e.MAX_DRAW_BUFFERS_WEBGL:0}},36203:t=>t.getExtension("OES_element_index")?2147483647:65535,33001:t=>t.getExtension("OES_element_index")?16777216:65535,33e3:t=>16777216,37157:pi,35373:pi,35657:pi,36183:pi,37137:pi,34045:pi,35978:pi,35979:pi,35968:pi,35376:pi,35375:pi,35659:pi,37154:pi,35371:pi,35658:pi,35076:pi,35077:pi,35380:pi};const mi={OES_vertex_array_object:{meta:{suffix:"OES"},createVertexArray:()=>{si(!1,"VertexArray requires WebGL2 or OES_vertex_array_object extension")},deleteVertexArray:()=>{},bindVertexArray:()=>{},isVertexArray:()=>!1},ANGLE_instanced_arrays:{meta:{suffix:"ANGLE"},vertexAttribDivisor(t,e){si(0===e,"WebGL instanced rendering not supported")},drawElementsInstanced:()=>{},drawArraysInstanced:()=>{}},WEBGL_draw_buffers:{meta:{suffix:"WEBGL"},drawBuffers:()=>{si(!1)}},EXT_disjoint_timer_query:{meta:{suffix:"EXT"},createQuery:()=>{si(!1)},deleteQuery:()=>{si(!1)},beginQuery:()=>{si(!1)},endQuery:()=>{},getQuery(t,e){return this.getQueryObject(t,e)},getQueryParameter(t,e){return this.getQueryObject(t,e)},getQueryObject:()=>{}}},vi={readBuffer:(t,e,i)=>{ai(t)&&e(i)},getVertexAttrib:(t,e,i,n)=>{const{webgl2:r,ext:s}=function(t,e){return{webgl2:ai(t),ext:t.getExtension(e)}}(t,"ANGLE_instanced_arrays");let o;switch(n){case 35069:o=!!r&&void 0;break;case 35070:o=r||s?void 0:0}return void 0!==o?o:e(i,n)},getProgramParameter:(t,e,i,n)=>{if(!ai(t))switch(n){case 35967:return 35981;case 35971:case 35382:return 0}return e(i,n)},getInternalformatParameter:(t,e,i,n,r)=>{if(!ai(t))switch(r){case 32937:return new Int32Array([0])}return t.getInternalformatParameter(i,n,r)},getTexParameter(t,e,i,n){switch(n){case 34046:const{extensions:e}=t.luma,i=e.EXT_texture_filter_anisotropic;n=i&&i.TEXTURE_MAX_ANISOTROPY_EXT||34046}return e(i,n)},getParameter:function(t,e,i){const n=gi[i],r="function"==typeof n?n(t,e,i):n;return void 0!==r?r:e(i)},hint:(t,e,i,n)=>e(i,n)};function _i(t,e){let{extension:i,target:n,target2:r}=e;const s=mi[i];si(s);const{meta:o={}}=s,{suffix:a=""}=o,c=t.getExtension(i);for(const e of Object.keys(s)){const i="".concat(e).concat(a);let o=null;"meta"===e||"function"==typeof t[e]||(c&&"function"==typeof c[i]?o=function(){return c[i](...arguments)}:"function"==typeof s[e]&&(o=s[e].bind(n))),o&&(n[e]=o,r[e]=o)}}globalThis.polyfillContext=function(t){t.luma=t.luma||{};const{luma:e}=t;return e.polyfilled||(!function(t){if("function"==typeof t.createVertexArray)return;const e=t.getSupportedExtensions;t.getSupportedExtensions=function(){const t=e.call(this)||[];return t.indexOf("OES_vertex_array_object")<0&&t.push("OES_vertex_array_object"),t};const i=t.getExtension;t.getExtension=function(e){const n=i.call(this,e);return n||("OES_vertex_array_object"!==e?null:(t.__OESVertexArrayObject||(this.__OESVertexArrayObject=new fi(this)),this.__OESVertexArrayObject))}}(t),function(t){t.luma.extensions={};const e=t.getSupportedExtensions()||[];for(const i of e)t.luma[i]=t.getExtension(i)}(t),function(t,e){for(const i of Object.getOwnPropertyNames(e))"overrides"!==i&&_i(t,{extension:i,target:t.luma,target2:t})}(t,mi),function(t,e){let{target:i,target2:n}=e;Object.keys(vi).forEach(e=>{if("function"==typeof vi[e]){const r=t[e]?t[e].bind(t):()=>{},s=vi[e].bind(null,t,r);i[e]=s,n[e]=s}})}(t,{target:e,target2:t}),e.polyfilled=!0),t};const bi={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,36006:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],3333:4,3317:4,37440:!1,37441:!1,37443:37444,35723:4352,36010:null,35977:!1,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},yi=(t,e,i)=>e?t.enable(i):t.disable(i),wi=(t,e,i)=>t.hint(i,e),xi=(t,e,i)=>t.pixelStorei(i,e);function Ei(t){return Array.isArray(t)||ArrayBuffer.isView(t)}const Ti={3042:yi,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:yi,2885:(t,e)=>t.cullFace(e),2929:yi,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:yi,35723:wi,36006:(t,e)=>{const i=ai(t)?36009:36160;return t.bindFramebuffer(i,e)},2886:(t,e)=>t.frontFace(e),33170:wi,2849:(t,e)=>t.lineWidth(e),32823:yi,32824:"polygonOffset",10752:"polygonOffset",35977:yi,32938:"sampleCoverage",32939:"sampleCoverage",3089:yi,3088:(t,e)=>t.scissor(...e),2960:yi,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(t,e)=>t.viewport(...e),3333:xi,3317:xi,37440:xi,37441:xi,37443:xi,3330:xi,3332:xi,3331:xi,36010:(t,e)=>t.bindFramebuffer(36008,e),3314:xi,32878:xi,3316:xi,3315:xi,32877:xi,framebuffer:(t,e)=>{const i=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,i)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{e=Ei(e)?e:[e,e],t.blendEquationSeparate(...e)},blendFunc:(t,e)=>{e=Ei(e)&&2===e.length?[...e,...e]:e,t.blendFuncSeparate(...e)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Ei(e)?e:[e,e];const[i,n]=e;t.stencilMaskSeparate(1028,i),t.stencilMaskSeparate(1029,n)},stencilFunc:(t,e)=>{e=Ei(e)&&3===e.length?[...e,...e]:e;const[i,n,r,s,o,a]=e;t.stencilFuncSeparate(1028,i,n,r),t.stencilFuncSeparate(1029,s,o,a)},stencilOp:(t,e)=>{e=Ei(e)&&3===e.length?[...e,...e]:e;const[i,n,r,s,o,a]=e;t.stencilOpSeparate(1028,i,n,r),t.stencilOpSeparate(1029,s,o,a)},viewport:(t,e)=>t.viewport(...e)};function Ai(t,e,i){return void 0!==e[t]?e[t]:i[t]}const Pi={blendEquation:(t,e,i)=>t.blendEquationSeparate(Ai(32777,e,i),Ai(34877,e,i)),blendFunc:(t,e,i)=>t.blendFuncSeparate(Ai(32969,e,i),Ai(32968,e,i),Ai(32971,e,i),Ai(32970,e,i)),polygonOffset:(t,e,i)=>t.polygonOffset(Ai(32824,e,i),Ai(10752,e,i)),sampleCoverage:(t,e,i)=>t.sampleCoverage(Ai(32938,e,i),Ai(32939,e,i)),stencilFuncFront:(t,e,i)=>t.stencilFuncSeparate(1028,Ai(2962,e,i),Ai(2967,e,i),Ai(2963,e,i)),stencilFuncBack:(t,e,i)=>t.stencilFuncSeparate(1029,Ai(34816,e,i),Ai(36003,e,i),Ai(36004,e,i)),stencilOpFront:(t,e,i)=>t.stencilOpSeparate(1028,Ai(2964,e,i),Ai(2965,e,i),Ai(2966,e,i)),stencilOpBack:(t,e,i)=>t.stencilOpSeparate(1029,Ai(34817,e,i),Ai(34818,e,i),Ai(34819,e,i))},Si={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,i)=>t({[e]:i}),hint:(t,e,i)=>t({[e]:i}),bindFramebuffer:(t,e,i)=>{switch(e){case 36160:return t({36006:i,36010:i});case 36009:return t({36006:i});case 36008:return t({36010:i});default:return null}},blendColor:(t,e,i,n,r)=>t({32773:new Float32Array([e,i,n,r])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,i)=>t({32777:e,34877:i}),blendFunc:(t,e,i)=>t({32969:e,32968:i,32971:e,32970:i}),blendFuncSeparate:(t,e,i,n,r)=>t({32969:e,32968:i,32971:n,32970:r}),clearColor:(t,e,i,n,r)=>t({3106:new Float32Array([e,i,n,r])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,i,n,r)=>t({3107:[e,i,n,r]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,i)=>t({2928:new Float32Array([e,i])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,i)=>t({32824:e,10752:i}),sampleCoverage:(t,e,i)=>t({32938:e,32939:i}),scissor:(t,e,i,n,r)=>t({3088:new Int32Array([e,i,n,r])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,i)=>t({[1028===e?2968:36005]:i}),stencilFunc:(t,e,i,n)=>t({2962:e,2967:i,2963:n,34816:e,36003:i,36004:n}),stencilFuncSeparate:(t,e,i,n,r)=>t({[1028===e?2962:34816]:i,[1028===e?2967:36003]:n,[1028===e?2963:36004]:r}),stencilOp:(t,e,i,n)=>t({2964:e,2965:i,2966:n,34817:e,34818:i,34819:n}),stencilOpSeparate:(t,e,i,n,r)=>t({[1028===e?2964:34817]:i,[1028===e?2965:34818]:n,[1028===e?2966:34819]:r}),viewport:(t,e,i,n,r)=>t({2978:[e,i,n,r]})},Mi=(t,e)=>t.isEnabled(e),Ci={3042:Mi,2884:Mi,2929:Mi,3024:Mi,32823:Mi,32926:Mi,32928:Mi,3089:Mi,2960:Mi,35977:Mi};function Li(t){for(const e in t)return!1;return!0}function Ri(t,e){if(t===e)return!0;const i=Array.isArray(t)||ArrayBuffer.isView(t),n=Array.isArray(e)||ArrayBuffer.isView(e);if(i&&n&&t.length===e.length){for(let i=0;i{})}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.program=null,this.stateStack=[],this.enable=!0,this.cache=e?Ni(t):Object.assign({},bi),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(){this.stateStack.push({})}pop(){si(this.stateStack.length>0);const t=this.stateStack[this.stateStack.length-1];ji(this.gl,t),this.stateStack.pop()}_updateCache(t){let e,i=!1;const n=this.stateStack.length>0&&this.stateStack[this.stateStack.length-1];for(const r in t){si(void 0!==r);const s=t[r],o=this.cache[r];Ri(s,o)||(i=!0,e=o,n&&!(r in n)&&(n[r]=o),this.cache[r]=s)}return{valueChanged:i,oldValue:e}}}function Di(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{enable:i=!0,copyState:n}=e;if(si(void 0!==n),!t.state){const{polyfillContext:e}=globalThis;e&&e(t),t.state=new Fi(t,{copyState:n}),ki(t);for(const e in Si){Ii(t,e,Si[e])}Oi(t,"getParameter"),Oi(t,"isEnabled")}return t.state.enable=i,t}function Bi(t){si(t.state),t.state.pop()}function ji(t,e){if(si(oi(t),"setParameters requires a WebGL context"),Li(e))return;const i={};for(const n in e){const r=Number(n),s=Ti[n];s&&("string"==typeof s?i[s]=!0:s(t,e[n],r))}const n=t.state&&t.state.cache;if(n)for(const r in i){(0,Pi[r])(t,e,n)}}function Ni(t,e){if("number"==typeof(e=e||bi)){const i=e,n=Ci[i];return n?n(t,i):t.getParameter(i)}const i=Array.isArray(e)?e:Object.keys(e),n={};for(const e of i){const i=Ci[e];n[e]=i?i(t,Number(e)):t.getParameter(Number(e))}return n}function Ui(t,e,i){if(Li(e))return i(t);const{nocatch:n=!0}=e;let r;if(function(t){t.state||Di(t,{copyState:!1}),t.state.push()}(t),ji(t,e),n)r=i(t),Bi(t);else try{r=i(t)}finally{Bi(t)}return r}function zi(t){const{luma:e}=t;if(t.canvas&&e){const{clientWidth:i}=e.canvasSizeInfo;return i?t.drawingBufferWidth/i:1}return 1}function Vi(t,e){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const n=zi(t),r=t.drawingBufferWidth,s=t.drawingBufferHeight;return Wi(e,n,r,s,i)}function Gi(t){const e="undefined"==typeof window?1:window.devicePixelRatio||1;return Number.isFinite(t)?t<=0?1:t:t?e:1}function Wi(t,e,i,n,r){const s=Hi(t[0],e,i);let o=Xi(t[1],e,n,r),a=Hi(t[0]+1,e,i);const c=a===i-1?a:a-1;let l;return a=Xi(t[1]+1,e,n,r),r?(a=0===a?a:a+1,l=o,o=a):l=a===n-1?a:a-1,{x:s,y:o,width:Math.max(c-s+1,1),height:Math.max(l-o+1,1)}}function Hi(t,e,i){return Math.min(Math.round(t*e),i-1)}function Xi(t,e,i,n){return n?Math.max(0,i-1-Math.round(t*e)):Math.min(Math.round(t*e),i-1)}const qi=Object(s.a)(),Yi=qi&&"undefined"!=typeof document,Zi={webgl2:!0,webgl1:!0,throwOnError:!0,manageState:!0,canvas:null,debug:!1,width:800,height:600};function Ki(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};si(qi,"createGLContext only available in the browser.\nCreate your own headless context or use 'createHeadlessContext' from @luma.gl/test-utils"),t=Object.assign({},Zi,t);const{width:e,height:i}=t;function n(e){if(t.throwOnError)throw new Error(e);return console.error(e),null}let r;t.onError=n;const{canvas:s}=t,o=$i({canvas:s,width:e,height:i,onError:n});return r=Ji(o,t),r?(r=Qi(r,t),tn(r),r):null}function Qi(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t||t._instrumented)return t;t._version=t._version||en(t),t.luma=t.luma||{},t.luma.canvasSizeInfo=t.luma.canvasSizeInfo||{},e=Object.assign({},Zi,e);const{manageState:i,debug:n}=e;return i&&Di(t,{copyState:!1,log:function(){for(var t=arguments.length,e=new Array(t),i=0;in=t.statusMessage||n;t.addEventListener("webglcontextcreationerror",r,!1);const{webgl1:s=!0,webgl2:o=!0}=e;let a=null;return o&&(a=a||t.getContext("webgl2",e),a=a||t.getContext("experimental-webgl2",e)),s&&(a=a||t.getContext("webgl",e),a=a||t.getContext("experimental-webgl",e)),t.removeEventListener("webglcontextcreationerror",r,!1),a?(e.onContextLost&&t.addEventListener("webglcontextlost",e.onContextLost,!1),e.onContextRestored&&t.addEventListener("webglcontextrestored",e.onContextRestored,!1),a):i("Failed to create ".concat(o&&!s?"WebGL2":"WebGL"," context: ").concat(n||"Unknown error"))}function $i(t){let e,{canvas:i,width:n=800,height:r=600,onError:s}=t;if("string"==typeof i){Yi&&"complete"===document.readyState||s("createGLContext called on canvas '".concat(i,"' before page was loaded")),e=document.getElementById(i)}else i?e=i:(e=document.createElement("canvas"),e.id="lumagl-canvas",e.style.width=Number.isFinite(n)?"".concat(n,"px"):"100%",e.style.height=Number.isFinite(r)?"".concat(r,"px"):"100%",document.body.insertBefore(e,document.body.firstChild));return e}function tn(t){const e=ai(t)?"WebGL2":"WebGL1",i=function(t){const e=t.getParameter(7936),i=t.getParameter(7937),n=t.getExtension("WEBGL_debug_renderer_info");return{vendor:n&&t.getParameter(n.UNMASKED_VENDOR_WEBGL||7936)||e,renderer:n&&t.getParameter(n.UNMASKED_RENDERER_WEBGL||7937)||i,vendorMasked:e,rendererMasked:i,version:t.getParameter(7938),shadingLanguageVersion:t.getParameter(35724)}}(t),n=i?"(".concat(i.vendor,",").concat(i.renderer,")"):"",r=t.debug?" debug":"";ri.info(1,"".concat(e).concat(r," context ").concat(n))()}function en(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext?2:1}function nn(t,e,i){let n="width"in i?i.width:t.canvas.clientWidth,r="height"in i?i.height:t.canvas.clientHeight;n&&r||(ri.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=t.canvas.width||1,r=t.canvas.height||1),t.luma=t.luma||{},t.luma.canvasSizeInfo=t.luma.canvasSizeInfo||{};const s=t.luma.canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==r||s.devicePixelRatio!==e){let i=e;const s=Math.floor(n*i),o=Math.floor(r*i);t.canvas.width=s,t.canvas.height=o,t.drawingBufferWidth===s&&t.drawingBufferHeight===o||(ri.warn("Device pixel ratio clamped")(),i=Math.min(t.drawingBufferWidth/n,t.drawingBufferHeight/r),t.canvas.width=Math.floor(n*i),t.canvas.height=Math.floor(r*i)),Object.assign(t.luma.canvasSizeInfo,{clientWidth:n,clientHeight:r,devicePixelRatio:e})}}const rn=new Float32Array(12);function sn(t,e=2){let i=0;for(const n of t)for(let t=0;t0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class cn{constructor(t){r(this,"id",void 0),r(this,"stats",{}),this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count";return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(const t in this.stats)this.stats[t].reset();return this}forEach(t){for(const e in this.stats)t(this.stats[e])}getTable(){const t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(t=>this._getOrCreate(t))}_getOrCreate(t){if(!t||!t.name)return null;const{name:e,type:i}=t;return this.stats[e]||(this.stats[e]=t instanceof an?t:new an(e,i)),this.stats[e]}}const ln=new class{constructor(){this.stats=new Map}get(t){return this.stats.has(t)||this.stats.set(t,new cn({id:t})),this.stats.get(t)}};if(globalThis.luma&&"8.5.18"!==globalThis.luma.VERSION)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat("8.5.18"));globalThis.luma||(Object(s.a)()&&ri.log(1,"luma.gl ".concat("8.5.18"," - ").concat("set luma.log.level=1 (or higher) to trace rendering"))(),globalThis.luma=globalThis.luma||{VERSION:"8.5.18",version:"8.5.18",log:ri,stats:ln,globals:{modules:{},nodeIO:{}}});globalThis.luma;function hn(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}function un(t,e){if("string"!=typeof e)return e;const i=Number(e);if(!isNaN(i))return i;const n=t[e=e.replace(/^.*\./,"")];return hn(void 0!==n,"Accessing undefined constant GL.".concat(e)),n}function dn(t,e){e=Number(e);for(const i in t)if(t[i]===e)return"GL.".concat(i);return String(e)}const fn={};function pn(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";fn[t]=fn[t]||1;const e=fn[t]++;return"".concat(t,"-").concat(e)}function gn(t){return hn("number"==typeof t,"Input must be a number"),t&&0==(t&t-1)}function mn(t){let e=!0;for(const i in t){e=!1;break}return e}function vn(t,e,i,n){const r="See luma.gl ".concat(i," Upgrade Guide at https://luma.gl/docs/upgrade-guide"),s=Object.getPrototypeOf(t);n.forEach(t=>{s.methodName||(s[t]=()=>{throw ri.removed("Calling removed method ".concat(e,".").concat(t,": "),r)(),new Error(t)})})}const _n="Resource subclass must define virtual methods";class bn{get[Symbol.toStringTag](){return"Resource"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ci(t);const{id:i,userData:n={}}=e;this.gl=t,this.gl2=t,this.id=i||pn(this[Symbol.toStringTag]),this.userData=n,this._bound=!1,this._handle=e.handle,void 0===this._handle&&(this._handle=this._createHandle()),this.byteLength=0,this._addStats()}toString(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")}get handle(){return this._handle}delete(){let{deleteChildren:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this._handle&&this._deleteHandle(this._handle);return this._handle&&this._removeStats(),this._handle=null,e&&t&&e.filter(Boolean).forEach(t=>t.delete()),this}bind(){let t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.handle;return"function"!=typeof e?(this._bindHandle(e),this):(this._bound?t=e():(this._bindHandle(this.handle),this._bound=!0,t=e(),this._bound=!1,this._bindHandle(null)),t)}unbind(){this.bind(null)}getParameter(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};hn(t=un(this.gl,t));const i=(this.constructor.PARAMETERS||{})[t];if(i){const t=ai(this.gl);if(!((!("webgl2"in i)||t)&&(!("extension"in i)||this.gl.getExtension(i.extension)))){const e=i.webgl1,n="webgl2"in i?i.webgl2:i.webgl1;return t?n:e}}return this._getParameter(t,e)}getParameters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{parameters:e,keys:i}=t,n=this.constructor.PARAMETERS||{},r=ai(this.gl),s={},o=e||Object.keys(n);for(const e of o){const o=n[e];if(o&&(!("webgl2"in o)||r)&&(!("extension"in o)||this.gl.getExtension(o.extension))){const n=i?dn(this.gl,e):e;s[n]=this.getParameter(e,t),i&&"GLenum"===o.type&&(s[n]=dn(this.gl,s[n]))}}return s}setParameter(t,e){hn(t=un(this.gl,t));const i=(this.constructor.PARAMETERS||{})[t];if(i){const t=ai(this.gl);if(!((!("webgl2"in i)||t)&&(!("extension"in i)||this.gl.getExtension(i.extension))))throw new Error("Parameter not available on this platform");"GLenum"===i.type&&(e=un(e))}return this._setParameter(t,e),this}setParameters(t){for(const e in t)this.setParameter(e,t[e]);return this}stubRemovedMethods(t,e,i){return vn(this,t,e,i)}initialize(t){}_createHandle(){throw new Error(_n)}_deleteHandle(){throw new Error(_n)}_bindHandle(t){throw new Error(_n)}_getOptsFromHandle(){throw new Error(_n)}_getParameter(t,e){throw new Error(_n)}_setParameter(t,e){throw new Error(_n)}_context(){return this.gl.luma=this.gl.luma||{},this.gl.luma}_addStats(){const t=this[Symbol.toStringTag],e=ln.get("Resource Counts");e.get("Resources Created").incrementCount(),e.get("".concat(t,"s Created")).incrementCount(),e.get("".concat(t,"s Active")).incrementCount()}_removeStats(){const t=this[Symbol.toStringTag];ln.get("Resource Counts").get("".concat(t,"s Active")).decrementCount()}_trackAllocatedMemory(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag];this._trackAllocatedMemoryForContext(t,e),this._trackAllocatedMemoryForContext(t,e,this.gl.canvas&&this.gl.canvas.id),this.byteLength=t}_trackAllocatedMemoryForContext(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this[Symbol.toStringTag],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const n=ln.get("Memory Usage".concat(i));n.get("GPU Memory").addCount(t),n.get("".concat(e," Memory")).addCount(t)}_trackDeallocatedMemory(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag];this._trackDeallocatedMemoryForContext(t),this._trackDeallocatedMemoryForContext(t,this.gl.canvas&&this.gl.canvas.id),this.byteLength=0}_trackDeallocatedMemoryForContext(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this[Symbol.toStringTag],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const i=ln.get("Memory Usage".concat(e));i.get("GPU Memory").subtractCount(this.byteLength),i.get("".concat(t," Memory")).subtractCount(this.byteLength)}}function yn(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}function wn(t){let{clamped:e=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return e?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}function xn(t){let{data:e,width:i,height:n,bytesPerPixel:r=4,temp:s}=t;const o=i*r;s=s||new Uint8Array(o);for(let t=0;tthis._assign(t)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return Sn.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return Sn.getBytesPerVertex(this)}_assign(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=Tn("Accessor",t,Pn),void 0!==t.type&&(this.type=t.type,5124!==t.type&&5125!==t.type||(this.integer=!0)),void 0!==t.size&&(this.size=t.size),void 0!==t.offset&&(this.offset=t.offset),void 0!==t.stride&&(this.stride=t.stride),void 0!==t.normalized&&(this.normalized=t.normalized),void 0!==t.integer&&(this.integer=t.integer),void 0!==t.divisor&&(this.divisor=t.divisor),void 0!==t.buffer&&(this.buffer=t.buffer),void 0!==t.index&&("boolean"==typeof t.index?this.index=t.index?1:0:this.index=t.index),void 0!==t.instanced&&(this.divisor=t.instanced?1:0),void 0!==t.isInstanced&&(this.divisor=t.isInstanced?1:0),this}}const Mn={offset:"accessor.offset",stride:"accessor.stride",type:"accessor.type",size:"accessor.size",divisor:"accessor.divisor",normalized:"accessor.normalized",integer:"accessor.integer",instanced:"accessor.divisor",isInstanced:"accessor.divisor"},Cn={removedProps:{},replacedProps:{bytes:"byteLength"},deprecatedProps:Mn},Ln={removedProps:Mn};class Rn extends bn{get[Symbol.toStringTag](){return"Buffer"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.stubRemovedMethods("Buffer","v6.0",["layout","setLayout","getIndexedParameter"]),this.target=e.target||(this.gl.webgl2?36662:34962),this.initialize(e),Object.seal(this)}getElementCount(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/Sn.getBytesPerElement(t))}getVertexCount(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.accessor;return Math.round(this.byteLength/Sn.getBytesPerVertex(t))}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ArrayBuffer.isView(t)&&(t={data:t}),Number.isFinite(t)&&(t={byteLength:t}),t=Tn("Buffer",t,Cn),this.usage=t.usage||35044,this.debugData=null,this.setAccessor(Object.assign({},t,t.accessor)),t.data?this._setData(t.data,t.offset,t.byteLength):this._setByteLength(t.byteLength||0),this}setProps(t){return"accessor"in(t=Tn("Buffer",t,Ln))&&this.setAccessor(t.accessor),this}setAccessor(t){return delete(t=Object.assign({},t)).buffer,this.accessor=new Sn(t),this}reallocate(t){return t>this.byteLength?(this._setByteLength(t),!0):(this.bytesUsed=t,!1)}setData(t){return this.initialize(t)}subData(t){ArrayBuffer.isView(t)&&(t={data:t});const{data:e,offset:i=0,srcOffset:n=0}=t,r=t.byteLength||t.length;hn(e);const s=this.gl.webgl2?36663:this.target;return this.gl.bindBuffer(s,this.handle),0!==n||void 0!==r?(li(this.gl),this.gl.bufferSubData(this.target,i,e,n,r)):this.gl.bufferSubData(s,i,e),this.gl.bindBuffer(s,null),this.debugData=null,this._inferType(e),this}copyData(t){let{sourceBuffer:e,readOffset:i=0,writeOffset:n=0,size:r}=t;const{gl:s}=this;return li(s),s.bindBuffer(36662,e.handle),s.bindBuffer(36663,this.handle),s.copyBufferSubData(36662,36663,i,n,r),s.bindBuffer(36662,null),s.bindBuffer(36663,null),this.debugData=null,this}getData(){let{dstData:t=null,srcByteOffset:e=0,dstOffset:i=0,length:n=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};li(this.gl);const r=wn(this.accessor.type||5126,{clamped:!1}),s=this._getAvailableElementCount(e),o=i;let a,c;t?(c=t.length,a=c-o):(a=Math.min(s,n||s),c=o+a);const l=Math.min(s,a);return n=n||l,hn(n<=l),t=t||new r(c),this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,t,i,n),this.gl.bindBuffer(36662,null),t}bind(){let{target:t=this.target,index:e=this.accessor&&this.accessor.index,offset:i=0,size:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 35345===t||35982===t?void 0!==n?this.gl.bindBufferRange(t,e,this.handle,i,n):(hn(0===i),this.gl.bindBufferBase(t,e,this.handle)):this.gl.bindBuffer(t,this.handle),this}unbind(){let{target:t=this.target,index:e=this.accessor&&this.accessor.index}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return 35345===t||35982===t?this.gl.bindBufferBase(t,e,null):this.gl.bindBuffer(t,null),this}getDebugData(){return this.debugData?{data:this.debugData,changed:!1}:(this.debugData=this.getData({length:Math.min(10,this.byteLength)}),{data:this.debugData,changed:!0})}invalidateDebugData(){this.debugData=null}_setData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.byteLength+e;hn(ArrayBuffer.isView(t)),this._trackDeallocatedMemory();const n=this._getTarget();this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.usage),this.gl.bufferSubData(n,e,t),this.gl.bindBuffer(n,null),this.debugData=t.slice(0,10),this.bytesUsed=i,this._trackAllocatedMemory(i);const r=yn(t);return hn(r),this.setAccessor(new Sn(this.accessor,{type:r})),this}_setByteLength(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.usage;hn(t>=0),this._trackDeallocatedMemory();let i=t;0===t&&(i=new Float32Array(0));const n=this._getTarget();return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,e),this.gl.bindBuffer(n,null),this.usage=e,this.debugData=null,this.bytesUsed=t,this._trackAllocatedMemory(t),this}_getTarget(){return this.gl.webgl2?36663:this.target}_getAvailableElementCount(t){const e=t/wn(this.accessor.type||5126,{clamped:!1}).BYTES_PER_ELEMENT;return this.getElementCount()-e}_inferType(t){this.accessor.type||this.setAccessor(new Sn(this.accessor,{type:yn(t)}))}_createHandle(){return this.gl.createBuffer()}_deleteHandle(){this.gl.deleteBuffer(this.handle),this._trackDeallocatedMemory()}_getParameter(t){this.gl.bindBuffer(this.target,this.handle);const e=this.gl.getBufferParameter(this.target,t);return this.gl.bindBuffer(this.target,null),e}get type(){return ri.deprecated("Buffer.type","Buffer.accessor.type")(),this.accessor.type}get bytes(){return ri.deprecated("Buffer.bytes","Buffer.byteLength")(),this.byteLength}setByteLength(t){return ri.deprecated("setByteLength","reallocate")(),this.reallocate(t)}updateAccessor(t){return ri.deprecated("updateAccessor(...)","setAccessor(new Accessor(buffer.accessor, ...)")(),this.accessor=new Sn(this.accessor,t),this}}const On={6407:{dataFormat:6407,types:[5121,33635]},6408:{dataFormat:6408,types:[5121,32819,32820]},6406:{dataFormat:6406,types:[5121]},6409:{dataFormat:6409,types:[5121]},6410:{dataFormat:6410,types:[5121]},33326:{dataFormat:6403,types:[5126],gl2:!0},33328:{dataFormat:33319,types:[5126],gl2:!0},34837:{dataFormat:6407,types:[5126],gl2:!0},34836:{dataFormat:6408,types:[5126],gl2:!0}},In={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},kn={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};const Fn=[9729,9728],Dn=globalThis.WebGLBuffer||function(){};class Bn extends bn{get[Symbol.toStringTag](){return"Texture"}static isSupported(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{format:i,linearFiltering:n}=e;let r=!0;return i&&(r=r&&function(t,e){const i=On[e];if(!i)return!1;if(void 0===i.gl1&&void 0===i.gl2)return!0;const n=ai(t)&&i.gl2||i.gl1;return"string"==typeof n?t.getExtension(n):n}(t,i),r=r&&(!n||function(t,e){const i=On[e];switch(i&&i.types[0]){case 5126:return t.getExtension("OES_texture_float_linear");case 5131:return t.getExtension("OES_texture_half_float_linear");default:return!0}}(t,i))),r}constructor(t,e){const{id:i=pn("texture"),handle:n,target:r}=e;super(t,{id:i,handle:n}),this.target=r,this.textureUnit=void 0,this.loaded=!1,this.width=void 0,this.height=void 0,this.depth=void 0,this.format=void 0,this.type=void 0,this.dataFormat=void 0,this.border=void 0,this.textureUnit=void 0,this.mipmaps=void 0}toString(){return"Texture(".concat(this.id,",").concat(this.width,"x").concat(this.height,")")}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.data;if(e instanceof Promise)return e.then(e=>this.initialize(Object.assign({},t,{pixels:e,data:e}))),this;const i="undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement;if(i&&e.readyStatethis.initialize(t)),this;const{pixels:n=null,format:r=6408,border:s=0,recreate:o=!1,parameters:a={},pixelStore:c={},textureUnit:l}=t;e||(e=n);let{width:h,height:u,dataFormat:d,type:f,compressed:p=!1,mipmaps:g=!0}=t;const{depth:m=0}=t;return({width:h,height:u,compressed:p,dataFormat:d,type:f}=this._deduceParameters({format:r,type:f,dataFormat:d,compressed:p,data:e,width:h,height:u})),this.width=h,this.height=u,this.depth=m,this.format=r,this.type=f,this.dataFormat=d,this.border=s,this.textureUnit=l,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),g&&this._isNPOT()&&(ri.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),g=!1,this._updateForNPOT(a)),this.mipmaps=g,this.setImageData({data:e,width:h,height:u,depth:m,format:r,type:f,dataFormat:d,border:s,mipmaps:g,parameters:c,compressed:p}),g&&this.generateMipmap(),this.setParameters(a),o&&(this.data=e),i&&(this._video={video:e,parameters:a,lastTime:e.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?e.currentTime:-1}),this}update(){if(this._video){const{video:t,parameters:e,lastTime:i}=this._video;if(i===t.currentTime||t.readyState0&&void 0!==arguments[0]?arguments[0]:{};return this._isNPOT()?(ri.warn("texture: ".concat(this," is Non-Power-Of-Two, disabling mipmaping"))(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Ui(this.gl,t,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this)}setImageData(t){this._trackDeallocatedMemory("Texture");const{target:e=this.target,pixels:i=null,level:n=0,format:r=this.format,border:s=this.border,offset:o=0,parameters:a={}}=t;let{data:c=null,type:l=this.type,width:h=this.width,height:u=this.height,dataFormat:d=this.dataFormat,compressed:f=!1}=t;c||(c=i),({type:l,dataFormat:d,compressed:f,width:h,height:u}=this._deduceParameters({format:r,type:l,dataFormat:d,compressed:f,data:c,width:h,height:u}));const{gl:p}=this;p.bindTexture(this.target,this.handle);let g,m=null;({data:c,dataType:m}=this._getDataType({data:c,compressed:f}));let v=0;if(Ui(this.gl,a,()=>{switch(m){case"null":p.texImage2D(e,n,r,h,u,s,d,l,c);break;case"typed-array":p.texImage2D(e,n,r,h,u,s,d,l,c,o);break;case"buffer":g=li(p),g.bindBuffer(35052,c.handle||c),g.texImage2D(e,n,r,h,u,s,d,l,o),g.bindBuffer(35052,null);break;case"browser-object":ai(p)?p.texImage2D(e,n,r,h,u,s,d,l,c):p.texImage2D(e,n,r,d,l,c);break;case"compressed":for(const[t,i]of c.entries())p.compressedTexImage2D(e,t,i.format,i.width,i.height,s,i.data),v+=i.levelSize;break;default:hn(!1,"Unknown image data type")}}),"compressed"===m)this._trackAllocatedMemory(v,"Texture");else if(c&&c.byteLength)this._trackAllocatedMemory(c.byteLength,"Texture");else{const t=In[this.dataFormat]||4,e=kn[this.type]||1;this._trackAllocatedMemory(this.width*this.height*t*e,"Texture")}return this.loaded=!0,this}setSubImageData(t){let{target:e=this.target,pixels:i=null,data:n=null,x:r=0,y:s=0,width:o=this.width,height:a=this.height,level:c=0,format:l=this.format,type:h=this.type,dataFormat:u=this.dataFormat,compressed:d=!1,offset:f=0,border:p=this.border,parameters:g={}}=t;if(({type:h,dataFormat:u,compressed:d,width:o,height:a}=this._deduceParameters({format:l,type:h,dataFormat:u,compressed:d,data:n,width:o,height:a})),hn(0===this.depth,"texSubImage not supported for 3D textures"),n||(n=i),n&&n.data){const t=n;n=t.data,o=t.shape[0],a=t.shape[1]}n instanceof Rn&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),Ui(this.gl,g,()=>{if(d)this.gl.compressedTexSubImage2D(e,c,r,s,o,a,l,n);else if(null===n)this.gl.texSubImage2D(e,c,r,s,o,a,u,h,null);else if(ArrayBuffer.isView(n))this.gl.texSubImage2D(e,c,r,s,o,a,u,h,n,f);else if(n instanceof Dn){const t=li(this.gl);t.bindBuffer(35052,n),t.texSubImage2D(e,c,r,s,o,a,u,h,f),t.bindBuffer(35052,null)}else if(ai(this.gl)){li(this.gl).texSubImage2D(e,c,r,s,o,a,u,h,n)}else this.gl.texSubImage2D(e,c,r,s,u,h,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(){return ri.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit;const{gl:e}=this;return void 0!==t&&(this.textureUnit=t,e.activeTexture(33984+t)),e.bindTexture(this.target,this.handle),t}unbind(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.textureUnit;const{gl:e}=this;return void 0!==t&&(this.textureUnit=t,e.activeTexture(33984+t)),e.bindTexture(this.target,null),t}_getDataType(t){let{data:e,compressed:i=!1}=t;return i?{data:e,dataType:"compressed"}:null===e?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof Rn?{data:e.handle,dataType:"buffer"}:e instanceof Dn?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(t){const{format:e,data:i}=t;let{width:n,height:r,dataFormat:s,type:o,compressed:a}=t;const c=On[e];return s=s||c&&c.dataFormat,o=o||c&&c.types[0],a=a||c&&c.compressed,({width:n,height:r}=this._deduceImageSize(i,n,r)),{dataFormat:s,type:o,compressed:a,width:n,height:r,format:e,data:i}}_deduceImageSize(t,e,i){let n;return n="undefined"!=typeof ImageData&&t instanceof ImageData?{width:t.width,height:t.height}:"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?{width:t.naturalWidth,height:t.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?{width:t.width,height:t.height}:"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:t?{width:e,height:i}:{width:e>=0?e:1,height:i>=0?i:1},hn(n,"Could not deduced texture size"),hn(void 0===e||n.width===e,"Deduced texture width does not match supplied width"),hn(void 0===i||n.height===i,"Deduced texture height does not match supplied height"),n}_createHandle(){return this.gl.createTexture()}_deleteHandle(){this.gl.deleteTexture(this.handle),this._trackDeallocatedMemory("Texture")}_getParameter(t){switch(t){case 4096:return this.width;case 4097:return this.height;default:this.gl.bindTexture(this.target,this.handle);const e=this.gl.getTexParameter(this.target,t);return this.gl.bindTexture(this.target,null),e}}_setParameter(t,e){switch(this.gl.bindTexture(this.target,this.handle),e=this._getNPOTParam(t,e),t){case 33082:case 33083:this.gl.texParameterf(this.handle,t,e);break;case 4096:case 4097:hn(!1);break;default:this.gl.texParameteri(this.target,t,e)}return this.gl.bindTexture(this.target,null),this}_isNPOT(){return!ai(this.gl)&&(!(!this.width||!this.height)&&(!gn(this.width)||!gn(this.height)))}_updateForNPOT(t){void 0===t[this.gl.TEXTURE_MIN_FILTER]&&(t[this.gl.TEXTURE_MIN_FILTER]=this.gl.LINEAR),void 0===t[this.gl.TEXTURE_WRAP_S]&&(t[this.gl.TEXTURE_WRAP_S]=this.gl.CLAMP_TO_EDGE),void 0===t[this.gl.TEXTURE_WRAP_T]&&(t[this.gl.TEXTURE_WRAP_T]=this.gl.CLAMP_TO_EDGE)}_getNPOTParam(t,e){if(this._isNPOT())switch(t){case 10241:-1===Fn.indexOf(e)&&(e=9729);break;case 10242:case 10243:33071!==e&&(e=33071)}return e}}let jn="";class Nn extends Bn{get[Symbol.toStringTag](){return"Texture2D"}static isSupported(t,e){return Bn.isSupported(t,e)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;ci(t),(e instanceof Promise||"string"==typeof e)&&(e={data:e}),"string"==typeof e.data&&(e=Object.assign({},e,{data:(i=e.data,hn("string"==typeof i),i=jn+i,new Promise((t,e)=>{try{const r=new Image;r.onload=()=>t(r),r.onerror=()=>e(new Error("Could not load image ".concat(i,"."))),r.crossOrigin=n&&n.crossOrigin||"anonymous",r.src=i}catch(t){e(t)}}))})),super(t,Object.assign({},e,{target:3553})),this.initialize(e),Object.seal(this)}}const Un="EXT_color_buffer_float";var zn={33189:{bpp:2},33190:{gl2:!0,bpp:3},36012:{gl2:!0,bpp:4},36168:{bpp:1},34041:{bpp:4},35056:{gl2:!0,bpp:4},36013:{gl2:!0,bpp:5},32854:{bpp:2},36194:{bpp:2},32855:{bpp:2},33321:{gl2:!0,bpp:1},33330:{gl2:!0,bpp:1},33329:{gl2:!0,bpp:1},33332:{gl2:!0,bpp:2},33331:{gl2:!0,bpp:2},33334:{gl2:!0,bpp:4},33333:{gl2:!0,bpp:4},33323:{gl2:!0,bpp:2},33336:{gl2:!0,bpp:2},33335:{gl2:!0,bpp:2},33338:{gl2:!0,bpp:4},33337:{gl2:!0,bpp:4},33340:{gl2:!0,bpp:8},33339:{gl2:!0,bpp:8},32849:{gl2:!0,bpp:3},32856:{gl2:!0,bpp:4},32857:{gl2:!0,bpp:4},36220:{gl2:!0,bpp:4},36238:{gl2:!0,bpp:4},36975:{gl2:!0,bpp:4},36214:{gl2:!0,bpp:8},36232:{gl2:!0,bpp:8},36226:{gl2:!0,bpp:16},36208:{gl2:!0,bpp:16},33325:{gl2:Un,bpp:2},33327:{gl2:Un,bpp:4},34842:{gl2:Un,bpp:8},33326:{gl2:Un,bpp:4},33328:{gl2:Un,bpp:8},34836:{gl2:Un,bpp:16},35898:{gl2:Un,bpp:4}};class Vn extends bn{get[Symbol.toStringTag](){return"Renderbuffer"}static isSupported(t){let{format:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{format:null};return!e||function(t,e,i){const n=i[e];if(!n)return!1;const r=ai(t)&&n.gl2||n.gl1;return"string"==typeof r?t.getExtension(r):r}(t,e,zn)}static getSamplesForFormat(t,e){let{format:i}=e;return t.getInternalformatParameter(36161,i,32937)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.initialize(e),Object.seal(this)}initialize(t){let{format:e,width:i=1,height:n=1,samples:r=0}=t;return hn(e,"Needs format"),this._trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),0!==r&&ai(this.gl)?this.gl.renderbufferStorageMultisample(36161,r,e,i,n):this.gl.renderbufferStorage(36161,e,i,n),this.format=e,this.width=i,this.height=n,this.samples=r,this._trackAllocatedMemory(this.width*this.height*(this.samples||1)*zn[this.format].bpp),this}resize(t){let{width:e,height:i}=t;return e!==this.width||i!==this.height?this.initialize({width:e,height:i,format:this.format,samples:this.samples}):this}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this._trackDeallocatedMemory()}_bindHandle(t){this.gl.bindRenderbuffer(36161,t)}_syncHandle(t){this.format=this.getParameter(36164),this.width=this.getParameter(36162),this.height=this.getParameter(36163),this.samples=this.getParameter(36011)}_getParameter(t){this.gl.bindRenderbuffer(36161,this.handle);return this.gl.getRenderbufferParameter(36161,t)}}const Gn=6144;function Wn(t){let{framebuffer:e=null,color:i=null,depth:n=null,stencil:r=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s={};e&&(s.framebuffer=e);let o=0;i&&(o|=16384,!0!==i&&(s.clearColor=i)),n&&(o|=256,!0!==n&&(s.clearDepth=n)),r&&(o|=1024,!0!==n&&(s.clearStencil=n)),hn(0!==o,"clear: bad arguments"),Ui(t,s,()=>{t.clear(o)})}function Hn(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return hn(!1),0}}const Xn=[34069,34070,34071,34072,34073,34074];class qn extends Bn{get[Symbol.toStringTag](){return"TextureCube"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ci(t),super(t,Object.assign({},e,{target:34067})),this.initialize(e),Object.seal(this)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{mipmaps:e=!0,parameters:i={}}=t;return this.opts=t,this.setCubeMapImageData(t).then(()=>{this.loaded=!0,e&&this.generateMipmap(t),this.setParameters(i)}),this}subImage(t){let{face:e,data:i,x:n=0,y:r=0,mipmapLevel:s=0}=t;return this._subImage({target:e,data:i,x:n,y:r,mipmapLevel:s})}async setCubeMapImageData(t){let{width:e,height:i,pixels:n,data:r,border:s=0,format:o=6408,type:a=5121}=t;const{gl:c}=this,l=n||r,h=await Promise.all(Xn.map(t=>{const e=l[t];return Promise.all(Array.isArray(e)?e:[e])}));this.bind(),Xn.forEach((t,n)=>{h[n].length>1&&!1!==this.opts.mipmaps&&ri.warn("".concat(this.id," has mipmap and multiple LODs."))(),h[n].forEach((n,r)=>{e&&i?c.texImage2D(t,r,o,e,i,s,o,a,n):c.texImage2D(t,r,o,o,a,n)})}),this.unbind()}setImageDataForFace(t){const{face:e,width:i,height:n,pixels:r,data:s,border:o=0,format:a=6408,type:c=5121}=t,{gl:l}=this,h=r||s;return this.bind(),h instanceof Promise?h.then(i=>this.setImageDataForFace(Object.assign({},t,{face:e,data:i,pixels:i}))):this.width||this.height?l.texImage2D(e,0,a,i,n,o,a,c,h):l.texImage2D(e,0,a,a,c,h),this}}qn.FACES=Xn;class Yn extends Bn{get[Symbol.toStringTag](){return"Texture3D"}static isSupported(t){return ai(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};li(t),e=Object.assign({depth:1},e,{target:32879,unpackFlipY:!1}),super(t,e),this.initialize(e),Object.seal(this)}setImageData(t){let{level:e=0,dataFormat:i=6408,width:n,height:r,depth:s=1,border:o=0,format:a,type:c=5121,offset:l=0,data:h,parameters:u={}}=t;if(this._trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle),Ui(this.gl,u,()=>{ArrayBuffer.isView(h)&&this.gl.texImage3D(this.target,e,i,n,r,s,o,a,c,h),h instanceof Rn&&(this.gl.bindBuffer(35052,h.handle),this.gl.texImage3D(this.target,e,i,n,r,s,o,a,c,l))}),h&&h.byteLength)this._trackAllocatedMemory(h.byteLength,"Texture");else{const t=In[this.dataFormat]||4,e=kn[this.type]||1;this._trackAllocatedMemory(this.width*this.height*this.depth*t*e,"Texture")}return this.loaded=!0,this}}function Zn(t,e){const{gl:i,width:n,height:r,id:s}=t;return new nr(i,Object.assign({},e,{id:"framebuffer-for-".concat(s),width:n,height:r,attachments:{36064:t}}))}function Kn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{sourceX:i=0,sourceY:n=0,sourceFormat:r=6408}=e;let{sourceAttachment:s=36064,target:o=null,sourceWidth:a,sourceHeight:c,sourceType:l}=e;const{framebuffer:h,deleteFramebuffer:u}=Jn(t);hn(h);const{gl:d,handle:f,attachments:p}=h;a=a||h.width,c=c||h.height,36064===s&&null===f&&(s=1028),hn(p[s]),l=l||p[s].type,o=$n(o,l,r,a,c),l=l||yn(o);const g=d.bindFramebuffer(36160,f);return d.readPixels(i,n,a,c,r,l,o),d.bindFramebuffer(36160,g||null),u&&h.delete(),o}function Qn(t){let{sourceAttachment:e=36064,targetMaxHeight:i=Number.MAX_SAFE_INTEGER}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Kn(t,{sourceAttachment:e}),{width:r,height:s}=t;for(;s>i;)({data:n,width:r,height:s}=En({data:n,width:r,height:s}));xn({data:n,width:r,height:s});const o=document.createElement("canvas");o.width=r,o.height=s;const a=o.getContext("2d"),c=a.createImageData(r,s);return c.data.set(n),a.putImageData(c,0,0),o.toDataURL()}function Jn(t){return t instanceof nr?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:Zn(t),deleteFramebuffer:!0}}function $n(t,e,i,n,r){if(t)return t;return new(wn(e=e||5121,{clamped:!1}))(n*r*Hn(i))}function tr(t,e){return er(t,e)}function er(t,e){return(e=Array.isArray(e)?e:[e]).every(e=>ir(t,e))}function ir(t,e){return t.luma=t.luma||{},t.luma.caps=t.luma.caps||{},void 0===t.luma.caps[e]&&(t.luma.caps[e]=function(t,e){const i=ur[e];let n;hn(i,e);const r=ai(t)&&i[1]||i[0];if("function"==typeof r)n=r(t);else if(Array.isArray(r)){n=!0;for(const e of r)n=n&&Boolean(t.getExtension(e))}else"string"==typeof r?n=Boolean(t.getExtension(r)):"boolean"==typeof r?n=r:hn(!1);return n}(t,e)),t.luma.caps[e]||ri.log(2,"Feature: ".concat(e," not supported"))(),t.luma.caps[e]}class nr extends bn{get[Symbol.toStringTag](){return"Framebuffer"}static isSupported(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{colorBufferFloat:i,colorBufferHalfFloat:n}=e;let r=!0;return i&&(r=Boolean(t.getExtension("EXT_color_buffer_float")||t.getExtension("WEBGL_color_buffer_float")||t.getExtension("OES_texture_float"))),n&&(r=r&&Boolean(t.getExtension("EXT_color_buffer_float")||t.getExtension("EXT_color_buffer_half_float"))),r}static getDefaultFramebuffer(t){return t.luma=t.luma||{},t.luma.defaultFramebuffer=t.luma.defaultFramebuffer||new nr(t,{id:"default-framebuffer",handle:null,attachments:{}}),t.luma.defaultFramebuffer}get MAX_COLOR_ATTACHMENTS(){const t=li(this.gl);return t.getParameter(t.MAX_COLOR_ATTACHMENTS)}get MAX_DRAW_BUFFERS(){const t=li(this.gl);return t.getParameter(t.MAX_DRAW_BUFFERS)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.width=null,this.height=null,this.attachments={},this.readBuffer=36064,this.drawBuffers=[36064],this.ownResources=[],this.initialize(e),Object.seal(this)}get color(){return this.attachments[36064]||null}get texture(){return this.attachments[36064]||null}get depth(){return this.attachments[36096]||this.attachments[33306]||null}get stencil(){return this.attachments[36128]||this.attachments[33306]||null}initialize(t){let{width:e=1,height:i=1,attachments:n=null,color:r=!0,depth:s=!0,stencil:o=!1,check:a=!0,readBuffer:c,drawBuffers:l}=t;if(hn(e>=0&&i>=0,"Width and height need to be integers"),this.width=e,this.height=i,n)for(const t in n){const r=n[t];(Array.isArray(r)?r[0]:r).resize({width:e,height:i})}else n=this._createDefaultAttachments(r,s,o,e,i);this.update({clearAttachments:!0,attachments:n,readBuffer:c,drawBuffers:l}),n&&a&&this.checkStatus()}delete(){for(const t of this.ownResources)t.delete();return super.delete(),this}update(t){let{attachments:e={},readBuffer:i,drawBuffers:n,clearAttachments:r=!1,resizeAttachments:s=!0}=t;this.attach(e,{clearAttachments:r,resizeAttachments:s});const{gl:o}=this,a=o.bindFramebuffer(36160,this.handle);return i&&this._setReadBuffer(i),n&&this._setDrawBuffers(n),o.bindFramebuffer(36160,a||null),this}resize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{width:e,height:i}=t;if(null===this.handle)return hn(void 0===e&&void 0===i),this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;void 0===e&&(e=this.gl.drawingBufferWidth),void 0===i&&(i=this.gl.drawingBufferHeight),e!==this.width&&i!==this.height&&ri.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(e,"x").concat(i))();for(const t in this.attachments)this.attachments[t].resize({width:e,height:i});return this.width=e,this.height=i,this}attach(t){let{clearAttachments:e=!1,resizeAttachments:i=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={};e&&Object.keys(this.attachments).forEach(t=>{n[t]=null}),Object.assign(n,t);const r=this.gl.bindFramebuffer(36160,this.handle);for(const t in n){hn(void 0!==t,"Misspelled framebuffer binding point?");const e=Number(t),r=n[e];let s=r;if(s)if(s instanceof Vn)this._attachRenderbuffer({attachment:e,renderbuffer:s});else if(Array.isArray(r)){const[t,i=0,n=0]=r;s=t,this._attachTexture({attachment:e,texture:t,layer:i,level:n})}else this._attachTexture({attachment:e,texture:s,layer:0,level:0});else this._unattach(e);i&&s&&s.resize({width:this.width,height:this.height})}this.gl.bindFramebuffer(36160,r||null),Object.assign(this.attachments,t),Object.keys(this.attachments).filter(t=>!this.attachments[t]).forEach(t=>{delete this.attachments[t]})}checkStatus(){const{gl:t}=this,e=this.getStatus();if(36053!==e)throw new Error(function(t){return(nr.STATUS||{})[t]||"Framebuffer error ".concat(t)}(e));return this}getStatus(){const{gl:t}=this,e=t.bindFramebuffer(36160,this.handle),i=t.checkFramebufferStatus(36160);return t.bindFramebuffer(36160,e||null),i}clear(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:e,depth:i,stencil:n,drawBuffers:r=[]}=t,s=this.gl.bindFramebuffer(36160,this.handle);return(e||i||n)&&Wn(this.gl,{color:e,depth:i,stencil:n}),r.forEach((t,e)=>{!function(t){let{framebuffer:e=null,buffer:i=Gn,drawBuffer:n=0,value:r=[0,0,0,0]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};li(t),Ui(t,{framebuffer:e},()=>{switch(i){case Gn:switch(r.constructor){case Int32Array:t.clearBufferiv(i,n,r);break;case Uint32Array:t.clearBufferuiv(i,n,r);break;case Float32Array:default:t.clearBufferfv(i,n,r)}break;case 6145:t.clearBufferfv(6145,0,[r]);break;case 6146:t.clearBufferiv(6146,0,[r]);break;case 34041:const[e,s]=r;t.clearBufferfi(34041,0,e,s);break;default:hn(!1,"clear: bad arguments")}})}(this.gl,{drawBuffer:e,value:t})}),this.gl.bindFramebuffer(36160,s||null),this}readPixels(){return ri.error("Framebuffer.readPixels() is no logner supported, use readPixelsToArray(framebuffer)")(),null}readPixelsToBuffer(){return ri.error("Framebuffer.readPixelsToBuffer()is no logner supported, use readPixelsToBuffer(framebuffer)")(),null}copyToDataUrl(){return ri.error("Framebuffer.copyToDataUrl() is no logner supported, use copyToDataUrl(framebuffer)")(),null}copyToImage(){return ri.error("Framebuffer.copyToImage() is no logner supported, use copyToImage(framebuffer)")(),null}copyToTexture(){return ri.error("Framebuffer.copyToTexture({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}blit(){return ri.error("Framebuffer.blit({...}) is no logner supported, use blit(source, target, opts)")(),null}invalidate(t){let{attachments:e=[],x:i=0,y:n=0,width:r,height:s}=t;const o=li(this.gl),a=o.bindFramebuffer(36008,this.handle);return 0===i&&0===n&&void 0===r&&void 0===s?o.invalidateFramebuffer(36008,e):o.invalidateFramebuffer(36008,e,i,n,r,s),o.bindFramebuffer(36008,a),this}getAttachmentParameter(t,e,i){let n=this._getAttachmentParameterFallback(e);return null===n&&(this.gl.bindFramebuffer(36160,this.handle),n=this.gl.getFramebufferAttachmentParameter(36160,t,e),this.gl.bindFramebuffer(36160,null)),i&&n>1e3&&(n=dn(this.gl,n)),n}getAttachmentParameters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36064,e=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.constructor.ATTACHMENT_PARAMETERS||[];const n={};for(const r of i){n[e?dn(this.gl,r):r]=this.getAttachmentParameter(t,r,e)}return n}getParameters(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=Object.keys(this.attachments),i={};for(const n of e){const e=Number(n);i[t?dn(this.gl,e):e]=this.getAttachmentParameters(e,t)}return i}show(){return"undefined"!=typeof window&&window.open(Qn(this),"luma-debug-texture"),this}log(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t>ri.level||"undefined"==typeof window)return this;e=e||"Framebuffer ".concat(this.id);const i=Qn(this,{targetMaxHeight:100});return ri.image({logLevel:t,message:e,image:i},e)(),this}bind(){let{target:t=36160}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.gl.bindFramebuffer(t,this.handle),this}unbind(){let{target:t=36160}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.gl.bindFramebuffer(t,null),this}_createDefaultAttachments(t,e,i,n,r){let s=null;return t&&(s=s||{},s[36064]=new Nn(this.gl,{id:"".concat(this.id,"-color0"),pixels:null,format:6408,type:5121,width:n,height:r,mipmaps:!1,parameters:{10241:9729,10240:9729,10242:33071,10243:33071}}),this.ownResources.push(s[36064])),e&&i?(s=s||{},s[33306]=new Vn(this.gl,{id:"".concat(this.id,"-depth-stencil"),format:35056,width:n,height:111}),this.ownResources.push(s[33306])):e?(s=s||{},s[36096]=new Vn(this.gl,{id:"".concat(this.id,"-depth"),format:33189,width:n,height:r}),this.ownResources.push(s[36096])):i&&hn(!1),s}_unattach(t){const e=this.attachments[t];e&&(e instanceof Vn?this.gl.framebufferRenderbuffer(36160,t,36161,null):this.gl.framebufferTexture2D(36160,t,3553,null,0),delete this.attachments[t])}_attachRenderbuffer(t){let{attachment:e=36064,renderbuffer:i}=t;const{gl:n}=this;n.framebufferRenderbuffer(36160,e,36161,i.handle),this.attachments[e]=i}_attachTexture(t){let{attachment:e=36064,texture:i,layer:n,level:r}=t;const{gl:s}=this;switch(s.bindTexture(i.target,i.handle),i.target){case 35866:case 32879:li(s).framebufferTextureLayer(36160,e,i.target,r,n);break;case 34067:const t=function(t){return t<34069?t+34069:t}(n);s.framebufferTexture2D(36160,e,t,i.handle,r);break;case 3553:s.framebufferTexture2D(36160,e,3553,i.handle,r);break;default:hn(!1,"Illegal texture type")}s.bindTexture(i.target,null),this.attachments[e]=i}_setReadBuffer(t){const e=ai(i=this.gl)?i:null;var i;e?e.readBuffer(t):hn(36064===t||1029===t,"Multiple render targets not supported"),this.readBuffer=t}_setDrawBuffers(t){const{gl:e}=this,i=li(e);if(i)i.drawBuffers(t);else{const i=e.getExtension("WEBGL_draw_buffers");i?i.drawBuffersWEBGL(t):hn(1===t.length&&(36064===t[0]||1029===t[0]),"Multiple render targets not supported")}this.drawBuffers=t}_getAttachmentParameterFallback(t){const e=function(t){t.luma=t.luma||{},t.luma.caps=t.luma.caps||{};for(const e in ur)void 0===t.luma.caps[e]&&(t.luma.caps[e]=ir(t,e));return t.luma.caps}(this.gl);switch(t){case 36052:return e.WEBGL2?null:0;case 33298:case 33299:case 33300:case 33301:case 33302:case 33303:return e.WEBGL2?null:8;case 33297:return e.WEBGL2?null:5125;case 33296:return e.WEBGL2||e.EXT_sRGB?null:9729;default:return null}}_createHandle(){return this.gl.createFramebuffer()}_deleteHandle(){this.gl.deleteFramebuffer(this.handle)}_bindHandle(t){return this.gl.bindFramebuffer(36160,t)}}nr.ATTACHMENT_PARAMETERS=[36049,36048,33296,33298,33299,33300,33301,33302,33303];const rr="TIMER_QUERY",sr="ELEMENT_INDEX_UINT32",or="BLEND_EQUATION_MINMAX",ar="FLOAT_BLEND",cr="TEXTURE_FLOAT",lr="COLOR_ATTACHMENT_RGBA32F",hr="GLSL_DERIVATIVES";var ur={["WEBGL2"]:[!1,!0],["VERTEX_ARRAY_OBJECT"]:["OES_vertex_array_object",!0],[rr]:["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"],["INSTANCED_RENDERING"]:["ANGLE_instanced_arrays",!0],["MULTIPLE_RENDER_TARGETS"]:["WEBGL_draw_buffers",!0],[sr]:["OES_element_index_uint",!0],[or]:["EXT_blend_minmax",!0],[ar]:["EXT_float_blend"],["COLOR_ENCODING_SRGB"]:["EXT_sRGB",!0],["TEXTURE_DEPTH"]:["WEBGL_depth_texture",!0],[cr]:["OES_texture_float",!0],["TEXTURE_HALF_FLOAT"]:["OES_texture_half_float",!0],["TEXTURE_FILTER_LINEAR_FLOAT"]:["OES_texture_float_linear"],["TEXTURE_FILTER_LINEAR_HALF_FLOAT"]:["OES_texture_half_float_linear"],["TEXTURE_FILTER_ANISOTROPIC"]:["EXT_texture_filter_anisotropic"],[lr]:[function(t){const e=new Nn(t,{format:6408,type:5126,dataFormat:6408}),i=new nr(t,{id:"test-framebuffer",check:!1,attachments:{36064:e}}),n=i.getStatus();return e.delete(),i.delete(),36053===n},"EXT_color_buffer_float"],["COLOR_ATTACHMENT_FLOAT"]:[!1,"EXT_color_buffer_float"],["COLOR_ATTACHMENT_HALF_FLOAT"]:["EXT_color_buffer_half_float"],["GLSL_FRAG_DATA"]:["WEBGL_draw_buffers",!0],["GLSL_FRAG_DEPTH"]:["EXT_frag_depth",!0],[hr]:["OES_standard_derivatives",!0],["GLSL_TEXTURE_LOD"]:["EXT_shader_texture_lod",!0]};function dr(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}const fr="void main() {gl_FragColor = vec4(0);}",pr="out vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}",gr="#version 300 es\n".concat(pr);function mr(t,e){e=Array.isArray(e)?e:[e];const i=t.replace(/^\s+/,"").split(/\s+/),[n,r,s]=i;if(!e.includes(n)||!r||!s)return null;return{qualifier:n,type:r,name:s.split(";")[0]}}function vr(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{version:e=100,input:i,inputType:n,output:r}=t;if(!i)return 300===e?gr:e>300?"#version ".concat(e,"\n").concat(pr):fr;const s=_r(i,n);return e>=300?"#version ".concat(e," ").concat(300===e?"es":"","\nin ").concat(n," ").concat(i,";\nout vec4 ").concat(r,";\nvoid main() {\n ").concat(r," = ").concat(s,";\n}"):"varying ".concat(n," ").concat(i,";\nvoid main() {\n gl_FragColor = ").concat(s,";\n}")}function _r(t,e){switch(e){case"float":return"vec4(".concat(t,", 0.0, 0.0, 1.0)");case"vec2":return"vec4(".concat(t,", 0.0, 1.0)");case"vec3":return"vec4(".concat(t,", 1.0)");case"vec4":return t;default:return dr(!1),null}}class br extends bn{get[Symbol.toStringTag](){return"TransformFeedback"}static isSupported(t){return ai(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};li(t),super(t,e),this.initialize(e),this.stubRemovedMethods("TransformFeedback","v6.0",["pause","resume"]),Object.seal(this)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.buffers={},this.unused={},this.configuration=null,this.bindOnUse=!0,mn(this.buffers)||this.bind(()=>this._unbindBuffers()),this.setProps(t),this}setProps(t){"program"in t&&(this.configuration=t.program&&t.program.configuration),"configuration"in t&&(this.configuration=t.configuration),"bindOnUse"in t&&(t=t.bindOnUse),"buffers"in t&&this.setBuffers(t.buffers)}setBuffers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.bind(()=>{for(const e in t)this.setBuffer(e,t[e])}),this}setBuffer(t,e){const i=this._getVaryingIndex(t),{buffer:n,byteSize:r,byteOffset:s}=this._getBufferParams(e);return i<0?(this.unused[t]=n,ri.warn("".concat(this.id," unused varying buffer ").concat(t))(),this):(this.buffers[i]=e,this.bindOnUse||this._bindBuffer(i,n,s,r),this)}begin(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.gl.bindTransformFeedback(36386,this.handle),this._bindBuffers(),this.gl.beginTransformFeedback(t),this}end(){return this.gl.endTransformFeedback(),this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null),this}_getBufferParams(t){let e,i,n;return t instanceof Rn==!1?(n=t.buffer,i=t.byteSize,e=t.byteOffset):n=t,void 0===e&&void 0===i||(e=e||0,i=i||n.byteLength-e),{buffer:n,byteOffset:e,byteSize:i}}_getVaryingInfo(t){return this.configuration&&this.configuration.getVaryingInfo(t)}_getVaryingIndex(t){if(this.configuration)return this.configuration.getVaryingInfo(t).location;const e=Number(t);return Number.isFinite(e)?e:-1}_bindBuffers(){if(this.bindOnUse)for(const t in this.buffers){const{buffer:e,byteSize:i,byteOffset:n}=this._getBufferParams(this.buffers[t]);this._bindBuffer(t,e,n,i)}}_unbindBuffers(){if(this.bindOnUse)for(const t in this.buffers)this._bindBuffer(t,null)}_bindBuffer(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3?arguments[3]:void 0;const r=e&&e.handle;return r&&void 0!==n?this.gl.bindBufferRange(35982,t,r,i,n):this.gl.bindBufferBase(35982,t,r),this}_createHandle(){return this.gl.createTransformFeedback()}_deleteHandle(){this.gl.deleteTransformFeedback(this.handle)}_bindHandle(t){this.gl.bindTransformFeedback(36386,this.handle)}}class yr{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.currentIndex=0,this.feedbackMap={},this.varyings=null,this.bindings=[],this.resources={},this._initialize(e),Object.seal(this)}setupResources(t){for(const e of this.bindings)this._setupTransformFeedback(e,t)}updateModelProps(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{varyings:e}=this;return e.length>0&&(t=Object.assign({},t,{varyings:e})),t}getDrawOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this.bindings[this.currentIndex],{sourceBuffers:i,transformFeedback:n}=e;return{attributes:Object.assign({},i,t.attributes),transformFeedback:n}}swap(){return!!this.feedbackMap&&(this.currentIndex=this._getNextIndex(),!0)}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(t)}getBuffer(t){const{feedbackBuffers:e}=this.bindings[this.currentIndex],i=t?e[t]:null;return i?i instanceof Rn?i:i.buffer:null}getData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{varyingName:e}=t,i=this.getBuffer(e);return i?i.getData():null}delete(){for(const t in this.resources)this.resources[t].delete()}_initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupBuffers(t),this.varyings=t.varyings||Object.keys(this.bindings[this.currentIndex].feedbackBuffers),this.varyings.length>0&&hn(ai(this.gl))}_getFeedbackBuffers(t){const{sourceBuffers:e={}}=t,i={};if(this.bindings[this.currentIndex]&&Object.assign(i,this.bindings[this.currentIndex].feedbackBuffers),this.feedbackMap)for(const t in this.feedbackMap){const n=this.feedbackMap[t];t in e&&(i[n]=t)}Object.assign(i,t.feedbackBuffers);for(const t in i){const n=i[t];if("string"==typeof n){const r=e[n],{byteLength:s,usage:o,accessor:a}=r;i[t]=this._createNewBuffer(t,{byteLength:s,usage:o,accessor:a})}}return i}_setupBuffers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:e=null}=t;Object.assign(this.feedbackMap,t.feedbackMap);const i=this._getFeedbackBuffers(t);this._updateBindings({sourceBuffers:e,feedbackBuffers:i})}_setupTransformFeedback(t,e){let{model:i}=e;const{program:n}=i;t.transformFeedback=new br(this.gl,{program:n,buffers:t.feedbackBuffers})}_updateBindings(t){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t),this.feedbackMap){const{sourceBuffers:t,feedbackBuffers:e}=this._swapBuffers(this.bindings[this.currentIndex]),i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceBuffers:t,feedbackBuffers:e})}}_updateBinding(t,e){return t?(Object.assign(t.sourceBuffers,e.sourceBuffers),Object.assign(t.feedbackBuffers,e.feedbackBuffers),t.transformFeedback&&t.transformFeedback.setBuffers(t.feedbackBuffers),t):{sourceBuffers:Object.assign({},e.sourceBuffers),feedbackBuffers:Object.assign({},e.feedbackBuffers)}}_swapBuffers(t){if(!this.feedbackMap)return null;const e=Object.assign({},t.sourceBuffers),i=Object.assign({},t.feedbackBuffers);for(const n in this.feedbackMap){const r=this.feedbackMap[n];e[n]=t.feedbackBuffers[r],i[r]=t.sourceBuffers[n],hn(i[r]instanceof Rn)}return{sourceBuffers:e,feedbackBuffers:i}}_createNewBuffer(t,e){const i=new Rn(this.gl,e);return this.resources[t]&&this.resources[t].delete(),this.resources[t]=i,i}_getNextIndex(){return(this.currentIndex+1)%2}}function wr(t){let e=100;const i=t.match(/[^\s]+/g);if(i.length>=2&&"#version"===i[0]){const t=parseInt(i[1],10);Number.isFinite(t)&&(e=t)}return e}const xr={vs:"#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n",fs:"#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"},Er=/void\s+main\s*\([^)]*\)\s*\{\n?/,Tr=/}\n?[^{}]*$/,Ar=[];function Pr(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r="vs"===e;for(const e in i){const n=i[e];n.sort((t,e)=>t.order-e.order),Ar.length=n.length;for(let t=0,e=n.length;tt+s));break;case"vs:#main-end":r&&(t=t.replace(Tr,t=>s+t));break;case"fs:#decl":r||(t=t.replace("__LUMA_INJECT_DECLARATIONS__",s));break;case"fs:#main-start":r||(t=t.replace(Er,t=>t+s));break;case"fs:#main-end":r||(t=t.replace(Tr,t=>s+t));break;default:t=t.replace(e,t=>t+s)}}return t=t.replace("__LUMA_INJECT_DECLARATIONS__",""),n&&(t=t.replace(/\}\s*$/,t=>t+xr[e])),t}function Sr(t){const e={};return dr(Array.isArray(t)&&t.length>1),t.forEach(t=>{for(const i in t)e[i]=e[i]?"".concat(e[i],"\n").concat(t[i]):t[i]}),e}const Mr={name:"transform",vs:"attribute float transform_elementID;\nvec2 transform_getPixelSizeHalf(vec2 size) {\n return vec2(1.) / (2. * size);\n}\n\nvec2 transform_getPixelIndices(vec2 texSize, vec2 pixelSizeHalf) {\n float yIndex = floor((transform_elementID / texSize[0]) + pixelSizeHalf[1]);\n float xIndex = transform_elementID - (yIndex * texSize[0]);\n return vec2(xIndex, yIndex);\n}\nvec2 transform_getTexCoord(vec2 size) {\n vec2 pixelSizeHalf = transform_getPixelSizeHalf(size);\n vec2 indices = transform_getPixelIndices(size, pixelSizeHalf);\n vec2 coord = indices / size + pixelSizeHalf;\n return coord;\n}\nvec2 transform_getPos(vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n vec2 pos = (texCoord * (2.0, 2.0)) - (1., 1.);\n return pos;\n}\nvec4 transform_getInput(sampler2D texSampler, vec2 size) {\n vec2 texCoord = transform_getTexCoord(size);\n vec4 textureColor = texture2D(texSampler, texCoord);\n return textureColor;\n}\n",fs:null};function Cr(t){let{vs:e,sourceTextureMap:i,targetTextureVarying:n,targetTexture:r}=t;let s=Object.keys(i).length,o=null;const a={};let c=e,l={};if(s>0||n){const t=c.split("\n"),e=t.slice();if(t.forEach((t,r,c)=>{if(s>0){const n=function(t,e){const i={},n=function(t){return mr(t,["attribute","in"])}(t);if(!n)return null;const{type:r,name:s}=n;if(s&&e[s]){const e="// ".concat(t," => Replaced by Transform with a sampler"),{samplerName:n,sizeName:o,uniformDeclerations:a}=function(t){const e="".concat("transform_uSampler_").concat(t),i="".concat("transform_uSize_").concat(t),n=" uniform sampler2D ".concat(e,";\n uniform vec2 ").concat(i,";");return{samplerName:e,sizeName:i,uniformDeclerations:n}}(s),c=function(t){switch(t){case"float":return"x";case"vec2":return"xy";case"vec3":return"xyz";case"vec4":return"xyzw";default:return dr(!1),null}}(r),l=" ".concat(r," ").concat(s," = transform_getInput(").concat(n,", ").concat(o,").").concat(c,";\n");i[n]=s;return{updatedLine:e,inject:{"vs:#decl":a,"vs:#main-start":l},samplerTextureMap:i}}return null}(t,i);if(n){const{updatedLine:t,inject:i}=n;e[r]=t,l=Sr([l,i]),Object.assign(a,n.samplerTextureMap),s--}}n&&!o&&(o=function(t,e){const i=mr(t,["varying","out"]);if(!i)return null;return i.name===e?i.type:null}(t,n))}),n){hn(r);const t="".concat("transform_uSize_").concat(n),e="uniform vec2 ".concat(t,";\n"),i=" vec2 ".concat("transform_position"," = transform_getPos(").concat(t,");\n gl_Position = vec4(").concat("transform_position",", 0, 1.);\n");l=Sr([l,{"vs:#decl":e,"vs:#main-start":i}])}c=e.join("\n")}return{vs:c,targetTextureType:o,inject:l,samplerTextureMap:a}}const Lr={10241:9728,10240:9728,10242:33071,10243:33071};class Rr{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.id=this.currentIndex=0,this._swapTexture=null,this.targetTextureVarying=null,this.targetTextureType=null,this.samplerTextureMap=null,this.bindings=[],this.resources={},this._initialize(e),Object.seal(this)}updateModelProps(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this._processVertexShader(t);return Object.assign({},t,e)}getDrawOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:e,sourceTextures:i,framebuffer:n,targetTexture:r}=this.bindings[this.currentIndex],s=Object.assign({},e,t.attributes),o=Object.assign({},t.uniforms),a=Object.assign({},t.parameters);let c=t.discard;if(this.hasSourceTextures||this.hasTargetTexture){s.transform_elementID=this.elementIDBuffer;for(const t in this.samplerTextureMap){const e=this.samplerTextureMap[t];o[t]=i[e]}this._setSourceTextureParameters();const t=function(t){let{sourceTextureMap:e,targetTextureVarying:i,targetTexture:n}=t;const r={};let s,o;i&&(({width:s,height:o}=n),r["".concat("transform_uSize_").concat(i)]=[s,o]);for(const t in e)({width:s,height:o}=e[t]),r["".concat("transform_uSize_").concat(t)]=[s,o];return r}({sourceTextureMap:i,targetTextureVarying:this.targetTextureVarying,targetTexture:r});Object.assign(o,t)}return this.hasTargetTexture&&(c=!1,a.viewport=[0,0,n.width,n.height]),{attributes:s,framebuffer:n,uniforms:o,discard:c,parameters:a}}swap(){return!!this._swapTexture&&(this.currentIndex=this._getNextIndex(),!0)}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setupTextures(t)}getTargetTexture(){const{targetTexture:t}=this.bindings[this.currentIndex];return t}getData(){let{packed:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{framebuffer:e}=this.bindings[this.currentIndex],i=Kn(e);if(!t)return i;const n=i.constructor,r=function(t){switch(t){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;default:return dr(!1),null}}(this.targetTextureType),s=new n(i.length*r/4);let o=0;for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:{};const{_targetTextureVarying:e,_swapTexture:i}=t;this._swapTexture=i,this.targetTextureVarying=e,this.hasTargetTexture=e,this._setupTextures(t)}_createTargetTexture(t){const{sourceTextures:e,textureOrReference:i}=t;if(i instanceof Nn)return i;const n=e[i];return n?(this._targetRefTexName=i,this._createNewTexture(n)):null}_setupTextures(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceBuffers:e,_sourceTextures:i={},_targetTexture:n}=t,r=this._createTargetTexture({sourceTextures:i,textureOrReference:n});this.hasSourceTextures=this.hasSourceTextures||i&&Object.keys(i).length>0,this._updateBindings({sourceBuffers:e,sourceTextures:i,targetTexture:r}),"elementCount"in t&&this._updateElementIDBuffer(t.elementCount)}_updateElementIDBuffer(t){if("number"!=typeof t||this.elementCount>=t)return;const e=new Float32Array(t);e.forEach((t,e,i)=>{i[e]=e}),this.elementIDBuffer?this.elementIDBuffer.setData({data:e}):this.elementIDBuffer=new Rn(this.gl,{data:e,accessor:{size:1}}),this.elementCount=t}_updateBindings(t){if(this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t),this._swapTexture){const{sourceTextures:t,targetTexture:e}=this._swapTextures(this.bindings[this.currentIndex]),i=this._getNextIndex();this.bindings[i]=this._updateBinding(this.bindings[i],{sourceTextures:t,targetTexture:e})}}_updateBinding(t,e){const{sourceBuffers:i,sourceTextures:n,targetTexture:r}=e;if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,n),Object.assign(t.sourceBuffers,i),r){t.targetTexture=r;const{width:e,height:i}=r,{framebuffer:n}=t;n?(n.update({attachments:{36064:r},resizeAttachments:!1}),n.resize({width:e,height:i})):t.framebuffer=new nr(this.gl,{id:"transform-framebuffer",width:e,height:i,attachments:{36064:r}})}return t}_setSourceTextureParameters(){const t=this.currentIndex,{sourceTextures:e}=this.bindings[t];for(const t in e)e[t].setParameters(Lr)}_swapTextures(t){if(!this._swapTexture)return null;const e=Object.assign({},t.sourceTextures);e[this._swapTexture]=t.targetTexture;return{sourceTextures:e,targetTexture:t.sourceTextures[this._swapTexture]}}_createNewTexture(t){const e=function(t,e){hn(t instanceof Nn||t instanceof qn||t instanceof Yn);const i=t.constructor,{gl:n,width:r,height:s,format:o,type:a,dataFormat:c,border:l,mipmaps:h}=t;return new i(n,Object.assign({width:r,height:s,format:o,type:a,dataFormat:c,border:l,mipmaps:h},e))}(t,{parameters:{10241:9728,10240:9728,10242:33071,10243:33071},pixelStore:{37440:!1}});return this.ownTexture&&this.ownTexture.delete(),this.ownTexture=e,e}_getNextIndex(){return(this.currentIndex+1)%2}_processVertexShader(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sourceTextures:e,targetTexture:i}=this.bindings[this.currentIndex],{vs:n,uniforms:r,targetTextureType:s,inject:o,samplerTextureMap:a}=Cr({vs:t.vs,sourceTextureMap:e,targetTextureVarying:this.targetTextureVarying,targetTexture:i}),c=Sr([t.inject||{},o]);this.targetTextureType=s,this.samplerTextureMap=a;return{vs:n,fs:t._fs||vr({version:wr(n),input:this.targetTextureVarying,inputType:s,output:"transform_output"}),modules:this.hasSourceTextures||this.targetTextureVarying?[Mr].concat(t.modules||[]):t.modules,uniforms:r,inject:c}}}const Or={number:{validate:(t,e)=>Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)},array:{validate:(t,e)=>Array.isArray(t)||ArrayBuffer.isView(t)}};function Ir(t){let e=kr(t);return"object"===e?t?"type"in t?Object.assign({},t,Or[t.type]):"value"in t?(e=kr(t.value),Object.assign({type:e},t,Or[e])):{type:"object",value:t}:{type:"object",value:null}:Object.assign({type:e,value:t},Or[e])}function kr(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}class Fr{constructor(t){let{name:e,vs:i,fs:n,dependencies:r=[],uniforms:s,getUniforms:o,deprecations:a=[],defines:c={},inject:l={},vertexShader:h,fragmentShader:u}=t;dr("string"==typeof e),this.name=e,this.vs=i||h,this.fs=n||u,this.getModuleUniforms=o,this.dependencies=r,this.deprecations=this._parseDeprecationDefinitions(a),this.defines=c,this.injections=function(t){const e={vs:{},fs:{}};for(const i in t){let n=t[i];const r=i.slice(0,2);"string"==typeof n&&(n={order:0,injection:n}),e[r][i]=n}return e}(l),s&&(this.uniforms=function(t){const e={};for(const i in t){const n=Ir(t[i]);e[i]=n}return e}(s))}getModuleSource(t){let e;switch(t){case"vs":e=this.vs||"";break;case"fs":e=this.fs||"";break;default:dr(!1)}return"#define MODULE_".concat(this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),"\n").concat(e,"// END MODULE_").concat(this.name,"\n\n")}getUniforms(t,e){return this.getModuleUniforms?this.getModuleUniforms(t,e):this.uniforms?this._defaultGetUniforms(t):{}}getDefines(){return this.defines}checkDeprecations(t,e){this.deprecations.forEach(i=>{i.regex.test(t)&&(i.deprecated?e.deprecated(i.old,i.new)():e.removed(i.old,i.new)())})}_parseDeprecationDefinitions(t){return t.forEach(t=>{switch(t.type){case"function":t.regex=new RegExp("\\b".concat(t.old,"\\("));break;default:t.regex=new RegExp("".concat(t.type," ").concat(t.old,";"))}}),t}_defaultGetUniforms(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={},i=this.uniforms;for(const n in i){const r=i[n];n in t&&!r.private?(r.validate&&dr(r.validate(t[n],r),"".concat(this.name,": invalid ").concat(n)),e[n]=t[n]):e[n]=r.value}return e}}function Dr(t){return Br(function t(e,i){return e.map(e=>(e instanceof Fr||(dr("string"!=typeof e,"Shader module use by name is deprecated. Import shader module '".concat(e,"' and use it directly.")),dr(e.name,"shader module has no name"),(e=new Fr(e)).dependencies=t(e.dependencies)),e))}(t))}function Br(t){const e={},i={};return jr({modules:t,level:0,moduleMap:e,moduleDepth:i}),Object.keys(i).sort((t,e)=>i[e]-i[t]).map(t=>e[t])}function jr(t){let{modules:e,level:i,moduleMap:n,moduleDepth:r}=t;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const t of e)n[t.name]=t,(void 0===r[t.name]||r[t.name]0&&void 0!==arguments[0]?arguments[0]:{};const e="undefined"!=typeof window&&window.navigator||{},i=t.userAgent||e.userAgent||"",n=-1!==i.indexOf("MSIE "),r=-1!==i.indexOf("Trident/");return n||r}const Ur={GLSL_FRAG_DATA:["WEBGL_draw_buffers",!0],GLSL_FRAG_DEPTH:["EXT_frag_depth",!0],GLSL_DERIVATIVES:["OES_standard_derivatives",!0],GLSL_TEXTURE_LOD:["EXT_shader_texture_lod",!0]},zr={};Object.keys(Ur).forEach(t=>{zr[t]=t});const Vr={};function Gr(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=Ur[e];if(dr(n,e),!Nr(i))return!0;if(e in Vr)return Vr[e];const r=n[0],s=i.behavior||"enable",o="#extension GL_".concat(r," : ").concat(s,"\nvoid main(void) {}"),a=t.createShader(35633);t.shaderSource(a,o),t.compileShader(a);const c=t.getShaderParameter(a,35713);return t.deleteShader(a),Vr[e]=c,c}function Wr(t,e){const i=Ur[e];dr(i,e);const n=function(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||Boolean(t&&2===t._version)}(t)&&i[1]||i[0],r="string"==typeof n?Boolean(t.getExtension(n)):n;return dr(!1===r||!0===r),r}function Hr(t,e){return(e=Array.isArray(e)?e:[e]).every(e=>Wr(t,e))}function Xr(t){return new RegExp("\\b".concat(t,"[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)"),"g")}const qr=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Yr=[...qr,[Xr("attribute"),"in $1"],[Xr("varying"),"out $1"]],Zr=[...qr,[Xr("varying"),"in $1"]],Kr=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],Qr=[...Kr,[Xr("in"),"attribute $1"],[Xr("out"),"varying $1"]],Jr=[...Kr,[Xr("in"),"varying $1"]],$r=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,ts=/void\s+main\s*\([^)]*\)\s*\{\n?/;function es(t,e,i){switch(e){case 300:return i?is(t,Yr):function(t){const e=(t=is(t,Zr)).match($r);if(e){const i=e[1];t=t.replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),i)}else{const e="fragmentColor";t=t.replace(ts,t=>"out vec4 ".concat(e,";\n").concat(t)).replace(new RegExp("\\b".concat("gl_FragColor","\\b"),"g"),e)}return t}(t);case 100:return i?is(t,Qr):function(t){const e=(t=is(t,Jr)).match($r);if(e){const i=e[1];t=t.replace($r,"").replace(new RegExp("\\b".concat(i,"\\b"),"g"),"gl_FragColor")}return t}(t);default:throw new Error("unknown GLSL version ".concat(e))}}function is(t,e){for(const[i,n]of e)t=t.replace(i,n);return t}const ns="\n\n".concat("__LUMA_INJECT_DECLARATIONS__","\n\n"),rs={vs:"vertex",fs:"fragment"};function ss(t,e){let{id:i,source:n,type:r,modules:s,defines:o={},hookFunctions:a=[],inject:c={},transpileToGLSL100:l=!1,prologue:h=!0,log:u}=e;dr("string"==typeof n,"shader source must be a string");const d="vs"===r,f=n.split("\n");let p=100,g="",m=n;0===f[0].indexOf("#version ")?(p=300,g=f[0],m=f.slice(1).join("\n")):g="#version ".concat(p);const v={};s.forEach(t=>{Object.assign(v,t.getDefines())}),Object.assign(v,o);let _=h?"".concat(g,"\n").concat(function(t){let{id:e,source:i,type:n}=t;return e&&"string"==typeof e&&-1===i.indexOf("SHADER_NAME")?"\n#define SHADER_NAME ".concat(e,"_").concat(rs[n],"\n\n"):""}({id:i,source:n,type:r}),"\n").concat(function(t){let{type:e}=t;return"\n#define SHADER_TYPE_".concat(rs[e].toUpperCase(),"\n")}({type:r}),"\n").concat(function(t){switch(function(t){const e=t.getExtension("WEBGL_debug_renderer_info"),i=t.getParameter(e&&e.UNMASKED_VENDOR_WEBGL||7936),n=t.getParameter(e&&e.UNMASKED_RENDERER_WEBGL||7937);return{gpuVendor:function(t,e){if(t.match(/NVIDIA/i)||e.match(/NVIDIA/i))return"NVIDIA";if(t.match(/INTEL/i)||e.match(/INTEL/i))return"INTEL";if(t.match(/AMD/i)||e.match(/AMD/i)||t.match(/ATI/i)||e.match(/ATI/i))return"AMD";return"UNKNOWN GPU"}(i,n),vendor:i,renderer:n,version:t.getParameter(7938),shadingLanguageVersion:t.getParameter(35724)}}(t).gpuVendor.toLowerCase()){case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(t),"\n").concat(function(t,e,i){let n="#if (__VERSION__ > 120)\n\n# define FEATURE_GLSL_DERIVATIVES\n# define FEATURE_GLSL_DRAW_BUFFERS\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FEATURE_GLSL_TEXTURE_LOD\n\n// DEPRECATED FLAGS, remove in v9\n# define FRAG_DEPTH\n# define DERIVATIVES\n# define DRAW_BUFFERS\n# define TEXTURE_LOD\n\n#endif // __VERSION\n";return Hr(t,zr.GLSL_FRAG_DEPTH)&&(n+="\n// FRAG_DEPTH => gl_FragDepth is available\n#ifdef GL_EXT_frag_depth\n#extension GL_EXT_frag_depth : enable\n# define FEATURE_GLSL_FRAG_DEPTH\n# define FRAG_DEPTH\n# define gl_FragDepth gl_FragDepthEXT\n#endif\n"),Hr(t,zr.GLSL_DERIVATIVES)&&Gr(t,zr.GLSL_DERIVATIVES)&&(n+="\n// DERIVATIVES => dxdF, dxdY and fwidth are available\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n# define FEATURE_GLSL_DERIVATIVES\n# define DERIVATIVES\n#endif\n"),Hr(t,zr.GLSL_FRAG_DATA)&&Gr(t,zr.GLSL_FRAG_DATA,{behavior:"require"})&&(n+="\n// DRAW_BUFFERS => gl_FragData[] is available\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers : require\n#define FEATURE_GLSL_DRAW_BUFFERS\n#define DRAW_BUFFERS\n#endif\n"),Hr(t,zr.GLSL_TEXTURE_LOD)&&(n+="// TEXTURE_LOD => texture2DLod etc are available\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod : enable\n\n# define FEATURE_GLSL_TEXTURE_LOD\n# define TEXTURE_LOD\n\n#endif\n"),n}(t),"\n").concat(function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=0,i="";for(const n in t){0===e&&(i+="\n// APPLICATION DEFINES\n"),e++;const r=t[n];(r||Number.isFinite(r))&&(i+="#define ".concat(n.toUpperCase()," ").concat(t[n],"\n"))}0===e&&(i+="\n");return i}(v),"\n").concat(d?"":"precision highp float;\n\n","\n"):"".concat(g,"\n");const b=function(t){const e={vs:{},fs:{}};return t.forEach(t=>{let i;"string"!=typeof t?(i=t,t=i.hook):i={},t=t.trim();const[n,r]=t.split(":"),s=t.replace(/\(.+/,"");e[n][s]=Object.assign(i,{signature:r})}),e}(a),y={},w={},x={};for(const t in c){const e="string"==typeof c[t]?{injection:c[t],order:0}:c[t],i=t.match(/^(v|f)s:(#)?([\w-]+)$/);if(i){const n=i[2],r=i[3];n?"decl"===r?w[t]=[e]:x[t]=[e]:y[t]=[e]}else x[t]=[e]}for(const t of s){u&&t.checkDeprecations(m,u);_+=t.getModuleSource(r,p);const e=t.injections[r];for(const t in e){const i=t.match(/^(v|f)s:#([\w-]+)$/);if(i){const n="decl"===i[2]?w:x;n[t]=n[t]||[],n[t].push(e[t])}else y[t]=y[t]||[],y[t].push(e[t])}}return _+=ns,_=Pr(_,r,w),_+=function(t,e){let i="";for(const n in t){const r=t[n];if(i+="void ".concat(r.signature," {\n"),r.header&&(i+=" ".concat(r.header)),e[n]){const t=e[n];t.sort((t,e)=>t.order-e.order);for(const e of t)i+=" ".concat(e.injection,"\n")}r.footer&&(i+=" ".concat(r.footer)),i+="}\n"}return i}(b[r],y),_+=m,_=Pr(_,r,x),_=es(_,l?100:p,d),_}function os(t){return function(e){const i={};for(const n of t){const t=n.getUniforms(e,i);Object.assign(i,t)}return i}}const as={5126:ws.bind(null,"uniform1fv",fs,1,xs),35664:ws.bind(null,"uniform2fv",fs,2,xs),35665:ws.bind(null,"uniform3fv",fs,3,xs),35666:ws.bind(null,"uniform4fv",fs,4,xs),5124:ws.bind(null,"uniform1iv",ps,1,xs),35667:ws.bind(null,"uniform2iv",ps,2,xs),35668:ws.bind(null,"uniform3iv",ps,3,xs),35669:ws.bind(null,"uniform4iv",ps,4,xs),35670:ws.bind(null,"uniform1iv",ps,1,xs),35671:ws.bind(null,"uniform2iv",ps,2,xs),35672:ws.bind(null,"uniform3iv",ps,3,xs),35673:ws.bind(null,"uniform4iv",ps,4,xs),35674:ws.bind(null,"uniformMatrix2fv",fs,4,Es),35675:ws.bind(null,"uniformMatrix3fv",fs,9,Es),35676:ws.bind(null,"uniformMatrix4fv",fs,16,Es),35678:ys,35680:ys,5125:ws.bind(null,"uniform1uiv",gs,1,xs),36294:ws.bind(null,"uniform2uiv",gs,2,xs),36295:ws.bind(null,"uniform3uiv",gs,3,xs),36296:ws.bind(null,"uniform4uiv",gs,4,xs),35685:ws.bind(null,"uniformMatrix2x3fv",fs,6,Es),35686:ws.bind(null,"uniformMatrix2x4fv",fs,8,Es),35687:ws.bind(null,"uniformMatrix3x2fv",fs,6,Es),35688:ws.bind(null,"uniformMatrix3x4fv",fs,12,Es),35689:ws.bind(null,"uniformMatrix4x2fv",fs,8,Es),35690:ws.bind(null,"uniformMatrix4x3fv",fs,12,Es),35678:ys,35680:ys,35679:ys,35682:ys,36289:ys,36292:ys,36293:ys,36298:ys,36299:ys,36300:ys,36303:ys,36306:ys,36307:ys,36308:ys,36311:ys},cs={},ls={},hs={},us=[0];function ds(t,e,i,n){1===e&&"boolean"==typeof t&&(t=t?1:0),Number.isFinite(t)&&(us[0]=t,t=us);const r=t.length;if(r%e&&ri.warn("Uniform size should be multiples of ".concat(e),t)(),t instanceof i)return t;let s=n[r];s||(s=new i(r),n[r]=s);for(let e=0;e{const r=t!==n;return r&&(e.uniform1i(i,n),t=n),r}}function ws(t,e,i,n){let r=null,s=null;return(o,a,c)=>{const l=e(c,i),h=l.length;let u=!1;if(null===r)r=new Float32Array(h),s=h,u=!0;else{hn(s===h,"Uniform length cannot change.");for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:"unnamed";const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/,n=t.match(i);return n?n[1]:e}function As(t,e,i,n){const r=t.split(/\r?\n/),s={},o={},a=n||Ts(e)||"(unnamed)",c="".concat(function(t){switch(t){case 35632:return"fragment";case 35633:return"vertex";default:return"unknown type"}}(i)," shader ").concat(a);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:": ";const n=t.split(/\r?\n/),r=String(n.length+e-1).length;return n.map((t,n)=>{const s=String(n+e),o=s.length;return Ss(s,r-o)+i+t})}(e);return{shaderName:c,errors:Ps(s,l),warnings:Ps(o,l)}}function Ps(t,e){let i="";for(let n=0;n0&&void 0!==arguments[0]?arguments[0]:this.source;t.startsWith("#version ")||(t="#version 100\n".concat(t)),this.source=t,this.gl.shaderSource(this.handle,this.source),this.gl.compileShader(this.handle);if(!this.getParameter(35713)){const t=this.gl.getShaderInfoLog(this.handle),{shaderName:e,errors:i,warnings:n}=As(t,this.source,this.shaderType,this.id);throw ri.error("GLSL compilation errors in ".concat(e,"\n").concat(i))(),ri.warn("GLSL compilation warnings in ".concat(e,"\n").concat(n))(),new Error("GLSL compilation errors in ".concat(e))}}_deleteHandle(){this.gl.deleteShader(this.handle)}_getOptsFromHandle(){return{type:this.getParameter(35663),source:this.getSource()}}}class Cs extends Ms{get[Symbol.toStringTag](){return"VertexShader"}constructor(t,e){"string"==typeof e&&(e={source:e}),super(t,Object.assign({},e,{shaderType:35633}))}_createHandle(){return this.gl.createShader(35633)}}class Ls extends Ms{get[Symbol.toStringTag](){return"FragmentShader"}constructor(t,e){"string"==typeof e&&(e={source:e}),super(t,Object.assign({},e,{shaderType:35632}))}_createHandle(){return this.gl.createShader(35632)}}const Rs={5126:[5126,1,"float"],35664:[5126,2,"vec2"],35665:[5126,3,"vec3"],35666:[5126,4,"vec4"],5124:[5124,1,"int"],35667:[5124,2,"ivec2"],35668:[5124,3,"ivec3"],35669:[5124,4,"ivec4"],5125:[5125,1,"uint"],36294:[5125,2,"uvec2"],36295:[5125,3,"uvec3"],36296:[5125,4,"uvec4"],35670:[5126,1,"bool"],35671:[5126,2,"bvec2"],35672:[5126,3,"bvec3"],35673:[5126,4,"bvec4"],35674:[5126,8,"mat2"],35685:[5126,8,"mat2x3"],35686:[5126,8,"mat2x4"],35675:[5126,12,"mat3"],35687:[5126,12,"mat3x2"],35688:[5126,12,"mat3x4"],35676:[5126,16,"mat4"],35689:[5126,16,"mat4x2"],35690:[5126,16,"mat4x3"]};function Os(t){switch(t){case 0:return 0;case 1:case 3:case 2:return 1;case 4:case 5:case 6:return 4;default:return hn(!1),0}}function Is(t){const e=Rs[t];if(!e)return null;const[i,n]=e;return{type:i,components:n}}function ks(t,e){switch(t){case 5120:case 5121:case 5122:case 5123:t=5126}for(const i in Rs){const[n,r,s]=Rs[i];if(n===t&&r===e)return{glType:i,name:s}}return null}class Fs{constructor(t){this.id=t.id,this.attributeInfos=[],this.attributeInfosByName={},this.attributeInfosByLocation=[],this.varyingInfos=[],this.varyingInfosByName={},Object.seal(this),this._readAttributesFromProgram(t),this._readVaryingsFromProgram(t)}getAttributeInfo(t){const e=Number(t);return Number.isFinite(e)?this.attributeInfosByLocation[e]:this.attributeInfosByName[t]||null}getAttributeLocation(t){const e=this.getAttributeInfo(t);return e?e.location:-1}getAttributeAccessor(t){const e=this.getAttributeInfo(t);return e?e.accessor:null}getVaryingInfo(t){const e=Number(t);return Number.isFinite(e)?this.varyingInfos[e]:this.varyingInfosByName[t]||null}getVaryingIndex(t){const e=this.getVaryingInfo();return e?e.location:-1}getVaryingAccessor(t){const e=this.getVaryingInfo();return e?e.accessor:null}_readAttributesFromProgram(t){const{gl:e}=t,i=e.getProgramParameter(t.handle,35721);for(let n=0;n=0&&this._addAttribute(o,i,r,s)}this.attributeInfos.sort((t,e)=>t.location-e.location)}_readVaryingsFromProgram(t){const{gl:e}=t;if(!ai(e))return;const i=e.getProgramParameter(t.handle,35971);for(let n=0;nt.location-e.location)}_addAttribute(t,e,i,n){const{type:r,components:s}=Is(i),o={type:r,size:n*s};this._inferProperties(t,e,o);const a={location:t,name:e,accessor:new Sn(o)};this.attributeInfos.push(a),this.attributeInfosByLocation[t]=a,this.attributeInfosByName[a.name]=a}_inferProperties(t,e,i){/instance/i.test(e)&&(i.divisor=1)}_addVarying(t,e,i,n){const{type:r,components:s}=Is(i),o={location:t,name:e,accessor:new Sn({type:r,size:n*s})};this.varyingInfos.push(o),this.varyingInfosByName[o.name]=o}}const Ds=35981,Bs=["setVertexArray","setAttributes","setBuffers","unsetBuffers","use","getUniformCount","getUniformInfo","getUniformLocation","getUniformValue","getVarying","getFragDataLocation","getAttachedShaders","getAttributeCount","getAttributeLocation","getAttributeInfo"];class js extends bn{get[Symbol.toStringTag](){return"Program"}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.stubRemovedMethods("Program","v6.0",Bs),this._isCached=!1,this.initialize(e),Object.seal(this),this._setId(e.id)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{hash:e,vs:i,fs:n,varyings:r,bufferMode:s=Ds}=t;return this.hash=e||"",this.vs="string"==typeof i?new Cs(this.gl,{id:"".concat(t.id,"-vs"),source:i}):i,this.fs="string"==typeof n?new Ls(this.gl,{id:"".concat(t.id,"-fs"),source:n}):n,hn(this.vs instanceof Cs),hn(this.fs instanceof Ls),this.uniforms={},this._textureUniforms={},r&&r.length>0&&(li(this.gl),this.varyings=r,this.gl2.transformFeedbackVaryings(this.handle,r,s)),this._compileAndLink(),this._readUniformLocationsFromLinkedProgram(),this.configuration=new Fs(this),this.setProps(t)}delete(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._isCached?this:super.delete(t)}setProps(t){return"uniforms"in t&&this.setUniforms(t.uniforms),this}draw(t){let{logPriority:e,drawMode:i=4,vertexCount:n,offset:r=0,start:s,end:o,isIndexed:a=!1,indexType:c=5123,instanceCount:l=0,isInstanced:h=l>0,vertexArray:u=null,transformFeedback:d,framebuffer:f,parameters:p={},uniforms:g,samplers:m}=t;if((g||m)&&(ri.deprecated("Program.draw({uniforms})","Program.setUniforms(uniforms)")(),this.setUniforms(g||{})),ri.priority>=e){const t=f?f.id:"default",r="mode=".concat(dn(this.gl,i)," verts=").concat(n," ")+"instances=".concat(l," indexType=").concat(dn(this.gl,c)," ")+"isInstanced=".concat(h," isIndexed=").concat(a," ")+"Framebuffer=".concat(t);ri.log(e,r)()}return hn(u),this.gl.useProgram(this.handle),!(!this._areTexturesRenderable()||0===n||h&&0===l)&&(u.bindForDraw(n,l,()=>{if(void 0!==f&&(p=Object.assign({},p,{framebuffer:f})),d){const t=Os(i);d.begin(t)}this._bindTextures(),Ui(this.gl,p,()=>{a&&h?this.gl2.drawElementsInstanced(i,n,c,r,l):a&&ai(this.gl)&&!isNaN(s)&&!isNaN(o)?this.gl2.drawRangeElements(i,s,o,n,c,r):a?this.gl.drawElements(i,n,c,r):h?this.gl2.drawArraysInstanced(i,r,n,l):this.gl.drawArrays(i,r,n)}),d&&d.end()}),!0)}setUniforms(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ri.priority>=2&&function(t,e,i){for(const n in t){const r=t[n];if((!i||Boolean(i[n]))&&!_s(r))throw e=e?"".concat(e," "):"",console.error("".concat(e," Bad uniform ").concat(n),r),new Error("".concat(e," Bad uniform ").concat(n))}}(t,this.id,this._uniformSetters),this.gl.useProgram(this.handle);for(const e in t){const i=t[e],n=this._uniformSetters[e];if(n){let t=i,r=!1;if(t instanceof nr&&(t=t.texture),t instanceof Bn)if(r=this.uniforms[e]!==i,r){void 0===n.textureIndex&&(n.textureIndex=this._textureIndexCounter++);const i=t,{textureIndex:r}=n;i.bind(r),t=r,this._textureUniforms[e]=i}else t=n.textureIndex;else this._textureUniforms[e]&&delete this._textureUniforms[e];(n(t)||r)&&bs(this.uniforms,e,i)}}return this}_areTexturesRenderable(){let t=!0;for(const e in this._textureUniforms){const i=this._textureUniforms[e];i.update(),t=t&&i.loaded}return t}_bindTextures(){for(const t in this._textureUniforms){const e=this._uniformSetters[t].textureIndex;this._textureUniforms[t].bind(e)}}_createHandle(){return this.gl.createProgram()}_deleteHandle(){this.gl.deleteProgram(this.handle)}_getOptionsFromHandle(t){const e=this.gl.getAttachedShaders(t),i={};for(const t of e){switch(this.gl.getShaderParameter(this.handle,35663)){case 35633:i.vs=new Cs({handle:t});break;case 35632:i.fs=new Ls({handle:t})}}return i}_getParameter(t){return this.gl.getProgramParameter(this.handle,t)}_setId(t){if(!t){const t=this._getName();this.id=pn(t)}}_getName(){let t=this.vs.getName()||this.fs.getName();return t=t.replace(/shader/i,""),t=t?"".concat(t,"-program"):"program",t}_compileAndLink(){const{gl:t}=this;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),ri.time(4,"linkProgram for ".concat(this._getName()))(),t.linkProgram(this.handle),ri.timeEnd(4,"linkProgram for ".concat(this._getName()))(),t.debug||ri.level>0){if(!t.getProgramParameter(this.handle,35714))throw new Error("Error linking: ".concat(t.getProgramInfoLog(this.handle)));t.validateProgram(this.handle);if(!t.getProgramParameter(this.handle,35715))throw new Error("Error validating: ".concat(t.getProgramInfoLog(this.handle)))}}_readUniformLocationsFromLinkedProgram(){const{gl:t}=this;this._uniformSetters={},this._uniformCount=this._getParameter(35718);for(let e=0;e1)for(let e=0;ee.name===t.name)||this._defaultModules.push(t),this.stateHash++}removeDefaultModule(t){const e="string"==typeof t?t:t.name;this._defaultModules=this._defaultModules.filter(t=>t.name!==e),this.stateHash++}addShaderHook(t,e){e&&(t=Object.assign(e,{hook:t})),this._hookFunctions.push(t),this.stateHash++}get(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{vs:e="",fs:i="",defines:n={},inject:r={},varyings:s=[],bufferMode:o=35981,transpileToGLSL100:a=!1}=t,c=this._getModuleList(t.modules),l=this._getHash(e),h=this._getHash(i),u=c.map(t=>this._getHash(t.name)).sort(),d=s.map(t=>this._getHash(t)),f=Object.keys(n).sort(),p=Object.keys(r).sort(),g=[],m=[];for(const t of f)g.push(this._getHash(t)),g.push(this._getHash(n[t]));for(const t of p)m.push(this._getHash(t)),m.push(this._getHash(r[t]));const v="".concat(l,"/").concat(h,"D").concat(g.join("/"),"M").concat(u.join("/"),"I").concat(m.join("/"),"V").concat(d.join("/"),"H").concat(this.stateHash,"B").concat(o).concat(a?"T":"");if(!this._programCache[v]){const t=function(t,e){const{vs:i,fs:n}=e,r=Dr(e.modules||[]);return{gl:t,vs:ss(t,Object.assign({},e,{source:i,type:"vs",modules:r})),fs:ss(t,Object.assign({},e,{source:n,type:"fs",modules:r})),getUniforms:os(r)}}(this.gl,{vs:e,fs:i,modules:c,inject:r,defines:n,hookFunctions:this._hookFunctions,transpileToGLSL100:a});this._programCache[v]=new js(this.gl,{hash:v,vs:t.vs,fs:t.fs,varyings:s,bufferMode:o}),this._getUniforms[v]=t.getUniforms||(t=>{}),this._useCounts[v]=0}return this._useCounts[v]++,this._programCache[v]}getUniforms(t){return this._getUniforms[t.hash]||null}release(t){const e=t.hash;this._useCounts[e]--,0===this._useCounts[e]&&(this._programCache[e].delete(),delete this._programCache[e],delete this._getUniforms[e],delete this._useCounts[e])}_getHash(t){return void 0===this._hashes[t]&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}_getModuleList(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=new Array(this._defaultModules.length+t.length),i={};let n=0;for(let t=0,r=this._defaultModules.length;t-1)return"Edge";const n=-1!==i.indexOf("MSIE "),r=-1!==i.indexOf("Trident/");return n||r?"IE":Gs.chrome?"Chrome":Gs.safari?"Safari":Gs.mozInnerScreenX?"Firefox":"Unknown"}class Hs extends bn{get[Symbol.toStringTag](){return"VertexArrayObject"}static isSupported(t){return!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).constantAttributeZero||(ai(t)||"Chrome"===Ws())}static getDefaultArray(t){return t.luma=t.luma||{},t.luma.defaultVertexArray||(t.luma.defaultVertexArray=new Hs(t,{handle:null,isDefaultArray:!0})),t.luma.defaultVertexArray}static getMaxAttributes(t){return Hs.MAX_ATTRIBUTES=Hs.MAX_ATTRIBUTES||t.getParameter(34921),Hs.MAX_ATTRIBUTES}static setConstant(t,e,i){switch(i.constructor){case Float32Array:Hs._setConstantFloatArray(t,e,i);break;case Int32Array:Hs._setConstantIntArray(t,e,i);break;case Uint32Array:Hs._setConstantUintArray(t,e,i);break;default:hn(!1)}}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e.id||e.program&&e.program.id;super(t,Object.assign({},e,{id:i})),this.buffer=null,this.bufferValue=null,this.isDefaultArray=e.isDefaultArray||!1,this.gl2=t,this.initialize(e),Object.seal(this)}delete(){return super.delete(),this.buffer&&this.buffer.delete(),this}get MAX_ATTRIBUTES(){return Hs.getMaxAttributes(this.gl)}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setProps(t)}setProps(t){return this}setElementBuffer(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return hn(!t||34963===t.target,"elements must be GL.ELEMENT_ARRAY_BUFFER"),this.bind(()=>{this.gl.bindBuffer(34963,t?t.handle:null)}),this}setBuffer(t,e,i){if(34963===e.target)return this.setElementBuffer(e,i);const{size:n,type:r,stride:s,offset:o,normalized:a,integer:c,divisor:l}=i,{gl:h,gl2:u}=this;return t=Number(t),this.bind(()=>{h.bindBuffer(34962,e.handle),c?(hn(ai(h)),u.vertexAttribIPointer(t,n,r,s,o)):h.vertexAttribPointer(t,n,r,a,s,o),h.enableVertexAttribArray(t),u.vertexAttribDivisor(t,l||0)}),this}enable(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return!e&&0===t&&!Hs.isSupported(this.gl,{constantAttributeZero:!0})||(t=Number(t),this.bind(()=>e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t))),this}getConstantBuffer(t,e){const i=this._normalizeConstantArrayValue(e),n=i.byteLength*t,r=i.length*t;let s=!this.buffer;if(this.buffer=this.buffer||new Rn(this.gl,n),s=s||this.buffer.reallocate(n),s=s||!this._compareConstantArrayValues(i,this.bufferValue),s){const t=zs(e.constructor,r);!function(t){let{target:e,source:i,start:n=0,count:r=1}=t;const s=i.length,o=r*s;let a=0;for(let t=n;a{switch(t){case 34373:return this.gl.getVertexAttribOffset(i,t);default:return this.gl.getVertexAttrib(i,t)}})}}const Xs=/^(.+)__LOCATION_([0-9]+)$/,qs=["setBuffers","setGeneric","clearBindings","setLocations","setGenericValues","setDivisor","enable","disable"];class Ys{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e.id||e.program&&e.program.id;this.id=i,this.gl=t,this.configuration=null,this.elements=null,this.elementsAccessor=null,this.values=null,this.accessors=null,this.unused=null,this.drawParams=null,this.buffer=null,this.attributes={},this.vertexArrayObject=new Hs(t),vn(this,"VertexArray","v6.0",qs),this.initialize(e),Object.seal(this)}delete(){this.buffer&&this.buffer.delete(),this.vertexArrayObject.delete()}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.reset(),this.configuration=null,this.bindOnUse=!1,this.setProps(t)}reset(){this.elements=null,this.elementsAccessor=null;const{MAX_ATTRIBUTES:t}=this.vertexArrayObject;return this.values=new Array(t).fill(null),this.accessors=new Array(t).fill(null),this.unused={},this.drawParams=null,this}setProps(t){return"program"in t&&(this.configuration=t.program&&t.program.configuration),"configuration"in t&&(this.configuration=t.configuration),"attributes"in t&&this.setAttributes(t.attributes),"elements"in t&&this.setElementBuffer(t.elements),"bindOnUse"in t&&(t=t.bindOnUse),this}clearDrawParams(){this.drawParams=null}getDrawParams(){return this.drawParams=this.drawParams||this._updateDrawParams(),this.drawParams}setAttributes(t){return Object.assign(this.attributes,t),this.vertexArrayObject.bind(()=>{for(const e in t){const i=t[e];this._setAttribute(e,i)}this.gl.bindBuffer(34962,null)}),this}setElementBuffer(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.elements=t,this.elementsAccessor=e,this.clearDrawParams(),this.vertexArrayObject.setElementBuffer(t,e),this}setBuffer(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(34963===e.target)return this.setElementBuffer(e,i);const{location:n,accessor:r}=this._resolveLocationAndAccessor(t,e,e.accessor,i);return n>=0&&(this.values[n]=e,this.accessors[n]=r,this.clearDrawParams(),this.vertexArrayObject.setBuffer(n,e,r)),this}setConstant(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{location:n,accessor:r}=this._resolveLocationAndAccessor(t,e,Object.assign({size:e.length},i));return n>=0&&(e=this.vertexArrayObject._normalizeConstantArrayValue(e),this.values[n]=e,this.accessors[n]=r,this.clearDrawParams(),this.vertexArrayObject.enable(n,!1)),this}unbindBuffers(){return this.vertexArrayObject.bind(()=>{this.elements&&this.vertexArrayObject.setElementBuffer(null),this.buffer=this.buffer||new Rn(this.gl,{accessor:{size:4}});for(let t=0;t{this.elements&&this.setElementBuffer(this.elements);for(let t=0;t{this._setConstantAttributes(t,e),n=i()}),n}_resolveLocationAndAccessor(t,e,i,n){const r={location:-1,accessor:null},{location:s,name:o}=this._getAttributeIndex(t);if(!Number.isFinite(s)||s<0)return this.unused[t]=e,ri.once(3,()=>"unused value ".concat(t," in ").concat(this.id))(),r;const a=this._getAttributeInfo(o||s);if(!a)return r;const c=this.accessors[s]||{},l=Sn.resolve(a.accessor,c,i,n),{size:h,type:u}=l;return hn(Number.isFinite(h)&&Number.isFinite(u)),{location:s,accessor:l}}_getAttributeInfo(t){return this.configuration&&this.configuration.getAttributeInfo(t)}_getAttributeIndex(t){const e=Number(t);if(Number.isFinite(e))return{location:e};const i=Xs.exec(t),n=i?i[1]:t,r=i?Number(i[2]):0;return this.configuration?{location:this.configuration.getAttributeLocation(n)+r,name:n}:{location:-1}}_setAttribute(t,e){if(e instanceof Rn)this.setBuffer(t,e);else if(Array.isArray(e)&&e.length&&e[0]instanceof Rn){const i=e[0],n=e[1];this.setBuffer(t,i,n)}else if(ArrayBuffer.isView(e)||Array.isArray(e)){const i=e;this.setConstant(t,i)}else{if(!(e.buffer instanceof Rn))throw new Error("VertexArray: attributes must be Buffers or constants (i.e. typed array)");{const i=e;this.setBuffer(t,i.buffer,i)}}}_setConstantAttributes(t,e){const i=Math.max(0|t,0|e);let n=this.values[0];ArrayBuffer.isView(n)&&this._setConstantAttributeZero(n,i);for(let t=1;t0;if(t.isInstanced=t.isInstanced||s,i instanceof Rn){const e=i;if(s){const i=e.getVertexCount(n);t.instanceCount=Math.min(t.instanceCount,i)}else{const i=e.getVertexCount(n);t.vertexCount=Math.min(t.vertexCount,i)}}}setElements(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ri.deprecated("setElements","setElementBuffer")(),this.setElementBuffer(t,e)}}function Zs(t,e){const{maxElts:i=16,size:n=1}=e;let r="[";for(let s=0;s0&&(r+=",".concat(s%n==0?" ":"")),r+=Ks(t[s],e);const s=t.length>i?"...":"]";return"".concat(r).concat(s)}function Ks(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=1e-16,{isInteger:n=!1}=e;if(Array.isArray(t)||ArrayBuffer.isView(t))return Zs(t,e);if(!Number.isFinite(t))return String(t);if(Math.abs(t)100&&Math.abs(t)<1e4)return t.toFixed(0);const r=t.toPrecision(2),s=r.indexOf(".0");return s===r.length-2?r.slice(0,-1):r}function Qs(t,e,i,n){const{gl:r}=t;if(!e)return{[n]:"null","Format ":"N/A"};let s,o,a,c="NOT PROVIDED",l=1,h=0,u=0;if(i&&(c=i.type,l=i.size,c=String(c).replace("Array",""),s=-1!==c.indexOf("nt")),e instanceof Rn){const t=e,{data:d,changed:f}=t.getDebugData();let p;if(o=f?"*":"",a=d,u=t.byteLength,h=u/d.BYTES_PER_ELEMENT/l,i){const t=i.divisor>0;p="".concat(t?"I ":"P "," ").concat(h," (x").concat(l,"=").concat(u," bytes ").concat(dn(r,c),")")}else s=!0,p="".concat(u," bytes");return{[n]:"".concat(o).concat(Ks(a,{size:l,isInteger:s})),"Format ":p}}return a=e,l=e.length,c=String(e.constructor.name).replace("Array",""),s=-1!==c.indexOf("nt"),{[n]:"".concat(Ks(a,{size:l,isInteger:s})," (constant)"),"Format ":"".concat(l,"x").concat(c," (constant)")}}function Js(t,e){const{type:i,size:n}=e,r=ks(i,n);return r?"".concat(t," (").concat(r.name,")"):t}function $s(t){let{header:e="Uniforms",program:i,uniforms:n,undefinedOnly:r=!1}=t;hn(i);const s=i._uniformSetters,o={},a=Object.keys(s).sort();let c=0;for(const t of a)t.match(".*_.*")||t.match(".*Matrix")||to({table:o,header:e,uniforms:n,uniformName:t,undefinedOnly:r})&&c++;for(const t of a)t.match(".*Matrix")&&to({table:o,header:e,uniforms:n,uniformName:t,undefinedOnly:r})&&c++;for(const t of a)o[t]||to({table:o,header:e,uniforms:n,uniformName:t,undefinedOnly:r})&&c++;let l=0;const h={};if(!r)for(const t in n){const i=n[t];o[t]||(l++,h[t]={Type:"NOT USED: ".concat(i),[e]:Ks(i)})}return{table:o,count:c,unusedTable:h,unusedCount:l}}function to(t){let{table:e,header:i,uniforms:n,uniformName:r,undefinedOnly:s}=t;const o=n[r],a=function(t){return null!=t}(o);return(!s||!a)&&(e[r]={[i]:a?Ks(o):"N/A","Uniform Type":a?o:"NOT PROVIDED"},!0)}function eo(t){const{type:e,size:i}=t.accessor,n=ks(e,i);return n?"".concat(n.name," ").concat(t.name):t.name}const io={POSITION:"positions",NORMAL:"normals",COLOR_0:"colors",TEXCOORD_0:"texCoords",TEXCOORD_1:"texCoords1",TEXCOORD_2:"texCoords2"};function no(t,e){const{attributeMap:i=io}=e||{};return i&&i[t]||t}function ro(t,e){let i;switch(t){case"texCoords":case"texCoord1":case"texCoord2":case"texCoord3":i="uvs";break;case"vertices":case"positions":case"normals":case"pickingColors":i="vectors"}switch(i){case"vectors":e.size=e.size||3;break;case"uvs":e.size=e.size||2}hn(Number.isFinite(e.size),"attribute ".concat(t," needs size"))}const so=()=>{},oo={};class ao{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{id:i=pn("model")}=e;hn(oi(t)),this.id=i,this.gl=t,this.id=e.id||pn("Model"),this.lastLogTime=0,this.animated=!1,this.initialize(e)}initialize(t){this.props={},this.programManager=t.programManager||Ns.getDefaultProgramManager(this.gl),this._programManagerState=-1,this._managedProgram=!1;const{program:e=null,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:c,transpileToGLSL100:l}=t;this.programProps={program:e,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:c,transpileToGLSL100:l},this.program=null,this.vertexArray=null,this._programDirty=!0,this.userData={},this.needsRedraw=!0,this._attributes={},this.attributes={},this.uniforms={},this.pickable=!0,this._checkProgram(),this.setUniforms(Object.assign({},this.getModuleUniforms(t.moduleSettings))),this.drawMode=void 0!==t.drawMode?t.drawMode:4,this.vertexCount=t.vertexCount||0,this.geometryBuffers={},this.isInstanced=t.isInstanced||t.instanced||t.instanceCount>0,this._setModelProps(t),this.geometry={},hn(void 0!==this.drawMode&&Number.isFinite(this.vertexCount),"Model needs drawMode and vertexCount")}setProps(t){this._setModelProps(t)}delete(){for(const t in this._attributes)this._attributes[t]!==this.attributes[t]&&this._attributes[t].delete();this._managedProgram&&(this.programManager.release(this.program),this._managedProgram=!1),this.vertexArray.delete(),this._deleteGeometryBuffers()}getDrawMode(){return this.drawMode}getVertexCount(){return this.vertexCount}getInstanceCount(){return this.instanceCount}getAttributes(){return this.attributes}getProgram(){return this.program}setProgram(t){const{program:e,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:c,transpileToGLSL100:l}=t;this.programProps={program:e,vs:i,fs:n,modules:r,defines:s,inject:o,varyings:a,bufferMode:c,transpileToGLSL100:l},this._programDirty=!0}getUniforms(){return this.uniforms}setDrawMode(t){return this.drawMode=t,this}setVertexCount(t){return hn(Number.isFinite(t)),this.vertexCount=t,this}setInstanceCount(t){return hn(Number.isFinite(t)),this.instanceCount=t,this}setGeometry(t){return this.drawMode=t.drawMode,this.vertexCount=t.getVertexCount(),this._deleteGeometryBuffers(),this.geometryBuffers=function(t,e,i){const n={};let r=e.indices;for(const s in e.attributes){const o=e.attributes[s],a=no(s,i);if("indices"===s)r=o;else if(o.constant)n[a]=o.value;else{const e=o.value,i={...o};delete i.value,n[a]=[new Rn(t,e),i],ro(s,i)}}if(r){const e=r.value||r;hn(e instanceof Uint16Array||e instanceof Uint32Array,'attribute array for "indices" must be of integer type');const i={size:1,isIndexed:void 0===r.isIndexed||r.isIndexed};n.indices=[new Rn(t,{data:e,target:34963}),i]}return n}(this.gl,t),this.vertexArray.setAttributes(this.geometryBuffers),this}setAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(mn(t))return this;const e={};for(const i in t){const n=t[i];e[i]=n.getValue?n.getValue():n}return this.vertexArray.setAttributes(e),this}setUniforms(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(this.uniforms,t),this}getModuleUniforms(t){this._checkProgram();const e=this.programManager.getUniforms(this.program);return e?e(t):{}}updateModuleSettings(t){const e=this.getModuleUniforms(t||{});return this.setUniforms(e)}clear(t){return Wn(this.program.gl,t),this}draw(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._checkProgram();const{moduleSettings:e=null,framebuffer:i,uniforms:n={},attributes:r={},transformFeedback:s=this.transformFeedback,parameters:o={},vertexArray:a=this.vertexArray}=t;let c;this.setAttributes(r),this.updateModuleSettings(e),this.setUniforms(n),ri.priority>=2&&(c=this._logDrawCallStart(2));const l=this.vertexArray.getDrawParams(),{isIndexed:h=l.isIndexed,indexType:u=l.indexType,indexOffset:d=l.indexOffset,vertexArrayInstanced:f=l.isInstanced}=this.props;f&&!this.isInstanced&&ri.warn("Found instanced attributes on non-instanced model",this.id)();const{isInstanced:p,instanceCount:g}=this,{onBeforeRender:m=so,onAfterRender:v=so}=this.props;m(),this.program.setUniforms(this.uniforms);const _=this.program.draw(Object.assign(oo,t,{logPriority:c,uniforms:null,framebuffer:i,parameters:o,drawMode:this.getDrawMode(),vertexCount:this.getVertexCount(),vertexArray:a,transformFeedback:s,isIndexed:h,indexType:u,isInstanced:p,instanceCount:g,offset:h?d:0}));return v(),ri.priority>=2&&this._logDrawCallEnd(c,a,i),_}transform(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{discard:e=!0,feedbackBuffers:i,unbindModels:n=[]}=t;let{parameters:r}=t;i&&this._setFeedbackBuffers(i),e&&(r=Object.assign({},r,{35977:e})),n.forEach(t=>t.vertexArray.unbindBuffers());try{this.draw(Object.assign({},t,{parameters:r}))}finally{n.forEach(t=>t.vertexArray.bindBuffers())}return this}render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ri.warn("Model.render() is deprecated. Use Model.setUniforms() and Model.draw()")(),this.setUniforms(t).draw()}_setModelProps(t){Object.assign(this.props,t),"uniforms"in t&&this.setUniforms(t.uniforms),"pickable"in t&&(this.pickable=t.pickable),"instanceCount"in t&&(this.instanceCount=t.instanceCount),"geometry"in t&&this.setGeometry(t.geometry),"attributes"in t&&this.setAttributes(t.attributes),"_feedbackBuffers"in t&&this._setFeedbackBuffers(t._feedbackBuffers)}_checkProgram(){if(!(this._programDirty||this.programManager.stateHash!==this._programManagerState))return;let{program:t}=this.programProps;if(t)this._managedProgram=!1;else{const{vs:e,fs:i,modules:n,inject:r,defines:s,varyings:o,bufferMode:a,transpileToGLSL100:c}=this.programProps;t=this.programManager.get({vs:e,fs:i,modules:n,inject:r,defines:s,varyings:o,bufferMode:a,transpileToGLSL100:c}),this.program&&this._managedProgram&&this.programManager.release(this.program),this._programManagerState=this.programManager.stateHash,this._managedProgram=!0}hn(t instanceof js,"Model needs a program"),this._programDirty=!1,t!==this.program&&(this.program=t,this.vertexArray?this.vertexArray.setProps({program:this.program,attributes:this.vertexArray.attributes}):this.vertexArray=new Ys(this.gl,{program:this.program}),this.setUniforms(Object.assign({},this.getModuleUniforms())))}_deleteGeometryBuffers(){for(const t in this.geometryBuffers){const e=this.geometryBuffers[t][0]||this.geometryBuffers[t];e instanceof Rn&&e.delete()}}_setAnimationProps(t){this.animated&&hn(t,"Model.draw(): animated uniforms but no animationProps")}_setFeedbackBuffers(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(mn(t))return this;const{gl:e}=this.program;return this.transformFeedback=this.transformFeedback||new br(e,{program:this.program}),this.transformFeedback.setBuffers(t),this}_logDrawCallStart(t){const e=t>3?0:1e4;if(!(Date.now()-this.lastLogTime>> DRAWING MODEL ".concat(this.id),{collapsed:ri.level<=2})(),t}_logDrawCallEnd(t,e,i,n){if(void 0===t)return;const r=function(t){let{vertexArray:e,header:i="Attributes"}=t;if(!e.configuration)return{};const n={};e.elements&&(n.ELEMENT_ARRAY_BUFFER=Qs(e,e.elements,null,i));const r=e.values;for(const t in r){const s=e._getAttributeInfo(t);if(s){let o="".concat(t,": ").concat(s.name);const a=e.accessors[s.location];a&&(o="".concat(t,": ").concat(Js(s.name,a))),n[o]=Qs(e,r[t],a,i)}}return n}({vertexArray:e,header:"".concat(this.id," attributes"),attributes:this._attributes}),{table:s,unusedTable:o,unusedCount:a}=$s({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,i)}),{table:c,count:l}=$s({header:"".concat(this.id," uniforms"),program:this.program,uniforms:Object.assign({},this.program.uniforms,i),undefinedOnly:!0});l>0&&ri.log("MISSING UNIFORMS",Object.keys(c))(),a>0&&ri.log("UNUSED UNIFORMS",Object.keys(o))();const h=function(t){const e={},i="Accessors for ".concat(t.id);for(const n of t.attributeInfos)if(n){const t=eo(n);e["in ".concat(t)]={[i]:JSON.stringify(n.accessor)}}for(const n of t.varyingInfos)if(n){const t=eo(n);e["out ".concat(t)]={[i]:JSON.stringify(n.accessor)}}return e}(this.vertexArray.configuration);ri.table(t,r)(),ri.table(t,s)(),ri.table(t+1,h)(),n&&n.log({logLevel:2,message:"Rendered to ".concat(n.id)}),ri.groupEnd(2)()}}class co{static isSupported(t){return ai(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.gl=t,this.model=null,this.elementCount=0,this.bufferTransform=null,this.textureTransform=null,this.elementIDBuffer=null,this._initialize(e),Object.seal(this)}delete(){const{model:t,bufferTransform:e,textureTransform:i}=this;t&&t.delete(),e&&e.delete(),i&&i.delete()}run(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{clearRenderTarget:e=!0}=t,i=this._updateDrawOptions(t);e&&i.framebuffer&&i.framebuffer.clear({color:!0}),this.model.transform(i)}swap(){let t=!1;const e=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const i of e)t=t||i.swap();hn(t,"Nothing to swap")}getBuffer(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.bufferTransform&&this.bufferTransform.getBuffer(t)}getData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const i of e){const e=i.getData(t);if(e)return e}return null}getFramebuffer(){return this.textureTransform&&this.textureTransform.getFramebuffer()}update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"elementCount"in t&&this.model.setVertexCount(t.elementCount);const e=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const i of e)i.update(t)}_initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{gl:e}=this;this._buildResourceTransforms(e,t),t=this._updateModelProps(t),this.model=new ao(e,Object.assign({},t,{fs:t.fs||vr({version:wr(t.vs)}),id:t.id||"transform-model",drawMode:t.drawMode||0,vertexCount:t.elementCount})),this.bufferTransform&&this.bufferTransform.setupResources({model:this.model})}_updateModelProps(t){let e=Object.assign({},t);const i=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const t of i)e=t.updateModelProps(e);return e}_buildResourceTransforms(t,e){(function(t){if(!mn(t.feedbackBuffers)||!mn(t.feedbackMap)||t.varyings&&t.varyings.length>0)return!0;return!1})(e)&&(this.bufferTransform=new yr(t,e)),function(t){if(!mn(t._sourceTextures)||t._targetTexture||t._targetTextureVarying)return!0;return!1}(e)&&(this.textureTransform=new Rr(t,e)),hn(this.bufferTransform||this.textureTransform,"must provide source/feedback buffers or source/target textures")}_updateDrawOptions(t){let e=Object.assign({},t);const i=[this.bufferTransform,this.textureTransform].filter(Boolean);for(const t of i)e=Object.assign(e,t.getDrawOptions(e));return e}}class lo{constructor(t,e){r(this,"opts",void 0),r(this,"source",void 0),this.opts=e,this.source=t}get value(){return this.source.value}getValue(){const t=this.source.getBuffer(),e=this.getAccessor();if(t)return[t,e];const{value:i}=this.source,{size:n}=e;let r=i;if(i&&i.length!==n){r=new Float32Array(n);const t=e.elementOffset||0;for(let e=0;e0&&(po.length=t.length,n=po):n=fo,(e>0||Number.isFinite(i))&&(n=(Array.isArray(n)?n:Array.from(n)).slice(e,i),r.index=e-1),{iterable:n,objectInfo:r}}function mo(t){return t&&t[Symbol.asyncIterator]}function vo(t,e=(()=>!0)){return Array.isArray(t)?function t(e,i,n){let r=-1;for(;++rc)return void i.set(e.subarray(0,c),n);if(i.set(e,n),!s)return;let l=a;for(;lt},spring:{stiffness:.05,damping:.5}};function Eo(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});const i=t.type||"interpolation";return{...xo[i],...e,...t,type:i}}function To(t,e){const i=e.getBuffer();return i?[i,{divisor:0,size:e.size,normalized:e.settings.normalized}]:e.value}function Ao(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error('No defined attribute type for size "'.concat(t,'"'))}}function Po(t){t.push(t.shift())}function So(t,e){const{doublePrecision:i,settings:n,value:r,size:s}=t,o=i&&r instanceof Float64Array?2:1;return(n.noAlloc?r.length:e*s)*o}function Mo({buffer:t,numInstances:e,attribute:i,fromLength:n,fromStartIndices:r,getData:s=(t=>t)}){const o=i.doublePrecision&&i.value instanceof Float64Array?2:1,a=i.size*o,c=i.byteOffset,l=i.startIndices,h=r&&l,u=So(i,e),d=i.isConstant;if(!h&&n>=u)return;const f=d?i.value:i.getBuffer().getData({srcByteOffset:c});if(i.settings.normalized&&!d){const t=s;s=(e,n)=>i.normalizeConstant(t(e,n))}const p=d?(t,e)=>s(f,e):(t,e)=>s(f.subarray(t,t+a),e),g=t.getData({length:n}),m=new Float32Array(u);!function({source:t,target:e,size:i,getData:n,sourceStartIndices:r,targetStartIndices:s}){if(!Array.isArray(s))return wo({source:t,target:e,size:i,getData:n}),e;let o=0,a=0;const c=n&&((t,e)=>n(t+a,e)),l=Math.min(r.length,s.length);for(let n=1;n=r){const i=new Array(n).fill(1/0),s=new Array(n).fill(-1/0);for(let t=0;ts[r]&&(s[r]=n)}t=[i,s]}}return this.state.bounds=t,t}setData(t){const{state:e}=this;let i;i=ArrayBuffer.isView(t)?{value:t}:t instanceof Rn?{buffer:t}:t;const n={...this.settings,...i};if(e.bufferAccessor=n,e.bounds=null,i.constant){let t=i.value;t=this._normalizeValue(t,[],0),this.settings.normalized&&(t=this.normalizeConstant(t));if(!(!e.constant||!this._areValuesEqual(t,this.value)))return!1;e.externalBuffer=null,e.constant=!0,this.value=t}else if(i.buffer){const t=i.buffer;e.externalBuffer=t,e.constant=!1,this.value=i.value||null;const r=i.value instanceof Float64Array;n.type=i.type||t.accessor.type,n.bytesPerElement=t.accessor.BYTES_PER_ELEMENT*(r?2:1),n.stride=ho(n)}else if(i.value){this._checkExternalBuffer(i);let t=i.value;e.externalBuffer=null,e.constant=!1,this.value=t,n.bytesPerElement=t.BYTES_PER_ELEMENT,n.stride=ho(n);const{buffer:r,byteOffset:s}=this;this.doublePrecision&&t instanceof Float64Array&&(t=Q(t,n));const o=t.byteLength+s+2*n.stride;r.byteLength(t+128)/255*2-1);case 5122:return new Float32Array(t).map(t=>(t+32768)/65535*2-1);case 5121:return new Float32Array(t).map(t=>t/255);case 5123:return new Float32Array(t).map(t=>t/65535);default:return t}}_normalizeValue(t,e,i){const{defaultValue:n,size:r}=this.settings;if(Number.isFinite(t))return e[i]=t,e;if(!t)return e[i]=n[0],e;switch(r){case 4:e[i+3]=Number.isFinite(t[3])?t[3]:n[3];case 3:e[i+2]=Number.isFinite(t[2])?t[2]:n[2];case 2:e[i+1]=Number.isFinite(t[1])?t[1]:n[1];case 1:e[i+0]=Number.isFinite(t[0])?t[0]:n[0];break;default:let s=r;for(;--s>=0;)e[i+s]=Number.isFinite(t[s])?t[s]:n[s]}return e}_areValuesEqual(t,e){if(!t||!e)return!1;const{size:i}=this;for(let n=0;nt[e])]:t[e],i)}setNeedsUpdate(t=this.id,e){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),e){const{startRow:t=0,endRow:i=1/0}=e;this.state.updateRanges=function(t,e){if(t===yo)return t;if(e[0]<0&&(e[0]=0),e[0]>=e[1])return t;const i=[],n=t.length;let r=0;for(let s=0;se[1]?i.push(n):e=[Math.min(n[0],e[0]),Math.max(n[1],e[1])]}return i.splice(r,0,e),i}(this.state.updateRanges,[t,i])}else this.state.updateRanges=yo}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=bo}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){const{state:e,settings:i}=this;return!i.noAlloc&&(!!i.update&&(super.allocate(t,e.updateRanges!==yo),!0))}updateBuffer({numInstances:t,data:e,props:i,context:n}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:s,noAlloc:o}}=this;let a=!0;if(s){for(const[o,a]of r)s.call(n,this,{data:e,startRow:o,endRow:a,props:i,numInstances:t});if(this.value)if(this.constant||this.buffer.byteLength{if(!s){const e=n*c+l;for(let n=0;nl?c.set(i,p):(t._normalizeValue(i,m.target,0),_o({target:c,source:m.target,start:p,count:e}));p+=e*l}else t._normalizeValue(i,c,p),p+=l}}_validateAttributeUpdaters(){const{settings:t}=this;if(!(t.noAlloc||"function"==typeof t.update))throw new Error("Attribute ".concat(this.id," missing update or accessor"))}_checkAttributeArray(){const{value:t}=this,e=Math.min(4,this.size);if(t&&t.length>=e){let i=!0;switch(e){case 4:i=i&&Number.isFinite(t[3]);case 3:i=i&&Number.isFinite(t[2]);case 2:i=i&&Number.isFinite(t[1]);case 1:i=i&&Number.isFinite(t[0]);break;default:i=!1}if(!i)throw new Error("Illegal attribute generated for ".concat(this.id))}}}let Lo={};function Ro(t,e,i,n){T.level>0&&Lo[t]&&Lo[t].call(null,e,i,n)}const Oo={interpolation:class{constructor({gl:t,attribute:e,timeline:i}){r(this,"gl",void 0),r(this,"type","interpolation"),r(this,"attributeInTransition",void 0),r(this,"settings",void 0),r(this,"attribute",void 0),r(this,"transition",void 0),r(this,"currentStartIndices",void 0),r(this,"currentLength",void 0),r(this,"transform",void 0),r(this,"buffers",void 0),this.gl=t,this.transition=new de(i),this.attribute=e,this.attributeInTransition=new Co(t,e.settings),this.currentStartIndices=e.startIndices,this.currentLength=0,this.transform=function(t,e){const i=Ao(e.size);return new co(t,{vs:"\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nuniform float time;\nattribute ATTRIBUTE_TYPE aFrom;\nattribute ATTRIBUTE_TYPE aTo;\nvarying ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, time);\n gl_Position = vec4(0.0);\n}\n",defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"]})}(t,e);const n={byteLength:0,usage:35050};this.buffers=[new Rn(t,n),new Rn(t,n)]}get inProgress(){return this.transition.inProgress}start(t,e){if(t.duration<=0)return void this.transition.cancel();this.settings=t;const{gl:i,buffers:n,attribute:r}=this;Po(n);const s={numInstances:e,attribute:r,fromLength:this.currentLength,fromStartIndices:this.currentStartIndices,getData:t.enter};for(const t of n)Mo({buffer:t,...s});this.currentStartIndices=r.startIndices,this.currentLength=So(r,e),this.attributeInTransition.setData({buffer:n[1],value:r.value}),this.transition.start(t),this.transform.update({elementCount:Math.floor(this.currentLength/r.size),sourceBuffers:{aFrom:n[0],aTo:To(0,r)},feedbackBuffers:{vCurrent:n[1]}})}update(){const t=this.transition.update();if(t){const{duration:t,easing:e}=this.settings,{time:i}=this.transition;let n=i/t;e&&(n=e(n)),this.transform.run({uniforms:{time:n}})}return t}cancel(){this.transition.cancel(),this.transform.delete();for(const t of this.buffers)t.delete();this.buffers.length=0}},spring:class{constructor({gl:t,attribute:e,timeline:i}){r(this,"gl",void 0),r(this,"type","spring"),r(this,"attributeInTransition",void 0),r(this,"settings",void 0),r(this,"attribute",void 0),r(this,"transition",void 0),r(this,"currentStartIndices",void 0),r(this,"currentLength",void 0),r(this,"texture",void 0),r(this,"framebuffer",void 0),r(this,"transform",void 0),r(this,"buffers",void 0),this.gl=t,this.type="spring",this.transition=new de(i),this.attribute=e,this.attributeInTransition=new Co(t,{...e.settings,normalized:!1}),this.currentStartIndices=e.startIndices,this.currentLength=0,this.texture=function(t){return new Nn(t,{data:new Uint8Array(4),format:6408,type:5121,border:0,mipmaps:!1,dataFormat:6408,width:1,height:1})}(t),this.framebuffer=function(t,e){return new nr(t,{id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,attachments:{36064:e}})}(t,this.texture),this.transform=function(t,e,i){const n=Ao(e.size);return new co(t,{framebuffer:i,vs:"\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nuniform float stiffness;\nuniform float damping;\nattribute ATTRIBUTE_TYPE aPrev;\nattribute ATTRIBUTE_TYPE aCur;\nattribute ATTRIBUTE_TYPE aTo;\nvarying ATTRIBUTE_TYPE vNext;\nvarying float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE spring = delta * stiffness;\n ATTRIBUTE_TYPE damper = velocity * -1.0 * damping;\n return spring + damper + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n",fs:"\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nvarying float vIsTransitioningFlag;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n gl_FragColor = vec4(1.0);\n}",defines:{ATTRIBUTE_TYPE:n},varyings:["vNext"]})}(t,e,this.framebuffer);const n={byteLength:0,usage:35050};this.buffers=[new Rn(t,n),new Rn(t,n),new Rn(t,n)]}get inProgress(){return this.transition.inProgress}start(t,e){const{gl:i,buffers:n,attribute:r}=this,s={numInstances:e,attribute:r,fromLength:this.currentLength,fromStartIndices:this.currentStartIndices,getData:t.enter};for(const t of n)Mo({buffer:t,...s});this.settings=t,this.currentStartIndices=r.startIndices,this.currentLength=So(r,e),this.attributeInTransition.setData({buffer:n[1],value:r.value}),this.transition.start({...t,duration:1/0}),this.transform.update({elementCount:Math.floor(this.currentLength/r.size),sourceBuffers:{aTo:To(0,r)}})}update(){const{buffers:t,transform:e,framebuffer:i,transition:n}=this;if(!n.update())return!1;const r=this.settings;e.update({sourceBuffers:{aPrev:t[0],aCur:t[1]},feedbackBuffers:{vNext:t[2]}}),e.run({framebuffer:i,discard:!1,clearRenderTarget:!0,uniforms:{stiffness:r.stiffness,damping:r.damping},parameters:{depthTest:!1,blend:!0,viewport:[0,0,1,1],blendFunc:[1,1],blendEquation:[32776,32776]}}),Po(t),this.attributeInTransition.setData({buffer:t[1],value:this.attribute.value});return Kn(i)[0]>0||n.end(),!0}cancel(){this.transition.cancel(),this.transform.delete();for(const t of this.buffers)t.delete();this.buffers.length=0,this.texture.delete(),this.framebuffer.delete()}}};class Io{constructor(t,{id:e,timeline:i}){r(this,"id",void 0),r(this,"isSupported",void 0),r(this,"gl",void 0),r(this,"timeline",void 0),r(this,"transitions",void 0),r(this,"needsRedraw",void 0),r(this,"numInstances",void 0),this.id=e,this.gl=t,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1,this.isSupported=co.isSupported(t)}finalize(){for(const t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:e,numInstances:i}){this.numInstances=i||1;for(const i in t){const n=t[i],r=n.getTransitionSetting(e);r&&this._updateAttribute(i,n,r)}for(const i in this.transitions){const n=t[i];n&&n.getTransitionSetting(e)||this._removeTransition(i)}}hasAttribute(t){const e=this.transitions[t];return e&&e.inProgress}getAttributes(){const t={};for(const e in this.transitions){const i=this.transitions[e];i.inProgress&&(t[e]=i.attributeInTransition)}return t}run(){if(!this.isSupported||0===this.numInstances)return!1;for(const t in this.transitions){this.transitions[t].update()&&(this.needsRedraw=!0)}const t=this.needsRedraw;return this.needsRedraw=!1,t}_removeTransition(t){this.transitions[t].cancel(),delete this.transitions[t]}_updateAttribute(t,e,i){const n=this.transitions[t];let r=!n||n.type!==i.type;if(r){if(!this.isSupported)return void T.warn("WebGL2 not supported by this browser. Transition for ".concat(t," is disabled."))();n&&this._removeTransition(t);const s=Oo[i.type];s?this.transitions[t]=new s({attribute:e,timeline:this.timeline,gl:this.gl}):(T.error("unsupported transition type '".concat(i.type,"'"))(),r=!1)}(r||e.needsRedraw())&&(this.needsRedraw=!0,this.transitions[t].start(i,this.numInstances))}}class ko{constructor(t,{id:e="attribute-manager",stats:i,timeline:n}={}){r(this,"id",void 0),r(this,"gl",void 0),r(this,"attributes",void 0),r(this,"updateTriggers",void 0),r(this,"needsRedraw",void 0),r(this,"userData",void 0),r(this,"stats",void 0),r(this,"attributeTransitionManager",void 0),this.id=e,this.gl=t,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Io(t,{id:"".concat(e,"-transitions"),timeline:n}),Object.seal(this)}finalize(){for(const t in this.attributes)this.attributes[t].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(t={clearRedrawFlags:!1}){const e=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!t.clearRedrawFlags,e&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(t){this._add(t)}addInstanced(t){this._add(t,{instanced:1})}remove(t){for(const e of t)void 0!==this.attributes[e]&&(this.attributes[e].delete(),delete this.attributes[e])}invalidate(t,e){Ro("attributeManager.invalidate",this,t,this._invalidateTrigger(t,e))}invalidateAll(t){for(const e in this.attributes)this.attributes[e].setNeedsUpdate(e,t);Ro("attributeManager.invalidate",this,"all")}update({data:t,numInstances:e,startIndices:i=null,transitions:n,props:r={},buffers:s={},context:o={}}){let a=!1;Ro("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const n in this.attributes){const c=this.attributes[n],l=c.settings.accessor;c.startIndices=i,c.numInstances=e,r[n]&&T.removed("props.".concat(n),"data.attributes.".concat(n))(),c.setExternalBuffer(s[n])||c.setBinaryValue("string"==typeof l?s[l]:void 0,t.startIndices)||"string"==typeof l&&!s[l]&&c.setConstantValue(r[l])||c.needsUpdate()&&(a=!0,this._updateAttribute({attribute:c,numInstances:e,data:t,props:r,context:o})),this.needsRedraw=this.needsRedraw||c.needsRedraw()}a&&Ro("attributeManager.updateEnd",this,e),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:e,transitions:n})}updateTransition(){const{attributeTransitionManager:t}=this,e=t.run();return this.needsRedraw=this.needsRedraw||e,e}getAttributes(){return this.attributes}getChangedAttributes(t={clearChangedFlags:!1}){const{attributes:e,attributeTransitionManager:i}=this,n={...i.getAttributes()};for(const r in e){const s=e[r];s.needsRedraw(t)&&!i.hasAttribute(r)&&(n[r]=s)}return n}getShaderAttributes(t,e={}){t||(t=this.getAttributes());const i={};for(const n in t)e[n]||Object.assign(i,t[n].getShaderAttributes());return i}_add(t,e={}){for(const i in t){const n=t[i];this.attributes[i]=this._createAttribute(i,n,e)}this._mapUpdateTriggersToAttributes()}_createAttribute(t,e,i){const n={...e,id:t,size:(e.isIndexed?1:e.size)||1,divisor:i.instanced?1:e.divisor||0};return new Co(this.gl,n)}_mapUpdateTriggersToAttributes(){const t={};for(const e in this.attributes){this.attributes[e].getUpdateTriggers().forEach(i=>{t[i]||(t[i]=[]),t[i].push(e)})}this.updateTriggers=t}_invalidateTrigger(t,e){const{attributes:i,updateTriggers:n}=this,r=n[t];return r&&r.forEach(t=>{const n=i[t];n&&n.setNeedsUpdate(n.id,e)}),r}_updateAttribute(t){const{attribute:e,numInstances:i}=t;if(Ro("attribute.updateStart",e),e.constant)return void e.setConstantValue(e.value);e.allocate(i)&&Ro("attribute.allocate",e,i);e.updateBuffer(t)&&(this.needsRedraw=!0,Ro("attribute.updateEnd",e,i))}}const Fo={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Do{static get DRAW_MODE(){return Fo}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:e=pn("geometry"),drawMode:i=Fo.TRIANGLES,attributes:n={},indices:r=null,vertexCount:s=null}=t;this.id=e,this.drawMode=0|i,this.attributes={},this.userData={},this._setAttributes(n,r),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}get mode(){return this.drawMode}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return"Geometry ".concat(this.id," attribute ").concat(t)}_setAttributes(t,e){e&&(this.indices=ArrayBuffer.isView(e)?{value:e,size:1}:e);for(const e in t){let i=t[e];i=ArrayBuffer.isView(i)?{value:i}:i,hn(ArrayBuffer.isView(i.value),"".concat(this._print(e),": must be typed array or object with value as typed array")),"POSITION"!==e&&"positions"!==e||i.size||(i.size=3),"indices"===e?(hn(!this.indices),this.indices=i):this.attributes[e]=i}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}_calculateVertexCount(t,e){if(e)return e.value.length;let i=1/0;for(const e in t){const n=t[e],{value:r,size:s,constant:o}=n;!o&&r&&s>=1&&(i=Math.min(i,r.length/s))}return hn(Number.isFinite(i)),i}}function Bo(t,e,i,n,r){const s=e-t;return(i-e)*r+-s*n+s+e}function jo(t,e){if(Array.isArray(t)){let i=0;for(let n=0;n0}add(t,e,i,n){const{transitions:r}=this;if(r.has(t)){const i=r.get(t),{value:n=i.settings.fromValue}=i;e=n,this.remove(t)}if(!(n=Eo(n)))return;const s=No[n.type];if(!s)return void T.error("unsupported transition type '".concat(n.type,"'"))();const o=new s(this.timeline);o.start({...n,fromValue:e,toValue:i}),r.set(t,o)}remove(t){const{transitions:e}=this;e.has(t)&&(e.get(t).cancel(),e.delete(t))}update(){const t={};for(const[e,i]of this.transitions)i.update(),t[e]=i.value,i.inProgress||this.remove(e);return t}clear(){for(const t of this.transitions.keys())this.remove(t)}}const zo="Awaiting state",Vo="Matched. State transferred from previous layer",Go="Initialized",Wo="Discarded. Awaiting garbage collection",Ho="No longer matched. Awaiting garbage collection",Xo="Finalized! Awaiting garbage collection",qo=Symbol.for("component"),Yo=Symbol.for("asyncPropDefaults"),Zo=Symbol.for("asyncPropOriginal"),Ko=Symbol.for("asyncPropResolved");function Qo(t,e){const i=$o({newProps:t,oldProps:e,propTypes:na(t),ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),n=function(t,e){if(null===e)return"oldProps is null, initial diff";let i=!1;const{dataComparator:n,_dataDiff:r}=t;n?n(t.data,e.data)||(i="Data comparator detected a change"):t.data!==e.data&&(i="A new data container was supplied");i&&r&&(i=r(t.data,e.data)||i);return i}(t,e);let r=!1;return n||(r=function(t,e){if(null===e)return{all:!0};if("all"in t.updateTriggers){if(ia(t,e,"all"))return{all:!0}}const i={};let n=!1;for(const r in t.updateTriggers)if("all"!==r){ia(t,e,r)&&(i[r]=!0,n=!0)}return!!n&&i}(t,e)),{dataChanged:n,propsChanged:i,updateTriggersChanged:r,extensionsChanged:ea(t,e),transitionsChanged:Jo(t,e)}}function Jo(t,e){if(!t.transitions)return!1;const i={},n=na(t);let r=!1;for(const s in t.transitions){const o=n[s],a=o&&o.type;("number"===a||"color"===a||"array"===a)&&ta(t[s],e[s],o)&&(i[s]=!0,r=!0)}return!!r&&i}function $o({newProps:t,oldProps:e,ignoreProps:i={},propTypes:n={},triggerName:r="props"}){if(e===t)return!1;if("object"!=typeof t||null===t)return"".concat(r," changed shallowly");if("object"!=typeof e||null===e)return"".concat(r," changed shallowly");for(const s of Object.keys(t))if(!(s in i)){if(!(s in e))return"".concat(r,".").concat(s," added");const i=ta(t[s],e[s],n[s]);if(i)return"".concat(r,".").concat(s," ").concat(i)}for(const s of Object.keys(e))if(!(s in i)){if(!(s in t))return"".concat(r,".").concat(s," dropped");if(!Object.hasOwnProperty.call(t,s)){const i=ta(t[s],e[s],n[s]);if(i)return"".concat(r,".").concat(s," ").concat(i)}}return!1}function ta(t,e,i){let n=i&&i.equal;return n&&!n(t,e,i)?"changed deeply":n||(n=t&&e&&t.equals,!n||n.call(t,e))?n||e===t?null:"changed shallowly":"changed deeply"}function ea(t,e){if(null===e)return!0;const i=e.extensions,{extensions:n}=t;if(n===i)return!1;if(!i||!n)return!0;if(n.length!==i.length)return!0;for(let t=0;t{for(const r in n)if(!sa(n[r],i[r])){e=t(n),i=n;break}return e}}function aa(t,e){if(!e)return t;const i={...t,...e};if("defines"in e&&(i.defines={...t.defines,...e.defines}),"modules"in e&&(i.modules=(t.modules||[]).concat(e.modules),e.modules.some(t=>"project64"===t.name))){const t=i.modules.findIndex(t=>"project32"===t.name);t>=0&&i.modules.splice(t,1)}if("inject"in e)if(t.inject){const n={...t.inject};for(const t in e.inject)n[t]=(n[t]||"")+e.inject[t];i.inject=n}else i.inject=e.inject;return i}const ca=[0,0,0,0],la=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],ha=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],ua=[0,0,0],da=[0,0,0],fa=oa((function({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:n}){const{projectionCenter:r,viewProjectionMatrix:s,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=function(t,e,i){const{viewMatrixUncentered:n,projectionMatrix:r}=t;let{viewMatrix:s,viewProjectionMatrix:o}=t,a=ca,c=ca,l=t.cameraPosition;const{geospatialOrigin:h,shaderCoordinateOrigin:u,offsetMode:d}=pa(t,e,i);d&&(c=t.projectPosition(h||u),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=ht([],c,o),s=n||s,o=tt([],r,s),o=tt([],o,la));return{viewMatrix:s,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:u,geospatialOrigin:h}}(t,i,n),h=t.getDistanceScales(),u=[t.width*e,t.height*e],d=ht([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,f={project_uCoordinateSystem:i,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:c,project_uCommonOrigin:o.slice(0,3),project_uCenter:r,project_uPseudoMeters:Boolean(t._pseudoMeters),project_uViewportSize:u,project_uDevicePixelRatio:e,project_uFocalDistance:d,project_uCommonUnitsPerMeter:h.unitsPerMeter,project_uCommonUnitsPerWorldUnit:h.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:ua,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:s,project_uModelMatrix:ha,project_uCameraPosition:a};if(l){const e=t.getDistanceScales(l);switch(i){case Xt.METER_OFFSETS:f.project_uCommonUnitsPerWorldUnit=e.unitsPerMeter,f.project_uCommonUnitsPerWorldUnit2=e.unitsPerMeter2;break;case Xt.LNGLAT:case Xt.LNGLAT_OFFSETS:t._pseudoMeters||(f.project_uCommonUnitsPerMeter=e.unitsPerMeter),f.project_uCommonUnitsPerWorldUnit=e.unitsPerDegree,f.project_uCommonUnitsPerWorldUnit2=e.unitsPerDegree2;break;case Xt.CARTESIAN:f.project_uCommonUnitsPerWorldUnit=[1,1,e.unitsPerMeter[2]],f.project_uCommonUnitsPerWorldUnit2=[0,0,e.unitsPerMeter2[2]]}}return f}));function pa(t,e,i=da){i.length<3&&(i=[i[0],i[1],0]);let n,r=i,s=!0;switch(n=e===Xt.LNGLAT_OFFSETS||e===Xt.METER_OFFSETS?i:t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case qt.WEB_MERCATOR:e!==Xt.LNGLAT&&e!==Xt.CARTESIAN||(n=[0,0,0],s=!1);break;case qt.WEB_MERCATOR_AUTO_OFFSET:e===Xt.LNGLAT?r=n:e===Xt.CARTESIAN&&(r=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],n=t.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case qt.IDENTITY:r=t.position.map(Math.fround),r[2]=r[2]||0;break;case qt.GLOBE:s=!1,n=null;break;default:s=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:r,offsetMode:s}}function ga(t,e,i=!1){const n=e.projectPosition(t);if(i&&e instanceof ue){const[i,r,s=0]=t,o=e.getDistanceScales([i,r]);n[2]=s*o.unitsPerMeter[2]}return n}function ma(t,{viewport:e,modelMatrix:i,coordinateSystem:n,coordinateOrigin:r,offsetMode:s}){let[o,a,c=0]=t;switch(i&&([o,a,c]=ht([],[o,a,c,1],i)),n){case Xt.LNGLAT:return ga([o,a,c],e,s);case Xt.LNGLAT_OFFSETS:return ga([o+r[0],a+r[1],c+(r[2]||0)],e,s);case Xt.METER_OFFSETS:return ga(Ft(r,[o,a,c]),e,s);case Xt.CARTESIAN:default:return e.isGeospatial?[o+r[0],a+r[1],c+r[2]]:e.projectPosition([o,a,c])}}function va(t,e){const{viewport:i,coordinateSystem:n,coordinateOrigin:r,modelMatrix:s,fromCoordinateSystem:o,fromCoordinateOrigin:a}=function(t){const{viewport:e,modelMatrix:i,coordinateOrigin:n}=t;let{coordinateSystem:r,fromCoordinateSystem:s,fromCoordinateOrigin:o}=t;return r===Xt.DEFAULT&&(r=e.isGeospatial?Xt.LNGLAT:Xt.CARTESIAN),void 0===s&&(s=r),void 0===o&&(o=n),{viewport:e,coordinateSystem:r,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:s,fromCoordinateOrigin:o}}(e),{geospatialOrigin:c,shaderCoordinateOrigin:l,offsetMode:h}=pa(i,n,r),u=ma(t,{viewport:i,modelMatrix:s,coordinateSystem:o,coordinateOrigin:a,offsetMode:h});if(h){const t=i.projectPosition(c||l);G(u,u,t)}return u}const _a={10241:9987,10240:9729,10242:33071,10243:33071},ba={};const ya={boolean:{validate:(t,e)=>!0,equal:(t,e,i)=>Boolean(t)===Boolean(e)},number:{validate:(t,e)=>Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)},color:{validate:(t,e)=>e.optional&&!t||Ta(t)&&(3===t.length||4===t.length),equal:(t,e,i)=>wa(t,e)},accessor:{validate(t,e){const i=Aa(t);return"function"===i||i===Aa(e.value)},equal:(t,e,i)=>"function"==typeof e||wa(t,e)},array:{validate:(t,e)=>e.optional&&!t||Ta(t),equal:(t,e,i)=>i.compare?wa(t,e):t===e},object:{equal:(t,e,i)=>i.compare?oe(t,e):t===e},function:{validate:(t,e)=>e.optional&&!t||"function"==typeof t,equal:(t,e,i)=>!i.compare||t===e},data:{transform:(t,e,i)=>{const{dataTransform:n}=i.props;return n&&t?n(t):t}},image:{transform:(t,e,i)=>function(t,e){const i=t.context&&t.context.gl;if(!i||!e)return null;if(e instanceof Nn)return e;e.constructor&&"Object"!==e.constructor.name&&(e={data:e});let n=null;e.compressed&&(n={10241:e.data.length>1?9985:9729});const r=new Nn(i,{...e,parameters:{..._a,...n,...t.props.textureParameters}});return ba[r.id]=!0,r}(i,t),release:t=>{var e;(e=t)&&e instanceof Nn&&ba[e.id]&&(e.delete(),delete ba[e.id])}}};function wa(t,e){if(t===e)return!0;if(!Ta(t)||!Ta(e))return!1;const i=t.length;if(i!==e.length)return!1;for(let n=0;n{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const t in this.asyncProps){const e=this.asyncProps[t];e&&e.type&&e.type.release&&e.type.release(e.resolvedValue,e.type,this.component)}}getOldProps(){return this.oldAsyncProps||this.oldProps||Oa}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component.props}hasAsyncProp(t){return t in this.asyncProps}getAsyncProp(t){const e=this.asyncProps[t];return e&&e.resolvedValue}isAsyncPropLoading(t){if(t){const e=this.asyncProps[t];return Boolean(e&&e.pendingLoadCount>0&&e.pendingLoadCount!==e.resolvedLoadCount)}for(const t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(t,e){this._watchPromise(t,Promise.resolve(e))}setAsyncProps(t){const e=t[Ko]||{},i=t[Zo]||t,n=t[Yo]||{};for(const t in e){const i=e[t];this._createAsyncPropData(t,n[t]),this._updateAsyncProp(t,i),e[t]=this.getAsyncProp(t)}for(const t in i){const e=i[t];this._createAsyncPropData(t,n[t]),this._updateAsyncProp(t,e)}}_fetch(t,e){return null}_onResolve(t,e){}_onError(t,e){}_updateAsyncProp(t,e){this._didAsyncInputValueChange(t,e)&&("string"==typeof e&&(e=this._fetch(t,e)),e instanceof Promise?this._watchPromise(t,e):mo(e)?this._resolveAsyncIterable(t,e):this._setPropValue(t,e))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const t in this.asyncProps)Object.defineProperty(this.oldAsyncProps,t,{enumerable:!0,value:this.oldProps[t]})}}_didAsyncInputValueChange(t,e){const i=this.asyncProps[t];return e!==i.resolvedValue&&e!==i.lastValue&&(i.lastValue=e,!0)}_setPropValue(t,e){this._freezeAsyncOldProps();const i=this.asyncProps[t];i&&(e=this._postProcessValue(i,e),i.resolvedValue=e,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(t,e,i){const n=this.asyncProps[t];n&&i>=n.resolvedLoadCount&&void 0!==e&&(this._freezeAsyncOldProps(),n.resolvedValue=e,n.resolvedLoadCount=i,this.onAsyncPropUpdated(t,e))}_watchPromise(t,e){const i=this.asyncProps[t];if(i){i.pendingLoadCount++;const n=i.pendingLoadCount;e.then(e=>{e=this._postProcessValue(i,e),this._setAsyncPropValue(t,e,n),this._onResolve(t,e)}).catch(e=>{this._onError(t,e)})}}async _resolveAsyncIterable(t,e){if("data"!==t)return void this._setPropValue(t,e);const i=this.asyncProps[t];if(!i)return;i.pendingLoadCount++;const n=i.pendingLoadCount;let r=[],s=0;for await(const i of e){const{dataTransform:e}=this.component.props;r=e?e(i,r):r.concat(i),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:s,endRow:r.length}]}),s=r.length,this._setAsyncPropValue(t,r,n)}this._onResolve(t,r)}_postProcessValue(t,e){const i=t.type;return i&&(i.release&&i.release(t.resolvedValue,i,this.component),i.transform)?i.transform(e,i,this.component):e}_createAsyncPropData(t,e){if(!this.asyncProps[t]){const i=this.component&&this.component.constructor._propTypes;this.asyncProps[t]={type:i&&i[t],lastValue:null,resolvedValue:e,pendingLoadCount:0,resolvedLoadCount:0}}}}{constructor({attributeManager:t,layer:e}){super(e),r(this,"attributeManager",void 0),r(this,"needsRedraw",void 0),r(this,"needsUpdate",void 0),r(this,"subLayers",void 0),r(this,"usesPickingColorCache",void 0),r(this,"changeFlags",void 0),r(this,"viewport",void 0),r(this,"uniformTransitions",void 0),r(this,"propsInTransition",void 0),this.attributeManager=t,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}set layer(t){this.component=t}_fetch(t,e){const i=this.component.props.fetch;return i?i(e,{propName:t,layer:this.layer}):super._fetch(t,e)}_onResolve(t,e){const i=this.component.props.onDataLoad;"data"===t&&i&&i(e,{propName:t,layer:this.layer})}_onError(t,e){this.layer.raiseError(e,"loading ".concat(t," of ").concat(this.layer))}}const ka=t=>"boolean"==typeof t,Fa=t=>"function"==typeof t,Da=t=>null!==t&&"object"==typeof t,Ba=t=>Da(t)&&t.constructor==={}.constructor,ja=t=>t&&"function"==typeof t[Symbol.iterator],Na=t=>t&&"function"==typeof t[Symbol.asyncIterator],Ua=t=>"undefined"!=typeof Response&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json,za=t=>"undefined"!=typeof Blob&&t instanceof Blob,Va=t=>(t=>"undefined"!=typeof ReadableStream&&t instanceof ReadableStream||Da(t)&&Fa(t.tee)&&Fa(t.cancel)&&Fa(t.getReader))(t)||(t=>Da(t)&&Fa(t.read)&&Fa(t.pipe)&&ka(t.readable))(t);function Ga(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function Wa(t){var e;if(!t)return!1;Array.isArray(t)&&(t=t[0]);return Array.isArray(null===(e=t)||void 0===e?void 0:e.extensions)}function Ha(t){var e,i;let n;return Ga(t,"null loader"),Ga(Wa(t),"invalid loader"),Array.isArray(t)&&(n=t[1],t=t[0],t={...t,options:{...t.options,...n}}),(null!==(e=t)&&void 0!==e&&e.parseTextSync||null!==(i=t)&&void 0!==i&&i.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}let Xa="";const qa={};const Ya=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Za=/^([-\w.]+\/[-\w.+]+)/;function Ka(t){const e=Za.exec(t);return e?e[1]:t}function Qa(t){const e=Ya.exec(t);return e?e[1]:""}const Ja=/\?.*/;function $a(t){if(Ua(t)){const e=tc(t.url||"");return{url:e,type:Ka(t.headers.get("content-type")||"")||Qa(e)}}return za(t)?{url:tc(t.name||""),type:t.type||""}:"string"==typeof t?{url:tc(t),type:Qa(t)}:{url:"",type:""}}function tc(t){return t.replace(Ja,"")}async function ec(t){if(Ua(t))return t;const e={},i=function(t){return Ua(t)?t.headers["content-length"]||-1:za(t)?t.size:"string"==typeof t?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}(t);i>=0&&(e["content-length"]=String(i));const{url:n,type:r}=$a(t);r&&(e["content-type"]=r);const s=await async function(t){if("string"==typeof t)return"data:,".concat(t.slice(0,5));if(t instanceof Blob){const e=t.slice(0,5);return await new Promise(t=>{const i=new FileReader;i.onload=e=>{var i;return t(null==e||null===(i=e.target)||void 0===i?void 0:i.result)},i.readAsDataURL(e)})}if(t instanceof ArrayBuffer){const e=function(t){let e="";const i=new Uint8Array(t);for(let t=0;t60?"".concat(e.slice(0,60),"..."):e}catch(t){}return e}(t);throw new Error(e)}}async function nc(t,e){if("string"==typeof t){t=function(t){for(const e in qa)if(t.startsWith(e)){const i=qa[e];t=t.replace(e,i)}return t.startsWith("http://")||t.startsWith("https://")||(t="".concat(Xa).concat(t)),t}(t);let i=e;return null!=e&&e.fetch&&"function"!=typeof(null==e?void 0:e.fetch)&&(i=e.fetch),await fetch(t,i)}return await ec(t)}const rc=new y({id:"loaders.gl"});class sc{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}var oc=i(4);const ac={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){r(this,"console",void 0),this.console=console}log(...t){return this.console.log.bind(this.console,...t)}info(...t){return this.console.info.bind(this.console,...t)}warn(...t){return this.console.warn.bind(this.console,...t)}error(...t){return this.console.error.bind(this.console,...t)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:oc.a,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},cc={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function lc(){globalThis.loaders=globalThis.loaders||{};const{loaders:t}=globalThis;return t._state=t._state||{},t._state}const hc=()=>{const t=lc();return t.globalOptions=t.globalOptions||{...ac},t.globalOptions};function uc(t,e,i,n){return i=i||[],function(t,e){fc(t,null,ac,cc,e);for(const i of e){const n=t&&t[i.id]||{},r=i.options&&i.options[i.id]||{},s=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};fc(n,i.id,r,s,e)}}(t,i=Array.isArray(i)?i:[i]),gc(e,t,n)}function dc(t,e){const i=hc(),n=t||i;return"function"==typeof n.fetch?n.fetch:Da(n.fetch)?t=>nc(t,n):null!=e&&e.fetch?null==e?void 0:e.fetch:nc}function fc(t,e,i,n,r){const s=e||"Top level",o=e?"".concat(e,"."):"";for(const a in t){const c=!e&&Da(t[a]),l="baseUri"===a&&!e,h="workerUrl"===a&&e;if(!(a in i)&&!l&&!h)if(a in n)rc.warn("".concat(s," loader option '").concat(o).concat(a,"' no longer supported, use '").concat(n[a],"'"))();else if(!c){const t=pc(a,r);rc.warn("".concat(s," loader option '").concat(o).concat(a,"' not recognized. ").concat(t))()}}}function pc(t,e){const i=t.toLowerCase();let n="";for(const r of e)for(const e in r.options){if(t===e)return"Did you mean '".concat(r.id,".").concat(e,"'?");const s=e.toLowerCase();(i.startsWith(s)||s.startsWith(i))&&(n=n||"Did you mean '".concat(r.id,".").concat(e,"'?"))}return n}function gc(t,e,i){const n={...t.options||{}};return function(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}(n,i),null===n.log&&(n.log=new sc),mc(n,hc()),mc(n,e),n}function mc(t,e){for(const i in e)if(i in e){const n=e[i];Ba(n)&&Ba(t[i])?t[i]={...t[i],...e[i]}:t[i]=e[i]}}function vc(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var _c=i(9);class bc{}const yc=new Map;function wc(t){vc(t.source&&!t.url||!t.source&&t.url);let e=yc.get(t.source||t.url);return e||(t.url&&(e=function(t){if(!t.startsWith("http"))return t;return xc((e=t,"try {\n importScripts('".concat(e,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var e}(t.url),yc.set(t.url,e)),t.source&&(e=xc(t.source),yc.set(t.source,e))),vc(e),e}function xc(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function Ec(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}const Tc=()=>{};class Ac{static isSupported(){return"undefined"!=typeof Worker&&_c.a||void 0!==bc&&!_c.a}constructor(t){r(this,"name",void 0),r(this,"source",void 0),r(this,"url",void 0),r(this,"terminated",!1),r(this,"worker",void 0),r(this,"onMessage",void 0),r(this,"onError",void 0),r(this,"_loadableURL","");const{name:e,source:i,url:n}=t;vc(i||n),this.name=e,this.source=i,this.url=n,this.onMessage=Tc,this.onError=t=>console.log(t),this.worker=_c.a?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Tc,this.onError=Tc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||function t(e,i=!0,n){const r=n||new Set;if(e){if(Ec(e))r.add(e);else if(Ec(e.buffer))r.add(e.buffer);else if(ArrayBuffer.isView(e));else if(i&&"object"==typeof e)for(const n in e)t(e[n],i,r)}else;return void 0===n?Array.from(r):[]}(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+="worker ".concat(this.name," from ").concat(this.url,". "),t.message&&(e+="".concat(t.message," in ")),t.lineno&&(e+=":".concat(t.lineno,":").concat(t.colno)),new Error(e)}_createBrowserWorker(){this._loadableURL=wc({source:this.source,url:this.url});const t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},t.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},t.onmessageerror=t=>console.error(t),t}_createNodeWorker(){let t;if(this.url){const e=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);t=new bc(e,{eval:!1})}else{if(!this.source)throw new Error("no worker");t=new bc(this.source,{eval:!0})}return t.on("message",t=>{this.onMessage(t)}),t.on("error",t=>{this.onError(t)}),t.on("exit",t=>{}),t}}class Pc{constructor(t,e){r(this,"name",void 0),r(this,"workerThread",void 0),r(this,"isRunning",!0),r(this,"result",void 0),r(this,"_resolve",()=>{}),r(this,"_reject",()=>{}),this.name=t,this.workerThread=e,this.result=new Promise((t,e)=>{this._resolve=t,this._reject=e})}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){vc(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){vc(this.isRunning),this.isRunning=!1,this._reject(t)}}class Sc{static isSupported(){return Ac.isSupported()}constructor(t){r(this,"name","unnamed"),r(this,"source",void 0),r(this,"url",void 0),r(this,"maxConcurrency",1),r(this,"maxMobileConcurrency",1),r(this,"onDebug",()=>{}),r(this,"reuseWorkers",!0),r(this,"props",{}),r(this,"jobQueue",[]),r(this,"idleQueue",[]),r(this,"count",0),r(this,"isDestroyed",!1),this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},void 0!==t.name&&(this.name=t.name),void 0!==t.maxConcurrency&&(this.maxConcurrency=t.maxConcurrency),void 0!==t.maxMobileConcurrency&&(this.maxMobileConcurrency=t.maxMobileConcurrency),void 0!==t.reuseWorkers&&(this.reuseWorkers=t.reuseWorkers),void 0!==t.onDebug&&(this.onDebug=t.onDebug)}async startJob(t,e=((t,e,i)=>t.done(i)),i=((t,e)=>t.error(e))){const n=new Promise(n=>(this.jobQueue.push({name:t,onMessage:e,onError:i,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const t=this._getAvailableWorker();if(!t)return;const e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});const i=new Pc(e.name,t);t.onMessage=t=>e.onMessage(i,t.type,t.payload),t.onError=t=>e.onError(i,t),e.onStart(i);try{await i.result}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class Cc{static isSupported(){return Ac.isSupported()}static getWorkerFarm(t={}){return Cc._workerFarm=Cc._workerFarm||new Cc({}),Cc._workerFarm.setProps(t),Cc._workerFarm}constructor(t){r(this,"props",void 0),r(this,"workerPools",new Map),this.props={...Mc},this.setProps(t),this.workerPools=new Map}destroy(){for(const t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(t){const{name:e,source:i,url:n}=t;let r=this.workerPools.get(e);return r||(r=new Sc({name:e,source:i,url:n}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}r(Cc,"_workerFarm",void 0);async function Lc(t,e,i,n,r){const s=t.id,o=function(t,e={}){const i=e[t.id]||{},n="".concat(t.id,"-worker.js");let r=i.workerUrl;if(r||"compression"!==t.id||(r=e.workerUrl),"test"===e._workerType&&(r="modules/".concat(t.module,"/dist/").concat(n)),!r){let e=t.version;"latest"===e&&(e="latest");const i=e?"@".concat(e):"";r="https://unpkg.com/@loaders.gl/".concat(t.module).concat(i,"/dist/").concat(n)}return vc(r),r}(t,i),a=Cc.getWorkerFarm(i).getWorkerPool({name:s,url:o});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const c=await a.startJob("process-on-worker",Rc.bind(null,r));c.postMessage("process",{input:e,options:i,context:n});const l=await c.result;return await l.result}async function Rc(t,e,i,n){switch(i){case"done":e.done(n);break;case"error":e.error(new Error(n.error));break;case"process":const{id:r,input:s,options:o}=n;try{const i=await t(s,o);e.postMessage("done",{id:r,result:i})}catch(t){const i=t instanceof Error?t.message:"unknown error";e.postMessage("error",{id:r,error:i})}break;default:console.warn("parse-with-worker unknown message ".concat(i))}}i(21);function Oc(t){return t&&"object"==typeof t&&t.isBuffer}function Ic(t){if(Oc(t))return function(t){if(Oc(t)){return new Uint8Array(t.buffer,t.byteOffset,t.length).slice().buffer}return t}(t);if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return 0===t.byteOffset&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if("string"==typeof t){const e=t;return(new TextEncoder).encode(e).buffer}if(t&&"object"==typeof t&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}async function kc(t){const e=[];for await(const i of t)e.push(i);return function(...t){const e=t.map(t=>t instanceof ArrayBuffer?new Uint8Array(t):t),i=e.reduce((t,e)=>t+e.byteLength,0),n=new Uint8Array(i);let r=0;for(const t of e)n.set(t,r),r+=t.byteLength;return n.buffer}(...e)}const Fc=262144;function Dc(t,e){return oc.a?async function*(t,e){const i=t.getReader();let n;try{for(;;){const t=n||i.read();null!=e&&e._streamReadAhead&&(n=i.read());const{done:r,value:s}=await t;if(r)return;yield Ic(s)}}catch(t){i.releaseLock()}}(t,e):async function*(t,e){for await(const e of t)yield Ic(e)}(t)}function Bc(t,e){if("string"==typeof t)return function*(t,e){const i=(null==e?void 0:e.chunkSize)||262144;let n=0;const r=new TextEncoder;for(;n=0?t.substr(e+1):""}function zc(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(0,e):""}function Vc(...t){return(t=t.map((e,i)=>(i&&(e=e.replace(new RegExp("^".concat("/")),"")),i!==t.length-1&&(e=e.replace(new RegExp("".concat("/","$")),"")),e))).join("/")}i(15),i(27);const Gc=new y({id:"loaders.gl"}),Wc=()=>{const t=lc();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};const Hc=/\.([^.]+)$/;function Xc(t,e=[],i,n){if(!qc(t))return null;if(e&&!Array.isArray(e))return Ha(e);let r=[];e&&(r=r.concat(e)),null!=i&&i.ignoreRegisteredLoaders||r.push(...Wc()),function(t){for(const e of t)Ha(e)}(r);const s=function(t,e,i,n){const{url:r,type:s}=$a(t),o=r||(null==n?void 0:n.url);let a=null,c="";null!=i&&i.mimeType&&(a=Zc(e,null==i?void 0:i.mimeType),c="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType));var l;a=a||function(t,e){const i=e&&Hc.exec(e),n=i&&i[1];return n?function(t,e){e=e.toLowerCase();for(const i of t)for(const t of i.extensions)if(t.toLowerCase()===e)return i;return null}(t,n):null}(e,o),c=c||(a?"matched url ".concat(o):""),a=a||Zc(e,s),c=c||(a?"matched MIME type ".concat(s):""),a=a||function(t,e){if(!e)return null;for(const i of t)if("string"==typeof e){if(Kc(e,i))return i}else if(ArrayBuffer.isView(e)){if(Qc(e.buffer,e.byteOffset,i))return i}else if(e instanceof ArrayBuffer){if(Qc(e,0,i))return i}return null}(e,t),c=c||(a?"matched initial data ".concat(Jc(t)):""),a=a||Zc(e,null==i?void 0:i.fallbackMimeType),c=c||(a?"matched fallback MIME type ".concat(s):""),c&&Gc.log(1,"selectLoader selected ".concat(null===(l=a)||void 0===l?void 0:l.name,": ").concat(c,"."));return a}(t,r,i,n);if(!(s||null!=i&&i.nothrow))throw new Error(Yc(t));return s}function qc(t){return!(t instanceof Response&&204===t.status)}function Yc(t){const{url:e,type:i}=$a(t);let r="No valid loader found (";r+=e?"".concat(n.filename(e),", "):"no url provided, ",r+="MIME type: ".concat(i?'"'.concat(i,'"'):"not provided",", ");const s=t?Jc(t):"";return r+=s?' first bytes: "'.concat(s,'"'):"first bytes: not available",r+=")",r}function Zc(t,e){for(const i of t){if(i.mimeTypes&&i.mimeTypes.includes(e))return i;if(e==="application/x.".concat(i.id))return i}return null}function Kc(t,e){if(e.testText)return e.testText(t);return(Array.isArray(e.tests)?e.tests:[e.tests]).some(e=>t.startsWith(e))}function Qc(t,e,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(n=>function(t,e,i,n){if(n instanceof ArrayBuffer)return function(t,e,i){if(i=i||t.byteLength,t.byteLengtht.equals(e));let rl=new Uint8ClampedArray(0);const sl={data:{type:"data",value:il,async:!0},dataComparator:{type:"function",value:null,compare:!1,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,compare:!1,optional:!0},dataTransform:{type:"function",value:null,compare:!1,optional:!0},onDataLoad:{type:"function",value:null,compare:!1,optional:!0},onError:{type:"function",value:null,compare:!1,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:i,loaders:n,loadOptions:r,signal:s})=>{const{resourceManager:o}=i.context;var a;(r=r||i.getLoadOptions(),n=n||i.props.loaders,s)&&(r={...r,fetch:{...null===(a=r)||void 0===a?void 0:a.fetch,signal:s}});let c=o.contains(t);return c||r||(o.add({resourceId:t,data:el(t,n),persistent:!1}),c=!0),c?o.subscribe({resourceId:t,onChange:t=>{var n;return null===(n=i.internalState)||void 0===n?void 0:n.reloadAsyncProp(e,t)},consumerId:i.id,requestId:e}):el(t,n,r)},compare:!1},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:Kt,onHover:{type:"function",value:null,compare:!1,optional:!0},onClick:{type:"function",value:null,compare:!1,optional:!0},onDragStart:{type:"function",value:null,compare:!1,optional:!0},onDrag:{type:"function",value:null,compare:!1,optional:!0},onDragEnd:{type:"function",value:null,compare:!1,optional:!0},coordinateSystem:Xt.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,compare:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,100*-t],compare:!1},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class ol extends Ra{constructor(...t){super(...t),r(this,"internalState",null),r(this,"lifecycle",zo),r(this,"context",void 0),r(this,"state",void 0),r(this,"parent",null)}get root(){let t=this;for(;t.parent;)t=t.parent;return t}toString(){const t=this.constructor.layerName||this.constructor.name;return"".concat(t,"({id: '").concat(this.props.id,"'})")}project(t){ae(this.internalState);const e=this.internalState.viewport||this.context.viewport,i=ma(t,{viewport:e,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[n,r,s]=Ut(i,e.pixelProjectionMatrix);return 2===t.length?[n,r]:[n,r,s]}unproject(t){ae(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(t)}projectPosition(t,e){ae(this.internalState);return va(t,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...e})}get isComposite(){return!1}setState(t){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,t),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){return this.state&&(this.state.models||this.state.model&&[this.state.model])||[]}setModuleParameters(t){for(const e of this.getModels())e.updateModuleSettings(t)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:t}=this.props;return t===Xt.DEFAULT||t===Xt.LNGLAT||t===Xt.CARTESIAN}onHover(t,e){return this.props.onHover&&this.props.onHover(t,e)||!1}onClick(t,e){return this.props.onClick&&this.props.onClick(t,e)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(t,e=[]){return e[0]=t+1&255,e[1]=t+1>>8&255,e[2]=t+1>>8>>8&255,e}decodePickingColor(t){ae(t instanceof Uint8Array);const[e,i,n]=t;return e+256*i+65536*n-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:ra(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){var t;const e=this.getAttributeManager();if(!e)return null;const{positions:i,instancePositions:n}=e.attributes;return null===(t=i||n)||void 0===t?void 0:t.getBounds()}getShaders(t){for(const e of this.props.extensions)t=aa(t,e.getShaders.call(this,e));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){const e=this.getAttributeManager(),{dataChanged:i}=t.changeFlags;if(i&&e)if(Array.isArray(i))for(const t of i)e.invalidateAll(t);else e.invalidateAll();const{props:n,oldProps:r}=t,s=Number.isInteger(r.highlightedObjectIndex)||r.pickable,o=Number.isInteger(n.highlightedObjectIndex)||n.pickable;if(s!==o&&e){const{pickingColors:t,instancePickingColors:i}=e.attributes,n=t||i;n&&(o&&n.constant&&(n.constant=!1,e.invalidate(n.id)),n.value||o||(n.constant=!0,n.value=[0,0,0]))}}finalizeState(t){for(const t of this.getModels())t.delete();const e=this.getAttributeManager();e&&e.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(t){for(const e of this.getModels())e.draw(t)}getPickingInfo({info:t,mode:e,sourceLayer:i}){const{index:n}=t;return n>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[n]),t}raiseError(t,e){var i,n,r,s;(e&&(t.message="".concat(e,": ").concat(t.message)),null!==(i=(n=this.props).onError)&&void 0!==i&&i.call(n,t))||(null===(r=this.context)||void 0===r||null===(s=r.onError)||void 0===s||s.call(r,t,this))}getNeedsRedraw(t={clearRedrawFlags:!1}){return this._getNeedsRedraw(t)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){var t;return(null===(t=this.internalState)||void 0===t?void 0:t.uniformTransitions.active)||!1}activateViewport(t){if(!this.internalState)return;const e=this.internalState.viewport;this.internalState.viewport=t,e&&nl({oldViewport:e,viewport:t})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(t="all"){const e=this.getAttributeManager();e&&("all"===t?e.invalidateAll():e.invalidate(t))}updateAttributes(t){for(const e of this.getModels())this._setModelAttributes(e,t)}_updateAttributes(){const t=this.getAttributeManager();if(!t)return;const e=this.props,i=this.getNumInstances(),n=this.getStartIndices();t.update({data:e.data,numInstances:i,startIndices:n,props:e,transitions:e.transitions,buffers:e.data.attributes,context:this});const r=t.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const t=this.getAttributeManager();t&&t.updateTransition()}_updateUniformTransition(){const{uniformTransitions:t}=this.internalState;if(t.active){const e=t.update(),i=Object.create(this.props);for(const t in e)Object.defineProperty(i,t,{value:e[t]});return i}return this.props}calculateInstancePickingColors(t,{numInstances:e}){if(t.constant)return;const i=Math.floor(rl.length/3);if(this.internalState.usesPickingColorCache=!0,i2**24-1&&T.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),rl=A.allocate(rl,e,{size:3,copy:!0,maxCount:Math.max(e,2**24-1)});const t=Math.floor(rl.length/3),n=[];for(let e=i;e(T.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),t)}),this.internalState.layer=this,this.internalState.uniformTransitions=new Uo(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(t){Ro("layer.matched",this,this===t);const{state:e,internalState:i}=t;this!==t&&(this.internalState=i,this.internalState.layer=this,this.state=e,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const t=this.needsUpdate();if(Ro("layer.update",this,t),!t)return;const e=this.props,i=this.context,n=this.internalState,r=i.viewport,s=this._updateUniformTransition();n.propsInTransition=s,i.viewport=n.viewport||r,this.props=s;try{const t=this._getUpdateParams(),s=this.getModels();if(i.gl)this.updateState(t);else try{this.updateState(t)}catch(t){}for(const e of this.props.extensions)e.updateState.call(this,t,e);const o=this.getModels()[0]!==s[0];this._postUpdate(t,o)}finally{i.viewport=r,this.props=e,this._clearChangeFlags(),n.needsUpdate=!1,n.resetOldProps()}}_finalize(){Ro("layer.finalize",this),this.finalizeState(this.context);for(const t of this.props.extensions)t.finalizeState.call(this,t)}_drawLayer({moduleParameters:t=null,uniforms:e={},parameters:i={}}){this._updateAttributeTransition();const n=this.props,r=this.context;this.props=this.internalState.propsInTransition||n;const s=this.props.opacity;e.opacity=Math.pow(s,1/2.2);try{t&&this.setModuleParameters(t);const{getPolygonOffset:s}=this.props,o=s&&s(e)||[0,0];ji(r.gl,{polygonOffset:o}),Ui(r.gl,i,()=>{const n={moduleParameters:t,uniforms:e,parameters:i,context:r};for(const t of this.props.extensions)t.draw.call(this,n,t);this.draw(n)})}finally{this.props=n}}getChangeFlags(){var t;return null===(t=this.internalState)||void 0===t?void 0:t.changeFlags}setChangeFlags(t){if(!this.internalState)return;const{changeFlags:e}=this.internalState;for(const i in t)if(t[i]){let n=!1;switch(i){case"dataChanged":const r=t[i],s=e[i];r&&Array.isArray(s)&&(e.dataChanged=Array.isArray(r)?s.concat(r):r,n=!0);default:e[i]||(e[i]=t[i],n=!0)}n&&Ro("layer.changeFlag",this,i,t)}const i=Boolean(e.dataChanged||e.updateTriggersChanged||e.propsChanged||e.extensionsChanged);e.propsOrDataChanged=i,e.somethingChanged=i||e.viewportChanged||e.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(t,e){const i=Qo(t,e);if(i.updateTriggersChanged)for(const t in i.updateTriggersChanged)i.updateTriggersChanged[t]&&this.invalidateAttribute(t);if(i.transitionsChanged)for(const r in i.transitionsChanged){var n;this.internalState.uniformTransitions.add(r,e[r],t[r],null===(n=t.transitions)||void 0===n?void 0:n[r])}return this.setChangeFlags(i)}validateProps(){!function(t){const e=na(t);for(const i in e){const n=e[i],{validate:r}=n;if(r&&!r(t[i],n))throw new Error("Invalid prop ".concat(i,": ").concat(t[i]))}}(this.props)}updateAutoHighlight(t){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(t)}_updateAutoHighlight(t){const e={pickingSelectedColor:t.picked?t.color:null},{highlightColor:i}=this.props;t.picked&&"function"==typeof i&&(e.pickingHighlightColor=i(t)),this.setModuleParameters(e),this.setNeedsRedraw()}_getAttributeManager(){const t=this.context;return new ko(t.gl,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,e){const{props:i,oldProps:n}=t;this.setNeedsRedraw(),this._updateAttributes();const{model:r}=this.state;null==r||r.setInstanceCount(this.getNumInstances());const{autoHighlight:s,highlightedObjectIndex:o,highlightColor:a}=i;if(e||n.autoHighlight!==s||n.highlightedObjectIndex!==o||n.highlightColor!==a){const t={};s||(t.pickingSelectedColor=null),Array.isArray(a)&&(t.pickingHighlightColor=a),Number.isInteger(o)&&(t.pickingSelectedColor=Number.isFinite(o)&&o>=0?this.encodePickingColor(o):null),this.setModuleParameters(t)}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(t){if(!this.internalState)return!1;let e=!1;e=e||this.internalState.needsRedraw&&this.id,this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags;const i=this.getAttributeManager(),n=!!i&&i.getNeedsRedraw(t);return e=e||n,e}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}r(ol,"defaultProps",sl),r(ol,"layerName","Layer");const al={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01;\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03;\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04;\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06;\n\nfloat sin_taylor_fp32(float a) {\n float r, s, t, x;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n x = -a * a;\n s = a;\n r = a;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_3;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_5;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_7;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_9;\n s = s + t;\n\n return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n if (a == 0.0) {\n sin_t = 0.0;\n cos_t = 1.0;\n }\n sin_t = sin_taylor_fp32(a);\n cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n float sin_a;\n float cos_a;\n\n if (a == 0.0) {\n return 0.0;\n }\n float z = floor(a / TWO_PI);\n float r = a - TWO_PI * z;\n\n float t;\n float q = floor(r / PI_2 + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return 1.0 / 0.0;\n }\n\n t = r - PI_2 * q;\n\n q = floor(t / PI_16 + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return 1.0 / 0.0;\n } else {\n t = t - PI_16 * q;\n }\n\n float u = 0.0;\n float v = 0.0;\n\n float sin_t, cos_t;\n float s, c;\n sincos_taylor_fp32(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0;\n v = SIN_TABLE_0;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1;\n v = SIN_TABLE_1;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2;\n v = SIN_TABLE_2;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3;\n v = SIN_TABLE_3;\n }\n if (k > 0) {\n s = u * sin_t + v * cos_t;\n c = u * cos_t - v * sin_t;\n } else {\n s = u * sin_t - v * cos_t;\n c = u * cos_t + v * sin_t;\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n return tan_taylor_fp32(a);\n#else\n return tan(a);\n#endif\n}\n",fs:null};var cl={name:"geometry",vs:"\n".concat("#define SMOOTH_EDGE_RADIUS 0.5","\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n"),fs:"\n".concat("#define SMOOTH_EDGE_RADIUS 0.5","\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n")};const ll=Object.keys(Xt).map(t=>"const int COORDINATE_SYSTEM_".concat(t," = ").concat(Xt[t],";")).join(""),hl=Object.keys(qt).map(t=>"const int PROJECTION_MODE_".concat(t," = ").concat(qt[t],";")).join(""),ul=Object.keys(Yt).map(t=>"const int UNIT_".concat(t.toUpperCase()," = ").concat(Yt[t],";")).join("");var dl="".concat(ll,"\n").concat(hl,"\n").concat(ul,'\n\nuniform int project_uCoordinateSystem;\nuniform int project_uProjectionMode;\nuniform float project_uScale;\nuniform bool project_uWrapLongitude;\nuniform vec3 project_uCommonUnitsPerMeter;\nuniform vec3 project_uCommonUnitsPerWorldUnit;\nuniform vec3 project_uCommonUnitsPerWorldUnit2;\nuniform vec4 project_uCenter;\nuniform mat4 project_uModelMatrix;\nuniform mat4 project_uViewProjectionMatrix;\nuniform vec2 project_uViewportSize;\nuniform float project_uDevicePixelRatio;\nuniform float project_uFocalDistance;\nuniform vec3 project_uCameraPosition;\nuniform vec3 project_uCoordinateOrigin;\nuniform vec3 project_uCommonOrigin;\nuniform bool project_uPseudoMeters;\n\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0; // meters\nconst float GLOBE_RADIUS = 256.0;\n\n// returns an adjustment factor for uCommonUnitsPerMeter\nfloat project_size_at_latitude(float lat) {\n float y = clamp(lat, -89.9, 89.9);\n return 1.0 / cos(radians(y));\n}\n\nfloat project_size() {\n if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR &&\n project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\n project_uPseudoMeters == false) {\n\n // uCommonUnitsPerMeter in low-zoom Web Mercator is non-linear\n // Adjust by 1 / cos(latitude)\n // If geometry.position (vertex in common space) is populated, use it\n // Otherwise use geometry.worldPosition (anchor in world space)\n \n if (geometry.position.w == 0.0) {\n return project_size_at_latitude(geometry.worldPosition.y);\n }\n\n // latitude from common y: 2.0 * (atan(exp(y / TILE_SIZE * 2.0 * PI - PI)) - PI / 4.0)\n // Taylor series of 1 / cos(latitude)\n // Max error < 0.003\n \n float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\n float y2 = y * y;\n float y4 = y2 * y2;\n float y6 = y4 * y2;\n return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n }\n return 1.0;\n}\n\nfloat project_size_at_latitude(float meters, float lat) {\n return meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\n\n//\n// Scaling offsets - scales meters to "world distance"\n// Note the scalar version of project_size is for scaling the z component only\n//\nfloat project_size(float meters) {\n return meters * project_uCommonUnitsPerMeter.z * project_size();\n}\n\nvec2 project_size(vec2 meters) {\n return meters * project_uCommonUnitsPerMeter.xy * project_size();\n}\n\nvec3 project_size(vec3 meters) {\n return meters * project_uCommonUnitsPerMeter * project_size();\n}\n\nvec4 project_size(vec4 meters) {\n return vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w);\n}\n\n// Get rotation matrix that aligns the z axis with the given up vector\n// Find 3 unit vectors ux, uy, uz that are perpendicular to each other and uz == up\nmat3 project_get_orientation_matrix(vec3 up) {\n vec3 uz = normalize(up);\n // Tangent on XY plane\n vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\n vec3 uy = cross(uz, ux);\n return mat3(ux, uy, uz);\n}\n\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\n if (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\n transform = project_get_orientation_matrix(commonPosition);\n return true;\n }\n return false;\n}\n\n//\n// Projecting normal - transform deltas from current coordinate system to\n// normals in the worldspace\n//\nvec3 project_normal(vec3 vector) {\n // Apply model matrix\n vec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0);\n vec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter);\n mat3 rotation;\n if (project_needs_rotation(geometry.position.xyz, rotation)) {\n n = rotation * n;\n }\n return n;\n}\n\nvec4 project_offset_(vec4 offset) {\n float dy = offset.y;\n vec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy;\n return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\n\n//\n// Projecting positions - non-linear projection: lnglats => unit tile [0-1, 0-1]\n//\nvec2 project_mercator_(vec2 lnglat) {\n float x = lnglat.x;\n if (project_uWrapLongitude) {\n x = mod(x + 180., 360.0) - 180.;\n }\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\nvec3 project_globe_(vec3 lnglatz) {\n float lambda = radians(lnglatz.x);\n float phi = radians(lnglatz.y);\n float cosPhi = cos(phi);\n float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\n\n return vec3(\n sin(lambda) * cosPhi,\n -cos(lambda) * cosPhi,\n sin(phi)\n ) * D;\n}\n\n//\n// Projects positions (defined by project_uCoordinateSystem) to common space (defined by project_uProjectionMode)\n//\nvec4 project_position(vec4 position, vec3 position64Low) {\n vec4 position_world = project_uModelMatrix * position;\n\n // Work around for a Mac+NVIDIA bug https://github.com/visgl/deck.gl/issues/4145\n if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) {\n if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator_(position_world.xy),\n project_size_at_latitude(position_world.z, position_world.y),\n position_world.w\n );\n }\n if (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\n position_world.xyz += project_uCoordinateOrigin;\n }\n }\n if (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\n if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_globe_(position_world.xyz),\n position_world.w\n );\n }\n }\n if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\n if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n if (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) {\n // Too far from the projection center for offset mode to be accurate\n // Only use high parts\n return vec4(\n project_mercator_(position_world.xy) - project_uCommonOrigin.xy,\n project_size(position_world.z),\n position_world.w\n );\n }\n }\n }\n if (project_uProjectionMode == PROJECTION_MODE_IDENTITY ||\n (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\n // Subtract high part of 64 bit value. Convert remainder to float32, preserving precision.\n position_world.xyz -= project_uCoordinateOrigin;\n }\n\n // Translation is already added to the high parts\n return project_offset_(position_world + project_uModelMatrix * vec4(position64Low, 0.0));\n}\n\nvec4 project_position(vec4 position) {\n return project_position(position, ZERO_64_LOW);\n}\n\nvec3 project_position(vec3 position, vec3 position64Low) {\n vec4 projected_position = project_position(vec4(position, 1.0), position64Low);\n return projected_position.xyz;\n}\n\nvec3 project_position(vec3 position) {\n vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\n return projected_position.xyz;\n}\n\nvec2 project_position(vec2 position) {\n vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\n return projected_position.xy;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n return viewProjectionMatrix * position + center;\n}\n\n//\n// Projects from common space coordinates to clip space.\n// Uses project_uViewProjectionMatrix\n//\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter);\n}\n\n// Returns a clip space offset that corresponds to a given number of screen pixels\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;\n return offset * project_uFocalDistance;\n}\n\nfloat project_size_to_pixel(float meters) {\n return project_size(meters) * project_uScale;\n}\nfloat project_size_to_pixel(float size, int unit) {\n if (unit == UNIT_METERS) return project_size_to_pixel(size);\n if (unit == UNIT_COMMON) return size * project_uScale;\n // UNIT_PIXELS\n return size;\n}\nfloat project_pixel_size(float pixels) {\n return pixels / project_uScale;\n}\nvec2 project_pixel_size(vec2 pixels) {\n return pixels / project_uScale;\n}\n');const fl={};var pl={name:"project",dependencies:[al,cl],vs:dl,getUniforms:function(t=fl){return"viewport"in t?function({viewport:t,devicePixelRatio:e=1,modelMatrix:i=null,coordinateSystem:n=Xt.DEFAULT,coordinateOrigin:r=da,autoWrapLongitude:s=!1}){n===Xt.DEFAULT&&(n=t.isGeospatial?Xt.LNGLAT:Xt.CARTESIAN);const o=fa({viewport:t,devicePixelRatio:e,coordinateSystem:n,coordinateOrigin:r});return o.project_uWrapLongitude=s,o.project_uModelMatrix=i||ha,o}(t):{}}};var gl={name:"project32",dependencies:[pl],vs:"\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};class ml extends ol{getShaders(){return{vs:"#define SHADER_NAME heatp-map-layer-vertex-shader\n\nuniform sampler2D maxTexture;\nuniform float intensity;\nuniform vec2 colorDomain;\nuniform float threshold;\nuniform float aggregationMode;\n\nattribute vec3 positions;\nattribute vec2 texCoords;\n\nvarying vec2 vTexCoords;\nvarying float vIntensityMin;\nvarying float vIntensityMax;\n\nvoid main(void) {\n gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));\n vTexCoords = texCoords;\n vec4 maxTexture = texture2D(maxTexture, vec2(0.5));\n float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;\n float minValue = maxValue * threshold;\n if (colorDomain[1] > 0.) {\n // if user specified custom domain use it.\n maxValue = colorDomain[1];\n minValue = colorDomain[0];\n }\n vIntensityMax = intensity / maxValue;\n vIntensityMin = intensity / minValue;\n}\n",fs:"#define SHADER_NAME triangle-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D texture;\nuniform sampler2D colorTexture;\nuniform float aggregationMode;\n\nvarying vec2 vTexCoords;\nvarying float vIntensityMin;\nvarying float vIntensityMax;\n\nvec4 getLinearColor(float value) {\n float factor = clamp(value * vIntensityMax, 0., 1.);\n vec4 color = texture2D(colorTexture, vec2(factor, 0.5));\n color.a *= min(value * vIntensityMin, 1.0);\n return color;\n}\n\nvoid main(void) {\n vec4 weights = texture2D(texture, vTexCoords);\n float weight = weights.r;\n\n if (aggregationMode > 0.5) {\n weight /= max(1.0, weights.a);\n }\n\n // discard pixels with 0 weight.\n if (weight <= 0.) {\n discard;\n }\n\n vec4 linearColor = getLinearColor(weight);\n linearColor.a *= opacity;\n gl_FragColor =linearColor;\n}\n",modules:[gl]}}initializeState({gl:t}){this.getAttributeManager().add({positions:{size:3,noAlloc:!0},texCoords:{size:2,noAlloc:!0}}),this.setState({model:this._getModel(t)})}_getModel(t){const{vertexCount:e}=this.props;return new ao(t,{...this.getShaders(),id:this.props.id,geometry:new Do({drawMode:6,vertexCount:e})})}draw({uniforms:t}){const{model:e}=this.state,{texture:i,maxTexture:n,colorTexture:r,intensity:s,threshold:o,aggregationMode:a,colorDomain:c}=this.props;e.setUniforms({...t,texture:i,maxTexture:n,colorTexture:r,intensity:s,threshold:o,aggregationMode:a,colorDomain:c}).draw()}}r(ml,"layerName","TriangleLayer");class vl extends ol{get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(t=>t.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(t){}setState(t){super.setState(t),this.setNeedsUpdate()}getPickingInfo({info:t}){const{object:e}=t;return e&&e.__source&&e.__source.parent&&e.__source.parent.id===this.id?(t.object=e.__source.object,t.index=e.__source.index,t):t}filterSubLayer(t){return!0}shouldRenderSubLayer(t,e){return e&&e.length}getSubLayerClass(t,e){const{_subLayerProps:i}=this.props;return i&&i[t]&&i[t].type||e}getSubLayerRow(t,e,i){return t.__source={parent:this,object:e,index:i},t}getSubLayerAccessor(t){if("function"==typeof t){const e={index:-1,data:this.props.data,target:[]};return(i,n)=>i&&i.__source?(e.index=i.__source.index,t(i.__source.object,e)):t(i,n)}return t}getSubLayerProps(t={}){var e;const{opacity:i,pickable:n,visible:r,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:h,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:g,fetch:m,operation:v,_subLayerProps:_}=this.props,b={id:"",updateTriggers:{},opacity:i,pickable:n,visible:r,parameters:s,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:h,coordinateOrigin:u,wrapLongitude:d,positionFormat:f,modelMatrix:p,extensions:g,fetch:m,operation:v},y=_&&t.id&&_[t.id],w=y&&y.updateTriggers,x=t.id||"sublayer";if(y){const e=this.constructor._propTypes,i=t.type?t.type._propTypes:{};for(const t in y){const n=i[t]||e[t];n&&"accessor"===n.type&&(y[t]=this.getSubLayerAccessor(y[t]))}}Object.assign(b,t,y),b.id="".concat(this.props.id,"-").concat(x),b.updateTriggers={all:null===(e=this.props.updateTriggers)||void 0===e?void 0:e.all,...t.updateTriggers,...w};for(const t of g){const e=t.getSubLayerProps.call(this,t);e&&Object.assign(b,e,{updateTriggers:Object.assign(b.updateTriggers,e.updateTriggers)})}return b}_updateAutoHighlight(t){for(const e of this.getSubLayers())e.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(t,e){let i=this.internalState.subLayers;const n=!i||this.needsUpdate();if(n){i=vo(this.renderLayers(),Boolean),this.internalState.subLayers=i}Ro("compositeLayer.renderLayers",this,n,i);for(const t of i)t.parent=this}}function _l(t,e){const i={};for(const n in t)e.includes(n)||(i[n]=t[n]);return i}r(vl,"layerName","CompositeLayer");class bl extends vl{constructor(...t){super(...t),r(this,"state",void 0)}initializeAggregationLayer(t){super.initializeState(this.context),this.setState({ignoreProps:_l(this.constructor._propTypes,t.data.props),dimensions:t})}updateState(t){super.updateState(t);const{changeFlags:e}=t;if(e.extensionsChanged){const t=this.getShaders({});t&&t.defines&&(t.defines.NON_INSTANCED_MODEL=1),this.updateShaders(t)}this._updateAttributes()}updateAttributes(t){this.setState({changedAttributes:t})}getAttributes(){return this.getAttributeManager().getShaderAttributes()}getModuleSettings(){const{viewport:t,mousePosition:e,gl:i}=this.context;return Object.assign(Object.create(this.props),{viewport:t,mousePosition:e,pickingActive:0,devicePixelRatio:zi(i)})}updateShaders(t){}isAggregationDirty(t,e={}){const{props:i,oldProps:n,changeFlags:r}=t,{compareAll:s=!1,dimension:o}=e,{ignoreProps:a}=this.state,{props:c,accessors:l=[]}=o,{updateTriggersChanged:h}=r;if(r.dataChanged)return!0;if(h){if(h.all)return!0;for(const t of l)if(h[t])return!0}if(s)return!!r.extensionsChanged||$o({oldProps:n,newProps:i,ignoreProps:a,propTypes:this.constructor._propTypes});for(const t of c)if(i[t]!==n[t])return!0;return!1}isAttributeChanged(t){const{changedAttributes:e}=this.state;return t?e&&void 0!==e[t]:!function(t){let e=!0;for(const i in t){e=!1;break}return e}(e)}_getAttributeManager(){return new ko(this.context.gl,{id:this.props.id,stats:this.context.stats})}}r(bl,"layerName","AggregationLayer");const yl=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];const wl={mipmaps:!1,parameters:{10240:9729,10241:9729,10242:33071,10243:33071},dataFormat:6408},xl=[0,0],El={SUM:0,MEAN:1},Tl={getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:yl,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Al=[or,cr],Pl=[lr,ar],Sl={data:{props:["radiusPixels"]}};class Ml extends bl{constructor(...t){super(...t),r(this,"state",void 0)}initializeState(){const{gl:t}=this.context;if(!er(t,Al))return this.setState({supported:!1}),void T.error("HeatmapLayer: ".concat(this.id," is not supported on this browser"))();super.initializeAggregationLayer(Sl),this.setState({supported:!0,colorDomain:xl}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){this.state.supported&&(super.updateState(t),this._updateHeatmapState(t))}_updateHeatmapState(t){const{props:e,oldProps:i}=t,n=this._getChangeFlags(t);(n.dataChanged||n.viewportChanged)&&(n.boundsChanged=this._updateBounds(n.dataChanged),this._updateTextureRenderingBounds()),n.dataChanged||n.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):n.viewportZoomChanged&&this._debouncedUpdateWeightmap(),e.colorRange!==i.colorRange&&this._updateColorTexture(t),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:t.context.viewport.zoom})}renderLayers(){if(!this.state.supported)return[];const{weightsTexture:t,triPositionBuffer:e,triTexCoordBuffer:i,maxWeightsTexture:n,colorTexture:r,colorDomain:s}=this.state,{updateTriggers:o,intensity:a,threshold:c,aggregation:l}=this.props;return new(this.getSubLayerClass("triangle",ml))(this.getSubLayerProps({id:"triangle-layer",updateTriggers:o}),{coordinateSystem:Xt.DEFAULT,data:{attributes:{positions:e,texCoords:i}},vertexCount:4,maxTexture:n,colorTexture:r,aggregationMode:El[l]||0,texture:t,intensity:a,threshold:c,colorDomain:s})}finalizeState(t){super.finalizeState(t);const{weightsTransform:e,weightsTexture:i,maxWeightTransform:n,maxWeightsTexture:r,triPositionBuffer:s,triTexCoordBuffer:o,colorTexture:a,updateTimer:c}=this.state;null==e||e.delete(),null==i||i.delete(),null==n||n.delete(),null==r||r.delete(),null==s||s.delete(),null==o||o.delete(),null==a||a.delete(),c&&clearTimeout(c)}_getAttributeManager(){return new ko(this.context.gl,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(t){const e={},{dimensions:i}=this.state;e.dataChanged=this.isAttributeChanged()||this.isAggregationDirty(t,{compareAll:!0,dimension:i.data}),e.viewportChanged=t.changeFlags.viewportChanged;const{zoom:n}=this.state;return t.context.viewport&&t.context.viewport.zoom===n||(e.viewportZoomChanged=!0),e}_createTextures(){const{gl:t}=this.context,{textureSize:e,format:i,type:n}=this.state;this.setState({weightsTexture:new Nn(t,{width:e,height:e,format:i,type:n,...wl}),maxWeightsTexture:new Nn(t,{format:i,type:n,...wl})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:5130,accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){const{gl:t}=this.context,{weightsTextureSize:e}=this.props,i=Math.min(e,Ni(t,3379)),n=er(t,Pl),{format:r,type:s}=function({gl:t,floatTargetSupport:e}){return e?{format:ai(t)?34836:6408,type:5126}:{format:6408,type:5121}}({gl:t,floatTargetSupport:n}),o=n?1:1/255;this.setState({textureSize:i,format:r,type:s,weightsScale:o}),n||T.warn("HeatmapLayer: ".concat(this.id," rendering to float texture not supported, fallingback to low precession format"))()}getShaders(t){return super.getShaders("max-weights-transform"===t?{vs:"attribute vec4 inTexture;\nvarying vec4 outTexture;\n\nvoid main()\n{\noutTexture = inTexture;\ngl_Position = vec4(0, 0, 0, 1.);\n// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)\ngl_PointSize = 1.0;\n}\n",_fs:"varying vec4 outTexture;\nvoid main() {\n gl_FragColor = outTexture;\n gl_FragColor.g = outTexture.r / max(1.0, outTexture.a);\n}\n"}:{vs:"attribute vec3 positions;\nattribute vec3 positions64Low;\nattribute float weights;\nvarying vec4 weightsTexture;\nuniform float radiusPixels;\nuniform float textureWidth;\nuniform vec4 commonBounds;\nuniform float weightsScale;\nvoid main()\n{\n weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);\n\n float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);\n gl_PointSize = radiusTexels * 2.;\n\n vec3 commonPosition = project_position(positions, positions64Low);\n\n // map xy from commonBounds to [-1, 1]\n gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;\n gl_Position.xy = (gl_Position.xy * 2.) - (1.);\n}\n",_fs:"varying vec4 weightsTexture;\n// Epanechnikov function, keeping for reference\n// float epanechnikovKDE(float u) {\n// return 0.75 * (1.0 - u * u);\n// }\nfloat gaussianKDE(float u){\n return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);\n}\nvoid main()\n{\n float dist = length(gl_PointCoord - vec2(0.5, 0.5));\n if (dist > 0.5) {\n discard;\n }\n gl_FragColor = weightsTexture * gaussianKDE(2. * dist);\n DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n}\n"})}_createWeightsTransform(t={}){var e;const{gl:i}=this.context;let{weightsTransform:n}=this.state;const{weightsTexture:r}=this.state;null===(e=n)||void 0===e||e.delete(),n=new co(i,{id:"".concat(this.id,"-weights-transform"),elementCount:1,_targetTexture:r,_targetTextureVarying:"weightsTexture",...t}),this.setState({weightsTransform:n})}_setupResources(){const{gl:t}=this.context;this._createTextures();const{textureSize:e,weightsTexture:i,maxWeightsTexture:n}=this.state,r=this.getShaders("weights-transform");this._createWeightsTransform(r);const s=this.getShaders("max-weights-transform"),o=new co(t,{id:"".concat(this.id,"-max-weights-transform"),_sourceTextures:{inTexture:i},_targetTexture:n,_targetTextureVarying:"outTexture",...s,elementCount:e*e});this.setState({weightsTexture:i,maxWeightsTexture:n,maxWeightTransform:o,zoom:null,triPositionBuffer:new Rn(t,{byteLength:48,accessor:{size:3}}),triTexCoordBuffer:new Rn(t,{byteLength:48,accessor:{size:2}})})}updateShaders(t){this._createWeightsTransform(t)}_updateMaxWeightValue(){const{maxWeightTransform:t}=this.state;t.run({parameters:{blend:!0,depthTest:!1,blendFunc:[1,1],blendEquation:32776}})}_updateBounds(t=!1){const{viewport:e}=this.context,i=[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([e.width,e.height]),e.unproject([0,e.height])].map(t=>t.map(Math.fround)),n=function(t){const e=t.map(t=>t[0]),i=t.map(t=>t[1]),n=Math.min.apply(null,e),r=Math.max.apply(null,e);return[n,Math.min.apply(null,i),r,Math.max.apply(null,i)]}(i),r={visibleWorldBounds:n,viewportCorners:i};let s=!1;if(t||!this.state.worldBounds||(o=this.state.worldBounds,!((a=n)[0]>=o[0]&&a[2]<=o[2]&&a[1]>=o[1]&&a[3]<=o[3]))){const t=this._worldToCommonBounds(n),e=this._commonToWorldBounds(t);this.props.coordinateSystem===Xt.LNGLAT&&(e[1]=Math.max(e[1],-85.051129),e[3]=Math.min(e[3],85.051129),e[0]=Math.max(e[0],-360),e[2]=Math.min(e[2],360));const i=this._worldToCommonBounds(e);r.worldBounds=e,r.normalizedCommonBounds=i,s=!0}var o,a;return this.setState(r),s}_updateTextureRenderingBounds(){const{triPositionBuffer:t,triTexCoordBuffer:e,normalizedCommonBounds:i,viewportCorners:n}=this.state,{viewport:r}=this.context;t.subData(sn(n,3));const s=n.map(t=>function(t,e){const[i,n,r,s]=e;return[(t[0]-i)/(r-i),(t[1]-n)/(s-n)]}(r.projectPosition(t),i));e.subData(sn(s,2))}_updateColorTexture(t){const{colorRange:e}=t.props;let{colorTexture:i}=this.state;const n=function(t,e=!1,i=Float32Array){let n;if(Number.isFinite(t[0]))n=new i(t);else{n=new i(4*t.length);let e=0;for(let i=0;it*i*a)}else this.state.colorDomain=e||xl;const l={radiusPixels:t,commonBounds:c,textureWidth:s,weightsScale:a};n.update({elementCount:this.getNumInstances()}),Ui(this.context.gl,{clearColor:[0,0,0,0]},()=>{n.run({uniforms:l,parameters:{blend:!0,depthTest:!1,blendFunc:[1,1],blendEquation:32774},clearRenderTarget:!0,attributes:this.getAttributes(),moduleSettings:this.getModuleSettings()})}),this._updateMaxWeightValue(),o.setParameters({10240:9729,10241:9729})}_debouncedUpdateWeightmap(t=!1){let{updateTimer:e}=this.state;const{debounceTimeout:i}=this.props;t?(e=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(e),e=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),i)),this.setState({updateTimer:e})}_worldToCommonBounds(t,e={}){const{useLayerCoordinateSystem:i=!1}=e,[n,r,s,o]=t,{viewport:a}=this.context,{textureSize:c}=this.state,{coordinateSystem:l}=this.props,h=i&&(l===Xt.LNGLAT_OFFSETS||l===Xt.METER_OFFSETS),u=h?a.projectPosition(this.props.coordinateOrigin):[0,0],d=2*c/a.scale;let f,p;return i&&!h?(f=this.projectPosition([n,r,0]),p=this.projectPosition([s,o,0])):(f=a.projectPosition([n,r,0]),p=a.projectPosition([s,o,0])),function(t,e,i){const[n,r,s,o]=t,a=s-n,c=o-r;let l=a,h=c;a/c0&&void 0!==arguments[0]?arguments[0]:{};return t.map(t=>t*e/255)}function Ol(t){let{ambientLight:e,pointLights:i=[],directionalLights:n=[]}=t;const r={};return r["lighting_uAmbientLight.color"]=e?Rl(e):[0,0,0],i.forEach((t,e)=>{r["lighting_uPointLight[".concat(e,"].color")]=Rl(t),r["lighting_uPointLight[".concat(e,"].position")]=t.position,r["lighting_uPointLight[".concat(e,"].attenuation")]=t.attenuation||[1,0,0]}),r.lighting_uPointLightCount=i.length,n.forEach((t,e)=>{r["lighting_uDirectionalLight[".concat(e,"].color")]=Rl(t),r["lighting_uDirectionalLight[".concat(e,"].direction")]=t.direction}),r.lighting_uDirectionalLightCount=n.length,r}const Il={name:"lights",vs:Cl,fs:Cl,getUniforms:function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ll;if("lightSources"in e){const{ambientLight:t,pointLights:i,directionalLights:n}=e.lightSources||{};return t||i&&i.length>0||n&&n.length>0?Object.assign({},Ol({ambientLight:t,pointLights:i,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in e){const i={pointLights:[],directionalLights:[]};for(const t of e.lights||[])switch(t.type){case"ambient":i.ambientLight=t;break;case"directional":i.directionalLights.push(t);break;case"point":i.pointLights.push(t)}return t({lightSources:i})}return{}},defines:{MAX_LIGHTS:3}};var kl="\nuniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, lighting_uShininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n";const Fl={};function Dl(t){const{ambient:e=.35,diffuse:i=.6,shininess:n=32,specularColor:r=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:i,lighting_uShininess:n,lighting_uSpecularColor:r.map(t=>t/255)}}function Bl(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Fl;if(!("material"in t))return{};const{material:e}=t;return e?Dl(e):{lighting_uEnabled:!1}}const jl={name:"gouraud-lighting",dependencies:[Il],vs:kl,defines:{LIGHTING_VERTEX:1},getUniforms:Bl},Nl={name:"phong-lighting",dependencies:[Il],fs:kl,defines:{LIGHTING_FRAGMENT:1},getUniforms:Bl},Ul={pickingSelectedColor:null,pickingHighlightColor:new Uint8Array([0,255,255,255]),pickingActive:!1,pickingAttribute:!1};var zl={inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ","vs:DECKGL_FILTER_COLOR":"\n picking_setPickingColor(geometry.pickingColor);\n ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "}},...{name:"picking",vs:"uniform bool picking_uActive;\nuniform bool picking_uAttribute;\nuniform vec3 picking_uSelectedColor;\nuniform bool picking_uSelectedColorValid;\n\nout vec4 picking_vRGBcolor_Avalid;\n\nconst float COLOR_SCALE = 1. / 255.;\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.001;\n}\n\nbool isVertexPicked(vec3 vertexColor) {\n return\n picking_uSelectedColorValid &&\n !picking_isColorValid(abs(vertexColor - picking_uSelectedColor));\n}\n\nvoid picking_setPickingColor(vec3 pickingColor) {\n if (picking_uActive) {\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!picking_uAttribute) {\n picking_vRGBcolor_Avalid.rgb = pickingColor * COLOR_SCALE;\n }\n } else {\n picking_vRGBcolor_Avalid.a = float(isVertexPicked(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\nvoid picking_setPickingAttribute(vec2 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\nvoid picking_setPickingAttribute(vec3 value) {\n if (picking_uAttribute) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"uniform bool picking_uActive;\nuniform vec3 picking_uSelectedColor;\nuniform vec4 picking_uHighlightColor;\n\nin vec4 picking_vRGBcolor_Avalid;\nvec4 picking_filterHighlightColor(vec4 color) {\n if (picking_uActive) {\n return color;\n }\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n float highLightAlpha = picking_uHighlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking_uHighlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\nvec4 picking_filterPickingColor(vec4 color) {\n if (picking_uActive) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\nvec4 picking_filterColor(vec4 color) {\n vec4 highightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highightColor);\n}\n\n",getUniforms:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ul;const e={};if(void 0!==t.pickingSelectedColor)if(t.pickingSelectedColor){const i=t.pickingSelectedColor.slice(0,3);e.picking_uSelectedColorValid=1,e.picking_uSelectedColor=i}else e.picking_uSelectedColorValid=0;if(t.pickingHighlightColor){const i=Array.from(t.pickingHighlightColor,t=>t/255);Number.isFinite(i[3])||(i[3]=1),e.picking_uHighlightColor=i}return void 0!==t.pickingActive&&(e.picking_uActive=Boolean(t.pickingActive),e.picking_uAttribute=Boolean(t.pickingAttribute)),e}}};const Vl=-1;function Gl(t,e,i={}){return function(t,e={}){return Math.sign(Wl(t,e))}(t,i)!==e&&(function(t,e){const{start:i=0,end:n=t.length,size:r=2}=e,s=(n-i)/r,o=Math.floor(s/2);for(let e=0;e=n),r=r.flatMap(t=>[t[0],t[1]]),Gl(r,Vl));const s=i>0,o=n+1,a=s?3*o+1:n,c=2*Math.PI/n,l=new Uint16Array(s?3*n*2:0),h=new Float32Array(3*a),u=new Float32Array(3*a);let d=0;if(s){for(let t=0;tt.position},getFillColor:{type:"accessor",value:Xl},getLineColor:{type:"accessor",value:Xl},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class Yl extends ol{getShaders(){const{gl:t}=this.context,e=!ai(t),i={},n=this.props.flatShading&&tr(t,hr);return n&&(i.FLAT_SHADING=1),super.getShaders({vs:"#version 300 es\n\n#define SHADER_NAME column-layer-vertex-shader\n\nin vec3 positions;\nin vec3 normals;\n\nin vec3 instancePositions;\nin float instanceElevations;\nin vec3 instancePositions64Low;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin float instanceStrokeWidths;\n\nin vec3 instancePickingColors;\n\n// Custom uniforms\nuniform float opacity;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform bool extruded;\nuniform bool stroked;\nuniform bool isStroke;\nuniform float coverage;\nuniform float elevationScale;\nuniform float edgeDistance;\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform int radiusUnits;\nuniform int widthUnits;\n\n// Result\nout vec4 vColor;\n#ifdef FLAT_SHADING\nout vec4 position_commonspace;\n#endif\n\nvoid main(void) {\n geometry.worldPosition = instancePositions;\n\n vec4 color = isStroke ? instanceLineColors : instanceFillColors;\n // rotate primitive position and normal\n mat2 rotationMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n\n // calculate elevation, if 3d not enabled set to 0\n // cylindar gemoetry height are between -1.0 to 1.0, transform it to between 0, 1\n float elevation = 0.0;\n // calculate stroke offset\n float strokeOffsetRatio = 1.0;\n\n if (extruded) {\n elevation = instanceElevations * (positions.z + 1.0) / 2.0 * elevationScale;\n } else if (stroked) {\n float widthPixels = clamp(\n project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),\n widthMinPixels, widthMaxPixels) / 2.0;\n float halfOffset = project_pixel_size(widthPixels) / project_size(edgeDistance * coverage * radius);\n if (isStroke) {\n strokeOffsetRatio -= sign(positions.z) * halfOffset;\n } else {\n strokeOffsetRatio -= halfOffset;\n }\n }\n\n // if alpha == 0.0 or z < 0.0, do not render element\n float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);\n float dotRadius = radius * coverage * shouldRender;\n\n geometry.pickingColor = instancePickingColors;\n\n // project center of column\n vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);\n vec3 centroidPosition64Low = instancePositions64Low;\n vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + offset) * dotRadius;\n if (radiusUnits == UNIT_METERS) {\n offset = project_size(offset);\n }\n vec3 pos = vec3(offset, 0.);\n DECKGL_FILTER_SIZE(pos, geometry);\n\n gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);\n geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n // Light calculations\n if (extruded && !isStroke) {\n#ifdef FLAT_SHADING\n position_commonspace = geometry.position;\n vColor = vec4(color.rgb, color.a * opacity);\n#else\n vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);\n vColor = vec4(lightColor, color.a * opacity);\n#endif\n } else {\n vColor = vec4(color.rgb, color.a * opacity);\n }\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME column-layer-fragment-shader\n\nprecision highp float;\n\nuniform vec3 project_uCameraPosition;\nuniform bool extruded;\nuniform bool isStroke;\n\nout vec4 fragColor;\n\nin vec4 vColor;\n#ifdef FLAT_SHADING\nin vec4 position_commonspace;\n#endif\n\nvoid main(void) {\n fragColor = vColor;\n#ifdef FLAT_SHADING\n if (extruded && !isStroke && !picking_uActive) {\n vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n fragColor.rgb = lighting_getLightColor(vColor.rgb, project_uCameraPosition, position_commonspace.xyz, normal);\n }\n#endif\n DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:i,transpileToGLSL100:e,modules:[gl,n?Nl:jl,zl]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getFillColor",defaultValue:Xl},instanceLineColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getLineColor",defaultValue:Xl},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(t){super.updateState(t);const{props:e,oldProps:i,changeFlags:n}=t,r=n.extensionsChanged||e.flatShading!==i.flatShading;if(r){var s;const{gl:t}=this.context;null===(s=this.state.model)||void 0===s||s.delete(),this.state.model=this._getModel(t),this.getAttributeManager().invalidateAll()}(r||e.diskResolution!==i.diskResolution||e.vertices!==i.vertices||(e.extruded||e.stroked)!==(i.extruded||i.stroked))&&this._updateGeometry(e)}getGeometry(t,e,i){const n=new Hl({radius:1,height:i?2:0,vertices:e,nradial:t});let r=0;if(e)for(let i=0;it,n.range=()=>e,n}function th(t,e){return $l(t,e,i=>function(t,e,i){const n=t[1]-t[0];if(n<=0)return T.warn("quantizeScale: invalid domain, returning range[0]")(),e[0];const r=n/e.length,s=Math.floor((i-t[0])/r),o=Math.max(Math.min(s,e.length-1),0);return e[o]}(t,e,i))}function eh(t,e){return $l(t,e,i=>function(t,e,i){return(i-t[0])/(t[1]-t[0])*(e[1]-e[0])+e[0]}(t,e,i))}function ih(t,e){const i=t.sort(nh);let n=0;const r=Math.max(1,e.length),s=new Array(r-1);for(;++nfunction(t,e,i){return e[function(t,e){let i=0,n=t.length;for(;i>>1;nh(t[r],e)>0?n=r:i=r+1}return i}(t,i)]}(s,e,t);return o.thresholds=()=>s,$l(t,e,o)}function nh(t,e){return t-e}function rh(t,e){const i=t.length;if(e<=0||i<2)return t[0];if(e>=1)return t[i-1];const n=(i-1)*e,r=Math.floor(n),s=t[r];return s+(t[r+1]-s)*(n-r)}function sh(t,e){const i=new Map,n=[];for(const e of t){const t="".concat(e);i.has(t)||i.set(t,n.push(e))}return $l(t,e,t=>function(t,e,i,n){const r="".concat(n);let s=e.get(r);return void 0===s&&(s=t.push(n),e.set(r,s)),i[(s-1)%i.length]}(n,i,e,t))}function oh(t){return null!=t}function ah(t,e){return("function"==typeof e?t.map(e):t).filter(oh)}function ch(t,e){return ah(t,e)}function lh(t,e){return function(t){const e=[];return t.forEach(t=>{!e.includes(t)&&oh(t)&&e.push(t)}),e}(ah(t,e))}const hh=t=>t.length,uh=t=>t.points,dh=t=>t.index,fh=(t,e)=>te?1:t>=e?0:NaN,ph={getValue:hh,getPoints:uh,getIndex:dh,filterData:null};class gh{constructor(t=[],e=ph){r(this,"maxCount",void 0),r(this,"maxValue",void 0),r(this,"minValue",void 0),r(this,"totalCount",void 0),r(this,"aggregatedBins",void 0),r(this,"sortedBins",void 0),r(this,"binMap",void 0),this.aggregatedBins=this.getAggregatedBins(t,e),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(t,e){const{getValue:i=hh,getPoints:n=uh,getIndex:r=dh,filterData:s}=e,o="function"==typeof s,a=t.length,c=[];let l=0;for(let e=0;efunction(t,e,i){return Math.max(e,Math.min(i,t))}(t,0,100));return[Math.ceil(i/100*(e-1)),Math.floor(n/100*(e-1))]}getBinMap(){const t={};for(const e of this.aggregatedBins)t[e.i]=e;return t}_updateMinMaxValues(){let t=0,e=0,i=3402823466e29,n=0;for(const r of this.aggregatedBins)t=t>r.counts?t:r.counts,e=e>r.value?e:r.value,i=ifh(t.value,e.value))),!this.sortedBins.length)return[];let e=0,i=this.sortedBins.length-1;if(Array.isArray(t)){const n=this._percentileToIndex(t);e=n[0],i=n[1]}return[this.sortedBins[e].value,this.sortedBins[i].value]}getValueDomainByScale(t,[e=0,i=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((t,e)=>fh(t.value,e.value))),!this.sortedBins.length)return[];const n=this._percentileToIndex([e,i]);return this._getScaleDomain(t,n)}_getScaleDomain(t,[e,i]){const n=this.sortedBins;switch(t){case"quantize":case"linear":return[n[e].value,n[i].value];case"quantile":return ch(n.slice(e,i+1),t=>t.value);case"ordinal":return lh(n,t=>t.value);default:return[n[e].value,n[i].value]}}}const mh={SUM:1,MEAN:2,MIN:3,MAX:4};function vh(t,e){return t+e}function _h(t,e){return e>t?e:t}function bh(t,e){return e(e.index=i.index,t(i.source,e))}(e,i),n){case mh.MIN:return t=>function(t,e){if(Number.isFinite(e))return t.length?e:null;const i=t.map(e).filter(Number.isFinite);return i.length?i.reduce(bh,1/0):null}(t,e);case mh.SUM:return t=>function(t,e){if(Number.isFinite(e))return t.length?t.length*e:null;const i=t.map(e).filter(Number.isFinite);return i.length?i.reduce(vh,0):null}(t,e);case mh.MEAN:return t=>function(t,e){if(Number.isFinite(e))return t.length?e:null;const i=t.map(e).filter(Number.isFinite);return i.length?i.reduce(vh,0)/i.length:null}(t,e);case mh.MAX:return t=>function(t,e){if(Number.isFinite(e))return t.length?e:null;const i=t.map(e).filter(Number.isFinite);return i.length?i.reduce(_h,-1/0):null}(t,e);default:return null}}function wh(t,e={}){return i=>(e.indices=i.map(t=>t.index),t(i.map(t=>t.source),e))}function xh(){}const Eh=["getBins","getDomain","getScaleFunc"],Th=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],Ah=t=>t.cellSize;class Ph{constructor(t){this.state={layerData:{},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=t.getCellSize||Ah,this._getAggregator=t.getAggregator,this._addDimension(t.dimensions||Th)}static defaultDimensions(){return Th}updateState(t,e){const{oldProps:i,props:n,changeFlags:r}=t;this.updateGetValueFuncs(i,n,r);const s=this.needsReProjectPoints(i,n,r);let o=!1;if(r.dataChanged||s)this.getAggregatedData(n,e),o=!0;else{(this.getDimensionChanges(i,n,r)||[]).forEach(t=>"function"==typeof t&&t()),o=!0}return this.setState({aggregationDirty:o}),this.state}setState(t){this.state={...this.state,...t}}setDimensionState(t,e){this.setState({dimensions:{...this.state.dimensions,[t]:{...this.state.dimensions[t],...e}}})}normalizeResult(t={}){return t.hexagons?{data:t.hexagons,...t}:t.layerData?{data:t.layerData,...t}:t}getAggregatedData(t,e){const i=this._getAggregator(t)(t,e);this.setState({layerData:this.normalizeResult(i)}),this.changeFlags={layerData:!0},this.getSortedBins(t)}updateGetValueFuncs(t,e,i){for(const n in this.dimensionUpdaters){const{value:r,weight:s,aggregation:o}=this.dimensionUpdaters[n].getBins.triggers;let a=e[r.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[n].getBins,t,e,i)&&(a=a?wh(a,{data:e.data}):yh(e[o.prop],e[s.prop],{data:e.data})),a&&this.setDimensionState(n,{getValue:a})}}needsReProjectPoints(t,e,i){return this._getCellSize(t)!==this._getCellSize(e)||this._getAggregator(t)!==this._getAggregator(e)||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPosition)}addDimension(t){this._addDimension(t)}_addDimension(t=[]){t.forEach(t=>{const{key:e}=t;this.dimensionUpdaters[e]=this.getDimensionUpdaters(t),this.state.dimensions[e]={getValue:null,domain:null,sortedBins:null,scaleFunc:xh}})}getDimensionUpdaters({key:t,accessor:e,pickingInfo:i,getBins:n,getDomain:r,getScaleFunc:s,nullValue:o}){return{key:t,accessor:e,pickingInfo:i,getBins:{updater:this.getDimensionSortedBins,...n},getDomain:{updater:this.getDimensionValueDomain,...r},getScaleFunc:{updater:this.getDimensionScale,...s},attributeAccessor:this.getSubLayerDimensionAttribute(t,o)}}needUpdateDimensionStep(t,e,i,n){return Object.values(t.triggers).some(t=>t.updateTrigger?n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged[t.updateTrigger]):e[t.prop]!==i[t.prop])}getDimensionChanges(t,e,i){const n=[];for(const r in this.dimensionUpdaters){const s=Eh.find(n=>this.needUpdateDimensionStep(this.dimensionUpdaters[r][n],t,e,i));s&&n.push(this.dimensionUpdaters[r][s].updater.bind(this,e,this.dimensionUpdaters[r]))}return n.length?n:null}getUpdateTriggers(t){const e=t.updateTriggers||{},i={};for(const n in this.dimensionUpdaters){const{accessor:r}=this.dimensionUpdaters[n];i[r]={},Eh.forEach(s=>{Object.values(this.dimensionUpdaters[n][s].triggers).forEach(({prop:n,updateTrigger:s})=>{if(s){const t=e[s];"object"!=typeof t||Array.isArray(t)?void 0!==t&&(i[r][n]=t):Object.assign(i[r],t)}else i[r][n]=t[n]})})}return i}getSortedBins(t){for(const e in this.dimensionUpdaters)this.getDimensionSortedBins(t,this.dimensionUpdaters[e])}getDimensionSortedBins(t,e){const{key:i}=e,{getValue:n}=this.state.dimensions[i],r=new gh(this.state.layerData.data||[],{getValue:n,filterData:t._filterData});this.setDimensionState(i,{sortedBins:r}),this.getDimensionValueDomain(t,e)}getDimensionValueDomain(t,e){const{getDomain:i,key:n}=e,{triggers:{lowerPercentile:r,upperPercentile:s,scaleType:o}}=i,a=this.state.dimensions[n].sortedBins.getValueDomainByScale(t[o.prop],[t[r.prop],t[s.prop]]);this.setDimensionState(n,{valueDomain:a}),this.getDimensionScale(t,e)}getDimensionScale(t,e){const{key:i,getScaleFunc:n,getDomain:r}=e,{domain:s,range:o}=n.triggers,{scaleType:a}=r.triggers,{onSet:c}=n,l=t[o.prop],h=t[s.prop]||this.state.dimensions[i].valueDomain,u=function(t){switch(t){case"quantize":return th;case"linear":return eh;case"quantile":return ih;case"ordinal":return sh;default:return th}}(a&&t[a.prop])(h,l);"object"==typeof c&&"function"==typeof t[c.props]&&t[c.props](u.domain()),this.setDimensionState(i,{scaleFunc:u})}getSubLayerDimensionAttribute(t,e){return i=>{const{sortedBins:n,scaleFunc:r}=this.state.dimensions[t],s=n.binMap[i.index];if(s&&0===s.counts)return e;const o=s&&s.value,a=r.domain();return o>=a[0]&&o<=a[a.length-1]?r(o):e}}getSubLayerAccessors(t){const e={};for(const i in this.dimensionUpdaters){const{accessor:n}=this.dimensionUpdaters[i];e[n]=this.getSubLayerDimensionAttribute(t,i)}return e}getPickingInfo({info:t}){let e=null;if(t.picked&&t.index>-1){const i=this.state.layerData.data[t.index],n={};for(const t in this.dimensionUpdaters){const{pickingInfo:e}=this.dimensionUpdaters[t],{sortedBins:r}=this.state.dimensions[t],s=r.binMap[i.index]&&r.binMap[i.index].value;n[e]=s}e=Object.assign(n,i,{points:i.filteredPoints||i.points})}return t.picked=Boolean(e),t.object=e,t}getAccessor(t){return this.dimensionUpdaters.hasOwnProperty(t)?this.dimensionUpdaters[t].attributeAccessor:xh}}function Sh(){}const Mh={colorDomain:null,colorRange:yl,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:Sh,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:Sh,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:function(t,e){const{data:i,radius:n}=t,{viewport:r,attributes:s}=e,o=i.length?function(t,e){const{attributes:i}=e,n=i.positions.value,{size:r}=i.positions.getAccessor();let s,o=1/0,a=1/0,c=-1/0,l=-1/0;for(s=0;s1){var g=h-f,m=f+(h_*_+b*b&&(f=m+(1&d?1:-1)/2,d=v)}var y=f+"-"+d,w=r[y];w?w.push(l):(s.push(w=r[y]=[l]),w.x=(f+(1&d)/2)*e,w.y=d*i)}return s}function h(t){var e=0,i=0;return Kl.map((function(n){var r=Math.sin(n)*t,s=-Math.cos(n)*t,o=r-e,a=s-i;return e=r,i=s,[o,a]}))}return l.hexagon=function(e){return"m"+h(null==e?t:+e).join("l")+"z"},l.centers=function(){for(var a=[],c=Math.round(r/i),l=Math.round(n/e),h=c*i;ht.screenCoord[0]).y(t=>t.screenCoord[1])(c).map((t,e)=>({position:r.unprojectFlat([t.x,t.y]),points:t,index:e})),radiusCommon:a}},getPosition:{type:"accessor",value:t=>t.position},material:!0,_filterData:{type:"function",value:null,optional:!0}};class Ch extends bl{constructor(...t){super(...t),r(this,"state",void 0)}initializeState(){const t=new Ph({getAggregator:t=>t.hexagonAggregator,getCellSize:t=>t.radius});this.state={cpuAggregator:t,aggregatorState:t.state,vertices:null};this.getAttributeManager().add({positions:{size:3,type:5130,accessor:"getPosition"}})}updateState(t){if(super.updateState(t),t.changeFlags.propsOrDataChanged){const e=this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==e.layerData){const{hexagonVertices:t}=e.layerData||{};this.setState({vertices:t&&this.convertLatLngToMeterOffset(t)})}this.setState({aggregatorState:e})}}convertLatLngToMeterOffset(t){const{viewport:e}=this.context;if(Array.isArray(t)&&6===t.length){const i=t[0],n=t[3],r=[(i[0]+n[0])/2,(i[1]+n[1])/2],s=e.projectFlat(r),{metersPerUnit:o}=e.getDistanceScales(r);return t.map(t=>{const i=e.projectFlat(t);return[(i[0]-s[0])*o[0],(i[1]-s[1])*o[1]]})}return T.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){const{elevationScale:t,extruded:e,coverage:i,material:n,transitions:r}=this.props,{aggregatorState:s,vertices:o}=this.state,a=this.getSubLayerClass("hexagon-cell",Yl),c=this._getSublayerUpdateTriggers();return new a({...o?{vertices:o,radius:1}:{radius:s.layerData.radiusCommon||1,radiusUnits:"common",angle:90},diskResolution:6,elevationScale:t,extruded:e,coverage:i,material:n,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:r&&{getFillColor:r.getColorValue||r.getColorWeight,getElevation:r.getElevationValue||r.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:c}),{data:s.layerData.data})}}r(Ch,"layerName","HexagonLayer"),r(Ch,"defaultProps",Mh);let Lh=1,Rh=1;class Oh{constructor(){this.time=0,this.channels=new Map,this.animations=new Map,this.playing=!1,this.lastEngineTime=-1}addChannel(t){const{delay:e=0,duration:i=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=t,s=Lh++,o={time:0,delay:e,duration:i,rate:n,repeat:r};return this._setChannelTime(o,this.time),this.channels.set(s,o),s}removeChannel(t){this.channels.delete(t);for(const[e,i]of this.animations)i.channel===t&&this.detachAnimation(e)}isFinished(t){const e=this.channels.get(t);return void 0!==e&&this.time>=e.delay+e.duration*e.repeat}getTime(t){if(void 0===t)return this.time;const e=this.channels.get(t);return void 0===e?-1:e.time}setTime(t){this.time=Math.max(0,t);const e=this.channels.values();for(const t of e)this._setChannelTime(t,this.time);const i=this.animations.values();for(const t of i){const{animation:e,channel:i}=t;e.setTime(this.getTime(i))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,e){const i=Rh++;return this.animations.set(i,{animation:t,channel:e}),t.setTime(this.getTime(e)),i}detachAnimation(t){this.animations.delete(t)}update(t){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=t),this.setTime(this.time+(t-this.lastEngineTime)),this.lastEngineTime=t)}_setChannelTime(t,e){const i=e-t.delay;i>=t.duration*t.repeat?t.time=t.duration*t.rate:(t.time=Math.max(0,i)%t.duration,t.time*=t.rate)}}class Ih{constructor(t,e,i){r(this,"id",void 0),r(this,"context",void 0),r(this,"isLoaded",void 0),r(this,"persistent",void 0),r(this,"_loadCount",0),r(this,"_subscribers",new Set),r(this,"_data",void 0),r(this,"_loader",void 0),r(this,"_error",void 0),r(this,"_content",void 0),this.id=t,this.context=i,this.setData(e)}subscribe(t){this._subscribers.add(t)}unsubscribe(t){this._subscribers.delete(t)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(t,e){if(t===this._data&&!e)return;this._data=t;const i=++this._loadCount;let n=t;"string"==typeof t&&(n=el(t)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(t=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=t)}).catch(t=>{this._loadCount===i&&(this.isLoaded=!0,this._error=t||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=t);for(const t of this._subscribers)t.onChange(this.getData())}}class kh{constructor({gl:t,protocol:e}){r(this,"protocol",void 0),r(this,"_context",void 0),r(this,"_resources",void 0),r(this,"_consumers",void 0),r(this,"_pruneRequest",void 0),this.protocol=e||"resource://",this._context={gl:t,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(t){return!!t.startsWith(this.protocol)||t in this._resources}add({resourceId:t,data:e,forceUpdate:i=!1,persistent:n=!0}){let r=this._resources[t];r?r.setData(e,i):(r=new Ih(t,e,this._context),this._resources[t]=r),r.persistent=n}remove(t){const e=this._resources[t];e&&(e.delete(),delete this._resources[t])}unsubscribe({consumerId:t}){const e=this._consumers[t];if(e){for(const t in e){const i=e[t],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[t],this.prune()}}subscribe({resourceId:t,onChange:e,consumerId:i,requestId:n="default"}){const{_resources:r,protocol:s}=this;t.startsWith(s)&&(r[t=t.replace(s,"")]||this.add({resourceId:t,data:null,persistent:!1}));const o=r[t];if(this._track(i,n,o,e),o)return o.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const t in this._resources)this._resources[t].delete()}_track(t,e,i,n){const r=this._consumers,s=r[t]=r[t]||{},o=s[e]||{},a=o.resourceId&&this._resources[o.resourceId];a&&(a.unsubscribe(o),this.prune()),i&&(s[e]=o,o.onChange=n,o.resourceId=i.id,i.subscribe(o))}_prune(){this._pruneRequest=null;for(const t of Object.keys(this._resources)){const e=this._resources[t];e.persistent||e.inUse()||(e.delete(),delete this._resources[t])}}}const Fh=[pl],Dh=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"];function Bh(t){const e=Ns.getDefaultProgramManager(t);for(const t of Fh)e.addDefaultModule(t);for(const t of Dh)e.addShaderHook(t);return e}class jh{constructor(t,{deck:e,stats:i,viewport:n,timeline:s}={}){r(this,"layers",void 0),r(this,"context",void 0),r(this,"resourceManager",void 0),r(this,"_lastRenderedLayers",[]),r(this,"_needsRedraw",!1),r(this,"_needsUpdate",!1),r(this,"_nextLayers",null),r(this,"_debug",!1),r(this,"activateViewport",t=>{Ro("layerManager.activateViewport",this,t),t&&(this.context.viewport=t)}),this.layers=[],this.resourceManager=new kh({gl:t,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,gl:t,deck:e,programManager:t&&Bh(t),stats:i||new cn({id:"deck.gl"}),viewport:n||new ie({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:s||new Oh,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const t of this.layers)this._finalizeLayer(t)}needsRedraw(t={clearRedrawFlags:!1}){let e=this._needsRedraw;t.clearRedrawFlags&&(this._needsRedraw=!1);for(const i of this.layers){const n=i.getNeedsRedraw(t);e=e||n}return e}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._needsUpdate}setNeedsRedraw(t){this._needsRedraw=this._needsRedraw||t}setNeedsUpdate(t){this._needsUpdate=this._needsUpdate||t}getLayers({layerIds:t}={}){return t?this.layers.filter(e=>t.find(t=>0===e.id.indexOf(t))):this.layers}setProps(t){"debug"in t&&(this._debug=t.debug),"userData"in t&&(this.context.userData=t.userData),"layers"in t&&(this._nextLayers=t.layers),"onError"in t&&(this.context.onError=t.onError)}setLayers(t,e){Ro("layerManager.setLayers",this,e,t),this._lastRenderedLayers=t;const i=vo(t,Boolean);for(const t of i)t.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){const t=this.needsUpdate();t&&(this.setNeedsRedraw("updating layers: ".concat(t)),this.setLayers(this._nextLayers||this._lastRenderedLayers,t)),this._nextLayers=null}_handleError(t,e,i){i.raiseError(e,"".concat(t," of ").concat(i))}_updateLayers(t,e){const i={};for(const e of t)i[e.id]?T.warn("Multiple old layers with same id ".concat(e.id))():i[e.id]=e;const n=[];this._updateSublayersRecursively(e,i,n),this._finalizeOldLayers(i);let r=!1;for(const t of n)if(t.hasUniformTransition()){r="Uniform transition in ".concat(t);break}this._needsUpdate=r,this.layers=n}_updateSublayersRecursively(t,e,i){for(const n of t){n.context=this.context;const t=e[n.id];null===t&&T.warn("Multiple new layers with same id ".concat(n.id))(),e[n.id]=null;let r=null;try{this._debug&&t!==n&&n.validateProps(),t?(this._transferLayerState(t,n),this._updateLayer(n)):this._initializeLayer(n),i.push(n),r=n.isComposite?n.getSubLayers():null}catch(t){this._handleError("matching",t,n)}r&&this._updateSublayersRecursively(r,e,i)}}_finalizeOldLayers(t){for(const e in t){const i=t[e];i&&this._finalizeLayer(i)}}_initializeLayer(t){try{t._initialize(),t.lifecycle=Go}catch(e){this._handleError("initialization",e,t)}}_transferLayerState(t,e){e._transferState(t),e.lifecycle=Vo,e!==t&&(t.lifecycle=Wo)}_updateLayer(t){try{t._update()}catch(e){this._handleError("update",e,t)}}_finalizeLayer(t){this._needsRedraw=this._needsRedraw||"finalized ".concat(t),t.lifecycle=Ho;try{t._finalize(),t.lifecycle=Xo}catch(e){this._handleError("finalization",e,t)}}}class Nh{constructor(t){r(this,"width",void 0),r(this,"height",void 0),r(this,"views",void 0),r(this,"viewState",void 0),r(this,"controllers",void 0),r(this,"timeline",void 0),r(this,"_viewports",void 0),r(this,"_viewportMap",void 0),r(this,"_isUpdating",void 0),r(this,"_needsRedraw",void 0),r(this,"_needsUpdate",void 0),r(this,"_eventManager",void 0),r(this,"_eventCallbacks",void 0),this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=t.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=t.eventManager,this._eventCallbacks={onViewStateChange:t.onViewStateChange,onInteractionStateChange:t.onInteractionStateChange},Object.seal(this),this.setProps(t)}finalize(){for(const t in this.controllers){const e=this.controllers[t];e&&e.finalize()}this.controllers={}}needsRedraw(t={clearRedrawFlags:!1}){const e=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),e}setNeedsUpdate(t){this._needsUpdate=this._needsUpdate||t,this._needsRedraw=this._needsRedraw||t}updateViewStates(){for(const t in this.controllers){const e=this.controllers[t];e&&e.updateTransition()}}getViewports(t){return t?this._viewports.filter(e=>e.containsPixel(t)):this._viewports}getViews(){const t={};return this.views.forEach(e=>{t[e.id]=e}),t}getView(t){return this.views.find(e=>e.id===t)}getViewState(t){const e="string"==typeof t?this.getView(t):t,i=e&&this.viewState[e.getViewStateId()]||this.viewState;return e?e.filterViewState(i):i}getViewport(t){return this._viewportMap[t]}unproject(t,e){const i=this.getViewports(),n={x:t[0],y:t[1]};for(let r=i.length-1;r>=0;--r){const s=i[r];if(s.containsPixel(n)){const i=t.slice();return i[0]-=s.x,i[1]-=s.y,s.unproject(i,e)}}return null}setProps(t){t.views&&this._setViews(t.views),t.viewState&&this._setViewState(t.viewState),("width"in t||"height"in t)&&this._setSize(t.width,t.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(t,e){t===this.width&&e===this.height||(this.width=t,this.height=e,this.setNeedsUpdate("Size changed"))}_setViews(t){t=vo(t,Boolean);this._diffViews(t,this.views)&&this.setNeedsUpdate("views changed"),this.views=t}_setViewState(t){if(t){!oe(t,this.viewState)&&this.setNeedsUpdate("viewState changed"),this.viewState=t}else T.warn("missing `viewState` or `initialViewState`")()}_onViewStateChange(t,e){this._eventCallbacks.onViewStateChange&&this._eventCallbacks.onViewStateChange({...e,viewId:t})}_createController(t,e){return new(0,e.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._onViewStateChange.bind(this,e.id),onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:e=>{var i;return null===(i=this.getView(t.id))||void 0===i?void 0:i.makeViewport({viewState:e,width:this.width,height:this.height})}})}_updateController(t,e,i,n){const r=t.controller;if(r){const s={...e,...r,id:t.id,x:i.x,y:i.y,width:i.width,height:i.height};return n||(n=this._createController(t,s)),n&&n.setProps(s),n}return null}_rebuildViewports(){const{views:t}=this,e=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let n=t.length;n--;){const r=t[n],s=this.getViewState(r),o=r.makeViewport({viewState:s,width:this.width,height:this.height});let a=e[r.id];const c=Boolean(r.controller);c&&!a&&(i=!0),!i&&c||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,s,o,a),this._viewports.unshift(o)}for(const t in e){const i=e[t];i&&!this.controllers[t]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(t=>{t.id&&(this._viewportMap[t.id]=this._viewportMap[t.id]||t)})}_diffViews(t,e){return t.length!==e.length||t.some((i,n)=>!t[n].equals(e[n]))}}const Uh=[255,255,255],zh=1;let Vh=0;class Gh{constructor(t={}){r(this,"id",void 0),r(this,"color",void 0),r(this,"intensity",void 0),r(this,"type","ambient");const{color:e=Uh}=t,{intensity:i=zh}=t;this.id=t.id||"ambient-".concat(Vh++),this.color=e,this.intensity=i}}const Wh=[255,255,255],Hh=1,Xh=[0,0,-1];let qh=0;class Yh{constructor(t={}){r(this,"id",void 0),r(this,"color",void 0),r(this,"intensity",void 0),r(this,"type","directional"),r(this,"direction",void 0),r(this,"shadow",void 0);const{color:e=Wh}=t,{intensity:i=Hh}=t,{direction:n=Xh}=t,{_shadow:s=!1}=t;this.id=t.id||"directional-".concat(qh++),this.color=e,this.intensity=i,this.type="directional",this.direction=new q(n).normalize().toArray(),this.shadow=s}getProjectedLight(t){return this}}class Zh extends class{constructor(t,e={id:"pass"}){r(this,"id",void 0),r(this,"gl",void 0),r(this,"props",void 0);const{id:i}=e;this.id=i,this.gl=t,this.props={...e}}setProps(t){Object.assign(this.props,t)}render(t){}cleanup(){}}{constructor(...t){super(...t),r(this,"_lastRenderIndex",-1)}render(t){return ji(this.gl,{framebuffer:t.target}),this._drawLayers(t)}_drawLayers(t){const{target:e,moduleParameters:i,viewports:n,views:r,onViewportActive:s,clearStack:o=!0,clearCanvas:a=!0}=t;t.pass=t.pass||"unknown";const c=this.gl;a&&function(t){const e=t.drawingBufferWidth,i=t.drawingBufferHeight;ji(t,{viewport:[0,0,e,i]}),t.clear(16640)}(c),o&&(this._lastRenderIndex=-1);const l=[];for(const o of n){const n=r&&r[o.id];s(o);const a=this._getDrawLayerParams(o,t),h=o.subViewports||[o];for(const r of h){const s=this._drawLayersInViewport(c,{target:e,moduleParameters:i,viewport:r,view:n,pass:t.pass,layers:t.layers},a);l.push(s)}}return l}_getDrawLayerParams(t,{layers:e,pass:i,layerFilter:n,cullRect:r,effects:s,moduleParameters:o}){const a=[],c=function t(e=0,i={}){const n={},r=(s,o)=>{const a=s.props._offset,c=s.id,l=s.parent&&s.parent.id;let h;if(l&&!(l in i)&&r(s.parent,!1),l in n){const e=n[l]=n[l]||t(i[l],i);h=e(s,o),n[c]=e}else Number.isFinite(a)?(h=a+(i[l]||0),n[c]=null):h=e;return o&&h>=e&&(e=h+1),i[c]=h,h};return r}(this._lastRenderIndex+1),l={layer:e[0],viewport:t,isPicking:i.startsWith("picking"),renderPass:i,cullRect:r},h={};for(let r=0;rWn(t,e))}const l={totalCount:e.length,visibleCount:0,compositeCount:0,pickableCount:0};ji(t,{viewport:c});for(let t=0;t{const i=t.viewports[0],n=zi(this.gl),r=i.width*n,s=i.height*n;r===e.width&&s===e.height||e.resize({width:r,height:s}),super.render({...t,target:e,pass:"shadow"})})}shouldDrawLayer(t){return!1!==t.props.shadowEnabled}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.delete(),this.fbo=null),this.shadowMap&&(this.shadowMap.delete(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.delete(),this.depthBuffer=null)}}const Qh=oa((function({viewport:t,center:e}){return new vt(t.viewProjectionMatrix).invert().transform(e)})),Jh=oa((function({viewport:t,shadowMatrices:e}){const i=[],n=t.pixelUnprojectionMatrix,r=t.isGeospatial?void 0:1,s=[[0,0,r],[t.width,0,r],[0,t.height,r],[t.width,t.height,r],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(t=>function(t,e){const[i,n,r]=t,s=zt([i,n,r],e);if(Number.isFinite(r))return s;return[s[0],s[1],0]}(t,n));for(const n of e){const e=n.clone().translate(new q(t.center).negate()),r=s.map(t=>e.transform(t)),o=(new vt).ortho({left:Math.min(...r.map(t=>t[0])),right:Math.max(...r.map(t=>t[0])),bottom:Math.min(...r.map(t=>t[1])),top:Math.max(...r.map(t=>t[1])),near:Math.min(...r.map(t=>-t[2])),far:Math.max(...r.map(t=>-t[2]))});i.push(o.multiplyRight(n))}return i})),$h=[0,0,0,1],tu=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];var eu={name:"shadow",dependencies:[pl],vs:"\nconst int max_lights = 2;\nuniform mat4 shadow_uViewProjectionMatrices[max_lights];\nuniform vec4 shadow_uProjectCenters[max_lights];\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform int shadow_uLightId;\nuniform float shadow_uLightCount;\n\nvarying vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n if (shadow_uDrawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]);\n }\n if (shadow_uUseShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow_uLightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n",fs:"\nconst int max_lights = 2;\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\nuniform vec4 shadow_uColor;\nuniform float shadow_uLightCount;\n\nvarying vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture2D(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow_uDrawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow_uUseShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow_uLightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow_uColor.a / shadow_uLightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n",inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:(t={},e={})=>"viewport"in t&&(t.drawToShadowMap||t.shadowMaps&&t.shadowMaps.length>0)?function(t,e){const{shadowEnabled:i=!0}=t;if(!i||!t.shadowMatrices||!t.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1};const n={shadow_uDrawShadowMap:Boolean(t.drawToShadowMap),shadow_uUseShadowMap:!!t.shadowMaps&&t.shadowMaps.length>0,shadow_uColor:t.shadowColor||$h,shadow_uLightId:t.shadowLightId||0,shadow_uLightCount:t.shadowMatrices.length},r=Qh({viewport:t.viewport,center:e.project_uCenter}),s=[],o=Jh({shadowMatrices:t.shadowMatrices,viewport:t.viewport}).slice();for(let i=0;i0?n["shadow_uShadowMap".concat(e)]=t.shadowMaps[e]:n["shadow_uShadowMap".concat(e)]=t.dummyShadowMap;return n}(t,e):{}};const iu={color:[255,255,255],intensity:1},nu=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],ru=[0,0,0,200/255];class su{constructor(t={}){r(this,"id","lighting-effect"),r(this,"props",null),r(this,"shadowColor",ru),r(this,"shadow",void 0),r(this,"ambientLight",null),r(this,"directionalLights",[]),r(this,"pointLights",[]),r(this,"shadowPasses",[]),r(this,"shadowMaps",[]),r(this,"dummyShadowMap",null),r(this,"programManager",void 0),r(this,"shadowMatrices",void 0);for(const e in t){const i=t[e];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow)}preRender(t,{layers:e,layerFilter:i,viewports:n,onViewportActive:r,views:s}){if(this.shadow){this.shadowMatrices=this._calculateMatrices(),0===this.shadowPasses.length&&this._createShadowPasses(t),this.programManager||(this.programManager=Ns.getDefaultProgramManager(t),eu&&this.programManager.addDefaultModule(eu)),this.dummyShadowMap||(this.dummyShadowMap=new Nn(t,{width:1,height:1}));for(let t=0;te.getProjectedLight({layer:t})),pointLights:this.pointLights.map(e=>e.getProjectedLight({layer:t}))},e}cleanup(){for(const t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.delete(),this.dummyShadowMap=null),this.shadow&&this.programManager&&(this.programManager.removeDefaultModule(eu),this.programManager=null)}_calculateMatrices(){const t=[];for(const e of this.directionalLights){const i=(new vt).lookAt({eye:new q(e.direction).negate()});t.push(i)}return t}_createShadowPasses(t){for(let e=0;esuper.render({...t,target:this.fbo,pass:"mask"}))}shouldDrawLayer(t){return t.props.operation===Qt}delete(){this.fbo.delete(),this.maskMap.delete()}}const au=(new vt).lookAt({eye:[0,0,1]});function cu({width:t,height:e,near:i,far:n,padding:r}){let s=-t/2,o=t/2,a=-e/2,c=e/2;if(r){const{left:i=0,right:n=0,top:l=0,bottom:h=0}=r,u=L((i+t-n)/2,0,t)-t/2,d=L((l+e-h)/2,0,e)-e/2;s-=u,o-=u,a+=d,c+=d}return(new vt).ortho({left:s,right:o,bottom:a,top:c,near:i,far:n})}class lu extends ie{constructor(t){const{width:e,height:i,near:n=.1,far:r=1e3,zoom:s=0,target:o=[0,0,0],padding:a=null,flipY:c=!0}=t,l=Array.isArray(s)?s[0]:s,h=Array.isArray(s)?s[1]:s,u=Math.min(l,h),d=Math.pow(2,u);let f;if(l!==h){const t=Math.pow(2,l),e=Math.pow(2,h);f={unitsPerMeter:[t/d,e/d,1],metersPerUnit:[d/t,d/e,1]}}super({...t,longitude:void 0,position:o,viewMatrix:au.clone().scale([d,d*(c?-1:1),d]),projectionMatrix:cu({width:e||1,height:i||1,padding:a,near:n,far:r}),zoom:u,distanceScales:f})}projectFlat([t,e]){const{unitsPerMeter:i}=this.distanceScales;return[t*i[0],e*i[1]]}unprojectFlat([t,e]){const{metersPerUnit:i}=this.distanceScales;return[t*i[0],e*i[1]]}panByPosition(t,e){const i=zt(e,this.pixelUnprojectionMatrix),n=at([],this.projectFlat(t),ct([],i)),r=at([],this.center,n);return{target:this.unprojectFlat(r)}}}class hu extends Oe{constructor(t){const{width:e,height:i,rotationX:n=0,rotationOrbit:s=0,target:o=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:h=-1/0,maxZoom:u=1/0,startPanPosition:d,startRotatePos:f,startRotationX:p,startRotationOrbit:g,startZoomPosition:m,startZoom:v}=t;super({width:e,height:i,rotationX:n,rotationOrbit:s,target:o,zoom:a,minRotationX:c,maxRotationX:l,minZoom:h,maxZoom:u},{startPanPosition:d,startRotatePos:f,startRotationX:p,startRotationOrbit:g,startZoomPosition:m,startZoom:v}),r(this,"makeViewport",void 0),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanPosition:this._unproject(t)})}pan({pos:t,startPosition:e}){const i=this.getState().startPanPosition||e;if(!i)return this;const n=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:t,deltaAngleX:e=0,deltaAngleY:i=0}){const{startRotatePos:n,startRotationX:r,startRotationOrbit:s}=this.getState(),{width:o,height:a}=this.getViewportProps();if(!n||void 0===r||void 0===s)return this;let c;if(t){let e=(t[0]-n[0])/o;const i=(t[1]-n[1])/a;(r<-90||r>90)&&(e*=-1),c={rotationX:r+180*i,rotationOrbit:s+180*e}}else c={rotationX:r+i,rotationOrbit:s+e};return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(t){const e=t.getViewportProps(),i={...this.getViewportProps()},{rotationOrbit:n}=i;return Math.abs(n-e.rotationOrbit)>180&&(i.rotationOrbit=n<0?n+360:n-360),i}zoomStart({pos:t}){return this._getUpdatedState({startZoomPosition:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:e,scale:i}){let{startZoom:n,startZoomPosition:r}=this.getState();if(r||(n=this.getViewportProps().zoom,r=this._unproject(e)||this._unproject(t)),!r)return this;const s=this._calculateNewZoom({scale:i,startZoom:n}),o=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...o.panByPosition(r,t)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(t=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:t})})}zoomOut(t=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/t})})}moveLeft(t=50){return this._panFromCenter([-t,0])}moveRight(t=50){return this._panFromCenter([t,0])}moveUp(t=50){return this._panFromCenter([0,-t])}moveDown(t=50){return this._panFromCenter([0,t])}rotateLeft(t=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-t})}rotateRight(t=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+t})}rotateUp(t=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-t})}rotateDown(t=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+t})}_unproject(t){const e=this.makeViewport(this.getViewportProps());return t&&e.unproject(t)}_calculateNewZoom({scale:t,startZoom:e}){const{maxZoom:i,minZoom:n}=this.getViewportProps();void 0===e&&(e=this.getViewportProps().zoom);return L(e+Math.log2(t),n,i)}_panFromCenter(t){const{width:e,height:i,target:n}=this.getViewportProps();return this.pan({startPosition:n,pos:[e/2+t[0],i/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}applyConstraints(t){const{maxZoom:e,minZoom:i,zoom:n,maxRotationX:r,minRotationX:s,rotationOrbit:o}=t;return t.zoom=Array.isArray(n)?[L(n[0],i,e),L(n[1],i,e)]:L(n,i,e),t.rotationX=L(t.rotationX,s,r),(o<-180||o>180)&&(t.rotationOrbit=function(t,e){const i=t%e;return i<0?e+i:i}(o+180,360)-180),t}}class uu extends hu{constructor(t){super(t),r(this,"zoomAxis",void 0),this.zoomAxis=t.zoomAxis||"all"}_calculateNewZoom({scale:t,startZoom:e}){const{maxZoom:i,minZoom:n}=this.getViewportProps();void 0===e&&(e=this.getViewportProps().zoom);let r=Math.log2(t);if(Array.isArray(e)){let[t,s]=e;switch(this.zoomAxis){case"X":t=L(t+r,n,i);break;case"Y":s=L(s+r,n,i);break;default:let e=Math.min(t+r,s+r);ei&&(r+=i-e),t+=r,s+=r}return[t,s]}return L(e+r,n,i)}}class du extends Re{constructor(...t){super(...t),r(this,"ControllerState",uu),r(this,"transition",{transitionDuration:300,transitionInterpolator:new we(["target","zoom"])}),r(this,"dragMode","pan")}_onPanRotate(){return!1}}class fu extends ce{get ViewportType(){return lu}get ControllerType(){return du}}r(fu,"displayName","OrthographicView");class pu{constructor(){r(this,"id","mask-effect"),r(this,"props",null),r(this,"useInPicking",!0),r(this,"dummyMaskMap",void 0),r(this,"channels",[]),r(this,"masks",null),r(this,"maskPass",void 0),r(this,"maskMap",void 0),r(this,"lastViewport",void 0)}preRender(t,{layers:e,layerFilter:i,viewports:n,onViewportActive:r,views:s}){this.dummyMaskMap||(this.dummyMaskMap=new Nn(t,{width:1,height:1}));const o=e.filter(t=>t.props.visible&&t.props.operation===Qt);if(0===o.length)return this.masks=null,void(this.channels.length=0);this.masks={},this.maskPass||(this.maskPass=new ou(t,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap);const a=this._sortMaskChannels(o),c=n[0],l=!this.lastViewport||!this.lastViewport.equals(c);for(const t in a)this._renderChannel(a[t],{layerFilter:i,onViewportActive:r,views:s,viewport:c,viewportChanged:l})}_renderChannel(t,{layerFilter:e,onViewportActive:i,views:n,viewport:r,viewportChanged:s}){const o=this.channels[t.index];if(!o)return;const a=t===o||o.layers.length!==t.layers.length||t.layerBounds.some((t,e)=>t!==o.layerBounds[e]);if(t.bounds=o.bounds,t.maskBounds=o.maskBounds,this.channels[t.index]=t,(a||s)&&(this.lastViewport=r,t.bounds=function({layers:t,viewport:e}){let i=null;for(const e of t){const t=e.getBounds();t&&(i?(i[0]=Math.min(i[0],t[0][0]),i[1]=Math.min(i[1],t[0][1]),i[2]=Math.max(i[2],t[1][0]),i[3]=Math.max(i[3],t[1][1])):i=[t[0][0],t[0][1],t[1][0],t[1][1]])}const n=e.getBounds();if(!i)return n;const r=function(t){const e={x:t[2]-t[0],y:t[3]-t[1]},i={x:t[0]+.5*e.x,y:t[1]+.5*e.y};return[i.x-e.x,i.y-e.y,i.x+e.x,i.y+e.y]}(n);return i[2]-i[0]4){T.warn("Too many mask layers. The max supported is 4")();continue}r={id:t,index:this.channels.findIndex(e=>(null==e?void 0:e.id)===t),layers:[],layerBounds:[],coordinateOrigin:n.root.props.coordinateOrigin,coordinateSystem:n.root.props.coordinateSystem},e[t]=r}r.layers.push(n),r.layerBounds.push(n.getBounds())}for(let t=0;t<4;t++){const i=this.channels[t];i&&i.id in e||(this.channels[t]=null)}for(const t in e){const i=e[t];i.index<0&&(i.index=this.channels.findIndex(t=>!t),this.channels[i.index]=i)}return e}getModuleParameters(){return{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}}cleanup(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0}}const gu=new su;class mu{constructor(){r(this,"effects",void 0),r(this,"_internalEffects",void 0),r(this,"_needsRedraw",void 0),this.effects=[],this._internalEffects=[],this._needsRedraw="Initial render",this.setEffects()}setProps(t){"effects"in t&&(t.effects.length===this.effects.length&&oe(t.effects,this.effects)||(this.setEffects(t.effects),this._needsRedraw="effects changed"))}needsRedraw(t={clearRedrawFlags:!1}){const e=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),e}getEffects(){return this._internalEffects}finalize(){this.cleanup()}setEffects(t=[]){this.cleanup(),this.effects=t,this._internalEffects=t.slice(),this._internalEffects.push(new pu),t.some(t=>t instanceof su)||this._internalEffects.push(gu)}cleanup(){for(const t of this.effects)t.cleanup();for(const t of this._internalEffects)t.cleanup();this.effects.length=0,this._internalEffects.length=0}}class vu extends Zh{shouldDrawLayer(t){return t.props.operation===Kt}}const _u={blendFunc:[1,0,32771,0],blendEquation:32774};class bu extends Zh{constructor(...t){super(...t),r(this,"pickZ",void 0),r(this,"_colors",null)}render(t){return t.pickingFBO?this._drawPickingBuffer(t):super.render(t)}_drawPickingBuffer({layers:t,layerFilter:e,views:i,viewports:n,onViewportActive:r,pickingFBO:s,deviceRect:{x:o,y:a,width:c,height:l},cullRect:h,effects:u,pass:d="picking",pickZ:f}){const p=this.gl;this.pickZ=f;const g=f?null:{byLayer:new Map,byAlpha:[]};this._colors=g;const m=Ui(p,{scissorTest:!0,scissor:[o,a,c,l],clearColor:[0,0,0,0],depthMask:!0,depthTest:!0,depthRange:[0,1],colorMask:[!0,!0,!0,!0],..._u,blend:!f},()=>super.render({target:s,layers:t,layerFilter:e,views:i,viewports:n,onViewportActive:r,cullRect:h,effects:null==u?void 0:u.filter(t=>t.useInPicking),pass:d}));this._colors=null;return{decodePickingColor:g&&yu.bind(null,g),stats:m}}shouldDrawLayer(t){return t.props.pickable&&t.props.operation===Kt}getModuleParameters(){return{pickingActive:1,pickingAttribute:this.pickZ,lightSources:{}}}getLayerParameters(t,e,i){const n={...t.props.parameters};return this._colors?(Object.assign(n,_u),n.blend=!0,n.blendColor=function(t,e,i){const{byLayer:n,byAlpha:r}=t;let s,o=n.get(e);o?(o.viewports.push(i),s=o.a):(s=n.size+1,s<=255?(o={a:s,layer:e,viewports:[i]},n.set(e,o),r[s]=o):(T.warn("Too many pickable layers, only picking the first 255")(),s=0));return[0,0,0,s/255]}(this._colors,t,i)):n.blend=!1,n}}function yu(t,e){const i=t.byAlpha[e[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(e)}}class wu{constructor(t){this.gl=t,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new vu(t),this.pickLayersPass=new bu(t),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(t){"layerFilter"in t&&this.layerFilter!==t.layerFilter&&(this.layerFilter=t.layerFilter,this._needsRedraw="layerFilter changed"),"drawPickingColors"in t&&this.drawPickingColors!==t.drawPickingColors&&(this.drawPickingColors=t.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(t){const e=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass;t.layerFilter=t.layerFilter||this.layerFilter,t.effects=t.effects||[],t.target=t.target||nr.getDefaultFramebuffer(this.gl),this._preRender(t.effects,t);const i=this.lastPostProcessEffect?this.renderBuffers[0]:t.target,n=e.render({...t,target:i});this._postRender(t.effects,t),this.renderCount++,Ro("deckRenderer.renderLayers",this,n,t)}needsRedraw(t={clearRedrawFlags:!1}){const e=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),e}finalize(){const{renderBuffers:t}=this;for(const e of t)e.delete();t.length=0}_preRender(t,e){let i=null;for(const n of t)n.preRender(this.gl,e),n.postRender&&(i=n);i&&this._resizeRenderBuffers(),this.lastPostProcessEffect=i}_resizeRenderBuffers(){const{renderBuffers:t}=this;0===t.length&&t.push(new nr(this.gl),new nr(this.gl));for(const e of t)e.resize()}_postRender(t,e){const{renderBuffers:i}=this,n={inputBuffer:i[0],swapBuffer:i[1],target:null};for(const r of t)if(r.postRender){if(r===this.lastPostProcessEffect){n.target=e.target,r.postRender(this.gl,n);break}const t=r.postRender(this.gl,n);n.inputBuffer=t,n.swapBuffer=t===i[0]?i[1]:i[0]}}}const xu={pickedColor:null,pickedObjectIndex:-1};function Eu({pickedColors:t,decodePickingColor:e,deviceX:i,deviceY:n,deviceRadius:r,deviceRect:s}){const{x:o,y:a,width:c,height:l}=s;let h=r*r,u=-1,d=0;for(let e=0;eh)d+=4*c;else for(let e=0;e=0){const t=e+o-i,n=t*t+s;n<=h&&(h=n,u=d)}d+=4}}if(u>=0){const i=t.slice(u,u+4),n=e(i);if(n){const t=Math.floor(u/4/c),e=u/4-t*c;return{...n,pickedColor:i,pickedX:o+e,pickedY:a+t}}T.error("Picked non-existent layer. Is picking buffer corrupt?")()}return xu}function Tu({pickInfo:t,viewports:e,pixelRatio:i,x:n,y:r,z:s}){let o,a=e[0];if(e.length>1&&(a=function(t,e){for(let i=t.length-1;i>=0;i--){const n=t[i];if(n.containsPixel(e))return n}return t[0]}((null==t?void 0:t.pickedViewports)||e,{x:n,y:r})),a){const t=[n-a.x,r-a.y];void 0!==s&&(t[2]=s),o=a.unproject(t)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:n,y:r,pixel:[n,r],coordinate:o,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:i}}function Au(t){const{pickInfo:e,lastPickedInfo:i,mode:n,layers:r}=t,{pickedColor:s,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if("hover"===n){const t=i.index,e=i.layerId,n=o?o.props.id:null;if(n!==e||a!==t){if(n!==e){const t=r.find(t=>t.props.id===e);t&&c.unshift(t)}i.layerId=n,i.index=a,i.info=null}}const l=Tu(t),h=new Map;return h.set(null,l),c.forEach(t=>{let e={...l};t===o&&(e.color=s,e.index=a,e.picked=!0),e=Pu({layer:t,info:e,mode:n});const r=e.layer;t===o&&"hover"===n&&(i.info=e),h.set(r.id,e),"hover"===n&&r.updateAutoHighlight(e)}),h}function Pu({layer:t,info:e,mode:i}){for(;t&&e;){const n=e.layer||null;e.sourceLayer=n,e.layer=t,e=t.getPickingInfo({info:e,mode:i,sourceLayer:n}),t=t.parent}return e}class Su{constructor(t){r(this,"gl",void 0),r(this,"pickingFBO",void 0),r(this,"depthFBO",void 0),r(this,"pickLayersPass",void 0),r(this,"layerFilter",void 0),r(this,"lastPickedInfo",void 0),r(this,"_pickable",!0),this.gl=t,this.pickLayersPass=new bu(t),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(t){"layerFilter"in t&&(this.layerFilter=t.layerFilter),"_pickable"in t&&(this._pickable=t._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.delete(),this.depthFBO&&(this.depthFBO.color.delete(),this.depthFBO.delete())}pickObject(t){return this._pickClosestObject(t)}pickObjects(t){return this._pickVisibleObjects(t)}getLastPickedObject({x:t,y:e,layers:i,viewports:n},r=this.lastPickedInfo.info){const s=r&&r.layer&&r.layer.id,o=r&&r.viewport&&r.viewport.id,a=s?i.find(t=>t.id===s):null,c=o&&n.find(t=>t.id===o)||n[0],l=c&&c.unproject([t-c.x,e-c.y]),h={x:t,y:e,viewport:c,coordinate:l,layer:a};return{...r,...h}}_resizeBuffer(){var t,e;const{gl:i}=this;if(!this.pickingFBO&&(this.pickingFBO=new nr(i),nr.isSupported(i,{colorBufferFloat:!0}))){const t=new nr(i);t.attach({36064:new Nn(i,{format:ai(i)?34836:6408,type:5126})}),this.depthFBO=t}null===(t=this.pickingFBO)||void 0===t||t.resize({width:i.canvas.width,height:i.canvas.height}),null===(e=this.depthFBO)||void 0===e||e.resize({width:i.canvas.width,height:i.canvas.height})}_getPickable(t){if(!1===this._pickable)return null;const e=t.filter(t=>t.isPickable()&&!t.isComposite);return e.length?e:null}_pickClosestObject({layers:t,views:e,viewports:i,x:n,y:r,radius:s=0,depth:o=1,mode:a="query",unproject3D:c,onViewportActive:l,effects:h}){const u=this._getPickable(t),d=zi(this.gl);if(!u)return{result:[],emptyInfo:Tu({viewports:i,x:n,y:r,pixelRatio:d})};this._resizeBuffer();const f=Vi(this.gl,[n,r],!0),p=[f.x+Math.floor(f.width/2),f.y+Math.floor(f.height/2)],g=Math.round(s*d),{width:m,height:v}=this.pickingFBO,_=this._getPickingRect({deviceX:p[0],deviceY:p[1],deviceRadius:g,deviceWidth:m,deviceHeight:v}),b={x:n-s,y:r-s,width:2*s+1,height:2*s+1};let y;const w=[],x=new Set;for(let t=0;t=0){const r=t.slice(n,n+4),s=r.join(",");if(!i.has(s)){const t=e(r);t?i.set(s,{...t,color:r}):T.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(i.values())}(this._drawAndSample({layers:u,views:e,viewports:i,onViewportActive:l,deviceRect:b,cullRect:{x:n,y:r,width:s,height:o},effects:h,pass:"picking:".concat(a)})),w=new Map,x=Number.isFinite(c);for(let t=0;t=c);t++){const e=y[t];let i={color:e.pickedColor,layer:null,index:e.pickedObjectIndex,picked:!0,x:n,y:r,pixelRatio:d};i=Pu({layer:e.pickedLayer,info:i,mode:a}),w.has(i.object)||w.set(i.object,i)}return Array.from(w.values())}_drawAndSample({layers:t,views:e,viewports:i,onViewportActive:n,deviceRect:r,cullRect:s,effects:o,pass:a},c=!1){const l=c?this.depthFBO:this.pickingFBO,{decodePickingColor:h}=this.pickLayersPass.render({layers:t,layerFilter:this.layerFilter,views:e,viewports:i,onViewportActive:n,pickingFBO:l,deviceRect:r,cullRect:s,effects:o,pass:a,pickZ:c}),{x:u,y:d,width:f,height:p}=r,g=new(c?Float32Array:Uint8Array)(f*p*4);return Kn(l,{sourceX:u,sourceY:d,sourceWidth:f,sourceHeight:p,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:t,deviceY:e,deviceRadius:i,deviceWidth:n,deviceHeight:r}){const s=Math.max(0,t-i),o=Math.max(0,e-i),a=Math.min(n,t+i+1)-s,c=Math.min(r,e+i+1)-o;return a<=0||c<=0?null:{x:s,y:o,width:a,height:c}}}const Mu={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Cu{constructor(t){r(this,"el",null),r(this,"isVisible",!1);const e=t.parentElement;e&&(this.el=document.createElement("div"),this.el.className="deck-tooltip",Object.assign(this.el.style,Mu),e.appendChild(this.el))}setTooltip(t,e,i){const n=this.el;if(n){if("string"==typeof t)n.innerText=t;else{if(!t)return this.isVisible=!1,void(n.style.display="none");t.text&&(n.innerText=t.text),t.html&&(n.innerHTML=t.html),t.className&&(n.className=t.className),Object.assign(n.style,t.style)}this.isVisible=!0,n.style.display="block",n.style.transform="translate(".concat(e,"px, ").concat(i,"px)")}}remove(){this.el&&(this.el.remove(),this.el=null)}}const{_parseImageNode:Lu}=globalThis,Ru="undefined"!=typeof Image,Ou="undefined"!=typeof ImageBitmap,Iu=Boolean(Lu),ku=!!oc.a||Iu;function Fu(t){const e=Bu(t);if(!e)throw new Error("Not an image");return e}function Du(t){switch(Fu(t)){case"data":return t;case"image":case"imagebitmap":const e=document.createElement("canvas"),i=e.getContext("2d");if(!i)throw new Error("getImageData");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0),i.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function Bu(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&t instanceof Image?"image":t&&"object"==typeof t&&t.data&&t.width&&t.height?"data":null}const ju=/^data:image\/svg\+xml/,Nu=/\.svg((\?|#).*)?$/;function Uu(t){return t&&(ju.test(t)||Nu.test(t))}function zu(t,e){if(Uu(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Vu(t,e,i){const n=function(t,e){if(Uu(e)){let e=(new TextDecoder).decode(t);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(e=unescape(encodeURIComponent(e)))}catch(t){throw new Error(t.message)}return"data:image/svg+xml;base64,".concat(btoa(e))}return zu(t,e)}(t,i),r=self.URL||self.webkitURL,s="string"!=typeof n&&r.createObjectURL(n);try{return await async function(t,e){const i=new Image;if(i.src=t,e.image&&e.image.decode&&i.decode)return await i.decode(),i;return await new Promise((e,n)=>{try{i.onload=()=>e(i),i.onerror=e=>n(new Error("Could not load image ".concat(t,": ").concat(e)))}catch(t){n(t)}})}(s||n,e)}finally{s&&r.revokeObjectURL(s)}}const Gu={};let Wu=!0;async function Hu(t,e,i){let n;if(Uu(i)){n=await Vu(t,e,i)}else n=zu(t,i);const r=e&&e.imagebitmap;return await async function(t,e=null){!function(t){for(const e in t||Gu)return!1;return!0}(e)&&Wu||(e=null);if(e)try{return await createImageBitmap(t,e)}catch(t){console.warn(t),Wu=!1}return await createImageBitmap(t)}(n,r)}function Xu(t){const e=qu(t);return function(t){const e=qu(t);if(!(e.byteLength>=24&&2303741511===e.getUint32(0,!1)))return null;return{mimeType:"image/png",width:e.getUint32(16,!1),height:e.getUint32(20,!1)}}(e)||function(t){const e=qu(t);if(!(e.byteLength>=3&&65496===e.getUint16(0,!1)&&255===e.getUint8(2)))return null;const{tableMarkers:i,sofMarkers:n}=function(){const t=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)t.add(e);const e=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:t,sofMarkers:e}}();let r=2;for(;r+9=10&&1195984440===e.getUint32(0,!1)))return null;return{mimeType:"image/gif",width:e.getUint16(6,!0),height:e.getUint16(8,!0)}}(e)||function(t){const e=qu(t);if(!(e.byteLength>=14&&16973===e.getUint16(0,!1)&&e.getUint32(2,!0)===e.byteLength))return null;return{mimeType:"image/bmp",width:e.getUint32(18,!0),height:e.getUint32(22,!0)}}(e)}function qu(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}const Yu={id:"image",module:"images",name:"Images",version:"3.2.12",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(t,e,i){const n=((e=e||{}).image||{}).type||"auto",{url:r}=i||{};let s;switch(function(t){switch(t){case"auto":case"data":return function(){if(Ou)return"imagebitmap";if(Ru)return"image";if(ku)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(t){switch(t){case"auto":return Ou||Ru||ku;case"imagebitmap":return Ou;case"image":return Ru;case"data":return ku;default:throw new Error("@loaders.gl/images: image ".concat(t," not supported in this environment"))}}(t),t}}(n)){case"imagebitmap":s=await Hu(t,e,r);break;case"image":s=await Vu(t,e,r);break;case"data":s=await async function(t,e){const{mimeType:i}=Xu(t)||{},n=globalThis._parseImageNode;return Ga(n),await n(t,i)}(t);break;default:Ga(!1)}return"data"===n&&(s=Du(s)),s},tests:[t=>Boolean(Xu(new DataView(t)))],options:{image:{type:"auto",decode:!0}}};var Zu={id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(t){const e=t[0],i=t[t.length-1];return"{"===e&&"}"===i||"["===e&&"]"===i},parseTextSync:JSON.parse};const Ku=globalThis.deck&&globalThis.deck.VERSION;if(Ku&&"8.8.17"!==Ku)throw new Error("deck.gl - multiple versions detected: ".concat(Ku," vs ").concat("8.8.17"));Ku||(T.log(1,"deck.gl ".concat("8.8.17"))(),globalThis.deck={...globalThis.deck,VERSION:"8.8.17",version:"8.8.17",log:T,_registerLoggers:function(t){Lo=t}},function(t){const e=Wc();t=Array.isArray(t)?t:[t];for(const i of t){const t=Ha(i);e.find(e=>t===e)||e.unshift(t)}}([Zu,[Yu,{imagebitmap:{premultiplyAlpha:"none"}}]]));var Qu=globalThis.deck;class Ju extends bn{get[Symbol.toStringTag](){return"Query"}static isSupported(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const i=ai(t),n=er(t,rr);let r=i||n;for(const t of e)switch(t){case"queries":r=r&&i;break;case"timers":r=r&&n;break;default:hn(!1)}return r}constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),this.target=null,this._queryPending=!1,this._pollingPromise=null,Object.seal(this)}beginTimeElapsedQuery(){return this.begin(35007)}beginOcclusionQuery(){let{conservative:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.begin(t?36202:35887)}beginTransformFeedbackQuery(){return this.begin(35976)}begin(t){return this._queryPending||(this.target=t,this.gl2.beginQuery(this.target,this.handle)),this}end(){return this._queryPending||this.target&&(this.gl2.endQuery(this.target),this.target=null,this._queryPending=!0),this}isResultAvailable(){if(!this._queryPending)return!1;const t=this.gl2.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.gl2.getParameter(36795)}getResult(){return this.gl2.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}createPoll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY;if(this._pollingPromise)return this._pollingPromise;let e=0;return this._pollingPromise=new Promise((i,n)=>{const r=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):e++>t?(n("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)}),this._pollingPromise}_createHandle(){return Ju.isSupported(this.gl)?this.gl2.createQuery():null}_deleteHandle(){this.gl2.deleteQuery(this.handle)}}const $u=Object(s.a)()&&"undefined"!=typeof document;let td=0;class ed{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{onCreateContext:e=(t=>Ki(t)),onAddHTML:i=null,onInitialize:n=(()=>{}),onRender:r=(()=>{}),onFinalize:s=(()=>{}),onError:o,gl:a=null,glOptions:c={},debug:l=!1,createFramebuffer:h=!1,autoResizeViewport:u=!0,autoResizeDrawingBuffer:d=!0,stats:f=ln.get("animation-loop-".concat(td++))}=t;let{useDevicePixels:p=!0}=t;"useDevicePixelRatio"in t&&(ri.deprecated("useDevicePixelRatio","useDevicePixels")(),p=t.useDevicePixelRatio),this.props={onCreateContext:e,onAddHTML:i,onInitialize:n,onRender:r,onFinalize:s,onError:o,gl:a,glOptions:c,debug:l,createFramebuffer:h},this.gl=a,this.needsRedraw=null,this.timeline=null,this.stats=f,this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this._initialized=!1,this._running=!1,this._animationFrameId=null,this._nextFramePromise=null,this._resolveNextFrame=null,this._cpuStartTime=0,this.setProps({autoResizeViewport:u,autoResizeDrawingBuffer:d,useDevicePixels:p}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._pageLoadPromise=null,this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}delete(){this.stop(),this._setDisplay(null)}setNeedsRedraw(t){return hn("string"==typeof t),this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.autoResizeViewport=t.autoResizeViewport),"autoResizeDrawingBuffer"in t&&(this.autoResizeDrawingBuffer=t.autoResizeDrawingBuffer),"useDevicePixels"in t&&(this.useDevicePixels=t.useDevicePixels),this}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._running)return this;this._running=!0;const e=this._getPageLoadPromise().then(()=>!this._running||this._initialized?null:(this._createWebGLContext(t),this._createFramebuffer(),this._startEventHandling(),this._initializeCallbackData(),this._updateCallbackData(),this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._gpuTimeQuery=Ju.isSupported(this.gl,["timers"])?new Ju(this.gl):null,this._initialized=!0,this.onInitialize(this.animationProps))).then(t=>{this._running&&(this._addCallbackData(t||{}),!1!==t&&this._startLoop())});return this.props.onError&&e.catch(this.props.onError),this}redraw(){return this.isContextLost()||(this._beginTimers(),this._setupFrame(),this._updateCallbackData(),this._renderFrame(this.animationProps),this._clearNeedsRedraw(),this.offScreen&&this.gl.commit&&this.gl.commit(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endTimers()),this}stop(){return this._running&&(this._finalizeCallbackData(),this._cancelAnimationFrame(this._animationFrameId),this._nextFramePromise=null,this._resolveNextFrame=null,this._animationFrameId=null,this._running=!1),this}attachTimeline(t){return this.timeline=t,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(t=>{this._resolveNextFrame=t})),this._nextFramePromise}async toDataURL(){return this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.gl.canvas.toDataURL()}isContextLost(){return this.gl.isContextLost()}onCreateContext(){return this.props.onCreateContext(...arguments)}onInitialize(){return this.props.onInitialize(...arguments)}onRender(){return this.props.onRender(...arguments)}onFinalize(){return this.props.onFinalize(...arguments)}getHTMLControlValue(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=document.getElementById(t);return i?Number(i.value):e}setViewParameters(){return ri.removed("AnimationLoop.setViewParameters","AnimationLoop.setProps")(),this}_startLoop(){const t=()=>{this._running&&(this.redraw(),this._animationFrameId=this._requestAnimationFrame(t))};this._cancelAnimationFrame(this._animationFrameId),this._animationFrameId=this._requestAnimationFrame(t)}_getPageLoadPromise(){return this._pageLoadPromise||(this._pageLoadPromise=$u?new Promise((t,e)=>{$u&&"complete"===document.readyState?t(document):window.addEventListener("load",()=>{t(document)})}):Promise.resolve({})),this._pageLoadPromise}_setDisplay(t){this.display&&(this.display.delete(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_cancelAnimationFrame(t){return this.display&&this.display.cancelAnimationFrame?this.display.cancelAnimationFrame(t):(e=t,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e));var e}_requestAnimationFrame(t){if(this._running)return this.display&&this.display.requestAnimationFrame?this.display.requestAnimationFrame(t):(e=t,"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60));var e}_renderFrame(){this.display?this.display._renderFrame(...arguments):this.onRender(...arguments)}_clearNeedsRedraw(){this.needsRedraw=null}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport(),this._resizeFramebuffer()}_initializeCallbackData(){this.animationProps={gl:this.gl,stop:this.stop,canvas:this.gl.canvas,framebuffer:this.framebuffer,useDevicePixels:this.useDevicePixels,needsRedraw:null,startTime:Date.now(),engineTime:0,tick:0,tock:0,time:0,_timeline:this.timeline,_loop:this,_animationLoop:this,_mousePosition:null}}_updateCallbackData(){const{width:t,height:e,aspect:i}=this._getSizeAndAspect();t===this.animationProps.width&&e===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=e,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime,this.animationProps._offScreen=this.offScreen}_finalizeCallbackData(){this.onFinalize(this.animationProps)}_addCallbackData(t){"object"==typeof t&&null!==t&&(this.animationProps=Object.assign({},this.animationProps,t))}_createWebGLContext(t){if(this.offScreen=t.canvas&&"undefined"!=typeof OffscreenCanvas&&t.canvas instanceof OffscreenCanvas,t=Object.assign({},t,this.props.glOptions),this.gl=this.props.gl?Qi(this.props.gl,t):this.onCreateContext(t),!oi(this.gl))throw new Error("AnimationLoop.onCreateContext - illegal context returned");ji(this.gl,bi),this._createInfoDiv()}_createInfoDiv(){if(this.gl.canvas&&this.props.onAddHTML){const t=document.createElement("div");document.body.appendChild(t),t.style.position="relative";const e=document.createElement("div");e.style.position="absolute",e.style.left="10px",e.style.bottom="10px",e.style.width="300px",e.style.background="white",t.appendChild(this.gl.canvas),t.appendChild(e);const i=this.props.onAddHTML(e);i&&(e.innerHTML=i)}}_getSizeAndAspect(){const t=this.gl.drawingBufferWidth,e=this.gl.drawingBufferHeight;let i=1;const{canvas:n}=this.gl;return n&&n.clientHeight?i=n.clientWidth/n.clientHeight:t>0&&e>0&&(i=t/e),{width:t,height:e,aspect:i}}_resizeViewport(){this.autoResizeViewport&&this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.autoResizeDrawingBuffer&&function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.canvas){return void nn(t,Gi(e.useDevicePixels),e)}const i=t.getExtension("STACKGL_resize_drawingbuffer");i&&"width"in e&&"height"in e&&i.resize(e.width,e.height)}(this.gl,{useDevicePixels:this.useDevicePixels})}_createFramebuffer(){this.props.createFramebuffer&&(this.framebuffer=new nr(this.gl))}_resizeFramebuffer(){this.framebuffer&&this.framebuffer.resize({width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight})}_beginTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this._gpuTimeQuery&&this._gpuTimeQuery.isResultAvailable()&&!this._gpuTimeQuery.isTimerDisjoint()&&this.stats.get("GPU Time").addTime(this._gpuTimeQuery.getTimerMilliseconds()),this._gpuTimeQuery&&this._gpuTimeQuery.beginTimeElapsedQuery(),this.cpuTime.timeStart()}_endTimers(){this.cpuTime.timeEnd(),this._gpuTimeQuery&&this._gpuTimeQuery.end()}_startEventHandling(){const{canvas:t}=this.gl;t&&(t.addEventListener("mousemove",this._onMousemove),t.addEventListener("mouseleave",this._onMouseleave))}_onMousemove(t){this.animationProps._mousePosition=[t.offsetX,t.offsetY]}_onMouseleave(t){this.animationProps._mousePosition=null}}var id=i(11);const nd={mousedown:1,mousemove:2,mouseup:4};!function(t){const e=t.prototype.handler;t.prototype.handler=function(t){const i=this.store;t.button>0&&"pointerdown"===t.type&&(function(t,e){for(let i=0;ie.pointerId===t.pointerId)||i.push(t)),e.call(this,t)}}(id.PointerEventInput),id.MouseInput.prototype.handler=function(t){let e=nd[t.type];1&e&&t.button>=0&&(this.pressed=!0),2&e&&0===t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))};const rd=id.Manager;var sd=id;class od{constructor(t,e,i){this.element=t,this.callback=e,this.options={enable:!0,...i}}}const ad=sd?[[sd.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[sd.Rotate,{enable:!1}],[sd.Pinch,{enable:!1}],[sd.Swipe,{enable:!1}],[sd.Pan,{threshold:0,enable:!1}],[sd.Press,{enable:!1}],[sd.Tap,{event:"doubletap",taps:2,enable:!1}],[sd.Tap,{event:"anytap",enable:!1}],[sd.Tap,{enable:!1}]]:null,cd={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},ld={doubletap:["tap"]},hd={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},ud={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},dd={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},fd={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var pd=i(7);const gd=-1!==pd.b.indexOf("firefox"),{WHEEL_EVENTS:md}=ud;class vd extends od{constructor(t,e,i){super(t,e,i),this.handleEvent=t=>{if(!this.options.enable)return;let e=t.deltaY;pd.c.WheelEvent&&(gd&&t.deltaMode===pd.c.WheelEvent.DOM_DELTA_PIXEL&&(e/=pd.c.devicePixelRatio),t.deltaMode===pd.c.WheelEvent.DOM_DELTA_LINE&&(e*=40)),0!==e&&e%4.000244140625==0&&(e=Math.floor(e/4.000244140625)),t.shiftKey&&e&&(e*=.25),this.callback({type:"wheel",center:{x:t.clientX,y:t.clientY},delta:-e,srcEvent:t,pointerType:"mouse",target:t.target})},this.events=(this.options.events||[]).concat(md),this.events.forEach(e=>t.addEventListener(e,this.handleEvent,!!pd.a&&{passive:!1}))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){"wheel"===t&&(this.options.enable=e)}}const{MOUSE_EVENTS:_d}=ud;class bd extends od{constructor(t,e,i){super(t,e,i),this.handleEvent=t=>{this.handleOverEvent(t),this.handleOutEvent(t),this.handleEnterEvent(t),this.handleLeaveEvent(t),this.handleMoveEvent(t)},this.pressed=!1;const{enable:n}=this.options;this.enableMoveEvent=n,this.enableLeaveEvent=n,this.enableEnterEvent=n,this.enableOutEvent=n,this.enableOverEvent=n,this.events=(this.options.events||[]).concat(_d),this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){"pointermove"===t&&(this.enableMoveEvent=e),"pointerover"===t&&(this.enableOverEvent=e),"pointerout"===t&&(this.enableOutEvent=e),"pointerenter"===t&&(this.enableEnterEvent=e),"pointerleave"===t&&(this.enableLeaveEvent=e)}handleOverEvent(t){this.enableOverEvent&&"mouseover"===t.type&&this._emit("pointerover",t)}handleOutEvent(t){this.enableOutEvent&&"mouseout"===t.type&&this._emit("pointerout",t)}handleEnterEvent(t){this.enableEnterEvent&&"mouseenter"===t.type&&this._emit("pointerenter",t)}handleLeaveEvent(t){this.enableLeaveEvent&&"mouseleave"===t.type&&this._emit("pointerleave",t)}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":0===t.which&&(this.pressed=!1),this.pressed||this._emit("pointermove",t);break;case"mouseup":this.pressed=!1}}_emit(t,e){this.callback({type:t,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})}}const{KEY_EVENTS:yd}=ud;class wd extends od{constructor(t,e,i){super(t,e,i),this.handleEvent=t=>{const e=t.target||t.srcElement;"INPUT"===e.tagName&&"text"===e.type||"TEXTAREA"===e.tagName||(this.enableDownEvent&&"keydown"===t.type&&this.callback({type:"keydown",srcEvent:t,key:t.key,target:t.target}),this.enableUpEvent&&"keyup"===t.type&&this.callback({type:"keyup",srcEvent:t,key:t.key,target:t.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(yd),t.tabIndex=this.options.tabIndex||0,t.style.outline="none",this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){"keydown"===t&&(this.enableDownEvent=e),"keyup"===t&&(this.enableUpEvent=e)}}class xd extends od{constructor(t,e,i){super(t,e,i),this.handleEvent=t=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})},t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,e){"contextmenu"===t&&(this.options.enable=e)}}const Ed={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function Td(t){const e=Ed[t.srcEvent.type];if(!e)return null;const{buttons:i,button:n,which:r}=t.srcEvent;let s=!1,o=!1,a=!1;return 4===e||2===e&&!Number.isFinite(i)?(s=1===r,o=2===r,a=3===r):2===e?(s=Boolean(1&i),o=Boolean(4&i),a=Boolean(2&i)):1===e&&(s=0===n,o=1===n,a=2===n),{leftButton:s,middleButton:o,rightButton:a}}function Ad(t,e){const i=t.center;if(!i)return null;const n=e.getBoundingClientRect(),r=n.width/e.offsetWidth||1,s=n.height/e.offsetHeight||1;return{center:i,offsetCenter:{x:(i.x-n.left-e.clientLeft)/r,y:(i.y-n.top-e.clientTop)/s}}}const Pd={srcElement:"root",priority:0};class Sd{constructor(t){this.handleEvent=t=>{if(this.isEmpty())return;const e=this._normalizeEvent(t);let i=t.srcEvent.target;for(;i&&i!==e.rootElement;){if(this._emit(e,i),e.handled)return;i=i.parentNode}this._emit(e,"root")},this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(t,e,i,n=!1,r=!1){const{handlers:s,handlersByElement:o}=this;let a=Pd;"string"==typeof i||i&&i.addEventListener?a={...Pd,srcElement:i}:i&&(a={...Pd,...i});let c=o.get(a.srcElement);c||(c=[],o.set(a.srcElement,c));const l={type:t,handler:e,srcElement:a.srcElement,priority:a.priority};n&&(l.once=!0),r&&(l.passive=!0),s.push(l),this._active=this._active||!l.passive;let h=c.length-1;for(;h>=0&&!(c[h].priority>=l.priority);)h--;c.splice(h+1,0,l)}remove(t,e){const{handlers:i,handlersByElement:n}=this;for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.type===t&&s.handler===e){i.splice(r,1);const t=n.get(s.srcElement);t.splice(t.indexOf(s),1),0===t.length&&n.delete(s.srcElement)}}this._active=i.some(t=>!t.passive)}_emit(t,e){const i=this.handlersByElement.get(e);if(i){let e=!1;const n=()=>{t.handled=!0},r=()=>{t.handled=!0,e=!0},s=[];for(let o=0;o{t.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:e}}}const Md={events:null,recognizers:null,recognizerOptions:{},Manager:rd,touchAction:"none",tabIndex:0};class Cd{constructor(t=null,e){this._onBasicInput=t=>{const{srcEvent:e}=t,i=hd[e.type];i&&this.manager.emit(i,t)},this._onOtherEvent=t=>{this.manager.emit(t.type,t)},this.options={...Md,...e},this.events=new Map,this.setElement(t);const{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(t){if(this.element&&this.destroy(),this.element=t,!t)return;const{options:e}=this,i=e.Manager;this.manager=new i(t,{touchAction:e.touchAction,recognizers:e.recognizers||ad}).on("hammer.input",this._onBasicInput),e.recognizers||Object.keys(cd).forEach(t=>{const e=this.manager.get(t);e&&cd[t].forEach(t=>{e.recognizeWith(t)})});for(const t in e.recognizerOptions){const i=this.manager.get(t);if(i){const n=e.recognizerOptions[t];delete n.enable,i.set(n)}}this.wheelInput=new vd(t,this._onOtherEvent,{enable:!1}),this.moveInput=new bd(t,this._onOtherEvent,{enable:!1}),this.keyInput=new wd(t,this._onOtherEvent,{enable:!1,tabIndex:e.tabIndex}),this.contextmenuInput=new xd(t,this._onOtherEvent,{enable:!1});for(const[t,e]of this.events)e.isEmpty()||(this._toggleRecognizer(e.recognizerName,!0),this.manager.on(t,e.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(t,e,i){this._addEventHandler(t,e,i,!1)}once(t,e,i){this._addEventHandler(t,e,i,!0)}watch(t,e,i){this._addEventHandler(t,e,i,!1,!0)}off(t,e){this._removeEventHandler(t,e)}_toggleRecognizer(t,e){const{manager:i}=this;if(!i)return;const n=i.get(t);if(n&&n.options.enable!==e){n.set({enable:e});const r=ld[t];r&&!this.options.recognizers&&r.forEach(r=>{const s=i.get(r);e?(s.requireFailure(t),n.dropRequireFailure(r)):s.dropRequireFailure(t)})}this.wheelInput.enableEventType(t,e),this.moveInput.enableEventType(t,e),this.keyInput.enableEventType(t,e),this.contextmenuInput.enableEventType(t,e)}_addEventHandler(t,e,i,n,r){if("string"!=typeof t){i=e;for(const e in t)this._addEventHandler(e,t[e],i,n,r);return}const{manager:s,events:o}=this,a=fd[t]||t;let c=o.get(a);c||(c=new Sd(this),o.set(a,c),c.recognizerName=dd[a]||a,s&&s.on(a,c.handleEvent)),c.add(t,e,i,n,r),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(t,e){if("string"!=typeof t){for(const e in t)this._removeEventHandler(e,t[e]);return}const{events:i}=this,n=fd[t]||t,r=i.get(n);if(r&&(r.remove(t,e),r.isEmpty())){const{recognizerName:t}=r;let e=!1;for(const n of i.values())if(n.recognizerName===t&&!n.isEmpty()){e=!0;break}e||this._toggleRecognizer(t,!1)}}}function Ld(){}const Rd={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,glOptions:{},parameters:{},parent:null,gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,onWebGLInitialized:Ld,onResize:Ld,onViewStateChange:Ld,onInteractionStateChange:Ld,onBeforeRender:Ld,onAfterRender:Ld,onLoad:Ld,onError:t=>T.error(t.message)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:t})=>t?"grabbing":"grab",getTooltip:null,debug:!1,drawPickingColors:!1};class Od{constructor(t){r(this,"props",void 0),r(this,"width",0),r(this,"height",0),r(this,"userData",{}),r(this,"canvas",null),r(this,"viewManager",null),r(this,"layerManager",null),r(this,"effectManager",null),r(this,"deckRenderer",null),r(this,"deckPicker",null),r(this,"eventManager",null),r(this,"tooltip",null),r(this,"metrics",void 0),r(this,"animationLoop",void 0),r(this,"stats",void 0),r(this,"viewState",void 0),r(this,"cursorState",void 0),r(this,"_needsRedraw",void 0),r(this,"_pickRequest",void 0),r(this,"_lastPointerDownInfo",null),r(this,"_metricsCounter",void 0),r(this,"_onPointerMove",t=>{const{_pickRequest:e}=this;if("pointerleave"===t.type)e.x=-1,e.y=-1,e.radius=0;else{if(t.leftButton||t.rightButton)return;{const i=t.offsetCenter;if(!i)return;e.x=i.x,e.y=i.y,e.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:e.x,y:e.y}),e.event=t}),r(this,"_onEvent",t=>{const e=Zt[t.type],i=t.offsetCenter;if(!e||!i||!this.layerManager)return;const n=this.layerManager.getLayers(),r=this.deckPicker.getLastPickedObject({x:i.x,y:i.y,layers:n,viewports:this.getViewports(i)},this._lastPointerDownInfo),{layer:s}=r,o=s&&(s[e.handler]||s.props[e.handler]),a=this.props[e.handler];let c=!1;o&&(c=o.call(s,r,t)),!c&&a&&a(r,t)}),r(this,"_onPointerDown",t=>{const e=t.offsetCenter,i=this._pick("pickObject","pickObject Time",{x:e.x,y:e.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=i.result[0]||i.emptyInfo}),this.props={...Rd,...t},t=this.props,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this.cursorState={isHovering:!1,isDragging:!1},t.viewState&&t.initialViewState&&T.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),"IE"===Ws()&&T.warn("IE 11 is not supported")(),this.viewState=t.initialViewState,t.gl||"undefined"!=typeof document&&(this.canvas=this._createCanvas(t)),this.animationLoop=this._createAnimationLoop(t),this.stats=new cn({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this.setProps(t),t._typedArrayManagerProps&&A.setOptions(t._typedArrayManagerProps),this.animationLoop.start()}finalize(){var t,e,i,n,r,s,o,a;(this.animationLoop.stop(),this.animationLoop=null,this._lastPointerDownInfo=null,null===(t=this.layerManager)||void 0===t||t.finalize(),this.layerManager=null,null===(e=this.viewManager)||void 0===e||e.finalize(),this.viewManager=null,null===(i=this.effectManager)||void 0===i||i.finalize(),this.effectManager=null,null===(n=this.deckRenderer)||void 0===n||n.finalize(),this.deckRenderer=null,null===(r=this.deckPicker)||void 0===r||r.finalize(),this.deckPicker=null,null===(s=this.eventManager)||void 0===s||s.destroy(),this.eventManager=null,null===(o=this.tooltip)||void 0===o||o.remove(),this.tooltip=null,this.props.canvas||this.props.gl||!this.canvas)||(null===(a=this.canvas.parentElement)||void 0===a||a.removeChild(this.canvas),this.canvas=null)}setProps(t){this.stats.get("setProps Time").timeStart(),"onLayerHover"in t&&T.removed("onLayerHover","onHover")(),"onLayerClick"in t&&T.removed("onLayerClick","onClick")(),t.initialViewState&&!oe(this.props.initialViewState,t.initialViewState)&&(this.viewState=t.initialViewState),Object.assign(this.props,t),this._setCanvasSize(this.props);const e=Object.create(this.props);Object.assign(e,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop.setProps(e),this.layerManager&&(this.viewManager.setProps(e),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(e),this.effectManager.setProps(e),this.deckRenderer.setProps(e),this.deckPicker.setProps(e)),this.stats.get("setProps Time").timeEnd()}needsRedraw(t={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let e=this._needsRedraw;t.clearRedrawFlags&&(this._needsRedraw=!1);const i=this.viewManager.needsRedraw(t),n=this.layerManager.needsRedraw(t),r=this.effectManager.needsRedraw(t),s=this.deckRenderer.needsRedraw(t);return e=e||i||n||r||s,e}redraw(t){if(!this.layerManager)return;let e=this.needsRedraw({clearRedrawFlags:!0});e=t||e,e&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(e):this._drawLayers(e))}get isInitialized(){return null!==this.viewManager}getViews(){return ae(this.viewManager),this.viewManager.views}getViewports(t){return ae(this.viewManager),this.viewManager.getViewports(t)}pickObject(t){const e=this._pick("pickObject","pickObject Time",t).result;return e.length?e[0]:null}pickMultipleObjects(t){return t.depth=t.depth||10,this._pick("pickObject","pickMultipleObjects Time",t).result}pickObjects(t){return this._pick("pickObjects","pickObjects Time",t)}_addResources(t,e=!1){for(const i in t)this.layerManager.resourceManager.add({resourceId:i,data:t[i],forceUpdate:e})}_removeResources(t){for(const e of t)this.layerManager.resourceManager.remove(e)}_pick(t,e,i){ae(this.deckPicker);const{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(e).timeStart();const r=this.deckPicker[t]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return n.get(e).timeEnd(),r}_createCanvas(t){let e=t.canvas;if("string"==typeof e&&(e=document.getElementById(e),ae(e)),!e){e=document.createElement("canvas"),e.id=t.id||"deckgl-overlay";(t.parent||document.body).appendChild(e)}return Object.assign(e.style,t.style),e}_setCanvasSize(t){if(!this.canvas)return;const{width:e,height:i}=t;if(e||0===e){const t=Number.isFinite(e)?"".concat(e,"px"):e;this.canvas.style.width=t}if(i||0===i){var n;const e=Number.isFinite(i)?"".concat(i,"px"):i;this.canvas.style.position=(null===(n=t.style)||void 0===n?void 0:n.position)||"absolute",this.canvas.style.height=e}}_updateCanvasSize(){const{canvas:t}=this;if(!t)return;const e=t.clientWidth||t.width,i=t.clientHeight||t.height;var n;e===this.width&&i===this.height||(this.width=e,this.height=i,null===(n=this.viewManager)||void 0===n||n.setProps({width:e,height:i}),this.props.onResize({width:e,height:i}))}_createAnimationLoop(t){const{width:e,height:i,gl:n,glOptions:r,debug:s,onError:o,onBeforeRender:a,onAfterRender:c,useDevicePixels:l}=t;return new ed({width:e,height:i,useDevicePixels:l,autoResizeViewport:!1,gl:n,onCreateContext:t=>Ki({...r,...t,canvas:this.canvas,debug:s,onContextLost:()=>this._onContextLost()}),onInitialize:t=>this._setGLContext(t.gl),onRender:this._onRenderFrame.bind(this),onBeforeRender:a,onAfterRender:c,onError:o})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let t=this.props.views||[new Fe({id:"default-view"})];return t=Array.isArray(t)?t:[t],t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){const{onError:t}=this.props;this.animationLoop&&t&&t(new Error("WebGL context is lost"))}_pickAndCallback(){const{_pickRequest:t}=this;if(t.event){const{result:i,emptyInfo:n}=this._pick("pickObject","pickObject Time",t);this.cursorState.isHovering=i.length>0;let r=n,s=!1;for(const n of i){var e;r=n,s=(null===(e=n.layer)||void 0===e?void 0:e.onHover(n,t.event))||s}if(!s&&this.props.onHover&&this.props.onHover(r,t.event),this.props.getTooltip&&this.tooltip){const t=this.props.getTooltip(r);this.tooltip.setTooltip(t,r.x,r.y)}t.event=null}}_updateCursor(){const t=this.props.parent||this.canvas;t&&(t.style.cursor=this.props.getCursor(this.cursorState))}_setGLContext(t){if(this.layerManager)return;this.canvas||(this.canvas=t.canvas,Qi(t,{enable:!0,copyState:!0})),this.tooltip=new Cu(this.canvas),ji(t,{blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onWebGLInitialized(t);const e=new Oh;e.play(),this.animationLoop.attachTimeline(e),this.eventManager=new Cd(this.props.parent||t.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const t in Zt)this.eventManager.on(t,this._onEvent);this.viewManager=new Nh({timeline:e,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});const i=this.viewManager.getViewports()[0];this.layerManager=new jh(t,{deck:this,stats:this.stats,viewport:i,timeline:e}),this.effectManager=new mu,this.deckRenderer=new wu(t),this.deckPicker=new Su(t),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(t,e){const{gl:i}=this.layerManager.context;ji(i,this.props.parameters),this.props.onBeforeRender({gl:i}),this.deckRenderer.renderLayers({target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",redrawReason:t,effects:this.effectManager.getEffects(),...e}),this.props.onAfterRender({gl:i})}_onRenderFrame(t){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),T.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.tooltip.isVisible&&this.viewManager.needsRedraw()&&this.tooltip.setTooltip(null),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(t){const e=this.props.onViewStateChange(t)||t.viewState;this.viewState&&(this.viewState={...this.viewState,[t.viewId]:e},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(t){this.cursorState.isDragging=t.isDragging||!1,this.props.onInteractionStateChange(t)}_getFrameStats(){const{stats:t}=this;t.get("frameRate").timeEnd(),t.get("frameRate").timeStart();const e=this.animationLoop.stats;t.get("GPU Time").addTime(e.get("GPU Time").lastTiming),t.get("CPU Time").addTime(e.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:t,stats:e}=this;t.fps=e.get("frameRate").getHz(),t.setPropsTime=e.get("setProps Time").time,t.updateAttributesTime=e.get("Update Attributes").time,t.framesRedrawn=e.get("Redraw Count").count,t.pickTime=e.get("pickObject Time").time+e.get("pickMultipleObjects Time").time+e.get("pickObjects Time").time,t.pickCount=e.get("Pick Count").count,t.gpuTime=e.get("GPU Time").time,t.cpuTime=e.get("CPU Time").time,t.gpuTimePerFrame=e.get("GPU Time").getAverageTime(),t.cpuTimePerFrame=e.get("CPU Time").getAverageTime();const i=ln.get("Memory Usage");t.bufferMemory=i.get("Buffer Memory").count,t.textureMemory=i.get("Texture Memory").count,t.renderbufferMemory=i.get("Renderbuffer Memory").count,t.gpuMemory=i.get("GPU Memory").count}}r(Od,"defaultProps",Rd),r(Od,"VERSION",Qu.VERSION);const Id=[{values:{capacity:150},id:"13934067909132301",point:{lon:55.296872,lat:25.261885}},{values:{capacity:62},id:"13934067909132302",point:{lon:55.296644,lat:25.262364}},{values:{capacity:71},id:"13934067909132306",point:{lon:55.299031,lat:25.254415}},{values:{capacity:80},id:"13934067909132307",point:{lon:55.291748,lat:25.257678}},{values:{capacity:110},id:"13934067909132308",point:{lon:55.290661,lat:25.257318}},{values:{capacity:100},id:"13934067909132329",point:{lon:55.286698,lat:25.248655}},{values:{capacity:250},id:"13934067909132336",point:{lon:55.292688,lat:25.255866}},{values:{capacity:100},id:"13934067909132338",point:{lon:55.292944,lat:25.261459}},{values:{capacity:86},id:"13934067909132352",point:{lon:55.288931,lat:25.253647}},{values:{capacity:91},id:"13934067909132360",point:{lon:55.300526,lat:25.240158}},{values:{capacity:35},id:"13934067909132367",point:{lon:55.298337,lat:25.24287}},{values:{capacity:44},id:"13934067909132394",point:{lon:55.316646,lat:25.241769}},{values:{capacity:150},id:"13934067909132395",point:{lon:55.3139,lat:25.245108}},{values:{capacity:150},id:"13934067909132407",point:{lon:55.313023,lat:25.236685}},{values:{capacity:47},id:"13934067909132409",point:{lon:55.32312,lat:25.262683}},{values:{capacity:64},id:"13934067909132412",point:{lon:55.310634,lat:25.241129}},{values:{capacity:60},id:"13934067909132417",point:{lon:55.306843,lat:25.235247}},{values:{capacity:220},id:"13934067909132430",point:{lon:55.308546,lat:25.234801}},{values:{capacity:100},id:"13934067909132431",point:{lon:55.307055,lat:25.237593}},{values:{capacity:190},id:"13934067909132445",point:{lon:55.327831,lat:25.264164}},{values:{capacity:350},id:"13934067909132452",point:{lon:55.288392,lat:25.256289}},{values:{capacity:300},id:"13934067909132465",point:{lon:55.316415,lat:25.266282}},{values:{capacity:30},id:"13934067909132467",point:{lon:55.316642,lat:25.265396}},{values:{capacity:50},id:"13934067909132477",point:{lon:55.316711,lat:25.237492}},{values:{capacity:118},id:"13934067909132479",point:{lon:55.318918,lat:25.262349}},{values:{capacity:200},id:"13934067909132480",point:{lon:55.325285,lat:25.273077}},{values:{capacity:20},id:"13934067909132490",point:{lon:55.321941,lat:25.274561}},{values:{capacity:60},id:"13934067909132505",point:{lon:55.319229,lat:25.270723}},{values:{capacity:130},id:"13934067909132509",point:{lon:55.325311,lat:25.271236}},{values:{capacity:17},id:"13934067909132522",point:{lon:55.314612,lat:25.232981}},{values:{capacity:75},id:"13934067909132523",point:{lon:55.311862,lat:25.280181}},{values:{capacity:370},id:"13934067909132525",point:{lon:55.311276,lat:25.279494}},{values:{capacity:50},id:"13934067909132533",point:{lon:55.291673,lat:25.245168}},{values:{capacity:30},id:"13934067909132538",point:{lon:55.315452,lat:25.27374}},{values:{capacity:200},id:"13934067909132547",point:{lon:55.313543,lat:25.281049}},{values:{capacity:50},id:"13934067909132586",point:{lon:55.320775,lat:25.279659}},{values:{capacity:144},id:"13934067909132604",point:{lon:55.308592,lat:25.273939}},{values:{capacity:90},id:"13934067909132610",point:{lon:55.300195,lat:25.257977}},{values:{capacity:250},id:"13934067909132613",point:{lon:55.306478,lat:25.266793}},{values:{capacity:21},id:"13934067909132616",point:{lon:55.314892,lat:25.263818}},{values:{capacity:12},id:"13934067909132639",point:{lon:55.306823,lat:25.276022}},{values:{capacity:8},id:"13934067909132666",point:{lon:55.29545,lat:25.266237}},{values:{capacity:30},id:"13934067909132682",point:{lon:55.277331,lat:25.231025}},{values:{capacity:100},id:"13934067909132685",point:{lon:55.278975,lat:25.23428}},{values:{capacity:300},id:"13934067909132694",point:{lon:55.331366,lat:25.229446}},{values:{capacity:170},id:"13934067909132709",point:{lon:55.301576,lat:25.235204}},{values:{capacity:35},id:"13934067909132717",point:{lon:55.313003,lat:25.273915}},{values:{capacity:33},id:"13934067909132723",point:{lon:55.320412,lat:25.25953}},{values:{capacity:300},id:"13934067909132738",point:{lon:55.300396,lat:25.2297}},{values:{capacity:10},id:"13934067909132742",point:{lon:55.321495,lat:25.22691}},{values:{capacity:80},id:"13934067909132754",point:{lon:55.324118,lat:25.22819}},{values:{capacity:49},id:"13934067909132756",point:{lon:55.325171,lat:25.227075}},{values:{capacity:500},id:"13934067909132779",point:{lon:55.256418,lat:25.210069}},{values:{capacity:40},id:"13934067909132808",point:{lon:55.223279,lat:25.10511}},{values:{capacity:18},id:"13934067909132809",point:{lon:55.278131,lat:25.23463}},{values:{capacity:35},id:"13934067909132819",point:{lon:55.331314,lat:25.280257}},{values:{capacity:40},id:"13934067909132820",point:{lon:55.330445,lat:25.271552}},{values:{capacity:40},id:"13934067909132822",point:{lon:55.219422,lat:25.08158}},{values:{capacity:50},id:"13934067909132837",point:{lon:55.234875,lat:25.041505}},{values:{capacity:120},id:"13934067909132845",point:{lon:55.346136,lat:25.276486}},{values:{capacity:110},id:"13934067909132858",point:{lon:55.198323,lat:25.109154}},{values:{capacity:150},id:"13934067909132881",point:{lon:55.373198,lat:25.280188}},{values:{capacity:150},id:"13934067909132883",point:{lon:55.2936,lat:25.273725}},{values:{capacity:100},id:"13934067909132889",point:{lon:55.371813,lat:25.270933}},{values:{capacity:70},id:"13934067909132892",point:{lon:55.394301,lat:25.245186}},{values:{capacity:100},id:"13934067909132901",point:{lon:55.394639,lat:25.263217}},{values:{capacity:15},id:"13934067909132914",point:{lon:55.363059,lat:25.277003}},{values:{capacity:507},id:"13934067909132916",point:{lon:55.33553,lat:25.258428}},{values:{capacity:300},id:"13934067909132925",point:{lon:55.34271,lat:25.24491}},{values:{capacity:200},id:"13934067909132926",point:{lon:55.340455,lat:25.244212}},{values:{capacity:15},id:"13934067909132927",point:{lon:55.176593,lat:25.060229}},{values:{capacity:210},id:"13934067909132930",point:{lon:55.339109,lat:25.252138}},{values:{capacity:15},id:"13934067909132936",point:{lon:55.347653,lat:25.233491}},{values:{capacity:205},id:"13934067909132946",point:{lon:55.372065,lat:25.288359}},{values:{capacity:10},id:"13934067909132949",point:{lon:55.35405,lat:25.234399}},{values:{capacity:39},id:"13934067909132950",point:{lon:55.357441,lat:25.237243}},{values:{capacity:38},id:"13934067909132956",point:{lon:55.282098,lat:25.25134}},{values:{capacity:102},id:"13934067909132963",point:{lon:55.3819,lat:25.286925}},{values:{capacity:129},id:"13934067909132966",point:{lon:55.377568,lat:25.289276}},{values:{capacity:327},id:"13934067909132967",point:{lon:55.376155,lat:25.290723}},{values:{capacity:114},id:"13934067909132969",point:{lon:55.375807,lat:25.294765}}],kd=new mapgl.Map("container",{center:[55.291748,25.237678],zoom:14.1,pitch:40,key:"4970330e-7f1c-4921-808c-0eb7c4e63001"}),Fd=new Od(Je(kd,{skipResizeRenderer:!0}));kd.once("ready",()=>{!function(){const t=(e=Id,new ni({id:"deckgl-HeatmapLayer",deck:Fd,colorRange:Dd,type:Ml,data:e,parameters:{depthTest:!1},getWeight:t=>t.values.capacity,getPosition:t=>[t.point.lon,t.point.lat]}));var e;kd.addLayer(t);const i=function(t){return new ni({id:"deckgl-HexagonLayer",deck:Fd,colorRange:Dd,type:Ch,data:t,parameters:{depthTest:!0},opacity:.8,radius:480,elevationScale:2,getPosition:t=>[t.point.lon,t.point.lat],extruded:!0,antialiasing:!0})}(Id);kd.addLayer(i);const n=function(t){return new ni({id:"deckgl-HexagonLayer2",deck:Fd,colorRange:Dd,type:Ch,data:t,parameters:{depthTest:!0},opacity:.2,radius:700,elevationScale:1,getPosition:t=>[t.point.lon,t.point.lat],extruded:!0})}(Id);kd.addLayer(n)}()});const Dd=[[1,152,189],[73,227,206],[216,254,181],[254,237,177],[254,173,84],[209,55,78]];window.addEventListener("resize",()=>kd.invalidateSize())}]); \ No newline at end of file diff --git a/dist/docs.json b/dist/docs.json new file mode 100644 index 0000000..0f06608 --- /dev/null +++ b/dist/docs.json @@ -0,0 +1 @@ +{"typescript":{"Deck2gisLayer":{"documentation":{"contents":["

A class that provides rendering any deck.gl layer inside the MapGl canvas / WebGL context.

\n"],"contentsRaw":"A class that provides rendering any deck.gl layer inside the MapGl canvas / WebGL context.","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"class","name":"Deck2gisLayer","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L46","implements":["DeckCustomLayer"],"methods":[{"documentation":{"contents":["

Initializes deck.gl properties for working with the MapGL map.

\n"],"contentsRaw":"Initializes deck.gl properties for working with the MapGL map.","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":true},"kind":"method","name":"initDeck2gisProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L61","signatures":[{"documentation":{"contents":["

Initializes deck.gl properties for working with the MapGL map.

\n"],"contentsRaw":"Initializes deck.gl properties for working with the MapGL map.","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","kind":"signature","name":"initDeck2gisProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L61","parameters":[{"documentation":{"contents":["

The map instance.

\n"],"contentsRaw":"The map instance.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"map","type":"Map"},{"documentation":{"contents":["

CustomRenderProps initialization options.

\n"],"contentsRaw":"CustomRenderProps initialization options.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":true,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"deckProps","type":"CustomRenderProps"}],"returnType":"DeckProps","type":"(map: Map, deckProps?: CustomRenderProps) => DeckProps"}]},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":true,"isRest":false,"isStatic":false},"kind":"method","name":"setProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L155","signatures":[{"documentation":{"contents":["

Sets layer properties and updates the layer.

\n"],"contentsRaw":"Sets layer properties and updates the layer.","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","kind":"signature","name":"setProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L155","parameters":[{"documentation":{"contents":["

deck.gl layer properties.

\n"],"contentsRaw":"deck.gl layer properties.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"props","type":"Partial>"}],"returnType":"void","type":"(props: Partial>) => void"}]}],"properties":[{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"antialiasing","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L54","type":"boolean"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"deck","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L51","type":"Deck | null"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":true,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"gl","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L53","type":"WebGLRenderingContext | WebGL2RenderingContext"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"id","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L47","type":"string"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"map","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L50","type":"Map | null"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"props","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L52","type":"LayerProps"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"renderingMode","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L49","type":"\"2d\" | \"3d\""},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"type","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L48","type":"\"custom\""}],"accessors":[],"constructorType":{"documentation":{"contents":["

Example:

\n
const deckLayer = new mapgl.Deck2gisLayer(map, {\n    id: 'deckLayer',\n    deck,\n    type: HexagonLayer,\n    data,\n    getPosition: (d) => [d.point.lon, d.point.lat]\n});\n\nmap.addLayer(deckLayer);
\n"],"contentsRaw":"Example:\n```js\nconst deckLayer = new mapgl.Deck2gisLayer(map, {\n id: 'deckLayer',\n deck,\n type: HexagonLayer,\n data,\n getPosition: (d) => [d.point.lon, d.point.lat]\n});\n\nmap.addLayer(deckLayer);\n```","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"constructor","name":"constructor","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L66","signatures":[{"documentation":{"contents":["

Example:

\n
const deckLayer = new mapgl.Deck2gisLayer(map, {\n    id: 'deckLayer',\n    deck,\n    type: HexagonLayer,\n    data,\n    getPosition: (d) => [d.point.lon, d.point.lat]\n});\n\nmap.addLayer(deckLayer);
\n"],"contentsRaw":"Example:\n```js\nconst deckLayer = new mapgl.Deck2gisLayer(map, {\n id: 'deckLayer',\n deck,\n type: HexagonLayer,\n data,\n getPosition: (d) => [d.point.lon, d.point.lat]\n});\n\nmap.addLayer(deckLayer);\n```","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","kind":"signature","name":"new Deck2gisLayer","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L66","parameters":[{"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"props","type":"LayerProps"}],"returnType":"Deck2gisLayer","type":"(props: LayerProps) => Deck2gisLayer"}]}},"initDeck2gisProps":{"fileName":"src/utils.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"method","name":"initDeck2gisProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/utils.ts#L209","signatures":[{"documentation":{"contents":["

Initializes deck.gl properties for working with the MapGL map.

\n"],"contentsRaw":"Initializes deck.gl properties for working with the MapGL map.","metadata":{}},"fileName":"src/utils.ts","kind":"signature","name":"initDeck2gisProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/utils.ts#L209","parameters":[{"documentation":{"contents":["

The map instance.

\n"],"contentsRaw":"The map instance.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"map","type":"Map"},{"documentation":{"contents":["

CustomRenderProps initialization options.

\n"],"contentsRaw":"CustomRenderProps initialization options.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":true,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"deckProps","type":"RenderProps | CustomRenderProps"}],"returnType":"DeckProps","type":"(map: Map, deckProps?: RenderProps | CustomRenderProps) => DeckProps"}]},"DeckCustomLayer":{"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"DeckCustomLayer","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L6","methods":[],"properties":[{"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"id","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L8","type":"string"},{"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"props","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L10","type":"any"},{"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"render","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L9","type":"(gl: WebGLRenderingContext) => void"},{"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"type","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L7","type":"\"custom\""}]},"Deck2gisLayerProps":{"documentation":{"contents":["

Deck2gisLayer required props.

\n"],"contentsRaw":"Deck2gisLayer required props.","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"Deck2gisLayerProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L29","methods":[],"properties":[{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":true,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"antialiasing","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L34","type":"undefined | false | true"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"deck","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L32","type":"Deck"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"id","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L30","type":"string"},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":true,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"renderingMode","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L31","type":"\"2d\" | \"3d\""},{"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"type","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L33","type":"DeckLayer"}]},"CustomRenderProps":{"documentation":{"contents":["

CustomRenderProps is type extends from DeckProps:\nhttps://deck.gl/docs/api-reference/core/deck#properties

\n"],"contentsRaw":"CustomRenderProps is type extends from DeckProps:\nhttps://deck.gl/docs/api-reference/core/deck#properties","metadata":{}},"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"type alias","name":"CustomRenderProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L51","type":"Partial & CustomRenderInternalProps"},"RenderProps":{"documentation":{"contents":["

RenderProps is type extends from DeckProps:\nhttps://deck.gl/docs/api-reference/core/deck#properties

\n"],"contentsRaw":"RenderProps is type extends from DeckProps:\nhttps://deck.gl/docs/api-reference/core/deck#properties","metadata":{}},"fileName":"src/types.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"type alias","name":"RenderProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/types.ts#L57","type":"Partial & "},"DeckLayer":{"documentation":{"contents":["

Any Layer class from deck.gl.

\n"],"contentsRaw":"Any Layer class from deck.gl.","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"type alias","name":"DeckLayer","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L24","type":"any"},"LayerProps":{"documentation":{"contents":["

LayerProps is type extends from Layer:\nhttps://deck.gl/docs/api-reference/core/layer

\n"],"contentsRaw":"LayerProps is type extends from Layer:\nhttps://deck.gl/docs/api-reference/core/layer","metadata":{}},"fileName":"src/deckgl2gisLayer.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"type alias","name":"LayerProps","sourceUrl":"https://github.com/2gis/deck2gisLayer/blob/673aa91/src/deckgl2gisLayer.ts#L41","type":"Deck2gisLayerProps & Partial"}}} \ No newline at end of file diff --git a/dist/index.html b/dist/index.html new file mode 100644 index 0000000..e57ce11 --- /dev/null +++ b/dist/index.html @@ -0,0 +1,23 @@ + + + + + + MapGL deckgl layer example + + + +
+ + + + diff --git a/dist/types/deckgl2gisLayer.d.ts b/dist/types/deckgl2gisLayer.d.ts new file mode 100644 index 0000000..18d6200 --- /dev/null +++ b/dist/types/deckgl2gisLayer.d.ts @@ -0,0 +1,66 @@ +import type { Deck, Layer } from '@deck.gl/core/typed'; +import { CustomRenderProps, DeckCustomLayer } from './types'; +import type { Map } from '@2gis/mapgl/types'; +/** + * Any Layer class from deck.gl. + */ +export type DeckLayer = any; +/** + * Deck2gisLayer required props. + */ +export interface Deck2gisLayerProps { + id: string; + renderingMode?: '2d' | '3d'; + deck: Deck; + type: DeckLayer; + antialiasing?: boolean; +} +/** + * LayerProps is type extends from Layer: + * https://deck.gl/docs/api-reference/core/layer + */ +export type LayerProps = Deck2gisLayerProps & Partial; +/** + * A class that provides rendering any deck.gl layer inside the MapGl canvas / WebGL context. + */ +export declare class Deck2gisLayer implements DeckCustomLayer { + id: string; + type: 'custom'; + renderingMode: '2d' | '3d'; + map: Map | null; + deck: Deck | null; + props: LayerProps; + gl?: WebGLRenderingContext | WebGL2RenderingContext; + antialiasing: boolean; + /** + * Initializes deck.gl properties for working with the MapGL map. + * @param map The map instance. + * @param deckProps CustomRenderProps initialization options. + */ + static initDeck2gisProps: (map: Map, deckProps?: CustomRenderProps) => import("@deck.gl/core/typed").DeckProps; + private frameBuffer?; + private program?; + private vao?; + /** + * Example: + * ```js + * const deckLayer = new mapgl.Deck2gisLayer(map, { + * id: 'deckLayer', + * deck, + * type: HexagonLayer, + * data, + * getPosition: (d) => [d.point.lon, d.point.lat] + * }); + * + * map.addLayer(deckLayer); + * ``` + * @param map The map instance. + * @param options Deck2gisLayer initialization options. + */ + constructor(props: LayerProps); + /** + * Sets layer properties and updates the layer. + * @param props deck.gl layer properties. + */ + setProps(props: Partial>): void; +} diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts new file mode 100644 index 0000000..89ba228 --- /dev/null +++ b/dist/types/index.d.ts @@ -0,0 +1,3 @@ +import { Deck2gisLayer } from './deckgl2gisLayer'; +import { initDeck2gisProps } from './utils'; +export { Deck2gisLayer, initDeck2gisProps }; diff --git a/dist/types/optimized.fsh.d.ts b/dist/types/optimized.fsh.d.ts new file mode 100644 index 0000000..88a897c --- /dev/null +++ b/dist/types/optimized.fsh.d.ts @@ -0,0 +1,2 @@ +declare const _default: "precision mediump float;\n#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\nvarying vec2 vUv;\nuniform vec2 iResolution;\nuniform sampler2D iChannel0;\nuniform bool enabled;\n#ifndef FXAA_REDUCE_MIN\n #define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n #define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n #define FXAA_SPAN_MAX 8.0\n#endif\nvec4 fxaa_1_0(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE, \n vec2 v_rgbSW, vec2 v_rgbSE, \n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n \n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n \n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n \n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n \n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\nvoid main() {\n \n mediump vec2 fragCoord = vUv * iResolution; \n vec4 color;\n if (enabled) {\n color = fxaa_1_0(iChannel0, fragCoord, iResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n } else {\n color = texture2D(iChannel0, vUv);\n }\n gl_FragColor = color;\n}\n"; +export default _default; diff --git a/dist/types/optimized.vsh.d.ts b/dist/types/optimized.vsh.d.ts new file mode 100644 index 0000000..211c94a --- /dev/null +++ b/dist/types/optimized.vsh.d.ts @@ -0,0 +1,2 @@ +declare const _default: "precision mediump float;\n#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\nuniform vec2 iResolution;\nattribute vec2 position;\nvarying vec2 vUv;\nvoid texcoords_1_0(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvoid main(void) {\n gl_Position = vec4(position, 1.0, 1.0);\n \n \n vUv = (position + 1.0) * 0.5;\n vUv.y = vUv.y;\n vec2 fragCoord = vUv * iResolution;\n texcoords_1_0(fragCoord, iResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}"; +export default _default; diff --git a/dist/types/types.d.ts b/dist/types/types.d.ts new file mode 100644 index 0000000..316c7c2 --- /dev/null +++ b/dist/types/types.d.ts @@ -0,0 +1,19 @@ +import { DeckProps } from '@deck.gl/core/typed'; +export interface DeckCustomLayer { + type: 'custom'; + id: string; + render: (gl: WebGLRenderingContext) => void; + props: any; +} +/** + * CustomRenderProps is type extends from DeckProps: + * https://deck.gl/docs/api-reference/core/deck#properties + */ +export type CustomRenderProps = Partial & CustomRenderInternalProps; +/** + * RenderProps is type extends from DeckProps: + * https://deck.gl/docs/api-reference/core/deck#properties + */ +export type RenderProps = Partial & { + skipResizeRenderer?: boolean; +}; diff --git a/dist/types/utils.d.ts b/dist/types/utils.d.ts new file mode 100644 index 0000000..9c35815 --- /dev/null +++ b/dist/types/utils.d.ts @@ -0,0 +1,9 @@ +import type { Map } from '@2gis/mapgl/types'; +import { CustomRenderProps, RenderProps } from './types'; +import { DeckProps } from '@deck.gl/core/typed'; +/** + * Initializes deck.gl properties for working with the MapGL map. + * @param map The map instance. + * @param deckProps CustomRenderProps initialization options. + */ +export declare function initDeck2gisProps(map: Map, deckProps?: RenderProps | CustomRenderProps): DeckProps; diff --git a/dist/types/viewport.d.ts b/dist/types/viewport.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/types/viewport.d.ts @@ -0,0 +1 @@ +export {};