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(ta&&(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,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>16,d=65535&h;return(s==0||s>g,this.codeSize=s-g,this.bytesPos=y,d},p.prototype.generateHuffmanTable=function(o){for(var i=o.length,l=0,s=0;sl&&(l=o[s]);for(var m=1<>=1;for(s=d;s0;)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=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{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{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=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;C0;)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+10)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<>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)<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<>4,(K=15&Z)==0)Q<15?(_=O(Q)+(1<=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=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>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>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>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>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;w4)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=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;bimport("./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{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.byteLength1){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;N1){T.set(d[0]);for(let D=1;D=w;if(u>0&&S)for(let D=0;D1?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)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<>>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=0;o--)c[a++]=n>>o&1;for(o=7;a>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>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;wOt(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;A1){const x=Math.round(c.length/m);for(d=0;d{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;gp?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{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;ln?0:1;else for(let s=0;sn?0:1);return i},Cr=e=>{if(!e)return null;const t=e.match(//gi);if(!t||t.length===0)return null;const r=new Map;let c,a,n,p,o;for(let d=0;d")),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("")).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;dg&&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>>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<>>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<>>32-m)}}else{i-=c,a&&(i=0);for(let f=i;fparseFloat(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_?_:B.x,F=B.xG?G:B.y,q=B.yWe(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;DD.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;v1e24)for(o=0;ol;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?Td;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?li;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;S1&&s/uMr(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.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;Eb?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;P360&&(R%=360)),o[S+v]=R}}for(let w=0;wt[r]+2||e[r]{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;us?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;Ty+b);a=a.map(y=>y/u)}else{a=[];for(let u=0;u{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=o,h=[];if(b)for(i=0;i1?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;i1&&(C-=(1/y)**(g*h[i])),ft[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=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;i0&&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=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[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;Cp[C][1]&&(m[C]=p[C][1]);break;case"histogramEqualization":for(le(o),C=0;C=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;Td){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]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,v=[];if(S)for(h=0;h1?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;g1&&(f-=(1/T)**(C*v[h])),dp[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;g1&&(f-=(1/T)**(C*v[h])),dp[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;gp[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;gp[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;np.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;yT>f);C&&l.push([d].concat(C.symbol.color))}}else{i=Math.floor(e.minValue);for(let u=0;u0&&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;g1?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};