@arcgis/core 4.24.0-next.20220520 → 4.24.0-next.20220521

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 (49) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{26646a7545a194e67441.js → 27572edd67242e1b6646.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{d94c5f36d52cf71f0bb9.js → 27f974dae930eb12fe38.js} +1 -1
  4. package/assets/esri/core/workers/chunks/2b708cc5ba0edd6c80e1.js +1 -0
  5. package/assets/esri/core/workers/chunks/{c5fadaa98749ffb490f5.js → 3c258ac11c963b7d9509.js} +1 -1
  6. package/assets/esri/core/workers/chunks/40d70d446abe357d6f43.js +1 -0
  7. package/assets/esri/core/workers/chunks/5cf2064bfd9d0847d9ec.js +1 -0
  8. package/assets/esri/core/workers/chunks/{f5089121d845ec594008.js → 6ac32325a961f1cf3c1b.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{1c2805cc97dcee70e60d.js → 816ae3f0513ecf856f8f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{8033531b0cc706b40d86.js → 8523d45cf4765eddc380.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{a5ee17cdc9eb23ebeaf0.js → 85f2f6a50cf1b6c7ce82.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{c40d9caf5189be2c698e.js → 87b83dfce3ee252aba94.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{6e48b0db65bcaaace838.js → 8cd8dad8bcd5c0ef445e.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{54711b8a98104eeec833.js → 8ec860742695e5bbbcb2.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{e51f0e71f2a55af604d3.js → 93c4e01b237a6b3f871f.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{3e94e35f44aadbb332ff.js → aae70408958f6ee7279e.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{7e150c38e25fbb8bacaf.js → b476a80ef81c211685be.js} +1 -1
  18. package/assets/esri/core/workers/chunks/b8db486a3dba68a8030a.js +1 -0
  19. package/assets/esri/core/workers/chunks/{82b6535a30287c74ba13.js → c0e6dbecdbd30066a82c.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{66e8a253312d72a8e7f9.js → c4115e8d1eb2ca6bb605.js} +1 -1
  21. package/assets/esri/core/workers/chunks/cd04bae81e5fc27ec97b.js +1 -0
  22. package/assets/esri/core/workers/chunks/{24217129d492e170f0f0.js → f668ccaf8bd0be0ab57b.js} +1 -1
  23. package/core/CollectionFlattener.js +1 -1
  24. package/core/promiseUtils.js +1 -1
  25. package/interfaces.d.ts +78 -2
  26. package/layers/FeatureLayer.js +1 -1
  27. package/layers/SubtypeGroupLayer.js +1 -1
  28. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  29. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  30. package/layers/mixins/ArcGISImageService.js +1 -1
  31. package/layers/mixins/refresh.js +1 -1
  32. package/layers/support/FeatureReductionCluster.js +1 -1
  33. package/layers/support/capabilities.js +1 -1
  34. package/package.json +1 -1
  35. package/support/revision.js +1 -1
  36. package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
  37. package/views/2d/engine/webgl/TextureManager.js +1 -1
  38. package/views/2d/engine/webgl/animatedFormats/BaseAnimatableTextureResource.js +1 -1
  39. package/views/2d/engine/webgl/animatedFormats/apng.js +1 -1
  40. package/views/2d/engine/webgl/animatedFormats/gif.js +1 -1
  41. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  42. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  43. package/views/2d/layers/features/schemaUtils.js +1 -1
  44. package/views/SceneView.js +1 -1
  45. package/assets/esri/core/workers/chunks/128f461007ef039d4f73.js +0 -1
  46. package/assets/esri/core/workers/chunks/672da24bbf86718bf48d.js +0 -1
  47. package/assets/esri/core/workers/chunks/824a700ba611e6c4fa9a.js +0 -1
  48. package/assets/esri/core/workers/chunks/be4bf1e4cbe2a593f8b3.js +0 -1
  49. package/assets/esri/core/workers/chunks/d6315aa9eedf79a7bca1.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import s from"../../../core/Loadable.js";import{isSome as r,isNone as o}from"../../../core/maybe.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{queryFeatureSetJSON as a,crsDefault as n,getSpatialReferenceWkid as u,getServerLandingPage as c,getServerConformance as l,getServerCollections as m,getServerOpenApi as d,getCollectionDefinition as y,crsPrefix as f}from"../../ogc/ogcFeatureUtils.js";import g from"../../../rest/support/FeatureSet.js";import h from"../../../geometry/SpatialReference.js";import{typeKebabDictionary as S}from"../../../geometry/support/typeUtils.js";let x=class extends s{constructor(){super(...arguments),this.featureDefinition=null,this.type="ogc-feature"}load(e){return this.addResolvingPromise(this._loadOGCServices(this.layer,e)),this.when()}getFeatureDefinition(){const{featureDefinition:{collection:e,layerDefinition:t,spatialReference:s,supportedCrs:r},layer:{apiKey:o,capabilities:p,customParameters:i}}=this;return{capabilities:p,collection:e,layerDefinition:t,queryParameters:{apiKey:o,customParameters:i},spatialReference:s,supportedCrs:r}}queryExtent(e,t={}){return null}queryFeatureCount(e,t={}){return null}queryFeatures(e,t={}){return this.queryFeaturesJSON(e,t).then((e=>g.fromJSON(e)))}queryFeaturesJSON(e,t={}){const s=this.getFeatureDefinition();return this.load(t).then((()=>a(s,e,t)))}queryObjectIds(e,t={}){return null}serviceSupportsSpatialReference(e){return!(!e.isWGS84&&!e.isWebMercator)||!!this.featureDefinition.supportedCrs[e.wkid]}_conformsToType(e,t){const s=new RegExp(`^${t}$`,"i");return e.conformsTo.some((e=>s.test(e)))??!1}_getCapabilities(e,t){const s=r(t)?t.components?.parameters:null;return{attachment:null,data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s?.limit?.schema?.maximum??s?.limitFeatures?.schema?.maximum??5e3,maxRecordCountFactor:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,tileMaxRecordCount:void 0},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1}}}_getExtent(e){const t=e.extent?.spatial;if(!t)return null;const s=t.bbox[0],r=4===s.length,o=s[0],p=s[1],i=r?void 0:s[2];return{xmin:o,ymin:p,xmax:r?s[2]:s[3],ymax:r?s[3]:s[4],zmin:i,zmax:r?void 0:s[5],spatialReference:h.WGS84.toJSON()}}_getStorageSpatialReference(e){const t=e.storageCrs??n,s=u(t);return o(s)?h.WGS84:new h({wkid:s})}_getSupportedSpatialReferences(e,t){const s="#/crs",r=e.crs??[n],o=r.includes(s)?r.filter((e=>e!==s)).concat(t.crs):r,p=/^http:\/\/www\.opengis.net\/def\/crs\/epsg\/.*\/3785$/i;return o.filter((e=>!p.test(e)))}async _loadOGCServices(e,s){const o=r(s)?s.signal:null,{apiKey:p,collectionId:i,customParameters:a,fields:n,geometryType:g,hasZ:h,objectIdField:x,timeInfo:R,url:w}=e,C={fields:n?.map((e=>e.toJSON())),geometryType:S.toJSON(g),hasZ:h,objectIdField:x,timeInfo:R?.toJSON()},j={apiKey:p,customParameters:a,signal:o},O=await c(w,j),[v,F]=await Promise.all([l(O,j),m(O,j)]);if(!this._conformsToType(v,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson"))throw new t("ogc-feature-layer:no-geojson-support","Server does not support geojson");const b=F.collections.find((e=>e.id===i));if(!b)throw new t("ogc-feature-layer:collection-not-found","Server does not contain the named collection");const D=this._conformsToType(v,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30")?await d(O,j):null,P=await y(b,C,j),T=this._getCapabilities(P.hasZ,D),_=this._getExtent(b),q=this._getStorageSpatialReference(b).toJSON(),E=this._getSupportedSpatialReferences(b,F),G=new RegExp(`^${f}`,"i"),I={};for(const t of E){const e=u(t);r(e)&&(I[e]||(I[e]=t.replace(G,"")))}P.extent=_,this.featureDefinition={capabilities:T,collection:b,layerDefinition:P,queryParameters:{},spatialReference:q,supportedCrs:I}}};e([p()],x.prototype,"featureDefinition",void 0),e([p({constructOnly:!0})],x.prototype,"layer",void 0),e([p()],x.prototype,"type",void 0),x=e([i("esri.layers.graphics.sources.OGCFeatureSource")],x);export{x as OGCFeatureSource};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import s from"../../../core/Loadable.js";import{isSome as r,isNone as o}from"../../../core/maybe.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{queryFeatureSetJSON as a,crsDefault as n,getSpatialReferenceWkid as u,getServerLandingPage as c,getServerConformance as l,getServerCollections as m,getServerOpenApi as d,getCollectionDefinition as y,crsPrefix as f}from"../../ogc/ogcFeatureUtils.js";import g from"../../../rest/support/FeatureSet.js";import h from"../../../geometry/SpatialReference.js";import{typeKebabDictionary as S}from"../../../geometry/support/typeUtils.js";let x=class extends s{constructor(){super(...arguments),this.featureDefinition=null,this.type="ogc-feature"}load(e){return this.addResolvingPromise(this._loadOGCServices(this.layer,e)),this.when()}getFeatureDefinition(){const{featureDefinition:{collection:e,layerDefinition:t,spatialReference:s,supportedCrs:r},layer:{apiKey:o,capabilities:p,customParameters:i}}=this;return{capabilities:p,collection:e,layerDefinition:t,queryParameters:{apiKey:o,customParameters:i},spatialReference:s,supportedCrs:r}}queryExtent(e,t={}){return null}queryFeatureCount(e,t={}){return null}queryFeatures(e,t={}){return this.queryFeaturesJSON(e,t).then((e=>g.fromJSON(e)))}queryFeaturesJSON(e,t={}){const s=this.getFeatureDefinition();return this.load(t).then((()=>a(s,e,t)))}queryObjectIds(e,t={}){return null}serviceSupportsSpatialReference(e){return!(!e.isWGS84&&!e.isWebMercator)||!!this.featureDefinition.supportedCrs[e.wkid]}_conformsToType(e,t){const s=new RegExp(`^${t}$`,"i");return e.conformsTo.some((e=>s.test(e)))??!1}_getCapabilities(e,t){const s=r(t)?t.components?.parameters:null;return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s?.limit?.schema?.maximum??s?.limitFeatures?.schema?.maximum??5e3,maxRecordCountFactor:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,tileMaxRecordCount:void 0},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1}}}_getExtent(e){const t=e.extent?.spatial;if(!t)return null;const s=t.bbox[0],r=4===s.length,o=s[0],p=s[1],i=r?void 0:s[2];return{xmin:o,ymin:p,xmax:r?s[2]:s[3],ymax:r?s[3]:s[4],zmin:i,zmax:r?void 0:s[5],spatialReference:h.WGS84.toJSON()}}_getStorageSpatialReference(e){const t=e.storageCrs??n,s=u(t);return o(s)?h.WGS84:new h({wkid:s})}_getSupportedSpatialReferences(e,t){const s="#/crs",r=e.crs??[n],o=r.includes(s)?r.filter((e=>e!==s)).concat(t.crs):r,p=/^http:\/\/www\.opengis.net\/def\/crs\/epsg\/.*\/3785$/i;return o.filter((e=>!p.test(e)))}async _loadOGCServices(e,s){const o=r(s)?s.signal:null,{apiKey:p,collectionId:i,customParameters:a,fields:n,geometryType:g,hasZ:h,objectIdField:x,timeInfo:C,url:R}=e,w={fields:n?.map((e=>e.toJSON())),geometryType:S.toJSON(g),hasZ:h,objectIdField:x,timeInfo:C?.toJSON()},j={apiKey:p,customParameters:a,signal:o},F=await c(R,j),[O,v]=await Promise.all([l(F,j),m(F,j)]);if(!this._conformsToType(O,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson"))throw new t("ogc-feature-layer:no-geojson-support","Server does not support geojson");const b=v.collections.find((e=>e.id===i));if(!b)throw new t("ogc-feature-layer:collection-not-found","Server does not contain the named collection");const D=this._conformsToType(O,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30")?await d(F,j):null,T=await y(b,w,j),P=this._getCapabilities(T.hasZ,D),_=this._getExtent(b),q=this._getStorageSpatialReference(b).toJSON(),E=this._getSupportedSpatialReferences(b,v),G=new RegExp(`^${f}`,"i"),A={};for(const t of E){const e=u(t);r(e)&&(A[e]||(A[e]=t.replace(G,"")))}T.extent=_,this.featureDefinition={capabilities:P,collection:b,layerDefinition:T,queryParameters:{},spatialReference:q,supportedCrs:A}}};e([p()],x.prototype,"featureDefinition",void 0),e([p({constructOnly:!0})],x.prototype,"layer",void 0),e([p()],x.prototype,"type",void 0),x=e([i("esri.layers.graphics.sources.OGCFeatureSource")],x);export{x as OGCFeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{queryCapabilities as e}from"../../data/QueryEngineCapabilities.js";import{defaultPointSymbolJSON as r,defaultPolylineSymbolJSON as p,defaultPolygonSymbolJSON as o}from"../../../../symbols/support/defaultsJSON.js";function n(t){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?r:"esriGeometryPolyline"===t?p:o}}}const u=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let i=1;function a(s,e){if(t("esri-csp-restrictions"))return()=>({[e]:null,...s});try{let t=`this.${e} = null;`;for(const e in s){t+=`this${u.test(e)?`.${e}`:`["${e}"]`} = ${JSON.stringify(s[e])};`}const r=new Function(`\n return class AttributesClass$${i++} {\n constructor() {\n ${t};\n }\n }\n `)();return()=>new r}catch(r){return()=>({[e]:null,...s})}}function l(t={}){return[{name:"New Feature",description:"",prototype:{attributes:s(t)}}]}function c(t,s){return{attachment:null,data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:s,supportsDelete:s,supportsEditing:s,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:s,supportsExceedsLimitStatistics:!0},query:e,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0},editing:{supportsGeometryUpdate:s,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1}}}export{c as createCapabilities,a as createDefaultAttributesFunction,l as createDefaultTemplate,n as createDrawingInfo};
5
+ import t from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{queryCapabilities as e}from"../../data/QueryEngineCapabilities.js";import{defaultPointSymbolJSON as r,defaultPolylineSymbolJSON as p,defaultPolygonSymbolJSON as o}from"../../../../symbols/support/defaultsJSON.js";function u(t){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?r:"esriGeometryPolyline"===t?p:o}}}const n=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let i=1;function a(s,e){if(t("esri-csp-restrictions"))return()=>({[e]:null,...s});try{let t=`this.${e} = null;`;for(const e in s){t+=`this${n.test(e)?`.${e}`:`["${e}"]`} = ${JSON.stringify(s[e])};`}const r=new Function(`\n return class AttributesClass$${i++} {\n constructor() {\n ${t};\n }\n }\n `)();return()=>new r}catch(r){return()=>({[e]:null,...s})}}function l(t={}){return[{name:"New Feature",description:"",prototype:{attributes:s(t)}}]}function c(t,s){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:s,supportsDelete:s,supportsEditing:s,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:s,supportsExceedsLimitStatistics:!0},query:e,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsGeometryUpdate:s,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1}}}export{c as createCapabilities,a as createDefaultAttributesFunction,l as createDefaultTemplate,u as createDrawingInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{read as r,rasterRendererTypes as i,websceneRasterRendererTypes as s}from"../../rasterRenderers.js";import n from"../../request.js";import o from"../../core/Error.js";import{strict as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isSome as p,isNone as c,unwrap as m}from"../../core/maybe.js";import{when as d}from"../../core/promiseUtils.js";import{watch as h}from"../../core/reactiveUtils.js";import{urlToObject as f}from"../../core/urlUtils.js";import{aliasOf as y}from"../../core/accessorSupport/decorators/aliasOf.js";import{ensureClass as g,Integer as R,ensureNumber as v}from"../../core/accessorSupport/ensureType.js";import{property as b,ensureRange as S}from"../../core/accessorSupport/decorators/property.js";import{reader as I}from"../../core/accessorSupport/decorators/reader.js";import{subclass as x}from"../../core/accessorSupport/decorators/subclass.js";import{writer as w}from"../../core/accessorSupport/decorators/writer.js";import{opacity as _,url as F}from"../support/commonProperties.js";import D from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as j}from"../support/ExportImageServiceParameters.js";import T from"../support/Field.js";import P from"../support/FieldsIndex.js";import{isSupportedRendererType as O}from"../support/imageryRendererUtils.js";import N from"../support/MosaicRule.js";import C from"../support/PixelBlock.js";import{interpolationKebab as M,noDataInterpretationKebab as J}from"../support/rasterEnums.js";import q from"../support/RasterFunction.js";import V from"../support/RasterInfo.js";import A from"../support/RasterJobHandler.js";import{decode as E,getFormat as Q}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as z}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as H,getDefaultBandCombination as U,createDefaultRenderer as L,normalizeRendererJSON as B}from"../../renderers/support/rasterRendererHelper.js";import G from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as k,computePixelSpaceLocations as W,computeHistograms as X,computeStatisticsHistograms as K,getImageSpatialReferenceQueryParameter as Y,getSamples as $,identify as Z}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as ee}from"../../rest/query/executeQueryJSON.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import"../graphics/featureConversionUtils.js";import te from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import re from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import ie from"../../rest/support/FeatureSet.js";import se from"../../rest/support/Query.js";import"../../kernel.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as ne}from"../../rest/query/executeForCount.js";import{executeForIds as oe}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{fetchServiceRasterInfo as ae,generateRasterInfo as le}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as ue}from"../../rest/imageService/getCatalogItemRasterInfo.js";import pe from"../../rest/support/ImageAngleParameters.js";import ce from"../../rest/support/ImageHistogramParameters.js";import me from"../../rest/support/ImageIdentifyParameters.js";import de from"../../rest/support/ImagePixelLocationParameters.js";import he from"../../rest/support/ImageSampleParameters.js";import{createFlowMesh as fe}from"../../views/2d/engine/flow/dataUtils.js";import ye from"../../geometry/SpatialReference.js";const ge=u.getLogger("esri.layers.mixins.ArcGISImageService"),Re=a()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),ve=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),be=S(v,{min:0,max:255});function Se(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi)?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return t?t.join("/"):null}const Ie=a=>{let u=class extends a{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._defaultServiceMosaicRule=null,this._serviceSourceType=null,this._serviceSupportsMosaicRule=null,this.rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandCount=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelSizeX=null,this.pixelSizeY=null,this.pixelFilter=null,this.raster=void 0,this.viewId=void 0,this.symbolizer=null,this.rasterAttributeTable=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new j({layer:this}))}readDefaultServiceMosaicRule(e,t){return this._serviceSupportsMosaicRule?N.fromJSON(t):null}readServiceSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.length<1||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get fieldsIndex(){return this.fields?new P(this.fields):null}set format(e){e&&ve.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=N.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?N.fromJSON(r):this._isMosaicRuleSupported(t)?N.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new N({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=be(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return this.url?f(this.url):null}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){const s=t?.layerDefinition?.drawingInfo?.renderer,n=r(s,i);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!s.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),O(n)||ge.warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.rasterAttributeTableFieldPrefix||"Raster.",t=new T({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new T({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new T({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new T({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),null==this.pixelFilter||"esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType||(s.push(new T({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new T({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const n=this.rasterInfo.attributeTable&&this.rasterInfo.attributeTable.fields||null;if(n&&n.length>0){const t=n.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=q.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?q.fromJSON({rasterFunctionDefinition:t.renderingRule}):q.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){const i=e.toJSON();i.rasterFunctionDefinition?t[r]=i.rasterFunctionDefinition:t[r]=i}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?ye.fromJSON(r):null}readPixelType(e){return Re.fromJSON(e)||e}writePixelType(e,t,r){(c(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=Re.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;if(!this._isPicture()&&this.renderer&&this.symbolizer&&!this.pixelFilter){const i=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(this.renderer.toJSON()),s=this._rasterJobHandler.instance,{bandIds:n}=this;if(s){i&&(this.symbolizer.bind(),await s.updateSymbolizer(this.symbolizer,t),this._cachedRendererJson=this.renderer.toJSON());const o=await s.symbolize({bandIds:n,...e},t);r={extent:e.extent,pixelBlock:o}}else r={extent:e.extent,pixelBlock:this.symbolizer.symbolize({bandIds:n,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputeAngles)throw new o("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=g(pe,e).clone(),k(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputePixelLocation)throw new o("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=g(de,e).clone(),W(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputeHistograms)throw new o("imagery-layer:compute-histograms","this operation is not supported on the input image service");e=g(ce,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),X(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputeStatisticsHistograms)throw new o("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");e=g(ce,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),K(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return p(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)return Promise.reject(new o("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required."));const s=this.renderer||this.symbolizer?this.generateRasterInfo(this.renderingRule,{signal:i.signal}):null;return d(s).then((s=>{s&&(this.rasterInfo=s);const n={imageServiceParameters:this.getExportImageServiceParameters(e,t,r,i.timeExtent),imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}))}fetchKeyProperties(e){return n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>e.data))}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new o("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>ie.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return ue(this.parsedUrl.path,e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(this.parsedUrl.path+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(this.parsedUrl.path+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},u=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},y=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([o,u,y]);let R=g[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const v=te.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);v&&(v.spatialReference=new ye({wkid:0,imageCoordinateSystem:i}));const b=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],S=b.length;if(S<3)return{ics:i,icsToPixelTransform:R,icsExtent:v,northDirection:null};let I=0,x=0,w=0,_=0;for(let n=0;n<S;n++)I+=b[n].x,x+=b[n].y,w+=b[n].x*b[n].x,_+=b[n].x*b[n].y;const F=(S*_-I*x)/(S*w-I*I);let D=0;const j=b[p-1].x>b[0].x,T=b[p-1].y>b[0].y;return F===1/0?D=T?90:270:0===F?D=j?0:180:F>0?D=j?180*Math.atan(F)/Math.PI:180*Math.atan(F)/Math.PI+180:F<0&&(D=T?180+180*Math.atan(F)/Math.PI:360+180*Math.atan(F)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:v,northDirection:D}}async generateRasterInfo(e,t){if((!e||"none"===e?.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e))&&p(this.serviceRasterInfo))return this.serviceRasterInfo;const r=Se(e);if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i=this._generateRasterInfo(e,t);this._functionRasterInfos[r]=i;try{return await i}catch{return this._functionRasterInfos[r]=null,null}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=Y(e.spatialReference,this.parsedUrl.path);p(this.serviceRasterInfo)&&this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.renderingRule?.rasterFunctionDefinition,c=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRenderingRule(this.renderingRule)&&!u&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const m=this._serviceSupportsMosaicRule?this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,i):null;n.mosaicRule=m&&JSON.stringify(m),n.renderingRule=this._getRenderingRuleString(q.fromJSON(l));const d={};if(i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${null==e?"null":e},${null==t?"null":t}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...d}}async getSamples(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsGetSamples)throw new o("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=g(he,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),$(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsIdentify)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");e=g(me,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;if(s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule){const t=this._combineMosaicRuleWithTimeExtent(i,e.timeExtent);e.mosaicRule=m(t)}return r&&null==e.raster&&(e.raster=r),Z(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new se;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ee(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),oe(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ne(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new o("imagery-layer: query-visible-rasters","missing query parameter");const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let a=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this.rasterFunctionNamesIndex;if(p(e.outFields)&&(a=e.outFields.some((e=>!e.toLowerCase().includes(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(m)&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new q({functionName:e[0]}))),u=t.map((e=>e[1])),0===l.length?this.renderingRule?(l.push(this.renderingRule),u.push(this.renderingRule.functionName)):l=null:this.renderingRule&&!l.some((e=>e.functionName===this.renderingRule.functionName))&&(l.push(this.renderingRule),u.push(this.renderingRule.functionName))}const h=c(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=e.timeExtent||this.timeExtent,y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f),g=this._getQueryParams({geometry:e.geometry,timeExtent:f,mosaicRule:y,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:a,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new me(g);try{await this.generateRasterInfo(this.renderingRule);const r=await Z(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,o=r.value.toLowerCase().includes("nodata");if(!(a&&!h&&r?.catalogItems?.features.length&&(n||!o)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",c=r.catalogItems.features,m=c.map((e=>e.attributes?.[l])),d=new se({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),f=await this.queryRasters(d);return f?.features?.length&&f.features.forEach((t=>{c.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new re(t.geometry),p(e.outSpatialReference)&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new o("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(this.parsedUrl.path+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):fe(e.meshType,e.simulationSettings,e.flowData,p(t.signal)?t.signal:(new AbortController).signal)}async _fetchService(e){await this._fetchServiceInfo(e),p(this.serviceRasterInfo)&&!this.rasterInfo&&(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=p(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):ae(this.parsedUrl.path,t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),e))),i=this._hasRenderingRule(this.renderingRule)?this.generateRasterInfo(this.renderingRule,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),ge.warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.own(h((()=>this.renderingRule),(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))})));const t=p(this.serviceRasterInfo)&&this.serviceRasterInfo.multidimensionalInfo;t&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const r=this.timeInfo;if(c(e)||c(this.multidimensionalInfo)||c(t)||c(r?.startField))return e;const{startField:i}=r;if(e=e.clone(),"mosaic-dataset"===this._serviceSourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==i)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const s=e.multidimensionalDefinition.filter((e=>e.dimensionName===i)),n=p(t.start)?t.start.getTime():null,o=p(t.end)?t.end.getTime():null,a=null==n||null==o||n===o,l=a?[n||o]:[[n,o]],u=this.version>=10.8;if(s.length)s.forEach((e=>{e.dimensionName===i&&(u?(e.dimensionName=null,e.isSlice=null,e.values=null):(e.isSlice=a,e.values=l))}));else if(!u){const t=e.multidimensionalDefinition.filter((e=>null!=e.variableName&&null==e.dimensionName));t.length?t.forEach((e=>{e.dimensionName=i,e.isSlice=a,e.values=l})):e.multidimensionalDefinition.push(new D({variableName:"",dimensionName:i,isSlice:a,values:l}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return c(e)?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>!(!e.variableName&&!e.dimensionName))),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this._serviceSourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsQuery)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=p(e)?g(se,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new A;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>null)),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&this._hasRenderingRule(r)&&1===t.bandCount&&["u8","s8"].includes(t.pixelType)||H(this.rasterInfo).includes(this.renderer.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:i}=await n(this.parsedUrl.path,{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new o("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),r=e.currentVersion>=10.71&&e.hasMultidimensions&&e.timeInfo&&!(e.objectIdField&&e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){if(!this._isPicture()&&!this.pixelFilter){if(!this.bandIds&&this.rasterInfo.bandCount>=3){const e=U(this.rasterInfo);!e||3===this.rasterInfo.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=L(this.rasterInfo,{bandIds:this.bandIds,variableName:this.renderingRule?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=B(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=this.rasterInfo):this.symbolizer=new G({rendererJSON:t,rasterInfo:this.rasterInfo}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:p(e.pixelBlock)&&e.pixelBlock.clone()}}_getQueryParams(e){p(e?.renderingRule)&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):E(e,t,r)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.serviceRasterInfo)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;return(await n(this.parsedUrl.path+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e})).data?.rasterFunctionInfos}return null}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,signal:i}=e;if(r&&!this.pixelFilter&&t.format?.indexOf("png")>-1){return{imageElement:(await n(this.parsedUrl.path+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i})).data,params:t}}const s=this._initJobHandler(),a=n(this.parsedUrl.path+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i}),l=(await Promise.all([a,s]))[0].data,u=t.format||"jpgpng";let p=u;if("bsq"!==p&&"bip"!==p&&(p=Q(l)),!p)throw new o("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(l)));const c={signal:i},m="gif"===u||"bmp"===u||u.includes("png")&&("png"===p||"jpg"===p)?E(l,{useCanvas:!0,...t},c):this._decodePixelBlock(l,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:u},c);return{pixelData:{pixelBlock:await m,extent:t.extent},params:t}}_generateRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return le(this.parsedUrl.path,e,r)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this._defaultServiceMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;const t=e.variables[0].dimensions,r="",i=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s],n=e.extent;let o=!0,a=[n[0]];e.hasRanges&&!0===e.hasRanges?(o=!1,a=[e.values[0]]):"stdz"===e.name.toLowerCase()&&Math.abs(n[1])<=Math.abs(n[0])&&(a=[n[1]]),i.push(new D({variableName:r,dimensionName:t[s].name,isSlice:o,values:a}))}if(i.length>0){this.mosaicRule=this.mosaicRule||new N;const e=this.mosaicRule.multidimensionalDefinition;(!e||e&&e.length<=0)&&(this.mosaicRule.multidimensionalDefinition=i)}}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,c=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().includes("nodata"),h=[];if(i&&!u&&!d){const e={};e[m]=0;c=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,y,g;this._updateResponseFieldNames(u,a),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i){if(y=c[t],g=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.includes(this.renderingRule.functionName)?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=y,f.attributes[r]=g,this._updateFeatureWithMagDirValues(f,y);const o=this.fields&&this.fields.length>0;let a=this.renderingRule&&p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable?o?y:i:g;this.renderingRule||(a=o?y:i),this._updateFeatureWithRasterAttributeTableValues(f,a)}if(f.sourceLayer=f.layer=this,o&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=l[e]}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo&&this.rasterInfo.attributeTable||p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable,i=r&&r.features;if(!i)return;const s=r.fields,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),o=n&&n[0];if(!o)return;const a=i.filter((e=>e.attributes[o]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const r=this.rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if("esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType)return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new C({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new te(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:z([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)||e.forEach((e=>{if(e&&e.attributes)for(const i of t)if(r.has(i)){const t=r.get(i).name;t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(this._hasRenderingRule(e)){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRenderingRule(e){return e&&e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:t.includes("mensuration")&&a,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&o,supportsComputePixelLocation:r>=10.7&&t.includes("catalog"),supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}}}};return e([b()],u.prototype,"_functionRasterInfos",void 0),e([b()],u.prototype,"_rasterJobHandler",void 0),e([b({dependsOn:["_serviceSupportsMosaicRule"]})],u.prototype,"_defaultServiceMosaicRule",void 0),e([I("_defaultServiceMosaicRule",["defaultMosaicMethod"])],u.prototype,"readDefaultServiceMosaicRule",null),e([b()],u.prototype,"_cachedRendererJson",void 0),e([b({readOnly:!0})],u.prototype,"_serviceSourceType",void 0),e([I("_serviceSourceType",["serviceSourceType","fields"])],u.prototype,"readServiceSourceType",null),e([b({readOnly:!0})],u.prototype,"_serviceSupportsMosaicRule",void 0),e([I("_serviceSupportsMosaicRule",["currentVersion","fields"])],u.prototype,"readServiceSupportsMosaicRule",null),e([b()],u.prototype,"rasterAttributeTableFieldPrefix",void 0),e([b({readOnly:!0})],u.prototype,"rasterFunctionNamesIndex",null),e([b()],u.prototype,"adjustAspectRatio",void 0),e([b({readOnly:!0}),y("serviceRasterInfo.bandCount")],u.prototype,"bandCount",void 0),e([b({type:[R],json:{write:!0}})],u.prototype,"bandIds",void 0),e([I("bandIds")],u.prototype,"readBandIds",null),e([b({readOnly:!0,json:{read:!1}})],u.prototype,"capabilities",void 0),e([I("service","capabilities",["capabilities","currentVersion","serviceDataType"])],u.prototype,"readCapabilities",null),e([b({type:Number})],u.prototype,"compressionQuality",void 0),e([w("compressionQuality")],u.prototype,"writeCompressionQuality",null),e([b({type:Number})],u.prototype,"compressionTolerance",void 0),e([w("compressionTolerance")],u.prototype,"writeCompressionTolerance",null),e([b({json:{read:{source:"copyrightText"}}})],u.prototype,"copyright",void 0),e([b({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],u.prototype,"definitionExpression",void 0),e([b({readOnly:!0,constructOnly:!0})],u.prototype,"exportImageServiceParameters",void 0),e([b()],u.prototype,"rasterInfo",void 0),e([b({readOnly:!0,type:[T]})],u.prototype,"fields",void 0),e([b({readOnly:!0})],u.prototype,"fieldsIndex",null),e([b({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],u.prototype,"format",null),e([I("service","format",["serviceDataType"])],u.prototype,"readFormat",null),e([b({type:te})],u.prototype,"fullExtent",void 0),e([b({readOnly:!0})],u.prototype,"hasMultidimensions",void 0),e([b({json:{read:{source:"maxImageHeight"}}})],u.prototype,"imageMaxHeight",void 0),e([b({json:{read:{source:"maxImageWidth"}}})],u.prototype,"imageMaxWidth",void 0),e([b({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],u.prototype,"interpolation",void 0),e([b()],u.prototype,"minScale",void 0),e([I("service","minScale")],u.prototype,"readMinScale",null),e([b()],u.prototype,"maxScale",void 0),e([I("service","maxScale")],u.prototype,"readMaxScale",null),e([b({type:N})],u.prototype,"mosaicRule",null),e([I("mosaicRule",["mosaicRule","defaultMosaicMethod"])],u.prototype,"readMosaicRule",null),e([w("mosaicRule")],u.prototype,"writeMosaicRule",null),e([b({readOnly:!0}),y("serviceRasterInfo.multidimensionalInfo")],u.prototype,"multidimensionalInfo",void 0),e([b({json:{type:R}})],u.prototype,"noData",void 0),e([w("noData")],u.prototype,"writeNoData",null),e([b({type:String,json:{type:J.jsonValues,read:J.read,write:J.write}})],u.prototype,"noDataInterpretation",void 0),e([b({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],u.prototype,"objectIdField",void 0),e([I("objectIdField")],u.prototype,"readObjectIdField",null),e([b({})],u.prototype,"geometryType",void 0),e([b({})],u.prototype,"typeIdField",void 0),e([b({})],u.prototype,"types",void 0),e([b({readOnly:!0})],u.prototype,"parsedUrl",null),e([b({readOnly:!0}),y("serviceRasterInfo.pixelSize.x")],u.prototype,"pixelSizeX",void 0),e([b({readOnly:!0}),y("serviceRasterInfo.pixelSize.y")],u.prototype,"pixelSizeY",void 0),e([b({type:Function})],u.prototype,"pixelFilter",void 0),e([b()],u.prototype,"raster",void 0),e([b()],u.prototype,"viewId",void 0),e([b({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:s,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],u.prototype,"renderer",null),e([I("renderer")],u.prototype,"readRenderer",null),e([w("renderer")],u.prototype,"writeRenderer",null),e([b()],u.prototype,"symbolizer",void 0),e([b(_)],u.prototype,"opacity",void 0),e([b({readOnly:!0}),y("serviceRasterInfo.attributeTable")],u.prototype,"rasterAttributeTable",void 0),e([b({readOnly:!0})],u.prototype,"rasterFields",null),e([b({constructOnly:!0})],u.prototype,"rasterFunctionInfos",void 0),e([b({type:q})],u.prototype,"renderingRule",null),e([I("renderingRule",["renderingRule","rasterFunctionInfos"])],u.prototype,"readRenderingRule",null),e([w("renderingRule")],u.prototype,"writeRenderingRule",null),e([b()],u.prototype,"serviceDataType",void 0),e([b({readOnly:!0,type:ye})],u.prototype,"spatialReference",void 0),e([I("spatialReference",["spatialReference","extent"])],u.prototype,"readSpatialReference",null),e([b({json:{type:Re.jsonValues}})],u.prototype,"pixelType",void 0),e([I("pixelType")],u.prototype,"readPixelType",null),e([w("pixelType")],u.prototype,"writePixelType",null),e([b({constructOnly:!0,type:V})],u.prototype,"serviceRasterInfo",void 0),e([b()],u.prototype,"sourceJSON",void 0),e([b(F)],u.prototype,"url",void 0),e([b({readOnly:!0})],u.prototype,"version",void 0),e([I("version",["currentVersion","fields","timeInfo"])],u.prototype,"readVersion",null),u=e([x("esri.layers.mixins.ArcGISImageService")],u),u};export{Ie as ArcGISImageService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{read as r,rasterRendererTypes as i,websceneRasterRendererTypes as s}from"../../rasterRenderers.js";import n from"../../request.js";import o from"../../core/Error.js";import{strict as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isSome as p,isNone as c,unwrap as m}from"../../core/maybe.js";import{when as d}from"../../core/promiseUtils.js";import{watch as h}from"../../core/reactiveUtils.js";import{urlToObject as f}from"../../core/urlUtils.js";import{aliasOf as y}from"../../core/accessorSupport/decorators/aliasOf.js";import{ensureClass as g,Integer as R,ensureNumber as v}from"../../core/accessorSupport/ensureType.js";import{property as b,ensureRange as S}from"../../core/accessorSupport/decorators/property.js";import{reader as I}from"../../core/accessorSupport/decorators/reader.js";import{subclass as x}from"../../core/accessorSupport/decorators/subclass.js";import{writer as w}from"../../core/accessorSupport/decorators/writer.js";import{opacity as _,url as F}from"../support/commonProperties.js";import D from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as j}from"../support/ExportImageServiceParameters.js";import T from"../support/Field.js";import P from"../support/FieldsIndex.js";import{isSupportedRendererType as O}from"../support/imageryRendererUtils.js";import N from"../support/MosaicRule.js";import C from"../support/PixelBlock.js";import{interpolationKebab as M,noDataInterpretationKebab as J}from"../support/rasterEnums.js";import q from"../support/RasterFunction.js";import V from"../support/RasterInfo.js";import A from"../support/RasterJobHandler.js";import{decode as E,getFormat as Q}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as z}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as H,getDefaultBandCombination as U,createDefaultRenderer as L,normalizeRendererJSON as B}from"../../renderers/support/rasterRendererHelper.js";import G from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as k,computePixelSpaceLocations as W,computeHistograms as X,computeStatisticsHistograms as K,getImageSpatialReferenceQueryParameter as Y,getSamples as $,identify as Z}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as ee}from"../../rest/query/executeQueryJSON.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import"../graphics/featureConversionUtils.js";import te from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import re from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import ie from"../../rest/support/FeatureSet.js";import se from"../../rest/support/Query.js";import"../../kernel.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as ne}from"../../rest/query/executeForCount.js";import{executeForIds as oe}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{fetchServiceRasterInfo as ae,generateRasterInfo as le}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as ue}from"../../rest/imageService/getCatalogItemRasterInfo.js";import pe from"../../rest/support/ImageAngleParameters.js";import ce from"../../rest/support/ImageHistogramParameters.js";import me from"../../rest/support/ImageIdentifyParameters.js";import de from"../../rest/support/ImagePixelLocationParameters.js";import he from"../../rest/support/ImageSampleParameters.js";import{createFlowMesh as fe}from"../../views/2d/engine/flow/dataUtils.js";import ye from"../../geometry/SpatialReference.js";const ge=u.getLogger("esri.layers.mixins.ArcGISImageService"),Re=a()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),ve=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),be=S(v,{min:0,max:255});function Se(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi)?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return t?t.join("/"):null}const Ie=a=>{let u=class extends a{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._defaultServiceMosaicRule=null,this._serviceSourceType=null,this._serviceSupportsMosaicRule=null,this.rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandCount=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelSizeX=null,this.pixelSizeY=null,this.pixelFilter=null,this.raster=void 0,this.viewId=void 0,this.symbolizer=null,this.rasterAttributeTable=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new j({layer:this}))}readDefaultServiceMosaicRule(e,t){return this._serviceSupportsMosaicRule?N.fromJSON(t):null}readServiceSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.length<1||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get fieldsIndex(){return this.fields?new P(this.fields):null}set format(e){e&&ve.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=N.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?N.fromJSON(r):this._isMosaicRuleSupported(t)?N.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new N({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=be(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return this.url?f(this.url):null}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){const s=t?.layerDefinition?.drawingInfo?.renderer,n=r(s,i);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!s.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),O(n)||ge.warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.rasterAttributeTableFieldPrefix||"Raster.",t=new T({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new T({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new T({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new T({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),null==this.pixelFilter||"esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType||(s.push(new T({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new T({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const n=this.rasterInfo.attributeTable&&this.rasterInfo.attributeTable.fields||null;if(n&&n.length>0){const t=n.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=q.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?q.fromJSON({rasterFunctionDefinition:t.renderingRule}):q.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){const i=e.toJSON();i.rasterFunctionDefinition?t[r]=i.rasterFunctionDefinition:t[r]=i}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?ye.fromJSON(r):null}readPixelType(e){return Re.fromJSON(e)||e}writePixelType(e,t,r){(c(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=Re.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;if(!this._isPicture()&&this.renderer&&this.symbolizer&&!this.pixelFilter){const i=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(this.renderer.toJSON()),s=this._rasterJobHandler.instance,{bandIds:n}=this;if(s){i&&(this.symbolizer.bind(),await s.updateSymbolizer(this.symbolizer,t),this._cachedRendererJson=this.renderer.toJSON());const o=await s.symbolize({bandIds:n,...e},t);r={extent:e.extent,pixelBlock:o}}else r={extent:e.extent,pixelBlock:this.symbolizer.symbolize({bandIds:n,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputeAngles)throw new o("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=g(pe,e).clone(),k(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputePixelLocation)throw new o("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=g(de,e).clone(),W(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputeHistograms)throw new o("imagery-layer:compute-histograms","this operation is not supported on the input image service");e=g(ce,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),X(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsComputeStatisticsHistograms)throw new o("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");e=g(ce,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),r&&null==e.raster&&(e.raster=r),K(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return p(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)return Promise.reject(new o("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required."));const s=this.renderer||this.symbolizer?this.generateRasterInfo(this.renderingRule,{signal:i.signal}):null;return d(s).then((s=>{s&&(this.rasterInfo=s);const n={imageServiceParameters:this.getExportImageServiceParameters(e,t,r,i.timeExtent),imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}))}fetchKeyProperties(e){return n(this.parsedUrl.path+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>e.data))}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new o("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(this.parsedUrl.path+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>ie.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return ue(this.parsedUrl.path,e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(this.parsedUrl.path+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(this.parsedUrl.path+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(this.parsedUrl.path+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},u=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},y=n(this.parsedUrl.path+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([o,u,y]);let R=g[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const v=te.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);v&&(v.spatialReference=new ye({wkid:0,imageCoordinateSystem:i}));const b=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],S=b.length;if(S<3)return{ics:i,icsToPixelTransform:R,icsExtent:v,northDirection:null};let I=0,x=0,w=0,_=0;for(let n=0;n<S;n++)I+=b[n].x,x+=b[n].y,w+=b[n].x*b[n].x,_+=b[n].x*b[n].y;const F=(S*_-I*x)/(S*w-I*I);let D=0;const j=b[p-1].x>b[0].x,T=b[p-1].y>b[0].y;return F===1/0?D=T?90:270:0===F?D=j?0:180:F>0?D=j?180*Math.atan(F)/Math.PI:180*Math.atan(F)/Math.PI+180:F<0&&(D=T?180+180*Math.atan(F)/Math.PI:360+180*Math.atan(F)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:v,northDirection:D}}async generateRasterInfo(e,t){if((!e||"none"===e?.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e))&&p(this.serviceRasterInfo))return this.serviceRasterInfo;const r=Se(e);if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i=this._generateRasterInfo(e,t);this._functionRasterInfos[r]=i;try{return await i}catch{return this._functionRasterInfos[r]=null,null}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=Y(e.spatialReference,this.parsedUrl.path);p(this.serviceRasterInfo)&&this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.renderingRule?.rasterFunctionDefinition,c=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRenderingRule(this.renderingRule)&&!u&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const m=this._serviceSupportsMosaicRule?this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,i):null;n.mosaicRule=m&&JSON.stringify(m),n.renderingRule=this._getRenderingRuleString(q.fromJSON(l));const d={};if(i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${null==e?"null":e},${null==t?"null":t}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...d}}async getSamples(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsGetSamples)throw new o("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=g(he,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),$(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsIdentify)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");e=g(me,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;if(s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule){const t=this._combineMosaicRuleWithTimeExtent(i,e.timeExtent);e.mosaicRule=m(t)}return r&&null==e.raster&&(e.raster=r),Z(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new se;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ee(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),oe(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ne(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new o("imagery-layer: query-visible-rasters","missing query parameter");const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let a=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this.rasterFunctionNamesIndex;if(p(e.outFields)&&(a=e.outFields.some((e=>!e.toLowerCase().includes(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(m)&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new q({functionName:e[0]}))),u=t.map((e=>e[1])),0===l.length?this.renderingRule?(l.push(this.renderingRule),u.push(this.renderingRule.functionName)):l=null:this.renderingRule&&!l.some((e=>e.functionName===this.renderingRule.functionName))&&(l.push(this.renderingRule),u.push(this.renderingRule.functionName))}const h=c(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=e.timeExtent||this.timeExtent,y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f),g=this._getQueryParams({geometry:e.geometry,timeExtent:f,mosaicRule:y,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:a,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new me(g);try{await this.generateRasterInfo(this.renderingRule);const r=await Z(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,o=r.value.toLowerCase().includes("nodata");if(!(a&&!h&&r?.catalogItems?.features.length&&(n||!o)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",c=r.catalogItems.features,m=c.map((e=>e.attributes?.[l])),d=new se({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),f=await this.queryRasters(d);return f?.features?.length&&f.features.forEach((t=>{c.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new re(t.geometry),p(e.outSpatialReference)&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new o("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(this.parsedUrl.path+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(this.parsedUrl.path+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):fe(e.meshType,e.simulationSettings,e.flowData,p(t.signal)?t.signal:(new AbortController).signal)}async _fetchService(e){await this._fetchServiceInfo(e),p(this.serviceRasterInfo)&&!this.rasterInfo&&(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=p(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):ae(this.parsedUrl.path,t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),e))),i=this._hasRenderingRule(this.renderingRule)?this.generateRasterInfo(this.renderingRule,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),ge.warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.own(h((()=>this.renderingRule),(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))})));const t=p(this.serviceRasterInfo)&&this.serviceRasterInfo.multidimensionalInfo;t&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const r=this.timeInfo;if(c(e)||c(this.multidimensionalInfo)||c(t)||c(r?.startField))return e;const{startField:i}=r;if(e=e.clone(),"mosaic-dataset"===this._serviceSourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==i)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const s=e.multidimensionalDefinition.filter((e=>e.dimensionName===i)),n=p(t.start)?t.start.getTime():null,o=p(t.end)?t.end.getTime():null,a=null==n||null==o||n===o,l=a?[n||o]:[[n,o]],u=this.version>=10.8;if(s.length)s.forEach((e=>{e.dimensionName===i&&(u?(e.dimensionName=null,e.isSlice=null,e.values=null):(e.isSlice=a,e.values=l))}));else if(!u){const t=e.multidimensionalDefinition.filter((e=>null!=e.variableName&&null==e.dimensionName));t.length?t.forEach((e=>{e.dimensionName=i,e.isSlice=a,e.values=l})):e.multidimensionalDefinition.push(new D({variableName:"",dimensionName:i,isSlice:a,values:l}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return c(e)?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>!(!e.variableName&&!e.dimensionName))),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this._serviceSourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(await this._fetchCapabilities(t?.signal),!this.capabilities.operations.supportsQuery)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=p(e)?g(se,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new A;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>null)),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&this._hasRenderingRule(r)&&1===t.bandCount&&["u8","s8"].includes(t.pixelType)||H(this.rasterInfo).includes(this.renderer.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:i}=await n(this.parsedUrl.path,{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new o("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),r=e.currentVersion>=10.71&&e.hasMultidimensions&&e.timeInfo&&!(e.objectIdField&&e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){if(!this._isPicture()&&!this.pixelFilter){if(!this.bandIds&&this.rasterInfo.bandCount>=3){const e=U(this.rasterInfo);!e||3===this.rasterInfo.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=L(this.rasterInfo,{bandIds:this.bandIds,variableName:this.renderingRule?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=B(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=this.rasterInfo):this.symbolizer=new G({rendererJSON:t,rasterInfo:this.rasterInfo}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:p(e.pixelBlock)&&e.pixelBlock.clone()}}_getQueryParams(e){p(e?.renderingRule)&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):E(e,t,r)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.serviceRasterInfo)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;return(await n(this.parsedUrl.path+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e})).data?.rasterFunctionInfos}return null}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,signal:i}=e;if(r&&!this.pixelFilter&&t.format?.indexOf("png")>-1){return{imageElement:(await n(this.parsedUrl.path+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i})).data,params:t}}const s=this._initJobHandler(),a=n(this.parsedUrl.path+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i}),l=(await Promise.all([a,s]))[0].data,u=t.format||"jpgpng";let p=u;if("bsq"!==p&&"bip"!==p&&(p=Q(l)),!p)throw new o("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(l)));const c={signal:i},m="gif"===u||"bmp"===u||u.includes("png")&&("png"===p||"jpg"===p)?E(l,{useCanvas:!0,...t},c):this._decodePixelBlock(l,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:u},c);return{pixelData:{pixelBlock:await m,extent:t.extent},params:t}}_generateRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return le(this.parsedUrl.path,e,r)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this._defaultServiceMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;const t=e.variables[0].dimensions,r="",i=[];for(const s in t)if(t.hasOwnProperty(s)){const e=t[s],n=e.extent;let o=!0,a=[n[0]];e.hasRanges&&!0===e.hasRanges?(o=!1,a=[e.values[0]]):"stdz"===e.name.toLowerCase()&&Math.abs(n[1])<=Math.abs(n[0])&&(a=[n[1]]),i.push(new D({variableName:r,dimensionName:t[s].name,isSlice:o,values:a}))}if(i.length>0){this.mosaicRule=this.mosaicRule||new N;const e=this.mosaicRule.multidimensionalDefinition;(!e||e&&e.length<=0)&&(this.mosaicRule.multidimensionalDefinition=i)}}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,c=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().includes("nodata"),h=[];if(i&&!u&&!d){const e={};e[m]=0;c=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,y,g;this._updateResponseFieldNames(u,a),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i){if(y=c[t],g=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.includes(this.renderingRule.functionName)?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=y,f.attributes[r]=g,this._updateFeatureWithMagDirValues(f,y);const o=this.fields&&this.fields.length>0;let a=this.renderingRule&&p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable?o?y:i:g;this.renderingRule||(a=o?y:i),this._updateFeatureWithRasterAttributeTableValues(f,a)}if(f.sourceLayer=f.layer=this,o&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=l[e]}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo&&this.rasterInfo.attributeTable||p(this.serviceRasterInfo)&&this.serviceRasterInfo.attributeTable,i=r&&r.features;if(!i)return;const s=r.fields,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),o=n&&n[0];if(!o)return;const a=i.filter((e=>e.attributes[o]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const r=this.rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if("esriImageServiceDataTypeVector-UV"!==this.serviceDataType&&"esriImageServiceDataTypeVector-MagDir"!==this.serviceDataType)return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new C({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new te(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:z([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)||e.forEach((e=>{if(e&&e.attributes)for(const i of t)if(r.has(i)){const t=r.get(i).name;t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(this._hasRenderingRule(e)){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRenderingRule(e){return e&&e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:t.includes("mensuration")&&a,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&o,supportsComputePixelLocation:r>=10.7&&t.includes("catalog"),supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}}}};return e([b()],u.prototype,"_functionRasterInfos",void 0),e([b()],u.prototype,"_rasterJobHandler",void 0),e([b({dependsOn:["_serviceSupportsMosaicRule"]})],u.prototype,"_defaultServiceMosaicRule",void 0),e([I("_defaultServiceMosaicRule",["defaultMosaicMethod"])],u.prototype,"readDefaultServiceMosaicRule",null),e([b()],u.prototype,"_cachedRendererJson",void 0),e([b({readOnly:!0})],u.prototype,"_serviceSourceType",void 0),e([I("_serviceSourceType",["serviceSourceType","fields"])],u.prototype,"readServiceSourceType",null),e([b({readOnly:!0})],u.prototype,"_serviceSupportsMosaicRule",void 0),e([I("_serviceSupportsMosaicRule",["currentVersion","fields"])],u.prototype,"readServiceSupportsMosaicRule",null),e([b()],u.prototype,"rasterAttributeTableFieldPrefix",void 0),e([b({readOnly:!0})],u.prototype,"rasterFunctionNamesIndex",null),e([b()],u.prototype,"adjustAspectRatio",void 0),e([b({readOnly:!0}),y("serviceRasterInfo.bandCount")],u.prototype,"bandCount",void 0),e([b({type:[R],json:{write:!0}})],u.prototype,"bandIds",void 0),e([I("bandIds")],u.prototype,"readBandIds",null),e([b({readOnly:!0,json:{read:!1}})],u.prototype,"capabilities",void 0),e([I("service","capabilities",["capabilities","currentVersion","serviceDataType"])],u.prototype,"readCapabilities",null),e([b({type:Number})],u.prototype,"compressionQuality",void 0),e([w("compressionQuality")],u.prototype,"writeCompressionQuality",null),e([b({type:Number})],u.prototype,"compressionTolerance",void 0),e([w("compressionTolerance")],u.prototype,"writeCompressionTolerance",null),e([b({json:{read:{source:"copyrightText"}}})],u.prototype,"copyright",void 0),e([b({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],u.prototype,"definitionExpression",void 0),e([b({readOnly:!0,constructOnly:!0})],u.prototype,"exportImageServiceParameters",void 0),e([b()],u.prototype,"rasterInfo",void 0),e([b({readOnly:!0,type:[T]})],u.prototype,"fields",void 0),e([b({readOnly:!0})],u.prototype,"fieldsIndex",null),e([b({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],u.prototype,"format",null),e([I("service","format",["serviceDataType"])],u.prototype,"readFormat",null),e([b({type:te})],u.prototype,"fullExtent",void 0),e([b({readOnly:!0})],u.prototype,"hasMultidimensions",void 0),e([b({json:{read:{source:"maxImageHeight"}}})],u.prototype,"imageMaxHeight",void 0),e([b({json:{read:{source:"maxImageWidth"}}})],u.prototype,"imageMaxWidth",void 0),e([b({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],u.prototype,"interpolation",void 0),e([b()],u.prototype,"minScale",void 0),e([I("service","minScale")],u.prototype,"readMinScale",null),e([b()],u.prototype,"maxScale",void 0),e([I("service","maxScale")],u.prototype,"readMaxScale",null),e([b({type:N})],u.prototype,"mosaicRule",null),e([I("mosaicRule",["mosaicRule","defaultMosaicMethod"])],u.prototype,"readMosaicRule",null),e([w("mosaicRule")],u.prototype,"writeMosaicRule",null),e([b({readOnly:!0}),y("serviceRasterInfo.multidimensionalInfo")],u.prototype,"multidimensionalInfo",void 0),e([b({json:{type:R}})],u.prototype,"noData",void 0),e([w("noData")],u.prototype,"writeNoData",null),e([b({type:String,json:{type:J.jsonValues,read:J.read,write:J.write}})],u.prototype,"noDataInterpretation",void 0),e([b({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],u.prototype,"objectIdField",void 0),e([I("objectIdField")],u.prototype,"readObjectIdField",null),e([b({})],u.prototype,"geometryType",void 0),e([b({})],u.prototype,"typeIdField",void 0),e([b({})],u.prototype,"types",void 0),e([b({readOnly:!0})],u.prototype,"parsedUrl",null),e([b({readOnly:!0}),y("serviceRasterInfo.pixelSize.x")],u.prototype,"pixelSizeX",void 0),e([b({readOnly:!0}),y("serviceRasterInfo.pixelSize.y")],u.prototype,"pixelSizeY",void 0),e([b({type:Function})],u.prototype,"pixelFilter",void 0),e([b()],u.prototype,"raster",void 0),e([b()],u.prototype,"viewId",void 0),e([b({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:s,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],u.prototype,"renderer",null),e([I("renderer")],u.prototype,"readRenderer",null),e([w("renderer")],u.prototype,"writeRenderer",null),e([b()],u.prototype,"symbolizer",void 0),e([b(_)],u.prototype,"opacity",void 0),e([b({readOnly:!0}),y("serviceRasterInfo.attributeTable")],u.prototype,"rasterAttributeTable",void 0),e([b({readOnly:!0})],u.prototype,"rasterFields",null),e([b({constructOnly:!0})],u.prototype,"rasterFunctionInfos",void 0),e([b({type:q})],u.prototype,"renderingRule",null),e([I("renderingRule",["renderingRule","rasterFunctionInfos"])],u.prototype,"readRenderingRule",null),e([w("renderingRule")],u.prototype,"writeRenderingRule",null),e([b()],u.prototype,"serviceDataType",void 0),e([b({readOnly:!0,type:ye})],u.prototype,"spatialReference",void 0),e([I("spatialReference",["spatialReference","extent"])],u.prototype,"readSpatialReference",null),e([b({json:{type:Re.jsonValues}})],u.prototype,"pixelType",void 0),e([I("pixelType")],u.prototype,"readPixelType",null),e([w("pixelType")],u.prototype,"writePixelType",null),e([b({constructOnly:!0,type:V})],u.prototype,"serviceRasterInfo",void 0),e([b()],u.prototype,"sourceJSON",void 0),e([b(F)],u.prototype,"url",void 0),e([b({readOnly:!0})],u.prototype,"version",void 0),e([I("version",["currentVersion","fields","timeInfo"])],u.prototype,"readVersion",null),u=e([x("esri.layers.mixins.ArcGISImageService")],u),u};export{Ie as ArcGISImageService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Collection.js";import"../../core/Error.js";import"../../core/Logger.js";import"../../core/accessorSupport/watch.js";import{autorun as r}from"../../core/accessorSupport/trackingUtils.js";const t=new e,o=new WeakMap;function n(e){c(e)&&t.push(e)}function s(e){c(e)&&t.includes(e)&&t.remove(e)}function c(e){return e&&"object"==typeof e&&"refreshInterval"in e&&"refresh"in e}function i(e,r){return Number.isFinite(e)&&Number.isFinite(r)?r<=0?e:i(r,e%r):0}let f=0,a=0;function l(){const e=Date.now();for(const r of t)if(r.refreshInterval){e-(o.get(r)??0)+5>=6e4*r.refreshInterval&&(o.set(r,e),r.refresh(e))}}r((()=>{const e=Date.now();let r=0;for(const n of t)r=i(Math.round(6e4*n.refreshInterval),r),n.refreshInterval?o.get(n)||o.set(n,e):o.delete(n);if(r!==a){if(a=r,clearInterval(f),0===a)return void(f=0);f=setInterval(l,a)}}));const u={get hasRefreshTimer(){return f>0},get tickInterval(){return a},forceRefresh(){l()},hasLayer:e=>c(e)&&t.includes(e),clear(){for(const e of t)o.delete(e);t.removeAll()}};export{n as registerLayer,u as test,s as unregisterLayer};
5
+ import e from"../../core/Collection.js";import"../../core/has.js";import"../../core/Error.js";import"../../core/Logger.js";import"../../core/accessorSupport/watch.js";import{autorun as r}from"../../core/accessorSupport/trackingUtils.js";const t=new e,o=new WeakMap;function n(e){c(e)&&t.push(e)}function s(e){c(e)&&t.includes(e)&&t.remove(e)}function c(e){return e&&"object"==typeof e&&"refreshInterval"in e&&"refresh"in e}function i(e,r){return Number.isFinite(e)&&Number.isFinite(r)?r<=0?e:i(r,e%r):0}let f=0,a=0;function l(){const e=Date.now();for(const r of t)if(r.refreshInterval){e-(o.get(r)??0)+5>=6e4*r.refreshInterval&&(o.set(r,e),r.refresh(e))}}r((()=>{const e=Date.now();let r=0;for(const n of t)r=i(Math.round(6e4*n.refreshInterval),r),n.refreshInterval?o.get(n)||o.set(n,e):o.delete(n);if(r!==a){if(a=r,clearInterval(f),0===a)return void(f=0);f=setInterval(l,a)}}));const u={get hasRefreshTimer(){return f>0},get tickInterval(){return a},forceRefresh(){l()},hasLayer:e=>c(e)&&t.includes(e),clear(){for(const e of t)o.delete(e);t.removeAll()}};export{n as registerLayer,u as test,s as unregisterLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import{symbolTypesCluster as o}from"../../symbols.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as r}from"../../core/lang.js";import{toPt as p}from"../../core/screenUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import a from"./AggregateField.js";import{popupEnabled as u,labelsVisible as n}from"./commonProperties.js";import c from"./LabelClass.js";var m;let d=m=class extends s{constructor(e){super(e),this.type="cluster",this.clusterRadius=p("80px"),this.clusterMinSize=p("12px"),this.clusterMaxSize=p("50px"),this.popupEnabled=!0,this.popupTemplate=null,this.symbol=null,this.labelingInfo=null,this.labelsVisible=!0,this.fields=null}clone(){return new m({clusterRadius:this.clusterRadius,clusterMinSize:this.clusterMinSize,clusterMaxSize:this.clusterMaxSize,labelingInfo:r(this.labelingInfo),labelsVisible:this.labelsVisible,fields:r(this.fields),popupEnabled:this.popupEnabled,popupTemplate:r(this.popupTemplate)})}};e([i({type:["cluster"],readOnly:!0,json:{write:!0}})],d.prototype,"type",void 0),e([i({type:Number,cast:e=>"auto"===e?e:p(e),json:{write:!0}})],d.prototype,"clusterRadius",void 0),e([i({type:Number,cast:p,json:{write:!0}})],d.prototype,"clusterMinSize",void 0),e([i({type:Number,cast:p,json:{write:!0}})],d.prototype,"clusterMaxSize",void 0),e([i(u)],d.prototype,"popupEnabled",void 0),e([i({type:t,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],d.prototype,"popupTemplate",void 0),e([i({types:o})],d.prototype,"symbol",void 0),e([i({type:[c],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo"}}})],d.prototype,"labelingInfo",void 0),e([i(n)],d.prototype,"labelsVisible",void 0),e([i({type:[a],json:{write:!0,origins:{"web-document":{write:!1},"portal-item":{write:!1}}}})],d.prototype,"fields",void 0),d=m=e([l("esri.layers.support.FeatureReductionCluster")],d);const b=d;export{b as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as t}from"../../renderers/support/types.js";import{symbolTypesCluster as s}from"../../symbols.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{clone as p}from"../../core/lang.js";import{toPt as i}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"./AggregateField.js";import{popupEnabled as u,labelsVisible as d}from"./commonProperties.js";import m from"./LabelClass.js";var c;let y=c=class extends o{constructor(e){super(e),this.type="cluster",this.clusterRadius=i("80px"),this.clusterMinSize=i("12px"),this.clusterMaxSize=i("50px"),this.popupEnabled=!0,this.popupTemplate=null,this.symbol=null,this.labelingInfo=null,this.labelsVisible=!0,this.fields=null}clone(){return new c({clusterRadius:this.clusterRadius,clusterMinSize:this.clusterMinSize,clusterMaxSize:this.clusterMaxSize,labelingInfo:p(this.labelingInfo),labelsVisible:this.labelsVisible,fields:p(this.fields),renderer:p(this.renderer),popupEnabled:this.popupEnabled,popupTemplate:p(this.popupTemplate)})}};e([l({type:["cluster"],readOnly:!0,json:{write:!0}})],y.prototype,"type",void 0),e([l({type:Number,cast:e=>"auto"===e?e:i(e),json:{write:!0}})],y.prototype,"clusterRadius",void 0),e([l({type:Number,cast:i,json:{write:!0}})],y.prototype,"clusterMinSize",void 0),e([l({type:Number,cast:i,json:{write:!0}})],y.prototype,"clusterMaxSize",void 0),e([l(u)],y.prototype,"popupEnabled",void 0),e([l({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],y.prototype,"popupTemplate",void 0),e([l({types:t,json:{write:!0}})],y.prototype,"renderer",void 0),e([l({types:s})],y.prototype,"symbol",void 0),e([l({type:[m],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo"}}})],y.prototype,"labelingInfo",void 0),e([l(d)],y.prototype,"labelsVisible",void 0),e([l({type:[a],json:{write:!0,origins:{"web-document":{write:!1},"portal-item":{write:!1}}}})],y.prototype,"fields",void 0),y=c=e([n("esri.layers.support.FeatureReductionCluster")],y);const j=y;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const t={attachment:{supportsContentType:!1,supportsExifInfo:!1,supportsKeywords:!1,supportsName:!1,supportsSize:!1},data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1},query:{maxRecordCount:0,maxRecordCountFactor:0,standardMaxRecordCount:0,supportsCacheHint:!1,supportsCentroid:!1,supportsCompactGeometry:!1,supportsDefaultSpatialReference:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsSqlExpression:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsStatistics:!1,tileMaxRecordCount:0}};export{t as zeroCapabilities};
5
+ const t={analytics:{supportsCacheHint:!1},attachment:{supportsContentType:!1,supportsExifInfo:!1,supportsKeywords:!1,supportsName:!1,supportsSize:!1,supportsCacheHint:!1,supportsResize:!1},data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},query:{maxRecordCount:0,maxRecordCountFactor:0,standardMaxRecordCount:0,supportsCacheHint:!1,supportsCentroid:!1,supportsCompactGeometry:!1,supportsDefaultSpatialReference:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsSqlExpression:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsStatistics:!1,tileMaxRecordCount:0}};export{t as zeroCapabilities};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.24.0-next.20220520",
3
+ "version": "4.24.0-next.20220521",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const c="20220520",e="8ee859ce5acc33f8b8f9b2eb4506897ddfa5adcc";export{c as buildDate,e as commitHash};
5
+ const e="20220521",b="621819ed470361bce037e44b4ad7bde54d227fbe";export{e as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/Error.js";import{isSome as e}from"../../../../core/maybe.js";import{SPRITE_PADDING as i}from"./definitions.js";import{log2 as s}from"./GeometryUtils.js";import a from"./Rect.js";import r from"./RectangleBinPack.js";import{PixelFormat as o,PixelType as h,TextureSamplingMode as c,TextureWrapMode as n}from"../../../webgl/enums.js";import{Texture as g}from"../../../webgl/Texture.js";function m(t){return t&&"static"===t.type}class p{constructor(t,e,i,s=0){this._mosaicPages=[],this._maxItemSize=0,this._currentPage=0,this._pageWidth=0,this._pageHeight=0,this._mosaicRects=new Map,this._spriteCopyQueue=[],this.pixelRatio=1,(e<=0||i<=0)&&console.error("Sprites mosaic defaultWidth and defaultHeight must be greater than zero!"),this._pageWidth=e,this._pageHeight=i,this._requestRender=t,s>0&&(this._maxItemSize=s),this.pixelRatio=window.devicePixelRatio||1,this._binPack=new r(this._pageWidth,this._pageHeight);const a=Math.floor(this._pageWidth),o=Math.floor(this._pageHeight);this._mosaicPages.push({mosaicsData:{type:"static",data:new Uint32Array(a*o)},size:[this._pageWidth,this._pageHeight],dirty:!0,texture:void 0})}getWidth(t){return t>=this._mosaicPages.length?-1:this._mosaicPages[t].size[0]}getHeight(t){return t>=this._mosaicPages.length?-1:this._mosaicPages[t].size[1]}getPageTexture(t){return t<this._mosaicPages.length?this._mosaicPages[t].texture:null}has(t){return this._mosaicRects.has(t)}get itemCount(){return this._mosaicRects.size}getSpriteItem(t){return this._mosaicRects.get(t)}addSpriteItem(t,e,i,s,r,o){if(this._mosaicRects.has(t))return this._mosaicRects.get(t);let h,c,n;if(m(i))[h,c,n]=this._allocateImage(e[0],e[1]);else{h=new a(0,0,e[0],e[1]),c=this._mosaicPages.length;const t=void 0;this._mosaicPages.push({mosaicsData:i,size:e,dirty:!0,texture:t})}if(h.width<=0||h.height<=0)return null;const g={rect:h,width:e[0],height:e[1],sdf:r,simplePattern:o,pixelRatio:1,page:c};return this._mosaicRects.set(t,g),m(i)&&this._copy({rect:h,spriteSize:e,spriteData:i.data,page:c,pageSize:n,repeat:s,sdf:r}),g}hasItemsToProcess(){return 0!==this._spriteCopyQueue.length}processNextItem(){const t=this._spriteCopyQueue.pop();t&&this._copy(t)}getSpriteItems(t){const e={};for(const i of t)e[i]=this.getSpriteItem(i);return e}getMosaicItemPosition(t){const e=this.getSpriteItem(t),s=e&&e.rect;if(!s)return null;s.width=e.width,s.height=e.height;const a=e.width,r=e.height,o=i,h=this._mosaicPages[e.page];return{size:[e.width,e.height],tl:[(s.x+o)/h[0],(s.y+o)/h[1]],br:[(s.x+o+a)/h[0],(s.y+o+r)/h[1]],page:e.page}}bind(t,i,s=0,a=0){const r=this._mosaicPages[s],o=r.mosaicsData;let h=r.texture;if(h||(h=_(t,o,r.size),r.texture=h),h.setSamplingMode(i),m(o))t.bindTexture(h,a),r.dirty&&(h.setData(new Uint8Array(o.data.buffer)),h.generateMipmap());else{const i=o.data,s=i.bindFrame(t,h,a);e(this._requestRender)&&s&&i.frameCount>0&&this._requestRender.requestRender(),i.bindFrame(t,h,a)}r.dirty=!1}static _copyBits(t,e,i,s,a,r,o,h,c,n,g){let m=s*e+i,p=h*r+o;if(g){p-=r;for(let o=-1;o<=n;o++,m=((o+n)%n+s)*e+i,p+=r)for(let e=-1;e<=c;e++)a[p+e]=t[m+(e+c)%c]}else for(let _=0;_<n;_++){for(let e=0;e<c;e++)a[p+e]=t[m+e];m+=e,p+=r}}_copy(e){if(e.page>=this._mosaicPages.length)return;const s=this._mosaicPages[e.page],a=s.mosaicsData;if(!m(s.mosaicsData))throw new t("mapview-invalid-resource","unsuitable data type!");const r=e.spriteData,o=a.data;o&&r||console.error("Source or target images are uninitialized!"),p._copyBits(r,e.spriteSize[0],0,0,o,e.pageSize[0],e.rect.x+i,e.rect.y+i,e.spriteSize[0],e.spriteSize[1],e.repeat),s.dirty=!0}_allocateImage(t,e){t+=2*i,e+=2*i;const o=Math.max(t,e);if(this._maxItemSize&&this._maxItemSize<o){const i=2**Math.ceil(s(t)),r=2**Math.ceil(s(e)),o=new a(0,0,t,e);return this._mosaicPages.push({mosaicsData:{type:"static",data:new Uint32Array(i*r)},size:[i,r],dirty:!0,texture:void 0}),[o,this._mosaicPages.length-1,[i,r]]}const h=this._binPack.allocate(t,e);if(h.width<=0){const i=this._mosaicPages[this._currentPage];return!i.dirty&&m(i.mosaicsData)&&(i.mosaicsData.data=null),this._currentPage=this._mosaicPages.length,this._mosaicPages.push({mosaicsData:{type:"static",data:new Uint32Array(this._pageWidth*this._pageHeight)},size:[this._pageWidth,this._pageHeight],dirty:!0,texture:void 0}),this._binPack=new r(this._pageWidth,this._pageHeight),this._allocateImage(t,e)}return[h,this._currentPage,[this._pageWidth,this._pageHeight]]}dispose(){this._binPack=null;for(const t of this._mosaicPages){const e=t.texture;e&&e.dispose();const i=t.mosaicsData;if(!m(i)){i.data.destroy()}}this._mosaicPages=null,this._mosaicRects.clear()}}function _(t,e,i){return m(e)?new g(t,{pixelFormat:o.RGBA,dataType:h.UNSIGNED_BYTE,width:i[0],height:i[1]},new Uint8Array(e.data.buffer)):new g(t,{pixelFormat:o.RGBA,dataType:h.UNSIGNED_BYTE,samplingMode:c.LINEAR,wrapMode:n.CLAMP_TO_EDGE,width:i[0],height:i[1]},null)}export{p as default};
5
+ import t from"../../../../core/Error.js";import{SPRITE_PADDING as e}from"./definitions.js";import{log2 as i}from"./GeometryUtils.js";import s from"./Rect.js";import a from"./RectangleBinPack.js";import{PixelFormat as r,PixelType as o,TextureSamplingMode as h,TextureWrapMode as c}from"../../../webgl/enums.js";import{Texture as n}from"../../../webgl/Texture.js";function g(t){return t&&"static"===t.type}class p{constructor(t,e,i=0){this._mosaicPages=[],this._maxItemSize=0,this._currentPage=0,this._pageWidth=0,this._pageHeight=0,this._mosaicRects=new Map,this._spriteCopyQueue=[],this.pixelRatio=1,(t<=0||e<=0)&&console.error("Sprites mosaic defaultWidth and defaultHeight must be greater than zero!"),this._pageWidth=t,this._pageHeight=e,i>0&&(this._maxItemSize=i),this.pixelRatio=window.devicePixelRatio||1,this._binPack=new a(this._pageWidth,this._pageHeight);const s=Math.floor(this._pageWidth),r=Math.floor(this._pageHeight);this._mosaicPages.push({mosaicsData:{type:"static",data:new Uint32Array(s*r)},size:[this._pageWidth,this._pageHeight],dirty:!0,texture:void 0})}getWidth(t){return t>=this._mosaicPages.length?-1:this._mosaicPages[t].size[0]}getHeight(t){return t>=this._mosaicPages.length?-1:this._mosaicPages[t].size[1]}getPageTexture(t){return t<this._mosaicPages.length?this._mosaicPages[t].texture:null}has(t){return this._mosaicRects.has(t)}get itemCount(){return this._mosaicRects.size}getSpriteItem(t){return this._mosaicRects.get(t)}addSpriteItem(t,i,a,r,o,h){if(this._mosaicRects.has(t))return this._mosaicRects.get(t);let c,n,p;if(g(a))[c,n,p]=this._allocateImage(i[0],i[1]);else{c=new s(0,0,i[0],i[1]),n=this._mosaicPages.length;const t=void 0;this._mosaicPages.push({mosaicsData:a,size:[i[0]+2*e,i[1]+2*e],dirty:!0,texture:t})}if(c.width<=0||c.height<=0)return null;const m={rect:c,width:i[0],height:i[1],sdf:o,simplePattern:h,pixelRatio:1,page:n};return this._mosaicRects.set(t,m),g(a)&&this._copy({rect:c,spriteSize:i,spriteData:a.data,page:n,pageSize:p,repeat:r,sdf:o}),m}hasItemsToProcess(){return 0!==this._spriteCopyQueue.length}processNextItem(){const t=this._spriteCopyQueue.pop();t&&this._copy(t)}getSpriteItems(t){const e={};for(const i of t)e[i]=this.getSpriteItem(i);return e}getMosaicItemPosition(t){const i=this.getSpriteItem(t),s=i&&i.rect;if(!s)return null;s.width=i.width,s.height=i.height;const a=i.width,r=i.height,o=e,h=this._mosaicPages[i.page];return{size:[i.width,i.height],tl:[(s.x+o)/h[0],(s.y+o)/h[1]],br:[(s.x+o+a)/h[0],(s.y+o+r)/h[1]],page:i.page}}bind(t,e,i=0,s=0){const a=this._mosaicPages[i],r=a.mosaicsData;let o=a.texture;if(o||(o=m(t,r,a.size),a.texture=o),o.setSamplingMode(e),g(r))t.bindTexture(o,s),a.dirty&&(o.setData(new Uint8Array(r.data.buffer)),o.generateMipmap());else{r.data.bindFrame(t,o,s)}a.dirty=!1}static _copyBits(t,e,i,s,a,r,o,h,c,n,g){let p=s*e+i,m=h*r+o;if(g){m-=r;for(let o=-1;o<=n;o++,p=((o+n)%n+s)*e+i,m+=r)for(let e=-1;e<=c;e++)a[m+e]=t[p+(e+c)%c]}else for(let _=0;_<n;_++){for(let e=0;e<c;e++)a[m+e]=t[p+e];p+=e,m+=r}}_copy(i){if(i.page>=this._mosaicPages.length)return;const s=this._mosaicPages[i.page],a=s.mosaicsData;if(!g(s.mosaicsData))throw new t("mapview-invalid-resource","unsuitable data type!");const r=i.spriteData,o=a.data;o&&r||console.error("Source or target images are uninitialized!"),p._copyBits(r,i.spriteSize[0],0,0,o,i.pageSize[0],i.rect.x+e,i.rect.y+e,i.spriteSize[0],i.spriteSize[1],i.repeat),s.dirty=!0}_allocateImage(t,r){t+=2*e,r+=2*e;const o=Math.max(t,r);if(this._maxItemSize&&this._maxItemSize<o){const e=2**Math.ceil(i(t)),a=2**Math.ceil(i(r)),o=new s(0,0,t,r);return this._mosaicPages.push({mosaicsData:{type:"static",data:new Uint32Array(e*a)},size:[e,a],dirty:!0,texture:void 0}),[o,this._mosaicPages.length-1,[e,a]]}const h=this._binPack.allocate(t,r);if(h.width<=0){const e=this._mosaicPages[this._currentPage];return!e.dirty&&g(e.mosaicsData)&&(e.mosaicsData.data=null),this._currentPage=this._mosaicPages.length,this._mosaicPages.push({mosaicsData:{type:"static",data:new Uint32Array(this._pageWidth*this._pageHeight)},size:[this._pageWidth,this._pageHeight],dirty:!0,texture:void 0}),this._binPack=new a(this._pageWidth,this._pageHeight),this._allocateImage(t,r)}return[h,this._currentPage,[this._pageWidth,this._pageHeight]]}dispose(){this._binPack=null;for(const t of this._mosaicPages){const e=t.texture;e&&e.dispose();const i=t.mosaicsData;if(!g(i)){i.data.destroy()}}this._mosaicPages=null,this._mosaicRects.clear()}}function m(t,e,i){return g(e)?new n(t,{pixelFormat:r.RGBA,dataType:o.UNSIGNED_BYTE,width:i[0],height:i[1]},new Uint8Array(e.data.buffer)):new n(t,{pixelFormat:r.RGBA,dataType:o.UNSIGNED_BYTE,samplingMode:h.LINEAR,wrapMode:c.CLAMP_TO_EDGE,width:i[0],height:i[1]},null)}export{p as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../config.js";import t from"../../../../request.js";import{bidiText as i}from"../../../../core/BidiText.js";import s from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isNone as n,isSome as o}from"../../../../core/maybe.js";import{throwIfAborted as a,isAbortError as c}from"../../../../core/promiseUtils.js";import{pt2px as h}from"../../../../core/screenUtils.js";import{a as u}from"../../../../chunks/vec2.js";import{c as d}from"../../../../chunks/vec2f32.js";import{AnimatedSymbolRepeatType as m}from"../../../../symbols/cim/enums.js";import l from"../../../../symbols/cim/Rasterizer.js";import{TEXTURE_BINDING_GLYPH_ATLAS as p,TEXTURE_BINDING_SPRITE_ATLAS as g}from"./definitions.js";import{MosaicType as f}from"./enums.js";import{getFullyQualifiedFontName as _}from"./fontUtils.js";import w from"./GlyphMosaic.js";import y from"./GlyphSource.js";import M from"./SDFConverter.js";import v from"./SpriteMosaic.js";import{is3D as I,charCodes as T,isSimple as b,isSVGResource as z,isImageResource as R,shouldRepeat as S,getPMSResourceSize as j,isGIF as x,isPNG as U,getUrl as B,isSVGImage as G}from"./Utils.js";import{isPNG as L,isAnimatedPNG as P,APNG as A}from"./animatedFormats/apng.js";import{isGIF as C,isAnimatedGIF as F,GIF as q}from"./animatedFormats/gif.js";import{ok as N}from"./util/Result.js";import{keyFromSymbol as O}from"./util/symbolUtils.js";import{QueueProcessor as E}from"../../../support/QueueProcessor.js";import{TextureSamplingMode as $}from"../../../webgl/enums.js";const k=d(),D="arial-unicode-ms-regular",Q=126,H=r.getLogger("esri.views.2d.engine.webgl.TextureManager");async function V(e,i){const r=B(e);let n;const o=";base64,";if(r.includes(o)){const e=r.indexOf(o)+o.length,t=r.substring(e),i=atob(t),s=new Uint8Array(i.length);for(let r=0;r<i.length;r++)s[r]=i.charCodeAt(r);n=s.buffer}else try{const{data:e}=await t(r,{responseType:"array-buffer",...i});n=e}catch(a){if(!c(a))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}`)}return n}function Y(e,t){const i=Math.round(h(t)*window.devicePixelRatio),s=i>=128?2:4;return Math.min(e,i*s)}const J=(e,t,i)=>H.error(new s(e,t,i));class W{constructor(e,t,i){this.mosaicType=e,this.page=t,this.sdf=i}static fromMosaic(e,t){return new W(e,t.page,t.sdf)}}function X(e){return{playAnimation:e.playAnimation,reverseAnimation:e.reverseAnimation,randomizeStartTime:e.randomizeStartTime,randomizeStartSeed:e.randomizeStartSeed,startTimeOffset:e.startTimeOffset,duration:e.duration,endingDuration:e.endingDuration,useEndingDuration:e.useEndingDuration,repeatType:null!=e.repeatType?{None:m.None,Loop:m.Loop,Oscillate:m.Oscillate}[e.repeatType]:void 0,repeatDelay:e.repeatDelay}}class K{constructor(i,r){this.resourceManager=r,this._invalidFontsMap=new Map,this._sdfConverter=new M(Q),this._bindingInfos=new Array,this._hashToBindingIndex=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new E({concurrency:10,process:async(e,i)=>{a(i);try{return await t(e,{responseType:"image",signal:i})}catch(r){if(!c(r))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${e}`,r);throw r}}}),this._spriteMosaic=new v(i,2048,2048,500),this._glyphSource=new y(`${e.fontsUrl}/{fontstack}/{range}.pbf`),this._glyphMosaic=new w(1024,1024,this._glyphSource),this._rasterizer=new l(r)}dispose(){this._spriteMosaic.dispose(),this._glyphMosaic.dispose(),this._rasterizer.dispose(),this._sdfConverter.dispose(),this._spriteMosaic=null,this._glyphMosaic=null,this._sdfConverter=null,this._hashToBindingIndex.clear(),this._hashToBindingIndex=null,this._bindingInfos=null,this._ongoingRasterizations.clear(),this._ongoingRasterizations=null,this._imageRequestQueue.clear(),this._imageRequestQueue=null}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}async rasterizeItem(e,t,i,s){if(n(e))return J("mapview-null-resource","Unable to rasterize null resource"),null;switch(e.type){case"text":case"esriTS":{const t=await this._rasterizeText(e,i,s);return t.forEach((e=>this._setTextureBinding(f.GLYPH,e))),{glyphMosaicItems:t}}default:{if(I(e))return J("mapview-invalid-type",`MapView does not support symbol type: ${e.type}`,e),null;const i=await this._rasterizeSpriteSymbol(e,t,s);return N(i)&&i&&this._setTextureBinding(f.SPRITE,i),{spriteMosaicItem:i}}}}bindTextures(e,t,i,s=!1){if(0===i.textureBinding)return;const r=this._bindingInfos[i.textureBinding-1],n=r.page,o=s?$.LINEAR_MIPMAP_LINEAR:$.LINEAR;switch(r.mosaicType){case f.SPRITE:{const i=this.sprites.getWidth(n),s=this.sprites.getHeight(n),r=u(k,i,s);return this._spriteMosaic.bind(e,o,n,g),t.setUniform1i("u_texture",g),void t.setUniform2fv("u_mosaicSize",r)}case f.GLYPH:{const i=this.glyphs.width,s=this.glyphs.height,r=u(k,i,s);return this._glyphMosaic.bind(e,o,n,p),t.setUniform1i("u_texture",p),void t.setUniform2fv("u_mosaicSize",r)}default:H.error("mapview-texture-manager",`Cannot handle unknown type ${r.mosaicType}`)}}_hashMosaic(e,t){return 1|e<<1|(t.sdf?1:0)<<2|t.page<<3}_setTextureBinding(e,t){const i=this._hashMosaic(e,t);if(!this._hashToBindingIndex.has(i)){const s=W.fromMosaic(e,t),r=this._bindingInfos.length+1;this._hashToBindingIndex.set(i,r),this._bindingInfos.push(s)}t.textureBinding=this._hashToBindingIndex.get(i)}async _rasterizeText(e,t,s){let r,n;if("cim"in e){const t=e;r=t.fontName,n=t.text}else{const t=e;r=_(t.font),n=t.text}const o=this._invalidFontsMap.has(r),a=t||T(i(n)[0]);try{return await this._glyphMosaic.getGlyphItems(o?D:r,a,s)}catch(c){return J("mapview-invalid-resource",`Couldn't find font ${r}. Falling back to Arial Unicode MS Regular`),this._invalidFontsMap.set(r,!0),this._glyphMosaic.getGlyphItems(D,a,s)}}async _rasterizeSpriteSymbol(e,t,i){if(b(e))return null;const r=O(e);if(this._spriteMosaic.has(r))return this._spriteMosaic.getSpriteItem(r);if(z(e)||R(e))return this._handleAsyncResource(r,e,i);const n=1,o=this._rasterizer.rasterizeJSONResource(e,n);if(o){const{size:t,image:i,sdf:s,simplePattern:n}=o;return this._addItemToMosaic(r,t,{type:"static",data:i},S(e),s,n)}return new s("TextureManager","unrecognized or null rasterized image")}async _handleAsyncResource(e,t,i){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let s;s=z(t)?this._handleSVG(t,e,i):this._handleImage(t,e,i),this._ongoingRasterizations.set(e,s);try{await s,this._ongoingRasterizations.delete(e)}catch{this._ongoingRasterizations.delete(e)}return s}async _handleSVG(e,t,i){const s=[Q,Q],r=await this._sdfConverter.draw(e.path,i);return this._addItemToMosaic(t,s,{type:"static",data:new Uint32Array(r.buffer)},!1,!0,!0)}async _handleGIFOrPNG(e,t,i){const r=await V(e,i);if(N(r)){const o=C(r),a=L(r);if(!o&&!a)return new s("mapview-invalid-resource","Image data is neither GIF nor PNG!");let h;try{const t=X((e.cim||{}).animatedSymbolProperties||{}),s=e.objectId;o&&F(r)?h=await q.create(r,t,s,i):a&&P(r)&&(h=await A.create(r,t,s,i))}catch(n){if(!c(n))return new s("mapview-invalid-resource","Could not fetch requested resource!")}if(h&&N(h))return this._addItemToMosaic(t,[h.width,h.height],{type:"animated",data:h},S(e),!1,!1);const u=new Blob([r],{type:o?"image/gif":"image/png"}),d=await this._imageFromBlob(u);if(d&&d instanceof HTMLImageElement){let i=d.width,s=d.height;"esriPMS"===e.type&&(i=Math.round(Y(d.width,j(e))),s=Math.round(d.height*(i/d.width)));const r="cim"in e?e.cim.colorSubstitutions:void 0,{size:n,sdf:o,image:a}=this._rasterizer.rasterizeImageResource(i,s,d,r);return this._addItemToMosaic(t,n,{type:"static",data:a},S(e),o,!1)}}return new s("mapview-invalid-resource","Could not handle resource!")}async _handleImage(e,t,i){if(x(e)||U(e))return this._handleGIFOrPNG(e,t,i);const r=B(e);try{let s;const n=this.resourceManager.getResource(r);if(o(n))s=n;else{const{data:e}=await this._imageRequestQueue.push(r,{...i});s=e}if(G(r))if("width"in e&&"height"in e)s.width=h(e.width),s.height=h(e.height);else if("cim"in e){const t=e.cim;s.width=h(t.width??t.scaleX*t.size),s.height=h(t.size)}if(!s.width||!s.height)return null;let a=s.width,c=s.height;"esriPMS"===e.type&&(a=Math.round(Y(s.width,j(e))),c=Math.round(s.height*(a/s.width)));const u="cim"in e?e.cim.colorSubstitutions:void 0,{size:d,sdf:m,image:l}=this._rasterizer.rasterizeImageResource(a,c,s,u);return this._addItemToMosaic(t,d,{type:"static",data:l},S(e),m,!1)}catch(n){if(!c(n))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}. ${n.message}`)}}async _imageFromBlob(e){const t=window.URL.createObjectURL(e);try{const{data:e}=await this._imageRequestQueue.push(t);return window.URL.revokeObjectURL(t),e}catch(i){if(window.URL.revokeObjectURL(t),!c(i))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${t}`);throw i}}_addItemToMosaic(e,t,i,s,r,n){return this._spriteMosaic.addSpriteItem(e,t,i,s,r,n)}}export{K as default};
5
+ import e from"../../../../config.js";import t from"../../../../request.js";import{bidiText as i}from"../../../../core/BidiText.js";import s from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isNone as n,isSome as o}from"../../../../core/maybe.js";import{throwIfAborted as a,isAbortError as h}from"../../../../core/promiseUtils.js";import{pt2px as c}from"../../../../core/screenUtils.js";import{a as u}from"../../../../chunks/vec2.js";import{c as d}from"../../../../chunks/vec2f32.js";import{AnimatedSymbolRepeatType as m}from"../../../../symbols/cim/enums.js";import l from"../../../../symbols/cim/Rasterizer.js";import{TEXTURE_BINDING_GLYPH_ATLAS as p,TEXTURE_BINDING_SPRITE_ATLAS as g}from"./definitions.js";import{MosaicType as f}from"./enums.js";import{getFullyQualifiedFontName as _}from"./fontUtils.js";import w from"./GlyphMosaic.js";import y from"./GlyphSource.js";import M from"./SDFConverter.js";import v from"./SpriteMosaic.js";import{is3D as I,charCodes as R,isSimple as T,isSVGResource as b,isImageResource as z,shouldRepeat as S,getPMSResourceSize as j,isGIF as x,isPNG as U,getUrl as B,isSVGImage as G}from"./Utils.js";import{isPNG as L,isAnimatedPNG as P,APNG as A}from"./animatedFormats/apng.js";import{isGIF as q,isAnimatedGIF as C,GIF as F}from"./animatedFormats/gif.js";import{ok as N}from"./util/Result.js";import{keyFromSymbol as O}from"./util/symbolUtils.js";import{QueueProcessor as E}from"../../../support/QueueProcessor.js";import{TextureSamplingMode as $}from"../../../webgl/enums.js";const k=d(),D="arial-unicode-ms-regular",Q=126,H=r.getLogger("esri.views.2d.engine.webgl.TextureManager");async function V(e,i){const r=B(e);let n;const o=";base64,";if(r.includes(o)){const e=r.indexOf(o)+o.length,t=r.substring(e),i=atob(t),s=new Uint8Array(i.length);for(let r=0;r<i.length;r++)s[r]=i.charCodeAt(r);n=s.buffer}else try{const{data:e}=await t(r,{responseType:"array-buffer",...i});n=e}catch(a){if(!h(a))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}`)}return n}function Y(e,t){const i=Math.round(c(t)*window.devicePixelRatio),s=i>=128?2:4;return Math.min(e,i*s)}const J=(e,t,i)=>H.error(new s(e,t,i));class W{constructor(e,t,i){this.mosaicType=e,this.page=t,this.sdf=i}static fromMosaic(e,t){return new W(e,t.page,t.sdf)}}function X(e){return{playAnimation:e.playAnimation,reverseAnimation:e.reverseAnimation,randomizeStartTime:e.randomizeStartTime,randomizeStartSeed:e.randomizeStartSeed,startTimeOffset:e.startTimeOffset,duration:e.duration,endingDuration:e.endingDuration,useEndingDuration:e.useEndingDuration,repeatType:null!=e.repeatType?{None:m.None,Loop:m.Loop,Oscillate:m.Oscillate}[e.repeatType]:void 0,repeatDelay:e.repeatDelay}}class K{constructor(i,r){this._requestRender=i,this.resourceManager=r,this._invalidFontsMap=new Map,this._sdfConverter=new M(Q),this._bindingInfos=new Array,this._hashToBindingIndex=new Map,this._ongoingRasterizations=new Map,this._imageRequestQueue=new E({concurrency:10,process:async(e,i)=>{a(i);try{return await t(e,{responseType:"image",signal:i})}catch(r){if(!h(r))throw new s("mapview-invalid-resource",`Could not fetch requested resource at ${e}`,r);throw r}}}),this._spriteMosaic=new v(2048,2048,500),this._glyphSource=new y(`${e.fontsUrl}/{fontstack}/{range}.pbf`),this._glyphMosaic=new w(1024,1024,this._glyphSource),this._rasterizer=new l(r)}dispose(){this._spriteMosaic.dispose(),this._glyphMosaic.dispose(),this._rasterizer.dispose(),this._sdfConverter.dispose(),this._spriteMosaic=null,this._glyphMosaic=null,this._sdfConverter=null,this._hashToBindingIndex.clear(),this._hashToBindingIndex=null,this._bindingInfos=null,this._ongoingRasterizations.clear(),this._ongoingRasterizations=null,this._imageRequestQueue.clear(),this._imageRequestQueue=null}get sprites(){return this._spriteMosaic}get glyphs(){return this._glyphMosaic}async rasterizeItem(e,t,i,s){if(n(e))return J("mapview-null-resource","Unable to rasterize null resource"),null;switch(e.type){case"text":case"esriTS":{const t=await this._rasterizeText(e,i,s);return t.forEach((e=>this._setTextureBinding(f.GLYPH,e))),{glyphMosaicItems:t}}default:{if(I(e))return J("mapview-invalid-type",`MapView does not support symbol type: ${e.type}`,e),null;const i=await this._rasterizeSpriteSymbol(e,t,s);return N(i)&&i&&this._setTextureBinding(f.SPRITE,i),{spriteMosaicItem:i}}}}bindTextures(e,t,i,s=!1){if(0===i.textureBinding)return;const r=this._bindingInfos[i.textureBinding-1],n=r.page,o=s?$.LINEAR_MIPMAP_LINEAR:$.LINEAR;switch(r.mosaicType){case f.SPRITE:{const i=this.sprites.getWidth(n),s=this.sprites.getHeight(n),r=u(k,i,s);return this._spriteMosaic.bind(e,o,n,g),t.setUniform1i("u_texture",g),void t.setUniform2fv("u_mosaicSize",r)}case f.GLYPH:{const i=this.glyphs.width,s=this.glyphs.height,r=u(k,i,s);return this._glyphMosaic.bind(e,o,n,p),t.setUniform1i("u_texture",p),void t.setUniform2fv("u_mosaicSize",r)}default:H.error("mapview-texture-manager",`Cannot handle unknown type ${r.mosaicType}`)}}_hashMosaic(e,t){return 1|e<<1|(t.sdf?1:0)<<2|t.page<<3}_setTextureBinding(e,t){const i=this._hashMosaic(e,t);if(!this._hashToBindingIndex.has(i)){const s=W.fromMosaic(e,t),r=this._bindingInfos.length+1;this._hashToBindingIndex.set(i,r),this._bindingInfos.push(s)}t.textureBinding=this._hashToBindingIndex.get(i)}async _rasterizeText(e,t,s){let r,n;if("cim"in e){const t=e;r=t.fontName,n=t.text}else{const t=e;r=_(t.font),n=t.text}const o=this._invalidFontsMap.has(r),a=t||R(i(n)[0]);try{return await this._glyphMosaic.getGlyphItems(o?D:r,a,s)}catch(h){return J("mapview-invalid-resource",`Couldn't find font ${r}. Falling back to Arial Unicode MS Regular`),this._invalidFontsMap.set(r,!0),this._glyphMosaic.getGlyphItems(D,a,s)}}async _rasterizeSpriteSymbol(e,t,i){if(T(e))return null;const r=O(e);if(this._spriteMosaic.has(r))return this._spriteMosaic.getSpriteItem(r);if(b(e)||z(e))return this._handleAsyncResource(r,e,i);const n=1,o=this._rasterizer.rasterizeJSONResource(e,n);if(o){const{size:t,image:i,sdf:s,simplePattern:n}=o;return this._addItemToMosaic(r,t,{type:"static",data:i},S(e),s,n)}return new s("TextureManager","unrecognized or null rasterized image")}async _handleAsyncResource(e,t,i){if(this._ongoingRasterizations.has(e))return this._ongoingRasterizations.get(e);let s;s=b(t)?this._handleSVG(t,e,i):this._handleImage(t,e,i),this._ongoingRasterizations.set(e,s);try{await s,this._ongoingRasterizations.delete(e)}catch{this._ongoingRasterizations.delete(e)}return s}async _handleSVG(e,t,i){const s=[Q,Q],r=await this._sdfConverter.draw(e.path,i);return this._addItemToMosaic(t,s,{type:"static",data:new Uint32Array(r.buffer)},!1,!0,!0)}async _handleGIFOrPNG(e,t,i){const r=await V(e,i);if(N(r)){const o=q(r),a=L(r);if(!o&&!a)return new s("mapview-invalid-resource","Image data is neither GIF nor PNG!");let c;try{const t=X((e.cim||{}).animatedSymbolProperties||{}),s=e.objectId;o&&C(r)?c=await F.create(r,t,s,this._requestRender,i):a&&P(r)&&(c=await A.create(r,t,s,this._requestRender,i))}catch(n){if(!h(n))return new s("mapview-invalid-resource","Could not fetch requested resource!")}if(c&&N(c))return this._addItemToMosaic(t,[c.width,c.height],{type:"animated",data:c},S(e),!1,!1);const u=new Blob([r],{type:o?"image/gif":"image/png"}),d=await this._imageFromBlob(u);if(d&&d instanceof HTMLImageElement){let i=d.width,s=d.height;"esriPMS"===e.type&&(i=Math.round(Y(d.width,j(e))),s=Math.round(d.height*(i/d.width)));const r="cim"in e?e.cim.colorSubstitutions:void 0,{size:n,sdf:o,image:a}=this._rasterizer.rasterizeImageResource(i,s,d,r);return this._addItemToMosaic(t,n,{type:"static",data:a},S(e),o,!1)}}return new s("mapview-invalid-resource","Could not handle resource!")}async _handleImage(e,t,i){if(x(e)||U(e))return this._handleGIFOrPNG(e,t,i);const r=B(e);try{let s;const n=this.resourceManager.getResource(r);if(o(n))s=n;else{const{data:e}=await this._imageRequestQueue.push(r,{...i});s=e}if(G(r))if("width"in e&&"height"in e)s.width=c(e.width),s.height=c(e.height);else if("cim"in e){const t=e.cim;s.width=c(t.width??t.scaleX*t.size),s.height=c(t.size)}if(!s.width||!s.height)return null;let a=s.width,h=s.height;"esriPMS"===e.type&&(a=Math.round(Y(s.width,j(e))),h=Math.round(s.height*(a/s.width)));const u="cim"in e?e.cim.colorSubstitutions:void 0,{size:d,sdf:m,image:l}=this._rasterizer.rasterizeImageResource(a,h,s,u);return this._addItemToMosaic(t,d,{type:"static",data:l},S(e),m,!1)}catch(n){if(!h(n))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${r}. ${n.message}`)}}async _imageFromBlob(e){const t=window.URL.createObjectURL(e);try{const{data:e}=await this._imageRequestQueue.push(t);return window.URL.revokeObjectURL(t),e}catch(i){if(window.URL.revokeObjectURL(t),!h(i))return new s("mapview-invalid-resource",`Could not fetch requested resource at ${t}`);throw i}}_addItemToMosaic(e,t,i,s,r,n){return this._spriteMosaic.addSpriteItem(e,t,i,s,r,n)}}export{K as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../core/Error.js";import{isNone as a}from"../../../../../core/maybe.js";import{isAbortError as r}from"../../../../../core/promiseUtils.js";import{play as e}from"./utils.js";class i{constructor(){this._frameData=null}destroy(){this._playHandle.remove()}bindFrame(t,r,e){return t.bindTexture(r,e),!a(this._frameData)&&(r.updateData(0,0,0,this._frameData.width,this._frameData.height,this._frameData),this._frameData=null,!0)}async _load(a,i,s,o){try{const t=t=>{this._frameData=t},r=await this._loadAnimation(a,t,o);this.frameCount=r.frameDurations.length,this.width=r.width,this.height=r.height,this._playHandle=e(r,i,s)}catch(h){if(!r(h))return new t("invalid-resource","Could not parse animated resource.")}}}export{i as BaseAnimatableTextureResource};
5
+ import t from"../../../../../core/Error.js";import{isNone as e}from"../../../../../core/maybe.js";import{isAbortError as r}from"../../../../../core/promiseUtils.js";import{SPRITE_PADDING as a}from"../definitions.js";import{play as i}from"./utils.js";class s{constructor(t){this._requestRender=t,this._frameData=null}destroy(){this._playHandle.remove()}bindFrame(t,r,i){t.bindTexture(r,i),e(this._frameData)||(r.updateData(0,a,a,this._frameData.width,this._frameData.height,this._frameData),this._frameData=null)}async _load(e,a,s,o){try{const t=t=>{this._frameData=t,this._requestRender.requestRender()},r=await this._loadAnimation(e,t,o);this.frameCount=r.frameDurations.length,this.width=r.width,this.height=r.height,this._playHandle=i(r,a,s)}catch(h){if(!r(h))return new t("invalid-resource","Could not parse animated resource.")}}}export{s as BaseAnimatableTextureResource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../core/Error.js";import{isSome as e}from"../../../../../core/maybe.js";import{isAbortError as a}from"../../../../../core/promiseUtils.js";import{Milliseconds as n}from"../../../../../core/time.js";import{BaseAnimatableTextureResource as r}from"./BaseAnimatableTextureResource.js";class i extends r{static async create(e,n,r,s){const o=new i;try{await o._load(e,n,r,s)}catch(h){if(!a(h))return new t("invalid-resource",`Could not load PNG: ${h.message}`)}return o}async _loadAnimation(t,e,a){return s(t,e,a)}}async function s(t,e,a){return new o(t,e,a).animation}class o{constructor(t,e,a){this.width=0,this.height=0,this.numPlays=0,this.playTime=0,this.frames=[],this.paused=!1,this.playing=!1,this.playSpeed=1,this.animation=new Promise((r=>{this._load(t,a).then((()=>{const t={frameDurations:this.frames.map((t=>n(t.delay))),selectFrame:t=>{e(this.frames[t].imageData)},width:this.width,height:this.height};r(t)}))}))}async _load(n,r){try{const t=this._parse(n);if(e(t))return t;this._resizeCanvas=document.createElement("canvas"),this._resizeCanvas.width=this.width,this._resizeCanvas.height=this.height,await Promise.all(this.frames.map((t=>t.createImage(this._resizeCanvas))))}catch(i){if(!a(i))return new t("invalid-resource","Could not parse PNG")}}_parse(t){const e=new Uint8Array(t);if(d.some(((t,a)=>t!==e[a])))return l;let a=!1;if(w(e,(t=>!(a="acTL"===t))),!a)return u;const n=[],r=[];let i=null,s=null,o=0;if(w(e,((t,e,a,h)=>{const c=new DataView(e.buffer);switch(t){case"IHDR":i=e.subarray(a+8,a+8+h),this.width=c.getUint32(a+8),this.height=c.getUint32(a+12);break;case"acTL":this.numPlays=c.getUint32(a+8+4);break;case"fcTL":{s&&(this.frames.push(s),o++),s=new g,s.width=c.getUint32(a+8+4),s.height=c.getUint32(a+8+8),s.left=c.getUint32(a+8+12),s.top=c.getUint32(a+8+16);const t=c.getUint16(a+8+20);let e=c.getUint16(a+8+22);0===e&&(e=100),s.delay=1e3*t/e,s.delay<=10&&(s.delay=100),this.playTime+=s.delay,s.disposeOp=c.getUint8(a+8+24),s.blendOp=c.getUint8(a+8+25),s.dataParts=[],0===o&&2===s.disposeOp&&(s.disposeOp=1);break}case"fdAT":s&&s.dataParts.push(e.subarray(a+8+4,a+8+h));break;case"IDAT":s&&s.dataParts.push(e.subarray(a+8,a+8+h));break;case"IEND":r.push(b(e,a,12+h));break;default:n.push(b(e,a,12+h))}})),0===this.frames.length)return u;this.frameCount=this.frames.length;const h=new Blob(n),c=new Blob(r);return this.frames.forEach((t=>{let e=[];e.push(d),i.set(D(t.width),0),i.set(D(t.height),4),e.push(A("IHDR",i)),e.push(h),t.dataParts.forEach((t=>e.push(A("IDAT",t)))),e.push(c),t.data=new Blob(e,{type:"image/png"}),delete t.dataParts,e=null})),null}}const h=new Uint32Array(256);for(let P=0;P<256;P++){let t=P;for(let e=0;e<8;e++)t=0!=(1&t)?3988292384^t>>>1:t>>>1;h[P]=t}function c(t,e=0,a=t.length-e){let n=-1;for(let r=e,i=e+a;r<i;r++)n=n>>>8^h[255&(n^t[r])];return-1^n}const l=new t("Not a PNG"),u=new t("Not an animated PNG"),d=new Uint8Array([137,80,78,71,13,10,26,10]);function m(t){const e=t.constructor===Uint8Array?t:new Uint8Array(t);return!d.some(((t,a)=>t!==e[a]))}function f(t){const e=new Uint8Array(t);if(!m(e))return!1;let a=!1;return w(e,(t=>!(a="acTL"===t))),a}class g{constructor(){this.left=0,this.top=0,this.width=0,this.height=0,this.delay=0,this.disposeOp=0,this.blendOp=0,this.data=null,this.imageData=null}async createImage(t){if(null===this.imageData)return new Promise(((e,a)=>{const n=URL.createObjectURL(this.data),r=document.createElement("img");document.body.appendChild(r),r.style.border="1px solid black",r.onload=()=>{URL.revokeObjectURL(n),this.imageData=p(r,t,this.left,this.top),e()},r.onerror=()=>{URL.revokeObjectURL(n),this.imageData=null,a(new Error("Image creation error"))},r.src=n}))}}function p(t,e,a,n){const r=e.getContext("2d");r.clearRect(0,0,e.width,e.height),r.drawImage(t,a,n,t.width,t.height);const i=r.getImageData(0,0,e.width,e.height),s=new Uint8Array(i.data);let o;for(let h=0;h<s.length;h+=4)o=s[h+3]/255,s[h]=s[h]*o,s[h+1]=s[h+1]*o,s[h+2]=s[h+2]*o;return new ImageData(new Uint8ClampedArray(s.buffer),e.width,e.height)}function w(t,e){const a=new DataView(t.buffer);let n,r,i,s=8;do{r=a.getUint32(s),n=y(t,s+4,4),i=e(n,t,s,r),s+=12+r}while(!1!==i&&"IEND"!==n&&s<t.length)}function y(t,e,a){const n=Array.prototype.slice.call(t.subarray(e,e+a));return String.fromCharCode.apply(String,n)}function U(t){const e=new Uint8Array(t.length);for(let a=0;a<t.length;a++)e[a]=t.charCodeAt(a);return e}function b(t,e,a){const n=new Uint8Array(a);return n.set(t.subarray(e,e+a)),n}function A(t,e){const a=t.length+e.length,n=new Uint8Array(a+8),r=new DataView(n.buffer);r.setUint32(0,e.length),n.set(U(t),4),n.set(e,8);const i=c(n,4,a);return r.setUint32(a+4,i),n}function D(t){return new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t])}export{i as APNG,f as isAnimatedPNG,m as isPNG,s as parseApng};
5
+ import t from"../../../../../core/Error.js";import{isSome as e}from"../../../../../core/maybe.js";import{isAbortError as a}from"../../../../../core/promiseUtils.js";import{Milliseconds as n}from"../../../../../core/time.js";import{BaseAnimatableTextureResource as r}from"./BaseAnimatableTextureResource.js";class i extends r{static async create(e,n,r,s,o){const h=new i(s);try{await h._load(e,n,r,o)}catch(c){if(!a(c))return new t("invalid-resource",`Could not load PNG: ${c.message}`)}return h}async _loadAnimation(t,e,a){return s(t,e,a)}}async function s(t,e,a){return new o(t,e,a).animation}class o{constructor(t,e,a){this.width=0,this.height=0,this.numPlays=0,this.playTime=0,this.frames=[],this.paused=!1,this.playing=!1,this.playSpeed=1,this.animation=new Promise((r=>{this._load(t,a).then((()=>{const t={frameDurations:this.frames.map((t=>n(t.delay))),selectFrame:t=>{e(this.frames[t].imageData)},width:this.width,height:this.height};r(t)}))}))}async _load(n,r){try{const t=this._parse(n);if(e(t))return t;this._resizeCanvas=document.createElement("canvas"),this._resizeCanvas.width=this.width,this._resizeCanvas.height=this.height,await Promise.all(this.frames.map((t=>t.createImage(this._resizeCanvas))))}catch(i){if(!a(i))return new t("invalid-resource","Could not parse PNG")}}_parse(t){const e=new Uint8Array(t);if(d.some(((t,a)=>t!==e[a])))return l;let a=!1;if(w(e,(t=>!(a="acTL"===t))),!a)return u;const n=[],r=[];let i=null,s=null,o=0;if(w(e,((t,e,a,h)=>{const c=new DataView(e.buffer);switch(t){case"IHDR":i=e.subarray(a+8,a+8+h),this.width=c.getUint32(a+8),this.height=c.getUint32(a+12);break;case"acTL":this.numPlays=c.getUint32(a+8+4);break;case"fcTL":{s&&(this.frames.push(s),o++),s=new g,s.width=c.getUint32(a+8+4),s.height=c.getUint32(a+8+8),s.left=c.getUint32(a+8+12),s.top=c.getUint32(a+8+16);const t=c.getUint16(a+8+20);let e=c.getUint16(a+8+22);0===e&&(e=100),s.delay=1e3*t/e,s.delay<=10&&(s.delay=100),this.playTime+=s.delay,s.disposeOp=c.getUint8(a+8+24),s.blendOp=c.getUint8(a+8+25),s.dataParts=[],0===o&&2===s.disposeOp&&(s.disposeOp=1);break}case"fdAT":s&&s.dataParts.push(e.subarray(a+8+4,a+8+h));break;case"IDAT":s&&s.dataParts.push(e.subarray(a+8,a+8+h));break;case"IEND":r.push(b(e,a,12+h));break;default:n.push(b(e,a,12+h))}})),0===this.frames.length)return u;this.frameCount=this.frames.length;const h=new Blob(n),c=new Blob(r);return this.frames.forEach((t=>{let e=[];e.push(d),i.set(D(t.width),0),i.set(D(t.height),4),e.push(A("IHDR",i)),e.push(h),t.dataParts.forEach((t=>e.push(A("IDAT",t)))),e.push(c),t.data=new Blob(e,{type:"image/png"}),delete t.dataParts,e=null})),null}}const h=new Uint32Array(256);for(let P=0;P<256;P++){let t=P;for(let e=0;e<8;e++)t=0!=(1&t)?3988292384^t>>>1:t>>>1;h[P]=t}function c(t,e=0,a=t.length-e){let n=-1;for(let r=e,i=e+a;r<i;r++)n=n>>>8^h[255&(n^t[r])];return-1^n}const l=new t("Not a PNG"),u=new t("Not an animated PNG"),d=new Uint8Array([137,80,78,71,13,10,26,10]);function m(t){const e=t.constructor===Uint8Array?t:new Uint8Array(t);return!d.some(((t,a)=>t!==e[a]))}function f(t){const e=new Uint8Array(t);if(!m(e))return!1;let a=!1;return w(e,(t=>!(a="acTL"===t))),a}class g{constructor(){this.left=0,this.top=0,this.width=0,this.height=0,this.delay=0,this.disposeOp=0,this.blendOp=0,this.data=null,this.imageData=null}async createImage(t){if(null===this.imageData)return new Promise(((e,a)=>{const n=URL.createObjectURL(this.data),r=document.createElement("img");document.body.appendChild(r),r.style.border="1px solid black",r.onload=()=>{URL.revokeObjectURL(n),this.imageData=p(r,t,this.left,this.top),e()},r.onerror=()=>{URL.revokeObjectURL(n),this.imageData=null,a(new Error("Image creation error"))},r.src=n}))}}function p(t,e,a,n){const r=e.getContext("2d");r.clearRect(0,0,e.width,e.height),r.drawImage(t,a,n,t.width,t.height);const i=r.getImageData(0,0,e.width,e.height),s=new Uint8Array(i.data);let o;for(let h=0;h<s.length;h+=4)o=s[h+3]/255,s[h]=s[h]*o,s[h+1]=s[h+1]*o,s[h+2]=s[h+2]*o;return new ImageData(new Uint8ClampedArray(s.buffer),e.width,e.height)}function w(t,e){const a=new DataView(t.buffer);let n,r,i,s=8;do{r=a.getUint32(s),n=y(t,s+4,4),i=e(n,t,s,r),s+=12+r}while(!1!==i&&"IEND"!==n&&s<t.length)}function y(t,e,a){const n=Array.prototype.slice.call(t.subarray(e,e+a));return String.fromCharCode.apply(String,n)}function U(t){const e=new Uint8Array(t.length);for(let a=0;a<t.length;a++)e[a]=t.charCodeAt(a);return e}function b(t,e,a){const n=new Uint8Array(a);return n.set(t.subarray(e,e+a)),n}function A(t,e){const a=t.length+e.length,n=new Uint8Array(a+8),r=new DataView(n.buffer);r.setUint32(0,e.length),n.set(U(t),4),n.set(e,8);const i=c(n,4,a);return r.setUint32(a+4,i),n}function D(t){return new Uint8Array([t>>>24&255,t>>>16&255,t>>>8&255,255&t])}export{i as APNG,f as isAnimatedPNG,m as isPNG,s as parseApng};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../core/Error.js";import{isAbortError as e,isAborted as s,createAbortError as i}from"../../../../../core/promiseUtils.js";import{Milliseconds as a}from"../../../../../core/time.js";import{BaseAnimatableTextureResource as o}from"./BaseAnimatableTextureResource.js";class r extends o{static async create(s,i,a,o){const h=new r;try{await h._load(s,i,a,o)}catch(n){if(!e(n))return new t("invalid-resource",`Could not load GIF: ${n.message}`)}return h}async _loadAnimation(t,e,s){return h(t,e,s)}}async function h(t,e,s){return new n(t,e,s).animation}class n{constructor(t,e,s){this.loading=!1,this.firstFrameOnly=!1,this.frames=[],this.comment="",this.length=0,this.frameCount=0,this.playSpeed=1,this.lastFrame=null,this.complete=!1,this.interlaceOffsets=[0,4,2,1],this.interlaceSteps=[8,8,4,2],this.animation=new Promise((i=>{this._load(t,s).then((()=>{const t={frameDurations:this.frames.map((t=>a(t.delay))),selectFrame:t=>{e(this.frames[t].image)},width:this.width,height:this.height};i(t)}))}))}async _load(s,i){try{this.loading=!0,await this._parse(s,i),this.loading=!1}catch(a){if(!e(a))return new t("invalid-resource","Could not parse gif!")}}_parse(t,e){const s=new l(t);s.pos+=6,this.width=s.data[s.pos++]+(s.data[s.pos++]<<8),this.height=s.data[s.pos++]+(s.data[s.pos++]<<8);const i=s.data[s.pos++];return this.globalColourCount=1<<1+(7&i),s.pos++,s.pos++,128&i&&(this.globalColourTable=this._parseColourTable(this.globalColourCount,s)),new Promise(((t,i)=>{setTimeout((()=>this._parseBlock(s,t,i,e)),0)}))}async _parseBlock(t,e,a,o){if(o&&o.signal&&s(o.signal))return void a(i());const r=t.data[t.pos++];if(r===d.IMAGE){if(this._parseImg(t),this.firstFrameOnly)return this._finishedLoading(),void e()}else{if(r===d.EOF)return this._finishedLoading(),void e();this._parseExt(t)}"function"==typeof this.onprogress&&this.onprogress({bytesRead:t.pos,totalBytes:t.data.length,frame:this.frames.length}),setTimeout((()=>this._parseBlock(t,e,a,o)),0)}_parseColourTable(t,e){const s=[];for(let i=0;i<t;i++)s.push([e.data[e.pos++],e.data[e.pos++],e.data[e.pos++]]);return s}_parseImg(t){const e=t=>{const e=this.pixelBufSize/t;this.interlacedBufSize!==this.pixelBufSize&&(this.deinterlaceBuf=new Uint8Array(this.pixelBufSize),this.interlacedBufSize=this.pixelBufSize);let s=0;for(let i=0;i<4;i++)for(let a=this.interlaceOffsets[i];a<e;a+=this.interlaceSteps[i])this.deinterlaceBuf.set(this.pixelBuf.subarray(s,s+t),a*t),s+=t},s={};this.frames.push(s),s.disposalMethod=this.disposalMethod,s.time=this.length,s.delay=10*this.delayTime,this.length+=s.delay,this.transparencyGiven?s.transparencyIndex=this.transparencyIndex:s.transparencyIndex=void 0,s.leftPos=t.data[t.pos++]+(t.data[t.pos++]<<8),s.topPos=t.data[t.pos++]+(t.data[t.pos++]<<8),s.width=t.data[t.pos++]+(t.data[t.pos++]<<8),s.height=t.data[t.pos++]+(t.data[t.pos++]<<8);const i=t.data[t.pos++];s.localColourTableFlag=!!(128&i),s.localColourTableFlag&&(s.localColourTable=this._parseColourTable(1<<1+(7&i),t)),this.pixelBufSize!==s.width*s.height&&(this.pixelBuf=new Uint8Array(s.width*s.height),this.pixelBufSize=s.width*s.height),this._lzwDecode(t.data[t.pos++],t.readSubBlocksB()),64&i?(s.interlaced=!0,e(s.width)):s.interlaced=!1,this._processFrame(s)}_lzwDecode(t,e){let s,i,a,o,r,h,n,l,d;a=i=0;let p=[];const c=1<<t,u=c+1;for(o=t+1,d=!1;!d;){for(h=r,r=0,s=0;s<o;s++)e[a>>3]&1<<(7&a)&&(r|=1<<s),a++;if(r===c){for(p=[],o=t+1,s=0;s<c;s++)p[s]=[s];p[c]=[],p[u]=null}else{if(r===u)return void(d=!0);for(r>=p.length?p.push(p[h].concat(p[h][0])):h!==c&&p.push(p[h].concat(p[r][0])),n=p[r],l=n.length,s=0;s<l;s++)this.pixelBuf[i++]=n[s];p.length===1<<o&&o<12&&o++}}}_processFrame(t){t.image=document.createElement("canvas"),t.image.width=this.width,t.image.height=this.height,t.ctx=t.image.getContext("2d");const e=t.localColourTableFlag?t.localColourTable:this.globalColourTable;null===this.lastFrame&&(this.lastFrame=t);const s=2===this.lastFrame.disposalMethod||3===this.lastFrame.disposalMethod;s||t.ctx.drawImage(this.lastFrame.image,0,0,this.width,this.height);const i=t.ctx.getImageData(t.leftPos,t.topPos,t.width,t.height),a=t.transparencyIndex,o=i.data,r=t.interlaced?this.deinterlaceBuf:this.pixelBuf,h=r.length;let n,l,d=0;for(let p=0;p<h;p++)n=r[p],l=e[n],a!==n?(o[d++]=l[0],o[d++]=l[1],o[d++]=l[2],o[d++]=255):s?(o[d+3]=0,d+=4):d+=4;t.ctx.putImageData(i,t.leftPos,t.topPos),this.lastFrame=t}_parseExt(t){const e=t.data[t.pos++];e===d.GCExt?this._parseGCExt(t):e===d.COMMENT?this.comment+=t.readSubBlocks():e===d.APPExt?this._parseAppExt(t):(e===d.UNKNOWN&&(t.pos+=13),t.readSubBlocks())}_parseAppExt(t){t.pos+=1,"NETSCAPE"===t.getString(8)?t.pos+=8:(t.pos+=3,t.readSubBlocks())}_parseGCExt(t){t.pos++;const e=t.data[t.pos++];this.disposalMethod=(28&e)>>2,this.transparencyGiven=!!(1&e),this.delayTime=t.data[t.pos++]+(t.data[t.pos++]<<8),this.delayTime=this.delayTime>0?this.delayTime:1,this.transparencyIndex=t.data[t.pos++],t.pos++}_finishedLoading(){this.loading=!1,this.frameCount=this.frames.length,this.lastFrame=null,this.complete=!0,this.disposalMethod=void 0,this.transparencyGiven=void 0,this.delayTime=void 0,this.transparencyIndex=void 0,this.pixelBuf=void 0,this.deinterlaceBuf=void 0,this.pixelBufSize=void 0,this.deinterlaceBuf=void 0}}class l{constructor(t){this.pos=0,this.data=new Uint8ClampedArray(t),this.len=this.data.length}getString(t){let e="";for(;t--;)e+=String.fromCharCode(this.data[this.pos++]);return e}readSubBlocks(){let t,e,s="";do{for(e=t=this.data[this.pos++];e--;)s+=String.fromCharCode(this.data[this.pos++])}while(0!==t&&this.pos<this.len);return s}readSubBlocksB(){let t,e;const s=[];do{for(e=t=this.data[this.pos++];e--;)s.push(this.data[this.pos++])}while(0!==t&&this.pos<this.len);return s}}const d={GCExt:249,COMMENT:254,APPExt:255,UNKNOWN:1,IMAGE:44,EOF:59,EXT:33};function p(t){if(!t||0===t.byteLength)return!1;const e=t.constructor===Uint8Array?t:new Uint8Array(t);return 71===e[0]&&73===e[1]&&70===e[2]&&56===e[3]}function c(t){if(!t||0===t.byteLength)return!1;const e=new Uint8Array(t);if(!p(e))return!1;let s=0;for(let i=0,a=e.length-9;i<a;++i)if(0===e[i]&&33===e[i+1]&&249===e[i+2]&&4===e[i+3]&&0===e[i+8]&&(44===e[i+9]||33===e[i+9])&&(s++,s>1))return!0;return!1}export{r as GIF,c as isAnimatedGIF,p as isGIF,h as parseGif};
5
+ import t from"../../../../../core/Error.js";import{isAbortError as e,isAborted as s,createAbortError as i}from"../../../../../core/promiseUtils.js";import{Milliseconds as a}from"../../../../../core/time.js";import{BaseAnimatableTextureResource as o}from"./BaseAnimatableTextureResource.js";class r extends o{static async create(s,i,a,o,h){const n=new r(o);try{await n._load(s,i,a,h)}catch(l){if(!e(l))return new t("invalid-resource",`Could not load GIF: ${l.message}`)}return n}async _loadAnimation(t,e,s){return h(t,e,s)}}async function h(t,e,s){return new n(t,e,s).animation}class n{constructor(t,e,s){this.loading=!1,this.firstFrameOnly=!1,this.frames=[],this.comment="",this.length=0,this.frameCount=0,this.playSpeed=1,this.lastFrame=null,this.complete=!1,this.interlaceOffsets=[0,4,2,1],this.interlaceSteps=[8,8,4,2],this.animation=new Promise((i=>{this._load(t,s).then((()=>{const t={frameDurations:this.frames.map((t=>a(t.delay))),selectFrame:t=>{e(this.frames[t].image)},width:this.width,height:this.height};i(t)}))}))}async _load(s,i){try{this.loading=!0,await this._parse(s,i),this.loading=!1}catch(a){if(!e(a))return new t("invalid-resource","Could not parse gif!")}}_parse(t,e){const s=new l(t);s.pos+=6,this.width=s.data[s.pos++]+(s.data[s.pos++]<<8),this.height=s.data[s.pos++]+(s.data[s.pos++]<<8);const i=s.data[s.pos++];return this.globalColourCount=1<<1+(7&i),s.pos++,s.pos++,128&i&&(this.globalColourTable=this._parseColourTable(this.globalColourCount,s)),new Promise(((t,i)=>{setTimeout((()=>this._parseBlock(s,t,i,e)),0)}))}async _parseBlock(t,e,a,o){if(o&&o.signal&&s(o.signal))return void a(i());const r=t.data[t.pos++];if(r===d.IMAGE){if(this._parseImg(t),this.firstFrameOnly)return this._finishedLoading(),void e()}else{if(r===d.EOF)return this._finishedLoading(),void e();this._parseExt(t)}"function"==typeof this.onprogress&&this.onprogress({bytesRead:t.pos,totalBytes:t.data.length,frame:this.frames.length}),setTimeout((()=>this._parseBlock(t,e,a,o)),0)}_parseColourTable(t,e){const s=[];for(let i=0;i<t;i++)s.push([e.data[e.pos++],e.data[e.pos++],e.data[e.pos++]]);return s}_parseImg(t){const e=t=>{const e=this.pixelBufSize/t;this.interlacedBufSize!==this.pixelBufSize&&(this.deinterlaceBuf=new Uint8Array(this.pixelBufSize),this.interlacedBufSize=this.pixelBufSize);let s=0;for(let i=0;i<4;i++)for(let a=this.interlaceOffsets[i];a<e;a+=this.interlaceSteps[i])this.deinterlaceBuf.set(this.pixelBuf.subarray(s,s+t),a*t),s+=t},s={};this.frames.push(s),s.disposalMethod=this.disposalMethod,s.time=this.length,s.delay=10*this.delayTime,this.length+=s.delay,this.transparencyGiven?s.transparencyIndex=this.transparencyIndex:s.transparencyIndex=void 0,s.leftPos=t.data[t.pos++]+(t.data[t.pos++]<<8),s.topPos=t.data[t.pos++]+(t.data[t.pos++]<<8),s.width=t.data[t.pos++]+(t.data[t.pos++]<<8),s.height=t.data[t.pos++]+(t.data[t.pos++]<<8);const i=t.data[t.pos++];s.localColourTableFlag=!!(128&i),s.localColourTableFlag&&(s.localColourTable=this._parseColourTable(1<<1+(7&i),t)),this.pixelBufSize!==s.width*s.height&&(this.pixelBuf=new Uint8Array(s.width*s.height),this.pixelBufSize=s.width*s.height),this._lzwDecode(t.data[t.pos++],t.readSubBlocksB()),64&i?(s.interlaced=!0,e(s.width)):s.interlaced=!1,this._processFrame(s)}_lzwDecode(t,e){let s,i,a,o,r,h,n,l,d;a=i=0;let p=[];const c=1<<t,u=c+1;for(o=t+1,d=!1;!d;){for(h=r,r=0,s=0;s<o;s++)e[a>>3]&1<<(7&a)&&(r|=1<<s),a++;if(r===c){for(p=[],o=t+1,s=0;s<c;s++)p[s]=[s];p[c]=[],p[u]=null}else{if(r===u)return void(d=!0);for(r>=p.length?p.push(p[h].concat(p[h][0])):h!==c&&p.push(p[h].concat(p[r][0])),n=p[r],l=n.length,s=0;s<l;s++)this.pixelBuf[i++]=n[s];p.length===1<<o&&o<12&&o++}}}_processFrame(t){t.image=document.createElement("canvas"),t.image.width=this.width,t.image.height=this.height,t.ctx=t.image.getContext("2d");const e=t.localColourTableFlag?t.localColourTable:this.globalColourTable;null===this.lastFrame&&(this.lastFrame=t);const s=2===this.lastFrame.disposalMethod||3===this.lastFrame.disposalMethod;s||t.ctx.drawImage(this.lastFrame.image,0,0,this.width,this.height);const i=t.ctx.getImageData(t.leftPos,t.topPos,t.width,t.height),a=t.transparencyIndex,o=i.data,r=t.interlaced?this.deinterlaceBuf:this.pixelBuf,h=r.length;let n,l,d=0;for(let p=0;p<h;p++)n=r[p],l=e[n],a!==n?(o[d++]=l[0],o[d++]=l[1],o[d++]=l[2],o[d++]=255):s?(o[d+3]=0,d+=4):d+=4;t.ctx.putImageData(i,t.leftPos,t.topPos),this.lastFrame=t}_parseExt(t){const e=t.data[t.pos++];e===d.GCExt?this._parseGCExt(t):e===d.COMMENT?this.comment+=t.readSubBlocks():e===d.APPExt?this._parseAppExt(t):(e===d.UNKNOWN&&(t.pos+=13),t.readSubBlocks())}_parseAppExt(t){t.pos+=1,"NETSCAPE"===t.getString(8)?t.pos+=8:(t.pos+=3,t.readSubBlocks())}_parseGCExt(t){t.pos++;const e=t.data[t.pos++];this.disposalMethod=(28&e)>>2,this.transparencyGiven=!!(1&e),this.delayTime=t.data[t.pos++]+(t.data[t.pos++]<<8),this.delayTime=this.delayTime>0?this.delayTime:1,this.transparencyIndex=t.data[t.pos++],t.pos++}_finishedLoading(){this.loading=!1,this.frameCount=this.frames.length,this.lastFrame=null,this.complete=!0,this.disposalMethod=void 0,this.transparencyGiven=void 0,this.delayTime=void 0,this.transparencyIndex=void 0,this.pixelBuf=void 0,this.deinterlaceBuf=void 0,this.pixelBufSize=void 0,this.deinterlaceBuf=void 0}}class l{constructor(t){this.pos=0,this.data=new Uint8ClampedArray(t),this.len=this.data.length}getString(t){let e="";for(;t--;)e+=String.fromCharCode(this.data[this.pos++]);return e}readSubBlocks(){let t,e,s="";do{for(e=t=this.data[this.pos++];e--;)s+=String.fromCharCode(this.data[this.pos++])}while(0!==t&&this.pos<this.len);return s}readSubBlocksB(){let t,e;const s=[];do{for(e=t=this.data[this.pos++];e--;)s.push(this.data[this.pos++])}while(0!==t&&this.pos<this.len);return s}}const d={GCExt:249,COMMENT:254,APPExt:255,UNKNOWN:1,IMAGE:44,EOF:59,EXT:33};function p(t){if(!t||0===t.byteLength)return!1;const e=t.constructor===Uint8Array?t:new Uint8Array(t);return 71===e[0]&&73===e[1]&&70===e[2]&&56===e[3]}function c(t){if(!t||0===t.byteLength)return!1;const e=new Uint8Array(t);if(!p(e))return!1;let s=0;for(let i=0,a=e.length-9;i<a;++i)if(0===e[i]&&33===e[i+1]&&249===e[i+2]&&4===e[i+3]&&0===e[i+8]&&(44===e[i+9]||33===e[i+9])&&(s++,s>1))return!0;return!1}export{r as GIF,c as isAnimatedGIF,p as isGIF,h as parseGif};