RasterSymbolizer.04994a43.js 110 KB

1
  1. import{g as de,bV as Wt,w as Kt,al as Yt,ck as Jt,ea as le,a as H,b1 as lt,cl as Ht,t as Fe,k as we,_ as $,$ as z,a7 as qt,a0 as Qe,cp as et,aY as te,cA as ct,aL as Xt,s as ut}from"./index.6c049565.js";import{g as oe,r as Ae,s as ft,f as $e,p as Zt,c as ht,a as Pe}from"./pixelUtils.f4eba4af.js";import{y as _e,z as dt,v as pt,p as Qt}from"./colorUtils.bb6424b7.js";var je,mt,gt,Rt={exports:{}};mt=Rt,je=function(){function e(){this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=null}return e.prototype={ensureBuffer:function(t){var r=this.buffer,c=r?r.byteLength:0;if(t<c)return r;for(var a=512;a<t;)a<<=1;for(var n=new Uint8Array(a),p=0;p<c;++p)n[p]=r[p];return this.buffer=n},getByte:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(t){var r=this.pos;if(t){this.ensureBuffer(r+t);for(var c=r+t;!this.eof&&this.bufferLength<c;)this.readBlock();var a=this.bufferLength;c>a&&(c=a)}else{for(;!this.eof;)this.readBlock();c=this.bufferLength}return this.pos=c,this.buffer.subarray(r,c)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,r,c){for(var a=t+r;this.bufferLength<=a&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,r,c)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},e}(),(gt=function(){if(!self||!self.Uint32Array)return null;var e=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),c=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],a=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function n(o){throw new Error(o)}function p(o){var i=0,l=o[i++],s=o[i++];l!=-1&&s!=-1||n("Invalid header in flate stream"),(15&l)!=8&&n("Unknown compression method in flate stream"),((l<<8)+s)%31!=0&&n("Bad FCHECK in flate stream"),32&s&&n("FDICT bit set in flate stream"),this.bytes=o,this.bytesPos=i,this.codeSize=0,this.codeBuf=0,je.call(this)}return p.prototype=Object.create(je.prototype),p.prototype.getBits=function(o){for(var i,l=this.codeSize,s=this.codeBuf,m=this.bytes,u=this.bytesPos;l<o;)(i=m[u++])===void 0&&n("Bad encoding in flate stream"),s|=i<<l,l+=8;return i=s&(1<<o)-1,this.codeBuf=s>>o,this.codeSize=l-=o,this.bytesPos=u,i},p.prototype.getCode=function(o){for(var i=o[0],l=o[1],s=this.codeSize,m=this.codeBuf,u=this.bytes,y=this.bytesPos;s<l;){var b;(b=u[y++])===void 0&&n("Bad encoding in flate stream"),m|=b<<s,s+=8}var h=i[m&(1<<l)-1],g=h>>16,d=65535&h;return(s==0||s<g||g==0)&&n("Bad encoding in flate stream"),this.codeBuf=m>>g,this.codeSize=s-g,this.bytesPos=y,d},p.prototype.generateHuffmanTable=function(o){for(var i=o.length,l=0,s=0;s<i;++s)o[s]>l&&(l=o[s]);for(var m=1<<l,u=new Uint32Array(m),y=1,b=0,h=2;y<=l;++y,b<<=1,h<<=1)for(var g=0;g<i;++g)if(o[g]==y){var d=0,f=b;for(s=0;s<y;++s)d=d<<1|1&f,f>>=1;for(s=d;s<m;s+=h)u[s]=y<<16|g;++b}return[u,l]},p.prototype.readBlock=function(){function o(M,B,_,G,F){for(var q=M.getBits(_)+G;q-- >0;)B[h++]=F}var i=this.getBits(3);if(1&i&&(this.eof=!0),(i>>=1)!=0){var l,s;if(i==1)l=c,s=a;else if(i==2){for(var m=this.getBits(5)+257,u=this.getBits(5)+1,y=this.getBits(4)+4,b=Array(e.length),h=0;h<y;)b[e[h++]]=this.getBits(3);for(var g=this.generateHuffmanTable(b),d=0,f=(h=0,m+u),C=new Array(f);h<f;){var T=this.getCode(g);T==16?o(this,C,2,3,d):T==17?o(this,C,3,3,d=0):T==18?o(this,C,7,11,d=0):C[h++]=d=T}l=this.generateHuffmanTable(C.slice(0,m)),s=this.generateHuffmanTable(C.slice(m,f))}else n("Unknown block type in flate stream");for(var w=(O=this.buffer)?O.length:0,S=this.bufferLength;;){var v=this.getCode(l);if(v<256)S+1>=w&&(w=(O=this.ensureBuffer(S+1)).length),O[S++]=v;else{if(v==256)return void(this.bufferLength=S);var A=(v=t[v-=257])>>16;A>0&&(A=this.getBits(A)),d=(65535&v)+A,v=this.getCode(s),(A=(v=r[v])>>16)>0&&(A=this.getBits(A));var k=(65535&v)+A;S+d>=w&&(w=(O=this.ensureBuffer(S+d)).length);for(var D=0;D<d;++D,++S)O[S]=O[S-k]}}}else{var R,E=this.bytes,L=this.bytesPos;(R=E[L++])===void 0&&n("Bad block header in flate stream");var P=R;(R=E[L++])===void 0&&n("Bad block header in flate stream"),P|=R<<8,(R=E[L++])===void 0&&n("Bad block header in flate stream");var I=R;(R=E[L++])===void 0&&n("Bad block header in flate stream"),(I|=R<<8)!=(65535&~P)&&n("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var x=this.bufferLength,O=this.ensureBuffer(x+P),N=x+P;this.bufferLength=N;for(var V=x;V<N;++V){if((R=E[L++])===void 0){this.eof=!0;break}O[V]=R}this.bytesPos=L}},p}())!==void 0&&(mt.exports=gt);const Te=Rt.exports;class tt{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(t,r,c){if(!t||t.byteLength<10)throw new de("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:a=0,height:n=0,format:p}=r;const{applyJpegMask:o}=r;if(o&&(!a||!n))throw new de("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((i,l)=>{let s=null;p==="jpg"&&o&&(s=tt._getMask(t,{width:a,height:n}));const m=new Blob([new Uint8Array(t)],{type:"image/"+p=="jpg"?"jpeg":p}),u=URL.createObjectURL(m),y=new Image;let b;y.src=u,y.onload=()=>{if(URL.revokeObjectURL(u),Wt(c))return void l(Kt());a=y.width,n=y.height,this._canvas&&this._ctx?(this._canvas.width===a&&this._canvas.height===n||(this._canvas.width=a,this._canvas.height=n),this._ctx.clearRect(0,0,a,n)):(this._canvas=document.createElement("canvas"),this._canvas.width=a,this._canvas.height=n,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(y,0,0);const h=this._ctx.getImageData(0,0,a,n);let g;if(b=h.data,r.renderOnCanvas){if(s)for(g=0;g<s.length;g++)s[g]?b[4*g+3]=255:b[4*g+3]=0;return this._ctx.putImageData(h,0,0),void i(null)}const d=a*n,f=new Uint8Array(d),C=new Uint8Array(d),T=new Uint8Array(d);if(s)for(g=0;g<d;g++)f[g]=b[4*g],C[g]=b[4*g+1],T[g]=b[4*g+2];else for(s=new Uint8Array(d),g=0;g<d;g++)f[g]=b[4*g],C[g]=b[4*g+1],T[g]=b[4*g+2],s[g]=b[4*g+3];i({width:a,height:n,pixels:[f,C,T],mask:s,pixelType:"u8"})},y.onerror=()=>{URL.revokeObjectURL(u),l("cannot load image")}})}static _getMask(t,r){let c=null;try{const a=new Uint8Array(t),n=Math.ceil(a.length/2);let p=0;const o=a.length-2;for(p=n;p<o&&(a[p]!==255||a[p+1]!==217);p++);if(p+=2,p<a.length-1){const i=new Te(a.subarray(p)).getBytes();c=new Uint8Array(r.width*r.height);let l=0;for(let s=0;s<i.length;s++)for(let m=7;m>=0;m--)c[l++]=i[s]>>m&1}}catch{}return c}}var yt,Ct,wt,Et={exports:{}};yt=Et,Ct=function(){var e=function(){function t(r){this.message="JPEG error: "+r}return t.prototype=new Error,t.prototype.name="JpegError",t.constructor=t,t}();return function(){if(!self||!self.Uint8ClampedArray)return null;var t=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),r=4017,c=799,a=3406,n=2276,p=1567,o=3784,i=5793,l=2896;function s(){this.decodeTransform=null,this.colorTransform=-1}function m(d,f){for(var C,T,w=0,S=[],v=16;v>0&&!d[v-1];)v--;S.push({children:[],index:0});var A,k=S[0];for(C=0;C<v;C++){for(T=0;T<d[C];T++){for((k=S.pop()).children[k.index]=f[w];k.index>0;)k=S.pop();for(k.index++,S.push(k);S.length<=C;)S.push(A={children:[],index:0}),k.children[k.index]=A.children,k=A;w++}C+1<v&&(S.push(A={children:[],index:0}),k.children[k.index]=A.children,k=A)}return S[0].children}function u(d,f,C){return 64*((d.blocksPerLine+1)*f+C)}function y(d,f,C,T,w,S,v,A,k){var D=C.mcusPerLine,R=C.progressive,E=f,L=0,P=0;function I(){if(P>0)return P--,L>>P&1;if((L=d[f++])===255){var U=d[f++];if(U)throw new e("unexpected marker "+(L<<8|U).toString(16))}return P=7,L>>>7}function x(U){for(var j=U;;){if(typeof(j=j[I()])=="number")return j;if(typeof j!="object")throw new e("invalid huffman sequence")}}function O(U){for(var j=0;U>0;)j=j<<1|I(),U--;return j}function N(U){if(U===1)return I()===1?1:-1;var j=O(U);return j>=1<<U-1?j:j+(-1<<U)+1}function V(U,j){var K=x(U.huffmanTableDC),Z=K===0?0:N(K);U.blockData[j]=U.pred+=Z;for(var re=1;re<64;){var se=x(U.huffmanTableAC),Q=15&se,ie=se>>4;if(Q!==0){var zt=t[re+=ie];U.blockData[j+zt]=N(Q),re++}else{if(ie<15)break;re+=16}}}function M(U,j){var K=x(U.huffmanTableDC),Z=K===0?0:N(K)<<k;U.blockData[j]=U.pred+=Z}function B(U,j){U.blockData[j]|=I()<<k}var _=0;function G(U,j){if(_>0)_--;else for(var K=S,Z=v;K<=Z;){var re=x(U.huffmanTableAC),se=15&re,Q=re>>4;if(se!==0){var ie=t[K+=Q];U.blockData[j+ie]=N(se)*(1<<k),K++}else{if(Q<15){_=O(Q)+(1<<Q)-1;break}K+=16}}}var F,q=0;function X(U,j){for(var K,Z,re=S,se=v,Q=0;re<=se;){var ie=t[re];switch(q){case 0:if(Q=(Z=x(U.huffmanTableAC))>>4,(K=15&Z)==0)Q<15?(_=O(Q)+(1<<Q),q=4):(Q=16,q=1);else{if(K!==1)throw new e("invalid ACn encoding");F=N(K),q=Q?2:3}continue;case 1:case 2:U.blockData[j+ie]?U.blockData[j+ie]+=I()<<k:--Q==0&&(q=q===2?3:0);break;case 3:U.blockData[j+ie]?U.blockData[j+ie]+=I()<<k:(U.blockData[j+ie]=F<<k,q=0);break;case 4:U.blockData[j+ie]&&(U.blockData[j+ie]+=I()<<k)}re++}q===4&&--_==0&&(q=0)}function ve(U,j,K,Z,re){var se=K%D;j(U,u(U,(K/D|0)*U.v+Z,se*U.h+re))}function Se(U,j,K){j(U,u(U,K/U.blocksPerLine|0,K%U.blocksPerLine))}var ce,ne,ue,pe,Y,De,me=T.length;De=R?S===0?A===0?M:B:A===0?G:X:V;var ae,ge,Le,Me,fe=0;for(ge=me===1?T[0].blocksPerLine*T[0].blocksPerColumn:D*C.mcusPerColumn;fe<ge;){var Oe=w?Math.min(ge-fe,w):ge;for(ne=0;ne<me;ne++)T[ne].pred=0;if(_=0,me===1)for(ce=T[0],Y=0;Y<Oe;Y++)Se(ce,De,fe),fe++;else for(Y=0;Y<Oe;Y++){for(ne=0;ne<me;ne++)for(Le=(ce=T[ne]).h,Me=ce.v,ue=0;ue<Me;ue++)for(pe=0;pe<Le;pe++)ve(ce,De,fe,ue,pe);fe++}P=0,(ae=g(d,f))&&ae.invalid&&(console.log("decodeScan - unexpected MCU data, next marker is: "+ae.invalid),f=ae.offset);var ye=ae&&ae.marker;if(!ye||ye<=65280)throw new e("marker was not found");if(!(ye>=65488&&ye<=65495))break;f+=2}return(ae=g(d,f))&&ae.invalid&&(console.log("decodeScan - unexpected Scan data, next marker is: "+ae.invalid),f=ae.offset),f-E}function b(d,f,C){var T,w,S,v,A,k,D,R,E,L,P,I,x,O,N,V,M,B=d.quantizationTable,_=d.blockData;if(!B)throw new e("missing required Quantization Table.");for(var G=0;G<64;G+=8)E=_[f+G],L=_[f+G+1],P=_[f+G+2],I=_[f+G+3],x=_[f+G+4],O=_[f+G+5],N=_[f+G+6],V=_[f+G+7],E*=B[G],(L|P|I|x|O|N|V)!=0?(L*=B[G+1],P*=B[G+2],I*=B[G+3],x*=B[G+4],O*=B[G+5],N*=B[G+6],V*=B[G+7],w=(T=(T=i*E+128>>8)+(w=i*x+128>>8)+1>>1)-w,M=(S=P)*o+(v=N)*p+128>>8,S=S*p-v*o+128>>8,D=(A=(A=l*(L-V)+128>>8)+(D=O<<4)+1>>1)-D,k=(R=(R=l*(L+V)+128>>8)+(k=I<<4)+1>>1)-k,v=(T=T+(v=M)+1>>1)-v,S=(w=w+S+1>>1)-S,M=A*n+R*a+2048>>12,A=A*a-R*n+2048>>12,R=M,M=k*c+D*r+2048>>12,k=k*r-D*c+2048>>12,D=M,C[G]=T+R,C[G+7]=T-R,C[G+1]=w+D,C[G+6]=w-D,C[G+2]=S+k,C[G+5]=S-k,C[G+3]=v+A,C[G+4]=v-A):(M=i*E+512>>10,C[G]=M,C[G+1]=M,C[G+2]=M,C[G+3]=M,C[G+4]=M,C[G+5]=M,C[G+6]=M,C[G+7]=M);for(var F=0;F<8;++F)E=C[F],((L=C[F+8])|(P=C[F+16])|(I=C[F+24])|(x=C[F+32])|(O=C[F+40])|(N=C[F+48])|(V=C[F+56]))!=0?(w=(T=4112+((T=i*E+2048>>12)+(w=i*x+2048>>12)+1>>1))-w,M=(S=P)*o+(v=N)*p+2048>>12,S=S*p-v*o+2048>>12,v=M,D=(A=(A=l*(L-V)+2048>>12)+(D=O)+1>>1)-D,k=(R=(R=l*(L+V)+2048>>12)+(k=I)+1>>1)-k,M=A*n+R*a+2048>>12,A=A*a-R*n+2048>>12,R=M,M=k*c+D*r+2048>>12,k=k*r-D*c+2048>>12,E=(E=(T=T+v+1>>1)+R)<16?0:E>=4080?255:E>>4,L=(L=(w=w+S+1>>1)+(D=M))<16?0:L>=4080?255:L>>4,P=(P=(S=w-S)+k)<16?0:P>=4080?255:P>>4,I=(I=(v=T-v)+A)<16?0:I>=4080?255:I>>4,x=(x=v-A)<16?0:x>=4080?255:x>>4,O=(O=S-k)<16?0:O>=4080?255:O>>4,N=(N=w-D)<16?0:N>=4080?255:N>>4,V=(V=T-R)<16?0:V>=4080?255:V>>4,_[f+F]=E,_[f+F+8]=L,_[f+F+16]=P,_[f+F+24]=I,_[f+F+32]=x,_[f+F+40]=O,_[f+F+48]=N,_[f+F+56]=V):(M=(M=i*E+8192>>14)<-2040?0:M>=2024?255:M+2056>>4,_[f+F]=M,_[f+F+8]=M,_[f+F+16]=M,_[f+F+24]=M,_[f+F+32]=M,_[f+F+40]=M,_[f+F+48]=M,_[f+F+56]=M)}function h(d,f){for(var C=f.blocksPerLine,T=f.blocksPerColumn,w=new Int16Array(64),S=0;S<T;S++)for(var v=0;v<C;v++)b(f,u(f,S,v),w);return f.blockData}function g(d,f,C){function T(k){return d[k]<<8|d[k+1]}var w=d.length-1,S=C<f?C:f;if(f>=w)return null;var v=T(f);if(v>=65472&&v<=65534)return{invalid:null,marker:v,offset:f};for(var A=T(S);!(A>=65472&&A<=65534);){if(++S>=w)return null;A=T(S)}return{invalid:v.toString(16),marker:A,offset:S}}return s.prototype={parse:function(d){function f(){var U=d[v]<<8|d[v+1];return v+=2,U}function C(){var U=f(),j=v+U-2,K=g(d,j,v);K&&K.invalid&&(console.log("readDataBlock - incorrect length, next marker is: "+K.invalid),j=K.offset);var Z=d.subarray(v,j);return v+=Z.length,Z}function T(U){for(var j=Math.ceil(U.samplesPerLine/8/U.maxH),K=Math.ceil(U.scanLines/8/U.maxV),Z=0;Z<U.components.length;Z++){Y=U.components[Z];var re=Math.ceil(Math.ceil(U.samplesPerLine/8)*Y.h/U.maxH),se=Math.ceil(Math.ceil(U.scanLines/8)*Y.v/U.maxV),Q=j*Y.h,ie=K*Y.v*64*(Q+1);Y.blockData=new Int16Array(ie),Y.blocksPerLine=re,Y.blocksPerColumn=se}U.mcusPerLine=j,U.mcusPerColumn=K}var w,S,v=0,A=null,k=null,D=[],R=[],E=[],L=f();if(L!==65496)throw new e("SOI not found");for(L=f();L!==65497;){var P,I,x;switch(L){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var O=C();L===65504&&O[0]===74&&O[1]===70&&O[2]===73&&O[3]===70&&O[4]===0&&(A={version:{major:O[5],minor:O[6]},densityUnits:O[7],xDensity:O[8]<<8|O[9],yDensity:O[10]<<8|O[11],thumbWidth:O[12],thumbHeight:O[13],thumbData:O.subarray(14,14+3*O[12]*O[13])}),L===65518&&O[0]===65&&O[1]===100&&O[2]===111&&O[3]===98&&O[4]===101&&(k={version:O[5]<<8|O[6],flags0:O[7]<<8|O[8],flags1:O[9]<<8|O[10],transformCode:O[11]});break;case 65499:for(var N=f()+v-2;v<N;){var V=d[v++],M=new Uint16Array(64);if(V>>4==0)for(I=0;I<64;I++)M[t[I]]=d[v++];else{if(V>>4!=1)throw new e("DQT - invalid table spec");for(I=0;I<64;I++)M[t[I]]=f()}D[15&V]=M}break;case 65472:case 65473:case 65474:if(w)throw new e("Only single frame JPEGs supported");f(),(w={}).extended=L===65473,w.progressive=L===65474,w.precision=d[v++],w.scanLines=f(),w.samplesPerLine=f(),w.components=[],w.componentIds={};var B,_=d[v++],G=0,F=0;for(P=0;P<_;P++){B=d[v];var q=d[v+1]>>4,X=15&d[v+1];G<q&&(G=q),F<X&&(F=X);var ve=d[v+2];x=w.components.push({h:q,v:X,quantizationId:ve,quantizationTable:null}),w.componentIds[B]=x-1,v+=3}w.maxH=G,w.maxV=F,T(w);break;case 65476:var Se=f();for(P=2;P<Se;){var ce=d[v++],ne=new Uint8Array(16),ue=0;for(I=0;I<16;I++,v++)ue+=ne[I]=d[v];var pe=new Uint8Array(ue);for(I=0;I<ue;I++,v++)pe[I]=d[v];P+=17+ue,(ce>>4==0?E:R)[15&ce]=m(ne,pe)}break;case 65501:f(),S=f();break;case 65498:f();var Y,De=d[v++],me=[];for(P=0;P<De;P++){var ae=w.componentIds[d[v++]];Y=w.components[ae];var ge=d[v++];Y.huffmanTableDC=E[ge>>4],Y.huffmanTableAC=R[15&ge],me.push(Y)}var Le=d[v++],Me=d[v++],fe=d[v++],Oe=y(d,v,w,me,S,Le,Me,fe>>4,15&fe);v+=Oe;break;case 65535:d[v]!==255&&v--;break;default:if(d[v-3]===255&&d[v-2]>=192&&d[v-2]<=254){v-=3;break}throw new e("unknown marker "+L.toString(16))}L=f()}for(this.width=w.samplesPerLine,this.height=w.scanLines,this.jfif=A,this.eof=v,this.adobe=k,this.components=[],P=0;P<w.components.length;P++){var ye=D[(Y=w.components[P]).quantizationId];ye&&(Y.quantizationTable=ye),this.components.push({output:h(w,Y),scaleX:Y.h/w.maxH,scaleY:Y.v/w.maxV,blocksPerLine:Y.blocksPerLine,blocksPerColumn:Y.blocksPerColumn})}this.numComponents=this.components.length},_getLinearizedBlockData:function(d,f){var C,T,w,S,v,A,k,D,R,E,L,P=this.width/d,I=this.height/f,x=0,O=this.components.length,N=d*f*O,V=new Uint8ClampedArray(N),M=new Uint32Array(d),B=4294967288;for(k=0;k<O;k++){for(T=(C=this.components[k]).scaleX*P,w=C.scaleY*I,x=k,L=C.output,S=C.blocksPerLine+1<<3,v=0;v<d;v++)D=0|v*T,M[v]=(D&B)<<3|7&D;for(A=0;A<f;A++)for(E=S*((D=0|A*w)&B)|(7&D)<<3,v=0;v<d;v++)V[x]=L[E+M[v]],x+=O}var _=this.decodeTransform;if(_)for(k=0;k<N;)for(D=0,R=0;D<O;D++,k++,R+=2)V[k]=(V[k]*_[R]>>8)+_[R+1];return V},_isColorConversionNeeded:function(){return this.adobe?!!this.adobe.transformCode:this.numComponents===3?this.colorTransform!==0:this.colorTransform===1},_convertYccToRgb:function(d){for(var f,C,T,w=0,S=d.length;w<S;w+=3)f=d[w],C=d[w+1],T=d[w+2],d[w]=f-179.456+1.402*T,d[w+1]=f+135.459-.344*C-.714*T,d[w+2]=f-226.816+1.772*C;return d},_convertYcckToRgb:function(d){for(var f,C,T,w,S=0,v=0,A=d.length;v<A;v+=4)f=d[v],C=d[v+1],T=d[v+2],w=d[v+3],d[S++]=C*(-660635669420364e-19*C+.000437130475926232*T-54080610064599e-18*f+.00048449797120281*w-.154362151871126)-122.67195406894+T*(-.000957964378445773*T+.000817076911346625*f-.00477271405408747*w+1.53380253221734)+f*(.000961250184130688*f-.00266257332283933*w+.48357088451265)+w*(-.000336197177618394*w+.484791561490776),d[S++]=107.268039397724+C*(219927104525741e-19*C-.000640992018297945*T+.000659397001245577*f+.000426105652938837*w-.176491792462875)+T*(-.000778269941513683*T+.00130872261408275*f+.000770482631801132*w-.151051492775562)+f*(.00126935368114843*f-.00265090189010898*w+.25802910206845)+w*(-.000318913117588328*w-.213742400323665),d[S++]=C*(-.000570115196973677*C-263409051004589e-19*T+.0020741088115012*f-.00288260236853442*w+.814272968359295)-20.810012546947+T*(-153496057440975e-19*T-.000132689043961446*f+.000560833691242812*w-.195152027534049)+f*(.00174418132927582*f-.00255243321439347*w+.116935020465145)+w*(-.000343531996510555*w+.24165260232407);return d},_convertYcckToCmyk:function(d){for(var f,C,T,w=0,S=d.length;w<S;w+=4)f=d[w],C=d[w+1],T=d[w+2],d[w]=434.456-f-1.402*T,d[w+1]=119.541-f+.344*C+.714*T,d[w+2]=481.816-f-1.772*C;return d},_convertCmykToRgb:function(d){for(var f,C,T,w,S=0,v=1/255,A=0,k=d.length;A<k;A+=4)f=d[A]*v,C=d[A+1]*v,T=d[A+2]*v,w=d[A+3]*v,d[S++]=255+f*(-4.387332384609988*f+54.48615194189176*C+18.82290502165302*T+212.25662451639585*w-285.2331026137004)+C*(1.7149763477362134*C-5.6096736904047315*T-17.873870861415444*w-5.497006427196366)+T*(-2.5217340131683033*T-21.248923337353073*w+17.5119270841813)-w*(21.86122147463605*w+189.48180835922747),d[S++]=255+f*(8.841041422036149*f+60.118027045597366*C+6.871425592049007*T+31.159100130055922*w-79.2970844816548)+C*(-15.310361306967817*C+17.575251261109482*T+131.35250912493976*w-190.9453302588951)+T*(4.444339102852739*T+9.8632861493405*w-24.86741582555878)-w*(20.737325471181034*w+187.80453709719578),d[S++]=255+f*(.8842522430003296*f+8.078677503112928*C+30.89978309703729*T-.23883238689178934*w-14.183576799673286)+C*(10.49593273432072*C+63.02378494754052*T+50.606957656360734*w-112.23884253719248)+T*(.03296041114873217*T+115.60384449646641*w-193.58209356861505)-w*(22.33816807309886*w+180.12613974708367);return d},getData:function(d,f,C){if(this.numComponents>4)throw new e("Unsupported color mode");var T=this._getLinearizedBlockData(d,f);if(this.numComponents===1&&C){for(var w=T.length,S=new Uint8ClampedArray(3*w),v=0,A=0;A<w;A++){var k=T[A];S[v++]=k,S[v++]=k,S[v++]=k}return S}if(this.numComponents===3&&this._isColorConversionNeeded())return this._convertYccToRgb(T);if(this.numComponents===4){if(this._isColorConversionNeeded())return C?this._convertYcckToRgb(T):this._convertYcckToCmyk(T);if(C)return this._convertCmykToRgb(T)}return T}},s}()},(wt=Ct())!==void 0&&(yt.exports=wt);const Be=Et.exports;class er{static decode(t,r=!1){const c=new Uint8Array(t),a=new Be;a.parse(c);const{width:n,height:p,numComponents:o,eof:i}=a,l=a.getData(n,p,!0),s=n*p;let m,u=null,y=0,b=0,h=0;if(!r&&i<c.length-1)try{const g=new Te(c.subarray(i)).getBytes();u=new Uint8Array(s);let d=0;for(y=0;y<g.length;y++)for(h=7;h>=0;h--)u[d++]=g[y]>>h&1}catch{}if(o===1&&l.length===n*p)m=[l,l,l];else{for(m=[],y=0;y<3;y++)m.push(new Uint8Array(s));for(h=0,b=0;b<s;b++)for(y=0;y<3;y++)m[y][b]=l[h++]}return{width:n,height:p,pixels:m,mask:u}}}const Lt=[{pixelType:"S8",size:1,ctor:Int8Array,range:[-128,128]},{pixelType:"U8",size:1,ctor:Uint8Array,range:[0,255]},{pixelType:"S16",size:2,ctor:Int16Array,range:[-32768,32767]},{pixelType:"U16",size:2,ctor:Uint16Array,range:[0,65536]},{pixelType:"S32",size:4,ctor:Int32Array,range:[-2147483648,2147483647]},{pixelType:"U32",size:4,ctor:Uint32Array,range:[0,4294967296]},{pixelType:"F32",size:4,ctor:Float32Array,range:[-34027999387901484e22,34027999387901484e22]},{pixelType:"F64",size:8,ctor:Float64Array,range:[-17976931348623157e292,17976931348623157e292]}];let ze=null;function Mt(){return ze||(ze=Yt(()=>import("./lerc-wasm.8ece762d.js"),[]).then(e=>e.l).then(({default:e})=>e({locateFile:t=>Jt(`esri/layers/support/rasterFormats/${t}`)})).then(e=>{rr(e)}),ze)}const Ne={getBlobInfo:null,decode:null};function tr(e){return 16+(e>>3<<3)}function he(e,t,r){r.set(e.slice(t,t+r.length))}function rr(e){const{_malloc:t,_free:r,_lerc_getBlobInfo:c,_lerc_getDataRanges:a,_lerc_decode_4D:n,asm:p}=e;let o;const i=Object.values(p).find(s=>s&&"buffer"in s&&s.buffer===e.HEAPU8.buffer),l=s=>{const m=s.map(h=>tr(h)),u=m.reduce((h,g)=>h+g),y=t(u);o=new Uint8Array(i.buffer);let b=m[0];m[0]=y;for(let h=1;h<m.length;h++){const g=m[h];m[h]=m[h-1]+b,b=g}return m};Ne.getBlobInfo=s=>{const y=new Uint8Array(48),b=new Uint8Array(8*3),[h,g,d]=l([s.length,y.length,b.length]);o.set(s,h),o.set(y,g),o.set(b,d);let f=c(h,s.length,g,d,12,3);if(f)throw r(h),`lerc-getBlobInfo: error code is ${f}`;o=new Uint8Array(i.buffer),he(o,g,y),he(o,d,b);const C=new Uint32Array(y.buffer),T=new Float64Array(b.buffer),[w,S,,v,A,k,D,R,E,L,P]=C,I={version:w,depthCount:L,width:v,height:A,validPixelCount:D,bandCount:k,blobSize:R,maskCount:E,dataType:S,minValue:T[0],maxValue:T[1],maxZerror:T[2],statistics:[],bandCountWithNoData:P};if(P)return I;if(L===1&&k===1)return r(h),I.statistics.push({minValue:T[0],maxValue:T[1]}),I;const x=L*k*8,O=new Uint8Array(x),N=new Uint8Array(x);let V=h,M=0,B=0,_=!1;if(o.byteLength<h+2*x?(r(h),_=!0,[V,M,B]=l([s.length,x,x]),o.set(s,V)):[M,B]=l([x,x]),o.set(O,M),o.set(N,B),f=a(V,s.length,L,k,M,B),f)throw r(V),_||r(M),`lerc-getDataRanges: error code is ${f}`;o=new Uint8Array(i.buffer),he(o,M,O),he(o,B,N);const G=new Float64Array(O.buffer),F=new Float64Array(N.buffer),q=I.statistics;for(let X=0;X<k;X++)if(L>1){const ve=G.slice(X*L,(X+1)*L),Se=F.slice(X*L,(X+1)*L),ce=Math.min.apply(null,ve),ne=Math.max.apply(null,Se);q.push({minValue:ce,maxValue:ne,depthStats:{minValues:ve,maxValues:Se}})}else q.push({minValue:G[X],maxValue:F[X]});return r(V),_||r(M),I},Ne.decode=(s,m)=>{const{maskCount:u,depthCount:y,bandCount:b,width:h,height:g,dataType:d,bandCountWithNoData:f}=m,C=Lt[d],T=h*g,w=new Uint8Array(T*b),S=T*y*b*C.size,v=new Uint8Array(S),A=new Uint8Array(b),k=new Uint8Array(8*b),[D,R,E,L,P]=l([s.length,w.length,v.length,A.length,k.length]);o.set(s,D),o.set(w,R),o.set(v,E),o.set(A,L),o.set(k,P);const I=n(D,s.length,u,R,y,h,g,b,d,E,L,P);if(I)throw r(D),`lerc-decode: error code is ${I}`;o=new Uint8Array(i.buffer),he(o,E,v),he(o,R,w);let x=null;if(f){he(o,L,A),he(o,P,k),x=[];const O=new Float64Array(k.buffer);for(let N=0;N<A.length;N++)x.push(A[N]?O[N]:null)}return r(D),{data:v,maskData:w,noDataValues:x}}}function or(e,t,r,c,a){if(r<2)return e;const n=new c(t*r);if(a)for(let p=0,o=0;p<t;p++)for(let i=0,l=p;i<r;i++,l+=t)n[l]=e[o++];else for(let p=0,o=0;p<t;p++)for(let i=0,l=p;i<r;i++,l+=t)n[o++]=e[l];return n}function Ot(e,t={}){var k;const r=(k=t.inputOffset)!=null?k:0,c=e instanceof Uint8Array?e.subarray(r):new Uint8Array(e,r),a=Ne.getBlobInfo(c),{data:n,maskData:p}=Ne.decode(c,a),{width:o,height:i,bandCount:l,depthCount:s,dataType:m,maskCount:u,statistics:y}=a,b=Lt[m],h=new b.ctor(n.buffer),g=[],d=[],f=o*i,C=f*s;for(let D=0;D<l;D++){const R=h.subarray(D*C,(D+1)*C);if(t.returnInterleaved)g.push(R);else{const E=or(R,f,s,b.ctor,!0);g.push(E)}d.push(p.subarray(D*C,(D+1)*C))}const T=u===0?null:u===1?d[0]:new Uint8Array(f);if(u>1){T.set(d[0]);for(let D=1;D<d.length;D++){const R=d[D];for(let E=0;E<f;E++)T[E]=T[E]&R[E]}}const{noDataValue:w}=t,S=w!=null&&b.range[0]<=w&&b.range[1]>=w;if(u>0&&S)for(let D=0;D<l;D++){const R=g[D],E=d[D]||T;for(let L=0;L<f;L++)E[L]===0&&(R[L]=w)}const v=u===l&&l>1?d:null,{pixelType:A}=b;return{width:o,height:i,bandCount:l,pixelType:A,depthCount:s,statistics:y,pixels:g,mask:T,bandMasks:v}}function ir(e,t,r,c=!0){if(t%4!=0||r%4!=0){const a=new ArrayBuffer(4*Math.ceil(r/4)),n=new Uint8Array(a),p=new Uint8Array(e,t,r);if(c)for(let o=0;o<n.length;o+=4)n[o]=p[o+3],n[o+1]=p[o+2],n[o+2]=p[o+1],n[o+3]=p[o];else n.set(p);return new Uint32Array(n.buffer)}if(c){const a=new Uint8Array(e,t,r),n=new Uint8Array(a.length);for(let p=0;p<n.length;p+=4)n[p]=a[p+3],n[p+1]=a[p+2],n[p+2]=a[p+1],n[p+3]=a[p];return new Uint32Array(n.buffer)}return new Uint32Array(e,t,r/4)}function bt(){const e=[];for(let t=0;t<=257;t++)e[t]=[t];return e}function Tt(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}const ke=new Set;function rt(e,t,r,c=!0){const a=ir(e,t,r,c);let n=9,p=bt(),o=32,i=p.length,l=[],s=1,m=a[0],u=0;const y=a.length,b=8*(4*y-r),h=[];for(;m!=null;){if(o>=n)o-=n,u=m>>>32-n,m<<=n;else{u=m>>>32-o,m=a[s++];const d=n-o;o=32-d,u=(u<<d)+(m>>>o),m<<=d}if(u===257)break;if(u===256){n=9,p=bt(),i=p.length,l=[];continue}const g=p[u];if(g==null){if(u>p.length)throw"data integrity issue: code does not exist on code page";l.push(l[0]),p[i++]=l.slice(),Tt(h,l)}else Tt(h,g),l.push(g[0]),l.length>1&&(p[i++]=l.slice()),l=g.slice();if(ke.has(i)&&n++,o===0&&(m=a[s++],o=32),s>y||s===y&&o<=b)break}return new Uint8Array(h)}ke.add(511),ke.add(1023),ke.add(2047),ke.add(4095),ke.add(8191);const vt=(e,t)=>{const r=t.width*t.height,c=t.pixelType;return Math.floor(e.byteLength/(r*Ut(c)))},Ut=e=>{let t=1;switch(e){case Uint8Array:case Int8Array:t=1;break;case Uint16Array:case Int16Array:t=2;break;case Uint32Array:case Int32Array:case Float32Array:t=4;break;case Float64Array:t=8}return t},nr=(e,t)=>{if(8*e.byteLength<t)return null;const r=new Uint8Array(e,0,Math.ceil(t/8)),c=new Uint8Array(t);let a=0,n=0,p=0,o=0;for(p=0;p<r.length-1;p++)for(n=r[p],o=7;o>=0;o--)c[a++]=n>>o&1;for(o=7;a<t-1;)n=r[r.length-1],c[a++]=n>>o&1,o--;return c};class ar{static decode(t,r){const c=r.pixelType,a=[],n=r.width*r.height,p=vt(t,r),{bandIds:o,format:i}=r,l=o&&o.length||vt(t,r),s=t.byteLength-t.byteLength%(n*Ut(c)),m=new c(t,0,n*p);let u,y,b,h,g=null;if(i==="bip")for(u=0;u<l;u++){for(b=new c(n),h=o?o[u]:u,y=0;y<n;y++)b[y]=m[y*p+h];a.push(b)}else if(i==="bsq")for(u=0;u<l;u++)h=o?o[u]:u,a.push(m.subarray(h*n,(h+1)*n));return s<t.byteLength-1&&(g=nr(t.slice(s),n)),{pixels:a,mask:g}}}function sr(e,t){let r=0,c="",a=0,n=0;const p=e.length;for(;r<p;)n=e[r++],a=n>>4,a<8?a=1:a===15?(a=4,n=(7&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++]):a===14?(a=3,n=(15&n)<<12|(63&e[r++])<<6|63&e[r++]):(a=2,n=(31&n)<<6|63&e[r++]),(n!==0||t)&&(c+=String.fromCharCode(n));return c}const ot=(()=>{const e=[];return e[254]="NEWSUBFILETYPE",e[255]="SUBFILETYPE",e[256]="IMAGEWIDTH",e[257]="IMAGELENGTH",e[258]="BITSPERSAMPLE",e[259]="COMPRESSION",e[262]="PHOTOMETRICINTERPRETATION",e[263]="THRESHHOLDING",e[264]="CELLWIDTH",e[265]="CELLLENGTH",e[266]="FILLORDER",e[269]="DOCUMENTNAME",e[270]="IMAGEDESCRIPTION",e[271]="MAKE",e[272]="MODEL",e[273]="STRIPOFFSETS",e[274]="ORIENTATION",e[277]="SAMPLESPERPIXEL",e[278]="ROWSPERSTRIP",e[279]="STRIPBYTECOUNTS",e[280]="MINSAMPLEVALUE",e[281]="MAXSAMPLEVALUE",e[282]="XRESOLUTION",e[283]="YRESOLUTION",e[284]="PLANARCONFIGURATION",e[285]="PAGENAME",e[286]="XPOSITION",e[287]="YPOSITION",e[288]="FREEOFFSETS",e[289]="FREEBYTECOUNTS",e[290]="GRAYRESPONSEUNIT",e[291]="GRAYRESPONSECURVE",e[292]="T4OPTIONS",e[293]="T6OPTIONS",e[296]="RESOLUTIONUNIT",e[297]="PAGENUMBER",e[300]="COLORRESPONSEUNIT",e[301]="TRANSFERFUNCTION",e[305]="SOFTWARE",e[306]="DATETIME",e[315]="ARTIST",e[316]="HOSTCOMPUTER",e[317]="PREDICTOR",e[318]="WHITEPOINT",e[319]="PRIMARYCHROMATICITIES",e[320]="COLORMAP",e[321]="HALFTONEHINTS",e[322]="TILEWIDTH",e[323]="TILELENGTH",e[324]="TILEOFFSETS",e[325]="TILEBYTECOUNTS",e[326]="BADFAXLINES",e[327]="CLEANFAXDATA",e[328]="CONSECUTIVEBADFAXLINES",e[330]="SUBIFD",e[332]="INKSET",e[333]="INKNAMES",e[334]="NUMBEROFINKS",e[336]="DOTRANGE",e[337]="TARGETPRINTER",e[338]="EXTRASAMPLES",e[339]="SAMPLEFORMAT",e[340]="SMINSAMPLEVALUE",e[341]="SMAXSAMPLEVALUE",e[342]="TRANSFERRANGE",e[347]="JPEGTABLES",e[512]="JPEGPROC",e[513]="JPEGIFOFFSET",e[514]="JPEGIFBYTECOUNT",e[515]="JPEGRESTARTINTERVAL",e[517]="JPEGLOSSLESSPREDICTORS",e[518]="JPEGPOINTTRANSFORM",e[519]="JPEGQTABLES",e[520]="JPEGDCTABLES",e[521]="JPEGACTABLES",e[529]="YCBCRCOEFFICIENTS",e[530]="YCBCRSUBSAMPLING",e[531]="YCBCRPOSITIONING",e[532]="REFERENCEBLACKWHITE",e[700]="XMP",e[33550]="GEOPIXELSCALE",e[33922]="GEOTIEPOINTS",e[33432]="COPYRIGHT",e[42112]="GDAL_METADATA",e[42113]="GDAL_NODATA",e[50844]="RPCCOEFFICIENT",e[34264]="GEOTRANSMATRIX",e[34735]="GEOKEYDIRECTORY",e[34736]="GEODOUBLEPARAMS",e[34737]="GEOASCIIPARAMS",e[34665]="EXIFIFD",e[34853]="GPSIFD",e[40965]="INTEROPERABILITYIFD",e})(),lr=(()=>{const e=ot.slice();return e[36864]="ExifVersion",e[40960]="FlashpixVersion",e[40961]="ColorSpace",e[42240]="Gamma",e[37121]="ComponentsConfiguration",e[37122]="CompressedBitsPerPixel",e[40962]="PixelXDimension",e[40963]="PixelYDimension",e[37500]="MakerNote",e[37510]="UserComment",e[40964]="RelatedSoundFile",e[36867]="DateTimeOriginal",e[36868]="DateTimeDigitized",e[36880]="OffsetTime",e[36881]="OffsetTimeOriginal",e[36882]="OffsetTimeDigitized",e[37520]="SubSecTime",e[37521]="SubSecTimeOriginal",e[37522]="SubSecTimeDigitized",e[37888]="Temperature",e[37889]="Humidity",e[37890]="Pressure",e[37891]="WaterDepth",e[37892]="Acceleration",e[37893]="CameraElevationAngle",e[42016]="ImageUniqueID",e[42032]="CameraOwnerName",e[42033]="BodySerialNumber",e[42034]="LensSpecification",e[42035]="LensMake",e[42036]="LensModel",e[42037]="LensSerialNumber",e[33434]="ExposureTime",e[33437]="FNumber",e[34850]="ExposureProgram",e[34852]="SpectralSensitivity",e[34855]="PhotographicSensitivity",e[34856]="OECF",e[34864]="SensitivityType",e[34865]="StandardOutputSensitivity",e[34866]="RecommendedExposureIndex",e[34867]="ISOSpeed",e[34868]="ISOSpeedLatitudeyyy",e[34869]="ISOSpeedLatitudezzz",e[37377]="ShutterSpeedValue",e[37378]="ApertureValue",e[37379]="BrightnessValue",e[37380]="ExposureBiasValue",e[37381]="MaxApertureValue",e[37382]="SubjectDistance",e[37383]="MeteringMode",e[37384]="LightSource",e[37385]="Flash",e[37386]="FocalLength",e[37396]="SubjectArea",e[41483]="FlashEnergy",e[41484]="SpatialFrequencyResponse",e[41486]="FocalPlaneXResolution",e[41487]="FocalPlaneYResolution",e[41488]="FocalPlaneResolutionUnit",e[41492]="SubjectLocation",e[41493]="ExposureIndex",e[41495]="SensingMethod",e[41728]="FileSource",e[41729]="SceneType",e[41730]="CFAPattern",e[41985]="CustomRendered",e[41986]="ExposureMode",e[41987]="WhiteBalance",e[41988]="DigitalZoomRatio",e[41989]="FocalLengthIn35mmFilm",e[41990]="SceneCaptureType",e[41991]="GainControl",e[41992]="Contrast",e[41993]="Saturation",e[41994]="Sharpness",e[41995]="DeviceSettingDescription",e[41996]="SubjectDistanceRange",e})(),cr=["GPSVersionID","GPSLatitudeRef","GPSLatitude","GPSLongitudeRef","GPSLongitude","GPSAltitudeRef","GPSAltitude","GPSTimeStamp","GPSSatellites","GPSStatus","GPSMeasureMode","GPSDOP","GPSSpeedRef","GPSSpeed","GPSTrackRef","GPSTrack","GPSImgDirectionRef","GPSImgDirection","GPSMapDatum","GPSDestLatitudeRef","GPSDestLatitude","GPSDestLongitudeRef","GPSDestLongitude","GPSDestBearingRef","GPSDestBearing","GPSDestDistanceRef","GPSDestDistance","GPSProcessingMethod","GPSAreaInformation","GPSDateStamp","GPSDifferential","GPSHPositioningError"],ur=(()=>{const e=[];return e[1024]="GTModelTypeGeoKey",e[1025]="GTRasterTypeGeoKey",e[1026]="GTCitationGeoKey",e[2048]="GeographicTypeGeoKey",e[2049]="GeogCitationGeoKey",e[2050]="GeogGeodeticDatumGeoKey",e[2051]="GeogPrimeMeridianGeoKey",e[2052]="GeogLinearUnitsGeoKey",e[2053]="GeogLinearUnitSizeGeoKey",e[2054]="GeogAngularUnitsGeoKey",e[2055]="GeogAngularUnitSizeGeoKey",e[2056]="GeogEllipsoidGeoKey",e[2057]="GeogSemiMajorAxisGeoKey",e[2058]="GeogSemiMinorAxisGeoKey",e[2059]="GeogInvFlatteningGeoKey",e[2061]="GeogPrimeMeridianLongGeoKey",e[2060]="GeogAzimuthUnitsGeoKey",e[3072]="ProjectedCSTypeGeoKey",e[3073]="PCSCitationGeoKey",e[3074]="ProjectionGeoKey",e[3075]="ProjCoordTransGeoKey",e[3076]="ProjLinearUnitsGeoKey",e[3077]="ProjLinearUnitSizeGeoKey",e[3078]="ProjStdParallel1GeoKey",e[3079]="ProjStdParallel2GeoKey",e[3080]="ProjNatOriginLongGeoKey",e[3081]="ProjNatOriginLatGeoKey",e[3082]="ProjFalseEastingGeoKey",e[3083]="ProjFalseNorthingGeoKey",e[3084]="ProjFalseOriginLongGeoKey",e[3085]="ProjFalseOriginLatGeoKey",e[3086]="ProjFalseOriginEastingGeoKey",e[3087]="ProjFalseOriginNorthingGeoKey",e[3088]="ProjCenterLongGeoKey",e[3090]="ProjCenterEastingGeoKey",e[3091]="ProjCenterNorthingGeoKey",e[3092]="ProjScaleAtNatOriginGeoKey",e[3093]="ProjScaleAtCenterGeoKey",e[3094]="ProjAzimuthAngleGeoKey",e[3095]="ProjStraightVertPoleLongGeoKey",e[4096]="VerticalCSTypeGeoKey",e[4097]="VerticalCitationGeoKey",e[4098]="VerticalDatumGeoKey",e[4099]="VerticalUnitsGeoKey",e})(),fr=(e,t)=>{let r=(t||ot)[e];return r===void 0&&(r="unknown"+String(e)),r},He=new Map;He.set("EXIFIFD",lr),He.set("GPSIFD",cr);const Ie={TIFF_TAGS:ot,ifdTags:He,GEO_KEYS:ur,getTagName:fr},it=(()=>{const e=new ArrayBuffer(4),t=new Uint8Array(e);return new Uint32Array(e)[0]=1,t[0]===1})(),St=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],xe=4294967296,hr=new Set([1,5,6,7,8,34712,34887]);function Gt(e,t){let r="unknown";return e===3?r=t===64?"f64":"f32":e===1?t===1?r="u1":t===2?r="u2":t===4?r="u4":t<=8?r="u8":t<=16?r="u16":t<=32&&(r="u32"):e===2&&(t<=8?r="s8":t<=16?r="s16":t<=32&&(r="s32")),r}function Ve(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;case"f64":t=Float64Array;break;default:t=Float32Array}return t}function dr(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function _t(e,t){var r;return(r=e.get(t))==null?void 0:r.values}function be(e,t){var r;return(r=e.get(t))==null?void 0:r.values}function We(e,t){var r,c;return(c=(r=e.get(t))==null?void 0:r.values)==null?void 0:c[0]}function W(e,t){var r,c;return(c=(r=e.get(t))==null?void 0:r.values)==null?void 0:c[0]}function Ke(e,t,r,c=0,a=Ie.TIFF_TAGS,n=4){const p=n===8,o=p?st(new DataView(e,r,8),0,t):new DataView(e,r,2).getUint16(0,t),i=4+2*n,l=p?8:2,s=l+o*i;if(r+s>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:s};const m=r+s+4<=e.byteLength?Ge(new DataView(e,r+s,n===8?8:4),0,t,n===8):null,u=r+l,y=new Map;let b,h,g,d,f,C=0,T=0;for(let w=0;w<o;w++){h=new DataView(e,u+i*w,i),g=h.getUint16(0,t),f=h.getUint16(2,t),d=Ie.getTagName(g,a);const S=[];n===2?(C=h.getUint16(4,t),T=h.getUint16(6,t)):n===4?(C=h.getUint32(4,t),T=h.getUint32(8,t)):n===8&&(C=Ge(h,4,t,!0),T=Ge(h,12,t,!0),S.push(h.getUint32(12,t)),S.push(h.getUint32(16,t))),b={id:g,type:f,valueCount:C,valueOffset:T,valueOffsets:S,values:null},wr(e,t,b,c,!1,n),y.set(d,b)}return{success:!0,ifd:y,nextIFD:m,requiredBufferSize:s}}const pr=(e,t)=>Ot(e,{inputOffset:t}).pixels[0];async function qe(e,t,r,c,a){var d,f;const n=it===t,p=W(r,"BITSPERSAMPLE"),o=Gt((d=W(r,"SAMPLEFORMAT"))!=null?d:1,p),i=(f=W(r,"COMPRESSION"))!=null?f:1,l=Ve(o);let s,m,u,y,b,h,g;if(i===34887)return await Mt(),pr(e,c);if(i===1)g=e.slice(c,c+a),u=new Uint8Array(g);else if(i===8||i===32946)u=new Uint8Array(e,c,a),b=new Te(u),h=b.getBytes(),g=new ArrayBuffer(h.length),u=new Uint8Array(g),u.set(h);else if(i===6){u=new Uint8Array(e,c,a);const C=new Be;C.parse(u);const T=C.getData(C.width,C.height,!0);g=new ArrayBuffer(T.length),u=new Uint8Array(g),u.set(T)}else if(i===7){const C=r.get("JPEGTABLES").values,T=C.length-2;u=new Uint8Array(T+a-2);for(let A=0;A<T;A++)u[A]=C[A];const w=new Uint8Array(e,c+2,a-2);for(let A=0;A<w.length;A++)u[T+A]=w[A];const S=new Be;S.parse(u);const v=S.getData(S.width,S.height,!0);g=new ArrayBuffer(v.length),u=new Uint8Array(g),u.set(v)}else i===5&&(u=rt(e,c,a,t),g=u.buffer);if(o==="u8"||o==="s8"||n)m=new l(g);else{switch(le(u),g=new ArrayBuffer(u.length),y=new Uint8Array(g),o){case"u16":case"s16":for(s=0;s<u.length;s+=2)y[s]=u[s+1],y[s+1]=u[s];break;case"u32":case"s32":case"f32":for(s=0;s<u.length;s+=4)y[s]=u[s+3],y[s+1]=u[s+2],y[s+2]=u[s+1],y[s+3]=u[s]}m=new l(g)}return m}async function mr(e,t,r){var I;const c=be(r,"TILEOFFSETS");if(c===void 0)return null;const a=be(r,"TILEBYTECOUNTS"),{width:n,height:p,pixelType:o,tileWidth:i,tileHeight:l}=nt([r]),s=at(r,t),m=t.planes,u=n*p,y=W(r,"BITSPERSAMPLE"),b=((I=W(r,"COMPRESSION"))!=null?I:1)===34887,h=Ve(o),g=[];for(let x=0;x<m;x++)g.push(new h(u));let d,f,C,T,w,S,v,A,k,D,R,E,L;const P=Math.ceil(n/i);if(y%8==0){if(b&&s&&m>1){const x=Math.round(c.length/m);for(d=0;d<x;d++){S=Math.floor(d/P)*l,v=d%P*i,A=S*n+v;for(let O=0;O<m;O++){const N=d*m+O;if(a[N]!==0)for(C=await qe(e,t.littleEndian,r,c[N],a[N]),D=0,k=A,E=Math.min(i,n-v),R=Math.min(l,p-S),L=g[O],T=0;T<R;T++)for(k=A+T*n,D=T*i,w=0;w<E;w++,k++,D++)L[k]=C[D]}}}else for(d=0;d<c.length;d++)if(a[d]!==0)for(S=Math.floor(d/P)*l,v=d%P*i,A=S*n+v,C=await qe(e,t.littleEndian,r,c[d],a[d]),D=0,k=A,E=Math.min(i,n-v),R=Math.min(l,p-S),f=0;f<m;f++)if(L=g[f],s||b)for(T=0;T<R;T++)for(k=A+T*n,D=i*l*f+T*i,w=0;w<E;w++,k++,D++)L[k]=C[D];else for(T=0;T<R;T++)for(k=A+T*n,D=T*i*m+f,w=0;w<E;w++,k++,D+=m)L[k]=C[D]}return{width:n,height:p,pixelType:o,pixels:g}}const gr=(e,t,r)=>{var L;const c=it===t.littleEndian,a=be(r,"STRIPOFFSETS");if(a===void 0)return null;const{width:n,height:p,pixelType:o}=nt([r]),i=t.planes,l=n*p,s=W(r,"BITSPERSAMPLE"),m=Ve(o),u=new m(l*i),y=be(r,"STRIPBYTECOUNTS"),b=W(r,"ROWSPERSTRIP"),h=(L=W(r,"COMPRESSION"))!=null?L:1;let g,d,f,C,T,w,S,v,A,k,D,R=b;if(s%8==0)for(g=0;g<a.length;g++){if(T=g*(b*n)*i,R=(g+1)*b>p?p-g*b:b,o==="u8"||o==="s8"||c){if(h===8||h===32946)S=new Uint8Array(e,a[g],y[g]),k=new Te(S),D=k.getBytes(),w=new ArrayBuffer(D.length),S=new Uint8Array(w),S.set(D),S.length!==R*n*i*s/8&&console.log("strip byte counts is different than expected");else if(h===6){S=new Uint8Array(e,a[g],y[g]);const P=new Be;P.parse(S);const I=P.getData(P.width,P.height,!0);w=new ArrayBuffer(I.length),S=new Uint8Array(w),S.set(I)}else h===5?(S=rt(e,a[g],y[g],t.littleEndian),w=S.buffer):(y[g]!==R*n*i*s/8&&console.log("strip byte counts is different than expected"),w=e.slice(a[g],a[g]+y[g]));C=new m(w)}else{switch(h===6||h===8||h===32946?(S=new Uint8Array(e,a[g],y[g]),k=new Te(S),S=k.getBytes(),w=new ArrayBuffer(S.length),v=new Uint8Array(w),S.length!==R*n*i*s/8&&console.log("strip byte counts is different than expected")):(y[g]!==R*n*i*s/8&&console.log("strip byte counts is different than expected"),w=new ArrayBuffer(y[g]),S=new Uint8Array(e,a[g],y[g]),v=new Uint8Array(w)),o){case"u16":case"s16":for(f=0;f<S.length;f+=2)v[f]=S[f+1],v[f+1]=S[f];break;case"u32":case"s32":case"f32":for(f=0;f<S.length;f+=4)v[f]=S[f+3],v[f+1]=S[f+2],v[f+2]=S[f+1],v[f+3]=S[f]}le(w),C=new m(w)}u.set(C,T)}const E=[];if(i===1)E.push(u);else for(g=0;g<i;g++){for(A=new m(l),d=0;d<l;d++)A[d]=u[d*i+g];E.push(A)}return{width:n,height:p,pixelType:o,pixels:E}},yr=(e,t,r)=>{if(!(e&&e.length>0&&t&&r))return null;let c,a,n;const p=e[0].length,o=e.length,i=new Uint8Array(p);for(let l=0;l<o;l++)if(c=e[l],a=t[l],n=r[l],l===0)for(let s=0;s<p;s++)i[s]=c[s]<a||c[s]>n?0:1;else for(let s=0;s<p;s++)i[s]&&(i[s]=c[s]<a||c[s]>n?0:1);return i},Cr=e=>{if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||t.length===0)return null;const r=new Map;let c,a,n,p,o;for(let d=0;d<t.length;d++)c=t[d],a=c.slice(6,c.indexOf(">")),p=c.indexOf("sample="),p>-1&&(o=c.slice(p+8,c.indexOf('"',p+8))),p=c.indexOf("name="),p>-1&&(a=c.slice(p+6,c.indexOf('"',p+6))),a&&(n=c.slice(c.indexOf(">")+1,c.indexOf("</Item>")).trim(),o!=null?r.has(a)?r.get(a)[o]=n:r.set(a,[n]):r.set(a,n)),o=null;const i=r.get("STATISTICS_MINIMUM"),l=r.get("STATISTICS_MAXIMUM"),s=r.get("STATISTICS_MEAN"),m=r.get("STATISTICS_STDDEV");let u=null;if(i&&l){u=[];for(let d=0;d<i.length;d++)u.push({min:parseFloat(i[d]),max:parseFloat(l[d]),avg:s&&parseFloat(s[d]),stddev:m&&parseFloat(m[d])})}const y=r.get("BandName"),b=r.get("WavelengthMin"),h=r.get("WavelengthMax");let g=null;if(y){g=[];for(let d=0;d<y.length;d++)g.push({BandName:y[d],WavelengthMin:b&&parseFloat(b[d]),WavelengthMax:h&&parseFloat(h[d])})}return{statistics:u,bandProperties:g,dataType:r.get("DataType"),rawMetadata:r}};function wr(e,t,r,c=0,a=!1,n=4){if(r.values)return!0;const p=r.type,o=r.valueCount;let i=r.valueOffset,l=[];const s=St[p],m=8*s,u=o*s,y=o*St[p]*8;let b,h;const g=n===8?64:32,d=r.valueOffsets;if(y>g&&u>(a?e.byteLength:e?e.byteLength-i+c:0))return r.offlineOffsetSize=[i,u],r.values=null,!1;if(y<=g){if(!t)if(g<=32)i>>>=32-y;else{const f=d!=null&&d.length?d[0]:i>>>0,C=d!=null&&d.length?d[1]:Math.round((i-f)/xe);y<=32?(i=f>>>32-y,d[0]=i):(i=f*2**(32-y)+(C>>>32-y),d[0]=f,d[1]=C>>>32-y)}if(o===1&&m===g)l=[i];else if(g===64){const f=d!=null&&d.length?d[0]:i>>>0,C=d!=null&&d.length?d[1]:Math.round((i-f)/xe);let T=f,w=32;for(h=1;h<=o;h++){const S=32-m*h%32;if(w<m){const v=T<<S>>>32-w,A=C<<32-w>>>32-w;T=C,l.push(v+A*2**(m-w)),w-=32-(m-w)}else l.push(T<<S>>>32-m),w-=m;w===0&&(w=32,T=C)}}else for(h=1;h<=o;h++){const f=32-m*h;l.push(i<<f>>>32-m)}}else{i-=c,a&&(i=0);for(let f=i;f<i+u;f+=s){switch(p){case 1:case 2:case 7:b=new DataView(e,f,1).getUint8(0);break;case 3:b=new DataView(e,f,2).getUint16(0,t);break;case 4:case 13:b=new DataView(e,f,4).getUint32(0,t);break;case 5:b=new DataView(e,f,4).getUint32(0,t)/new DataView(e,f+4,4).getUint32(0,t);break;case 6:b=new DataView(e,f,1).getInt8(0);break;case 8:b=new DataView(e,f,2).getInt16(0,t);break;case 9:b=new DataView(e,f,4).getInt32(0,t);break;case 10:b=new DataView(e,f,4).getInt32(0,t)/new DataView(e,f+4,4).getInt32(0,t);break;case 11:b=new DataView(e,f,4).getFloat32(0,t);break;case 12:b=new DataView(e,f,8).getFloat64(0,t);break;case 16:case 18:b=st(new DataView(e,f,8),0,t);break;case 17:b=Tr(new DataView(e,f,8),0,t);break;default:b=null}l.push(b)}}if(p===2){let f="";const C=l;for(l=[],h=0;h<C.length;h++)C[h]===0&&f!==""?(l.push(f),f=""):f+=String.fromCharCode(C[h]);f===""&&l.length!==0||l.push(f)}return r.values=l,!0}function nt(e){var N,V;const t=e[0],r=W(t,"TILEWIDTH"),c=W(t,"TILELENGTH"),a=W(t,"IMAGEWIDTH"),n=W(t,"IMAGELENGTH"),p=W(t,"BITSPERSAMPLE"),o=W(t,"SAMPLESPERPIXEL"),i=(N=W(t,"SAMPLEFORMAT"))!=null?N:1,l=Gt(i,p),s=at(t),m=_t(t,"GDAL_NODATA");let u=null;m!=null&&m.length&&(u=m.map(M=>parseFloat(M)),u.some(M=>isNaN(M))&&(u=null));const y=(V=W(t,"COMPRESSION"))!=null?V:1;let b;switch(y){case 1:b="NONE";break;case 2:case 3:case 4:case 32771:b="CCITT";break;case 5:b="LZW";break;case 6:case 7:b="JPEG";break;case 32773:b="PACKBITS";break;case 8:case 32946:b="DEFLATE";break;case 34712:b="JPEG2000";break;case 34887:b="LERC";break;default:b=String(y)}let h=!0,g="";hr.has(y)||(h=!1,g+="unsupported tag compression "+y),i>3&&(h=!1,g+="unsupported tag sampleFormat "+i),p%8!=0&&(h=!1,g+="unsupported tag bitsPerSample "+p);const d=We(t,"GEOASCIIPARAMS");let f;if(d){const M=d.split("|").find(_=>_.includes("ESRI PE String = ")),B=M?M.replace("ESRI PE String = ",""):"";f=B.startsWith("COMPD_CS")||B.startsWith("PROJCS")||B.startsWith("GEOGCS")?{wkid:null,wkt:B}:null}const C=be(t,"GEOTIEPOINTS"),T=be(t,"GEOPIXELSCALE"),w=be(t,"GEOTRANSMATRIX"),S=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let v,A,k=!1;if(S){k=W(S,"GTRasterTypeGeoKey")===2;const M=W(S,"GTModelTypeGeoKey");if(M===2){const B=W(S,"GeographicTypeGeoKey");B>=1024&&B<=32766&&(f={wkid:B})}else if(M===1){const B=W(S,"ProjectedCSTypeGeoKey");B>=1024&&B<=32766&&(f={wkid:B})}}if(T&&C&&C.length>=6?(v=[T[0],0,C[3]-C[0]*T[0],0,-Math.abs(T[1]),C[4]-C[1]*T[1]],k&&(v[2]-=.5*v[0]+.5*v[1],v[5]-=.5*v[3]+.5*v[4])):w&&w.length===16&&(v=k?[w[0],w[1],w[3]-.5*w[0],w[4],w[5],w[7]-.5*w[5]]:[w[0],w[1],w[3],w[4],w[5],w[7]]),v){const M=[{x:0,y:n},{x:0,y:0},{x:a,y:n},{x:a,y:0}];let B,_=Number.POSITIVE_INFINITY,G=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,q=Number.NEGATIVE_INFINITY;for(let X=0;X<M.length;X++)B=dr(M[X],v),_=B.x>_?_:B.x,F=B.x<F?F:B.x,G=B.y>G?G:B.y,q=B.y<q?q:B.y;A={xmin:_,xmax:F,ymin:G,ymax:q,spatialReference:f}}else A={xmin:-.5,ymin:.5-n,xmax:a-.5,ymax:.5,spatialReference:f};const D=e.filter(M=>We(M,"NEWSUBFILETYPE")===1);let R,E,L,P,I;if(D.length>0){L=Math.round(Math.log(a/W(D[0],"IMAGEWIDTH"))/Math.LN2);const M=D[D.length-1];P=Math.round(Math.log(a/W(M,"IMAGEWIDTH"))/Math.LN2),R=W(M,"TILEWIDTH"),E=W(M,"TILELENGTH")}R=P!=null&&P>0?R||r:null,E=P!=null&&P>0?E||c:null,r&&(I=[{maxCol:Math.ceil(a/r)-1,maxRow:Math.ceil(n/c)-1,minRow:0,minCol:0}],D.forEach(M=>{I.push({maxCol:Math.ceil(W(M,"IMAGEWIDTH")/W(M,"TILEWIDTH"))-1,maxRow:Math.ceil(W(M,"IMAGELENGTH")/W(M,"TILELENGTH"))-1,minRow:0,minCol:0})}));const x=We(e[0],"GDAL_METADATA"),O=Cr(x);return g+=" "+Bt({width:a,height:n,tileWidth:r,tileHeight:c,planes:o,ifds:e}),{width:a,height:n,tileWidth:r,tileHeight:c,planes:o,isBSQ:s,pixelType:l,compression:b,noData:u,isSupported:h,message:g,extent:A,affine:T?null:v,firstPyramidLevel:L,maximumPyramidLevel:P,pyramidBlockWidth:R,pyramidBlockHeight:E,tileBoundary:I,metadata:O}}function at(e,t){const r=_t(e,"PLANARCONFIGURATION");return r?r[0]===2:!!t&&t.isBSQ}function br(e){const{littleEndian:t,isBigTiff:r,firstIFDPos:c}=vr(e);let a=c;const n=[];do{const p=Sr(e,t,a,0,Ie.TIFF_TAGS,r?8:4);if(!p.success)break;n.push(p.ifd),a=p.nextIFD}while(a>0);return{...nt(n),littleEndian:t,isBigTiff:r,ifds:n}}function st(e,t,r){const c=e.getUint32(t,r),a=e.getUint32(t+4,r);return r?a*xe+c:c*xe+a}function Tr(e,t,r){let c=r?e.getInt32(t,r):e.getUint32(t,r),a=r?e.getUint32(t+4,r):e.getInt32(t+4,r);const n=(r?c:a)>=0?1:-1;return r?c*=n:a*=n,n*(r?a*xe+c:c*xe+a)}function Ge(e,t,r,c){return c?st(e,t,r):e.getUint32(t,r)}function vr(e){const t=new DataView(e,0,16),r=t.getUint16(0,!1);let c=null;if(r===18761)c=!0;else{if(r!==19789)throw"unexpected endianess byte";c=!1}const a=t.getUint16(2,c);if(a!==42&&a!==43)throw"unexpected tiff identifier";let n=4;const p=a===43;if(p){const o=t.getUint16(n,c);if(n+=2,o!==8||t.getUint16(n,c)!==0)throw"unsupported bigtiff version";n+=2}return{littleEndian:c,isBigTiff:p,firstIFDPos:Ge(t,n,c,p)}}function Sr(e,t,r,c=0,a=Ie.TIFF_TAGS,n=4){const p=Ke(e,t,r,c,a,n);let o;const i=p.ifd;if(i){if(Ie.ifdTags.forEach((l,s)=>{i.has(s)&&(o=i.get(s),o.data=Ke(e,t,o.valueOffset-c,c,l).ifd)}),i.has("GEOKEYDIRECTORY")){o=i.get("GEOKEYDIRECTORY");const l=o.values;if(l&&l.length>4){const s=l[0]+"."+l[1]+"."+l[2];o.data=Ke(e,t,o.valueOffset+6-c,c,Ie.GEO_KEYS,2).ifd,o.data&&o.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[s]})}}if(i.has("XMP")){o=i.get("XMP");const l=o.values;typeof l[0]=="number"&&o.type===7&&(o.values=[sr(new Uint8Array(l))])}}return p}function Bt(e){const{width:t,height:r,tileHeight:c,tileWidth:a}=e,n=e.planes,p=a?a*c:t*r,o=W(e.ifds[0],"BITSPERSAMPLE");let i="";return p*n>2**30/(o>8?o/8:1)&&(i=a?"tiled tiff exceeding 1 gigabits per tile is not supported":"scanline tiff exceeding 1 gigabits is not supported"),i}async function kr(e,t){var k;const{headerInfo:r,ifd:c,offsets:a,sizes:n}=t,p=[];for(let D=0;D<a.length;D++){const R=await qe(e,r.littleEndian,c,a[D],n[D]||e.byteLength);p.push(R)}const o=at(c,r),{pixelType:i,planes:l}=r,s=Ve(i),m=W(c,"TILEWIDTH"),u=W(c,"TILELENGTH"),y=(k=W(c,"COMPRESSION"))!=null?k:1,b=m*u;let h;const g=[];let d=p[0];const f=y===34887;for(let D=0;D<l;D++){if(h=new s(b),o&&f){if(d=p[D],d.length)for(let R=0;R<b;R++)h[R]=d[D][R+D]}else if(d.length)if(o||f&&!o)h=d.slice(b*D,b*(D+1));else for(let R=0;R<b;R++)h[R]=d[R*l+D];g.push(h)}const C=r.noData?r.noData[0]:t.noDataValue,T=r.metadata?r.metadata.statistics:null,w=T?T.map(D=>D.min):null,S=T?T.map(D=>D.max):null;let v,A=null;if(C!=null)if(A=new Uint8Array(b),Math.abs(C)>1e24)for(v=0;v<b;v++)Math.abs((g[0][v]-C)/C)<1e-6?A[v]=0:A[v]=1;else for(v=0;v<b;v++)g[0][v]===C?A[v]=0:A[v]=1;else w&&S&&t.applyMinMaxConstraint&&(A=yr(g,w,S));return{pixelType:i,width:m,height:u,pixels:g,mask:A,noDataValue:C}}async function Ir(e,t={}){const r=t.pyramidLevel||0,c=t.headerInfo||br(e),{ifds:a,noData:n}=c;if(a.length===0)throw"no valid image file directory";const p=Bt(c);if(p)throw p;let o,i=null;const l=r===-1?a[a.length-1]:a[r],s=n?n[0]:t.noDataValue;if(i=c.tileWidth?await mr(e,c,l):await gr(e,c,l),s!=null){if(le(i),i.mask=new Uint8Array(i.width*i.height),Math.abs(s)>1e24)for(o=0;o<i.width*i.height;o++)Math.abs((i.pixels[0][o]-s)/s)<1e-6?i.mask[o]=0:i.mask[o]=1;else for(o=0;o<i.width*i.height;o++)i.pixels[0][o]===s?i.mask[o]=0:i.mask[o]=1;i.noDataValue=s}return i}var Ar=function(e){var t,r,c,a,n,p;function o(i){var l,s,m,u,y,b,h,g,d,f,C,T,w;for(this.data=i,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},y=null;;){switch(l=this.readUInt32(),g=function(){var S,v;for(v=[],S=0;S<4;++S)v.push(String.fromCharCode(this.data[this.pos++]));return v}.call(this).join(""),g){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(l);break;case"fcTL":y&&this.animation.frames.push(y),this.pos+=4,y={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},u=this.readUInt16(),m=this.readUInt16()||100,y.delay=1e3*u/m,y.disposeOp=this.data[this.pos++],y.blendOp=this.data[this.pos++],y.data=[];break;case"IDAT":case"fdAT":for(g==="fdAT"&&(this.pos+=4,l-=4),i=(y!=null?y.data:void 0)||this.imgData,C=0;0<=l?C<l:C>l;0<=l?++C:--C)i.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(l),(d=255-this.transparency.indexed.length)>0)for(T=0;0<=d?T<d:T>d;0<=d?++T:--T)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(l)[0];break;case 2:this.transparency.rgb=this.read(l)}break;case"tEXt":b=(f=this.read(l)).indexOf(0),h=String.fromCharCode.apply(String,f.slice(0,b)),this.text[h]=String.fromCharCode.apply(String,f.slice(b+1));break;case"IEND":return y&&this.animation.frames.push(y),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=(w=this.colorType)===4||w===6,s=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*s,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=l}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(i,l,s){var m;return typeof l=="function"&&(s=l),(m=new XMLHttpRequest).open("GET",i,!0),m.responseType="arraybuffer",m.onload=function(){var u;return u=new o(new Uint8Array(m.response||m.mozResponseArrayBuffer)),typeof(l!=null?l.getContext:void 0)=="function"&&u.render(l),typeof s=="function"?s(u):void 0},m.send(null)},r=1,c=2,t=0,o.prototype.read=function(i){var l,s;for(s=[],l=0;0<=i?l<i:l>i;0<=i?++l:--l)s.push(this.data[this.pos++]);return s},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(i){var l,s,m,u,y,b,h,g,d,f,C,T,w,S,v,A,k,D,R,E,L,P,I;if(i==null&&(i=this.imgData),i.length===0)return new Uint8Array(0);for(i=(i=new Te(i)).getBytes(),A=(T=this.pixelBitlength/8)*this.width,w=new Uint8Array(A*this.height),b=i.length,v=0,S=0,s=0;S<b;){switch(i[S++]){case 0:for(u=R=0;R<A;u=R+=1)w[s++]=i[S++];break;case 1:for(u=E=0;E<A;u=E+=1)l=i[S++],y=u<T?0:w[s-T],w[s++]=(l+y)%256;break;case 2:for(u=L=0;L<A;u=L+=1)l=i[S++],m=(u-u%T)/T,k=v&&w[(v-1)*A+m*T+u%T],w[s++]=(k+l)%256;break;case 3:for(u=P=0;P<A;u=P+=1)l=i[S++],m=(u-u%T)/T,y=u<T?0:w[s-T],k=v&&w[(v-1)*A+m*T+u%T],w[s++]=(l+Math.floor((y+k)/2))%256;break;case 4:for(u=I=0;I<A;u=I+=1)l=i[S++],m=(u-u%T)/T,y=u<T?0:w[s-T],v===0?k=D=0:(k=w[(v-1)*A+m*T+u%T],D=m&&w[(v-1)*A+(m-1)*T+u%T]),h=y+k-D,g=Math.abs(h-y),f=Math.abs(h-k),C=Math.abs(h-D),d=g<=f&&g<=C?y:f<=C?k:D,w[s++]=(l+d)%256;break;default:throw new Error("Invalid filter algorithm: "+i[S-1])}v++}return w},o.prototype.decodePalette=function(){var i,l,s,m,u,y,b,h,g;for(s=this.palette,y=this.transparency.indexed||[],u=new Uint8Array((y.length||0)+s.length),m=0,s.length,i=0,l=b=0,h=s.length;b<h;l=b+=3)u[m++]=s[l],u[m++]=s[l+1],u[m++]=s[l+2],u[m++]=(g=y[i++])!=null?g:255;return u},o.prototype.copyToImageData=function(i,l){var s,m,u,y,b,h,g,d,f,C,T;if(m=this.colors,f=null,s=this.hasAlphaChannel,this.palette.length&&(f=(T=this._decodedPalette)!=null?T:this._decodedPalette=this.decodePalette(),m=4,s=!0),d=(u=i.data||i).length,b=f||l,y=h=0,m===1)for(;y<d;)g=f?4*l[y/4]:h,C=b[g++],u[y++]=C,u[y++]=C,u[y++]=C,u[y++]=s?b[g++]:this.transparency.grayscale&&this.transparency.grayscale===C?0:255,h=g;else for(;y<d;)g=f?4*l[y/4]:h,u[y++]=b[g++],u[y++]=b[g++],u[y++]=b[g++],u[y++]=s?b[g++]:this.transparency.rgb&&this.transparency.rgb[1]===b[g-3]&&this.transparency.rgb[3]===b[g-2]&&this.transparency.rgb[5]===b[g-1]?0:255,h=g},o.prototype.decode=function(){var i;return i=new Uint8Array(this.width*this.height*4),this.copyToImageData(i,this.decodePixels()),i},n=e.document&&e.document.createElement("canvas"),p=n&&n.getContext("2d"),a=function(i){var l;return p.width=i.width,p.height=i.height,p.clearRect(0,0,i.width,i.height),p.putImageData(i,0,0),(l=new Image).src=n.toDataURL(),l},o.prototype.decodeFrames=function(i){var l,s,m,u,y,b,h,g;if(this.animation){for(g=[],s=y=0,b=(h=this.animation.frames).length;y<b;s=++y)l=h[s],m=i.createImageData(l.width,l.height),u=this.decodePixels(new Uint8Array(l.data)),this.copyToImageData(m,u),l.imageData=m,g.push(l.image=a(m));return g}},o.prototype.renderFrame=function(i,l){var s,m,u;return s=(m=this.animation.frames)[l],u=m[l-1],l===0&&i.clearRect(0,0,this.width,this.height),(u!=null?u.disposeOp:void 0)===r?i.clearRect(u.xOffset,u.yOffset,u.width,u.height):(u!=null?u.disposeOp:void 0)===c&&i.putImageData(u.imageData,u.xOffset,u.yOffset),s.blendOp===t&&i.clearRect(s.xOffset,s.yOffset,s.width,s.height),i.drawImage(s.image,s.xOffset,s.yOffset)},o.prototype.animate=function(i){var l,s,m,u,y,b,h=this;return s=0,b=this.animation,u=b.numFrames,m=b.frames,y=b.numPlays,(l=function(){var g,d;if(g=s++%u,d=m[g],h.renderFrame(i,g),u>1&&s/u<y)return h.animation._timeout=setTimeout(l,d.delay)})()},o.prototype.stopAnimation=function(){var i;return clearTimeout((i=this.animation)!=null?i._timeout:void 0)},o.prototype.render=function(i){var l,s;return i._png&&i._png.stopAnimation(),i._png=this,i.width=this.width,i.height=this.height,l=i.getContext("2d"),this.animation?(this.decodeFrames(l),this.animate(l)):(s=l.createImageData(this.width,this.height),this.copyToImageData(s,this.decodePixels()),l.putImageData(s,0,0))},o}(self);const xr=new Set(["jpg","png","bmp","gif"]);async function Dr(e,t){if(!it)throw new de("rasterCoded:decode","lerc decoder is not supported on big endian platform");await Mt();const{offset:r,noDataValue:c}=t,{width:a,height:n,pixelType:p,statistics:o,pixels:i,mask:l}=Ot(e,{inputOffset:r,noDataValue:c,returnInterleaved:t.returnInterleaved});return new oe({width:a,height:n,pixelType:p.toLowerCase(),pixels:i,mask:l,statistics:o})}async function Pr(e,t){const r=await Ir(e,t);le(r);const c=new oe({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask,statistics:null});return c.updateStatistics(),c}async function Rr(e,t){const r=await kr(e,t.customOptions),c=new oe({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask,statistics:null});return c.updateStatistics(),c}function Nt(e,t){const r=t.pixelType||"u8",c=oe.getPixelArrayConstructor(r),a=r==="u8"?e:new c(e.buffer),n=[],p=t.planes||1;if(p===1)n.push(a);else for(let i=0;i<p;i++){const l=(t.width||1)*(t.height||e.length),s=new c(l);for(let m=0;m<l;m++)s[m]=a[m*p+i];n.push(s)}const o=new oe({width:t.width||1,height:t.height||e.length,pixels:n,pixelType:r,statistics:null});return o.updateStatistics(),o}function Er(e,t){return Nt(new Te(new Uint8Array(e)).getBytes(),t)}function Lr(e,t){return Nt(rt(e,t.offset,t.eof,!t.isInputBigEndian),t)}function Mr(e,t,r){const{pixelTypeCtor:c}=Br(t.pixelType),a=(0,ar.decode)(e,{width:t.width,height:t.height,pixelType:c,format:r}),n=new oe({width:t.width,height:t.height,pixels:a.pixels,pixelType:t.pixelType,mask:a.mask,statistics:null});return n.updateStatistics(),n}function Or(e,t){var a;const r=er.decode(e,(a=t.hasNoZlibMask)!=null?a:void 0),c=new oe({width:r.width,height:r.height,pixels:r.pixels,pixelType:"U8",mask:r.mask,statistics:null});return c.updateStatistics(),c}function Ur(e,t){const r=new Uint8Array(e),c=new Ar(r),{width:a,height:n}=t,p=a*n,o=c.decode();let i,l=0,s=0;const m=new Uint8Array(p);for(l=0;l<p;l++)m[l]=o[4*l+3];const u=new oe({width:a,height:n,pixels:[],pixelType:"U8",mask:m,statistics:[]});for(l=0;l<3;l++){for(i=new Uint8Array(p),s=0;s<p;s++)i[s]=o[4*s+l];u.addData({pixels:i})}return u.updateStatistics(),u}async function Gr(e,t,r,c){const a=new tt,n={applyJpegMask:!1,format:t,...r},p=await a.decode(e,n,c),o=new oe(p);return o.updateStatistics(),o}function Ft(e){if(e==null)throw new de("rasterCodec:decode","parameter encodeddata is required.");const t=new Uint8Array(e,0,10);let r="";return t[0]===255&&t[1]===216?r="jpg":t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?r="png":t[0]===67&&t[1]===110&&t[2]===116&&t[3]===90&&t[4]===73&&t[5]===109&&t[6]===97&&t[7]===103&&t[8]===101&&t[9]===32?r="lerc":t[0]===76&&t[1]===101&&t[2]===114&&t[3]===99&&t[4]===50&&t[5]===32?r="lerc2":t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42||t[0]===73&&t[1]===73&&t[2]===43&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===43?r="tiff":t[0]===71&&t[1]===73&&t[2]===70?r="gif":t[0]===66&&t[1]===77?r="bmp":String.fromCharCode.apply(null,t).toLowerCase().includes("error")&&(r="error"),r}function _r(e){let t=null;switch(e){case"lerc":case"lerc2":t=Dr;break;case"jpg":t=Or;break;case"png":t=Ur;break;case"bsq":case"bip":t=(r,c)=>Mr(r,c,e);break;case"tiff":t=Pr;break;case"deflate":t=Er;break;case"lzw":t=Lr;break;case"error":t=()=>{throw new de("rasterCodec:decode","input data contains error")};break;default:t=()=>{throw new de("rasterCodec:decode","unsupported raster format")}}return t}function Br(e){let t=null,r=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":r=255,t=Uint8Array;break;case"u16":r=r||65535,t=Uint16Array;break;case"u32":r=r||2**32-1,t=Uint32Array;break;case"s8":r=r||-128,t=Int8Array;break;case"s16":r=r||-32768,t=Int16Array;break;case"s32":r=r||0-2**31,t=Int32Array;break;default:t=Float32Array}return{pixelTypeCtor:t,noDataValue:r}}function Nr(e,t=1){if(!e)return;const{pixels:r,width:c,height:a,mask:n}=e;if(!r||r.length===0)return;const p=r.length,o=c-1,i=a-1,l=[];let s,m,u,y,b,h,g=null;const d=oe.getPixelArrayConstructor(e.pixelType);if(t===0){for(s=0;s<p;s++){for(b=r[s],h=new d(o*i),m=0;m<i;m++)for(y=m*c,u=0;u<o;u++)h[m*o+u]=b[y+u];l.push(h)}if(H(n))for(g=new Uint8Array(o*i),m=0;m<i;m++)for(y=m*c,u=0;u<o;u++)g[m*o+u]=n[y+u]}else{for(s=0;s<p;s++){for(b=r[s],h=new d(o*i),m=0;m<i;m++)for(y=m*c,u=0;u<o;u++)h[m*o+u]=(b[y+u]+b[y+u+1]+b[y+c+u]+b[y+c+u+1])/4;l.push(h)}if(n)for(g=new Uint8Array(o*i),m=0;m<i;m++)for(y=m*c,u=0;u<o;u++)g[m*o+u]=Math.min.apply(null,[n[y+u],n[y+u+1],n[y+c+u],n[y+c+u+1]])}e.width=o,e.height=i,e.mask=g,e.pixels=l}function ho(e){let t=Ft(e);return t==="lerc2"?t="lerc":t==="error"&&(t=""),t}async function po(e,t={},r){if(e==null)throw new de("rasterCodec:decode","missing encodeddata parameter.");let c,a,n=t.format&&t.format.toLowerCase();if(!(n!=="bsq"&&n!=="bip"||t.width!=null&&t.height!=null))throw new de("rasterCodec:decode","requires width and height in options parameter.");return n==="tiff"&&t.customOptions?Rr(e,t):((!n||n!=="bsq"&&n!=="bip"&&n!=="deflate"&&n!=="lzw")&&(n=Ft(e)),t.useCanvas&&xr.has(n)?a=await Gr(e,n,t,r):(c=_r(n),t.isPoint&&((t={...t}).width!=null&&t.width++,t.height!=null&&t.height++),a=await c(e,t),t.isPoint&&Nr(a)),a)}function Vt(e){let{altitude:t,azimuth:r}=e;const{hillshadeType:c,pixelSizePower:a=1,pixelSizeFactor:n=1,scalingType:p,isGCS:o,resolution:i}=e,l=c==="multi-directional"?2*e.zFactor:e.zFactor,{x:s,y:m}=i;let u=l/(8*s),y=l/(8*m);if(o&&l>.001&&(u/=111e3,y/=111e3),p==="adjusted")if(o){const E=111e3*s,L=111e3*m;u=(l+E**a*n)/(8*E),y=(l+L**a*n)/(8*L)}else u=(l+s**a*n)/(8*s),y=(l+m**a*n)/(8*m);let b=(90-t)*Math.PI/180,h=Math.cos(b),g=(360-r+90)*Math.PI/180,d=Math.sin(b)*Math.cos(g),f=Math.sin(b)*Math.sin(g);const C=[315,270,225,360,180,0],T=[60,60,60,60,60,90],w=new Float32Array([3,5,3,2,1,4]),S=w.reduce((E,L)=>E+L),v=w.map(E=>E/S),A=c==="multi-directional"?C.length:1,k=new Float32Array(6),D=new Float32Array(6),R=new Float32Array(6);if(c==="multi-directional")for(let E=0;E<A;E++)t=T[E],r=C[E],b=(90-t)*Math.PI/180,h=Math.cos(b),g=(360-r+90)*Math.PI/180,d=Math.sin(b)*Math.cos(g),f=Math.sin(b)*Math.sin(g),k[E]=h,D[E]=d,R[E]=f;else k.fill(h),D.fill(d),R.fill(f);return{resolution:i,factor:[u,y],sinZcosA:d,sinZsinA:f,cosZ:h,sinZcosAs:D,sinZsinAs:R,cosZs:k,weights:v,hillshadeType:["traditional","multi-directional"].indexOf(c)}}function Fr(e,t){if(!Ae(e))return e;const{width:r,height:c,mask:a}=e,n=new Uint8Array(r*c);let p=1;if(H(a)){for(let P=0;P<a.length;P++)if(a[P]){p=a[P];break}n.set(a)}const{factor:o,sinZcosA:i,sinZsinA:l,cosZ:s,sinZcosAs:m,sinZsinAs:u,cosZs:y,weights:b}=Vt(t),[h,g]=o,{hillshadeType:d}=t,f=e.pixels[0],C=new Uint8Array(r*c);let T,w,S,v,A,k,D,R;const E=1,L=H(a);for(let P=E;P<c-E;P++){const I=P*r;for(let x=E;x<r-E;x++){if(a&&!a[I+x]){C[I+x]=0;continue}let O=8;if(L&&(O=(a[I-r+x-1]+a[I-r+x]+a[I-r+x+1]+a[I+x-1]+a[I+x+1]+a[I+r+x-1]+a[I+r+x]+a[I+r+x+1])/p,O<7)){C[I+x]=0,n[I+x]=0;continue}a&&O===7?(T=a[I-r+x-1]?f[I-r+x-1]:f[I+x],w=a[I-r+x]?f[I-r+x]:f[I+x],S=a[I-r+x+1]?f[I-r+x+1]:f[I+x],v=a[I+x-1]?f[I+x-1]:f[I+x],A=a[I+x+1]?f[I+x+1]:f[I+x],k=a[I+r+x-1]?f[I+r+x-1]:f[I+x],D=a[I+r+x]?f[I+r+x]:f[I+x],R=a[I+r+x+1]?f[I+r+x+1]:f[I+x]):(T=f[I-r+x-1],w=f[I-r+x],S=f[I-r+x+1],v=f[I+x-1],A=f[I+x+1],k=f[I+r+x-1],D=f[I+r+x],R=f[I+r+x+1]);const N=(S+A+A+R-(T+v+v+k))*h,V=(k+D+D+R-(T+w+w+S))*g,M=Math.sqrt(1+N*N+V*V);let B=0;if(d==="traditional"){let _=255*(s+l*V-i*N)/M;_<0&&(_=0),B=_}else{const _=u.length;for(let G=0;G<_;G++){let F=255*(y[G]+u[G]*V-m[G]*N)/M;F<0&&(F=0),B+=F*b[G]}}C[I+x]=255&B}}for(let P=0;P<c;P++)C[P*r]=C[P*r+1],C[(P+1)*r-1]=C[(P+1)*r-2];for(let P=1;P<r-1;P++)C[P]=C[P+r],C[P+(c-1)*r]=C[P+(c-2)*r];return new oe({width:r,height:c,pixels:[C],mask:a?n:null,pixelType:"u8",validPixelCount:e.validPixelCount,statistics:[{minValue:0,maxValue:255}]})}function Vr(e,t,r,c){if(!Ae(e)||!Ae(t))return;const{min:a,max:n}=c,p=e.pixels[0],{pixels:o,mask:i}=t,l=o[0],s=255.00001/(n-a),m=new Uint8ClampedArray(l.length),u=new Uint8ClampedArray(l.length),y=new Uint8ClampedArray(l.length),b=r.length-1;for(let h=0;h<l.length;h++){if(i&&i[h]===0)continue;const g=Math.floor((l[h]-a)*s),[d,f]=r[g<0?0:g>b?b:g],C=p[h],T=C*f,w=T*(1-Math.abs(d%2-1)),S=C-T;switch(Math.floor(d)){case 0:m[h]=T+S,u[h]=w+S,y[h]=S;break;case 1:m[h]=w+S,u[h]=T+S,y[h]=S;break;case 2:m[h]=S,u[h]=T+S,y[h]=w+S;break;case 3:m[h]=S,u[h]=w+S,y[h]=T+S;break;case 4:m[h]=w+S,u[h]=S,y[h]=T+S;break;case 5:case 6:m[h]=T+S,u[h]=S,y[h]=w+S}}e.pixels=[m,u,y],e.updateStatistics()}function mo(e,t){var E,L;if(!Ae(e))return e;const r=t.zFactor,c=(E=t.pixelSizePower)!=null?E:1,a=(L=t.pixelSizeFactor)!=null?L:1,n=t.slopeType,p=t.isGCS,{width:o,height:i,mask:l}=e,s=e.pixels[0],m=new Uint8Array(o*i);let u=1;if(H(l)){for(let P=0;P<l.length;P++)if(l[P]){u=l[P];break}m.set(l)}const y=new Float32Array(o*i),{x:b,y:h}=t.resolution;let g=r/(8*b),d=r/(8*h);if(p&&Math.abs(r-1)<1e-4&&(g/=111e3,d/=111e3),n==="adjusted")if(p){const P=111e3*b,I=111e3*h;g=(r+P**c*a)/(8*P),d=(r+I**c*a)/(8*I)}else g=(r+b**c*a)/(8*b),d=(r+h**c*a)/(8*h);const f=1;let C,T,w,S,v,A,k,D;const R=H(l);for(let P=f;P<i-f;P++){const I=P*o;for(let x=f;x<o-f;x++){if(l&&!l[I+x]){y[I+x]=0;continue}let O=0;if(R&&(O=(l[I-o+x-1]+l[I-o+x]+l[I-o+x+1]+l[I+x-1]+l[I+x+1]+l[I+o+x-1]+l[I+o+x]+l[I+o+x+1])/u,O<7)){y[I+x]=0,m[I+x]=0;continue}l&&O===7?(C=l[I-o+x-1]?s[I-o+x-1]:s[I+x],T=l[I-o+x]?s[I-o+x]:s[I+x],w=l[I-o+x+1]?s[I-o+x+1]:s[I+x],S=l[I+x-1]?s[I+x-1]:s[I+x],v=l[I+x+1]?s[I+x+1]:s[I+x],A=l[I+o+x-1]?s[I+o+x-1]:s[I+x],k=l[I+o+x]?s[I+o+x]:s[I+x],D=l[I+o+x+1]?s[I+o+x+1]:s[I+x]):(C=s[I-o+x-1],T=s[I-o+x],w=s[I-o+x+1],S=s[I+x-1],v=s[I+x+1],A=s[I+o+x-1],k=s[I+o+x],D=s[I+o+x+1]);const N=(w+v+v+D-(C+S+S+A))*g,V=(A+k+k+D-(C+T+T+w))*d,M=Math.sqrt(N*N+V*V);y[I+x]=n==="percent-rise"?100*M:57.2957795*Math.atan(M)}}for(let P=0;P<i;P++)y[P*o]=y[P*o+1],y[(P+1)*o-1]=y[(P+1)*o-2];for(let P=1;P<o-1;P++)y[P]=y[P+o],y[P+(i-1)*o]=y[P+(i-2)*o];return new oe({width:o,height:i,pixels:[y],mask:l?m:null,pixelType:"f32",validPixelCount:e.validPixelCount,statistics:[{minValue:0,maxValue:n==="percent-rise"?100:360}]})}function go(e,t={}){if(!Ae(e))return e;const{width:r,height:c,mask:a}=e,n=e.pixels[0],p=new Uint8Array(r*c);H(a)&&p.set(a);const o=new Float32Array(r*c),{resolution:i}=t,l=i?1/i.x:1,s=i?1/i.y:1,m=1;let u,y,b,h,g,d,f,C;const T=H(a);for(let w=m;w<c-m;w++){const S=w*r;for(let v=m;v<r-m;v++){if(a&&!a[S+v]){o[S+v]=0;continue}let A=0;if(T&&(A=a[S-r+v-1]+a[S-r+v]+a[S-r+v+1]+a[S+v-1]+a[S+v+1]+a[S+r+v-1]+a[S+r+v]+a[S+r+v+1],A<7)){o[S+v]=0,p[S+v]=0;continue}a&&A===7?(u=a[S-r+v-1]?n[S-r+v-1]:n[S+v],y=a[S-r+v]?n[S-r+v]:n[S+v],b=a[S-r+v+1]?n[S-r+v+1]:n[S+v],h=a[S+v-1]?n[S+v-1]:n[S+v],g=a[S+v+1]?n[S+v+1]:n[S+v],d=a[S+r+v-1]?n[S+r+v-1]:n[S+v],f=a[S+r+v]?n[S+r+v]:n[S+v],C=a[S+r+v+1]?n[S+r+v+1]:n[S+v]):(u=n[S-r+v-1],y=n[S-r+v],b=n[S-r+v+1],h=n[S+v-1],g=n[S+v+1],d=n[S+r+v-1],f=n[S+r+v],C=n[S+r+v+1]);const k=(b+g+g+C-(u+h+h+d))*l,D=(d+f+f+C-(u+y+y+b))*s;let R=-1;k===0&&D===0||(R=90-57.29578*Math.atan2(D,-k),R<0&&(R+=360),R===360?R=0:R>360&&(R%=360)),o[S+v]=R}}for(let w=0;w<c;w++)o[w*r]=o[w*r+1],o[(w+1)*r-1]=o[(w+1)*r-2];for(let w=1;w<r-1;w++)o[w]=o[w+r],o[w+(c-1)*r]=o[w+(c-2)*r];return new oe({width:r,height:c,pixels:[o],mask:a?p:null,pixelType:"f32",validPixelCount:e.validPixelCount,statistics:[{minValue:0,maxValue:360}]})}const $r=[{id:"aspect_predefined",type:"multipart",colorRamps:[{fromColor:[190,190,190],toColor:[255,45,8]},{fromColor:[255,45,8],toColor:[255,181,61]},{fromColor:[255,181,61],toColor:[255,254,52]},{fromColor:[255,254,52],toColor:[0,251,50]},{fromColor:[0,251,50],toColor:[255,254,52]},{fromColor:[0,253,255],toColor:[0,181,255]},{fromColor:[0,181,255],toColor:[26,35,253]},{fromColor:[26,35,253],toColor:[255,57,251]},{fromColor:[255,57,251],toColor:[255,45,8]}]},{id:"blackToWhite_predefined",fromColor:[0,0,0],toColor:[255,255,255]},{id:"blueBright_predefined",fromColor:[204,204,255],toColor:[0,0,224]},{id:"blueLightToDark_predefined",fromColor:[211,229,232],toColor:[46,100,140]},{id:"blueGreenBright_predefined",fromColor:[203,245,234],toColor:[48,207,146]},{id:"blueGreenLightToDark_predefined",fromColor:[216,242,237],toColor:[21,79,74]},{id:"brownLightToDark_predefined",fromColor:[240,236,170],toColor:[102,72,48]},{id:"brownToBlueGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[156,85,31],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[33,130,145]}]},{id:"brownToBlueGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[110,70,45],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[48,100,102]}]},{id:"coefficientBias_predefined",fromColor:[214,214,255],toColor:[0,57,148]},{id:"coldToHotDiverging_predefined",type:"multipart",colorRamps:[{fromColor:[69,117,181],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[214,47,39]}]},{id:"conditionNumber_predefined",type:"multipart",colorRamps:[{fromColor:[0,97,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,34,0]}]},{id:"cyanToPurple_predefined",type:"multipart",colorRamps:[{fromColor:[0,245,245],toColor:[0,0,245]},{fromColor:[0,0,245],toColor:[245,0,245]}]},{id:"cyanLightToBlueDark_predefined",type:"multipart",colorRamps:[{fromColor:[182,237,240],toColor:[31,131,224]},{fromColor:[31,131,224],toColor:[9,9,145]}]},{id:"distance_predefined",fromColor:[255,200,0],toColor:[0,0,255]},{id:"elevation1_predefined",type:"multipart",colorRamps:[{fromColor:[175,240,233],toColor:[255,255,179]},{fromColor:[255,255,179],toColor:[0,128,64]},{fromColor:[0,128,64],toColor:[252,186,3]},{fromColor:[252,186,3],toColor:[128,0,0]},{fromColor:[120,0,0],toColor:[105,48,13]},{fromColor:[105,48,13],toColor:[171,171,171]},{fromColor:[171,171,171],toColor:[255,252,255]}]},{id:"elevation2_predefined",type:"multipart",colorRamps:[{fromColor:[118,219,211],toColor:[255,255,199]},{fromColor:[255,255,199],toColor:[255,255,128]},{fromColor:[255,255,128],toColor:[217,194,121]},{fromColor:[217,194,121],toColor:[135,96,38]},{fromColor:[135,96,38],toColor:[150,150,181]},{fromColor:[150,150,181],toColor:[181,150,181]},{fromColor:[181,150,181],toColor:[255,252,255]}]},{id:"errors_predefined",fromColor:[255,235,214],toColor:[196,10,10]},{id:"grayLightToDark_predefined",fromColor:[219,219,219],toColor:[69,69,69]},{id:"greenBright_predefined",fromColor:[204,255,204],toColor:[14,204,14]},{id:"greenLightToDark_predefined",fromColor:[220,245,233],toColor:[34,102,51]},{id:"greenToBlue_predefined",type:"multipart",colorRamps:[{fromColor:[32,204,16],toColor:[0,242,242]},{fromColor:[0,242,242],toColor:[2,33,227]}]},{id:"orangeBright_predefined",fromColor:[255,235,204],toColor:[240,118,5]},{id:"orangeLightToDark_predefined",fromColor:[250,233,212],toColor:[171,65,36]},{id:"partialSpectrum_predefined",type:"multipart",colorRamps:[{fromColor:[242,241,162],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]},{fromColor:[252,3,69],toColor:[176,7,237]},{fromColor:[176,7,237],toColor:[2,29,173]}]},{id:"partialSpectrum1Diverging_predefined",type:"multipart",colorRamps:[{fromColor:[135,38,38],toColor:[240,149,12]},{fromColor:[240,149,12],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[74,80,181]},{fromColor:[74,80,181],toColor:[39,32,122]}]},{id:"partialSpectrum2Diverging_predefined",type:"multipart",colorRamps:[{fromColor:[115,77,42],toColor:[201,137,52]},{fromColor:[201,137,52],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[91,63,176]},{fromColor:[91,63,176],toColor:[81,13,97]}]},{id:"pinkToYellowGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[158,30,113],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[99,110,45]}]},{id:"pinkToYellowGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[97,47,73],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[22,59,15]}]},{id:"precipitation_predefined",type:"multipart",colorRamps:[{fromColor:[194,82,60],toColor:[237,161,19]},{fromColor:[237,161,19],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,219,0]},{fromColor:[0,219,0],toColor:[32,153,143]},{fromColor:[32,153,143],toColor:[11,44,122]}]},{id:"prediction_predefined",type:"multipart",colorRamps:[{fromColor:[40,146,199],toColor:[250,250,100]},{fromColor:[250,250,100],toColor:[232,16,20]}]},{id:"purpleBright_predefined",fromColor:[255,204,255],toColor:[199,0,199]},{id:"purpleToGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[77,32,150],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[20,122,11]}]},{id:"purpleToGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[67,14,89],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[24,79,15]}]},{id:"purpleBlueBright_predefined",fromColor:[223,184,230],toColor:[112,12,242]},{id:"purpleBlueLightToDark_predefined",fromColor:[229,213,242],toColor:[93,44,112]},{id:"purpleRedBright_predefined",fromColor:[255,204,225],toColor:[199,0,99]},{id:"purpleRedLightToDark_predefined",fromColor:[250,215,246],toColor:[143,17,57]},{id:"redBright_predefined",fromColor:[255,204,204],toColor:[219,0,0]},{id:"redLightToDark_predefined",fromColor:[255,224,224],toColor:[143,10,10]},{id:"redToBlueDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[196,69,57],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[48,95,207]}]},{id:"redToBlueDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[107,13,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[13,53,97]}]},{id:"redToGreen_predefined",type:"multipart",colorRamps:[{fromColor:[245,0,0],toColor:[245,245,0]},{fromColor:[245,245,0],toColor:[0,245,0]}]},{id:"redToGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[186,20,20],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[54,145,33]}]},{id:"redToGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[97,21,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[16,69,16]}]},{id:"slope_predefined",type:"multipart",colorRamps:[{fromColor:[56,168,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]},{id:"spectrumFullBright_predefined",type:"multipart",colorRamps:[{fromColor:[255,0,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,0,255]}]},{id:"spectrumFullDark_predefined",type:"multipart",colorRamps:[{fromColor:[153,0,0],toColor:[153,153,0]},{fromColor:[153,153,0],toColor:[0,153,153]},{fromColor:[0,153,153],toColor:[0,0,153]}]},{id:"spectrumFullLight_predefined",type:"multipart",colorRamps:[{fromColor:[255,153,153],toColor:[255,255,153]},{fromColor:[255,255,153],toColor:[153,255,255]},{fromColor:[153,255,255],toColor:[153,153,255]}]},{id:"surface_predefined",type:"multipart",colorRamps:[{fromColor:[112,153,89],toColor:[242,238,162]},{fromColor:[242,238,162],toColor:[242,206,133]},{fromColor:[242,206,133],toColor:[194,140,124]},{fromColor:[194,140,124],toColor:[255,242,255]}]},{id:"temperature_predefined",type:"multipart",colorRamps:[{fromColor:[255,252,255],toColor:[255,0,255]},{fromColor:[255,0,255],toColor:[0,0,255]},{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,255,0]},{fromColor:[0,255,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,128,0]},{fromColor:[255,128,0],toColor:[128,0,0]}]},{id:"whiteToBlack_predefined",fromColor:[255,255,255],toColor:[0,0,0]},{id:"yellowToDarkRed_predefined",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[242,167,46]},{fromColor:[242,167,46],toColor:[107,0,0]}]},{id:"yellowToGreenToDarkBlue_predefined",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[56,224,9]},{fromColor:[56,224,9],toColor:[26,147,171]},{fromColor:[26,147,171],toColor:[12,16,120]}]},{id:"yellowToRed_predefined",fromColor:[245,245,0],toColor:[255,0,0]},{id:"yellowGreenBright_predefined",fromColor:[236,252,204],toColor:[157,204,16]},{id:"yellowGreenLightToDark_predefined",fromColor:[215,240,175],toColor:[96,107,45]}],jr={aspect_predefined:"Aspect",blackToWhite_predefined:"Black to White",blueBright_predefined:"Blue Bright",blueLightToDark_predefined:"Blue Light to Dark",blueGreenBright_predefined:"Blue-Green Bright",blueGreenLightToDark_predefined:"Blue-Green Light to Dark",brownLightToDark_predefined:"Brown Light to Dark",brownToBlueGreenDivergingBright_predefined:"Brown to Blue Green Diverging, Bright",brownToBlueGreenDivergingDark_predefined:"Brown to Blue Green Diverging, Dark",coefficientBias_predefined:"Coefficient Bias",coldToHotDiverging_predefined:"Cold to Hot Diverging",conditionNumber_predefined:"Condition Number",cyanToPurple_predefined:"Cyan to Purple",cyanLightToBlueDark_predefined:"Cyan-Light to Blue-Dark",distance_predefined:"Distance",elevation1_predefined:"Elevation #1",elevation2_predefined:"Elevation #2",errors_predefined:"Errors",grayLightToDark_predefined:"Gray Light to Dark",greenBright_predefined:"Green Bright",greenLightToDark_predefined:"Green Light to Dark",greenToBlue_predefined:"Green to Blue",orangeBright_predefined:"Orange Bright",orangeLightToDark_predefined:"Orange Light to Dark",partialSpectrum_predefined:"Partial Spectrum",partialSpectrum1Diverging_predefined:"Partial Spectrum 1 Diverging",partialSpectrum2Diverging_predefined:"Partial Spectrum 2 Diverging",pinkToYellowGreenDivergingBright_predefined:"Pink to YellowGreen Diverging, Bright",pinkToYellowGreenDivergingDark_predefined:"Pink to YellowGreen Diverging, Dark",precipitation_predefined:"Precipitation",prediction_predefined:"Prediction",purpleBright_predefined:"Purple Bright",purpleToGreenDivergingBright_predefined:"Purple to Green Diverging, Bright",purpleToGreenDivergingDark_predefined:"Purple to Green Diverging, Dark",purpleBlueBright_predefined:"Purple-Blue Bright",purpleBlueLightToDark_predefined:"Purple-Blue Light to Dark",purpleRedBright_predefined:"Purple-Red Bright",purpleRedLightToDark_predefined:"Purple-Red Light to Dark",redBright_predefined:"Red Bright",redLightToDark_predefined:"Red Light to Dark",redToBlueDivergingBright_predefined:"Red to Blue Diverging, Bright",redToBlueDivergingDark_predefined:"Red to Blue Diverging, Dark",redToGreen_predefined:"Red to Green",redToGreenDivergingBright_predefined:"Red to Green Diverging, Bright",redToGreenDivergingDark_predefined:"Red to Green Diverging, Dark",slope_predefined:"Slope",spectrumFullBright_predefined:"Spectrum-Full Bright",spectrumFullDark_predefined:"Spectrum-Full Dark",spectrumFullLight_predefined:"Spectrum-Full Light",surface_predefined:"Surface",temperature_predefined:"Temperature",whiteToBlack_predefined:"White to Black",yellowToDarkRed_predefined:"Yellow to Dark Red",yellowToGreenToDarkBlue_predefined:"Yellow to Green to Dark Blue",yellowToRed_predefined:"Yellow to Red",yellowGreenBright_predefined:"Yellow-Green Bright",yellowGreenLightToDark_predefined:"Yellow-Green Light to Dark"};function Ue(e,t){if(!e||!t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]>t[r]+2||e[r]<t[r]-2)return!1;return!0}function zr(e,t){if(!e)return;const r=t||$r;let c=null;return e.type==="algorithmic"?r.some(a=>{if(Ue(e.fromColor.toRgb(),a.fromColor)&&Ue(e.toColor.toRgb(),a.toColor))return c=a.id,!0}):e.type==="multipart"&&r.some(a=>{const n=e.colorRamps,p=a.colorRamps;if(n&&p&&n.length===p.length&&!p.some((o,i)=>{if(!Ue(n[i].fromColor.toRgb(),new lt(o.fromColor).toRgb())||!Ue(n[i].toColor.toRgb(),new lt(o.toColor).toRgb()))return!0})){if(c)return!0;c=a.id}}),c}function Wr(e){const t=zr(e);return t?jr[t]:null}function Ee(e){const t=(e=e||{}).numColors||256,r=e.distanceOffset||0,c=e.isCustomInterval!=null?e.isCustomInterval:e.distanceInterval!==null&&e.distanceInterval!==1/(t-1),a=e.distanceInterval||1/(t-1);return{...e,numColors:t,distanceOffset:r,interpolateAlpha:!!e.interpolateAlpha,distanceInterval:a,isCustomInterval:c,weights:e.weights}}function Kr(e,t,r){const{numColors:c,distanceOffset:a,distanceInterval:n,isCustomInterval:p}=Ee(r),o=e.s===0,i=t.s===0;let l=e.h,s=t.h;o&&!i?l=s:i&&!o&&(t={...t,h:l},s=l);let m,u=Math.abs(s-l);const y=360;u<y/2?m=(s-l)*n:(u=y-u,m=l>s?u*n:-u*n);const b=(t.s-e.s)*n,h=(t.v-e.v)*n;let{s:g,v:d}=e,f=l;if(a){const T=a/n;f=(f+T*m+y)%y,g+=T*b,d+=T*h}const C=[];for(let T=0;T<c-1;T++)C.push({h:f,s:g,v:d}),f=(f+m+y)%y,g+=b,d+=h;return C.push(p?{h:f,s:g,v:d}:t),C}function Yr(e,t,r){const{numColors:c,distanceOffset:a,distanceInterval:n,isCustomInterval:p}=Ee(r);let{l:o,a:i,b:l}=e;const s=(t.l-o)*n,m=(t.a-i)*n,u=(t.b-l)*n,y=[];if(a){const b=a/n;o+=b*s,i+=b*m,l+=b*u}for(let b=0;b<c-1;b++)y.push({l:o,a:i,b:l}),o+=s,i+=m,l+=u;return y.push(p?{l:o,a:i,b:l}:t),y}function Jr(e,t,r){const{numColors:c,distanceOffset:a,distanceInterval:n,isCustomInterval:p}=Ee(r),o=e.h,i=t.h,l=2*Math.PI;let s;if(o<=i){const f=i-o,C=i-o-l;s=Math.abs(C)<Math.abs(f)?C:f}else{const f=i+l-o,C=i-o;s=Math.abs(C)<Math.abs(f)?C:f}const m=s*n,u=(t.l-e.l)*n,y=(t.c-e.c)*n;let{l:b,c:h,h:g}=e;if(a){const f=a/n;b+=f*u,h+=f*y,g=(g+f*m+l)%l}const d=[];for(let f=0;f<c-1;f++)d.push({l:b,c:h,h:g}),b+=u,h+=y,g=(g+m+l)%l;return d.push(p?{l:b,c:h,h:g}:t),d}function $t(e,t){var h,g;let{fromColor:r,toColor:c}=e;r.length===3&&(r=r.concat([255])),c.length===3&&(c=c.concat([255]));const a=e.algorithm||"esriCIELabAlgorithm",{numColors:n,distanceOffset:p,isCustomInterval:o,interpolateAlpha:i}=Ee(t);if(n===1&&p===0)return[r];if(n===2&&p===0&&!o)return[r,c];const l={r:r[0],g:r[1],b:r[2]},s={r:c[0],g:c[1],b:c[2]},m=a==="esriCIELabAlgorithm"?Yr(dt(l),dt(s),t):a==="esriHSVAlgorithm"?Kr(_e(l),_e(s),t):Jr(pt(l),pt(s),t),u=[],y=(h=r[3])!=null?h:255,b=(((g=c[3])!=null?g:255)-y)/(n-1);for(let d=0;d<n;d++){const{r:f,g:C,b:T}=Qt(m[d]),w=i?Math.round(y+b*d):255;u.push([f,C,T,w])}return u}function Hr(e,t){const{numColors:r,interpolateAlpha:c}=Ee(t);let a=t==null?void 0:t.weights;const{colorRamps:n}=e;if(a){const u=a.reduce((y,b)=>y+b);a=a.map(y=>y/u)}else{a=[];for(let u=0;u<n.length;u++)a[u]=1/n.length}const p=[];let o=0,i=0;const l=1/(r-1);let s=!1;for(let u=0;u<n.length;u++){let y=s?0:o*l-i,b=u===n.length-1?r-1-o:(a[u]-y)/l;if(s=Math.ceil(b)===b,b=Math.ceil(b),b===0)continue;y/=a[u];const h=$t(n[u],{numColors:b,interpolateAlpha:c,distanceOffset:y,distanceInterval:l/a[u]});o+=h.length,p.push(...h),i+=a[u]}const m=[...n[n.length-1].toColor];return m.length===3&&m.push(255),p.push(m),p}function qr(e,t=256,r=!1){const c="toJSON"in e?e.toJSON():e,a={numColors:t,interpolateAlpha:r};return c.type==="multipart"?Hr(c,a):$t(c,a)}function kt(e,t=256,r=!1){const c=qr(e,t,r);return c.forEach((a,n)=>{a.unshift(n),r||a.pop()}),c}function yo(e){const t=Wr(e);if(e){if(e.type==="algorithmic")return{...It(e),Name:t};if(e.colorRamps){const r=e.colorRamps.map(It);return{type:"MultiPartColorRamp",NumColorRamps:r.length,ArrayOfColorRamp:r,Name:t}}}}function It(e){var t;if(!!e)return{Algorithm:((t=e.toJSON())==null?void 0:t.Algorithm)||"esriHSVAlgorithm",type:"AlgorithmicColorRamp",FromColor:At(e.fromColor),ToColor:At(e.toColor)}}function At(e){const t=_e(e);return{type:"HsvColor",Hue:t.h,Saturation:t.s,Value:t.v,AlphaValue:255}}function Co(e){const t=e.reverse().map(r=>{const c=r.toString(16);return c.length<2?"0"+c:c});return 4294967295&Number.parseInt(t.join(""),16)}const wo=new Ht({none:"none",standardDeviation:"standard-deviation",histogramEqualization:"histogram-equalization",minMax:"min-max",percentClip:"percent-clip",sigmoid:"sigmoid"}),Xr={0:"none",3:"standardDeviation",4:"histogramEqualization",5:"minMax",6:"percentClip",9:"sigmoid"},xt={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767],u32:[0,4294967295],s32:[-2147483648,2147483647],f32:[-34e38,34e38],f64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ye=1,Zr=[.299,.587,.114];function jt(e,t=256){t=Math.min(t,256);const{size:r,counts:c}=e,a=new Uint8Array(r),n=c.reduce((s,m)=>s+m/t,0);let p=0,o=0,i=0,l=n;for(let s=0;s<r;s++)if(i+=c[s],!(s<r-1&&i+c[s+1]<l)){for(;p<t-1&&l<i;)p++,l+=n;for(let m=o;m<=s;m++)a[m]=p;o=s+1}for(let s=o;s<r;s++)a[s]=t-1;return a}function Dt(e){const{minCutOff:t,maxCutOff:r,gamma:c,pixelType:a}=e,n=e.outMin||0,p=e.outMax||255;if(!["u8","u16","s8","s16"].includes(a))return null;const o=t.length;let i,l,s=0;a==="s8"?s=-127:a==="s16"&&(s=-32767);let m=256;["u16","s16"].includes(a)&&(m=65536);const u=[],y=p-n;for(i=0;i<o;i++)u[i]=r[i]-t[i],r[i],t[i];const b=c&&c.length>=o,h=[];if(b)for(i=0;i<o;i++)c[i]>1?c[i]>2?h[i]=6.5+(c[i]-2)**2.5:h[i]=6.5+100*(2-c[i])**4:h[i]=1;let g;const d=[];let f,C,T;if(b)for(i=0;i<o;i++){for(T=[],l=0;l<m;l++)f=l+s,g=(f-t[i])/u[i],C=1,c[i]>1&&(C-=(1/y)**(g*h[i])),f<r[i]&&f>t[i]?T[l]=Math.floor(C*y*g**(1/c[i]))+n:f>=r[i]?T[l]=p:T[l]=n;d[i]=T}else for(i=0;i<o;i++){for(T=[],l=0;l<m;l++)f=l+s,f<=t[i]?T[l]=n:f>=r[i]?T[l]=p:T[l]=Math.floor((f-t[i])/u[i]*y)+n;d[i]=T}if(e.contrastOffset!=null){const w=Qr(e.contrastOffset,e.brightnessOffset);for(i=0;i<o;i++)for(T=d[i],l=0;l<m;l++)T[l]=w[T[l]]}return{lut:d,offset:s}}function Qr(e,t){const r=Math.min(Math.max(e,-100),100),c=Math.min(Math.max(t!=null?t:0,-100),100),a=255,n=128;let p=0,o=0;const i=new Uint8Array(256);for(p=0;p<256;p++)r>0&&r<100?o=(200*p-100*a+2*a*c)/(2*(100-r))+n:r<=0&&r>-100?o=(200*p-100*a+2*a*c)*(100+r)/2e4+n:r===100?(o=200*p-100*a+(a+1)*(100-r)+2*a*c,o=o>0?a:0):r===-100&&(o=n),i[p]=o>a?a:o<0?0:o;return i}function eo(e,t,r){const c=[];for(let a=0;a<t.length;a++){let n=0,p=0,o=0;"min"in t[a]?{min:n,max:p,avg:o}=t[a]:[n,p,o]=t[a];let i=o!=null?o:0;e!=="u8"&&(i=255*(i-n)/(p-n)),r&&(i*=Zr[a]),c.push(to(i))}return c}function to(e){if(e<=0||e>=255)return Ye;let t=0;e!==150&&(t=e<=150?45*Math.cos(.01047*e):17*Math.sin(.021*e));const r=255,c=e+t,a=Math.log(e/r),n=Math.log(c/r);if(n===0)return Ye;const p=a/n;return isNaN(p)?Ye:Math.min(9.9,Math.max(.01,p))}function ro(e){var k;if(Fe(e)||!((k=e.pixels)!=null&&k.length))return null;e.statistics||e.updateStatistics();const{pixels:t,mask:r,pixelType:c,statistics:a}=e,n=e.width*e.height,p=t.length;let o,i,l,s,m;const u=[],y=[];let b,h,g,d,f,C,T,w,S,v;const A=256;for(s=0;s<p;s++){if(b=new Uint32Array(A),g=t[s],c==="u8")if(o=-.5,i=255.5,r)for(m=0;m<n;m++)r[m]&&b[g[m]]++;else for(m=0;m<n;m++)b[g[m]]++;else{if(le(a),o=a[s].minValue,i=a[s].maxValue,l=(i-o)/A,h=new Uint32Array(A+1),r)for(m=0;m<n;m++)r[m]&&h[Math.floor((g[m]-o)/l)]++;else for(m=0;m<n;m++)h[Math.floor((g[m]-o)/l)]++;for(m=0;m<255;m++)b[m]=h[m];b[255]=h[255]+h[256]}for(u.push({min:o,max:i,size:A,counts:b}),d=0,f=0,w=0,m=0;m<A;m++)d+=b[m],f+=m*b[m];for(S=f/d,m=0;m<A;m++)w+=b[m]*(m-S)**2;v=Math.sqrt(w/(d-1)),l=(i-o)/A,C=(S+.5)*l+o,T=v*l,y.push({min:o,max:i,avg:C,stddev:T})}return{statistics:y,histograms:u}}function bo(e){const t=[];for(let r=0;r<e.length;r++){const{min:c,max:a,size:n,counts:p}=e[r];let o=0,i=0;for(let b=0;b<n;b++)o+=p[b],i+=b*p[b];const l=i/o;let s=0;for(let b=0;b<n;b++)s+=p[b]*(b-l)**2;const m=(a-c)/n,u=(l+.5)*m+c,y=Math.sqrt(s/(o-1))*m;t.push({min:c,max:a,avg:u,stddev:y})}return t}function Re(e,t){var A;const{pixelBlock:r,bandIds:c,returnHistogramLut:a,rasterInfo:n}=t;let p=null,o=null,i=e.stretchType;if(typeof i=="number"&&(i=Xr[i]),e.dra)if(i==="minMax"&&H(r)&&r.statistics)p=r.statistics.map(k=>[k.minValue,k.maxValue,0,0]);else{const k=ro(r);p=H(k)?k.statistics:null,o=H(k)?k.histograms:null}else p=((A=e.statistics)==null?void 0:A.length)>0?e.statistics:we(n.statistics),o=e.histograms||we(n.histograms);i!=="percentClip"&&i!=="histogramEqualization"||(o==null?void 0:o.length)||(i="minMax");const l=(p==null?void 0:p.length)||(o==null?void 0:o.length)||n.bandCount,s=[],m=[];let u,y,b,h,g,d,f,C,T,w,S,v;switch(p&&!Array.isArray(p[0])&&(p=p.map(k=>[k.min,k.max,k.avg,k.stddev])),i){case"none":{const k=xt[n.pixelType]||xt.f32;for(C=0;C<l;C++)s[C]=k[0],m[C]=k[1]}break;case"minMax":for(le(p),C=0;C<l;C++)s[C]=p[C][0],m[C]=p[C][1];break;case"standardDeviation":for(le(p),C=0;C<l;C++)s[C]=p[C][2]-e.numberOfStandardDeviations*p[C][3],m[C]=p[C][2]+e.numberOfStandardDeviations*p[C][3],s[C]<p[C][0]&&(s[C]=p[C][0]),m[C]>p[C][1]&&(m[C]=p[C][1]);break;case"histogramEqualization":for(le(o),C=0;C<l;C++)s[C]=o[C].min,m[C]=o[C].max;break;case"percentClip":for(le(o),C=0;C<o.length;C++){for(u=o[C],g=new Uint32Array(u.size),h=[...u.counts],h.length>=20&&(h[0]=h[1]=h[2]=h[h.length-1]=h[h.length-2]=0),b=0,y=(u.max-u.min)/u.size,f=u.min===-.5&&y===1?.5:0,T=0;T<u.size;T++)b+=h[T],g[T]=b;for(d=(e.minPercent||0)*b/100,T=0;T<u.size;T++)if(g[T]>d){s[C]=u.min+y*(T+f);break}for(d=(1-(e.maxPercent||0)/100)*b,T=u.size-2;T>=0;T--)if(g[T]<d){m[C]=u.min+y*(T+2-f);break}}break;default:for(le(p),C=0;C<l;C++)s[C]=p[C][0],m[C]=p[C][1]}return i==="histogramEqualization"?(le(o),S=o[0].size||256,w=0,a&&(v=o.map(k=>jt(k)))):(S=e.max||255,w=e.min||0),oo({minCutOff:s,maxCutOff:m,outMax:S,outMin:w,histogramLut:v},c)}function oo(e,t){if(t==null||t.length===0)return e;const r=Math.max.apply(null,t),{minCutOff:c,maxCutOff:a,outMin:n,outMax:p,histogramLut:o}=e;return c.length===t.length||c.length<=r?e:{minCutOff:t.map(i=>c[i]),maxCutOff:t.map(i=>a[i]),histogramLut:o?t.map(i=>o[i]):null,outMin:n,outMax:p}}function Je(e,t){var k;if(Fe(e)||!((k=e.pixels)!=null&&k.length))return e;const{mask:r,width:c,height:a,pixels:n}=e,{minCutOff:p,maxCutOff:o,gamma:i}=t,l=t.outMin||0,s=t.outMax||255,m=c*a,u=t.outputPixelType||"u8",y=e.pixels.map(()=>oe.createEmptyBand(u,m)),b=y.length;let h,g,d,f,C;const T=s-l,w=[];for(h=0;h<b;h++)w[h]=o[h]-p[h],o[h],p[h];const S=i&&i.length>=b,v=[];if(S)for(h=0;h<b;h++)i[h]>1?i[h]>2?v[h]=6.5+(i[h]-2)**2.5:v[h]=6.5+100*(2-i[h])**4:v[h]=1;if(S)if(r!=null){for(g=0;g<m;g++)if(r[g])for(h=0;h<b;h++)d=n[h][g],C=(d-p[h])/w[h],f=1,i[h]>1&&(f-=(1/T)**(C*v[h])),d<o[h]&&d>p[h]?y[h][g]=Math.floor(f*T*C**(1/i[h]))+l:d>=o[h]?y[h][g]=s:y[h][g]=l}else for(g=0;g<m;g++)for(h=0;h<b;h++)d=n[h][g],C=(d-p[h])/w[h],f=1,i[h]>1&&(f-=(1/T)**(C*v[h])),d<o[h]&&d>p[h]?y[h][g]=Math.floor(f*T*C**(1/i[h]))+l:d>=o[h]?y[h][g]=s:y[h][g]=l;else if(r!=null){for(g=0;g<m;g++)if(r[g])for(h=0;h<b;h++)d=n[h][g],d<o[h]&&d>p[h]?y[h][g]=Math.floor((d-p[h])/w[h]*T)+l:d>=o[h]?y[h][g]=s:y[h][g]=l}else for(g=0;g<m;g++)for(h=0;h<b;h++)d=n[h][g],d<o[h]&&d>p[h]?y[h][g]=Math.floor((d-p[h])/w[h]*T)+l:d>=o[h]?y[h][g]=s:y[h][g]=l;const A=new oe({width:c,height:a,mask:r,pixels:y,pixelType:u});return A.updateStatistics(),A}var Xe;let ee=Xe=class extends et{constructor(){super(...arguments),this.blockWidth=void 0,this.blockHeight=void 0,this.compression=null,this.origin=null,this.firstPyramidLevel=null,this.maximumPyramidLevel=null,this.pyramidScalingFactor=2,this.pyramidBlockWidth=null,this.pyramidBlockHeight=null,this.isVirtualTileInfo=!1,this.tileInfo=null,this.transposeInfo=null,this.blockBoundary=null}clone(){return new Xe({blockWidth:this.blockWidth,blockHeight:this.blockHeight,compression:this.compression,origin:te(this.origin),firstPyramidLevel:this.firstPyramidLevel,maximumPyramidLevel:this.maximumPyramidLevel,pyramidResolutions:te(this.pyramidResolutions),pyramidScalingFactor:this.pyramidScalingFactor,pyramidBlockWidth:this.pyramidBlockWidth,pyramidBlockHeight:this.pyramidBlockHeight,isVirtualTileInfo:this.isVirtualTileInfo,tileInfo:te(this.tileInfo),transposeInfo:te(this.transposeInfo),blockBoundary:te(this.blockBoundary)})}};$([z({type:Number,json:{write:!0}})],ee.prototype,"blockWidth",void 0),$([z({type:Number,json:{write:!0}})],ee.prototype,"blockHeight",void 0),$([z({type:String,json:{write:!0}})],ee.prototype,"compression",void 0),$([z({type:qt,json:{write:!0}})],ee.prototype,"origin",void 0),$([z({type:Number,json:{write:!0}})],ee.prototype,"firstPyramidLevel",void 0),$([z({type:Number,json:{write:!0}})],ee.prototype,"maximumPyramidLevel",void 0),$([z({json:{write:!0}})],ee.prototype,"pyramidResolutions",void 0),$([z({type:Number,json:{write:!0}})],ee.prototype,"pyramidScalingFactor",void 0),$([z({type:Number,json:{write:!0}})],ee.prototype,"pyramidBlockWidth",void 0),$([z({type:Number,json:{write:!0}})],ee.prototype,"pyramidBlockHeight",void 0),$([z({type:Boolean,json:{write:!0}})],ee.prototype,"isVirtualTileInfo",void 0),$([z({json:{write:!0}})],ee.prototype,"tileInfo",void 0),$([z()],ee.prototype,"transposeInfo",void 0),$([z()],ee.prototype,"blockBoundary",void 0),ee=Xe=$([Qe("esri.layers.support.RasterStorageInfo")],ee);const io=ee;var Ze;let J=Ze=class extends et{constructor(e){super(e),this.attributeTable=null,this.bandCount=null,this.colormap=null,this.extent=null,this.format=void 0,this.height=null,this.width=null,this.histograms=null,this.keyProperties={},this.multidimensionalInfo=null,this.noDataValue=null,this.pixelSize=null,this.pixelType=null,this.isPseudoSpatialReference=!1,this.spatialReference=null,this.statistics=null,this.storageInfo=null,this.transform=null}get dataType(){var t,r,c;const e=(c=(r=(t=this.keyProperties)==null?void 0:t.DataType)==null?void 0:r.toLowerCase())!=null?c:"generic";return e==="stdtime"?"standard-time":e}get nativeExtent(){return this._get("nativeExtent")||this.extent}set nativeExtent(e){e&&this._set("nativeExtent",e)}get nativePixelSize(){if(Fe(this.transform)||!this.transform.affectsPixelSize)return this.pixelSize;const e=this.nativeExtent;return{x:e.width/this.width,y:e.height/this.height}}get hasMultidimensionalTranspose(){var e;return!!((e=this.storageInfo)!=null&&e.transposeInfo)}clone(){return new Ze({attributeTable:te(this.attributeTable),bandCount:this.bandCount,colormap:te(this.colormap),extent:te(this.extent),nativePixelSize:te(this.nativePixelSize),format:this.format,height:this.height,width:this.width,histograms:te(this.histograms),keyProperties:te(this.keyProperties),multidimensionalInfo:te(this.multidimensionalInfo),noDataValue:this.noDataValue,pixelSize:te(this.pixelSize),pixelType:this.pixelType,isPseudoSpatialReference:this.isPseudoSpatialReference,spatialReference:te(this.spatialReference),statistics:te(this.statistics),storageInfo:te(this.storageInfo),transform:te(this.transform)})}};$([z({json:{write:!0}})],J.prototype,"attributeTable",void 0),$([z({json:{write:!0}})],J.prototype,"bandCount",void 0),$([z({json:{write:!0}})],J.prototype,"colormap",void 0),$([z({type:String,readOnly:!0})],J.prototype,"dataType",null),$([z({type:ct,json:{write:!0}})],J.prototype,"extent",void 0),$([z({type:ct,json:{write:!0}})],J.prototype,"nativeExtent",null),$([z({json:{write:!0}})],J.prototype,"nativePixelSize",null),$([z({json:{write:!0}})],J.prototype,"format",void 0),$([z({json:{write:!0}})],J.prototype,"height",void 0),$([z({json:{write:!0}})],J.prototype,"width",void 0),$([z({json:{write:!0}})],J.prototype,"hasMultidimensionalTranspose",null),$([z({json:{write:!0}})],J.prototype,"histograms",void 0),$([z({json:{write:!0}})],J.prototype,"keyProperties",void 0),$([z({json:{write:!0}})],J.prototype,"multidimensionalInfo",void 0),$([z({json:{write:!0}})],J.prototype,"noDataValue",void 0),$([z({json:{write:!0}})],J.prototype,"pixelSize",void 0),$([z({json:{write:!0}})],J.prototype,"pixelType",void 0),$([z()],J.prototype,"isPseudoSpatialReference",void 0),$([z({type:Xt,json:{write:!0}})],J.prototype,"spatialReference",void 0),$([z({json:{write:!0}})],J.prototype,"statistics",void 0),$([z({type:io,json:{write:!0}})],J.prototype,"storageInfo",void 0),$([z({json:{write:!0}})],J.prototype,"transform",void 0),J=Ze=$([Qe("esri.layers.support.RasterInfo")],J);const no=J;function ao(e,t){const{attributeTable:r,bandCount:c}=e;return!(Fe(r)||c>1||t&&r.fields.find(a=>a.name.toLowerCase()===t.toLowerCase())==null)}function so(e){const{bandCount:t,dataType:r,pixelType:c}=e;return r==="elevation"||r==="generic"&&t===1&&(c==="s16"||c==="f32"||c==="f64")}function lo(e){const{bandCount:t,colormap:r}=e;return H(r)&&r.length>0&&t===1}let Ce=class extends et{constructor(e){super(e)}bind(){const{rendererJSON:e}=this;if(!e)return{success:!1};let t;switch(this.lookup={rendererJSON:{}},e.type){case"uniqueValue":t=this._updateUVRenderer(e);break;case"rasterColormap":t=this._updateColormapRenderer(e);break;case"rasterStretch":t=this._updateStretchRenderer(e);break;case"classBreaks":t=this._updateClassBreaksRenderer(e);break;case"rasterShadedRelief":t=this._updateShadedReliefRenderer(e);break;case"vectorField":t=this._updateVectorFieldRenderer();break;case"flowRenderer":t=this._updateFlowRenderer()}return t}symbolize(e){let t=e&&e.pixelBlock;if(!Pt(t))return t;if(e.simpleStretchParams&&this.rendererJSON.type==="rasterStretch")return this.simpleStretch(t,e.simpleStretchParams);try{let r;switch(t.pixels.length>3&&(t=ft(t,[0,1,2])),this.rendererJSON.type){case"uniqueValue":case"rasterColormap":r=this._symbolizeColormap(t);break;case"classBreaks":r=this._symbolizeClassBreaks(t);break;case"rasterStretch":r=this._symbolizeStretch(t,e.bandIds);break;case"rasterShadedRelief":{const c=e.extent,a=c.spatialReference.isGeographic,n={x:(c.xmax-c.xmin)/t.width,y:(c.ymax-c.ymin)/t.height};r=this._symbolizeShadedRelief(t,{isGCS:a,resolution:n});break}}return r}catch(r){return ut.getLogger(this.declaredClass).error("symbolize",r.message),t}}simpleStretch(e,t){if(!Pt(e))return e;try{return e.pixels.length>3&&(e=ft(e,[0,1,2])),Je(e,t)}catch(r){return ut.getLogger(this.declaredClass).error("symbolize",r.message),e}}generateWebGLParameters(e){if(["uniqueValue","rasterColormap","classBreaks"].includes(this.rendererJSON.type)){const{indexedColormap:p,offset:o}=this.lookup.colormapLut||{};return{colormap:p,colormapOffset:o,type:"lut"}}const{pixelBlock:t,isGCS:r,resolution:c,bandIds:a}=e,{rendererJSON:n}=this;return n.type==="rasterStretch"?this._generateStretchWebGLParams(t,n,a):n.type==="rasterShadedRelief"?this._generateShadedReliefWebGLParams(n,r,c):n.type==="vectorField"?this._generateVectorFieldWebGLParams(n):null}_isLUTChanged(e){if(!this.lookup||!this.lookup.rendererJSON)return!0;if("colorRamp"in this.rendererJSON){const t=this.rendererJSON.colorRamp;return e?JSON.stringify(t)!==JSON.stringify(this.lookup.rendererJSON.colorRamp):(this.rendererJSON,this.lookup.rendererJSON,JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON))}return JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}_symbolizeColormap(e){return this._isLUTChanged()&&!this.bind().success?e:$e(e,this.lookup.colormapLut)}_symbolizeClassBreaks(e){var r;const{canUseIndexedLUT:t}=this._analyzeClassBreaks(this.rendererJSON);return this._isLUTChanged()&&!this.bind().success?e:t?$e(e,this.lookup.colormapLut):Zt(e,(r=this.lookup.remapLut)!=null?r:[])}_symbolizeStretch(e,t){var m,u,y;const{rasterInfo:r}=this,{pixelType:c,bandCount:a}=r,n=this.rendererJSON,p=["u8","u16","s8","s16"].includes(c);let o,i;const{dra:l}=n,{gamma:s}=this.lookup;if(n.stretchType==="histogramEqualization"){const b=l?null:(m=this.lookup)==null?void 0:m.histogramLut,h=Re(n,{rasterInfo:r,pixelBlock:e,bandIds:t,returnHistogramLut:!b}),g=Je(e,{...h,gamma:s});i=ht(g,{lut:l?h.histogramLut:b,offset:0})}else if(p){if(l){const b=Re(n,{rasterInfo:r,pixelBlock:e,bandIds:t});o=Dt({pixelType:c,...b,gamma:s})}else if(this._isLUTChanged()){if(!this.bind().success)return e;o=this.lookup?this.lookup.stretchLut:null}else o=this.lookup?this.lookup.stretchLut:null;if(!o)return e;a>1&&(t==null?void 0:t.length)===((u=we(e))==null?void 0:u.pixels.length)&&(o==null?void 0:o.lut.length)===a&&(o={lut:t.map(b=>o.lut[b]),offset:o.offset}),i=ht(e,o)}else{const b=Re(n,{rasterInfo:r,pixelBlock:e,bandIds:t});i=Je(e,{...b,gamma:s})}if(n.colorRamp){if(this._isLUTChanged(!0)&&!this.bind().success)return e;i=$e(i,(y=this.lookup)==null?void 0:y.colormapLut)}return i}_symbolizeShadedRelief(e,t){var o,i;const r=this.rendererJSON,c={...r,...t},a=Fr(e,c);if(!r.colorRamp)return a;let n;if(this._isLUTChanged(!0)){if(!this.bind().success)return a;n=this.lookup?this.lookup.hsvMap:null}else n=this.lookup?this.lookup.hsvMap:null;if(!n)return a;const p=(i=(o=we(this.rasterInfo.statistics))==null?void 0:o[0])!=null?i:{min:0,max:8e3};return Vr(a,e,n,p),a}_isVectorFieldData(){const{bandCount:e,dataType:t}=this.rasterInfo;return e===2&&(t==="vector-magdir"||t==="vector-uv")}_updateVectorFieldRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; VectorFieldRenderer only supports "vector-magdir" and "vector-uv".`}}_updateFlowRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; FlowRenderer only supports "vector-magdir" and "vector-uv".`}}_updateUVRenderer(e){var l;const{bandCount:t,attributeTable:r,pixelType:c}=this.rasterInfo,a=e.field1;if(!a)return{success:!1,error:"Unsupported renderer; missing UniqueValueRenderer.field."};const n=e.defaultSymbol,p=t===1&&["u8","s8"].includes(c);if(!ao(this.rasterInfo,a)&&!p)return{success:!1,error:"Unsupported data; UniqueValueRenderer is only supported on single band data with a valid raster attribute table."};const o=[];if(H(r)){const s=r.fields.find(m=>m.name.toLowerCase()==="value");if(!s)return{success:!1,error:"Unsupported data; the data's raster attribute table does not have a value field."};r.features.forEach(m=>{var b,h;const u=(b=e.uniqueValueInfos)==null?void 0:b.find(g=>String(g.value)===String(m.attributes[a])),y=(h=u==null?void 0:u.symbol)==null?void 0:h.color;y?o.push([m.attributes[s.name]].concat(y)):n&&o.push([m.attributes[s.name]].concat(n.color))})}else{if(a.toLowerCase()!=="value")return{success:!1,error:'Unsupported renderer; UniqueValueRenderer.field must be "Value" when raster attribute table is not availalbe.'};(l=e.uniqueValueInfos)==null||l.forEach(s=>{var u;const m=(u=s==null?void 0:s.symbol)==null?void 0:u.color;m?o.push([parseInt(""+s.value,10)].concat(m)):n&&o.push([parseInt(""+s.value,10)].concat(n==null?void 0:n.color))})}if(o.length===0)return{success:!1,error:"Invalid UniqueValueRenderer. Cannot find matching records in the raster attribute table."};const i=Pe({colormap:o});return this.lookup={rendererJSON:e,colormapLut:i},this.canRenderInWebGL=!0,{success:!0}}_updateColormapRenderer(e){if(!lo(this.rasterInfo))return{success:!1,error:"Unsupported data; the data source does not have a colormap."};const t=e.colormapInfos.map(c=>[c.value].concat(c.color)).sort((c,a)=>c[0]-a[0]);if(!t||t.length===0)return{success:!1,error:"Unsupported renderer; ColormapRenderer must have meaningful colormapInfos."};const r=Pe({colormap:t});return this.lookup={rendererJSON:e,colormapLut:r},this.canRenderInWebGL=!0,{success:!0}}_updateShadedReliefRenderer(e){if(!so(this.rasterInfo))return{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; ShadedReliefRenderer only supports "elevation", or single band float/s16 data.`};if(e.colorRamp){const t=kt(e.colorRamp,256,!0),r=Pe({colormap:t}),c=[],a=r.indexedColormap;for(let n=0;n<a.length;n+=4){const p=_e({r:a[n],g:a[n+1],b:a[n+2]});c.push([p.h/60,p.s/100,255*p.v/100])}this.lookup={rendererJSON:e,colormapLut:r,hsvMap:c}}else this.lookup=null;return this.canRenderInWebGL=!0,{success:!0}}_analyzeClassBreaks(e){const{attributeTable:t,pixelType:r}=this.rasterInfo,c=H(t)?t.fields.find(p=>p.name.toLowerCase()==="value"):null,a=H(t)?t.fields.find(p=>p.name.toLowerCase()===e.field.toLowerCase()):null,n=c!=null&&a!==null;return{canUseIndexedLUT:["u8","u16","s8","s16"].includes(r)||n,tableValueField:c,tableBreakField:a}}_updateClassBreaksRenderer(e){var m;const{attributeTable:t}=this.rasterInfo,{canUseIndexedLUT:r,tableValueField:c,tableBreakField:a}=this._analyzeClassBreaks(e),n=e.classBreakInfos;if(!(n!=null&&n.length))return{success:!1,error:"Unsupported renderer; missing or invalid ClassBreaksRenderer.classBreakInfos."};const p=n.sort((u,y)=>u.classMaxValue-y.classMaxValue),o=p[p.length-1];let i=e.minValue;if(!r){const u=[];for(let y=0;y<p.length;y++)u.push({value:(m=p[y].classMinValue)!=null?m:i,mappedColor:p[y].symbol.color}),i=p[y].classMaxValue;return u.push({value:o.classMaxValue,mappedColor:o.symbol.color}),this.lookup={rendererJSON:e,remapLut:u},this.canRenderInWebGL=!1,{success:!0}}const l=[];if(H(t)&&c!=null&&a!==null&&c!==a){const u=c.name,y=a.name,b=p[p.length-1],{classMaxValue:h}=b;i=e.minValue;for(const g of t.features){const d=g.attributes[u],f=g.attributes[y],C=f===h?b:f<i?null:p.find(({classMaxValue:T})=>T>f);C&&l.push([d].concat(C.symbol.color))}}else{i=Math.floor(e.minValue);for(let u=0;u<p.length;u++){const y=p[u];for(let b=i;b<y.classMaxValue;b++)l.push([b].concat(y.symbol.color));i=Math.ceil(y.classMaxValue)}o.classMaxValue===i&&l.push([o.classMaxValue].concat(o.symbol.color))}const s=Pe({colormap:l,fillUnspecified:!1});return this.lookup={rendererJSON:e,colormapLut:s},this.canRenderInWebGL=!0,{success:!0}}_isHistogramRequired(e){return e==="percentClip"||e==="histogramEqualization"}_isValidRasterStatistics(e){return H(e)&&e.length>0&&e[0].min!=null&&e[0].max!=null}_updateStretchRenderer(e){var s,m;let{stretchType:t,dra:r}=e;if(!(t==="none"||((s=e.statistics)==null?void 0:s.length)||this._isValidRasterStatistics(this.rasterInfo.statistics)||r))return{success:!1,error:"Unsupported renderer; StretchRenderer.statistics is required when dynamic range adjustment is not used."};const c=we(e.histograms||this.rasterInfo.histograms);!this._isHistogramRequired(e.stretchType)||(c==null?void 0:c.length)||r||(t="minMax");const{computeGamma:a,useGamma:n,colorRamp:p}=e;let{gamma:o}=e;if(n&&a&&!(o!=null&&o.length)){const u=(m=e.statistics)!=null&&m.length?e.statistics:we(this.rasterInfo.statistics);o=eo(this.rasterInfo.pixelType,u)}const i=this.rasterInfo.pixelType,l=!r&&["u8","u16","s8","s16"].includes(i);if(t==="histogramEqualization"){const u=c.map(y=>jt(y));this.lookup={rendererJSON:e,histogramLut:u}}else if(l){const u=Re(e,{rasterInfo:this.rasterInfo}),y=Dt({pixelType:i,...u,gamma:n?o:null});this.lookup={rendererJSON:e,stretchLut:y}}if(p){const u=kt(p,256,!0);this.lookup||(this.lookup={rendererJSON:e}),this.lookup.colormapLut=Pe({colormap:u}),this.lookup.rendererJSON=e}return this.lookup.gamma=n&&(o==null?void 0:o.length)?o:null,this.canRenderInWebGL=!0,{success:!0}}_generateStretchWebGLParams(e,t,r){let c=null,a=null;const n=this.lookup&&this.lookup.colormapLut;t.colorRamp&&n&&(c=n.indexedColormap,a=n.offset),t.stretchType==="histogramEqualization"&&(t={...t,stretchType:"minMax"});const{gamma:p}=this.lookup,o=!!(t.useGamma&&p&&p.some(f=>f!==1)),{minCutOff:i,maxCutOff:l,outMin:s,outMax:m}=Re(t,{rasterInfo:this.rasterInfo,pixelBlock:e,bandIds:r});let u=0;H(e)&&(u=e.getPlaneCount(),u===2&&((e=e.clone()).statistics=[e.statistics[0]],e.pixels=[e.pixels[0]]));const y=Math.min(3,(r==null?void 0:r.length)||u||this.rasterInfo.bandCount),b=new Float32Array(y),h=c||o?1:255;let g;for(g=0;g<y;g++)b[g]=(m-s)/(l[g]-i[g])/h;const d=new Float32Array(y);if(o)for(g=0;g<y;g++)p[g]>1?p[g]>2?d[g]=6.5+(p[g]-2)**2.5:d[g]=6.5+100*(2-p[g])**4:d[g]=1;return{bandCount:y,outMin:s/h,outMax:m/h,minCutOff:i,maxCutOff:l,factor:b,useGamma:o,gamma:o?p:[1,1,1],gammaCorrection:o?d:[1,1,1],colormap:c,colormapOffset:a,stretchType:t.stretchType,type:"stretch"}}_generateShadedReliefWebGLParams(e,t=!1,r={x:0,y:0}){var l,s,m;let c=null,a=null;const n=this.lookup&&this.lookup.colormapLut;e.colorRamp&&n&&(c=n.indexedColormap,a=n.offset);const p={...e,isGCS:t,resolution:r},o=Vt(p),i=(l=we(this.rasterInfo.statistics))==null?void 0:l[0];return{...o,minValue:(s=i==null?void 0:i.min)!=null?s:0,maxValue:(m=i==null?void 0:i.max)!=null?m:8e3,hillshadeType:e.hillshadeType==="traditional"?0:1,type:"hillshade",colormap:c,colormapOffset:a}}_generateVectorFieldWebGLParams(e){var d,f,C,T,w,S,v,A;const{style:t,inputUnit:r,outputUnit:c,visualVariables:a,symbolTileSize:n,flowRepresentation:p}=e;let o;const i=(f=(d=this.rasterInfo.statistics)==null?void 0:d[0].min)!=null?f:0,l=(T=(C=this.rasterInfo.statistics)==null?void 0:C[0].max)!=null?T:50,s=(w=a==null?void 0:a.find(k=>k.type==="sizeInfo"))!=null?w:{type:"sizeInfo",field:"Magnitude",maxDataValue:l,maxSize:.8*n,minDataValue:i,minSize:.2*n},m=(S=s.minDataValue)!=null?S:i,u=(v=s.maxDataValue)!=null?v:l,y=H(s.maxSize)&&H(s.minSize)?[s.minSize/n,s.maxSize/n]:[.2,.8];if(t==="wind_speed"){const k=(y[0]+y[1])/2;y[0]=y[1]=k}const b=H(m)&&H(u)?[m,u]:null;if(t==="classified_arrow")if(H(m)&&H(u)&&H(s)){o=[];const k=(s.maxDataValue-s.minDataValue)/5;for(let D=0;D<6;D++)o.push(s.minDataValue+k*D)}else o=[0,1e-6,3.5,7,10.5,14];const h=p==="flow_to"==(t==="ocean_current_kn"||t==="ocean_current_m")?0:Math.PI,g=a==null?void 0:a.find(k=>k.type==="rotationInfo");return{breakValues:o,dataRange:b,inputUnit:r,outputUnit:c,symbolTileSize:n,symbolPercentRange:y,style:t||"single_arrow",rotation:h,rotationType:((A=this.rasterInfo.storageInfo)==null?void 0:A.tileInfo)&&this.rasterInfo.dataType==="vector-uv"?"geographic":(g==null?void 0:g.rotationType)||e.rotationType,type:"vectorField"}}};function Pt(e){return Ae(e)&&e.validPixelCount!==0}$([z({json:{write:!0}})],Ce.prototype,"rendererJSON",void 0),$([z({type:no,json:{write:!0}})],Ce.prototype,"rasterInfo",void 0),$([z({json:{write:!0}})],Ce.prototype,"lookup",void 0),$([z()],Ce.prototype,"canRenderInWebGL",void 0),Ce=$([Qe("esri.renderers.support.RasterSymbolizer")],Ce);const To=Ce;export{nt as D,Sr as G,vr as N,at as O,ho as P,po as S,To as T,yo as _,mo as a,io as b,qr as c,Je as d,no as e,Wr as f,Xr as g,kt as h,$r as i,bo as j,Co as k,it as l,Ie as m,wo as n,go as o,ro as p,wr as q,sr as r,Dt as u,Re as x};