1import{aF as c,bQ as J}from"./index-ec743896.js";import{cj as I,eU as ui,eW as Ot,eY as ci,fD as hi,eV as fs,ii as ht,eN as pi,L as ys,aF as xs,j as F,k as it,Q as di,bH as mi,a3 as gi,br as fi,_ as yi,w as Ke,l as et,e9 as is,aO as xi,fa as wi,ax as He,s as bi,ad as _i,d1 as rs,aA as os}from"./projectors-89580c2c.js";import{t as ws,c as as}from"./datasetUtils-f271d5f4.js";import{v as Ti,i as vi,d as Ci}from"./RasterVFDisplayObject-3520c531.js";import{b as Si}from"./LayerView2D-fc9b817c.js";import{l as Ri}from"./pixelRangeUtils-085021cc.js";import{h as Pi}from"./clipUtils-c43c4f7e.js";import{i as se,S as Fi}from"./vectorFieldUtils-27d770e5.js";import{d as tt,m as Ii,W as bs,o as zi}from"./MapView-dc83c12e.js";import{r as pt,a as ns,h as $i,p as Mi}from"./Tile-177ac237.js";import{e as Di}from"./Container-3833bb6a.js";import{i as ki,s as Oi,u as Bi,o as jt}from"./rasterUtils-ab5d887c.js";import{b as _s}from"./WGLContainer-5a1d0962.js";import{n as Ts}from"./TileContainer-face4c34.js";import{f as Oe,m,g as X,i as Be,c as _,j as $,U as D,b as d,P as Ve,_ as x,d as z,V as v,N as R,Z as M,x as k,I as Ae,v as Ge,t as st,X as rt,B as le,k as ot,z as ue,T as Kt,e as W,$ as Vi,a0 as ls,Y as b,p as Q,A as vs,w as Z,n as C,a1 as ce,r as _e,a2 as L,q as ie,D as Ut,Q as U,E as te,W as he,a3 as De,G as Cs,K as Ft,s as E,C as $e,a4 as ge,a5 as Ai,a as ye,a6 as Gi,a7 as qi,a8 as ji,a9 as Ui,aa as Li,ab as Ei,ac as Hi,ad as Ni,ae as Wi,af as Zi,ag as Qi,ah as Yi,u as Ji,ai as Xi,M as Ki,aj as er,ak as tr,al as sr,am as ir,an as rr,ao as or,H as ar,ap as Bt,aq as nr,y as lr,ar as ur,as as cr,at as hr}from"./GraphShaderModule-476b565e.js";import{e as us}from"./utils-574c1df2.js";import{g as at,J as Lt,E as ke}from"./utils-3eb62380.js";import{H as dt}from"./constants-f7650527.js";import{t as Ss}from"./capabilities-2af38b34.js";import{U as fe,P as ve,D as j,C as Ce,E as Y,N as ee}from"./enums-f9b09dbc.js";import{m as zt}from"./FramebufferObject-95ebe40d.js";import{A as $t,h as Mt}from"./Texture-12c48ff4.js";import{m as pr}from"./bitmapUtils-93ab2c96.js";import{o as N}from"./definitions-c9d1325d.js";import{h as dr}from"./UpdatingHandles-2cbd8cdf.js";import{c as mr}from"./PixelBlock-576ecf0f.js";import{z as cs}from"./TileInfo-3c4aa26a.js";import{g as hs,a as ps,i as gr,u as fr}from"./RawBlockCache-2b61becb.js";import{$ as yr,m as xr,v as wr,u as ds,I as br}from"./rasterProjectionHelper-1063c86a.js";import"./TileKey-a9913e43.js";import{f as _r}from"./Scheduler-b837355d.js";import{r as Vt}from"./highlightOptionsUtils-905406b9.js";import{_ as Tr}from"./Graphic-b38a95b0.js";import{a as vr,i as Ue,V as Cr}from"./rasterFieldUtils-903c2e3b.js";import{i as Sr}from"./timeSupport-b93bdebb.js";import{n as Rr}from"./popupUtils-5ddd4808.js";import{d as Pr}from"./LayerView-36837ce5.js";import{i as Fr}from"./RefreshableLayerView-b6b1333b.js";import"./screenUtils-c9e101bc.js";import"./VertexArrayObject-bc224e72.js";import"./memoryEstimations-e39a3b7f.js";import"./VertexAttributeLocations-5351167d.js";import"./VertexBuffer-f34939b0.js";import"./BufferObject-f9badb60.js";import"./VertexElementDescriptor-2925c6af.js";import"./dataUtils-ec93c2d0.js";import"./Utils-9f79cbf3.js";import"./BoundingBox-f89c8d18.js";import"./utils-959993e6.js";import"./ReactiveMap-7d651aa2.js";import"./jsonUtils-87334bc8.js";import"./layerViewUtils-caa119a9.js";import"./typeUtils-c530565a.js";import"./CollectionFlattener-05fbfd0e.js";import"./workers-dcb5a3b8.js";import"./Queue-875ec290.js";import"./intl-ad646b03.js";import"./GraphicsCollection-ad48d5fc.js";import"./projectionUtils-65ca48fc.js";import"./jsxFactory-f9f03aee.js";import"./uuid-409b6a0c.js";import"./sanitizerUtils-8778e332.js";import"./asyncUtils-c128580c.js";import"./signal-c6bff383.js";import"./Map-d496c183.js";import"./Basemap-ed0c857e.js";import"./loadAll-49a2a2f4.js";import"./PortalItem-c1e0ac6b.js";import"./isBasemap-a44d5d0f.js";import"./writeUtils-9d1c4624.js";import"./layerUtils-e17c9ca4.js";import"./persistable-061755af.js";import"./MD5-715f37cd.js";import"./multiOriginJSONSupportUtils-c978f4c3.js";import"./resourceExtension-296c26fa.js";import"./PolygonCollection-12c34299.js";import"./mat4f32-176526a0.js";import"./mat4-6eafcee1.js";import"./TablesMixin-b62f11eb.js";import"./HeightModelInfo-b60513ff.js";import"./timeZoneUtils-48a51224.js";import"./Query-855c25fd.js";import"./Field-545bfca1.js";import"./fieldType-d07b5726.js";import"./vec2f64-1f37f5b9.js";import"./normalizeUtils-13dbdedd.js";
1import"./Cyclical-976bf4bf.js";import"./normalizeUtilsCommon-305fa5aa.js";import"./utils-9bb59dea.js";import"./utils-89e1adff.js";import"./vec32-cc67dc50.js";import"./unitBezier-0bb0dc5d.js";import"./arcadeUtils-ff917068.js";import"./quickselect-b7b34c34.js";import"./imageUtils-8d625b3a.js";import"./Version-ddbf928d.js";import"./EffectView-c733d290.js";import"./parser-e8753ad4.js";import"./ProgramTemplate-46761392.js";import"./vec3f32-5edf24fc.js";import"./config-1337d16e.js";import"./earcut-5a6c70eb.js";import"./featureConversionUtils-824de5e1.js";import"./aaBoundingBox-320413aa.js";import"./DoubleArray-eaf5f7f5.js";import"./mat4f64-78ff2589.js";import"./OptimizedFeature-12739fdd.js";import"./OptimizedGeometry-0f89db72.js";import"./OptimizedFeatureSet-5dc8ee29.js";import"./createFeatureId-0ffcb182.js";import"./ShaderBuilder-09022b3b.js";import"./TileKey-4739c75b.js";import"./getPopupProvider-997a7607.js";import"./fieldUtils-415e03cd.js";import"./typeUtils-24903583.js";import"./SimpleMarkerSymbol-561835ce.js";import"./TextSymbol-57f1eab9.js";import"./PictureMarkerSymbol-ff7b77f8.js";const Ir={bandCount:3,minOutput:0,maxOutput:1,minCutOff:[0,0,0],maxCutOff:[255,255,255],factor:[1/255,1/255,1/255],useGamma:!1,gamma:[1,1,1],gammaCorrection:[1,1,1],colormap:null,colormapOffset:null,stretchType:"none",type:"stretch"};let zr=class extends Di{constructor(e=null,t=null,s=null){super(),this._textureInvalidated=!0,this._colormapTextureInvalidated=!0,this._rasterTexture=null,this._maskTexture=null,this._rasterTextureBandIds=null,this._transformGridTexture=null,this._colormapTexture=null,this._colormap=null,this._supportsBilinearTexture=!0,this._processedTexture=null,this._highlightTexture=null,this.functionTextures=[],this.projected=!1,this.stencilRef=0,this.coordScale=[1,1],this._processed=!1,this._highlighted=!1,this._symbolizerParameters=null,this.height=null,this.isRendereredSource=!1,this.pixelRatio=1,this.resolution=0,this.rotation=0,this._source=null,this._mask=null,this.rawPixelData=null,this._suspended=!1,this._bandIds=null,this._interpolation=null,this._transformGrid=null,this.width=null,this.x=0,this.y=0,this.source=e,this.transformGrid=t,this.interpolation=s}destroy(){super.destroy(),this._disposeTextures()}get processedTexture(){return this._processedTexture}set processedTexture(e){this._processedTexture!==e&&(this._disposeTextures(!0),this._processedTexture=e)}get highlightTexture(){return this._highlightTexture}set highlightTexture(e){var t;this._highlightTexture!==e&&((t=this._highlightTexture)==null||t.dispose(),this._highlightTexture=e),e==null&&(this._highlighted=!1)}get rasterTexture(){return this._rasterTexture}set rasterTexture(e){var t;this._rasterTexture!==e&&((t=this._rasterTexture)==null||t.dispose(),this._rasterTexture=e),e==null&&(this.projected=!1)}get processed(){return this._processed}set processed(e){this._processed=e,e||(this.processedTexture=I(this.processedTexture),this.invalidateTexture())}get highlighted(){return this._highlighted}get symbolizerParameters(){return this._symbolizerParameters||Ir}set symbolizerParameters(e){this._symbolizerParameters!==e&&(this._symbolizerParameters=e,this._colormapTextureInvalidated=!0)}get source(){return this._source}set source(e){this._source!==e&&(this._source=e,this._rasterTexture&&(this._rasterTexture=I(this._rasterTexture),this._rasterTextureBandIds=null),this.projected=!1,this.invalidateTexture())}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._maskTexture=I(this._maskTexture))}get suspended(){return this._suspended}set suspended(e){this._suspended&&!e&&this.stage&&(this.ready(),this.requestRender()),this._suspended=e}get bandIds(){return this._bandIds}set bandIds(e){this._bandIds=e,this._isBandIdsChanged(e)&&(this.projected=!1,this.invalidateTexture())}get interpolation(){return this._interpolation||"nearest"}set interpolation(e){this._interpolation=e,this._rasterTexture&&this._rasterTexture.setSamplingMode(this._getTextureSamplingMethod(e||"nearest")==="bilinear"?9729:9728)}get transformGrid(){return this._transformGrid}set transformGrid(e){this._transformGrid!==e&&(this._transformGrid=e,this._transformGridTexture=I(this._transformGridTexture))}invalidateTexture(){this._textureInvalidated||(this._textureInvalidated=!0,this.requestRender())}getRasterTextureSize(e=!1){var s,o;const t=e||this.projected;return[t?this.width:((s=this.source)==null?void 0:s.width)||this.width,t?this.height:((o=this.source)==null?void 0:o.height)||this.height]}getRasterCellSize(){var o;const e=(o=this.rawPixelData)==null?void 0:o.srcPixelSize,{projected:t,resolution:s}=this;return e&&!t?[e.x,e.y]:[s,s]}_createTransforms(){return{displayViewScreenMat3:tt()}}setTransform(e){const t=ui(this.transforms.displayViewScreenMat3),[s,o]=e.toScreenNoRotation([0,0],[this.x,this.y]),i=this.resolution/this.pixelRatio/e.resolution,a=i*this.width,n=i*this.height,l=Math.PI*this.rotation/180;Ot(t,t,pt(s,o)),Ot(t,t,pt(a/2,n/2)),ci(t,t,-l),Ot(t,t,pt(-a/2,-n/2)),hi(t,t,pt(a,n)),fs(this.transforms.displayViewScreenMat3,e.displayViewMat3,t)}getTextures({forProcessing:e=!1,useProcessedTexture:t=!1}={}){const s=t?this._processedTexture??this._rasterTexture:this._rasterTexture,o=[],i=[];return s?(this._transformGridTexture&&!this.projected&&(i.push(this._transformGridTexture),o.push("u_transformGrid")),i.push(s),o.push("u_image"),!this._colormapTexture||!t&&e||(i.push(this._colormapTexture),o.push("u_colormap")),this._maskTexture&&(i.push(this._maskTexture),o.push("u_mask")),{names:o,textures:i}):{names:o,textures:i}}onAttach(){this.invalidateTexture()}onDetach(){this.invalidateTexture()}updateTexture({context:e}){if(!this.stage)return void this._disposeTextures();const t=this._isValidSource(this.source);t&&this._colormapTextureInvalidated&&(this._colormapTextureInvalidated=!1,this._updateColormapTexture(e)),this._textureInvalidated&&(this._textureInvalidated=!1,this._createOrDestroyRasterTexture(e),this._rasterTexture&&(t?(this.transformGrid&&!this._transformGridTexture&&(this._transformGridTexture=ki(e,this.transformGrid)),this._mask&&!this._maskTexture&&(this._maskTexture=Oi(e,this._mask,[this.width,this.height]))):this._rasterTexture.setData(null)),this.suspended||(this.ready(),this.requestRender()))}updateProcessedTexture(e=!0){e&&(this._highlighted=this.highlightTexture!=null);const{functionTextures:t}=this;t.length!==0&&(this.processedTexture=t.shift(),t.forEach(s=>s==null?void 0:s.dispose()),t.length=0,this.processed=!!this.processedTexture)}_createOrDestroyRasterTexture(e){var a;const t=(a=this.source)==null?void 0:a.extractBands(this.bandIds);if(!this._isValidSource(t))return void(this._rasterTexture&&(this._rasterTexture=I(this._rasterTexture),this._rasterTextureBandIds=null));const s=!this._isBandIdsChanged(this.bandIds);if(this._rasterTexture){if(s)return;this._rasterTexture=I(this._rasterTexture),this._rasterTextureBandIds=null}this._supportsBilinearTexture=!!e.capabilities.textureFloatLinear;const o=this._getTextureSamplingMethod(this.interpolation),i=this.isRendereredSource;this._rasterTexture=Bi(e,t,o,i),this.projected=!1,this._processed=!1,this._rasterTextureBandIds=this.bandIds?[...this.bandIds]:null}_isBandIdsChanged(e){const t=this._rasterTextureBandIds;return!(t==null&&e==null||t&&e&&t.join("")===e.join(""))}_isValidSource(e){var t;return e!=null&&((t=e.pixels)==null?void 0:t.length)>0}_getTextureSamplingMethod(e){const{type:t}=this.symbolizerParameters,s=t==="lut"&&!this.symbolizerParameters.isClassBreaks||t==="hillshade"||t==="stretch"&&this.symbolizerParameters.bandCount===1;return!this._supportsBilinearTexture||s||e!=="bilinear"&&e!=="cubic"?"nearest":"bilinear"}_updateColormapTexture(e){const t=this._colormap,s=this.symbolizerParameters.colormap;return s?t?s.length!==t.length||s.some((o,i)=>o!==t[i])?(this._colormapTexture&&(this._colormapTexture=I(this._colormapTexture)),this._colormapTexture=jt(e,s),void(this._colormap=s)):void 0:(this._colormapTexture=jt(e,s),void(this._colormap=s)):(this._colormapTexture&&(this._colormapTexture=I(this._colormapTexture)),void(this._colormap=null))}_disposeTextures(e=!1){e?this.projected&&(this._transformGridTexture=I(this._transformGridTexture)):(this._rasterTexture=I(this._rasterTexture),this._colormapTexture=I(this._colormapTexture),this._transformGridTexture=I(this._transformGridTexture),this._maskTexture=I(this._maskTexture),this._rasterTextureBandIds=null,this._colormap=null,this._colormapTextureInvalidated=!0),this._processedTexture=I(this._processedTexture),this._highlightTexture=I(this._highlightTexture)}},$r=class extends _s{constructor(e,t,s,o,i,a,n=null){super(e,t,s,o,i,a),this.bitmap=null,this.bitmap=new zr(n,null,
vendor: 4,834 bytes, line 1
1null),this.bitmap.coordScale=[i,a],this.bitmap.once("isReady",()=>this.ready())}destroy(){super.destroy(),this.bitmap.destroy(),this.bitmap=null,this.stage=null}set stencilRef(e){this.bitmap.stencilRef=e}get stencilRef(){return this.bitmap.stencilRef}setTransform(e){super.setTransform(e),this.bitmap.transforms.displayViewScreenMat3=this.transforms.displayViewScreenMat3}_createTransforms(){return{displayViewScreenMat3:tt(),tileMat3:tt()}}onAttach(){this.bitmap.stage=this.stage}onDetach(){this.bitmap.stage=null}},Rs=class extends Be{};c([Oe(0,_)],Rs.prototype,"position",void 0);let Mr=class extends Ae{},Ne=class extends ${};c([m(D)],Ne.prototype,"inputTexture",void 0),c([m(D)],Ne.prototype,"sumTexture",void 0),c([m(D)],Ne.prototype,"numOfNoDataTexture",void 0),c([m(d)],Ne.prototype,"numTexels",void 0);let ft=class extends Ve{constructor(){super(...arguments),this.type="TextureStatisticsDiffShader"}vertex(e){const t=e.position;return{uv:t,glPosition:new x(at(t),0,1)}}fragment(e){const{inputTexture:t,numOfNoDataTexture:s,sumTexture:o}=this.config,i=new Ge,a=z(t,e.uv),n=v(o,new M(0,0),new R(0)),l=v(s,new M(0,0),new R(0)).r,u=this.config.numTexels.subtract(l),h=n.divide(u),p=k(a.a,new d(0)),g=new d(1).subtract(p).multiply(a.subtract(h));return i.fragColor=g.multiply(g),i}};c([m(Ne)],ft.prototype,"config",void 0),c([J(0,X(Rs))],ft.prototype,"vertex",null),c([J(0,X(Mr))],ft.prototype,"fragment",null);let Ps=class extends Be{};c([Oe(0,_)],Ps.prototype,"position",void 0);let Dr=class extends Ae{},de=class extends ${};c([m(D)],de.prototype,"minTexture",void 0),c([m(D)],de.prototype,"maxTexture",void 0),c([m(D)],de.prototype,"sumTexture",void 0),c([m(D)],de.prototype,"numOfNoDataTexture",void 0),c([m(R)],de.prototype,"width",void 0),c([m(R)],de.prototype,"height",void 0),c([m(R)],de.prototype,"isFirstPass",void 0);let yt=class extends Ve{constructor(){super(...arguments),this.type="TextureStatisticsMinMaxSumShader"}vertex(e){const t=e.position;return{uv:t,glPosition:new x(at(t),0,1)}}fragment(e){const t=new Ge,{minTexture:s,maxTexture:o,sumTexture:i,numOfNoDataTexture:a}=this.config,n=e.glFragCoord.xy,l=new M(n.multiply(2)),u=new R(0),h=v(s,l,u),p=v(s,l.add(new M(-1,0)),u),g=v(s,l.add(new M(0,-1)),u),f=v(s,l.add(new M(-1,-1)),u),y=Le(Le(h,Le(p,new x(dt))),Le(g,Le(f,new x(dt)))),w=v(o,l,u),T=v(o,l.add(new M(-1,0)),u),P=v(o,l.add(new M(0,-1)),u),S=v(o,l.add(new M(-1,-1)),u),O=Ee(Ee(w,Ee(T,new x(-dt))),Ee(P,Ee(S,new x(-dt)))),K=v(i,l,u),pe=v(i,l.add(new M(-1,0)),u),je=v(i,l.add(new M(0,-1)),u),Dt=v(i,l.add(new M(-1,-1)),u),ut=Lt(mt(K),mt(pe),mt(je),mt(Dt)),kt=v(a,l,u),Te=v(a,l.add(new M(-1,0)),u),re=v(a,l.add(new M(0,-1)),u),ni=v(a,l.add(new M(-1,-1)),u),ct=new d(this.config.isFirstPass),li=Lt(gt(kt,ct),gt(Te,ct),gt(re,ct),gt(ni,ct));return t.fragData0=y,t.fragData1=O,t.fragData2=ut,t.fragData3=li,t}};function Le(r,e){const t=k(r.a,new d(0));return st(r,e).multiply(new d(1).subtract(t)).add(e.multiply(t))}function Ee(r,e){const t=k(r.a,new d(0));return rt(r,e).multiply(new d(1).subtract(t)).add(e.multiply(t))}function mt(r){const e=k(r.a,new d(0)),t=new d(1).subtract(e);return r.multiply(t)}function gt(r,e){const t=k(r.a,new d(0)),s=new d(1).subtract(e);return e.multiply(t).multiply(new x(1)).add(s.multiply(r))}c([m(de)],yt.prototype,"config",void 0),c([J(0,X(Ps))],yt.prototype,"vertex",null),c([J(0,X(Dr))],yt.prototype,"fragment",null);let Fs=class extends Be{};c([Oe(0,_)],Fs.prototype,"position",void 0);let kr=class extends Ae{},xe=class extends ${};c([m(D)],xe.prototype,"minTexture",void 0),c([m(D)],xe.prototype,"maxTexture",void 0),c([m(D)],xe.prototype,"sumTexture",void 0),c([m(D)],xe.prototype,"numOfNoDataTexture",void 0),c([m(D)],xe.prototype,"diffSqTexture",void 0),c([m(d)],xe.prototype,"numTexels",void 0);let xt=class extends Ve{constructor(){super(...arguments),this.type="TextureStatisticsStdDevShader"}vertex(e){const t=e.position;return{uv:t,glPosition:new x(at(t),0,1)}}fragment(e){const t=new Ge,{minTexture:s,maxTexture:o,numOfNoDataTexture:i,sumTexture:a,diffSqTexture:n}=this.config,l=e.glFragCoord.xy,u=new M(l),h=new R(0),p=v(s,u,h),g=v(o,u,h),f=v(a,u,h),y=v(i,u,h).r,w=v(n,u,h),T=this.config.numTexels.subtract(y),P=f.divide(T),S=w.divide(T),O=le(S);return t.fragData0=p,t.fragData1=g,t.fragData2=P,t.fragData3=O,t}};c([m(xe)],xt.prototype,"config",void 0),c([J(0,X(Fs))],xt.prototype,"vertex",null),c([J(0,X(kr))],xt.prototype,"fragment",null);let Is=class extends Be{};c([Oe(0,_)],Is.prototype,"position",void 0);let Or=class extends Ae{},wt=class extends ${};c([m(D)],wt.prototype,"sumTexture",void 0),c([m(R)],wt.prototype,"width",void 0),c([m(R)],wt.prototype,"height",void 0);class bt extends Ve{constructor(){super(...arguments),this.type="TextureStatisticsSumOfSquaredDiffShader"}vertex(e){const t=e.position;return{uv:t,glPosition:new x(at(t),0,1)}}
1fragment(e){const t=new Ge,{sumTexture:s}=this.config,o=e.glFragCoord.xy,i=new M(o.multiply(2)),a=new R(0),n=v(s,i,a),l=v(s,i.add(new M(-1,0)),a),u=v(s,i.add(new M(0,-1)),a),h=v(s,i.add(new M(-1,-1)),a),p=Lt(n,l,u,h);return t.fragData0=p,t.fragData1=new x(0),t.fragData2=new x(0),t.fragData3=new x(0),t}}c([m(wt)],bt.prototype,"config",void 0),c([J(0,X(Is))],bt.prototype,"vertex",null),c([J(0,X(Or))],bt.prototype,"fragment",null);const At=1048576;class Br extends ot{constructor(){super(...arguments),this.type=32,this._width=0,this._height=0,this._framebuffers=null,this._minTexture=null,this._maxTexture=null,this._sumTexture=null,this._numOfNoDataTexture=null,this._resultsFramebuffer=null,this._startFramebuffer=null,this._diffFramebuffer=null,this._scaleFbo=null,this.shaders={textureStatisticsMinMaxSum:new yt,textureStatisticsSum:new bt,textureStatisticsDiff:new ft,textureStatisticsStdDev:new xt}}dispose(){this.shaders.textureStatisticsMinMaxSum=null,this._framebuffers&&(this._framebuffers.forEach(e=>I(e)),this._framebuffers=null),I(this._resultsFramebuffer),I(this._startFramebuffer),I(this._diffFramebuffer),I(this._scaleFbo),I(this._minTexture),I(this._maxTexture),I(this._sumTexture),I(this._numOfNoDataTexture)}get minValuesTexture(){return this._minTexture||null}get maxValuesTexture(){return this._maxTexture||null}get meanValuesTexture(){var e;return((e=this._resultsFramebuffer)==null?void 0:e.getColorTexture(fe))||null}get stdDevValuesTexture(){var e;return((e=this._resultsFramebuffer)==null?void 0:e.getColorTexture(ve))||null}get statsFbo(){return this._resultsFramebuffer}render(e,t){const{context:s,painter:o}=e;let i=t.fbo.width,a=t.fbo.height,n=t.fbo;const l=s.gl,u=s.getBoundFramebufferObject();if(i*a>At||!ht(i)||!ht(a)){const f=i/a;if(i*a>At){const y=Math.max(Math.floor(Math.sqrt(At/f)),1);i=Math.max(Math.floor(f*y),1),a=y}if(ht(i)||(i=ms(i)),ht(a)||(a=ms(a)),this._scaleFbo)this._scaleFbo.resize(i,a);else{const{dataType:y,internalFormat:w}=t.fbo.getColorTexture(j).descriptor,T=w??Y.RGBA8;this._scaleFbo=We(s,i,a,y,T)}s.bindFramebuffer(this._scaleFbo),s.setViewport(0,0,i,a),o.blitTexture(s,n.getColorTexture(j),9728),n=this._scaleFbo}this._updateResources(e,n),o.setPipelineState({...us,color:{write:[!0,!0,!0,!0],blendMode:"none"}});const h=this._applyReductionPass(e);l.readBuffer(l.COLOR_ATTACHMENT3),h.copyToTexture(0,0,1,1,0,0,this._numOfNoDataTexture),l.readBuffer(l.COLOR_ATTACHMENT2),h.copyToTexture(0,0,1,1,0,0,this._sumTexture),l.readBuffer(l.COLOR_ATTACHMENT1),h.copyToTexture(0,0,1,1,0,0,this._maxTexture),l.readBuffer(l.COLOR_ATTACHMENT0),h.copyToTexture(0,0,1,1,0,0,this._minTexture);const p=t.fbo.getColorTexture(j);if(!p)throw new Error("Start buffer color texture is not available, cannot compute diff.");this._computeDiff(e,p,this._sumTexture,this._numOfNoDataTexture,i,a);const g=this._applySecondReductionPass(e,i,a).getColorTexture(j);this._computeSdtDev(e,this._minTexture,this._maxTexture,this._sumTexture,this._numOfNoDataTexture,g,i,a),s.bindFramebuffer(u),s.setViewport(0,0,t.fbo.width,t.fbo.height),s.setDrawBuffers([j]),o.setPipelineState(us)}_applyReductionPass(e){const{context:t,painter:s}=e,o=this.shaders.textureStatisticsMinMaxSum,i=this._framebuffers;if(i===null)throw new Error("Framebuffers are not initialized, cannot apply reduction pass.");t.setDrawBuffers([j,Ce,fe]);const a=this._startFramebuffer;let n=a.getColorTexture(j),l=a.getColorTexture(Ce),u=a.getColorTexture(fe),h=a.getColorTexture(ve);const p=i;let g=0;for(const f of p){t.setViewport(0,0,f.width,f.height),t.bindFramebuffer(f),t.setClearColor(0,0,0,0),t.clear(16384);const y={shader:o,uniforms:{config:{minTexture:{texture:n,unit:1},maxTexture:{texture:l,unit:2},sumTexture:{texture:u,unit:3},numOfNoDataTexture:{texture:h,unit:4},width:f.width,height:f.height,isFirstPass:g===0?1:0}},defines:null,optionalAttributes:null,useComputeBuffer:!1};s.submitDrawMesh(t,y,s.quadMesh),n=f.getColorTexture(j),l=f.getColorTexture(Ce),u=f.getColorTexture(fe),h=f.getColorTexture(ve),g++}return i.at(-1)}_applySecondReductionPass(e,t,s){const{context:o,painter:i}=e,a=this.shaders.textureStatisticsSum,n=this._framebuffers;if(n===null||this._diffFramebuffer==null)throw new Error("Framebuffers are not initialized, cannot apply reduction pass.");o.setDrawBuffers([j]);let l=this._diffFramebuffer.getColorTexture(j);const u=n;for(const h of u){o.setViewport(0,0,h.width,h.height),o.bindFramebuffer(h),o.setClearColor(0,0,0,0),o.clear(16384);const p={shader:a,uniforms:{config:{sumTexture:{texture:l,unit:2},width:h.width,height:h.height}},defines:null,optionalAttributes:null,useComputeBuffer:!1};i.submitDrawMesh(o,p,i.quadMesh),l=h.getColorTexture(j)}return n.at(-1)}_updateResources(e,t){const{context:s}=e,o=t.width,i=t.height;if(this._startFramebuffer===null){if(!Ss().supportsColorBufferFloat)throw new Error("WebGL does not support color buffer float, cannot compute texture statistics.");const n=t.getColorTexture(j);if(!n)throw new Error("Input FBO does not have a color attachment 0, cannot compute texture statistics.");const l=n.descriptor,{dataType:u,internalFormat:h}=l,p=We(s,o,i,u,h??Y.RGBA8,4),g=p.getColorTexture(j),f=p.getColorTexture(Ce),y=p.getColorTexture(fe),w=p.getColorTexture(ve);t.copyToTexture(0,0,o,i,0,0,g),t.copyToTexture(0,0,o,i,0,0,f),t.copyToTexture(0,0,o,i,0,0,y),t.copyToTexture(0,0,o,i,0,0,w),this._startFramebuffer=p,this._diffFramebuffer=We(s,o,i,ee.FLOAT,Y.RGBA32F),this._resultsFramebuffer=We(s,1,1,ee.FLOAT,Y.RGBA32F,4),this._minTexture=Me(s,1,1,ee.FLOAT,Y.RGBA32F),this._maxTexture=Me(s,1,1,ee.FLOAT,Y.RGBA32F),this._sumTexture=Me(s,1,1,ee.FLOAT,Y.RGBA32F),this._numOfNoDataTexture=Me(s,1,1,ee.FLOAT,Y.R32F)}else{const n=this._startFramebuffer;n.resize(o,i);const l=n.getColorTexture(j),u=n.getColorTexture(Ce),h=n.getColorTexture(fe),p=n.getColorTexture(ve);t.copyToTexture(0,0,o,i,0,0,l),t.copyToTexture(0,0,o,i,0,0,u),t.copyToTexture(0,0,o,i,0,0,h),t.copyToTexture(0,0,o,i,0,0,p),this._diffFramebuffer.resize(o,i)}if(this._width===o&&this._height===i&&this._framebuffers!==null)return;const a=(this._framebuffers||[]).reverse();this._framebuffers=null,this._width=o,this._height=i,this._framebuffers=this._updateFramebuffers(s,o,i,a,4)}_updateFramebuffers(e,t,s,o,i=1){const a=[];let n=t,l=s;for(;n>1||l>1;){const u=Math.max(1,Math.floor(n/2)),h=Math.max(1,Math.floor(l/2)),p=Vr(e,u,h,o,i);a.push(p),n=u,l=h}return a.at(-1),o.forEach(u=>I(u)),o.length=0,a}_computeDiff(e,t,s,o,i,a){const{context:n,painter:l}=e;n.bindFramebuffer(this._diffFramebuffer),n.setDrawBuffers([j]),n.setVie
1wport(0,0,i,a),n.setClearColor(0,0,0,0),n.clear(16384);const u={shader:this.shaders.textureStatisticsDiff,uniforms:{config:{inputTexture:{texture:t,unit:1},sumTexture:{texture:s,unit:2},numOfNoDataTexture:{texture:o,unit:3},numTexels:i*a}},defines:null,optionalAttributes:null,useComputeBuffer:!1};l.submitDrawMesh(n,u,l.quadMesh)}_computeSdtDev(e,t,s,o,i,a,n,l){const{context:u,painter:h}=e;u.bindFramebuffer(this._resultsFramebuffer),u.setDrawBuffers([j,Ce,fe,ve]),u.setViewport(0,0,1,1),u.setClearColor(0,0,0,0),u.clear(16384);const p={shader:this.shaders.textureStatisticsStdDev,uniforms:{config:{minTexture:{texture:t,unit:1},maxTexture:{texture:s,unit:2},sumTexture:{texture:o,unit:3},numOfNoDataTexture:{texture:i,unit:4},diffSqTexture:{texture:a,unit:5},numTexels:n*l}},defines:null,optionalAttributes:null,useComputeBuffer:!1};h.submitDrawMesh(u,p,h.quadMesh)}}function Vr(r,e,t,s,o=1){let i=s.pop();return i!==void 0?i.resize(e,t):i=We(r,e,t,ee.FLOAT,Y.RGBA32F,o),i}function We(r,e,t,s,o,i=1){if(i<1||i>4)throw new Error("Number of color attachments must be between 1 and 4.");const a=new zt(r,Me(r,e,t,s,o));for(let n=1;n<i;n++){const l=Me(r,e,t,s,o);a.attachColorTexture(l,j+n)}return a}function Me(r,e,t,s,o){const i=new Mt(e,t);return i.samplingMode=9728,i.wrapMode=33071,i.pixelFormat=6408,i.dataType=s,i.internalFormat=o,new $t(r,i)}function ms(r){const e=pi(r),t=e/2;return Math.abs(e-r)<Math.abs(t-r)?e:t}function zs(r,e){const t=new Mt(r,e);
1return t.internalFormat=Y.RGBA32F,t.samplingMode=9728,t.dataType=ee.FLOAT,t.isImmutable=!0,t.wrapMode=33071,t}function Ar(r,e,t){const s=zs(e,t);return new $t(r,s)}function $s(r,e,t){const s=zs(e,t);return new zt(r,s)}function _t(r){const{symbolizerParameters:e}=r,{type:t}=e,s=t==="lut"?"nearest":r.interpolation,o=s==="bilinear"&&t!=="lut"&&(t!=="stretch"||e.bandCount===1);return{bilinear:o,bicubic:s==="cubic",nearestOnEdge:o}}function Gr(r,e,t,s){const o=ue(e.multiply(t)),i=new M(new R(o.x),new R(o.y)),a=new M(i.x.add(1),i.y),n=new M(i.x,i.y.add(1)),l=new M(i.x.add(1),i.y.add(1)),u=v(r,i,new R(0)),h=v(r,a,new R(0)),p=v(r,n,new R(0)),g=v(r,l,new R(0)),f=Kt(e.multiply(t)),y=W(u,h,f.x),w=W(p,g,f.x),T=W(y,w,f.y);if(!s)return T;const P=new x(u.a,h.a,p.a,g.a),S=P.xy.multiply(P.zw),O=ue(S.x.multiply(S.y).add(.5)),K=T.multiply(O),pe=ke(O).multiply(z(r,e));return K.add(pe)}let Ze=class extends ${};function qr(r,e){const t=z(e.transformTexture,r);return new _(t.r,t.g)}function jr(r,e){const{transformTexture:t,targetImageSize:s,transformSpacing:o}=e,i=ue(r.multiply(s)),a=new _(4,1),n=ue(i.divide(o)).multiply(a),l=Kt(i.add(new _(.5,.5)).divide(o)),u=new M(ls(n.x),ls(n.y)),h=new b(l,1);return Q(vs(l.x,l.y),Ur(t,u,h),Lr(t,u,h))}function Ur(r,e,t){const s=v(r,e,new R(0)),o=new M(e.x.add(1),e.y),i=v(r,o,new R(0));return new _(Z(s.rgb,t),Z(i.rgb,t))}function Lr(r,e,t){const s=new M(e.x.add(2),e.y),o=v(r,s,new R(0)),i=new M(e.x.add(3),e.y),a=v(r,i,new R(0));return new _(Z(o.rgb,t),Z(a.rgb,t))}function Er(r){const e=k(new _(-1e-5,-1e-5),r).multiply(k(r,new _(1.00001,1.00001))),t=ke(e.x.multiply(e.y));return new Vi(t)}function Ms(r,e,t=!1){return e?t?qr(r,e):jr(r,e):r}function Ds(r,e,t){const{bicubic:s=!1,bilinear:o=!1,nearestOnEdge:i=!1}=t??{};return s||o?s?pr(e.texture,r,e.srcImageSize):Gr(e.texture,r,e.srcImageSize,i):z(e.texture,r)}c([m(D)],Ze.prototype,"transformTexture",void 0),c([m(_)],Ze.prototype,"targetImageSize",void 0),c([m(_)],Ze.prototype,"transformSpacing",void 0),c([m(_)],Ze.prototype,"transformGridSize",void 0);let ks=class extends Be{};c([Oe(0,_)],ks.prototype,"position",void 0);let Hr=class extends Ae{};class Se extends ${}c([m(D)],Se.prototype,"texture",void 0),c([m(_e)],Se.prototype,"dvsMat3",void 0),c([m(_)],Se.prototype,"coordScale",void 0),c([m(_)],Se.prototype,"srcImageSize",void 0),c([m(d)],Se.prototype,"opacity",void 0);let Os=class extends ${};c([m(D)],Os.prototype,"maskTexture",void 0);let Bs=class extends ${};c([m(D)],Bs.prototype,"highlightTexture",void 0);let q=class extends Ve{constructor(){super(...arguments),this.applyProjection=!0,this.lookupProjection=!1,this.bilinear=!1,this.bicubic=!1,this.nearestOnEdge=!1,this.applyPixelMask=!1,this.applyPixelHighlights=!1}vertex(e){const t=e.position,{dvsMat3:s,coordScale:o}=this.config,i=s.multiply(new b(t.multiply(o),1));return{uv:t,glPosition:new x(i,1)}}fragment(e){const t=new Ge,s=Ms(e.uv,this.applyProjection?this.projectionConfig:void 0,this.lookupProjection);let o=this._colorize(s,e.uv);this.applyPixelHighlights&&(o=this._highlightPixels(e.uv,o));const i=Q(Er(s),new x(0),o);let a=i.a.multiply(this.config.opacity);if(this.applyPixelMask){const n=this._getPixelMask(e.uv);a=a.multiply(n)}return t.fragColor=new x(i.rgb,1).multiply(a),t}_getPixel(e){const{config:t,bicubic:s,bilinear:o,nearestOnEdge:i}=this;return Ds(e,t,{bicubic:s,bilinear:o,nearestOnEdge:i})}_getPixelMask(e){const{maskTexture:t}=this.pixelMaskConfig,s=z(t,e);return L(s.a)}_highlightPixels(e,t){const{highlightTexture:s}=this.highlightConfig,o=z(s,e),i=L(o.a);return W(t,o,i)}};c([C],q.prototype,"applyProjection",void 0),c([C],q.prototype,"lookupProjection",void 0),c([C],q.prototype,"bilinear",void 0),c([C],q.prototype,"bicubic",void 0),c([C],q.prototype,"nearestOnEdge",void 0),c([C],q.prototype,"applyPixelMask",void 0),c([C],q.prototype,"applyPixelHighlights",void 0),c([m(Se)],q.prototype,"config",void 0),c([ce(Ze)],q.prototype,"projectionConfig",void 0),c([ce(Os)],q.prototype,"pixelMaskConfig",void 0),c([ce(Bs)],q.prototype,"highlightConfig",void 0),c([J(0,X(ks))],q.prototype,"vertex",null),c([J(0,X(Hr))],q.prototype,"fragment",null);let me=class extends ${};function nt(r,e,t,s=!0){const{colormapTexture:o,colormapOffset:i,colormapMaxIndex:a}=t,n=r.r.multiply(e).subtract(i),l=ie(n,new d(0),a),u=new _(l.add(.5).divide(a.add(1)),0),h=z(o,u),p=new x(h.rgb,h.a.multiply(r.a));if(s)return p;const g=k(new d(0),n).multiply(k(n,t.colormapMaxIndex));return p.multiply(g)}c([m(D)],me.prototype,"colormapTexture",void 0),c([m(d)],me.prototype,"colormapOffset",void 0),c([m(d)],me.prototype,"colormapMaxIndex",void 0);let Vs=class extends q{constructor(){super(...arguments),this.type="RasterColorizerLUTShader"}_colorize(e){const t=this._getPixel(e);return nt(t,new d(1),this.colormapConfig,!1)}};c([m(me)],Vs.prototype,"colormapConfig",void 0);function As(r){const e=new x(0,-.3333333333333333,.6666666666666666,-1),t=Q(Ut(r.y,r.z),new x(r.zy,e.wz),new x(r.yz,e.xy)),s=Q(Ut(r.x,t.x),new x(t.xyw,r.x),new x(r.x,t.yzx)),o=s.x.subtract(st(s.w,s.y)),i=new d(1e-10),a=s.w.subtract(s.y),n=o.multiply(6).add(i),l=U(a.divide(n).add(s.z)),u=s.x.add(i),h=st(o.divide(u),new d(1));return new b(l,h,s.x)}function Gs(r){const e=new x(1,.6666666666666666,.3333333333333333,3),t=U(Kt(r.xxx.add(e.xyz)).multiply(6).subtract(e.www)),s=ie(t.subtract(e.xxx),new b(0,0,0),new b(1));
vendor: 4,404 bytes, line 1
1return r.z.multiply(W(e.xxx,s,r.y))}let ae=class extends ${};function H(r){const e=U(r),t=k(e,new _(1,1)).multiply(e),s=new d(2).subtract(e),o=k(new d(1),e).multiply(s);return t.add(o)}function lt(r,e,t){const s=new d(1).divide(t),o=z(r,H(s.multiply(new _(-1,-1)).add(e))),i=z(r,H(s.multiply(new _(0,-1)).add(e))),a=z(r,H(s.multiply(new _(1,-1)).add(e))),n=z(r,H(s.multiply(new _(-1,0)).add(e))),l=z(r,H(e)),u=z(r,H(s.multiply(new _(1,0)).add(e))),h=z(r,H(s.multiply(new _(-1,1)).add(e))),p=z(r,H(s.multiply(new _(0,1)).add(e))),g=z(r,H(s.multiply(new _(1,1)).add(e))),f=new x(o.a,i.a,a.a,n.a),y=new x(u.a,h.a,p.a,g.a),w=f.multiply(y),T=w.xy.multiply(w.zw),P=T.x.multiply(T.y).multiply(l.a),S=new te(new d(0),10);return S[0]=o.r,S[1]=i.r,S[2]=a.r,S[3]=n.r,S[4]=l.r,S[5]=u.r,S[6]=h.r,S[7]=p.r,S[8]=g.r,S[9]=P,S}function es(r,e){const t=new x(r[5],r[3],r[7],r[1]).multiply(2),s=new b(r[2],t[0],r[8]),o=new b(r[0],t[1],r[6]),i=Z(s.subtract(o),new b(1)),a=new b(r[6],t[2],r[8]),n=new b(r[0],t[3],r[2]),l=Z(a.subtract(n),new b(1));return new _(i,l).multiply(e)}function qs(r,e,t){const{factor:s}=e,o=es(r,s),i=le(Z(o,o).add(1)),a=r[9],{sinZsinAs:n,sinZcosAs:l,cosZs:u,weights:h}=e;if(!t){const y=Gt({sinZsinA:n[0],sinZcosA:l[0],cosZ:u[0],weights:new d(1),dzxy:o,dzd:i});return new x(y,y,y,a)}const p=Gt({sinZsinA:new b(n[0],n[1],n[2]),sinZcosA:new b(l[0],l[1],l[2]),cosZ:new b(u[0],u[1],u[2]),weights:new b(h[0],h[1],h[2]),dzxy:o,dzd:i}),g=Gt({sinZsinA:new b(n[3],n[4],n[5]),sinZcosA:new b(l[3],l[5],l[5]),cosZ:new b(u[3],u[4],u[5]),weights:new b(h[3],h[4],h[5]),dzxy:o,dzd:i}),f=Z(p.add(g),new b(1));return new x(f,f,f,a)}function Gt(r){const e=r.sinZsinA.multiply(r.dzxy.y),t=r.sinZcosA.multiply(r.dzxy.x),s=e.subtract(t),o=r.cosZ.add(s).divide(r.dzd);return o.multiply(k(new d(0),o)).multiply(r.weights)}function js(r,e){const{pixelSizeFactor:t}=r,s=[r.factor[0]/e[0],r.factor[1]/e[1]];if(t>0){const{zFactor:o,pixelSizePower:i,gcsFactor:a}=r,n=e[0]*a,l=e[1]*a;s[0]=(o+n**i*t)/(8*n),s[1]=(o+l**i*t)/(8*l)}return s}c([m(te.ofType(d,6))],ae.prototype,"sinZcosAs",void 0),c([m(te.ofType(d,6))],ae.prototype,"sinZsinAs",void 0),c([m(te.ofType(d,6))],ae.prototype,"cosZs",void 0),c([m(te.ofType(d,6))],ae.prototype,"weights",void 0),c([m(d)],ae.prototype,"minValue",void 0),c([m(d)],ae.prototype,"maxValue",void 0),c([m(_)],ae.prototype,"factor",void 0);let Qe=class extends q{constructor(){super(...arguments),this.type="RasterColorizerShadedReliefShader",this.applyColormap=!1,this.isMultidirectional=!1}_colorize(e){const{texture:t}=this.config,s=lt(t,e,this.config.srcImageSize),o=qs(s,this.hillshadeConfig,this.isMultidirectional);if(!this.applyColormap)return new x(o.x,o.x,o.x,o.a);const{minValue:i,maxValue:a}=this.hillshadeConfig,n=this._getPixel(e),l=a.subtract(i),u=n.r.subtract(i),h=ie(u.divide(l),new d(0),new d(1)),p=nt(new x(h,h,h,1),new d(255),this.colormapConfig),g=As(p.xyz),f=Gs(new b(g.xy,o.x));return new x(f,p.a.multiply(o.a))}};c([C],Qe.prototype,"applyColormap",void 0),c([C],Qe.prototype,"isMultidirectional",void 0),c([m(ae)],Qe.prototype,"hillshadeConfig",void 0),c([ce(me)],Qe.prototype,"colormapConfig",void 0);function B(r){const e=L(r),t=r.add(U(e).subtract(1));return e.multiply(e).divide(t)}function qe(r){return new x(ue(r.rgb.add(.5)),r.a)}function Us(r,e){return k(e.x,r).multiply(k(r,e.y))}function Nr(r,e){let t=new b(0,0,0);const s=new b(r);for(let o=0;o<se/3;o++){const i=6*o,a=new b(e[i],e[i+2],e[i+4]),n=new b(e[i+1],e[i+3],e[i+5]);t=t.add(k(a,s).multiply(k(s,n)))}return L(Z(t,new b(1,1,1)))}function Wr(r,e,t){const s=new b(r);let o=new b(0,0,0),i=new d(0);for(let a=0;a<t/3;a++){const n=9*a,l=new b(e[n],e[n+3],e[n+6]),u=new b(e[n+1],e[n+4],e[n+7]),h=k(l,s).multiply(k(s,u)),p=new b(e[n+2],e[n+5],e[n+8]);i=W(i,p.x,h.x),i=W(i,p.y,h.y),i=W(i,p.z,h.z),o=o.add(h)}return{mapValue:i,includeMask:L(Z(o,new b(1,1,1)))}}let ne=class extends ${};c([m(d)],ne.prototype,"minOutput",void 0),c([m(d)],ne.prototype,"maxOutput",void 0),c([m(b)],ne.prototype,"minCutOff",void 0),c([m(b)],ne.prototype,"maxCutOff",void 0),c([m(b)],ne.prototype,"factor",void 0),c([m(b)],ne.prototype,"gamma",void 0),c([m(b)],ne.prototype,"gammaCorrection",void 0);class Re extends ${}function Ls(r,e){const{minCutOff:t,maxCutOff:s,factor:o,minOutput:i}=e;return ie(r,t,s).subtract(t).multiply(o).add(i)}function Es(r,e){const{minCutOff:t,maxCutOff:s,minOutput:o,maxOutput:i,gamma:a,gammaCorrection:n}
1=e,l=ie(r,t,s).subtract(t),u=s.subtract(t),h=l.divide(u),p=k(new d(1),a),g=L(a.subtract(1)),f=i.subtract(o),y=new b(1),w=he(y.divide(f),h.multiply(n)),T=ke(p.multiply(g).multiply(w)),P=he(h,y.divide(a)),S=T.multiply(f).multiply(P).add(o);return ie(S,o,i)}function Hs(r,e,t,s=255){const o=t?Es(r.rgb,e).divide(s):Ls(r.rgb,e);return new x(o,r.a)}function Zr(r,e,t,s,o){const i=new M(0,0),a=new R(0);let n=v(t.minTexture,i,a).rgb,l=v(t.maxTexture,i,a).rgb;if(o){const y=v(t.meanTexture,i,a).rgb,w=v(t.stddevTexture,i,a).rgb.multiply(t.numberOfStandardDeviations);n=rt(n,y.subtract(w)),l=st(l,y.add(w))}const u=l.subtract(n),h=new b(B(u.x),B(u.y),B(u.z)),p=e.maxOutput.subtract(e.minOutput).multiply(h),g={...e,minCutOff:n,maxCutOff:l,factor:p},f=s?Es(r.rgb,g).divide(255):Ls(r.rgb,g);return new x(f,r.a)}c([m(D)],Re.prototype,"minTexture",void 0),c([m(D)],Re.prototype,"maxTexture",void 0),c([m(D)],Re.prototype,"meanTexture",void 0),c([m(D)],Re.prototype,"stddevTexture",void 0),c([m(d)],Re.prototype,"numberOfStandardDeviations",void 0);let oe=class extends q{constructor(){super(...arguments),this.type="RasterColorizerStretchShader",this.isMultiband=!0,this.applyColormap=!1,this.useGamma=!1,this.noOp=!1,this.draStretchType=0}_colorize(e){const t=this._getPixel(e);if(this.noOp)return t;const{draStretchType:s,stretchConfig:o,useGamma:i,statisticsConfig:a}=this;let n=s===0?Hs(t,o,i):Zr(t,o,a,i,s===2);if(this.isMultiband)return n;if(n=new x(n.rrr,n.a),this.applyColormap){const l=this.useGamma?255:1;n=nt(n,new d(l),this.colormapConfig)}
1return n}};c([C],oe.prototype,"isMultiband",void 0),c([C],oe.prototype,"applyColormap",void 0),c([C],oe.prototype,"useGamma",void 0),c([C],oe.prototype,"noOp",void 0),c([C],oe.prototype,"draStretchType",void 0),c([m(ne)],oe.prototype,"stretchConfig",void 0),c([ce(me)],oe.prototype,"colormapConfig",void 0),c([ce(Re)],oe.prototype,"statisticsConfig",void 0);const Qr=160,Yr=new Set(["f32","f64","u16","s16","u32","s32"]);let Jr=class extends ot{constructor(){super(...arguments),this.name="BrushRasterColorizer",this.type=0,this.shaders={lut:new Vs,stretch:new oe,shadedRelief:new Qe},this._mosaicFbo=null,this._statisticsTechnique=null,this._draTimer=0}shutdown(e){super.shutdown(e),this._mosaicFbo=I(this._mosaicFbo),this._statisticsTechnique=I(this._statisticsTechnique)}render(e,t){const s=t.bitmaps.some(qt);s||(this._mosaicFbo=I(this._mosaicFbo),this._statisticsTechnique=I(this._statisticsTechnique));const o=s?this._computeStatisticsTextures(e,t):void 0;for(const i of t.bitmaps){if(!i.source||i.suspended)continue;e.timeline.begin(this.name);const{painter:a}=e;a.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}}),i.updateTexture(e),i.updateProcessedTexture();const{type:n}=i.symbolizerParameters,l=n==="stretch"?this._getStretchOptions(i,o):n==="lut"?this._getLutOptions(i):this._getShadedReliefOptions(i);i.interpolation!=="bilinear"||e.context.capabilities.textureFloatLinear||(l.defines.bilinear=!0),a.submitDrawMesh(e.context,l,a.quadMesh,i),e.timeline.end(this.name)}}_computeStatisticsTextures(e,t){this._statisticsTechnique??(this._statisticsTechnique=new Br);const s=this._statisticsTechnique;let o=ys("esri-2d-dra-delay");if(o==null){const i=t.bitmaps.find(qt),{stretchType:a,bandCount:n}=i.symbolizerParameters,{pixelType:l}=i.source;a==="minMax"&&n>=3&&Yr.has(l)&&(o=Qr)}if(o){const i=performance.now();(i-this._draTimer>=o||e.stationary||!s.minValuesTexture)&&(this._mosaic(e,t),s.render(e,{fbo:this._mosaicFbo}),this._draTimer=i)}else this._mosaic(e,t),s.render(e,{fbo:this._mosaicFbo});return{minTexture:s.minValuesTexture,maxTexture:s.maxValuesTexture,meanTexture:s.meanValuesTexture,stddevTexture:s.stdDevValuesTexture}}_mosaic(e,t){const{context:s,painter:o}=e,i=s.getBoundFramebufferObject();if(this._mosaicFbo)this._mosaicFbo.resize(i.width,i.height);else{const n=Xr(s,i.width,i.height);this._mosaicFbo=new zt(s,n)}s.bindFramebuffer(this._mosaicFbo);const a="RasterColorizerMosaic";for(const n of t.bitmaps){if(!qt(n))continue;e.timeline.begin(a),o.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}});const l=n.interpolation;n.interpolation="nearest",n.updateTexture(e),n.updateProcessedTexture();const u=this._getStretchOptions(n);u.defines.noOp=!0,o.submitDrawMesh(e.context,u,o.quadMesh,n),n.interpolation=l,e.timeline.end(a)}s.bindFramebuffer(i)}_getLutOptions(e){const{config:t,projectionConfig:s,colormapConfig:o,pixelMaskConfig:i,highlightConfig:a,projectionDefines:n}=this._getCommonConfig(e),l=_t(e);return{shader:this.shaders.lut,uniforms:{projectionConfig:s,config:t,colormapConfig:o,pixelMaskConfig:i,highlightConfig:a},defines:{...n,...l,applyPixelMask:!!i,applyPixelHighlights:!!a},optionalAttributes:null,useComputeBuffer:!1}}_getStretchOptions(e,t){const s=e.symbolizerParameters,{config:o,projectionConfig:i,colormapConfig:a,pixelMaskConfig:n,highlightConfig:l,projectionDefines:u,textureUnit:h}=this._getCommonConfig(e),p=_t(e),g=t?{minTexture:{texture:t.minTexture,unit:h},maxTexture:{texture:t.maxTexture,unit:h+1},meanTexture:{texture:t.meanTexture,unit:h+2},stddevTexture:{texture:t.stddevTexture,unit:h+3},numberOfStandardDeviations:s.numberOfStandardDeviations||2}:void 0,f=t?s.stretchType==="standardDeviation"?2:1:0;return{shader:this.shaders.stretch,uniforms:{projectionConfig:i,config:o,stretchConfig:s,colormapConfig:a,pixelMaskConfig:n,highlightConfig:l,statisticsConfig:g},defines:{...u,...p,isMultiband:s.bandCount>1,applyColormap:!!a,useGamma:s.useGamma,noOp:e.isRendereredSource&&!e.processed,applyPixelMask:!!n,applyPixelHighlights:!!l,draStretchType:f},optionalAttributes:null,useComputeBuffer:!1}}_getShadedReliefOptions(e){const t=e.symbolizerParameters,{config:s,projectionConfig:o,colormapConfig:i,pixelMaskConfig:a,highlightConfig:n,projectionDefines:l}=this._getCommonConfig(e),u=_t(e);return{shader:this.shaders.shadedRelief,uniforms:{projectionConfig:o,config:s,hillshadeConfig:t,colormapConfig:i,pixelMaskConfig:a,highlightConfig:n},defines:{...l,...u,isMultidirectional:t.hillshadeType>0,applyColormap:!!i,applyPixelMask:!!a,applyPixelHighlights:!!n},optionalAttributes:null,useComputeBuffer:!1}}_getCommonConfig(e){const{coordScale:t,computedOpacity:s,transforms:o}=e,{names:i,textures:a}=e.getTextures({useProcessedTexture:e.processed}),n=a[i.indexOf("u_image")],l=e.getRasterTextureSize();let u=0;const h={texture:{texture:n,unit:u++},dvsMat3:o.displayViewScreenMat3,coordScale:t,srcImageSize:l,opacity:s},p=a[i.indexOf("u_transformGrid")],{transformGrid:g}=e,f=!(!p||!g),y=f?{transformTexture:{texture:p,unit:u++},targetImageSize:[e.width,e.height],transformSpacing:g.spacing,transformGridSize:g.size}:void 0,w=a[i.indexOf("u_colormap")],{colormap:T,colormapOffset:P}=e.symbolizerParameters,S=w&&T?{colormapTexture:{texture:w,unit:u++},colormapOffset:P??0,colormapMaxIndex:T.length/4-1}:void 0,O=a[i.indexOf("u_mask")],K=O?{maskTexture:{texture:O,unit:u++}}:void 0,{highlightTexture:pe}=e;return{config:h,projectionConfig:y,colormapConfig:S,pixelMaskConfig:K,highlightConfig:pe?{highlightTexture:{texture:pe,unit:u++}}:void 0,projectionDefines:{applyProjection:f,lookupProjection:f&&g.spacing[0]===1},textureUnit:u}}};function Xr(r,e,t){const s=new Mt(e,t);return s.internalFormat=Y.RGBA32F,s.samplingMode=9728,s.dataType=ee.FLOAT,s.wrapMode=33071,new $t(r,s)}function qt(r){return!r.suspended&&r.source!=null&&!r.isRendereredSource&&r.symbolizerParameters.type==="stretch"&&!!r.symbolizerParameters.dynamicRangeAdjustment}let Tt=class extends ${};c([m(te.ofType(d,2*se))],Tt.prototype,"ranges",void 0),c([m(_e)],Tt.prototype,"bandSwap",void 0),c([m(x)],Tt.prototype,"color",void 0);let Et=class extends q{constructor(){super(...arguments),this.type="RasterRangeHighlightShader",this.hasExistingHighlights=!1}_colorize(e,t){const s=this._getPixel(e),{ranges:o,color:i,bandSwap:a}=this.rangeHighlightConfig,n=a.multiply(s.rgb).x,l=Nr(n,o).multiply(L(s.a)),u=W(new x(0),i,l);if(this.hasExistingHighlights){const{highlightTexture:h}=this.highlightConfig,p=z(h,t);return W(p,u,l)}return u}};c([C],Et.prototype,"hasExistingHighlights",void 0),c([m(Tt)],Et.prototype,"rangeHighlightConfig",void 0);let Kr=class extends ot{constructor(){super(...arguments),this.name="BrushRasterHighlight",this.type=2,this.shaders={range:new Et}}shutdown(e){var t;
1super.shutdown(e),(t=this._fbo)==null||t.dispose(),this._fbo=void 0}render(e,t){var n;const{context:s}=e;if(!this._fbo){const l=gs(e.context,N,N);this._fbo=new zt(s,l)}const o=s.getBoundFramebufferObject(),i=s.getViewport(),{pixelHighlightOptions:a}=e;for(const l of t.bitmaps){if(!a||!l.source||l.highlighted||l.suspended||l.isRendereredSource)continue;const u=(n=l.bandIds)!=null&&n.length?l.bandIds.indexOf(a.bandId):0;if(u<0||u>2)continue;e.timeline.begin(this.name);const{painter:h}=e;h.setPipelineState({depth:!1,stencil:{test:!1,write:!1},color:{write:[!0,!0,!0,!0],blendMode:"custom",blendParameters:{srcRGB:1,dstRGB:0,srcAlpha:1,dstAlpha:0}}}),l.updateTexture(e),l.updateProcessedTexture(!1);const{config:p,projectionConfig:g,highlightConfig:f,projectionDefines:y}=this._getCommonConfig(l),w=_t(l);l.interpolation!=="bilinear"||e.context.capabilities.textureFloatLinear||(w.bilinear=!0);const T=new Float32Array(9);T[3*u]=1;const P={...a,bandSwap:T},S={shader:this.shaders.range,uniforms:{projectionConfig:g,config:p,rangeHighlightConfig:P,highlightConfig:f},defines:{...y,...w,applyPixelMask:!1,applyPixelHighlights:!1,hasExistingHighlights:!!f},optionalAttributes:null,useComputeBuffer:!1};s.bindFramebuffer(this._fbo),s.setViewport(0,0,N,N),h.submitDrawMesh(e.context,S,h.quadMesh);const O=gs(e.context,N,N);this._fbo.copyToTexture(0,0,N,N,0,0,O),l.highlightTexture=O,e.timeline.end(this.name)}s.bindFramebuffer(o),s.setViewport(i.x,i.y,i.width,i.height)}_getCommonConfig(e){const{names:t,textures:s}=e.getTextures({forProcessing:!0,useProcessedTexture:e.processed}),o=s[t.indexOf("u_image")],i=e.getRasterTextureSize(),a={texture:{texture:o,unit:0},dvsMat3:new Float32Array([2,0,0,0,2,0,-1,-1,0]),coordScale:[1,1],srcImageSize:i,opacity:1},n=s[t.indexOf("u_transformGrid")],{transformGrid:l}=e,u=!(!n||!l),h=u?{transformTexture:{texture:n,unit:1},targetImageSize:[e.width,e.height],transformSpacing:l.spacing,transformGridSize:l.size}:void 0,{highlightTexture:p}=e;return{config:a,projectionConfig:h,highlightConfig:p?{highlightTexture:{texture:p,unit:2}}:void 0,projectionDefines:{applyProjection:u,lookupProjection:u&&l.spacing[0]===1}}}};function gs(r,e,t){const s=new Mt(e,t);return s.internalFormat=Y.RGBA8,s.samplingMode=9728,s.dataType=ee.UNSIGNED_BYTE,s.isImmutable=!0,s.wrapMode=33071,new $t(r,s)}let A=class extends ot{shutdown(e){var t;super.shutdown(e),(t=this._fbo)==null||t.dispose(),this._fbo=void 0}render(e,t){var u;const{rasterFunction:s}=e;if(!s)return;const{context:o}=e,i="indexedColormap"in s.parameters?jt(o,s.parameters.indexedColormap):void 0,a=s.name==="Reproject",n=o.getBoundFramebufferObject(),l=o.getViewport();for(const h of t.bitmaps){const p=a?!(h.rasterTexture&&h.projected):!h.processed;if(!h.source||!p||h.suspended)continue;e.timeline.begin(this.name);const{painter:g}=e;g.setPipelineState({depth:!1,stencil:{test:!1,write:!1},color:{write:[!0,!0,!0,!0],blendMode:"custom",blendParameters:{srcRGB:1,dstRGB:0,srcAlpha:1,dstAlpha:0}}}),a||(h.processedTexture=I(h.processedTexture)),h.updateTexture(e);const[f,y]=h.getRasterTextureSize(a),w=f===N&&y===N,T=w?t.processorFbo:$s(o,f,y);o.bindFramebuffer(T),o.setViewport(0,0,T.width,T.height),this._process(e,h,i);const P=Ar(e.context,f,y);if(T.copyToTexture(0,0,f,y,0,0,P),a)h.rasterTexture=P;else{const S=e.hasBranches?s.id:0;(u=h.functionTextures[S])==null||u.dispose(),h.functionTextures[S]=P}w||T.dispose(),e.timeline.end(this.name)}i==null||i.dispose(),o.bindFramebuffer(n),o.setViewport(l.x,l.y,l.width,l.height)}_getCommonConfig(e,t){var h;const{rasterFunction:s,hasBranches:o}=e,{raster:i,rasters:a}=s.parameters,n=o?(i==null?void 0:i.id)??((h=a==null?void 0:a.find(p=>p.name!=="Constant"))==null?void 0:h.id)??-1:0,l=t.functionTextures[n]??t.rasterTexture,u=s.name==="Reproject";return{texture:{texture:l,unit:0},srcImageSize:t.getRasterTextureSize(u)}}_getMultipleInputConfig(e,t){return t!=null&&t.length?t.length===2?{twoRasterConfig:this._getTwoInputConfig(t,e)}:t.length===3?{threeRasterConfig:this._getThreeInputConfig(t,e)}:{}:{}}_getConstantCount(e){return(e==null?void 0:e.filter(t=>t.name==="Constant").length)??0}_getTextures(e,t){return e.filter(s=>s.name!=="Constant").map(s=>s.id!=null&&s.name!=="Identity"?t.functionTextures[s.id]:t.rasterTexture)}_getTwoInputConfig(e,t){const s=this._getTextures(e,t),o=s[1]?{texture:s[1],unit:1}:void 0,i=e.findIndex(n=>n.name==="Constant"),a=i===0?new Float32Array([0,1,0,1,0,0,0,0,0]):new Float32Array([1,0,0,0,1,0,0,0,0]);return{image1:o,image1Const:i>-1?e[i].parameters.value:0,imageSwap:a}}_getThreeInputConfig(e,t){const s=this._getTextures(e,t);let o=0,i=0,a=new Float32Array([1,0,0,0,1,0,0,0,1]);const n=s[1]?{texture:s[1],unit:1}:void 0,l=s[2]?{texture:s[2],unit:2}:void 0,u=[];
1if(e.forEach((h,p)=>h.name==="Constant"&&u.push(p)),u.length===1)o=e[u[0]].parameters.value,a=u[0]===0?new Float32Array([0,1,0,0,0,1,1,0,0]):u[0]===1?new Float32Array([1,0,0,0,0,1,0,1,0]):new Float32Array([1,0,0,0,1,0,0,0,1]);else if(u.length===2){o=e[u[0]].parameters.value,i=e[u[1]].parameters.value;const h=e.findIndex(p=>p.name!=="Constant");a=h===0?new Float32Array([1,0,0,0,1,0,0,0,1]):h===1?new Float32Array([0,1,0,1,0,0,0,0,1]):new Float32Array([0,0,1,1,0,0,0,1,0])}return{image1:n,image2:l,image1Const:o,image2Const:i,imageSwap:a}}},Ns=class extends Be{};c([Oe(0,_)],Ns.prototype,"position",void 0);class eo extends Ae{}let Ht=class extends ${};c([m(D)],Ht.prototype,"texture",void 0),c([m(_)],Ht.prototype,"srcImageSize",void 0);let V=class extends Ve{vertex(e){return{uv:e.position,glPosition:new x(at(e.position),0,1)}}fragment(e){const t=new Ge,s=Ms(e.uv),o=this._process(s);return t.fragColor=new x(o.rgb,1).multiply(o.a),t}_getPixel(e){return Ds(e,this.config)}};c([m(Ht)],V.prototype,"config",void 0),c([J(0,X(Ns))],V.prototype,"vertex",null),c([J(0,X(eo))],V.prototype,"fragment",null);let Ws=class extends ${};c([m(_)],Ws.prototype,"cellSize",void 0);let Zs=class extends V{constructor(){super(...arguments),this.type="AspectShader"}_process(e){const{texture:t}=this.config,s=lt(t,e,this.config.srcImageSize),o=new _(1).divide(this.aspectConfig.cellSize.multiply(8)),{x:i,y:a}=es(s,o),n=De(a),l=s[9].multiply(L(U(i).add(U(n)))),u=U(L(i)),h=new d(3.14159265359),p=new d(0),g=k(p,n).multiply(.5).multiply(h).add(k(n,p).multiply(1.5).multiply(h)),f=Cs(new d(2.5).multiply(h).add(Ft(n,De(i))),new d(2).multiply(h)),y=W(g,f,u).multiply(180).divide(h);return new x(y,y,y,l)}};c([m(Ws)],Zs.prototype,"aspectConfig",void 0);let to=class extends A{constructor(){super(...arguments),this.name="RasterAspectProcessor",this.type=3,this.shaders={aspect:new Zs}}_process(e,t){const s={cellSize:t.getRasterCellSize()},o=this._getCommonConfig(e,t),i={shader:this.shaders.aspect,uniforms:{config:o,aspectConfig:s},defines:{},optionalAttributes:null,useComputeBuffer:!1},{painter:a,context:n}=e;a.submitDrawMesh(n,i,a.quadMesh)}},Qs=class extends ${};c([m(_e)],Qs.prototype,"bandIndexMat3",void 0);let Ys=class extends ${};c([m(b)],Ys.prototype,"adjustments",void 0);let Ye=class extends V{constructor(){super(...arguments),this.type="BandArithmeticShader",this.isOutputRounded=!1}_process(e){const t=this._getPixel(e),s=this.bandArithmeticConfig.bandIndexMat3.multiply(t.rgb),o=this._processIndex(s),i=new x(o,o,o,t.a);return this.isOutputRounded?qe(i):i}_processIndex(e){var i;const{r:t,g:s}=e,o=(i=this.adjustmentConfig)==null?void 0:i.adjustments;switch(this.indexType){case"ndxi":{const a=t.subtract(s),n=t.add(s);return a.multiply(B(n))}case"sr":return t.multiply(B(s));case"ci":return t.multiply(B(s)).subtract(1);case"savi":{const{x:a}=o,n=t.subtract(s),l=t.add(s).add(a);return n.multiply(B(l)).multiply(a.add(1))}case"tsavi":{const{x:a,y:n,z:l}=o,u=l.multiply(a.multiply(a).add(1)).subtract(n.multiply(a)),h=a.multiply(t.subtract(a.multiply(s)).subtract(n)),p=n.multiply(t).add(s).add(u);return h.multiply(B(p))}case"msavi":{const a=t.multiply(2).add(1),n=a.multiply(a).subtract(t.subtract(s).multiply(8));return a.subtract(le(n)).multiply(.5)}case"gemi":{const a=t.multiply(t).subtract(s.multiply(s)).multiply(2).add(t.multiply(1.5)).add(s.multiply(.5)),n=t.add(s).add(.5),l=a.multiply(B(n)),u=l.multiply(ke(l.multiply(.25))),h=s.subtract(.125).multiply(B(ke(s)));return u.subtract(h)}case"pvi":{const{x:a,y:n}=o,l=le(a.multiply(a).add(1));return t.subtract(s.multiply(a)).subtract(n).multiply(B(l))}case"vari":{const a=e.g.subtract(e.r),n=e.g.add(e.r).subtract(e.b);return a.multiply(B(n))}case"rtvicore":return t.subtract(s).multiply(100).subtract(t.subtract(e.b).multiply(10));case"bai":{const a=he(new d(.1).subtract(s),new d(2)),n=he(new d(.06).subtract(t),new d(2));return B(a.add(n))}case"evi":{const a=e.b,n=t.add(s.multiply(6)).subtract(a.multiply(7.5)).add(1);return t.subtract(s).multiply(2.5).multiply(B(n))}case"wndwi":{const{r:a,g:n,b:l}=e,u=o.x,h=u.multiply(n),p=u.multiply(l),g=a.add(h).add(l).subtract(p);return a.subtract(h).subtract(l).add(p).multiply(B(g))}case"mtvi":{const a=e.b,n=he(t.multiply(2).add(1),new d(2)),l=t.multiply(6).subtract(le(s).multiply(5)),u=le(n.subtract(l).subtract(.5)),h=t.subtract(a).multiply(1.2),p=s.subtract(a).multiply(2.5);return h.subtract(p).multiply(1.5).multiply(B(u))}default:return t}}};c([C],Ye.prototype,"indexType",void 0),c([C],Ye.prototype,"isOutputRounded",void 0),c([m(Qs)],Ye.prototype,"bandArithmeticConfig",void 0),c([ce(Ys)],Ye.prototype,"adjustmentConfig",void 0);let so=class extends A{constructor(){super(...arguments),this.name="RasterBandArithmeticProcessor",this.type=4,this.shaders={bandArithmetic:new Ye}}
1_process(e,t){const s=e.rasterFunction.parameters,o={indexType:s.indexType,isOutputRounded:s.isOutputRounded},i={bandIndexMat3:s.bandIndexMat3},a=s.adjustments?{adjustments:[...s.adjustments]}:void 0,n=this._getCommonConfig(e,t),l={shader:this.shaders.bandArithmetic,uniforms:{config:n,bandArithmeticConfig:i,adjustmentConfig:a},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:u,context:h}=e;u.submitDrawMesh(h,l,u.quadMesh)}},Js=class extends V{constructor(){super(...arguments),this.type="ColormapToRGBShader"}_process(e){const t=this._getPixel(e),s=nt(t,new d(1),this.colormapConfig,!1);return new x(s.xyz.multiply(255),s.a)}};c([m(me)],Js.prototype,"colormapConfig",void 0);let io=class extends A{constructor(){super(...arguments),this.name="RasterColormapToRGBProcessor",this.type=5,this.shaders={colormapToRGB:new Js}}_process(e,t,s){const o=e.rasterFunction.parameters,i={colormapTexture:{texture:s,unit:1},colormapOffset:o.offset,colormapMaxIndex:o.indexedColormap.length/4-1},a=this._getCommonConfig(e,t),n={shader:this.shaders.colormapToRGB,uniforms:{config:a,colormapConfig:i},defines:{},optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}},vt=class extends ${};c([m(D)],vt.prototype,"image1",void 0),c([m(d)],vt.prototype,"image1Const",void 0),c([m(_e)],vt.prototype,"imageSwap",void 0);let Pe=class extends ${};c([m(D)],Pe.prototype,"image1",void 0),c([m(D)],Pe.prototype,"image2",void 0),c([m(d)],Pe.prototype,"image1Const",void 0),c([m(d)],Pe.prototype,"image2Const",void 0),c([m(_e)],Pe.prototype,"imageSwap",void 0);const ts=r=>{const e=r;class t extends e{constructor(){super(...arguments),this.constantCount=0,this.imageCount=1}_getRasterValues(o){const{imageCount:i}=this;if(i===1){const a=z(this.config.texture,o);return{a:a.r,b:a.g,c:a.b,alpha:a.a}}if(i===2){const a=this._getTwoValues(o);return{a:a.a,b:a.b,c:a.b,alpha:a.alpha}}return this._getThreeValues(o)}_getTwoValues(o){const i=z(this.config.texture,o);if(this.constantCount===1){const{imageSwap:l,image1Const:u}=this.twoRasterConfig,h=l.multiply(new b(i.r,u,0));return{a:h.x,b:h.y,alpha:i.a}}const{image1:a}=this.twoRasterConfig,n=z(a,o);return{a:i.r,b:n.r,alpha:i.a.multiply(n.a)}}_getThreeValues(o){const i=z(this.config.texture,o),{imageSwap:a,image1:n,image2:l,image1Const:u,image2Const:h}=this.threeRasterConfig;if(this.constantCount===2){const f=a.multiply(new b(i.r,u,h));return{a:f.x,b:f.y,c:f.z,alpha:i.a}}if(this.constantCount===1){const f=z(n,o),y=a.multiply(new b(i.r,f.r,u));return{a:y.x,b:y.y,c:y.z,alpha:i.a.multiply(f.a)}}const p=z(n,o),g=z(l,o);return{a:i.r,b:p.r,c:g.r,alpha:i.a.multiply(p.a).multiply(g.a)}}}return c([C],t.prototype,"constantCount",void 0),c([C],t.prototype,"imageCount",void 0),c([ce(vt)],t.prototype,"twoRasterConfig",void 0),c([ce(Pe)],t.prototype,"threeRasterConfig",void 0),t};let ro=class extends ts(V){constructor(){super(...arguments),this.type="C
1ompositeBandShader"}_process(e){const{a:t,b:s,c:o,alpha:i}=this._getRasterValues(e);return new x(t,s,o,i)}},oo=class extends A{constructor(){super(...arguments),this.name="RasterCompositeBandProcessor",this.type=6,this.shaders={compositeBand:new ro}}_process(e,t){const{rasters:s}=e.rasterFunction.parameters,o={constantCount:this._getConstantCount(s),imageCount:(s==null?void 0:s.length)??1},i=this._getMultipleInputConfig(t,s),a=this._getCommonConfig(e,t),n={shader:this.shaders.compositeBand,uniforms:{config:a,...i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}};class ss extends ${}c([m(_)],ss.prototype,"domainRange",void 0);class Ct extends ts(V){constructor(){super(...arguments),this.type="LocalShader",this.isOutputRounded=!1}_process(e){if(this.operationName==="conditional")return this._conditional(e);const{a:t,b:s,alpha:o}=this._getRasterValues(e),{value:i,alpha:a}=this._compute(t,s,o);return this._processResult(i,a)}_processResult(e,t){const s=Us(e,this.domainRangeConfig.domainRange),o=new x(e,e,e,t).multiply(s);return this.isOutputRounded?qe(o):o}_compute(e,t,s){const{operationName:o}=this;let i;switch(o){case"plus":i=e.add(t);break;case"minus":i=e.subtract(t);break;case"times":i=e.multiply(t);break;case"divide":case"floatdivide":i=e.multiply(B(t)),s=s.multiply(E(U(L(t))));break;case"floordivide":i=ue(e.multiply(B(t))),s=s.multiply(E(U(L(t))));break;case"square":i=e.multiply(e);break;case"sqrt":i=le(e);break;case"power":i=he(e,t);break;case"ln":i=Q(ye(e,new d(0)),nr(e),new d(0)),s=s.multiply(this._isAboveZero(e));break;case"log10":i=Q(ye(e,new d(0)),Bt(e).multiply(B(Bt(new d(10)))),new d(0)),s=s.multiply(this._isAboveZero(e));break;case"log2":i=Q(ye(e,new d(0)),Bt(e),new d(0)),s=s.multiply(this._isAboveZero(e));break;case"exp":i=ar(e);break;case"exp10":i=he(new d(10),e);break;case"exp2":i=he(new d(2),e);break;case"rounddown":i=ue(e);break;case"roundup":i=or(e);break;case"int":i=L(e).multiply(ue(U(e)));break;case"mod":i=Cs(e,t);break;case"negate":i=De(e);break;case"abs":i=U(e);break;case"acos":{const a=this._isAbsBiggerThanOne(e);i=Q(a,new d(0),rr(e)),s=Q(a,new d(0),s);break}case"acosh":i=ir(e);break;case"asin":{const a=this._isAbsBiggerThanOne(e);i=Q(a,new d(0),sr(e)),s=Q(a,new d(0),s);break}case"asinh":i=tr(e);break;case"atan":i=Ft(e);break;case"atanh":{const a=this._isAbsBiggerThanOne(e);i=Q(a,new d(0),er(e)),s=Q(a,new d(0),s);break}case"atan2":i=Ft(e,t);break;case"cos":i=Ki(e);break;case"cosh":i=Xi(e);break;case"sin":i=Ji(e);break;case"sinh":i=Yi(e);break;case"tan":i=Qi(e);break;case"tanh":i=Zi(e);break;case"bitwiseand":i=new d(Wi(new R(e),new R(t)));break;case"bitwiseor":i=new d(Ni(new R(e),new R(t)));break;case"bitwiseleftshift":i=new d(Hi(new R(e),new R(t)));break;case"bitwiserightshift":i=new d(Ei(new R(e),new R(t)));break;case"bitwisenot":i=new d(Li(new R(e)));break;case"bitwisexor":i=new d(Ui(new R(e),new R(t)));break;case"booleanand":i=E(ji(ge(e,new d(0)),ge(t,new d(0))));break;case"booleanor":i=E(qi(ge(e,new d(0)),ge(t,new d(0))));break;case"booleannot":i=E($e(e,new d(0)));break;case"booleanxor":i=E(Gi(ge(e,new d(0)),ge(t,new d(0))));break;case"greaterthan":i=E(ye(e,t));break;case"greaterthanequal":i=E(Ai(e,t));break;case"lessthan":i=E(Ut(e,t));break;case"lessthanequal":i=E(vs(e,t));break;case"equalto":i=E($e(e,t));break;case"notequal":i=E(ge(e,t));break;case"isnull":i=E($e(s,new d(0))),s=new d(1);break;case"setnull":{const a=E($e(e,new d(0)));i=a.multiply(t),s=s.multiply(a);break}default:i=e}return{value:i,alpha:s}}_conditional(e){const{a:t,b:s,c:o,alpha:i}=this._getRasterValues(e),a=new d(U(L(t))),n=W(o,s,a);return this._processResult(n,i)}_isAboveZero(e){return E(ye(e,new d(0)))}_isAbsBiggerThanOne(e){return ye(U(e),new d(1))}}c([C],Ct.prototype,"operationName",void 0),c([C],Ct.prototype,"isOutputRounded",void 0),c([m(ss)],Ct.prototype,"domainRangeConfig",void 0);let St=class extends ts(V){constructor(){super(...arguments),this.type="C
1omputeChangeShader",this.isOutputRounded=!1}_process(e){const{a:t,b:s,alpha:o}=this._getRasterValues(e);let i=t.subtract(s);this.method==="relative-difference"&&(i=i.multiply(B(rt(U(t),U(s)))));const a=Us(i,this.domainRangeConfig.domainRange),n=new x(i,i,i,o).multiply(a);return this.isOutputRounded?qe(n):n}};c([C],St.prototype,"method",void 0),c([C],St.prototype,"isOutputRounded",void 0),c([m(ss)],St.prototype,"domainRangeConfig",void 0);let ao=class extends A{constructor(){super(...arguments),this.name="RasterComputeChangeProcessor",this.type=7,this.shaders={computeChange:new St}}_process(e,t){const s=e.rasterFunction.parameters,{rasters:o}=s,i={constantCount:this._getConstantCount(o),imageCount:o.length,method:s.method,isOutputRounded:s.isOutputRounded},a={domainRange:s.domainRange},{twoRasterConfig:n}=this._getMultipleInputConfig(t,o),l=this._getCommonConfig(e,t),u={shader:this.shaders.computeChange,uniforms:{config:l,domainRangeConfig:a,twoRasterConfig:n},defines:i,optionalAttributes:null,useComputeBuffer:!1},{painter:h,context:p}=e;h.submitDrawMesh(p,u,h.quadMesh)}},Nt=class extends ${};c([m(d)],Nt.prototype,"contrastOffset",void 0),c([m(d)],Nt.prototype,"brightnessOffset",void 0);let Xs=class extends V{constructor(){super(...arguments),this.type="C
1ontrastBrightnessShader"}_process(e){const{rgb:t,a:s}=this._getPixel(e),{contrastOffset:o,brightnessOffset:i}=this.contrastBrightnessConfig,a=new d(255),n=new d(128),l=t.multiply(200),u=a.multiply(100),h=a.multiply(2).multiply(i),p=l.subtract(u).add(h),g=lr([$e(o,new d(-100)),new b(n)],[$e(o,new d(100)),L(p).add(1).divide(2).multiply(a)],[ye(o,new d(0)),p.divide(new d(100).subtract(o).multiply(2)).add(n)],[!0,p.multiply(o.add(100)).divide(2e4).add(n)]);return qe(new x(g,s))}};c([m(Nt)],Xs.prototype,"contrastBrightnessConfig",void 0);let no=class extends A{constructor(){super(...arguments),this.name="RasterContrastBrightnessProcessor",this.type=8,this.shaders={contrastBrightness:new Xs}}_process(e,t){const s=this._getCommonConfig(e,t),o=e.rasterFunction.parameters,i={shader:this.shaders.contrastBrightness,uniforms:{config:s,contrastBrightnessConfig:o},defines:{},optionalAttributes:null,useComputeBuffer:!1},{painter:a,context:n}=e;a.submitDrawMesh(n,i,a.quadMesh)}};class Wt extends ${}c([m(ur.ofType(d,5,5,!0))],Wt.prototype,"kernel",void 0),c([m(_)],Wt.prototype,"clampRange",void 0);let Rt=class extends V{constructor(){super(...arguments),this.type="C
1onvolutionShader",this.rows=3,this.cols=3}_process(e){const{rows:t,cols:s}=this,o=new _(Math.floor(t/2),Math.floor(s/2)),{texture:i,srcImageSize:a}=this.config,n=new d(1).divide(a),{kernel:l}=this.convolutionConfig,u=cr(l,{initialValue:new x(0,0,0,1),xRange:[0,t],yRange:[0,s],callback:(p,g,f,y)=>{const w=new _(new d(f),new d(y)).subtract(o).multiply(n),T=z(i,H(e.add(w))),P=T.rgb.multiply(g).add(p.rgb),S=T.a.multiply(p.a);return new x(P,S)}}),{clampRange:h}=this.convolutionConfig;return new x(ie(u.rgb,h.x,h.y),1).multiply(u.a)}};c([C],Rt.prototype,"rows",void 0),c([C],Rt.prototype,"cols",void 0),c([m(Wt)],Rt.prototype,"convolutionConfig",void 0);let lo=class extends A{constructor(){super(...arguments),this.name="RasterConvolutionProcessor",this.type=9,this.shaders={convolution:new Rt}}_process(e,t){const s=e.rasterFunction.parameters,o={rows:s.kernelRows,cols:s.kernelCols},i={kernel:[...s.kernel],clampRange:s.clampRange},a=this._getCommonConfig(e,t),n={shader:this.shaders.convolution,uniforms:{config:a,convolutionConfig:i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}},Ks=class extends ${};c([m(d)],Ks.prototype,"zlFactor",void 0);let Zt=class extends V{constructor(){super(...arguments),this.type="CurvatureShader"}_process(e){const{texture:t}=this.config,s=lt(t,e,this.config.srcImageSize),o=s[3].add(s[5]).multiply(.5).subtract(s[4]),i=s[1].add(s[7]).multiply(.5).subtract(s[4]),{zlFactor:a}=this.curvatureConfig,{curvatureType:n}=this;let l;if(n==="standard")l=De(a).multiply(o.add(i));else{const u=s[2].subtract(s[0]).add(s[6]).subtract(s[8]).divide(4),h=s[5].subtract(s[3]).divide(2),p=s[1].subtract(s[7]).divide(2),g=h.multiply(h),f=p.multiply(
1p),y=h.multiply(p),w=a.divide(g.add(f));l=n==="profile"?Z(new b(o,i,u),new b(g,f,y)).multiply(w):Z(new b(o,i,De(u)),new b(f,g,y)).multiply(De(w))}return new x(l,l,l,s[9])}};c([C],Zt.prototype,"curvatureType",void 0),c([m(Ks)],Zt.prototype,"curvatureConfig",void 0);let uo=class extends A{constructor(){super(...arguments),this.name="RasterCurvatureProcessor",this.type=10,this.shaders={curvature:new Zt}}_process(e,t){const s=e.rasterFunction.parameters,o={curvatureType:s.curvatureType},i=t.getRasterCellSize(),a={zlFactor:200*s.zFactor/i[0]/i[1]},n=this._getCommonConfig(e,t),l={shader:this.shaders.curvature,uniforms:{config:n,curvatureConfig:a},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:u,context:h}=e;u.submitDrawMesh(h,l,u.quadMesh)}},ei=class extends ${};c([m(_e)],ei.prototype,"bandIndexMat3",void 0);let ti=class extends V{constructor(){super(...arguments),this.type="ExtractBandShader"}_process(e){const t=this._getPixel(e),s=this.extractBandConfig.bandIndexMat3.multiply(t.rgb);return new x(s,t.a)}};c([m(ei)],ti.prototype,"extractBandConfig",void 0);let co=class extends A{constructor(){super(...arguments),this.name="RasterExtractBandProcessor",this.type=11,this.shaders={extractBand:new ti}}_process(e,t){const s={bandIndexMat3:e.rasterFunction.parameters.bandIndexMat3},o=this._getCommonConfig(e,t),i={shader:this.shaders.extractBand,uniforms:{config:o,extractBandConfig:s},defines:{},optionalAttributes:null,useComputeBuffer:!1},{painter:a,context:n}=e;a.submitDrawMesh(n,i,a.quadMesh)}},si=class extends ${};c([m(_)],si.prototype,"clampRange",void 0);class Fe extends V{constructor(){super(...arguments),this.type="FocalStatisticsShader",this.rows=3,this.cols=3,this.fill=!1}_process(e){const t=this._process1(e),s=k(new d(1),t.a);if(!this.fill)return this._clamp(t.rgb,s);const o=this._getPixel(e),i=W(t.rgb,o.rgb,o.a);return this._clamp(i,s)}_clamp(e,t){const{clampRange:s}=this.focalStatisticsConfig;return new x(ie(e,s.x,s.y),1).multiply(t)}_process1(e){const{texture:t,srcImageSize:s}=this.config,{rows:o,cols:i}=this,a=new _(Math.floor(o/2),Math.floor(i/2)),n=new d(1).divide(s),l=this._getPixel(e),{statisticsType:u}=this,h=u==="min"||u==="max"?new x(l.rgb,0):new x(0,0,0,0);switch(u){case"min":return this._stat(o,i,h,(p,g,f)=>{const y=new _(new d(g),new d(f)).subtract(a).multiply(n),w=z(t,H(e.add(y))),T=st(p.rgb,w.rgb);return new x(T,p.a.add(w.a))});case"max":return this._stat(o,i,h,(p,g,f)=>{const y=new _(new d(g),new d(f)).subtract(a).multiply(n),w=z(t,H(e.add(y))),T=rt(p.rgb,w.rgb);return new x(T,p.a.add(w.a))});case"mean":{const p=this._stat(o,i,h,(f,y,w)=>{const T=new _(new d(y),new d(w)).subtract(a).multiply(n),P=z(t,H(e.add(T))),S=f.rgb.add(P.rgb.multiply(P.a));return new x(S,f.a.add(P.a))}),g=p.rgb.multiply(B(p.a));return new x(g,p.a)}case"stddev":{const p=this._stat(o,i,h,(w,T,P)=>{const S=new _(new d(T),new d(P)).subtract(a).multiply(n),O=z(t,H(e.add(S))),K=w.rgb.add(O.rgb.multiply(O.a));return new x(K,w.a.add(O.a))}),g=this._stat(o,i,h,(w,T,P)=>{const S=new _(new d(T),new d(P)).subtract(a).multiply(n),O=z(t,H(e.add(S))),K=w.rgb.add(O.a.multiply(O.rgb).multiply(O.rgb));return new x(K,w.a.add(O.a))}
1),f=B(g.a),y=le(g.subtract(p.multiply(p).multiply(f)).multiply(f));return new x(y.rgb,p.a)}default:return l}}_stat(e=3,t=3,s,o){const i=new R(0).setMutable().setDebugName("StatColIterator"),a=new R(0).setMutable().setDebugName("StatRowIterator"),n=s.setMutable().setDebugName("StatAccumulator"),l=o(n,i,a).setDebugName("StatPredicate");return hr({iterX:i,iterY:a,accumulator:n},x,l,({out:h,iterX:p,iterY:g,accumulator:f,subgraph:y})=>` 2 for (${g} = 0; ${g} < ${e}; ${g}++) { 3 for (${p} = 0; ${p} < ${t}; ${p}++) { 4 5 ${y.body} 6 7 ${f} = ${y.varName}; 8 } 9 } 10 ${h} = ${f}; 11 `).setDebugName("statBody")}}c([C],Fe.prototype,"rows",void 0),c([C],Fe.prototype,"cols",void 0),c([C],Fe.prototype,"statisticsType",void 0),c([C],Fe.prototype,"fill",void 0),c([m(si)],Fe.prototype,"focalStatisticsConfig",void 0);class ho extends A{constructor(){super(...arguments),this.name="RasterFocalStatisticsProcessor",this.type=21,this.shaders={focalStatistics:new Fe}}_process(e,t){const s=e.rasterFunction.parameters,o={rows:s.kernelRows,cols:s.kernelCols,statisticsType:s.statisticsType,fill:s.fillNoDataOnly},i={clampRange:s.clampRange},a=this._getCommonConfig(e,t),n={shader:this.shaders.focalStatistics,uniforms:{config:a,focalStatisticsConfig:i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}}class ii extends ${}c([m(b)],ii.prototype,"weights",void 0);let ri=class extends V{constructor(){super(...arguments),this.type="GrayscaleShader"}_process(e){const t=this._getPixel(e),{weights:s}=this.grayscaleConfig,o=Z(s,t.rgb);return new x(o,o,o,t.a)}};c([m(ii)],ri.prototype,"grayscaleConfig",void 0);let po=class extends A{constructor(){super(...arguments),this.name="RasterGrayscaleProcessor",this.type=12,this.shaders={grayscale:new ri}}_process(e,t){const s={weights:e.rasterFunction.parameters.weights},o=this._getCommonConfig(e,t),i={shader:this.shaders.grayscale,uniforms:{config:o,grayscaleConfig:s},defines:{},optionalAttributes:null,useComputeBuffer:!1},{painter:a,context:n}=e;a.submitDrawMesh(n,i,a.quadMesh)}},It=class extends V{constructor(){super(...arguments),this.type="HillshadeShader",this.isMultidirectional=!1}_process(e){const{texture:t}=this.config,s=lt(t,e,this.config.srcImageSize),o=qs(s,this.hillshadeConfig,this.isMultidirectional);return new x(o.rgb.multiply(255),o.a)}};c([C],It.prototype,"isMultidirectional",void 0),c([m(ae)],It.prototype,"hillshadeConfig",void 0);let mo=class extends A{constructor(){super(...arguments),this.name="RasterHillshadeProcessor",this.type=13,this.shaders={hillshade:new It}}_process(e,t){const s=e.rasterFunction.parameters,o={isMultidirectional:s.hillshadeType>0},i=t.getRasterCellSize(),a=js(s,i),n={...s,factor:a,minValue:0,maxValue:8e3},l=this._getCommonConfig(e,t),u={shader:this.shaders.hillshade,uniforms:{config:l,hillshadeConfig:n},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:h,context:p}=e;h.submitDrawMesh(p,u,h.quadMesh)}},go=class extends A{constructor(){super(...arguments),this.name="RasterLocalProcessor",this.type=14,this.shaders={local:new Ct}}_process(e,t){var g;const s=e.rasterFunction.parameters,o={constantCount:this._getConstantCount(s.rasters),imageCount:s.imageCount,operationName:s.operationName,isOutputRounded:s.isOutputRounded},i={domainRange:s.domainRange},a=s.operationName==="conditional"?s.rasters:(g=s.rasters)==null?void 0:g.slice(0,2),n=this._getMultipleInputConfig(t,a),l=this._getCommonConfig(e,t),u={shader:this.shaders.local,uniforms:{config:l,domainRangeConfig:i,...n},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:h,context:p}=e;h.submitDrawMesh(p,u,h.quadMesh)}};class Qt extends ${}c([m(te.ofType(d,6))],Qt.prototype,"includedRanges",void 0),c([m(te.ofType(d,se))],Qt.prototype,"noDataValues",void 0);let Yt=class extends V{constructor(){super(...arguments),this.type="MaskShader",this.isMultiband=!0}_process(e){const t=this._getPixel(e),s=this._computeNoDataFactor(t.r),o=this._computeRangeFactor(t.rgb);let i;if(this.isMultiband){const a=this._computeNoDataFactor(t.g),n=this._computeNoDataFactor(t.b),l=new b(s,a,n).multiply(o);i=l.x.multiply(l.y).multiply(l.z)}else i=s.multiply(o.x);return t.multiply(i)}_computeNoDataFactor(e){const{noDataValues:t}=this.maskConfig;let s=new b(1);for(let o=0;o<se/3;o++){const i=3*o,a=new b(t[i+0],t[i+1],t[i+2]),n=U(L(a.subtract(e)));s=s.multiply(n)}return s.x.multiply(s.y).multiply(s.z)}_computeRangeFactor(e){const{includedRanges:t}
vendor: 5,244 bytes, line 11
11=this.maskConfig,s=new b(t[0],t[2],t[4]),o=new b(t[1],t[3],t[5]);return k(s,e).multiply(k(e,o))}};c([C],Yt.prototype,"isMultiband",void 0),c([m(Qt)],Yt.prototype,"maskConfig",void 0);let fo=class extends A{constructor(){super(...arguments),this.name="RasterMaskProcessor",this.type=15,this.shaders={mask:new Yt}}_process(e,t){const s=e.rasterFunction.parameters,o={isMultiband:s.bandCount>1},i={includedRanges:[...s.includedRanges],noDataValues:[...s.noDataValues]},a=this._getCommonConfig(e,t),n={shader:this.shaders.mask,uniforms:{config:a,maskConfig:i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}};class oi extends ${}c([m(_e)],oi.prototype,"bandIndexMat3",void 0);class Jt extends V{constructor(){super(...arguments),this.type="NDVIShader",this.scaled=!0}_process(e){const t=this._getPixel(e),{r:s,g:o}=this.ndviConfig.bandIndexMat3.multiply(t.rgb),i=s.subtract(o),a=s.add(o),n=i.multiply(B(a));if(!this.scaled)return new x(n,n,n,t.a);const l=ue(n.multiply(100).add(100.5));return new x(l,l,l,t.a)}}c([C],Jt.prototype,"scaled",void 0),c([m(oi)],Jt.prototype,"ndviConfig",void 0);let yo=class extends A{constructor(){super(...arguments),this.name="RasterNDVIProcessor",this.type=16,this.shaders={ndvi:new Jt}}_process(e,t){const s=e.rasterFunction.parameters,o={scaled:s.scaled},i={bandIndexMat3:s.bandIndexMat3},a=this._getCommonConfig(e,t),n={shader:this.shaders.ndvi,uniforms:{config:a,ndviConfig:i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}};class Ie extends ${}c([m(te.ofType(d,3*se))],Ie.prototype,"rangeMaps",void 0),c([m(te.ofType(d,2*se))],Ie.prototype,"noDataRanges",void 0),c([m(d)],Ie.prototype,"unmatchMask",void 0),c([m(d)],Ie.prototype,"replacementValue",void 0),c([m(_)],Ie.prototype,"clampRange",void 0);class Xt extends V{constructor(){super(...arguments),this.type="RemapShader"}_process(e){const t=this._getPixel(e),{rangeMaps:s,unmatchMask:o,clampRange:i,replacementValue:a}=this.remapConfig,{mapValue:n,includeMask:l}=Wr(t.r,s,se),u=this.replaceUnmatched?a:o.multiply(t.r),h=W(u,n,l),p=ie(h,i.x,i.y),g=this._computeNoDataFactor(t.rrr).multiply(rt(o,l));return new x(p,p,p,t.a).multiply(g)}_computeNoDataFactor(e){const{noDataRanges:t}=this.remapConfig;let s=new b(0,0,0);for(let o=0;o<se/3;o++){const i=6*o,a=new b(t[i],t[i+2],t[i+4]),n=new b(t[i+1],t[i+3],t[i+5]);s=s.add(k(a,e).multiply(k(e,n)))}return ke(L(Z(s,new b(1,1,1))))}}c([m(Ie)],Xt.prototype,"remapConfig",void 0),c([C],Xt.prototype,"replaceUnmatched",void 0);class xo extends A{constructor(){super(...arguments),this.name="RasterRemapProcessor",this.type=17,this.shaders={remap:new Xt}}_process(e,t){const s=e.rasterFunction.parameters,o={replaceUnmatched:s.allowUnmatched&&s.replacementValue!=null},i={rangeMaps:[...s.rangeMaps],noDataRanges:[...s.noDataRanges],unmatchMask:s.allowUnmatched?1:0,replacementValue:s.replacementValue??0,clampRange:s.clampRange},a=this._getCommonConfig(e,t),n={shader:this.shaders.remap,uniforms:{config:a,remapConfig:i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}}let wo=class extends q{constructor(){super(...arguments),this.type="ReprojectShader"}_colorize(e){return this._getPixel(e)}},bo=class extends A{constructor(){super(...arguments),this.name="RasterReprojectProcessor",this.type=18,this.shaders={reproject:new wo}}_process(e,t){const s=e.rasterFunction.parameters,o=this._getInterpolationDefines(t.interpolation,!!s.requireNNEdge),{config:i,projectionConfig:a,projectionDefines:n}=this._getReprojectConfig(t),l={shader:this.shaders.reproject,uniforms:{config:i,projectionConfig:a},defines:{...n,...o,applyPixelMask:!1,applyPixelHighlights:!1},optionalAttributes:null,useComputeBuffer:!1},{interpolation:u}=t;t.interpolation="nearest";const{painter:h,context:p}=e;h.submitDrawMesh(p,l,h.quadMesh),t.interpolation=u,t.projected=!0}_getReprojectConfig(e){const{source:t}=e,{names:s,textures:o}=e.getTextures({forProcessing:!0}),i={texture:{texture:o[s.indexOf("u_image")],unit:0},dvsMat3:new Float32Array([2,0,0,0,2,0,-1,-1,0]),coordScale:[1,1],srcImageSize:[t.width,t.height],opacity:1},a=o[s.indexOf("u_transformGrid")],{transformGrid:n}=e,l=!(!a||!n);return{config:i,projectionConfig:l?{transformTexture:{texture:a,unit:1},targetImageSize:[e.width,e.height],transformSpacing:n.spacing,transformGridSize:n.size}:void 0,projectionDefines:{applyProjection:l,lookupProjection:l&&n.spacing[0]===1}}}_getInterpolationDefines(e,t){const s=e==="bilinear"&&t;return{bilinear:s,bicubic:e==="cubic",nearestOnEdge:s}}};class ai extends It{constructor(){super(...arguments),this.type="ShadedReliefShader"}_process(e){const t=super._process(e),{minValue:s,maxValue:o}=this.hillshadeConfig,i=this._getPixel(e),a=o.subtract(s),n=i.r.subtract(s),l=ie(n.divide(a),new d(0),new d(1)),u=nt(new x(l,l,l,1),new d(255),this.colormapConfig),h=As(u.xyz),p=Gs(new b(h.xy,t.x.divide(255))).multiply(255);return new x(p,u.a.multiply(t.a))}}c([m(me)],ai.prototype,"colormapConfig",void 0);let _o=class extends A{constructor(){super(...arguments),this.name="RasterShadedReliefProcessor",this.type=19,this.shaders={shadedRelief:new ai}}
11_process(e,t,s){const o=e.rasterFunction.parameters,i={isMultidirectional:o.hillshadeType>0},a=t.getRasterCellSize(),n=js(o,a),l={...o,factor:n},u={colormapTexture:{texture:s,unit:1},colormapOffset:o.offset,colormapMaxIndex:o.indexedColormap.length/4-1},h=this._getCommonConfig(e,t),p={shader:this.shaders.shadedRelief,uniforms:{config:h,hillshadeConfig:l,colormapConfig:u},defines:i,optionalAttributes:null,useComputeBuffer:!1},{painter:g,context:f}=e;g.submitDrawMesh(f,p,g.quadMesh)}},Je=class extends ${};c([m(d)],Je.prototype,"pixelSizePower",void 0),c([m(d)],Je.prototype,"pixelSizeFactor",void 0),c([m(d)],Je.prototype,"zFactor",void 0),c([m(_)],Je.prototype,"cellSize",void 0);let Pt=class extends V{constructor(){super(...arguments),this.type="SlopeShader",this.isOutputRounded=!1,this.percentRise=!1}_process(e){const{cellSize:t,pixelSizePower:s,pixelSizeFactor:o,zFactor:i}=this.slopeConfig,a=he(t,new _(s)).multiply(o).add(i).divide(t.multiply(8)),{texture:n}=this.config,l=lt(n,e,this.config.srcImageSize),{x:u,y:h}=es(l,a),p=le(u.multiply(u).add(h.multiply(h))),g=this.percentRise?p.multiply(100):Ft(p).multiply(57.2957795),f=new x(g,g,g,l[9]);return this.isOutputRounded?qe(f):f}};c([C],Pt.prototype,"isOutputRounded",void 0),c([C],Pt.prototype,"percentRise",void 0),c([m(Je)],Pt.prototype,"slopeConfig",void 0);let To=class extends A{constructor(){super(...arguments),this.name="RasterSlopeProcessor",this.type=20,this.shaders={slope:new Pt}}_process(e,t){const s=e.rasterFunction.parameters,o={isOutputRounded:s.isOutputRounded,percentRise:s.slopeType==="percent-rise"},i={cellSize:t.getRasterCellSize(),pixelSizePower:s.slopeType==="adjusted"?s.pixelSizePower:0,pixelSizeFactor:s.slopeType==="adjusted"?s.pixelSizeFactor:0,zFactor:s.zFactor},a=this._getCommonConfig(e,t),n={shader:this.shaders.slope,uniforms:{config:a,slopeConfig:i},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:l,context:u}=e;l.submitDrawMesh(u,n,l.quadMesh)}};class Xe extends V{constructor(){super(...arguments),this.type="StretchShader",this.isMultiband=!0,this.isOutputRounded=!1,this.useGamma=!1}_process(e){const t=this._getPixel(e);let s=Hs(t,this.stretchConfig,this.useGamma,1);return this.isMultiband||(s=new x(s.rrr,s.a)),this.isOutputRounded?qe(s):s}}c([C],Xe.prototype,"isMultiband",void 0),c([C],Xe.prototype,"isOutputRounded",void 0),c([C],Xe.prototype,"useGamma",void 0),c([m(ne)],Xe.prototype,"stretchConfig",void 0);class vo extends A{constructor(){super(...arguments),this.name="RasterStretchProcessor",this.type=22,this.shaders={stretch:new Xe}}_process(e,t){const s=e.rasterFunction.parameters,o={isMultiband:s.bandCount>1,isOutputRounded:s.isOutputRounded,useGamma:s.useGamma},i=this._getCommonConfig(e,t),a={shader:this.shaders.stretch,uniforms:{config:i,stretchConfig:s},defines:o,optionalAttributes:null,useComputeBuffer:!1},{painter:n,context:l}=e;n.submitDrawMesh(l,a,n.quadMesh)}}const Co=new Map([["Aspect",to],["BandArithmetic",so],["ColormapToRGB",io],["CompositeBand",oo],["ComputeChange",ao],["ContrastBrightness",no],["Convolution",lo],["Curvature",uo],["ExtractBand",co],["Grayscale",po],["Hillshade",mo],["Local",go],["Mask",fo],["NDVI",yo],["Remap",xo],["Reproject",bo],["ShadedRelief",_o],["Slope",To],["Statistics",ho],["Stretch",vo]]);class So extends ot{constructor(){super(...arguments),this.type=1,this.shaders={},this._techniques=new Map}shutdown(e){var t;super.shutdown(e),(t=this._fbo)==null||t.dispose(),this._fbo=void 0;for(const s of this._techniques.values())s.shutdown();this._techniques.clear()}render(e,t){this._fbo??(this._fbo=$s(e.context,N,N));let{name:s}=e.rasterFunction;if(s==="Arithmetic"&&(s="Local"),!this._techniques.has(s)){const o=Co.get(s);if(!o)return;this._techniques.set(s,new o)}this._techniques.get(s).render(e,{...t,processorFbo:this._fbo})}}class Ro extends Ts{constructor(){super(...arguments),this.isCustomTilingScheme=!1}get pixelHighlights(){return this._pixelHighlights}set pixelHighlights(e){this._pixelHighlights=e,this.children.forEach(({bitmap:t})=>t.highlightTexture=null),this.requestRender()}createTile(e){const t=this._getTileBounds(e),[s,o]=this.tileInfoView.tileInfo.size,i=this.tileInfoView.getTileResolution(e.level);return new $r(e,i,t[0],t[3],s,o)}onAttach(){super.onAttach(),this._colorizerTechnique=new Jr,this._processorTechnique=new So,this._highlightTechnique=new Kr}onDetach(){var e,t,s;super.onDetach(),(e=this._colorizerTechnique)==null||e.shutdown(),this._colorizerTechnique=void 0,(t=this._processorTechnique)==null||t.shutdown(),this._processorTechnique=void 0,(s=this._highlightTechnique)==null||s.shutdown(),this._highlightTechnique=void 0}doRender(e){var o,i;if(!this.visible||e.drawPhase!==1||!this._colorizerTechnique)return;
11const{rasterFunctionChain:t}=this;if((o=t==null?void 0:t.functions)!=null&&o.length){if(!this._processorTechnique)return;const{functions:a,hasBranches:n}=t;for(const l of a){if(l.name==="Constant"||l.name==="Identity")continue;e.rasterFunction=l,e.hasBranches=n,super.doRender(e);const u=this.children.map(h=>h.bitmap);this._processorTechnique.render(e,{bitmaps:u})}}if((i=this._pixelHighlights)!=null&&i.length&&this._highlightTechnique)for(const a of this._pixelHighlights){e.pixelHighlightOptions=a,super.doRender(e);const n=this.children.map(l=>l.bitmap);this._highlightTechnique.render(e,{bitmaps:n})}e.rasterFunction=null,e.pixelHighlightOptions=void 0,super.doRender(e);const s=this.children.map(a=>a.bitmap);this._colorizerTechnique.render(e,{bitmaps:s})}_getTileBounds(e){const t=this.tileInfoView.getTileBounds(xs(),e);if(this.isCustomTilingScheme&&e.world){const{tileInfo:s}=this.tileInfoView,o=Ii(s.spatialReference);if(o){const i=s.lodAt(e.level);if(!i)return t;const{resolution:a}=i,n=a*s.size[0];t[0]=o*e.world+s.origin.x+e.col*n,t[2]=t[0]+n}}return t}}const Po=[0,0];let G=class extends di{constructor(){super(...arguments),this._updatingHandles=new dr,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=mi(async(r={})=>{const e=this._rasterFunctionState,t=r.reprocess||e==="gpu"&&!this.canUseWebGLForProcessing||e==="cpu"&&this.canUseWebGLForProcessing;if(t&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const s=this._rasterFunctionState,{type:o}=this;return r.refetch||o!=="raster"&&t||s==="cpu"||e==="cpu"?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(r.signal))})}destroy(){this._updatingHandles.destroy()}get canUseWebGLForProcessing(){return!1}get canUseLocalSymbolizerParams(){return(this.canUseWebGLForProcessing||this.type==="rasterVF")&&!this.layerView.hasTilingEffects}get isCPUBasedDRA(){const{renderer:r}=this.layer;return(r==null?void 0:r.type)==="raster-stretch"&&r.dynamicRangeAdjustment&&(!this.canUseWebGLForProcessing||!(r.stretchType==="min-max"||r.stretchType==="standard-deviation"))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(r){this._set("useWebGLForProcessing",r)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(r){if(this._tileStrategy&&this.useProgressiveUpdate!==r){this._tileStrategy.destroy(),this.container.removeAllChildren();const e=this._getCacheSize(r);
11this._tileStrategy=new ns({cachePolicy:"purge",acquireTile:t=>this.acquireTile(t),releaseTile:t=>this.releaseTile(t),cacheSize:e,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",r),this.layerView.requestUpdate()}}update(r){var i;this._fetchQueue.pause(),this._fetchQueue.state=r.state,this._tileStrategy.update(r),this._fetchQueue.resume();const{extent:e,resolution:t,scale:s}=r.state,o=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const a=this._srcResolutions[o.level],n="toJSON"in e?e:gi.fromJSON(e);hs(this._blockCacheRegistryUrl,this._blockCacheRegistryId,n,t,a,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,((i=this.previousLOD)==null?void 0:i.level)!==o.level&&(this.previousLOD=o,this._symbolizerParams!=null&&this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.isCPUBasedDRA&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,this._fetchQueue.length===0&&this._redrawImage(this._abortController.signal).then(()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()}));const r=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(r),this.layerView.requestUpdate()}get updating(){var r;return this._globalUpdateRequested||((r=this._updatingHandles)==null?void 0:r.updating)}attach(){const r=Ss();this._maxIndexedColormapSize=4*(r.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new $i(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new Mi({tileInfoView:this._tileInfoView,concurrency:e,process:(s,o)=>this._fetchTile(s,o),priority:_r.MAPVIEW_FETCH_QUEUE,scheduler:this.scheduler});const t=this._getCacheSize(this.useProgressiveUpdate);
11this._tileStrategy=new ns({cachePolicy:"purge",acquireTile:s=>this.acquireTile(s),releaseTile:s=>this.releaseTile(s),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,ps(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(r){const e=this.container.createTile(r);return this._updatingHandles.addPromise(this._enqueueTileFetch(e)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.isCPUBasedDRA||!this.useProgressiveUpdate,e}releaseTile(r){this._fetchQueue.abort(r.key.id),this.container.removeChild(r),r.once("detach",()=>{r.destroy(),this.layerView.requestUpdate()}),this.layerView.requestUpdate()}createEmptyTilePixelBlock(r=null){const e=r==null||r.join(",")===this._tileInfoView.tileInfo.size.join(",");if(e&&this._emptyTilePixelBlock!=null)return this._emptyTilePixelBlock;r=r||this._tileInfoView.tileInfo.size;const[t,s]=r,o=new mr({width:t,height:s,pixels:[new Uint8Array(t*s)],mask:new Uint8Array(t*s),pixelType:"u8"});return e&&(this._emptyTilePixelBlock=o),o}_getBandIds(){if(this.container&&(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain))return this.layer.bandIds;const{bandIds:r,raster:e}=this.layer,t="rasterFunction"in e?e.rasterFunction.rawInputBandIds:null;return r!=null&&r.length&&(t!=null&&t.length)&&e.rasterInfo.bandCount!==1?r.map(s=>
11t[Math.min(s,t.length-1)]):"rasterFunction"in e?t:r}updateRasterFunctionParameters(){}_fetchTile(r,e){const t=this._getFetchOptions(r.level,e.signal);return this.fetchTile(r,t)}_getFetchOptions(r,e){var u;const{canUseWebGLForProcessing:t}=this,{layerView:s}=this,{tileInfo:o}=s,i=!o.isWrappable&&yr(s.view.spatialReference)!=null,a=t&&this.layer.raster.hasUniqueSourceStorageInfo,{layer:n}=this.layerView,l=(u=n.serviceRasterInfo)!=null&&u.storageInfo.isBsqTile?n.getRawDisplayBandIds():void 0;return{allowPartialFill:!0,datumTransformation:s.datumTransformation,interpolation:t?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:a,skipRasterFunction:this.type==="raster"&&this.container.rasterFunctionChain!=null,signal:e,srcResolution:this._srcResolutions[r],timeExtent:s.timeExtent,tileInfo:o,bandIds:l,disableWrapAround:i}}_getCacheSize(r){return r?40:0}_initializeTileInfo(){const{layerView:r}=this,e=r.view.spatialReference;if(this._canUseLayerLODs()){const{origin:u,lods:h}=this.layer.tileInfo,p=h.map(({scale:f})=>f),g=cs.create({spatialReference:e,size:N,scales:p,origin:u});return r.set("tileInfo",g),void(this._srcResolutions=h.map(({resolution:f})=>({x:f,y:f})))}const{scales:t,srcResolutions:s,isCustomTilingScheme:o}=xr(this.layer.serviceRasterInfo,e,{tileSize:N,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),i=cs.create({spatialReference:e,size:N,scales:t}),a=i.origin.x===0;fi(r.fullExtent);const{xmin:n,ymax:l}=r.fullExtent;(a||o&&i.origin.x>n)&&(i.origin=new yi({x:n,y:l,spatialReference:e})),this._isCustomTilingScheme=o,r.set("tileInfo",i),this._srcResolutions=s??[]}_canUseLayerLODs(){var o;const{layer:r,layerView:e}=this;if(r.raster.tileType!=="Map")return!1;const{lods:t}=r.tileInfo,s=(o=e.view.constraints)==null?void 0:o.effectiveLODs;return(s==null?void 0:s.length)===t.length&&s.every(({scale:i},a)=>Math.abs(i-t[a].scale)<.001)}_computeFetchConcurrency(){const{blockBoundary:r}=this.layer.serviceRasterInfo.storageInfo,e=r[r.length-1];return(e.maxCol-e.minCol+1)*(e.maxRow-e.minRow+1)>64?2:10}async _enqueueTileFetch(r,e){var t;if(!this._fetchQueue.has(r.key.id)){try{let s=r.once("detach",()=>s=void 0);const o=await this._fetchQueue.push(r.key),i=this._getBandIds();let a=!this.useProgressiveUpdate||this.isCPUBasedDRA&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&this._fetchQueue.length===0){a=!1;try{await this._redrawImage((t=this._abortController)==null?void 0:t.signal)}catch(u){Ke(u)&&et.getLogger(this).error(u)}this._globalUpdateRequested=!1}if(!s)return;this.canUseLocalSymbolizerParams&&this._symbolizerParams==null&&this._updateSymbolizerParams();const n=this._tileInfoView.getTileCoords(Po,r.key),l=this._tileInfoView.getTileResolution(r.key);await this.updateTileSource(r,{source:o,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:a,bandIds:i,coords:n,resolution:l}),s&&(r.once("attach",()=>this.layerView.requestUpdate()),this.container.addChild(r),s.remove())}catch(s){Ke(s)||et.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(r){if(!this.attached||this.container.children.length===0||(await this.layer.updateRenderer(),this.isCPUBasedDRA?await this._updateGlobalSymbolizerParams(r):(this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._globalSymbolizerParams=null),!this.attached||(r==null?void 0:r.aborted)))return;const e=this.container.children.map(async t=>this.updateTileSymbolizerParameters(t,{local:this._symbolizerParams,global:this._globalSymbolizerParams},r));await Promise.allSettled(e),this.attached&&!(r!=null&&r.aborted)&&this.container.requestRender()}async _updateGlobalSymbolizerParams(r){const e=this._getFetchOptions(this.previousLOD.level,r),t=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,{...e,interpolation:"nearest",requestRawData:!1,skipRasterFunction:!1});if(!(t!=null&&t.pixelBlock))return;const{resolution:s}=this.previousLOD,{isBsqTile:o}=this.layer.raster.rasterInfo.storageInfo,i=o?null:this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:t.pixelBlock.extractBands(i),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:i});!this.canUseWebGLForProcessing&&a&&a.type==="stretch"&&this.layer.renderer&&this.layer.renderer.type==="raster-stretch"&&(a.factor=a.factor.map(n=>255*n),a.minOutput=Math.round(255*a.minOutput),a.maxOutput=Math.round(255*a.maxOutput)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:r}=this.previousLOD,e=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:r,y:r},bandIds:e})}_updateBlockCacheRegistry(r=!1){const{layer:e,layerView:t}=this,{raster:s}=e,{multidimensionalDefinition:o}=e.normalizeRasterFetchOptions({multidimensionalDefinition:e.multidimensionalDefinition,timeExtent:t.timeExtent}),i=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(o):null,a=s.rasterInfo.storageInfo.isBsqTile?e.getRawDisplayBandIds():null,n=gr(s.rasterId,i,a);if(n!==this._blockCacheRegistryUrl){if(this._blockCacheRegistryUrl!=null&&ps(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=fr(n,s.rasterInfo),r){const{view:l}=t,u=this._tileInfoView.getClosestInfoForScale(l.scale),h=this._srcResolutions[u.level];hs(n,this._blockCacheRegistryId,l.extent,l.resolution,h,s.ioConfig.sampling)}this._blockCacheRegistryUrl=n}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const r=[];this._globalUpdateRequested=this.isCPUBasedDRA||!this.useProgressiveUpdate,this._tileStrategy.refresh(e=>r.push(this._enqueueTileFetch(e))),await this._updatingHandles.addPromise(Promise.allSettled(r))}};c([F()],G.prototype,"_globalUpdateRequested",void 0),c([F()],G.prototype,"attached",void 0),c([F()],G.prototype,"canUseWebGLForProcessing",null),c([F()],G.prototype,"canUseLocalSymbolizerParams",null),c([F()],G.prototype,"isCPUBasedDRA",null),c([F()],G.prototype,"container",void 0),c([F()],G.prototype,"layer",void 0),c([F()],G.prototype,"layerView",void 0),c([F()],G.prototype,"scheduler",void 0),c([F()],G.prototype,"type",void 0),c([F()],G.prototype,"useWebGLForProcessing",null),c([F()],G.prototype,"useProgressiveUpdate",null),c([F()],G.prototype,"timeExtent",void 0),c([F()],G.prototype,"updating",null),G=c([it("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],G);let we=class extends G{constructor(){super(...arguments),this.type="raster"}get canUseWebGLForProcessing(){var i;const{loaded:r,symbolizer:e}=this.layer;if(!r||!e)return!1;const t=(i=e.lookup.colormapLut)==null?void 0:i.indexedColormap,s=t&&t.length>this._maxIndexedColormapSize,o=Ri(this.layer.serviceRasterInfo);return!(ys("ios")&&o>4)&&this.useWebGLForProcessing&&e.canRenderInWebGL&&!s&&!(this.layer.interpolation==="majority"&&bs(this.layer))}attach(){super.attach(),this.container=new Ro(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}fetchTile(r,e){return this.layer.fetchTile(r.level,r.row,r.col,e)}
11updateRasterFunctionParameters(){var g;const{raster:r,type:e}=this.layer,{container:t}=this;if(r.datasetFormat!=="Function"||e==="wcs")return t.rasterFunctionChain=null,t.children.forEach(f=>{const{bitmap:y}=f;y&&(y.suspended=!0,y.processed=!1,y.projected&&(y.invalidateTexture(),y.rasterTexture=null))}),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:o,primaryRasters:i}=r,a=o.supportsGPU&&(!i||i.rasters.length<=1),n=a?o.flatWebGLFunctionChain:null,{renderer:l}=this.layer,u=!a||!(n!=null&&n.functions.length)||(l==null?void 0:l.type)==="raster-stretch"&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing;t.rasterFunctionChain=u?null:this._addProjection(n);const h=o==null?"na":t.rasterFunctionChain?"gpu":"cpu",p=s===h||s==="na"&&h==="cpu"&&((g=n==null?void 0:n.functions)==null?void 0:g.length)===0;t.children.forEach(f=>{const{bitmap:y}=f;y&&(y.suspended=!p,y.processed=!1,y.processedTexture=null)}),this._rasterFunctionState=h}async updateTileSource(r,e){const t=this._getBandIds(),s=this._getLayerInterpolation(),{canUseWebGLForProcessing:o}=this,{source:i,globalSymbolizerParams:a,suspended:n,coords:l,resolution:u}=e,h=this.isCPUBasedDRA?a:e.symbolizerParams,{bitmap:p}=r;if([p.x,p.y]=l,p.resolution=u,(i==null?void 0:i.pixelBlock)!=null){const y={extent:i.extent,pixelBlock:i.pixelBlock,srcPixelSize:i.srcTilePixelSize};if(p.rawPixelData=y,o)p.source=i.pixelBlock,p.isRendereredSource=!1;else{const w=await this.layer.applyRenderer(y,(a==null?void 0:a.type)==="stretch"?a:void 0);p.source=w,p.isRendereredSource=!0}p.symbolizerParameters=o?h:null,p.transformGrid=o?i.transformGrid:null}else{const y=this.createEmptyTilePixelBlock();p.source=y,p.symbolizerParameters=o?h:null,p.transformGrid=null}const{isBsqTile:g}=this.layer.raster.rasterInfo.storageInfo;p.bandIds=o&&!g?t:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=n;const{raster:f}=this.layer;if(ws(f)){const y=f.getClippingGeometry(this.layerView.view.spatialReference);if(y){const w=f.getTileExtentFromTileInfo(r.key.level,r.key.row,r.key.col,this._tileInfoView.tileInfo);w&&(p.mask=Pi({srcExtent:w,geometry:y,size:[p.width,p.height]}))}}p.invalidateTexture()}async updateTileSymbolizerParameters(r,e,t){const{local:s,global:o}=e,i=this._getBandIds(),a=this._getLayerInterpolation(),{canUseWebGLForProcessing:n}=this,{bitmap:l}=r,{rawPixelData:u}=l;n||u==null?(l.isRendereredSource&&u!=null&&(l.source=u.pixelBlock),l.isRendereredSource=!1):(l.source=await this.layer.applyRenderer(u,(o==null?void 0:o.type)==="stretch"?o:void 0,{signal:t}),l.isRendereredSource=!0),l.symbolizerParameters=n?this.layerView.hasTilingEffects?o:s:null;const{isBsqTile:h}=this.layer.raster.rasterInfo.storageInfo;l.bandIds=n&&!h?i:null,l.interpolation=a,l.suspended=!1}updateHighlightOptions(r){var s;if(!r.length)return void(this.container.pixelHighlights=void 0);const e=[],{highlights:t}=this.layerView.view;r.sort((o,i)=>t.findIndex(({name:a})=>a===Vt(i.options))-t.findIndex(({name:a})=>a===Vt(o.options)));for(const{target:o,options:i}of r){const{pixelRanges:a}=o,n=Array.from({length:2*se},()=>0);for(let g=0;g<a.length;g++)n[2*g]=a[g][0],n[2*g+1]=a[g][1];for(let g=a.length;g<se;g++)n[2*g]=is,n[2*g+1]=-is;const l=o.bandId??0,u=Vt(i),h=((s=t.find(g=>g.name===u))==null?void 0:s.color)??zi,p=xi.toUnitRGBA(h);e.push({ranges:n,bandId:l,color:p})}this.container.pixelHighlights=e}_getLayerInterpolation(){const{interpolation:r,renderer:e}=this.layer;if(!e)return r;const t=e.type;return t==="raster-colormap"||t==="unique-value"?"nearest":e.type==="raster-stretch"&&e.colorRamp!=null?r==="bilinear"||r==="cubic"?"bilinear":"nearest":r}_addProjection(r){var e;return(e=r==null?void 0:r.functions)!=null&&e.length&&!r.hasFocalFunction&&r.functions.unshift({name:"Reproject",parameters:{targetImageSize:this._tileInfoView.tileInfo.size,requireNNEdge:r.isSourceSingleBand},pixelType:"f32",id:0,isNoopProcess:!1}),r}};c([F()],we.prototype,"canUseWebGLForProcessing",null),c([F()],we.prototype,"container",void 0),c([F()],we.prototype,"layer",void 0),c([F()],we.prototype,"type",void 0),we=c([it("esri.views.2d.layers.imagery.ImageryTileView2D")],we);class Fo extends _s{constructor(e,t,s,o,i,a,n=null){super(e,t,s,o,i,a),this.tileData=new Ti(n),this.tileData.coordScale=[i,a],this.tileData.once("isReady",()=>this.ready())}destroy(){super.destroy(),this.tileData.destroy(),this.tileData=null,this.stage=null}set stencilRef(e){this.tileData.stencilRef=e}get stencilRef(){return this.tileData.stencilRef}_createTransforms(){return{displayViewScreenMat3:tt(),tileMat3:tt()}}setTransform(e){super.setTransform(e);const t=this.resolution/(e.resolution*e.pixelRatio),s=this.transforms.tileMat3,[o,i]=this.tileData.offset,a=[this.x+o*this.resolution,this.y-i*this.resolution],[n,l]=e.toScreenNoRotation([0,0],a),{symbolTileSize:u}=this.tileData.symbolizerParameters,h=Math.round((this.width-this.tileData.offset[0])/u)*u,p=Math.round((this.height-this.tileData.offset[1])/u)*u,g=h/this.rangeX*t,f=p/this.rangeY*t;wi(s,g,0,0,0,f,0,n,l,1),fs(this.transforms.displayViewScreenMat3,e.displayViewMat3,s),this.tileData.transforms.displayViewScreenMat3=this.transforms.displayViewScreenMat3}onAttach(){this.tileData.stage=this.stage}onDetach(){this.tileData.stage=null}}
11class Io extends Ts{constructor(){super(...arguments),this.isCustomTilingScheme=!1,this.symbolTypes=["triangle"]}createTile(e){const t=this.tileInfoView.getTileBounds(xs(),e),[s,o]=this.tileInfoView.tileInfo.size,i=this.tileInfoView.getTileResolution(e.level);return new Fo(e,i,t[0],t[3],s,o)}prepareRenderPasses(e){const t=e.registerRenderPass({name:"imagery (vf tile)",brushes:[vi],target:()=>this.children.map(s=>s.tileData),drawPhase:1});return[...super.prepareRenderPasses(e),t]}doRender(e){this.visible&&e.drawPhase===1&&this.symbolTypes.forEach(t=>{e.renderPass=t,super.doRender(e)})}}let ze=class extends G{constructor(){super(...arguments),this._handle=null,this.type="rasterVF"}async fetchTile(r,e){var s;e={...e,interpolation:"nearest",requestProjectedLocalDirections:!0};const t=await this.layer.fetchTile(r.level,r.row,r.col,e);return((s=this.layer.serviceRasterInfo)==null?void 0:s.dataType)==="vector-magdir"&&(t!=null&&t.pixelBlock)&&(t.pixelBlock=await this.layer.convertVectorFieldData(t.pixelBlock,"vector-magdir",e)),t}updateTileSource(r,e){const t=e.symbolizerParams,{tileData:s}=r;s.key=r.key,s.width=this._tileInfoView.tileInfo.size[0],s.height=this._tileInfoView.tileInfo.size[1];const{symbolTileSize:o}=t,{source:i}=e;if(s.offset=this._getTileSymbolOffset(s.key,o),(i==null?void 0:i.pixelBlock)!=null){const a={extent:i.extent,pixelBlock:i.pixelBlock};s.rawPixelData=a,s.symbolizerParameters=t,s.source=this._sampleVectorFieldData(i.pixelBlock,t,s.offset)}else{const a=[Math.round((this._tileInfoView.tileInfo.size[0]-s.offset[0])/o),Math.round((this._tileInfoView.tileInfo.size[1]-s.offset[1])/o)],n=this.createEmptyTilePixelBlock(a);s.source=n,s.symbolizerParameters=t}return s.invalidateVAO(),Promise.resolve()}updateTileSymbolizerParameters(r,e){var n;const t=e.local,{symbolTileSize:s}=t,{tileData:o}=r;o.offset=this._getTileSymbolOffset(o.key,s);const i=o.symbolizerParameters.symbolTileSize;o.symbolizerParameters=t;const a=(n=o.rawPixelData)==null?void 0:n.pixelBlock;return a!=null&&i!==s&&(o.source=this._sampleVectorFieldData(a,o.symbolizerParameters,o.offset)),Promise.resolve()}attach(){super.attach(),this.container=new Io(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this._updateSymbolType(this.layer.renderer),this._handle=He(()=>this.layer.renderer,r=>this._updateSymbolType(r))}detach(){var r;super.detach(),this.container.removeAllChildren(),(r=this._handle)==null||r.remove(),this._handle=null,this.container=null}_getTileSymbolOffset(r,e){const t=r.col*this._tileInfoView.tileInfo.size[0]%e,s=r.row*this._tileInfoView.tileInfo.size[1]%e;return[t>e/2?e-t:-t,s>e/2?e-s:-s]}_sampleVectorFieldData(r,e,t){const{symbolTileSize:s}=e;return Fi(r,"vector-uv",s,t)}_updateSymbolType(r){(r==null?void 0:r.type)==="vector-field"&&(this.container.symbolTypes=r.style==="wind-barb"?["scalar","triangle"]:r.style==="simple-scalar"?["scalar"]:["triangle"])}};c([F()],ze.prototype,"container",void 0),c([F()],ze.prototype,"layer",void 0),c([F()],ze.prototype,"type",void 0),ze=c([it("esri.views.2d.layers.imagery.VectorFieldTileView2D")],ze);const zo=r=>{const e=r;let t=class extends e{constructor(...s){super(...s),this.layer=null,this.tileInfo=null}get fullExtent(){try{return this.layer.loaded?this._getFullExtent():null}catch{return null}}get timeExtent(){var s;return Sr(this.layer,(s=this.view)==null?void 0:s.timeExtent,this._get("timeExtent"))}get hasTilingEffects(){const{renderer:s}=this.layer;return!!((s==null?void 0:s.type)==="raster-stretch"&&s.dynamicRangeAdjustment&&!(s.stretchType==="min-max"||s.stretchType==="standard-deviation"))}get datumTransformation(){try{return this.layer.loaded?wr(this.layer.fullExtent,this.view.spatialReference,!0):null}catch{return null}}supportsSpatialReference(s){try{return!this.layer.loaded||!!ds(this.layer.serviceRasterInfo,s)}catch{return!1}}async fetchPopupFeaturesAtLocation(s,o){var f,y;const{layer:i}=this;if(!s)throw new bi("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:i});const{popupEnabled:a}=i,n=Rr(i,o);if(!a||n==null)return[];const l=[],{value:u,magdirValue:h,processedValue:p}=await i.identify(s,{timeExtent:this.timeExtent,signal:o==null?void 0:o.signal});let g="";if(u!=null&&u.length){g=i.type==="imagery-tile"&&i.hasStandardTime()&&u[0]!=null?u.map(je=>i.getStandardTimeValue(je)).join(", "):u.join(", ");const w={ObjectId:0};w[Ue.servicePixelValue]=i.type==="imagery-tile"&&ws(i.raster)?p==null?void 0:p.join(", "):g,w[Ue.rawServicePixelValue]=g;const T=((f=i.raster)==null?void 0:f.rasterInfo)??i.serviceRasterInfo,P=T==null?void 0:T.attributeTable;if(P!=null){const{fields:je,features:Dt}=P,ut=je.find(({name:re})=>re.toLowerCase()==="value"),kt=w[Ue.servicePixelValue],Te=ut?Dt.find(re=>String(re.attributes[ut.name])===kt):null;if(Te)for(const re in Te.attributes)Te.attributes.hasOwnProperty(re)&&(w[vr+re]=Te.attributes[re])}const S=T==null?void 0:T.dataType;S!=="vector-magdir"&&S!=="vector-uv"||(w[Ue.magnitude]=h==null?void 0:h[0],w[Ue.direction]=h==null?void 0:h[1]);const{multidimensionalDefinition:O}=this.layer.normalizeRasterFetchOptions({timeExtent:this.timeExtent});Cr(i.rasterFields,w,O);const{graphicOrigin:K}=i,pe=new Tr({geometry:(y=this.fullExtent)==null?void 0:y.clone(),attributes:w,layer:i,origin:K,sourceLayer:i});l.push(pe)}return l}async getSourceScale(){return await this.layer.load(),br(this.layer.serviceRasterInfo,this.view.spatialReference)}_getFullExtent(){return ds(this.layer.serviceRasterInfo,this.view.spatialReference)}};return c([F()],t.prototype,"fullExtent",null),c([F()],t.prototype,"layer",void 0),c([F({readOnly:!0})],t.prototype,"timeExtent",null),c([F()],t.prototype,"tileInfo",void 0),c([F({readOnly:!0})],t.prototype,"hasTilingEffects",null),c([F()],t.prototype,"datumTransformation",null),t=c([it("esri.views.layers.ImageryTileLayerView")],t),t};let be=class extends zo(Fr(Si(Pr))){constructor(){super(...arguments),this._useWebGLForProcessing=!0,this._useProgressiveUpdate=!0,this._pixelHighlights=[],this.subview=null}get useWebGLForProcessing(){return this._useWebGLForProcessing}set useWebGLForProcessing(r){this._useWebGLForProcessing=r,this.subview&&"useWebGLForProcessing"in this.subview&&(this.subview.useWebGLForProcessing=r)}get useProgressiveUpdate(){return this._useWebGLForProcessing}set useProgressiveUpdate(r){this._useProgressiveUpdate=r,this.subview&&"useProgressiveUpdate"in this.subview&&(this.subview.useProgressiveUpdate=r)}get displayParameters(){const{layer:r}=this,e=this._get("displayParameters");return r.renderer&&r.visible?{bandIds:r.bandIds,renderer:r.renderer,interpolation:r.interpolation,multidimensionalDefinition:r.multidimensionalDefinition,rasterFu
11nction:r.type==="imagery-tile"?r.rasterFunction:null}:e}update(r){var e;(e=this.subview)==null||e.update(r),this.notifyChange("updating")}isUpdating(){return!this.subview||this.subview.updating}attach(){this.layer.increaseRasterJobHandlerUsage(),this._updateSubview(),this.addAttachHandles([He(()=>this.displayParameters,(r,e)=>{var u,h,p,g;const t=r.interpolation!==(e==null?void 0:e.interpolation)&&(r.interpolation==="majority"||(e==null?void 0:e.interpolation)==="majority")&&bs(this.layer),s=!!((h=(u=this.layer.serviceRasterInfo)==null?void 0:u.storageInfo)!=null&&h.isBsqTile)&&((p=r.bandIds)==null?void 0:p.join())!==((g=e==null?void 0:e.bandIds)==null?void 0:g.join()),o=r.renderer!==(e==null?void 0:e.renderer)&&this._getSubviewType(e==null?void 0:e.renderer)!==this._getSubviewType(r.renderer);o&&this._updateSubview();const i=r.multidimensionalDefinition!==(e==null?void 0:e.multidimensionalDefinition),a=r.rasterFunction!==(e==null?void 0:e.rasterFunction),n=a&&!this._useWebGLForProcessing,l=i||t||o||n||s;this.subview.redrawOrRefetch({refetch:l,reprocess:a}).catch(f=>{Ke(f)||et.getLogger(this).error(f)}),this.notifyChange("updating")}),He(()=>this.layer.multidimensionalSubset??null,(r,e)=>{const{multidimensionalDefinition:t}=this.layer;t!=null&&as(t,r)!==as(t,e)&&(this.subview.redrawOrRefetch({refetch:!0}).catch(s=>{Ke(s)||et.getLogger(this).error(s)}),this.notifyChange("updating"))},_i),He(()=>this.timeExtent,()=>{this.subview.timeExtent=this.timeExtent,this.subview.redrawOrRefetch({refetch:!0}).catch(r=>{Ke(r)||et.getLogger(this).error(r)})},rs),He(()=>this.view.highlights.items.map(({name:r,color:e})=>({name:r,color:e})),()=>this._updateHighlightOptions(this.subview),rs)])}detach(){var r;this.layer.decreaseRasterJobHandlerUsage(),this._detachSubview(this.subview),(r=this.subview)==null||r.destroy(),this.subview=null}viewChange(){this.requestUpdate()}moveEnd(){this.subview.moveEnd()}highlight(r,e){var s;if(!((s=r.pixelRanges)!=null&&s.length))return os();const t={target:{...r},options:{...e}};return this._pixelHighlights.push(t),this._updateHighlightOptions(this.subview),os(()=>{const o=this._pixelHighlights.indexOf(t);o!==-1&&(this._pixelHighlights.splice(o,1),this._updateHighlightOptions(this.subview))})}doRefresh(){return this.subview?this.subview.doRefresh():Promise.resolve()}_updateSubview(){var o;const{renderer:r}=this.layer;if(!r)return;const e=this._getSubviewType(r);if(this.subview){if(this.subview.type===e)return void this._attachSubview(this.subview);this._detachSubview(this.subview),(o=this.subview)==null||o.destroy(),this.subview=null}const{layer:t}=this;let s;if(s=e==="rasterVF"?new ze({layer:t,layerView:this,scheduler:this.scheduler}):e==="flow"?new Ci({layer:t,layerView:this,scheduler:this.scheduler}):new we({layer:t,layerView:this,scheduler:this.scheduler}),"useWebGLForProcessing"in s&&(s.useWebGLForProcessing=this._useWebGLForProcessing),"useProgressiveUpdate"in s&&(s.useProgressiveUpdate=this._useProgressiveUpdate),"previousLOD"in s){const{subview:i}=this;s.previousLOD=i&&"previousLOD"in i?i.previousLOD:null}this._attachSubview(s),this._updateHighlightOptions(s),this.subview=s,this.requestUpdate()}_attachSubview(r){r&&!r.attached&&(r.attach(),r.attached=!0,this.container.addChildAt(r.container,0))}_detachSubview(r){r!=null&&r.attached&&(this.container.removeChild(r.container),r.detach(),r.attached=!1)}_getSubviewType(r){const e=r==null?void 0:r.type;return e==="vector-field"?"rasterVF":e==="flow"?"flow":"raster"}_updateHighlightOptions(r){(r==null?void 0:r.type)==="raster"&&r.updateHighlightOptions(this._pixelHighlights)}};c([F()],be.prototype,"subview",void 0),c([F()],be.prototype,"useWebGLForProcessing",null),c([F()],be.prototype,"useProgressiveUpdate",null),c([F({readOnly:!0})],be.prototype,"displayParameters",null),be=c([it("esri.views.2d.layers.ImageryTileLayerView2D")],be);const pu=be;export{pu as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.