@arcgis/core 4.29.0-next.20231021 → 4.29.0-next.20231024

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8652],{92835:(e,t,i)=>{i.d(t,{Z:()=>m});var s,n=i(43697),r=i(96674),a=i(35463),o=i(5600),l=(i(75215),i(77734),i(80442),i(71715)),c=i(52011),h=i(30556),u=i(25031);let f=s=class extends r.wq{static get allTime(){return p}static get empty(){return d}constructor(e){super(e),this.end=null,this.start=null}readEnd(e,t){return null!=t.end?new Date(t.end):null}writeEnd(e,t){t.end=e?.getTime()??null}get isAllTime(){return this.equals(s.allTime)}get isEmpty(){return this.equals(s.empty)}readStart(e,t){return null!=t.start?new Date(t.start):null}writeStart(e,t){t.start=e?.getTime()??null}clone(){return new s({end:this.end,start:this.start})}equals(e){if(!e)return!1;const t=this.start?.getTime()??this.start,i=this.end?.getTime()??this.end,s=e.start?.getTime()??e.start,n=e.end?.getTime()??e.end;return t===s&&i===n}expandTo(e,t=u.By){if(this.isEmpty||this.isAllTime)return this.clone();let i=this.start;i&&(i=(0,a.JE)(i,e,t));let n=this.end;if(n){const i=(0,a.JE)(n,e,t);n=n.getTime()===i.getTime()?i:(0,a.Nm)(i,1,e,t)}return new s({start:i,end:n})}intersection(e){if(!e)return this.clone();if(this.isEmpty||e.isEmpty)return s.empty;if(this.isAllTime)return e.clone();if(e.isAllTime)return this.clone();const t=this.start?.getTime()??-1/0,i=this.end?.getTime()??1/0,n=e.start?.getTime()??-1/0,r=e.end?.getTime()??1/0;let a,o;if(n>=t&&n<=i?a=n:t>=n&&t<=r&&(a=t),i>=n&&i<=r?o=i:r>=t&&r<=i&&(o=r),null!=a&&null!=o&&!isNaN(a)&&!isNaN(o)){const e=new s;return e.start=a===-1/0?null:new Date(a),e.end=o===1/0?null:new Date(o),e}return s.empty}offset(e,t,i=u.By){if(this.isEmpty||this.isAllTime)return this.clone();const n=new s,{start:r,end:o}=this;return null!=r&&(n.start=(0,a.Nm)(r,e,t,i)),null!=o&&(n.end=(0,a.Nm)(o,e,t,i)),n}union(e){if(!e||e.isEmpty)return this.clone();if(this.isEmpty)return e.clone();if(this.isAllTime||e.isAllTime)return p.clone();const t=null!=this.start&&null!=e.start?new Date(Math.min(this.start.getTime(),e.start.getTime())):null,i=null!=this.end&&null!=e.end?new Date(Math.max(this.end.getTime(),e.end.getTime())):null;return new s({start:t,end:i})}};(0,n._)([(0,o.Cb)({type:Date,json:{write:{allowNull:!0}}})],f.prototype,"end",void 0),(0,n._)([(0,l.r)("end")],f.prototype,"readEnd",null),(0,n._)([(0,h.c)("end")],f.prototype,"writeEnd",null),(0,n._)([(0,o.Cb)({readOnly:!0,json:{read:!1}})],f.prototype,"isAllTime",null),(0,n._)([(0,o.Cb)({readOnly:!0,json:{read:!1}})],f.prototype,"isEmpty",null),(0,n._)([(0,o.Cb)({type:Date,json:{write:{allowNull:!0}}})],f.prototype,"start",void 0),(0,n._)([(0,l.r)("start")],f.prototype,"readStart",null),(0,n._)([(0,h.c)("start")],f.prototype,"writeStart",null),f=s=(0,n._)([(0,c.j)("esri.TimeExtent")],f);const p=new f,d=new f({start:void 0,end:void 0}),m=f},91303:(e,t,i)=>{var s;i.d(t,{Y:()=>s}),function(e){e[e.KILOBYTES=1024]="KILOBYTES",e[e.MEGABYTES=1048576]="MEGABYTES",e[e.GIGABYTES=1073741824]="GIGABYTES"}(s||(s={}))},2368:(e,t,i)=>{i.d(t,{J:()=>h,j:()=>u});var s=i(43697),n=i(92036),r=(i(80442),i(22974)),a=(i(92604),i(70586)),o=i(31263),l=i(1153),c=i(52011);const h=e=>{let t=class extends e{clone(){const e=(0,l.vw)(this);(0,a.O3)(e,"unable to clone instance of non-accessor class");const t=e.metadatas,i=e.store,s={},n=new Map;for(const e in t){const a=t[e],l=i?.originOf(e),c=a.clonable;if(a.readOnly||!1===c||l!==o.s3.USER&&l!==o.s3.DEFAULTS&&l!==o.s3.WEB_MAP&&l!==o.s3.WEB_SCENE)continue;const h=this[e];let u=null;u="function"==typeof c?c(h):"reference"===c?h:(0,r.Vo)(h),null!=h&&null==u||(l===o.s3.DEFAULTS?n.set(e,u):s[e]=u)}const c=new(0,Object.getPrototypeOf(this).constructor)(s);if(n.size){const e=(0,l.vw)(c)?.store;if(e)for(const[t,i]of n)e.set(t,i,o.s3.DEFAULTS)}return c}};return t=(0,s._)([(0,c.j)("esri.core.Clonable")],t),t};let u=class extends(h(n.Z)){};u=(0,s._)([(0,c.j)("esri.core.Clonable")],u)},13867:(e,t,i)=>{i.d(t,{z:()=>n});var s=i(69801);class n{constructor(e,t){this._storage=new s.WJ,this.id="",this.name="",this.size=0,this._storage.maxSize=e,this._storage.register(this),t&&this._storage.registerRemoveFunc("",t)}destroy(){this._storage.deregister(this),this._storage.destroy()}put(e,t,i=1){this._storage.put(this,e,t,i,1)}pop(e){return this._storage.pop(this,e)}get(e){return this._storage.get(this,e)}clear(){this._storage.clearAll()}get maxSize(){return this._storage.maxSize}set maxSize(e){this._storage.maxSize=e}resetHitRate(){}}},69801:(e,t,i)=>{i.d(t,{WJ:()=>o,Xq:()=>a});var s,n,r=i(44553);(n=s||(s={}))[n.ALL=0]="ALL",n[n.SOME=1]="SOME";class a{constructor(e,t,i){this.name=e,this._storage=t,this.id=l+++":",this.size=0,this.maxSize=0,this._removeFunc=!1,this._hit=0,this._miss=0,this._storage.register(this),i&&(this._storage.registerRemoveFunc(this.id,i),this._removeFunc=!0)}destroy(){this._storage.clear(this),this._removeFunc&&this._storage.deregisterRemoveFunc(this.id),this._storage.deregister(this),this._storage=null}get hitRate(){return this._hit/(this._hit+this._miss)}get sizeAll(){return this._storage.size}resetHitRate(){this._hit=this._miss=0}put(e,t,i,s=0){this._storage.put(this,e,t,i,s)}get(e){const t=this._storage.get(this,e);return void 0===t?++this._miss:++this._hit,t}peek(e){return this._storage.peek(this,e)}pop(e){const t=this._storage.pop(this,e);return void 0===t?++this._miss:++this._hit,t}updateSize(e,t,i){this._storage.updateSize(this,e,t,i)}clear(){this._storage.clear(this)}clearAll(){this._storage.clearAll()}get performanceInfo(){return this._storage.performanceInfo}resetStats(){this._storage.resetStats()}}class o{get size(){return this._size}constructor(e=10485760){this._maxSize=e,this._db=new Map,this._size=0,this._hit=0,this._miss=0,this._removeFuncs=new r.Z,this._users=new r.Z}destroy(){this.clearAll(),this._removeFuncs.clear(),this._users.clear(),this._db=null}register(e){this._users.push(e)}deregister(e){this._users.removeUnordered(e)}registerRemoveFunc(e,t){this._removeFuncs.push([e,t])}deregisterRemoveFunc(e){this._removeFuncs.filterInPlace((t=>t[0]!==e))}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=Math.max(e,0),this._checkSizeLimits()}put(e,t,i,n,r){t=e.id+t;const a=this._db.get(t);if(a&&(this._size-=a.size,e.size-=a.size,this._db.delete(t),a.entry!==i&&this._notifyRemove(t,a.entry,s.ALL)),n>this._maxSize)return void this._notifyRemove(t,i,s.ALL);if(void 0===i)return void console.warn("Refusing to cache undefined entry ");if(!n||n<0)return console.warn(`Refusing to cache entry with size ${n} for key ${t}`),void this._notifyRemove(t,i,s.ALL);const o=1+Math.max(r,-3)- -3;this._db.set(t,{entry:i,size:n,lifetime:o,lives:o}),this._size+=n,e.size+=n,this._checkSizeLimits()}updateSize(e,t,i,n){t=e.id+t;const r=this._db.get(t);if(r&&r.entry===i){for(this._size-=r.size,e.size-=r.size;n>this._maxSize;){const e=this._notifyRemove(t,i,s.SOME);if(!(null!=e&&e>0))return void this._db.delete(t);n=e}r.size=n,this._size+=n,e.size+=n,this._checkSizeLimits()}}pop(e,t){t=e.id+t;const i=this._db.get(t);if(i)return this._size-=i.size,e.size-=i.size,this._db.delete(t),++this._hit,i.entry;++this._miss}get(e,t){t=e.id+t;const i=this._db.get(t);if(void 0!==i)return this._db.delete(t),i.lives=i.lifetime,this._db.set(t,i),++this._hit,i.entry;++this._miss}peek(e,t){const i=this._db.get(e.id+t);return i?++this._hit:++this._miss,i?.entry}get performanceInfo(){const e={Size:Math.round(this._size/1048576)+"/"+Math.round(this._maxSize/1048576)+"MB","Hit rate":Math.round(100*this._getHitRate())+"%",Entries:this._db.size.toString()},t={},i=new Array;this._db.forEach(((e,s)=>{const n=e.lifetime;i[n]=(i[n]||0)+e.size,this._users.forAll((i=>{const{id:n,name:r}=i;if(s.startsWith(n)){const i=t[r]||0;t[r]=i+e.size}}))}));const s={};this._users.forAll((e=>{const i=e.name;if("hitRate"in e&&"number"==typeof e.hitRate&&!isNaN(e.hitRate)&&e.hitRate>0){const n=t[i]||0;t[i]=n,s[i]=Math.round(100*e.hitRate)+"%"}else s[i]="0%"}));const n=Object.keys(t);n.sort(((e,i)=>t[i]-t[e])),n.forEach((i=>e[i]=Math.round(t[i]/2**20)+"MB / "+s[i]));for(let t=i.length-1;t>=0;--t){const s=i[t];s&&(e["Priority "+(t+-3-1)]=Math.round(s/this._size*100)+"%")}return e}resetStats(){this._hit=this._miss=0,this._users.forAll((e=>e.resetHitRate()))}clear(e){const t=e.id;this._db.forEach(((e,i)=>{i.startsWith(t)&&(this._size-=e.size,this._db.delete(i),this._notifyRemove(i,e.entry,s.ALL))})),e.size=0}clearAll(){this._db.forEach(((e,t)=>this._notifyRemove(t,e.entry,s.ALL))),this._users.forEach((e=>e.size=0)),this._size=0,this._db.clear()}_getHitRate(){return this._hit/(this._hit+this._miss)}_notifyRemove(e,t,i){let s;return this._removeFuncs.some((n=>{if(e.startsWith(n[0])){const e=n[1](t,i);return"number"==typeof e&&(s=e),!0}return!1})),s}_checkSizeLimits(){if(this._size>this._maxSize)for(const[e,t]of this._db)if(this._purgeItem(e,t),this._size<=.9*this.maxSize)return;this._users.forEach((e=>{if(e.maxSize>0&&e.size>e.maxSize)for(const[t,i]of this._db)if(t.startsWith(e.id)&&(this._purgeItem(t,i,e),e.size<=.9*e.maxSize))return}))}_purgeItem(e,t,i=this._users.find((t=>e.startsWith(t.id)))){if(this._db.delete(e),t.lives<=1){this._size-=t.size,i&&(i.size-=t.size);const n=this._notifyRemove(e,t.entry,s.SOME);null!=n&&n>0&&(this._size+=n,i&&(i.size+=n),t.lives=t.lifetime,t.size=n,this._db.set(e,t))}else--t.lives,this._db.set(e,t)}}let l=0},17445:(e,t,i)=>{i.d(t,{N1:()=>f,YP:()=>l,Z_:()=>m,gx:()=>c,nn:()=>y,on:()=>u,tX:()=>g}),i(66643),i(46791);var s=i(91460),n=i(50758),r=i(70586),a=i(95330),o=i(26258);function l(e,t,i={}){return h(e,t,i,p)}function c(e,t,i={}){return h(e,t,i,d)}function h(e,t,i={},s){let n=null;const a=i.once?(e,i)=>{s(e)&&((0,r.hw)(n),t(e,i))}:(e,i)=>{s(e)&&t(e,i)};if(n=(0,o.aQ)(e,a,i.sync,i.equals),i.initial){const t=e();a(t,t)}return n}function u(e,t,i,a={}){let o=null,c=null,h=null;function u(){o&&c&&(c.remove(),a.onListenerRemove?.(o),o=null,c=null)}function f(e){a.once&&a.once&&(0,r.hw)(h),i(e)}const p=l(e,((e,i)=>{u(),(0,s.vT)(e)&&(o=e,c=(0,s.on)(e,t,f),a.onListenerAdd?.(e))}),{sync:a.sync,initial:!0});return h=(0,n.kB)((()=>{p.remove(),u()})),h}function f(e,t){return function(e,t,i){if((0,a.Hc)(i))return Promise.reject((0,a.zE)());const s=e();if(t?.(s))return Promise.resolve(s);let o=null;function l(){o=(0,r.hw)(o)}return new Promise(((s,r)=>{o=(0,n.AL)([(0,a.fu)(i,(()=>{l(),r((0,a.zE)())})),h(e,(e=>{l(),s(e)}),{sync:!1,once:!0},t??p)])}))}(e,d,t)}function p(e){return!0}function d(e){return!!e}i(87538);const m={sync:!0},y={initial:!0},g={sync:!0,initial:!0}},95528:(e,t,i)=>{i.d(t,{t:()=>o});var s=i(22974),n=i(58971),r=i(10661);class a{constructor(e,t){this._observable=new r.s,this._value=e,this._equalityFunction=t}get value(){return(0,n.it)(this._observable),this._value}set value(e){this._equalityFunction(e,this._value)||(this._value=e,this._observable.notify())}mutate(e){e(this._value),this._observable.notify()}}function o(e,t=s.y7){return new a(e,t)}},16306:(e,t,i)=>{i.d(t,{aX:()=>v});var s=i(68773),n=i(20102),r=i(92604),a=i(38913),o=i(58901),l=i(73913),c=i(8744),h=i(40488),u=(i(66577),i(3172)),f=i(33955),p=i(11282),d=i(17452);async function m(e,t,i){const s="string"==typeof e?(0,d.mN)(e):e,n=t[0].spatialReference,r=(0,f.Ji)(t[0]),a={...i,query:{...s.query,f:"json",sr:(0,c.B9)(n),geometries:JSON.stringify((l=t,{geometryType:(0,f.Ji)(l[0]),geometries:l.map((e=>e.toJSON()))}))}},{data:o}=await(0,u.Z)(s.path+"/simplify",a);var l;return function(e,t,i){const s=(0,f.q9)(t);return e.map((e=>{const t=s.fromJSON(e);return t.spatialReference=i,t}))}(o.geometries,r,n)}const y=r.Z.getLogger("esri.geometry.support.normalizeUtils");function g(e){return"polygon"===e[0].type}function x(e){return"polyline"===e[0].type}function _(e,t,i){if(t){const t=function(e,t){if(!(e instanceof o.Z||e instanceof a.Z)){const e="straightLineDensify: the input geometry is neither polyline nor polygon";throw y.error(e),new n.Z(e)}const i=(0,l.x3)(e),s=[];for(const e of i){const i=[];s.push(i),i.push([e[0][0],e[0][1]]);for(let s=0;s<e.length-1;s++){const n=e[s][0],r=e[s][1],a=e[s+1][0],o=e[s+1][1],l=Math.sqrt((a-n)*(a-n)+(o-r)*(o-r)),c=(o-r)/l,h=(a-n)/l,u=l/t;if(u>1){for(let e=1;e<=u-1;e++){const s=e*t,a=h*s+n,o=c*s+r;i.push([a,o])}const e=(l+Math.floor(u-1)*t)/2,s=h*e+n,a=c*e+r;i.push([s,a])}i.push([a,o])}}return function(e){return"polygon"===e.type}(e)?new a.Z({rings:s,spatialReference:e.spatialReference}):new o.Z({paths:s,spatialReference:e.spatialReference})}(e,1e6);e=(0,h.Sx)(t,!0)}return i&&(e=(0,l.Sy)(e,i)),e}function w(e,t,i){if(Array.isArray(e)){const s=e[0];if(s>t){const i=(0,l.XZ)(s,t);e[0]=s+i*(-2*t)}else if(s<i){const t=(0,l.XZ)(s,i);e[0]=s+t*(-2*i)}}else{const s=e.x;if(s>t){const i=(0,l.XZ)(s,t);e=e.clone().offset(i*(-2*t),0)}else if(s<i){const t=(0,l.XZ)(s,i);e=e.clone().offset(t*(-2*i),0)}}return e}function b(e,t){let i=-1;for(let s=0;s<t.cutIndexes.length;s++){const n=t.cutIndexes[s],r=t.geometries[s],a=(0,l.x3)(r);for(let e=0;e<a.length;e++){const t=a[e];t.some((i=>{if(i[0]<180)return!0;{let i=0;for(let e=0;e<t.length;e++){const s=t[e][0];i=s>i?s:i}i=Number(i.toFixed(9));const s=-360*(0,l.XZ)(i,180);for(let i=0;i<t.length;i++){const t=r.getPoint(e,i);r.setPoint(e,i,t.clone().offset(s,0))}return!0}}))}if(n===i){if(g(e))for(const t of(0,l.x3)(r))e[n]=e[n].addRing(t);else if(x(e))for(const t of(0,l.x3)(r))e[n]=e[n].addPath(t)}else i=n,e[n]=r}return e}async function v(e,t,i){if(!Array.isArray(e))return v([e],t);t&&"string"!=typeof t&&y.warn("normalizeCentralMeridian()","The url object is deprecated, use the url string instead");const n="string"==typeof t?t:t?.url??s.default.geometryServiceUrl;let r,d,g,x,I,S,R,T,C=0;const k=[],M=[];for(const t of e)if(null!=t)if(r||(r=t.spatialReference,d=(0,c.C5)(r),g=r.isWebMercator,S=g?102100:4326,x=l.UZ[S].maxX,I=l.UZ[S].minX,R=l.UZ[S].plus180Line,T=l.UZ[S].minus180Line),d)if("mesh"===t.type)M.push(t);else if("point"===t.type)M.push(w(t.clone(),x,I));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map((e=>w(e,x,I))),M.push(e)}else if("extent"===t.type){const e=t.clone()._normalize(!1,!1,d);M.push(e.rings?new a.Z(e):e)}else if(t.extent){const e=t.extent,i=(0,l.XZ)(e.xmin,I)*(2*x);let s=0===i?t.clone():(0,l.Sy)(t.clone(),i);e.offset(i,0),e.intersects(R)&&e.xmax!==x?(C=e.xmax>C?e.xmax:C,s=_(s,g),k.push(s),M.push("cut")):e.intersects(T)&&e.xmin!==I?(C=e.xmax*(2*x)>C?e.xmax*(2*x):C,s=_(s,g,360),k.push(s),M.push("cut")):M.push(s)}else M.push(t.clone());else M.push(t);else M.push(t);let F=(0,l.XZ)(C,x),z=-90;const O=F,P=new o.Z;for(;F>0;){const e=360*F-180;P.addPath([[e,z],[e,-1*z]]),z*=-1,F--}if(k.length>0&&O>0){const t=b(k,await async function(e,t,i,s){const n=(0,p.en)(e),r=t[0].spatialReference,a={...s,responseType:"json",query:{...n.query,f:"json",sr:(0,c.B9)(r),target:JSON.stringify({geometryType:(0,f.Ji)(t[0]),geometries:t}),cutter:JSON.stringify(i)}},o=await(0,u.Z)(n.path+"/cut",a),{cutIndexes:l,geometries:h=[]}=o.data;return{cutIndexes:l,geometries:h.map((e=>{const t=(0,f.im)(e);return t.spatialReference=r,t}))}}(n,k,P,i)),s=[],r=[];for(let i=0;i<M.length;i++){const n=M[i];if("cut"!==n)r.push(n);else{const n=t.shift(),a=e[i];null!=a&&"polygon"===a.type&&a.rings&&a.rings.length>1&&n.rings.length>=a.rings.length?(s.push(n),r.push("simplify")):r.push(g?(0,h.$)(n):n)}}if(!s.length)return r;const a=await m(n,s,i),o=[];for(let e=0;e<r.length;e++){const t=r[e];"simplify"!==t?o.push(t):o.push(g?(0,h.$)(a.shift()):a.shift())}return o}const E=[];for(let e=0;e<M.length;e++){const t=M[e];if("cut"!==t)E.push(t);else{const e=k.shift();E.push(!0===g?(0,h.$)(e):e)}}return E}},73913:(e,t,i)=>{i.d(t,{Sy:()=>l,UZ:()=>a,XZ:()=>o,x3:()=>c});var s=i(58901),n=i(82971),r=i(33955);const a={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new s.Z({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:n.Z.WebMercator}),minus180Line:new s.Z({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:n.Z.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new s.Z({paths:[[[180,-180],[180,180]]],spatialReference:n.Z.WGS84}),minus180Line:new s.Z({paths:[[[-180,-180],[-180,180]]],spatialReference:n.Z.WGS84})}};function o(e,t){return Math.ceil((e-t)/(2*t))}function l(e,t){const i=c(e);for(const e of i)for(const i of e)i[0]+=t;return e}function c(e){return(0,r.oU)(e)?e.rings:e.paths}},78719:(e,t,i)=>{i.r(t),i.d(t,{default:()=>wt});var s=i(43697),n=i(51773),r=i(2368),a=i(20102),o=i(92604),l=i(16453),c=i(95330),h=i(17445),u=i(5600),f=i(75215),p=(i(77734),i(80442)),d=i(36030),m=i(52011),y=i(87085),g=i(17287),x=i(71612),_=i(17017),w=(i(66577),i(30030)),b=i(3172),v=i(71715),I=i(8744),S=i(66677),R=i(21506),T=i(35956),C=i(29876),k=i(45663),M=i(88281),F=i(11145),z=i(96674),O=i(609),P=i(39450),E=i(36679),Z=i(99815),N=i(73506),D=i(94139);const A=new Map,B=new class{constructor(e=15e3,t=5e3){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=e,this._interval=Math.min(e,t)}decreaseRefCount(e,t){const i=e+"/"+t,s=this._cachedBlocks;if(s.has(i)){const e=s.get(i);return e.refCount--,e.refCount<=0&&(s.delete(i),e.controller&&e.controller.abort()),e.refCount}return 0}getBlock(e,t){const i=e+"/"+t,s=this._cachedBlocks;if(s.has(i)){const e=s.get(i);return e.ts=Date.now(),e.refCount++,s.delete(i),s.set(i,e),e.block}return null}putBlock(e,t,i,s){const n=this._cachedBlocks,r=e+"/"+t;if(n.has(r)){const e=n.get(r);e.ts=Date.now(),e.refCount++}else n.set(r,{block:i,ts:Date.now(),refCount:1,controller:s});this._trim(),this._updateTimer()}deleteBlock(e,t){const i=this._cachedBlocks,s=e+"/"+t;i.has(s)&&i.delete(s)}updateMaxSize(e){this._size=e,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(null!=this._timer)return;const e=this._cachedBlocks;this._timer=setInterval((()=>{const t=Array.from(e),i=Date.now();for(let s=0;s<t.length&&t[s][1].ts<=i-this._duration;s++)e.delete(t[s][0]);0===e.size&&this._clearTimer()}),this._interval)}_trim(){const e=this._cachedBlocks;if(-1===this._size||this._size>=e.size)return;const t=Array.from(e);for(let i=0;i<t.length-this._size;i++)e.delete(t[i][0])}_clearTimer(){null!=this._timer&&(clearInterval(this._timer),this._timer=null)}};function L(e,t){return null==t?e:`${e}?sliceId=${t}`}function J(e,t,i){const s=A.get(e);if(!s)return null==t?B.decreaseRefCount(e,i):0;if(null==t||null==s[t])return B.decreaseRefCount(e,i);const n=s[t]?.cache,r=n?.get(i);if(n&&r){if(r.refCount--,0===r.refCount){n.delete(i);for(let e=0;e<s.length;e++)s[e]?.cache.delete(i);r.controller&&r.controller.abort()}return r.refCount}return 0}function H(e,t,i){const s=A.get(e);if(!s)return null==t?B.getBlock(e,i):null;if(null==t||null==s[t]){for(let e=0;e<s.length;e++){const t=s[e]?.cache.get(i);if(t)return t.refCount++,t.block}return B.getBlock(e,i)}const n=s[t]?.cache.get(i);if(n)return n.refCount++,n.block;for(let e=0;e<s.length;e++){if(e===t||!s[e])continue;const n=s[e]?.cache,r=n?.get(i);if(n&&r)return r.refCount++,n.set(i,r),r.block}return null}function q(e,t,i,s,n=null){const r=A.get(e);if(!r)return void(null==t&&B.putBlock(e,i,s,n));if(null==t||null==r[t])return void B.putBlock(e,i,s,n);const a={refCount:1,block:s,isResolved:!1,isRejected:!1,controller:n};s.then((()=>a.isResolved=!0)).catch((()=>a.isRejected=!0)),r[t]?.cache.set(i,a)}function j(e,t,i){const s=A.get(e);s?null!=t&&null!=s[t]?s[t]?.cache.delete(i):B.deleteBlock(e,i):null==t&&B.deleteBlock(e,i)}var W=i(81578),U=i(75993),G=i(55914),$=i(80676),V=i(79384),X=i(6570);let Y=0,K=class extends((0,O.v)(z.wq)){constructor(){super(...arguments),this._tileFetchQueue=new V.e({concurrency:32,process:(e,t)=>this._fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=(0,N.zD)();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:F.Z.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=(0,N.ut)(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+Y++}set url(e){this._set("url",(0,S.Nm)(e,o.Z.getLogger(this)))}async open(e){throw new a.Z("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,s={}){const n=s.tileInfo||this.rasterInfo.storageInfo.tileInfo,r=this.getTileExtentFromTileInfo(e,t,i,n);return s={...s,noClip:!0},this.fetchPixels(r,n.size[0],n.size[1],s)}async identify(e,t={}){e=(0,f.TJ)(D.Z,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:s}=t,{rasterInfo:n}=this,{hasMultidimensionalTranspose:r,multidimensionalInfo:a}=n;let{transposedVariableName:o}=t;const l=null!=a&&r&&(null!=s||(0,Z.WU)(i));l&&!o&&(o=null!=i&&i.length>0?i[0].variableName??void 0:a.variables[0].name,t={...t,transposedVariableName:o}),t=this._getRequestOptionsWithSliceId(t);const{spatialReference:c,extent:h}=n,{datumTransformation:u}=t;let p=(0,N.nF)(e,c,u);if(!h.intersects(p))return{location:p,value:null};if(null!=n.transform){const e=n.transform.inverseTransform(p);if(!n.nativeExtent.intersects(e))return{location:e,value:null};p=e}let d=0;const m=null!=o&&null!=a&&n.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(m)return e.identify(p,t);const{pixelSize:i}=n,s=3,r=i.x*s/2,a=i.y*s/2,o=new X.Z({xmin:p.x-r,xmax:p.x+r,ymin:p.y-a,ymax:p.y+a,spatialReference:c}),l={interpolation:"nearest"},{pixelBlock:h}=await e.fetchPixels(o,s,s,l),{pixelBlock:u}=await this.fetchPixels(o,s,s,l);if(null==h)return{location:p,value:null};const f=Math.floor(s*s*.5),d=!h.mask||h.mask[f]?h.pixels.map((e=>e[f])):null;let y;return null!=u&&(y=!u.mask||u.mask[f]?u.pixels.map((e=>e[f])):void 0),{location:p,value:d,processedValue:y,pyramidLevel:0}}if(!m)if(t.srcResolution)d=(0,N.kr)(t.srcResolution,n,this.ioConfig.sampling).pyramidLevel;else if(d=await this.computeBestPyramidLevelForLocation(e,t),null==d)return{location:p,value:null};const y=this.identifyPixelLocation(p,d,null,m);if(null===y)return{location:p,value:null};const{row:g,col:x,rowOffset:_,colOffset:w,blockWidth:b}=y,v=o??t.sliceId,I=L(this.rasterId,v),S=`${d}/${g}/${x}`;let R=H(I,null,S);null==R&&(R=this.fetchRawTile(d,g,x,t),q(I,null,S,R));const T=await R;if(!T?.pixels?.length)return{location:p,value:null};const C=_*b+w;return this._processIdentifyResult(T,{srcLocation:p,position:C,pyramidLevel:d,useTransposedTile:!!m,requestSomeSlices:l,identifyOptions:t})}async fetchPixels(e,t,i,s={}){e=(0,N.Fi)(e),s=this._getRequestOptionsWithSliceId(s);const{_hasNoneOrGCSShiftTransform:n}=this;if(s.requestRawData&&n)return this._fetchPixels(e,t,i,s);const r=(0,N.ut)(e.spatialReference),a=(0,N.Hq)(e);if(null==r||0===a||1===a&&this._isGlobalWrappableSource&&n)return this._fetchPixels(e,t,i,s);if(a>=3)return{extent:e,pixelBlock:null};const o=[],{xmin:l,xmax:c}=e,h=Math.round(r/(c-l)*t),u=h-Math.round((r/2-l)/(c-l)*t);let f=0;const p=[];for(let n=0;n<=a;n++){const d=new X.Z({xmin:0===n?l:-r/2,xmax:n===a?c-r*n:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),m=0===n?h-u:n===a?t-f:h;f+=m,p.push(m);const y=s.disableWrapAround&&n>0?null:this._fetchPixels(d,m,i,s);o.push(y)}const d=(await Promise.all(o)).map((e=>e?.pixelBlock));let m=null;const y={width:t,height:i};return m=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:p},s)).pixelBlock:(0,G.us)(d,y,{blockWidths:p}),{extent:e,srcExtent:(0,N.tB)(e,this.rasterInfo.spatialReference,s.datumTransformation),pixelBlock:m}}async fetchRawPixels(e,t,i,s={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const n=await this._fetchRawTiles(e,t,i,s),{nativeExtent:r,nativePixelSize:a,storageInfo:o}=this.rasterInfo,l=2**e,c=a.x*l,h=a.y*l,u=new X.Z({xmin:r.xmin+c*t.x,xmax:r.xmin+c*(t.x+i.width-1),ymin:r.ymax-h*(t.y+i.height-1),ymax:r.ymax-h*t.y,spatialReference:r.spatialReference});if(!n)return{extent:u,srcExtent:u,pixelBlock:null};const{pixelBlocks:f,mosaicSize:p}=n;if(1===f.length&&null!=f[0]&&f[0].width===i.width&&f[0].height===i.height)return{extent:u,srcExtent:u,pixelBlock:n.pixelBlocks[0]};const d=e>0?o.pyramidBlockWidth:o.blockWidth,m=e>0?o.pyramidBlockHeight:o.blockHeight,y={x:t.x%d,y:t.y%m};let g;return g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:f,srcMosaicSize:p,destDimension:i,clipOffset:y,clipSize:i,coefs:null,sampleSpacing:null,interpolation:s.interpolation,alignmentInfo:null,blockWidths:null},s)).pixelBlock:(0,G.us)(f,p,{clipOffset:y,clipSize:i}),{extent:u,srcExtent:u,pixelBlock:g}}fetchRawTile(e,t,i,s){throw new a.Z("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return(0,N.tB)(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?(0,U.J)(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,t,i=0){const{customFetchParameters:s}=this.ioConfig,{range:n,query:r,headers:a}=t;i=i??t.retryCount??this.ioConfig.retryCount;const o=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await(0,b.Z)(e,{...t,query:{...r,...s},headers:{...a,...o}})}catch(s){if(i>0)return i--,this.request(e,t,i);throw s}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:(0,Z.gk)(e,t)}getTileExtentFromTileInfo(e,t,i,s){const n=s.lodAt(e);return this.getTileExtent({x:n.resolution,y:n.resolution},t,i,s.origin,s.spatialReference,s.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:s}=this.rasterInfo;if(!e.tileInfo){const n=[],r=e.maximumPyramidLevel||0;let a=Math.max(s.x,s.y),o=1/.0254*96*a;for(let e=0;e<=r;e++)n.unshift(new P.Z({level:r-e,resolution:a,scale:o})),a*=2,o*=2;const l=new D.Z({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new F.Z({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:n}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,s){const{width:n,height:r,nativeExtent:a,pixelSize:o,spatialReference:l}=e,c=new D.Z({x:a.xmin,y:a.ymax,spatialReference:l});null==s&&(s=Math.max(0,Math.round(Math.log(Math.max(n,r))/Math.LN2-8)));const h=this.computeBlockBoundary(a,512,512,{x:a.xmin,y:a.ymax},[o],s);e.storageInfo=new E.Z({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:s,blockBoundary:h})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,s,n,r=0,a=2){if(1===n.length&&r>0){n=[...n];let{x:e,y:t}=n[0];for(let i=0;i<r;i++)e*=a,t*=a,n.push({x:e,y:t})}const o=[],{x:l,y:c}=s;for(let s=0;s<n.length;s++){const{x:r,y:a}=n[s];o.push({minCol:Math.floor((e.xmin-l+.1*r)/t/r),maxCol:Math.floor((e.xmax-l-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*a)/i/a),maxRow:Math.floor((c-e.ymin-.1*a)/i/a)})}return o}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:s}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const n=s**e;return{x:t.x*n,y:t.y*n}}identifyPixelLocation(e,t,i,s){const{spatialReference:n,nativeExtent:r,storageInfo:a}=this.rasterInfo,{maximumPyramidLevel:o,origin:l,transposeInfo:c}=a,h=s&&null!=c?c.tileSize[0]:a.blockWidth,u=s&&null!=c?c.tileSize[1]:a.blockHeight,f=(0,N.nF)(e,n,i);if(!r.intersects(f))return null;if(t<0||t>o)return null;const p=this.getPyramidPixelSize(t),{x:d,y:m}=p,y=(l.y-f.y)/m/u,g=(f.x-l.x)/d/h,x=Math.min(u-1,Math.floor((y-Math.floor(y))*u)),_=Math.min(h-1,Math.floor((g-Math.floor(g))*h));return{pyramidLevel:t,row:Math.floor(y),col:Math.floor(g),rowOffset:x,colOffset:_,blockWidth:h,srcLocation:f}}getTileExtent(e,t,i,s,n,r){const[a,o]=r,l=s.x+i*a*e.x,c=l+a*e.x,h=s.y-t*o*e.y,u=h-o*e.y;return new X.Z({xmin:l,xmax:c,ymin:u,ymax:h,spatialReference:n})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const s=this.rasterInfo.storageInfo.blockBoundary[e];return!s||s.maxRow<t||s.maxCol<i||s.minRow>t||s.minCol>i}async _fetchPixels(e,t,i,s={}){let n=(0,N.Hq)(e);if(n>=2)return{extent:e,pixelBlock:null};const r=this._getSourceDataInfo(e,t,i,s),{pyramidLevel:a,srcResolution:o,srcExtent:l,srcWidth:c,srcHeight:h,ul:u}=r;if(0===c||0===h)return{extent:e,srcExtent:l,pixelBlock:null};const{rasterInfo:f}=this,p=f.transform,d="gcs-shift"===p?.type,m=null!=(0,N.ut)(e.spatialReference);!d&&m||(n=(0,N.Hq)(r.srcExtent,d));const y=await this._fetchRawTiles(a,u,{width:c,height:h,wrapCount:n},s);if(!y)return{extent:e,srcExtent:l,pixelBlock:null};const g=f.storageInfo,x=a>0?g.pyramidBlockWidth:g.blockWidth,_=a>0?g.pyramidBlockHeight:g.blockHeight;let{x:w,y:b}=f.pixelSize;if(a>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=g;if(null!=e&&e[a-1])({x:w,y:b}=e[a-1]);else{const e=t**a;w*=e,b*=e}}const v=f.spatialReference,I=new D.Z({x:w,y:b,spatialReference:v}),S=x===c&&_===h&&u.x%x==0&&u.y%_==0,R=new D.Z({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),T=!e.spatialReference.equals(v),C=v.isGeographic?1e-9:1e-4,{datumTransformation:k}=s;if(!T&&S&&1===y.pixelBlocks.length&&x===t&&_===i&&this._isSameResolution(o,R,C))return{extent:e,srcExtent:l,srcTilePixelSize:I,pixelBlock:y.pixelBlocks[0]};const M=m&&null!=(0,N.ut)(l.spatialReference)&&this._hasNoneOrGCSShiftTransform,F=s.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");F&&!this.rasterJobHandler&&await(0,N.zD)();const z=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:R.toJSON(),datumTransformation:k,rasterTransform:p,hasWrapAround:n>0||M,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:F},s):(0,N.Qp)({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:R,datumTransformation:k,rasterTransform:p,hasWrapAround:n>0||M,isAdaptive:!1,includeGCSGrid:F});let O;const P=!s.requestRawData,E={rows:z.spacing[0],cols:z.spacing[1]},Z=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(a,y.extent.xmin):void 0,{pixelBlocks:A,mosaicSize:B,isPartiallyFilled:L}=y;let J=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:A,srcMosaicSize:B,destDimension:P?{width:t,height:i}:null,coefs:P?z.coefficients:null,sampleSpacing:P?E:null,projectDirections:F,gcsGrid:F?z.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:s.interpolation,alignmentInfo:Z,blockWidths:null},s);({pixelBlock:O,localNorthDirections:J}=e)}else{const e=(0,G.us)(A,B,{alignmentInfo:Z});O=P?(0,G.Uk)(e,{width:t,height:i},z.coefficients,E,s.interpolation):e,F&&z.gcsGrid&&(J=(0,G.Qh)({width:t,height:i},z.gcsGrid),O=(0,$.xQ)(O,this.rasterInfo.dataType,J))}return s.requestRawData||F?{extent:e,srcExtent:l,srcTilePixelSize:I,pixelBlock:O,transformGrid:z,localNorthDirections:J,isPartiallyFilled:L}:{extent:e,srcExtent:l,srcTilePixelSize:I,pixelBlock:O}}async _fetchRawTiles(e,t,i,s){const{origin:n,blockBoundary:r}=this.rasterInfo.storageInfo,{blockWidth:a,blockHeight:o}=this.getBlockWidthHeight(e);let{x:l,y:c}=t,{width:h,height:u,wrapCount:f}=i;const p=this._getRasterTileAlignmentInfo(e,0);s.buffer&&(l-=s.buffer.cols,c-=s.buffer.rows,h+=2*s.buffer.cols,u+=2*s.buffer.rows);let d=0,m=0,y=0;f&&null!=p&&(({worldColumnCountFromOrigin:m,originColumnOffset:y,rightPadding:d}=p),m*p.blockWidth-d>=l+h&&(d=0));const g=Math.floor(l/a),x=Math.floor(c/o),_=Math.floor((l+h+d-1)/a),w=Math.floor((c+u+d-1)/o),b=r[e];if(!b)return null;const{minRow:v,minCol:I,maxCol:S,maxRow:R}=b;if(0===f&&(w<v||_<I||x>R||g>S))return null;const T=new Array;let C=!1;const k=null==this.ioConfig.allowPartialFill?s.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=x;t<=w;t++)for(let i=g;i<=_;i++){let n=i;if(!s.disableWrapAround&&f&&null!=p&&m<=i&&(n=i-m-y),t>=v&&n>=I&&R>=t&&S>=n){const i=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:s},{signal:s.signal});k?T.push(new Promise((e=>{i.then((t=>e(t))).catch((()=>{C=!0,e(null)}))}))):T.push(i)}else T.push(Promise.resolve(null))}if(0===T.length)return null;const M=await Promise.all(T),F={height:(w-x+1)*o,width:(_-g+1)*a},{spatialReference:z}=this.rasterInfo,O=this.getPyramidPixelSize(e),{x:P,y:E}=O;return{extent:new X.Z({xmin:n.x+g*a*P,xmax:n.x+(_+1)*a*P,ymin:n.y-(w+1)*o*E,ymax:n.y-x*o*E,spatialReference:z}),pixelBlocks:M,mosaicSize:F,isPartiallyFilled:C}}_isSameResolution(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}_fetchRawTile(e,t,i,s){const n=this.rasterInfo.storageInfo.blockBoundary[e];if(!n)return Promise.resolve(null);const{minRow:r,minCol:a,maxCol:o,maxRow:l}=n;if(t<r||i<a||t>l||i>o)return Promise.resolve(null);const h=L(this.rasterId,s.sliceId),u=`${e}/${t}/${i}`;let f=H(h,s.registryId,u);if(null==f){const n=new AbortController;f=this.fetchRawTile(e,t,i,{...s,signal:n.signal}),q(h,s.registryId,u,f,n),f.catch((()=>j(h,s.registryId,u)))}return s.signal&&(0,c.fu)(s,(()=>{J(h,s.registryId,u)})),f}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if((2!==t||"vector-magdir"!==i)&&"vector-uv"!==i||2!==e?.length||!e[0]?.length)return null;const s=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[n,r]=e,a=[],o=[];for(let e=0;e<s;e++){const[t,i]=(0,$.Tg)([n[e],r[e]]);a.push(t),o.push(i)}return[a,o]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=(0,N.P_)(this.rasterInfo)),null==this._rasterTileAlighmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,s={}){const n={datumTransformation:s.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};s.srcResolution&&(n.srcResolution=s.srcResolution,this._updateSourceDataInfo(e,n));const r=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:a,srcHeight:o,pyramidLevel:l}=n,c=a/t,h=o/i,u=l<r&&c*h>=16,f=l===r&&this._requireTooManySrcTiles(a,o,t,i);if(u||f||0===a||0===o){const a=new D.Z({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let o=(0,N.VO)(a,this.rasterInfo.spatialReference,e,n.datumTransformation);const f=!o||s.srcResolution&&o.x+o.y<s.srcResolution.x+s.srcResolution.y;if(u&&s.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,h))/Math.LN2)-1;if(r-l+3>=e){const t=2**e;o={x:s.srcResolution.x*t,y:s.srcResolution.y*t}}}o&&(n.srcResolution=o,this._updateSourceDataInfo(e,n))}return this._requireTooManySrcTiles(n.srcWidth,n.srcHeight,t,i)&&(n.srcWidth=0,n.srcHeight=0),n}_requireTooManySrcTiles(e,t,i,s){const{tileInfo:n}=this.rasterInfo.storageInfo,r=e/i,a=t/s;return Math.ceil(e/n.size[0])*Math.ceil(t/n.size[1])>=256*Math.max(1,(i+s)/1024)||r>8||a>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,s=i.spatialReference,{srcResolution:n,datumTransformation:r}=t,{pyramidLevel:a,pyramidResolution:o,excessiveReading:l}=(0,N.kr)(n,i,this.ioConfig.sampling);if(l)return;let c=t.srcExtent||(0,N.tB)(e,s,r);if(null==c)return;const h=i.transform;h&&(c=h.inverseTransform(c)),t.srcExtent=c;const{x:u,y:f}=i.storageInfo.origin,p=Math.floor((c.xmin-u)/o.x+.1),d=Math.floor((f-c.ymax)/o.y+.1),m=Math.floor((c.xmax-u)/o.x-.1),y=Math.floor((f-c.ymin)/o.y-.1),g=c.width<.1*o.x?0:m-p+1,x=c.height<.1*o.y?0:y-d+1;t.pyramidLevel=a,t.pyramidResolution=o,t.srcWidth=g,t.srcHeight=x,t.ul={x:p,y:d}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:s,pyramidLevel:n,useTransposedTile:r}=t,a=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[s])return{location:i,value:null};const{multidimensionalInfo:o}=this.rasterInfo;if(null==o||!r){const t=e.pixels.map((e=>e[s])),r={location:i,value:t,pyramidLevel:n},a=this._computeMagDirValues(t.map((e=>[e])));return a?.length&&(r.magdirValue=a.map((e=>e[0]))),r}let l=e.pixels.map((e=>e.slice(s*a,s*a+a))),c=this._computeMagDirValues(l);const{requestSomeSlices:h,identifyOptions:u}=t;let f=(0,Z.MO)(o,u.transposedVariableName);if(h){const e=(0,Z.Ur)(f,u.multidimensionalDefinition,u.timeExtent);l=l.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),f=e.map((e=>f[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:l,pixelType:e.pixelType};let m;return null!=p&&((0,W.A)(d,p),m=d.mask),{location:i,value:null,dataSeries:f.map(((e,t)=>{const i={value:0===m?.[t]?null:l.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new T.Z({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:n}}};(0,s._)([(0,u.Cb)()],K.prototype,"_rasterTileAlighmentInfo",void 0),(0,s._)([(0,u.Cb)()],K.prototype,"_tileFetchQueue",void 0),(0,s._)([(0,u.Cb)({readOnly:!0})],K.prototype,"_isGlobalWrappableSource",null),(0,s._)([(0,u.Cb)({readOnly:!0})],K.prototype,"_hasNoneOrGCSShiftTransform",null),(0,s._)([(0,u.Cb)()],K.prototype,"rasterJobHandler",null),(0,s._)([(0,u.Cb)({readOnly:!0})],K.prototype,"rasterId",null),(0,s._)([(0,u.Cb)(R.HQ)],K.prototype,"url",null),(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],K.prototype,"datasetName",void 0),(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],K.prototype,"datasetFormat",void 0),(0,s._)([(0,u.Cb)()],K.prototype,"hasUniqueSourceStorageInfo",void 0),(0,s._)([(0,u.Cb)()],K.prototype,"rasterInfo",void 0),(0,s._)([(0,u.Cb)()],K.prototype,"ioConfig",void 0),(0,s._)([(0,u.Cb)()],K.prototype,"sourceJSON",void 0),K=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.BaseRaster")],K);const Q=K;var ee=i(67900),te=i(5847);async function ie(e,t,s){if("extent"===s.type)return function(e,t,i){const{width:s,height:n}=e,r=new Uint8Array(s*n),a=t.width/s,o=t.height/n;if(i.width/a<.5||i.height/o<.5)return new te.Z({pixelType:e.pixelType,width:s,height:n,mask:r,pixels:[...e.pixels]});const{xmin:l,xmax:c,ymin:h,ymax:u}=t,{xmin:f,xmax:p,ymin:d,ymax:m}=i,y=Math.max(l,f),g=Math.min(c,p),x=Math.max(h,d),_=Math.min(u,m),w=.5*a,b=.5*o;if(g-y<w||_-x<b||g<l+w||y>c-w||x>u-b||_<h+b)return new te.Z({pixelType:e.pixelType,width:s,height:n,mask:r,pixels:[...e.pixels]});const v=Math.max(0,(y-l)/a),I=Math.min(s,Math.max(0,(g-l)/a)),S=Math.max(0,(u-_)/o),R=Math.min(n,Math.max(0,(u-x)/o)),T=Math.round(v),C=Math.round(I)-1,k=Math.round(S),M=Math.round(R)-1;if(T===C&&v%1>.5&&I%1<.5||k===M&&S%1>.5&&R%1<.5)return new te.Z({pixelType:e.pixelType,width:s,height:n,mask:r,pixels:[...e.pixels]});if(0===T&&0===k&&C===s&&M===n)return e;const F=e.mask;for(let e=k;e<=M;e++)for(let t=T;t<=C;t++){const i=e*s+t;r[i]=F?F[i]:255}return new te.Z({pixelType:e.pixelType,width:s,height:n,mask:r,pixels:[...e.pixels]})}(e,t,s);const{width:n,height:r}=e,a=new Uint8Array(n*r),{contains:o,intersects:l}=await Promise.all([i.e(5837),i.e(1433)]).then(i.bind(i,61433));return l(t,s)?"polyline"===s.type?function(e,t,i){const{width:s,height:n}=e,r=new Uint8Array(s*n),a=t.width/s,o=t.height/n,{xmin:l,ymax:c}=t,{paths:h}=i,u=e.mask;for(let e=0;e<h.length;e++){const t=h[e];for(let e=0;e<t.length-1;e++){const[i,h]=t[e],[f,p]=t[e+1];let d=Math.floor((c-h)/o),m=Math.floor((c-p)/o);if(m<d){const e=d;d=m,m=e}d=Math.max(0,d),m=Math.min(n-1,m);const y=(f-i)/(p-h);for(let e=d;e<=m;e++){const t=e===d?Math.max(h,p):(n+1-e)*o,c=e===m?Math.min(h,p):t-o;let g=p===h?Math.floor((i-l)/a):Math.floor((y*(t-h)+i-l)/a),x=p===h?Math.floor((f-l)/a):Math.floor((y*(c-h)+i-l)/a);if(x<g){const e=g;g=x,x=e}const _=e*s;g=Math.max(0,g),x=Math.min(s-1,x);for(let e=_+g;e<=_+x;e++)r[e]=u?u[e]:255}}}return new te.Z({pixelType:e.pixelType,width:s,height:n,mask:r,pixels:[...e.pixels]})}(e,t,s):o(s,t)?e:function(e,t,i){if(!e)return e;const{width:s,height:n}=e,r=t.width/s,a=t.height/n,{xmin:o,ymax:l}=t;let c;if("extent"===i.type){const e=(i.xmin-o)/r,t=(i.xmax-o)/r,s=(l-i.ymax)/a,n=(l-i.ymin)/a;c=[[[e,s],[e,n],[t,n],[t,s],[e,s]]]}else c=i.rings.map((e=>e.map((([e,t])=>[(e-o)/r,(l-t)/a]))));const h=document.createElement("canvas");h.width=s,h.height=n;const u=h.getContext("2d");u.fillStyle="#f00",c.forEach((e=>{u.beginPath(),u.moveTo(e[0][0],e[0][1]);for(let t=0;t<e.length;t++)u.lineTo(e[t][0],e[t][1]);u.closePath(),u.fill()}));const f=u.getImageData(0,0,s,n).data,p=e.mask,d=s*n,m=new Uint8Array(d);for(let e=0;e<d;e++)p&&!p[e]||(m[e]=f[4*e+3]>127?255:0);return new te.Z({pixelType:e.pixelType,width:s,height:n,mask:m,maskIsAlpha:!1,pixels:[...e.pixels]})}(e,t,s):new te.Z({pixelType:e.pixelType,width:n,height:r,mask:a,maskIsAlpha:!1,pixels:[...e.pixels]})}var se=i(74889);let ne=class extends Q{constructor(){super(...arguments),this.datasetFormat="Function",this.tileType="Raster",this.rasterFunction=null}async open(e){await this.init();const{rasterFunction:t}=this;this.primaryRasters?.rasters?.length?t.sourceRasters=this.primaryRasters.rasters:(this.primaryRasters=t.getPrimaryRasters(),this.rasterJobHandler&&this.primaryRasters.rasters?.forEach((e=>e.rasterJobHandler=this.rasterJobHandler)));const{rasters:i,rasterIds:s}=this.primaryRasters,n=i.map((t=>t.rasterInfo?void 0:t.open(e)));await Promise.all(n);const r=i.map((({rasterInfo:e})=>e)),o=t.bind({rasterInfos:r,rasterIds:s});if(!o.success||0===r.length)throw new a.Z("raster-function:open",`cannot bind the function: ${o.error??""}`);const l="Table"===t.functionName?t:t.functionArguments?.raster;"Table"===l?.functionName&&(t.rasterInfo.attributeTable=se.Z.fromJSON(l.functionArguments.attributeTableAsRecordSet)),await this.syncJobHandler();const c=r[0];this.hasUniqueSourceStorageInfo=1===r.length||r.slice(1).every((e=>this._hasSameStorageInfo(e,c))),this.set("sourceJSON",i[0].sourceJSON),this.set("rasterInfo",t.rasterInfo)}async syncJobHandler(){return this.rasterJobHandler?.updateRasterFunction(this.rasterFunction)}async fetchPixels(e,t,i,s={}){const{rasters:n,rasterIds:r}=this.primaryRasters;let a=!1;const{interpolation:o}=s,l=this.rasterFunction.flatWebGLFunctionChain?.hasFocalFunction;!s.requestRawData&&"bilinear"!==o&&l&&(a=1===n.length&&!s.skipRasterFunction,s={...s,interpolation:"bilinear",requestRawData:a});const c=n.map((n=>n.fetchPixels(e,t,i,s))),h=await Promise.all(c),u=h.map((e=>e.pixelBlock)),f=a||s.requestRawData?h.map((e=>e.srcTilePixelSize)):null;if(s.skipRasterFunction||u.every((e=>null==e)))return h[0];const p=h.find((e=>null!=e.pixelBlock))?.extent??e;let d=this.rasterJobHandler?await this.rasterJobHandler.process({extent:p,primaryPixelBlocks:u,primaryPixelSizes:f,primaryRasterIds:r}):this.rasterFunction.process({extent:p,primaryPixelBlocks:u,primaryPixelSizes:f,primaryRasterIds:r});const{transformGrid:m}=h[0],y=s.noClip?null:this.getClippingGeometry(p.spatialReference);if(!a||null==d||null==m)return s.noClip||s.requestRawData||null==d||null==y||(d=await ie(d,p,y)),{...h[0],pixelBlock:d};const g={rows:m.spacing[0],cols:m.spacing[1]};let x;return x=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:[d],srcMosaicSize:{width:d.width,height:d.height},destDimension:{width:t,height:i},coefs:m.coefficients,sampleSpacing:g,projectDirections:!1,gcsGrid:null,isUV:!1,interpolation:o,alignmentInfo:void 0,blockWidths:null},s)).pixelBlock:(0,G.Uk)(d,{width:t,height:i},m.coefficients,g,o),s.noClip||s.requestRawData||null==x||null==y||(x=await ie(x,e,y)),{extent:e,srcExtent:h[0].srcExtent,pixelBlock:x}}getClippingGeometry(e){const t=this.rasterFunction.getClippingGeometries()[0]?.clippingGeometry;return e&&t?.spatialReference?e.equals(t.spatialReference)?t:(0,N.Wt)(t,e):t}_hasSameStorageInfo(e,t){const{storageInfo:i,pixelSize:s,spatialReference:n,extent:r}=e,{storageInfo:a,pixelSize:o,spatialReference:l,extent:c}=t;return s.x===o.x&&s.y===o.y&&n.equals(l)&&r.equals(c)&&i.blockHeight===a.blockHeight&&i.blockWidth===a.blockWidth&&i.maximumPyramidLevel===a.maximumPyramidLevel}};(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],ne.prototype,"datasetFormat",void 0),(0,s._)([(0,u.Cb)()],ne.prototype,"tileType",void 0),(0,s._)([(0,u.Cb)()],ne.prototype,"rasterFunction",void 0),(0,s._)([(0,u.Cb)()],ne.prototype,"primaryRasters",void 0),ne=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.FunctionRaster")],ne);const re=ne;var ae=i(24197),oe=i(15612),le=i(67058),ce=i(72758),he=i(79681),ue=i(23808),fe=i(82971);const pe=o.Z.getLogger("esri.layers.mixins.ImageryTileMixin"),de=e=>{let t=class extends e{constructor(...e){super(...e),this._isConstructedFromFunctionRaster=!1,this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster="Function"===e[0]?.raster?.datasetFormat}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}set rasterFunction(e){"none"===e?.functionName?.toLowerCase()&&(e=void 0),this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",(0,S.Nm)(e,pe))}set renderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("renderer",e),this.updateRenderer())}readRenderer(e,t,i){const s=t?.layerDefinition?.drawingInfo?.renderer;return(0,w.ij)(s,i)||void 0}async convertVectorFieldData(e,t){if(null==e||!this.rasterInfo)return null;const i=this._rasterJobHandler.instance,s=this.rasterInfo.dataType;return i?i.convertVectorFieldData({pixelBlock:e,dataType:s},t):(0,$.KC)(e,s)}async computeStatisticsHistograms(e,t){e=(0,f.TJ)(he.Z,e).clone();const{rasterInfo:i}=this,{geometry:s}=e;if(null==s)throw new a.Z("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=s;const{spatialReference:r}=i;s.spatialReference.equals(r)||(await(0,N.zD)(),n="extent"===s.type?(0,N.tB)(s,r):(0,N.Wt)(s,r));const o=e.pixelSize??new D.Z({x:i.pixelSize.x,y:i.pixelSize.y,spatialReference:r}),{extent:l,width:c,height:h}=function(e,t,i,s=!0){const{spatialReference:n}=e,{x:r,y:a}=function(e,t){if(e.spatialReference.equals(t))return e;const i=(0,ee.c9)(e.spatialReference),s=(0,ee.c9)(t);if(i===s)return e;const n=i/s;return{x:e.x*n,y:e.y*n}}(i,n);let o,l,c;const h="extent"===t.type?t:t.extent;let{xmin:u,xmax:f,ymax:p,ymin:d}=h;const{xmin:m,ymax:y}=e.extent;return s?(u=m+(u>m?r*Math.round((u-m)/r):0),p=y-(p<y?a*Math.round((y-p)/a):0),f=m+(f>m?r*Math.round((f-m)/r):0),d=y-(d<y?a*Math.round((y-d)/a):0),o=new X.Z({xmin:u,ymax:p,xmax:f,ymin:d,spatialReference:n}),l=Math.round(o.width/r),c=Math.round(o.height/a)):(l=Math.floor((f-u)/r+.8),c=Math.floor((p-d)/a+.8),u=m+(u>m?r*Math.floor((u-m)/r+.1):0),p=y-(p<y?a*Math.floor((y-p)/a+.1):0),f=u+l*r,d=p-c*a,o=new X.Z({xmin:u,ymax:p,xmax:f,ymin:d,spatialReference:n})),{extent:o,width:l,height:c}}(i,n,o),u=await this.fetchPixels(l,c,h,{...t,interpolation:"nearest"});if(null==u.pixelBlock)throw new a.Z("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const p=await ie(u.pixelBlock,l,n),d=this._rasterJobHandler.instance;return d?d.computeStatisticsHistograms({pixelBlock:p},t):(0,oe.js)(p)}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):(0,ue.GE)(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.rasterInfo??{};if(null==t)return e;let i=e.multidimensionalDefinition||this.multidimensionalDefinition;i?.length||(i=(0,Z.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const s=e.timeExtent||this.timeExtent;if(null!=i&&null!=s&&(null!=s.start||null!=s.end)){i=i.map((e=>e.clone()));const n=t.variables.find((({name:e})=>e===i[0].variableName))?.dimensions?.find((({name:e})=>"StdTime"===e)),r=i.find((({dimensionName:e})=>"StdTime"===e));if(!n||!r)return{...e,multidimensionalDefinition:null};const{start:a,end:o}=s,l=null==a?null:a.getTime(),c=null==o?null:o.getTime(),h=l??c,u=c??l;if(null!=n.values){const e=n.values.filter((e=>{if(Array.isArray(e)){if(h===u)return e[0]<=h&&e[1]>=h;const t=e[0]<=h&&e[1]>h||e[0]<u&&e[1]>=u,i=e[0]>=h&&e[1]<=u||e[0]<h&&e[1]>u;return t||i}return h===u?e===h:e>=h&&e<=u}));if(e.length){const t=e.sort(((e,t)=>{const i=Array.isArray(e)?e[0]:e,s=Array.isArray(e)?e[1]:e,n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t[1]:t;return h===u?i-n:Math.abs(s-u)-Math.abs(r-u)}))[0];r.values=[t]}else i=null}else if(n.hasRegularIntervals&&n.extent){const[e,t]=n.extent;h>t||u<e?i=null:r.values=h===u?[h]:[Math.max(e,h),Math.min(t,u)]}}return null!=i&&(0,Z.nb)(i,this.multidimensionalSubset)?{...e,multidimensionalDefinition:null}:{...e,multidimensionalDefinition:i}}async updateRasterFunction(){if(!this.loaded||"imagery-tile"!==this.type||!this.rasterFunction&&!this._cachedRasterFunctionJson||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;if(this._isConstructedFromFunctionRaster&&"Function"===this.raster.datasetFormat){const e=this.raster.rasterFunction.toJSON();return!this.rasterFunction&&e&&this._set("rasterFunction",k.Z.fromJSON(e)),void(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON())}let e,t=this.raster,i=!1;"Function"===t.datasetFormat?(e=t.primaryRasters.rasters,t=e[0],i=!0):e=[t];const{rasterFunction:s}=this;if(s){const i={raster:t};e.length>1&&e.forEach((e=>i[e.url]=e));const n=(0,ae.Ue)(s.functionDefinition?.toJSON()??s.toJSON(),i),r=new re({rasterFunction:n});r.rasterJobHandler=this._rasterJobHandler.instance,await r.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=r}else this.raster=t,this._cachedRasterFunctionJson=null,await t.when();if(this._cachedRendererJson=null,!i&&!s)return;const{bandIds:n}=this,{bandCount:r}=this.raster.rasterInfo,a=n?.length?n.some((e=>e>=r)):r>=3;n&&(a||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:e,symbolizer:t}=this;if(!e||!t||!this.renderer)return;const{rasterInfo:i}=this.raster,s=(0,Z.WY)(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=s?.name,r=(0,le.ol)({...this.renderer.toJSON(),variableName:n});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(r))return;const a=this._rasterJobHandler.instance;a&&(t.rasterInfo=(0,le.FI)(i,n),t.rendererJSON=r,t.bind(),await a.updateSymbolizer(t),this._cachedRendererJson=r)}async applyRenderer(e,t){const i=e?.pixelBlock;if(!(null!=i&&i.pixels&&i.pixels.length>0))return null;let s;await this.updateRenderer();const n=this._rasterJobHandler.instance,r=this.bandIds??[];return s=n?await n.symbolize({...e,simpleStretchParams:t,bandIds:r}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:r}),s}getTileUrl(e,t,i){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${i}`:""}getCompatibleTileInfo(e,t,i=!1){if(!this.loaded||null==t)return null;if(i&&e.equals(this.spatialReference))return this.tileInfo;const s=(0,I.C5)(e);return F.Z.create({size:256,spatialReference:e,origin:s?{x:s.origin[0],y:s.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,t,s,n={}){if(i(this),n.requestAsImageElement){const i=this.getTileUrl(e,t,s);return(0,b.Z)(i,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:n.signal}).then((e=>e.data))}const{rasterInfo:r}=this;if(null!=r.multidimensionalInfo&&null==(n=this.normalizeRasterFetchOptions(n)).multidimensionalDefinition){const i=n.tileInfo||r.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(e,t,s,i),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(n={...n,buffer:{cols:1,rows:1}}),this.raster.fetchTile(e,t,s,n)}async fetchPixels(e,t,i,s={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(s=this.normalizeRasterFetchOptions(s)).multidimensionalDefinition?{extent:e,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),t=Math.round(t),i=Math.round(i),this.raster.fetchPixels(e,t,i,s))}async identify(e,t={}){const{raster:i,rasterInfo:s}=this;if(null!=s.multidimensionalInfo&&!(s.hasMultidimensionalTranspose&&((0,Z.WU)(t.multidimensionalDefinition)||t.transposedVariableName||t.timeExtent)||null!=(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition))return{location:e,value:null};const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(e))throw new a.Z("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return i.identify(e,t)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const e=this.rasterInfo?.multidimensionalInfo;if(null==e||"standard-time"!==this.rasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,i=t?.[0]?.variableName;return e.variables.some((e=>e.name===i&&(!t?.[0].dimensionName||e.dimensions.some((e=>"StdTime"===e.name)))))}getStandardTimeValue(e){return new Date(24*(e-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(e){const t=e??this.rasterInfo?.multidimensionalInfo;return(0,Z.jj)(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=(0,Z.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&"Function"===this.raster.datasetFormat&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new M.Z;return this._rasterJobHandler.connectionPromise=e.initialize().then((async()=>{i(this),this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch((()=>{})),this.renderer&&this.updateRenderer()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){i(this);const{raster:e}=this,t=(0,le.In)(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){i(this);const{rasterInfo:t}=this.raster;!this.bandIds&&t.bandCount>1&&(this.bandIds=(0,le.YD)(t));const s=(0,Z.WY)(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=s?.name;if(!this.renderer||"override"===e){const e=(0,le.Ob)(t,{bandIds:this.bandIds,variableName:n}),i=t.statistics,s=i&&i.length>0?i[0]:null,r=s?.max??0,a=s?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===e.type&&(r>1e24||a<-1e24)&&(e.dynamicRangeAdjustment=!0,e.statistics=null,"none"===e.stretchType&&(e.stretchType="min-max")),this.renderer=e}const r=(0,le.ol)({...this.renderer.toJSON(),variableName:n}),a=(0,le.FI)(t,n);this.symbolizer?(this.symbolizer.rendererJSON=r,this.symbolizer.rasterInfo=a):this.symbolizer=new ce.Z({rendererJSON:r,rasterInfo:a});const o=this.symbolizer.bind();if(o.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if(null!=e&&"raster-colormap"===t.type){const e=(0,le.Ob)(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,i=t.statistics?.length;!t.dynamicRangeAdjustment&&i&&e&&i!==e&&this._configDefaultRenderer("override")}}}else pe.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}};function i(e){if(!e.raster||!e.rasterInfo)throw new a.Z("imagery-tile","no raster")}return(0,s._)([(0,u.Cb)({clonable:!1})],t.prototype,"_cachedRendererJson",void 0),(0,s._)([(0,u.Cb)({clonable:!1})],t.prototype,"_cachedRasterFunctionJson",void 0),(0,s._)([(0,u.Cb)({clonable:!1})],t.prototype,"_compatibleFullExtent",void 0),(0,s._)([(0,u.Cb)({clonable:!1})],t.prototype,"_isConstructedFromFunctionRaster",void 0),(0,s._)([(0,u.Cb)({clonable:!1})],t.prototype,"_rasterJobHandler",void 0),(0,s._)([(0,u.Cb)()],t.prototype,"bandIds",void 0),(0,s._)([(0,u.Cb)({json:{origins:{service:{read:{source:"copyrightText"}}}}})],t.prototype,"copyright",void 0),(0,s._)([(0,u.Cb)({json:{read:!1}})],t.prototype,"fullExtent",null),(0,s._)([(0,u.Cb)()],t.prototype,"interpolation",void 0),(0,s._)([(0,u.Cb)()],t.prototype,"ioConfig",void 0),(0,s._)([(0,u.Cb)({type:[T.Z],json:{write:!0}})],t.prototype,"multidimensionalDefinition",null),(0,s._)([(0,u.Cb)({type:C.Z,json:{write:!0}})],t.prototype,"multidimensionalSubset",void 0),(0,s._)([(0,u.Cb)()],t.prototype,"raster",void 0),(0,s._)([(0,u.Cb)({type:k.Z,json:{name:"renderingRule",write:!0}})],t.prototype,"rasterFunction",null),(0,s._)([(0,u.Cb)()],t.prototype,"rasterInfo",void 0),(0,s._)([(0,u.Cb)()],t.prototype,"sourceJSON",void 0),(0,s._)([(0,u.Cb)({readOnly:!0,type:fe.Z,json:{read:!1}})],t.prototype,"spatialReference",void 0),(0,s._)([(0,u.Cb)({type:F.Z})],t.prototype,"tileInfo",void 0),(0,s._)([(0,u.Cb)(R.HQ)],t.prototype,"url",null),(0,s._)([(0,u.Cb)({types:w.dr,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:w.FK,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],t.prototype,"renderer",null),(0,s._)([(0,v.r)("renderer")],t.prototype,"readRenderer",null),(0,s._)([(0,u.Cb)({clonable:!1})],t.prototype,"symbolizer",void 0),t=(0,s._)([(0,m.j)("esri.layers.ImageryTileMixin")],t),t};var me=i(38009),ye=i(16859),ge=i(34760),xe=i(72965),_e=i(28294),we=i(1231),be=i(69608),ve=i(25972),Ie=i(20095);function Se(e){const t=e.fields,i=e.records,s=t.some((e=>"oid"===e.name.toLowerCase()))?"OBJECTID":"OID",n=[{name:s,type:"esriFieldTypeOID",alias:"OID"}].concat(t.map((e=>({name:e.name,type:"esriFieldType"+e.typeName,alias:e.name})))),r=n.map((e=>e.name)),a=[];let o=0,l=0;return i.forEach((e=>{const t={};for(t[s]=o++,l=1;l<r.length;l++)t[r[l]]=e[l-1];a.push({attributes:t})})),{displayFieldName:"",fields:n,features:a}}class Re{static get supportedVersions(){return[5]}static parse(e){const t=new DataView(e),i=3&t.getUint8(0);if(3!==i)return{header:{version:i},recordSet:null};const s=t.getUint32(4,!0),n=t.getUint16(8,!0),r=t.getUint16(10,!0),a={version:i,recordCount:s,headerByteCount:n,recordByteCount:r};let o=32;const l=[],c=[];let h;if(3===i){for(;13!==t.getUint8(o);)h=String.fromCharCode(t.getUint8(o+11)).trim(),l.push({name:(0,Ie.f)(new Uint8Array(e,o,11)),type:h,typeName:["String","Date","Double","Boolean","String","Integer"][["C","D","F","L","M","N"].indexOf(h)],length:t.getUint8(o+16)}),o+=32;if(o+=1,l.length>0)for(;c.length<s&&e.byteLength-o>r;){const i=[];32===t.getUint8(o)?(o+=1,l.forEach((t=>{if("C"===t.type)i.push((0,Ie.f)(new Uint8Array(e,o,t.length)).trim());else if("N"===t.type)i.push(parseInt(String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim(),10));else if("F"===t.type)i.push(parseFloat(String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim()));else if("D"===t.type){const s=String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim();i.push(new Date(parseInt(s.substring(0,4),10),parseInt(s.substring(4,6),10)-1,parseInt(s.substring(6,8),10)))}o+=t.length})),c.push(i)):o+=r}}return{header:a,fields:l,records:c,recordSet:Se({fields:l,records:c})}}}var Te=i(87521);const Ce=new Map;Ce.set("int16","esriFieldTypeSmallInteger"),Ce.set("int32","esriFieldTypeInteger"),Ce.set("int64","esriFieldTypeInteger"),Ce.set("float32","esriFieldTypeSingle"),Ce.set("float64","esriFieldTypeDouble"),Ce.set("text","esriFieldTypeString");let ke=class extends Q{constructor(){super(...arguments),this.storageInfo=null,this.datasetFormat="CRF"}async open(e){await this.init();const{data:t}=await this.request(this.url+"/conf.json",{signal:e?.signal});if(!this._validateHeader(t))throw new a.Z("cloudraster:open","Invalid or unsupported conf.json.");this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const{storageInfo:i,rasterInfo:s}=this._parseHeader(t);if("thematic"===s.dataType){const e=await this._fetchAuxiliaryInformation();s.attributeTable=e}this._set("storageInfo",i),this._set("rasterInfo",s),this.ioConfig.retryCount=this.ioConfig.retryCount||0}async fetchRawTile(e,t,i,s={}){const{transposeInfo:n}=this.rasterInfo.storageInfo,{transposedVariableName:r}=s,a=!(!n||!r),o=a?0:this.rasterInfo.storageInfo.maximumPyramidLevel-e;if(o<0)return null;const l=this._buildCacheFilePath(o,t,i,s.multidimensionalDefinition,r),c=this._getIndexRecordFromBundle(t,i,a),h=await this.request(l,{range:{from:0,to:this.storageInfo.headerSize-1},responseType:"array-buffer",signal:s.signal});if(!h)return null;const u=new Uint8Array(h.data),f=this._getTileEndAndContentType(u,c);if(0===f.recordSize)return null;const p=await this.request(l,{range:{from:f.position,to:f.position+f.recordSize},responseType:"array-buffer",signal:s.signal});if(!p)return null;const[d,m]=this._getTileSize(a);return this.decodePixelBlock(p.data,{width:d,height:m,planes:null,pixelType:null,returnInterleaved:a})}_validateHeader(e){return e&&"RasterInfo"===e.type&&!["origin","extent","geodataXform","LODInfos","blockWidth","blockHeight","bandCount","pixelType","pixelSizeX","pixelSizeY","format","packetSize"].some((t=>!e[t]))}_parseHeader(e){const t=["u1","u2","u4","u8","s8","u16","s16","u32","s32","f32","f64"][e.pixelType],{bandCount:i,colormap:s,blockWidth:n,blockHeight:r,firstPyramidLevel:a,maximumPyramidLevel:o}=e,l=e.statistics?.map((e=>({min:e.min,max:e.max,avg:e.mean,stddev:e.standardDeviation,median:e.median,mode:e.mode}))),c=e.histograms?.[0]?.counts?.length?e.histograms:null,h=e.extent.spatialReference,u=e.geodataXform?.spatialReference,f=new fe.Z(h?.wkid||h?.wkt||h?.wkt2?h:u);let p=new X.Z({xmin:e.extent.xmin,ymin:e.extent.ymin,xmax:e.extent.xmax,ymax:e.extent.ymax,spatialReference:f});const d=new D.Z({x:e.pixelSizeX,y:e.pixelSizeY,spatialReference:f}),m=Math.round((p.xmax-p.xmin)/d.x),y=Math.round((p.ymax-p.ymin)/d.y),g=this._parseTransform(e.geodataXform),x=g?p:null;g&&(p=g.forwardTransform(p),d.x=(p.xmax-p.xmin)/m,d.y=(p.ymax-p.ymin)/y);const _=e.properties??{},w=e.format.toLowerCase().replace("cache/",""),b=new D.Z(e.origin.x,e.origin.y,f);let v,I,S,R;if(s?.colors)for(v=[],I=0;I<s.colors.length;I++)S=s.colors[I],R=s.values?s.values[I]:I,v.push([R,255&S,S<<16>>>24,S<<8>>>24,S>>>24]);const T=e.LODInfos,C=[];for(I=0;I<T.levels.length;I++)C.push(new P.Z({level:T.levels[I],resolution:T.resolutions[I],scale:96/.0254*T.resolutions[I]}));const k=new F.Z({dpi:96,lods:C,format:w,origin:b,size:[n,r],spatialReference:f}),M={recordSize:8,packetSize:e.packetSize,headerSize:e.packetSize*e.packetSize*8+64},z=[{maxCol:Math.ceil(m/n)-1,maxRow:Math.ceil(y/r)-1,minCol:0,minRow:0}];let O=2;if(o>0)for(I=0;I<o;I++)z.push({maxCol:Math.ceil(m/O/n)-1,maxRow:Math.ceil(y/O/r)-1,minCol:0,minRow:0}),O*=2;const Z=e.mdInfo;let N=null;if(Z&&_._yxs){const e=_._yxs;N={packetSize:e.PacketSize,tileSize:[e.TileXSize,e.TileYSize]}}return{storageInfo:M,rasterInfo:new ve.Z({width:m,height:y,pixelType:t,bandCount:i,extent:p,nativeExtent:x,transform:g,spatialReference:f,pixelSize:d,keyProperties:_,statistics:l,histograms:c,multidimensionalInfo:Z,colormap:v,storageInfo:new E.Z({blockWidth:n,blockHeight:r,pyramidBlockWidth:n,pyramidBlockHeight:r,origin:b,tileInfo:k,transposeInfo:N,firstPyramidLevel:a,maximumPyramidLevel:o,blockBoundary:z})})}}_parseTransform(e){if(!(0,Te.j)(e))throw new a.Z("cloudraster:open","the data contains unsupported geodata transform types");const t=(0,Te.c)(e);if("identity"===t.type)return null;if("polynomial"!==t.type||!t.forwardCoefficients?.length||!t.inverseCoefficients?.length)throw new a.Z("cloudraster:open","the data contains unsupported geodata transforms - both forward and inverse coefficients are required currently");return t}async _fetchAuxiliaryInformation(e){const t=this.request(this.url+"/conf.vat.json",{signal:e}).then((e=>e.data)).catch((()=>null)),i=this.request(this.url+"/conf.vat.dbf",{responseType:"array-buffer",signal:e}).then((e=>e.data)).catch((()=>null)),s=await Promise.all([t,i]);let n;if(s[0]){let e=s[0].fields;const t=s[0].values;if(e&&t){e=e.map((e=>({type:"OID"===e.name?"esriFieldTypeOID":Ce.get(e.type),name:e.name,alias:e.alias||e.name})));const i=t.map((e=>({attributes:e})));e&&t&&(n={fields:e,features:i})}}return!n&&s[1]&&(n=Re.parse(s[1]).recordSet),se.Z.fromJSON(n)}_buildCacheFilePath(e,t,i,s,n){const r=this._getPackageSize(!!n),a=Math.floor(t/r)*r,o=Math.floor(i/r)*r,l="R"+this._toHexString4(a)+"C"+this._toHexString4(o);let c="L";c+=e>=10?e.toString():"0"+e.toString();const{multidimensionalInfo:h}=this.rasterInfo,u=s?.[0];if(null==h||!u)return`${this.url}/_alllayers/${c}/${l}.bundle`;let f="_yxs";if(!n){f=h.variables.find((e=>e.name===u.variableName)).dimensions[0].values.indexOf(u.values[0]).toString(16);const e=4-f.length;for(let t=0;t<e;t++)f="0"+f;f="S"+f}const p=this._getVariableFolderName(n||u.variableName);return`${this.url}/_alllayers/${p}/${f}/${c}/${l}.bundle`}_getPackageSize(e=!1){const{transposeInfo:t}=this.rasterInfo.storageInfo;return e&&null!=t?t.packetSize??0:this.storageInfo.packetSize}_getTileSize(e=!1){const{storageInfo:t}=this.rasterInfo,{transposeInfo:i}=t;return e&&null!=i?i.tileSize:t.tileInfo.size}_getVariableFolderName(e){return""===(e=e.trim())?"_v":e.replaceAll(/[\{|\}\-]/g,"_").replace("\\*","_v")}_getIndexRecordFromBundle(e,t,i=!1){const s=this._getPackageSize(i),n=s*(e%s)+t%s;if(n<0)throw new Error("Invalid level / row / col");return 20+n*this.storageInfo.recordSize+44}_getTileEndAndContentType(e,t){const i=e.subarray(t,t+8);let s,n=0;for(s=0;s<5;s++)n|=(255&i[s])<<8*s;const r=0xffffffffff&n;for(n=0,s=5;s<8;s++)n|=(255&i[s])<<8*(s-5);return{position:r,recordSize:0xffffffffff&n}}_toHexString4(e){let t=e.toString(16);if(4!==t.length){let e=4-t.length;for(;e-- >0;)t="0"+t}return t}};(0,s._)([(0,u.Cb)({readOnly:!0})],ke.prototype,"storageInfo",void 0),(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],ke.prototype,"datasetFormat",void 0),ke=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.CloudRaster")],ke);const Me=ke;function Fe(e){return["x","e","east","long","longitude"].includes(e.toLowerCase())}function ze(e){return["y","n","west","lat","latitude"].includes(e.toLowerCase())}function Oe(e){let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let s=0;s<e.length;s++){const n=e[s];null!=n&&(n<t&&(t=n),n>i&&(i=n))}return t<0?t>=-128&&i<128?"s8":t>=-32768&&i<32768?"s16":"s32":i<256?"u8":i<65536?"u16":"u32"}let Pe=class extends Q{constructor(){super(...arguments),this.datasetFormat="MEMORY",this.source=null}async open(e){await this.init();const t=this.source,{pixelBlocks:i,statistics:s,histograms:n,name:r,keyProperties:a,nativeExtent:o,transform:l}=t,c=i[0],{width:h,height:u,pixelType:f}=c,p=t.extent??new X.Z({xmin:-.5,ymin:.5,xmax:h-.5,ymax:u-.5,spatialReference:new fe.Z({wkid:3857})}),d=t.isPseudoSpatialReference??!t.extent,m={x:p.width/h,y:p.height/u},y=new ve.Z({width:h,height:u,pixelType:f,extent:p,nativeExtent:o,transform:l,pixelSize:m,spatialReference:p.spatialReference,bandCount:c.pixels.length,keyProperties:a||{},multidimensionalInfo:t.multidimensionalInfo,statistics:s,isPseudoSpatialReference:d,histograms:n});this.createRemoteDatasetStorageInfo(y,512,512),this._set("rasterInfo",y),this.updateTileInfo(),y.multidimensionalInfo?await this._buildMDimStats(t.pixelBlocks,y.multidimensionalInfo):await this._buildInMemoryRaster(c,{width:512,height:512},e),y.multidimensionalInfo||(this.source=null),this.datasetName=r,this.url="/InMemory/"+r}fetchRawTile(e,t,i,s={}){if(!this._pixelBlockTiles){const{rasterInfo:n}=this,[r,a]=n.storageInfo.tileInfo.size,{sliceId:o}=s,{pixelBlocks:l}=this.source,c={pixelBlock:null==o?l[0]:l[o],useBilinear:"thematic"!==n.dataType,tileSize:{width:r,height:a},level:e,row:t,col:i},h=this.rasterJobHandler?this.rasterJobHandler.clipTile(c,s):(0,G.Uu)(c);return Promise.resolve(h)}const n=this._pixelBlockTiles.get(`${e}/${t}/${i}`);return Promise.resolve(n)}async _buildInMemoryRaster(e,t,i){const{rasterInfo:s}=this,n=s.storageInfo.maximumPyramidLevel??0,r="thematic"!==s.dataType,o=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:e,tileSize:t,maximumPyramidLevel:n,useBilinear:r},i):Promise.resolve((0,G.Vl)(e,t,n,r)),l=null!=s.statistics,h=null!=s.histograms,u=l?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.computeStatisticsHistograms({pixelBlock:e},i):Promise.resolve((0,oe.js)(e)),f=await(0,c.as)([o,u]);if(!f[0].value&&f[1].value)throw new a.Z("inmemory-raster:open","failed to build in memory raster");this._pixelBlockTiles=f[0].value,l||(s.statistics=f[1].value?.statistics),h||(s.histograms=f[1].value?.histograms)}async _buildMDimStats(e,t,i){for(let s=0;s<t.variables.length;s++){const n=t.variables[s];if(n.statistics)continue;const r=n.dimensions.map((e=>new T.Z({variableName:n.name,dimensionName:e.name,values:[e.values?.[0]??e.extent?.[0]],isSlice:!0}))),a=(0,Z.gk)(r,t),o=null==a?null:e[a];if(null==o)continue;const l=this.rasterJobHandler?await this.rasterJobHandler.computeStatisticsHistograms({pixelBlock:o},i):(0,oe.js)(o);n.statistics=l.statistics,n.histograms||(n.histograms=l.histograms)}}};(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],Pe.prototype,"datasetFormat",void 0),(0,s._)([(0,u.Cb)()],Pe.prototype,"source",void 0),Pe=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.InMemoryRaster")],Pe);const Ee=Pe;let Ze=class extends Q{constructor(){super(...arguments),this.datasetFormat="CovJSON"}async open(e){await this.init();const{extent:t,pixelBlocks:i,multidimensionalInfo:s,bandNames:n}=await this._fetchData(e),{statistics:r,histograms:a}=(0,oe.js)(i[0]),o=n?.map((e=>({BandName:e}))),l=new Ee({source:{extent:t,pixelBlocks:i,multidimensionalInfo:s,statistics:r,histograms:a,keyProperties:{DataType:s?"Scientific":"Generic",BandProperties:o},isPseudoSpatialReference:!1}});await l.open(),this._inMemoryRaster=l;const c=this.url.slice(this.url.lastIndexOf("/")+1);this._set("datasetName",c.slice(0,c.indexOf("."))),this._set("rasterInfo",l.rasterInfo)}fetchRawTile(e,t,i,s={}){return this._inMemoryRaster.fetchRawTile(e,t,i,s)}async _fetchData(e){const t=this.source??(await this.request(this.url,{signal:e?.signal})).data,i="imagery-tile-layer:open-coverage-json";if("coverage"!==t.type?.toLowerCase()||"grid"!==t.domain?.domainType?.toLowerCase())throw new a.Z(i,"Only coverage with Grid domain type is supported");if(!t.ranges)throw new a.Z(i,"Missing ranges in the grid coverage data");const s=Object.values(t.ranges);for(let e=0;e<s.length;e++){const{axisNames:t,type:n,values:r}=s[e];if("ndarray"!==n.toLowerCase()||!r?.length||!t?.length)throw new a.Z(i,"Only ranges with valid NdArray and axisNames are supported");if(t.length>4)throw new a.Z(i,"Coverages with more than 4 dimensions are not supported currently.");if(!Fe(t[t.length-1])||!ze(t[t.length-2]))throw new a.Z(i,"Only row-major ordered pixel values are supported. X axis must be the last axis.")}return function(e){const{width:t,height:i,extent:s,dimensions:n}=function(e){const{axes:t}=e.domain,i=Object.keys(t),s=[],n=[];let r=-1,a=-1,o=[];for(let e=0;e<i.length;e++){const l=i[e];Fe(l)?r=e:ze(l)&&(a=e);const c=t[l],h=[];if("values"in c){c.values.forEach((e=>h.push("string"==typeof e?new Date(e).getTime():e)));const e=h[1]-h[0];s.push([h[0]-.5*e,h[h.length-1]+.5*e]),n.push(e)}else{const{start:e,stop:t,num:i}=c,r=(t-e)/(i-1);s.push([e-.5*r,t+.5*r]),n.push(r);for(let t=0;t<i;t++)h.push(e+r*t)}o.push({name:l,values:h,extent:[h[0],h[h.length-1]]})}r>-1&&-1===a?a=0===r?1:0:a>-1&&-1===r?r=0===a?1:0:-1===a&&-1===r&&(r=0,a=1),o=o.filter(((e,t)=>!(t===r||t===a)));const{referencing:l}=e.domain,c=l.find((e=>e.coordinates.includes(i[r]))),h=(c?.system).id,u=Number(h.slice(h.lastIndexOf("/")+1)),f=new fe.Z({wkid:u}),p=new X.Z({xmin:s[r][0],xmax:s[r][1],ymin:s[a][0],ymax:s[a][1]},f);return{width:(s[r][1]-s[r][0])/n[r],height:(s[a][1]-s[a][0])/n[a],extent:p,dimensions:o}}(e),{ranges:r}=e,a=Object.keys(r).sort(),o=[],l=[];for(let e=0;e<a.length;e++){const s=a[e];n?.length&&o.push({name:s,dimensions:n});const{values:c,dataType:h,axisNames:u}=r[s],f="float"===h?"f32":Oe(c),p=t*i,d=c.length/p;for(let s=0;s<d;s++){const r=te.Z.createEmptyBand(f,p),a=new Uint8Array(p).fill(255);let o=!1;const h=s*p;for(let e=0;e<p;e++){const t=c[h+e];null==t?(a[e]=0,o=!0):r[e]=t}if(0===e||n?.length){const e=new te.Z({width:t,height:i,mask:o?a:null,pixels:[r],pixelType:f});e.updateStatistics(),l.push(e)}else{const e=l[s];e.pixels.push(r),o?e.mask&&(e.mask=te.Z.combineBandMasks([e.mask,a])):e.mask=o?a:null}}if(2===n.length&&u[0]>u[1]){const e=n.map((({values:e})=>e.length)),t=l.slice(-d),i=l.length-d;for(let s=0;s<e[0];s++)for(let n=0;n<e[1];n++)l[i+s*e[1]+n]=t[s+n*e[0]]}}const c=o.length?{variables:o}:void 0;return{extent:s,pixelBlocks:l,multidimensionalInfo:c,bandNames:c?void 0:a}}(t)}};(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],Ze.prototype,"datasetFormat",void 0),(0,s._)([(0,u.Cb)({constructOnly:!0})],Ze.prototype,"source",void 0),Ze=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.CovJSONRaster")],Ze);const Ne=Ze;var De=i(67676);function Ae(e,t){if(!e||!t)return[];let i=t;t.includes("/")?(i=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const s=[];if(t){const n=Ae(e,i);for(let e=0;e<n.length;e++)Ae(n[e],t).forEach((e=>s.push(e)));return s}const n=e.getElementsByTagNameNS("*",i);if(!n||0===n.length)return[];for(let e=0;e<n.length;e++)s.push(n[e]||n.item(e));return s}function Be(e,t){if(!e||!t)return null;let i=t;t.includes("/")?(i=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const s=Ae(e,i);return s.length>0?t?Be(s[0],t):s[0]:null}function Le(e,t=null){const i=t?Be(e,t):e;let s;return i?(s=i.textContent||i.nodeValue,s?s.trim():null):null}function Je(e,t){return function(e,t){const i=Ae(e,t),s=[];let n;for(let e=0;e<i.length;e++)n=i[e].textContent||i[e].nodeValue,n&&(n=n.trim(),""!==n&&s.push(n));return s}(e,t).map((e=>Number(e)))}function He(e,t){const i=Le(e,t);return Number(i)}function qe(e,t){const i=e?.nodeName?.toLowerCase(),s=t.toLowerCase();return i.slice(i.lastIndexOf(":")+1)===s}var je=i(87390);function We(e,t){if(!e||!t)return null;const i=[];for(let s=0;s<e.length;s++)i.push(e[s]),i.push(t[s]);return i}function Ue(e){if(!e)return null;let t=Number(e);if(!isNaN(t)&&0!==t)return new fe.Z({wkid:t});if(e=String(e).trim(),(0,I.xl)(e))return new fe.Z({wkt2:e});const i=e.toUpperCase();if(i.startsWith("COMPD_CS")){if(!i.includes("VERTCS")||!i.includes("GEOGCS")&&!i.startsWith("PROJCS"))return null;const s=i.indexOf("VERTCS"),n=i.indexOf("PROJCS"),r=n>-1?n:i.indexOf("GEOGCS");if(-1===r)return null;const a=e.slice(r,e.lastIndexOf("]",s)+1).trim(),o=e.slice(s,e.lastIndexOf("]")).trim();t=Ge(a);const l=new fe.Z(t?{wkid:t}:{wkt:a}),c=Ge(o);return c&&(l.vcsWkid=c),l}return i.startsWith("GEOGCS")||i.startsWith("PROJCS")?(t=Ge(e),new fe.Z(0!==t?{wkid:t}:{wkt:e})):null}function Ge(e){const t=e.replaceAll("]","[").replaceAll('"',"").split("[").map((e=>e.trim())).filter((e=>""!==e)),i=t[t.length-1].split(","),s=i[0]?.toLowerCase();if(("epsg"===s||"esri"===s)&&e.endsWith('"]]')){const e=Number(i[1]);if(!isNaN(e)&&0!==e)return e}return 0}function $e(e){if("pamdataset"!==e?.documentElement.tagName?.toLowerCase())return{};const t={spatialReference:null,transform:null,metadata:{},rasterBands:[],statistics:null,histograms:null};e.documentElement.childNodes.forEach((e=>{if(1===e.nodeType)if(qe(e,"SRS")){if(!t.spatialReference){const i=Le(e);t.spatialReference=Ue(i)}}else if(qe(e,"Metadata"))if("xml:ESRI"===e.getAttribute("domain")){const{spatialReference:i,transform:s}=function(e){const t=Be(e,"GeodataXform"),i=Ue(He(t,"SpatialReference/WKID")||Le(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:i,transform:null};const s=He(t,"PolynomialOrder")??1,n=Je(t,"CoeffX/Double"),r=Je(t,"CoeffY/Double"),a=Je(t,"InverseCoeffX/Double"),o=Je(t,"InverseCoeffY/Double"),l=We(n,r),c=We(a,o);return{spatialReference:i,transform:l&&c&&l.length&&c.length?new je.Z({spatialReference:i,polynomialOrder:s,forwardCoefficients:l,inverseCoefficients:c}):null}}(e);t.transform=s,t.spatialReference||(t.spatialReference=i)}else Ae(e,"MDI").forEach((e=>t.metadata[e.getAttribute("key")]=Le(e)));else if(qe(e,"PAMRasterBand")){const i=function(e){const t=He(e,"NoDataValue"),i=Be(e,"Histograms/HistItem"),s=He(i,"HistMin"),n=He(i,"HistMax"),r=He(i,"BucketCount"),a=Le(i,"HistCounts")?.split("|").map((e=>Number(e)));let o,l,c,h;Ae(e,"Metadata/MDI").forEach((e=>{const t=Number(e.textContent??e.nodeValue);switch(e.getAttribute("key").toUpperCase()){case"STATISTICS_MINIMUM":o=t;break;case"STATISTICS_MAXIMUM":l=t;break;case"STATISTICS_MEAN":c=t;break;case"STATISTICS_STDDEV":h=t}}));const u=He(e,"Metadata/SourceBandIndex");return{noDataValue:t,histogram:a?.length&&null!=s&&null!=n?{min:s,max:n,size:r||a.length,counts:a}:null,sourceBandIndex:u,statistics:null!=o&&null!=l?{min:o,max:l,avg:c,stddev:h}:null}}(e);null!=i.sourceBandIndex&&null==t.rasterBands[i.sourceBandIndex]?t.rasterBands[i.sourceBandIndex]=i:t.rasterBands.push(i)}}));const i=t.rasterBands;if(i.length){const e=!!i[0].statistics;t.statistics=e?i.map((e=>e.statistics)).filter(De.pC):null;const s=!!i[0].histogram;t.histograms=s?i.map((e=>e.histogram)).filter(De.pC):null}return t}let Ve=class extends Q{async open(e){await this.init();const t=await this._fetchData(e);let{spatialReference:i,statistics:s,histograms:n,transform:r}=await this._fetchAuxiliaryData(e);const a=!i;a&&(i=new fe.Z({wkid:3857})),n?.length&&null==s&&(s=(0,oe.Oh)(n));const{width:o,height:l}=t;let c=new X.Z({xmin:-.5,ymin:.5-l,xmax:o-.5,ymax:.5,spatialReference:i});const h=r?r.forwardTransform(c):c;let u=!0;if(r){const e=r.forwardCoefficients;u=e&&0===e[1]&&0===e[2],u&&(r=null,c=h)}const f=new Ee({source:{extent:h,nativeExtent:c,transform:r,pixelBlocks:[t],statistics:s,histograms:n,keyProperties:{DateType:"Processed"},isPseudoSpatialReference:a}});await f.open(),f.source=null,this._set("rasterInfo",f.rasterInfo),this._inMemoryRaster=f}fetchRawTile(e,t,i,s={}){return this._inMemoryRaster.fetchRawTile(e,t,i,s)}async _fetchData(e){const{data:t}=await this.request(this.url,{responseType:"array-buffer",signal:e?.signal}),i=(0,U.y)(t).toUpperCase();if("JPG"!==i&&"PNG"!==i&&"GIF"!==i&&"BMP"!==i)throw new a.Z("image-aux-raster:open","the data is not a supported format");this._set("datasetFormat",i);const s=i.toLowerCase(),n="gif"===s||"bmp"===s||!(0,p.Z)("ios"),r=await this.decodePixelBlock(t,{format:s,useCanvas:n,hasNoZlibMask:!0});if(null==r)throw new a.Z("image-aux-raster:open","the data cannot be decoded");return r}async _fetchAuxiliaryData(e){const t=e?.signal,i=this.ioConfig.skipExtensions??[],s=i.includes("aux.xml")?null:this.request(this.url+".aux.xml",{responseType:"xml",signal:t}),n=this.datasetFormat,r="JPG"===n?"jgw":"PNG"===n?"pgw":"BMP"===n?"bpw":null,a=r&&i.includes(r)?null:this.request(this.url.slice(0,this.url.lastIndexOf("."))+"."+r,{responseType:"text",signal:t}),o=await(0,c.as)([s,a]);if(t?.aborted)throw(0,c.zE)();const l=$e(o[0].value?.data);if(!l.transform){const e=o[1].value?o[1].value.data.split("\n").slice(0,6).map((e=>Number(e))):null;l.transform=6===e?.length?new je.Z({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return l}};(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],Ve.prototype,"datasetFormat",void 0),Ve=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.ImageAuxRaster")],Ve);const Xe=Ve;var Ye=i(70586),Ke=i(17452),Qe=i(28589),et=i(29680),tt=i(26059);let it=class extends Q{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async open(e){await this.init();const t=e?.signal,i=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:t});i.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const s=i.data;if(this.sourceJSON=s,!s)throw new a.Z("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!s.tileInfo)throw new a.Z("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo(),this.tileType=s.cacheType,null==this.tileType&&(["jpg","jpeg","png","png8","png24","png32","mixed"].includes(s.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===s.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=s.name?.slice(s.name.indexOf("/")+1)??"";const n=await this._fetchRasterInfo({signal:t});if(null==n)throw new a.Z("image-server-raster:open","cannot initialize image service");(0,tt.n$)(n,s);const r="Map"===this.tileType?function(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:n,maxLOD:r}=t;if(null!=n&&null!=r)return F.Z.fromJSON({...e,lods:e.lods.filter((({level:e})=>null!=e&&e>=n&&e<=r))});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,n=i?t(i):1/0,r=s?t(s):-1/0;return F.Z.fromJSON({...e,lods:e.lods.filter((e=>{const i=t(e.scale);return i<=n&&i>=r}))})}return F.Z.fromJSON(e)}(s.tileInfo,s):F.Z.fromJSON(s.tileInfo);(0,Ye.O3)(r);const[o,l]=this._computeMinMaxLOD(n,r),{extent:c,pixelSize:h}=n,u=.5/n.width*h.x,f=Math.max(h.x,h.y),{lods:p}=r;("Map"!==this.tileType&&0!==s.maxScale||Math.abs(h.x-h.y)>u||!p.some((e=>Math.abs(e.resolution-f)<u)))&&(h.x=h.y=o.resolution,n.width=Math.ceil((c.xmax-c.xmin)/h.x-.1),n.height=Math.ceil((c.ymax-c.ymin)/h.y-.1));const d=o.level-l.level,[m,y]=r.size,g=[],x=[];p.forEach(((e,t)=>{e.level>=l.level&&e.level<=o.level&&g.push({x:e.resolution,y:e.resolution}),t<p.length-1&&x.push(Math.round(10*e.resolution/p[t+1].resolution)/10)})),g.sort(((e,t)=>e.x-t.x));const _=this.computeBlockBoundary(c,m,y,r.origin,g,d),w=g.length>1?g.slice(1):null;let b;s.transposeInfo&&(b={tileSize:[s.transposeInfo.rows,s.transposeInfo.cols],packetSize:n.keyProperties?._yxs.PacketSize??0});const v=x.length<=1||x.length>=3&&x.slice(0,-1).every((e=>e===x[0]))?x[0]??2:Math.round(10/(l.resolution/o.resolution)**(-1/d))/10;if(n.storageInfo=new E.Z({blockWidth:r.size[0],blockHeight:r.size[1],pyramidBlockWidth:r.size[0],pyramidBlockHeight:r.size[1],pyramidResolutions:w,pyramidScalingFactor:v,compression:r.format,origin:r.origin,firstPyramidLevel:1,maximumPyramidLevel:d,tileInfo:r,transposeInfo:b,blockBoundary:_}),this._fixGCSShift(n),this._set("rasterInfo",n),s.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:n.storageInfo.tileInfo,parsedUrl:(0,Ke.mN)(this.url),url:this.url,tileServers:[]};this._tilemapCache=new Qe.y({layer:e})}}async fetchRawTile(e,t,i,s={}){const{storageInfo:n,extent:r}=this.rasterInfo,{transposeInfo:a}=n,o=null!=a&&!!s.transposedVariableName;if(this._slices&&!o&&null==s.sliceId)return null;const l=o?0:n.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${l}/${t}/${i}`,h=this._slices?o?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null,{data:u}=await this.request(c,{query:h,responseType:"array-buffer",signal:s.signal});if(!u)return null;const f=o?a.tileSize:n.tileInfo.size,p=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:null,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:o,noDataValue:this.rasterInfo.noDataValue});if(null==p)return null;const d=n.blockBoundary[e];if("jpg"!==n.compression||i>d.minCol&&i<d.maxCol&&t>d.minRow&&t<d.maxRow)return p;const{origin:m,blockWidth:y,blockHeight:g}=n,{x,y:_}=this.getPyramidPixelSize(e),w=Math.round((r.xmin-m.x)/x)%y,b=Math.round((r.xmax-m.x)/x)%y||y,v=Math.round((m.y-r.ymax)/_)%g,I=Math.round((m.y-r.ymin)/_)%g||g,S=i===d.minCol?w:0,R=t===d.minRow?v:0,T=i===d.maxCol?b:y,C=t===d.maxRow?I:g;return(0,G.pW)(p,{x:S,y:R},{width:T-S,height:C-R}),p}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let e=0;e<this._slices.length;e++){const i=this._slices[e].multidimensionalDefinition;if(i.length===t.length&&!i.some((e=>{const i=t.find((t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName));return!i||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])})))return e}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.statistics)),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.histograms)),n=await Promise.all([i,s]);return n[0]&&n[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),n[1]?.[0]?.counts?.length||(n[1]=null),{statistics:n[0]||null,histograms:n[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:n}=this.rasterInfo.storageInfo;let r=n-s+this._levelOffset;const a=i.srcLocation;for(;r>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(r,i.row,i.col,t))break}catch{}if(r--,s++,i=this.identifyPixelLocation(a,s,t.datumTransformation),null===i)return null}return-1===r||null==i?null:s}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),n=fe.Z.fromJSON(t.spatialReference||e.spatialReference),r=new D.Z({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:n});return new ve.Z({width:i,height:s,bandCount:3,extent:X.Z.fromJSON(e),spatialReference:n,pixelSize:r,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=(0,tt.gh)(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),n=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then((e=>e.data?.slices)).catch((()=>null)):null,r=await Promise.all([s,n]);return this._slices=r[1],r[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_fixGCSShift(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new et.Z,e.extent=e.transform.forwardTransform(t))}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:n}=t,r=t.lodAt(Math.max.apply(null,n.map((e=>e.level)))),a=t.lodAt(Math.min.apply(null,n.map((e=>e.level)))),{tileType:o}=this;if("Map"===o)return this._levelOffset=n[0].level,[r,a];if("Raster"===o)return[n.find((e=>e.resolution===i.x))??r,a];const{minScale:l,maxScale:c}=this.sourceJSON;let h=r;c>0&&(h=n.find((e=>Math.abs(e.scale-c)<s)),h||(h=n.filter((e=>e.scale>c)).sort(((e,t)=>e.scale>t.scale?1:-1))[0]??r));let u=a;return l>0&&(u=n.find((e=>Math.abs(e.scale-l)<s))??a,this._levelOffset=u.level-a.level),[h,u]}};(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],it.prototype,"datasetFormat",void 0),(0,s._)([(0,u.Cb)()],it.prototype,"tileType",void 0),it=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.ImageServerRaster")],it);const st=it;var nt=i(48279);const rt=new Map;rt.set("Int8","s8"),rt.set("UInt8","u8"),rt.set("Int16","s16"),rt.set("UInt16","u16"),rt.set("Int32","s32"),rt.set("UInt32","u32"),rt.set("Float32","f32"),rt.set("Float64","f32"),rt.set("Double64","f32");const at=new Map;at.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),at.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),at.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),at.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"});let ot=class extends Q{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this.datasetFormat="MRF"}async open(e){await this.init(),this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const t=e?e.signal:null,i=await this.request(this.url,{responseType:"xml",signal:t}),{rasterInfo:s,files:n}=this._parseHeader(i.data);if(-1===this.ioConfig.skipExtensions?.indexOf("aux.xml")){const t=await this._fetchAuxiliaryData(e);null!=t&&(s.statistics=t.statistics??s.statistics,s.histograms=t.histograms,t.histograms&&null==s.statistics&&(s.statistics=(0,oe.Oh)(t.histograms)))}this._set("rasterInfo",s),this._files=n;const r=await this.request(n.index,{responseType:"array-buffer",signal:t});this._storageIndex=this._parseIndex(r.data);const{blockWidth:a,blockHeight:o}=this.rasterInfo.storageInfo,l=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:c,height:h}=this.rasterInfo,u=[],f=this._getBandSegmentCount();let p=0,d=-1;for(;p<this._storageIndex.length;){d++;const e=Math.ceil(c/a/l**d)-1,t=Math.ceil(h/o/l**d)-1;p+=(e+1)*(t+1)*f*4,u.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=u,d>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=d),this.updateTileInfo()}async fetchRawTile(e,t,i,s={}){const{blockWidth:n,blockHeight:r,blockBoundary:a}=this.rasterInfo.storageInfo,o=a[e];if(!o||o.maxRow<t||o.maxCol<i||o.minRow>t||o.minCol>i)return null;const{bandCount:l,pixelType:c}=this.rasterInfo,{ranges:h,actualTileWidth:u,actualTileHeight:f}=this._getTileLocation(e,t,i);if(!h||0===h.length)return null;if(0===h[0].from&&0===h[0].to){const e=new Uint8Array(n*r);return new te.Z({width:n,height:r,pixels:null,mask:e,validPixelCount:0})}const{bandIds:p}=this.ioConfig,d=this._getBandSegmentCount(),m=[];let y=0;for(y=0;y<d;y++)p&&!p.includes(y)||m.push(this.request(this._files.data,{range:{from:h[y].from,to:h[y].to},responseType:"array-buffer",signal:s.signal}));const g=await Promise.all(m),x=g.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),_=new Uint8Array(x);let w=0;for(y=0;y<d;y++)_.set(new Uint8Array(g[y].data),w),w+=g[y].data.byteLength;const b=at.get(this.rasterInfo.storageInfo.compression).decoderFormat,v=await this.decodePixelBlock(_.buffer,{width:n,height:r,format:b,planes:p?.length||l,pixelType:c});if(null==v)return null;let{noDataValue:I}=this.rasterInfo;if(null!=I&&"lerc"!==b&&!v.mask&&(I=I[0],null!=I)){const e=v.width*v.height,t=new Uint8Array(e);if(Math.abs(I)>1e24)for(y=0;y<e;y++)Math.abs((v.pixels[0][y]-I)/I)>1e-6&&(t[y]=1);else for(y=0;y<e;y++)v.pixels[0][y]!==I&&(t[y]=1);v.mask=t}let S=0,R=0;if(u!==n||f!==r){let e=v.mask;if(e)for(y=0;y<r;y++)if(R=y*n,y<f)for(S=u;S<n;S++)e[R+S]=0;else for(S=0;S<n;S++)e[R+S]=0;else for(e=new Uint8Array(n*r),v.mask=e,y=0;y<f;y++)for(R=y*n,S=0;S<u;S++)e[R+S]=1}return v}_parseIndex(e){if(e.byteLength%16>0)throw new Error("invalid array buffer must be multiples of 16");let t,i,s,n,r,a;if(nt.f){for(i=new Uint8Array(e),n=new ArrayBuffer(e.byteLength),s=new Uint8Array(n),r=0;r<e.byteLength/4;r++)for(a=0;a<4;a++)s[4*r+a]=i[4*r+3-a];t=new Uint32Array(n)}else t=new Uint32Array(e);return t}_getBandSegmentCount(){return at.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(e,t,i){const{blockWidth:s,blockHeight:n,pyramidScalingFactor:r}=this.rasterInfo.storageInfo,{width:a,height:o}=this.rasterInfo,l=this._getBandSegmentCount();let c,h,u,f=0,p=0;for(u=0;u<e;u++)p=r**u,c=Math.ceil(a/s/p),h=Math.ceil(o/n/p),f+=c*h;p=r**e,c=Math.ceil(a/s/p),h=Math.ceil(o/n/p),f+=t*c+i,f*=4*l;const d=this._storageIndex.subarray(f,f+4*l);let m=0,y=0;const g=[];for(let e=0;e<l;e++)m=d[4*e]*2**32+d[4*e+1],y=m+d[4*e+2]*2**32+d[4*e+3],g.push({from:m,to:y});return{ranges:g,actualTileWidth:i<c-1?s:Math.ceil(a/p)-s*(c-1),actualTileHeight:t<h-1?n:Math.ceil(o/p)-n*(h-1)}}_parseHeader(e){const t=Be(e,"MRF_META/Raster");if(!t)throw new a.Z("mrf:open","not a valid MRF format");const i=Be(t,"Size"),s=parseInt(i.getAttribute("x"),10),n=parseInt(i.getAttribute("y"),10),r=parseInt(i.getAttribute("c"),10),o=(Le(t,"Compression")||"none").toLowerCase();if(!at.has(o))throw new a.Z("mrf:open","currently does not support compression "+o);const l=Le(t,"DataType")||"UInt8",c=rt.get(l);if(null==c)throw new a.Z("mrf:open","currently does not support pixel type "+l);const h=Be(t,"PageSize"),u=parseInt(h.getAttribute("x"),10),f=parseInt(h.getAttribute("y"),10),p=Be(t,"DataValues");let d,m;if(p&&(m=p.getAttribute("NoData"),null!=m&&(d=m.trim().split(" ").map((e=>parseFloat(e))))),Be(e,"MRF_META/CachedSource"))throw new a.Z("mrf:open","currently does not support MRF referencing other data files");const y=Be(e,"MRF_META/GeoTags"),g=Be(y,"BoundingBox");let x,_=!1;if(null!=g){const e=parseFloat(g.getAttribute("minx")),t=parseFloat(g.getAttribute("miny")),i=parseFloat(g.getAttribute("maxx")),s=parseFloat(g.getAttribute("maxy")),n=Le(y,"Projection")||"";let r=fe.Z.WGS84;if("LOCAL_CS[]"!==n)if(n.toLowerCase().startsWith("epsg:")){const e=Number(n.slice(5));isNaN(e)||0===e||(r=new fe.Z({wkid:e}))}else r=Ue(n)??fe.Z.WGS84;else _=!0,r=new fe.Z({wkid:3857});x=new X.Z(e,t,i,s),x.spatialReference=r}else _=!0,x=new X.Z({xmin:-.5,ymin:.5-n,xmax:s-.5,ymax:.5,spatialReference:new fe.Z({wkid:3857})});const w=Be(e,"MRF_META/Rsets"),b=parseInt(w?.getAttribute("scale")||"2",10),v=x.spatialReference,I=new E.Z({origin:new D.Z({x:x.xmin,y:x.ymax,spatialReference:v}),blockWidth:u,blockHeight:f,pyramidBlockWidth:u,pyramidBlockHeight:f,compression:o,pyramidScalingFactor:b}),S=new D.Z({x:x.width/s,y:x.height/n,spatialReference:v}),R=new ve.Z({width:s,height:n,extent:x,isPseudoSpatialReference:_,spatialReference:v,bandCount:r,pixelType:c,pixelSize:S,noDataValue:d,storageInfo:I}),T=Le(e,"datafile"),C=Le(e,"IndexFile");return{rasterInfo:R,files:{mrf:this.url,index:C||this.url.replace(".mrf",".idx"),data:T||this.url.replace(".mrf",at.get(o).blobExtension)}}}async _fetchAuxiliaryData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return $e(t)}catch{return null}}};(0,s._)([(0,u.Cb)()],ot.prototype,"_files",void 0),(0,s._)([(0,u.Cb)()],ot.prototype,"_storageIndex",void 0),(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],ot.prototype,"datasetFormat",void 0),ot=(0,s._)([(0,m.j)("esri.layers.support.rasterIO.MRFRaster")],ot);const lt=ot;var ct=i(94793),ht=i(9832);const ut=(e,t)=>e.get(t)?.values,ft=(e,t)=>e.get(t)?.values?.[0];let pt=class extends Q{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this.datasetFormat="TIFF"}async open(e){await this.init();const t=e?e.signal:null,{data:i}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:"array-buffer",signal:t});if(!i)throw new a.Z("tiffraster:open","failed to open url "+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1,this.url.lastIndexOf("."));const{littleEndian:s,firstIFDPos:n,isBigTiff:r}=(0,ct.cK)(i),l=[];await this._readIFDs(l,i,s,n,0,r?8:4,t);const{imageInfo:c,rasterInfo:h}=this._parseIFDs(l),u=(0,ct.ee)(l),f=(0,ct.I7)(l);if(this._headerInfo={littleEndian:s,isBigTiff:r,ifds:l,pyramidIFDs:u,maskIFDs:f,...c},this._set("rasterInfo",h),!c.isSupported)throw new a.Z("tiffraster:open","this tiff is not supported: "+c.message);if(!c.tileWidth)throw new a.Z("tiffraster:open","none-tiled tiff is not optimized for access, convert to COG and retry.");h.isPseudoSpatialReference&&o.Z.getLogger(this).warn("The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.");const p=l[0].get("PREDICTOR")?.values?.[0],d=l[0].get("SAMPLEFORMAT")?.values?.[0];if(3===d&&2===p)throw new a.Z("tiffraster:open","unsupported horizontal difference encoding. Predictor=3 is supported for floatting point data");const{skipExtensions:m=[]}=this.ioConfig;if(!m.includes("aux.xml")){const t=await this._fetchAuxiliaryMetaData(e);null!=t&&this._processPAMInfo(t,h)}m.includes("vat.dbf")||1!==h.bandCount||"u8"!==h.pixelType||(h.attributeTable=await this._fetchAuxiliaryTable(e),null!=h.attributeTable&&(h.keyProperties.DataType="thematic")),this.updateTileInfo()}async fetchRawTile(e,t,i,s={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,i))return null;const n=await this._fetchRawTiffTile(e,t,i,!1,s);if(null!=n&&this._headerInfo.hasMaskBand){const r=await this._fetchRawTiffTile(e,t,i,!0,s);null!=r&&r.pixels[0]instanceof Uint8Array&&(n.mask=r.pixels[0])}return n}_parseIFDs(e){const t=(0,ct.FI)(e),{width:i,height:s,tileWidth:n,tileHeight:r,planes:a,pixelType:o,compression:l,firstPyramidLevel:c,maximumPyramidLevel:h,pyramidBlockWidth:u,pyramidBlockHeight:f,tileBoundary:p,affine:d,metadata:m}=t;let y=Ue(t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid),g=!!t.isPseudoGeographic;null==y&&(g=!0,y=new fe.Z({wkid:3857}));const x=new X.Z({...t.extent,spatialReference:y}),_=new D.Z(x?{x:x.xmin,y:x.ymax,spatialReference:y}:{x:0,y:0}),w=new E.Z({blockWidth:n,blockHeight:r,pyramidBlockWidth:u,pyramidBlockHeight:f,compression:l,origin:_,firstPyramidLevel:c,maximumPyramidLevel:h,blockBoundary:p}),b=new D.Z({x:(x.xmax-x.xmin)/i,y:(x.ymax-x.ymin)/s,spatialReference:y}),v=m?{BandProperties:m.bandProperties,DataType:m.dataType}:{};let I=null;const S=ft(e[0],"PHOTOMETRICINTERPRETATION"),R=ut(e[0],"COLORMAP");if(S<=3&&R?.length>3&&R.length%3==0){I=[];const e=R.length/3;for(let t=0;t<e;t++)I.push([t,R[t]>>>8,R[t+e]>>>8,R[t+2*e]>>>8])}const T=new ve.Z({width:i,height:s,bandCount:a,pixelType:o,pixelSize:b,storageInfo:w,spatialReference:y,isPseudoSpatialReference:g,keyProperties:v,extent:x,colormap:I,statistics:m?m.statistics:null});return d?.length&&(T.nativeExtent=new X.Z({xmin:-.5,ymin:.5-s,xmax:i-.5,ymax:.5,spatialReference:y}),T.transform=new je.Z({polynomialOrder:1,forwardCoefficients:[d[2]+d[0]/2,d[5]-d[3]/2,d[0],d[3],-d[1],-d[4]]}),T.extent=T.transform.forwardTransform(T.nativeExtent),T.pixelSize=new D.Z({x:(x.xmax-x.xmin)/i,y:(x.ymax-x.ymin)/s,spatialReference:y}),w.origin.x=-.5,w.origin.y=.5),{imageInfo:t,rasterInfo:T}}_processPAMInfo(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&null==t.statistics&&(t.statistics=(0,oe.Oh)(e.histograms)),e.transform&&null==t.transform){t.transform=e.transform,t.nativeExtent=t.extent;const i=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new D.Z({x:(i.xmax-i.xmin)/t.width,y:(i.ymax-i.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=i}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}async _readIFDs(e,t,i,s,n,r=4,a){if(!s)return null;(s>=t.byteLength||s<0)&&(t=(await this.request(this.url,{range:{from:s+n,to:s+n+this._bufferSize},responseType:"array-buffer",signal:a})).data,n=s+n,s=0);const o=await this._readIFD(t,i,s,n,ht.Z.tiffTags,r,a);if(e.push(o.ifd),!o.nextIFD)return null;await this._readIFDs(e,t,i,o.nextIFD-n,n,r,a)}async _readIFD(e,t,i,s,n=ht.Z.tiffTags,r=4,a){if(!e)return null;const o=(0,ct.vr)(e,t,i,s,n,r);if(o.success){const i=[];if(o.ifd?.forEach((e=>{e.values||i.push(e)})),i.length>0){const n=i.map((e=>e.offlineOffsetSize)).filter(De.pC),r=Math.min.apply(null,n.map((e=>e[0])));if(Math.min.apply(null,n.map((e=>e[0]+e[1])))-r<=this._bufferSize){const{data:n}=await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:"array-buffer",signal:a});e=n,s=r,i.forEach((i=>(0,ct.Dq)(e,t,i,s)))}}if(o.ifd?.has("GEOKEYDIRECTORY")){const i=o.ifd.get("GEOKEYDIRECTORY"),n=i?.values;if(n&&n.length>4){const r=n[0]+"."+n[1]+"."+n[2],o=await this._readIFD(e,t,i.valueOffset+6-s,s,ht.Z.geoKeys,2,a);i.data=o.ifd,i.data&&i.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[r]})}}return o}if(o.requiredBufferSize&&o.requiredBufferSize!==e.byteLength){const i=await this.request(this.url,{range:{from:s,to:s+o.requiredBufferSize+4},responseType:"array-buffer",signal:a});return(e=i.data).byteLength<o.requiredBufferSize?null:this._readIFD(e,t,0,s,ht.Z.tiffTags,4,a)}}async _fetchRawTiffTile(e,t,i,s,n={}){const r=this._getTileLocation(e,t,i,s);if(!r)return null;const{ranges:a,actualTileWidth:o,actualTileHeight:l,ifd:c}=r,h=a.map((e=>this.request(this.url,{range:e,responseType:"array-buffer",signal:n.signal}))),u=await Promise.all(h),f=u.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),p=1===u.length?u[0].data:new ArrayBuffer(f),d=[0],m=[0];if(u.length>1){const e=new Uint8Array(p);for(let t=0,i=0;t<u.length;t++){const s=u[t].data;e.set(new Uint8Array(s),i),d[t]=i,i+=s.byteLength,m[t]=s.byteLength}}const{blockWidth:y,blockHeight:g}=this.getBlockWidthHeight(e),x=await this.decodePixelBlock(p,{format:"tiff",customOptions:{headerInfo:this._headerInfo,ifd:c,offsets:d,sizes:m},width:y,height:g,planes:null,pixelType:null});if(null==x)return null;let _,w,b;if(o!==y||l!==g){let e=x.mask;if(e)for(_=0;_<g;_++)if(b=_*y,_<l)for(w=o;w<y;w++)e[b+w]=0;else for(w=0;w<y;w++)e[b+w]=0;else for(e=new Uint8Array(y*g),x.mask=e,_=0;_<l;_++)for(b=_*y,w=0;w<o;w++)e[b+w]=1}return x}_getTileLocation(e,t,i,s=!1){const{firstPyramidLevel:n,blockBoundary:r}=this.rasterInfo.storageInfo,a=0===e?0:e-(n-1),{_headerInfo:o}=this;if(!o)return null;const l=s?o.maskIFDs[a]:0===a?o?.ifds[0]:o?.pyramidIFDs[a-1];if(!l)return null;const c=(0,ct.If)(l,o),h=ut(l,"TILEOFFSETS");if(void 0===h)return null;const u=ut(l,"TILEBYTECOUNTS"),{minRow:f,minCol:p,maxRow:d,maxCol:m}=r[a];if(t>d||i>m||t<f||i<p)return null;const y=ft(l,"IMAGEWIDTH"),g=ft(l,"IMAGELENGTH"),x=ft(l,"TILEWIDTH"),_=ft(l,"TILELENGTH"),w=[];if(c){const{bandCount:e}=this.rasterInfo;for(let s=0;s<e;s++){const e=s*(d+1)*(m+1)+t*(m+1)+i;w[s]={from:h[e],to:h[e]+u[e]-1}}}else{const e=t*(m+1)+i;w.push({from:h[e],to:h[e]+u[e]-1})}for(let e=0;e<w.length;e++)if(null==w[e].from||!w[e].to||w[e].to<0)return null;return{ranges:w,ifd:l,actualTileWidth:i===m&&y%x||x,actualTileHeight:t===d&&g%_||_}}async _fetchAuxiliaryMetaData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return $e(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{const{data:t}=await this.request(this.url+".vat.dbf",{responseType:"array-buffer",signal:e?.signal}),i=Re.parse(t);return i?.recordSet?se.Z.fromJSON(i.recordSet):null}catch{return null}}};(0,s._)([(0,u.Cb)()],pt.prototype,"_files",void 0),(0,s._)([(0,u.Cb)()],pt.prototype,"_headerInfo",void 0),(0,s._)([(0,u.Cb)()],pt.prototype,"_bufferSize",void 0),(0,s._)([(0,u.Cb)({type:String,json:{write:!0}})],pt.prototype,"datasetFormat",void 0),pt=(0,s._)([(0,m.j)("esri.layers.support.rasterDatasets.TIFFRaster")],pt);const dt=pt,mt=new Map;mt.set("CRF",{desc:"Cloud Raster Format",constructor:Me}),mt.set("MRF",{desc:"Meta Raster Format",constructor:lt}),mt.set("TIFF",{desc:"GeoTIFF",constructor:dt}),mt.set("RasterTileServer",{desc:"Raster Tile Server",constructor:st}),mt.set("JPG",{desc:"JPG Raster Format",constructor:Xe}),mt.set("PNG",{desc:"PNG Raster Format",constructor:Xe}),mt.set("GIF",{desc:"GIF Raster Format",constructor:Xe}),mt.set("BMP",{desc:"BMP Raster Format",constructor:Xe}),mt.set("CovJSON",{desc:"COVJSON Raster Format",constructor:Ne}),mt.set("MEMORY",{desc:"In Memory Raster Format",constructor:Ee});class yt{static get supportedFormats(){const e=new Set;return mt.forEach(((t,i)=>e.add(i))),e}static async open(e){const{url:t,ioConfig:i,source:s,sourceJSON:n}=e;let r=e.datasetFormat;null==r&&(t.includes(".")?r=t.slice(t.lastIndexOf(".")+1).toUpperCase():"coverage"===s?.type?.toLowerCase()?r="CovJSON":s?.extent&&s.pixelblocks&&(r="MEMORY")),"OVR"===r||"TIF"===r?r="TIFF":"JPG"===r||"JPEG"===r||"JFIF"===r?r="JPG":"COVJSON"===r&&(r="CovJSON"),t.toLowerCase().includes("/imageserver")&&!t.toLowerCase().includes("/wcsserver")&&(r="RasterTileServer");const o={url:t,source:s,sourceJSON:n,datasetFormat:r,ioConfig:i??{bandIds:null,sampling:null}};if(Object.keys(o).forEach((e=>{null==o[e]&&delete o[e]})),r){if(!this.supportedFormats.has(r))throw new a.Z("rasterfactory:open","not a supported format "+r);if("CRF"===r&&!i?.enableCRF)throw new a.Z("rasterfactory:open",`cannot open raster: ${t}`);const s=new(0,mt.get(r).constructor)(o);return await s.open({signal:e.signal}),s}const l=Array.from(mt.keys()).filter((e=>"CovJSON"!==e&&"Memory"!==e));let c=0;const h=()=>{if(r=l[c++],!r)return null;if("CRF"===r&&!i?.enableCRF)return null;const t=new(0,mt.get(r).constructor)(o);return t.open({signal:e.signal}).then((()=>t)).catch((()=>h()))};return h()}static register(e,t,i){mt.has(e.toUpperCase())||mt.set(e.toUpperCase(),{desc:t,constructor:i})}}var gt=i(32163),xt=i(12259);let _t=class extends((0,x.h)((0,xe.M)((0,me.q)((0,ye.I)((0,_.N)(de((0,_e.n)((0,g.Y)((0,ge.Q)((0,l.R)((0,r.J)(y.Z)))))))))))){constructor(...e){super(...e),this._primaryRasters=[],this.bandIds=null,this.interpolation=null,this.legendEnabled=!0,this.isReference=null,this.listMode="show",this.sourceJSON=null,this.version=null,this.type="imagery-tile",this.operationalLayerType="ArcGISTiledImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.fields=null,this._debouncedSaveOperations=(0,c.Ds)((async(e,t,s)=>{const{save:n,saveAs:r}=await i.e(4697).then(i.bind(i,64697));switch(e){case xt.x.SAVE:return n(this,t);case xt.x.SAVE_AS:return r(this,s,t)}}))}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(c.r9).then((()=>this._openRaster(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[new we.Z({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"}),new we.Z({name:"Raster.ServicePixelValue.Raw",alias:"Raw Pixel Value",domain:null,editable:!1,length:50,type:"string"})],{rasterInfo:t}=this,i=t?.attributeTable,s=null!=i?i.fields:null;if(s){const t=s.filter((e=>"oid"!==e.type&&"value"!==e.name.toLowerCase())).map((e=>{const t=e.clone();return t.name="Raster."+e.name,t}));e.push(...t)}const n=t?.dataType,r=t?.multidimensionalInfo;if(("vector-magdir"===n||"vector-uv"===n)&&null!=r){const t=r.variables[0].unit?.trim(),i="Magnitude"+(t?` (${t})`:"");e.push(new we.Z({name:"Raster.Magnitude",alias:i,domain:null,editable:!1,type:"double"})),e.push(new we.Z({name:"Raster.Direction",alias:"Direction (°)",domain:null,editable:!1,type:"double"}))}return e}createPopupTemplate(e){const{rasterFields:t}=this,i=new Set(t.map((({name:e})=>e)).filter((e=>"raster.servicepixelvalue.raw"!==e.toLowerCase())));return(0,gt.eZ)({fields:t,title:this.title},{...e,visibleFieldNames:i})}async generateRasterInfo(e,t){if(!(e=(0,f.TJ)(k.Z,e)))return this.rasterInfo;try{const i={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((e=>i[e.url]=e));const s=(0,ae.Ue)(e.functionDefinition?.toJSON()??e.toJSON(),i),n=new re({rasterFunction:s});return await n.open(t),n.rasterInfo}catch(e){if(e instanceof a.Z)throw e;throw new a.Z("imagery-tile-layer","the given raster function is not supported")}}async save(e){return this._debouncedSaveOperations(xt.x.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(xt.x.SAVE_AS,t,e)}write(e,t){const i=this._primaryRasters[0]??this.raster;if(this.loaded?"RasterTileServer"===i.datasetFormat&&("Raster"===i.tileType||"Map"===i.tileType):this.url&&/\/ImageServer(\/|\/?$)/i.test(this.url))return super.write(e,t);if(t?.messages){const e=`${t.origin}/${t.layerContainerType||"operational-layers"}`;t.messages.push(new a.Z("layer:unsupported",`Layers (${this.title}, ${this.id}) of type '${this.declaredClass}' are not supported in the context of '${e}'`,{layer:this}))}return null}async _openRaster(e){let t=!1;if(this.raster)await this._openFromRaster(this.raster,e),t="Function"===this.raster.datasetFormat;else{const{url:t,rasterFunction:i,source:s}=this;if(!t&&!s)throw new a.Z("imagery-tile-layer:open","missing url or source parameter");i?await this._openFromUrlWithRasterFunction(t,i,e):s?await this._openFromSource(s,e):await this._openFromUrl(t,e)}const i=this.raster.rasterInfo;if(!i)throw new a.Z("imagery-tile-layer:load","cannot load resources on "+this.url);if(this._set("rasterInfo",t?i:this._primaryRasters[0].rasterInfo),this._set("spatialReference",i.spatialReference),this.sourceJSON=this.sourceJSON||this.raster.sourceJSON,null!=this.sourceJSON){const e="Map"===this.raster.tileType&&null!=this.sourceJSON.minLOD&&null!=this.sourceJSON.maxLOD?this.sourceJSON:{...this.sourceJSON,minScale:0,maxScale:0};this.read(e,{origin:"service"})}else this.read({tileInfo:this.rasterInfo.storageInfo.tileInfo.toJSON()},{origin:"service"});this.title||(this.title=this.raster.datasetName),"Map"===this.raster.tileType&&(this.popupEnabled=!1),this._configDefaultSettings(),this.addHandles((0,h.YP)((()=>this.customParameters),(e=>{this.raster&&(this.raster.ioConfig.customFetchParameters=e)})))}async _openFromRaster(e,t){e.rasterInfo||await e.open({signal:t}),this._primaryRasters="Function"===e.datasetFormat?e.primaryRasters.rasters:[e],this.url||(this.url=this._primaryRasters[0].url)}async _openFromUrlWithRasterFunction(e,t,i){const s=[e];t&&(0,ae.G8)(t.toJSON(),s);const n=await Promise.all(s.map((e=>yt.open({url:e,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:i})))),r=n.findIndex((e=>null==e));if(r>-1)throw new a.Z("imagery-tile-layer:open",`cannot open raster: ${s[r]}`);this._primaryRasters=n;const l={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((e=>l[e.url]=e));const c=(0,ae.Ue)(t.functionDefinition?.toJSON()??t.toJSON(),l),h=new re({rasterFunction:c});try{await h.open(),this.raster=h}catch(e){const t=o.Z.getLogger(this);e instanceof a.Z&&t.error("imagery-tile-layer:open",e.message),t.warn("imagery-tile-layer:open","the raster function cannot be applied and is removed"),this._set("rasterFunction",null),this.raster=n[0]}}async _openFromUrl(e,t){const i=await yt.open({url:e,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:t});if(null==i)throw new a.Z("imagery-tile-layer:open",`cannot open raster: ${e}`);this._primaryRasters=[i],this.raster=i}async _openFromSource(e,t){const i="the tiled imagery data source is not supported",s="coverage"===e.type?.toLowerCase()?"CovJSON":e.extent&&e.pixelBlock?"MEMORY":null;if(!s)throw new a.Z("imagery-tile-layer:open",i);"MEMORY"===s&&(e={extent:e.extent,pixelBlocks:[e.pixelBlock]});const n=await yt.open({url:"",source:e,datasetFormat:s,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:t});if(null==n)throw new a.Z("imagery-tile-layer:open",i);this._primaryRasters=[n],this.raster=n}};(0,s._)([(0,u.Cb)({clonable:!1})],_t.prototype,"_primaryRasters",void 0),(0,s._)([(0,u.Cb)({type:[f.z8],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],_t.prototype,"bandIds",void 0),(0,s._)([(0,u.Cb)({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),(0,d.J)(be.cl)],_t.prototype,"interpolation",void 0),(0,s._)([(0,u.Cb)(R.rn)],_t.prototype,"legendEnabled",void 0),(0,s._)([(0,u.Cb)({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],_t.prototype,"isReference",void 0),(0,s._)([(0,u.Cb)({type:["show","hide"]})],_t.prototype,"listMode",void 0),(0,s._)([(0,u.Cb)({json:{read:!0,write:!0}})],_t.prototype,"blendMode",void 0),(0,s._)([(0,u.Cb)()],_t.prototype,"sourceJSON",void 0),(0,s._)([(0,u.Cb)({readOnly:!0,json:{origins:{service:{read:{source:"currentVersion"}}}}})],_t.prototype,"version",void 0),(0,s._)([(0,u.Cb)({readOnly:!0,json:{read:!1}})],_t.prototype,"type",void 0),(0,s._)([(0,u.Cb)({type:["ArcGISTiledImageServiceLayer"]})],_t.prototype,"operationalLayerType",void 0),(0,s._)([(0,u.Cb)({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,t)=>!t.disablePopup},write:{target:"disablePopup",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}},writer(e,t,i){t[i]=!e}}}})],_t.prototype,"popupEnabled",void 0),(0,s._)([(0,u.Cb)({type:n.Z,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}}}}})],_t.prototype,"popupTemplate",void 0),(0,s._)([(0,u.Cb)({readOnly:!0})],_t.prototype,"defaultPopupTemplate",null),(0,s._)([(0,u.Cb)({readOnly:!0,type:[we.Z]})],_t.prototype,"fields",void 0),(0,s._)([(0,u.Cb)({readOnly:!0,type:[we.Z]})],_t.prototype,"rasterFields",null),(0,s._)([(0,u.Cb)({constructOnly:!0})],_t.prototype,"source",void 0),_t=(0,s._)([(0,m.j)("esri.layers.ImageryTileLayer")],_t);const wt=_t},39450:(e,t,i)=>{i.d(t,{Z:()=>h});var s,n=i(43697),r=i(96674),a=i(5600),o=i(75215),l=(i(77734),i(80442),i(52011));let c=s=class extends r.wq{constructor(e){super(e),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new s({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,n._)([(0,a.Cb)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"cols",void 0),(0,n._)([(0,a.Cb)({type:o.z8,json:{write:!0}})],c.prototype,"level",void 0),(0,n._)([(0,a.Cb)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,n._)([(0,a.Cb)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"origin",void 0),(0,n._)([(0,a.Cb)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,n._)([(0,a.Cb)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"rows",void 0),(0,n._)([(0,a.Cb)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=s=(0,n._)([(0,l.j)("esri.layers.support.LOD")],c);const h=c},11145:(e,t,i)=>{i.d(t,{Z:()=>S});var s,n=i(43697),r=i(35454),a=i(96674),o=i(67900),l=i(5600),c=i(75215),h=(i(77734),i(80442),i(71715)),u=i(52011),f=i(30556),p=i(94139),d=i(82971),m=i(24470),y=i(8744),g=i(40488),x=i(39450),_=i(43077);const w=new r.X({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let b=s=class extends a.wq{static create(e={}){const{resolutionFactor:t=1,scales:i,size:n=256,spatialReference:r=d.Z.WebMercator,numLODs:a=24}=e;if(!(0,y.JY)(r)){const e=[];if(i)for(let t=0;t<i.length;t++){const s=i[t];e.push(new x.Z({level:t,scale:s,resolution:s}))}else{let t=5e-4;for(let i=a-1;i>=0;i--)e.unshift(new x.Z({level:i,scale:t,resolution:t})),t*=2}return new s({dpi:96,lods:e,origin:new p.Z(0,0,r),size:[n,n],spatialReference:r})}const l=(0,y.C5)(r),c=e.origin?new p.Z({x:e.origin.x,y:e.origin.y,spatialReference:r}):new p.Z(l?{x:l.origin[0],y:l.origin[1],spatialReference:r}:{x:0,y:0,spatialReference:r}),h=1/(39.37*(0,o.c9)(r)*96),u=[];if(i)for(let e=0;e<i.length;e++){const t=i[e],s=t*h;u.push(new x.Z({level:e,scale:t,resolution:s}))}else{let e=(0,y.sT)(r)?512/n*591657527.5917094:256/n*591657527.591555;const i=Math.ceil(a/t);u.push(new x.Z({level:0,scale:e,resolution:e*h}));for(let s=1;s<i;s++){const i=e/2**t,n=i*h;u.push(new x.Z({level:s,scale:i,resolution:n})),e=i}}return new s({dpi:96,lods:u,origin:c,size:[n,n],spatialReference:r})}constructor(e){super(e),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:e,origin:t}=this;if(e&&t){const i=(0,y.C5)(e);return e.isWrappable&&!!i&&Math.abs(i.origin[0]-t.x)<=i.dx}return!1}readOrigin(e,t){return p.Z.fromJSON({spatialReference:t.spatialReference,...e})}set lods(e){let t=0,i=0;const s=[],n=this._levelToLOD={};e&&(t=-1/0,i=1/0,e.forEach((e=>{s.push(e.scale),t=e.scale>t?e.scale:t,i=e.scale<i?e.scale:i,n[e.level]=e}))),this._set("scales",s),this._set("lods",e),this._initializeUpsampleLevels()}readSize(e,t){return[t.cols,t.rows]}writeSize(e,t){t.cols=e[0],t.rows=e[1]}zoomToScale(e){const t=this.scales;if(e<=0)return t[0];if(e>=t.length-1)return t[t.length-1];const i=Math.floor(e),s=i+1;return t[i]/(t[i]/t[s])**(e-i)}scaleToZoom(e){const t=this.scales,i=t.length-1;let s=0;for(;s<i;s++){const i=t[s],n=t[s+1];if(i<=e)return s;if(n===e)return s+1;if(i>e&&n<e)return s+Math.log(i/e)/Math.log(i/n)}return s}snapScale(e,t=.95){const i=this.scaleToZoom(e);return i%Math.floor(i)>=t?this.zoomToScale(Math.ceil(i)):this.zoomToScale(Math.floor(i))}tileAt(e,t,i,s){const n=this.lodAt(e);if(!n)return null;let r,a;if("number"==typeof t)r=t,a=i;else if((0,y.fS)(t.spatialReference,this.spatialReference))r=t.x,a=t.y,s=i;else{const e=(0,g.iV)(t,this.spatialReference);if(null==e)return null;r=e.x,a=e.y,s=i}const o=n.resolution*this.size[0],l=n.resolution*this.size[1];return s||(s=new _.f(null,0,0,0,(0,m.Ue)())),s.level=e,s.row=Math.floor((this.origin.y-a)/l+.001),s.col=Math.floor((r-this.origin.x)/o+.001),this.updateTileInfo(s),s}updateTileInfo(e,t=s.ExtrapolateOptions.NONE){let i=this.lodAt(e.level);if(!i&&t===s.ExtrapolateOptions.POWER_OF_TWO){const t=this.lods[this.lods.length-1];t.level<e.level&&(i=t)}if(!i)return;const n=e.level-i.level,r=i.resolution*this.size[0]/2**n,a=i.resolution*this.size[1]/2**n;e.id=`${e.level}/${e.row}/${e.col}`,e.extent||(e.extent=(0,m.Ue)()),e.extent[0]=this.origin.x+e.col*r,e.extent[1]=this.origin.y-(e.row+1)*a,e.extent[2]=e.extent[0]+r,e.extent[3]=e.extent[1]+a}upsampleTile(e){const t=this._upsampleLevels[e.level];return!(!t||-1===t.parentLevel||(e.level=t.parentLevel,e.row=Math.floor(e.row/t.factor+.001),e.col=Math.floor(e.col/t.factor+.001),this.updateTileInfo(e),0))}getTileBounds(e,t){const i=this.lodAt(t.level);if(null==i)return null;const{resolution:s}=i,n=s*this.size[0],r=s*this.size[1];return e[0]=this.origin.x+t.col*n,e[1]=this.origin.y-(t.row+1)*r,e[2]=e[0]+n,e[3]=e[1]+r,e}lodAt(e){return this._levelToLOD?.[e]??null}clone(){return s.fromJSON(this.write({}))}getOrCreateCompatible(e,t){if(256===this.size[0]&&256===this.size[1])return 256===e?this:null;const i=[],n=this.lods.length;for(let e=0;e<n;e++){const s=this.lods[e],n=s.resolution*t;i.push(new x.Z({level:s.level,scale:s.scale,resolution:n}))}return new s({size:[e,e],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:i})}_initializeUpsampleLevels(){const e=this.lods;this._upsampleLevels=[];let t=null;for(let i=0;i<e.length;i++){const s=e[i];this._upsampleLevels[s.level]={parentLevel:t?t.level:-1,factor:t?t.resolution/s.resolution:0},t=s}}};var v,I;(0,n._)([(0,l.Cb)({type:Number,json:{write:!0}})],b.prototype,"compressionQuality",void 0),(0,n._)([(0,l.Cb)({type:Number,json:{write:!0}})],b.prototype,"dpi",void 0),(0,n._)([(0,l.Cb)({type:String,json:{read:w.read,write:w.write,origins:{"web-scene":{read:!1,write:!1}}}})],b.prototype,"format",void 0),(0,n._)([(0,l.Cb)({readOnly:!0})],b.prototype,"isWrappable",null),(0,n._)([(0,l.Cb)({type:p.Z,json:{write:!0}})],b.prototype,"origin",void 0),(0,n._)([(0,h.r)("origin")],b.prototype,"readOrigin",null),(0,n._)([(0,l.Cb)({type:[x.Z],value:null,json:{write:!0}})],b.prototype,"lods",null),(0,n._)([(0,l.Cb)({readOnly:!0})],b.prototype,"scales",void 0),(0,n._)([(0,l.Cb)({cast:e=>Array.isArray(e)?e:"number"==typeof e?[e,e]:[256,256]})],b.prototype,"size",void 0),(0,n._)([(0,h.r)("size",["rows","cols"])],b.prototype,"readSize",null),(0,n._)([(0,f.c)("size",{cols:{type:c.z8},rows:{type:c.z8}})],b.prototype,"writeSize",null),(0,n._)([(0,l.Cb)({type:d.Z,json:{write:!0}})],b.prototype,"spatialReference",void 0),b=s=(0,n._)([(0,u.j)("esri.layers.support.TileInfo")],b),v=b||(b={}),(I=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[I.NONE=0]="NONE",I[I.POWER_OF_TWO=1]="POWER_OF_TWO";const S=b},43077:(e,t,i)=>{i.d(t,{f:()=>s});class s{constructor(e,t,i,s,n=void 0){this.id=e,this.level=t,this.row=i,this.col=s,this.extent=n}}},28589:(e,t,i)=>{i.d(t,{y:()=>S});var s,n=i(43697),r=i(3172),a=i(92036),o=i(91303),l=i(20102),c=i(50758),h=i(13867),u=i(44553),f=i(95330),p=i(17445),d=i(1654),m=i(17452),y=i(5600),g=(i(75215),i(77734),i(80442),i(52011)),x=i(43077),_=i(67676),w=i(22974),b=i(1533);class v{constructor(e){this._validateJSON(e);const{location:t,data:i}=e;this.location=Object.freeze((0,w.d9)(t));const s=this.location.width,n=this.location.height;let r=!0,a=!0;const o=function(e,t=!1){return e<=b.c8?t?new Array(e).fill(0):new Array(e):new Uint32Array(e)}(Math.ceil(s*n/32));let l=0;for(let e=0;e<i.length;e++){const t=e%32;i[e]?(a=!1,o[l]|=1<<t):r=!1,31===t&&++l}a?(this._availability="unavailable",this.byteSize=40):r?(this._availability="available",this.byteSize=40):(this._availability=o,this.byteSize=40+(0,b.Xw)(o))}getAvailability(e,t){if("unavailable"===this._availability||"available"===this._availability)return this._availability;const i=(e-this.location.top)*this.location.width+(t-this.location.left),s=i%32,n=i>>5,r=this._availability;return n<0||n>r.length?"unknown":r[n]&1<<s?"available":"unavailable"}static fromDefinition(e,t){const i=e.service.request||r.Z,{row:s,col:n,width:a,height:o}=e,c={query:{f:"json"}};return t=t?{...c,...t}:c,i(function(e){let t;if(e.service.tileServers?.length){const i=e.service.tileServers;t=`${i&&i.length?i[e.row%i.length]:e.service.url}/tilemap/${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`}else t=`${e.service.url}/tilemap/${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`;const i=e.service.query;return i&&(t=`${t}?${i}`),t}(e),t).then((e=>e.data)).catch((e=>{if(e&&e.details&&422===e.details.httpStatus)return{location:{top:s,left:n,width:a,height:o},valid:!0,data:(0,_.a9)(a*o,0)};throw e})).then((e=>{if(e.location&&(e.location.top!==s||e.location.left!==n||e.location.width!==a||e.location.height!==o))throw new l.Z("tilemap:location-mismatch","Tilemap response for different location than requested",{response:e,definition:{top:s,left:n,width:a,height:o}});return v.fromJSON(e)}))}static fromJSON(e){return Object.freeze(new v(e))}_validateJSON(e){if(!e?.location)throw new l.Z("tilemap:missing-location","Location missing from tilemap response");if(!1===e.valid)throw new l.Z("tilemap:invalid","Tilemap response was marked as invalid");if(!e.data)throw new l.Z("tilemap:missing-data","Data missing from tilemap response");if(!Array.isArray(e.data))throw new l.Z("tilemap:data-mismatch","Data must be an array of numbers");if(e.data.length!==e.location.width*e.location.height)throw new l.Z("tilemap:data-mismatch","Number of data items does not match width/height of tilemap")}}function I(e){return`${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`}let S=s=class extends a.Z{constructor(e){super(e),this._pendingTilemapRequests={},this.request=r.Z,this.size=32,this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new h.z(2*o.Y.MEGABYTES),this.addHandles([(0,p.YP)((()=>{const{layer:e}=this;return[e?.parsedUrl,e?.tileServers,e?.apiKey,e?.customParameters]}),(()=>this._initializeTilemapDefinition()),p.nn)])}get effectiveMinLOD(){return this.minLOD??this.layer.tileInfo.lods[0].level}get effectiveMaxLOD(){return this.maxLOD??this.layer.tileInfo.lods[this.layer.tileInfo.lods.length-1].level}fetchTilemap(e,t,i,s){if(!this.layer.tileInfo.lodAt(e)||e<this.effectiveMinLOD||e>this.effectiveMaxLOD)return Promise.reject(new l.Z("tilemap-cache:level-unavailable",`Level ${e} is unavailable in the service`));const n=this._tmpTilemapDefinition,r=this._tilemapFromCache(e,t,i,n);if(r)return Promise.resolve(r);const a=s?.signal;return s={...s,signal:null},new Promise(((e,t)=>{(0,f.fu)(a,(()=>t((0,f.zE)())));const i=I(n);let r=this._pendingTilemapRequests[i];if(!r){r=v.fromDefinition(n,s).then((e=>(this._tilemapCache.put(i,e,e.byteSize),e)));const e=()=>{delete this._pendingTilemapRequests[i]};this._pendingTilemapRequests[i]=r,r.then(e,e)}r.then(e,t)}))}getAvailability(e,t,i){if(!this.layer.tileInfo.lodAt(e)||e<this.effectiveMinLOD||e>this.effectiveMaxLOD)return"unavailable";const s=this._tilemapFromCache(e,t,i,this._tmpTilemapDefinition);return s?s.getAvailability(t,i):"unknown"}fetchAvailability(e,t,i,s){return!this.layer.tileInfo.lodAt(e)||e<this.effectiveMinLOD||e>this.effectiveMaxLOD?Promise.reject(new l.Z("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i})):this.fetchTilemap(e,t,i,s).catch((e=>e)).then((s=>{if(s instanceof v){const n=s.getAvailability(t,i);if("unavailable"===n)throw new l.Z("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i});return n}if((0,f.D_)(s))throw s;return"unknown"}))}fetchAvailabilityUpsample(e,t,i,s,n){s.level=e,s.row=t,s.col=i;const r=this.layer.tileInfo;r.updateTileInfo(s);const a=this.fetchAvailability(e,t,i,n).catch((e=>{if((0,f.D_)(e))throw e;if(r.upsampleTile(s))return this.fetchAvailabilityUpsample(s.level,s.row,s.col,s,n);throw e}));return this._fetchAvailabilityUpsamplePrefetch(s.id,e,t,i,n,a),a}async _fetchAvailabilityUpsamplePrefetch(e,t,i,n,r,a){if(!this._prefetchingEnabled||null==e)return;const o=`prefetch-${e}`;if(this.hasHandles(o))return;const l=new AbortController;a.then((()=>l.abort()),(()=>l.abort()));let h=!1;const u=(0,c.kB)((()=>{h||(h=!0,l.abort())}));if(this.addHandles(u,o),await(0,d.MU)(10,l.signal).catch((()=>{})),h||(h=!0,this.removeHandles(o)),(0,f.Hc)(l))return;const p=new x.f(e,t,i,n),m={...r,signal:l.signal},y=this.layer.tileInfo;for(let e=0;s._prefetches.length<s._maxPrefetch&&y.upsampleTile(p);++e){const e=this.fetchAvailability(p.level,p.row,p.col,m);s._prefetches.push(e);const t=()=>{s._prefetches.removeUnordered(e)};e.then(t,t)}}_initializeTilemapDefinition(){if(!this.layer.parsedUrl)return;const{parsedUrl:e,apiKey:t,customParameters:i}=this.layer;this._tilemapCache.clear(),this._tmpTilemapDefinition={service:{url:e.path,query:(0,m.B7)({...e.query,...i,token:t??e.query?.token}),tileServers:this.layer.tileServers,request:this.request},width:this.size,height:this.size,level:0,row:0,col:0}}_tilemapFromCache(e,t,i,s){s.level=e,s.row=t-t%this.size,s.col=i-i%this.size;const n=I(s);return this._tilemapCache.get(n)}get test(){const e=this;return{get prefetchingEnabled(){return e._prefetchingEnabled},set prefetchingEnabled(t){e._prefetchingEnabled=t},hasTilemap:(t,i,s)=>!!e._tilemapFromCache(t,i,s,e._tmpTilemapDefinition)}}};S._maxPrefetch=4,S._prefetches=new u.Z({initialSize:s._maxPrefetch}),(0,n._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"layer",void 0),(0,n._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"minLOD",void 0),(0,n._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"maxLOD",void 0),(0,n._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"request",void 0),(0,n._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"size",void 0),S=s=(0,n._)([(0,g.j)("esri.layers.support.TilemapCache")],S)},11282:(e,t,i)=>{i.d(t,{cv:()=>o,en:()=>a,lA:()=>r}),i(68773),i(40330);var s=i(22974),n=i(17452);function r(e,t){return t?{...t,query:{...e??{},...t.query}}:{query:e}}function a(e){return"string"==typeof e?(0,n.mN)(e):(0,s.d9)(e)}function o(e,t,i){const s={};for(const n in e){if("declaredClass"===n)continue;const r=e[n];if(null!=r&&"function"!=typeof r)if(Array.isArray(r)){s[n]=[];for(let e=0;e<r.length;e++)s[n][e]=o(r[e])}else if("object"==typeof r)if(r.toJSON){const e=r.toJSON(i?.[n]);s[n]=t?e:JSON.stringify(e)}else s[n]=t?r:JSON.stringify(r);else s[n]=r}return s}i(71058)},79384:(e,t,i)=>{i.d(t,{e:()=>f});var s=i(70586),n=i(95330),r=i(64830),a=i(58971),o=i(10661);class l{constructor(){this._map=new Map,this._observable=new o.s}get size(){return(0,a.it)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(e){const t=this._map.delete(e);return t&&this._observable.notify(),t}entries(){return(0,a.it)(this._observable),this._map.entries()}forEach(e,t){(0,a.it)(this._observable),this._map.forEach(((i,s)=>e.call(t,i,s,this)),t)}get(e){return(0,a.it)(this._observable),this._map.get(e)}has(e){return(0,a.it)(this._observable),this._map.has(e)}keys(){return(0,a.it)(this._observable),this._map.keys()}set(e,t){return this._map.set(e,t),this._observable.notify(),this}values(){return(0,a.it)(this._observable),this._map.values()}[Symbol.iterator](){return(0,a.it)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}var c=i(1654),h=i(95528);class u{constructor(e,t){this.item=e,this.controller=t,this.promise=null}}class f{constructor(e){this._schedule=null,this._task=null,this._deferreds=new l,this._controllers=new l,this._processingItems=new l,this._pausedSignal=(0,h.t)(!1),this.concurrency=1,e.concurrency&&(this.concurrency=e.concurrency),this._queue=new r.Z(e.peeker),this.process=e.process;const t=e.scheduler;e.priority&&t&&(this._task=t.registerTask(e.priority,this))}destroy(){this.clear(),this._schedule=(0,s.hw)(this._schedule),this._task=(0,s.hw)(this._task)}get updating(){return!!this._task?.updating||this.running}get length(){return this._processingItems.size+this._queue.length}abort(e){const t=this._controllers.get(e);t&&t.abort()}clear(){this._queue.clear();const e=[];this._controllers.forEach((t=>e.push(t))),this._controllers.clear(),e.forEach((e=>e.abort())),this._processingItems.clear(),this._cancelNext()}forEach(e){this._deferreds.forEach(((t,i)=>e(i)))}get(e){const t=this._deferreds.get(e);return t?t.promise:void 0}isOngoing(e){return this._processingItems.has(e)}has(e){return this._deferreds.has(e)}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(e,t){const i=this.get(e);if(i)return i;const s=new AbortController;let r=null;t&&(r=(0,n.fu)(t,(()=>s.abort())));const a=()=>{o.remove(),null!=r&&r.remove(),this._deferreds.delete(e),this._controllers.delete(e),this._queue.remove(e),this._processingItems.delete(e),this._scheduleNext()},o=(0,n.$F)(s.signal,(()=>{const t=this._processingItems.get(e);t&&t.controller.abort(),a(),l.reject((0,n.zE)())})),l=(0,n.hh)();return this._deferreds.set(e,l),this._controllers.set(e,s),l.promise.then(a,a),this._queue.push(e),this._scheduleNext(),l.promise}last(){return this._queue.last()}peek(){return this._queue.peek()}popLast(){return this._queue.popLast()}reset(){const e=[];this._processingItems.forEach((t=>e.push(t))),this._processingItems.clear();for(const t of e)this._queue.push(t.item),t.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const e=[];for(;this._queue.length;)e.push(this._queue.pop());return this.clear(),e}get running(){return!this._pausedSignal.value&&this._queue.length>0&&this._processingItems.size<this.concurrency}runTask(e){for(;!e.done&&this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop()),e.madeProgress()}_scheduleNext(){this._task||this._pausedSignal.value||this._schedule||(this._schedule=(0,c.Os)((()=>{this._schedule=null,this._next()})))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).resolve(t))}_processError(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).reject(t))}_canProcessFulfillment(e){return!!this._deferreds.get(e.item)&&this._processingItems.get(e.item)===e}_process(e){if(null==e)return;let t;const i=new AbortController,s=new u(e,i);this._processingItems.set(e,s);try{t=this.process(e,i.signal)}catch(e){this._processError(s,e)}(0,n.y8)(t)?(s.promise=t,t.then((e=>this._processResult(s,e)),(e=>this._processError(s,e)))):this._processResult(s,t)}get test(){return{update:e=>this.runTask(e)}}}}}]);
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{onAbort as s}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import{ensureClass as a}from"../../../core/accessorSupport/ensureType.js";import"../../../core/RandomLCG.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as m}from"../arcgisLayerUrl.js";import{url as f}from"../commonProperties.js";import u from"../DimensionalDefinition.js";import h from"../LOD.js";import p from"../RasterStorageInfo.js";import d from"../TileInfo.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{getRasterId as R,getBlock as w,putBlock as S,deleteBlock as k,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as b}from"../rasterFormats/pixelRangeUtils.js";import{decode as v}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as C,projectPoint as W,snapPyramid as j,shiftExtent as H,getWorldWrapCount as L,projectExtent as z,getProjectionOffsetGrid as E,getRasterDatasetAlignmentInfo as D,projectResolution as O}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as F,uvComponentToVector as A}from"../rasterFunctions/vectorFieldUtils.js";import G from"../../../geometry/Extent.js";import q from"../../../geometry/Point.js";const J=8,N=256;let V=0,U=class extends(n(r)){constructor(){super(...arguments),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=_();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+V++}set url(e){this._set("url",m(e,o.getLogger(this)))}async open(e){throw new i("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,r={}){const o=r.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,o);return r={...r,noClip:!0},this.fetchPixels(n,o.size[0],o.size[1],r)}async identify(e,t={}){e=a(q,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:r}=t,{rasterInfo:o}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=o;let{transposedVariableName:l}=t;const c=null!=s&&n&&(null!=r||x(i));if(c&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:f}=o,{datumTransformation:u}=t;let h=W(e,m,u);if(!f.intersects(h))return{location:h,value:null};if(null!=o.transform){const e=o.transform.inverseTransform(h);if(!o.nativeExtent.intersects(e))return{location:e,value:null};h=e}let p=0;const d=null!=l&&null!=s&&o.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(d)return e.identify(h,t);const{pixelSize:i}=o,r=3,n=i.x*r/2,s=i.y*r/2,l=new G({xmin:h.x-n,xmax:h.x+n,ymin:h.y-s,ymax:h.y+s,spatialReference:m}),a={interpolation:"nearest"},{pixelBlock:c}=await e.fetchPixels(l,r,r,a),{pixelBlock:f}=await this.fetchPixels(l,r,r,a);if(null==c)return{location:h,value:null};const u=Math.floor(r*r*.5),p=!c.mask||c.mask[u]?c.pixels.map((e=>e[u])):null;let x;return null!=f&&(x=!f.mask||f.mask[u]?f.pixels.map((e=>e[u])):void 0),{location:h,value:p,processedValue:x,pyramidLevel:0}}if(!d)if(t.srcResolution){p=j(t.srcResolution,o,this.ioConfig.sampling).pyramidLevel}else if(p=await this.computeBestPyramidLevelForLocation(e,t),null==p)return{location:h,value:null};const y=this.identifyPixelLocation(h,p,null,d);if(null===y)return{location:h,value:null};const{row:g,col:I,rowOffset:k,colOffset:T,blockWidth:b}=y,v=l??t.sliceId,P=R(this.rasterId,v),B=`${p}/${g}/${I}`;let M=w(P,null,B);null==M&&(M=this.fetchRawTile(p,g,I,t),S(P,null,B,M));const _=await M;if(!_?.pixels?.length)return{location:h,value:null};const C=k*b+T;return this._processIdentifyResult(_,{srcLocation:h,position:C,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,r={}){e=H(e),r=this._getRequestOptionsWithSliceId(r);const{_hasNoneOrGCSShiftTransform:o}=this;if(r.requestRawData&&o)return this._fetchPixels(e,t,i,r);const n=C(e.spatialReference),s=L(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&o)return this._fetchPixels(e,t,i,r);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,m=Math.round(n/(c-a)*t),f=m-Math.round((n/2-a)/(c-a)*t);let u=0;const h=[];for(let y=0;y<=s;y++){const o=new G({xmin:0===y?a:-n/2,xmax:y===s?c-n*y:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===y?m-f:y===s?t-u:m;u+=p,h.push(p);const d=r.disableWrapAround&&y>0?null:this._fetchPixels(o,p,i,r);l.push(d)}const p=(await Promise.all(l)).map((e=>e?.pixelBlock));let d=null;const x={width:t,height:i};if(this.rasterJobHandler){d=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:h},r)).pixelBlock}else d=P(p,x,{blockWidths:h});return{extent:e,srcExtent:z(e,this.rasterInfo.spatialReference,r.datumTransformation),pixelBlock:d}}async fetchRawPixels(e,t,i,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,i,r),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,m=s.y*a,f=new G({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-m*(t.y+i.height-1),ymax:n.ymax-m*t.y,spatialReference:n.spatialReference});if(!o)return{extent:f,srcExtent:f,pixelBlock:null};const{pixelBlocks:u,mosaicSize:h}=o;if(1===u.length&&null!=u[0]&&u[0].width===i.width&&u[0].height===i.height)return{extent:f,srcExtent:f,pixelBlock:o.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,d=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%d};let y;if(this.rasterJobHandler){y=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:u,srcMosaicSize:h,destDimension:i,clipOffset:x,clipSize:i,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock}else y=P(u,h,{clipOffset:x,clipSize:i});return{extent:f,srcExtent:f,pixelBlock:y}}fetchRawTile(e,t,r,o){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return z(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?v(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,r=0){const{customFetchParameters:o}=this.ioConfig,{range:n,query:s,headers:l}=i;r=r??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...o},headers:{...l,...a}})}catch(c){if(r>0)return r--,this.request(e,i,r);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,r){const o=r.lodAt(e);return this.getTileExtent({x:o.resolution,y:o.resolution},t,i,r.origin,r.spatialReference,r.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:r}=this.rasterInfo;if(!e.tileInfo){const o=[],n=e.maximumPyramidLevel||0;let s=Math.max(r.x,r.y),l=1/.0254*96*s;for(let e=0;e<=n;e++)o.unshift(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new q({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new d({origin:a,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:o}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,r){const{width:o,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new q({x:s.xmin,y:s.ymax,spatialReference:a});null==r&&(r=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const m=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],r);e.storageInfo=new p({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:m})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,r,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let i=0;i<n;i++)e*=s,t*=s,o.push({x:e,y:t})}const l=[],{x:a,y:c}=r;for(let m=0;m<o.length;m++){const{x:r,y:n}=o[m];l.push({minCol:Math.floor((e.xmin-a+.1*r)/t/r),maxCol:Math.floor((e.xmax-a-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const o=r**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,i,r){const{spatialReference:o,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,m=r&&null!=c?c.tileSize[0]:s.blockWidth,f=r&&null!=c?c.tileSize[1]:s.blockHeight,u=W(e,o,i);if(!n.intersects(u))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-u.y)/d/f,y=(u.x-a.x)/p/m,g=Math.min(f-1,Math.floor((x-Math.floor(x))*f)),I=Math.min(m-1,Math.floor((y-Math.floor(y))*m));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:m,srcLocation:u}}getTileExtent(e,t,i,r,o,n){const[s,l]=n,a=r.x+i*s*e.x,c=a+s*e.x,m=r.y-t*l*e.y,f=m-l*e.y;return new G({xmin:a,xmax:c,ymin:f,ymax:m,spatialReference:o})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<i||r.minRow>t||r.minCol>i}async _fetchPixels(e,t,i,r={}){let o=L(e);if(o>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,r),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:m,ul:f}=n;if(0===c||0===m)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:u}=this,h=u.transform,p="gcs-shift"===h?.type,d=null!=C(e.spatialReference);!p&&d||(o=L(n.srcExtent,p));const x=await this._fetchRawTiles(s,f,{width:c,height:m,wrapCount:o},r);if(!x)return{extent:e,srcExtent:a,pixelBlock:null};const y=u.storageInfo,g=s>0?y.pyramidBlockWidth:y.blockWidth,I=s>0?y.pyramidBlockHeight:y.blockHeight;let{x:R,y:w}=u.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=y;if(null!=e&&e[s-1])({x:R,y:w}=e[s-1]);else{const e=t**s;R*=e,w*=e}}const S=u.spatialReference,k=new q({x:R,y:w,spatialReference:S}),T=g===c&&I===m&&f.x%g==0&&f.y%I==0,b=new q({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),v=!e.spatialReference.equals(S),W=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=r;if(!v&&T&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,b,W))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const H=d&&null!=C(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,z=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");z&&!this.rasterJobHandler&&await _();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:b.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||H,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:z},r):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:b,datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||H,isAdaptive:!1,includeGCSGrid:z});let O;const A=!r.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},J=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,x.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=x;let $=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:A?{width:t,height:i}:null,coefs:A?D.coefficients:null,sampleSpacing:A?G:null,projectDirections:z,gcsGrid:z?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:r.interpolation,alignmentInfo:J,blockWidths:null},r);({pixelBlock:O,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:J});O=A?B(e,{width:t,height:i},D.coefficients,G,r.interpolation):e,z&&D.gcsGrid&&($=M({width:t,height:i},D.gcsGrid),O=F(O,this.rasterInfo.dataType,$))}return r.requestRawData||z?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:O,transformGrid:D,localNorthDirections:$,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:O}}async _fetchRawTiles(e,t,i,r){const{origin:o,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:m,height:f,wrapCount:u}=i;const h=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(a-=r.buffer.cols,c-=r.buffer.rows,m+=2*r.buffer.cols,f+=2*r.buffer.rows);let p=0,d=0,x=0;if(u&&null!=h){({worldColumnCountFromOrigin:d,originColumnOffset:x,rightPadding:p}=h);d*h.blockWidth-p>=a+m&&(p=0)}const y=Math.floor(a/s),g=Math.floor(c/l),I=Math.floor((a+m+p-1)/s),R=Math.floor((c+f+p-1)/l),w=n[e];if(!w)return null;const{minRow:S,minCol:k,maxCol:T,maxRow:b}=w;if(0===u&&(R<S||I<k||g>b||y>T))return null;const v=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let L=g;L<=R;L++)for(let t=y;t<=I;t++){let i=t;if(!r.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),L>=S&&i>=k&&b>=L&&T>=i){const t=this._fetchRawTile(e,L,i,r);B?v.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):v.push(t)}else v.push(Promise.resolve(null))}if(0===v.length)return null;const M=await Promise.all(v),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:C}=this.rasterInfo,W=this.getPyramidPixelSize(e),{x:j,y:H}=W;return{extent:new G({xmin:o.x+y*s*j,xmax:o.x+(I+1)*s*j,ymin:o.y-(R+1)*l*H,ymax:o.y-g*l*H,spatialReference:C}),pixelBlocks:M,mosaicSize:_,isPartiallyFilled:P}}_isSameResolution(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}_fetchRawTile(e,t,i,r){const o=this.rasterInfo.storageInfo.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:l,maxCol:a,maxRow:c}=o;if(t<n||i<l||t>c||i>a)return Promise.resolve(null);const m=R(this.rasterId,r.sliceId),f=`${e}/${t}/${i}`;let u=w(m,r.registryId,f);if(null==u){const o=new AbortController;u=this.fetchRawTile(e,t,i,{...r,signal:o.signal}),S(m,r.registryId,f,u,o),u.catch((()=>k(m,r.registryId,f)))}return r.signal&&s(r,(()=>{T(m,r.registryId,f)})),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const r=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[o,n]=e,s=[],l=[];for(let a=0;a<r;a++){const[e,t]=A([o[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=D(this.rasterInfo)),null==this._rasterTileAlighmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,r={}){const o={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(o.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=o,c=s/t,m=l/i,f=a<n&&c*m>=16,u=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(f||u||(0===s||0===l)){const s=new q({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=O(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const u=!l||r.srcResolution&&l.x+l.y<r.srcResolution.x+r.srcResolution.y;if(f&&r.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,m))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}l&&(o.srcResolution=l,this._updateSourceDataInfo(e,o))}return this._requireTooManySrcTiles(o.srcWidth,o.srcHeight,t,i)&&(o.srcWidth=0,o.srcHeight=0),o}_requireTooManySrcTiles(e,t,i,r){const{tileInfo:o}=this.rasterInfo.storageInfo;return Math.ceil(e/o.size[0])*Math.ceil(t/o.size[1])>=N||e/i>J||t/r>J}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,r=i.spatialReference,{srcResolution:o,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(o,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||z(e,r,n);if(null==c)return;const m=i.transform;m&&(c=m.inverseTransform(c)),t.srcExtent=c;const{x:f,y:u}=i.storageInfo.origin,h=Math.floor((c.xmin-f)/l.x+.1),p=Math.floor((u-c.ymax)/l.y+.1),d=Math.floor((c.xmax-f)/l.x-.1),x=Math.floor((u-c.ymin)/l.y-.1),y=c.width<.1*l.x?0:d-h+1,g=c.height<.1*l.y?0:x-p+1;t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=y,t.srcHeight=g,t.ul={x:h,y:p}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:r,pyramidLevel:o,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[r]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map((e=>e[r])),n={location:i,value:t,pyramidLevel:o},s=this._computeMagDirValues(t.map((e=>[e])));return s?.length&&(n.magdirValue=s.map((e=>e[0]))),n}let a=e.pixels.map((e=>e.slice(r*s,r*s+s))),c=this._computeMagDirValues(a);const{requestSomeSlices:m,identifyOptions:f}=t;let h=g(l,f.transposedVariableName);if(m){const e=I(h,f.multidimensionalDefinition,f.timeExtent);a=a.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),h=e.map((e=>h[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let x;null!=p&&(b(d,p),x=d.mask);return{location:i,value:null,dataSeries:h.map(((e,t)=>{const i={value:0===x?.[t]?null:a.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new u({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:o}}};e([l()],U.prototype,"_rasterTileAlighmentInfo",void 0),e([l({readOnly:!0})],U.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],U.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],U.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],U.prototype,"rasterId",null),e([l(f)],U.prototype,"url",null),e([l({type:String,json:{write:!0}})],U.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],U.prototype,"datasetFormat",void 0),e([l()],U.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],U.prototype,"rasterInfo",void 0),e([l()],U.prototype,"ioConfig",void 0),e([l()],U.prototype,"sourceJSON",void 0),U=e([c("esri.layers.support.rasterDatasets.BaseRaster")],U);const $=U;export{$ as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{onAbort as s}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import{ensureClass as a}from"../../../core/accessorSupport/ensureType.js";import"../../../core/RandomLCG.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as m}from"../arcgisLayerUrl.js";import{url as u}from"../commonProperties.js";import f from"../DimensionalDefinition.js";import h from"../LOD.js";import p from"../RasterStorageInfo.js";import d from"../TileInfo.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{getRasterId as R,getBlock as w,putBlock as S,deleteBlock as k,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as v}from"../rasterFormats/pixelRangeUtils.js";import{decode as b}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as C,projectPoint as W,snapPyramid as j,shiftExtent as H,getWorldWrapCount as L,projectExtent as z,getProjectionOffsetGrid as E,getRasterDatasetAlignmentInfo as D,projectResolution as F}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as O,uvComponentToVector as A}from"../rasterFunctions/vectorFieldUtils.js";import{QueueProcessor as G}from"../../../views/support/QueueProcessor.js";import q from"../../../geometry/Extent.js";import J from"../../../geometry/Point.js";const N=8,V=256;let U=0,$=class extends(n(r)){constructor(){super(...arguments),this._tileFetchQueue=new G({concurrency:32,process:(e,t)=>this._fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=_();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+U++}set url(e){this._set("url",m(e,o.getLogger(this)))}async open(e){throw new i("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,r={}){const o=r.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,o);return r={...r,noClip:!0},this.fetchPixels(n,o.size[0],o.size[1],r)}async identify(e,t={}){e=a(J,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:r}=t,{rasterInfo:o}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=o;let{transposedVariableName:l}=t;const c=null!=s&&n&&(null!=r||x(i));if(c&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:u}=o,{datumTransformation:f}=t;let h=W(e,m,f);if(!u.intersects(h))return{location:h,value:null};if(null!=o.transform){const e=o.transform.inverseTransform(h);if(!o.nativeExtent.intersects(e))return{location:e,value:null};h=e}let p=0;const d=null!=l&&null!=s&&o.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(d)return e.identify(h,t);const{pixelSize:i}=o,r=3,n=i.x*r/2,s=i.y*r/2,l=new q({xmin:h.x-n,xmax:h.x+n,ymin:h.y-s,ymax:h.y+s,spatialReference:m}),a={interpolation:"nearest"},{pixelBlock:c}=await e.fetchPixels(l,r,r,a),{pixelBlock:u}=await this.fetchPixels(l,r,r,a);if(null==c)return{location:h,value:null};const f=Math.floor(r*r*.5),p=!c.mask||c.mask[f]?c.pixels.map((e=>e[f])):null;let x;return null!=u&&(x=!u.mask||u.mask[f]?u.pixels.map((e=>e[f])):void 0),{location:h,value:p,processedValue:x,pyramidLevel:0}}if(!d)if(t.srcResolution){p=j(t.srcResolution,o,this.ioConfig.sampling).pyramidLevel}else if(p=await this.computeBestPyramidLevelForLocation(e,t),null==p)return{location:h,value:null};const y=this.identifyPixelLocation(h,p,null,d);if(null===y)return{location:h,value:null};const{row:g,col:I,rowOffset:k,colOffset:T,blockWidth:v}=y,b=l??t.sliceId,P=R(this.rasterId,b),B=`${p}/${g}/${I}`;let M=w(P,null,B);null==M&&(M=this.fetchRawTile(p,g,I,t),S(P,null,B,M));const _=await M;if(!_?.pixels?.length)return{location:h,value:null};const C=k*v+T;return this._processIdentifyResult(_,{srcLocation:h,position:C,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,r={}){e=H(e),r=this._getRequestOptionsWithSliceId(r);const{_hasNoneOrGCSShiftTransform:o}=this;if(r.requestRawData&&o)return this._fetchPixels(e,t,i,r);const n=C(e.spatialReference),s=L(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&o)return this._fetchPixels(e,t,i,r);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,m=Math.round(n/(c-a)*t),u=m-Math.round((n/2-a)/(c-a)*t);let f=0;const h=[];for(let y=0;y<=s;y++){const o=new q({xmin:0===y?a:-n/2,xmax:y===s?c-n*y:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===y?m-u:y===s?t-f:m;f+=p,h.push(p);const d=r.disableWrapAround&&y>0?null:this._fetchPixels(o,p,i,r);l.push(d)}const p=(await Promise.all(l)).map((e=>e?.pixelBlock));let d=null;const x={width:t,height:i};if(this.rasterJobHandler){d=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:h},r)).pixelBlock}else d=P(p,x,{blockWidths:h});return{extent:e,srcExtent:z(e,this.rasterInfo.spatialReference,r.datumTransformation),pixelBlock:d}}async fetchRawPixels(e,t,i,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,i,r),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,m=s.y*a,u=new q({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-m*(t.y+i.height-1),ymax:n.ymax-m*t.y,spatialReference:n.spatialReference});if(!o)return{extent:u,srcExtent:u,pixelBlock:null};const{pixelBlocks:f,mosaicSize:h}=o;if(1===f.length&&null!=f[0]&&f[0].width===i.width&&f[0].height===i.height)return{extent:u,srcExtent:u,pixelBlock:o.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,d=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%d};let y;if(this.rasterJobHandler){y=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:f,srcMosaicSize:h,destDimension:i,clipOffset:x,clipSize:i,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock}else y=P(f,h,{clipOffset:x,clipSize:i});return{extent:u,srcExtent:u,pixelBlock:y}}fetchRawTile(e,t,r,o){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return z(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?b(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,r=0){const{customFetchParameters:o}=this.ioConfig,{range:n,query:s,headers:l}=i;r=r??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...o},headers:{...l,...a}})}catch(c){if(r>0)return r--,this.request(e,i,r);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,r){const o=r.lodAt(e);return this.getTileExtent({x:o.resolution,y:o.resolution},t,i,r.origin,r.spatialReference,r.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:r}=this.rasterInfo;if(!e.tileInfo){const o=[],n=e.maximumPyramidLevel||0;let s=Math.max(r.x,r.y),l=1/.0254*96*s;for(let e=0;e<=n;e++)o.unshift(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new J({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new d({origin:a,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:o}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,r){const{width:o,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new J({x:s.xmin,y:s.ymax,spatialReference:a});null==r&&(r=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const m=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],r);e.storageInfo=new p({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:m})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,r,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let i=0;i<n;i++)e*=s,t*=s,o.push({x:e,y:t})}const l=[],{x:a,y:c}=r;for(let m=0;m<o.length;m++){const{x:r,y:n}=o[m];l.push({minCol:Math.floor((e.xmin-a+.1*r)/t/r),maxCol:Math.floor((e.xmax-a-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const o=r**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,i,r){const{spatialReference:o,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,m=r&&null!=c?c.tileSize[0]:s.blockWidth,u=r&&null!=c?c.tileSize[1]:s.blockHeight,f=W(e,o,i);if(!n.intersects(f))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-f.y)/d/u,y=(f.x-a.x)/p/m,g=Math.min(u-1,Math.floor((x-Math.floor(x))*u)),I=Math.min(m-1,Math.floor((y-Math.floor(y))*m));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:m,srcLocation:f}}getTileExtent(e,t,i,r,o,n){const[s,l]=n,a=r.x+i*s*e.x,c=a+s*e.x,m=r.y-t*l*e.y,u=m-l*e.y;return new q({xmin:a,xmax:c,ymin:u,ymax:m,spatialReference:o})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<i||r.minRow>t||r.minCol>i}async _fetchPixels(e,t,i,r={}){let o=L(e);if(o>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,r),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:m,ul:u}=n;if(0===c||0===m)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:f}=this,h=f.transform,p="gcs-shift"===h?.type,d=null!=C(e.spatialReference);!p&&d||(o=L(n.srcExtent,p));const x=await this._fetchRawTiles(s,u,{width:c,height:m,wrapCount:o},r);if(!x)return{extent:e,srcExtent:a,pixelBlock:null};const y=f.storageInfo,g=s>0?y.pyramidBlockWidth:y.blockWidth,I=s>0?y.pyramidBlockHeight:y.blockHeight;let{x:R,y:w}=f.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=y;if(null!=e&&e[s-1])({x:R,y:w}=e[s-1]);else{const e=t**s;R*=e,w*=e}}const S=f.spatialReference,k=new J({x:R,y:w,spatialReference:S}),T=g===c&&I===m&&u.x%g==0&&u.y%I==0,v=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),b=!e.spatialReference.equals(S),W=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=r;if(!b&&T&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,v,W))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const H=d&&null!=C(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,z=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");z&&!this.rasterJobHandler&&await _();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:v.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||H,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:z},r):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:v,datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||H,isAdaptive:!1,includeGCSGrid:z});let F;const A=!r.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,x.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=x;let $=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:A?{width:t,height:i}:null,coefs:A?D.coefficients:null,sampleSpacing:A?G:null,projectDirections:z,gcsGrid:z?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:r.interpolation,alignmentInfo:q,blockWidths:null},r);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:q});F=A?B(e,{width:t,height:i},D.coefficients,G,r.interpolation):e,z&&D.gcsGrid&&($=M({width:t,height:i},D.gcsGrid),F=O(F,this.rasterInfo.dataType,$))}return r.requestRawData||z?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F,transformGrid:D,localNorthDirections:$,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F}}async _fetchRawTiles(e,t,i,r){const{origin:o,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:m,height:u,wrapCount:f}=i;const h=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(a-=r.buffer.cols,c-=r.buffer.rows,m+=2*r.buffer.cols,u+=2*r.buffer.rows);let p=0,d=0,x=0;if(f&&null!=h){({worldColumnCountFromOrigin:d,originColumnOffset:x,rightPadding:p}=h);d*h.blockWidth-p>=a+m&&(p=0)}const y=Math.floor(a/s),g=Math.floor(c/l),I=Math.floor((a+m+p-1)/s),R=Math.floor((c+u+p-1)/l),w=n[e];if(!w)return null;const{minRow:S,minCol:k,maxCol:T,maxRow:v}=w;if(0===f&&(R<S||I<k||g>v||y>T))return null;const b=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let L=g;L<=R;L++)for(let t=y;t<=I;t++){let i=t;if(!r.disableWrapAround&&f&&null!=h&&d<=t&&(i=t-d-x),L>=S&&i>=k&&v>=L&&T>=i){const t=this._tileFetchQueue.push({pyramidLevel:e,row:L,col:i,options:r},{signal:r.signal});B?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):b.push(t)}else b.push(Promise.resolve(null))}if(0===b.length)return null;const M=await Promise.all(b),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:C}=this.rasterInfo,W=this.getPyramidPixelSize(e),{x:j,y:H}=W;return{extent:new q({xmin:o.x+y*s*j,xmax:o.x+(I+1)*s*j,ymin:o.y-(R+1)*l*H,ymax:o.y-g*l*H,spatialReference:C}),pixelBlocks:M,mosaicSize:_,isPartiallyFilled:P}}_isSameResolution(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}_fetchRawTile(e,t,i,r){const o=this.rasterInfo.storageInfo.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:l,maxCol:a,maxRow:c}=o;if(t<n||i<l||t>c||i>a)return Promise.resolve(null);const m=R(this.rasterId,r.sliceId),u=`${e}/${t}/${i}`;let f=w(m,r.registryId,u);if(null==f){const o=new AbortController;f=this.fetchRawTile(e,t,i,{...r,signal:o.signal}),S(m,r.registryId,u,f,o),f.catch((()=>k(m,r.registryId,u)))}return r.signal&&s(r,(()=>{T(m,r.registryId,u)})),f}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const r=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[o,n]=e,s=[],l=[];for(let a=0;a<r;a++){const[e,t]=A([o[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=D(this.rasterInfo)),null==this._rasterTileAlighmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,r={}){const o={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(o.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=o,c=s/t,m=l/i,u=a<n&&c*m>=16,f=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(u||f||(0===s||0===l)){const s=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=F(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const f=!l||r.srcResolution&&l.x+l.y<r.srcResolution.x+r.srcResolution.y;if(u&&r.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,m))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}l&&(o.srcResolution=l,this._updateSourceDataInfo(e,o))}return this._requireTooManySrcTiles(o.srcWidth,o.srcHeight,t,i)&&(o.srcWidth=0,o.srcHeight=0),o}_requireTooManySrcTiles(e,t,i,r){const{tileInfo:o}=this.rasterInfo.storageInfo,n=Math.ceil(e/o.size[0])*Math.ceil(t/o.size[1]),s=e/i,l=t/r,a=Math.max(1,(i+r)/1024);return n>=V*a||s>N||l>N}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,r=i.spatialReference,{srcResolution:o,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(o,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||z(e,r,n);if(null==c)return;const m=i.transform;m&&(c=m.inverseTransform(c)),t.srcExtent=c;const{x:u,y:f}=i.storageInfo.origin,h=Math.floor((c.xmin-u)/l.x+.1),p=Math.floor((f-c.ymax)/l.y+.1),d=Math.floor((c.xmax-u)/l.x-.1),x=Math.floor((f-c.ymin)/l.y-.1),y=c.width<.1*l.x?0:d-h+1,g=c.height<.1*l.y?0:x-p+1;t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=y,t.srcHeight=g,t.ul={x:h,y:p}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:r,pyramidLevel:o,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[r]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map((e=>e[r])),n={location:i,value:t,pyramidLevel:o},s=this._computeMagDirValues(t.map((e=>[e])));return s?.length&&(n.magdirValue=s.map((e=>e[0]))),n}let a=e.pixels.map((e=>e.slice(r*s,r*s+s))),c=this._computeMagDirValues(a);const{requestSomeSlices:m,identifyOptions:u}=t;let h=g(l,u.transposedVariableName);if(m){const e=I(h,u.multidimensionalDefinition,u.timeExtent);a=a.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),h=e.map((e=>h[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let x;null!=p&&(v(d,p),x=d.mask);return{location:i,value:null,dataSeries:h.map(((e,t)=>{const i={value:0===x?.[t]?null:a.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new f({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:o}}};e([l()],$.prototype,"_rasterTileAlighmentInfo",void 0),e([l()],$.prototype,"_tileFetchQueue",void 0),e([l({readOnly:!0})],$.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],$.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],$.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],$.prototype,"rasterId",null),e([l(u)],$.prototype,"url",null),e([l({type:String,json:{write:!0}})],$.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],$.prototype,"datasetFormat",void 0),e([l()],$.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],$.prototype,"rasterInfo",void 0),e([l()],$.prototype,"ioConfig",void 0),e([l()],$.prototype,"sourceJSON",void 0),$=e([c("esri.layers.support.rasterDatasets.BaseRaster")],$);const Q=$;export{Q as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.29.0-next.20231021",
3
+ "version": "4.29.0-next.20231024",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- const d="20231021",f="4729b4d7166d53942f9ad1d328388701f9af5f6d";export{d as buildDate,f as commitHash};
5
+ const e="20231024",f="fbcd4eea17c7edf0e89c0974ff2c54fd87fe4906";export{e as buildDate,f as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import i from"../../../../../core/Collection.js";import e from"../../../../../core/Evented.js";import{makeHandle as o}from"../../../../../core/handleUtils.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{zeroMeters as a,scale as s}from"../../../../../core/quantityUtils.js";import{watch as r,syncAndInitial as p}from"../../../../../core/reactiveUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../../../core/support/UpdatingHandles.js";import{makeDehydratedPoint as u}from"../../../../../layers/graphics/dehydratedPoint.js";import{getGraphicEffectiveElevationInfo as m,getConvertedElevation as d}from"../../../../../support/elevationInfoUtils.js";import{getGraphicAttachmentOrigin as g}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as f}from"../../SnappingVisualizer3D.js";import{orientation as v}from"../geometryUtils.js";import{SupportedGraphicResult as _}from"../isSupportedGraphicUtils.js";import{canMoveZ as M}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as y}from"../meshFastUpdateUtils.js";import{createVisualElements as w}from"../visualElementUtils.js";import{discRadius as j}from"../manipulations/config.js";import{ManipulationType as b,MoveManipulation as x}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as T}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as S}from"../manipulations/MoveXYGraphicManipulation.js";import{isSupportedGraphic as E}from"./isSupportedGraphic.js";import{OutlineVisualElement as G}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as O}from"../../../layers/graphics/GraphicState.js";import{dragGraphicMany as H,resetGraphicMany as U}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as X}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as I}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as Y}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as z}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as A}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as P,TranslateGraphicZTooltipInfo as k,TranslateGraphicXYTooltipInfo as R}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Z}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as C}from"../../../../support/euclideanLengthMeasurementUtils.js";class F{constructor(t){this.allGraphics=t,this.type="graphic-move-start"}}class V{constructor(t,i,e){this.dx=t,this.dy=i,this.allGraphics=e,this.type="graphic-move"}}class L{constructor(t){this.allGraphics=t,this.type="graphic-move-stop"}}const N="manipulators";let q=class extends(e.EventedMixin(X)){constructor(t){super(t),this._infos=new Map,this.graphics=new i,this.enableZ=!0,this.tooltipOptions=new D,this.type="move-3d",this._updatingHandles=new c,this._moveManipulation=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateGraphicXYTooltipInfo=null,this._translateGraphicZTooltipInfo=null}initialize(){const{view:t}=this;this.addHandles([this.graphics.on("change",(t=>{t.removed.forEach((t=>this.removeHandles(t))),this._updateGraphicInfos(t),this._setupFastTransformUpdates(t.added),this._refreshManipulators()})),r((()=>this.tooltipOptions.enabled),(i=>{this._tooltip=i?new A({view:t}):n(this._tooltip)}),p)]);const i=this.graphics.toArray();this._updateGraphicInfos({added:i,removed:[]}),this._setupFastTransformUpdates(i),this._refreshManipulators(),this.finishToolCreation()}destroy(){this._tooltip=n(this._tooltip),this._moveManipulation=n(this._moveManipulation),this._set("view",null),this._updatingHandles.destroy()}get updating(){return this._updatingHandles.updating}reset(){}_updateGraphicInfos({added:t,removed:i}){for(const e of t){if(E(e)!==_.SUPPORTED)continue;const t=new B(e),i=this.view.trackGraphicState(t.state);this._infos.set(t.graphic,{info:t,handle:i})}for(const e of i)this._infos.get(e)?.handle.remove(),this._infos.delete(e)}_setupFastTransformUpdates(t){for(const i of t){const{info:t}=this._infos.get(i);this.addHandles(y(t.state),i)}}_refreshManipulators(){if(this.removeHandles(N),this._moveManipulation=n(this._moveManipulation),this.manipulators.removeAll(),0===this._infos.size)return;const t=Array.from(this._infos.values(),(({info:t})=>t));this._createManipulators(t),this._createVisualElements(t),this._updateMoveManipulation(t)}_createManipulators(t){for(const i of t){const e=i.state;i.manipulationXY=new S({tool:this,view:this.view,graphicState:e}),i.manipulationXY.forEachManipulator((t=>this.addHandles([t.events.on("immediate-click",(t=>{this.emit("immediate-click",{...t,graphic:e.graphic}),t.stopPropagation()})),t.events.on("grab-changed",(({action:t})=>{const{tooltipOptions:i,_tooltip:e}=this;null!=e&&("start"===t?(this._translateGraphicTooltipInfo??=new P({tooltipOptions:i}),e.info=this._translateGraphicTooltipInfo,e.info.tooltipOptions=i,e.info.distance=a):e.clear())}))],N))),this.addHandles(i.manipulationXY.createDragPipeline(((i,e,o,n)=>this._buildDragEventPipeline(t,b.XY,i,e,o,n))),N)}this._createMoveManipulation(t)}_createMoveManipulation(t){const i=new x({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:1===t.length?x.radiusForSymbol(t[0].graphic.symbol):j});this._moveManipulation=i,i.elevationInfo={mode:"absolute-height",offset:0},i.forEachManipulator((t=>{this.addHandles(t.events.on("immediate-click",(e=>{i.zManipulation.hasManipulator(t)||1!==this.graphics.length||this.emit("immediate-click",{...e,graphic:this.graphics.at(0)}),e.stopPropagation()})),N)}));const e=i=>e=>{this.addHandles(e.events.on("focus-changed",(({action:e})=>{const o=this._tooltip;null!=o&&("focus"===e?this._updateMoveTooltip(t,i):o.clear())})),N)};this._moveManipulation.xyManipulation.forEachManipulator(e(b.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(e(b.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(e(b.Z));const o=()=>this._updateMoveManipulation(t);for(const a of t)this.addHandles([a.state.on("changed",o),r((()=>a.state.displaying),o)],N);const n=t[t.length-1];this.addHandles(n.state.on("changed",(()=>this._updateMoveManipulationAngle(n))),N),this.addHandles(i.createDragPipeline(((i,e,o,n,a)=>this._buildDragEventPipeline(t,i,e,o,n,a)),m(n.graphic),n.graphic.geometry.spatialReference,n.graphic),N),this._updateMoveManipulationAngle(n)}_createVisualElements(t){for(const i of t){const e=i.graphic,n=w({view:this.view,graphic:e,forEachManipulator:t=>{i.manipulationXY?.forEachManipulator(t),this._moveManipulation?.forEachManipulator(t)},onManipulatorsChanged:()=>o()});null!=n&&(i.geometryRepresentation=n.visualElement,i.geometryRepresentation instanceof G&&this.addHandles([i.geometryRepresentation.events.on("attachment-origin-changed",(()=>{i.state.isDraped||this._updateMoveManipulation(t)})),r((()=>i.state.isDraped),(()=>this._updateMoveManipulation(t)))],N),this.addHandles(n,N))}}_updateMoveManipulationAngle(t){this._moveManipulation&&(this._moveManipulation.angle=v(t.graphic.geometry))}_updateMoveManipulation(t){const i=u(0,0,0,this.view.spatialReference);let e=0,o=!1;const n=this._moveManipulation;if(n){for(const n of t){if(!n.state.displaying)continue;const t=n.state.graphic;this.enableZ&&M(t)&&(o=!0);const a=n.geometryRepresentation instanceof G&&!n.state.isDraped?n.geometryRepresentation.attachmentOrigin:g(this.view,t);if(null!=a){const{x:t,y:o,z:n}=a;i.x+=t,i.y+=o,n&&(i.z??=0,i.z+=n),e++}}e>0?(i.x/=e,i.y/=e,i.z??=0,i.z/=e,n.location=i,n.xyManipulation.available=!0,n.xyAxisManipulation.available=!0,n.zManipulation.available=o):n.available=!1}}_buildDragEventPipeline(t,i,e,o,n,a){const s=[],r=[];let p=null,l=null;const h=()=>{for(const t of s)t.dragging=!1;s.length=0,r.length=0,p=null,l=null,this._moveManipulation&&(this._moveManipulation.interactive=!0)};if(1===t.length&&i===b.XY){const i=t[0].graphic;({steps:o,cancel:n}=this._buildSnappingPipelineSteps(i,m(i),o,n,a))}return n=n.next((t=>l?.(t))).next((()=>(this.emit("graphic-move-stop",new L(r)),this.destroyed||h(),null))),{steps:o=o.next((i=>{if("start"===i.action){s.length=0,r.length=0;for(const i of t)i.dragging||!i.manipulationXY?.hasManipulator(e)&&i.manipulationXY?.grabbing||(s.push(i),r.push(i.graphic),i.dragging=!0);if(0!==r.length&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),p=H(r,this.view.state.viewingMode),l=U(r),this.emit("graphic-move-start",new F(r)),this.destroyed))return null}return 0!==r.length?i:null})).next((t=>p?.(t))).next((e=>(this._updateMoveTooltip(t,i,e),e))).next((t=>{switch(t.action){case"start":case"update":if(t.translationX||t.translationY||t.translationZ){const i=this.view.toScreen(t.mapStart),e=this.view.toScreen(t.mapEnd),o=e.x-i.x,n=e.y-i.y;if(this.emit("graphic-move",new V(o,n,r)),this.destroyed)return null}break;case"end":if(this.emit("graphic-move-stop",new L(r)),this.destroyed)return null;h()}return null})),cancel:n}}_updateMoveTooltip(t,i,e){const{tooltipOptions:o,_tooltip:n}=this;if(null==n)return;n.clear();const a=0===t.length?"absolute-height":t[0].state.isDraped?"on-the-ground":"absolute-height";switch(i){case b.XY:n.info=this._translateGraphicTooltipInfo??=new P({tooltipOptions:o}),this._updateMoveTooltipDistance(n.info,e,((t,i)=>Z(t,i,a)));break;case b.XY_AXIS:n.info=this._translateGraphicXYTooltipInfo??=new R({tooltipOptions:o}),this._updateMoveTooltipDistance(n.info,e,((t,i)=>{const o=Z(t,i,a);return s(o,T(e))}));break;case b.Z:n.info=this._translateGraphicZTooltipInfo??=new k({tooltipOptions:o}),this._updateMoveTooltipDistance(n.info,e,C)}n.info.tooltipOptions=o}_updateMoveTooltipDistance(t,i,e){if(null!=i&&"end"!==i.action){const{mapStart:o,mapEnd:n}=i,s=e(o,n);t.distance=null!=s?s:a}else t.distance=a}_buildSnappingPipelineSteps(t,i,e,o,n){const a=t.geometry;if(null==a||"point"!==a.type&&"mesh"!==a.type)return{steps:e,cancel:o};const s=("point"===a.type?a:a.anchor).clone(),r=new Y({elevationInfo:i,pointer:n,editGeometryOperations:I.fromGeometry(s,this.view.state.viewingMode),visualizer:new f,excludeFeature:t}),p=this.snappingManager,{snappingStep:l,cancelSnapping:h}=z({snappingContext:r,snappingManager:p,updatingHandles:this._updatingHandles});return o=o.next(h),{steps:e=e.next((i=>{s.z=d(this.view,s,m(t),{mode:"absolute-height",offset:0});return{...i,snapOrigin:r.coordinateHelper.pointToVector(s)}})).next(...l),cancel:o}}get test(){return{tooltip:this._tooltip}}};t([l({constructOnly:!0,nonNullable:!0})],q.prototype,"view",void 0),t([l()],q.prototype,"graphics",void 0),t([l({constructOnly:!0,nonNullable:!0})],q.prototype,"enableZ",void 0),t([l({constructOnly:!0,type:D})],q.prototype,"tooltipOptions",void 0),t([l({constructOnly:!0})],q.prototype,"snappingManager",void 0),t([l()],q.prototype,"type",void 0),t([l()],q.prototype,"updating",null),q=t([h("esri.views.3d.interactive.editingTools.graphicMove3D.GraphicMoveTool")],q);class B{constructor(t){this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1,this.state=new O({graphic:t})}get graphic(){return this.state.graphic}}export{V as GraphicMoveEvent,F as GraphicMoveStartEvent,L as GraphicMoveStopEvent,q as GraphicMoveTool};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import i from"../../../../../core/Collection.js";import e from"../../../../../core/Evented.js";import{makeHandle as o}from"../../../../../core/handleUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{zeroMeters as n,scale as s}from"../../../../../core/quantityUtils.js";import{watch as r,syncAndInitial as p}from"../../../../../core/reactiveUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../../../core/support/UpdatingHandles.js";import{makeDehydratedPoint as u}from"../../../../../layers/graphics/dehydratedPoint.js";import{getGraphicEffectiveElevationInfo as m,getConvertedElevation as d}from"../../../../../support/elevationInfoUtils.js";import{getGraphicAttachmentOrigin as g}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as f}from"../../SnappingVisualizer3D.js";import{orientation as v}from"../geometryUtils.js";import{SupportedGraphicResult as _}from"../isSupportedGraphicUtils.js";import{canMoveZ as M}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as y}from"../meshFastUpdateUtils.js";import{createVisualElements as T}from"../visualElementUtils.js";import{discRadius as w}from"../manipulations/config.js";import{ManipulationType as j,MoveManipulation as b}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as I}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as x}from"../manipulations/MoveXYGraphicManipulation.js";import{isSupportedGraphic as S}from"./isSupportedGraphic.js";import{OutlineVisualElement as E}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as G}from"../../../layers/graphics/GraphicState.js";import{dragGraphicMany as H,resetGraphicMany as X}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as O}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as U}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import Y from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as D}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as z}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as A}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as P,TranslateGraphicXYTooltipInfo as k,TranslateGraphicTooltipInfo as R}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Z}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as C}from"../../../../support/euclideanLengthMeasurementUtils.js";class F{constructor(t){this.allGraphics=t,this.type="graphic-move-start"}}class V{constructor(t,i,e){this.dx=t,this.dy=i,this.allGraphics=e,this.type="graphic-move"}}class L{constructor(t){this.allGraphics=t,this.type="graphic-move-stop"}}const N="manipulators";let q=class extends(e.EventedMixin(O)){constructor(t){super(t),this._infos=new Map,this.graphics=new i,this.enableZ=!0,this.tooltipOptions=new Y,this.type="move-3d",this._updatingHandles=new c,this._moveManipulation=null,this._tooltip=null,this._latestTooltipInfo=null,this._translateGraphicTooltipInfo=null,this._translateGraphicXYTooltipInfo=null,this._translateGraphicZTooltipInfo=null}initialize(){const{view:t}=this;this.addHandles([this.graphics.on("change",(t=>{t.removed.forEach((t=>this.removeHandles(t))),this._updateGraphicInfos(t),this._setupFastTransformUpdates(t.added),this._refreshManipulators()})),r((()=>this.tooltipOptions.enabled),(i=>{this._tooltip=i?new A({info:this._latestTooltipInfo,view:t}):a(this._tooltip)}),p)]);const i=this.graphics.toArray();this._updateGraphicInfos({added:i,removed:[]}),this._setupFastTransformUpdates(i),this._refreshManipulators(),this.finishToolCreation()}destroy(){this._tooltip=a(this._tooltip),this._moveManipulation=a(this._moveManipulation),this._set("view",null),this._updatingHandles.destroy()}get updating(){return this._updatingHandles.updating}reset(){}_updateGraphicInfos({added:t,removed:i}){for(const e of t){if(S(e)!==_.SUPPORTED)continue;const t=new B(e),i=this.view.trackGraphicState(t.state);this._infos.set(t.graphic,{info:t,handle:i})}for(const e of i)this._infos.get(e)?.handle.remove(),this._infos.delete(e)}_setupFastTransformUpdates(t){for(const i of t){const{info:t}=this._infos.get(i);this.addHandles(y(t.state),i)}}_refreshManipulators(){if(this.removeHandles(N),this._moveManipulation=a(this._moveManipulation),this.manipulators.removeAll(),0===this._infos.size)return;const t=Array.from(this._infos.values(),(({info:t})=>t));this._createManipulators(t),this._createVisualElements(t),this._updateMoveManipulation(t)}_createManipulators(t){for(const i of t){const e=i.state;i.manipulationXY=new x({tool:this,view:this.view,graphicState:e}),i.manipulationXY.forEachManipulator((i=>this.addHandles([i.events.on("immediate-click",(t=>{this.emit("immediate-click",{...t,graphic:e.graphic}),t.stopPropagation()})),i.events.on("grab-changed",(({action:i})=>{"start"===i?this._showTooltip(t,j.XY):this._hideTooltip()}))],N))),this.addHandles(i.manipulationXY.createDragPipeline(((i,e,o,a)=>this._buildDragEventPipeline(t,j.XY,i,e,o,a))),N)}this._createMoveManipulation(t)}_createMoveManipulation(t){const i=new b({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:1===t.length?b.radiusForSymbol(t[0].graphic.symbol):w});this._moveManipulation=i,i.elevationInfo={mode:"absolute-height",offset:0},i.forEachManipulator((t=>{this.addHandles(t.events.on("immediate-click",(e=>{i.zManipulation.hasManipulator(t)||1!==this.graphics.length||this.emit("immediate-click",{...e,graphic:this.graphics.at(0)}),e.stopPropagation()})),N)}));const e=i=>e=>{this.addHandles([e.events.on("focus-changed",(({action:e})=>{"focus"===e?this._showTooltip(t,i):this._hideTooltip()})),e.events.on("grab-changed",(()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=n)}))],N)};this._moveManipulation.xyManipulation.forEachManipulator(e(j.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(e(j.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(e(j.Z));const o=()=>this._updateMoveManipulation(t);for(const n of t)this.addHandles([n.state.on("changed",o),r((()=>n.state.displaying),o)],N);const a=t[t.length-1];this.addHandles(a.state.on("changed",(()=>this._updateMoveManipulationAngle(a))),N),this.addHandles(i.createDragPipeline(((i,e,o,a,n)=>this._buildDragEventPipeline(t,i,e,o,a,n)),m(a.graphic),a.graphic.geometry.spatialReference,a.graphic),N),this._updateMoveManipulationAngle(a)}_createVisualElements(t){for(const i of t){const e=i.graphic,a=T({view:this.view,graphic:e,forEachManipulator:t=>{i.manipulationXY?.forEachManipulator(t),this._moveManipulation?.forEachManipulator(t)},onManipulatorsChanged:()=>o()});null!=a&&(i.geometryRepresentation=a.visualElement,i.geometryRepresentation instanceof E&&this.addHandles([i.geometryRepresentation.events.on("attachment-origin-changed",(()=>{i.state.isDraped||this._updateMoveManipulation(t)})),r((()=>i.state.isDraped),(()=>this._updateMoveManipulation(t)))],N),this.addHandles(a,N))}}_updateMoveManipulationAngle(t){this._moveManipulation&&(this._moveManipulation.angle=v(t.graphic.geometry))}_updateMoveManipulation(t){const i=u(0,0,0,this.view.spatialReference);let e=0,o=!1;const a=this._moveManipulation;if(a){for(const a of t){if(!a.state.displaying)continue;const t=a.state.graphic;this.enableZ&&M(t)&&(o=!0);const n=a.geometryRepresentation instanceof E&&!a.state.isDraped?a.geometryRepresentation.attachmentOrigin:g(this.view,t);if(null!=n){const{x:t,y:o,z:a}=n;i.x+=t,i.y+=o,a&&(i.z??=0,i.z+=a),e++}}e>0?(i.x/=e,i.y/=e,i.z??=0,i.z/=e,a.location=i,a.xyManipulation.available=!0,a.xyAxisManipulation.available=!0,a.zManipulation.available=o):a.available=!1}}_buildDragEventPipeline(t,i,e,o,a,n){const s=[],r=[];let p=null,l=null;const h=()=>{for(const t of s)t.dragging=!1;s.length=0,r.length=0,p=null,l=null,this._moveManipulation&&(this._moveManipulation.interactive=!0)};if(1===t.length&&i===j.XY){const i=t[0].graphic;({steps:o,cancel:a}=this._buildSnappingPipelineSteps(i,m(i),o,a,n))}return a=a.next((t=>l?.(t))).next((()=>(this.emit("graphic-move-stop",new L(r)),this.destroyed||h(),null))),{steps:o=o.next((i=>{if("start"===i.action){s.length=0,r.length=0;for(const i of t)i.dragging||!i.manipulationXY?.hasManipulator(e)&&i.manipulationXY?.grabbing||(s.push(i),r.push(i.graphic),i.dragging=!0);if(0!==r.length&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),p=H(r,this.view.state.viewingMode),l=X(r),this.emit("graphic-move-start",new F(r)),this.destroyed))return null}return 0!==r.length?i:null})).next((t=>p?.(t))).next((e=>(this._updateMoveTooltip(t,i,e),e))).next((t=>{switch(t.action){case"start":case"update":if(t.translationX||t.translationY||t.translationZ){const i=this.view.toScreen(t.mapStart),e=this.view.toScreen(t.mapEnd),o=e.x-i.x,a=e.y-i.y;if(this.emit("graphic-move",new V(o,a,r)),this.destroyed)return null}break;case"end":if(this.emit("graphic-move-stop",new L(r)),this.destroyed)return null;h()}return null})),cancel:a}}_showTooltip(t,i){this._updateMoveTooltip(t,i),this._latestTooltipInfo&&(this._latestTooltipInfo.distance=n)}_hideTooltip(){this._tooltip?.clear(),this._latestTooltipInfo=null}_updateMoveTooltip(t,i,e){const{tooltipOptions:o,_tooltip:a}=this,n=0===t.length?"absolute-height":t[0].state.isDraped?"on-the-ground":"absolute-height";switch(i){case j.XY:this._latestTooltipInfo=this._translateGraphicTooltipInfo??=new R({tooltipOptions:o}),this._updateMoveTooltipDistance(this._latestTooltipInfo,e,((t,i)=>Z(t,i,n)));break;case j.XY_AXIS:this._latestTooltipInfo=this._translateGraphicXYTooltipInfo??=new k({tooltipOptions:o}),this._updateMoveTooltipDistance(this._latestTooltipInfo,e,((t,i)=>{const o=Z(t,i,n);return s(o,I(e))}));break;case j.Z:this._latestTooltipInfo=this._translateGraphicZTooltipInfo??=new P({tooltipOptions:o}),this._updateMoveTooltipDistance(this._latestTooltipInfo,e,C)}this._latestTooltipInfo.tooltipOptions=o,a&&(a.info=this._latestTooltipInfo)}_updateMoveTooltipDistance(t,i,e){if(null==i||"end"===i.action)return;const{mapStart:o,mapEnd:a}=i,s=e(o,a);t.distance=null!=s?s:n}_buildSnappingPipelineSteps(t,i,e,o,a){const n=t.geometry;if(null==n||"point"!==n.type&&"mesh"!==n.type)return{steps:e,cancel:o};const s=("point"===n.type?n:n.anchor).clone(),r=new D({elevationInfo:i,pointer:a,editGeometryOperations:U.fromGeometry(s,this.view.state.viewingMode),visualizer:new f,excludeFeature:t}),p=this.snappingManager,{snappingStep:l,cancelSnapping:h}=z({snappingContext:r,snappingManager:p,updatingHandles:this._updatingHandles});return o=o.next(h),{steps:e=e.next((i=>{s.z=d(this.view,s,m(t),{mode:"absolute-height",offset:0});return{...i,snapOrigin:r.coordinateHelper.pointToVector(s)}})).next(...l),cancel:o}}get test(){return{tooltip:this._tooltip}}};t([l({constructOnly:!0,nonNullable:!0})],q.prototype,"view",void 0),t([l()],q.prototype,"graphics",void 0),t([l({constructOnly:!0,nonNullable:!0})],q.prototype,"enableZ",void 0),t([l({constructOnly:!0,type:Y})],q.prototype,"tooltipOptions",void 0),t([l({constructOnly:!0})],q.prototype,"snappingManager",void 0),t([l()],q.prototype,"type",void 0),t([l()],q.prototype,"updating",null),q=t([h("esri.views.3d.interactive.editingTools.graphicMove3D.GraphicMoveTool")],q);class B{constructor(t){this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1,this.state=new G({graphic:t})}get graphic(){return this.state.graphic}}export{V as GraphicMoveEvent,F as GraphicMoveStartEvent,L as GraphicMoveStopEvent,q as GraphicMoveTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{createLength as t}from"../../../../../core/quantityUtils.js";import{rotateZ as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as o}from"../../../../../chunks/vec32.js";import{clone as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sm4d as a,sv3d as r}from"../../../../../geometry/support/vectorStacks.js";import{ShiftManipulator as n,OffsetMode as s}from"../../../analysis/Slice/ShiftManipulator.js";import{IsShiftEdgeOnScreenFlag as p}from"../../../analysis/Slice/sliceToolUtils.js";import{screenToZConstrained as l}from"../dragEventPipeline3D.js";import{ManipulatorType as m}from"../ManipulatorType.js";import{ManipulationType as c}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as h}from"../manipulations/MoveXYGraphicManipulation.js";import{createManipulatorDragEventPipeline as u,addScreenDelta as d,addMapDelta as v}from"../../../../interactive/dragEventPipeline.js";import{AccumulationBehaviour as _}from"../../../../interactive/editGeometry/interfaces.js";import{apply as f}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{TranslateGraphicTooltipInfo as g,TranslateGraphicZTooltipInfo as M}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as S}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistance as y}from"../../../../support/euclideanLengthMeasurementUtils.js";class T{constructor(t,e,o,i){this._tool=t,this._graphicState=e,this._editGeometryOperations=o,this._bounds=i,this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null;const a=this._tool,r=a.view;this.moveXYGraphicManipulation=new h({view:r,tool:a,graphicState:this._graphicState}),a.addHandles(this._createMoveXYGraphicDragPipeline()),this.moveZManipulator=new n(r,s.CENTER_ON_CALLOUT),this.moveZManipulator.state|=p,a.manipulators.add(this.moveZManipulator),a.addHandles([this._createMoveZDragPipeline()]),a.addHandles([a.on("graphic-translate-stop",(()=>{this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null}))])}destroy(){this.moveXYGraphicManipulation.destroy(),this._tool.manipulators.remove(this.moveZManipulator),this.moveZManipulator.destroy()}forEachManipulator(t){this.moveXYGraphicManipulation.forEachManipulator(t),t(this.moveZManipulator,m.TRANSLATE_Z)}updateManipulators(t,i){const n=this.moveZManipulator,s=e(a.get(),t,Math.PI);s[12]=0,s[13]=0,s[14]=0,n.modelTransform=s,n.renderLocation=o(r.get(),i.origin,i.basis1)}getUpdatedTooltipInfo(){return this.moveXYGraphicManipulation.grabbing||this.moveXYGraphicManipulation.dragging?this._computeMoveXYTooltipInfo():this.moveZManipulator.focused?this._computeMoveZTooltipInfo():null}_computeMoveXYTooltipInfo(){const t=this._tool.tooltipOptions;return this._moveXYTooltipInfo??=new g({tooltipOptions:t})}_computeMoveZTooltipInfo(){const e=this._tool,o=e.tooltipOptions,i=this._moveZTooltipInfo??=new M({tooltipOptions:o});if(this.moveZManipulator.dragging){const t=this._bounds,e=t.mapBoundsStart.origin,o=t.mapBounds.origin,a=y(e,o,this._tool.view.spatialReference);if(null==a)return null;i.distance=a}else i.distance=t(0,e.moveUnit);return i}_updateMoveTooltip(t,e){if(e===c.XY||e===c.XY_AXIS){const e=S(t.mapStart,t.mapEnd,this._graphicState.isDraped?"on-the-ground":"absolute-height");null!=e&&null!=this._moveXYTooltipInfo&&(this._moveXYTooltipInfo.distance=e)}return t}_createMoveXYGraphicDragPipeline(){return this.moveXYGraphicManipulation.createDragPipeline(((t,e,o)=>this._applyGraphicMoveSteps(e,o,c.XY)))}_createMoveZDragPipeline(){const t=this._editGeometryOperations.data.spatialReference;return u(this.moveZManipulator,((e,o,a)=>{const r=i(e.renderLocation),n=o.next(l(this._tool.view,r,t)).next(d());this._applyGraphicMoveSteps(n,a,c.Z)}))}_applyGraphicMoveSteps(t,e,o){const i=this._tool,a=i.graphic,r=t.next((t=>("start"===t.action&&(i.inputState={type:"move"},this._bounds.backupMapBounds(),i.emit("graphic-translate-start",{graphic:a,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(v()).next(this._moveDragUpdateGeometry()).next((t=>{const e={graphic:a,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY};switch(t.action){case"start":case"update":(t.mapEnd.x-t.mapStart.x||t.mapEnd.y-t.mapStart.y||(t.mapEnd.z??0)-(t.mapStart.z??0))&&i.emit("graphic-translate",e);break;case"end":i.inputState=null,i.emit("graphic-translate-stop",e)}return t})).next((t=>this._updateMoveTooltip(t,o)));return e.next((()=>{null!=i.inputState&&i.emit("graphic-translate-stop",{graphic:a,dxScreen:0,dyScreen:0}),i.cancel()})),r}_moveDragUpdateGeometry(){const t=this._tool;return e=>{if(null==t.inputState||"move"!==t.inputState.type)return e;const o=[];for(const t of this._editGeometryOperations.data.components)o.push(...t.vertices);const i="start"===e.action?_.NEW_STEP:_.ACCUMULATE_STEPS,a=this._editGeometryOperations.moveVertices(o,e.mapDeltaX,e.mapDeltaY,e.mapDeltaZ,i);return f(a,this._bounds.mapBounds),t.graphic.geometry=this._editGeometryOperations.data.geometry,e}}}export{T as ExtentMove};
5
+ import{zeroMeters as t}from"../../../../../core/quantityUtils.js";import{rotateZ as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as o}from"../../../../../chunks/vec32.js";import{clone as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sm4d as a,sv3d as r}from"../../../../../geometry/support/vectorStacks.js";import{ShiftManipulator as n,OffsetMode as s}from"../../../analysis/Slice/ShiftManipulator.js";import{IsShiftEdgeOnScreenFlag as p}from"../../../analysis/Slice/sliceToolUtils.js";import{screenToZConstrained as l}from"../dragEventPipeline3D.js";import{ManipulatorType as c}from"../ManipulatorType.js";import{MoveXYGraphicManipulation as m}from"../manipulations/MoveXYGraphicManipulation.js";import{createManipulatorDragEventPipeline as h,addScreenDelta as u,addMapDelta as d}from"../../../../interactive/dragEventPipeline.js";import{AccumulationBehaviour as v}from"../../../../interactive/editGeometry/interfaces.js";import{apply as g}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{TranslateGraphicTooltipInfo as f,TranslateGraphicZTooltipInfo as _}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationMode as M}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistance as S}from"../../../../support/euclideanLengthMeasurementUtils.js";class y{constructor(t,e,o,i){this._tool=t,this._graphicState=e,this._editGeometryOperations=o,this._bounds=i,this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null;const a=this._tool,r=a.view;this.moveXYGraphicManipulation=new m({view:r,tool:a,graphicState:this._graphicState}),a.addHandles(this._createMoveXYGraphicDragPipeline()),this.moveZManipulator=new n(r,s.CENTER_ON_CALLOUT),this.moveZManipulator.state|=p,a.manipulators.add(this.moveZManipulator),a.addHandles([this._createMoveZDragPipeline()]),a.addHandles([a.on("graphic-translate-stop",(()=>{this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null}))])}destroy(){this.moveXYGraphicManipulation.destroy(),this._tool.manipulators.remove(this.moveZManipulator),this.moveZManipulator.destroy()}forEachManipulator(t){this.moveXYGraphicManipulation.forEachManipulator(t),t(this.moveZManipulator,c.TRANSLATE_Z)}updateManipulators(t,i){const n=this.moveZManipulator,s=e(a.get(),t,Math.PI);s[12]=0,s[13]=0,s[14]=0,n.modelTransform=s,n.renderLocation=o(r.get(),i.origin,i.basis1)}getUpdatedTooltipInfo(){return this.moveXYGraphicManipulation.grabbing||this.moveXYGraphicManipulation.dragging?this._computeMoveXYTooltipInfo():this.moveZManipulator.focused?this._computeMoveZTooltipInfo():null}_computeMoveXYTooltipInfo(){const e=this._tool.tooltipOptions,o=this._moveXYTooltipInfo??=new f({tooltipOptions:e});if(this.moveXYGraphicManipulation.dragging){const t=this._bounds,e=t.mapBoundsStart.origin,i=t.mapBounds.origin,{renderSpatialReference:a}=this._tool.view;if(!a)return null;const r=this._graphicState.isDraped?"on-the-ground":"absolute-height",n=M(e,i,a,r);if(null==n)return null;o.distance=n}else o.distance=t;return o}_computeMoveZTooltipInfo(){const e=this._tool.tooltipOptions,o=this._moveZTooltipInfo??=new _({tooltipOptions:e});if(this.moveZManipulator.dragging){const t=this._bounds,e=t.mapBoundsStart.origin,i=t.mapBounds.origin,{renderSpatialReference:a}=this._tool.view;if(!a)return null;const r=S(e,i,a);if(null==r)return null;o.distance=r}else o.distance=t;return o}_createMoveXYGraphicDragPipeline(){return this.moveXYGraphicManipulation.createDragPipeline(((t,e,o)=>this._applyGraphicMoveSteps(e,o)))}_createMoveZDragPipeline(){const t=this._editGeometryOperations.data.spatialReference;return h(this.moveZManipulator,((e,o,a)=>{const r=i(e.renderLocation),n=o.next(l(this._tool.view,r,t)).next(u());this._applyGraphicMoveSteps(n,a)}))}_applyGraphicMoveSteps(t,e){const o=this._tool,i=o.graphic,a=t.next((t=>("start"===t.action&&(o.inputState={type:"move"},this._bounds.backupMapBounds(),o.emit("graphic-translate-start",{graphic:i,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(d()).next(this._moveDragUpdateGeometry()).next((t=>{const e={graphic:i,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY};switch(t.action){case"start":case"update":(t.mapEnd.x-t.mapStart.x||t.mapEnd.y-t.mapStart.y||(t.mapEnd.z??0)-(t.mapStart.z??0))&&o.emit("graphic-translate",e);break;case"end":o.inputState=null,o.emit("graphic-translate-stop",e)}return t}));return e.next((()=>{null!=o.inputState&&o.emit("graphic-translate-stop",{graphic:i,dxScreen:0,dyScreen:0}),o.cancel()})),a}_moveDragUpdateGeometry(){const t=this._tool;return e=>{if(null==t.inputState||"move"!==t.inputState.type)return e;const o=[];for(const t of this._editGeometryOperations.data.components)o.push(...t.vertices);const i="start"===e.action?v.NEW_STEP:v.ACCUMULATE_STEPS,a=this._editGeometryOperations.moveVertices(o,e.mapDeltaX,e.mapDeltaY,e.mapDeltaZ,i);return g(a,this._bounds.mapBounds),t.graphic.geometry=this._editGeometryOperations.data.geometry,e}}}export{y as ExtentMove};