@arcgis/core 4.27.0-next.20230516 → 4.27.0-next.20230517

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.
Files changed (148) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/06d5f5e37fd44dc7de06.js +1 -0
  3. package/assets/esri/core/workers/chunks/12714d64a0154688072e.js +1 -0
  4. package/assets/esri/core/workers/chunks/{a507135977d83aea4421.js → 1827a3da6b5b9272ffe1.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{395ef46b635f9e9a5643.js → 20e8e18e4bd2fd5da47c.js} +1 -1
  6. package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +1 -0
  7. package/assets/esri/core/workers/chunks/{15dda462b979e90b58fe.js → 3cebdd77a8401495097f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/48cb634255e39711a720.js +1 -0
  9. package/assets/esri/core/workers/chunks/4d5f71d84c85f45c97ea.js +1 -0
  10. package/assets/esri/core/workers/chunks/6312783626bacf52df7a.js +1 -0
  11. package/assets/esri/core/workers/chunks/6d80f81bf6ad97a7e69e.js +1 -0
  12. package/assets/esri/core/workers/chunks/{a3822a97701890c12d63.js → 7903beee895860c7e3af.js} +1 -1
  13. package/assets/esri/core/workers/chunks/887a630c5c980c5028e1.js +1 -0
  14. package/assets/esri/core/workers/chunks/{522660da4589739a70c3.js → c7fb48ea5d907883bcce.js} +1 -1
  15. package/assets/esri/core/workers/chunks/d0ff968e42116f592065.js +1 -0
  16. package/assets/esri/core/workers/chunks/{fdf64f23529a22c79fbd.js → d52c920acf08c95277c3.js} +19 -19
  17. package/assets/esri/core/workers/chunks/d64c271c173797d98286.js +1 -0
  18. package/assets/esri/core/workers/chunks/e1b2076d0040fcb7d864.js +1 -0
  19. package/assets/esri/core/workers/chunks/{b3013a5a39d038b2d748.js → e4f84c79fe3e7b54b76c.js} +1 -1
  20. package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.js +1 -0
  21. package/assets/esri/core/workers/chunks/f3f6035a17f7dcd19675.js +1 -0
  22. package/assets/esri/core/workers/chunks/{bff317b08e91414f6edc.js → f720967ba8c5486a26a2.js} +1 -1
  23. package/assets/esri/themes/base/widgets/_ValuePicker.scss +27 -10
  24. package/assets/esri/themes/dark/main.css +1 -1
  25. package/assets/esri/themes/light/main.css +1 -1
  26. package/assets/esri/themes/light/view.css +1 -1
  27. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ar.json +1 -1
  28. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_bg.json +1 -1
  29. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_bs.json +1 -1
  30. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ca.json +1 -1
  31. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_cs.json +1 -1
  32. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_da.json +1 -1
  33. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_de.json +1 -1
  34. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_el.json +1 -1
  35. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_es.json +1 -1
  36. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_et.json +1 -1
  37. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_fi.json +1 -1
  38. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_fr.json +1 -1
  39. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_he.json +1 -1
  40. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_hr.json +1 -1
  41. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_hu.json +1 -1
  42. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_id.json +1 -1
  43. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_it.json +1 -1
  44. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ja.json +1 -1
  45. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ko.json +1 -1
  46. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_lt.json +1 -1
  47. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_lv.json +1 -1
  48. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_nb.json +1 -1
  49. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_nl.json +1 -1
  50. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pl.json +1 -1
  51. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pt-BR.json +1 -1
  52. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pt-PT.json +1 -1
  53. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ro.json +1 -1
  54. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ru.json +1 -1
  55. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sk.json +1 -1
  56. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sl.json +1 -1
  57. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sr.json +1 -1
  58. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sv.json +1 -1
  59. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_th.json +1 -1
  60. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_tr.json +1 -1
  61. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_uk.json +1 -1
  62. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_vi.json +1 -1
  63. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-CN.json +1 -1
  64. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-HK.json +1 -1
  65. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-TW.json +1 -1
  66. package/chunks/DefaultMaterial.glsl.js +4 -4
  67. package/chunks/HUDMaterial.glsl.js +22 -22
  68. package/chunks/HeatmapDensity.glsl.js +5 -5
  69. package/chunks/LineMarker.glsl.js +35 -35
  70. package/chunks/RibbonLine.glsl.js +47 -47
  71. package/chunks/ShadowCastVisualize.glsl.js +2 -2
  72. package/core/Queue.js +1 -1
  73. package/interfaces.d.ts +290 -6
  74. package/intl/date.js +1 -1
  75. package/layers/ImageryTileLayer.js +1 -1
  76. package/layers/WMSLayer.js +1 -1
  77. package/layers/graphics/data/QueryEngine.js +1 -1
  78. package/layers/graphics/data/attributeSupport.js +1 -1
  79. package/layers/mixins/ArcGISImageService.js +1 -1
  80. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  81. package/package.json +1 -1
  82. package/popup/FieldInfo.js +1 -1
  83. package/popup/support/FieldInfoFormat.js +1 -1
  84. package/portal/schemas/definitions.js +1 -1
  85. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  86. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  87. package/support/revision.js +1 -1
  88. package/views/2d/layers/MediaLayerView2D.js +1 -1
  89. package/views/2d/layers/TileLayerView2D.js +1 -1
  90. package/views/2d/layers/support/cimSymbolUtils.js +1 -1
  91. package/views/3d/support/DisplayQualityProfile.js +1 -1
  92. package/views/3d/support/QualitySettings.js +1 -1
  93. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  94. package/views/3d/terrain/Overlay.js +1 -1
  95. package/views/3d/terrain/OverlayManager.js +1 -1
  96. package/views/3d/terrain/OverlayRenderer.js +1 -1
  97. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +13 -13
  98. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +18 -18
  99. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +8 -8
  100. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  101. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  102. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  103. package/views/3d/webgl-engine/lib/RenderTargetHelper.js +1 -1
  104. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  105. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  106. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  107. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  108. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  109. package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
  110. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  111. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  112. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  113. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  114. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  115. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  116. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  117. package/views/3d/webgl-engine/materials/lineStippleUtils.js +1 -1
  118. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  119. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  120. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  121. package/views/3d/webgl-engine/shaders/HeatmapDensity.glsl.js +1 -1
  122. package/views/3d/webgl-engine/shaders/LineCalloutTechniqueConfiguration.js +1 -1
  123. package/views/3d/webgl-engine/shaders/LineMarkerTechniqueConfiguration.js +1 -1
  124. package/views/PopupView.js +1 -1
  125. package/views/webgl/ValidatedTextureDescriptor.js +1 -1
  126. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  127. package/widgets/FeatureTable.js +1 -1
  128. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  129. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  130. package/widgets/ValuePicker/ValuePickerCollection.js +1 -1
  131. package/widgets/ValuePicker/ValuePickerCombobox.js +1 -1
  132. package/widgets/ValuePicker/ValuePickerLabel.js +1 -1
  133. package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
  134. package/widgets/ValuePicker/ValuePickerViewModel.js +1 -1
  135. package/widgets/ValuePicker.js +1 -1
  136. package/assets/esri/core/workers/chunks/009026614cae60e9505c.js +0 -1
  137. package/assets/esri/core/workers/chunks/415c326d268b1a8fd03f.js +0 -1
  138. package/assets/esri/core/workers/chunks/504e929b686570ee858d.js +0 -1
  139. package/assets/esri/core/workers/chunks/5c811527898eb1c04e67.js +0 -1
  140. package/assets/esri/core/workers/chunks/6164a9c654c38f9cb64e.js +0 -1
  141. package/assets/esri/core/workers/chunks/6dd99db0adce09ac9794.js +0 -1
  142. package/assets/esri/core/workers/chunks/7cec069db0598431829e.js +0 -1
  143. package/assets/esri/core/workers/chunks/8bb3b10a777ae19f57f9.js +0 -1
  144. package/assets/esri/core/workers/chunks/91971a76a4ae0474a878.js +0 -1
  145. package/assets/esri/core/workers/chunks/9ed9e2ad50816a4f937a.js +0 -1
  146. package/assets/esri/core/workers/chunks/b81bb096ccfcea182cc1.js +0 -1
  147. package/assets/esri/core/workers/chunks/d05d9ddf244bb3dcbcaa.js +0 -1
  148. package/assets/esri/core/workers/chunks/d3a6504fbaf555707c58.js +0 -1
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[5913],{91303:(e,t,i)=>{var n;i.d(t,{Y:()=>n}),function(e){e[e.KILOBYTES=1024]="KILOBYTES",e[e.MEGABYTES=1048576]="MEGABYTES",e[e.GIGABYTES=1073741824]="GIGABYTES"}(n||(n={}))},16306:(e,t,i)=>{i.d(t,{aX:()=>v});var n=i(68773),s=i(20102),r=i(92604),a=i(38913),o=i(58901),l=i(73913),c=i(8744),u=i(40488),h=(i(66577),i(3172)),f=i(33955),p=i(11282),d=i(81271);async function m(e,t,i){const n="string"==typeof e?(0,d.mN)(e):e,s=t[0].spatialReference,r=(0,f.Ji)(t[0]),a={...i,query:{...n.query,f:"json",sr:s.wkid??JSON.stringify(s),geometries:JSON.stringify((l=t,{geometryType:(0,f.Ji)(l[0]),geometries:l.map((e=>e.toJSON()))}))}},{data:o}=await(0,h.default)(n.path+"/simplify",a);var l;return function(e,t,i){const n=(0,f.q9)(t);return e.map((e=>{const t=n.fromJSON(e);return t.spatialReference=i,t}))}(o.geometries,r,s)}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 w(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 s.Z(e)}const i=(0,l.x3)(e),n=[];for(const e of i){const i=[];n.push(i),i.push([e[0][0],e[0][1]]);for(let n=0;n<e.length-1;n++){const s=e[n][0],r=e[n][1],a=e[n+1][0],o=e[n+1][1],l=Math.sqrt((a-s)*(a-s)+(o-r)*(o-r)),c=(o-r)/l,u=(a-s)/l,h=l/t;if(h>1){for(let e=1;e<=h-1;e++){const n=e*t,a=u*n+s,o=c*n+r;i.push([a,o])}const e=(l+Math.floor(h-1)*t)/2,n=u*e+s,a=c*e+r;i.push([n,a])}i.push([a,o])}}return function(e){return"polygon"===e.type}(e)?new a.Z({rings:n,spatialReference:e.spatialReference}):new o.Z({paths:n,spatialReference:e.spatialReference})}(e,1e6);e=(0,u.Sx)(t,!0)}return i&&(e=(0,l.Sy)(e,i)),e}function b(e,t,i){if(Array.isArray(e)){const n=e[0];if(n>t){const i=(0,l.XZ)(n,t);e[0]=n+i*(-2*t)}else if(n<i){const t=(0,l.XZ)(n,i);e[0]=n+t*(-2*i)}}else{const n=e.x;if(n>t){const i=(0,l.XZ)(n,t);e=e.clone().offset(i*(-2*t),0)}else if(n<i){const t=(0,l.XZ)(n,i);e=e.clone().offset(t*(-2*i),0)}}return e}function I(e,t){let i=-1;for(let n=0;n<t.cutIndexes.length;n++){const s=t.cutIndexes[n],r=t.geometries[n],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 n=t[e][0];i=n>i?n:i}i=Number(i.toFixed(9));const n=-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(n,0))}return!0}}))}if(s===i){if(g(e))for(const t of(0,l.x3)(r))e[s]=e[s].addRing(t);else if(x(e))for(const t of(0,l.x3)(r))e[s]=e[s].addPath(t)}else i=s,e[s]=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 s="string"==typeof t?t:t?.url??n.default.geometryServiceUrl;let r,d,g,x,_,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,_=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(b(t.clone(),x,_));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map((e=>b(e,x,_))),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,_)*(2*x);let n=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,n=w(n,g),k.push(n),M.push("cut")):e.intersects(T)&&e.xmin!==_?(C=e.xmax*(2*x)>C?e.xmax*(2*x):C,n=w(n,g,360),k.push(n),M.push("cut")):M.push(n)}else M.push(t.clone());else M.push(t);else M.push(t);let F=(0,l.XZ)(C,x),O=-90;const P=F,D=new o.Z;for(;F>0;){const e=360*F-180;D.addPath([[e,O],[e,-1*O]]),O*=-1,F--}if(k.length>0&&P>0){const t=I(k,await async function(e,t,i,n){const s=(0,p.en)(e),r=t[0].spatialReference,a={...n,query:{...s.query,f:"json",sr:JSON.stringify(r),target:JSON.stringify({geometryType:(0,f.Ji)(t[0]),geometries:t}),cutter:JSON.stringify(i)}},o=await(0,h.default)(s.path+"/cut",a),{cutIndexes:l,geometries:c=[]}=o.data;return{cutIndexes:l,geometries:c.map((e=>{const t=(0,f.im)(e);return t.spatialReference=r,t}))}}(s,k,D,i)),n=[],r=[];for(let i=0;i<M.length;i++){const s=M[i];if("cut"!==s)r.push(s);else{const s=t.shift(),a=e[i];null!=a&&"polygon"===a.type&&a.rings&&a.rings.length>1&&s.rings.length>=a.rings.length?(n.push(s),r.push("simplify")):r.push(g?(0,u.$)(s):s)}}if(!n.length)return r;const a=await m(s,n,i),o=[];for(let e=0;e<r.length;e++){const t=r[e];"simplify"!==t?o.push(t):o.push(g?(0,u.$)(a.shift()):a.shift())}return o}const z=[];for(let e=0;e<M.length;e++){const t=M[e];if("cut"!==t)z.push(t);else{const e=k.shift();z.push(!0===g?(0,u.$)(e):e)}}return z}},73913:(e,t,i)=>{i.d(t,{Sy:()=>l,UZ:()=>a,XZ:()=>o,x3:()=>c});var n=i(58901),s=i(82971),r=i(33955);const a={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new n.Z({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:s.Z.WebMercator}),minus180Line:new n.Z({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:s.Z.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new n.Z({paths:[[[180,-180],[180,180]]],spatialReference:s.Z.WGS84}),minus180Line:new n.Z({paths:[[[-180,-180],[-180,180]]],spatialReference:s.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}},74878:(e,t,i)=>{i.r(t),i.d(t,{default:()=>ut});var n=i(43697),s=i(51773),r=i(20102),a=i(92604),o=i(16453),l=i(95330),c=i(17445),u=i(5600),h=i(75215),f=i(67676),p=i(80442),d=i(36030),m=i(52011),y=i(87085),g=i(17287),x=i(71612),w=i(17017),b=(i(66577),i(30030)),I=i(3172),v=i(71715),_=i(8744),S=i(66677),R=i(21506),T=i(35956),C=i(29876),k=i(40297),M=i(88281),F=i(11145),O=i(96674),P=i(70586),D=i(609),z=i(39450),Z=i(36679),B=i(99815),N=i(73506),A=i(94139);const E=new Map,J=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,n=this._cachedBlocks;if(n.has(i)){const e=n.get(i);return e.refCount--,e.refCount<=0&&(n.delete(i),e.controller&&e.controller.abort()),e.refCount}return 0}getBlock(e,t){const i=e+"/"+t,n=this._cachedBlocks;if(n.has(i)){const e=n.get(i);return e.ts=Date.now(),e.refCount++,n.delete(i),n.set(i,e),e.block}return null}putBlock(e,t,i,n){const s=this._cachedBlocks,r=e+"/"+t;if(s.has(r)){const e=s.get(r);e.ts=Date.now(),e.refCount++}else s.set(r,{block:i,ts:Date.now(),refCount:1,controller:n});this._trim(),this._updateTimer()}deleteBlock(e,t){const i=this._cachedBlocks,n=e+"/"+t;i.has(n)&&i.delete(n)}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 n=0;n<t.length&&t[n][1].ts<=i-this._duration;n++)e.delete(t[n][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 H(e,t,i){const n=E.get(e);if(!n)return null==t?J.decreaseRefCount(e,i):0;if(null==t||null==n[t])return J.decreaseRefCount(e,i);const s=n[t]?.cache,r=s?.get(i);if(s&&r){if(r.refCount--,0===r.refCount){s.delete(i);for(let e=0;e<n.length;e++)n[e]?.cache.delete(i);r.controller&&r.controller.abort()}return r.refCount}return 0}function W(e,t,i){const n=E.get(e);if(!n)return null==t?J.getBlock(e,i):null;if(null==t||null==n[t]){for(let e=0;e<n.length;e++){const t=n[e]?.cache.get(i);if(t)return t.refCount++,t.block}return J.getBlock(e,i)}const s=n[t]?.cache.get(i);if(s)return s.refCount++,s.block;for(let e=0;e<n.length;e++){if(e===t||!n[e])continue;const s=n[e]?.cache,r=s?.get(i);if(s&&r)return r.refCount++,s.set(i,r),r.block}return null}function q(e,t,i,n,s=null){const r=E.get(e);if(!r)return void(null==t&&J.putBlock(e,i,n,s));if(null==t||null==r[t])return void J.putBlock(e,i,n,s);const a={refCount:1,block:n,isResolved:!1,isRejected:!1,controller:s};n.then((()=>a.isResolved=!0)).catch((()=>a.isRejected=!0)),r[t]?.cache.set(i,a)}function j(e,t,i){const n=E.get(e);n?null!=t&&null!=n[t]?n[t]?.cache.delete(i):J.deleteBlock(e,i):null==t&&J.deleteBlock(e,i)}var G=i(81578),U=i(75993),$=i(55914),V=i(80676),X=i(6570);let Y=class extends((0,D.v)(O.wq)){constructor(){super(...arguments),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&&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))}set url(e){this._set("url",(0,S.Nm)(e,a.Z.getLogger(this)))}async open(e){throw new r.Z("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,n={}){const s=n.tileInfo||this.rasterInfo.storageInfo.tileInfo,r=this.getTileExtentFromTileInfo(e,t,i,s);return this.fetchPixels(r,s.size[0],s.size[1],n)}async identify(e,t={}){e=(0,h.TJ)(A.Z,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:n}=t,{rasterInfo:s}=this,{hasMultidimensionalTranspose:r,multidimensionalInfo:a}=s;let{transposedVariableName:o}=t;const l=null!=a&&r&&(null!=n||(0,B.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:u}=s,{datumTransformation:f}=t;let p=(0,N.nF)(e,c,f);if(!u.intersects(p))return{location:p,value:null};if(null!=s.transform){const e=s.transform.inverseTransform(p);if(!s.nativeExtent.intersects(e))return{location:e,value:null};p=e}let d=0;const m=null!=o&&null!=a&&s.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(m)return e.identify(p,t);const{pixelSize:i}=s,n=3,r=i.x*n/2,a=i.y*n/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:u}=await e.fetchPixels(o,n,n,l),{pixelBlock:h}=await this.fetchPixels(o,n,n,l);if(null==u)return{location:p,value:null};const f=Math.floor(n*n*.5),d=!u.mask||u.mask[f]?u.pixels.map((e=>e[f])):null;let y;return null!=h&&(y=!h.mask||h.mask[f]?h.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,s,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:w,colOffset:b,blockWidth:I}=y,v=o??t.sliceId,_=L(this.url,v),S=`${d}/${g}/${x}`;let R=W(_,null,S);null==R&&(R=this.fetchRawTile(d,g,x,t),q(_,null,S,R));const T=await R;if(null==T||!T.pixels?.length)return{location:p,value:null};const C=w*I+b;return this._processIdentifyResult(T,{srcLocation:p,position:C,pyramidLevel:d,useTransposedTile:!!m,requestSomeSlices:l,identifyOptions:t})}async fetchPixels(e,t,i,n={}){e=(0,N.kZ)(e),n=this._getRequestOptionsWithSliceId(n);const{_hasNoneOrGCSShiftTransform:s}=this;if(n.requestRawData&&s)return this._fetchPixels(e,t,i,n);const r=(0,N.ut)(e.spatialReference),a=(0,N.Hq)(e);if(null==r||0===a||1===a&&this._isGlobalWrappableSource&&s)return this._fetchPixels(e,t,i,n);if(a>=3)return{extent:e,pixelBlock:null};const o=[],{xmin:l,xmax:c}=e,u=Math.round(r/(c-l)*t),h=u-Math.round((r/2-l)/(c-l)*t);let f=0;const p=[];for(let s=0;s<=a;s++){const d=new X.Z({xmin:0===s?l:-r/2,xmax:s===a?c-r*s:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),m=0===s?u-h:s===a?t-f:u;f+=m,p.push(m);const y=n.disableWrapAround&&s>0?null:this._fetchPixels(d,m,i,n);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},n)).pixelBlock:(0,$.us)(d,y,{blockWidths:p}),{extent:e,srcExtent:(0,N.tB)(e,this.rasterInfo.spatialReference,n.datumTransformation),pixelBlock:m}}async fetchRawPixels(e,t,i,n={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const s=await this._fetchRawTiles(e,t,i,n),{nativeExtent:r,nativePixelSize:a,storageInfo:o}=this.rasterInfo,l=2**e,c=a.x*l,u=a.y*l,h=new X.Z({xmin:r.xmin+c*t.x,xmax:r.xmin+c*(t.x+i.width-1),ymin:r.ymax-u*(t.y+i.height-1),ymax:r.ymax-u*t.y,spatialReference:r.spatialReference});if(!s)return{extent:h,srcExtent:h,pixelBlock:null};const{pixelBlocks:f,mosaicSize:p}=s;if(1===f.length&&null!=f[0]&&f[0].width===i.width&&f[0].height===i.height)return{extent:h,srcExtent:h,pixelBlock:s.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:n.interpolation,alignmentInfo:null,blockWidths:null},n)).pixelBlock:(0,$.us)(f,p,{clipOffset:y,clipSize:i}),{extent:h,srcExtent:h,pixelBlock:g}}fetchRawTile(e,t,i,n){throw new r.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:n}=this.ioConfig,{range:s,query:r,headers:a}=t;i=i??t.retryCount??this.ioConfig.retryCount;const o=s?{Range:`bytes=${s.from}-${s.to}`}:null;try{return await(0,I.default)(e,{...t,query:{...r,...n},headers:{...a,...o}})}catch(n){if(i>0)return i--,this.request(e,t,i);throw n}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:(0,B.gk)(e,t)}getTileExtentFromTileInfo(e,t,i,n){const s=(0,P.s3)(n.lodAt(e));return this.getTileExtent({x:s.resolution,y:s.resolution},t,i,n.origin,n.spatialReference,n.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:n}=this.rasterInfo;if(!e.tileInfo){const s=[],r=e.maximumPyramidLevel||0;let a=Math.max(n.x,n.y),o=1/.0254*96*a;for(let e=0;e<=r;e++)s.push(new z.Z({level:r-e,resolution:a,scale:o})),a*=2,o*=2;const l=new A.Z({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new F.Z({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:s}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,n){const{width:s,height:r,nativeExtent:a,pixelSize:o,spatialReference:l}=e,c=new A.Z({x:a.xmin,y:a.ymax,spatialReference:l});null==n&&(n=Math.max(0,Math.round(Math.log(Math.max(s,r))/Math.LN2-8)));const u=this.computeBlockBoundary(a,512,512,{x:a.xmin,y:a.ymax},[o],n);e.storageInfo=new Z.Z({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:n,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,n,s,r=0,a=2){if(1===s.length&&r>0){s=[...s];let{x:e,y:t}=s[0];for(let i=0;i<r;i++)e*=a,t*=a,s.push({x:e,y:t})}const o=[],{x:l,y:c}=n;for(let n=0;n<s.length;n++){const{x:r,y:a}=s[n];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:n}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const s=n**e;return{x:t.x*s,y:t.y*s}}identifyPixelLocation(e,t,i,n){const{spatialReference:s,nativeExtent:r,storageInfo:a}=this.rasterInfo,{maximumPyramidLevel:o,origin:l,transposeInfo:c}=a,u=n&&null!=c?c.tileSize[0]:a.blockWidth,h=n&&null!=c?c.tileSize[1]:a.blockHeight,f=(0,N.nF)(e,s,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/h,g=(f.x-l.x)/d/u,x=Math.min(h-1,Math.floor((y-Math.floor(y))*h)),w=Math.min(u-1,Math.floor((g-Math.floor(g))*u));return{pyramidLevel:t,row:Math.floor(y),col:Math.floor(g),rowOffset:x,colOffset:w,blockWidth:u,srcLocation:f}}getTileExtent(e,t,i,n,s,r){const[a,o]=r,l=n.x+i*a*e.x,c=l+a*e.x,u=n.y-t*o*e.y,h=u-o*e.y;return new X.Z({xmin:l,xmax:c,ymin:h,ymax:u,spatialReference:s})}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 n=this.rasterInfo.storageInfo.blockBoundary[e];return!n||n.maxRow<t||n.maxCol<i||n.minRow>t||n.minCol>i}async _fetchPixels(e,t,i,n={}){let s=(0,N.Hq)(e);if(s>=2)return{extent:e,pixelBlock:null};const r=this._getSourceDataInfo(e,t,i,n),{pyramidLevel:a,srcResolution:o,srcExtent:l,srcWidth:c,srcHeight:u,ul:h}=r;if(0===c||0===u)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||(s=(0,N.Hq)(r.srcExtent,d));const y=await this._fetchRawTiles(a,h,{width:c,height:u,wrapCount:s},n);if(!y)return{extent:e,srcExtent:l,pixelBlock:null};const g=f.storageInfo,x=a>0?g.pyramidBlockWidth:g.blockWidth,w=a>0?g.pyramidBlockHeight:g.blockHeight;let{x:b,y:I}=f.pixelSize;if(a>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=g;if(null!=e&&e[a-1])({x:b,y:I}=e[a-1]);else{const e=t**a;b*=e,I*=e}}const v=f.spatialReference,_=new A.Z({x:b,y:I,spatialReference:v}),S=x===c&&w===u&&h.x%x==0&&h.y%w==0,R=new A.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}=n;if(!T&&S&&1===y.pixelBlocks.length&&x===t&&w===i&&this._isSameResolution(o,R,C))return{extent:e,srcExtent:l,srcTilePixelSize:_,pixelBlock:y.pixelBlocks[0]};const M=m&&null!=(0,N.ut)(l.spatialReference)&&this._hasNoneOrGCSShiftTransform,F=n.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");F&&!this.rasterJobHandler&&await(0,N.zD)();const O=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:R.toJSON(),datumTransformation:k,rasterTransform:p,hasWrapAround:s>0||M,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:F},n):(0,N.Qp)({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:R,datumTransformation:k,rasterTransform:p,hasWrapAround:s>0||M,isAdaptive:!1,includeGCSGrid:F});let P;const D=!n.requestRawData,z={rows:O.spacing[0],cols:O.spacing[1]},Z=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(a,y.extent.xmin):void 0,{pixelBlocks:B,mosaicSize:E,isPartiallyFilled:J}=y;let L=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:B,srcMosaicSize:E,destDimension:D?{width:t,height:i}:null,coefs:D?O.coefficients:null,sampleSpacing:D?z:null,projectDirections:F,gcsGrid:F?O.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:n.interpolation,alignmentInfo:Z,blockWidths:null},n);({pixelBlock:P,localNorthDirections:L}=e)}else{const e=(0,$.us)(B,E,{alignmentInfo:Z});P=D?(0,$.Uk)(e,{width:t,height:i},O.coefficients,z,n.interpolation):e,F&&O.gcsGrid&&(L=(0,$.Qh)({width:t,height:i},O.gcsGrid),P=(0,V.xQ)(P,this.rasterInfo.dataType,L))}return n.requestRawData||F?{extent:e,srcExtent:l,srcTilePixelSize:_,pixelBlock:P,transformGrid:O,localNorthDirections:L,isPartiallyFilled:J}:{extent:e,srcExtent:l,srcTilePixelSize:_,pixelBlock:P}}async _fetchRawTiles(e,t,i,n){const{origin:s,blockBoundary:r}=this.rasterInfo.storageInfo,{blockWidth:a,blockHeight:o}=this.getBlockWidthHeight(e);let{x:l,y:c}=t,{width:u,height:h,wrapCount:f}=i;const p=this._getRasterTileAlignmentInfo(e,0);n.buffer&&(l-=n.buffer.cols,c-=n.buffer.rows,u+=2*n.buffer.cols,h+=2*n.buffer.rows);let d=0,m=0,y=0;f&&null!=p&&(({worldColumnCountFromOrigin:m,originColumnOffset:y,rightPadding:d}=p),m*p.blockWidth-d>=l+u&&(d=0));const g=Math.floor(l/a),x=Math.floor(c/o),w=Math.floor((l+u+d-1)/a),b=Math.floor((c+h+d-1)/o),I=r[e];if(!I)return null;const{minRow:v,minCol:_,maxCol:S,maxRow:R}=I;if(0===f&&(b<v||w<_||x>R||g>S))return null;const T=new Array;let C=!1;const k=null==this.ioConfig.allowPartialFill?n.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=x;t<=b;t++)for(let i=g;i<=w;i++){let s=i;if(!n.disableWrapAround&&f&&null!=p&&m<=i&&(s=i-m-y),t>=v&&s>=_&&R>=t&&S>=s){const i=this._fetchRawTile(e,t,s,n);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:(b-x+1)*o,width:(w-g+1)*a},{spatialReference:O}=this.rasterInfo,P=this.getPyramidPixelSize(e),{x:D,y:z}=P;return{extent:new X.Z({xmin:s.x+g*a*D,xmax:s.x+(w+1)*a*D,ymin:s.y-(b+1)*o*z,ymax:s.y-x*o*z,spatialReference:O}),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,n){const s=this.rasterInfo.storageInfo.blockBoundary[e];if(!s)return Promise.resolve(null);const{minRow:r,minCol:a,maxCol:o,maxRow:c}=s;if(t<r||i<a||t>c||i>o)return Promise.resolve(null);const u=L(this.url,n.sliceId),h=`${e}/${t}/${i}`;let f=W(u,n.registryId,h);if(null==f){const s=new AbortController;f=this.fetchRawTile(e,t,i,{...n,signal:s.signal}),q(u,n.registryId,h,f,s),f.catch((()=>j(u,n.registryId,h)))}return n.signal&&(0,l.fu)(n,(()=>{H(u,n.registryId,h)})),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 n=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[s,r]=e,a=[],o=[];for(let e=0;e<n;e++){const[t,i]=(0,V.Tg)([s[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,n={}){const s={datumTransformation:n.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};n.srcResolution&&(s.srcResolution=n.srcResolution,this._updateSourceDataInfo(e,s));const r=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:a,srcHeight:o,pyramidLevel:l}=s,c=a/t,u=o/i,h=l<r&&c*u>=16,f=l===r&&this._requireTooManySrcTiles(a,o,t,i);if(h||f||0===a||0===o){const a=new A.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,s.datumTransformation);const f=!o||n.srcResolution&&o.x+o.y<n.srcResolution.x+n.srcResolution.y;if(h&&n.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,u))/Math.LN2)-1;if(r-l+3>=e){const t=2**e;o={x:n.srcResolution.x*t,y:n.srcResolution.y*t}}}o&&(s.srcResolution=o,this._updateSourceDataInfo(e,s))}return this._requireTooManySrcTiles(s.srcWidth,s.srcHeight,t,i)&&(s.srcWidth=0,s.srcHeight=0),s}_requireTooManySrcTiles(e,t,i,n){const{tileInfo:s}=this.rasterInfo.storageInfo;return Math.ceil(e/s.size[0])*Math.ceil(t/s.size[1])>=256||e/i>8||t/n>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,n=i.spatialReference,{srcResolution:s,datumTransformation:r}=t,{pyramidLevel:a,pyramidResolution:o,excessiveReading:l}=(0,N.kr)(s,i,this.ioConfig.sampling);if(l)return;let c=t.srcExtent||(0,N.tB)(e,n,r);if(null==c)return;const u=i.transform;u&&(c=u.inverseTransform(c)),t.srcExtent=c;const{x:h,y:f}=i.storageInfo.origin,p=Math.floor((c.xmin-h)/o.x+.1),d=Math.floor((f-c.ymax)/o.y+.1),m=Math.floor((c.xmax-h)/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:n,pyramidLevel:s,useTransposedTile:r}=t,a=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[n])return{location:i,value:null};const{multidimensionalInfo:o}=this.rasterInfo;if(null==o||!r){const t=e.pixels.map((e=>e[n])),r={location:i,value:t,pyramidLevel:s},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(n*a,n*a+a))),c=this._computeMagDirValues(l);const{requestSomeSlices:u,identifyOptions:h}=t;let f=(0,B.MO)(o,h.transposedVariableName);if(u){const e=(0,B.Ur)(f,h.multidimensionalDefinition,h.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,G.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:s}}};(0,n._)([(0,u.Cb)()],Y.prototype,"_rasterTileAlighmentInfo",void 0),(0,n._)([(0,u.Cb)({readOnly:!0})],Y.prototype,"_isGlobalWrappableSource",null),(0,n._)([(0,u.Cb)({readOnly:!0})],Y.prototype,"_hasNoneOrGCSShiftTransform",null),(0,n._)([(0,u.Cb)()],Y.prototype,"rasterJobHandler",null),(0,n._)([(0,u.Cb)(R.HQ)],Y.prototype,"url",null),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Y.prototype,"datasetName",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Y.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"hasUniqueSourceStorageInfo",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"rasterInfo",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"ioConfig",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"sourceJSON",void 0),Y=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.BaseRaster")],Y);const K=Y;let Q=class extends K{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:n}=this.primaryRasters,s=i.map((t=>t.rasterInfo?void 0:t.open(e)));await Promise.all(s);const a=i.map((({rasterInfo:e})=>e)),o=t.bind({rasterInfos:a,rasterIds:n});if(!o.success||0===a.length)throw new r.Z("raster-function:open",`cannot bind the function: ${o.error??""}`);await this.syncJobHandler();const l=a[0];this.hasUniqueSourceStorageInfo=1===a.length||a.slice(1).every((e=>this._hasSameStorageInfo(e,l))),this.set("sourceJSON",i[0].sourceJSON),this.set("rasterInfo",t.rasterInfo)}async syncJobHandler(){return this.rasterJobHandler?.updateRasterFunction(this.rasterFunction)}async fetchPixels(e,t,i,n={}){const{rasters:s,rasterIds:r}=this.primaryRasters;let a=!1;const{interpolation:o}=n,l=this.rasterFunction.flatWebGLFunctionChain?.hasSurfaceFunction;!n.requestRawData&&"bilinear"!==o&&l&&(a=1===s.length&&!n.skipRasterFunction,n={...n,interpolation:"bilinear",requestRawData:a});const c=s.map((s=>s.fetchPixels(e,t,i,n))),u=await Promise.all(c),h=u.map((e=>e.pixelBlock)),f=a||n.requestRawData?u.map((e=>e.srcTilePixelSize)):null;if(n.skipRasterFunction||h.every((e=>null==e)))return u[0];const p=u.find((e=>null!=e.pixelBlock))?.extent??e,d=this.rasterJobHandler?await this.rasterJobHandler.process({extent:p,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:r}):this.rasterFunction.process({extent:p,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:r}),{transformGrid:m}=u[0];if(!a||null==d||null==m)return{...u[0],pixelBlock:d};const y={rows:m.spacing[0],cols:m.spacing[1]};let g;return g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:[d],srcMosaicSize:{width:d.width,height:d.height},destDimension:{width:t,height:i},coefs:m.coefficients,sampleSpacing:y,projectDirections:!1,gcsGrid:null,isUV:!1,interpolation:o,alignmentInfo:void 0,blockWidths:null},n)).pixelBlock:(0,$.Uk)(d,{width:t,height:i},m.coefficients,y,o),{extent:e,srcExtent:u[0].srcExtent,pixelBlock:g}}_hasSameStorageInfo(e,t){const{storageInfo:i,pixelSize:n,spatialReference:s,extent:r}=e,{storageInfo:a,pixelSize:o,spatialReference:l,extent:c}=t;return n.x===o.x&&n.y===o.y&&s.equals(l)&&r.equals(c)&&i.blockHeight===a.blockHeight&&i.blockWidth===a.blockWidth&&i.maximumPyramidLevel===a.maximumPyramidLevel}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Q.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],Q.prototype,"tileType",void 0),(0,n._)([(0,u.Cb)()],Q.prototype,"rasterFunction",void 0),(0,n._)([(0,u.Cb)()],Q.prototype,"primaryRasters",void 0),Q=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.FunctionRaster")],Q);const ee=Q;var te=i(67900),ie=i(5847);var ne=i(90036),se=i(15612),re=i(67058),ae=i(72758),oe=i(79681),le=i(23808),ce=i(82971);const ue=a.Z.getLogger("esri.layers.mixins.ImageryTileMixin"),he=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){this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",(0,S.Nm)(e,ue))}set renderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("renderer",e),this.updateRenderer())}readRenderer(e,t,i){const n=t?.layerDefinition?.drawingInfo?.renderer;return(0,b.ij)(n,i)||void 0}async convertVectorFieldData(e,t){if(null==e||!this.rasterInfo)return null;const i=this._rasterJobHandler.instance,n=this.rasterInfo.dataType;return i?i.convertVectorFieldData({pixelBlock:e,dataType:n},t):(0,V.KC)(e,n)}async computeStatisticsHistograms(e,t){e=(0,h.TJ)(oe.Z,e).clone();const{rasterInfo:n}=this,{geometry:s}=e;if(null==s)throw new r.Z("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let a=s;const{spatialReference:o}=n;s.spatialReference.equals(o)||(await(0,N.zD)(),a="extent"===s.type?(0,N.tB)(s,o):(0,N.Wt)(s,o));const l=e.pixelSize??new A.Z({x:n.pixelSize.x,y:n.pixelSize.y,spatialReference:o}),{extent:c,width:u,height:f}=function(e,t,i,n=!0){const{spatialReference:s}=e,{x:r,y:a}=function(e,t){if(e.spatialReference.equals(t))return e;const i=(0,te.c9)(e.spatialReference),n=(0,te.c9)(t);if(i===n)return e;const s=i/n;return{x:e.x*s,y:e.y*s}}(i,s);let o,l,c;const u="extent"===t.type?t:t.extent;let{xmin:h,xmax:f,ymax:p,ymin:d}=u;const{xmin:m,ymax:y}=e.extent;return n?(h=m+(h>m?r*Math.round((h-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:h,ymax:p,xmax:f,ymin:d,spatialReference:s}),l=Math.round(o.width/r),c=Math.round(o.height/a)):(l=Math.floor((f-h)/r+.8),c=Math.floor((p-d)/a+.8),h=m+(h>m?r*Math.floor((h-m)/r+.1):0),p=y-(p<y?a*Math.floor((y-p)/a+.1):0),f=h+l*r,d=p-c*a,o=new X.Z({xmin:h,ymax:p,xmax:f,ymin:d,spatialReference:s})),{extent:o,width:l,height:c}}(n,a,l),p=await this.fetchPixels(c,u,f,{...t,interpolation:"nearest"});if(null==p.pixelBlock)throw new r.Z("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const d=await async function(e,t,n){if("extent"===n.type)return function(e,t,i){const{width:n,height:s}=e,r=new Uint8Array(n*s),a=t.width/n,o=t.height/s;if(i.width/a<.5||i.height/o<.5)return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]});const{xmin:l,xmax:c,ymin:u,ymax:h}=t,{xmin:f,xmax:p,ymin:d,ymax:m}=i,y=Math.max(l,f),g=Math.min(c,p),x=Math.max(u,d),w=Math.min(h,m),b=.5*a,I=.5*o;if(g-y<b||w-x<I||g<l+b||y>c-b||x>h-I||w<u+I)return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]});const v=Math.max(0,(y-l)/a),_=Math.min(n,Math.max(0,(g-l)/a)),S=Math.max(0,(h-w)/o),R=Math.min(s,Math.max(0,(h-x)/o)),T=Math.round(v),C=Math.round(_)-1,k=Math.round(S),M=Math.round(R)-1;if(T===C&&v%1>.5&&_%1<.5||k===M&&S%1>.5&&R%1<.5)return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]});if(0===T&&0===k&&C===n&&M===s)return e;const F=e.mask;for(let e=k;e<=M;e++)for(let t=T;t<=C;t++){const i=e*n+t;r[i]=F?F[i]:255}return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]})}(e,t,n);const{width:s,height:r}=e,a=new Uint8Array(s*r),{contains:o,intersects:l}=await Promise.all([i.e(5837),i.e(1433)]).then(i.bind(i,61433));return l(t,n)?"polyline"===n.type?function(e,t,i){const{width:n,height:s}=e,r=new Uint8Array(n*s),a=t.width/n,o=t.height/s,{xmin:l,ymax:c}=t,{paths:u}=i,h=e.mask;for(let e=0;e<u.length;e++){const t=u[e];for(let e=0;e<t.length-1;e++){const[i,u]=t[e],[f,p]=t[e+1];let d=Math.floor((c-u)/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(s-1,m);const y=(f-i)/(p-u);for(let e=d;e<=m;e++){const t=e===d?Math.max(u,p):(s+1-e)*o,c=e===m?Math.min(u,p):t-o;let g=p===u?Math.floor((i-l)/a):Math.floor((y*(t-u)+i-l)/a),x=p===u?Math.floor((f-l)/a):Math.floor((y*(c-u)+i-l)/a);if(x<g){const e=g;g=x,x=e}const w=e*n;g=Math.max(0,g),x=Math.min(n-1,x);for(let e=w+g;e<=w+x;e++)r[e]=h?h[e]:255}}}return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]})}(e,t,n):o(n,t)?e:function(e,t,i){if(!e)return e;const{width:n,height:s}=e,r=t.width/n,a=t.height/s,{xmin:o,ymax:l}=t;let c;if("extent"===i.type){const e=(i.xmin-o)/r,t=(i.xmax-o)/r,n=(l-i.ymax)/a,s=(l-i.ymin)/a;c=[[[e,n],[e,s],[t,s],[t,n],[e,n]]]}else c=i.rings.map((e=>e.map((([e,t])=>[(e-o)/r,(l-t)/a]))));const u=document.createElement("canvas");u.width=n,u.height=s;const h=u.getContext("2d");h.fillStyle="#f00",c.forEach((e=>{h.beginPath(),h.moveTo(e[0][0],e[0][1]);for(let t=0;t<e.length;t++)h.lineTo(e[t][0],e[t][1]);h.closePath(),h.fill()}));const f=h.getImageData(0,0,n,s).data,p=e.mask,d=n*s,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 ie.Z({pixelType:e.pixelType,width:n,height:s,mask:m,maskIsAlpha:!1,pixels:[...e.pixels]})}(e,t,n):new ie.Z({pixelType:e.pixelType,width:s,height:r,mask:a,maskIsAlpha:!1,pixels:[...e.pixels]})}(p.pixelBlock,c,a),m=this._rasterJobHandler.instance;return m?m.computeStatisticsHistograms({pixelBlock:d},t):(0,se.js)(d)}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):(0,le.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;null!=i&&i.length||(i=(0,B.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const n=e.timeExtent||this.timeExtent;if(null!=i&&null!=n&&(null!=n.start||null!=n.end)){i=i.map((e=>e.clone()));const s=t.variables.find((({name:e})=>e===i[0].variableName))?.dimensions?.find((({name:e})=>"StdTime"===e)),r=i.find((({dimensionName:e})=>"StdTime"===e));if(!s||!r)return{...e,multidimensionalDefinition:null};const{start:a,end:o}=n,l=null==a?null:a.getTime(),c=null==o?null:o.getTime(),u=l??c,h=c??l;if(null!=s.values){const e=s.values.filter((e=>{if(Array.isArray(e)){if(u===h)return e[0]<=u&&e[1]>=u;const t=e[0]<=u&&e[1]>u||e[0]<h&&e[1]>=h,i=e[0]>=u&&e[1]<=h||e[0]<u&&e[1]>h;return t||i}return u===h?e===u:e>=u&&e<=h}));if(e.length){const t=e.sort(((e,t)=>{const i=Array.isArray(e)?e[0]:e,n=Array.isArray(e)?e[1]:e,s=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t[1]:t;return u===h?i-s:Math.abs(n-h)-Math.abs(r-h)}))[0];r.values=[t]}else i=null}else if(s.hasRegularIntervals&&s.extent){const[e,t]=s.extent;u>t||h<e?i=null:r.values=u===h?[u]:[Math.max(e,u),Math.min(t,h)]}}return null!=i&&(0,B.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:n}=this;if(n){const i={raster:t};e.length>1&&e.forEach((e=>i[e.url]=e));const s=(0,ne.Ue)(n.rasterFunctionDefinition??n.toJSON(),i),r=new ee({rasterFunction:s});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&&!n)return;const{bandIds:s}=this,{bandCount:r}=this.raster.rasterInfo,a=s?.length?s.some((e=>e>=r)):r>=3;s&&(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,n=(0,B.WY)(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=n?.name,r=(0,re.ol)({...this.renderer.toJSON(),variableName:s});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(r))return;const a=this._rasterJobHandler.instance;a&&(t.rasterInfo=(0,re.FI)(i,s),t.rendererJSON=r,t.bind(),await a.updateSymbolizer(t),this._cachedRendererJson=r)}async applyRenderer(e,t){const i=e&&e.pixelBlock;if(!(null!=i&&i.pixels&&i.pixels.length>0))return null;let n;await this.updateRenderer();const s=this._rasterJobHandler.instance,r=this.bandIds??[];return n=s?await s.symbolize({...e,simpleStretchParams:t,bandIds:r}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:r}),n}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 n=(0,_.C5)(e);return F.Z.create({size:256,spatialReference:e,origin:n?{x:n.origin[0],y:n.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,i,n={}){if(s(this),n.requestAsImageElement){const s=this.getTileUrl(e,t,i);return(0,I.default)(s,{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 s=n.tileInfo||r.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(e,t,i,s),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,i,n)}async fetchPixels(e,t,i,n={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(n=this.normalizeRasterFetchOptions(n)).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,n))}async identify(e,t={}){const{raster:i,rasterInfo:n}=this;if(null!=n.multidimensionalInfo&&!(n.hasMultidimensionalTranspose&&((0,B.WU)(t.multidimensionalDefinition)||t.transposedVariableName||t.timeExtent)||null!=(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition))return{location:e,value:null};const s=this.multidimensionalSubset?.areaOfInterest;if(s&&!s.contains(e))throw new r.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,B.jj)(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=(0,B.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new M.Z;return this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{s(this),this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).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){s(this);const{raster:e}=this,t=(0,re.In)(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){s(this);const{rasterInfo:t}=this.raster;!this.bandIds&&t.bandCount>1&&(this.bandIds=(0,re.YD)(t));const i=(0,B.WY)(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=i?.name;if(!this.renderer||"override"===e){const e=(0,re.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,re.ol)({...this.renderer.toJSON(),variableName:n}),a=(0,re.FI)(t,n);this.symbolizer?(this.symbolizer.rendererJSON=r,this.symbolizer.rasterInfo=a):this.symbolizer=new ae.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)if("raster-colormap"!==t.type)this._configDefaultRenderer("override");else{const e=(0,re.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 ue.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}};function s(e){if(!e.raster||!e.rasterInfo)throw new r.Z("imagery-tile","no raster")}return(0,n._)([(0,u.Cb)()],t.prototype,"_cachedRendererJson",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_cachedRasterFunctionJson",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_compatibleFullExtent",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_isConstructedFromFunctionRaster",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_rasterJobHandler",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"bandIds",void 0),(0,n._)([(0,u.Cb)({json:{origins:{service:{read:{source:"copyrightText"}}}}})],t.prototype,"copyright",void 0),(0,n._)([(0,u.Cb)({json:{read:!1}})],t.prototype,"fullExtent",null),(0,n._)([(0,u.Cb)()],t.prototype,"interpolation",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"ioConfig",void 0),(0,n._)([(0,u.Cb)({type:[T.Z],json:{write:!0}})],t.prototype,"multidimensionalDefinition",null),(0,n._)([(0,u.Cb)({type:C.Z,json:{write:!0}})],t.prototype,"multidimensionalSubset",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"raster",void 0),(0,n._)([(0,u.Cb)({type:k.Z})],t.prototype,"rasterFunction",null),(0,n._)([(0,u.Cb)()],t.prototype,"rasterInfo",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"sourceJSON",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,type:ce.Z,json:{read:!1}})],t.prototype,"spatialReference",void 0),(0,n._)([(0,u.Cb)({type:F.Z})],t.prototype,"tileInfo",void 0),(0,n._)([(0,u.Cb)(R.HQ)],t.prototype,"url",null),(0,n._)([(0,u.Cb)({types:b.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:b.FK,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],t.prototype,"renderer",null),(0,n._)([(0,v.r)("renderer")],t.prototype,"readRenderer",null),(0,n._)([(0,u.Cb)()],t.prototype,"symbolizer",void 0),t=(0,n._)([(0,m.j)("esri.layers.ImageryTileMixin")],t),t};var fe=i(38009),pe=i(16859),de=i(34760),me=i(72965),ye=i(28294),ge=i(1231),xe=i(69608),we=i(25972),be=i(20095);function Ie(e){const t=e.fields,i=e.records,n=t.some((e=>"oid"===e.name.toLowerCase()))?"OBJECTID":"OID",s=[{name:n,type:"esriFieldTypeOID",alias:"OID"}].concat(t.map((e=>({name:e.name,type:"esriFieldType"+e.typeName,alias:e.name})))),r=s.map((e=>e.name)),a=[];let o=0,l=0;return i.forEach((e=>{const t={};for(t[n]=o++,l=1;l<r.length;l++)t[r[l]]=e[l-1];a.push({attributes:t})})),{displayFieldName:"",fields:s,features:a}}class ve{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 n=t.getUint32(4,!0),s=t.getUint16(8,!0),r=t.getUint16(10,!0),a={version:i,recordCount:n,headerByteCount:s,recordByteCount:r};let o=32;const l=[],c=[];let u;if(3===i){for(;13!==t.getUint8(o);)u=String.fromCharCode(t.getUint8(o+11)).trim(),l.push({name:(0,be.f)(new Uint8Array(e,o,11)),type:u,typeName:["String","Date","Double","Boolean","String","Integer"][["C","D","F","L","M","N"].indexOf(u)],length:t.getUint8(o+16)}),o+=32;if(o+=1,l.length>0)for(;c.length<n&&e.byteLength-o>r;){const i=[];32===t.getUint8(o)?(o+=1,l.forEach((t=>{if("C"===t.type)i.push((0,be.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 n=String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim();i.push(new Date(parseInt(n.substring(0,4),10),parseInt(n.substring(4,6),10)-1,parseInt(n.substring(6,8),10)))}o+=t.length})),c.push(i)):o+=r}}return{header:a,fields:l,records:c,recordSet:Ie({fields:l,records:c})}}}var _e=i(87521),Se=i(74889);const Re=new Map;Re.set("int16","esriFieldTypeSmallInteger"),Re.set("int32","esriFieldTypeInteger"),Re.set("int64","esriFieldTypeInteger"),Re.set("float32","esriFieldTypeSingle"),Re.set("float64","esriFieldTypeDouble"),Re.set("text","esriFieldTypeString");let Te=class extends K{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 r.Z("cloudraster:open","Invalid or unsupported conf.json.");this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const{storageInfo:i,rasterInfo:n}=this._parseHeader(t);if("thematic"===n.dataType){const e=await this._fetchAuxiliaryInformation();n.attributeTable=e}this._set("storageInfo",i),this._set("rasterInfo",n),this.ioConfig.retryCount=this.ioConfig.retryCount||0}async fetchRawTile(e,t,i,n={}){const{transposeInfo:s}=this.rasterInfo.storageInfo,{transposedVariableName:r}=n,a=!(!s||!r),o=a?0:this.rasterInfo.storageInfo.maximumPyramidLevel-e;if(o<0)return null;const l=this._buildCacheFilePath(o,t,i,n.multidimensionalDefinition,r),c=this._getIndexRecordFromBundle(t,i,a),u=await this.request(l,{range:{from:0,to:this.storageInfo.headerSize-1},responseType:"array-buffer",signal:n.signal});if(!u)return null;const h=new Uint8Array(u.data),f=this._getTileEndAndContentType(h,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:n.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,histograms:n,colormap:s,blockWidth:r,blockHeight:a,firstPyramidLevel:o,maximumPyramidLevel:l}=e,c=e.statistics&&e.statistics.map((e=>({min:e.min,max:e.max,avg:e.mean,stddev:e.standardDeviation,median:e.median,mode:e.mode}))),u=e.extent.spatialReference,h=e.geodataXform?.spatialReference,f=new ce.Z(u?.wkid||u?.wkt?u:h);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 A.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 w=e.properties??{},b=e.format.toLowerCase().replace("cache/",""),I=new A.Z(e.origin.x,e.origin.y,f);let v,_,S,R;if(s&&s.colors)for(v=[],_=0;_<s.colors.length;_++)S=s.colors[_],R=s.values?s.values[_]:_,v.push([R,255&S,S<<16>>>24,S<<8>>>24,S>>>24]);const T=e.LODInfos,C=[];for(_=0;_<T.levels.length;_++)C.push(new z.Z({level:T.levels[_],resolution:T.resolutions[_],scale:96/.0254*T.resolutions[_]}));const k=new F.Z({dpi:96,lods:C,format:b,origin:I,size:[r,a],spatialReference:f}),M={recordSize:8,packetSize:e.packetSize,headerSize:e.packetSize*e.packetSize*8+64},O=[{maxCol:Math.ceil(m/r)-1,maxRow:Math.ceil(y/a)-1,minCol:0,minRow:0}];let P=2;if(l>0)for(_=0;_<l;_++)O.push({maxCol:Math.ceil(m/P/r)-1,maxRow:Math.ceil(y/P/a)-1,minCol:0,minRow:0}),P*=2;const D=e.mdInfo;let B=null;if(D&&w._yxs){const e=w._yxs;B={packetSize:e.PacketSize,tileSize:[e.TileXSize,e.TileYSize]}}return{storageInfo:M,rasterInfo:new we.Z({width:m,height:y,pixelType:t,bandCount:i,extent:p,nativeExtent:x,transform:g,spatialReference:f,pixelSize:d,keyProperties:w,statistics:c,histograms:n,multidimensionalInfo:D,colormap:v,storageInfo:new Z.Z({blockWidth:r,blockHeight:a,pyramidBlockWidth:r,pyramidBlockHeight:a,origin:I,tileInfo:k,transposeInfo:B,firstPyramidLevel:o,maximumPyramidLevel:l,blockBoundary:O})})}}_parseTransform(e){if(!(0,_e.j)(e))throw new r.Z("cloudraster:open","the data contains unsupported geodata transform types");const t=(0,_e.c)(e);if("identity"===t.type)return null;if("polynomial"!==t.type||!t.forwardCoefficients?.length||!t.inverseCoefficients?.length)throw new r.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)),n=await Promise.all([t,i]);let s;if(n[0]){let e=n[0].fields;const t=n[0].values;if(e&&t){e=e.map((e=>({type:"OID"===e.name?"esriFieldTypeOID":Re.get(e.type),name:e.name,alias:e.alias||e.name})));const i=t.map((e=>({attributes:e})));e&&t&&(s={fields:e,features:i})}}return!s&&n[1]&&(s=ve.parse(n[1]).recordSet),Se.Z.fromJSON(s)}_buildCacheFilePath(e,t,i,n,s){const r=this._getPackageSize(!!s),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:u}=this.rasterInfo,h=n?.[0];if(null==u||!h)return`${this.url}/_alllayers/${c}/${l}.bundle`;let f="_yxs";if(!s){f=u.variables.find((e=>e.name===h.variableName)).dimensions[0].values.indexOf(h.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(s||h.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 n=this._getPackageSize(i),s=n*(e%n)+t%n;if(s<0)throw new Error("Invalid level / row / col");return 20+s*this.storageInfo.recordSize+44}_getTileEndAndContentType(e,t){const i=e.subarray(t,t+8);let n,s=0;for(n=0;n<5;n++)s|=(255&i[n])<<8*n;const r=0xffffffffff&s;for(s=0,n=5;n<8;n++)s|=(255&i[n])<<8*(n-5);return{position:r,recordSize:0xffffffffff&s}}_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,n._)([(0,u.Cb)({readOnly:!0})],Te.prototype,"storageInfo",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Te.prototype,"datasetFormat",void 0),Te=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.CloudRaster")],Te);const Ce=Te;let ke=class extends K{constructor(){super(...arguments),this.datasetFormat="MEMORY",this.data=null}async open(e){await this.init();const t=this.data,{pixelBlock:i,statistics:n,histograms:s,name:r,keyProperties:a,nativeExtent:o,transform:l}=this.data,{width:c,height:u,pixelType:h}=i,f=t.extent??new X.Z({xmin:-.5,ymin:.5,xmax:c-.5,ymax:u-.5,spatialReference:new ce.Z({wkid:3857})}),p=t.isPseudoSpatialReference??!t.extent,d={x:f.width/c,y:f.height/u},m=new we.Z({width:c,height:u,pixelType:h,extent:f,nativeExtent:o,transform:l,pixelSize:d,spatialReference:f.spatialReference,bandCount:i.pixels.length,keyProperties:a||{},statistics:n,isPseudoSpatialReference:p,histograms:s});this.createRemoteDatasetStorageInfo(m,512,512),this._set("rasterInfo",m),this.updateTileInfo(),await this._buildInMemoryRaster(i,{width:512,height:512},e),this.datasetName=r,this.url="/InMemory/"+r}fetchRawTile(e,t,i,n={}){const s=this._pixelBlockTiles.get(`${e}/${t}/${i}`);return Promise.resolve(s)}async _buildInMemoryRaster(e,t,i){const n=this.rasterInfo.storageInfo.maximumPyramidLevel,s=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:e,tileSize:t,maximumPyramidLevel:n},i):Promise.resolve((0,$.Vl)(e,t,n)),a=null!=this.rasterInfo.statistics,o=null!=this.rasterInfo.histograms,c=a?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:e},i):Promise.resolve((0,se.Hv)(e)),u=await(0,l.as)([s,c]);if(!u[0].value&&u[1].value)throw new r.Z("inmemory-raster:open","failed to build in memory raster");this._pixelBlockTiles=u[0].value,a||(this.rasterInfo.statistics=u[1].value?.statistics),o||(this.rasterInfo.histograms=u[1].value?.histograms)}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],ke.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],ke.prototype,"data",void 0),ke=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.InMemoryRaster")],ke);const Me=ke;function Fe(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 n=[];if(t){const s=Fe(e,i);for(let e=0;e<s.length;e++)Fe(s[e],t).forEach((e=>n.push(e)));return n}const s=e.getElementsByTagNameNS("*",i);if(!s||0===s.length)return[];for(let e=0;e<s.length;e++)n.push(s[e]||s.item(e));return n}function Oe(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 n=Fe(e,i);return n.length>0?t?Oe(n[0],t):n[0]:null}function Pe(e,t=null){const i=t?Oe(e,t):e;let n;return i?(n=i.textContent||i.nodeValue,n?n.trim():null):null}function De(e,t){return function(e,t){const i=Fe(e,t),n=[];let s;for(let e=0;e<i.length;e++)s=i[e].textContent||i[e].nodeValue,s&&(s=s.trim(),""!==s&&n.push(s));return n}(e,t).map((e=>Number(e)))}function ze(e,t){const i=Pe(e,t);return Number(i)}function Ze(e,t){const i=e?.nodeName?.toLowerCase(),n=t.toLowerCase();return i.slice(i.lastIndexOf(":")+1)===n}var Be=i(87390);function Ne(e,t){if(!e||!t)return null;const i=[];for(let n=0;n<e.length;n++)i.push(e[n]),i.push(t[n]);return i}function Ae(e){if(!e)return null;let t=Number(e);if(!isNaN(t)&&0!==t)return new ce.Z({wkid:t});if((e=String(e)).startsWith("COMPD_CS")){if(!e.includes("VERTCS")||!e.includes("GEOGCS")&&!e.startsWith("PROJCS"))return null;const i=e.indexOf("VERTCS"),n=e.indexOf("PROJCS"),s=n>-1?n:e.indexOf("GEOGCS");if(-1===s)return null;const r=e.slice(s,e.lastIndexOf("]",i)+1).trim(),a=e.slice(i,e.lastIndexOf("]")).trim();t=Ee(r);const o=new ce.Z(t?{wkid:t}:{wkt:r}),l=Ee(a);return l&&(o.vcsWkid=l),o}return e.startsWith("GEOGCS")||e.startsWith("PROJCS")?(t=Ee(e),new ce.Z(0!==t?{wkid:t}:{wkt:e})):null}function Ee(e){const t=e.replaceAll("]","[").replaceAll('"',"").split("[").map((e=>e.trim())).filter((e=>""!==e)),i=t[t.length-1].split(","),n=i[0]?.toLowerCase();if(("epsg"===n||"esri"===n)&&e.endsWith('"]]')){const e=Number(i[1]);if(!isNaN(e)&&0!==e)return e}return 0}function Je(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(Ze(e,"SRS")){if(!t.spatialReference){const i=Pe(e);t.spatialReference=Ae(i)}}else if(Ze(e,"Metadata"))if("xml:ESRI"===e.getAttribute("domain")){const{spatialReference:i,transform:n}=function(e){const t=Oe(e,"GeodataXform"),i=Ae(ze(t,"SpatialReference/WKID")||Pe(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:i,transform:null};const n=ze(t,"PolynomialOrder")??1,s=De(t,"CoeffX/Double"),r=De(t,"CoeffY/Double"),a=De(t,"InverseCoeffX/Double"),o=De(t,"InverseCoeffY/Double"),l=Ne(s,r),c=Ne(a,o);return{spatialReference:i,transform:l&&c&&l.length&&c.length?new Be.Z({spatialReference:i,polynomialOrder:n,forwardCoefficients:l,inverseCoefficients:c}):null}}(e);t.transform=n,t.spatialReference||(t.spatialReference=i)}else Fe(e,"MDI").forEach((e=>t.metadata[e.getAttribute("key")]=Pe(e)));else if(Ze(e,"PAMRasterBand")){const i=function(e){const t=ze(e,"NoDataValue"),i=Oe(e,"Histograms/HistItem"),n=ze(i,"HistMin"),s=ze(i,"HistMax"),r=ze(i,"BucketCount"),a=Pe(i,"HistCounts")?.split("|").map((e=>Number(e)));let o,l,c,u;Fe(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":u=t}}));const h=ze(e,"Metadata/SourceBandIndex");return{noDataValue:t,histogram:a?.length&&null!=n&&null!=s?{min:n,max:s,size:r||a.length,counts:a}:null,sourceBandIndex:h,statistics:null!=o&&null!=l?{min:o,max:l,avg:c,stddev:u}: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(f.pC):null;const n=!!i[0].histogram;t.histograms=n?i.map((e=>e.histogram)).filter(f.pC):null}return t}let Le=class extends K{async open(e){await this.init();const t=await this._fetchData(e);let{spatialReference:i,statistics:n,histograms:s,transform:r}=await this._fetchAuxiliaryData(e);const a=!i;a&&(i=new ce.Z({wkid:3857})),s?.length&&null==n&&(n=(0,se.Oh)(s));const{width:o,height:l}=t;let c=new X.Z({xmin:-.5,ymin:.5-l,xmax:o-.5,ymax:.5,spatialReference:i});const u=r?r.forwardTransform(c):c;let h=!0;if(r){const e=r.forwardCoefficients;h=e&&0===e[1]&&0===e[2],h&&(r=null,c=u)}const f=new Me({data:{extent:u,nativeExtent:c,transform:r,pixelBlock:t,statistics:n,histograms:s,keyProperties:{DateType:"Processed"},isPseudoSpatialReference:a}});await f.open(),f.data=null,this._set("rasterInfo",f.rasterInfo),this._inMemoryRaster=f}fetchRawTile(e,t,i,n={}){return this._inMemoryRaster.fetchRawTile(e,t,i,n)}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 r.Z("image-aux-raster:open","the data is not a supported format");this._set("datasetFormat",i);const n=i.toLowerCase(),s="gif"===n||"bmp"===n||!(0,p.Z)("ios"),a=await this.decodePixelBlock(t,{format:n,useCanvas:s,hasNoZlibMask:!0});if(null==a)throw new r.Z("image-aux-raster:open","the data cannot be decoded");return a}async _fetchAuxiliaryData(e){const t=e?.signal,i=this.ioConfig.skipExtensions??[],n=i.includes("aux.xml")?null:this.request(this.url+".aux.xml",{responseType:"xml",signal:t}),s=this.datasetFormat,r="JPG"===s?"jgw":"PNG"===s?"pgw":"BMP"===s?"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,l.as)([n,a]);if(t?.aborted)throw(0,l.zE)();const c=Je(o[0].value?.data);if(!c.transform){const e=o[1].value?o[1].value.data.split("\n").slice(0,6).map((e=>Number(e))):null;c.transform=6===e?.length?new Be.Z({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return c}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Le.prototype,"datasetFormat",void 0),Le=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.ImageAuxRaster")],Le);const He=Le;var We=i(81271),qe=i(28589),je=i(29680),Ge=i(26059);let Ue=class extends K{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&&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 n=i.data;if(this.sourceJSON=n,!n)throw new r.Z("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!n.tileInfo)throw new r.Z("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo(),this.tileType=n.cacheType,null==this.tileType&&(["jpg","jpeg","png","png8","png24","png32","mixed"].includes(n.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===n.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=n.name?.slice(n.name.indexOf("/")+1)??"";const s=await this._fetchRasterInfo({signal:t});if(null==s)throw new r.Z("image-server-raster:open","cannot initialize image service");const a="Map"===this.tileType?function(e,t){if(!e)return null;const{minScale:i,maxScale:n,minLOD:s,maxLOD:r}=t;if(null!=s&&null!=r)return F.Z.fromJSON({...e,lods:e.lods.filter((({level:e})=>null!=e&&e>=s&&e<=r))});if(0!==i&&0!==n){const t=e=>Math.round(1e4*e)/1e4,s=i?t(i):1/0,r=n?t(n):-1/0;return F.Z.fromJSON({...e,lods:e.lods.filter((e=>{const i=t(e.scale);return i<=s&&i>=r}))})}return F.Z.fromJSON(e)}(n.tileInfo,n):F.Z.fromJSON(n.tileInfo);(0,P.O3)(a);const[o,l]=this._computeMinMaxLOD(s,a),{extent:c,pixelSize:u}=s,h=.5/s.width*u.x,f=Math.max(u.x,u.y),{lods:p}=a;("Map"!==this.tileType&&0!==n.maxScale||Math.abs(u.x-u.y)>h||!p.some((e=>Math.abs(e.resolution-f)<h)))&&(u.x=u.y=o.resolution,s.width=Math.ceil((c.xmax-c.xmin)/u.x-.1),s.height=Math.ceil((c.ymax-c.ymin)/u.y-.1));const d=o.level-l.level,[m,y]=a.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 w=this.computeBlockBoundary(c,m,y,a.origin,g,d),b=g.length>1?g.slice(1):null;let I;n.transposeInfo&&(I={tileSize:[n.transposeInfo.rows,n.transposeInfo.cols],packetSize:s.keyProperties?._yxs.PacketSize??0});const v=x.length<=1||x.length>=3&&x.slice(0,x.length-1).every((e=>e===x[0]))?x[0]??2:Math.round(10/(l.resolution/o.resolution)**(-1/d))/10;if(s.storageInfo=new Z.Z({blockWidth:a.size[0],blockHeight:a.size[1],pyramidBlockWidth:a.size[0],pyramidBlockHeight:a.size[1],pyramidResolutions:b,pyramidScalingFactor:v,compression:a.format,origin:a.origin,firstPyramidLevel:1,maximumPyramidLevel:d,tileInfo:a,transposeInfo:I,blockBoundary:w}),this._fixGCSShift(s),this._set("rasterInfo",s),n.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:s.storageInfo.tileInfo,parsedUrl:(0,We.mN)(this.url),url:this.url,tileServers:[]};this._tilemapCache=new qe.y({layer:e})}}async fetchRawTile(e,t,i,n={}){const{storageInfo:s,extent:r}=this.rasterInfo,{transposeInfo:a}=s,o=null!=a&&!!n.transposedVariableName;if(this._slices&&!o&&null==n.sliceId)return null;const l=o?0:s.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${l}/${t}/${i}`,u=this._slices?o?{variable:n.transposedVariableName}:{sliceId:n.sliceId||0}:null,{data:h}=await this.request(c,{query:u,responseType:"array-buffer",signal:n.signal});if(!h)return null;const f=o?a.tileSize:s.tileInfo.size,p=await this.decodePixelBlock(h,{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=s.blockBoundary[e];if("jpg"!==s.compression||i>d.minCol&&i<d.maxCol&&t>d.minRow&&t<d.maxRow)return p;const{origin:m,blockWidth:y,blockHeight:g}=s,{x,y:w}=this.getPyramidPixelSize(e),b=Math.round((r.xmin-m.x)/x)%y,I=Math.round((r.xmax-m.x)/x)%y||y,v=Math.round((m.y-r.ymax)/w)%g,_=Math.round((m.y-r.ymin)/w)%g||g,S=i===d.minCol?b:0,R=t===d.minRow?v:0,T=i===d.maxCol?I:y,C=t===d.maxRow?_:g;return(0,$.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)),n=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([i,n]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[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 n=0;const{maximumPyramidLevel:s}=this.rasterInfo.storageInfo;let r=s-n+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--,n++,i=this.identifyPixelLocation(a,n,t.datumTransformation),null===i)return null}return-1===r||null==i?null:n}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),n=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),s=ce.Z.fromJSON(t.spatialReference||e.spatialReference),r=new A.Z({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:s});return new we.Z({width:i,height:n,bandCount:3,extent:X.Z.fromJSON(e),spatialReference:s,pixelSize:r,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,n=(0,Ge.g)(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),s=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then((e=>e.data&&e.data.slices)).catch((()=>null)):null,r=await Promise.all([n,s]);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 je.Z,e.extent=e.transform.forwardTransform(t))}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,n=.5/e.width*i.x,{lods:s}=t,r=t.lodAt(Math.max.apply(null,s.map((e=>e.level)))),a=t.lodAt(Math.min.apply(null,s.map((e=>e.level)))),{tileType:o}=this;if("Map"===o)return this._levelOffset=s[0].level,[r,a];if("Raster"===o)return[s.find((e=>e.resolution===i.x))??r,a];const{minScale:l,maxScale:c}=this.sourceJSON;let u=r;c>0&&(u=s.find((e=>Math.abs(e.scale-c)<n)),u||(u=s.filter((e=>e.scale>c)).sort(((e,t)=>e.scale>t.scale?1:-1))[0]??r));let h=a;return l>0&&(h=s.find((e=>Math.abs(e.scale-l)<n))??a,this._levelOffset=h.level-a.level),[u,h]}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Ue.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],Ue.prototype,"tileType",void 0),Ue=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.ImageServerRaster")],Ue);const $e=Ue;var Ve=i(48279);const Xe=new Map;Xe.set("Int8","s8"),Xe.set("UInt8","u8"),Xe.set("Int16","s16"),Xe.set("UInt16","u16"),Xe.set("Int32","s32"),Xe.set("UInt32","u32"),Xe.set("Float32","f32"),Xe.set("Float64","f32"),Xe.set("Double64","f32");const Ye=new Map;Ye.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),Ye.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),Ye.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),Ye.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"});let Ke=class extends K{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:n,files:s}=this._parseHeader(i.data);if(-1===this.ioConfig.skipExtensions?.indexOf("aux.xml")){const t=await this._fetchAuxiliaryData(e);null!=t&&(n.statistics=t.statistics??n.statistics,n.histograms=t.histograms,t.histograms&&null==n.statistics&&(n.statistics=(0,se.Oh)(t.histograms)))}this._set("rasterInfo",n),this._files=s;const r=await this.request(s.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:u}=this.rasterInfo,h=[],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(u/o/l**d)-1;p+=(e+1)*(t+1)*f*4,h.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=h,d>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=d),this.updateTileInfo()}async fetchRawTile(e,t,i,n={}){const{blockWidth:s,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:u,actualTileWidth:h,actualTileHeight:f}=this._getTileLocation(e,t,i);if(!u||0===u.length)return null;if(0===u[0].from&&0===u[0].to){const e=new Uint8Array(s*r);return new ie.Z({width:s,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:u[y].from,to:u[y].to},responseType:"array-buffer",signal:n.signal}));const g=await Promise.all(m),x=g.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),w=new Uint8Array(x);let b=0;for(y=0;y<d;y++)w.set(new Uint8Array(g[y].data),b),b+=g[y].data.byteLength;const I=Ye.get(this.rasterInfo.storageInfo.compression).decoderFormat,v=await this.decodePixelBlock(w.buffer,{width:s,height:r,format:I,planes:p?.length||l,pixelType:c});if(null==v)return null;let{noDataValue:_}=this.rasterInfo;if(null!=_&&"lerc"!==I&&!v.mask&&(_=_[0],null!=_)){const e=v.width*v.height,t=new Uint8Array(e);if(Math.abs(_)>1e24)for(y=0;y<e;y++)Math.abs((v.pixels[0][y]-_)/_)>1e-6&&(t[y]=1);else for(y=0;y<e;y++)v.pixels[0][y]!==_&&(t[y]=1);v.mask=t}let S=0,R=0;if(h!==s||f!==r){let e=v.mask;if(e)for(y=0;y<r;y++)if(R=y*s,y<f)for(S=h;S<s;S++)e[R+S]=0;else for(S=0;S<s;S++)e[R+S]=0;else for(e=new Uint8Array(s*r),v.mask=e,y=0;y<f;y++)for(R=y*s,S=0;S<h;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,n,s,r,a;if(Ve.f){for(i=new Uint8Array(e),s=new ArrayBuffer(e.byteLength),n=new Uint8Array(s),r=0;r<e.byteLength/4;r++)for(a=0;a<4;a++)n[4*r+a]=i[4*r+3-a];t=new Uint32Array(s)}else t=new Uint32Array(e);return t}_getBandSegmentCount(){return Ye.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(e,t,i){const{blockWidth:n,blockHeight:s,pyramidScalingFactor:r}=this.rasterInfo.storageInfo,{width:a,height:o}=this.rasterInfo,l=this._getBandSegmentCount();let c,u,h,f=0,p=0;for(h=0;h<e;h++)p=r**h,c=Math.ceil(a/n/p),u=Math.ceil(o/s/p),f+=c*u;p=r**e,c=Math.ceil(a/n/p),u=Math.ceil(o/s/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?n:Math.ceil(a/p)-n*(c-1),actualTileHeight:t<u-1?s:Math.ceil(o/p)-s*(u-1)}}_parseHeader(e){const t=Oe(e,"MRF_META/Raster");if(!t)throw new r.Z("mrf:open","not a valid MRF format");const i=Oe(t,"Size"),n=parseInt(i.getAttribute("x"),10),s=parseInt(i.getAttribute("y"),10),a=parseInt(i.getAttribute("c"),10),o=(Pe(t,"Compression")||"none").toLowerCase();if(!Ye.has(o))throw new r.Z("mrf:open","currently does not support compression "+o);const l=Pe(t,"DataType")||"UInt8",c=Xe.get(l);if(null==c)throw new r.Z("mrf:open","currently does not support pixel type "+l);const u=Oe(t,"PageSize"),h=parseInt(u.getAttribute("x"),10),f=parseInt(u.getAttribute("y"),10),p=Oe(t,"DataValues");let d,m;if(p&&(m=p.getAttribute("NoData"),null!=m&&(d=m.trim().split(" ").map((e=>parseFloat(e))))),Oe(e,"MRF_META/CachedSource"))throw new r.Z("mrf:open","currently does not support MRF referencing other data files");const y=Oe(e,"MRF_META/GeoTags"),g=Oe(y,"BoundingBox");let x,w=!1;if(null!=g){const e=parseFloat(g.getAttribute("minx")),t=parseFloat(g.getAttribute("miny")),i=parseFloat(g.getAttribute("maxx")),n=parseFloat(g.getAttribute("maxy")),s=Pe(y,"Projection")||"";let r=ce.Z.WGS84;if("LOCAL_CS[]"!==s)if(s.toLowerCase().startsWith("epsg:")){const e=Number(s.slice(5));isNaN(e)||0===e||(r=new ce.Z({wkid:e}))}else r=Ae(s)??ce.Z.WGS84;else w=!0,r=new ce.Z({wkid:3857});x=new X.Z(e,t,i,n),x.spatialReference=r}else w=!0,x=new X.Z({xmin:-.5,ymin:.5-s,xmax:n-.5,ymax:.5,spatialReference:new ce.Z({wkid:3857})});const b=Oe(e,"MRF_META/Rsets"),I=parseInt(b&&b.getAttribute("scale")||"2",10),v=x.spatialReference,_=new Z.Z({origin:new A.Z({x:x.xmin,y:x.ymax,spatialReference:v}),blockWidth:h,blockHeight:f,pyramidBlockWidth:h,pyramidBlockHeight:f,compression:o,pyramidScalingFactor:I}),S=new A.Z({x:x.width/n,y:x.height/s,spatialReference:v}),R=new we.Z({width:n,height:s,extent:x,isPseudoSpatialReference:w,spatialReference:v,bandCount:a,pixelType:c,pixelSize:S,noDataValue:d,storageInfo:_}),T=Pe(e,"datafile"),C=Pe(e,"IndexFile");return{rasterInfo:R,files:{mrf:this.url,index:C||this.url.replace(".mrf",".idx"),data:T||this.url.replace(".mrf",Ye.get(o).blobExtension)}}}async _fetchAuxiliaryData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return Je(t)}catch{return null}}};(0,n._)([(0,u.Cb)()],Ke.prototype,"_files",void 0),(0,n._)([(0,u.Cb)()],Ke.prototype,"_storageIndex",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Ke.prototype,"datasetFormat",void 0),Ke=(0,n._)([(0,m.j)("esri.layers.support.rasterIO.MRFRaster")],Ke);const Qe=Ke;var et=i(94793),tt=i(9832);const it=(e,t)=>e.get(t)?.values,nt=(e,t)=>e.get(t)?.values?.[0];let st=class extends K{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 r.Z("tiffraster:open","failed to open url "+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1,this.url.lastIndexOf("."));const{littleEndian:n,firstIFDPos:s,isBigTiff:a}=(0,et.cK)(i),o=[];await this._readIFDs(o,i,n,s,0,a?8:4,t);const{imageInfo:l,rasterInfo:c}=this._parseIFDs(o),u=(0,et.ee)(o),h=(0,et.I7)(o);if(this._headerInfo={littleEndian:n,isBigTiff:a,ifds:o,pyramidIFDs:u,maskIFDs:h,...l},this._set("rasterInfo",c),!l.isSupported)throw new r.Z("tiffraster:open","this tiff is not supported: "+l.message);if(!l.tileWidth)throw new r.Z("tiffraster:open","none-tiled tiff is not optimized for access, convert to COG and retry.");const{skipExtensions:f=[]}=this.ioConfig;if(!f.includes("aux.xml")){const t=await this._fetchAuxiliaryMetaData(e);null!=t&&this._processPAMInfo(t,c)}f.includes("vat.dbf")||1!==c.bandCount||"u8"!==c.pixelType||(c.attributeTable=await this._fetchAuxiliaryTable(e),null!=c.attributeTable&&(c.keyProperties.DataType="thematic")),this.updateTileInfo()}async fetchRawTile(e,t,i,n={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,i))return null;const s=await this._fetchRawTiffTile(e,t,i,!1,n);if(null!=s&&this._headerInfo.hasMaskBand){const r=await this._fetchRawTiffTile(e,t,i,!0,n);null!=r&&r.pixels[0]instanceof Uint8Array&&(s.mask=r.pixels[0])}return s}_parseIFDs(e){const t=(0,et.FI)(e),{width:i,height:n,tileWidth:s,tileHeight:r,planes:a,pixelType:o,compression:l,firstPyramidLevel:c,maximumPyramidLevel:u,pyramidBlockWidth:h,pyramidBlockHeight:f,tileBoundary:p,affine:d,metadata:m}=t;let y=Ae(t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid),g=!!t.isPseudoGeographic;null==y&&(g=!0,y=new ce.Z({wkid:3857}));const x=new X.Z({...t.extent,spatialReference:y}),w=new A.Z(x?{x:x.xmin,y:x.ymax,spatialReference:y}:{x:0,y:0}),b=new Z.Z({blockWidth:s,blockHeight:r,pyramidBlockWidth:h,pyramidBlockHeight:f,compression:l,origin:w,firstPyramidLevel:c,maximumPyramidLevel:u,blockBoundary:p}),I=new A.Z({x:(x.xmax-x.xmin)/i,y:(x.ymax-x.ymin)/n,spatialReference:y}),v=m?{BandProperties:m.bandProperties,DataType:m.dataType}:{};let _=null;const S=nt(e[0],"PHOTOMETRICINTERPRETATION"),R=it(e[0],"COLORMAP");if(S<=3&&R?.length>3&&R.length%3==0){_=[];const e=R.length/3;for(let t=0;t<e;t++)_.push([t,R[t]>>>8,R[t+e]>>>8,R[t+2*e]>>>8])}const T=new we.Z({width:i,height:n,bandCount:a,pixelType:o,pixelSize:I,storageInfo:b,spatialReference:y,isPseudoSpatialReference:g,keyProperties:v,extent:x,colormap:_,statistics:m?m.statistics:null});return d?.length&&(T.nativeExtent=new X.Z({xmin:-.5,ymin:.5-n,xmax:i-.5,ymax:.5,spatialReference:y}),T.transform=new Be.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 A.Z({x:(x.xmax-x.xmin)/i,y:(x.ymax-x.ymin)/n,spatialReference:y}),b.origin.x=-.5,b.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,se.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 A.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,n,s,r=4,a){if(!n)return null;(n>=t.byteLength||n<0)&&(t=(await this.request(this.url,{range:{from:n+s,to:n+s+this._bufferSize},responseType:"array-buffer",signal:a})).data,s=n+s,n=0);const o=await this._readIFD(t,i,n,s,tt.Z.TIFF_TAGS,r,a);if(e.push(o.ifd),!o.nextIFD)return null;await this._readIFDs(e,t,i,o.nextIFD-s,s,r,a)}async _readIFD(e,t,i,n,s=tt.Z.TIFF_TAGS,r=4,a){if(!e)return null;const o=(0,et.vr)(e,t,i,n,s,r);if(o.success){const i=[];if(o.ifd?.forEach((e=>{e.values||i.push(e)})),i.length>0){const s=i.map((e=>e.offlineOffsetSize)).filter(f.pC),r=Math.min.apply(null,s.map((e=>e[0])));if(Math.min.apply(null,s.map((e=>e[0]+e[1])))-r<=this._bufferSize){const{data:s}=await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:"array-buffer",signal:a});e=s,n=r,i.forEach((i=>(0,et.Dq)(e,t,i,n)))}}if(o.ifd?.has("GEOKEYDIRECTORY")){const i=o.ifd.get("GEOKEYDIRECTORY"),s=i?.values;if(s&&s.length>4){const r=s[0]+"."+s[1]+"."+s[2],o=await this._readIFD(e,t,i.valueOffset+6-n,n,tt.Z.GEO_KEYS,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:n,to:n+o.requiredBufferSize+4},responseType:"array-buffer",signal:a});return(e=i.data).byteLength<o.requiredBufferSize?null:this._readIFD(e,t,0,n,tt.Z.TIFF_TAGS,4,a)}}async _fetchRawTiffTile(e,t,i,n,s={}){const r=this._getTileLocation(e,t,i,n);if(!r)return null;const{ranges:a,actualTileWidth:o,actualTileHeight:l,ifd:c}=r,u=a.map((e=>this.request(this.url,{range:e,responseType:"array-buffer",signal:s.signal}))),h=await Promise.all(u),f=h.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),p=1===h.length?h[0].data:new ArrayBuffer(f),d=[0],m=[0];if(h.length>1){const e=new Uint8Array(p);for(let t=0,i=0;t<h.length;t++){const n=h[t].data;e.set(new Uint8Array(n),i),d[t]=i,i+=n.byteLength,m[t]=n.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,I;if(o!==y||l!==g){let e=x.mask;if(e)for(w=0;w<g;w++)if(I=w*y,w<l)for(b=o;b<y;b++)e[I+b]=0;else for(b=0;b<y;b++)e[I+b]=0;else for(e=new Uint8Array(y*g),x.mask=e,w=0;w<l;w++)for(I=w*y,b=0;b<o;b++)e[I+b]=1}return x}_getTileLocation(e,t,i,n=!1){const{firstPyramidLevel:s,blockBoundary:r}=this.rasterInfo.storageInfo,a=0===e?0:e-(s-1),{_headerInfo:o}=this;if(!o)return null;const l=n?o.maskIFDs[a]:0===a?o?.ifds[0]:o?.pyramidIFDs[a-1];if(!l)return null;const c=(0,et.If)(l,o),u=it(l,"TILEOFFSETS");if(void 0===u)return null;const h=it(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=nt(l,"IMAGEWIDTH"),g=nt(l,"IMAGELENGTH"),x=nt(l,"TILEWIDTH"),w=nt(l,"TILELENGTH"),b=c?this.rasterInfo.bandCount:1,I=b*t*(m+1)+i,v=[{from:u[I],to:u[I+b-1]+h[I+b-1]-1}];if(c){let e=!0;for(let t=0;t<b;t++)if(u[I+t]+h[I+t]!==u[I+t+1]){e=!1;break}if(!e)for(let e=0;e<b;e++)v[e]={from:u[I+e],to:u[I+e]+h[I+e]-1}}const _=u[I],S=h[I];return null==_||null==S?null:{ranges:v,ifd:l,actualTileWidth:i===m&&y%x||x,actualTileHeight:t===d&&g%w||w}}async _fetchAuxiliaryMetaData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return Je(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=ve.parse(t);return i?.recordSet?Se.Z.fromJSON(i.recordSet):null}catch{return null}}};(0,n._)([(0,u.Cb)()],st.prototype,"_files",void 0),(0,n._)([(0,u.Cb)()],st.prototype,"_headerInfo",void 0),(0,n._)([(0,u.Cb)()],st.prototype,"_bufferSize",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],st.prototype,"datasetFormat",void 0),st=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.TIFFRaster")],st);const rt=st,at=new Map;at.set("CRF",{desc:"Cloud Raster Format",constructor:Ce}),at.set("MRF",{desc:"Meta Raster Format",constructor:Qe}),at.set("TIFF",{desc:"GeoTIFF",constructor:rt}),at.set("RasterTileServer",{desc:"Raster Tile Server",constructor:$e}),at.set("JPG",{desc:"JPG Raster Format",constructor:He}),at.set("PNG",{desc:"PNG Raster Format",constructor:He}),at.set("GIF",{desc:"GIF Raster Format",constructor:He}),at.set("BMP",{desc:"BMP Raster Format",constructor:He});class ot{static get supportedFormats(){const e=new Set;return at.forEach(((t,i)=>e.add(i))),e}static async open(e){const{url:t,ioConfig:i,sourceJSON:n}=e;let s=e.datasetFormat;null==s&&t.lastIndexOf(".")&&(s=t.slice(t.lastIndexOf(".")+1).toUpperCase()),"OVR"===s||"TIF"===s?s="TIFF":"JPG"!==s&&"JPEG"!==s&&"JFIF"!==s||(s="JPG"),t.toLowerCase().includes("/imageserver")&&!t.toLowerCase().includes("/wcsserver")&&(s="RasterTileServer");const a={url:t,sourceJSON:n,datasetFormat:s,ioConfig:i??{bandIds:null,sampling:null}};let o,l;if(s&&this.supportedFormats.has(s)){if("CRF"===s&&!i?.enableCRF)throw new r.Z("rasterfactory:open",`cannot open raster: ${t}`);return o=at.get(s).constructor,l=new o(a),await l.open({signal:e.signal}),l}if(s)throw new r.Z("rasterfactory:open","not a supported format "+s);const c=Array.from(at.keys());let u=0;const h=()=>(s=c[u++],s&&("CRF"!==s||i?.enableCRF)?(o=at.get(s).constructor,l=new o(a),l.open({signal:e.signal}).then((()=>l)).catch((()=>h()))):null);return h()}static register(e,t,i){at.has(e.toUpperCase())||at.set(e.toUpperCase(),{desc:t,constructor:i})}}var lt=i(32163);let ct=class extends((0,x.h)((0,me.M)((0,fe.q)((0,pe.I)((0,w.N)(he((0,ye.n)((0,g.Y)((0,de.Q)((0,o.R)(y.Z))))))))))){constructor(...e){super(...e),this._primaryRasters=null,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}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(l.r9).then((()=>this._openRaster(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[new ge.Z({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"}),new ge.Z({name:"Raster.ServicePixelValue.Raw",alias:"Raw Pixel Value",domain:null,editable:!1,length:50,type:"string"})],{rasterInfo:t}=this,i=t?.attributeTable,n=null!=i?i.fields:null;if(n){const t=n.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 s=t?.dataType,r=t?.multidimensionalInfo;if(("vector-magdir"===s||"vector-uv"===s)&&null!=r){const t=r.variables[0].unit?.trim(),i="Magnitude"+(t?` (${t})`:"");e.push(new ge.Z({name:"Raster.Magnitude",alias:i,domain:null,editable:!1,type:"double"})),e.push(new ge.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,lt.eZ)({fields:t,title:this.title},{...e,visibleFieldNames:i})}async generateRasterInfo(e,t){if(!(e=(0,h.TJ)(k.Z,e)))return this._primaryRasters[0].rasterInfo;try{const i={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((e=>i[e.url]=e));const n=(0,ne.Ue)(e.rasterFunctionDefinition??e.toJSON(),i),s=new ee({rasterFunction:n});return await s.open(t),s.rasterInfo}catch{return null}}write(e,t){const{raster:i}=this;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&&t.messages){const e=`${t.origin}/${t.layerContainerType||"operational-layers"}`;t.messages.push(new r.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)this.raster.rasterInfo||await this.raster.open(),"Function"===this.raster.datasetFormat?(t=!0,this._primaryRasters=this.raster.primaryRasters.rasters):this._primaryRasters=[this.raster],this.url=this.raster.url;else{const{rasterFunction:t}=this,i=[this.url];t&&(0,ne.G8)(t.toJSON(),i);const n=await Promise.all(i.map((t=>ot.open({url:t,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:e})))),s=n.findIndex((e=>null==e));if(s>-1)throw new r.Z("imagery-tile-layer:open",`cannot open raster: ${i[s]}`);if(this._primaryRasters=n,t){const e={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((t=>e[t.url]=t));const i=(0,ne.Ue)(t.rasterFunctionDefinition??t.toJSON(),e),s=new ee({rasterFunction:i});try{await s.open(),this.raster=s}catch(e){const t=a.Z.getLogger(this);e instanceof r.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]}}else this.raster=n[0]}const i=this.raster.rasterInfo;if(!i)throw new r.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,c.YP)((()=>this.customParameters),(e=>{this.raster&&(this.raster.ioConfig.customFetchParameters=e)})))}};(0,n._)([(0,u.Cb)()],ct.prototype,"_primaryRasters",void 0),(0,n._)([(0,u.Cb)({type:[h.z8],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],ct.prototype,"bandIds",void 0),(0,n._)([(0,u.Cb)({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),(0,d.J)(xe.c)],ct.prototype,"interpolation",void 0),(0,n._)([(0,u.Cb)(R.rn)],ct.prototype,"legendEnabled",void 0),(0,n._)([(0,u.Cb)({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],ct.prototype,"isReference",void 0),(0,n._)([(0,u.Cb)({type:["show","hide"]})],ct.prototype,"listMode",void 0),(0,n._)([(0,u.Cb)({json:{read:!0,write:!0}})],ct.prototype,"blendMode",void 0),(0,n._)([(0,u.Cb)()],ct.prototype,"sourceJSON",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,json:{origins:{service:{read:{source:"currentVersion"}}}}})],ct.prototype,"version",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,json:{read:!1}})],ct.prototype,"type",void 0),(0,n._)([(0,u.Cb)({type:["ArcGISTiledImageServiceLayer"]})],ct.prototype,"operationalLayerType",void 0),(0,n._)([(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}}}})],ct.prototype,"popupEnabled",void 0),(0,n._)([(0,u.Cb)({type:s.Z,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}}}}})],ct.prototype,"popupTemplate",void 0),(0,n._)([(0,u.Cb)({readOnly:!0})],ct.prototype,"defaultPopupTemplate",null),(0,n._)([(0,u.Cb)({readOnly:!0,type:[ge.Z]})],ct.prototype,"fields",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,type:[ge.Z]})],ct.prototype,"rasterFields",null),ct=(0,n._)([(0,m.j)("esri.layers.ImageryTileLayer")],ct);const ut=ct},39450:(e,t,i)=>{i.d(t,{Z:()=>u});var n,s=i(43697),r=i(96674),a=i(5600),o=i(75215),l=(i(67676),i(80442),i(52011));let c=n=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 n({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,s._)([(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,s._)([(0,a.Cb)({type:o.z8,json:{write:!0}})],c.prototype,"level",void 0),(0,s._)([(0,a.Cb)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,s._)([(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,s._)([(0,a.Cb)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,s._)([(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,s._)([(0,a.Cb)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=n=(0,s._)([(0,l.j)("esri.layers.support.LOD")],c);const u=c},11145:(e,t,i)=>{i.d(t,{Z:()=>S});var n,s=i(43697),r=i(35454),a=i(96674),o=i(67900),l=i(5600),c=i(75215),u=(i(67676),i(80442),i(71715)),h=i(52011),f=i(30556),p=i(94139),d=i(82971),m=i(24470),y=i(8744),g=i(40488),x=i(39450),w=i(43077);const b=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 I=n=class extends a.wq{static create(e={}){const{resolutionFactor:t=1,scales:i,size:s=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 n=i[t];e.push(new x.Z({level:t,scale:n,resolution:n}))}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 n({dpi:96,lods:e,origin:new p.Z(0,0,r),size:[s,s],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}),u=1/(39.37*(0,o.c9)(r)*96),h=[];if(i)for(let e=0;e<i.length;e++){const t=i[e],n=t*u;h.push(new x.Z({level:e,scale:t,resolution:n}))}else{let e=(0,y.sT)(r)?512/s*591657527.5917094:256/s*591657527.591555;const i=Math.ceil(a/t);h.push(new x.Z({level:0,scale:e,resolution:e*u}));for(let n=1;n<i;n++){const i=e/2**t,s=i*u;h.push(new x.Z({level:n,scale:i,resolution:s})),e=i}}return new n({dpi:96,lods:h,origin:c,size:[s,s],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 n=[],s=this._levelToLOD={};e&&(t=-1/0,i=1/0,e.forEach((e=>{n.push(e.scale),t=e.scale>t?e.scale:t,i=e.scale<i?e.scale:i,s[e.level]=e}))),this._set("scales",n),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),n=i+1;return t[i]/(t[i]/t[n])**(e-i)}scaleToZoom(e){const t=this.scales,i=t.length-1;let n=0;for(;n<i;n++){const i=t[n],s=t[n+1];if(i<=e)return n;if(s===e)return n+1;if(i>e&&s<e)return n+Math.log(i/e)/Math.log(i/s)}return n}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,n){const s=this.lodAt(e);if(!s)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,n=i;else{const e=(0,g.iV)(t,this.spatialReference);if(null==e)return null;r=e.x,a=e.y,n=i}const o=s.resolution*this.size[0],l=s.resolution*this.size[1];return n||(n=new w.f(null,0,0,0,(0,m.Ue)())),n.level=e,n.row=Math.floor((this.origin.y-a)/l+.001),n.col=Math.floor((r-this.origin.x)/o+.001),this.updateTileInfo(n),n}updateTileInfo(e,t=n.ExtrapolateOptions.NONE){let i=this.lodAt(e.level);if(!i&&t===n.ExtrapolateOptions.POWER_OF_TWO){const t=this.lods[this.lods.length-1];t.level<e.level&&(i=t)}if(!i)return;const s=e.level-i.level,r=i.resolution*this.size[0]/2**s,a=i.resolution*this.size[1]/2**s;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:n}=i,s=n*this.size[0],r=n*this.size[1];return e[0]=this.origin.x+t.col*s,e[1]=this.origin.y-(t.row+1)*r,e[2]=e[0]+s,e[3]=e[1]+r,e}lodAt(e){return this._levelToLOD?.[e]??null}clone(){return n.fromJSON(this.write({}))}getOrCreateCompatible(e,t){if(256===this.size[0]&&256===this.size[1])return 256===e?this:null;const i=[],s=this.lods.length;for(let e=0;e<s;e++){const n=this.lods[e],s=n.resolution*t;i.push(new x.Z({level:n.level,scale:n.scale,resolution:s}))}return new n({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 n=e[i];this._upsampleLevels[n.level]={parentLevel:t?t.level:-1,factor:t?t.resolution/n.resolution:0},t=n}}};var v,_;(0,s._)([(0,l.Cb)({type:Number,json:{write:!0}})],I.prototype,"compressionQuality",void 0),(0,s._)([(0,l.Cb)({type:Number,json:{write:!0}})],I.prototype,"dpi",void 0),(0,s._)([(0,l.Cb)({type:String,json:{read:b.read,write:b.write,origins:{"web-scene":{read:!1,write:!1}}}})],I.prototype,"format",void 0),(0,s._)([(0,l.Cb)({readOnly:!0})],I.prototype,"isWrappable",null),(0,s._)([(0,l.Cb)({type:p.Z,json:{write:!0}})],I.prototype,"origin",void 0),(0,s._)([(0,u.r)("origin")],I.prototype,"readOrigin",null),(0,s._)([(0,l.Cb)({type:[x.Z],value:null,json:{write:!0}})],I.prototype,"lods",null),(0,s._)([(0,l.Cb)({readOnly:!0})],I.prototype,"scales",void 0),(0,s._)([(0,l.Cb)({cast:e=>Array.isArray(e)?e:"number"==typeof e?[e,e]:[256,256]})],I.prototype,"size",void 0),(0,s._)([(0,u.r)("size",["rows","cols"])],I.prototype,"readSize",null),(0,s._)([(0,f.c)("size",{cols:{type:c.z8},rows:{type:c.z8}})],I.prototype,"writeSize",null),(0,s._)([(0,l.Cb)({type:d.Z,json:{write:!0}})],I.prototype,"spatialReference",void 0),I=n=(0,s._)([(0,h.j)("esri.layers.support.TileInfo")],I),v=I||(I={}),(_=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[_.NONE=0]="NONE",_[_.POWER_OF_TWO=1]="POWER_OF_TWO";const S=I},43077:(e,t,i)=>{i.d(t,{f:()=>n});class n{constructor(e,t,i,n,s=void 0){this.id=e,this.level=t,this.row=i,this.col=n,this.extent=s}}},28589:(e,t,i)=>{i.d(t,{y:()=>S});var n,s=i(43697),r=i(3172),a=i(92036),o=i(91303),l=i(20102),c=i(50758),u=i(13867),h=i(44553),f=i(95330),p=i(17445),d=i(1654),m=i(81271),y=i(5600),g=(i(75215),i(67676)),x=(i(80442),i(52011)),w=i(43077),b=i(22974),I=i(1533);class v{constructor(e){this._validateJSON(e);const{location:t,data:i}=e;this.location=Object.freeze((0,b.d9)(t));const n=this.location.width,s=this.location.height;let r=!0,a=!0;const o=function(e,t=!1){return e<=I.DB?t?new Array(e).fill(0):new Array(e):new Uint32Array(e)}(Math.ceil(n*s/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,I.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),n=i%32,s=i>>5,r=this._availability;return s<0||s>r.length?"unknown":r[s]&1<<n?"available":"unavailable"}static fromDefinition(e,t){const i=e.service.request||r.default,{row:n,col:s,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:n,left:s,width:a,height:o},valid:!0,data:(0,g.a9)(a*o,0)};throw e})).then((e=>{if(e.location&&(e.location.top!==n||e.location.left!==s||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:n,left:s,width:a,height:o}});return v.fromJSON(e)}))}static fromJSON(e){return Object.freeze(new v(e))}_validateJSON(e){if(!e||!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 _(e){return`${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`}let S=n=class extends a.Z{constructor(e){super(e),this._pendingTilemapRequests={},this.request=r.default,this.size=32,this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new u.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,n){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 s=this._tmpTilemapDefinition,r=this._tilemapFromCache(e,t,i,s);if(r)return Promise.resolve(r);const a=n&&n.signal;return n={...n,signal:null},new Promise(((e,t)=>{(0,f.fu)(a,(()=>t((0,f.zE)())));const i=_(s);let r=this._pendingTilemapRequests[i];if(!r){r=v.fromDefinition(s,n).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 n=this._tilemapFromCache(e,t,i,this._tmpTilemapDefinition);return n?n.getAvailability(t,i):"unknown"}fetchAvailability(e,t,i,n){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,n).catch((e=>e)).then((n=>{if(n instanceof v){const s=n.getAvailability(t,i);if("unavailable"===s)throw new l.Z("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i});return s}if((0,f.D_)(n))throw n;return"unknown"}))}fetchAvailabilityUpsample(e,t,i,n,s){n.level=e,n.row=t,n.col=i;const r=this.layer.tileInfo;r.updateTileInfo(n);const a=this.fetchAvailability(e,t,i,s).catch((e=>{if((0,f.D_)(e))throw e;if(r.upsampleTile(n))return this.fetchAvailabilityUpsample(n.level,n.row,n.col,n,s);throw e}));return this._fetchAvailabilityUpsamplePrefetch(n.id,e,t,i,s,a),a}async _fetchAvailabilityUpsamplePrefetch(e,t,i,s,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 u=!1;const h=(0,c.kB)((()=>{u||(u=!0,l.abort())}));if(this.addHandles(h,o),await(0,d.MU)(10,l.signal).catch((()=>{})),u||(u=!0,this.removeHandles(o)),(0,f.Hc)(l))return;const p=new w.f(e,t,i,s),m={...r,signal:l.signal},y=this.layer.tileInfo;for(let e=0;n._prefetches.length<n._maxPrefetch&&y.upsampleTile(p);++e){const e=this.fetchAvailability(p.level,p.row,p.col,m);n._prefetches.push(e);const t=()=>{n._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,n){n.level=e,n.row=t-t%this.size,n.col=i-i%this.size;const s=_(n);return this._tilemapCache.get(s)}get test(){const e=this;return{get prefetchingEnabled(){return e._prefetchingEnabled},set prefetchingEnabled(t){e._prefetchingEnabled=t},hasTilemap:(t,i,n)=>!!e._tilemapFromCache(t,i,n,e._tmpTilemapDefinition)}}};S._maxPrefetch=4,S._prefetches=new h.Z({initialSize:n._maxPrefetch}),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"layer",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"minLOD",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"maxLOD",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"request",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"size",void 0),S=n=(0,s._)([(0,x.j)("esri.layers.support.TilemapCache")],S)},11282:(e,t,i)=>{i.d(t,{cv:()=>o,en:()=>a,lA:()=>r}),i(68773),i(40330);var n=i(22974),s=i(81271);function r(e,t){return t?{...t,query:{...e??{},...t.query}}:{query:e}}function a(e){return"string"==typeof e?(0,s.mN)(e):(0,n.d9)(e)}function o(e,t,i){const n={};for(const s in e){if("declaredClass"===s)continue;const r=e[s];if(null!=r&&"function"!=typeof r)if(Array.isArray(r)){n[s]=[];for(let e=0;e<r.length;e++)n[s][e]=o(r[e])}else if("object"==typeof r)if(r.toJSON){const e=r.toJSON(i&&i[s]);n[s]=t?e:JSON.stringify(e)}else n[s]=t?r:JSON.stringify(r);else n[s]=r}return n}i(71058)}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[5913],{91303:(e,t,i)=>{var n;i.d(t,{Y:()=>n}),function(e){e[e.KILOBYTES=1024]="KILOBYTES",e[e.MEGABYTES=1048576]="MEGABYTES",e[e.GIGABYTES=1073741824]="GIGABYTES"}(n||(n={}))},16306:(e,t,i)=>{i.d(t,{aX:()=>v});var n=i(68773),s=i(20102),r=i(92604),a=i(38913),o=i(58901),l=i(73913),c=i(8744),u=i(40488),h=(i(66577),i(3172)),f=i(33955),p=i(11282),d=i(81271);async function m(e,t,i){const n="string"==typeof e?(0,d.mN)(e):e,s=t[0].spatialReference,r=(0,f.Ji)(t[0]),a={...i,query:{...n.query,f:"json",sr:s.wkid??JSON.stringify(s),geometries:JSON.stringify((l=t,{geometryType:(0,f.Ji)(l[0]),geometries:l.map((e=>e.toJSON()))}))}},{data:o}=await(0,h.default)(n.path+"/simplify",a);var l;return function(e,t,i){const n=(0,f.q9)(t);return e.map((e=>{const t=n.fromJSON(e);return t.spatialReference=i,t}))}(o.geometries,r,s)}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 w(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 s.Z(e)}const i=(0,l.x3)(e),n=[];for(const e of i){const i=[];n.push(i),i.push([e[0][0],e[0][1]]);for(let n=0;n<e.length-1;n++){const s=e[n][0],r=e[n][1],a=e[n+1][0],o=e[n+1][1],l=Math.sqrt((a-s)*(a-s)+(o-r)*(o-r)),c=(o-r)/l,u=(a-s)/l,h=l/t;if(h>1){for(let e=1;e<=h-1;e++){const n=e*t,a=u*n+s,o=c*n+r;i.push([a,o])}const e=(l+Math.floor(h-1)*t)/2,n=u*e+s,a=c*e+r;i.push([n,a])}i.push([a,o])}}return function(e){return"polygon"===e.type}(e)?new a.Z({rings:n,spatialReference:e.spatialReference}):new o.Z({paths:n,spatialReference:e.spatialReference})}(e,1e6);e=(0,u.Sx)(t,!0)}return i&&(e=(0,l.Sy)(e,i)),e}function b(e,t,i){if(Array.isArray(e)){const n=e[0];if(n>t){const i=(0,l.XZ)(n,t);e[0]=n+i*(-2*t)}else if(n<i){const t=(0,l.XZ)(n,i);e[0]=n+t*(-2*i)}}else{const n=e.x;if(n>t){const i=(0,l.XZ)(n,t);e=e.clone().offset(i*(-2*t),0)}else if(n<i){const t=(0,l.XZ)(n,i);e=e.clone().offset(t*(-2*i),0)}}return e}function I(e,t){let i=-1;for(let n=0;n<t.cutIndexes.length;n++){const s=t.cutIndexes[n],r=t.geometries[n],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 n=t[e][0];i=n>i?n:i}i=Number(i.toFixed(9));const n=-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(n,0))}return!0}}))}if(s===i){if(g(e))for(const t of(0,l.x3)(r))e[s]=e[s].addRing(t);else if(x(e))for(const t of(0,l.x3)(r))e[s]=e[s].addPath(t)}else i=s,e[s]=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 s="string"==typeof t?t:t?.url??n.default.geometryServiceUrl;let r,d,g,x,_,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,_=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(b(t.clone(),x,_));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map((e=>b(e,x,_))),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,_)*(2*x);let n=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,n=w(n,g),k.push(n),M.push("cut")):e.intersects(T)&&e.xmin!==_?(C=e.xmax*(2*x)>C?e.xmax*(2*x):C,n=w(n,g,360),k.push(n),M.push("cut")):M.push(n)}else M.push(t.clone());else M.push(t);else M.push(t);let F=(0,l.XZ)(C,x),O=-90;const P=F,D=new o.Z;for(;F>0;){const e=360*F-180;D.addPath([[e,O],[e,-1*O]]),O*=-1,F--}if(k.length>0&&P>0){const t=I(k,await async function(e,t,i,n){const s=(0,p.en)(e),r=t[0].spatialReference,a={...n,query:{...s.query,f:"json",sr:JSON.stringify(r),target:JSON.stringify({geometryType:(0,f.Ji)(t[0]),geometries:t}),cutter:JSON.stringify(i)}},o=await(0,h.default)(s.path+"/cut",a),{cutIndexes:l,geometries:c=[]}=o.data;return{cutIndexes:l,geometries:c.map((e=>{const t=(0,f.im)(e);return t.spatialReference=r,t}))}}(s,k,D,i)),n=[],r=[];for(let i=0;i<M.length;i++){const s=M[i];if("cut"!==s)r.push(s);else{const s=t.shift(),a=e[i];null!=a&&"polygon"===a.type&&a.rings&&a.rings.length>1&&s.rings.length>=a.rings.length?(n.push(s),r.push("simplify")):r.push(g?(0,u.$)(s):s)}}if(!n.length)return r;const a=await m(s,n,i),o=[];for(let e=0;e<r.length;e++){const t=r[e];"simplify"!==t?o.push(t):o.push(g?(0,u.$)(a.shift()):a.shift())}return o}const z=[];for(let e=0;e<M.length;e++){const t=M[e];if("cut"!==t)z.push(t);else{const e=k.shift();z.push(!0===g?(0,u.$)(e):e)}}return z}},73913:(e,t,i)=>{i.d(t,{Sy:()=>l,UZ:()=>a,XZ:()=>o,x3:()=>c});var n=i(58901),s=i(82971),r=i(33955);const a={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new n.Z({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:s.Z.WebMercator}),minus180Line:new n.Z({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:s.Z.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new n.Z({paths:[[[180,-180],[180,180]]],spatialReference:s.Z.WGS84}),minus180Line:new n.Z({paths:[[[-180,-180],[-180,180]]],spatialReference:s.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}},74878:(e,t,i)=>{i.r(t),i.d(t,{default:()=>ut});var n=i(43697),s=i(51773),r=i(20102),a=i(92604),o=i(16453),l=i(95330),c=i(17445),u=i(5600),h=i(75215),f=i(67676),p=i(80442),d=i(36030),m=i(52011),y=i(87085),g=i(17287),x=i(71612),w=i(17017),b=(i(66577),i(30030)),I=i(3172),v=i(71715),_=i(8744),S=i(66677),R=i(21506),T=i(35956),C=i(29876),k=i(40297),M=i(88281),F=i(11145),O=i(96674),P=i(70586),D=i(609),z=i(39450),Z=i(36679),B=i(99815),N=i(73506),A=i(94139);const E=new Map,J=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,n=this._cachedBlocks;if(n.has(i)){const e=n.get(i);return e.refCount--,e.refCount<=0&&(n.delete(i),e.controller&&e.controller.abort()),e.refCount}return 0}getBlock(e,t){const i=e+"/"+t,n=this._cachedBlocks;if(n.has(i)){const e=n.get(i);return e.ts=Date.now(),e.refCount++,n.delete(i),n.set(i,e),e.block}return null}putBlock(e,t,i,n){const s=this._cachedBlocks,r=e+"/"+t;if(s.has(r)){const e=s.get(r);e.ts=Date.now(),e.refCount++}else s.set(r,{block:i,ts:Date.now(),refCount:1,controller:n});this._trim(),this._updateTimer()}deleteBlock(e,t){const i=this._cachedBlocks,n=e+"/"+t;i.has(n)&&i.delete(n)}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 n=0;n<t.length&&t[n][1].ts<=i-this._duration;n++)e.delete(t[n][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 H(e,t,i){const n=E.get(e);if(!n)return null==t?J.decreaseRefCount(e,i):0;if(null==t||null==n[t])return J.decreaseRefCount(e,i);const s=n[t]?.cache,r=s?.get(i);if(s&&r){if(r.refCount--,0===r.refCount){s.delete(i);for(let e=0;e<n.length;e++)n[e]?.cache.delete(i);r.controller&&r.controller.abort()}return r.refCount}return 0}function W(e,t,i){const n=E.get(e);if(!n)return null==t?J.getBlock(e,i):null;if(null==t||null==n[t]){for(let e=0;e<n.length;e++){const t=n[e]?.cache.get(i);if(t)return t.refCount++,t.block}return J.getBlock(e,i)}const s=n[t]?.cache.get(i);if(s)return s.refCount++,s.block;for(let e=0;e<n.length;e++){if(e===t||!n[e])continue;const s=n[e]?.cache,r=s?.get(i);if(s&&r)return r.refCount++,s.set(i,r),r.block}return null}function q(e,t,i,n,s=null){const r=E.get(e);if(!r)return void(null==t&&J.putBlock(e,i,n,s));if(null==t||null==r[t])return void J.putBlock(e,i,n,s);const a={refCount:1,block:n,isResolved:!1,isRejected:!1,controller:s};n.then((()=>a.isResolved=!0)).catch((()=>a.isRejected=!0)),r[t]?.cache.set(i,a)}function j(e,t,i){const n=E.get(e);n?null!=t&&null!=n[t]?n[t]?.cache.delete(i):J.deleteBlock(e,i):null==t&&J.deleteBlock(e,i)}var G=i(81578),U=i(75993),$=i(55914),V=i(80676),X=i(6570);let Y=class extends((0,D.v)(O.wq)){constructor(){super(...arguments),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&&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))}set url(e){this._set("url",(0,S.Nm)(e,a.Z.getLogger(this)))}async open(e){throw new r.Z("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,n={}){const s=n.tileInfo||this.rasterInfo.storageInfo.tileInfo,r=this.getTileExtentFromTileInfo(e,t,i,s);return this.fetchPixels(r,s.size[0],s.size[1],n)}async identify(e,t={}){e=(0,h.TJ)(A.Z,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:n}=t,{rasterInfo:s}=this,{hasMultidimensionalTranspose:r,multidimensionalInfo:a}=s;let{transposedVariableName:o}=t;const l=null!=a&&r&&(null!=n||(0,B.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:u}=s,{datumTransformation:f}=t;let p=(0,N.nF)(e,c,f);if(!u.intersects(p))return{location:p,value:null};if(null!=s.transform){const e=s.transform.inverseTransform(p);if(!s.nativeExtent.intersects(e))return{location:e,value:null};p=e}let d=0;const m=null!=o&&null!=a&&s.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(m)return e.identify(p,t);const{pixelSize:i}=s,n=3,r=i.x*n/2,a=i.y*n/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:u}=await e.fetchPixels(o,n,n,l),{pixelBlock:h}=await this.fetchPixels(o,n,n,l);if(null==u)return{location:p,value:null};const f=Math.floor(n*n*.5),d=!u.mask||u.mask[f]?u.pixels.map((e=>e[f])):null;let y;return null!=h&&(y=!h.mask||h.mask[f]?h.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,s,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:w,colOffset:b,blockWidth:I}=y,v=o??t.sliceId,_=L(this.url,v),S=`${d}/${g}/${x}`;let R=W(_,null,S);null==R&&(R=this.fetchRawTile(d,g,x,t),q(_,null,S,R));const T=await R;if(null==T||!T.pixels?.length)return{location:p,value:null};const C=w*I+b;return this._processIdentifyResult(T,{srcLocation:p,position:C,pyramidLevel:d,useTransposedTile:!!m,requestSomeSlices:l,identifyOptions:t})}async fetchPixels(e,t,i,n={}){e=(0,N.kZ)(e),n=this._getRequestOptionsWithSliceId(n);const{_hasNoneOrGCSShiftTransform:s}=this;if(n.requestRawData&&s)return this._fetchPixels(e,t,i,n);const r=(0,N.ut)(e.spatialReference),a=(0,N.Hq)(e);if(null==r||0===a||1===a&&this._isGlobalWrappableSource&&s)return this._fetchPixels(e,t,i,n);if(a>=3)return{extent:e,pixelBlock:null};const o=[],{xmin:l,xmax:c}=e,u=Math.round(r/(c-l)*t),h=u-Math.round((r/2-l)/(c-l)*t);let f=0;const p=[];for(let s=0;s<=a;s++){const d=new X.Z({xmin:0===s?l:-r/2,xmax:s===a?c-r*s:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),m=0===s?u-h:s===a?t-f:u;f+=m,p.push(m);const y=n.disableWrapAround&&s>0?null:this._fetchPixels(d,m,i,n);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},n)).pixelBlock:(0,$.us)(d,y,{blockWidths:p}),{extent:e,srcExtent:(0,N.tB)(e,this.rasterInfo.spatialReference,n.datumTransformation),pixelBlock:m}}async fetchRawPixels(e,t,i,n={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const s=await this._fetchRawTiles(e,t,i,n),{nativeExtent:r,nativePixelSize:a,storageInfo:o}=this.rasterInfo,l=2**e,c=a.x*l,u=a.y*l,h=new X.Z({xmin:r.xmin+c*t.x,xmax:r.xmin+c*(t.x+i.width-1),ymin:r.ymax-u*(t.y+i.height-1),ymax:r.ymax-u*t.y,spatialReference:r.spatialReference});if(!s)return{extent:h,srcExtent:h,pixelBlock:null};const{pixelBlocks:f,mosaicSize:p}=s;if(1===f.length&&null!=f[0]&&f[0].width===i.width&&f[0].height===i.height)return{extent:h,srcExtent:h,pixelBlock:s.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:n.interpolation,alignmentInfo:null,blockWidths:null},n)).pixelBlock:(0,$.us)(f,p,{clipOffset:y,clipSize:i}),{extent:h,srcExtent:h,pixelBlock:g}}fetchRawTile(e,t,i,n){throw new r.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:n}=this.ioConfig,{range:s,query:r,headers:a}=t;i=i??t.retryCount??this.ioConfig.retryCount;const o=s?{Range:`bytes=${s.from}-${s.to}`}:null;try{return await(0,I.default)(e,{...t,query:{...r,...n},headers:{...a,...o}})}catch(n){if(i>0)return i--,this.request(e,t,i);throw n}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:(0,B.gk)(e,t)}getTileExtentFromTileInfo(e,t,i,n){const s=(0,P.s3)(n.lodAt(e));return this.getTileExtent({x:s.resolution,y:s.resolution},t,i,n.origin,n.spatialReference,n.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:n}=this.rasterInfo;if(!e.tileInfo){const s=[],r=e.maximumPyramidLevel||0;let a=Math.max(n.x,n.y),o=1/.0254*96*a;for(let e=0;e<=r;e++)s.push(new z.Z({level:r-e,resolution:a,scale:o})),a*=2,o*=2;const l=new A.Z({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new F.Z({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:s}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,n){const{width:s,height:r,nativeExtent:a,pixelSize:o,spatialReference:l}=e,c=new A.Z({x:a.xmin,y:a.ymax,spatialReference:l});null==n&&(n=Math.max(0,Math.round(Math.log(Math.max(s,r))/Math.LN2-8)));const u=this.computeBlockBoundary(a,512,512,{x:a.xmin,y:a.ymax},[o],n);e.storageInfo=new Z.Z({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:n,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,n,s,r=0,a=2){if(1===s.length&&r>0){s=[...s];let{x:e,y:t}=s[0];for(let i=0;i<r;i++)e*=a,t*=a,s.push({x:e,y:t})}const o=[],{x:l,y:c}=n;for(let n=0;n<s.length;n++){const{x:r,y:a}=s[n];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:n}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const s=n**e;return{x:t.x*s,y:t.y*s}}identifyPixelLocation(e,t,i,n){const{spatialReference:s,nativeExtent:r,storageInfo:a}=this.rasterInfo,{maximumPyramidLevel:o,origin:l,transposeInfo:c}=a,u=n&&null!=c?c.tileSize[0]:a.blockWidth,h=n&&null!=c?c.tileSize[1]:a.blockHeight,f=(0,N.nF)(e,s,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/h,g=(f.x-l.x)/d/u,x=Math.min(h-1,Math.floor((y-Math.floor(y))*h)),w=Math.min(u-1,Math.floor((g-Math.floor(g))*u));return{pyramidLevel:t,row:Math.floor(y),col:Math.floor(g),rowOffset:x,colOffset:w,blockWidth:u,srcLocation:f}}getTileExtent(e,t,i,n,s,r){const[a,o]=r,l=n.x+i*a*e.x,c=l+a*e.x,u=n.y-t*o*e.y,h=u-o*e.y;return new X.Z({xmin:l,xmax:c,ymin:h,ymax:u,spatialReference:s})}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 n=this.rasterInfo.storageInfo.blockBoundary[e];return!n||n.maxRow<t||n.maxCol<i||n.minRow>t||n.minCol>i}async _fetchPixels(e,t,i,n={}){let s=(0,N.Hq)(e);if(s>=2)return{extent:e,pixelBlock:null};const r=this._getSourceDataInfo(e,t,i,n),{pyramidLevel:a,srcResolution:o,srcExtent:l,srcWidth:c,srcHeight:u,ul:h}=r;if(0===c||0===u)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||(s=(0,N.Hq)(r.srcExtent,d));const y=await this._fetchRawTiles(a,h,{width:c,height:u,wrapCount:s},n);if(!y)return{extent:e,srcExtent:l,pixelBlock:null};const g=f.storageInfo,x=a>0?g.pyramidBlockWidth:g.blockWidth,w=a>0?g.pyramidBlockHeight:g.blockHeight;let{x:b,y:I}=f.pixelSize;if(a>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=g;if(null!=e&&e[a-1])({x:b,y:I}=e[a-1]);else{const e=t**a;b*=e,I*=e}}const v=f.spatialReference,_=new A.Z({x:b,y:I,spatialReference:v}),S=x===c&&w===u&&h.x%x==0&&h.y%w==0,R=new A.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}=n;if(!T&&S&&1===y.pixelBlocks.length&&x===t&&w===i&&this._isSameResolution(o,R,C))return{extent:e,srcExtent:l,srcTilePixelSize:_,pixelBlock:y.pixelBlocks[0]};const M=m&&null!=(0,N.ut)(l.spatialReference)&&this._hasNoneOrGCSShiftTransform,F=n.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");F&&!this.rasterJobHandler&&await(0,N.zD)();const O=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:R.toJSON(),datumTransformation:k,rasterTransform:p,hasWrapAround:s>0||M,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:F},n):(0,N.Qp)({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:R,datumTransformation:k,rasterTransform:p,hasWrapAround:s>0||M,isAdaptive:!1,includeGCSGrid:F});let P;const D=!n.requestRawData,z={rows:O.spacing[0],cols:O.spacing[1]},Z=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(a,y.extent.xmin):void 0,{pixelBlocks:B,mosaicSize:E,isPartiallyFilled:J}=y;let L=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:B,srcMosaicSize:E,destDimension:D?{width:t,height:i}:null,coefs:D?O.coefficients:null,sampleSpacing:D?z:null,projectDirections:F,gcsGrid:F?O.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:n.interpolation,alignmentInfo:Z,blockWidths:null},n);({pixelBlock:P,localNorthDirections:L}=e)}else{const e=(0,$.us)(B,E,{alignmentInfo:Z});P=D?(0,$.Uk)(e,{width:t,height:i},O.coefficients,z,n.interpolation):e,F&&O.gcsGrid&&(L=(0,$.Qh)({width:t,height:i},O.gcsGrid),P=(0,V.xQ)(P,this.rasterInfo.dataType,L))}return n.requestRawData||F?{extent:e,srcExtent:l,srcTilePixelSize:_,pixelBlock:P,transformGrid:O,localNorthDirections:L,isPartiallyFilled:J}:{extent:e,srcExtent:l,srcTilePixelSize:_,pixelBlock:P}}async _fetchRawTiles(e,t,i,n){const{origin:s,blockBoundary:r}=this.rasterInfo.storageInfo,{blockWidth:a,blockHeight:o}=this.getBlockWidthHeight(e);let{x:l,y:c}=t,{width:u,height:h,wrapCount:f}=i;const p=this._getRasterTileAlignmentInfo(e,0);n.buffer&&(l-=n.buffer.cols,c-=n.buffer.rows,u+=2*n.buffer.cols,h+=2*n.buffer.rows);let d=0,m=0,y=0;f&&null!=p&&(({worldColumnCountFromOrigin:m,originColumnOffset:y,rightPadding:d}=p),m*p.blockWidth-d>=l+u&&(d=0));const g=Math.floor(l/a),x=Math.floor(c/o),w=Math.floor((l+u+d-1)/a),b=Math.floor((c+h+d-1)/o),I=r[e];if(!I)return null;const{minRow:v,minCol:_,maxCol:S,maxRow:R}=I;if(0===f&&(b<v||w<_||x>R||g>S))return null;const T=new Array;let C=!1;const k=null==this.ioConfig.allowPartialFill?n.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=x;t<=b;t++)for(let i=g;i<=w;i++){let s=i;if(!n.disableWrapAround&&f&&null!=p&&m<=i&&(s=i-m-y),t>=v&&s>=_&&R>=t&&S>=s){const i=this._fetchRawTile(e,t,s,n);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:(b-x+1)*o,width:(w-g+1)*a},{spatialReference:O}=this.rasterInfo,P=this.getPyramidPixelSize(e),{x:D,y:z}=P;return{extent:new X.Z({xmin:s.x+g*a*D,xmax:s.x+(w+1)*a*D,ymin:s.y-(b+1)*o*z,ymax:s.y-x*o*z,spatialReference:O}),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,n){const s=this.rasterInfo.storageInfo.blockBoundary[e];if(!s)return Promise.resolve(null);const{minRow:r,minCol:a,maxCol:o,maxRow:c}=s;if(t<r||i<a||t>c||i>o)return Promise.resolve(null);const u=L(this.url,n.sliceId),h=`${e}/${t}/${i}`;let f=W(u,n.registryId,h);if(null==f){const s=new AbortController;f=this.fetchRawTile(e,t,i,{...n,signal:s.signal}),q(u,n.registryId,h,f,s),f.catch((()=>j(u,n.registryId,h)))}return n.signal&&(0,l.fu)(n,(()=>{H(u,n.registryId,h)})),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 n=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[s,r]=e,a=[],o=[];for(let e=0;e<n;e++){const[t,i]=(0,V.Tg)([s[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,n={}){const s={datumTransformation:n.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};n.srcResolution&&(s.srcResolution=n.srcResolution,this._updateSourceDataInfo(e,s));const r=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:a,srcHeight:o,pyramidLevel:l}=s,c=a/t,u=o/i,h=l<r&&c*u>=16,f=l===r&&this._requireTooManySrcTiles(a,o,t,i);if(h||f||0===a||0===o){const a=new A.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,s.datumTransformation);const f=!o||n.srcResolution&&o.x+o.y<n.srcResolution.x+n.srcResolution.y;if(h&&n.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,u))/Math.LN2)-1;if(r-l+3>=e){const t=2**e;o={x:n.srcResolution.x*t,y:n.srcResolution.y*t}}}o&&(s.srcResolution=o,this._updateSourceDataInfo(e,s))}return this._requireTooManySrcTiles(s.srcWidth,s.srcHeight,t,i)&&(s.srcWidth=0,s.srcHeight=0),s}_requireTooManySrcTiles(e,t,i,n){const{tileInfo:s}=this.rasterInfo.storageInfo;return Math.ceil(e/s.size[0])*Math.ceil(t/s.size[1])>=256||e/i>8||t/n>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,n=i.spatialReference,{srcResolution:s,datumTransformation:r}=t,{pyramidLevel:a,pyramidResolution:o,excessiveReading:l}=(0,N.kr)(s,i,this.ioConfig.sampling);if(l)return;let c=t.srcExtent||(0,N.tB)(e,n,r);if(null==c)return;const u=i.transform;u&&(c=u.inverseTransform(c)),t.srcExtent=c;const{x:h,y:f}=i.storageInfo.origin,p=Math.floor((c.xmin-h)/o.x+.1),d=Math.floor((f-c.ymax)/o.y+.1),m=Math.floor((c.xmax-h)/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:n,pyramidLevel:s,useTransposedTile:r}=t,a=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[n])return{location:i,value:null};const{multidimensionalInfo:o}=this.rasterInfo;if(null==o||!r){const t=e.pixels.map((e=>e[n])),r={location:i,value:t,pyramidLevel:s},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(n*a,n*a+a))),c=this._computeMagDirValues(l);const{requestSomeSlices:u,identifyOptions:h}=t;let f=(0,B.MO)(o,h.transposedVariableName);if(u){const e=(0,B.Ur)(f,h.multidimensionalDefinition,h.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,G.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:s}}};(0,n._)([(0,u.Cb)()],Y.prototype,"_rasterTileAlighmentInfo",void 0),(0,n._)([(0,u.Cb)({readOnly:!0})],Y.prototype,"_isGlobalWrappableSource",null),(0,n._)([(0,u.Cb)({readOnly:!0})],Y.prototype,"_hasNoneOrGCSShiftTransform",null),(0,n._)([(0,u.Cb)()],Y.prototype,"rasterJobHandler",null),(0,n._)([(0,u.Cb)(R.HQ)],Y.prototype,"url",null),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Y.prototype,"datasetName",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Y.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"hasUniqueSourceStorageInfo",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"rasterInfo",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"ioConfig",void 0),(0,n._)([(0,u.Cb)()],Y.prototype,"sourceJSON",void 0),Y=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.BaseRaster")],Y);const K=Y;let Q=class extends K{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:n}=this.primaryRasters,s=i.map((t=>t.rasterInfo?void 0:t.open(e)));await Promise.all(s);const a=i.map((({rasterInfo:e})=>e)),o=t.bind({rasterInfos:a,rasterIds:n});if(!o.success||0===a.length)throw new r.Z("raster-function:open",`cannot bind the function: ${o.error??""}`);await this.syncJobHandler();const l=a[0];this.hasUniqueSourceStorageInfo=1===a.length||a.slice(1).every((e=>this._hasSameStorageInfo(e,l))),this.set("sourceJSON",i[0].sourceJSON),this.set("rasterInfo",t.rasterInfo)}async syncJobHandler(){return this.rasterJobHandler?.updateRasterFunction(this.rasterFunction)}async fetchPixels(e,t,i,n={}){const{rasters:s,rasterIds:r}=this.primaryRasters;let a=!1;const{interpolation:o}=n,l=this.rasterFunction.flatWebGLFunctionChain?.hasSurfaceFunction;!n.requestRawData&&"bilinear"!==o&&l&&(a=1===s.length&&!n.skipRasterFunction,n={...n,interpolation:"bilinear",requestRawData:a});const c=s.map((s=>s.fetchPixels(e,t,i,n))),u=await Promise.all(c),h=u.map((e=>e.pixelBlock)),f=a||n.requestRawData?u.map((e=>e.srcTilePixelSize)):null;if(n.skipRasterFunction||h.every((e=>null==e)))return u[0];const p=u.find((e=>null!=e.pixelBlock))?.extent??e,d=this.rasterJobHandler?await this.rasterJobHandler.process({extent:p,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:r}):this.rasterFunction.process({extent:p,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:r}),{transformGrid:m}=u[0];if(!a||null==d||null==m)return{...u[0],pixelBlock:d};const y={rows:m.spacing[0],cols:m.spacing[1]};let g;return g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:[d],srcMosaicSize:{width:d.width,height:d.height},destDimension:{width:t,height:i},coefs:m.coefficients,sampleSpacing:y,projectDirections:!1,gcsGrid:null,isUV:!1,interpolation:o,alignmentInfo:void 0,blockWidths:null},n)).pixelBlock:(0,$.Uk)(d,{width:t,height:i},m.coefficients,y,o),{extent:e,srcExtent:u[0].srcExtent,pixelBlock:g}}_hasSameStorageInfo(e,t){const{storageInfo:i,pixelSize:n,spatialReference:s,extent:r}=e,{storageInfo:a,pixelSize:o,spatialReference:l,extent:c}=t;return n.x===o.x&&n.y===o.y&&s.equals(l)&&r.equals(c)&&i.blockHeight===a.blockHeight&&i.blockWidth===a.blockWidth&&i.maximumPyramidLevel===a.maximumPyramidLevel}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Q.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],Q.prototype,"tileType",void 0),(0,n._)([(0,u.Cb)()],Q.prototype,"rasterFunction",void 0),(0,n._)([(0,u.Cb)()],Q.prototype,"primaryRasters",void 0),Q=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.FunctionRaster")],Q);const ee=Q;var te=i(67900),ie=i(5847);var ne=i(90036),se=i(15612),re=i(67058),ae=i(72758),oe=i(79681),le=i(23808),ce=i(82971);const ue=a.Z.getLogger("esri.layers.mixins.ImageryTileMixin"),he=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){this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",(0,S.Nm)(e,ue))}set renderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("renderer",e),this.updateRenderer())}readRenderer(e,t,i){const n=t?.layerDefinition?.drawingInfo?.renderer;return(0,b.ij)(n,i)||void 0}async convertVectorFieldData(e,t){if(null==e||!this.rasterInfo)return null;const i=this._rasterJobHandler.instance,n=this.rasterInfo.dataType;return i?i.convertVectorFieldData({pixelBlock:e,dataType:n},t):(0,V.KC)(e,n)}async computeStatisticsHistograms(e,t){e=(0,h.TJ)(oe.Z,e).clone();const{rasterInfo:n}=this,{geometry:s}=e;if(null==s)throw new r.Z("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let a=s;const{spatialReference:o}=n;s.spatialReference.equals(o)||(await(0,N.zD)(),a="extent"===s.type?(0,N.tB)(s,o):(0,N.Wt)(s,o));const l=e.pixelSize??new A.Z({x:n.pixelSize.x,y:n.pixelSize.y,spatialReference:o}),{extent:c,width:u,height:f}=function(e,t,i,n=!0){const{spatialReference:s}=e,{x:r,y:a}=function(e,t){if(e.spatialReference.equals(t))return e;const i=(0,te.c9)(e.spatialReference),n=(0,te.c9)(t);if(i===n)return e;const s=i/n;return{x:e.x*s,y:e.y*s}}(i,s);let o,l,c;const u="extent"===t.type?t:t.extent;let{xmin:h,xmax:f,ymax:p,ymin:d}=u;const{xmin:m,ymax:y}=e.extent;return n?(h=m+(h>m?r*Math.round((h-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:h,ymax:p,xmax:f,ymin:d,spatialReference:s}),l=Math.round(o.width/r),c=Math.round(o.height/a)):(l=Math.floor((f-h)/r+.8),c=Math.floor((p-d)/a+.8),h=m+(h>m?r*Math.floor((h-m)/r+.1):0),p=y-(p<y?a*Math.floor((y-p)/a+.1):0),f=h+l*r,d=p-c*a,o=new X.Z({xmin:h,ymax:p,xmax:f,ymin:d,spatialReference:s})),{extent:o,width:l,height:c}}(n,a,l),p=await this.fetchPixels(c,u,f,{...t,interpolation:"nearest"});if(null==p.pixelBlock)throw new r.Z("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const d=await async function(e,t,n){if("extent"===n.type)return function(e,t,i){const{width:n,height:s}=e,r=new Uint8Array(n*s),a=t.width/n,o=t.height/s;if(i.width/a<.5||i.height/o<.5)return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]});const{xmin:l,xmax:c,ymin:u,ymax:h}=t,{xmin:f,xmax:p,ymin:d,ymax:m}=i,y=Math.max(l,f),g=Math.min(c,p),x=Math.max(u,d),w=Math.min(h,m),b=.5*a,I=.5*o;if(g-y<b||w-x<I||g<l+b||y>c-b||x>h-I||w<u+I)return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]});const v=Math.max(0,(y-l)/a),_=Math.min(n,Math.max(0,(g-l)/a)),S=Math.max(0,(h-w)/o),R=Math.min(s,Math.max(0,(h-x)/o)),T=Math.round(v),C=Math.round(_)-1,k=Math.round(S),M=Math.round(R)-1;if(T===C&&v%1>.5&&_%1<.5||k===M&&S%1>.5&&R%1<.5)return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]});if(0===T&&0===k&&C===n&&M===s)return e;const F=e.mask;for(let e=k;e<=M;e++)for(let t=T;t<=C;t++){const i=e*n+t;r[i]=F?F[i]:255}return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]})}(e,t,n);const{width:s,height:r}=e,a=new Uint8Array(s*r),{contains:o,intersects:l}=await Promise.all([i.e(5837),i.e(1433)]).then(i.bind(i,61433));return l(t,n)?"polyline"===n.type?function(e,t,i){const{width:n,height:s}=e,r=new Uint8Array(n*s),a=t.width/n,o=t.height/s,{xmin:l,ymax:c}=t,{paths:u}=i,h=e.mask;for(let e=0;e<u.length;e++){const t=u[e];for(let e=0;e<t.length-1;e++){const[i,u]=t[e],[f,p]=t[e+1];let d=Math.floor((c-u)/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(s-1,m);const y=(f-i)/(p-u);for(let e=d;e<=m;e++){const t=e===d?Math.max(u,p):(s+1-e)*o,c=e===m?Math.min(u,p):t-o;let g=p===u?Math.floor((i-l)/a):Math.floor((y*(t-u)+i-l)/a),x=p===u?Math.floor((f-l)/a):Math.floor((y*(c-u)+i-l)/a);if(x<g){const e=g;g=x,x=e}const w=e*n;g=Math.max(0,g),x=Math.min(n-1,x);for(let e=w+g;e<=w+x;e++)r[e]=h?h[e]:255}}}return new ie.Z({pixelType:e.pixelType,width:n,height:s,mask:r,pixels:[...e.pixels]})}(e,t,n):o(n,t)?e:function(e,t,i){if(!e)return e;const{width:n,height:s}=e,r=t.width/n,a=t.height/s,{xmin:o,ymax:l}=t;let c;if("extent"===i.type){const e=(i.xmin-o)/r,t=(i.xmax-o)/r,n=(l-i.ymax)/a,s=(l-i.ymin)/a;c=[[[e,n],[e,s],[t,s],[t,n],[e,n]]]}else c=i.rings.map((e=>e.map((([e,t])=>[(e-o)/r,(l-t)/a]))));const u=document.createElement("canvas");u.width=n,u.height=s;const h=u.getContext("2d");h.fillStyle="#f00",c.forEach((e=>{h.beginPath(),h.moveTo(e[0][0],e[0][1]);for(let t=0;t<e.length;t++)h.lineTo(e[t][0],e[t][1]);h.closePath(),h.fill()}));const f=h.getImageData(0,0,n,s).data,p=e.mask,d=n*s,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 ie.Z({pixelType:e.pixelType,width:n,height:s,mask:m,maskIsAlpha:!1,pixels:[...e.pixels]})}(e,t,n):new ie.Z({pixelType:e.pixelType,width:s,height:r,mask:a,maskIsAlpha:!1,pixels:[...e.pixels]})}(p.pixelBlock,c,a),m=this._rasterJobHandler.instance;return m?m.computeStatisticsHistograms({pixelBlock:d},t):(0,se.js)(d)}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):(0,le.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;null!=i&&i.length||(i=(0,B.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const n=e.timeExtent||this.timeExtent;if(null!=i&&null!=n&&(null!=n.start||null!=n.end)){i=i.map((e=>e.clone()));const s=t.variables.find((({name:e})=>e===i[0].variableName))?.dimensions?.find((({name:e})=>"StdTime"===e)),r=i.find((({dimensionName:e})=>"StdTime"===e));if(!s||!r)return{...e,multidimensionalDefinition:null};const{start:a,end:o}=n,l=null==a?null:a.getTime(),c=null==o?null:o.getTime(),u=l??c,h=c??l;if(null!=s.values){const e=s.values.filter((e=>{if(Array.isArray(e)){if(u===h)return e[0]<=u&&e[1]>=u;const t=e[0]<=u&&e[1]>u||e[0]<h&&e[1]>=h,i=e[0]>=u&&e[1]<=h||e[0]<u&&e[1]>h;return t||i}return u===h?e===u:e>=u&&e<=h}));if(e.length){const t=e.sort(((e,t)=>{const i=Array.isArray(e)?e[0]:e,n=Array.isArray(e)?e[1]:e,s=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t[1]:t;return u===h?i-s:Math.abs(n-h)-Math.abs(r-h)}))[0];r.values=[t]}else i=null}else if(s.hasRegularIntervals&&s.extent){const[e,t]=s.extent;u>t||h<e?i=null:r.values=u===h?[u]:[Math.max(e,u),Math.min(t,h)]}}return null!=i&&(0,B.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:n}=this;if(n){const i={raster:t};e.length>1&&e.forEach((e=>i[e.url]=e));const s=(0,ne.Ue)(n.rasterFunctionDefinition??n.toJSON(),i),r=new ee({rasterFunction:s});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&&!n)return;const{bandIds:s}=this,{bandCount:r}=this.raster.rasterInfo,a=s?.length?s.some((e=>e>=r)):r>=3;s&&(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,n=(0,B.WY)(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=n?.name,r=(0,re.ol)({...this.renderer.toJSON(),variableName:s});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(r))return;const a=this._rasterJobHandler.instance;a&&(t.rasterInfo=(0,re.FI)(i,s),t.rendererJSON=r,t.bind(),await a.updateSymbolizer(t),this._cachedRendererJson=r)}async applyRenderer(e,t){const i=e&&e.pixelBlock;if(!(null!=i&&i.pixels&&i.pixels.length>0))return null;let n;await this.updateRenderer();const s=this._rasterJobHandler.instance,r=this.bandIds??[];return n=s?await s.symbolize({...e,simpleStretchParams:t,bandIds:r}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:r}),n}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 n=(0,_.C5)(e);return F.Z.create({size:256,spatialReference:e,origin:n?{x:n.origin[0],y:n.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,i,n={}){if(s(this),n.requestAsImageElement){const s=this.getTileUrl(e,t,i);return(0,I.default)(s,{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 s=n.tileInfo||r.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(e,t,i,s),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,i,n)}async fetchPixels(e,t,i,n={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(n=this.normalizeRasterFetchOptions(n)).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,n))}async identify(e,t={}){const{raster:i,rasterInfo:n}=this;if(null!=n.multidimensionalInfo&&!(n.hasMultidimensionalTranspose&&((0,B.WU)(t.multidimensionalDefinition)||t.transposedVariableName||t.timeExtent)||null!=(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition))return{location:e,value:null};const s=this.multidimensionalSubset?.areaOfInterest;if(s&&!s.contains(e))throw new r.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,B.jj)(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=(0,B.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new M.Z;return this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{s(this),this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).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){s(this);const{raster:e}=this,t=(0,re.In)(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){s(this);const{rasterInfo:t}=this.raster;!this.bandIds&&t.bandCount>1&&(this.bandIds=(0,re.YD)(t));const i=(0,B.WY)(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=i?.name;if(!this.renderer||"override"===e){const e=(0,re.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,re.ol)({...this.renderer.toJSON(),variableName:n}),a=(0,re.FI)(t,n);this.symbolizer?(this.symbolizer.rendererJSON=r,this.symbolizer.rasterInfo=a):this.symbolizer=new ae.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)if("raster-colormap"!==t.type)this._configDefaultRenderer("override");else{const e=(0,re.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 ue.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}};function s(e){if(!e.raster||!e.rasterInfo)throw new r.Z("imagery-tile","no raster")}return(0,n._)([(0,u.Cb)()],t.prototype,"_cachedRendererJson",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_cachedRasterFunctionJson",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_compatibleFullExtent",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_isConstructedFromFunctionRaster",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"_rasterJobHandler",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"bandIds",void 0),(0,n._)([(0,u.Cb)({json:{origins:{service:{read:{source:"copyrightText"}}}}})],t.prototype,"copyright",void 0),(0,n._)([(0,u.Cb)({json:{read:!1}})],t.prototype,"fullExtent",null),(0,n._)([(0,u.Cb)()],t.prototype,"interpolation",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"ioConfig",void 0),(0,n._)([(0,u.Cb)({type:[T.Z],json:{write:!0}})],t.prototype,"multidimensionalDefinition",null),(0,n._)([(0,u.Cb)({type:C.Z,json:{write:!0}})],t.prototype,"multidimensionalSubset",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"raster",void 0),(0,n._)([(0,u.Cb)({type:k.Z})],t.prototype,"rasterFunction",null),(0,n._)([(0,u.Cb)()],t.prototype,"rasterInfo",void 0),(0,n._)([(0,u.Cb)()],t.prototype,"sourceJSON",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,type:ce.Z,json:{read:!1}})],t.prototype,"spatialReference",void 0),(0,n._)([(0,u.Cb)({type:F.Z})],t.prototype,"tileInfo",void 0),(0,n._)([(0,u.Cb)(R.HQ)],t.prototype,"url",null),(0,n._)([(0,u.Cb)({types:b.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:b.FK,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],t.prototype,"renderer",null),(0,n._)([(0,v.r)("renderer")],t.prototype,"readRenderer",null),(0,n._)([(0,u.Cb)()],t.prototype,"symbolizer",void 0),t=(0,n._)([(0,m.j)("esri.layers.ImageryTileMixin")],t),t};var fe=i(38009),pe=i(16859),de=i(34760),me=i(72965),ye=i(28294),ge=i(1231),xe=i(69608),we=i(25972),be=i(20095);function Ie(e){const t=e.fields,i=e.records,n=t.some((e=>"oid"===e.name.toLowerCase()))?"OBJECTID":"OID",s=[{name:n,type:"esriFieldTypeOID",alias:"OID"}].concat(t.map((e=>({name:e.name,type:"esriFieldType"+e.typeName,alias:e.name})))),r=s.map((e=>e.name)),a=[];let o=0,l=0;return i.forEach((e=>{const t={};for(t[n]=o++,l=1;l<r.length;l++)t[r[l]]=e[l-1];a.push({attributes:t})})),{displayFieldName:"",fields:s,features:a}}class ve{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 n=t.getUint32(4,!0),s=t.getUint16(8,!0),r=t.getUint16(10,!0),a={version:i,recordCount:n,headerByteCount:s,recordByteCount:r};let o=32;const l=[],c=[];let u;if(3===i){for(;13!==t.getUint8(o);)u=String.fromCharCode(t.getUint8(o+11)).trim(),l.push({name:(0,be.f)(new Uint8Array(e,o,11)),type:u,typeName:["String","Date","Double","Boolean","String","Integer"][["C","D","F","L","M","N"].indexOf(u)],length:t.getUint8(o+16)}),o+=32;if(o+=1,l.length>0)for(;c.length<n&&e.byteLength-o>r;){const i=[];32===t.getUint8(o)?(o+=1,l.forEach((t=>{if("C"===t.type)i.push((0,be.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 n=String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim();i.push(new Date(parseInt(n.substring(0,4),10),parseInt(n.substring(4,6),10)-1,parseInt(n.substring(6,8),10)))}o+=t.length})),c.push(i)):o+=r}}return{header:a,fields:l,records:c,recordSet:Ie({fields:l,records:c})}}}var _e=i(87521),Se=i(74889);const Re=new Map;Re.set("int16","esriFieldTypeSmallInteger"),Re.set("int32","esriFieldTypeInteger"),Re.set("int64","esriFieldTypeInteger"),Re.set("float32","esriFieldTypeSingle"),Re.set("float64","esriFieldTypeDouble"),Re.set("text","esriFieldTypeString");let Te=class extends K{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 r.Z("cloudraster:open","Invalid or unsupported conf.json.");this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const{storageInfo:i,rasterInfo:n}=this._parseHeader(t);if("thematic"===n.dataType){const e=await this._fetchAuxiliaryInformation();n.attributeTable=e}this._set("storageInfo",i),this._set("rasterInfo",n),this.ioConfig.retryCount=this.ioConfig.retryCount||0}async fetchRawTile(e,t,i,n={}){const{transposeInfo:s}=this.rasterInfo.storageInfo,{transposedVariableName:r}=n,a=!(!s||!r),o=a?0:this.rasterInfo.storageInfo.maximumPyramidLevel-e;if(o<0)return null;const l=this._buildCacheFilePath(o,t,i,n.multidimensionalDefinition,r),c=this._getIndexRecordFromBundle(t,i,a),u=await this.request(l,{range:{from:0,to:this.storageInfo.headerSize-1},responseType:"array-buffer",signal:n.signal});if(!u)return null;const h=new Uint8Array(u.data),f=this._getTileEndAndContentType(h,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:n.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,histograms:n,colormap:s,blockWidth:r,blockHeight:a,firstPyramidLevel:o,maximumPyramidLevel:l}=e,c=e.statistics&&e.statistics.map((e=>({min:e.min,max:e.max,avg:e.mean,stddev:e.standardDeviation,median:e.median,mode:e.mode}))),u=e.extent.spatialReference,h=e.geodataXform?.spatialReference,f=new ce.Z(u?.wkid||u?.wkt?u:h);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 A.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 w=e.properties??{},b=e.format.toLowerCase().replace("cache/",""),I=new A.Z(e.origin.x,e.origin.y,f);let v,_,S,R;if(s&&s.colors)for(v=[],_=0;_<s.colors.length;_++)S=s.colors[_],R=s.values?s.values[_]:_,v.push([R,255&S,S<<16>>>24,S<<8>>>24,S>>>24]);const T=e.LODInfos,C=[];for(_=0;_<T.levels.length;_++)C.push(new z.Z({level:T.levels[_],resolution:T.resolutions[_],scale:96/.0254*T.resolutions[_]}));const k=new F.Z({dpi:96,lods:C,format:b,origin:I,size:[r,a],spatialReference:f}),M={recordSize:8,packetSize:e.packetSize,headerSize:e.packetSize*e.packetSize*8+64},O=[{maxCol:Math.ceil(m/r)-1,maxRow:Math.ceil(y/a)-1,minCol:0,minRow:0}];let P=2;if(l>0)for(_=0;_<l;_++)O.push({maxCol:Math.ceil(m/P/r)-1,maxRow:Math.ceil(y/P/a)-1,minCol:0,minRow:0}),P*=2;const D=e.mdInfo;let B=null;if(D&&w._yxs){const e=w._yxs;B={packetSize:e.PacketSize,tileSize:[e.TileXSize,e.TileYSize]}}return{storageInfo:M,rasterInfo:new we.Z({width:m,height:y,pixelType:t,bandCount:i,extent:p,nativeExtent:x,transform:g,spatialReference:f,pixelSize:d,keyProperties:w,statistics:c,histograms:n,multidimensionalInfo:D,colormap:v,storageInfo:new Z.Z({blockWidth:r,blockHeight:a,pyramidBlockWidth:r,pyramidBlockHeight:a,origin:I,tileInfo:k,transposeInfo:B,firstPyramidLevel:o,maximumPyramidLevel:l,blockBoundary:O})})}}_parseTransform(e){if(!(0,_e.j)(e))throw new r.Z("cloudraster:open","the data contains unsupported geodata transform types");const t=(0,_e.c)(e);if("identity"===t.type)return null;if("polynomial"!==t.type||!t.forwardCoefficients?.length||!t.inverseCoefficients?.length)throw new r.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)),n=await Promise.all([t,i]);let s;if(n[0]){let e=n[0].fields;const t=n[0].values;if(e&&t){e=e.map((e=>({type:"OID"===e.name?"esriFieldTypeOID":Re.get(e.type),name:e.name,alias:e.alias||e.name})));const i=t.map((e=>({attributes:e})));e&&t&&(s={fields:e,features:i})}}return!s&&n[1]&&(s=ve.parse(n[1]).recordSet),Se.Z.fromJSON(s)}_buildCacheFilePath(e,t,i,n,s){const r=this._getPackageSize(!!s),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:u}=this.rasterInfo,h=n?.[0];if(null==u||!h)return`${this.url}/_alllayers/${c}/${l}.bundle`;let f="_yxs";if(!s){f=u.variables.find((e=>e.name===h.variableName)).dimensions[0].values.indexOf(h.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(s||h.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 n=this._getPackageSize(i),s=n*(e%n)+t%n;if(s<0)throw new Error("Invalid level / row / col");return 20+s*this.storageInfo.recordSize+44}_getTileEndAndContentType(e,t){const i=e.subarray(t,t+8);let n,s=0;for(n=0;n<5;n++)s|=(255&i[n])<<8*n;const r=0xffffffffff&s;for(s=0,n=5;n<8;n++)s|=(255&i[n])<<8*(n-5);return{position:r,recordSize:0xffffffffff&s}}_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,n._)([(0,u.Cb)({readOnly:!0})],Te.prototype,"storageInfo",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Te.prototype,"datasetFormat",void 0),Te=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.CloudRaster")],Te);const Ce=Te;let ke=class extends K{constructor(){super(...arguments),this.datasetFormat="MEMORY",this.data=null}async open(e){await this.init();const t=this.data,{pixelBlock:i,statistics:n,histograms:s,name:r,keyProperties:a,nativeExtent:o,transform:l}=this.data,{width:c,height:u,pixelType:h}=i,f=t.extent??new X.Z({xmin:-.5,ymin:.5,xmax:c-.5,ymax:u-.5,spatialReference:new ce.Z({wkid:3857})}),p=t.isPseudoSpatialReference??!t.extent,d={x:f.width/c,y:f.height/u},m=new we.Z({width:c,height:u,pixelType:h,extent:f,nativeExtent:o,transform:l,pixelSize:d,spatialReference:f.spatialReference,bandCount:i.pixels.length,keyProperties:a||{},statistics:n,isPseudoSpatialReference:p,histograms:s});this.createRemoteDatasetStorageInfo(m,512,512),this._set("rasterInfo",m),this.updateTileInfo(),await this._buildInMemoryRaster(i,{width:512,height:512},e),this.datasetName=r,this.url="/InMemory/"+r}fetchRawTile(e,t,i,n={}){const s=this._pixelBlockTiles.get(`${e}/${t}/${i}`);return Promise.resolve(s)}async _buildInMemoryRaster(e,t,i){const n=this.rasterInfo.storageInfo.maximumPyramidLevel,s=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:e,tileSize:t,maximumPyramidLevel:n},i):Promise.resolve((0,$.Vl)(e,t,n)),a=null!=this.rasterInfo.statistics,o=null!=this.rasterInfo.histograms,c=a?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:e},i):Promise.resolve((0,se.Hv)(e)),u=await(0,l.as)([s,c]);if(!u[0].value&&u[1].value)throw new r.Z("inmemory-raster:open","failed to build in memory raster");this._pixelBlockTiles=u[0].value,a||(this.rasterInfo.statistics=u[1].value?.statistics),o||(this.rasterInfo.histograms=u[1].value?.histograms)}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],ke.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],ke.prototype,"data",void 0),ke=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.InMemoryRaster")],ke);const Me=ke;function Fe(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 n=[];if(t){const s=Fe(e,i);for(let e=0;e<s.length;e++)Fe(s[e],t).forEach((e=>n.push(e)));return n}const s=e.getElementsByTagNameNS("*",i);if(!s||0===s.length)return[];for(let e=0;e<s.length;e++)n.push(s[e]||s.item(e));return n}function Oe(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 n=Fe(e,i);return n.length>0?t?Oe(n[0],t):n[0]:null}function Pe(e,t=null){const i=t?Oe(e,t):e;let n;return i?(n=i.textContent||i.nodeValue,n?n.trim():null):null}function De(e,t){return function(e,t){const i=Fe(e,t),n=[];let s;for(let e=0;e<i.length;e++)s=i[e].textContent||i[e].nodeValue,s&&(s=s.trim(),""!==s&&n.push(s));return n}(e,t).map((e=>Number(e)))}function ze(e,t){const i=Pe(e,t);return Number(i)}function Ze(e,t){const i=e?.nodeName?.toLowerCase(),n=t.toLowerCase();return i.slice(i.lastIndexOf(":")+1)===n}var Be=i(87390);function Ne(e,t){if(!e||!t)return null;const i=[];for(let n=0;n<e.length;n++)i.push(e[n]),i.push(t[n]);return i}function Ae(e){if(!e)return null;let t=Number(e);if(!isNaN(t)&&0!==t)return new ce.Z({wkid:t});if((e=String(e)).startsWith("COMPD_CS")){if(!e.includes("VERTCS")||!e.includes("GEOGCS")&&!e.startsWith("PROJCS"))return null;const i=e.indexOf("VERTCS"),n=e.indexOf("PROJCS"),s=n>-1?n:e.indexOf("GEOGCS");if(-1===s)return null;const r=e.slice(s,e.lastIndexOf("]",i)+1).trim(),a=e.slice(i,e.lastIndexOf("]")).trim();t=Ee(r);const o=new ce.Z(t?{wkid:t}:{wkt:r}),l=Ee(a);return l&&(o.vcsWkid=l),o}return e.startsWith("GEOGCS")||e.startsWith("PROJCS")?(t=Ee(e),new ce.Z(0!==t?{wkid:t}:{wkt:e})):null}function Ee(e){const t=e.replaceAll("]","[").replaceAll('"',"").split("[").map((e=>e.trim())).filter((e=>""!==e)),i=t[t.length-1].split(","),n=i[0]?.toLowerCase();if(("epsg"===n||"esri"===n)&&e.endsWith('"]]')){const e=Number(i[1]);if(!isNaN(e)&&0!==e)return e}return 0}function Je(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(Ze(e,"SRS")){if(!t.spatialReference){const i=Pe(e);t.spatialReference=Ae(i)}}else if(Ze(e,"Metadata"))if("xml:ESRI"===e.getAttribute("domain")){const{spatialReference:i,transform:n}=function(e){const t=Oe(e,"GeodataXform"),i=Ae(ze(t,"SpatialReference/WKID")||Pe(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:i,transform:null};const n=ze(t,"PolynomialOrder")??1,s=De(t,"CoeffX/Double"),r=De(t,"CoeffY/Double"),a=De(t,"InverseCoeffX/Double"),o=De(t,"InverseCoeffY/Double"),l=Ne(s,r),c=Ne(a,o);return{spatialReference:i,transform:l&&c&&l.length&&c.length?new Be.Z({spatialReference:i,polynomialOrder:n,forwardCoefficients:l,inverseCoefficients:c}):null}}(e);t.transform=n,t.spatialReference||(t.spatialReference=i)}else Fe(e,"MDI").forEach((e=>t.metadata[e.getAttribute("key")]=Pe(e)));else if(Ze(e,"PAMRasterBand")){const i=function(e){const t=ze(e,"NoDataValue"),i=Oe(e,"Histograms/HistItem"),n=ze(i,"HistMin"),s=ze(i,"HistMax"),r=ze(i,"BucketCount"),a=Pe(i,"HistCounts")?.split("|").map((e=>Number(e)));let o,l,c,u;Fe(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":u=t}}));const h=ze(e,"Metadata/SourceBandIndex");return{noDataValue:t,histogram:a?.length&&null!=n&&null!=s?{min:n,max:s,size:r||a.length,counts:a}:null,sourceBandIndex:h,statistics:null!=o&&null!=l?{min:o,max:l,avg:c,stddev:u}: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(f.pC):null;const n=!!i[0].histogram;t.histograms=n?i.map((e=>e.histogram)).filter(f.pC):null}return t}let Le=class extends K{async open(e){await this.init();const t=await this._fetchData(e);let{spatialReference:i,statistics:n,histograms:s,transform:r}=await this._fetchAuxiliaryData(e);const a=!i;a&&(i=new ce.Z({wkid:3857})),s?.length&&null==n&&(n=(0,se.Oh)(s));const{width:o,height:l}=t;let c=new X.Z({xmin:-.5,ymin:.5-l,xmax:o-.5,ymax:.5,spatialReference:i});const u=r?r.forwardTransform(c):c;let h=!0;if(r){const e=r.forwardCoefficients;h=e&&0===e[1]&&0===e[2],h&&(r=null,c=u)}const f=new Me({data:{extent:u,nativeExtent:c,transform:r,pixelBlock:t,statistics:n,histograms:s,keyProperties:{DateType:"Processed"},isPseudoSpatialReference:a}});await f.open(),f.data=null,this._set("rasterInfo",f.rasterInfo),this._inMemoryRaster=f}fetchRawTile(e,t,i,n={}){return this._inMemoryRaster.fetchRawTile(e,t,i,n)}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 r.Z("image-aux-raster:open","the data is not a supported format");this._set("datasetFormat",i);const n=i.toLowerCase(),s="gif"===n||"bmp"===n||!(0,p.Z)("ios"),a=await this.decodePixelBlock(t,{format:n,useCanvas:s,hasNoZlibMask:!0});if(null==a)throw new r.Z("image-aux-raster:open","the data cannot be decoded");return a}async _fetchAuxiliaryData(e){const t=e?.signal,i=this.ioConfig.skipExtensions??[],n=i.includes("aux.xml")?null:this.request(this.url+".aux.xml",{responseType:"xml",signal:t}),s=this.datasetFormat,r="JPG"===s?"jgw":"PNG"===s?"pgw":"BMP"===s?"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,l.as)([n,a]);if(t?.aborted)throw(0,l.zE)();const c=Je(o[0].value?.data);if(!c.transform){const e=o[1].value?o[1].value.data.split("\n").slice(0,6).map((e=>Number(e))):null;c.transform=6===e?.length?new Be.Z({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return c}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Le.prototype,"datasetFormat",void 0),Le=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.ImageAuxRaster")],Le);const He=Le;var We=i(81271),qe=i(28589),je=i(29680),Ge=i(26059);let Ue=class extends K{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&&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 n=i.data;if(this.sourceJSON=n,!n)throw new r.Z("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!n.tileInfo)throw new r.Z("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo(),this.tileType=n.cacheType,null==this.tileType&&(["jpg","jpeg","png","png8","png24","png32","mixed"].includes(n.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===n.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=n.name?.slice(n.name.indexOf("/")+1)??"";const s=await this._fetchRasterInfo({signal:t});if(null==s)throw new r.Z("image-server-raster:open","cannot initialize image service");const a="Map"===this.tileType?function(e,t){if(!e)return null;const{minScale:i,maxScale:n,minLOD:s,maxLOD:r}=t;if(null!=s&&null!=r)return F.Z.fromJSON({...e,lods:e.lods.filter((({level:e})=>null!=e&&e>=s&&e<=r))});if(0!==i&&0!==n){const t=e=>Math.round(1e4*e)/1e4,s=i?t(i):1/0,r=n?t(n):-1/0;return F.Z.fromJSON({...e,lods:e.lods.filter((e=>{const i=t(e.scale);return i<=s&&i>=r}))})}return F.Z.fromJSON(e)}(n.tileInfo,n):F.Z.fromJSON(n.tileInfo);(0,P.O3)(a);const[o,l]=this._computeMinMaxLOD(s,a),{extent:c,pixelSize:u}=s,h=.5/s.width*u.x,f=Math.max(u.x,u.y),{lods:p}=a;("Map"!==this.tileType&&0!==n.maxScale||Math.abs(u.x-u.y)>h||!p.some((e=>Math.abs(e.resolution-f)<h)))&&(u.x=u.y=o.resolution,s.width=Math.ceil((c.xmax-c.xmin)/u.x-.1),s.height=Math.ceil((c.ymax-c.ymin)/u.y-.1));const d=o.level-l.level,[m,y]=a.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 w=this.computeBlockBoundary(c,m,y,a.origin,g,d),b=g.length>1?g.slice(1):null;let I;n.transposeInfo&&(I={tileSize:[n.transposeInfo.rows,n.transposeInfo.cols],packetSize:s.keyProperties?._yxs.PacketSize??0});const v=x.length<=1||x.length>=3&&x.slice(0,x.length-1).every((e=>e===x[0]))?x[0]??2:Math.round(10/(l.resolution/o.resolution)**(-1/d))/10;if(s.storageInfo=new Z.Z({blockWidth:a.size[0],blockHeight:a.size[1],pyramidBlockWidth:a.size[0],pyramidBlockHeight:a.size[1],pyramidResolutions:b,pyramidScalingFactor:v,compression:a.format,origin:a.origin,firstPyramidLevel:1,maximumPyramidLevel:d,tileInfo:a,transposeInfo:I,blockBoundary:w}),this._fixGCSShift(s),this._set("rasterInfo",s),n.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:s.storageInfo.tileInfo,parsedUrl:(0,We.mN)(this.url),url:this.url,tileServers:[]};this._tilemapCache=new qe.y({layer:e})}}async fetchRawTile(e,t,i,n={}){const{storageInfo:s,extent:r}=this.rasterInfo,{transposeInfo:a}=s,o=null!=a&&!!n.transposedVariableName;if(this._slices&&!o&&null==n.sliceId)return null;const l=o?0:s.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${l}/${t}/${i}`,u=this._slices?o?{variable:n.transposedVariableName}:{sliceId:n.sliceId||0}:null,{data:h}=await this.request(c,{query:u,responseType:"array-buffer",signal:n.signal});if(!h)return null;const f=o?a.tileSize:s.tileInfo.size,p=await this.decodePixelBlock(h,{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=s.blockBoundary[e];if("jpg"!==s.compression||i>d.minCol&&i<d.maxCol&&t>d.minRow&&t<d.maxRow)return p;const{origin:m,blockWidth:y,blockHeight:g}=s,{x,y:w}=this.getPyramidPixelSize(e),b=Math.round((r.xmin-m.x)/x)%y,I=Math.round((r.xmax-m.x)/x)%y||y,v=Math.round((m.y-r.ymax)/w)%g,_=Math.round((m.y-r.ymin)/w)%g||g,S=i===d.minCol?b:0,R=t===d.minRow?v:0,T=i===d.maxCol?I:y,C=t===d.maxRow?_:g;return(0,$.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)),n=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([i,n]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[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 n=0;const{maximumPyramidLevel:s}=this.rasterInfo.storageInfo;let r=s-n+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--,n++,i=this.identifyPixelLocation(a,n,t.datumTransformation),null===i)return null}return-1===r||null==i?null:n}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),n=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),s=ce.Z.fromJSON(t.spatialReference||e.spatialReference),r=new A.Z({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:s});return new we.Z({width:i,height:n,bandCount:3,extent:X.Z.fromJSON(e),spatialReference:s,pixelSize:r,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,n=(0,Ge.g)(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),s=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then((e=>e.data&&e.data.slices)).catch((()=>null)):null,r=await Promise.all([n,s]);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 je.Z,e.extent=e.transform.forwardTransform(t))}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,n=.5/e.width*i.x,{lods:s}=t,r=t.lodAt(Math.max.apply(null,s.map((e=>e.level)))),a=t.lodAt(Math.min.apply(null,s.map((e=>e.level)))),{tileType:o}=this;if("Map"===o)return this._levelOffset=s[0].level,[r,a];if("Raster"===o)return[s.find((e=>e.resolution===i.x))??r,a];const{minScale:l,maxScale:c}=this.sourceJSON;let u=r;c>0&&(u=s.find((e=>Math.abs(e.scale-c)<n)),u||(u=s.filter((e=>e.scale>c)).sort(((e,t)=>e.scale>t.scale?1:-1))[0]??r));let h=a;return l>0&&(h=s.find((e=>Math.abs(e.scale-l)<n))??a,this._levelOffset=h.level-a.level),[u,h]}};(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Ue.prototype,"datasetFormat",void 0),(0,n._)([(0,u.Cb)()],Ue.prototype,"tileType",void 0),Ue=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.ImageServerRaster")],Ue);const $e=Ue;var Ve=i(48279);const Xe=new Map;Xe.set("Int8","s8"),Xe.set("UInt8","u8"),Xe.set("Int16","s16"),Xe.set("UInt16","u16"),Xe.set("Int32","s32"),Xe.set("UInt32","u32"),Xe.set("Float32","f32"),Xe.set("Float64","f32"),Xe.set("Double64","f32");const Ye=new Map;Ye.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),Ye.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),Ye.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),Ye.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"});let Ke=class extends K{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:n,files:s}=this._parseHeader(i.data);if(-1===this.ioConfig.skipExtensions?.indexOf("aux.xml")){const t=await this._fetchAuxiliaryData(e);null!=t&&(n.statistics=t.statistics??n.statistics,n.histograms=t.histograms,t.histograms&&null==n.statistics&&(n.statistics=(0,se.Oh)(t.histograms)))}this._set("rasterInfo",n),this._files=s;const r=await this.request(s.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:u}=this.rasterInfo,h=[],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(u/o/l**d)-1;p+=(e+1)*(t+1)*f*4,h.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=h,d>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=d),this.updateTileInfo()}async fetchRawTile(e,t,i,n={}){const{blockWidth:s,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:u,actualTileWidth:h,actualTileHeight:f}=this._getTileLocation(e,t,i);if(!u||0===u.length)return null;if(0===u[0].from&&0===u[0].to){const e=new Uint8Array(s*r);return new ie.Z({width:s,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:u[y].from,to:u[y].to},responseType:"array-buffer",signal:n.signal}));const g=await Promise.all(m),x=g.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),w=new Uint8Array(x);let b=0;for(y=0;y<d;y++)w.set(new Uint8Array(g[y].data),b),b+=g[y].data.byteLength;const I=Ye.get(this.rasterInfo.storageInfo.compression).decoderFormat,v=await this.decodePixelBlock(w.buffer,{width:s,height:r,format:I,planes:p?.length||l,pixelType:c});if(null==v)return null;let{noDataValue:_}=this.rasterInfo;if(null!=_&&"lerc"!==I&&!v.mask&&(_=_[0],null!=_)){const e=v.width*v.height,t=new Uint8Array(e);if(Math.abs(_)>1e24)for(y=0;y<e;y++)Math.abs((v.pixels[0][y]-_)/_)>1e-6&&(t[y]=1);else for(y=0;y<e;y++)v.pixels[0][y]!==_&&(t[y]=1);v.mask=t}let S=0,R=0;if(h!==s||f!==r){let e=v.mask;if(e)for(y=0;y<r;y++)if(R=y*s,y<f)for(S=h;S<s;S++)e[R+S]=0;else for(S=0;S<s;S++)e[R+S]=0;else for(e=new Uint8Array(s*r),v.mask=e,y=0;y<f;y++)for(R=y*s,S=0;S<h;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,n,s,r,a;if(Ve.f){for(i=new Uint8Array(e),s=new ArrayBuffer(e.byteLength),n=new Uint8Array(s),r=0;r<e.byteLength/4;r++)for(a=0;a<4;a++)n[4*r+a]=i[4*r+3-a];t=new Uint32Array(s)}else t=new Uint32Array(e);return t}_getBandSegmentCount(){return Ye.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(e,t,i){const{blockWidth:n,blockHeight:s,pyramidScalingFactor:r}=this.rasterInfo.storageInfo,{width:a,height:o}=this.rasterInfo,l=this._getBandSegmentCount();let c,u,h,f=0,p=0;for(h=0;h<e;h++)p=r**h,c=Math.ceil(a/n/p),u=Math.ceil(o/s/p),f+=c*u;p=r**e,c=Math.ceil(a/n/p),u=Math.ceil(o/s/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?n:Math.ceil(a/p)-n*(c-1),actualTileHeight:t<u-1?s:Math.ceil(o/p)-s*(u-1)}}_parseHeader(e){const t=Oe(e,"MRF_META/Raster");if(!t)throw new r.Z("mrf:open","not a valid MRF format");const i=Oe(t,"Size"),n=parseInt(i.getAttribute("x"),10),s=parseInt(i.getAttribute("y"),10),a=parseInt(i.getAttribute("c"),10),o=(Pe(t,"Compression")||"none").toLowerCase();if(!Ye.has(o))throw new r.Z("mrf:open","currently does not support compression "+o);const l=Pe(t,"DataType")||"UInt8",c=Xe.get(l);if(null==c)throw new r.Z("mrf:open","currently does not support pixel type "+l);const u=Oe(t,"PageSize"),h=parseInt(u.getAttribute("x"),10),f=parseInt(u.getAttribute("y"),10),p=Oe(t,"DataValues");let d,m;if(p&&(m=p.getAttribute("NoData"),null!=m&&(d=m.trim().split(" ").map((e=>parseFloat(e))))),Oe(e,"MRF_META/CachedSource"))throw new r.Z("mrf:open","currently does not support MRF referencing other data files");const y=Oe(e,"MRF_META/GeoTags"),g=Oe(y,"BoundingBox");let x,w=!1;if(null!=g){const e=parseFloat(g.getAttribute("minx")),t=parseFloat(g.getAttribute("miny")),i=parseFloat(g.getAttribute("maxx")),n=parseFloat(g.getAttribute("maxy")),s=Pe(y,"Projection")||"";let r=ce.Z.WGS84;if("LOCAL_CS[]"!==s)if(s.toLowerCase().startsWith("epsg:")){const e=Number(s.slice(5));isNaN(e)||0===e||(r=new ce.Z({wkid:e}))}else r=Ae(s)??ce.Z.WGS84;else w=!0,r=new ce.Z({wkid:3857});x=new X.Z(e,t,i,n),x.spatialReference=r}else w=!0,x=new X.Z({xmin:-.5,ymin:.5-s,xmax:n-.5,ymax:.5,spatialReference:new ce.Z({wkid:3857})});const b=Oe(e,"MRF_META/Rsets"),I=parseInt(b&&b.getAttribute("scale")||"2",10),v=x.spatialReference,_=new Z.Z({origin:new A.Z({x:x.xmin,y:x.ymax,spatialReference:v}),blockWidth:h,blockHeight:f,pyramidBlockWidth:h,pyramidBlockHeight:f,compression:o,pyramidScalingFactor:I}),S=new A.Z({x:x.width/n,y:x.height/s,spatialReference:v}),R=new we.Z({width:n,height:s,extent:x,isPseudoSpatialReference:w,spatialReference:v,bandCount:a,pixelType:c,pixelSize:S,noDataValue:d,storageInfo:_}),T=Pe(e,"datafile"),C=Pe(e,"IndexFile");return{rasterInfo:R,files:{mrf:this.url,index:C||this.url.replace(".mrf",".idx"),data:T||this.url.replace(".mrf",Ye.get(o).blobExtension)}}}async _fetchAuxiliaryData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return Je(t)}catch{return null}}};(0,n._)([(0,u.Cb)()],Ke.prototype,"_files",void 0),(0,n._)([(0,u.Cb)()],Ke.prototype,"_storageIndex",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],Ke.prototype,"datasetFormat",void 0),Ke=(0,n._)([(0,m.j)("esri.layers.support.rasterIO.MRFRaster")],Ke);const Qe=Ke;var et=i(94793),tt=i(9832);const it=(e,t)=>e.get(t)?.values,nt=(e,t)=>e.get(t)?.values?.[0];let st=class extends K{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 r.Z("tiffraster:open","failed to open url "+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1,this.url.lastIndexOf("."));const{littleEndian:n,firstIFDPos:s,isBigTiff:a}=(0,et.cK)(i),o=[];await this._readIFDs(o,i,n,s,0,a?8:4,t);const{imageInfo:l,rasterInfo:c}=this._parseIFDs(o),u=(0,et.ee)(o),h=(0,et.I7)(o);if(this._headerInfo={littleEndian:n,isBigTiff:a,ifds:o,pyramidIFDs:u,maskIFDs:h,...l},this._set("rasterInfo",c),!l.isSupported)throw new r.Z("tiffraster:open","this tiff is not supported: "+l.message);if(!l.tileWidth)throw new r.Z("tiffraster:open","none-tiled tiff is not optimized for access, convert to COG and retry.");const{skipExtensions:f=[]}=this.ioConfig;if(!f.includes("aux.xml")){const t=await this._fetchAuxiliaryMetaData(e);null!=t&&this._processPAMInfo(t,c)}f.includes("vat.dbf")||1!==c.bandCount||"u8"!==c.pixelType||(c.attributeTable=await this._fetchAuxiliaryTable(e),null!=c.attributeTable&&(c.keyProperties.DataType="thematic")),this.updateTileInfo()}async fetchRawTile(e,t,i,n={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,i))return null;const s=await this._fetchRawTiffTile(e,t,i,!1,n);if(null!=s&&this._headerInfo.hasMaskBand){const r=await this._fetchRawTiffTile(e,t,i,!0,n);null!=r&&r.pixels[0]instanceof Uint8Array&&(s.mask=r.pixels[0])}return s}_parseIFDs(e){const t=(0,et.FI)(e),{width:i,height:n,tileWidth:s,tileHeight:r,planes:a,pixelType:o,compression:l,firstPyramidLevel:c,maximumPyramidLevel:u,pyramidBlockWidth:h,pyramidBlockHeight:f,tileBoundary:p,affine:d,metadata:m}=t;let y=Ae(t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid),g=!!t.isPseudoGeographic;null==y&&(g=!0,y=new ce.Z({wkid:3857}));const x=new X.Z({...t.extent,spatialReference:y}),w=new A.Z(x?{x:x.xmin,y:x.ymax,spatialReference:y}:{x:0,y:0}),b=new Z.Z({blockWidth:s,blockHeight:r,pyramidBlockWidth:h,pyramidBlockHeight:f,compression:l,origin:w,firstPyramidLevel:c,maximumPyramidLevel:u,blockBoundary:p}),I=new A.Z({x:(x.xmax-x.xmin)/i,y:(x.ymax-x.ymin)/n,spatialReference:y}),v=m?{BandProperties:m.bandProperties,DataType:m.dataType}:{};let _=null;const S=nt(e[0],"PHOTOMETRICINTERPRETATION"),R=it(e[0],"COLORMAP");if(S<=3&&R?.length>3&&R.length%3==0){_=[];const e=R.length/3;for(let t=0;t<e;t++)_.push([t,R[t]>>>8,R[t+e]>>>8,R[t+2*e]>>>8])}const T=new we.Z({width:i,height:n,bandCount:a,pixelType:o,pixelSize:I,storageInfo:b,spatialReference:y,isPseudoSpatialReference:g,keyProperties:v,extent:x,colormap:_,statistics:m?m.statistics:null});return d?.length&&(T.nativeExtent=new X.Z({xmin:-.5,ymin:.5-n,xmax:i-.5,ymax:.5,spatialReference:y}),T.transform=new Be.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 A.Z({x:(x.xmax-x.xmin)/i,y:(x.ymax-x.ymin)/n,spatialReference:y}),b.origin.x=-.5,b.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,se.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 A.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,n,s,r=4,a){if(!n)return null;(n>=t.byteLength||n<0)&&(t=(await this.request(this.url,{range:{from:n+s,to:n+s+this._bufferSize},responseType:"array-buffer",signal:a})).data,s=n+s,n=0);const o=await this._readIFD(t,i,n,s,tt.Z.TIFF_TAGS,r,a);if(e.push(o.ifd),!o.nextIFD)return null;await this._readIFDs(e,t,i,o.nextIFD-s,s,r,a)}async _readIFD(e,t,i,n,s=tt.Z.TIFF_TAGS,r=4,a){if(!e)return null;const o=(0,et.vr)(e,t,i,n,s,r);if(o.success){const i=[];if(o.ifd?.forEach((e=>{e.values||i.push(e)})),i.length>0){const s=i.map((e=>e.offlineOffsetSize)).filter(f.pC),r=Math.min.apply(null,s.map((e=>e[0])));if(Math.min.apply(null,s.map((e=>e[0]+e[1])))-r<=this._bufferSize){const{data:s}=await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:"array-buffer",signal:a});e=s,n=r,i.forEach((i=>(0,et.Dq)(e,t,i,n)))}}if(o.ifd?.has("GEOKEYDIRECTORY")){const i=o.ifd.get("GEOKEYDIRECTORY"),s=i?.values;if(s&&s.length>4){const r=s[0]+"."+s[1]+"."+s[2],o=await this._readIFD(e,t,i.valueOffset+6-n,n,tt.Z.GEO_KEYS,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:n,to:n+o.requiredBufferSize+4},responseType:"array-buffer",signal:a});return(e=i.data).byteLength<o.requiredBufferSize?null:this._readIFD(e,t,0,n,tt.Z.TIFF_TAGS,4,a)}}async _fetchRawTiffTile(e,t,i,n,s={}){const r=this._getTileLocation(e,t,i,n);if(!r)return null;const{ranges:a,actualTileWidth:o,actualTileHeight:l,ifd:c}=r,u=a.map((e=>this.request(this.url,{range:e,responseType:"array-buffer",signal:s.signal}))),h=await Promise.all(u),f=h.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),p=1===h.length?h[0].data:new ArrayBuffer(f),d=[0],m=[0];if(h.length>1){const e=new Uint8Array(p);for(let t=0,i=0;t<h.length;t++){const n=h[t].data;e.set(new Uint8Array(n),i),d[t]=i,i+=n.byteLength,m[t]=n.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,I;if(o!==y||l!==g){let e=x.mask;if(e)for(w=0;w<g;w++)if(I=w*y,w<l)for(b=o;b<y;b++)e[I+b]=0;else for(b=0;b<y;b++)e[I+b]=0;else for(e=new Uint8Array(y*g),x.mask=e,w=0;w<l;w++)for(I=w*y,b=0;b<o;b++)e[I+b]=1}return x}_getTileLocation(e,t,i,n=!1){const{firstPyramidLevel:s,blockBoundary:r}=this.rasterInfo.storageInfo,a=0===e?0:e-(s-1),{_headerInfo:o}=this;if(!o)return null;const l=n?o.maskIFDs[a]:0===a?o?.ifds[0]:o?.pyramidIFDs[a-1];if(!l)return null;const c=(0,et.If)(l,o),u=it(l,"TILEOFFSETS");if(void 0===u)return null;const h=it(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=nt(l,"IMAGEWIDTH"),g=nt(l,"IMAGELENGTH"),x=nt(l,"TILEWIDTH"),w=nt(l,"TILELENGTH"),b=c?this.rasterInfo.bandCount:1,I=b*t*(m+1)+i,v=[{from:u[I],to:u[I+b-1]+h[I+b-1]-1}];if(c){let e=!0;for(let t=0;t<b;t++)if(u[I+t]+h[I+t]!==u[I+t+1]){e=!1;break}if(!e)for(let e=0;e<b;e++)v[e]={from:u[I+e],to:u[I+e]+h[I+e]-1}}const _=u[I],S=h[I];return null==_||null==S?null:{ranges:v,ifd:l,actualTileWidth:i===m&&y%x||x,actualTileHeight:t===d&&g%w||w}}async _fetchAuxiliaryMetaData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return Je(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=ve.parse(t);return i?.recordSet?Se.Z.fromJSON(i.recordSet):null}catch{return null}}};(0,n._)([(0,u.Cb)()],st.prototype,"_files",void 0),(0,n._)([(0,u.Cb)()],st.prototype,"_headerInfo",void 0),(0,n._)([(0,u.Cb)()],st.prototype,"_bufferSize",void 0),(0,n._)([(0,u.Cb)({type:String,json:{write:!0}})],st.prototype,"datasetFormat",void 0),st=(0,n._)([(0,m.j)("esri.layers.support.rasterDatasets.TIFFRaster")],st);const rt=st,at=new Map;at.set("CRF",{desc:"Cloud Raster Format",constructor:Ce}),at.set("MRF",{desc:"Meta Raster Format",constructor:Qe}),at.set("TIFF",{desc:"GeoTIFF",constructor:rt}),at.set("RasterTileServer",{desc:"Raster Tile Server",constructor:$e}),at.set("JPG",{desc:"JPG Raster Format",constructor:He}),at.set("PNG",{desc:"PNG Raster Format",constructor:He}),at.set("GIF",{desc:"GIF Raster Format",constructor:He}),at.set("BMP",{desc:"BMP Raster Format",constructor:He});class ot{static get supportedFormats(){const e=new Set;return at.forEach(((t,i)=>e.add(i))),e}static async open(e){const{url:t,ioConfig:i,sourceJSON:n}=e;let s=e.datasetFormat;null==s&&t.lastIndexOf(".")&&(s=t.slice(t.lastIndexOf(".")+1).toUpperCase()),"OVR"===s||"TIF"===s?s="TIFF":"JPG"!==s&&"JPEG"!==s&&"JFIF"!==s||(s="JPG"),t.toLowerCase().includes("/imageserver")&&!t.toLowerCase().includes("/wcsserver")&&(s="RasterTileServer");const a={url:t,sourceJSON:n,datasetFormat:s,ioConfig:i??{bandIds:null,sampling:null}};let o,l;if(s&&this.supportedFormats.has(s)){if("CRF"===s&&!i?.enableCRF)throw new r.Z("rasterfactory:open",`cannot open raster: ${t}`);return o=at.get(s).constructor,l=new o(a),await l.open({signal:e.signal}),l}if(s)throw new r.Z("rasterfactory:open","not a supported format "+s);const c=Array.from(at.keys());let u=0;const h=()=>(s=c[u++],s&&("CRF"!==s||i?.enableCRF)?(o=at.get(s).constructor,l=new o(a),l.open({signal:e.signal}).then((()=>l)).catch((()=>h()))):null);return h()}static register(e,t,i){at.has(e.toUpperCase())||at.set(e.toUpperCase(),{desc:t,constructor:i})}}var lt=i(32163);let ct=class extends((0,x.h)((0,me.M)((0,fe.q)((0,pe.I)((0,w.N)(he((0,ye.n)((0,g.Y)((0,de.Q)((0,o.R)(y.Z))))))))))){constructor(...e){super(...e),this._primaryRasters=null,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}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(l.r9).then((()=>this._openRaster(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[new ge.Z({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"}),new ge.Z({name:"Raster.ServicePixelValue.Raw",alias:"Raw Pixel Value",domain:null,editable:!1,length:50,type:"string"})],{rasterInfo:t}=this,i=t?.attributeTable,n=null!=i?i.fields:null;if(n){const t=n.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 s=t?.dataType,r=t?.multidimensionalInfo;if(("vector-magdir"===s||"vector-uv"===s)&&null!=r){const t=r.variables[0].unit?.trim(),i="Magnitude"+(t?` (${t})`:"");e.push(new ge.Z({name:"Raster.Magnitude",alias:i,domain:null,editable:!1,type:"double"})),e.push(new ge.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,lt.eZ)({fields:t,title:this.title},{...e,visibleFieldNames:i})}async generateRasterInfo(e,t){if(!(e=(0,h.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 n=(0,ne.Ue)(e.rasterFunctionDefinition??e.toJSON(),i),s=new ee({rasterFunction:n});return await s.open(t),s.rasterInfo}catch(e){if(e instanceof r.Z)throw e;throw new r.Z("imagery-tile-layer","the given raster function is not supported")}}write(e,t){const{raster:i}=this;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&&t.messages){const e=`${t.origin}/${t.layerContainerType||"operational-layers"}`;t.messages.push(new r.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)this.raster.rasterInfo||await this.raster.open(),"Function"===this.raster.datasetFormat?(t=!0,this._primaryRasters=this.raster.primaryRasters.rasters):this._primaryRasters=[this.raster],this.url=this.raster.url;else{const{rasterFunction:t}=this,i=[this.url];t&&(0,ne.G8)(t.toJSON(),i);const n=await Promise.all(i.map((t=>ot.open({url:t,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:e})))),s=n.findIndex((e=>null==e));if(s>-1)throw new r.Z("imagery-tile-layer:open",`cannot open raster: ${i[s]}`);if(this._primaryRasters=n,t){const e={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((t=>e[t.url]=t));const i=(0,ne.Ue)(t.rasterFunctionDefinition??t.toJSON(),e),s=new ee({rasterFunction:i});try{await s.open(),this.raster=s}catch(e){const t=a.Z.getLogger(this);e instanceof r.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]}}else this.raster=n[0]}const i=this.raster.rasterInfo;if(!i)throw new r.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,c.YP)((()=>this.customParameters),(e=>{this.raster&&(this.raster.ioConfig.customFetchParameters=e)})))}};(0,n._)([(0,u.Cb)()],ct.prototype,"_primaryRasters",void 0),(0,n._)([(0,u.Cb)({type:[h.z8],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],ct.prototype,"bandIds",void 0),(0,n._)([(0,u.Cb)({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),(0,d.J)(xe.c)],ct.prototype,"interpolation",void 0),(0,n._)([(0,u.Cb)(R.rn)],ct.prototype,"legendEnabled",void 0),(0,n._)([(0,u.Cb)({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],ct.prototype,"isReference",void 0),(0,n._)([(0,u.Cb)({type:["show","hide"]})],ct.prototype,"listMode",void 0),(0,n._)([(0,u.Cb)({json:{read:!0,write:!0}})],ct.prototype,"blendMode",void 0),(0,n._)([(0,u.Cb)()],ct.prototype,"sourceJSON",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,json:{origins:{service:{read:{source:"currentVersion"}}}}})],ct.prototype,"version",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,json:{read:!1}})],ct.prototype,"type",void 0),(0,n._)([(0,u.Cb)({type:["ArcGISTiledImageServiceLayer"]})],ct.prototype,"operationalLayerType",void 0),(0,n._)([(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}}}})],ct.prototype,"popupEnabled",void 0),(0,n._)([(0,u.Cb)({type:s.Z,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}}}}})],ct.prototype,"popupTemplate",void 0),(0,n._)([(0,u.Cb)({readOnly:!0})],ct.prototype,"defaultPopupTemplate",null),(0,n._)([(0,u.Cb)({readOnly:!0,type:[ge.Z]})],ct.prototype,"fields",void 0),(0,n._)([(0,u.Cb)({readOnly:!0,type:[ge.Z]})],ct.prototype,"rasterFields",null),ct=(0,n._)([(0,m.j)("esri.layers.ImageryTileLayer")],ct);const ut=ct},39450:(e,t,i)=>{i.d(t,{Z:()=>u});var n,s=i(43697),r=i(96674),a=i(5600),o=i(75215),l=(i(67676),i(80442),i(52011));let c=n=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 n({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,s._)([(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,s._)([(0,a.Cb)({type:o.z8,json:{write:!0}})],c.prototype,"level",void 0),(0,s._)([(0,a.Cb)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,s._)([(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,s._)([(0,a.Cb)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,s._)([(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,s._)([(0,a.Cb)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=n=(0,s._)([(0,l.j)("esri.layers.support.LOD")],c);const u=c},11145:(e,t,i)=>{i.d(t,{Z:()=>S});var n,s=i(43697),r=i(35454),a=i(96674),o=i(67900),l=i(5600),c=i(75215),u=(i(67676),i(80442),i(71715)),h=i(52011),f=i(30556),p=i(94139),d=i(82971),m=i(24470),y=i(8744),g=i(40488),x=i(39450),w=i(43077);const b=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 I=n=class extends a.wq{static create(e={}){const{resolutionFactor:t=1,scales:i,size:s=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 n=i[t];e.push(new x.Z({level:t,scale:n,resolution:n}))}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 n({dpi:96,lods:e,origin:new p.Z(0,0,r),size:[s,s],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}),u=1/(39.37*(0,o.c9)(r)*96),h=[];if(i)for(let e=0;e<i.length;e++){const t=i[e],n=t*u;h.push(new x.Z({level:e,scale:t,resolution:n}))}else{let e=(0,y.sT)(r)?512/s*591657527.5917094:256/s*591657527.591555;const i=Math.ceil(a/t);h.push(new x.Z({level:0,scale:e,resolution:e*u}));for(let n=1;n<i;n++){const i=e/2**t,s=i*u;h.push(new x.Z({level:n,scale:i,resolution:s})),e=i}}return new n({dpi:96,lods:h,origin:c,size:[s,s],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 n=[],s=this._levelToLOD={};e&&(t=-1/0,i=1/0,e.forEach((e=>{n.push(e.scale),t=e.scale>t?e.scale:t,i=e.scale<i?e.scale:i,s[e.level]=e}))),this._set("scales",n),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),n=i+1;return t[i]/(t[i]/t[n])**(e-i)}scaleToZoom(e){const t=this.scales,i=t.length-1;let n=0;for(;n<i;n++){const i=t[n],s=t[n+1];if(i<=e)return n;if(s===e)return n+1;if(i>e&&s<e)return n+Math.log(i/e)/Math.log(i/s)}return n}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,n){const s=this.lodAt(e);if(!s)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,n=i;else{const e=(0,g.iV)(t,this.spatialReference);if(null==e)return null;r=e.x,a=e.y,n=i}const o=s.resolution*this.size[0],l=s.resolution*this.size[1];return n||(n=new w.f(null,0,0,0,(0,m.Ue)())),n.level=e,n.row=Math.floor((this.origin.y-a)/l+.001),n.col=Math.floor((r-this.origin.x)/o+.001),this.updateTileInfo(n),n}updateTileInfo(e,t=n.ExtrapolateOptions.NONE){let i=this.lodAt(e.level);if(!i&&t===n.ExtrapolateOptions.POWER_OF_TWO){const t=this.lods[this.lods.length-1];t.level<e.level&&(i=t)}if(!i)return;const s=e.level-i.level,r=i.resolution*this.size[0]/2**s,a=i.resolution*this.size[1]/2**s;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:n}=i,s=n*this.size[0],r=n*this.size[1];return e[0]=this.origin.x+t.col*s,e[1]=this.origin.y-(t.row+1)*r,e[2]=e[0]+s,e[3]=e[1]+r,e}lodAt(e){return this._levelToLOD?.[e]??null}clone(){return n.fromJSON(this.write({}))}getOrCreateCompatible(e,t){if(256===this.size[0]&&256===this.size[1])return 256===e?this:null;const i=[],s=this.lods.length;for(let e=0;e<s;e++){const n=this.lods[e],s=n.resolution*t;i.push(new x.Z({level:n.level,scale:n.scale,resolution:s}))}return new n({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 n=e[i];this._upsampleLevels[n.level]={parentLevel:t?t.level:-1,factor:t?t.resolution/n.resolution:0},t=n}}};var v,_;(0,s._)([(0,l.Cb)({type:Number,json:{write:!0}})],I.prototype,"compressionQuality",void 0),(0,s._)([(0,l.Cb)({type:Number,json:{write:!0}})],I.prototype,"dpi",void 0),(0,s._)([(0,l.Cb)({type:String,json:{read:b.read,write:b.write,origins:{"web-scene":{read:!1,write:!1}}}})],I.prototype,"format",void 0),(0,s._)([(0,l.Cb)({readOnly:!0})],I.prototype,"isWrappable",null),(0,s._)([(0,l.Cb)({type:p.Z,json:{write:!0}})],I.prototype,"origin",void 0),(0,s._)([(0,u.r)("origin")],I.prototype,"readOrigin",null),(0,s._)([(0,l.Cb)({type:[x.Z],value:null,json:{write:!0}})],I.prototype,"lods",null),(0,s._)([(0,l.Cb)({readOnly:!0})],I.prototype,"scales",void 0),(0,s._)([(0,l.Cb)({cast:e=>Array.isArray(e)?e:"number"==typeof e?[e,e]:[256,256]})],I.prototype,"size",void 0),(0,s._)([(0,u.r)("size",["rows","cols"])],I.prototype,"readSize",null),(0,s._)([(0,f.c)("size",{cols:{type:c.z8},rows:{type:c.z8}})],I.prototype,"writeSize",null),(0,s._)([(0,l.Cb)({type:d.Z,json:{write:!0}})],I.prototype,"spatialReference",void 0),I=n=(0,s._)([(0,h.j)("esri.layers.support.TileInfo")],I),v=I||(I={}),(_=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[_.NONE=0]="NONE",_[_.POWER_OF_TWO=1]="POWER_OF_TWO";const S=I},43077:(e,t,i)=>{i.d(t,{f:()=>n});class n{constructor(e,t,i,n,s=void 0){this.id=e,this.level=t,this.row=i,this.col=n,this.extent=s}}},28589:(e,t,i)=>{i.d(t,{y:()=>S});var n,s=i(43697),r=i(3172),a=i(92036),o=i(91303),l=i(20102),c=i(50758),u=i(13867),h=i(44553),f=i(95330),p=i(17445),d=i(1654),m=i(81271),y=i(5600),g=(i(75215),i(67676)),x=(i(80442),i(52011)),w=i(43077),b=i(22974),I=i(1533);class v{constructor(e){this._validateJSON(e);const{location:t,data:i}=e;this.location=Object.freeze((0,b.d9)(t));const n=this.location.width,s=this.location.height;let r=!0,a=!0;const o=function(e,t=!1){return e<=I.DB?t?new Array(e).fill(0):new Array(e):new Uint32Array(e)}(Math.ceil(n*s/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,I.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),n=i%32,s=i>>5,r=this._availability;return s<0||s>r.length?"unknown":r[s]&1<<n?"available":"unavailable"}static fromDefinition(e,t){const i=e.service.request||r.default,{row:n,col:s,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:n,left:s,width:a,height:o},valid:!0,data:(0,g.a9)(a*o,0)};throw e})).then((e=>{if(e.location&&(e.location.top!==n||e.location.left!==s||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:n,left:s,width:a,height:o}});return v.fromJSON(e)}))}static fromJSON(e){return Object.freeze(new v(e))}_validateJSON(e){if(!e||!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 _(e){return`${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`}let S=n=class extends a.Z{constructor(e){super(e),this._pendingTilemapRequests={},this.request=r.default,this.size=32,this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new u.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,n){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 s=this._tmpTilemapDefinition,r=this._tilemapFromCache(e,t,i,s);if(r)return Promise.resolve(r);const a=n&&n.signal;return n={...n,signal:null},new Promise(((e,t)=>{(0,f.fu)(a,(()=>t((0,f.zE)())));const i=_(s);let r=this._pendingTilemapRequests[i];if(!r){r=v.fromDefinition(s,n).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 n=this._tilemapFromCache(e,t,i,this._tmpTilemapDefinition);return n?n.getAvailability(t,i):"unknown"}fetchAvailability(e,t,i,n){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,n).catch((e=>e)).then((n=>{if(n instanceof v){const s=n.getAvailability(t,i);if("unavailable"===s)throw new l.Z("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i});return s}if((0,f.D_)(n))throw n;return"unknown"}))}fetchAvailabilityUpsample(e,t,i,n,s){n.level=e,n.row=t,n.col=i;const r=this.layer.tileInfo;r.updateTileInfo(n);const a=this.fetchAvailability(e,t,i,s).catch((e=>{if((0,f.D_)(e))throw e;if(r.upsampleTile(n))return this.fetchAvailabilityUpsample(n.level,n.row,n.col,n,s);throw e}));return this._fetchAvailabilityUpsamplePrefetch(n.id,e,t,i,s,a),a}async _fetchAvailabilityUpsamplePrefetch(e,t,i,s,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 u=!1;const h=(0,c.kB)((()=>{u||(u=!0,l.abort())}));if(this.addHandles(h,o),await(0,d.MU)(10,l.signal).catch((()=>{})),u||(u=!0,this.removeHandles(o)),(0,f.Hc)(l))return;const p=new w.f(e,t,i,s),m={...r,signal:l.signal},y=this.layer.tileInfo;for(let e=0;n._prefetches.length<n._maxPrefetch&&y.upsampleTile(p);++e){const e=this.fetchAvailability(p.level,p.row,p.col,m);n._prefetches.push(e);const t=()=>{n._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,n){n.level=e,n.row=t-t%this.size,n.col=i-i%this.size;const s=_(n);return this._tilemapCache.get(s)}get test(){const e=this;return{get prefetchingEnabled(){return e._prefetchingEnabled},set prefetchingEnabled(t){e._prefetchingEnabled=t},hasTilemap:(t,i,n)=>!!e._tilemapFromCache(t,i,n,e._tmpTilemapDefinition)}}};S._maxPrefetch=4,S._prefetches=new h.Z({initialSize:n._maxPrefetch}),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"layer",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"minLOD",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"maxLOD",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"request",void 0),(0,s._)([(0,y.Cb)({constructOnly:!0})],S.prototype,"size",void 0),S=n=(0,s._)([(0,x.j)("esri.layers.support.TilemapCache")],S)},11282:(e,t,i)=>{i.d(t,{cv:()=>o,en:()=>a,lA:()=>r}),i(68773),i(40330);var n=i(22974),s=i(81271);function r(e,t){return t?{...t,query:{...e??{},...t.query}}:{query:e}}function a(e){return"string"==typeof e?(0,s.mN)(e):(0,n.d9)(e)}function o(e,t,i){const n={};for(const s in e){if("declaredClass"===s)continue;const r=e[s];if(null!=r&&"function"!=typeof r)if(Array.isArray(r)){n[s]=[];for(let e=0;e<r.length;e++)n[s][e]=o(r[e])}else if("object"==typeof r)if(r.toJSON){const e=r.toJSON(i&&i[s]);n[s]=t?e:JSON.stringify(e)}else n[s]=t?r:JSON.stringify(r);else n[s]=r}return n}i(71058)}}]);