import{_ as l,$ as p,a0 as x,cp as It,co as re,t as T,cl as Bt,a as k,e4 as tt,aY as j,eP as oe,cK as ft,eQ as ie,dN as at,k as ae,g as Ot,a7 as Mt,cA as ue}from"./index.6c049565.js";import{o as le,c as ce,a as pe,x as ht,u as he,d as fe}from"./RasterSymbolizer.04994a43.js";import{r as me,g,h as de,o as Gt,i as Lt,k as ge,y as ye,w as xe,c as Vt,x as we}from"./pixelUtils.f4eba4af.js";let ut=class extends It{constructor(){super(...arguments),this.raster=void 0}};l([p({json:{write:!0}})],ut.prototype,"raster",void 0),ut=l([x("esri.layers.support.rasterFunctions.AspectFunctionArguments")],ut);const R=ut;var mt;let dt=mt=class extends R{clone(){return new mt({raster:this.raster})}};dt=mt=l([x("esri.layers.support.rasterFunctions.AspectFunctionArguments")],dt);const Ae=dt;let B=class extends It{constructor(){super(...arguments),this.functionArguments=null,this.readingBufferSize=0}bind(t,n=!1){const a=this._getRasterValues();for(let o=0;othis._readRasterValue(a,t));return this._processPixels({...t,pixelBlocks:n})}getPrimaryRasters(){const t=[],n=[];return this._getPrimaryRasters(this,t,n),{rasters:t,rasterIds:n}}_getOutputPixelType(t){var n;return this.outputPixelType==="unknown"?t:(n=this.outputPixelType)!=null?n:t}_getRasterValues(){const{rasterArgumentNames:t}=this;return t[0]==="rasters"&&Array.isArray(this.functionArguments.rasters)?this.functionArguments.rasters:t.map(n=>this.functionArguments[n])}_getSourceRasterInfos(t){const n=this._getRasterValues(),{rasterInfos:a,rasterIds:o}=t;return n.map(r=>r&&typeof r=="object"&&"bind"in r&&r.rasterInfo?r.rasterInfo:typeof r=="string"&&o.includes(r)?a[o.indexOf(r)]:a[0])}_getPrimaryRasterId(t){return t==null?void 0:t.url}_getPrimaryRasters(t,n=[],a=[]){for(let o=0;or),s}return t.process(n)}};l([p({json:{write:!0}})],B.prototype,"functionName",void 0),l([p({json:{write:!0}})],B.prototype,"functionArguments",void 0),l([p()],B.prototype,"rasterArgumentNames",void 0),l([p({json:{write:!0}}),re(t=>t==null?void 0:t.toLowerCase())],B.prototype,"outputPixelType",void 0),l([p({json:{write:!0}})],B.prototype,"mainPrimaryRasterId",void 0),l([p()],B.prototype,"sourceRasters",void 0),l([p({json:{write:!0}})],B.prototype,"sourceRasterInfos",void 0),l([p({json:{write:!0}})],B.prototype,"rasterInfo",void 0),l([p({json:{write:!0}})],B.prototype,"readingBufferSize",void 0),B=l([x("esri.layers.support.rasterFunctions.BaseRasterFunction")],B);const I=B;let C=class extends I{constructor(){super(...arguments),this.functionName="Aspect",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){const t=this.sourceRasterInfos[0];this.isGCS=t.spatialReference.isGeographic,this.outputPixelType=this._getOutputPixelType("f32");const n=t.clone();return n.pixelType=this.outputPixelType,n.statistics=null,n.histograms=null,this.rasterInfo=n,{success:!0}}_processPixels(t){var r;const n=(r=t.pixelBlocks)==null?void 0:r[0];if(T(n))return null;const{extent:a}=t,o=a?{x:a.width/n.width,y:a.height/n.height}:{x:1,y:1};return le(n,{resolution:o})}};l([p({json:{write:!0,name:"rasterFunction"}})],C.prototype,"functionName",void 0),l([p({type:Ae,json:{write:!0,name:"rasterFunctionArguments"}})],C.prototype,"functionArguments",void 0),l([p()],C.prototype,"rasterArgumentNames",void 0),l([p({json:{write:!0}})],C.prototype,"isGCS",void 0),C=l([x("esri.layers.support.rasterFunctions.AspectFunction")],C);const ve=C,$e=new Set(["+","-","*","/","(",")"]);function Ne(t,n){(t=t.replace(/ /g,"")).startsWith("-")&&(t="0"+t),t.startsWith("+")&&(t=t.slice(1,t.length));const a=t.split(""),o=[],r=[];let s="";for(let i=0;i-1)a>0&&(r+=n+1);else{for(let i=0;i0&&(r+=n+1)}let s=0;for(let i=0;i0;){const{numIndex:i,opIndex:e}=Se(r);if(o=Fe(t,r[e],s[i],s[i+1]),r.length===1)break;r=be(r,e),s.splice(i,2,o)}return[o]}const Re=new Bt({0:"custom",1:"ndvi",2:"savi",3:"tsavi",4:"msavi",5:"gemi",6:"pvi",7:"gvitm",8:"sultan",9:"vari",10:"gndvi",11:"sr",12:"ndvi-re",13:"sr-re",14:"mtvi2",15:"rtvi-core",16:"ci-re",17:"ci-g",18:"ndwi",19:"evi",20:"iron-oxide",21:"ferrous-minerals",22:"clay-minerals",23:"wndwi",24:"bai",25:"nbr",26:"ndbi",27:"ndmi",28:"ndsi",29:"mndwi"},{useNumericKeys:!0});function Ie(t,n){var h;if(!me(t))return t;const{equation:a,method:o}=n,r=n.bandIndexes.map(f=>f-1),{pixels:s,mask:i}=t;let e;switch(o){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":e=Dt(i,s[r[0]],s[r[1]]);break;case"ndwi":e=Dt(i,s[r[1]],s[r[0]]);break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":e=Pe(i,s[r[0]],s[r[1]]);break;case"ci-g":case"ci-re":e=ke(i,s[r[0]],s[r[1]]);break;case"savi":e=je(i,s[r[0]],s[r[1]],r[2]+1);break;case"tsavi":e=Me(i,s[r[0]],s[r[1]],r[2]+1,r[3]+1,r[4]+1);break;case"msavi":e=De(i,s[r[0]],s[r[1]]);break;case"gemi":e=Ce(i,s[r[0]],s[r[1]]);break;case"pvi":e=Ee(i,s[r[0]],s[r[1]],r[2]+1,r[3]+1);break;case"gvitm":e=_e(i,[s[r[0]],s[r[1]],s[r[2]],s[r[3]],s[r[4]],s[r[5]]]);break;case"sultan":e=Oe(i,[s[r[0]],s[r[1]],s[r[2]],s[r[3]],s[r[4]],s[r[5]]]);break;case"vari":e=Ge(i,[s[r[0]],s[r[1]],s[r[2]]]);break;case"mtvi2":e=Le(i,[s[r[0]],s[r[1]],s[r[2]]]);break;case"rtvi-core":e=Ve(i,[s[r[0]],s[r[1]],s[r[2]]]);break;case"evi":e=ze(i,[s[r[0]],s[r[1]],s[r[2]]]);break;case"wndwi":e=qe(i,[s[r[0]],s[r[1]],s[r[2]]],(h=r[3])!=null?h:.5);break;case"bai":e=He(i,s[r[0]],s[r[1]]);break;case"custom":e=Te(i,s,a);break;default:return t}const u=k(i)?new Uint8Array(i.length):null;k(i)&&k(u)&&u.set(i);const c=new g({width:t.width,height:t.height,pixelType:"f32",pixels:e,mask:u});return c.updateStatistics(),c}function Be(t,n,a,o){const{mask:r,pixels:s,width:i,height:e}=t,u=s[a],c=s[n],h=c.length,f=o?new Uint8Array(h):new Float32Array(h),m=o?100:1,v=o?100:0;for(let A=0;AparseFloat(i));return Ie(n,{method:a,bandIndexes:r,equation:o})}};l([p({json:{write:!0,name:"rasterFunction"}})],U.prototype,"functionName",void 0),l([p({type:Ue,json:{write:!0,name:"rasterFunctionArguments"}})],U.prototype,"functionArguments",void 0),l([p()],U.prototype,"rasterArgumentNames",void 0),U=l([x("esri.layers.support.rasterFunctions.BandArithmeticFunction")],U);const Xe=U;var yt;let M=yt=class extends R{readColorRamp(t){return ie(t)}clone(){var t;return new yt({colormap:j(this.colormap),colormapName:this.colormapName,colorRamp:(t=this.colorRamp)==null?void 0:t.clone(),colorRampName:this.colorRampName})}};l([p({type:[[Number]],json:{write:!0}})],M.prototype,"colormap",void 0),l([p({type:String,json:{write:!0}})],M.prototype,"colormapName",void 0),l([p({types:oe,json:{write:!0}})],M.prototype,"colorRamp",void 0),l([ft("colorRamp")],M.prototype,"readColorRamp",null),l([p({type:String,json:{write:!0}})],M.prototype,"colorRampName",void 0),M=yt=l([x("esri.layers.support.rasterFunctions.ColormapFunctionArguments")],M);const We=M;let E=class extends I{constructor(){super(...arguments),this.functionName="Colormap",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const t=this.sourceRasterInfos[0];if(t.bandCount>1)return{success:!1,error:"colormap-function: source data must be single band"};let{colormap:n,colorRamp:a}=this.functionArguments;if(n!=null&&n.length||a&&(n=ce(a,256,!0)),!(n!=null&&n.length))return{success:!1,error:"colormap-function: missing colormap argument"};this.outputPixelType=this._getOutputPixelType("u8");const o=t.clone();return o.pixelType=this.outputPixelType,o.colormap=n,this.rasterInfo=o,{success:!0}}_processPixels(t){var n;return(n=t.pixelBlocks)==null?void 0:n[0]}};l([p({json:{write:!0,name:"rasterFunction"}})],E.prototype,"functionName",void 0),l([p({type:We,json:{write:!0,name:"rasterFunctionArguments"}})],E.prototype,"functionArguments",void 0),l([p()],E.prototype,"rasterArgumentNames",void 0),l([p({json:{write:!0}})],E.prototype,"indexedColormap",void 0),E=l([x("esri.layers.support.rasterFunctions.ColormapFunction")],E);const Ye=E;var xt;let nt=xt=class extends R{writeRasters(t,n){n.rasters=t.map(a=>typeof a=="number"||typeof a=="string"?a:a.toJSON())}clone(){return new xt({rasters:j(this.rasters)})}};l([p({json:{write:!0}})],nt.prototype,"rasters",void 0),l([at("rasters")],nt.prototype,"writeRasters",null),nt=xt=l([x("esri.layers.support.rasterFunctions.CompositeBandFunctionArguments")],nt);const Je=nt;let X=class extends I{constructor(){super(...arguments),this.functionName="CompositeBand",this.functionArguments=null,this.rasterArgumentNames=["rasters"]}_bindSourceRasters(){const{sourceRasterInfos:t}=this,n=t[0];this.outputPixelType=this._getOutputPixelType(n.pixelType);const a=n.clone();if(a.attributeTable=null,a.colormap=null,a.pixelType=this.outputPixelType,a.bandCount=t.map(({bandCount:o})=>o).reduce((o,r)=>o+r),t.every(({statistics:o})=>k(o)&&o.length)){const o=[];t.forEach(({statistics:r})=>k(r)&&o.push(...r)),a.statistics=o}if(t.every(({histograms:o})=>k(o)&&o.length)){const o=[];t.forEach(({histograms:r})=>k(r)&&o.push(...r)),a.histograms=o}return this.rasterInfo=a,{success:!0}}_processPixels(t){const{pixelBlocks:n}=t;if(!n)return null;const a=n==null?void 0:n[0];return T(a)?null:de(n)}};l([p({json:{write:!0,name:"rasterFunction"}})],X.prototype,"functionName",void 0),l([p({type:Je,json:{write:!0,name:"rasterFunctionArguments"}})],X.prototype,"functionArguments",void 0),l([p()],X.prototype,"rasterArgumentNames",void 0),X=l([x("esri.layers.support.rasterFunctions.CompositeBandFunction")],X);const Ke=X;var y;(function(t){t[t.UserDefined=-1]="UserDefined",t[t.LineDetectionHorizontal=0]="LineDetectionHorizontal",t[t.LineDetectionVertical=1]="LineDetectionVertical",t[t.LineDetectionLeftDiagonal=2]="LineDetectionLeftDiagonal",t[t.LineDetectionRightDiagonal=3]="LineDetectionRightDiagonal",t[t.GradientNorth=4]="GradientNorth",t[t.GradientWest=5]="GradientWest",t[t.GradientEast=6]="GradientEast",t[t.GradientSouth=7]="GradientSouth",t[t.GradientNorthEast=8]="GradientNorthEast",t[t.GradientNorthWest=9]="GradientNorthWest",t[t.SmoothArithmeticMean=10]="SmoothArithmeticMean",t[t.Smoothing3x3=11]="Smoothing3x3",t[t.Smoothing5x5=12]="Smoothing5x5",t[t.Sharpening3x3=13]="Sharpening3x3",t[t.Sharpening5x5=14]="Sharpening5x5",t[t.Laplacian3x3=15]="Laplacian3x3",t[t.Laplacian5x5=16]="Laplacian5x5",t[t.SobelHorizontal=17]="SobelHorizontal",t[t.SobelVertical=18]="SobelVertical",t[t.Sharpen=19]="Sharpen",t[t.Sharpen2=20]="Sharpen2",t[t.PointSpread=21]="PointSpread",t[t.None=255]="None"})(y||(y={}));const $=new Map;function Qe(t){const n=Math.sqrt(t.length),a=t.slice(0,n),o=[1];for(let r=1;re+u);return s!==0&&s!==1&&(a=a.map(e=>e/s)),nn(n,{kernel:a,rows:o,cols:r,outputPixelType:this.outputPixelType})}};l([p({json:{write:!0,name:"rasterFunction"}})],W.prototype,"functionName",void 0),l([p({type:sn,json:{write:!0,name:"rasterFunctionArguments"}})],W.prototype,"functionArguments",void 0),l([p()],W.prototype,"rasterArgumentNames",void 0),W=l([x("esri.layers.support.rasterFunctions.ConvolutionFunction")],W);const rn=W;var At;let st=At=class extends R{constructor(){super(...arguments),this.bandIDs=[],this.missingBandAction=Gt.bestMatch}clone(){return new At({bandIDs:[...this.bandIDs],missingBandAction:this.missingBandAction})}};l([p({json:{write:!0}})],st.prototype,"bandIDs",void 0),l([p({json:{write:!0}})],st.prototype,"missingBandAction",void 0),st=At=l([x("esri.layers.support.rasterFunctions.ExtractBandFunctionArguments")],st);const on=st;let Y=class extends I{constructor(){super(...arguments),this.functionName="ExtractBand",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{sourceRasterInfos:t}=this,n=t[0],{bandCount:a}=n,{bandIDs:o,missingBandAction:r}=this.functionArguments;if(r===Gt.fail&&o.some(u=>u<0||u>=a))return{success:!1,error:"extract-band-function: invalid bandIDs"};this.outputPixelType=this._getOutputPixelType("f32");const s=n.clone();s.pixelType=this.outputPixelType;const{statistics:i,histograms:e}=s;return k(i)&&i.length&&(s.statistics=o.map(u=>i[u]||i[i.length-1])),k(e)&&e.length&&(s.histograms=o.map(u=>e[u]||e[e.length-1])),this.rasterInfo=s,{success:!0}}_processPixels(t){var r;const n=(r=t.pixelBlocks)==null?void 0:r[0];if(T(n))return null;const a=n.pixels.length,o=this.functionArguments.bandIDs.map(s=>s>=a?a-1:s);return n.extractBands(o)}};l([p({json:{write:!0,name:"rasterFunction"}})],Y.prototype,"functionName",void 0),l([p({type:on,json:{write:!0,name:"rasterFunctionArguments"}})],Y.prototype,"functionArguments",void 0),l([p()],Y.prototype,"rasterArgumentNames",void 0),Y=l([x("esri.layers.support.rasterFunctions.ExtractBandFunction")],Y);const an=Y;var vt;let O=vt=class extends R{constructor(){super(...arguments),this.rasters=[],this.processAsMultiband=!1}writeRasters(t,n){n.rasters=t.map(a=>typeof a=="number"||typeof a=="string"?a:a.toJSON())}clone(){return new vt({method:this.operation,processAsMultiband:this.processAsMultiband,rasters:j(this.rasters)})}};l([p({json:{write:!0}})],O.prototype,"operation",void 0),l([p({json:{write:!0}})],O.prototype,"rasters",void 0),l([at("rasters")],O.prototype,"writeRasters",null),l([p({json:{write:!0}})],O.prototype,"processAsMultiband",void 0),O=vt=l([x("esri.layers.support.rasterFunctions.LocalFunctionArguments")],O);const un=O;var ct;(function(t){t[t.Plus=1]="Plus",t[t.Minus=2]="Minus",t[t.Times=3]="Times",t[t.SquareRoot=4]="SquareRoot",t[t.Power=5]="Power",t[t.ACos=6]="ACos",t[t.ASin=7]="ASin",t[t.ATan=8]="ATan",t[t.ATanH=9]="ATanH",t[t.Abs=10]="Abs",t[t.BitwiseAnd=11]="BitwiseAnd",t[t.BitwiseLeftShift=12]="BitwiseLeftShift",t[t.BitwiseNot=13]="BitwiseNot",t[t.BitwiseOr=14]="BitwiseOr",t[t.BitwiseRightShift=15]="BitwiseRightShift",t[t.BitwiseXOr=16]="BitwiseXOr",t[t.BooleanAnd=17]="BooleanAnd",t[t.BooleanNot=18]="BooleanNot",t[t.BooleanOr=19]="BooleanOr",t[t.BooleanXOr=20]="BooleanXOr",t[t.Cos=21]="Cos",t[t.CosH=22]="CosH",t[t.Divide=23]="Divide",t[t.EqualTo=24]="EqualTo",t[t.Exp=25]="Exp",t[t.Exp10=26]="Exp10",t[t.Exp2=27]="Exp2",t[t.GreaterThan=28]="GreaterThan",t[t.GreaterThanEqual=29]="GreaterThanEqual",t[t.Int=30]="Int",t[t.IsNull=31]="IsNull",t[t.Float=32]="Float",t[t.LessThan=33]="LessThan",t[t.LessThanEqual=34]="LessThanEqual",t[t.Ln=35]="Ln",t[t.Log10=36]="Log10",t[t.Log2=37]="Log2",t[t.Majority=38]="Majority",t[t.Max=39]="Max",t[t.Mean=40]="Mean",t[t.Med=41]="Med",t[t.Min=42]="Min",t[t.Minority=43]="Minority",t[t.Mod=44]="Mod",t[t.Negate=45]="Negate",t[t.NotEqual=46]="NotEqual",t[t.Range=47]="Range",t[t.RoundDown=48]="RoundDown",t[t.RoundUp=49]="RoundUp",t[t.SetNull=50]="SetNull",t[t.Sin=51]="Sin",t[t.SinH=52]="SinH",t[t.Square=53]="Square",t[t.Std=54]="Std",t[t.Sum=55]="Sum",t[t.Tan=56]="Tan",t[t.TanH=57]="TanH",t[t.Variety=58]="Variety",t[t.ACosH=59]="ACosH",t[t.ASinH=60]="ASinH",t[t.ATan2=61]="ATan2",t[t.FloatDivide=64]="FloatDivide",t[t.FloorDivide=65]="FloorDivide",t[t.MajorityIgnoreNoData=66]="MajorityIgnoreNoData",t[t.MaxIgnoreNoData=67]="MaxIgnoreNoData",t[t.MeanIgnoreNoData=68]="MeanIgnoreNoData",t[t.MedIgnoreNoData=69]="MedIgnoreNoData",t[t.MinIgnoreNoData=70]="MinIgnoreNoData",t[t.MinorityIgnoreNoData=71]="MinorityIgnoreNoData",t[t.RangeIgnoreNoData=72]="RangeIgnoreNoData",t[t.StdIgnoreNoData=73]="StdIgnoreNoData",t[t.SumIgnoreNoData=74]="SumIgnoreNoData",t[t.VarietyIgnoreNoData=75]="VarietyIgnoreNoData",t[t.Con=76]="Con"})(ct||(ct={}));function ln(t){const n=t.map(i=>i.mask).filter(i=>k(i));if(n.length===0)return null;const a=n[0].length,o=new Uint8Array(a);if(n.length===1)return o.set(n[0]),o;let r,s=n[0];for(let i=1;i>r[e]);return i}function $n(t,n,a){const[o,r]=t,s=o.length,i=g.createEmptyBand(a,s);for(let e=0;er[e]?1:0);return i}function Pn(t,n,a){const[o,r]=t,s=o.length,i=g.createEmptyBand(a,s);for(let e=0;e=r[e]?1:0);return i}function kn(t,n,a){const[o,r]=t,s=o.length,i=g.createEmptyBand(a,s);for(let e=0;ec[e]&&(i[e]=c[e])}return i}function Wt(t,n,a){const o=t.length;if(o<2)return t[0];const[r]=t,s=r.length,i=g.createEmptyBand(a,s);i.set(r);for(let e=0;eh[e]&&(u=h[e])}i[e]-=u}return i}function Yt(t,n,a){const o=t.length;if(o<2)return t[0];const[r]=t,s=r.length,i=g.createEmptyBand(a,s);i.set(r);for(let e=0;ef&&(f=h,c=m);i[u]=c}return i}function te(t,n,a){const o=t.length;if(o<2)return t[0];const[r]=t,s=r.length,i=g.createEmptyBand(a,s),e=new Map;for(let u=0;uv.pixels[h]);let m;if(n===ct.SetNull){const v=_n(f,o,s);m=v.band,u=v.mask}else d.has(n)?m=d.get(n)(f,o,s):N.has(n)?m=gn(f,o,s,N.get(n)):pt.has(n)&&(m=yn(f,o,s,pt.get(n)));if(m==null)return null;e.push(m)}u||n===ct.IsNull||(u=o);const c=t[0];return new g({width:c.width,height:c.height,pixelType:s,mask:u,pixels:e})}let J=class extends I{constructor(){super(...arguments),this.functionName="Local",this.functionArguments=null,this.rasterArgumentNames=["rasters"]}_bindSourceRasters(){const{sourceRasterInfos:t}=this,n=t[0],{bandCount:a}=n,{processAsMultiband:o}=this.functionArguments;if(o&&t.some(s=>s.bandCount!==a))return{success:!1,error:"local-function: input rasters do not have same band count"};this.outputPixelType=this._getOutputPixelType("f32");const r=n.clone();return r.pixelType=this.outputPixelType,r.statistics=null,r.histograms=null,o||(r.bandCount=1),this.rasterInfo=r,{success:!0}}_processPixels(t){var a;const{pixelBlocks:n}=t;return T(n)||n.some(o=>T(o))?null:Kn(n,this.functionArguments.operation,{processAsMultiband:this.functionArguments.processAsMultiband,outputPixelType:(a=this.outputPixelType)!=null?a:void 0})}};l([p({json:{write:!0,name:"rasterFunction"}})],J.prototype,"functionName",void 0),l([p({type:un,json:{write:!0,name:"rasterFunctionArguments"}})],J.prototype,"functionArguments",void 0),l([p()],J.prototype,"rasterArgumentNames",void 0),J=l([x("esri.layers.support.rasterFunctions.LocalFunction")],J);const Qn=J;var $t;let K=$t=class extends R{constructor(){super(...arguments),this.includedRanges=null,this.noDataValues=null,this.noDataInterpretation=Lt.matchAny}clone(){var t,n,a,o;return new $t({includedRanges:(n=(t=this.includedRanges)==null?void 0:t.slice())!=null?n:[],noDataValues:(o=(a=this.noDataValues)==null?void 0:a.slice())!=null?o:[],noDataInterpretation:this.noDataInterpretation})}};l([p({json:{write:!0}})],K.prototype,"includedRanges",void 0),l([p({json:{write:!0}})],K.prototype,"noDataValues",void 0),l([p({json:{write:!0}})],K.prototype,"noDataInterpretation",void 0),K=$t=l([x("esri.layers.support.rasterFunctions.MaskFunctionArguments")],K);const Zn=K;let G=class extends I{constructor(){super(...arguments),this.functionName="Mask",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:n}=t;this.outputPixelType=this._getOutputPixelType(n),t.pixelType=this.outputPixelType,this.rasterInfo=t;const{includedRanges:a,noDataValues:o}=this.functionArguments;return(a==null?void 0:a.length)||(o==null?void 0:o.length)?(this.lookup=ge(n,this.functionArguments.includedRanges,this.functionArguments.noDataValues),{success:!0}):{success:!1,error:"missing includedRanges or noDataValues argument"}}_processPixels(t){var u;const n=(u=t.pixelBlocks)==null?void 0:u[0];if(T(n))return null;const{outputPixelType:a,lookup:o}=this,{includedRanges:r,noDataValues:s,noDataInterpretation:i}=this.functionArguments,e=i===Lt.matchAll;return ye(n,{includedRanges:r,noDataValues:s,outputPixelType:a,matchAll:e,lookup:o})}};l([p({json:{write:!0,name:"rasterFunction"}})],G.prototype,"functionName",void 0),l([p({type:Zn,json:{write:!0,name:"rasterFunctionArguments"}})],G.prototype,"functionArguments",void 0),l([p()],G.prototype,"rasterArgumentNames",void 0),l([p({json:{write:!0}})],G.prototype,"lookup",void 0),G=l([x("esri.layers.support.rasterFunctions.MaskFunction")],G);const ts=G;var Nt;let Q=Nt=class extends R{constructor(){super(...arguments),this.visibleBandID=0,this.infraredBandID=1,this.scaled=!0}clone(){const{visibleBandID:t,infraredBandID:n,scaled:a}=this;return new Nt({visibleBandID:t,infraredBandID:n,scaled:a})}};l([p({json:{write:!0}})],Q.prototype,"visibleBandID",void 0),l([p({json:{write:!0}})],Q.prototype,"infraredBandID",void 0),l([p({json:{write:!0}})],Q.prototype,"scaled",void 0),Q=Nt=l([x("esri.layers.support.rasterFunctions.NDVIFunctionArguments")],Q);const es=Q;let Z=class extends I{constructor(){super(...arguments),this.functionName="NDVI",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{scaled:t}=this.functionArguments;this.outputPixelType=this._getOutputPixelType(t?"u8":"f32");const n=this.sourceRasterInfos[0].clone();n.pixelType=this.outputPixelType,n.colormap=null,n.histograms=null;const[a,o,r,s]=t?[0,200,100,10]:[-1,1,0,.1];return n.statistics=[{min:a,max:o,avg:r,stddev:s}],this.rasterInfo=n,{success:!0}}_processPixels(t){var s;const n=(s=t.pixelBlocks)==null?void 0:s[0];if(T(n))return null;const{visibleBandID:a,infraredBandID:o,scaled:r}=this.functionArguments;return Be(n,a,o,r)}};l([p({json:{write:!0,name:"rasterFunction"}})],Z.prototype,"functionName",void 0),l([p({type:es,json:{write:!0,name:"rasterFunctionArguments"}})],Z.prototype,"functionArguments",void 0),l([p()],Z.prototype,"rasterArgumentNames",void 0),Z=l([x("esri.layers.support.rasterFunctions.NDVIFunction")],Z);const ns=Z;var Ft;let L=Ft=class extends R{constructor(){super(...arguments),this.inputRanges=null,this.outputValues=null,this.noDataRanges=null,this.allowUnmatched=!1}clone(){return new Ft({inputRanges:[...this.inputRanges],outputValues:[...this.outputValues],noDataRanges:[...this.noDataRanges],allowUnmatched:this.allowUnmatched})}};l([p({json:{write:!0}})],L.prototype,"inputRanges",void 0),l([p({json:{write:!0}})],L.prototype,"outputValues",void 0),l([p({json:{write:!0}})],L.prototype,"noDataRanges",void 0),l([p({json:{write:!0}})],L.prototype,"allowUnmatched",void 0),L=Ft=l([x("esri.layers.support.rasterFunctions.RemapFunctionArguments")],L);const ss=L;let V=class extends I{constructor(){super(...arguments),this.functionName="Remap",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:n}=t;this.outputPixelType=this._getOutputPixelType(n),t.pixelType=this.outputPixelType,t.colormap=null,t.histograms=null;const{statistics:a}=t,{allowUnmatched:o,outputValues:r}=this.functionArguments;if(k(a)&&a.length&&!o){let s=r[0],i=s;for(let e=0;er[e]?r[e]:s,i=i>r[e]?i:r[e];for(let e=0;e({min:r,max:s,avg:i,stddev:e}))),this.rasterInfo=n,{success:!0}}_processPixels(t){var n;return(n=t.pixelBlocks)==null?void 0:n[0]}};l([p({json:{write:!0,name:"rasterFunction"}})],H.prototype,"functionName",void 0),l([p({type:us,json:{write:!0,name:"rasterFunctionArguments"}})],H.prototype,"functionArguments",void 0),l([p()],H.prototype,"rasterArgumentNames",void 0),l([p({json:{write:!0}})],H.prototype,"indexedColormap",void 0),H=l([x("esri.layers.support.rasterFunctions.StatisticsHistogramsFunction")],H);const ls=H;var Tt;const cs=new Bt({0:"none",3:"standard-deviation",4:"histogram-equalization",5:"min-max",6:"percent-clip",7:"sigmoid"},{useNumericKeys:!0});let b=Tt=class extends R{constructor(){super(...arguments),this.computeGamma=!1,this.dynamicRangeAdjustment=!1,this.gamma=[],this.histograms=null,this.statistics=null,this.stretchType="none",this.useGamma=!1}writeStatistics(t,n,a){t!=null&&t.length&&(Array.isArray(t[0])||(t=t.map(o=>[o.min,o.max,o.avg,o.stddev])),n[a]=t)}clone(){return new Tt({stretchType:this.stretchType,outputMin:this.outputMin,outputMax:this.outputMax,useGamma:this.useGamma,computeGamma:this.computeGamma,statistics:j(this.statistics),gamma:j(this.gamma),sigmoidStrengthLevel:this.sigmoidStrengthLevel,numberOfStandardDeviations:this.numberOfStandardDeviations,minPercent:this.minPercent,maxPercent:this.maxPercent,histograms:j(this.histograms),dynamicRangeAdjustment:this.dynamicRangeAdjustment,raster:this.raster})}};l([p({type:Boolean,json:{write:!0}})],b.prototype,"computeGamma",void 0),l([p({type:Boolean,json:{name:"dra",write:!0}})],b.prototype,"dynamicRangeAdjustment",void 0),l([p({type:[Number],json:{write:!0}})],b.prototype,"gamma",void 0),l([p()],b.prototype,"histograms",void 0),l([p({type:Number,json:{write:!0}})],b.prototype,"maxPercent",void 0),l([p({type:Number,json:{write:!0}})],b.prototype,"minPercent",void 0),l([p({type:Number,json:{write:!0}})],b.prototype,"numberOfStandardDeviations",void 0),l([p({type:Number,json:{name:"max",write:!0}})],b.prototype,"outputMax",void 0),l([p({type:Number,json:{name:"min",write:!0}})],b.prototype,"outputMin",void 0),l([p({type:Number,json:{write:!0}})],b.prototype,"sigmoidStrengthLevel",void 0),l([p({json:{type:[[Number]],write:!0}})],b.prototype,"statistics",void 0),l([at("statistics")],b.prototype,"writeStatistics",null),l([tt(cs)],b.prototype,"stretchType",void 0),l([p({type:Boolean,json:{write:!0}})],b.prototype,"useGamma",void 0),b=Tt=l([x("esri.layers.support.rasterFunctions.StretchFunctionArguments")],b);const ps=b;let D=class extends I{constructor(){super(...arguments),this.functionName="Stretch",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null,this.cutOffs=null}_bindSourceRasters(){this.lookup=null,this.cutOffs=null;const t=this.sourceRasterInfos[0],{pixelType:n}=t,{functionArguments:a}=this,{dynamicRangeAdjustment:o,gamma:r,useGamma:s}=a;if(!o&&["u8","u16","s8","s16"].includes(n)){const e=ht(a.toJSON(),{rasterInfo:t});this.lookup=he({pixelType:n,...e,gamma:s?r:null})}else o&&(this.cutOffs=ht(a.toJSON(),{rasterInfo:t}));this.outputPixelType=this._getOutputPixelType(n);const i=t.clone();return i.pixelType=this.outputPixelType,i.statistics=null,i.histograms=null,this.outputPixelType==="u8"&&(i.keyProperties.DataType="processed"),this.rasterInfo=i,{success:!0}}_processPixels(t){var i;const n=(i=t.pixelBlocks)==null?void 0:i[0];if(T(n))return n;const{lookup:a}=this;if(a)return Vt(n,{...a,outputPixelType:this.rasterInfo.pixelType});const{functionArguments:o}=this,r=this.cutOffs||ht(o.toJSON(),{rasterInfo:this.sourceRasterInfos[0],pixelBlock:n}),s=o.useGamma?o.gamma:null;return fe(n,{...r,gamma:s,outputPixelType:this.outputPixelType})}};l([p({json:{write:!0,name:"rasterFunction"}})],D.prototype,"functionName",void 0),l([p({type:ps,json:{write:!0,name:"rasterFunctionArguments"}})],D.prototype,"functionArguments",void 0),l([p()],D.prototype,"rasterArgumentNames",void 0),l([p({json:{write:!0}})],D.prototype,"lookup",void 0),l([p({json:{write:!0}})],D.prototype,"cutOffs",void 0),D=l([x("esri.layers.support.rasterFunctions.StretchFunction")],D);const hs=D,S=new Map;function $s(t,n){if("rasterFunction"in t)return ne(t,n!=null?n:{});throw new Ot("raster-function-helper","unsupported raster function json.")}function fs(t,n){return n[0]==="rasters"&&Array.isArray(t.rasters)?t.rasters:n.map(a=>t[a])}function ne(t,n){var m,v;const{rasterFunction:a,rasterFunctionArguments:o}=t,r=(m=t.outputPixelType)==null?void 0:m.toLowerCase();if(a==null||!S.has(a))throw new Ot("raster-function-helper",`unsupported raster function: ${a}`);const s=S.get(a),i=(typeof s.ctor=="function"?s.ctor:s.ctor.default).fromJSON({...t,outputPixelType:r}),{rasterArgumentNames:e}=i,u=[],c=fs(o,e),h=e[0]==="rasters",f=[];for(let w=0;w180+this.tolerance&&(t.x-=360),t):(t.xmin>=180-this.tolerance?(t.xmax-=360,t.xmin-=360):t.xmax>180+this.tolerance&&(t.xmin=-180,t.xmax=180),t)}inverseTransform(t){return(t=t.clone()).type==="point"?(t.x<-this.tolerance&&(t.x+=360),t):(t.xmin<-this.tolerance&&(t.xmin+=360,t.xmax+=360),t)}};l([tt({GCSShiftXform:"gcs-shift"})],it.prototype,"type",void 0),l([p()],it.prototype,"tolerance",void 0),it=l([x("esri.layers.support.rasterTransforms.GCSShiftTransform")],it);const ms=it;let lt=class extends Pt{constructor(){super(...arguments),this.type="identity"}};l([tt({IdentityXform:"identity"})],lt.prototype,"type",void 0),lt=l([x("esri.layers.support.rasterTransforms.IdentityTransform")],lt);const ds=lt;function Rt(t,n,a){const{x:o,y:r}=n;if(a<2)return{x:t[0]+o*t[2]+r*t[4],y:t[1]+o*t[3]+r*t[5]};if(a===2){const m=o*o,v=r*r,w=o*r;return{x:t[0]+o*t[2]+r*t[4]+m*t[6]+w*t[8]+v*t[10],y:t[1]+o*t[3]+r*t[5]+m*t[7]+w*t[9]+v*t[11]}}const s=o*o,i=r*r,e=o*r,u=s*o,c=s*r,h=o*i,f=r*i;return{x:t[0]+o*t[2]+r*t[4]+s*t[6]+e*t[8]+i*t[10]+u*t[12]+c*t[14]+h*t[16]+f*t[18],y:t[1]+o*t[3]+r*t[5]+s*t[7]+e*t[9]+i*t[11]+u*t[13]+c*t[15]+h*t[17]+f*t[19]}}function _t(t,n,a){const{xmin:o,ymin:r,xmax:s,ymax:i,spatialReference:e}=n;let u=[];if(a<2)u.push({x:o,y:i}),u.push({x:s,y:i}),u.push({x:o,y:r}),u.push({x:s,y:r});else{let f=10;for(let m=0;mRt(t,f,a));const c=u.map(f=>f.x),h=u.map(f=>f.y);return new ue({xmin:Math.min.apply(null,c),xmax:Math.max.apply(null,c),ymin:Math.min.apply(null,h),ymax:Math.max.apply(null,h),spatialReference:e})}function gs(t){const[n,a,o,r,s,i]=t,e=o*i-s*r,u=s*r-o*i;return[(s*a-n*i)/e,(o*a-n*r)/u,i/e,r/u,-s/e,-o/u]}let P=class extends Pt{constructor(){super(...arguments),this.polynomialOrder=1,this.type="polynomial"}readForwardCoefficients(t,n){const{coeffX:a,coeffY:o}=n;if(!(a!=null&&a.length)||!(o!=null&&o.length)||a.length!==o.length)return null;const r=[];for(let s=0;s0}forwardTransform(t){if(t.type==="point"){const n=Rt(this.forwardCoefficients,t,this.polynomialOrder);return new Mt({x:n.x,y:n.y,spatialReference:t.spatialReference})}return _t(this.forwardCoefficients,t,this.polynomialOrder)}inverseTransform(t){if(t.type==="point"){const n=Rt(this.inverseCoefficients,t,this.polynomialOrder);return new Mt({x:n.x,y:n.y,spatialReference:t.spatialReference})}return _t(this.inverseCoefficients,t,this.polynomialOrder)}};l([p({json:{write:!0}})],P.prototype,"polynomialOrder",void 0),l([p()],P.prototype,"forwardCoefficients",void 0),l([ft("forwardCoefficients",["coeffX","coeffY"])],P.prototype,"readForwardCoefficients",null),l([at("forwardCoefficients")],P.prototype,"writeForwardCoefficients",null),l([p({json:{write:!0}})],P.prototype,"inverseCoefficients",null),l([ft("inverseCoefficients",["inverseCoeffX","inverseCoeffY"])],P.prototype,"readInverseCoefficients",null),l([at("inverseCoefficients")],P.prototype,"writeInverseCoefficients",null),l([p()],P.prototype,"affectsPixelSize",null),l([tt({PolynomialXform:"polynomial"})],P.prototype,"type",void 0),P=l([x("esri.layers.support.rasterTransforms.PolynomialTransform")],P);const ys=P,se={GCSShiftXform:ms,IdentityXform:ds,PolynomialXform:ys},xs=Object.keys(se);function Ns(t){const n=t==null?void 0:t.type;return!t||xs.includes(n)}function Fs(t){if(!(t==null?void 0:t.type))return null;const a=se[t==null?void 0:t.type];if(a){const o=new a;return o.read(t),o}return null}export{ms as c,Ns as f,Fs as i,$s as l,ys as m};