@arcgis/core 5.2.0-next.155 → 5.2.0-next.156

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 (162) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{d994bcf0a65d1c07160f.js → 0320cbd825f9a4222042.js} +1 -1
  3. package/assets/esri/core/workers/chunks/0590857215c547e63b51.js +1 -0
  4. package/assets/esri/core/workers/chunks/08fe248e412bb170210d.js +1 -0
  5. package/assets/esri/core/workers/chunks/0cb50bc2b2125c5fedf2.js +1 -0
  6. package/assets/esri/core/workers/chunks/1201b8c5852830836eac.js +1 -0
  7. package/assets/esri/core/workers/chunks/129e04d24ced77c9bb6d.js +1 -0
  8. package/assets/esri/core/workers/chunks/15e1117a706a98b17ad5.js +1 -0
  9. package/assets/esri/core/workers/chunks/164e74d586297946a717.js +1 -0
  10. package/assets/esri/core/workers/chunks/168a523bdc3653081f8a.js +1 -0
  11. package/assets/esri/core/workers/chunks/{6f4e6022a52de0c54aab.js → 172cfeb5f415e4662432.js} +1 -1
  12. package/assets/esri/core/workers/chunks/1aa4f5394a596e544aeb.js +1 -0
  13. package/assets/esri/core/workers/chunks/22b01fe31bbf0bdc48db.js +1 -0
  14. package/assets/esri/core/workers/chunks/27c2da2e779def2ee08b.js +1 -0
  15. package/assets/esri/core/workers/chunks/{481589c3eddad6e026ad.js → 369780276b2755361f7d.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{2a226b69d38c72a47a08.js → 3914d96147642a9d4b01.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{731018c0deffc41ffc97.js → 3e3e076fa5e8d5d5f33f.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{96b6ea199ad949fef17c.js → 43cf862577bf37344ff4.js} +1 -1
  19. package/assets/esri/core/workers/chunks/4932773663469919d10a.js +1 -0
  20. package/assets/esri/core/workers/chunks/4996869b9cbd8c8ddcfa.js +1 -0
  21. package/assets/esri/core/workers/chunks/4c389472b8cdb0c55154.js +1 -0
  22. package/assets/esri/core/workers/chunks/4e4f747de424941a0bfa.js +1 -0
  23. package/assets/esri/core/workers/chunks/{eb815148ae65388dd733.js → 544070198d2ca556103a.js} +1 -1
  24. package/assets/esri/core/workers/chunks/5736feefa261589b6273.js +1 -0
  25. package/assets/esri/core/workers/chunks/{aeaaff7a4b1a99540f52.js → 5cb26bbaa08114aec5ce.js} +1 -1
  26. package/assets/esri/core/workers/chunks/6f73e41e14817acfaead.js +1 -0
  27. package/assets/esri/core/workers/chunks/{320e5942a098dd104366.js → 74137ffec5265628c33b.js} +1 -1
  28. package/assets/esri/core/workers/chunks/7446d0dfebf93e86c098.js +1 -0
  29. package/assets/esri/core/workers/chunks/{688f2dbf784e66082308.js → 74c866e0b66e61751861.js} +1 -1
  30. package/assets/esri/core/workers/chunks/7711ae5612f685078fc8.js +1 -0
  31. package/assets/esri/core/workers/chunks/{5116b569a8dbda4910c8.js → 784a2fba3e18286958d1.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{f6e62d2d279a328cbed7.js → 7bcedf479b07a4b4a234.js} +1 -1
  33. package/assets/esri/core/workers/chunks/842893e75696428d536f.js +1 -0
  34. package/assets/esri/core/workers/chunks/8e19629899a5becf8e19.js +1 -0
  35. package/assets/esri/core/workers/chunks/950d4578dc450467404c.js +1 -0
  36. package/assets/esri/core/workers/chunks/{68be3fb88ca61f82fb90.js → 95dbbddac6581b9d671f.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{900181f68449d8f82eeb.js → aa1ac7954e4f0fefe15b.js} +1 -1
  38. package/assets/esri/core/workers/chunks/ac24b4370dc7194a3107.js +1 -0
  39. package/assets/esri/core/workers/chunks/ace2e0a9d9013edd8624.js +1 -0
  40. package/assets/esri/core/workers/chunks/b1d5d236d5268fcbc74b.js +1 -0
  41. package/assets/esri/core/workers/chunks/{49ff0985fb307ac193ab.js → b573df59391ca41ee5a7.js} +1 -1
  42. package/assets/esri/core/workers/chunks/bac8c32665e982896ecc.js +1 -0
  43. package/assets/esri/core/workers/chunks/{f3da30d7300b92bd8bb0.js → befa32b9e7b3fbdd431e.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{6c469b43089767176ced.js → c5ed67fdf261cbb1624b.js} +1 -1
  45. package/assets/esri/core/workers/chunks/d9b1aed88b205689cec6.js +1 -0
  46. package/assets/esri/core/workers/chunks/{c598b22f78ccc57f9d6d.js → dfd2dc5cdc97ffba8926.js} +1 -1
  47. package/assets/esri/core/workers/chunks/e1b7806ab3e1967b15f0.js +1 -0
  48. package/assets/esri/core/workers/chunks/eaddffcc7004101fc230.js +1 -0
  49. package/assets/esri/core/workers/chunks/eb2652ec48faa78de3c5.js +1 -0
  50. package/assets/esri/core/workers/chunks/{c62738f84c914671b143.js → f4a7aa3cdbc0c429c359.js} +1 -1
  51. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -0
  52. package/assets/esri/themes/dark/main.css +1 -1
  53. package/assets/esri/themes/light/main.css +1 -1
  54. package/assets/esri/themes/light/view.css +1 -1
  55. package/config.d.ts +2 -0
  56. package/config.js +1 -1
  57. package/core/ObjectPool.js +1 -1
  58. package/core/PooledArray.js +1 -1
  59. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  60. package/geometry/support/buffer/BufferPool.js +1 -1
  61. package/geometry/support/coordsUtils.js +1 -1
  62. package/kernel.js +1 -1
  63. package/layers/AnnotationFeatureLayer.d.ts +2 -2
  64. package/layers/AnnotationFeatureLayer.js +1 -1
  65. package/layers/CatalogLayer.d.ts +2 -2
  66. package/layers/CatalogLayer.js +1 -1
  67. package/layers/DimensionFeatureLayer.d.ts +2 -2
  68. package/layers/DimensionFeatureLayer.js +1 -1
  69. package/layers/FeatureLayer.d.ts +2 -2
  70. package/layers/FeatureLayer.js +1 -1
  71. package/layers/SubtypeGroupLayer.d.ts +2 -2
  72. package/layers/SubtypeGroupLayer.js +1 -1
  73. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  74. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +9 -9
  75. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  76. package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
  77. package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
  78. package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
  79. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  80. package/layers/graphics/sources/parquet/FileProvider.js +1 -1
  81. package/layers/mixins/{FeatureLayerReload.d.ts → ReloadableLayer.d.ts} +5 -3
  82. package/layers/mixins/ReloadableLayer.js +2 -0
  83. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  84. package/layers/raster/datasets/BaseRaster.js +1 -1
  85. package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
  86. package/layers/raster/datasets/ImageAuxRaster.js +1 -1
  87. package/layers/raster/datasets/ImageServerRaster.js +1 -1
  88. package/layers/raster/datasets/MRFRaster.js +1 -1
  89. package/layers/raster/datasets/TIFFRaster.js +1 -1
  90. package/layers/raster/datasets/WCSRaster.js +1 -1
  91. package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
  92. package/layers/raster/formats/RasterCodec.js +1 -1
  93. package/layers/raster/formats/TiffDecoder.js +1 -1
  94. package/layers/raster/formats/Zlib.js +1 -1
  95. package/layers/support/RasterWorker.js +1 -1
  96. package/package.json +2 -2
  97. package/popup/FeatureModel.js +1 -1
  98. package/popup/FeaturesModel.js +1 -1
  99. package/request/process.js +1 -1
  100. package/request/types.d.ts +7 -0
  101. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
  102. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  103. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  104. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  105. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  106. package/views/3d/analysis/LineOfSight/{LineOfSightRootPlugin.js → LineOfSightPlacementRootPlugin.js} +1 -1
  107. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  108. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  109. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  110. package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
  111. package/views/3d/support/MemoryController.js +1 -1
  112. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  113. package/views/3d/webgl-engine/effects/geometry/RenderOccluded.js +1 -1
  114. package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
  115. package/widgets/HistogramRangeSlider.d.ts +2 -2
  116. package/widgets/HistogramRangeSlider.js +1 -1
  117. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  118. package/widgets/OrientedImageryViewer.js +2 -2
  119. package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
  120. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.d.ts +5 -2
  121. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  122. package/widgets/ScaleRangeSlider.js +1 -1
  123. package/widgets/ValuePicker/ValuePickerBaseComponent.d.ts +5 -1
  124. package/widgets/ValuePicker/ValuePickerCollection.d.ts +2 -0
  125. package/widgets/ValuePicker/ValuePickerCombobox.d.ts +7 -1
  126. package/widgets/ValuePicker/ValuePickerLabel.d.ts +7 -1
  127. package/widgets/ValuePicker/ValuePickerSlider.d.ts +2 -0
  128. package/widgets/ValuePicker/ValuePickerSliderVisibleElements.d.ts +5 -1
  129. package/widgets/ValuePicker/ValuePickerVisibleElements.d.ts +5 -1
  130. package/widgets/ValuePicker/types.d.ts +2 -0
  131. package/assets/esri/core/workers/chunks/03261b9451e293a0fac8.js +0 -1
  132. package/assets/esri/core/workers/chunks/0ad0484ffcbe4ad21bd3.js +0 -1
  133. package/assets/esri/core/workers/chunks/19743dedaa40446259ec.js +0 -1
  134. package/assets/esri/core/workers/chunks/1c65ab9ed611c322ce27.js +0 -1
  135. package/assets/esri/core/workers/chunks/1f339247b68b061ab0a4.js +0 -1
  136. package/assets/esri/core/workers/chunks/251921cd10ecfbc89451.js +0 -1
  137. package/assets/esri/core/workers/chunks/3252b1fae363bb0129a0.js +0 -1
  138. package/assets/esri/core/workers/chunks/408e81c8f1eff8a7b379.js +0 -1
  139. package/assets/esri/core/workers/chunks/50036a323c2e7f155311.js +0 -1
  140. package/assets/esri/core/workers/chunks/55dcbf296d8d0092e473.js +0 -1
  141. package/assets/esri/core/workers/chunks/59b216b60464611742d4.js +0 -1
  142. package/assets/esri/core/workers/chunks/5bfea0c55aca826de536.js +0 -1
  143. package/assets/esri/core/workers/chunks/60d3056a31d982c9cad0.js +0 -1
  144. package/assets/esri/core/workers/chunks/6558488ea96620439f34.js +0 -1
  145. package/assets/esri/core/workers/chunks/6aebf7cfd294e88bf926.js +0 -1
  146. package/assets/esri/core/workers/chunks/6b43bb78f9839ed43135.js +0 -1
  147. package/assets/esri/core/workers/chunks/6c83398cf586ecea0eb1.js +0 -1
  148. package/assets/esri/core/workers/chunks/7267b17de212207142c9.js +0 -1
  149. package/assets/esri/core/workers/chunks/88c74f3316f1fc253207.js +0 -1
  150. package/assets/esri/core/workers/chunks/912080c90b5cc2e817cf.js +0 -1
  151. package/assets/esri/core/workers/chunks/a97d85774f9a417202df.js +0 -1
  152. package/assets/esri/core/workers/chunks/aff32980d91dab07dfb7.js +0 -1
  153. package/assets/esri/core/workers/chunks/b1b4066e8d1c0c9656e5.js +0 -1
  154. package/assets/esri/core/workers/chunks/b6ba66a05030d3815dfd.js +0 -1
  155. package/assets/esri/core/workers/chunks/bbec9d2e3b75a5c59681.js +0 -1
  156. package/assets/esri/core/workers/chunks/bf69024804ac51c8f733.js +0 -1
  157. package/assets/esri/core/workers/chunks/c1254cd131a62750ff6f.js +0 -1
  158. package/assets/esri/core/workers/chunks/d938987344bce83cc660.js +0 -1
  159. package/assets/esri/core/workers/chunks/db1ab9b9c8bf5c7635d3.js +0 -1
  160. package/assets/esri/core/workers/chunks/fd9663952d5a94f3a83f.js +0 -1
  161. package/layers/mixins/FeatureLayerReload.js +0 -2
  162. /package/views/3d/analysis/LineOfSight/{lineOfSightPlacementUtils.js → placementUtils.js} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseFieldValues as g,isBSQConfig as _,getTagNumericValues as v,getTagFirstNumericValue as y,getImageInfo as b}from"../formats/tiffParser.js";import{tiffTags as x,geoKeys as S}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as C}from"../functions/stretchUtils.js";import w from"../transforms/PolynomialTransform.js";import T from"../../support/RasterInfo.js";import E from"../../support/RasterStorageInfo.js";import D from"../../../rest/support/FeatureSet.js";const O=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let k=class extends c{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this._chunkSize=10*1024**2,this.datasetFormat=`TIFF`}async fetchRawTile(e,t,n,r={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this._headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){let r=e?e.signal:null,{data:i}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:`array-buffer`,signal:r});if(!i)throw new t(`tiffraster:open`,`failed to open url `+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`));let{littleEndian:a,firstIFDPos:o,isBigTiff:s}=f(i),c=[],l={fileChunk:i,posIFD:o,fileOffset:0};await this._readIFDs(c,l,a,s?8:4,r);let{imageInfo:u,rasterInfo:d}=A(c),h=p(c),g=m(c);if(this._headerInfo={littleEndian:a,isBigTiff:s,ifds:c,pyramidIFDs:h,maskIFDs:g,...u},this._set(`rasterInfo`,d),!u.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+u.message);if(!u.tileWidth||!u.tileHeight)throw new t(`tiffraster:open`,O);d.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let _=c[0].get(`PREDICTOR`)?.values?.[0];if(c[0].get(`SAMPLEFORMAT`)?.values?.[0]===3&&_===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`);let{skipMapInfo:v,skipExtensions:y=[]}=this.ioConfig;if(!y.includes(`aux.xml`)&&!v){let t=await this._fetchAuxiliaryMetaData(e);t!=null&&j(t,d)}!y.includes(`vat.dbf`)&&d.bandCount===1&&d.pixelType===`u8`&&!v&&(d.attributeTable=await this._fetchAuxiliaryTable(e),d.attributeTable!=null&&(d.keyProperties.DataType=`thematic`)),v&&this.updateImageSpaceRasterInfo(d),this.updateTileInfo()}async _validateOrFetchHeaderBuffer(e,t){let{fileChunk:n,fileOffset:r,posIFD:i}=e;return(i+8>=n.byteLength||i<0)&&(r=i+r,n=(await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:`array-buffer`,signal:t})).data,i=0),{fileChunk:n,fileOffset:r,posIFD:i}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,x,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=x,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===x&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,O);let i=[];if(e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),e.has(`GEOKEYDIRECTORY`)){let t=e.get(`GEOKEYDIRECTORY`),r=t?.values;if(r&&r.length>4){let e=r[0]+`.`+r[1]+`.`+r[2];s=t.valueOffset+6-c;let i=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);t.data=(await this._readIFD(i,n,S,2,a))?.ifd,t.data&&t.data.set(`GEOTIFFVersion`,{id:0,type:2,valueCount:1,valueOffset:null,values:[e]})}}return l}return l.requiredBufferSize?(o=(await this.request(this.url,{range:{from:c,to:c+s+l.requiredBufferSize+8},responseType:`array-buffer`,signal:a})).data,o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=await this._fetchOffsets(o,Math.max(s,o+this._bufferSize),r);i.forEach(n=>g(e,t,n,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchOffsets(n[0],n[1]+n[0],r);g(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize,a=Math.ceil((t-e)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(a===1)return s[0].data;let c=new Uint8Array(t-e+1);for(let e=0;e<a;e++)c.set(new Uint8Array(s[e].data),e*i);return c.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{_headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=_(c,s),u=v(c,`TILEOFFSETS`),d=v(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=y(c,`IMAGEWIDTH`),b=y(c,`IMAGELENGTH`),x=y(c,`TILEWIDTH`),S=y(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%x||x,actualTileHeight:t===m&&b%S||S}}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?D.fromJSON(n.recordSet):null}catch{return null}}};e([r()],k.prototype,`_files`,void 0),e([r()],k.prototype,`_headerInfo`,void 0),e([r()],k.prototype,`_bufferSize`,void 0),e([r()],k.prototype,`_chunkSize`,void 0),e([r({type:String,json:{write:!0}})],k.prototype,`datasetFormat`,void 0),k=e([i(`esri.layers.raster.datasets.TIFFRaster`)],k);function A(e){let t=b(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:x,colormap:S}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,D=d(C),O=!!t.isPseudoGeographic;D??=(O=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:D}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:D}):new o({x:0,y:0}),j=new E({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),N=x?{BandProperties:x.bandProperties,DataType:x.dataType}:{},P=new T({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:D,isPseudoSpatialReference:O,keyProperties:N,extent:k,colormap:S,statistics:x?x.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:D}),P.transform=new w({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function j(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=C(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const M=k;export{M as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseFieldValues as g,isBSQConfig as _,getTagNumericValues as v,getTagFirstNumericValue as y,getImageInfo as b}from"../formats/tiffParser.js";import{tiffTags as x,geoKeys as S}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as C}from"../functions/stretchUtils.js";import w from"../transforms/PolynomialTransform.js";import T from"../../support/RasterInfo.js";import E from"../../support/RasterStorageInfo.js";import D from"../../../rest/support/FeatureSet.js";const O=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let k=class extends c{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this._chunkSize=10*1024**2,this.datasetFormat=`TIFF`}async fetchRawTile(e,t,n,r={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this._headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){let r=e?e.signal:null,{data:i}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:`array-buffer`,signal:r});if(!i)throw new t(`tiffraster:open`,`failed to open url `+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`));let{littleEndian:a,firstIFDPos:o,isBigTiff:s}=f(i),c=[],l={fileChunk:i,posIFD:o,fileOffset:0};await this._readIFDs(c,l,a,s?8:4,r);let{imageInfo:u,rasterInfo:d}=A(c),h=p(c),g=m(c);if(this._headerInfo={littleEndian:a,isBigTiff:s,ifds:c,pyramidIFDs:h,maskIFDs:g,...u},this._set(`rasterInfo`,d),!u.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+u.message);if(!u.tileWidth||!u.tileHeight)throw new t(`tiffraster:open`,O);d.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let _=c[0].get(`PREDICTOR`)?.values?.[0];if(c[0].get(`SAMPLEFORMAT`)?.values?.[0]===3&&_===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`);let{skipMapInfo:v,skipExtensions:y=[]}=this.ioConfig;if(!y.includes(`aux.xml`)&&!v){let t=await this._fetchAuxiliaryMetaData(e);t!=null&&j(t,d)}!y.includes(`vat.dbf`)&&d.bandCount===1&&d.pixelType===`u8`&&!v&&(d.attributeTable=await this._fetchAuxiliaryTable(e),d.attributeTable!=null&&(d.keyProperties.DataType=`thematic`)),v&&this.updateImageSpaceRasterInfo(d),this.updateTileInfo()}async _validateOrFetchHeaderBuffer(e,t){let{fileChunk:n,fileOffset:r,posIFD:i}=e;return(i+8>=n.byteLength||i<0)&&(r=i+r,n=(await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:`array-buffer`,signal:t})).data,i=0),{fileChunk:n,fileOffset:r,posIFD:i}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,x,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=x,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===x&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,O);let i=[];if(e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),e.has(`GEOKEYDIRECTORY`)){let t=e.get(`GEOKEYDIRECTORY`),r=t?.values;if(r&&r.length>4){let e=r[0]+`.`+r[1]+`.`+r[2];s=t.valueOffset+6-c;let i=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);t.data=(await this._readIFD(i,n,S,2,a))?.ifd,t.data&&t.data.set(`GEOTIFFVersion`,{id:0,type:2,valueCount:1,valueOffset:null,values:[e]})}}return l}return l.requiredBufferSize?(o=(await this.request(this.url,{range:{from:c,to:c+s+l.requiredBufferSize+8},responseType:`array-buffer`,signal:a})).data,o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=await this._fetchOffsets(o,Math.max(s,o+this._bufferSize),r);i.forEach(n=>g(e,t,n,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchOffsets(n[0],n[1]+n[0],r);g(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize,a=Math.ceil((t-e)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(a===1)return s[0].data;let c=new Uint8Array(t-e+1);for(let e=0;e<a;e++)c.set(new Uint8Array(s[e].data),e*i);return c.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null},{signal:i.signal});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{_headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=_(c,s),u=v(c,`TILEOFFSETS`),d=v(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=y(c,`IMAGEWIDTH`),b=y(c,`IMAGELENGTH`),x=y(c,`TILEWIDTH`),S=y(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%x||x,actualTileHeight:t===m&&b%S||S}}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?D.fromJSON(n.recordSet):null}catch{return null}}};e([r()],k.prototype,`_files`,void 0),e([r()],k.prototype,`_headerInfo`,void 0),e([r()],k.prototype,`_bufferSize`,void 0),e([r()],k.prototype,`_chunkSize`,void 0),e([r({type:String,json:{write:!0}})],k.prototype,`datasetFormat`,void 0),k=e([i(`esri.layers.raster.datasets.TIFFRaster`)],k);function A(e){let t=b(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:x,colormap:S}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,D=d(C),O=!!t.isPseudoGeographic;D??=(O=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:D}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:D}):new o({x:0,y:0}),j=new E({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),N=x?{BandProperties:x.bandProperties,DataType:x.dataType}:{},P=new T({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:D,isPseudoSpatialReference:O,keyProperties:N,extent:k,colormap:S,statistics:x?x.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:D}),P.transform=new w({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:D}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function j(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=C(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const M=k;export{M as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as s,describeCoverage as c}from"../../ogc/wcsUtils.js";import l from"./BaseRaster.js";import{convertOleDateTimeToEpoch as u}from"./multidimensionalUtils.js";import{parse as d}from"./multipartParser.js";import{standardizeInterpolations as f}from"./wcsCoverageParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{clip as m}from"../functions/pixelUtils.js";import h from"../../support/DimensionalDefinition.js";const g=[`nearest neighbor`,`bilinear`,`bicubic`],_=[`nearest`,`linear`,`cubic`],v=`response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode`,y=new Set([`1.0.0`,`1.1.0`,`1.1.1`,`1.1.2`,`2.0.1`]);let b=class extends l{constructor(){super(...arguments),this.datasetFormat=`WCSServer`,this.tileType=`Raster`}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,r,i,a={}){if(this.isBlockOutside(e,r,i))return null;let{nativePixelSize:o,spatialReference:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:u},r,i,p,s,[d,f]),g=this.rasterInfo.extent,_=h.xmax>g.xmax,v=h.ymin<g.ymin,y=_||v,b=h,x=d,S=f;if(y&&(b=h.clone().intersection(g),b!=null&&(_&&(x=Math.floor((b.xmax-b.xmin)/l),b.xmax=b.xmin+l*x),v&&(S=Math.floor((b.ymax-b.ymin)/u),b.ymin=b.ymax-u*S))),b==null||x<=1||S<=1)return null;let C=await this._getCoverage(b,x,S,c,a);if(!C)return null;let{coverageDescription:w}=this.coverageInfo,{noDataValue:T,multidimensionalInfo:E}=this.rasterInfo,{multidimensionalDefinition:D}=a,O;if(E!=null&&D!=null&&D.length){let e=D[0].variableName;w.version===`2.0`?O=w.rangeType[0].find(t=>t.name===e)?.nilValue:w.version===`1.1`&&(O=w.range.find(t=>t.identifier===e)?.nullValues)}let k=O??T,A=await this.decodePixelBlock(C,{width:x,height:S,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(k)?k[0]:k,matchAllNoData:!0});if(A==null)return null;if(A&&(A.width!==x||A.height!==S)){let e=`The tiff coverage response has unexpected width: ${A.width}, height: ${A.height}, expecting width: ${x}, height: ${S}`;throw n.getLogger(this).error(`wcsraster-fetch`,e),new t(`wcsraster-fetch`,e)}return y?m(A,{x:0,y:0},{width:f,height:f}):A}async _open(e){let{customFetchParameters:n}=this.ioConfig,r=e?.signal,i=await s(this.url,{version:n?.version??this.version,customParameters:n,signal:r});if(this.capabilities=i,!this.version){let e=i.version.slice(0,3);e===`2.0`||e===`1.1`||e===`1.0`?this.version=i.version:(e=i.supportedVersions.find(e=>e===`2.0.1`)||i.supportedVersions.find(e=>e.startsWith(`2.0`))||i.supportedVersions.find(e=>e.startsWith(`1.1`))||i.supportedVersions.find(e=>e.startsWith(`1.0`))||`1.0.0`,this.version=e)}let{version:a}=this;if(!y.has(a))throw new t(`wcsraster-open`,`unsupported WCS version ${a}`);let{gridCoverages:o}=i;if(!o.length)throw new t(`wcsraster-open`,`cannot find rectified grid coverages`);this.coverageId??=o[0].id;let{coverageId:l}=this,u=o.find(e=>e.id===l);if(u==null)throw new t(`wcsraster-open`,`the coverageId ${l} does not exist in capabilities`);let d=await c(this.url,{coverageIds:[l],version:a,customParameters:n,signal:r});if(this.coverageInfo=d[0],a.startsWith(`2.0`)){let{coverageInfo:e}=this;e.lonLatEnvelope=u.lonLatEnvelope,e.supportedInterpolations=f(i.supportedInterpolations),this._patchDimensionValues201(l,r)}this.datasetName=this.coverageInfo.title;let{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set(`rasterInfo`,p),p.spatialReference==null)throw new t(`wcsraster-open`,`coverage without spatial reference is not supported: ${l}`);let{pixelType:m,bandCount:h}=await this._getPixelTypeAndBandCount(r);p.pixelType=m,p.bandCount===1&&h>1&&(p.bandCount=h),this.updateTileInfo()}async _patchDimensionValues201(e,t){let{coverageInfo:n}=this,r=n.rasterInfo.multidimensionalInfo?.variables,i=y.has(`1.1.2`)?`1.1.2`:y.has(`1.1.1`)?`1.1.1`:y.has(`1.1.0`)?`1.1.0`:null,{customFetchParameters:a}=this.ioConfig;if(r&&i)try{let n=this.url.includes(`/ImageServer/`),o=e.length>8&&e.startsWith(`Coverage`)&&n?e.slice(8):e,s=(await c(this.url,{coverageIds:[o??e],version:i,customParameters:a,signal:t}).catch(()=>{if(o)return c(this.url,{coverageIds:[e],version:i,customParameters:a,signal:t})}))?.[0].rasterInfo.multidimensionalInfo?.variables;if(s)for(let e of r){let t=s.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let r=e.dimensions.length-1;r>=0;r--){let i=e.dimensions[r],a=t.dimensions.find(({name:e})=>e===i.name);if(!a){n&&e.dimensions.splice(r,1);continue}a.values&&a.extent?.join(`,`)===i.extent?.join(`,`)&&(e.dimensions[r]={...i,values:a.values})}}}catch{}}async _getPixelTypeAndBandCount(e){let{pixelSize:r,extent:i,multidimensionalInfo:o}=this.rasterInfo,s=i.center,c=new a({xmin:s.x-r.x,xmax:s.x+r.x,ymin:s.y-r.y,ymax:s.y+r.y,spatialReference:i.spatialReference}),l=[];if(o!=null){let e=o.variables[0];l=[],e.dimensions.forEach(t=>{l.push(new h({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}let{coverageDescription:u}=this.coverageInfo,d={interpolation:`nearest`,multidimensionalDefinition:l,signal:e},{version:f}=u,{ioConfig:p}=this,m=f===`2.0`&&p.allowAnyMediaType==null||f===`1.1`&&p.use2GridOffsets==null,g;try{g=await this._getCoverage(c,2,2,1,d,!0)}catch(e){if(!m)throw e;if(f===`1.1`){if(e.details?.isResolutionMismatch)p.use2GridOffsets=!0;else throw e}}if(!g&&m&&(f===`2.0`&&(p.allowAnyMediaType=!0),g=await this._getCoverage(c,2,2,1,d),g&&n.getLogger(this).warn(`wcsraster:getcoverage`,v)),!g)throw new t(`wcsraster-open`,`unable to determine pixel type`);let _=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(_==null)throw new t(`wcsraster-open`,`unable to determine pixel type`);return{pixelType:_.pixelType,bandCount:_.getPlaneCount()??0}}async _getCoverage(e,r,i,a,o,s=!1){let{coverageDescription:c}=this.coverageInfo,{version:l}=c,u=l===`2.0`?this._getCoverage201Parameters(e,r,i,a,o,c):l===`1.1`?this._getCoverage110Parameters(e,r,i,o,c):this._getCoverage100Parameters(e,r,i,o),f=l===`2.0`?await this.request(this._constructWCS201Url(u),{signal:o.signal,responseType:`array-buffer`}):await this.request(this.url,{query:u,signal:o.signal,responseType:`array-buffer`});if(l===`1.0`)return f.data;if(l===`2.0`&&this.ioConfig.allowAnyMediaType!==!1&&p(f.data)===`tiff`)return s&&(this.ioConfig.allowAnyMediaType=!0,n.getLogger(this).warn(`wcsraster:getcoverage`,v)),f.data;let m=d(f);if(m.isMultipart&&m.data){let e=m.data.find(e=>e.isValidImage);return s&&e?.contentTransferEncoding===`base64`&&n.getLogger(this).warn(`wcsraster:getcoverage`,`response is base64 encoded which may impact layer display performance`),e?.contentData}let h=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,h).toLowerCase().includes(`exception`),_=g&&String.fromCharCode.apply(null,h).includes(`A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided`);throw g?new t(`wcsraster:getcoverage`,`server returns an exception`,{isResolutionMismatch:_}):new t(`wcsraster:getcoverage`,`response is not a supported multipart mediaType with inline tiff`)}_getInterpolationIndex(e){return!e||!this.coverageInfo.supportedInterpolations?.includes(e)||e===`nearest`?0:e===`bilinear`?1:e===`cubic`?2:0}_getCoverage100Parameters(e,t,n,r){let i=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,a=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`GEOTIFF`,{bandIds:s,interpolation:c}=r,l=this._getInterpolationIndex(c),u=s?s.map(e=>this.coverageInfo.bandNames[e]):null,d=g[l],{multidimensionalDefinition:f}=r,p;if(f!=null&&this.rasterInfo.multidimensionalInfo!=null){let e=f.find(e=>e.dimensionName===`StdTime`)?.values;e&&e.length>0&&(Array.isArray(e[0])&&(e=e[0]),p=e.map(e=>x(e)).join(`,`))}return{service:`WCS`,request:`GetCoverage`,version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${a}`,bbox:i,width:t,height:n,time:p,interpolation:d,band:u?.join(`,`)}}_getCoverage110Parameters(e,t,n,r,i){let{multidimensionalDefinition:a,bandIds:s,interpolation:c}=r,l=e.spatialReference.wkid,u=`urn:ogc:def:crs:EPSG::${l}`,d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,f=this._getInterpolationIndex(c),p=_[f],m=c==null||this.coverageInfo.supportedInterpolations?.indexOf(c)===0,h=i.domain.spatialDomain,g=h.origin.x<=h.envelope.xmin&&h.origin.y<=h.envelope.ymin,v=e.width/t,y=e.height/n*(g?1:-1),b=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],S=h.useEPSGAxis&&o(l),C=S?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,w=this.ioConfig.use2GridOffsets,T=S?w?`${y},${v}`:`${y},0,0,${v}`:w?`${v},${y}`:`${v},0,0,${y}`,E=v/2,D=e.xmin+E,O=e.xmax-E,k=Math.abs(y)/2,A=e.ymin+k,j=e.ymax-k,M=S?`${A},${D},${j},${O},${u}`:`${D},${A},${O},${j},${u}`,N=i.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes(`band`))),P=N&&p&&s?m?`${N.identifier}[${N.axis[0].identifier}[${s.join(`,`)}]]`:`${N.identifier}:${p}[${N.axis[0].identifier}[${s.join(`,`)}]]`:null,F;if(a!=null&&a.length)for(let e=0;e<a.length;e++){let t=a[e].values,n=a[e].dimensionName?.toLowerCase(),r=a[e].variableName?.toLowerCase(),o=i.range.find(e=>e.identifier.toLowerCase()===r);if(t.length>0){if(Array.isArray(t[0])&&(t=t[0]),n===`stdtime`)F=t.map(e=>x(e)).join(`,`);else if(o){let e=o.axis.find(e=>e.identifier.toLowerCase()===n);e&&(P=m?o.identifier+`[`+e.identifier+`[`+t.join(`,`)+`]]`:o.identifier+`:`+p+`[`+e.identifier+`[`+t.join(`,`)+`]]`)}}e===a.length-1&&o&&!P&&(P=m?o.identifier:o.identifier+`:`+p)}return{service:`WCS`,request:`GetCoverage`,version:this.version,identifier:this.coverageId,format:d,crs:`EPSG:${l}`,boundingbox:M,gridCS:`urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS`,gridType:`urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs`,gridOrigin:C,gridOffsets:T,gridBaseCRS:u,timeSequence:F,rangeSubset:P}}_getCoverage201Parameters(e,t,n,r,i,a){let{multidimensionalDefinition:o,interpolation:s}=i,c=this._getInterpolationIndex(s),l=null,{supportedInterpolations:u}=this.capabilities;if(u?.length)switch(c){case 0:l=u.find(e=>e.toLowerCase().includes(`nearest`));break;case 1:l=u.find(e=>e.toLowerCase().includes(`linear`));break;case 2:l=u.find(e=>e.toLowerCase().includes(`cubic`)||e.toLowerCase().includes(`quadratic`))}let d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,{bandNames:f}=this.coverageInfo,{boundedBy:p,domainSet:m,rangeType:h}=a,g=+!p.isEastFirst,_=1-g,{axisLabels:v}=p,y=v[g],b=v[_],S=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=S,w=[];w.push(`${y}(${e.xmin},${e.xmax})`),w.push(`${b}(${e.ymin},${e.ymax})`);let T=[];if(v.length>2)for(let e=2;e<v.length;e++){let t=m.origin[e];if(v[e].toLowerCase().includes(`time`)){let n=t.toString();p.uomLabels?.[e].toLowerCase().includes(`ole`)&&(T.push(v[e]),n=x(t,!0)),w.push(v[e]+`,http://www.opengis.net(`+n+`)`)}else w.push(v[e]+`,http://www.opengis.net(`+t+`)`)}let E=null;if(o!=null&&o.length){let e=[];h.forEach(t=>t.forEach(t=>e.push(t.name)));let t=[];for(let n=0;n<o.length;n++){let r=v.find(e=>e===o[n].dimensionName),i=e.find(e=>e===o[n].variableName);if(t.includes(i)||t.push(i),r){let e=o[n].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t=``;t=r.toLowerCase().includes(`time`)?e.map(e=>x(e)).join(`,`):e.join(`,`);let n=w.findIndex(e=>e.startsWith(r+`,http://www.opengis.net`));n===-1&&w.push(r+`,http://www.opengis.net(`+t+`)`),n!==-1&&!w[n].includes(`(`+t+`)`)&&w.splice(n,1,r+`,http://www.opengis.net(`+t+`)`)}}}t.length&&(E=t.join(`,`))}else f?.length>=2&&(E=(i.bandIds?i.bandIds.map(e=>f[e]):f).join(`,`));let D=w.join(`&subset=`),O=!a.domainSet.hasSameAxisLabelsAsBoundedBy&&this.ioConfig.allowScaleFactor!==!1,k=O?null:`${y}(${t}),${b}(${n})`,A=O?1/r:null;return{service:`WCS`,request:`GetCoverage`,version:this.version,coverageId:this.coverageId,rangesubset:E,interpolation:l,scaleSize:k,scaleFactor:A,subset:D,format:d,mediaType:this.ioConfig.allowAnyMediaType?null:`multipart/related`,outputcrs:S,subsettingcrs:C}}_constructWCS201Url(e){let t={...this.ioConfig.customFetchParameters,...e},n=[];return Object.keys(t).forEach(e=>{let r=t[e];if(r!=null){if(e!==`subset`){n.push(`${e}=${encodeURIComponent(r)}`);return}typeof r==`string`&&r.split(`&subset=`).forEach(e=>{e&&n.push(`subset=${encodeURIComponent(e)}`)})}}),`${encodeURI(this.url)}?${n.join(`&`)}`}};e([r({type:String,json:{write:!0}})],b.prototype,`datasetFormat`,void 0),e([r({readOnly:!0})],b.prototype,`tileType`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`version`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`coverageId`,void 0),e([r({readOnly:!0})],b.prototype,`rasterId`,null),b=e([i(`esri.layers.raster.datasets.WCSRaster`)],b);function x(e,t=!1){return(t?new Date(u(e)):new Date(e)).toISOString()}export{b as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as s,describeCoverage as c}from"../../ogc/wcsUtils.js";import l from"./BaseRaster.js";import{convertOleDateTimeToEpoch as u}from"./multidimensionalUtils.js";import{parse as d}from"./multipartParser.js";import{standardizeInterpolations as f}from"./wcsCoverageParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{clip as m}from"../functions/pixelUtils.js";import h from"../../support/DimensionalDefinition.js";const g=[`nearest neighbor`,`bilinear`,`bicubic`],_=[`nearest`,`linear`,`cubic`],v=`response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode`,y=new Set([`1.0.0`,`1.1.0`,`1.1.1`,`1.1.2`,`2.0.1`]);let b=class extends l{constructor(){super(...arguments),this.datasetFormat=`WCSServer`,this.tileType=`Raster`}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,r,i,a={}){if(this.isBlockOutside(e,r,i))return null;let{nativePixelSize:o,spatialReference:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:u},r,i,p,s,[d,f]),g=this.rasterInfo.extent,_=h.xmax>g.xmax,v=h.ymin<g.ymin,y=_||v,b=h,x=d,S=f;if(y&&(b=h.clone().intersection(g),b!=null&&(_&&(x=Math.floor((b.xmax-b.xmin)/l),b.xmax=b.xmin+l*x),v&&(S=Math.floor((b.ymax-b.ymin)/u),b.ymin=b.ymax-u*S))),b==null||x<=1||S<=1)return null;let C=await this._getCoverage(b,x,S,c,a);if(!C)return null;let{coverageDescription:w}=this.coverageInfo,{noDataValue:T,multidimensionalInfo:E}=this.rasterInfo,{multidimensionalDefinition:D}=a,O;if(E!=null&&D!=null&&D.length){let e=D[0].variableName;w.version===`2.0`?O=w.rangeType[0].find(t=>t.name===e)?.nilValue:w.version===`1.1`&&(O=w.range.find(t=>t.identifier===e)?.nullValues)}let k=O??T,A=await this.decodePixelBlock(C,{width:x,height:S,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(k)?k[0]:k,matchAllNoData:!0},{signal:a.signal});if(A==null)return null;if(A&&(A.width!==x||A.height!==S)){let e=`The tiff coverage response has unexpected width: ${A.width}, height: ${A.height}, expecting width: ${x}, height: ${S}`;throw n.getLogger(this).error(`wcsraster-fetch`,e),new t(`wcsraster-fetch`,e)}return y?m(A,{x:0,y:0},{width:f,height:f}):A}async _open(e){let{customFetchParameters:n}=this.ioConfig,r=e?.signal,i=await s(this.url,{version:n?.version??this.version,customParameters:n,signal:r});if(this.capabilities=i,!this.version){let e=i.version.slice(0,3);e===`2.0`||e===`1.1`||e===`1.0`?this.version=i.version:(e=i.supportedVersions.find(e=>e===`2.0.1`)||i.supportedVersions.find(e=>e.startsWith(`2.0`))||i.supportedVersions.find(e=>e.startsWith(`1.1`))||i.supportedVersions.find(e=>e.startsWith(`1.0`))||`1.0.0`,this.version=e)}let{version:a}=this;if(!y.has(a))throw new t(`wcsraster-open`,`unsupported WCS version ${a}`);let{gridCoverages:o}=i;if(!o.length)throw new t(`wcsraster-open`,`cannot find rectified grid coverages`);this.coverageId??=o[0].id;let{coverageId:l}=this,u=o.find(e=>e.id===l);if(u==null)throw new t(`wcsraster-open`,`the coverageId ${l} does not exist in capabilities`);let d=await c(this.url,{coverageIds:[l],version:a,customParameters:n,signal:r});if(this.coverageInfo=d[0],a.startsWith(`2.0`)){let{coverageInfo:e}=this;e.lonLatEnvelope=u.lonLatEnvelope,e.supportedInterpolations=f(i.supportedInterpolations),this._patchDimensionValues201(l,r)}this.datasetName=this.coverageInfo.title;let{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set(`rasterInfo`,p),p.spatialReference==null)throw new t(`wcsraster-open`,`coverage without spatial reference is not supported: ${l}`);let{pixelType:m,bandCount:h}=await this._getPixelTypeAndBandCount(r);p.pixelType=m,p.bandCount===1&&h>1&&(p.bandCount=h),this.updateTileInfo()}async _patchDimensionValues201(e,t){let{coverageInfo:n}=this,r=n.rasterInfo.multidimensionalInfo?.variables,i=y.has(`1.1.2`)?`1.1.2`:y.has(`1.1.1`)?`1.1.1`:y.has(`1.1.0`)?`1.1.0`:null,{customFetchParameters:a}=this.ioConfig;if(r&&i)try{let n=this.url.includes(`/ImageServer/`),o=e.length>8&&e.startsWith(`Coverage`)&&n?e.slice(8):e,s=(await c(this.url,{coverageIds:[o??e],version:i,customParameters:a,signal:t}).catch(()=>{if(o)return c(this.url,{coverageIds:[e],version:i,customParameters:a,signal:t})}))?.[0].rasterInfo.multidimensionalInfo?.variables;if(s)for(let e of r){let t=s.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let r=e.dimensions.length-1;r>=0;r--){let i=e.dimensions[r],a=t.dimensions.find(({name:e})=>e===i.name);if(!a){n&&e.dimensions.splice(r,1);continue}a.values&&a.extent?.join(`,`)===i.extent?.join(`,`)&&(e.dimensions[r]={...i,values:a.values})}}}catch{}}async _getPixelTypeAndBandCount(e){let{pixelSize:r,extent:i,multidimensionalInfo:o}=this.rasterInfo,s=i.center,c=new a({xmin:s.x-r.x,xmax:s.x+r.x,ymin:s.y-r.y,ymax:s.y+r.y,spatialReference:i.spatialReference}),l=[];if(o!=null){let e=o.variables[0];l=[],e.dimensions.forEach(t=>{l.push(new h({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}let{coverageDescription:u}=this.coverageInfo,d={interpolation:`nearest`,multidimensionalDefinition:l,signal:e},{version:f}=u,{ioConfig:p}=this,m=f===`2.0`&&p.allowAnyMediaType==null||f===`1.1`&&p.use2GridOffsets==null,g;try{g=await this._getCoverage(c,2,2,1,d,!0)}catch(e){if(!m)throw e;if(f===`1.1`){if(e.details?.isResolutionMismatch)p.use2GridOffsets=!0;else throw e}}if(!g&&m&&(f===`2.0`&&(p.allowAnyMediaType=!0),g=await this._getCoverage(c,2,2,1,d),g&&n.getLogger(this).warn(`wcsraster:getcoverage`,v)),!g)throw new t(`wcsraster-open`,`unable to determine pixel type`);let _=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null},{signal:d.signal});if(_==null)throw new t(`wcsraster-open`,`unable to determine pixel type`);return{pixelType:_.pixelType,bandCount:_.getPlaneCount()??0}}async _getCoverage(e,r,i,a,o,s=!1){let{coverageDescription:c}=this.coverageInfo,{version:l}=c,u=l===`2.0`?this._getCoverage201Parameters(e,r,i,a,o,c):l===`1.1`?this._getCoverage110Parameters(e,r,i,o,c):this._getCoverage100Parameters(e,r,i,o),f=l===`2.0`?await this.request(this._constructWCS201Url(u),{signal:o.signal,responseType:`array-buffer`}):await this.request(this.url,{query:u,signal:o.signal,responseType:`array-buffer`});if(l===`1.0`)return f.data;if(l===`2.0`&&this.ioConfig.allowAnyMediaType!==!1&&p(f.data)===`tiff`)return s&&(this.ioConfig.allowAnyMediaType=!0,n.getLogger(this).warn(`wcsraster:getcoverage`,v)),f.data;let m=d(f);if(m.isMultipart&&m.data){let e=m.data.find(e=>e.isValidImage);return s&&e?.contentTransferEncoding===`base64`&&n.getLogger(this).warn(`wcsraster:getcoverage`,`response is base64 encoded which may impact layer display performance`),e?.contentData}let h=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,h).toLowerCase().includes(`exception`),_=g&&String.fromCharCode.apply(null,h).includes(`A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided`);throw g?new t(`wcsraster:getcoverage`,`server returns an exception`,{isResolutionMismatch:_}):new t(`wcsraster:getcoverage`,`response is not a supported multipart mediaType with inline tiff`)}_getInterpolationIndex(e){return!e||!this.coverageInfo.supportedInterpolations?.includes(e)||e===`nearest`?0:e===`bilinear`?1:e===`cubic`?2:0}_getCoverage100Parameters(e,t,n,r){let i=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,a=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`GEOTIFF`,{bandIds:s,interpolation:c}=r,l=this._getInterpolationIndex(c),u=s?s.map(e=>this.coverageInfo.bandNames[e]):null,d=g[l],{multidimensionalDefinition:f}=r,p;if(f!=null&&this.rasterInfo.multidimensionalInfo!=null){let e=f.find(e=>e.dimensionName===`StdTime`)?.values;e&&e.length>0&&(Array.isArray(e[0])&&(e=e[0]),p=e.map(e=>x(e)).join(`,`))}return{service:`WCS`,request:`GetCoverage`,version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${a}`,bbox:i,width:t,height:n,time:p,interpolation:d,band:u?.join(`,`)}}_getCoverage110Parameters(e,t,n,r,i){let{multidimensionalDefinition:a,bandIds:s,interpolation:c}=r,l=e.spatialReference.wkid,u=`urn:ogc:def:crs:EPSG::${l}`,d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,f=this._getInterpolationIndex(c),p=_[f],m=c==null||this.coverageInfo.supportedInterpolations?.indexOf(c)===0,h=i.domain.spatialDomain,g=h.origin.x<=h.envelope.xmin&&h.origin.y<=h.envelope.ymin,v=e.width/t,y=e.height/n*(g?1:-1),b=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],S=h.useEPSGAxis&&o(l),C=S?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,w=this.ioConfig.use2GridOffsets,T=S?w?`${y},${v}`:`${y},0,0,${v}`:w?`${v},${y}`:`${v},0,0,${y}`,E=v/2,D=e.xmin+E,O=e.xmax-E,k=Math.abs(y)/2,A=e.ymin+k,j=e.ymax-k,M=S?`${A},${D},${j},${O},${u}`:`${D},${A},${O},${j},${u}`,N=i.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes(`band`))),P=N&&p&&s?m?`${N.identifier}[${N.axis[0].identifier}[${s.join(`,`)}]]`:`${N.identifier}:${p}[${N.axis[0].identifier}[${s.join(`,`)}]]`:null,F;if(a!=null&&a.length)for(let e=0;e<a.length;e++){let t=a[e].values,n=a[e].dimensionName?.toLowerCase(),r=a[e].variableName?.toLowerCase(),o=i.range.find(e=>e.identifier.toLowerCase()===r);if(t.length>0){if(Array.isArray(t[0])&&(t=t[0]),n===`stdtime`)F=t.map(e=>x(e)).join(`,`);else if(o){let e=o.axis.find(e=>e.identifier.toLowerCase()===n);e&&(P=m?o.identifier+`[`+e.identifier+`[`+t.join(`,`)+`]]`:o.identifier+`:`+p+`[`+e.identifier+`[`+t.join(`,`)+`]]`)}}e===a.length-1&&o&&!P&&(P=m?o.identifier:o.identifier+`:`+p)}return{service:`WCS`,request:`GetCoverage`,version:this.version,identifier:this.coverageId,format:d,crs:`EPSG:${l}`,boundingbox:M,gridCS:`urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS`,gridType:`urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs`,gridOrigin:C,gridOffsets:T,gridBaseCRS:u,timeSequence:F,rangeSubset:P}}_getCoverage201Parameters(e,t,n,r,i,a){let{multidimensionalDefinition:o,interpolation:s}=i,c=this._getInterpolationIndex(s),l=null,{supportedInterpolations:u}=this.capabilities;if(u?.length)switch(c){case 0:l=u.find(e=>e.toLowerCase().includes(`nearest`));break;case 1:l=u.find(e=>e.toLowerCase().includes(`linear`));break;case 2:l=u.find(e=>e.toLowerCase().includes(`cubic`)||e.toLowerCase().includes(`quadratic`))}let d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,{bandNames:f}=this.coverageInfo,{boundedBy:p,domainSet:m,rangeType:h}=a,g=+!p.isEastFirst,_=1-g,{axisLabels:v}=p,y=v[g],b=v[_],S=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=S,w=[];w.push(`${y}(${e.xmin},${e.xmax})`),w.push(`${b}(${e.ymin},${e.ymax})`);let T=[];if(v.length>2)for(let e=2;e<v.length;e++){let t=m.origin[e];if(v[e].toLowerCase().includes(`time`)){let n=t.toString();p.uomLabels?.[e].toLowerCase().includes(`ole`)&&(T.push(v[e]),n=x(t,!0)),w.push(v[e]+`,http://www.opengis.net(`+n+`)`)}else w.push(v[e]+`,http://www.opengis.net(`+t+`)`)}let E=null;if(o!=null&&o.length){let e=[];h.forEach(t=>t.forEach(t=>e.push(t.name)));let t=[];for(let n=0;n<o.length;n++){let r=v.find(e=>e===o[n].dimensionName),i=e.find(e=>e===o[n].variableName);if(t.includes(i)||t.push(i),r){let e=o[n].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t=``;t=r.toLowerCase().includes(`time`)?e.map(e=>x(e)).join(`,`):e.join(`,`);let n=w.findIndex(e=>e.startsWith(r+`,http://www.opengis.net`));n===-1&&w.push(r+`,http://www.opengis.net(`+t+`)`),n!==-1&&!w[n].includes(`(`+t+`)`)&&w.splice(n,1,r+`,http://www.opengis.net(`+t+`)`)}}}t.length&&(E=t.join(`,`))}else f?.length>=2&&(E=(i.bandIds?i.bandIds.map(e=>f[e]):f).join(`,`));let D=w.join(`&subset=`),O=!a.domainSet.hasSameAxisLabelsAsBoundedBy&&this.ioConfig.allowScaleFactor!==!1,k=O?null:`${y}(${t}),${b}(${n})`,A=O?1/r:null;return{service:`WCS`,request:`GetCoverage`,version:this.version,coverageId:this.coverageId,rangesubset:E,interpolation:l,scaleSize:k,scaleFactor:A,subset:D,format:d,mediaType:this.ioConfig.allowAnyMediaType?null:`multipart/related`,outputcrs:S,subsettingcrs:C}}_constructWCS201Url(e){let t={...this.ioConfig.customFetchParameters,...e},n=[];return Object.keys(t).forEach(e=>{let r=t[e];if(r!=null){if(e!==`subset`){n.push(`${e}=${encodeURIComponent(r)}`);return}typeof r==`string`&&r.split(`&subset=`).forEach(e=>{e&&n.push(`subset=${encodeURIComponent(e)}`)})}}),`${encodeURI(this.url)}?${n.join(`&`)}`}};e([r({type:String,json:{write:!0}})],b.prototype,`datasetFormat`,void 0),e([r({readOnly:!0})],b.prototype,`tileType`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`version`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`coverageId`,void 0),e([r({readOnly:!0})],b.prototype,`rasterId`,null),b=e([i(`esri.layers.raster.datasets.WCSRaster`)],b);function x(e,t=!1){return(t?new Date(u(e)):new Date(e)).toISOString()}export{b as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../core/Error.js";import{throwIfAborted as t,throwIfAbortError as n}from"../../../core/promiseUtils.js";import{inflate as r}from"./Zlib.js";async function i(r,i,c){if(!r||r.byteLength<10)throw new e(`imagecanvasdecoder: decode`,`required a valid encoded data as input.`);let{width:d,height:f,format:p}=i,{applyJpegMask:m}=i;if(m&&!(d&&f))throw new e(`imagecanvasdecoder: decode`,`image width and height are needed to apply jpeg mask directly to canvas`);let h=null;p===`jpg`&&m&&d&&f&&(h=await u(r,{width:d,height:f}));try{let e=new Blob([new Uint8Array(r)],{type:l(p)}),u=await createImageBitmap(e);t(c);let{useTiledDecoding:d,tileIndex:f,tileSize:m}=i;if(d&&f==null)return o(u,h,m);if(f!=null&&m!=null)return s(u,f,m);try{return a(u,h)}catch(e){if(n(e),u.width>4096||u.height>4096)return o(u,h);throw e}}catch(t){throw n(t),new e(`imagecanvasdecoder: decode`,`cannot load image`)}}function a(t,n){let{width:r,height:i}=t,a=new OffscreenCanvas(r,i),o=a.getContext(`2d`);if(!o)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);o.drawImage(t,0,0,r,i);let s=c(o.getImageData(0,0,r,i),r,i,n);return a.width=0,a.height=0,s}function o(t,n,r=[2048,2048]){let[i,a]=r,o=new OffscreenCanvas(i,a),s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);let{width:c,height:l}=t,u=c*l,d=new Uint8Array(u),f=new Uint8Array(u),p=new Uint8Array(u),m=n==null;n||=new Uint8Array(u);for(let e=0;e<l;e+=a){let r=Math.min(a,l-e);for(let a=0;a<c;a+=i){let o=Math.min(i,c-a);s.clearRect(0,0,o,r),s.drawImage(t,a,e,o,r,0,0,o,r);let{data:l}=s.getImageData(0,0,o,r);for(let t=0;t<r;t++){let r=t*o*4,i=(e+t)*c+a;for(let e=0;e<o;e++,r+=4,i++)d[i]=l[r],f[i]=l[r+1],p[i]=l[r+2],m&&(n[i]=l[r+3])}}}let h={width:c,height:l,pixels:[d,f,p],mask:n,pixelType:`u8`};return o.width=0,o.height=0,console.log(`decodeFullImageTiled: ${c}x${l} using tile ${i}x${a}`,h),h}function s(t,n,r){let[i,a,o]=n,[s,l]=r,u=Math.ceil(t.width/2**i),d=Math.ceil(t.height/2**i),f=Math.ceil(d/l),p=Math.ceil(u/s);if(a>=f||o>=p)return null;let m=new OffscreenCanvas(u,d),h=m.getContext(`2d`);if(!h)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);h.drawImage(t,0,0,u,d);let g=o*s,_=a*l,v=Math.min(s,u-g),y=Math.min(l,d-_),b=c(h.getImageData(g,_,v,y),s,l);return m.width=0,m.height=0,b}function c(e,t,n,r){let i=t*n,a=new Uint8Array(i),o=new Uint8Array(i),s=new Uint8Array(i),c=r==null;r||=new Uint8Array(i);let l={width:t,height:n,pixels:[a,o,s],mask:r,pixelType:`u8`},{width:u,height:d,data:f}=e;if(u===t&&d===n){for(let e=0,t=0;e<i;e++,t+=4)a[e]=f[t],o[e]=f[t+1],s[e]=f[t+2],c&&(r[e]=f[t+3]);return l}for(let e=0;e<d;e++){let n=e*u*4;for(let i=0;i<u;i++){let l=e*t+i;a[l]=f[n+i*4],o[l]=f[n+i*4+1],s[l]=f[n+i*4+2],c&&(r[l]=f[n+i*4+3])}}return l}function l(e){return`image/${e===`jpg`?`jpeg`:e}`}async function u(e,t){try{let n=new Uint8Array(e),r=Math.ceil(n.length/2),i=n.length-2;for(;r<i&&(n[r]!==255||n[r+1]!==217);r++);r+=2;let a=null;return r<n.length-1&&(a=await d(n.subarray(r,-4),t.width*t.height)),a}catch{return null}}async function d(e,t){try{let n=await r(e),i=new Uint8Array(t);for(let e=0,t=0;e<n.length;e++)for(let r=7;r>=0;r--)i[t++]=n[e]>>r&1;return i}catch{return null}}export{i as decode,d as decodeBitMask};
2
+ import e from"../../../core/Error.js";import{throwIfAborted as t,throwIfAbortError as n}from"../../../core/promiseUtils.js";import{inflate as r}from"./Zlib.js";async function i(r,i,c){if(!r||r.byteLength<10)throw new e(`imagecanvasdecoder: decode`,`required a valid encoded data as input.`);let{width:d,height:f,format:p}=i,{applyJpegMask:m}=i;if(m&&!(d&&f))throw new e(`imagecanvasdecoder: decode`,`image width and height are needed to apply jpeg mask directly to canvas`);let h=null;p===`jpg`&&m&&d&&f&&(h=await u(r,{width:d,height:f}));try{let e=new Blob([new Uint8Array(r)],{type:l(p)}),u=await createImageBitmap(e);t(c);let{useTiledDecoding:d,tileIndex:f,tileSize:m}=i;if(d&&f==null)return o(u,h,m);if(f!=null&&m!=null)return s(u,f,m);try{return a(u,h)}catch(e){if(n(e),u.width>4096||u.height>4096)return o(u,h);throw e}}catch(t){throw n(t),new e(`imagecanvasdecoder: decode`,`cannot load image`)}}function a(t,n){let{width:r,height:i}=t,a=new OffscreenCanvas(r,i),o=a.getContext(`2d`);if(!o)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);o.drawImage(t,0,0,r,i);let s=c(o.getImageData(0,0,r,i),r,i,n);return a.width=0,a.height=0,s}function o(t,n,r=[2048,2048]){let[i,a]=r,o=new OffscreenCanvas(i,a),s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);let{width:c,height:l}=t,u=c*l,d=new Uint8Array(u),f=new Uint8Array(u),p=new Uint8Array(u),m=n==null;n||=new Uint8Array(u);for(let e=0;e<l;e+=a){let r=Math.min(a,l-e);for(let a=0;a<c;a+=i){let o=Math.min(i,c-a);s.clearRect(0,0,o,r),s.drawImage(t,a,e,o,r,0,0,o,r);let{data:l}=s.getImageData(0,0,o,r);for(let t=0;t<r;t++){let r=t*o*4,i=(e+t)*c+a;for(let e=0;e<o;e++,r+=4,i++)d[i]=l[r],f[i]=l[r+1],p[i]=l[r+2],m&&(n[i]=l[r+3])}}}let h={width:c,height:l,pixels:[d,f,p],mask:n,pixelType:`u8`};return o.width=0,o.height=0,console.log(`decodeFullImageTiled: ${c}x${l} using tile ${i}x${a}`,h),h}function s(t,n,r){let[i,a,o]=n,[s,l]=r,u=Math.ceil(t.width/2**i),d=Math.ceil(t.height/2**i),f=Math.ceil(d/l),p=Math.ceil(u/s);if(a>=f||o>=p)return null;let m=new OffscreenCanvas(u,d),h=m.getContext(`2d`);if(!h)throw new e(`imagecanvasdecoder: decode`,`cannot create canvas context`);h.drawImage(t,0,0,u,d);let g=o*s,_=a*l,v=Math.min(s,u-g),y=Math.min(l,d-_),b=c(h.getImageData(g,_,v,y),s,l);return m.width=0,m.height=0,b}function c(e,t,n,r){let i=t*n,a=new Uint8Array(i),o=new Uint8Array(i),s=new Uint8Array(i),c=r==null;r||=new Uint8Array(i);let l={width:t,height:n,pixels:[a,o,s],mask:r,pixelType:`u8`},{width:u,height:d,data:f}=e;if(u===t&&d===n){for(let e=0,t=0;e<i;e++,t+=4)a[e]=f[t],o[e]=f[t+1],s[e]=f[t+2],c&&(r[e]=f[t+3]);return l}for(let e=0;e<d;e++){let n=e*u*4;for(let i=0;i<u;i++){let l=e*t+i;a[l]=f[n+i*4],o[l]=f[n+i*4+1],s[l]=f[n+i*4+2],c&&(r[l]=f[n+i*4+3])}}return l}function l(e){return`image/${e===`jpg`?`jpeg`:e}`}async function u(e,t){try{let n=new Uint8Array(e),r=Math.ceil(n.length/2),i=n.length-2;for(;r<i&&(n[r]!==255||n[r+1]!==217);r++);r+=2;let a=null;return r<n.length-1&&(a=await d(n.subarray(r,-4),t.width*t.height)),a}catch{return null}}async function d(e,t,n){try{let i=await r(e,void 0,n),a=new Uint8Array(t);for(let e=0,t=0;e<i.length;e++)for(let n=7;n>=0;n--)a[t++]=i[e]>>n&1;return a}catch{return null}}export{i as decode,d as decodeBitMask};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../core/Error.js";import{assertIsSome as t}from"../../../core/maybe.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{decode as r}from"./ImageCanvasDecoder.js";import{decode as i}from"./JpgPlus.js";import{load as a,decode as o}from"./Lerc.js";import{decode as s}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{load as l,decode as u}from"./Qb3.js";import{decode as d}from"./Raw.js";import{decodeTileOrStrip as f,decode as p}from"./TiffDecoder.js";import{isPlatformLittleEndian as m}from"./utils.js";import{inflate as h}from"./Zlib.js";import g from"../../support/PixelBlock.js";import _ from"../../support/SimpleBandStatistics.js";async function v(t,n){if(!m)throw new e(`rasterCoded:decode`,`lerc decoder is not supported on big endian platform`);await a();let{width:r,height:i,pixelType:s,statistics:c,depthCount:l,noDataValues:u,bandMasks:d,pixels:f,mask:p,validPixelCount:h}=o(t,{inputOffset:n.offset,returnInterleaved:n.returnInterleaved});return new g({width:r,height:i,pixelType:s.toLowerCase(),pixels:f,mask:p,validPixelCount:h,statistics:c.map(({minValue:e,maxValue:t})=>new _(e,t)),bandMasks:d,depthCount:l,noDataValues:u})}async function y(t,n){await l();let r=u(t);if(!r)throw new e(`rasterCodec:decode`,`failed to decode the input data.`);let{width:i,height:a,pixels:o,pixelType:s}=r;return new g({width:i,height:a,pixelType:s,pixels:o})}async function b(e,n){let r=await p(e,{...n,noDataValue:n.tiffNoDataValue,matchAllNoData:n.matchAllNoData});return t(r),new g({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask,bandMasks:r.bandMasks})}async function x(e,t){let n=await f(e,t.customOptions),r=new g({width:n.width,height:n.height,pixels:n.pixels,pixelType:n.pixelType.toLowerCase(),mask:n.mask});return t.skipStatistics||r.updateStatistics(),r}function S(e,t){let n=t.pixelType||`u8`,r=g.getPixelArrayConstructor(n),i=n===`u8`?e:new r(e.buffer),a=[],o=t.planes||1;if(o===1)a.push(i);else for(let n=0;n<o;n++){let s=(t.width||1)*(t.height||e.length),c=new r(s);for(let e=0;e<s;e++)c[e]=i[e*o+n];a.push(c)}return new g({width:t.width||1,height:t.height||e.length,pixels:a,pixelType:n})}async function C(e,t){return S(await h(new Uint8Array(e)),t)}function w(e,t){return S(s(e,t.offset,t.eof,!t.isInputBigEndian),t)}function T(e,t){let n=t.format,{pixelTypeCtor:r}=A(t.pixelType),i=d(e,{width:t.width,height:t.height,pixelType:r,format:n});return new g({width:t.width,height:t.height,pixels:i.pixels,pixelType:t.pixelType,mask:i.mask})}async function E(e,t){let n=await i(e,t);return new g({width:n.width,height:n.height,pixels:n.pixels,pixelType:`u8`,mask:n.mask})}async function D(e,t,n){let i=await r(e,t,n);return new g(i)}async function O(t,r,i){let a=r.format||M(t),o={...r,format:a},{canvasUsage:s}=r;if(s!==`no-canvas`||a===`png`)try{return await D(t,o,i)}catch(t){if(n(t))throw t;if(s===`canvas-only`)throw new e(`rasterCodec:decode`,`failed to decode the input data with canvas for format ${a}`)}return await E(t,o)}function k(t){let n=null;switch(t){case`lerc`:n=v;break;case`jpg`:case`png`:n=O;break;case`bmp`:case`gif`:n=D;break;case`bsq`:case`bip`:n=T;break;case`tiff`:n=b;break;case`deflate`:n=C;break;case`lzw`:n=w;break;case`qb3`:n=y;break;default:n=()=>{throw new e(`rasterCodec:decode`,`unsupported raster format ${t}`)}}return n}function A(e){let t=e?e.toLowerCase():`f32`,n=null,r=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:r=255,n=Uint8Array;break;case`u16`:r||=2**16-1,n=Uint16Array;break;case`u32`:r||=2**32-1,n=Uint32Array;break;case`s8`:r||=-128,n=Int8Array;break;case`s16`:r||=0-2**15,n=Int16Array;break;case`s32`:r||=0-2**31,n=Int32Array;break;default:n=Float32Array}return{pixelTypeCtor:n,noDataValue:r}}function j(e,t=`bilinear`){if(!e)return;let{pixels:n,width:r,height:i,mask:a}=e;if(!n||n.length===0)return;let o=r-1,s=i-1,c=[],l=null,u=g.getPixelArrayConstructor(e.pixelType);if(t===`nearest`){for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let r=0;r<o;r++)t[n*o+r]=e[i+r]}c.push(t)}if(a!=null){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=a[t+n]}}}else{for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let a=0;a<o;a++)t[n*o+a]=(e[i+a]+e[i+a+1]+e[i+r+a]+e[i+r+a+1])/4}c.push(t)}if(a){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=Math.min.apply(null,[a[t+n],a[t+n+1],a[t+r+n],a[t+r+n+1]])}}}e.width=o,e.height=s,e.mask=l,e.pixels=c}function M(e){if(!e)return;let t=new Uint8Array(e,0,10),n;return t[0]===255&&t[1]===216?n=`jpg`:t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?n=`png`:t[0]===67&&t[1]===110&&t[2]===116&&t[3]===90&&t[4]===73&&t[5]===109&&t[6]===97&&t[7]===103&&t[8]===101&&t[9]===32||t[0]===76&&t[1]===101&&t[2]===114&&t[3]===99&&t[4]===50&&t[5]===32?n=`lerc`:t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42||t[0]===73&&t[1]===73&&t[2]===43&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===43?n=`tiff`:t[0]===71&&t[1]===73&&t[2]===70?n=`gif`:t[0]===66&&t[1]===77?n=`bmp`:t[0]===81&&t[1]===66&&t[2]===51&&(n=`qb3`),n}async function N(t,n={},r){if(t==null)throw new e(`rasterCodec:decode`,`missing encodeddata parameter.`);let i=n.format?.toLowerCase();if((i===`bsq`||i===`bip`)&&(n.width==null||n.height==null))throw new e(`rasterCodec:decode`,`requires width and height in options parameter.`);if(i===`tiff`&&n.customOptions)return x(t,n);if(!i||i!==`bsq`&&i!==`bip`&&i!==`deflate`&&i!==`lzw`){if(i=M(t),!i)throw String.fromCharCode.apply(null,[...new Uint8Array(t,0,10)]).toLowerCase().includes(`error`)?new e(`rasterCodec:decode`,`input data contains error`):new e(`rasterCodec:decode`,`unsupported raster format`);n={...n,format:i}}let a=k(i);n.isPoint&&(n={...n},n.width!=null&&n.width++,n.height!=null&&n.height++);let o,{offsets:s}=n;if(s&&s.length>1){let e=s.map((e,i)=>a(t.slice(e,s[i+1]),n,r)),i=await Promise.all(e);o=i[0],o.pixels=i.map(e=>e.pixels[0]);let c=i.map(e=>e.mask);c.some(e=>e!=null)&&(c.forEach((e,t)=>{c[t]??=new Uint8Array(o.width*o.height).fill(255)}),o.bandMasks=c,o.mask=g.combineBandMasks(c))}else o=await a(t,{...n,offset:s?.[0]??n.offset},r);return i!==`jpg`&&n.noDataValue!=null&&o.depthCount===1&&c(o,n.noDataValue,{customFloatTolerance:n.tolerance}),n.isPoint&&j(o),!o.statistics?.length&&!n.skipStatistics&&o.updateStatistics(),o}export{N as decode,M as getFormat};
2
+ import e from"../../../core/Error.js";import{assertIsSome as t}from"../../../core/maybe.js";import{throwIfAborted as n,isAbortError as r}from"../../../core/promiseUtils.js";import{decode as i}from"./ImageCanvasDecoder.js";import{decode as a}from"./JpgPlus.js";import{load as o,decode as s}from"./Lerc.js";import{decode as c}from"./Lzw.js";import{convertNoDataToMask as l}from"./pixelRangeUtils.js";import{load as u,decode as d}from"./Qb3.js";import{decode as f}from"./Raw.js";import{decodeTileOrStrip as p,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as h}from"./utils.js";import{inflate as g}from"./Zlib.js";import _ from"../../support/PixelBlock.js";import v from"../../support/SimpleBandStatistics.js";async function y(t,n){if(!h)throw new e(`rasterCoded:decode`,`lerc decoder is not supported on big endian platform`);await o();let{width:r,height:i,pixelType:a,statistics:c,depthCount:l,noDataValues:u,bandMasks:d,pixels:f,mask:p,validPixelCount:m}=s(t,{inputOffset:n.offset,returnInterleaved:n.returnInterleaved});return new _({width:r,height:i,pixelType:a.toLowerCase(),pixels:f,mask:p,validPixelCount:m,statistics:c.map(({minValue:e,maxValue:t})=>new v(e,t)),bandMasks:d,depthCount:l,noDataValues:u})}async function b(t,n){await u();let r=d(t);if(!r)throw new e(`rasterCodec:decode`,`failed to decode the input data.`);let{width:i,height:a,pixels:o,pixelType:s}=r;return new _({width:i,height:a,pixelType:s,pixels:o})}async function x(e,n,r){let i=await m(e,{...n,noDataValue:n.tiffNoDataValue,matchAllNoData:n.matchAllNoData},r);return t(i),new _({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,bandMasks:i.bandMasks})}async function S(e,t,n){let r=await p(e,t.customOptions,n),i=new _({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask});return t.skipStatistics||i.updateStatistics(),i}function C(e,t){let n=t.pixelType||`u8`,r=_.getPixelArrayConstructor(n),i=n===`u8`?e:new r(e.buffer),a=[],o=t.planes||1;if(o===1)a.push(i);else for(let n=0;n<o;n++){let s=(t.width||1)*(t.height||e.length),c=new r(s);for(let e=0;e<s;e++)c[e]=i[e*o+n];a.push(c)}return new _({width:t.width||1,height:t.height||e.length,pixels:a,pixelType:n})}async function w(e,t,n){return C(await g(new Uint8Array(e),void 0,n),t)}function T(e,t){return C(c(e,t.offset,t.eof,!t.isInputBigEndian),t)}function E(e,t){let n=t.format,{pixelTypeCtor:r}=j(t.pixelType),i=f(e,{width:t.width,height:t.height,pixelType:r,format:n});return new _({width:t.width,height:t.height,pixels:i.pixels,pixelType:t.pixelType,mask:i.mask})}async function D(e,t){let n=await a(e,t);return new _({width:n.width,height:n.height,pixels:n.pixels,pixelType:`u8`,mask:n.mask})}async function O(e,t,n){let r=await i(e,t,n);return new _(r)}async function k(t,n,i){let a=n.format||N(t),o={...n,format:a},{canvasUsage:s}=n;if(s!==`no-canvas`||a===`png`)try{return await O(t,o,i)}catch(t){if(r(t))throw t;if(s===`canvas-only`)throw new e(`rasterCodec:decode`,`failed to decode the input data with canvas for format ${a}`)}return await D(t,o)}function A(t){let n=null;switch(t){case`lerc`:n=y;break;case`jpg`:case`png`:n=k;break;case`bmp`:case`gif`:n=O;break;case`bsq`:case`bip`:n=E;break;case`tiff`:n=x;break;case`deflate`:n=w;break;case`lzw`:n=T;break;case`qb3`:n=b;break;default:n=()=>{throw new e(`rasterCodec:decode`,`unsupported raster format ${t}`)}}return n}function j(e){let t=e?e.toLowerCase():`f32`,n=null,r=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:r=255,n=Uint8Array;break;case`u16`:r||=2**16-1,n=Uint16Array;break;case`u32`:r||=2**32-1,n=Uint32Array;break;case`s8`:r||=-128,n=Int8Array;break;case`s16`:r||=0-2**15,n=Int16Array;break;case`s32`:r||=0-2**31,n=Int32Array;break;default:n=Float32Array}return{pixelTypeCtor:n,noDataValue:r}}function M(e,t=`bilinear`){if(!e)return;let{pixels:n,width:r,height:i,mask:a}=e;if(!n||n.length===0)return;let o=r-1,s=i-1,c=[],l=null,u=_.getPixelArrayConstructor(e.pixelType);if(t===`nearest`){for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let r=0;r<o;r++)t[n*o+r]=e[i+r]}c.push(t)}if(a!=null){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=a[t+n]}}}else{for(let e of n){let t=new u(o*s);for(let n=0;n<s;n++){let i=n*r;for(let a=0;a<o;a++)t[n*o+a]=(e[i+a]+e[i+a+1]+e[i+r+a]+e[i+r+a+1])/4}c.push(t)}if(a){l=new Uint8Array(o*s);for(let e=0;e<s;e++){let t=e*r;for(let n=0;n<o;n++)l[e*o+n]=Math.min.apply(null,[a[t+n],a[t+n+1],a[t+r+n],a[t+r+n+1]])}}}e.width=o,e.height=s,e.mask=l,e.pixels=c}function N(e){if(!e)return;let t=new Uint8Array(e,0,10),n;return t[0]===255&&t[1]===216?n=`jpg`:t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?n=`png`:t[0]===67&&t[1]===110&&t[2]===116&&t[3]===90&&t[4]===73&&t[5]===109&&t[6]===97&&t[7]===103&&t[8]===101&&t[9]===32||t[0]===76&&t[1]===101&&t[2]===114&&t[3]===99&&t[4]===50&&t[5]===32?n=`lerc`:t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42||t[0]===73&&t[1]===73&&t[2]===43&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===43?n=`tiff`:t[0]===71&&t[1]===73&&t[2]===70?n=`gif`:t[0]===66&&t[1]===77?n=`bmp`:t[0]===81&&t[1]===66&&t[2]===51&&(n=`qb3`),n}async function P(t,r={},i){if(t==null)throw new e(`rasterCodec:decode`,`missing encodeddata parameter.`);let a=r.format?.toLowerCase();if((a===`bsq`||a===`bip`)&&(r.width==null||r.height==null))throw new e(`rasterCodec:decode`,`requires width and height in options parameter.`);if(a===`tiff`&&r.customOptions)return S(t,r,i);if(!a||a!==`bsq`&&a!==`bip`&&a!==`deflate`&&a!==`lzw`){if(a=N(t),!a)throw String.fromCharCode.apply(null,[...new Uint8Array(t,0,10)]).toLowerCase().includes(`error`)?new e(`rasterCodec:decode`,`input data contains error`):new e(`rasterCodec:decode`,`unsupported raster format`);r={...r,format:a}}let o=A(a);r.isPoint&&(r={...r},r.width!=null&&r.width++,r.height!=null&&r.height++);let s,{offsets:c}=r;if(c&&c.length>1){let e=c.map((e,n)=>o(t.slice(e,c[n+1]),r,i)),n=await Promise.all(e);s=n[0],s.pixels=n.map(e=>e.pixels[0]);let a=n.map(e=>e.mask);a.some(e=>e!=null)&&(a.forEach((e,t)=>{a[t]??=new Uint8Array(s.width*s.height).fill(255)}),s.bandMasks=a,s.mask=_.combineBandMasks(a))}else s=await o(t,{...r,offset:c?.[0]??r.offset},i);return n(i),a!==`jpg`&&r.noDataValue!=null&&s.depthCount===1&&l(s,r.noDataValue,{customFloatTolerance:r.tolerance}),r.isPoint&&M(s),!s.statistics?.length&&!r.skipStatistics&&s.updateStatistics(),s}export{P as decode,N as getFormat};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../core/Error.js";import"../../../core/has.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as r}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as a}from"./pixelRangeUtils.js";import{isBSQConfig as o,getTagFirstNumericValue as s,getCompressionType as c,parseHeader as l,checkRequiredArraySize as u,getTagNumericValues as d,getImageInfo as f}from"./tiffParser.js";import{isPlatformLittleEndian as p}from"./utils.js";import{inflate as m}from"./Zlib.js";function h(e,t){let n=`unknown`;return e===3?n=t===64?`f64`:`f32`:e===1?t===1?n=`u1`:t===2?n=`u2`:t===4?n=`u4`:t<=8?n=`u8`:t<=16?n=`u16`:t<=32&&(n=`u32`):e===2&&(t<=8?n=`s8`:t<=16?n=`s16`:t<=32&&(n=`s32`)),n}function g(e){let t=e?e.toLowerCase():`f32`,n=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:n=Uint8Array;break;case`u16`:n=Uint16Array;break;case`u32`:n=Uint32Array;break;case`s8`:n=Int8Array;break;case`s16`:n=Int16Array;break;case`s32`:n=Int32Array;break;case`f64`:n=Float64Array;break;default:n=Float32Array}return n}async function _(e,t){return await n(),r(e,{inputOffset:t}).pixels[0]}function v(e,t){if(t%8==0)return e;let n=t>16?32:t>8?16:8;n>8&&(e=b(e,n===32?4:2));let r=n===32?Uint32Array:n===16?Uint16Array:Uint8Array,i=new r(e),a=Math.floor(e.byteLength*8/t+1e-6),o=new r(a),s=(1<<t)-1,c=0,l=0,u=0;for(let e=0;e<a;e++)if(l===0&&(u=i[c++],l=n),l>=t)o[e]=u>>>l-t&s,l-=t;else{let r=t-l,a=(u&s)<<r&s;u=i[c++],l=n-r,a+=u>>>l,o[e]=a}return o.buffer}function y(e,n,r){let i=new t;i.parse(e),i.colorTransform=r===6?-1:0;let a=i.getData(i.width,i.height,n!==1&&n!==4);return new Uint8Array(a.buffer)}function b(e,t){let n=new Uint8Array(e),r=new Uint8Array(n.length);if(t===2)for(let e=0;e<n.length;e+=2)r[e]=n[e+1],r[e+1]=n[e];else if(t===4)for(let e=0;e<n.length;e+=4)r[e]=n[e+3],r[e+1]=n[e+2],r[e+2]=n[e+1],r[e+3]=n[e];else for(let e=0;e<n.length;e+=8)r[e]=n[e+7],r[e+1]=n[e+6],r[e+2]=n[e+5],r[e+3]=n[e+4],r[e+4]=n[e+3],r[e+5]=n[e+2],r[e+6]=n[e+1],r[e+7]=n[e];return r.buffer}async function x(t,n,r,a,l){let u=p===n,d=s(r,`BITSPERSAMPLE`),f=s(r,`SAMPLESPERPIXEL`)??1,x=s(r,`PHOTOMETRICINTERPRETATION`),S=s(r,`SAMPLEFORMAT`)??1,C=h(S,d),w=c(r);if(w===34887)return await _(t,a);let E=g(C),D,O;switch(w){case 1:D=t.slice(a,a+l),O=new Uint8Array(D);break;case 8:case 32946:O=await m(new Uint8Array(t,a,l)),D=O.buffer;break;case 6:O=y(new Uint8Array(t,a,l),f,x),D=O.buffer;break;case 7:{let e=r.get(`JPEGTABLES`).values,n=e.length-2,i=new Uint8Array(n+l-2);for(let t=0;t<n;t++)i[t]=e[t];let o=new Uint8Array(t,a+2,l-2);for(let e=0;e<o.length;e++)i[n+e]=o[e];O=y(i,f,x),D=O.buffer}break;case 5:O=i(t,a,l,n),D=O.buffer;break;default:throw new e(`tiff-reader:decode-data`,`unsupported compression `+w)}D=v(D,d);let k;if(u||d<=8)k=new E(D);else{let e=d>32?8:d>16?4:2;k=new E(b(O.buffer,e))}let A=s(r,`PREDICTOR`)??1,j=s(r,`TILEWIDTH`),M=s(r,`TILELENGTH`);if(A>1&&(w===5||w===8||w===32946)&&j&&M){let e=o(r),t=new E(k.length);t.set(k),k=T(t,M,j,S===3&&A===3,e?1:f)}return k}async function S(e,t,n){let r=d(n,`TILEOFFSETS`),i=d(n,`TILEBYTECOUNTS`);if(r==null||i==null)return null;let{width:a,height:l,pixelType:u,tileWidth:p,tileHeight:m}=f([n]),h=o(n,t),_=s(n,`SAMPLESPERPIXEL`)||t.planes,v=a*l,y=s(n,`BITSPERSAMPLE`),b=c(n)===34887,S=g(u),C=[];for(let e=0;e<_;e++)C.push(new S(v));let w=Math.ceil(a/p),T=new Uint8Array(v).fill(255),E=null,D=!1;if(y%8==0){if(b&&h&&_>1){let o=Math.round(r.length/_);for(let s=0;s<o;s++){let o=Math.floor(s/w)*m,c=s%w*p,u=o*a+c;for(let d=0;d<_;d++){let f=s*_+d;i[f]===0?(E=null,D=!0):E=await x(e,t.littleEndian,n,r[f],i[f]);let h=Math.min(p,a-c),g=Math.min(m,l-o),v=C[d];for(let e=0;e<g;e++){let t=u+e*a,n=e*p;for(let e=0;e<h;e++,t++,n++)E?v[t]=E[n]:T[t]=0}}}}else for(let o=0;o<r.length;o++){let s=Math.floor(o/w)*m,c=o%w*p,u=s*a+c;i[o]===0?(E=null,D=!0):E=await x(e,t.littleEndian,n,r[o],i[o]);let d=Math.min(p,a-c),f=Math.min(m,l-s);for(let e=0;e<_;e++){let t=C[e];if(h||b)for(let n=0;n<f;n++){let r=u+n*a,i=p*m*e+n*p;for(let e=0;e<d;e++,r++,i++)E?t[r]=E[i]:T[r]=0}else for(let n=0;n<f;n++){let r=u+n*a,i=n*p*_+e;for(let e=0;e<d;e++,r++,i+=_)E?t[r]=E[i]:T[r]=0}}}}return{width:a,height:l,pixelType:u,pixels:C,mask:D?T:void 0}}async function C(e,t,n){let r=p===t.littleEndian,a=d(n,`STRIPOFFSETS`),o=d(n,`STRIPBYTECOUNTS`);if(a==null||o==null)return null;let{width:l,height:u,pixelType:h}=f([n]),_=s(n,`SAMPLESPERPIXEL`)||t.planes,b=s(n,`PHOTOMETRICINTERPRETATION`),x=l*u,S=s(n,`BITSPERSAMPLE`),C=g(h),w=new C(x*_),T=s(n,`ROWSPERSTRIP`),E=c(n),D,O,k,A;if(S%8==0)for(let n=0;n<a.length;n++){let s=T*l*n*_;if(h===`u8`||h===`s8`||r)E===8||E===32946?(k=new Uint8Array(e,a[n],o[n]),k=await m(k),O=k.buffer):E===6?(k=new Uint8Array(e,a[n],o[n]),k=y(k,_,b),O=k.buffer):E===5?(k=i(e,a[n],o[n],t.littleEndian),O=k.buffer):O=e.slice(a[n],a[n]+o[n]),O=v(O,S),D=new C(O);else{switch(E===6||E===8||E===32946?(k=new Uint8Array(e,a[n],o[n]),A=await m(k),O=A.buffer):(O=new ArrayBuffer(o[n]),k=new Uint8Array(e,a[n],o[n]),A=new Uint8Array(O)),h){case`u16`:case`s16`:for(let e=0;e<k.length;e+=2)A[e]=k[e+1],A[e+1]=k[e];break;case`u32`:case`s32`:case`f32`:for(let e=0;e<k.length;e+=4)A[e]=k[e+3],A[e+1]=k[e+2],A[e+2]=k[e+1],A[e+3]=k[e]}O=v(O,S),D=new C(O)}w.set(D,s)}let j=[];if(_===1)j.push(w);else for(let e=0;e<_;e++){let t=new C(x);for(let n=0;n<x;n++)t[n]=w[n*_+e];j.push(t)}return{width:l,height:u,pixelType:h,pixels:j}}function w(e,t,n){if(!(e&&e.length>0&&t&&n))return null;let r,i,a,o=e[0].length,s=e.length,c=new Uint8Array(o);for(let l=0;l<s;l++)if(r=e[l],i=t[l],a=n[l],l===0)for(let e=0;e<o;e++)c[e]=r[e]<i||r[e]>a?0:1;else for(let e=0;e<o;e++)c[e]&&(c[e]=r[e]<i||r[e]>a?0:1);return c}function T(e,t,n,r,i){let a=r?4:1,o=n*a*i;r&&(e=new Uint8Array(e.buffer));for(let n=0;n<t;n++){let t=n*o;for(let n=i;n<o;n++)e[t+n]+=e[t+n-i]}if(!r)return e;let s=new Uint8Array(e.length),c=n*i;for(let n=0;n<t;n++){let t=n*o;for(let n=0;n<c;n++)for(let r=0;r<a;r++)s[t+n*a+r]=e[t+n+(a-r-1)*c]}return new Float32Array(s.buffer)}async function E(e,t){let{headerInfo:n,ifd:r,offsets:i,sizes:l}=t,u=[];for(let t=0;t<i.length;t++){+(l[t]===0);let a=await x(e,n.littleEndian,r,i[t],l[t]||e.byteLength);u.push(a)}let d=o(r,n),f=s(r,`BITSPERSAMPLE`),p=h(s(r,`SAMPLEFORMAT`)??1,f),m=s(r,`SAMPLESPERPIXEL`)||n.planes,_=g(p),v=s(r,`TILEWIDTH`),y=s(r,`TILELENGTH`),b=c(r)===34887,S=v*y,C,T=[],E=u[0];for(let e=0;e<m;e++){if(C=new _(S),u.length===m)E=u[e],E.length===S&&(C=E);else if(E.length){if(d||b)C=E.length===S?E:E.slice(S*e,S*(e+1));else for(let t=0;t<S;t++)C[t]=E[t*m+e]}T.push(C)}let D=n.noData?n.noData[0]:t.noDataValue,O=n.metadata?n.metadata.statistics:null,k=O?O.map(e=>e.min):null,A=O?O.map(e=>e.max):null,j={pixelType:p,width:v,height:y,pixels:T,noDataValue:D};return D==null?k&&A&&t.applyMinMaxConstraint&&(j.mask=w(T,k,A)):a(j,D,{matchAllNoData:t?.matchAllNoData}),j}async function D(t,n={}){let r=n.pyramidLevel||0,i=n.headerInfo||l(t),{ifds:o,noData:s}=i;if(o.length===0)throw new e(`tiff-reader:decode`,`no valid image file directory`);let c=u(i);if(c)throw new e(`tiff-reader:decode`,c);let d=r===-1?o[o.length-1]:o[r],f=s??n.noDataValue,p=i.tileWidth?await S(t,i,d):await C(t,i,d);if(!p)return p;if(f!=null){let e=s==null&&n?.matchAllNoData;a(p,f,{matchAllNoData:e})}return p}export{D as decode,E as decodeTileOrStrip};
2
+ import e from"../../../core/Error.js";import"../../../core/has.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as r}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as a}from"./pixelRangeUtils.js";import{isBSQConfig as o,getTagFirstNumericValue as s,getCompressionType as c,parseHeader as l,checkRequiredArraySize as u,getTagNumericValues as d,getImageInfo as f}from"./tiffParser.js";import{isPlatformLittleEndian as p}from"./utils.js";import{inflate as m}from"./Zlib.js";function h(e,t){let n=`unknown`;return e===3?n=t===64?`f64`:`f32`:e===1?t===1?n=`u1`:t===2?n=`u2`:t===4?n=`u4`:t<=8?n=`u8`:t<=16?n=`u16`:t<=32&&(n=`u32`):e===2&&(t<=8?n=`s8`:t<=16?n=`s16`:t<=32&&(n=`s32`)),n}function g(e){let t=e?e.toLowerCase():`f32`,n=null;switch(t){case`u1`:case`u2`:case`u4`:case`u8`:n=Uint8Array;break;case`u16`:n=Uint16Array;break;case`u32`:n=Uint32Array;break;case`s8`:n=Int8Array;break;case`s16`:n=Int16Array;break;case`s32`:n=Int32Array;break;case`f64`:n=Float64Array;break;default:n=Float32Array}return n}async function _(e,t){return await n(),r(e,{inputOffset:t}).pixels[0]}function v(e,t){if(t%8==0)return e;let n=t>16?32:t>8?16:8;n>8&&(e=b(e,n===32?4:2));let r=n===32?Uint32Array:n===16?Uint16Array:Uint8Array,i=new r(e),a=Math.floor(e.byteLength*8/t+1e-6),o=new r(a),s=(1<<t)-1,c=0,l=0,u=0;for(let e=0;e<a;e++)if(l===0&&(u=i[c++],l=n),l>=t)o[e]=u>>>l-t&s,l-=t;else{let r=t-l,a=(u&s)<<r&s;u=i[c++],l=n-r,a+=u>>>l,o[e]=a}return o.buffer}function y(e,n,r){let i=new t;i.parse(e),i.colorTransform=r===6?-1:0;let a=i.getData(i.width,i.height,n!==1&&n!==4);return new Uint8Array(a.buffer)}function b(e,t){let n=new Uint8Array(e),r=new Uint8Array(n.length);if(t===2)for(let e=0;e<n.length;e+=2)r[e]=n[e+1],r[e+1]=n[e];else if(t===4)for(let e=0;e<n.length;e+=4)r[e]=n[e+3],r[e+1]=n[e+2],r[e+2]=n[e+1],r[e+3]=n[e];else for(let e=0;e<n.length;e+=8)r[e]=n[e+7],r[e+1]=n[e+6],r[e+2]=n[e+5],r[e+3]=n[e+4],r[e+4]=n[e+3],r[e+5]=n[e+2],r[e+6]=n[e+1],r[e+7]=n[e];return r.buffer}async function x(t,n){let{input:r,isTiffLittleEndian:a,ifd:l,offset:u,size:d}=t,f=p===a,x=s(l,`BITSPERSAMPLE`),S=s(l,`SAMPLESPERPIXEL`)??1,C=s(l,`PHOTOMETRICINTERPRETATION`),w=s(l,`SAMPLEFORMAT`)??1,E=h(w,x),D=c(l);if(D===34887)return await _(r,u);let O=g(E),k,A;switch(D){case 1:k=r.slice(u,u+d),A=new Uint8Array(k);break;case 8:case 32946:A=await m(new Uint8Array(r,u,d),void 0,n),k=A.buffer;break;case 6:A=y(new Uint8Array(r,u,d),S,C),k=A.buffer;break;case 7:{let e=l.get(`JPEGTABLES`).values,t=e.length-2,n=new Uint8Array(t+d-2);for(let r=0;r<t;r++)n[r]=e[r];let i=new Uint8Array(r,u+2,d-2);for(let e=0;e<i.length;e++)n[t+e]=i[e];A=y(n,S,C),k=A.buffer}break;case 5:A=i(r,u,d,a),k=A.buffer;break;default:throw new e(`tiff-reader:decode-data`,`unsupported compression `+D)}k=v(k,x);let j;if(f||x<=8)j=new O(k);else{let e=x>32?8:x>16?4:2;j=new O(b(A.buffer,e))}let M=s(l,`PREDICTOR`)??1,N=s(l,`TILEWIDTH`),P=s(l,`TILELENGTH`);if(M>1&&(D===5||D===8||D===32946)&&N&&P){let e=o(l),t=new O(j.length);t.set(j),j=T(t,P,N,w===3&&M===3,e?1:S)}return j}async function S(e,t,n,r){let i=d(n,`TILEOFFSETS`),a=d(n,`TILEBYTECOUNTS`);if(i==null||a==null)return null;let{width:l,height:u,pixelType:p,tileWidth:m,tileHeight:h}=f([n]),_=o(n,t),v=s(n,`SAMPLESPERPIXEL`)||t.planes,y=l*u,b=s(n,`BITSPERSAMPLE`),S=c(n)===34887,C=g(p),w=[];for(let e=0;e<v;e++)w.push(new C(y));let T=Math.ceil(l/m),E=new Uint8Array(y).fill(255),D=null,O=!1;if(b%8==0){if(S&&_&&v>1){let o=Math.round(i.length/v);for(let s=0;s<o;s++){let o=Math.floor(s/T)*h,c=s%T*m,d=o*l+c;for(let f=0;f<v;f++){let p=s*v+f;a[p]===0?(D=null,O=!0):D=await x({input:e,isTiffLittleEndian:t.littleEndian,ifd:n,offset:i[p],size:a[p]},r);let g=Math.min(m,l-c),_=Math.min(h,u-o),y=w[f];for(let e=0;e<_;e++){let t=d+e*l,n=e*m;for(let e=0;e<g;e++,t++,n++)D?y[t]=D[n]:E[t]=0}}}}else for(let o=0;o<i.length;o++){let s=Math.floor(o/T)*h,c=o%T*m,d=s*l+c;a[o]===0?(D=null,O=!0):D=await x({input:e,isTiffLittleEndian:t.littleEndian,ifd:n,offset:i[o],size:a[o]},r);let f=Math.min(m,l-c),p=Math.min(h,u-s);for(let e=0;e<v;e++){let t=w[e];if(_||S)for(let n=0;n<p;n++){let r=d+n*l,i=m*h*e+n*m;for(let e=0;e<f;e++,r++,i++)D?t[r]=D[i]:E[r]=0}else for(let n=0;n<p;n++){let r=d+n*l,i=n*m*v+e;for(let e=0;e<f;e++,r++,i+=v)D?t[r]=D[i]:E[r]=0}}}}return{width:l,height:u,pixelType:p,pixels:w,mask:O?E:void 0}}async function C(e,t,n,r){let a=p===t.littleEndian,o=d(n,`STRIPOFFSETS`),l=d(n,`STRIPBYTECOUNTS`);if(o==null||l==null)return null;let{width:u,height:h,pixelType:_}=f([n]),b=s(n,`SAMPLESPERPIXEL`)||t.planes,x=s(n,`PHOTOMETRICINTERPRETATION`),S=u*h,C=s(n,`BITSPERSAMPLE`),w=g(_),T=new w(S*b),E=s(n,`ROWSPERSTRIP`),D=c(n),O,k,A,j;if(C%8==0)for(let n=0;n<o.length;n++){let s=E*u*n*b;if(_===`u8`||_===`s8`||a)D===8||D===32946?(A=new Uint8Array(e,o[n],l[n]),A=await m(A,void 0,r),k=A.buffer):D===6?(A=new Uint8Array(e,o[n],l[n]),A=y(A,b,x),k=A.buffer):D===5?(A=i(e,o[n],l[n],t.littleEndian),k=A.buffer):k=e.slice(o[n],o[n]+l[n]),k=v(k,C),O=new w(k);else{switch(D===6||D===8||D===32946?(A=new Uint8Array(e,o[n],l[n]),j=await m(A,void 0,r),k=j.buffer):(k=new ArrayBuffer(l[n]),A=new Uint8Array(e,o[n],l[n]),j=new Uint8Array(k)),_){case`u16`:case`s16`:for(let e=0;e<A.length;e+=2)j[e]=A[e+1],j[e+1]=A[e];break;case`u32`:case`s32`:case`f32`:for(let e=0;e<A.length;e+=4)j[e]=A[e+3],j[e+1]=A[e+2],j[e+2]=A[e+1],j[e+3]=A[e]}k=v(k,C),O=new w(k)}T.set(O,s)}let M=[];if(b===1)M.push(T);else for(let e=0;e<b;e++){let t=new w(S);for(let n=0;n<S;n++)t[n]=T[n*b+e];M.push(t)}return{width:u,height:h,pixelType:_,pixels:M}}function w(e,t,n){if(!(e&&e.length>0&&t&&n))return null;let r,i,a,o=e[0].length,s=e.length,c=new Uint8Array(o);for(let l=0;l<s;l++)if(r=e[l],i=t[l],a=n[l],l===0)for(let e=0;e<o;e++)c[e]=r[e]<i||r[e]>a?0:1;else for(let e=0;e<o;e++)c[e]&&(c[e]=r[e]<i||r[e]>a?0:1);return c}function T(e,t,n,r,i){let a=r?4:1,o=n*a*i;r&&(e=new Uint8Array(e.buffer));for(let n=0;n<t;n++){let t=n*o;for(let n=i;n<o;n++)e[t+n]+=e[t+n-i]}if(!r)return e;let s=new Uint8Array(e.length),c=n*i;for(let n=0;n<t;n++){let t=n*o;for(let n=0;n<c;n++)for(let r=0;r<a;r++)s[t+n*a+r]=e[t+n+(a-r-1)*c]}return new Float32Array(s.buffer)}async function E(e,t,n){let{headerInfo:r,ifd:i,offsets:l,sizes:u}=t,d=[];for(let t=0;t<l.length;t++){+(u[t]===0);let a=await x({input:e,isTiffLittleEndian:r.littleEndian,ifd:i,offset:l[t],size:u[t]||e.byteLength},n);d.push(a)}let f=o(i,r),p=s(i,`BITSPERSAMPLE`),m=h(s(i,`SAMPLEFORMAT`)??1,p),_=s(i,`SAMPLESPERPIXEL`)||r.planes,v=g(m),y=s(i,`TILEWIDTH`),b=s(i,`TILELENGTH`),S=c(i)===34887,C=y*b,T,E=[],D=d[0];for(let e=0;e<_;e++){if(T=new v(C),d.length===_)D=d[e],D.length===C&&(T=D);else if(D.length){if(f||S)T=D.length===C?D:D.slice(C*e,C*(e+1));else for(let t=0;t<C;t++)T[t]=D[t*_+e]}E.push(T)}let O=r.noData?r.noData[0]:t.noDataValue,k=r.metadata?r.metadata.statistics:null,A=k?k.map(e=>e.min):null,j=k?k.map(e=>e.max):null,M={pixelType:m,width:y,height:b,pixels:E,noDataValue:O};return O==null?A&&j&&t.applyMinMaxConstraint&&(M.mask=w(E,A,j)):a(M,O,{matchAllNoData:t?.matchAllNoData}),M}async function D(t,n={},r){let i=n.pyramidLevel||0,o=n.headerInfo||l(t),{ifds:s,noData:c}=o;if(s.length===0)throw new e(`tiff-reader:decode`,`no valid image file directory`);let d=u(o);if(d)throw new e(`tiff-reader:decode`,d);let f=i===-1?s[s.length-1]:s[i],p=c??n.noDataValue,m=o.tileWidth?await S(t,o,f,r):await C(t,o,f,r);if(!m)return m;if(p!=null){let e=c==null&&n?.matchAllNoData;a(m,p,{matchAllNoData:e})}return m}export{D as decode,E as decodeTileOrStrip};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- function e(e){if(e.length<2)return!1;let[t,n]=e.subarray(0,2),r=t&15,i=t>>4;return r!==8||i>7?!1:((t<<8|n)&65535)%31==0}function t(e){return e.length>=2&&e[0]===31&&e[1]===139}function n(n){return t(n)?`gzip`:e(n)?`deflate`:null}async function r(e,t){t??=n(e)??`deflate-raw`;let r=new Response(e).body.pipeThrough(new DecompressionStream(t)),i=await new Response(r).arrayBuffer();return new Uint8Array(i)}export{r as inflate};
2
+ function e(e){if(e.length<2)return!1;let[t,n]=e.subarray(0,2),r=t&15,i=t>>4;return r!==8||i>7?!1:((t<<8|n)&65535)%31==0}function t(e){return e.length>=2&&e[0]===31&&e[1]===139}function n(n){return t(n)?`gzip`:e(n)?`deflate`:null}async function r(e,t,r){t??=n(e)??`deflate-raw`;let i=new Response(e).body,a={signal:r?.signal??void 0},o=i.pipeThrough(new DecompressionStream(t),a),s=await new Response(o).arrayBuffer();return new Uint8Array(s)}export{r as inflate};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../geometry/Extent.js";import t from"../../geometry/Point.js";import n from"../../geometry/operators/support/GeographicTransformation.js";import{decode as r}from"../raster/formats/RasterCodec.js";import{transformPixels as i}from"../raster/functions/pixelTransformUtils.js";import{convertPixelBlockToFeatures as a,compositeBands as o,highlightPixels as s,split as c,clipTile as l,mosaicPixelData as u,mosaic as d,approximateTransform as f,getLocalArithmeticNorthRotations as p}from"../raster/functions/pixelUtils.js";import{create as m}from"../raster/functions/rasterFunctionHelper.js";import{load as h,getProjectionOffsetGrid as g}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as _,estimateStatisticsHistograms as v}from"../raster/functions/stretchUtils.js";import{convertVectorFieldData as y,sampleVectorField as b,convertToLocalDirections as x}from"../raster/functions/vectorFieldUtils.js";import{readTransform as S}from"../raster/transforms/utils.js";import C from"./PixelBlock.js";import w from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as T}from"../../views/2d/engine/flow/dataUtils.js";function E(e){if(!e)return{result:null,transferList:[]};let{pixelBlock:t,transferList:n}=e.getTransferableObject();return{result:t,transferList:n}}class D{convertVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(y(t,e.type));return Promise.resolve(n)}convertPixelBlockToFeatures(t){let n=a({pixelBlock:C.fromJSON(t.pixelBlock),extent:e.fromJSON(t.extent),fieldNames:t.fieldNames,skipFactor:t.skipFactor,skipSpatialReference:!0,pixelIdOffset:t.pixelIdOffset,imageRowSize:t.imageRowSize});return Promise.resolve(n)}sampleVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(b(t,e.srcDataType,e.tileSize,e.offset,e.maximumVoidPercentage));return Promise.resolve(n)}transformPixels(e){let t=C.fromJSON(e.pixelBlock),n=i(t,e.transformType,e.transformParameters);return Promise.resolve(E(n))}computeStatisticsHistograms(e){let t=C.fromJSON(e.pixelBlock),n=_(t,{histogramSize:e.histogramSize,includeSkewnessKurtosis:e.includeSkewnessKurtosis});return Promise.resolve(n)}compositeBands(e){let t=e.pixelBlocks.map(e=>e&&C.fromJSON(e)),n=E(o(t));return Promise.resolve(n)}async decode(e){return E(await r(e.data,e.options))}symbolize(t){let n=t.pixelBlock?C.fromJSON(t.pixelBlock):null,r=t.extent?e.fromJSON(t.extent):null,i=E(this.symbolizer.symbolize({...t,pixelBlock:n,extent:r}));return Promise.resolve(i)}highlightPixels(e){let t=C.fromJSON(e.pixelBlock),n=C.fromJSON(e.renderedPixelBlock);return s({pixelBlock:t,renderedPixelBlock:n,highlightOptions:e.highlightOptions}),Promise.resolve(n.toJSON())}async updateSymbolizer(e){this.symbolizer=w.fromJSON(e.symbolizerJSON),e.histograms&&this.symbolizer?.rendererJSON.type===`rasterStretch`&&(this.symbolizer.rendererJSON.histograms=e.histograms)}async updateRasterFunction(e){this.rasterFunction=m(e.rasterFunctionJSON)}async process(n){return E(this.rasterFunction.process({extent:e.fromJSON(n.extent),primaryPixelBlocks:n.primaryPixelBlocks.map(e=>e==null?null:C.fromJSON(e)),primaryPixelSizes:n.primaryPixelSizes?.map(e=>e==null?null:t.fromJSON(e)),primaryRasterIds:n.primaryRasterIds},n.parameters))}stretch(e){let t=E(this.symbolizer.simpleStretch(C.fromJSON(e.srcPixelBlock),e.stretchParams));return Promise.resolve(t)}estimateStatisticsHistograms(e){let t=v(C.fromJSON(e.srcPixelBlock));return Promise.resolve(t)}split(e){let t=c(C.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel??0,e.useBilinear===!1),n=[],r;return t&&(r=new Map,t.forEach((e,t)=>{if(e){let{pixelBlock:i,transferList:a}=e.getTransferableObject();r.set(t,i),a.forEach(e=>{n.includes(e)||n.push(e)})}})),Promise.resolve({result:r,transferList:n})}clipTile(e){let t=C.fromJSON(e.pixelBlock),n=E(l({...e,pixelBlock:t}));return Promise.resolve(n)}mosaicPixelData(t){let n=t.pixelData.map(t=>({extent:e.fromJSON(t.extent),pixelBlock:t.pixelBlock?C.fromJSON(t.pixelBlock):null})),r=e.fromJSON(t.destExtent),i=E(u(n,r)?.pixelBlock);return Promise.resolve(i)}async mosaicAndTransform(e){let t=e.srcPixelBlocks.map(e=>e?new C(e):null),n=d(t,e.srcMosaicSize,{blockWidths:e.blockWidths,alignmentInfo:e.alignmentInfo,clipOffset:e.clipOffset,clipSize:e.clipSize}),r=n;e.coefs&&(r=f(n,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation));let i;e.projectDirections&&e.gcsGrid&&(i=p(e.destDimension,e.gcsGrid),r=x(r,e.isUV?`vector-uv`:`vector-magdir`,i));let{result:a,transferList:o}=E(r);return{result:{pixelBlock:a,localNorthDirections:i},transferList:o}}async createFlowMesh(e,t){let n={data:new Float32Array(e.flowData.buffer),mask:new Uint8Array(e.flowData.maskBuffer),width:e.flowData.width,height:e.flowData.height},{vertexData:r,indexData:i,pathData:a}=await T(e.meshType,e.simulationSettings,n,e.startInfo,t.signal);return{result:{vertexBuffer:r.buffer,indexBuffer:i.buffer,pathBuffer:a.buffer},transferList:[r.buffer,i.buffer]}}async getProjectionOffsetGrid(t){let r=e.fromJSON(t.projectedExtent),i=e.fromJSON(t.srcBufferExtent),a=null;t.datumTransformationSteps?.length&&(a=new n({steps:t.datumTransformationSteps})),await h();let o=t.rasterTransform?S(t.rasterTransform):null;return g({...t,projectedExtent:r,srcBufferExtent:i,datumTransformation:a,rasterTransform:o})}}export{D as default};
2
+ import e from"../../geometry/Extent.js";import t from"../../geometry/Point.js";import n from"../../geometry/operators/support/GeographicTransformation.js";import{decode as r}from"../raster/formats/RasterCodec.js";import{transformPixels as i}from"../raster/functions/pixelTransformUtils.js";import{convertPixelBlockToFeatures as a,compositeBands as o,highlightPixels as s,split as c,clipTile as l,mosaicPixelData as u,mosaic as d,approximateTransform as f,getLocalArithmeticNorthRotations as p}from"../raster/functions/pixelUtils.js";import{create as m}from"../raster/functions/rasterFunctionHelper.js";import{load as h,getProjectionOffsetGrid as g}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as _,estimateStatisticsHistograms as v}from"../raster/functions/stretchUtils.js";import{convertVectorFieldData as y,sampleVectorField as b,convertToLocalDirections as x}from"../raster/functions/vectorFieldUtils.js";import{readTransform as S}from"../raster/transforms/utils.js";import C from"./PixelBlock.js";import w from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as T}from"../../views/2d/engine/flow/dataUtils.js";function E(e){if(!e)return{result:null,transferList:[]};let{pixelBlock:t,transferList:n}=e.getTransferableObject();return{result:t,transferList:n}}class D{convertVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(y(t,e.type));return Promise.resolve(n)}convertPixelBlockToFeatures(t){let n=a({pixelBlock:C.fromJSON(t.pixelBlock),extent:e.fromJSON(t.extent),fieldNames:t.fieldNames,skipFactor:t.skipFactor,skipSpatialReference:!0,pixelIdOffset:t.pixelIdOffset,imageRowSize:t.imageRowSize});return Promise.resolve(n)}sampleVectorFieldData(e){let t=C.fromJSON(e.pixelBlock),n=E(b(t,e.srcDataType,e.tileSize,e.offset,e.maximumVoidPercentage));return Promise.resolve(n)}transformPixels(e){let t=C.fromJSON(e.pixelBlock),n=i(t,e.transformType,e.transformParameters);return Promise.resolve(E(n))}computeStatisticsHistograms(e){let t=C.fromJSON(e.pixelBlock),n=_(t,{histogramSize:e.histogramSize,includeSkewnessKurtosis:e.includeSkewnessKurtosis});return Promise.resolve(n)}compositeBands(e){let t=e.pixelBlocks.map(e=>e&&C.fromJSON(e)),n=E(o(t));return Promise.resolve(n)}async decode(e,t){return E(await r(e.data,e.options,{signal:t?.signal}))}symbolize(t){let n=t.pixelBlock?C.fromJSON(t.pixelBlock):null,r=t.extent?e.fromJSON(t.extent):null,i=E(this.symbolizer.symbolize({...t,pixelBlock:n,extent:r}));return Promise.resolve(i)}highlightPixels(e){let t=C.fromJSON(e.pixelBlock),n=C.fromJSON(e.renderedPixelBlock);return s({pixelBlock:t,renderedPixelBlock:n,highlightOptions:e.highlightOptions}),Promise.resolve(n.toJSON())}async updateSymbolizer(e){this.symbolizer=w.fromJSON(e.symbolizerJSON),e.histograms&&this.symbolizer?.rendererJSON.type===`rasterStretch`&&(this.symbolizer.rendererJSON.histograms=e.histograms)}async updateRasterFunction(e){this.rasterFunction=m(e.rasterFunctionJSON)}async process(n){return E(this.rasterFunction.process({extent:e.fromJSON(n.extent),primaryPixelBlocks:n.primaryPixelBlocks.map(e=>e==null?null:C.fromJSON(e)),primaryPixelSizes:n.primaryPixelSizes?.map(e=>e==null?null:t.fromJSON(e)),primaryRasterIds:n.primaryRasterIds},n.parameters))}stretch(e){let t=E(this.symbolizer.simpleStretch(C.fromJSON(e.srcPixelBlock),e.stretchParams));return Promise.resolve(t)}estimateStatisticsHistograms(e){let t=v(C.fromJSON(e.srcPixelBlock));return Promise.resolve(t)}split(e){let t=c(C.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel??0,e.useBilinear===!1),n=[],r;return t&&(r=new Map,t.forEach((e,t)=>{if(e){let{pixelBlock:i,transferList:a}=e.getTransferableObject();r.set(t,i),a.forEach(e=>{n.includes(e)||n.push(e)})}})),Promise.resolve({result:r,transferList:n})}clipTile(e){let t=C.fromJSON(e.pixelBlock),n=E(l({...e,pixelBlock:t}));return Promise.resolve(n)}mosaicPixelData(t){let n=t.pixelData.map(t=>({extent:e.fromJSON(t.extent),pixelBlock:t.pixelBlock?C.fromJSON(t.pixelBlock):null})),r=e.fromJSON(t.destExtent),i=E(u(n,r)?.pixelBlock);return Promise.resolve(i)}async mosaicAndTransform(e){let t=e.srcPixelBlocks.map(e=>e?new C(e):null),n=d(t,e.srcMosaicSize,{blockWidths:e.blockWidths,alignmentInfo:e.alignmentInfo,clipOffset:e.clipOffset,clipSize:e.clipSize}),r=n;e.coefs&&(r=f(n,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation));let i;e.projectDirections&&e.gcsGrid&&(i=p(e.destDimension,e.gcsGrid),r=x(r,e.isUV?`vector-uv`:`vector-magdir`,i));let{result:a,transferList:o}=E(r);return{result:{pixelBlock:a,localNorthDirections:i},transferList:o}}async createFlowMesh(e,t){let n={data:new Float32Array(e.flowData.buffer),mask:new Uint8Array(e.flowData.maskBuffer),width:e.flowData.width,height:e.flowData.height},{vertexData:r,indexData:i,pathData:a}=await T(e.meshType,e.simulationSettings,n,e.startInfo,t.signal);return{result:{vertexBuffer:r.buffer,indexBuffer:i.buffer,pathBuffer:a.buffer},transferList:[r.buffer,i.buffer]}}async getProjectionOffsetGrid(t){let r=e.fromJSON(t.projectedExtent),i=e.fromJSON(t.srcBufferExtent),a=null;t.datumTransformationSteps?.length&&(a=new n({steps:t.datumTransformationSteps})),await h();let o=t.rasterTransform?S(t.rasterTransform):null;return g({...t,projectedExtent:r,srcBufferExtent:i,datumTransformation:a,rasterTransform:o})}}export{D as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.0-next.155",
3
+ "version": "5.2.0-next.156",
4
4
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
5
5
  "keywords": [
6
6
  "ArcGIS",
@@ -20,7 +20,7 @@
20
20
  "license": "SEE LICENSE IN LICENSE.md",
21
21
  "dependencies": {
22
22
  "@amcharts/amcharts5": "~5.20.8",
23
- "@arcgis/toolkit": "5.2.0-next.155",
23
+ "@arcgis/toolkit": "5.2.0-next.156",
24
24
  "@esri/arcgis-html-sanitizer": "~4.2.0-next.2",
25
25
  "@esri/calcite-components": "^5.2.0-next.89",
26
26
  "@vaadin/grid": "~25.3.2",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../Graphic.js";import{FeatureSetQueryInterceptor as n}from"../arcade/featureset/support/FeatureSetQueryInterceptor.js";import r from"../core/Accessor.js";import{isSome as i}from"../core/arrayUtils.js";import{createTask as a}from"../core/asyncUtils.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import s from"../core/Logger.js";import{abortMaybe as c}from"../core/maybe.js";import{eachAlways as l,isAbortError as u,throwIfAborted as d}from"../core/promiseUtils.js";import{watch as f,initial as p,when as m}from"../core/reactiveUtils.js";import{throttle as h}from"../core/throttle.js";import{property as g,subclass as _}from"../core/accessorSupport/decorators.js";import v from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import{ActionsCollection as b,createDefaultAggregateActions as x,createDefaultActions as S}from"./actions.js";import C from"./content/TextContent.js";import{compileExpressionInfos as w,formatArcadeValue as T}from"./support/arcadeFeatureUtils.js";import E from"./support/FeatureAbilities.js";import{preLayerQueryCallback as D,preRequestCallback as O,getPopupLayer as k,createFieldInfoMap as A,getAllFieldInfos as j,querySourceLayer as M,queryUpdatedFeature as N,isRelatableFeatureSupportedLayer as P,isAssociatedFeatureSupportedLayer as F,formatEditInfo as I,substituteFieldsInLinksAndAttributes as L,graphicCallback as R,formatAttributes as z,isRelatedField as B}from"./support/featureUtils.js";import{queryLayerInfos as V,queryRelatedFeatures as H,setRelatedFeatures as U,getRelatedFieldInfo as W,createRelatedInfo as G,updateRelatedInfo as K}from"./support/relatedFeatureUtils.js";import{system as q}from"../time/constants.js";var J;let Y=class extends o(r){static{J=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._graphicExpressionAttributes=null,this.abilities=new E,this.content=null,this.description=null,this.actions=new b,this.includeDefaultActions=!1,this.defaultPopupTemplateEnabled=!1,this.expressionAttributes=null,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.heading=``,this.view=null,this._graphicChangedThrottled=h(this._graphicChanged,()=>this.notifyChange(`waitingForContent`),1,this),this._isAllowedContentType=e=>{let{abilities:t}=this;return e.type===`attachments`&&!!t.attachmentsContent||e.type===`custom`&&!!t.customContent||e.type===`fields`&&!!t.fieldsContent||e.type===`media`&&!!t.mediaContent||e.type===`text`&&!!t.textContent||e.type===`expression`&&!!t.expressionContent||e.type===`relationship`&&!!t.relationshipContent||e.type===`utility-network-associations`&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=h(this._evaluateExpressionAttributes,()=>this.notifyChange(`waitingForContent`),1,this),this.addHandles([f(()=>[this._effectivePopupTemplate,this.abilities.attachmentsContent,this.abilities.chartAnimation,this.abilities.customContent,this.abilities.expressionContent,this.abilities.fieldsContent,this.abilities.mediaContent,this.abilities.relationshipContent,this.abilities.textContent,this.abilities.utilityNetworkAssociationsContent,this.graphic,this.timeZone],()=>this._graphicChangedThrottled(),p),m(()=>{if(!this._graphicChangedTask?.finished||this._graphicChangedTask.value==null)return null;let e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has(`view-scale`)?this.view?.scale:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.start:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.end:null]},([e])=>this._evaluateExpressionAttributesThrottled(e))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=c(this._graphicChangedTask),this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this.relatedInfos.clear()}static{this.interceptor=new n(D,O)}get _effectivePopupTemplate(){return this.graphic?.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled)??null}get _fieldInfoMap(){let e=k(this.graphic);return A(j(this._effectivePopupTemplate),e)}get defaultActions(){let e=this._get(`defaultActions`)||new b;return e.removeAll(),e.addMany(this.graphic?.isAggregate?x():S()),e}get allActions(){let e=this._get(`allActions`)||new b,{actions:t,defaultPopupTemplateEnabled:n,includeDefaultActions:r,graphic:a}=this,o=[];if(a){let e=r?this.defaultActions.concat(t):t,s=typeof a.getEffectivePopupTemplate==`function`&&a.getEffectivePopupTemplate(n)||a.popupTemplate,c=s?.actions;o=(s?.overwriteActions?c:c?.concat(e)??e)?.filter(i).toArray()??[]}let s=e.toArray();return(s.length!==o.length||s.some((e,t)=>e!==o[t]))&&(e.removeAll(),e.addMany(o)),e}get isFeatureFromTable(){return k(this.graphic)?.isTable??!1}get state(){return this.graphic?this._error?`error`:this.waitingForContent?`loading`:`ready`:`disabled`}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get timeZone(){return this.view?.timeZone??q}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get map(){return this.view?.map||null}set map(e){this._override(`map`,e)}get waitingForContent(){let{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:n,_evaluateExpressionAttributesTask:r}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||n!=null&&!n.finished||r!=null&&!r.finished}async updateGeometry(){let{graphic:e,spatialReference:t}=this,n=k(e);await n?.load();let r=n?.objectIdField;if(!r||!e)return;let i=e.attributes?.[r];if(i==null)return;let a=(await M({layer:n,graphic:e,outFields:[],objectIds:[i],returnGeometry:!0,spatialReference:t}))?.geometry;a&&(e.geometry=a)}_clear(){this._set(`heading`,``),this._set(`content`,null),this._set(`formattedAttributes`,null),this._set(`expressionAttributes`,null)}_graphicChanged(){this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._graphicChangedTask=c(this._graphicChangedTask),this._graphicChangedTask=a(async e=>{this._error=null,this._clear();let{graphic:t}=this;try{if(!t)return null;let{_effectivePopupTemplate:n}=this,r=k(t),i=this.spatialReference;await N({graphic:t,popupTemplate:n,layer:r,spatialReference:i},{signal:e});let[{value:a},{value:o}]=await l([this._getContent(),this._getTitle()]),[,{value:s}]=await l([this._checkForRelatedFeatures({signal:e}),w(n?.expressionInfos,t)]);return{expressionInfos:s,content:a,heading:o}}catch(e){throw u(e)||(this._error=e,s.getLogger(this).error(`error`,`The popupTemplate could not be displayed for this feature.`,{error:e,graphic:t,popupTemplate:this._effectivePopupTemplate})),e}})}_compileContentElement(e){let t=k(this.graphic);return e.type===`relationship`?P(t)?e:void 0:e.type===`utility-network-associations`?F(t)?e:void 0:e}_compileContent(e){if(this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(e=>this._compileContentElement(e)).filter(i):typeof e==`string`?new C({text:e}).text:e}_compileLastEditInfo(){let{_effectivePopupTemplate:e,graphic:t,timeZone:n}=this,r=k(t);if(!e)return;let{lastEditInfoEnabled:i}=e,a=r?.editFieldsInfo;if(i&&a)return I(a,t?.attributes,n,r)}_compileHeading(e){let{_fieldInfoMap:t,graphic:n,expressionAttributes:r}=this,i=k(n),a=n?.attributes??{},o=this.formattedAttributes?.global??{};return L({attributes:a,fieldInfoMap:t,globalAttributes:o,expressionAttributes:r,layer:i,text:e})}async _getTitle(){let{_effectivePopupTemplate:e,graphic:t}=this;return t?R({type:`title`,value:e?.title,event:{graphic:t}}):null}async _getContent(){let{_effectivePopupTemplate:e,graphic:t}=this;return t?R({type:`content`,value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({heading:e,content:t,expressionInfos:n}){this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=a(async r=>{let{graphic:i,map:a,view:o,spatialReference:c,location:l}=this;try{if(!i)return;let s;if(n!=null){let e=[];for(let[t,s]of n.expressions.entries())s==null?e.push(Promise.resolve([t,void 0])):e.push(s.evaluate({graphic:i,interceptor:J.interceptor,location:l,map:a,options:{signal:r},spatialReference:c,view:o}).then(e=>[t,typeof e==`string`?T(e):e]).catch(()=>[t,void 0]));s=Object.fromEntries(await Promise.all(e)),d(r)}this._set(`expressionAttributes`,s??null),this._graphicExpressionAttributes={...i.attributes,...s},this._set(`formattedAttributes`,this._createFormattedAttributes(t)),this._set(`heading`,this._compileHeading(e)),this._set(`lastEditInfo`,this._compileLastEditInfo()||null),this._set(`content`,this._compileContent(t)||null)}catch(e){u(e)||(this._error=e,s.getLogger(this).error(`error`,`The popupTemplate could not be displayed for this feature.`,{error:e,graphic:i,popupTemplate:this._effectivePopupTemplate}))}})}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:n}){let{_effectivePopupTemplate:r,graphic:i,relatedInfos:a,_fieldInfoMap:o,_graphicExpressionAttributes:s,timeZone:c}=this,l=k(i);n.content[t]=z({attributes:{...s,...e.attributes},fieldInfoMap:o,fieldInfos:r?.fieldInfos,graphic:i,layer:l,relatedInfos:a,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:n}){if(e.fieldInfos){let{graphic:r,relatedInfos:i,_fieldInfoMap:a,_graphicExpressionAttributes:o,timeZone:s}=this,c=k(r);n.content[t]=z({attributes:{...o,...e.attributes},fieldInfoMap:a,fieldInfos:e.fieldInfos,graphic:r,isContentFieldInfos:!0,layer:c,relatedInfos:i,timeZone:s})}}_createFormattedAttributes(e){let{_effectivePopupTemplate:t,graphic:n,relatedInfos:r,_fieldInfoMap:i,_graphicExpressionAttributes:a,timeZone:o}=this,s=k(n),c=t?.fieldInfos,l={global:z({attributes:a,fieldInfoMap:i,fieldInfos:c,graphic:n,layer:s,relatedInfos:r,timeZone:o}),content:[]};return Array.isArray(e)&&e.forEach((e,t)=>{e.type===`fields`&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l}),e.type===`media`&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l})}),l}_checkForRelatedFeatures(e){let{graphic:t,_effectivePopupTemplate:n}=this;return this._queryRelatedInfos(t,j(n),e)}async _queryRelatedInfos(e,t,n){let{relatedInfos:r}=this,i=k(e);r.clear();let a=await i?.associatedLayer?.load(n)??i;if(!a||!e||!t.filter(e=>!!e.fieldName&&B(e.fieldName))?.length)return;t.forEach(e=>this._configureRelatedInfo(e,a));let o=await V({relatedInfos:r,layer:a},n);Object.keys(o).forEach(e=>{let t=r.get(e.toString()),n=o[e]?.value;t&&n&&(t.layerInfo=n.data)});let s=await H({graphic:e,relatedInfos:r,layer:a},n);Object.keys(s).forEach(e=>{U(s[e]?.value,r.get(e.toString()))})}_configureRelatedInfo(e,t){let{relatedInfos:n}=this,r=W(e.fieldName||``);if(!r)return;let{layerId:i,fieldName:a}=r;if(!i)return;let o=n.get(i.toString())||G(i,t);o&&(K({relatedInfo:o,fieldName:a,fieldInfo:e}),this.relatedInfos.set(i,o))}};e([g()],Y.prototype,`_error`,void 0),e([g()],Y.prototype,`_graphicChangedTask`,void 0),e([g()],Y.prototype,`_evaluateExpressionAttributesTask`,void 0),e([g({readOnly:!0})],Y.prototype,`_effectivePopupTemplate`,null),e([g({readOnly:!0})],Y.prototype,`_fieldInfoMap`,null),e([g({type:E})],Y.prototype,`abilities`,void 0),e([g({readOnly:!0})],Y.prototype,`content`,void 0),e([g()],Y.prototype,`description`,void 0),e([g({type:b,readOnly:!0})],Y.prototype,`defaultActions`,null),e([g({type:b})],Y.prototype,`actions`,void 0),e([g()],Y.prototype,`includeDefaultActions`,void 0),e([g({type:b,readOnly:!0})],Y.prototype,`allActions`,null),e([g({type:Boolean})],Y.prototype,`defaultPopupTemplateEnabled`,void 0),e([g({readOnly:!0})],Y.prototype,`expressionAttributes`,void 0),e([g({readOnly:!0})],Y.prototype,`isFeatureFromTable`,null),e([g({readOnly:!0})],Y.prototype,`state`,null),e([g({readOnly:!0})],Y.prototype,`formattedAttributes`,void 0),e([g({type:t})],Y.prototype,`graphic`,void 0),e([g({readOnly:!0})],Y.prototype,`lastEditInfo`,void 0),e([g({type:v})],Y.prototype,`location`,void 0),e([g({readOnly:!0})],Y.prototype,`relatedInfos`,void 0),e([g({type:y})],Y.prototype,`spatialReference`,null),e([g()],Y.prototype,`timeZone`,null),e([g({readOnly:!0})],Y.prototype,`heading`,void 0),e([g()],Y.prototype,`map`,null),e([g({readOnly:!0})],Y.prototype,`waitingForContent`,null),e([g()],Y.prototype,`view`,void 0),Y=J=e([_(`esri.popup.FeatureModel`)],Y);const X=Y;export{X as default};
2
+ import{__decorate as e}from"tslib";import t from"../Graphic.js";import{FeatureSetQueryInterceptor as n}from"../arcade/featureset/support/FeatureSetQueryInterceptor.js";import r from"../core/Accessor.js";import{isSome as i}from"../core/arrayUtils.js";import{createTask as a}from"../core/asyncUtils.js";import{IdentifiableMixin as o}from"../core/Identifiable.js";import s from"../core/Logger.js";import{abortMaybe as c}from"../core/maybe.js";import{eachAlways as l,isAbortError as u,throwIfAborted as d}from"../core/promiseUtils.js";import{watch as f,initial as p,when as m}from"../core/reactiveUtils.js";import{throttle as h}from"../core/throttle.js";import{property as g,subclass as _}from"../core/accessorSupport/decorators.js";import v from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import{ActionsCollection as b,createDefaultAggregateActions as x,createDefaultActions as S}from"./actions.js";import C from"./content/TextContent.js";import{compileExpressionInfos as w,formatArcadeValue as T}from"./support/arcadeFeatureUtils.js";import E from"./support/FeatureAbilities.js";import{preLayerQueryCallback as D,preRequestCallback as O,getPopupLayer as k,createFieldInfoMap as A,getAllFieldInfos as j,querySourceLayer as M,queryUpdatedFeature as N,isRelatableFeatureSupportedLayer as P,isAssociatedFeatureSupportedLayer as F,formatEditInfo as I,substituteFieldsInLinksAndAttributes as L,graphicCallback as R,formatAttributes as z,isRelatedField as B}from"./support/featureUtils.js";import{queryLayerInfos as V,queryRelatedFeatures as H,setRelatedFeatures as U,getRelatedFieldInfo as W,createRelatedInfo as G,updateRelatedInfo as K}from"./support/relatedFeatureUtils.js";import{system as q}from"../time/constants.js";var J;let Y=class extends o(r){static{J=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._graphicExpressionAttributes=null,this.abilities=new E,this.content=null,this.description=null,this.actions=new b,this.includeDefaultActions=!1,this.defaultPopupTemplateEnabled=!1,this.expressionAttributes=null,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.heading=``,this.view=null,this._graphicChangedThrottled=h(this._graphicChanged,()=>{this._evaluateExpressionAttributesThrottled.remove(),this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._graphicChangedTask=c(this._graphicChangedTask),this.notifyChange(`waitingForContent`)},1,this),this._isAllowedContentType=e=>{let{abilities:t}=this;return e.type===`attachments`&&!!t.attachmentsContent||e.type===`custom`&&!!t.customContent||e.type===`fields`&&!!t.fieldsContent||e.type===`media`&&!!t.mediaContent||e.type===`text`&&!!t.textContent||e.type===`expression`&&!!t.expressionContent||e.type===`relationship`&&!!t.relationshipContent||e.type===`utility-network-associations`&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=h(this._evaluateExpressionAttributes,()=>this.notifyChange(`waitingForContent`),1,this),this.addHandles([f(()=>[this._effectivePopupTemplate,this.abilities.attachmentsContent,this.abilities.chartAnimation,this.abilities.customContent,this.abilities.expressionContent,this.abilities.fieldsContent,this.abilities.mediaContent,this.abilities.relationshipContent,this.abilities.textContent,this.abilities.utilityNetworkAssociationsContent,this.graphic,this.timeZone],()=>this._graphicChangedThrottled(),p),m(()=>{if(!this._graphicChangedTask?.finished||this._graphicChangedTask.value==null)return null;let e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has(`view-scale`)?this.view?.scale:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.start:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.end:null]},([e])=>this._evaluateExpressionAttributesThrottled(e))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=c(this._graphicChangedTask),this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this.relatedInfos.clear()}static{this.interceptor=new n(D,O)}get _effectivePopupTemplate(){return this.graphic?.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled)??null}get _fieldInfoMap(){let e=k(this.graphic);return A(j(this._effectivePopupTemplate),e)}get defaultActions(){let e=this._get(`defaultActions`)||new b;return e.removeAll(),e.addMany(this.graphic?.isAggregate?x():S()),e}get allActions(){let e=this._get(`allActions`)||new b,{actions:t,defaultPopupTemplateEnabled:n,includeDefaultActions:r,graphic:a}=this,o=[];if(a){let e=r?this.defaultActions.concat(t):t,s=typeof a.getEffectivePopupTemplate==`function`&&a.getEffectivePopupTemplate(n)||a.popupTemplate,c=s?.actions;o=(s?.overwriteActions?c:c?.concat(e)??e)?.filter(i).toArray()??[]}let s=e.toArray();return(s.length!==o.length||s.some((e,t)=>e!==o[t]))&&(e.removeAll(),e.addMany(o)),e}get isFeatureFromTable(){return k(this.graphic)?.isTable??!1}get state(){return this.graphic?this._error?`error`:this.waitingForContent?`loading`:`ready`:`disabled`}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get timeZone(){return this.view?.timeZone??q}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get map(){return this.view?.map||null}set map(e){this._override(`map`,e)}get waitingForContent(){let{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:n,_evaluateExpressionAttributesTask:r}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||n!=null&&!n.finished||r!=null&&!r.finished}async updateGeometry(){let{graphic:e,spatialReference:t}=this,n=k(e);await n?.load();let r=n?.objectIdField;if(!r||!e)return;let i=e.attributes?.[r];if(i==null)return;let a=(await M({layer:n,graphic:e,outFields:[],objectIds:[i],returnGeometry:!0,spatialReference:t}))?.geometry;a&&(e.geometry=a)}_clear(){this._set(`heading`,``),this._set(`content`,null),this._set(`formattedAttributes`,null),this._set(`expressionAttributes`,null)}_graphicChanged(){this._graphicChangedTask=a(async e=>{this._error=null;let{graphic:t}=this;try{if(!t)return this._clear(),null;let{_effectivePopupTemplate:n}=this,r=k(t),i=this.spatialReference;await N({graphic:t,popupTemplate:n,layer:r,spatialReference:i},{signal:e});let[{value:a},{value:o}]=await l([this._getContent(),this._getTitle()]),[,{value:s}]=await l([this._checkForRelatedFeatures({signal:e}),w(n?.expressionInfos,t)]);return{expressionInfos:s,content:a,heading:o}}catch(n){throw!u(n)&&!e.aborted&&(this._clear(),this._error=n,s.getLogger(this).error(`error`,`The popupTemplate could not be displayed for this feature.`,{error:n,graphic:t,popupTemplate:this._effectivePopupTemplate})),n}})}_compileContentElement(e){let t=k(this.graphic);return e.type===`relationship`?P(t)?e:void 0:e.type===`utility-network-associations`?F(t)?e:void 0:e}_compileContent(e){if(this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(e=>this._compileContentElement(e)).filter(i):typeof e==`string`?new C({text:e}).text:e}_compileLastEditInfo(){let{_effectivePopupTemplate:e,graphic:t,timeZone:n}=this,r=k(t);if(!e)return;let{lastEditInfoEnabled:i}=e,a=r?.editFieldsInfo;if(i&&a)return I(a,t?.attributes,n,r)}_compileHeading(e){let{_fieldInfoMap:t,graphic:n,expressionAttributes:r}=this,i=k(n),a=n?.attributes??{},o=this.formattedAttributes?.global??{};return L({attributes:a,fieldInfoMap:t,globalAttributes:o,expressionAttributes:r,layer:i,text:e})}async _getTitle(){let{_effectivePopupTemplate:e,graphic:t}=this;return t?R({type:`title`,value:e?.title,event:{graphic:t}}):null}async _getContent(){let{_effectivePopupTemplate:e,graphic:t}=this;return t?R({type:`content`,value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({heading:e,content:t,expressionInfos:n}){this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=a(async r=>{let{graphic:i,map:a,view:o,spatialReference:c,location:l}=this;try{if(!i)return;let s;if(n!=null){let e=[];for(let[t,s]of n.expressions.entries())s==null?e.push(Promise.resolve([t,void 0])):e.push(s.evaluate({graphic:i,interceptor:J.interceptor,location:l,map:a,options:{signal:r},spatialReference:c,view:o}).then(e=>[t,typeof e==`string`?T(e):e]).catch(()=>[t,void 0]));s=Object.fromEntries(await Promise.all(e)),d(r)}this._set(`expressionAttributes`,s??null),this._graphicExpressionAttributes={...i.attributes,...s},this._set(`formattedAttributes`,this._createFormattedAttributes(t)),this._set(`heading`,this._compileHeading(e)),this._set(`lastEditInfo`,this._compileLastEditInfo()||null),this._set(`content`,this._compileContent(t)||null)}catch(e){!u(e)&&!r.aborted&&(this._clear(),this._error=e,s.getLogger(this).error(`error`,`The popupTemplate could not be displayed for this feature.`,{error:e,graphic:i,popupTemplate:this._effectivePopupTemplate}))}})}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:n}){let{_effectivePopupTemplate:r,graphic:i,relatedInfos:a,_fieldInfoMap:o,_graphicExpressionAttributes:s,timeZone:c}=this,l=k(i);n.content[t]=z({attributes:{...s,...e.attributes},fieldInfoMap:o,fieldInfos:r?.fieldInfos,graphic:i,layer:l,relatedInfos:a,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:n}){if(e.fieldInfos){let{graphic:r,relatedInfos:i,_fieldInfoMap:a,_graphicExpressionAttributes:o,timeZone:s}=this,c=k(r);n.content[t]=z({attributes:{...o,...e.attributes},fieldInfoMap:a,fieldInfos:e.fieldInfos,graphic:r,isContentFieldInfos:!0,layer:c,relatedInfos:i,timeZone:s})}}_createFormattedAttributes(e){let{_effectivePopupTemplate:t,graphic:n,relatedInfos:r,_fieldInfoMap:i,_graphicExpressionAttributes:a,timeZone:o}=this,s=k(n),c=t?.fieldInfos,l={global:z({attributes:a,fieldInfoMap:i,fieldInfos:c,graphic:n,layer:s,relatedInfos:r,timeZone:o}),content:[]};return Array.isArray(e)&&e.forEach((e,t)=>{e.type===`fields`&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l}),e.type===`media`&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l})}),l}_checkForRelatedFeatures(e){let{graphic:t,_effectivePopupTemplate:n}=this;return this._queryRelatedInfos(t,j(n),e)}async _queryRelatedInfos(e,t,n){let{relatedInfos:r}=this,i=k(e);r.clear();let a=await i?.associatedLayer?.load(n)??i;if(!a||!e||!t.filter(e=>!!e.fieldName&&B(e.fieldName))?.length)return;t.forEach(e=>this._configureRelatedInfo(e,a));let o=await V({relatedInfos:r,layer:a},n);Object.keys(o).forEach(e=>{let t=r.get(e.toString()),n=o[e]?.value;t&&n&&(t.layerInfo=n.data)});let s=await H({graphic:e,relatedInfos:r,layer:a},n);Object.keys(s).forEach(e=>{U(s[e]?.value,r.get(e.toString()))})}_configureRelatedInfo(e,t){let{relatedInfos:n}=this,r=W(e.fieldName||``);if(!r)return;let{layerId:i,fieldName:a}=r;if(!i)return;let o=n.get(i.toString())||G(i,t);o&&(K({relatedInfo:o,fieldName:a,fieldInfo:e}),this.relatedInfos.set(i,o))}};e([g()],Y.prototype,`_error`,void 0),e([g()],Y.prototype,`_graphicChangedTask`,void 0),e([g()],Y.prototype,`_evaluateExpressionAttributesTask`,void 0),e([g({readOnly:!0})],Y.prototype,`_effectivePopupTemplate`,null),e([g({readOnly:!0})],Y.prototype,`_fieldInfoMap`,null),e([g({type:E})],Y.prototype,`abilities`,void 0),e([g({readOnly:!0})],Y.prototype,`content`,void 0),e([g()],Y.prototype,`description`,void 0),e([g({type:b,readOnly:!0})],Y.prototype,`defaultActions`,null),e([g({type:b})],Y.prototype,`actions`,void 0),e([g()],Y.prototype,`includeDefaultActions`,void 0),e([g({type:b,readOnly:!0})],Y.prototype,`allActions`,null),e([g({type:Boolean})],Y.prototype,`defaultPopupTemplateEnabled`,void 0),e([g({readOnly:!0})],Y.prototype,`expressionAttributes`,void 0),e([g({readOnly:!0})],Y.prototype,`isFeatureFromTable`,null),e([g({readOnly:!0})],Y.prototype,`state`,null),e([g({readOnly:!0})],Y.prototype,`formattedAttributes`,void 0),e([g({type:t})],Y.prototype,`graphic`,void 0),e([g({readOnly:!0})],Y.prototype,`lastEditInfo`,void 0),e([g({type:v})],Y.prototype,`location`,void 0),e([g({readOnly:!0})],Y.prototype,`relatedInfos`,void 0),e([g({type:y})],Y.prototype,`spatialReference`,null),e([g()],Y.prototype,`timeZone`,null),e([g({readOnly:!0})],Y.prototype,`heading`,void 0),e([g()],Y.prototype,`map`,null),e([g({readOnly:!0})],Y.prototype,`waitingForContent`,null),e([g()],Y.prototype,`view`,void 0),Y=J=e([_(`esri.popup.FeatureModel`)],Y);const X=Y;export{X as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../core/Error.js";import{EventedAccessor as n}from"../core/Evented.js";import r from"../core/Logger.js";import{abortMaybe as i}from"../core/maybe.js";import{debounce as a,logOnError as o,isAbortError as s}from"../core/promiseUtils.js";import{watch as c,when as l}from"../core/reactiveUtils.js";import{throttle as u}from"../core/throttle.js";import{property as d,subclass as f}from"../core/accessorSupport/decorators.js";import p from"../geometry/Point.js";import{project as m}from"../geometry/projectionUtils.js";import h from"../geometry/SpatialReference.js";import{geographicToWebMercator as g}from"../geometry/support/webMercatorUtils.js";import{getGraphicLayer as _}from"../graphic/graphicOriginUtils.js";import{fallbackObjectIDAttribute as v}from"../layers/LayerConstants.js";import{ActionsCollection as y,createDefaultActions as b}from"./actions.js";import{getSelectedTarget as x}from"./actionUtils.js";import S from"./FeatureModel.js";import C from"./support/FeatureAbilities.js";import{getDisplayedSymbol as w}from"../symbols/support/symbolUtils.js";import{system as T}from"../time/constants.js";import{highlightsSupported as E}from"../views/support/layerViewUtils.js";import{GoTo as D}from"../widgets/support/GoTo.js";const O=Symbol(`feature-stream-flush`);let k=null;function A(e,t){switch(e){case`building-scene`:case`map-image`:case`tile`:case`imagery`:return!0;case`imagery-tile`:return t===`2d`;default:return!1}}let j=class extends D(n){constructor(e){super(e),this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._defaultFeatureAbilities=new C,this._activeFeatureStream=null,this._featureStreamHasYielded=!1,this.actions=new y,this.activeFeature=null,this.aggregatedFeaturesEnabled=!1,this.defaultPopupTemplateEnabled=!1,this.diagnostics=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureItemAbilities=null,this.featureModels=[],this.heading=null,this.highlightEnabled=!0,this.includeDefaultActions=!0,this.open=!1,this.updateLocationEnabled=!1,this.view=null,this.zoomFactor=4,this._debouncedLocationUpdate=a(async()=>{this._cancelLocationUpdate();let e=new AbortController,{signal:t}=e;this._locationUpdateController=e,await this._locationUpdate({signal:t}).catch(()=>{}).finally(()=>{this._locationUpdateController===e&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([c(()=>this.view?.scale,()=>{this.open&&o(this._debouncedLocationUpdate(),r.getLogger(this))}),c(()=>[this.highlightEnabled,this.selectedFeature,this.open,this.view],()=>this._highlightSelectedFeature()),c(()=>[this.highlightEnabled,this.activeFeature,this.open,this.view],()=>this._highlightActiveFeature()),c(()=>this.location,e=>this._locationChange(e)),c(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),c(()=>[this.featurePage,this.selectedFeatureIndex,this.featuresPerPage,this.featureMenuOpen,this.open,this.initialDisplayMode,this.featureItemAbilities?.attachmentsContent,this.featureItemAbilities?.chartAnimation,this.featureItemAbilities?.customContent,this.featureItemAbilities?.expressionContent,this.featureItemAbilities?.fieldsContent,this.featureItemAbilities?.mediaContent,this.featureItemAbilities?.relationshipContent,this.featureItemAbilities?.textContent,this.featureItemAbilities?.utilityNetworkAssociationsContent,this.actions,this.defaultPopupTemplateEnabled,this.includeDefaultActions,this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureModels(),{initial:!0}),l(()=>!this.open,()=>this.aggregatedFeaturesEnabled=!1)])}destroy(){this._cancelLocationUpdate(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._destroyFeatureModels(),this.aggregatedFeaturesEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get defaultActions(){let e=this._get(`defaultActions`)||new y;return e.removeAll(),e.addMany(this.selectedFeatureItem?.defaultActions.toArray()??b()),e}get active(){return this.open&&!this.waitingForResult}set content(e){this.featureStream=null,this._set(`diagnostics`,null),this.features=[],this._set(`content`,e)}get effectiveHeading(){return this.selectedFeatureItem?.heading??this.heading}get featureCount(){return this.features.length}get featurePage(){return this._get(`featurePage`)}set featurePage(e){if(e==null){this.featureCount||this._set(`featurePage`,null);return}!Number.isInteger(e)||e<1||e>Math.ceil(this.featureCount/this.featuresPerPage)||e!==1&&e!==(this.featurePage??0)+1||this._set(`featurePage`,e)}set features(e){if(this._get(`features`)===e)return;let t=e||[];this._set(`features`,t),(!this._activeFeatureStream||!t.length||this.featurePage==null)&&(this.featurePage=t.length?1:null),this._syncSelectedFeatureIndex(t)}get featureStream(){return this._get(`featureStream`)||null}set featureStream(e){this._setFeatureStream(e)}_setFeatureStream(e,t,n){this._set(`diagnostics`,n??null),this._get(`featureStream`)!==e&&(this._set(`featureStream`,e),this._cancelFeatureStream(),e&&(this._featureStreamHasYielded=!1,this._set(`pendingLocation`,t??null),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})))}get initialDisplayMode(){return this._initialDisplayMode??(this.view?.focusRegionVisible?`list`:`feature`)}set initialDisplayMode(e){this._initialDisplayMode=e,this._syncSelectedFeatureIndex(this.features)}set location(e){let t=e?.spatialReference?.isWGS84&&this.spatialReference?.isWebMercator?g(e):e;this._set(`location`,t)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get pendingLocation(){return this._get(`pendingLocation`)??null}get streamingFeatures(){return this._activeFeatureStream!=null}get selectedFeature(){return this.selectedFeatureIndex===-1?null:this.features[this.selectedFeatureIndex]??null}get selectedFeatureIndex(){let e=this._get(`selectedFeatureIndex`);return typeof e==`number`?e:-1}set selectedFeatureIndex(e){let{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set(`selectedFeatureIndex`,e)}get selectedFeatureItem(){return this.featureModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){return this.view?this.view.ready?`ready`:`disabled`:this.map?`ready`:`disabled`}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get waitingForContents(){return this.featureModels.some(e=>e.waitingForContent)}get waitingForResult(){return this.streamingFeatures&&!this._featureStreamHasYielded}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this._set(`diagnostics`,null),this.set({featureStream:null,features:[],content:null,heading:null,location:null,activeFeature:null})}openFeatureStream(e){this._setFeatureStream(e.featureStream,e.location??null,e.diagnostics),this.open=!0}async fetchFeatures(e,n){let{view:r}=this;if(!r||!e)throw new t(`fetch-features:invalid-screenpoint-or-view`,`Cannot fetch features without a screen point/screen area and view.`,{screenPoint:e,view:r});let i={},a=r.fetchPopupFeatures(e,{diagnostics:i,pointerType:n?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:n?.signal});this._setFeatureStream(a,void 0,i)}next(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount)}previous(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount)}_syncSelectedFeatureIndex(e){let{selectedFeatureIndex:t}=this,n=this._activeFeatureStream!=null&&e.length>0;if(this.initialDisplayMode===`list`){n||(this.selectedFeatureIndex=-1);return}if(n&&t===-1){this.selectedFeatureIndex=0;return}n&&t!==-1||(this.selectedFeatureIndex=e.length?0:-1)}_centerAtLocation(){let{view:e}=this,n=x(this);this._cancelCenterAtLocation();let i=new AbortController,{signal:a}=i;return this._centerAtLocationController=i,!n||!e?Promise.reject(new t(`center-at-location:invalid-target-or-view`,`Cannot center at a location without a target and view.`,{target:n,view:e})):this.callGoTo({target:{target:n,scale:e.scale},options:{signal:a}}).catch(e=>{s(e)||r.getLogger(this).error(e)})}_getRoundRobinIndex(e,t){return(e+t)%t}_locationChange(e){let{selectedFeature:t,updateLocationEnabled:n,view:r}=this;r&&!this._locationUpdateController&&n&&e&&(!t||t.geometry)&&this._centerAtLocation()}async _selectedFeatureChange(e){let{location:t,updateLocationEnabled:n,view:r}=this;if(this.aggregatedFeaturesEnabled=!1,!e||!r)return;let i=_(e)?.type;if((i===`map-image`||i===`imagery`||i===`imagery-tile`)&&(e.symbol=await w(e)),(n||!t)&&e.geometry){if(e.geometry.type===`point`){this.location=e.geometry;return}let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);this.location=t(e.geometry);return}if(n&&!e.geometry){await this._centerAtLocation();let e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.featureStream&&(this.open=!1)}_destroyFeatureModels(){this.featureModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureModels`,[])}_reconcileFeatureModels(e){let t=[],n=new Map,r=[];if(this.featureModels.forEach((i,a)=>{let o=i?.graphic;!o||i.destroyed?i.destroy():e[a]===o?t[a]=i:(r.push(i),n.has(o)||n.set(o,[]))}),r.length){for(let r=e.length-1;r>=0;r--)t[r]||n.get(e[r])?.push(r);r.forEach(e=>{let r=n.get(e.graphic)?.pop();r==null?e.destroy():t[r]=e})}return t}_updateFeatureModels(){let{selectedFeature:e,features:t}=this;if(!t.length){this._destroyFeatureModels();return}let n={abilities:this.featureItemAbilities??this._defaultFeatureAbilities,actions:this.actions,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,includeDefaultActions:this.includeDefaultActions,spatialReference:this.spatialReference,location:this.location,map:this.map,view:this.view,timeZone:this.timeZone},r=this._reconcileFeatureModels(t);r.forEach(e=>e.set(n));let i=e=>{let i=t[e];i&&!r[e]&&(r[e]=new S({...n,graphic:i}))};if(e&&i(this.selectedFeatureIndex),(this.featurePage??0)>1||this.open&&(this.featureMenuOpen||this.initialDisplayMode===`list`)){let e=Math.min((this.featurePage??0)*this.featuresPerPage,t.length);for(let t=0;t<e;t++)i(t)}this._set(`featureModels`,r)}_cancelCenterAtLocation(){this._centerAtLocationController=i(this._centerAtLocationController)}_cancelFeatureStream(){this.removeHandles(O);let e=this._activeFeatureStream;this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._get(`featureStream`)===e&&this._set(`featureStream`,null),e?.return&&e.return(void 0).catch(()=>{})}async _locationUpdate(e){let{spatialReference:t}=this,n=this.selectedFeature,i=n?.geometry?.type,a=this.location;if(i&&i!==`mesh`&&t&&a&&n){if(i===`point`){let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);if(e?.signal?.aborted||this.selectedFeature!==n||!n.geometry)return;this.location=t(n.geometry);return}try{let r=n.geometry,i=this._getHighlightLayer(n),o=n.getObjectId();if(!i||!this.view)return;if(o!=null){let n=this.view?.allLayerViews.find(e=>e.layer.uid===i.uid);if(!n||!(`queryFeatures`in n))return;let a=n.createQuery();a.outSpatialReference=t,a.objectIds=[o],a.returnGeometry=!0;let{features:s}=await n.queryFeatures(a,e);if(e?.signal?.aborted)return;r=s[0]?.geometry}if(!r||r.type===`mesh`)return;r=m(r,t),k??=await Promise.all([import(`../geometry/operators/intersectsOperator.js`),import(`../geometry/operators/proximityOperator.js`)]);let[{intersectsExecute:s},{proximityGetNearestCoordinate:c}]=k;if(!s(r,a)){let e=c(r,a).coordinate??a;this.selectedFeature===n&&(this.location=e)}}catch(e){s(e)||r.getLogger(this).error(e)}}}_cancelLocationUpdate(){this._locationUpdateController=i(this._locationUpdateController)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){let t=_(e),{layer:n}=e;return t&&`layer`in t&&t.layer?t.layer:t?.type===`map-notes`||t?.type===`sketch`||t?.type===`subtype-group`?t:n??t}_getHighlightLayerView(e,t){return t.type===`subtype-sublayer`&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,n){if(A(t.type,n))return e;let r=e.getObjectId();if(r!=null)return r;let i=t.type===`imagery`?void 0:`objectIdField`in t?t.objectIdField||v:null,a=e.attributes;return a&&i&&a[i]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);let n=this[t];if(!n)return;let{highlightEnabled:r,view:i,open:a}=this;if(!i||!r||!a)return;let o=this._getHighlightLayer(n);if(!o)return;let s=this._getHighlightLayerView(i,o);if(!s)return;this._highlightPromises[e]=s;let c=await s;if(!c||!E(c)||this._highlightPromises[e]!==s||!this[t]||!this.highlightEnabled)return;let l=c.highlight(this._getHighlightTarget(n,o,i.type));this.addHandles(l,e)}async _highlightActiveFeature(){return this._highlightFeature(`highlight-active-feature`,`activeFeature`)}async _highlightSelectedFeature(){return this._highlightFeature(`highlight-selected-feature`,`selectedFeature`)}async _consumeFeatureStream(e,t){if(e!==this._activeFeatureStream)return;let n=[],r=u(()=>{let t=n;n=[],e===this._activeFeatureStream&&t.length&&this._addFeatures(t)},16);this.addHandles({remove:()=>{r.remove(),n=[]}},O);try{for await(let i of e){if(e!==this._activeFeatureStream)return;let a=!this._featureStreamHasYielded;a&&(this.features=[]),t!==void 0&&(this.location=t,t=void 0),this._set(`pendingLocation`,null),a?(this._addFeatures([i]),e===this._activeFeatureStream&&(this._featureStreamHasYielded=!0)):(n.push(i),r())}}finally{this._activeFeatureStream===e&&r.forceUpdate(),this._activeFeatureStream===e&&(this.removeHandles(O),this._featureStreamHasYielded||(this.features=[]),this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._waitingForResultChange())}}_addFeatures(e){let{features:t}=this,n=new Set(t),r=e.filter(e=>!n.has(e)&&(n.add(e),!0));r.length&&(this.features=t.concat(r))}};e([d()],j.prototype,`_initialDisplayMode`,void 0),e([d()],j.prototype,`_activeFeatureStream`,void 0),e([d()],j.prototype,`_featureStreamHasYielded`,void 0),e([d({type:y})],j.prototype,`actions`,void 0),e([d({type:y,readOnly:!0})],j.prototype,`defaultActions`,null),e([d({readOnly:!0})],j.prototype,`active`,null),e([d()],j.prototype,`activeFeature`,void 0),e([d()],j.prototype,`aggregatedFeaturesEnabled`,void 0),e([d({value:null})],j.prototype,`content`,null),e([d({type:Boolean})],j.prototype,`defaultPopupTemplateEnabled`,void 0),e([d({readOnly:!0})],j.prototype,`diagnostics`,void 0),e([d({readOnly:!0})],j.prototype,`effectiveHeading`,null),e([d({readOnly:!0})],j.prototype,`featureCount`,null),e([d({value:null})],j.prototype,`featurePage`,null),e([d({value:[]})],j.prototype,`features`,null),e([d()],j.prototype,`featureStream`,null),e([d()],j.prototype,`featuresPerPage`,void 0),e([d()],j.prototype,`featureMenuOpen`,void 0),e([d({type:C})],j.prototype,`featureItemAbilities`,void 0),e([d({readOnly:!0})],j.prototype,`featureModels`,void 0),e([d()],j.prototype,`heading`,void 0),e([d()],j.prototype,`highlightEnabled`,void 0),e([d()],j.prototype,`includeDefaultActions`,void 0),e([d()],j.prototype,`initialDisplayMode`,null),e([d({type:p})],j.prototype,`location`,null),e([d()],j.prototype,`map`,null),e([d()],j.prototype,`open`,void 0),e([d({readOnly:!0})],j.prototype,`pendingLocation`,null),e([d({readOnly:!0})],j.prototype,`streamingFeatures`,null),e([d({value:null,readOnly:!0})],j.prototype,`selectedFeature`,null),e([d({value:-1})],j.prototype,`selectedFeatureIndex`,null),e([d({readOnly:!0})],j.prototype,`selectedFeatureItem`,null),e([d({type:h})],j.prototype,`spatialReference`,null),e([d({readOnly:!0})],j.prototype,`state`,null),e([d()],j.prototype,`timeZone`,null),e([d()],j.prototype,`updateLocationEnabled`,void 0),e([d()],j.prototype,`view`,void 0),e([d({readOnly:!0})],j.prototype,`waitingForContents`,null),e([d({readOnly:!0})],j.prototype,`waitingForResult`,null),e([d()],j.prototype,`zoomFactor`,void 0),j=e([f(`esri.popup.FeaturesModel`)],j);const M=j;export{M as default};
2
+ import{__decorate as e}from"tslib";import t from"../core/Error.js";import{EventedAccessor as n}from"../core/Evented.js";import r from"../core/Logger.js";import{abortMaybe as i}from"../core/maybe.js";import{debounce as a,logOnError as o,isAbortError as s}from"../core/promiseUtils.js";import{watch as c,when as l}from"../core/reactiveUtils.js";import{throttle as u}from"../core/throttle.js";import{property as d,subclass as f}from"../core/accessorSupport/decorators.js";import p from"../geometry/Point.js";import{project as m}from"../geometry/projectionUtils.js";import h from"../geometry/SpatialReference.js";import{geographicToWebMercator as g}from"../geometry/support/webMercatorUtils.js";import{getGraphicLayer as _}from"../graphic/graphicOriginUtils.js";import{fallbackObjectIDAttribute as v}from"../layers/LayerConstants.js";import{ActionsCollection as y,createDefaultActions as b}from"./actions.js";import{getSelectedTarget as x}from"./actionUtils.js";import S from"./FeatureModel.js";import C from"./support/FeatureAbilities.js";import{getDisplayedSymbol as w}from"../symbols/support/symbolUtils.js";import{system as T}from"../time/constants.js";import{highlightsSupported as E}from"../views/support/layerViewUtils.js";import{GoTo as D}from"../widgets/support/GoTo.js";const O=Symbol(`feature-stream-flush`);let k=null;function A(e,t){switch(e){case`building-scene`:case`map-image`:case`tile`:case`imagery`:return!0;case`imagery-tile`:return t===`2d`;default:return!1}}let j=class extends D(n){constructor(e){super(e),this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._defaultFeatureAbilities=new C,this._activeFeatureStream=null,this._featureStreamHasYielded=!1,this.actions=new y,this.activeFeature=null,this.aggregatedFeaturesEnabled=!1,this.defaultPopupTemplateEnabled=!1,this.diagnostics=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureItemAbilities=null,this.featureModels=[],this.heading=null,this.highlightEnabled=!0,this.includeDefaultActions=!0,this.open=!1,this.updateLocationEnabled=!1,this.view=null,this.zoomFactor=4,this._debouncedLocationUpdate=a(async()=>{this._cancelLocationUpdate();let e=new AbortController,{signal:t}=e;this._locationUpdateController=e,await this._locationUpdate({signal:t}).catch(()=>{}).finally(()=>{this._locationUpdateController===e&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([c(()=>this.view?.scale,()=>{this.open&&o(this._debouncedLocationUpdate(),r.getLogger(this))}),c(()=>[this.highlightEnabled,this.selectedFeature,this.open,this.view],()=>this._highlightSelectedFeature()),c(()=>[this.highlightEnabled,this.activeFeature,this.open,this.view],()=>this._highlightActiveFeature()),c(()=>this.location,e=>this._locationChange(e)),c(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),c(()=>[this.featurePage,this.selectedFeatureIndex,this.featuresPerPage,this.featureMenuOpen,this.open,this.initialDisplayMode,this.featureItemAbilities?.attachmentsContent,this.featureItemAbilities?.chartAnimation,this.featureItemAbilities?.customContent,this.featureItemAbilities?.expressionContent,this.featureItemAbilities?.fieldsContent,this.featureItemAbilities?.mediaContent,this.featureItemAbilities?.relationshipContent,this.featureItemAbilities?.textContent,this.featureItemAbilities?.utilityNetworkAssociationsContent,this.actions,this.defaultPopupTemplateEnabled,this.includeDefaultActions,this.features,this.map,this.spatialReference,this.timeZone],(e,t)=>this._updateFeatureModels(t?.[1]??-1),{initial:!0}),l(()=>!this.open,()=>this.aggregatedFeaturesEnabled=!1)])}destroy(){this._cancelLocationUpdate(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._destroyFeatureModels(),this.aggregatedFeaturesEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get defaultActions(){let e=this._get(`defaultActions`)||new y;return e.removeAll(),e.addMany(this.selectedFeatureItem?.defaultActions.toArray()??b()),e}get active(){return this.open&&!this.waitingForResult}set content(e){this.featureStream=null,this._set(`diagnostics`,null),this.features=[],this._set(`content`,e)}get effectiveHeading(){return this.selectedFeatureItem?.heading??this.heading}get featureCount(){return this.features.length}get featurePage(){return this._get(`featurePage`)}set featurePage(e){if(e==null){this.featureCount||this._set(`featurePage`,null);return}!Number.isInteger(e)||e<1||e>Math.ceil(this.featureCount/this.featuresPerPage)||e!==1&&e!==(this.featurePage??0)+1||this._set(`featurePage`,e)}set features(e){if(this._get(`features`)===e)return;let t=e||[];this._set(`features`,t),(!this._activeFeatureStream||!t.length||this.featurePage==null)&&(this.featurePage=t.length?1:null),this._syncSelectedFeatureIndex(t)}get featureStream(){return this._get(`featureStream`)||null}set featureStream(e){this._setFeatureStream(e)}_setFeatureStream(e,t,n){this._set(`diagnostics`,n??null),this._get(`featureStream`)!==e&&(this._set(`featureStream`,e),this._cancelFeatureStream(),e&&(this._featureStreamHasYielded=!1,this._set(`pendingLocation`,t??null),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})))}get initialDisplayMode(){return this._initialDisplayMode??(this.view?.focusRegionVisible?`list`:`feature`)}set initialDisplayMode(e){this._initialDisplayMode=e,this._syncSelectedFeatureIndex(this.features)}set location(e){let t=e?.spatialReference?.isWGS84&&this.spatialReference?.isWebMercator?g(e):e;this._set(`location`,t)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get pendingLocation(){return this._get(`pendingLocation`)??null}get streamingFeatures(){return this._activeFeatureStream!=null}get selectedFeature(){return this.selectedFeatureIndex===-1?null:this.features[this.selectedFeatureIndex]??null}get selectedFeatureIndex(){let e=this._get(`selectedFeatureIndex`);return typeof e==`number`?e:-1}set selectedFeatureIndex(e){let{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set(`selectedFeatureIndex`,e)}get selectedFeatureItem(){return this.featureModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){return this.view?this.view.ready?`ready`:`disabled`:this.map?`ready`:`disabled`}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get waitingForContents(){return this.featureModels.some(e=>e.waitingForContent)}get waitingForResult(){return this.streamingFeatures&&!this._featureStreamHasYielded}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this._set(`diagnostics`,null),this.set({featureStream:null,features:[],content:null,heading:null,location:null,activeFeature:null})}openFeatureStream(e){this._setFeatureStream(e.featureStream,e.location??null,e.diagnostics),this.open=!0}async fetchFeatures(e,n){let{view:r}=this;if(!r||!e)throw new t(`fetch-features:invalid-screenpoint-or-view`,`Cannot fetch features without a screen point/screen area and view.`,{screenPoint:e,view:r});let i={},a=r.fetchPopupFeatures(e,{diagnostics:i,pointerType:n?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:n?.signal});this._setFeatureStream(a,void 0,i)}next(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount)}previous(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount)}_syncSelectedFeatureIndex(e){let{selectedFeatureIndex:t}=this,n=this._activeFeatureStream!=null&&e.length>0;if(this.initialDisplayMode===`list`){n||(this.selectedFeatureIndex=-1);return}if(n&&t===-1){this.selectedFeatureIndex=0;return}n&&t!==-1||(this.selectedFeatureIndex=e.length?0:-1)}_centerAtLocation(){let{view:e}=this,n=x(this);this._cancelCenterAtLocation();let i=new AbortController,{signal:a}=i;return this._centerAtLocationController=i,!n||!e?Promise.reject(new t(`center-at-location:invalid-target-or-view`,`Cannot center at a location without a target and view.`,{target:n,view:e})):this.callGoTo({target:{target:n,scale:e.scale},options:{signal:a}}).catch(e=>{s(e)||r.getLogger(this).error(e)})}_getRoundRobinIndex(e,t){return(e+t)%t}_locationChange(e){let{selectedFeature:t,updateLocationEnabled:n,view:r}=this;r&&!this._locationUpdateController&&n&&e&&(!t||t.geometry)&&this._centerAtLocation()}async _selectedFeatureChange(e){let{location:t,updateLocationEnabled:n,view:r}=this;if(this.aggregatedFeaturesEnabled=!1,!e||!r)return;let i=_(e)?.type;if((i===`map-image`||i===`imagery`||i===`imagery-tile`)&&(e.symbol=await w(e)),(n||!t)&&e.geometry){if(e.geometry.type===`point`){this.location=e.geometry;return}let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);this.location=t(e.geometry);return}if(n&&!e.geometry){await this._centerAtLocation();let e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.featureStream&&(this.open=!1)}_destroyFeatureModels(){this.featureModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureModels`,[])}_reconcileFeatureModels(e,t){let n=[],r=new Map;if(this.featureModels.forEach((t,i)=>{let a=t?.graphic;if(!a||t.destroyed)t.destroy();else if(e[i]===a)n[i]=t;else{let e=r.get(a);e?e.push(t):r.set(a,[t])}}),!r.size)return n;for(let e of r.values())e.reverse();for(let t=0;t<e.length&&r.size;t++){if(n[t])continue;let i=e[t],a=r.get(i);a&&(n[t]=a.pop(),a.length||r.delete(i))}let i=this.selectedFeatureIndex,a=e[i],o=this.featureModels[t],s=null;for(let e of r.values())for(let t of e)t===o?s=t:t.destroy();return s&&(a&&!n[i]?(s.graphic=a,n[i]=s):s.destroy()),n}_updateFeatureModels(e){let{selectedFeature:t,features:n}=this;if(!n.length){this._destroyFeatureModels();return}let r={abilities:this.featureItemAbilities??this._defaultFeatureAbilities,actions:this.actions,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,includeDefaultActions:this.includeDefaultActions,spatialReference:this.spatialReference,location:this.location,map:this.map,view:this.view,timeZone:this.timeZone},i=this._reconcileFeatureModels(n,e);i.forEach(e=>e.set(r));let a=e=>{let t=n[e];t&&!i[e]&&(i[e]=new S({...r,graphic:t}))};if(t&&a(this.selectedFeatureIndex),(this.featurePage??0)>1||this.open&&(this.featureMenuOpen||this.initialDisplayMode===`list`)){let e=Math.min((this.featurePage??0)*this.featuresPerPage,n.length);for(let t=0;t<e;t++)a(t)}this._set(`featureModels`,i)}_cancelCenterAtLocation(){this._centerAtLocationController=i(this._centerAtLocationController)}_cancelFeatureStream(){this.removeHandles(O);let e=this._activeFeatureStream;this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._get(`featureStream`)===e&&this._set(`featureStream`,null),e?.return&&e.return(void 0).catch(()=>{})}async _locationUpdate(e){let{spatialReference:t}=this,n=this.selectedFeature,i=n?.geometry?.type,a=this.location;if(i&&i!==`mesh`&&t&&a&&n){if(i===`point`){let{labelPointExecute:t}=await import(`../geometry/operators/labelPointOperator.js`);if(e?.signal?.aborted||this.selectedFeature!==n||!n.geometry)return;this.location=t(n.geometry);return}try{let r=n.geometry,i=this._getHighlightLayer(n),o=n.getObjectId();if(!i||!this.view)return;if(o!=null){let n=this.view?.allLayerViews.find(e=>e.layer.uid===i.uid);if(!n||!(`queryFeatures`in n))return;let a=n.createQuery();a.outSpatialReference=t,a.objectIds=[o],a.returnGeometry=!0;let{features:s}=await n.queryFeatures(a,e);if(e?.signal?.aborted)return;r=s[0]?.geometry}if(!r||r.type===`mesh`)return;r=m(r,t),k??=await Promise.all([import(`../geometry/operators/intersectsOperator.js`),import(`../geometry/operators/proximityOperator.js`)]);let[{intersectsExecute:s},{proximityGetNearestCoordinate:c}]=k;if(!s(r,a)){let e=c(r,a).coordinate??a;this.selectedFeature===n&&(this.location=e)}}catch(e){s(e)||r.getLogger(this).error(e)}}}_cancelLocationUpdate(){this._locationUpdateController=i(this._locationUpdateController)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){let t=_(e),{layer:n}=e;return t&&`layer`in t&&t.layer?t.layer:t?.type===`map-notes`||t?.type===`sketch`||t?.type===`subtype-group`?t:n??t}_getHighlightLayerView(e,t){return t.type===`subtype-sublayer`&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,n){if(A(t.type,n))return e;let r=e.getObjectId();if(r!=null)return r;let i=t.type===`imagery`?void 0:`objectIdField`in t?t.objectIdField||v:null,a=e.attributes;return a&&i&&a[i]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);let n=this[t];if(!n)return;let{highlightEnabled:r,view:i,open:a}=this;if(!i||!r||!a)return;let o=this._getHighlightLayer(n);if(!o)return;let s=this._getHighlightLayerView(i,o);if(!s)return;this._highlightPromises[e]=s;let c=await s;if(!c||!E(c)||this._highlightPromises[e]!==s||!this[t]||!this.highlightEnabled)return;let l=c.highlight(this._getHighlightTarget(n,o,i.type));this.addHandles(l,e)}async _highlightActiveFeature(){return this._highlightFeature(`highlight-active-feature`,`activeFeature`)}async _highlightSelectedFeature(){return this._highlightFeature(`highlight-selected-feature`,`selectedFeature`)}async _consumeFeatureStream(e,t){if(e!==this._activeFeatureStream)return;let n=[],r=u(()=>{let t=n;n=[],e===this._activeFeatureStream&&t.length&&this._addFeatures(t)},16);this.addHandles({remove:()=>{r.remove(),n=[]}},O);try{for await(let i of e){if(e!==this._activeFeatureStream)return;let a=!this._featureStreamHasYielded;a&&(this.features=[]),t!==void 0&&(this.location=t,t=void 0),this._set(`pendingLocation`,null),a?(this._addFeatures([i]),e===this._activeFeatureStream&&(this._featureStreamHasYielded=!0)):(n.push(i),r())}}finally{this._activeFeatureStream===e&&r.forceUpdate(),this._activeFeatureStream===e&&(this.removeHandles(O),this._featureStreamHasYielded||(this.features=[]),this._activeFeatureStream=null,this._set(`pendingLocation`,null),this._waitingForResultChange())}}_addFeatures(e){let{features:t}=this,n=new Set(t),r=e.filter(e=>!n.has(e)&&(n.add(e),!0));r.length&&(this.features=t.concat(r))}};e([d()],j.prototype,`_initialDisplayMode`,void 0),e([d()],j.prototype,`_activeFeatureStream`,void 0),e([d()],j.prototype,`_featureStreamHasYielded`,void 0),e([d({type:y})],j.prototype,`actions`,void 0),e([d({type:y,readOnly:!0})],j.prototype,`defaultActions`,null),e([d({readOnly:!0})],j.prototype,`active`,null),e([d()],j.prototype,`activeFeature`,void 0),e([d()],j.prototype,`aggregatedFeaturesEnabled`,void 0),e([d({value:null})],j.prototype,`content`,null),e([d({type:Boolean})],j.prototype,`defaultPopupTemplateEnabled`,void 0),e([d({readOnly:!0})],j.prototype,`diagnostics`,void 0),e([d({readOnly:!0})],j.prototype,`effectiveHeading`,null),e([d({readOnly:!0})],j.prototype,`featureCount`,null),e([d({value:null})],j.prototype,`featurePage`,null),e([d({value:[]})],j.prototype,`features`,null),e([d()],j.prototype,`featureStream`,null),e([d()],j.prototype,`featuresPerPage`,void 0),e([d()],j.prototype,`featureMenuOpen`,void 0),e([d({type:C})],j.prototype,`featureItemAbilities`,void 0),e([d({readOnly:!0})],j.prototype,`featureModels`,void 0),e([d()],j.prototype,`heading`,void 0),e([d()],j.prototype,`highlightEnabled`,void 0),e([d()],j.prototype,`includeDefaultActions`,void 0),e([d()],j.prototype,`initialDisplayMode`,null),e([d({type:p})],j.prototype,`location`,null),e([d()],j.prototype,`map`,null),e([d()],j.prototype,`open`,void 0),e([d({readOnly:!0})],j.prototype,`pendingLocation`,null),e([d({readOnly:!0})],j.prototype,`streamingFeatures`,null),e([d({value:null,readOnly:!0})],j.prototype,`selectedFeature`,null),e([d({value:-1})],j.prototype,`selectedFeatureIndex`,null),e([d({readOnly:!0})],j.prototype,`selectedFeatureItem`,null),e([d({type:h})],j.prototype,`spatialReference`,null),e([d({readOnly:!0})],j.prototype,`state`,null),e([d()],j.prototype,`timeZone`,null),e([d()],j.prototype,`updateLocationEnabled`,void 0),e([d()],j.prototype,`view`,void 0),e([d({readOnly:!0})],j.prototype,`waitingForContents`,null),e([d({readOnly:!0})],j.prototype,`waitingForResult`,null),e([d()],j.prototype,`zoomFactor`,void 0),j=e([f(`esri.popup.FeaturesModel`)],j);const M=j;export{M as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../config.js";import{id as t}from"../kernel.js";import n from"../core/Error.js";import has from"../core/has.js";import{clone as r}from"../core/lang.js";import{isAbortError as i,createAbortError as a,isAborted as o}from"../core/promiseUtils.js";import{isTrustedServer as s,getOrigin as c,isBlobProtocol as l,isDataProtocol as u,toHTTPS as d,objectToQuery as f,getProxyRule as p,getProxyUrl as m,addQueryParameters as h,hasSameOrigin as g,addProxyRule as _,getAppUrl as v}from"../core/urlUtils.js";import{isSecureProxyService as y}from"../portal/support/urlUtils.js";import{requestConfig as b}from"./config.js";import{registerNoCorsDomains as x,isNoCorsRequestRequired as S,sendNoCorsRequest as C}from"./cors.js";import{loadImage as w}from"./loadImage.js";import{setPreferredHost as T,getPreferredUrl as E}from"./preferredHosts.js";const D=`FormData`in globalThis,O=new Set([499,498,403,401]),k=new Set([`COM_0056`,`COM_0057`,`SB_0008`]),A=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i];async function j(t){await M(t);let n,r;try{do[n,r]=await N(t);while(!await V(t,n,r))}catch(e){let r=H(`request:server`,e,t.parameters,n);throw r.details.ssl=t.useSSL,t.interceptor?.error?.(r),r}let i=t.parameters.url;if(r){if(/\/sharing\/rest\/(accounts|portals)\/self/i.test(i)){if(!t.hasToken&&!t.credentialToken&&r.user?.username&&!s(i)){let t=c(i,!0);t&&e.request.trustedServers.push(t)}Array.isArray(r.authorizedCrossOriginNoCorsDomains)&&x(r.authorizedCrossOriginNoCorsDomains)}else(t.parameters.requestOptions.responseType||`json`)===`json`&&T(i,r)}return{data:r,getAllHeaders:n?()=>Array.from(n.headers):W,getHeader:n?e=>n.headers.get(e):W,httpStatus:n?.status??200,requestOptions:t.parameters.requestOptions,ssl:t.useSSL,url:t.parameters.url}}async function M(n){let r=n.parameters.url,i=n.parameters.requestOptions,a=n.controller.signal,s=i.body,c=null,l=null;if(D&&`HTMLFormElement`in globalThis&&(s instanceof FormData?c=s:s instanceof HTMLFormElement&&(c=new FormData(s))),typeof s==`string`&&(l=s),n.fetchOptions={cache:i.cacheMode??(i.cacheBust?`no-cache`:`default`),credentials:`same-origin`,headers:i.headers||{},keepalive:i.keepAlive??!1,method:i.method===`head`?`HEAD`:`GET`,mode:`cors`,priority:i.priority??e.request.priority,redirect:`follow`,signal:a},(c||l)&&(n.fetchOptions.body=c||l),(b.isForeignWorker||i.authMode===`anonymous`)&&(n.useIdentity=!1),n.hasToken=!!(/token=/i.test(r)||i.query?.token||c?.get(`token`)),!n.hasToken){let{getApiKey:e,getSessionToken:t}=await import(`../support/apiKeyUtils.js`),a=await t(r)??e(r);a&&(i.query??={},i.query.token=a,n.hasToken=!0)}if(n.useIdentity&&!n.hasToken&&!n.credential&&!n.credentialToken&&!R(r)&&!o(a)){let e;i.authMode===`immediate`?(await L(),e=await t.getCredential(r,{signal:a})):i.authMode===`no-prompt`?(await L(),e=await t.getCredential(r,{prompt:!1,signal:a}).catch(()=>void 0)):t&&(e=t.findCredential(r)),e&&(n.credential=e,n.credentialToken=e.token,n.useSSL=!!e.ssl)}}async function N(n){let r=n.parameters.url,i=E(r),o=n.parameters.requestOptions,x=n.fetchOptions??{},w=l(r)||u(r),T=o.responseType??`json`,O=w?0:o.timeout==null?e.request.timeout:o.timeout,k=!1;if(!w){n.useSSL&&(r=d(r));let a={...o.query};n.credentialToken&&(a.token=n.credentialToken);let c=f(a);has(`esri-url-encodes-apostrophe`)&&(c=c.replaceAll(`'`,`%27`));let l=i.length+1+c.length,u;k=o.method===`delete`||o.method===`post`||o.method===`put`||!!o.body||l>e.request.maxUrlLength;let _=o.useProxy||!!p(r);if(_){let t=m(r);u=t.path,!k&&u.length+1+l>e.request.maxUrlLength&&(k=!0),t.query&&(a={...t.query,...a})}if(x.method===`HEAD`&&(k||_)){if(k)throw l>e.request.maxUrlLength?H(`request:invalid-parameters`,Error(`URL exceeds maximum length`),n.parameters):H(`request:invalid-parameters`,Error(`cannot use POST request when method is 'head'`),n.parameters);if(_)throw H(`request:invalid-parameters`,Error(`cannot use proxy when method is 'head'`),n.parameters)}k?(x.method=o.method===`delete`?`DELETE`:o.method===`put`?`PUT`:`POST`,o.body?r=h(r,a):(x.body=f(a),x.headers||={},x.headers[`Content-Type`]=`application/x-www-form-urlencoded`)):r=h(r,a),_&&(n.useProxy=!0,r=`${u}?${r}`),a.token&&D&&x.body instanceof FormData&&!y(r)&&x.body.set(`token`,a.token),o.hasOwnProperty(`withCredentials`)?n.withCredentials=o.withCredentials:g(r,v())||(s(r)||t&&t.findServerInfo(r)?.webTierAuth)&&(n.withCredentials=!0),n.withCredentials&&(x.credentials=`include`,S(r)&&await C(k?h(r,a):r)),i=E(r)}let A=0,j=!1;O>0&&(A=setTimeout(()=>{j=!0,n.controller.abort()},O));let M,N;try{if(o.responseType===`native-request-init`)N=x,N.url=i,o.signal?N.signal=o.signal:delete N.signal;else if(o.responseType===`image`&&x.cache==="default"&&!x.keepalive&&x.method===`GET`&&!k&&!z(o.headers)&&(w||n.useProxy||!e.request.proxyUrl||I(r)))N=await P(i,n);else if(await b.beforeFetch?.(r,x),M=await fetch(i,x),await b.afterFetch?.(M),n.useProxy||F(r),o.responseType===`native`)N=M;else if(x.method!==`HEAD`){if(M.ok){switch(T){case`array-buffer`:N=await M.arrayBuffer();break;case`blob`:case`image`:N=await M.blob();break;default:N=await M.text()}if(A&&=(clearTimeout(A),0),T===`json`||T===`xml`||T===`document`){if(N)switch(T){case`json`:N=JSON.parse(N);break;case`xml`:N=B(N,`application/xml`);break;case`document`:N=B(N,`text/html`)}else N=null}if(N){if((T===`array-buffer`||T===`blob`)&&N[T===`blob`?`size`:`byteLength`]<=750)try{let e=await new Response(N).json();e.error&&(N=e)}catch{}T===`image`&&N instanceof Blob&&(N=await P(URL.createObjectURL(N),n,!0))}}else{N=await M.text();try{N=JSON.parse(N)}catch{}}}}catch(t){if(t.name===`AbortError`)throw j?K():a(`Request canceled`);if(!M&&t instanceof TypeError&&e.request.proxyUrl&&!o.body&&o.method!==`delete`&&o.method!==`head`&&o.method!==`post`&&o.method!==`put`&&!n.useProxy&&!I(r))n.redoRequest=!0,_({proxyUrl:e.request.proxyUrl,urlPrefix:c(r)??``});else throw t}finally{A&&clearTimeout(A)}return[M,N]}function P(t,n,r=!1){let i=n.controller.signal,a=new Image;return a.crossOrigin=n.withCredentials?`use-credentials`:`anonymous`,a.alt=``,a.fetchPriority=e.request.priority,a.src=t,w(a,t,r,i)}function F(e){let t=c(e);t&&!b.corsServers.includes(t)&&b.corsServers.push(t)}function I(e){let t=c(e);return!t||t.endsWith(`.arcgis.com`)||b.corsServers.includes(t)||s(t)}async function L(){t||await import(`../identity/IdentityManager.js`)}function R(e){return A.some(t=>t.test(e))}function z(e){if(e){for(let t of Object.getOwnPropertyNames(e))if(e[t])return!0}return!1}function B(e,t){let n;try{n=new DOMParser().parseFromString(e,t)}catch{}if(!n||n.getElementsByTagName(`parsererror`).length)throw SyntaxError(`XML Parse error`);return n}async function V(e,n,r){if(e.redoRequest)return e.redoRequest=!1,!1;let i=e.parameters.requestOptions;if(!n||i.responseType===`native`||i.responseType===`native-request-init`)return!0;let a;if(r&&(r.error&&typeof r.error==`object`?a=r.error:r.status===`error`&&Array.isArray(r.messages)&&(a={...r},a[U]=r,a.details=r.messages)),!a&&!n.ok)throw a=Error(`Unable to load ${n.url} status: ${n.status}`),a[U]=r,a;let o,s=null,c;a&&(o=Number(a.code),s=a.hasOwnProperty(`subcode`)?Number(a.subcode):null,c=a.messageCode,c=c?.toUpperCase());let l=i.authMode;if(o===403&&(s===4||a.message?.toLowerCase().includes(`ssl`)&&!a.message.toLowerCase().includes(`permission`))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&(l!==`no-prompt`||o===498)&&o!==void 0&&O.has(o)&&!R(e.parameters.url)&&(o!==403||(!c||!k.has(c))&&(s==null||s===2&&e.credentialToken))){await L();try{let n=await t.getCredential(e.parameters.url,{error:H(`request:server`,a,e.parameters),credential:e.credential,prompt:l!==`no-prompt`,signal:e.controller.signal,token:e.credentialToken});return e.credential=n,e.credentialToken=n.token,e.useSSL=e.useSSL||n.ssl,!1}catch(t){if(l===`no-prompt`)return e.credential=void 0,e.credentialToken=void 0,!1;a=t}}if(a)throw a;return!0}function H(e,t,o,s){let c,l={url:o.url,requestOptions:o.requestOptions,getAllHeaders:W,getHeader:W,ssl:!1};if(t instanceof n)return t.details?(t.details=r(t.details),t.details.url=o.url,t.details.requestOptions=o.requestOptions):t.details=l,t;if(t){let e=s&&(()=>Array.from(s.headers)),n=s&&(e=>s.headers.get(e)),r=s?.status,i=t.message;i&&(c=i),e&&n&&(l.getAllHeaders=e,l.getHeader=n),l.httpStatus=(t.httpCode==null?t.code:t.httpCode)||r||0,l.subCode=t.subcode,l.messageCode=t.messageCode,typeof t.details==`string`?(l.messages=[t.details],c??=t.details):(l.messages=t.details,c??=l.messages?.[0]),l.raw=U in t?t[U]:t}return c??=`Error`,i(t)?a():new n(e,c,l)}const U=Symbol(),W=()=>null,G=`Timeout exceeded`;function K(){return Error(G)}function q(e){return typeof e==`object`&&!!e&&`message`in e&&e.message===G}export{H as createRequestError,q as isTimeoutError,j as processRequest};
2
+ import e from"../config.js";import{id as t}from"../kernel.js";import n from"../core/Error.js";import has from"../core/has.js";import{clone as r}from"../core/lang.js";import{isAbortError as i,createAbortError as a,isAborted as o}from"../core/promiseUtils.js";import{isTrustedServer as s,getOrigin as c,isBlobProtocol as l,isDataProtocol as u,toHTTPS as d,objectToQuery as f,getProxyRule as p,getProxyUrl as m,addQueryParameters as h,hasSameOrigin as g,addProxyRule as _,getAppUrl as v}from"../core/urlUtils.js";import{isSecureProxyService as y}from"../portal/support/urlUtils.js";import{requestConfig as b}from"./config.js";import{registerNoCorsDomains as x,isNoCorsRequestRequired as S,sendNoCorsRequest as C}from"./cors.js";import{loadImage as w}from"./loadImage.js";import{setPreferredHost as T,getPreferredUrl as E}from"./preferredHosts.js";const D=`FormData`in globalThis,O=new Set([499,498,403,401]),k=new Set([`COM_0056`,`COM_0057`,`SB_0008`]),A=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i];async function j(t){await M(t);let n,r;try{do[n,r]=await N(t);while(!await V(t,n,r))}catch(e){let r=H(`request:server`,e,t.parameters,n);throw r.details.ssl=t.useSSL,t.interceptor?.error?.(r),r}let i=t.parameters.url;if(r){if(/\/sharing\/rest\/(accounts|portals)\/self/i.test(i)){if(!t.hasToken&&!t.credentialToken&&r.user?.username&&!s(i)){let t=c(i,!0);t&&e.request.trustedServers.push(t)}Array.isArray(r.authorizedCrossOriginNoCorsDomains)&&x(r.authorizedCrossOriginNoCorsDomains)}else(t.parameters.requestOptions.responseType||`json`)===`json`&&T(i,r)}return{data:r,getAllHeaders:n?()=>Array.from(n.headers):W,getHeader:n?e=>n.headers.get(e):W,httpStatus:n?.status??200,requestOptions:t.parameters.requestOptions,ssl:t.useSSL,url:t.parameters.url}}async function M(n){let r=n.parameters.url,i=n.parameters.requestOptions,a=n.controller.signal,s=i.body,c=null,l=null;if(D&&`HTMLFormElement`in globalThis&&(s instanceof FormData?c=s:s instanceof HTMLFormElement&&(c=new FormData(s))),typeof s==`string`&&(l=s),n.fetchOptions={cache:i.cacheMode??(i.cacheBust?`no-cache`:`default`),credentials:`same-origin`,headers:i.headers||{},keepalive:i.keepAlive??!1,method:i.method===`head`?`HEAD`:`GET`,mode:`cors`,priority:i.priority??e.request.priority,redirect:`follow`,signal:a},(c||l)&&(n.fetchOptions.body=c||l),(b.isForeignWorker||i.authMode===`anonymous`)&&(n.useIdentity=!1),n.hasToken=!!(/token=/i.test(r)||i.query?.token||c?.get(`token`)),!n.hasToken){let{getApiKey:e,getSessionToken:t}=await import(`../support/apiKeyUtils.js`),a=await t(r)??e(r);a&&(i.query??={},i.query.token=a,n.hasToken=!0)}if(n.useIdentity&&!n.hasToken&&!n.credential&&!n.credentialToken&&!R(r)&&!o(a)){let e;i.authMode===`immediate`?(await L(),e=await t.getCredential(r,{signal:a})):i.authMode===`no-prompt`?(await L(),e=await t.getCredential(r,{prompt:!1,signal:a}).catch(()=>void 0)):t&&(e=t.findCredential(r)),e&&(n.credential=e,n.credentialToken=e.token,n.useSSL=!!e.ssl)}}async function N(n){let r=n.parameters.url,i=E(r),o=n.parameters.requestOptions,x=n.fetchOptions??{},w=l(r)||u(r),T=o.responseType??`json`,O=w?0:o.timeout==null?e.request.timeout:o.timeout,k=!1;if(!w){n.useSSL&&(r=d(r));let a={...o.query};n.credentialToken&&(a.token=n.credentialToken);let c=f(a);has(`esri-url-encodes-apostrophe`)&&(c=c.replaceAll(`'`,`%27`));let l=o.maxUrlLength??e.request.maxUrlLength;l===0&&(l=1/0);let u=i.length+1+c.length,_;k=o.method===`delete`||o.method===`post`||o.method===`put`||!!o.body||u>l;let b=o.useProxy||!!p(r);if(b){let e=m(r);_=e.path,!k&&_.length+1+u>l&&(k=!0),e.query&&(a={...e.query,...a})}if(x.method===`HEAD`&&(k||b)){if(k)throw u>l?H(`request:invalid-parameters`,Error(`URL exceeds maximum length`),n.parameters):H(`request:invalid-parameters`,Error(`cannot use POST request when method is 'head'`),n.parameters);if(b)throw H(`request:invalid-parameters`,Error(`cannot use proxy when method is 'head'`),n.parameters)}k?(x.method=o.method===`delete`?`DELETE`:o.method===`put`?`PUT`:`POST`,o.body?r=h(r,a):(x.body=f(a),x.headers||={},x.headers[`Content-Type`]=`application/x-www-form-urlencoded`)):r=h(r,a),b&&(n.useProxy=!0,r=`${_}?${r}`),a.token&&D&&x.body instanceof FormData&&!y(r)&&x.body.set(`token`,a.token),o.hasOwnProperty(`withCredentials`)?n.withCredentials=o.withCredentials:g(r,v())||(s(r)||t&&t.findServerInfo(r)?.webTierAuth)&&(n.withCredentials=!0),n.withCredentials&&(x.credentials=`include`,S(r)&&await C(k?h(r,a):r)),i=E(r)}let A=0,j=!1;O>0&&(A=setTimeout(()=>{j=!0,n.controller.abort()},O));let M,N;try{if(o.responseType===`native-request-init`)N=x,N.url=i,o.signal?N.signal=o.signal:delete N.signal;else if(o.responseType===`image`&&x.cache==="default"&&!x.keepalive&&x.method===`GET`&&!k&&!z(o.headers)&&(w||n.useProxy||!e.request.proxyUrl||I(r)))N=await P(i,n);else if(await b.beforeFetch?.(r,x),M=await fetch(i,x),await b.afterFetch?.(M),n.useProxy||F(r),o.responseType===`native`)N=M;else if(x.method!==`HEAD`){if(M.ok){switch(T){case`array-buffer`:N=await M.arrayBuffer();break;case`blob`:case`image`:N=await M.blob();break;default:N=await M.text()}if(A&&=(clearTimeout(A),0),T===`json`||T===`xml`||T===`document`){if(N)switch(T){case`json`:N=JSON.parse(N);break;case`xml`:N=B(N,`application/xml`);break;case`document`:N=B(N,`text/html`)}else N=null}if(N){if((T===`array-buffer`||T===`blob`)&&N[T===`blob`?`size`:`byteLength`]<=750)try{let e=await new Response(N).json();e.error&&(N=e)}catch{}T===`image`&&N instanceof Blob&&(N=await P(URL.createObjectURL(N),n,!0))}}else{N=await M.text();try{N=JSON.parse(N)}catch{}}}}catch(t){if(t.name===`AbortError`)throw j?K():a(`Request canceled`);if(!M&&t instanceof TypeError&&e.request.proxyUrl&&!o.body&&o.method!==`delete`&&o.method!==`head`&&o.method!==`post`&&o.method!==`put`&&!n.useProxy&&!I(r))n.redoRequest=!0,_({proxyUrl:e.request.proxyUrl,urlPrefix:c(r)??``});else throw t}finally{A&&clearTimeout(A)}return[M,N]}function P(t,n,r=!1){let i=n.controller.signal,a=new Image;return a.crossOrigin=n.withCredentials?`use-credentials`:`anonymous`,a.alt=``,a.fetchPriority=e.request.priority,a.src=t,w(a,t,r,i)}function F(e){let t=c(e);t&&!b.corsServers.includes(t)&&b.corsServers.push(t)}function I(e){let t=c(e);return!t||t.endsWith(`.arcgis.com`)||b.corsServers.includes(t)||s(t)}async function L(){t||await import(`../identity/IdentityManager.js`)}function R(e){return A.some(t=>t.test(e))}function z(e){if(e){for(let t of Object.getOwnPropertyNames(e))if(e[t])return!0}return!1}function B(e,t){let n;try{n=new DOMParser().parseFromString(e,t)}catch{}if(!n||n.getElementsByTagName(`parsererror`).length)throw SyntaxError(`XML Parse error`);return n}async function V(e,n,r){if(e.redoRequest)return e.redoRequest=!1,!1;let i=e.parameters.requestOptions;if(!n||i.responseType===`native`||i.responseType===`native-request-init`)return!0;let a;if(r&&(r.error&&typeof r.error==`object`?a=r.error:r.status===`error`&&Array.isArray(r.messages)&&(a={...r},a[U]=r,a.details=r.messages)),!a&&!n.ok)throw a=Error(`Unable to load ${n.url} status: ${n.status}`),a[U]=r,a;let o,s=null,c;a&&(o=Number(a.code),s=a.hasOwnProperty(`subcode`)?Number(a.subcode):null,c=a.messageCode,c=c?.toUpperCase());let l=i.authMode;if(o===403&&(s===4||a.message?.toLowerCase().includes(`ssl`)&&!a.message.toLowerCase().includes(`permission`))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&(l!==`no-prompt`||o===498)&&o!==void 0&&O.has(o)&&!R(e.parameters.url)&&(o!==403||(!c||!k.has(c))&&(s==null||s===2&&e.credentialToken))){await L();try{let n=await t.getCredential(e.parameters.url,{error:H(`request:server`,a,e.parameters),credential:e.credential,prompt:l!==`no-prompt`,signal:e.controller.signal,token:e.credentialToken});return e.credential=n,e.credentialToken=n.token,e.useSSL=e.useSSL||n.ssl,!1}catch(t){if(l===`no-prompt`)return e.credential=void 0,e.credentialToken=void 0,!1;a=t}}if(a)throw a;return!0}function H(e,t,o,s){let c,l={url:o.url,requestOptions:o.requestOptions,getAllHeaders:W,getHeader:W,ssl:!1};if(t instanceof n)return t.details?(t.details=r(t.details),t.details.url=o.url,t.details.requestOptions=o.requestOptions):t.details=l,t;if(t){let e=s&&(()=>Array.from(s.headers)),n=s&&(e=>s.headers.get(e)),r=s?.status,i=t.message;i&&(c=i),e&&n&&(l.getAllHeaders=e,l.getHeader=n),l.httpStatus=(t.httpCode==null?t.code:t.httpCode)||r||0,l.subCode=t.subcode,l.messageCode=t.messageCode,typeof t.details==`string`?(l.messages=[t.details],c??=t.details):(l.messages=t.details,c??=l.messages?.[0]),l.raw=U in t?t[U]:t}return c??=`Error`,i(t)?a():new n(e,c,l)}const U=Symbol(),W=()=>null,G=`Timeout exceeded`;function K(){return Error(G)}function q(e){return typeof e==`object`&&!!e&&`message`in e&&e.message===G}export{H as createRequestError,q as isTimeoutError,j as processRequest};
@@ -56,6 +56,13 @@ export interface RequestOptions extends AbortOptions {
56
56
  * @since 5.0
57
57
  */
58
58
  keepAlive?: boolean;
59
+ /**
60
+ * Maximum number of characters allowed in the URL for HTTP GET requests. If this limit is exceeded, HTTP POST method will be used.
61
+ * Defaults to `maxUrlLength` in [RequestConfig](https://developers.arcgis.com/javascript/latest/references/core/config/#RequestConfig-maxUrlLength). Set to `0` to skip URL-length checks.
62
+ *
63
+ * @since 5.2
64
+ */
65
+ maxUrlLength?: number;
59
66
  /**
60
67
  * Indicates if the request should be made using the
61
68
  * HTTP DELETE, HEAD, POST, or PUT method. By default, HTTP POST will be used for `auto` if the request size is longer than the `maxUrlLength` property set in [Config](https://developers.arcgis.com/javascript/latest/references/core/config/#Config-request).
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{nextPowerOfTwo as e}from"../../../../../../../core/mathUtils.js";import{create as t}from"../../../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{fromValues as n}from"../../../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{getDefinesKey as r}from"../../../../vectorTiles/shaders/vtlMaterialUtils.js";import{vtlTextureBindingUnitSprites as i,vtlHighResCutoff as a}from"../../../definitions.js";import{Mesh as o}from"../../../meshing/Mesh.js";import{simplePipelineState as s}from"../../utils.js";import{Technique as c}from"../Technique.js";import{VTLShaderBackground as l}from"../shaders/vector-tiles/VTLShaderBackground.js";import{PrimitiveType as u}from"../../../../../../webgl/enums.js";function d(e,t){return{color:e.getPaintValue(`background-color`,t),opacity:e.getPaintValue(`background-opacity`,t),pattern:e.getPaintValue(`background-pattern`,Math.floor(t))}}class f extends c{constructor(){super(...arguments),this.type=38,this._color=n(1,0,0,1),this._patternMatrix=t(),this._mesh=null,this.shaders={background:new l}}render(n,o){if(o.tiles.length===0)return;this._loadResources(n);let{context:c,displayLevel:l,painter:u,spriteMosaic:f,styleLayer:p}=n,m=p,h=m.backgroundMaterial,{color:g,opacity:_,pattern:v}=d(m,l),y=v!==void 0,b=window.devicePixelRatio|1,x,S,C=h.key+r({hasPattern:y}),w=b>a?2:1,T={layerInfo:{depth:m.z,coordRange:o.tiles[0].rangeX},solidColor:null,pattern:null,patternMat:{mat:t()}},E=null;if(y){let e=f.getMosaicItemPosition(v,!0);if(e!=null){let{tl:t,br:n,page:r}=e;x=n[0]-t[0],S=n[1]-t[1];let a=f.getPageSize(r);a!=null&&(f.bind(c,9729,r,i),T.pattern={tlbr:[t[0],t[1],n[0],n[1]],mosaicSize:a,opacity:_},E={patternTexture:{texture:f.getTexture(r),unit:i}})}else return}else{let e=g[3]*_;this._color[0]=e*g[0],this._color[1]=e*g[1],this._color[2]=e*g[2],this._color[3]=e,T.solidColor={color:this._color}}u.setPipelineState(s);for(let t of o.tiles){if(T.layerInfo.coordRange=t.rangeX,y){let n=Math.max(2**(Math.round(l)-t.key.level),1),r=w*t.width*n,i=r/e(x),a=r/e(S);this._patternMatrix[0]=i,this._patternMatrix[4]=a,T.patternMat={mat:this._patternMatrix}}t.bind(c);let n={shader:this.shaders.background,uniforms:T,textures:E,defines:{renderMode:+!!y},optionalAttributes:h.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:h.getPrecisionFactors(),materialKey:C};u.submitDrawMeshUntyped(c,n,this._mesh,{stencilRef:t.stencilRef})}}shutdown(){this._mesh&&=(this._mesh.destroy(),null)}_loadResources(e){if(this._mesh)return;let{context:t,styleLayer:n}=e,r=n,i=new Int16Array([0,0,1,0,0,1,1,1]),a=r.backgroundMaterial.geometryLayout;if(!a)return;let s={vertex:{geometryVB:{data:i,layout:a}},groups:[{primitive:u.TRIANGLE_STRIP}],parts:[{group:0,start:0,count:4}]};this._mesh=new o(t,s)}}export{f as VTLTechniqueBackground,d as getBackgroundPaintValues};
2
+ import{nextPowerOfTwo as e}from"../../../../../../../core/mathUtils.js";import{create as t}from"../../../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{fromValues as n}from"../../../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{getDefinesKey as r}from"../../../../vectorTiles/shaders/vtlMaterialUtils.js";import{vtlTextureBindingUnitSprites as i,vtlHighResCutoff as a}from"../../../definitions.js";import{Mesh as o}from"../../../meshing/Mesh.js";import{simplePipelineState as s}from"../../utils.js";import{Technique as c}from"../Technique.js";import{VTLShaderBackground as l}from"../shaders/vector-tiles/VTLShaderBackground.js";import{PrimitiveType as u}from"../../../../../../webgl/enums.js";function d(e,t){return{color:e.getPaintValue(`background-color`,t),opacity:e.getPaintValue(`background-opacity`,t),pattern:e.getPaintValue(`background-pattern`,Math.floor(t))}}class f extends c{constructor(){super(...arguments),this.type=38,this._color=n(1,0,0,1),this._patternMatrix=t(),this._mesh=null,this.shaders={background:new l}}render(n,o){if(o.tiles.length===0)return;this._loadResources(n);let{context:c,displayLevel:l,painter:u,spriteMosaic:f,styleLayer:p}=n,m=p,h=m.backgroundMaterial,{color:g,opacity:_,pattern:v}=d(m,l),y=v!==void 0,b=window.devicePixelRatio|1,x,S,C=h.key+r({hasPattern:y}),w=b>a?2:1,T={layerInfo:{depth:m.z,coordRange:o.tiles[0].rangeX},solidColor:null,pattern:null,patternMat:{mat:t()}},E=null;if(y){let e=f.getMosaicItemPosition(v,!0);if(e!=null){let{tl:t,br:n,page:r}=e;x=n[0]-t[0],S=n[1]-t[1];let a=f.getPageSize(r);a!=null&&(f.bind(c,9729,r,i),T.pattern={tlbr:[t[0],t[1],n[0],n[1]],mosaicSize:a,opacity:_},E={patternTexture:{texture:f.getTexture(r),unit:i}})}else return}else{let e=g[3]*_;this._color[0]=e*g[0],this._color[1]=e*g[1],this._color[2]=e*g[2],this._color[3]=e,T.solidColor={color:this._color}}u.setPipelineState(s);for(let t of o.tiles){if(T.layerInfo.coordRange=t.rangeX,y){let r=Math.min(l,n.tilingScheme.tileInfo.lods.length-1),i=Math.max(2**(Math.round(r)-t.key.level),1),a=w*t.width*i,o=a/e(x),s=a/e(S);this._patternMatrix[0]=o,this._patternMatrix[4]=s,T.patternMat={mat:this._patternMatrix}}t.bind(c);let r={shader:this.shaders.background,uniforms:T,textures:E,defines:{renderMode:+!!y},optionalAttributes:h.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:h.getPrecisionFactors(),materialKey:C};u.submitDrawMeshUntyped(c,r,this._mesh,{stencilRef:t.stencilRef})}}shutdown(){this._mesh&&=(this._mesh.destroy(),null)}_loadResources(e){if(this._mesh)return;let{context:t,styleLayer:n}=e,r=n,i=new Int16Array([0,0,1,0,0,1,1,1]),a=r.backgroundMaterial.geometryLayout;if(!a)return;let s={vertex:{geometryVB:{data:i,layout:a}},groups:[{primitive:u.TRIANGLE_STRIP}],parts:[{group:0,start:0,count:4}]};this._mesh=new o(t,s)}}export{f as VTLTechniqueBackground,d as getBackgroundPaintValues};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{getDefinesKey as e}from"../../../../vectorTiles/shaders/vtlMaterialUtils.js";import{vtlTextureBindingUnitSprites as t,vtlHighResCutoff as n}from"../../../definitions.js";import{Technique as r}from"../Technique.js";import{VTLShaderFill as i}from"../shaders/vector-tiles/VTLShaderFill.js";import{VTLShaderOutline as a}from"../shaders/vector-tiles/VTLShaderOutline.js";const o=1/65536;class s extends r{constructor(){super(...arguments),this.type=40,this._fillMesh=null,this._outlineMesh=null,this.shaders={fill:new i,outline:new a}}shutdown(){this._fillMesh=null,this._outlineMesh=null}render(e,t){let{displayLevel:n,is3D:r,renderPass:i,spriteMosaic:a,styleLayer:o,styleLayerUID:s}=e,{tiles:c}=t,l=!1;for(let e of c)if(e.layerData.has(s)){let t=e.layerData.get(s);if(t.fillIndexCount>0||t.outlineIndexCount>0){l=!0;break}}if(!l)return;let u=o,d=u.getPaintProperty(`fill-pattern`),f=d!==void 0,p=f&&d.isDataDriven,m;if(f&&!p){let e=d.getValue(n);m=a.getMosaicItemPosition(e,!0)}let h=!f&&u.getPaintValue(`fill-antialias`,n),g=!r||f,_=1;if(!f){let e=u.getPaintProperty(`fill-color`),t=u.getPaintProperty(`fill-opacity`);if(!e?.isDataDriven&&!t?.isDataDriven){let e=u.getPaintValue(`fill-color`,n);_=u.getPaintValue(`fill-opacity`,n)*e[3],_<1&&(g=!0)}}if((u.hasDataDrivenColor||u.hasDataDrivenOpacity)&&(g=!0),g&&i===`opaque`)return;let v=u.getPaintValue(`fill-translate`,n),y=u.getPaintValue(`fill-translate-anchor`,n);(i===`opaque`&&!g||i===`translucent`&&g)&&this._drawFill(e,s,u,c,v,y,f,m,p);let b=!u.hasDataDrivenOutlineColor&&u.outlineUsesFillColor&&_<1;h&&i===`translucent`&&!b&&this._drawOutline(e,s,u,c,v,y)}_drawFill(r,i,a,s,c,l,u,d,f){if(u&&!f&&d==null)return;let{context:p,displayLevel:m,drawPhase:h,painter:g,pixelRatio:_,spriteMosaic:v}=r,y=_>n?2:1,b=a.fillMaterial,x=l===1,S={config:{depth:a.z+o,fillTranslation:c,tileOpacity:1},patternOptions:f||u&&d!=null?{mosaicSize:[0,0],patternFactor:1,tlbr:[0,0,0,0]}:null,color:null,opacity:null,colorMix:null,opacityMix:null},C={patternTexture:null},w={fillType:+!!u,translateAnchorViewport:x},T=b.key+e(w);if(d!=null){let{page:e,tl:n,br:r}=d,i=n[0],a=r[1],o=r[0],s=n[1],c=v.getPageSize(e);c!=null&&(v.bind(p,9729,e,t),S.patternOptions={mosaicSize:[c[0],c[1]],patternFactor:1,tlbr:[i,a,o,s]},C.patternTexture={texture:v.getTexture(e),unit:t})}let E=-1;for(let e of s){if(!e.layerData.has(i))continue;if(e.key.level!==E){E=e.key.level;let t=b.getUniforms();for(let e of t){let t=e.getValue(a,m,E,v);S[e.name]={value:t}}if(u&&S.patternOptions!=null){let t=Math.max(2**(Math.round(m)-e.key.level),1),n=e.rangeX/(y*e.width*t);S.patternOptions.patternFactor=n}}let n=e.layerData.get(i);if(n.isDestroyed||n.fillIndexCount===0||(this._fillMesh=n.getMesh(p,{value:0}),!this._fillMesh))continue;let{config:r}=S;r.tileOpacity=h===1?e.fader.value():1,e.bind(p);let o={shader:this.shaders.fill,uniforms:S,textures:C,defines:w,optionalAttributes:b.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:b.getPrecisionFactors(),materialKey:T};if(f){let r=S.patternOptions,i=n.patternMap;if(!i||r==null)continue;let a=0;for(let[n,s]of i){let i=v.getPageSize(n);i!=null&&(v.bind(p,9729,n,t),r.mosaicSize=i,C.patternTexture={texture:v.getTexture(n),unit:t},g.submitDrawMeshUntyped(p,o,this._fillMesh,{stencilRef:e.stencilRef,parts:[a++]}))}}else g.submitDrawMeshUntyped(p,o,this._fillMesh,{stencilRef:e.stencilRef});e.triangleCount+=n.fillIndexCount/3}}_drawOutline(t,n,r,i,a,s){let{context:c,displayLevel:l,spriteMosaic:u,painter:d,pixelRatio:f}=t,p=r.outlineMaterial,m={translateAnchorViewport:s===1},h=p.key+e(m),g=.75/f,_={config:{depth:r.z+o,fillTranslation:a,outlineWidth:g},color:null,opacity:null,colorMix:null,opacityMix:null},v=-1;for(let e of i){if(!e.layerData.has(n))continue;if(e.key.level!==v){v=e.key.level;let t=p.getUniforms();for(let e of t){let t=e.getValue(r,l,v,u);e.name in _&&(_[e.name]={value:t})}}let t=e.layerData.get(n);if(t.isDestroyed||t.outlineIndexCount===0||(this._outlineMesh=t.getMesh(c,{value:1}),this._outlineMesh==null))continue;e.bind(c);let i={shader:this.shaders.outline,uniforms:_,textures:{},defines:m,optionalAttributes:p.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:p.getPrecisionFactors(),materialKey:h};d.submitDrawMeshUntyped(c,i,this._outlineMesh,{stencilRef:e.stencilRef}),e.triangleCount+=t.outlineIndexCount/3}}}export{s as VTLTechniqueFill};
2
+ import{getDefinesKey as e}from"../../../../vectorTiles/shaders/vtlMaterialUtils.js";import{vtlTextureBindingUnitSprites as t,vtlHighResCutoff as n}from"../../../definitions.js";import{Technique as r}from"../Technique.js";import{VTLShaderFill as i}from"../shaders/vector-tiles/VTLShaderFill.js";import{VTLShaderOutline as a}from"../shaders/vector-tiles/VTLShaderOutline.js";const o=1/65536;class s extends r{constructor(){super(...arguments),this.type=40,this._fillMesh=null,this._outlineMesh=null,this.shaders={fill:new i,outline:new a}}shutdown(){this._fillMesh=null,this._outlineMesh=null}render(e,t){let{displayLevel:n,is3D:r,renderPass:i,spriteMosaic:a,styleLayer:o,styleLayerUID:s}=e,{tiles:c}=t,l=!1;for(let e of c)if(e.layerData.has(s)){let t=e.layerData.get(s);if(t.fillIndexCount>0||t.outlineIndexCount>0){l=!0;break}}if(!l)return;let u=o,d=u.getPaintProperty(`fill-pattern`),f=d!==void 0,p=f&&d.isDataDriven,m;if(f&&!p){let e=d.getValue(n);m=a.getMosaicItemPosition(e,!0)}let h=!f&&u.getPaintValue(`fill-antialias`,n),g=!r||f,_=1;if(!f){let e=u.getPaintProperty(`fill-color`),t=u.getPaintProperty(`fill-opacity`);if(!e?.isDataDriven&&!t?.isDataDriven){let e=u.getPaintValue(`fill-color`,n);_=u.getPaintValue(`fill-opacity`,n)*e[3],_<1&&(g=!0)}}if((u.hasDataDrivenColor||u.hasDataDrivenOpacity)&&(g=!0),g&&i===`opaque`)return;let v=u.getPaintValue(`fill-translate`,n),y=u.getPaintValue(`fill-translate-anchor`,n);(i===`opaque`&&!g||i===`translucent`&&g)&&this._drawFill(e,s,u,c,v,y,f,m,p);let b=!u.hasDataDrivenOutlineColor&&u.outlineUsesFillColor&&_<1;h&&i===`translucent`&&!b&&this._drawOutline(e,s,u,c,v,y)}_drawFill(r,i,a,s,c,l,u,d,f){if(u&&!f&&d==null)return;let{context:p,displayLevel:m,drawPhase:h,painter:g,pixelRatio:_,spriteMosaic:v}=r,y=_>n?2:1,b=a.fillMaterial,x=l===1,S={config:{depth:a.z+o,fillTranslation:c,tileOpacity:1},patternOptions:f||u&&d!=null?{mosaicSize:[0,0],patternFactor:1,tlbr:[0,0,0,0]}:null,color:null,opacity:null,colorMix:null,opacityMix:null},C={patternTexture:null},w={fillType:+!!u,translateAnchorViewport:x},T=b.key+e(w);if(d!=null){let{page:e,tl:n,br:r}=d,i=n[0],a=r[1],o=r[0],s=n[1],c=v.getPageSize(e);c!=null&&(v.bind(p,9729,e,t),S.patternOptions={mosaicSize:[c[0],c[1]],patternFactor:1,tlbr:[i,a,o,s]},C.patternTexture={texture:v.getTexture(e),unit:t})}let E=-1;for(let e of s){if(!e.layerData.has(i))continue;if(e.key.level!==E){E=e.key.level;let t=b.getUniforms();for(let e of t){let t=e.getValue(a,m,E,v);S[e.name]={value:t}}if(u&&S.patternOptions!=null){let t=Math.min(m,r.tilingScheme.tileInfo.lods.length-1),n=Math.max(2**(Math.round(t)-e.key.level),1),i=e.rangeX/(y*e.width*n);S.patternOptions.patternFactor=i}}let n=e.layerData.get(i);if(n.isDestroyed||n.fillIndexCount===0||(this._fillMesh=n.getMesh(p,{value:0}),!this._fillMesh))continue;let{config:o}=S;o.tileOpacity=h===1?e.fader.value():1,e.bind(p);let s={shader:this.shaders.fill,uniforms:S,textures:C,defines:w,optionalAttributes:b.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:b.getPrecisionFactors(),materialKey:T};if(f){let r=S.patternOptions,i=n.patternMap;if(!i||r==null)continue;let a=0;for(let[n,o]of i){let i=v.getPageSize(n);i!=null&&(v.bind(p,9729,n,t),r.mosaicSize=i,C.patternTexture={texture:v.getTexture(n),unit:t},g.submitDrawMeshUntyped(p,s,this._fillMesh,{stencilRef:e.stencilRef,parts:[a++]}))}}else g.submitDrawMeshUntyped(p,s,this._fillMesh,{stencilRef:e.stencilRef});e.triangleCount+=n.fillIndexCount/3}}_drawOutline(t,n,r,i,a,s){let{context:c,displayLevel:l,spriteMosaic:u,painter:d,pixelRatio:f}=t,p=r.outlineMaterial,m={translateAnchorViewport:s===1},h=p.key+e(m),g=.75/f,_={config:{depth:r.z+o,fillTranslation:a,outlineWidth:g},color:null,opacity:null,colorMix:null,opacityMix:null},v=-1;for(let e of i){if(!e.layerData.has(n))continue;if(e.key.level!==v){v=e.key.level;let t=p.getUniforms();for(let e of t){let t=e.getValue(r,l,v,u);e.name in _&&(_[e.name]={value:t})}}let t=e.layerData.get(n);if(t.isDestroyed||t.outlineIndexCount===0||(this._outlineMesh=t.getMesh(c,{value:1}),this._outlineMesh==null))continue;e.bind(c);let i={shader:this.shaders.outline,uniforms:_,textures:{},defines:m,optionalAttributes:p.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:p.getPrecisionFactors(),materialKey:h};d.submitDrawMeshUntyped(c,i,this._outlineMesh,{stencilRef:e.stencilRef}),e.triangleCount+=t.outlineIndexCount/3}}}export{s as VTLTechniqueFill};