@arcgis/core 4.28.0-next.20230711 → 4.28.0-next.20230713

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 (83) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/08ee2bd914867fd2cbd5.js +1 -0
  3. package/assets/esri/core/workers/chunks/{4f92fd5167e22c602e8a.js → 169b04f05f5c875c5083.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{d2f9988b576ac968dd92.js → 3a614d35dec6deebd041.js} +1 -1
  5. package/assets/esri/core/workers/chunks/55109f141c9f120833f6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{086173d3ada7857eea15.js → 7c585aee0f931e6b56c0.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{27fec382097efdcfee8a.js → 839d9039f0628ee98466.js} +1 -1
  8. package/assets/esri/core/workers/chunks/8c5a8c1dfb086069bb06.js +1 -0
  9. package/assets/esri/core/workers/chunks/{f156387d6c645b18a8dd.js → b2a0e3e1dfccda7ed12e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/d4881b238c8a93390cde.js +1 -0
  11. package/assets/esri/core/workers/chunks/dcb004dfba27335c7c3c.js +1 -0
  12. package/assets/esri/core/workers/chunks/e3610549f4c573e705ba.js +1 -0
  13. package/assets/esri/core/workers/chunks/{ad38aede3ec854191511.js → f6e24113643784bc6731.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{3a0e2535f6cdb2e65667.js → fb610982b1366cdbc0c3.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{5583921a498172edd5ac.js → fcab431f13b4a9f92dbf.js} +1 -1
  16. package/assets/esri/themes/base/_mixins.scss +3 -1
  17. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +6 -2
  18. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +6 -2
  19. package/assets/esri/themes/base/widgets/_Bookmarks.scss +3 -1
  20. package/assets/esri/themes/base/widgets/_BuildingLevelPicker.scss +6 -2
  21. package/assets/esri/themes/base/widgets/_ColorPicker.scss +3 -1
  22. package/assets/esri/themes/base/widgets/_Expand.scss +3 -1
  23. package/assets/esri/themes/base/widgets/_FeatureForm.scss +3 -1
  24. package/assets/esri/themes/base/widgets/_LayerList.scss +6 -2
  25. package/assets/esri/themes/base/widgets/_Popup.scss +3 -1
  26. package/assets/esri/themes/base/widgets/_ScaleBar.scss +7 -2
  27. package/assets/esri/themes/base/widgets/_SnappingControls.scss +6 -2
  28. package/assets/esri/themes/base/widgets/_TableList.scss +6 -2
  29. package/assets/esri/themes/base/widgets/_Widget.scss +3 -1
  30. package/copyright.txt +19 -20
  31. package/core/Collection.js +1 -1
  32. package/core/accessorSupport/ensureType.js +1 -1
  33. package/core/accessorSupport/set.js +1 -1
  34. package/layers/VoxelLayer.js +1 -1
  35. package/layers/VoxelWasmPerSceneView.js +1 -1
  36. package/layers/graphics/editingSupport.js +1 -1
  37. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  38. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  39. package/layers/support/wmtsUtils.js +1 -1
  40. package/package.json +1 -1
  41. package/support/revision.js +1 -1
  42. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  43. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  44. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  45. package/views/3d/support/LaserLineRenderer.js +1 -1
  46. package/views/3d/support/engineContent/line.js +1 -1
  47. package/views/3d/terrain/PatchRenderData.js +1 -1
  48. package/views/3d/terrain/TerrainRenderer.js +1 -1
  49. package/views/3d/terrain/TileRenderer.js +1 -1
  50. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  51. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +17 -21
  52. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  53. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  54. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  55. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  56. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  57. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  58. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  59. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  60. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  61. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  62. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  63. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  64. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  65. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  66. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  67. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  68. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  69. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  70. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  71. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  72. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  73. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  74. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  75. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  76. package/widgets/ElevationProfile/support/ProfileGenerationError.js +1 -1
  77. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  78. package/assets/esri/core/workers/chunks/00b023cb63f23bc074b8.js +0 -1
  79. package/assets/esri/core/workers/chunks/1e413a44b35bfecbfa59.js +0 -1
  80. package/assets/esri/core/workers/chunks/71c029f95cb4666ae207.js +0 -1
  81. package/assets/esri/core/workers/chunks/c9ef45225947ccc2bd4c.js +0 -1
  82. package/assets/esri/core/workers/chunks/dda6fab95d50c1215808.js +0 -1
  83. package/assets/esri/core/workers/chunks/f5f0a5318337439d464e.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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"./ArrayPool.js";import s from"./Evented.js";import{makeHandle as i}from"./handleUtils.js";import{clone as r}from"./lang.js";import n from"./ObjectPool.js";import{ObservableChangesType as h}from"./ObservableChangesType.js";import{schedule as o}from"./scheduling.js";import{ensureType as l,ensureOneOfType as a}from"./accessorSupport/ensureType.js";import{trackAccess as c}from"./accessorSupport/tracking.js";import{property as f}from"./accessorSupport/decorators/property.js";import{shared as _}from"./accessorSupport/decorators/shared.js";import{subclass as m}from"./accessorSupport/decorators/subclass.js";import{SimpleObservable as u}from"./accessorSupport/tracking/SimpleObservable.js";var g;class d{constructor(){this.target=null,this.cancellable=!1,this.defaultPrevented=!1,this.item=void 0,this.type=void 0}preventDefault(){this.cancellable&&(this.defaultPrevented=!0)}reset(e){this.defaultPrevented=!1,this.item=e}}class p{constructor(e,t,s,i,r){this.target=e,this.added=t,this.removed=s,this.start=i,this.deleteCount=r}}const b=new n(d,void 0,(e=>{e.item=null,e.target=null,e.defaultPrevented=!1,e.cancellable=!1}));function v(e){return e?e instanceof R?e.toArray():e.length?Array.prototype.slice.apply(e):[]:[]}function E(e){if(e&&e.length)return e[0]}function C(e,t,s,i){const r=Math.min(e.length-s,t.length-i);let n=0;for(;n<r&&e[s+n]===t[i+n];)n++;return n}function y(e,t,s,i){t&&t.forEach(((t,r,n)=>{e.push(t),y(e,s.call(i,t,r,n),s,i)}))}const A=new Set,O=new Set,M=new Set,D=new Map;let x=0,R=g=class extends s.EventedAccessor{static isCollection(e){return null!=e&&e instanceof g}constructor(e){super(e),this._chgListeners=[],this._notifications=null,this._timer=null,this._observable=new u,this.length=0,this._items=[],Object.defineProperty(this,"uid",{value:x++})}normalizeCtorArgs(e){return e?Array.isArray(e)||e instanceof g?{items:e}:e:{}}destroy(){this._removeAllRaw()}*[Symbol.iterator](){yield*this.items}get items(){return c(this._observable),this._items}set items(e){this._emitBeforeChanges(h.ADD)||(this._splice(0,this.length,v(e)),this._emitAfterChanges(h.ADD))}hasEventListener(e){return"change"===e?this._chgListeners.length>0:this._emitter.hasEventListener(e)}on(e,t){if("change"===e){const e=this._chgListeners,s={removed:!1,callback:t};return e.push(s),this._notifications&&this._notifications.push({listeners:e.slice(),items:this._items.slice(),changes:[]}),i((()=>{s.removed=!0,e.splice(e.indexOf(s),1)}))}return this._emitter.on(e,t)}once(e,t){return this.on(e,t)}add(e,t){if(c(this._observable),this._emitBeforeChanges(h.ADD))return this;const s=this.getNextIndex(t??null);return this._splice(s,0,[e]),this._emitAfterChanges(h.ADD),this}addMany(e,t=this._items.length){if(c(this._observable),!e||!e.length)return this;if(this._emitBeforeChanges(h.ADD))return this;const s=this.getNextIndex(t);return this._splice(s,0,v(e)),this._emitAfterChanges(h.ADD),this}at(e){if(c(this._observable),(e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this._items[e]}removeAll(){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return[];const e=this._removeAllRaw();return this._emitAfterChanges(h.REMOVE),e}_removeAllRaw(){return 0===this.length?[]:this._splice(0,this.length)||[]}clone(){return c(this._observable),this._createNewInstance({items:this._items.map(r)})}concat(...e){c(this._observable);const t=e.map(v);return this._createNewInstance({items:this._items.concat(...t)})}drain(e,t){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return;const s=this._splice(0,this.length),i=s.length;for(let r=0;r<i;r++)e.call(t,s[r],r,s);this._emitAfterChanges(h.REMOVE)}every(e,t){return c(this._observable),this._items.every(e,t)}filter(e,t){let s;return c(this._observable),s=2===arguments.length?this._items.filter(e,t):this._items.filter(e),this._createNewInstance({items:s})}find(e,t){return c(this._observable),this._items.find(e,t)}findIndex(e,t){return c(this._observable),this._items.findIndex(e,t)}flatten(e,t){c(this._observable);const s=[];return y(s,this,e,t),new g(s)}forEach(e,t){return c(this._observable),this._items.forEach(e,t)}getItemAt(e){return c(this._observable),this._items[e]}getNextIndex(e){c(this._observable);const t=this.length;return(e=e??t)<0?e=0:e>t&&(e=t),e}includes(e,t=0){return c(this._observable),this._items.includes(e,t)}indexOf(e,t=0){return c(this._observable),this._items.indexOf(e,t)}join(e=","){return c(this._observable),this._items.join(e)}lastIndexOf(e,t=this.length-1){return c(this._observable),this._items.lastIndexOf(e,t)}map(e,t){c(this._observable);const s=this._items.map(e,t);return new g({items:s})}reorder(e,t=this.length-1){c(this._observable);const s=this.indexOf(e);if(-1!==s){if(t<0?t=0:t>=this.length&&(t=this.length-1),s!==t){if(this._emitBeforeChanges(h.MOVE))return e;this._splice(s,1),this._splice(t,0,[e]),this._emitAfterChanges(h.MOVE)}return e}}pop(){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return;const e=E(this._splice(this.length-1,1));return this._emitAfterChanges(h.REMOVE),e}push(...e){return c(this._observable),this._emitBeforeChanges(h.ADD)||(this._splice(this.length,0,e),this._emitAfterChanges(h.ADD)),this.length}reduce(e,t){c(this._observable);const s=this._items;return 2===arguments.length?s.reduce(e,t):s.reduce(e)}reduceRight(e,t){c(this._observable);const s=this._items;return 2===arguments.length?s.reduceRight(e,t):s.reduceRight(e)}remove(e){return c(this._observable),this.removeAt(this.indexOf(e))}removeAt(e){if(c(this._observable),e<0||e>=this.length||this._emitBeforeChanges(h.REMOVE))return;const t=E(this._splice(e,1));return this._emitAfterChanges(h.REMOVE),t}removeMany(e){if(c(this._observable),!e||!e.length||this._emitBeforeChanges(h.REMOVE))return[];const t=e instanceof g?e.toArray():e,s=this._items,i=[],r=t.length;for(let n=0;n<r;n++){const e=t[n],r=s.indexOf(e);if(r>-1){const e=1+C(t,s,n+1,r+1),h=this._splice(r,e);h&&h.length>0&&i.push.apply(i,h),n+=e-1}}return this._emitAfterChanges(h.REMOVE),i}reverse(){if(c(this._observable),this._emitBeforeChanges(h.MOVE))return this;const e=this._splice(0,this.length);return e&&(e.reverse(),this._splice(0,0,e)),this._emitAfterChanges(h.MOVE),this}shift(){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return;const e=E(this._splice(0,1));return this._emitAfterChanges(h.REMOVE),e}slice(e=0,t=this.length){return c(this._observable),this._createNewInstance({items:this._items.slice(e,t)})}some(e,t){return c(this._observable),this._items.some(e,t)}sort(e){if(c(this._observable),!this.length||this._emitBeforeChanges(h.MOVE))return this;const t=this._splice(0,this.length);return arguments.length?t.sort(e):t.sort(),this._splice(0,0,t),this._emitAfterChanges(h.MOVE),this}splice(e,t,...s){c(this._observable);const i=(t?h.REMOVE:0)|(s.length?h.ADD:0);if(this._emitBeforeChanges(i))return[];const r=this._splice(e,t,s)||[];return this._emitAfterChanges(i),r}toArray(){return c(this._observable),this._items.slice()}toJSON(){return c(this._observable),this.toArray()}toLocaleString(){return c(this._observable),this._items.toLocaleString()}toString(){return c(this._observable),this._items.toString()}unshift(...e){return c(this._observable),!e.length||this._emitBeforeChanges(h.ADD)||(this._splice(0,0,e),this._emitAfterChanges(h.ADD)),this.length}_createNewInstance(e){return new this.constructor(e)}_splice(e,t,s){const i=this._items,r=this.itemType;let n,h;if(!this._notifications&&this.hasEventListener("change")&&(this._notifications=[{listeners:this._chgListeners.slice(),items:this._items.slice(),changes:[]}],this._timer&&this._timer.remove(),this._timer=o((()=>this._dispatchChange()))),t){if(h=i.splice(e,t),this.hasEventListener("before-remove")){const t=b.acquire();t.target=this,t.cancellable=!0;for(let s=0,r=h.length;s<r;s++)n=h[s],t.reset(n),this.emit("before-remove",t),t.defaultPrevented&&(h.splice(s,1),i.splice(e,0,n),e+=1,s-=1,r-=1);b.release(t)}if(this.length=this._items.length,this.hasEventListener("after-remove")){const e=b.acquire();e.target=this,e.cancellable=!1;const t=h.length;for(let s=0;s<t;s++)e.reset(h[s]),this.emit("after-remove",e);b.release(e)}}if(s&&s.length){if(r){const e=[];for(const t of s){const s=r.ensureType(t);null==s&&null!=t||e.push(s)}s=e}const t=this.hasEventListener("before-add"),n=this.hasEventListener("after-add"),h=e===this.length;if(t||n){const r=b.acquire();r.target=this,r.cancellable=!0;const o=b.acquire();o.target=this,o.cancellable=!1;for(const l of s)t?(r.reset(l),this.emit("before-add",r),r.defaultPrevented||(h?i.push(l):i.splice(e++,0,l),this._set("length",i.length),n&&(o.reset(l),this.emit("after-add",o)))):(h?i.push(l):i.splice(e++,0,l),this._set("length",i.length),o.reset(l),this.emit("after-add",o));b.release(o),b.release(r)}else{if(h)for(const e of s)i.push(e);else i.splice(e,0,...s);this._set("length",i.length)}}if((s&&s.length||h&&h.length)&&this._notifyChangeEvent(s,h),this.hasEventListener("after-splice")){const i=new p(this,s,h,e,t);this.emit("after-splice",i)}return h}_emitBeforeChanges(e){let t=!1;if(this.hasEventListener("before-changes")){const s=b.acquire();s.target=this,s.cancellable=!0,s.type=e,this.emit("before-changes",s),t=s.defaultPrevented,b.release(s)}return t}_emitAfterChanges(e){if(this.hasEventListener("after-changes")){const t=b.acquire();t.target=this,t.cancellable=!1,t.type=e,this.emit("after-changes",t),b.release(t)}this._observable.notify()}_notifyChangeEvent(e,t){this.hasEventListener("change")&&this._notifications&&this._notifications[this._notifications.length-1].changes.push({added:e,removed:t})}_dispatchChange(){if(this._timer&&(this._timer.remove(),this._timer=null),!this._notifications)return;const e=this._notifications;this._notifications=null;for(const s of e){const e=s.changes;A.clear(),O.clear(),M.clear();for(const{added:t,removed:s}of e){if(t)if(0===M.size&&0===O.size)for(const e of t)A.add(e);else for(const e of t)O.has(e)?(M.add(e),O.delete(e)):M.has(e)||A.add(e);if(s)if(0===M.size&&0===A.size)for(const e of s)O.add(e);else for(const e of s)A.has(e)?A.delete(e):(M.delete(e),O.add(e))}const i=t.acquire();A.forEach((e=>{i.push(e)}));const r=t.acquire();O.forEach((e=>{r.push(e)}));const n=this._items,h=s.items,o=t.acquire();if(M.forEach((e=>{h.indexOf(e)!==n.indexOf(e)&&o.push(e)})),s.listeners&&(i.length||r.length||o.length)){const e={target:this,added:i,removed:r,moved:o},t=s.listeners.length;for(let i=0;i<t;i++){const t=s.listeners[i];t.removed||t.callback.call(this,e)}}t.release(i),t.release(r),t.release(o)}A.clear(),O.clear(),M.clear()}};R.ofType=t=>{if(!t)return g;if(D.has(t))return D.get(t);let s=null;if("function"==typeof t)s=t.prototype.declaredClass;else if(t.base)s=t.base.prototype.declaredClass;else for(const e in t.typeMap){const i=t.typeMap[e].prototype.declaredClass;s?s+=` | ${i}`:s=i}let i=class extends g{};return e([_({Type:t,ensureType:"function"==typeof t?l(t):a(t)})],i.prototype,"itemType",void 0),i=e([m(`esri.core.Collection<${s}>`)],i),D.set(t,i),i},e([f()],R.prototype,"length",void 0),e([f()],R.prototype,"items",null),R=g=e([m("esri.core.Collection")],R);const V=R;export{V as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"./ArrayPool.js";import s from"./Evented.js";import{makeHandle as i}from"./handleUtils.js";import{clone as r}from"./lang.js";import n from"./ObjectPool.js";import{ObservableChangesType as h}from"./ObservableChangesType.js";import{schedule as o}from"./scheduling.js";import{ensureType as l,ensureOneOfType as a}from"./accessorSupport/ensureType.js";import{trackAccess as c}from"./accessorSupport/tracking.js";import{property as f}from"./accessorSupport/decorators/property.js";import{shared as _}from"./accessorSupport/decorators/shared.js";import{subclass as m}from"./accessorSupport/decorators/subclass.js";import{SimpleObservable as u}from"./accessorSupport/tracking/SimpleObservable.js";var g;class d{constructor(){this.target=null,this.cancellable=!1,this.defaultPrevented=!1,this.item=void 0,this.type=void 0}preventDefault(){this.cancellable&&(this.defaultPrevented=!0)}reset(e){this.defaultPrevented=!1,this.item=e}}class p{constructor(e,t,s,i,r){this.target=e,this.added=t,this.removed=s,this.start=i,this.deleteCount=r}}const b=new n(d,void 0,(e=>{e.item=null,e.target=null,e.defaultPrevented=!1,e.cancellable=!1}));function v(e){return e?e instanceof R?e.toArray():e.length?Array.prototype.slice.apply(e):[]:[]}function E(e){if(e&&e.length)return e[0]}function C(e,t,s,i){const r=Math.min(e.length-s,t.length-i);let n=0;for(;n<r&&e[s+n]===t[i+n];)n++;return n}function y(e,t,s,i){t&&t.forEach(((t,r,n)=>{e.push(t),y(e,s.call(i,t,r,n),s,i)}))}const A=new Set,O=new Set,M=new Set,D=new Map;let x=0,R=g=class extends s.EventedAccessor{static isCollection(e){return null!=e&&e instanceof g}constructor(e){super(e),this._chgListeners=[],this._notifications=null,this._timer=null,this._observable=new u,this.length=0,this._items=[],Object.defineProperty(this,"uid",{value:x++})}normalizeCtorArgs(e){return e?Array.isArray(e)||e instanceof g?{items:e}:e:{}}destroy(){this._removeAllRaw()}*[Symbol.iterator](){yield*this.items}get items(){return c(this._observable),this._items}set items(e){this._emitBeforeChanges(h.ADD)||(this._splice(0,this.length,v(e)),this._emitAfterChanges(h.ADD))}hasEventListener(e){return"change"===e?this._chgListeners.length>0:this._emitter.hasEventListener(e)}on(e,t){if("change"===e){const e=this._chgListeners,s={removed:!1,callback:t};return e.push(s),this._notifications&&this._notifications.push({listeners:e.slice(),items:this._items.slice(),changes:[]}),i((()=>{s.removed=!0,e.splice(e.indexOf(s),1)}))}return this._emitter.on(e,t)}once(e,t){return this.on(e,t)}add(e,t){if(c(this._observable),this._emitBeforeChanges(h.ADD))return this;const s=this.getNextIndex(t??null);return this._splice(s,0,[e]),this._emitAfterChanges(h.ADD),this}addMany(e,t=this._items.length){if(c(this._observable),!e||!e.length)return this;if(this._emitBeforeChanges(h.ADD))return this;const s=this.getNextIndex(t);return this._splice(s,0,v(e)),this._emitAfterChanges(h.ADD),this}at(e){if(c(this._observable),(e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this._items[e]}removeAll(){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return[];const e=this._removeAllRaw();return this._emitAfterChanges(h.REMOVE),e}_removeAllRaw(){return 0===this.length?[]:this._splice(0,this.length)||[]}clone(){return c(this._observable),this._createNewInstance({items:this._items.map(r)})}concat(...e){c(this._observable);const t=e.map(v);return this._createNewInstance({items:this._items.concat(...t)})}drain(e,t){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return;const s=this._splice(0,this.length),i=s.length;for(let r=0;r<i;r++)e.call(t,s[r],r,s);this._emitAfterChanges(h.REMOVE)}every(e,t){return c(this._observable),this._items.every(e,t)}filter(e,t){let s;return c(this._observable),s=2===arguments.length?this._items.filter(e,t):this._items.filter(e),this._createNewInstance({items:s})}find(e,t){return c(this._observable),this._items.find(e,t)}findIndex(e,t){return c(this._observable),this._items.findIndex(e,t)}flatten(e,t){c(this._observable);const s=[];return y(s,this,e,t),new g(s)}forEach(e,t){return c(this._observable),this._items.forEach(e,t)}getItemAt(e){return c(this._observable),this._items[e]}getNextIndex(e){c(this._observable);const t=this.length;return(e=e??t)<0?e=0:e>t&&(e=t),e}includes(e,t=0){return c(this._observable),this._items.includes(e,t)}indexOf(e,t=0){return c(this._observable),this._items.indexOf(e,t)}join(e=","){return c(this._observable),this._items.join(e)}lastIndexOf(e,t=this.length-1){return c(this._observable),this._items.lastIndexOf(e,t)}map(e,t){c(this._observable);const s=this._items.map(e,t);return new g({items:s})}reorder(e,t=this.length-1){c(this._observable);const s=this.indexOf(e);if(-1!==s){if(t<0?t=0:t>=this.length&&(t=this.length-1),s!==t){if(this._emitBeforeChanges(h.MOVE))return e;this._splice(s,1),this._splice(t,0,[e]),this._emitAfterChanges(h.MOVE)}return e}}pop(){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return;const e=E(this._splice(this.length-1,1));return this._emitAfterChanges(h.REMOVE),e}push(...e){return c(this._observable),this._emitBeforeChanges(h.ADD)||(this._splice(this.length,0,e),this._emitAfterChanges(h.ADD)),this.length}reduce(e,t){c(this._observable);const s=this._items;return 2===arguments.length?s.reduce(e,t):s.reduce(e)}reduceRight(e,t){c(this._observable);const s=this._items;return 2===arguments.length?s.reduceRight(e,t):s.reduceRight(e)}remove(e){return c(this._observable),this.removeAt(this.indexOf(e))}removeAt(e){if(c(this._observable),e<0||e>=this.length||this._emitBeforeChanges(h.REMOVE))return;const t=E(this._splice(e,1));return this._emitAfterChanges(h.REMOVE),t}removeMany(e){if(c(this._observable),!e||!e.length||this._emitBeforeChanges(h.REMOVE))return[];const t=e instanceof g?e.toArray():e,s=this._items,i=[],r=t.length;for(let n=0;n<r;n++){const e=t[n],r=s.indexOf(e);if(r>-1){const e=1+C(t,s,n+1,r+1),h=this._splice(r,e);h&&h.length>0&&i.push.apply(i,h),n+=e-1}}return this._emitAfterChanges(h.REMOVE),i}reverse(){if(c(this._observable),this._emitBeforeChanges(h.MOVE))return this;const e=this._splice(0,this.length);return e&&(e.reverse(),this._splice(0,0,e)),this._emitAfterChanges(h.MOVE),this}shift(){if(c(this._observable),!this.length||this._emitBeforeChanges(h.REMOVE))return;const e=E(this._splice(0,1));return this._emitAfterChanges(h.REMOVE),e}slice(e=0,t=this.length){return c(this._observable),this._createNewInstance({items:this._items.slice(e,t)})}some(e,t){return c(this._observable),this._items.some(e,t)}sort(e){if(c(this._observable),!this.length||this._emitBeforeChanges(h.MOVE))return this;const t=this._splice(0,this.length);return arguments.length?t.sort(e):t.sort(),this._splice(0,0,t),this._emitAfterChanges(h.MOVE),this}splice(e,t,...s){c(this._observable);const i=(t?h.REMOVE:0)|(s.length?h.ADD:0);if(this._emitBeforeChanges(i))return[];const r=this._splice(e,t,s)||[];return this._emitAfterChanges(i),r}toArray(){return c(this._observable),this._items.slice()}toJSON(){return c(this._observable),this.toArray()}toLocaleString(){return c(this._observable),this._items.toLocaleString()}toString(){return c(this._observable),this._items.toString()}unshift(...e){return c(this._observable),!e.length||this._emitBeforeChanges(h.ADD)||(this._splice(0,0,e),this._emitAfterChanges(h.ADD)),this.length}_createNewInstance(e){return new this.constructor(e)}_splice(e,t,s){const i=this._items,r=this.itemType;let n,h;if(!this._notifications&&this.hasEventListener("change")&&(this._notifications=[{listeners:this._chgListeners.slice(),items:this._items.slice(),changes:[]}],this._timer&&this._timer.remove(),this._timer=o((()=>this._dispatchChange()))),e<0&&(e+=this.length),t){if(h=i.splice(e,t),this.hasEventListener("before-remove")){const t=b.acquire();t.target=this,t.cancellable=!0;for(let s=0,r=h.length;s<r;s++)n=h[s],t.reset(n),this.emit("before-remove",t),t.defaultPrevented&&(h.splice(s,1),i.splice(e,0,n),e+=1,s-=1,r-=1);b.release(t)}if(this.length=this._items.length,this.hasEventListener("after-remove")){const e=b.acquire();e.target=this,e.cancellable=!1;const t=h.length;for(let s=0;s<t;s++)e.reset(h[s]),this.emit("after-remove",e);b.release(e)}}if(s&&s.length){if(r){const e=[];for(const t of s){const s=r.ensureType(t);null==s&&null!=t||e.push(s)}s=e}const t=this.hasEventListener("before-add"),n=this.hasEventListener("after-add"),h=e===this.length;if(t||n){const r=b.acquire();r.target=this,r.cancellable=!0;const o=b.acquire();o.target=this,o.cancellable=!1;for(const l of s)t?(r.reset(l),this.emit("before-add",r),r.defaultPrevented||(h?i.push(l):i.splice(e++,0,l),this._set("length",i.length),n&&(o.reset(l),this.emit("after-add",o)))):(h?i.push(l):i.splice(e++,0,l),this._set("length",i.length),o.reset(l),this.emit("after-add",o));b.release(o),b.release(r)}else{if(h)for(const e of s)i.push(e);else i.splice(e,0,...s);this._set("length",i.length)}}if((s&&s.length||h&&h.length)&&this._notifyChangeEvent(s,h),this.hasEventListener("after-splice")){const i=new p(this,s,h,e,t);this.emit("after-splice",i)}return h}_emitBeforeChanges(e){let t=!1;if(this.hasEventListener("before-changes")){const s=b.acquire();s.target=this,s.cancellable=!0,s.type=e,this.emit("before-changes",s),t=s.defaultPrevented,b.release(s)}return t}_emitAfterChanges(e){if(this.hasEventListener("after-changes")){const t=b.acquire();t.target=this,t.cancellable=!1,t.type=e,this.emit("after-changes",t),b.release(t)}this._observable.notify()}_notifyChangeEvent(e,t){this.hasEventListener("change")&&this._notifications&&this._notifications[this._notifications.length-1].changes.push({added:e,removed:t})}_dispatchChange(){if(this._timer&&(this._timer.remove(),this._timer=null),!this._notifications)return;const e=this._notifications;this._notifications=null;for(const s of e){const e=s.changes;A.clear(),O.clear(),M.clear();for(const{added:t,removed:s}of e){if(t)if(0===M.size&&0===O.size)for(const e of t)A.add(e);else for(const e of t)O.has(e)?(M.add(e),O.delete(e)):M.has(e)||A.add(e);if(s)if(0===M.size&&0===A.size)for(const e of s)O.add(e);else for(const e of s)A.has(e)?A.delete(e):(M.delete(e),O.add(e))}const i=t.acquire();A.forEach((e=>{i.push(e)}));const r=t.acquire();O.forEach((e=>{r.push(e)}));const n=this._items,h=s.items,o=t.acquire();if(M.forEach((e=>{h.indexOf(e)!==n.indexOf(e)&&o.push(e)})),s.listeners&&(i.length||r.length||o.length)){const e={target:this,added:i,removed:r,moved:o},t=s.listeners.length;for(let i=0;i<t;i++){const t=s.listeners[i];t.removed||t.callback.call(this,e)}}t.release(i),t.release(r),t.release(o)}A.clear(),O.clear(),M.clear()}};R.ofType=t=>{if(!t)return g;if(D.has(t))return D.get(t);let s=null;if("function"==typeof t)s=t.prototype.declaredClass;else if(t.base)s=t.base.prototype.declaredClass;else for(const e in t.typeMap){const i=t.typeMap[e].prototype.declaredClass;s?s+=` | ${i}`:s=i}let i=class extends g{};return e([_({Type:t,ensureType:"function"==typeof t?l(t):a(t)})],i.prototype,"itemType",void 0),i=e([m(`esri.core.Collection<${s}>`)],i),D.set(t,i),i},e([f()],R.prototype,"length",void 0),e([f()],R.prototype,"items",null),R=g=e([m("esri.core.Collection")],R);const V=R;export{V 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.28/esri/copyright.txt for details.
4
4
  */
5
- import"../has.js";import e from"../Logger.js";import{getOrCreateMapValue as n}from"../MapUtils.js";const r=e.getLogger("esri.core.accessorSupport.ensureTypes");function t(e){return null==e?e:new Date(e)}function o(e){return null==e?e:!!e}function u(e){return null==e?e:e.toString()}function a(e){return null==e?e:(e=parseFloat(e),isNaN(e)?0:e)}function s(e){return null==e?e:Math.round(parseFloat(e))}function i(e){return e&&e.constructor&&void 0!==e.constructor.__accessorMetadata__}function c(e,n){return null!=n&&e&&!(n instanceof e)}function l(e){return e&&"isCollection"in e}function f(e){return e&&e.Type?"function"==typeof e.Type?e.Type:e.Type.base:null}function p(e,n){if(!n||!n.constructor||!l(n.constructor))return y(e,n)?n:new e(n);const r=f(e.prototype.itemType),t=f(n.constructor.prototype.itemType);return r?t?r===t?n:r.prototype.isPrototypeOf(t.prototype)?new e(n):(y(e,n),n):new e(n):n}function y(e,n){return!!i(n)&&(r.error("Accessor#set","Assigning an instance of '"+(n.declaredClass||"unknown")+"' which is not a subclass of '"+g(e)+"'"),!0)}function v(e,n){return null==n?n:l(e)?p(e,n):c(e,n)?y(e,n)?n:new e(n):n}function g(e){return e&&e.prototype&&e.prototype.declaredClass||"unknown"}const h=new WeakMap;function m(e){switch(e){case Number:return a;case T:return s;case Boolean:return o;case String:return u;case Date:return t;default:return n(h,e,(()=>v.bind(null,e)))}}function d(e,n){const r=m(e);return 1===arguments.length?r:r(n)}function b(e,n,r){return 1===arguments.length?b.bind(null,e):n?Array.isArray(n)?n.map((n=>e(n,r))):[e(n,r)]:n}function w(e,n){return 1===arguments.length?b((n=>d(e,n))):b((n=>d(e,n)),n)}function A(e,n,r){return 0!==n&&Array.isArray(r)?r.map((r=>A(e,n-1,r))):e(r)}function $(e,n,r){if(2===arguments.length)return r=>$(e,n,r);if(!r)return r;r=A(e,n,r);let t=n,o=r;for(;t>0&&Array.isArray(o);)t--,o=o[0];if(void 0!==o)for(let u=0;u<t;u++)r=[r];return r}function j(e,n,r){return 2===arguments.length?$((n=>d(e,n)),n):$((n=>d(e,n)),n,r)}function k(e){return!!Array.isArray(e)&&!e.some((n=>{const r=typeof n;return!("string"===r||"number"===r||"function"===r&&e.length>1)}))}function M(e,n){if(2===arguments.length)return M(e).call(null,n);const t=new Set,o=e.filter((e=>"function"!=typeof e)),u=e.filter((e=>"function"==typeof e));for(const r of e)"string"!=typeof r&&"number"!=typeof r||t.add(r);let a=null,s=null;return(e,n)=>{if(null==e)return e;const i=typeof e,l="string"===i||"number"===i;return l&&(t.has(e)||u.some((e=>"string"===i&&e===String||"number"===i&&e===Number)))||"object"===i&&u.some((n=>!c(e,n)))?e:(l&&o.length?(a||(a=o.map((e=>"string"==typeof e?`'${e}'`:`${e}`)).join(", ")),r.error("Accessor#set",`'${e}' is not a valid value for this property, only the following values are valid: ${a}`)):"object"==typeof e&&u.length?(s||(s=u.map((e=>g(e))).join(", ")),r.error("Accessor#set",`'${e}' is not a valid value for this property, value must be one of ${s}`)):r.error("Accessor#set",`'${e}' is not a valid value for this property`),n&&(n.valid=!1),null)}}function S(e,n){if(2===arguments.length)return S(e).call(null,n);const t={},o=[],u=[];for(const r in e.typeMap){const n=e.typeMap[r];t[r]=d(n),o.push(g(n)),u.push(r)}const a=()=>`'${o.join("', '")}'`,s=()=>`'${u.join("', '")}'`,l="string"==typeof e.key?n=>n[e.key]:e.key;return n=>{if(e.base&&!c(e.base,n))return n;if(null==n)return n;const o=l(n)||e.defaultKeyValue,u=t[o];if(!u)return r.error("Accessor#set",`Invalid property value, value needs to be one of ${a()}, or a plain object that can autocast (having .type = ${s()})`),null;if(!c(e.typeMap[o],n))return n;if("string"==typeof e.key&&!i(n)){const r={};for(const t in n)t!==e.key&&(r[t]=n[t]);return u(r)}return u(n)}}class T{}const N={native:e=>({type:"native",value:e}),array:e=>({type:"array",value:e}),oneOf:e=>({type:"one-of",values:e})};function _(e){if(!e||!("type"in e))return!1;switch(e.type){case"native":case"array":case"one-of":return!0}return!1}function B(e){switch(e.type){case"native":return d(e.value);case"array":return b(B(e.value));case"one-of":return C(e);default:return null}}function C(e){let n=null;return(t,o)=>F(t,e)?t:(null==n&&(n=D(e)),r.error("Accessor#set",`Invalid property value, value needs to be of type ${n}`),o&&(o.valid=!1),null)}function D(e){switch(e.type){case"native":switch(e.value){case Number:return"number";case String:return"string";case Boolean:return"boolean";case T:return"integer";case Date:return"date";default:return g(e.value)}case"array":return`array of ${D(e.value)}`;case"one-of":{const n=e.values.map((e=>D(e)));return`one of ${n.slice(0,n.length-1)} or ${n[n.length-1]}`}}return"unknown"}function F(e,n){if(null==e)return!0;switch(n.type){case"native":switch(n.value){case Number:case T:return"number"==typeof e;case Boolean:return"boolean"==typeof e;case String:return"string"==typeof e}return e instanceof n.value;case"array":return!!Array.isArray(e)&&!e.some((e=>!F(e,n.value)));case"one-of":return n.values.some((n=>F(e,n)))}}export{T as Integer,w as ensureArray,b as ensureArrayTyped,o as ensureBoolean,v as ensureClass,t as ensureDate,s as ensureInteger,B as ensureLongFormType,j as ensureNArray,$ as ensureNArrayTyped,a as ensureNumber,M as ensureOneOf,S as ensureOneOfType,u as ensureString,d as ensureType,i as isClassedType,_ as isLongFormType,k as isOneOf,c as requiresType,N as types};
5
+ import"../has.js";import e from"../Logger.js";import{getOrCreateMapValue as n}from"../MapUtils.js";const r=e.getLogger("esri.core.accessorSupport.ensureTypes");function t(e){return null==e?e:new Date(e)}function o(e){return null==e?e:!!e}function u(e){return null==e?e:e.toString()}function a(e){return null==e?e:(e=parseFloat(e),isNaN(e)?0:e)}function s(e){return null==e?e:Math.round(parseFloat(e))}function i(e){return e&&e.constructor&&void 0!==e.constructor.__accessorMetadata__}function c(e,n){return null!=n&&e&&!(n instanceof e)}function l(e){return e&&"isCollection"in e}function f(e){return e&&e.Type?"function"==typeof e.Type?e.Type:e.Type.base:null}function p(e,n){if(!n||!n.constructor||!l(n.constructor))return y(e,n)?n:new e(n);const r=f(e.prototype.itemType),t=f(n.constructor.prototype.itemType);return r?t?r===t?n:r.prototype.isPrototypeOf(t.prototype)?new e(n):(y(e,n),n):new e(n):n}function y(e,n){return!!i(n)&&(r.error("Accessor#set","Assigning an instance of '"+(n.declaredClass||"unknown")+"' which is not a subclass of '"+g(e)+"'"),!0)}function v(e,n){return null==n?n:l(e)?p(e,n):c(e,n)?y(e,n)?n:new e(n):n}function g(e){return e&&e.prototype&&e.prototype.declaredClass||"unknown"}const h=new WeakMap;function m(e){switch(e){case Number:return a;case T:return s;case Boolean:return o;case String:return u;case Date:return t;default:return n(h,e,(()=>v.bind(null,e)))}}function d(e,n){const r=m(e);return 1===arguments.length?r:r(n)}function b(e,n,r){return 1===arguments.length?b.bind(null,e):n?Array.isArray(n)?n.map((n=>e(n,r))):[e(n,r)]:n}function w(e,n){return 1===arguments.length?b((n=>d(e,n))):b((n=>d(e,n)),n)}function A(e,n,r){return 0!==n&&Array.isArray(r)?r.map((r=>A(e,n-1,r))):e(r)}function $(e,n,r){if(2===arguments.length)return r=>$(e,n,r);if(!r)return r;r=A(e,n,r);let t=n,o=r;for(;t>0&&Array.isArray(o);)t--,o=o[0];if(void 0!==o)for(let u=0;u<t;u++)r=[r];return r}function j(e,n,r){return 2===arguments.length?$((n=>d(e,n)),n):$((n=>d(e,n)),n,r)}function k(e){return!!Array.isArray(e)&&!e.some((n=>{const r=typeof n;return!("string"===r||"number"===r||"function"===r&&e.length>1)}))}function M(e,n){if(2===arguments.length)return M(e).call(null,n);const t=new Set,o=e.filter((e=>"function"!=typeof e)),u=e.filter((e=>"function"==typeof e));for(const r of e)"string"!=typeof r&&"number"!=typeof r||t.add(r);let a=null,s=null;return(e,n)=>{if(null==e)return e;const i=typeof e,l="string"===i||"number"===i;return l&&(t.has(e)||u.some((e=>"string"===i&&e===String||"number"===i&&e===Number)))||"object"===i&&u.some((n=>!c(e,n)))?e:(l&&o.length?(a||(a=o.map((e=>"string"==typeof e?`'${e}'`:`${e}`)).join(", ")),r.error("Accessor#set",`'${e}' is not a valid value for this property, only the following values are valid: ${a}`)):"object"==typeof e&&u.length?(s||(s=u.map((e=>g(e))).join(", ")),r.error("Accessor#set",`'${e}' is not a valid value for this property, value must be one of ${s}`)):r.error("Accessor#set",`'${e}' is not a valid value for this property`),n&&(n.valid=!1),null)}}function S(e,n){if(2===arguments.length)return S(e).call(null,n);const t={},o=[],u=[];for(const r in e.typeMap){const n=e.typeMap[r];t[r]=d(n),o.push(g(n)),u.push(r)}const a=()=>`'${o.join("', '")}'`,s=()=>`'${u.join("', '")}'`,l="string"==typeof e.key?n=>n[e.key]:e.key;return n=>{if(e.base&&!c(e.base,n))return n;if(null==n)return n;const o=l(n)||e.defaultKeyValue,u=t[o];if(!u)return r.error("Accessor#set",`Invalid property value, value needs to be one of ${a()}, or a plain object that can autocast (having .type = ${s()})`),null;if(!c(e.typeMap[o],n))return n;if("string"==typeof e.key&&!i(n)){const r={};for(const t in n)t!==e.key&&(r[t]=n[t]);return u(r)}return u(n)}}class T{}const N={native:e=>({type:"native",value:e}),array:e=>({type:"array",value:e}),oneOf:e=>({type:"one-of",values:e})};function _(e){if(!e||!("type"in e))return!1;switch(e.type){case"native":case"array":case"one-of":return!0}return!1}function B(e){switch(e.type){case"native":return d(e.value);case"array":return b(B(e.value));case"one-of":return C(e);default:return null}}function C(e){let n=null;return(t,o)=>F(t,e)?t:(null==n&&(n=D(e)),r.error("Accessor#set",`Invalid property value, value needs to be of type ${n}`),o&&(o.valid=!1),null)}function D(e){switch(e.type){case"native":switch(e.value){case Number:return"number";case String:return"string";case Boolean:return"boolean";case T:return"integer";case Date:return"date";default:return g(e.value)}case"array":return`array of ${D(e.value)}`;case"one-of":{const n=e.values.map((e=>D(e)));return`one of ${n.slice(0,-1)} or ${n[n.length-1]}`}}return"unknown"}function F(e,n){if(null==e)return!0;switch(n.type){case"native":switch(n.value){case Number:case T:return"number"==typeof e;case Boolean:return"boolean"==typeof e;case String:return"string"==typeof e}return e instanceof n.value;case"array":return!!Array.isArray(e)&&!e.some((e=>!F(e,n.value)));case"one-of":return n.values.some((n=>F(e,n)))}}export{T as Integer,w as ensureArray,b as ensureArrayTyped,o as ensureBoolean,v as ensureClass,t as ensureDate,s as ensureInteger,B as ensureLongFormType,j as ensureNArray,$ as ensureNArrayTyped,a as ensureNumber,M as ensureOneOf,S as ensureOneOfType,u as ensureString,d as ensureType,i as isClassedType,_ as isLongFormType,k as isOneOf,c as requiresType,N as types};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import o from"../Error.js";import has from"../has.js";import"../Logger.js";import{get as r}from"./get.js";function t(o,e,s){if(o&&e)if("object"==typeof e)for(const r of Object.getOwnPropertyNames(e))t(o,r,e[r]);else{if(e.includes(".")){const n=e.split("."),i=n.splice(n.length-1,1)[0];return void t(r(o,n),i,s)}const i=o.__accessor__;null!=i&&n(e,i),o[e]=s}}function n(r,t){if(has("esri-unknown-property-errors")&&!e(r,t))throw new o("set:unknown-property",s(r,t))}function e(o,r){return null!=r.metadatas[o]}function s(o,r){return"setting unknown property '"+o+"' on instance of "+r.host.declaredClass}export{t as set};
5
+ import o from"../Error.js";import has from"../has.js";import"../Logger.js";import{get as r}from"./get.js";function t(o,e,s){if(o&&e)if("object"==typeof e)for(const r of Object.getOwnPropertyNames(e))t(o,r,e[r]);else{if(e.includes(".")){const n=e.split("."),i=n.splice(-1,1)[0];return void t(r(o,n),i,s)}const i=o.__accessor__;null!=i&&n(e,i),o[e]=s}}function n(r,t){if(has("esri-unknown-property-errors")&&!e(r,t))throw new o("set:unknown-property",s(r,t))}function e(o,r){return null!=r.metadatas[o]}function s(o,r){return"setting unknown property '"+o+"' on instance of "+r.host.declaredClass}export{t as set};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Error.js";import o from"../core/Logger.js";import{MultiOriginJSONMixin as r}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{Integer as l}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as a}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{n as p}from"../chunks/vec3.js";import{f as c}from"../chunks/vec3f64.js";import m from"../geometry/Extent.js";import y from"./Layer.js";import{APIKeyMixin as d}from"./mixins/APIKeyMixin.js";import{ArcGISService as f}from"./mixins/ArcGISService.js";import{OperationalLayer as v}from"./mixins/OperationalLayer.js";import{PortalLayer as h}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as b}from"./mixins/ScaleRangeLayer.js";import{SceneService as g}from"./mixins/SceneService.js";import{sanitizeUrl as S}from"./support/arcgisLayerUrl.js";import{legendEnabled as V,url as x,popupEnabled as j}from"./support/commonProperties.js";import w from"./support/Field.js";import I from"./voxel/VoxelSection.js";import T from"./voxel/VoxelSimpleShading.js";import D from"./voxel/VoxelVariable.js";import F from"./voxel/VoxelVariableStyle.js";import N from"./voxel/VoxelVolume.js";import L from"./voxel/VoxelVolumeIndex.js";import P from"./voxel/VoxelVolumeStyle.js";import{createPopupTemplate as E}from"../support/popupUtils.js";const O="esri.layers.VoxelLayer",R=o.getLogger(O);let A=class extends(g(f(v(h(b(r(d(y)))))))){constructor(e){super(e),this.serviceRoot="",this.operationalLayerType="Voxel",this.legendEnabled=!0,this.title=null,this.sections=null,this.currentVariableId=0,this.volumeStyles=null,this.renderMode="volume",this.variableStyles=null,this.enableSlices=!0,this.enableSections=!0,this.enableDynamicSections=!0,this.enableIsosurfaces=!0,this.shading=new T,this.opacity=1,this.variables=new t,this.volumes=new t,this.index=null,this.minScale=0,this.maxScale=0,this.type="voxel",this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.fullExtent=null,this.popupEnabled=!0,this.popupTemplate=null,this.test=null,this.volumeStyles=new(t.ofType(P)),this.variableStyles=new(t.ofType(F)),this.sections=new(t.ofType(I)),e?.constantUpscaling&&(this.test={constantUpscaling:!0})}set url(e){this._set("url",S(e,R))}load(e){const t=null!=e?e.signal:null,i=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(s).then((()=>this._fetchService(t))).then((()=>this.serviceRoot=this.url));return this.addResolvingPromise(i),Promise.resolve(this)}read(e,t){super.read(e,t);for(const i of this.volumes)i.spatialReference=this.spatialReference}readVersion(e,t){return super.parseVersionString(e)}validateLayer(e){if(e.layerType&&e.layerType!==this.operationalLayerType)throw new i("voxel-layer:layer-type-not-supported","VoxelLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor)||this.version.major<3)throw new i("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"});if(this.version.major>3)throw new i("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"})}readFullExtent(e,t,i){if(null!=e&&"object"==typeof e){const o=m.fromJSON(e,i);if(0===o.zmin&&0===o.zmax&&Array.isArray(t.volumes)){const e=N.fromJSON(t.volumes[0]);if(e.isValid&&"xyt"!==e.volumeType){const t=e.dimensions[2];if(t.isRegular){let e=t.regularSpacing.offset,i=t.regularSpacing.offset+t.regularSpacing.scale*(t.size-1);if(e>i){const t=e;e=i,i=t}o.zmin=e,o.zmax=i}}}return o}return null}get voxelFields(){const e=[new w({name:"Voxel.ServiceValue",alias:"Value",domain:null,editable:!1,length:128,type:"string"}),new w({name:"Voxel.ServiceVariableLabel",alias:"Variable",domain:null,editable:!1,length:128,type:"string"}),new w({name:"Voxel.Position",alias:"Voxel Position",domain:null,editable:!1,length:128,type:"string"})],t=this.getVolume(null);if(null!=t){if("xyzt"===t.volumeType||"xyt"===t.volumeType){const t=new w({name:"Voxel.ServiceLocalTime",alias:"Local Time",domain:null,editable:!1,length:128,type:"string"});e.push(t);const i=new w({name:"Voxel.ServiceNativeTime",alias:"Native Time",domain:null,editable:!1,length:128,type:"string"});e.push(i)}if("xyt"!==t.volumeType){const t=new w({name:"Voxel.ServiceDepth",alias:"Depth",domain:null,editable:!1,length:128,type:"string"});e.push(t)}}return e}get defaultPopupTemplate(){return this.createPopupTemplate()}createPopupTemplate(e){const t=this.voxelFields,i=this.title;return E({fields:t,title:i},e)}getConfiguration(){const e={layerType:this.operationalLayerType,version:this.version.versionString,name:this.title,spatialReference:this.spatialReference,fullExtent:this.fullExtent,volumes:this.volumes.toJSON(),variables:this.variables.toJSON(),index:this.index?.toJSON(),sections:this.getSections(),style:{volumeStyles:this.getVolumeStyles(),currentVariableId:this.currentVariableId,renderMode:this.renderMode,variableStyles:this.getVariableStyles(),enableSections:this.enableSections,enableDynamicSections:this.enableDynamicSections,enableIsosurfaces:this.enableIsosurfaces,enableSlices:this.enableSlices,shading:this.shading}};return e.index&&this.index?.isValid()?JSON.stringify(e):""}getVariableStyle(e){let t=-1;t=null!=e?e:this.currentVariableId;if(!this.variableStyles||-1===t)return null;const i=this.variableStyles.findIndex((e=>e.variableId===t));return i<0?null:this.variableStyles.at(i)}getVariable(e){let t=-1;if(t=null!=e?e:this.currentVariableId,!this.variables||-1===t)return null;const i=this.variables.findIndex((e=>e.id===t));return i<0?null:this.variables.at(i)}getVolume(e){const t=this.getVariable(e);return null!=t?this.volumes.find((({id:e})=>e===t.volumeId)):null}getVolumeStyle(e){const t=this.getVariable(e);return null!=t?this.volumeStyles.find((({volumeId:e})=>e===t.volumeId)):null}getColorForContinuousDataValue(e,t,i){const o=this.getVariable(e);if(null==o||"continuous"!==o.renderingFormat?.continuity)return null;if(!this.variableStyles)return null;const r=this.variableStyles.findIndex((t=>t.variableId===e));if(r<0)return null;const s=this.variableStyles.at(r);return s?.transferFunction?s.transferFunction.getColorForContinuousDataValue(t,i):null}getSections(){const e=[];for(const t of this.sections)e.push(new I({enabled:t.enabled,href:t.href,id:t.id,label:t.label,normal:t.normal,point:t.point,sizeInPixel:t.sizeInPixel,slices:t.slices,timeId:t.timeId,variableId:t.variableId}));return e}getVariableStyles(){const e=[];for(const t of this.variableStyles){const i=this._getVariable(t);if(null!=i){const o=t.clone();o.isosurfaces.length>4&&(o.isosurfaces=o.isosurfaces.slice(0,3),R.error("A maximum of 4 isosurfaces are supported for Voxel Layers."));for(const e of o.isosurfaces)if(!e.colorLocked){const t=this.getColorForContinuousDataValue(o.variableId,e.value,!1);null===t||t.equals(e.color)||(e.color=t)}if("continuous"===i.renderingFormat.continuity)(null===o.transferFunction||o.transferFunction.colorStops.length<2)&&R.error(`VoxelVariableStyle for variable ${i.id} is invalid. At least 2 color stops are required in the transferFunction for continuous Voxel Layer variables.`),null!==o.transferFunction&&(Array.isArray(o.transferFunction.stretchRange)&&2===o.transferFunction.stretchRange.length||(R.error(`VoxelVariableStyle for variable ${i.id} is invalid. The stretchRange of the transferFunction for continuous Voxel Layer variables must be of the form [minimumDataValue, maximumDataValue].`),o.transferFunction.stretchRange=[0,1],o.transferFunction.colorStops.removeAll()));else if("discrete"===i.renderingFormat.continuity)if(0===t.uniqueValues.length)R.error(`VoxelVariableStyle for variable ${i.id} is invalid. Unique values are required for discrete Voxel Layer variables.`);else for(const e of t.uniqueValues)null!==e.label&&void 0!==e.label||null===e.value||void 0===e.value||(e.label=e.value.toString());e.push(o)}else R.error(`VoxelVariable ID=${t.variableId} doesn't exist, VoxelVariableStyle for this VoxelVariable will be ignored.`)}return e}getVolumeStyles(){const e=[];for(const t of this.volumeStyles){const i=this._getVolumeFromVolumeId(t.volumeId);if(null!=i){const o=t.clone();for(const e of o.slices)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");for(const e of o.dynamicSections)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");e.push(o)}else R.error(`VoxelVolume ID=${t.volumeId} doesn't exist, VoxelVolumeStyle for this VoxelVolume will be ignored.`)}return e}_getVariable(e){const t=e.variableId;for(const i of this.variables)if(i.id===t)return i;return null}_getVolumeFromVolumeId(e){for(const t of this.volumes)if(t.id===e)return t;return null}_isPlaneValid(e,t,i){if(!e.point)return!1;if(!Array.isArray(e.point)||3!==e.point.length)return!1;if(!e.normal)return!1;if(!Array.isArray(e.normal)||3!==e.normal.length)return!1;const o=c(e.normal[0],e.normal[1],e.normal[2]);p(o,o);const r=1e-6;return!(Math.abs(o[0])+Math.abs(o[1])+Math.abs(o[2])<r)&&(e.normal[0]=o[0],e.normal[1]=o[1],e.normal[2]=o[2],!0)}};e([n({type:["Voxel"]})],A.prototype,"operationalLayerType",void 0),e([n(V)],A.prototype,"legendEnabled",void 0),e([n({json:{write:!0}})],A.prototype,"title",void 0),e([n(x)],A.prototype,"url",null),e([n({type:t.ofType(I),json:{origins:{"web-scene":{name:"layerDefinition.sections",write:!0}}}})],A.prototype,"sections",void 0),e([n({type:l,json:{origins:{"web-scene":{name:"layerDefinition.style.currentVariableId",write:{enabled:!0,isRequired:!0,ignoreOrigin:!0}},service:{name:"style.currentVariableId"}}}})],A.prototype,"currentVariableId",void 0),e([n({type:t.ofType(P),json:{origins:{"web-scene":{name:"layerDefinition.style.volumeStyles",write:!0},service:{name:"style.volumeStyles"}}}})],A.prototype,"volumeStyles",void 0),e([n({type:["volume","surfaces"],json:{origins:{"web-scene":{name:"layerDefinition.style.renderMode",write:!0},service:{name:"style.renderMode"}}}})],A.prototype,"renderMode",void 0),e([n({type:t.ofType(F),json:{origins:{"web-scene":{name:"layerDefinition.style.variableStyles",write:!0},service:{name:"style.variableStyles"}}}})],A.prototype,"variableStyles",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSlices",write:!0},service:{name:"style.enableSlices"}}}})],A.prototype,"enableSlices",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSections",write:!0},service:{name:"style.enableSections"}}}})],A.prototype,"enableSections",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableDynamicSections",write:!0},service:{name:"style.enableDynamicSections"}}}})],A.prototype,"enableDynamicSections",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableIsosurfaces",write:!0},service:{name:"style.enableIsosurfaces"}}}})],A.prototype,"enableIsosurfaces",void 0),e([n({type:T,json:{origins:{"web-scene":{name:"layerDefinition.style.shading",write:!0},service:{name:"style.shading"}}}})],A.prototype,"shading",void 0),e([n({type:["show","hide"]})],A.prototype,"listMode",void 0),e([n({type:Number,range:{min:0,max:1},nonNullable:!0,json:{read:!1,write:!1,origins:{"web-scene":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],A.prototype,"opacity",void 0),e([n({type:t.ofType(D)})],A.prototype,"variables",void 0),e([n({type:t.ofType(N)})],A.prototype,"volumes",void 0),e([n({type:L})],A.prototype,"index",void 0),e([n({type:Number,json:{name:"layerDefinition.minScale",read:!1,write:!1,origins:{service:{read:!1,write:!1}}}})],A.prototype,"minScale",void 0),e([n({type:Number,json:{name:"layerDefinition.maxScale",read:!1,write:!1,origins:{service:{read:!1,write:!1}}}})],A.prototype,"maxScale",void 0),e([n({json:{read:!1},readOnly:!0})],A.prototype,"type",void 0),e([n({readOnly:!0,json:{name:"serviceVersion"}})],A.prototype,"version",void 0),e([a("service","version")],A.prototype,"readVersion",null),e([n({type:m})],A.prototype,"fullExtent",void 0),e([a("service","fullExtent",["fullExtent"])],A.prototype,"readFullExtent",null),e([n({readOnly:!0,clonable:!1,json:{read:!1}})],A.prototype,"voxelFields",null),e([n(j)],A.prototype,"popupEnabled",void 0),e([n({readOnly:!0})],A.prototype,"defaultPopupTemplate",null),A=e([u(O)],A);const M=A;export{M as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Error.js";import r from"../core/Logger.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{Integer as l}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as a}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{n as p}from"../chunks/vec3.js";import{f as c}from"../chunks/vec3f64.js";import m from"../geometry/Extent.js";import y from"./Layer.js";import{APIKeyMixin as d}from"./mixins/APIKeyMixin.js";import{ArcGISService as f}from"./mixins/ArcGISService.js";import{OperationalLayer as v}from"./mixins/OperationalLayer.js";import{PortalLayer as h}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as b}from"./mixins/ScaleRangeLayer.js";import{SceneService as g}from"./mixins/SceneService.js";import{sanitizeUrl as S}from"./support/arcgisLayerUrl.js";import{legendEnabled as V,url as x,popupEnabled as j}from"./support/commonProperties.js";import w from"./support/Field.js";import I from"./voxel/VoxelSection.js";import T from"./voxel/VoxelSimpleShading.js";import D from"./voxel/VoxelVariable.js";import F from"./voxel/VoxelVariableStyle.js";import N from"./voxel/VoxelVolume.js";import L from"./voxel/VoxelVolumeIndex.js";import P from"./voxel/VoxelVolumeStyle.js";import{createPopupTemplate as A}from"../support/popupUtils.js";const E="esri.layers.VoxelLayer",O=r.getLogger(E);let R=class extends(g(f(v(h(b(o(d(y)))))))){constructor(e){super(e),this.serviceRoot="",this.operationalLayerType="Voxel",this.legendEnabled=!0,this.title=null,this.sections=null,this.currentVariableId=0,this.volumeStyles=null,this.renderMode="volume",this.variableStyles=null,this.enableSlices=!0,this.enableSections=!0,this.enableDynamicSections=!0,this.enableIsosurfaces=!0,this.shading=new T,this.opacity=1,this.variables=new t,this.volumes=new t,this.index=null,this.minScale=0,this.maxScale=0,this.type="voxel",this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.fullExtent=null,this.popupEnabled=!0,this.popupTemplate=null,this.test=null,this.volumeStyles=new(t.ofType(P)),this.variableStyles=new(t.ofType(F)),this.sections=new(t.ofType(I))}normalizeCtorArgs(e){return e?.constantUpscaling&&(this.test={constantUpscaling:!0},delete e.constantUpscaling),e}set url(e){this._set("url",S(e,O))}load(e){const t=null!=e?e.signal:null,i=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(s).then((()=>this._fetchService(t))).then((()=>this.serviceRoot=this.url));return this.addResolvingPromise(i),Promise.resolve(this)}read(e,t){super.read(e,t);for(const i of this.volumes)i.spatialReference=this.spatialReference}readVersion(e,t){return super.parseVersionString(e)}validateLayer(e){if(e.layerType&&e.layerType!==this.operationalLayerType)throw new i("voxel-layer:layer-type-not-supported","VoxelLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor)||this.version.major<3)throw new i("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"});if(this.version.major>3)throw new i("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"})}readFullExtent(e,t,i){if(null!=e&&"object"==typeof e){const r=m.fromJSON(e,i);if(0===r.zmin&&0===r.zmax&&Array.isArray(t.volumes)){const e=N.fromJSON(t.volumes[0]);if(e.isValid&&"xyt"!==e.volumeType){const t=e.dimensions[2];if(t.isRegular){let e=t.regularSpacing.offset,i=t.regularSpacing.offset+t.regularSpacing.scale*(t.size-1);if(e>i){const t=e;e=i,i=t}r.zmin=e,r.zmax=i}}}return r}return null}get voxelFields(){const e=[new w({name:"Voxel.ServiceValue",alias:"Value",domain:null,editable:!1,length:128,type:"string"}),new w({name:"Voxel.ServiceVariableLabel",alias:"Variable",domain:null,editable:!1,length:128,type:"string"}),new w({name:"Voxel.Position",alias:"Voxel Position",domain:null,editable:!1,length:128,type:"string"})],t=this.getVolume(null);if(null!=t){if("xyzt"===t.volumeType||"xyt"===t.volumeType){const t=new w({name:"Voxel.ServiceLocalTime",alias:"Local Time",domain:null,editable:!1,length:128,type:"string"});e.push(t);const i=new w({name:"Voxel.ServiceNativeTime",alias:"Native Time",domain:null,editable:!1,length:128,type:"string"});e.push(i)}if("xyt"!==t.volumeType){const t=new w({name:"Voxel.ServiceDepth",alias:"Depth",domain:null,editable:!1,length:128,type:"string"});e.push(t)}}return e}get defaultPopupTemplate(){return this.createPopupTemplate()}createPopupTemplate(e){const t=this.voxelFields,i=this.title;return A({fields:t,title:i},e)}getConfiguration(){const e={layerType:this.operationalLayerType,version:this.version.versionString,name:this.title,spatialReference:this.spatialReference,fullExtent:this.fullExtent,volumes:this.volumes.toJSON(),variables:this.variables.toJSON(),index:this.index?.toJSON(),sections:this.getSections(),style:{volumeStyles:this.getVolumeStyles(),currentVariableId:this.currentVariableId,renderMode:this.renderMode,variableStyles:this.getVariableStyles(),enableSections:this.enableSections,enableDynamicSections:this.enableDynamicSections,enableIsosurfaces:this.enableIsosurfaces,enableSlices:this.enableSlices,shading:this.shading}};return e.index&&this.index?.isValid()?JSON.stringify(e):""}getVariableStyle(e){let t=-1;t=null!=e?e:this.currentVariableId;if(!this.variableStyles||-1===t)return null;const i=this.variableStyles.findIndex((e=>e.variableId===t));return i<0?null:this.variableStyles.at(i)}getVariable(e){let t=-1;if(t=null!=e?e:this.currentVariableId,!this.variables||-1===t)return null;const i=this.variables.findIndex((e=>e.id===t));return i<0?null:this.variables.at(i)}getVolume(e){const t=this.getVariable(e);return null!=t?this.volumes.find((({id:e})=>e===t.volumeId)):null}getVolumeStyle(e){const t=this.getVariable(e);return null!=t?this.volumeStyles.find((({volumeId:e})=>e===t.volumeId)):null}getColorForContinuousDataValue(e,t,i){const r=this.getVariable(e);if(null==r||"continuous"!==r.renderingFormat?.continuity)return null;if(!this.variableStyles)return null;const o=this.variableStyles.findIndex((t=>t.variableId===e));if(o<0)return null;const s=this.variableStyles.at(o);return s?.transferFunction?s.transferFunction.getColorForContinuousDataValue(t,i):null}getSections(){const e=[];for(const t of this.sections)e.push(new I({enabled:t.enabled,href:t.href,id:t.id,label:t.label,normal:t.normal,point:t.point,sizeInPixel:t.sizeInPixel,slices:t.slices,timeId:t.timeId,variableId:t.variableId}));return e}getVariableStyles(){const e=[];for(const t of this.variableStyles){const i=this._getVariable(t);if(null!=i){const r=t.clone();r.isosurfaces.length>4&&(r.isosurfaces=r.isosurfaces.slice(0,3),O.error("A maximum of 4 isosurfaces are supported for Voxel Layers."));for(const e of r.isosurfaces)if(!e.colorLocked){const t=this.getColorForContinuousDataValue(r.variableId,e.value,!1);null===t||t.equals(e.color)||(e.color=t)}if("continuous"===i.renderingFormat.continuity)(null===r.transferFunction||r.transferFunction.colorStops.length<2)&&O.error(`VoxelVariableStyle for variable ${i.id} is invalid. At least 2 color stops are required in the transferFunction for continuous Voxel Layer variables.`),null!==r.transferFunction&&(Array.isArray(r.transferFunction.stretchRange)&&2===r.transferFunction.stretchRange.length||(O.error(`VoxelVariableStyle for variable ${i.id} is invalid. The stretchRange of the transferFunction for continuous Voxel Layer variables must be of the form [minimumDataValue, maximumDataValue].`),r.transferFunction.stretchRange=[0,1],r.transferFunction.colorStops.removeAll()));else if("discrete"===i.renderingFormat.continuity)if(0===t.uniqueValues.length)O.error(`VoxelVariableStyle for variable ${i.id} is invalid. Unique values are required for discrete Voxel Layer variables.`);else for(const e of t.uniqueValues)null!==e.label&&void 0!==e.label||null===e.value||void 0===e.value||(e.label=e.value.toString());e.push(r)}else O.error(`VoxelVariable ID=${t.variableId} doesn't exist, VoxelVariableStyle for this VoxelVariable will be ignored.`)}return e}getVolumeStyles(){const e=[];for(const t of this.volumeStyles){const i=this._getVolumeFromVolumeId(t.volumeId);if(null!=i){const r=t.clone();for(const e of r.slices)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");for(const e of r.dynamicSections)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");e.push(r)}else O.error(`VoxelVolume ID=${t.volumeId} doesn't exist, VoxelVolumeStyle for this VoxelVolume will be ignored.`)}return e}_getVariable(e){const t=e.variableId;for(const i of this.variables)if(i.id===t)return i;return null}_getVolumeFromVolumeId(e){for(const t of this.volumes)if(t.id===e)return t;return null}_isPlaneValid(e,t,i){if(!e.point)return!1;if(!Array.isArray(e.point)||3!==e.point.length)return!1;if(!e.normal)return!1;if(!Array.isArray(e.normal)||3!==e.normal.length)return!1;const r=c(e.normal[0],e.normal[1],e.normal[2]);p(r,r);const o=1e-6;return!(Math.abs(r[0])+Math.abs(r[1])+Math.abs(r[2])<o)&&(e.normal[0]=r[0],e.normal[1]=r[1],e.normal[2]=r[2],!0)}};e([n({type:["Voxel"]})],R.prototype,"operationalLayerType",void 0),e([n(V)],R.prototype,"legendEnabled",void 0),e([n({json:{write:!0}})],R.prototype,"title",void 0),e([n(x)],R.prototype,"url",null),e([n({type:t.ofType(I),json:{origins:{"web-scene":{name:"layerDefinition.sections",write:!0}}}})],R.prototype,"sections",void 0),e([n({type:l,json:{origins:{"web-scene":{name:"layerDefinition.style.currentVariableId",write:{enabled:!0,isRequired:!0,ignoreOrigin:!0}},service:{name:"style.currentVariableId"}}}})],R.prototype,"currentVariableId",void 0),e([n({type:t.ofType(P),json:{origins:{"web-scene":{name:"layerDefinition.style.volumeStyles",write:!0},service:{name:"style.volumeStyles"}}}})],R.prototype,"volumeStyles",void 0),e([n({type:["volume","surfaces"],json:{origins:{"web-scene":{name:"layerDefinition.style.renderMode",write:!0},service:{name:"style.renderMode"}}}})],R.prototype,"renderMode",void 0),e([n({type:t.ofType(F),json:{origins:{"web-scene":{name:"layerDefinition.style.variableStyles",write:!0},service:{name:"style.variableStyles"}}}})],R.prototype,"variableStyles",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSlices",write:!0},service:{name:"style.enableSlices"}}}})],R.prototype,"enableSlices",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSections",write:!0},service:{name:"style.enableSections"}}}})],R.prototype,"enableSections",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableDynamicSections",write:!0},service:{name:"style.enableDynamicSections"}}}})],R.prototype,"enableDynamicSections",void 0),e([n({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableIsosurfaces",write:!0},service:{name:"style.enableIsosurfaces"}}}})],R.prototype,"enableIsosurfaces",void 0),e([n({type:T,json:{origins:{"web-scene":{name:"layerDefinition.style.shading",write:!0},service:{name:"style.shading"}}}})],R.prototype,"shading",void 0),e([n({type:["show","hide"]})],R.prototype,"listMode",void 0),e([n({type:Number,range:{min:0,max:1},nonNullable:!0,json:{read:!1,write:!1,origins:{"web-scene":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],R.prototype,"opacity",void 0),e([n({type:t.ofType(D)})],R.prototype,"variables",void 0),e([n({type:t.ofType(N)})],R.prototype,"volumes",void 0),e([n({type:L})],R.prototype,"index",void 0),e([n({type:Number,json:{name:"layerDefinition.minScale",read:!1,write:!1,origins:{service:{read:!1,write:!1}}}})],R.prototype,"minScale",void 0),e([n({type:Number,json:{name:"layerDefinition.maxScale",read:!1,write:!1,origins:{service:{read:!1,write:!1}}}})],R.prototype,"maxScale",void 0),e([n({json:{read:!1},readOnly:!0})],R.prototype,"type",void 0),e([n({readOnly:!0,json:{name:"serviceVersion"}})],R.prototype,"version",void 0),e([a("service","version")],R.prototype,"readVersion",null),e([n({type:m})],R.prototype,"fullExtent",void 0),e([a("service","fullExtent",["fullExtent"])],R.prototype,"readFullExtent",null),e([n({readOnly:!0,clonable:!1,json:{read:!1}})],R.prototype,"voxelFields",null),e([n(j)],R.prototype,"popupEnabled",void 0),e([n({readOnly:!0})],R.prototype,"defaultPopupTemplate",null),R=e([u(E)],R);const M=R;export{M 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.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../Graphic.js";import t from"../request.js";import has from"../core/has.js";import i from"../core/Logger.js";import{removeMaybe as s}from"../core/maybe.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{i as n}from"../chunks/vec3.js";import{c as o}from"../chunks/vec3f64.js";import{renderSRFromViewSR as l}from"../geometry/support/coordinateSystem.js";import{PointIndex as h,PlaneIndex as d}from"../geometry/support/frustum.js";import{WasmCullMode as _,VoxelRequestType as u,UpdateFlags as c,ContainerType as m}from"../libs/vxl/enums.js";import{loadVoxelWASM as g}from"../libs/vxl/VxlModule.js";import{ViewingMode as f}from"../views/ViewingMode.js";import{VoxelTarget as p}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as x}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as y}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as v}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{newIntersectorResult as b}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as w,StoreResults as T}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as R}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as L}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as E}from"../views/webgl/contextUtils.js";import{CompareFunction as C,Face as F,StencilOperation as V}from"../views/webgl/enums.js";const S=i.getLogger("esri.layers.VoxelWasmPerSceneView");var P;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(P||(P={}));const U=L.VOXEL;class W{constructor(e){this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._readyWatchHandle=null,this._qualityWatchHandle=null,this._stationaryWatchHandle=null,this._timeExtentWatchHandle=null,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._shaderOutput=v.Color,this.renderSlots=[U],this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.type=w.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[],this._view=e,this._initialize()}get canRender(){return!!this._vxl&&"local"===this._view.viewingMode}_dbg(e,t){this._dbgFlags.has(e)&&(e===P.Error?S.error(t):S.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this._view._stage&&(this._dbg(P.Lifetime,"--removeRenderPlugin--"),this._view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}_initialize(){this._dbg(P.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this._readyWatchHandle=a((()=>this._view.ready),(e=>{e&&"local"===this._view.viewingMode?(this._dbg(P.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this._view._stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(P.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),{initial:!0}),this._qualityWatchHandle=a((()=>this._view?.qualityProfile),(e=>{this._dbg(P.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),{initial:!0}),this._timeExtentWatchHandle=a((()=>this._view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this._view?.timeExtent);this._dbg(P.Rendering,"sceneView timeExtent changed to useTime="+e.useTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.useTime),this._renderPluginContext.requestRender()}}),{initial:!0}),this._stationaryWatchHandle=a((()=>this._view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))}initializeRenderContext(e){this._dbg(P.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===E.WEBGL2?(this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)):this._dbg(P.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(P.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(P.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const i=!!this._rctx,s=!!this._renderTargetToRestore;if(!i||!s)return 0;const r=this._renderTargetToRestore.fbo.depthStencilTexture;return r?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(r,e,!0),1):(this._dbg(P.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,i){if(!this._rctx)return void this._dbg(P.Error,"modifyAllocation callback has no rendering context!");const s=e;1===i?this._rctx.instanceCounter.increment(s,t):this._rctx.instanceCounter.decrement(s,t)}_setBlendState(e,t,i,s){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,i),this._rctx.setBlendEquation(s)):this._dbg(P.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(P.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,i){this._rctx?(this._rctx.setDepthFunction(i),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(C.ALWAYS,0,255),this._rctx.setStencilOpSeparate(F.FRONT,V.KEEP,V.INCR,V.KEEP),this._rctx.setStencilOpSeparate(F.BACK,V.KEEP,V.DECR,V.KEEP)):this._dbg(P.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case _.None:this._rctx.setFaceCullingEnabled(!1);break;case _.Back:this._rctx.setCullFace(F.BACK),this._rctx.setFaceCullingEnabled(!0);break;case _.Front:this._rctx.setCullFace(F.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(P.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,i,s){this._rctx?this._rctx.setViewport(e,t,i,s):this._dbg(P.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const i=this._vxl.estimate_memory_usage(t);i>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(i))}}))}_syncRequestsResponses(){this._layers.forEach(((e,i)=>{const s=[];e.responses.forEach(((t,r)=>{s.push(r),this._dbg(P.RequestResponse,"responding for requestID:"+r+" size:"+t.size),this._vxl.respond(i,r,t),t.requestType!==u.TreeIndex&&t.requestType!==u.Section||(e.needMemoryUsageUpdate=!0)}));const a=e.responses;for(const t of s)a.delete(t);const n=this._vxl.get_new_requests(i),o=e.abortController.signal;for(const l in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const i=n[l],s={responseType:"array-buffer",signal:o};this._dbg(P.RequestResponse,"making requestID:"+l+" url:"+i.url),t(i.url,s).then((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(P.RequestResponse,"have response for requestID:"+l);let s=0;if(t.data.byteLength>0){s=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,s,t.data.byteLength),i=new Uint8Array(t.data);for(let s=0;s<t.data.byteLength;++s)e[s]=i[s]}a.set(+l,{responseType:i.responseType,ptr:s,size:t.data.byteLength,success:!0,requestType:i.requestType})})).catch((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),r(t)||(this._dbg(P.Error,`requestID:${l} failed, error=${t.toString()}`),a.set(+l,{responseType:i.responseType,ptr:0,size:0,success:!1,requestType:i.requestType}))}))}}))}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const i=this._vxl.get_layer_epoch_times(s,e.layer.currentVariableId);for(let e=0;e<i.length;++e)t.push(i[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(s))})),t}setEnabled(e,t){this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(s,t),i.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const i={mask:c.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,i,!0)}setCurrentVariable(e,t){const i={mask:c.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,i,!0)}setRenderMode(e,t){const i={mask:c.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,i,!0)}setVerticalExaggerationAndOffset(e,t,i,s){const r={mask:c.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:i,verticalOffset:s}};return this._doMaskedUIUpdate(e,r,!0)}setVariableStyles(e,t){const i={mask:c.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setVolumeStyles(e,t){const i={mask:c.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setEnableDynamicSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.DynamicSections};return this._doMaskedUIUpdate(e,i,!0)}setEnableIsosurfaces(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.Isosurfaces};return this._doMaskedUIUpdate(e,i,!0)}setEnableSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.StaticSections};return this._doMaskedUIUpdate(e,i,!0)}setAnalysisSlice(e,t,i,s){const r={mask:c.AnalysisSlice,analysisSlice:{point:i,normal:s,enabled:t}};return this._doMaskedUIUpdate(e,r,!0)}_doMaskedUIUpdate(e,t,i){if(!this._vxl)return!1;let s=!1;return this._layers.forEach(((i,r)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(s=1===this._vxl.handle_masked_ui_update(r,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),s&&i&&this._renderPluginContext.requestRender(),s}_addTriangleToWasmBuffer(e,t,i,s,r){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_addNormalToWasmBuffer(e,t,i){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,i=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(this._vxl.HEAPF32.buffer,i,3*e),r=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,r,e),n=this._frustum.points[h.NEAR_BOTTOM_LEFT],o=this._frustum.points[h.NEAR_BOTTOM_RIGHT],l=this._frustum.points[h.NEAR_TOP_RIGHT],_=this._frustum.points[h.NEAR_TOP_LEFT],u=this._frustum.points[h.FAR_BOTTOM_LEFT],c=this._frustum.points[h.FAR_BOTTOM_RIGHT],m=this._frustum.points[h.FAR_TOP_RIGHT],g=this._frustum.points[h.FAR_TOP_LEFT];let f=0,p=0;const x=this._frustum.planes[d.NEAR];f=this._addTriangleToWasmBuffer(s,f,l,o,n),p=this._addNormalToWasmBuffer(a,p,x),f=this._addTriangleToWasmBuffer(s,f,n,_,l),p=this._addNormalToWasmBuffer(a,p,x);const y=this._frustum.planes[d.FAR];f=this._addTriangleToWasmBuffer(s,f,u,c,m),p=this._addNormalToWasmBuffer(a,p,y),f=this._addTriangleToWasmBuffer(s,f,m,g,u),p=this._addNormalToWasmBuffer(a,p,y);const v=this._frustum.planes[d.TOP];f=this._addTriangleToWasmBuffer(s,f,m,l,_),p=this._addNormalToWasmBuffer(a,p,v),f=this._addTriangleToWasmBuffer(s,f,_,g,m),p=this._addNormalToWasmBuffer(a,p,v);const b=this._frustum.planes[d.BOTTOM];f=this._addTriangleToWasmBuffer(s,f,n,o,c),p=this._addNormalToWasmBuffer(a,p,b),f=this._addTriangleToWasmBuffer(s,f,c,u,n),p=this._addNormalToWasmBuffer(a,p,b);const w=this._frustum.planes[d.LEFT];f=this._addTriangleToWasmBuffer(s,f,_,n,u),p=this._addNormalToWasmBuffer(a,p,w),f=this._addTriangleToWasmBuffer(s,f,u,g,_),p=this._addNormalToWasmBuffer(a,p,w);const T=this._frustum.planes[d.RIGHT];f=this._addTriangleToWasmBuffer(s,f,l,m,c),p=this._addNormalToWasmBuffer(a,p,T),f=this._addTriangleToWasmBuffer(s,f,c,o,l),p=this._addNormalToWasmBuffer(a,p,T),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(i,3*e,r,e,255,0,0,64),this._vxl._free(i),this._vxl._free(r),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=y.create(f.Local,l(!1,this._view.spatialReference))),null===this._frustum&&(this._frustum=new x(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,i)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(i),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},i=new Promise(((e,i)=>{t.resolveCallback=e,t.rejectCallback=i}));return this._newLayers.push(t),i}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex((t=>e.uid===t.layerView.uid));t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const i=this._newLayers.length;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}let t=-1;this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){t=s,i.abortController.abort(),this._vxl.remove_layer(t);const r=this.layerUid.indexOf(e.layer.uid);-1!==r&&this.layerUid.splice(r,1)}})),t>=0&&this._layers.delete(t);const i=this._layers.size;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,i=Number.MAX_VALUE,s=!1;return null!=e&&(e.isAllTime?s=!0:(null!=e.start&&(s=!0,t=e.start.getTime()/1e3),null!=e.end&&(s=!0,i=e.end.getTime()/1e3))),{startTime:t,endTime:i,useTime:s}}_addVoxelLayer(e){const t=e.layer;let i=-1;const s=t.getConfiguration();if(s.length<1)return-1;const r={str:s,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(r))return-1;const a=this._getTimeArgs(this._view?.timeExtent),n=this._view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(i=this._vxl.add_layer(t.serviceRoot,r.ptr,r.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this._view.qualityProfile)),r.isReusable||this._vxl._free(r.ptr),i>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const s=new AbortController;if(this._layers.set(i,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:s,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let i="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let i="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&S.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),i}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,i=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(i[0],i[1],i[2],t[0],t[1],t[2]);const s=this._vxl.cull();this._dbg(P.RequestResponse,"missingResourceCount="+s),this._moreToLoad=s>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==this._shaderOutput||e.bindParameters.slot!==U)return;for(const i of this._newLayers){const e=this._addVoxelLayer(i.layerView);-1===e?i.rejectCallback(-1):i.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(P.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this._view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this._view._stage.renderer.isFeatureEnabled(R.HighResolutionVoxel),e.bindParameters.lighting.mainLight.direction[0],e.bindParameters.lighting.mainLight.direction[1],e.bindParameters.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach((e=>{e.needMemoryUsageUpdate=!0}))),0===t.x&&0===t.y||this._dbg(P.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(P.Lifetime,"--destroy--"),this._removeRenderPlugin(),this._readyWatchHandle=s(this._readyWatchHandle),this._qualityWatchHandle=s(this._qualityWatchHandle),this._timeExtentWatchHandle=s(this._timeExtentWatchHandle),this._stationaryWatchHandle=s(this._stationaryWatchHandle),this._vxl&&(this._layers.forEach((e=>{e.abortController.abort()})),this._wasmMemBlocks.forEach((e=>{0!==e&&this._vxl._free(e)})),this._vxl.uninitialize_voxel_wasm(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=g(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(P.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this._view?.timeExtent),i=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),s=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),r=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),o=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),l=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),_=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(i,s,r,a,n,o,l,h,t.startTime,t.endTime,t.useTime,d,_),this._renderPluginContext&&this._renderPluginContext.requestRender()})).catch((()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(P.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=i.viewport[3]-t;if(e<0||e>i.viewport[2]||t<0||t>i.viewport[3])return this._dbg(P.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${s.toFixed(0)}]]`),null;this._beforeDraw();const r=i.viewForward,a=i.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],r[0],r[1],r[2]),this.updateWasmCamera(i),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,s);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,i,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const r=Math.round(e),a=Math.round(t);if(r<0||r>i.viewport[2]||a<0||a>i.viewport[3])return this._dbg(P.Error,`[js] pickObject: outOfRange, screenXY=[${r}, ${a}], vp=[${i.viewport.toString()}]`),null;this._beforeDraw();const n=i.viewForward,o=i.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(i),this._vxl.begin_frame();let l=null;if(0===s.length)l=this._vxl.pick_object(r,a,0,0);else{const e={str:JSON.stringify({layerIds:s}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(r,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),l}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,i,s,r){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(r[0]<0||r[0]>e.camera.viewport[2]||r[1]<0||r[1]>e.camera.viewport[3])return this._dbg(P.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${r[0].toFixed(0)}, ${r[1].toFixed(0)}]`),null;const a=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&a.push(t.layerView.wasmLayerId)}));const l=this.pickObject(r[0],r[1],e.camera,a);if(null==l||-1===l.layerId)return;const h=this._layers.get(l.layerId);if(h){const t=h.layerView.layer.uid,r=l.distanceToCamera/n(i,s),a=o();a[0]=l.worldX,a[1]=l.worldY,a[2]=l.worldZ;const d={};if(null!=l.continuousValue&&null!=l.continuousValueUnits?d["Voxel.ServiceValue"]=`${l.continuousValue.toLocaleString()} ${l.continuousValueUnits}`:null!=l.uniqueValueLabel&&null!=l.uniqueValue?d["Voxel.ServiceValue"]=`${l.uniqueValueLabel} (${l.uniqueValue})`:null!=l.uniqueValue&&(d["Voxel.ServiceValue"]=`${l.uniqueValue}`),d["Voxel.ServiceVariableLabel"]=l.variableLabel,d["Voxel.Position"]=l.voxelSpacePosition,null!=l.epochTime&&null!=l.nativeTime&&null!=l.nativeTimeUnits){const e=new Date(l.epochTime);d["Voxel.ServiceLocalTime"]=e.toString(),d["Voxel.ServiceNativeTime"]=`${l.nativeTime.toLocaleString()} ${l.nativeTimeUnits}`}null!=l.depth&&null!=l.depthUnits&&(d["Voxel.ServiceDepth"]=`${l.depth.toLocaleString()} ${l.depthUnits}`);const _=l.faceNormal;d["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const u=e=>{const i=new p(a,t,(()=>this._createVoxelGraphic(h.layerView.layer,d)));e.set(this.type,i,r,_)},c=e.results,m=e.options.store===T.ALL;if((null==c.min.dist||r<c.min.dist)&&u(c.min),(null==c.max.dist||r>c.max.dist)&&u(c.max),m){const t=b(e.ray);u(t),e.results.all.push(t)}}}_createVoxelGraphic(t,i){return new e({layer:t,sourceLayer:t,attributes:i})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,i){this._vxl&&this._vxl.set_upscaling_limits(e,t,i)}}export{W as default};
5
+ import e from"../Graphic.js";import t from"../request.js";import has from"../core/has.js";import i from"../core/Logger.js";import{removeMaybe as s}from"../core/maybe.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{i as n}from"../chunks/vec3.js";import{c as o}from"../chunks/vec3f64.js";import{renderSRFromViewSR as l}from"../geometry/support/coordinateSystem.js";import{PointIndex as h,PlaneIndex as d}from"../geometry/support/frustum.js";import{WasmCullMode as _,VoxelRequestType as u,UpdateFlags as c,ContainerType as m}from"../libs/vxl/enums.js";import{loadVoxelWASM as g}from"../libs/vxl/VxlModule.js";import{ViewingMode as f}from"../views/ViewingMode.js";import{VoxelTarget as p}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as x}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as y}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as v}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{newIntersectorResult as b}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as w,StoreResults as T}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as R}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as L}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as E}from"../views/webgl/contextUtils.js";import{CompareFunction as C,Face as F,StencilOperation as V}from"../views/webgl/enums.js";const S=i.getLogger("esri.layers.VoxelWasmPerSceneView");var P;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(P||(P={}));const U=L.VOXEL;class W{constructor(e){this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._readyWatchHandle=null,this._qualityWatchHandle=null,this._stationaryWatchHandle=null,this._timeExtentWatchHandle=null,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._shaderOutput=v.Color,this.renderSlots=[U],this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.type=w.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[],this._view=e,this._initialize()}canRender(){return!!this._vxl&&"local"===this._view.viewingMode}requiresOutput(){return!1}_dbg(e,t){this._dbgFlags.has(e)&&(e===P.Error?S.error(t):S.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this._view._stage&&(this._dbg(P.Lifetime,"--removeRenderPlugin--"),this._view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}_initialize(){this._dbg(P.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this._readyWatchHandle=a((()=>this._view.ready),(e=>{e&&"local"===this._view.viewingMode?(this._dbg(P.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this._view._stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(P.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),{initial:!0}),this._qualityWatchHandle=a((()=>this._view?.qualityProfile),(e=>{this._dbg(P.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),{initial:!0}),this._timeExtentWatchHandle=a((()=>this._view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this._view?.timeExtent);this._dbg(P.Rendering,"sceneView timeExtent changed to useTime="+e.useTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.useTime),this._renderPluginContext.requestRender()}}),{initial:!0}),this._stationaryWatchHandle=a((()=>this._view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))}initializeRenderContext(e){this._dbg(P.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===E.WEBGL2?(this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)):this._dbg(P.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(P.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(P.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const i=!!this._rctx,s=!!this._renderTargetToRestore;if(!i||!s)return 0;const r=this._renderTargetToRestore.fbo.depthStencilTexture;return r?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(r,e,!0),1):(this._dbg(P.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,i){if(!this._rctx)return void this._dbg(P.Error,"modifyAllocation callback has no rendering context!");const s=e;1===i?this._rctx.instanceCounter.increment(s,t):this._rctx.instanceCounter.decrement(s,t)}_setBlendState(e,t,i,s){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,i),this._rctx.setBlendEquation(s)):this._dbg(P.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(P.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,i){this._rctx?(this._rctx.setDepthFunction(i),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(C.ALWAYS,0,255),this._rctx.setStencilOpSeparate(F.FRONT,V.KEEP,V.INCR,V.KEEP),this._rctx.setStencilOpSeparate(F.BACK,V.KEEP,V.DECR,V.KEEP)):this._dbg(P.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case _.None:this._rctx.setFaceCullingEnabled(!1);break;case _.Back:this._rctx.setCullFace(F.BACK),this._rctx.setFaceCullingEnabled(!0);break;case _.Front:this._rctx.setCullFace(F.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(P.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,i,s){this._rctx?this._rctx.setViewport(e,t,i,s):this._dbg(P.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const i=this._vxl.estimate_memory_usage(t);i>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(i))}}))}_syncRequestsResponses(){this._layers.forEach(((e,i)=>{const s=[];e.responses.forEach(((t,r)=>{s.push(r),this._dbg(P.RequestResponse,"responding for requestID:"+r+" size:"+t.size),this._vxl.respond(i,r,t),t.requestType!==u.TreeIndex&&t.requestType!==u.Section||(e.needMemoryUsageUpdate=!0)}));const a=e.responses;for(const t of s)a.delete(t);const n=this._vxl.get_new_requests(i),o=e.abortController.signal;for(const l in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const i=n[l],s={responseType:"array-buffer",signal:o};this._dbg(P.RequestResponse,"making requestID:"+l+" url:"+i.url),t(i.url,s).then((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(P.RequestResponse,"have response for requestID:"+l);let s=0;if(t.data.byteLength>0){s=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,s,t.data.byteLength),i=new Uint8Array(t.data);for(let s=0;s<t.data.byteLength;++s)e[s]=i[s]}a.set(+l,{responseType:i.responseType,ptr:s,size:t.data.byteLength,success:!0,requestType:i.requestType})})).catch((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),r(t)||(this._dbg(P.Error,`requestID:${l} failed, error=${t.toString()}`),a.set(+l,{responseType:i.responseType,ptr:0,size:0,success:!1,requestType:i.requestType}))}))}}))}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const i=this._vxl.get_layer_epoch_times(s,e.layer.currentVariableId);for(let e=0;e<i.length;++e)t.push(i[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(s))})),t}setEnabled(e,t){this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(s,t),i.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const i={mask:c.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,i,!0)}setCurrentVariable(e,t){const i={mask:c.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,i,!0)}setRenderMode(e,t){const i={mask:c.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,i,!0)}setVerticalExaggerationAndOffset(e,t,i,s){const r={mask:c.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:i,verticalOffset:s}};return this._doMaskedUIUpdate(e,r,!0)}setVariableStyles(e,t){const i={mask:c.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setVolumeStyles(e,t){const i={mask:c.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setEnableDynamicSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.DynamicSections};return this._doMaskedUIUpdate(e,i,!0)}setEnableIsosurfaces(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.Isosurfaces};return this._doMaskedUIUpdate(e,i,!0)}setEnableSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.StaticSections};return this._doMaskedUIUpdate(e,i,!0)}setAnalysisSlice(e,t,i,s){const r={mask:c.AnalysisSlice,analysisSlice:{point:i,normal:s,enabled:t}};return this._doMaskedUIUpdate(e,r,!0)}_doMaskedUIUpdate(e,t,i){if(!this._vxl)return!1;let s=!1;return this._layers.forEach(((i,r)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(s=1===this._vxl.handle_masked_ui_update(r,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),s&&i&&this._renderPluginContext.requestRender(),s}_addTriangleToWasmBuffer(e,t,i,s,r){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_addNormalToWasmBuffer(e,t,i){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,i=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(this._vxl.HEAPF32.buffer,i,3*e),r=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,r,e),n=this._frustum.points[h.NEAR_BOTTOM_LEFT],o=this._frustum.points[h.NEAR_BOTTOM_RIGHT],l=this._frustum.points[h.NEAR_TOP_RIGHT],_=this._frustum.points[h.NEAR_TOP_LEFT],u=this._frustum.points[h.FAR_BOTTOM_LEFT],c=this._frustum.points[h.FAR_BOTTOM_RIGHT],m=this._frustum.points[h.FAR_TOP_RIGHT],g=this._frustum.points[h.FAR_TOP_LEFT];let f=0,p=0;const x=this._frustum.planes[d.NEAR];f=this._addTriangleToWasmBuffer(s,f,l,o,n),p=this._addNormalToWasmBuffer(a,p,x),f=this._addTriangleToWasmBuffer(s,f,n,_,l),p=this._addNormalToWasmBuffer(a,p,x);const y=this._frustum.planes[d.FAR];f=this._addTriangleToWasmBuffer(s,f,u,c,m),p=this._addNormalToWasmBuffer(a,p,y),f=this._addTriangleToWasmBuffer(s,f,m,g,u),p=this._addNormalToWasmBuffer(a,p,y);const v=this._frustum.planes[d.TOP];f=this._addTriangleToWasmBuffer(s,f,m,l,_),p=this._addNormalToWasmBuffer(a,p,v),f=this._addTriangleToWasmBuffer(s,f,_,g,m),p=this._addNormalToWasmBuffer(a,p,v);const b=this._frustum.planes[d.BOTTOM];f=this._addTriangleToWasmBuffer(s,f,n,o,c),p=this._addNormalToWasmBuffer(a,p,b),f=this._addTriangleToWasmBuffer(s,f,c,u,n),p=this._addNormalToWasmBuffer(a,p,b);const w=this._frustum.planes[d.LEFT];f=this._addTriangleToWasmBuffer(s,f,_,n,u),p=this._addNormalToWasmBuffer(a,p,w),f=this._addTriangleToWasmBuffer(s,f,u,g,_),p=this._addNormalToWasmBuffer(a,p,w);const T=this._frustum.planes[d.RIGHT];f=this._addTriangleToWasmBuffer(s,f,l,m,c),p=this._addNormalToWasmBuffer(a,p,T),f=this._addTriangleToWasmBuffer(s,f,c,o,l),p=this._addNormalToWasmBuffer(a,p,T),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(i,3*e,r,e,255,0,0,64),this._vxl._free(i),this._vxl._free(r),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=y.create(f.Local,l(!1,this._view.spatialReference))),null===this._frustum&&(this._frustum=new x(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,i)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(i),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},i=new Promise(((e,i)=>{t.resolveCallback=e,t.rejectCallback=i}));return this._newLayers.push(t),i}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex((t=>e.uid===t.layerView.uid));t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const i=this._newLayers.length;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}let t=-1;this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){t=s,i.abortController.abort(),this._vxl.remove_layer(t);const r=this.layerUid.indexOf(e.layer.uid);-1!==r&&this.layerUid.splice(r,1)}})),t>=0&&this._layers.delete(t);const i=this._layers.size;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,i=Number.MAX_VALUE,s=!1;return null!=e&&(e.isAllTime?s=!0:(null!=e.start&&(s=!0,t=e.start.getTime()/1e3),null!=e.end&&(s=!0,i=e.end.getTime()/1e3))),{startTime:t,endTime:i,useTime:s}}_addVoxelLayer(e){const t=e.layer;let i=-1;const s=t.getConfiguration();if(s.length<1)return-1;const r={str:s,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(r))return-1;const a=this._getTimeArgs(this._view?.timeExtent),n=this._view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(i=this._vxl.add_layer(t.serviceRoot,r.ptr,r.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this._view.qualityProfile)),r.isReusable||this._vxl._free(r.ptr),i>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const s=new AbortController;if(this._layers.set(i,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:s,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let i="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let i="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&S.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),i}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,i=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(i[0],i[1],i[2],t[0],t[1],t[2]);const s=this._vxl.cull();this._dbg(P.RequestResponse,"missingResourceCount="+s),this._moreToLoad=s>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==this._shaderOutput||e.bindParameters.slot!==U)return;for(const i of this._newLayers){const e=this._addVoxelLayer(i.layerView);-1===e?i.rejectCallback(-1):i.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(P.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this._view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this._view._stage.renderer.isFeatureEnabled(R.HighResolutionVoxel),e.bindParameters.lighting.mainLight.direction[0],e.bindParameters.lighting.mainLight.direction[1],e.bindParameters.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach((e=>{e.needMemoryUsageUpdate=!0}))),0===t.x&&0===t.y||this._dbg(P.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(P.Lifetime,"--destroy--"),this._removeRenderPlugin(),this._readyWatchHandle=s(this._readyWatchHandle),this._qualityWatchHandle=s(this._qualityWatchHandle),this._timeExtentWatchHandle=s(this._timeExtentWatchHandle),this._stationaryWatchHandle=s(this._stationaryWatchHandle),this._vxl&&(this._layers.forEach((e=>{e.abortController.abort()})),this._wasmMemBlocks.forEach((e=>{0!==e&&this._vxl._free(e)})),this._vxl.uninitialize_voxel_wasm(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=g(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(P.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this._view?.timeExtent),i=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),s=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),r=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),o=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),l=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),_=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(i,s,r,a,n,o,l,h,t.startTime,t.endTime,t.useTime,d,_),this._renderPluginContext&&this._renderPluginContext.requestRender()})).catch((()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(P.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=i.viewport[3]-t;if(e<0||e>i.viewport[2]||t<0||t>i.viewport[3])return this._dbg(P.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${s.toFixed(0)}]]`),null;this._beforeDraw();const r=i.viewForward,a=i.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],r[0],r[1],r[2]),this.updateWasmCamera(i),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,s);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,i,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const r=Math.round(e),a=Math.round(t);if(r<0||r>i.viewport[2]||a<0||a>i.viewport[3])return this._dbg(P.Error,`[js] pickObject: outOfRange, screenXY=[${r}, ${a}], vp=[${i.viewport.toString()}]`),null;this._beforeDraw();const n=i.viewForward,o=i.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(i),this._vxl.begin_frame();let l=null;if(0===s.length)l=this._vxl.pick_object(r,a,0,0);else{const e={str:JSON.stringify({layerIds:s}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(r,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),l}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,i,s,r){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(r[0]<0||r[0]>e.camera.viewport[2]||r[1]<0||r[1]>e.camera.viewport[3])return this._dbg(P.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${r[0].toFixed(0)}, ${r[1].toFixed(0)}]`),null;const a=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&a.push(t.layerView.wasmLayerId)}));const l=this.pickObject(r[0],r[1],e.camera,a);if(null==l||-1===l.layerId)return;const h=this._layers.get(l.layerId);if(h){const t=h.layerView.layer.uid,r=l.distanceToCamera/n(i,s),a=o();a[0]=l.worldX,a[1]=l.worldY,a[2]=l.worldZ;const d={};if(null!=l.continuousValue&&null!=l.continuousValueUnits?d["Voxel.ServiceValue"]=`${l.continuousValue.toLocaleString()} ${l.continuousValueUnits}`:null!=l.uniqueValueLabel&&null!=l.uniqueValue?d["Voxel.ServiceValue"]=`${l.uniqueValueLabel} (${l.uniqueValue})`:null!=l.uniqueValue&&(d["Voxel.ServiceValue"]=`${l.uniqueValue}`),d["Voxel.ServiceVariableLabel"]=l.variableLabel,d["Voxel.Position"]=l.voxelSpacePosition,null!=l.epochTime&&null!=l.nativeTime&&null!=l.nativeTimeUnits){const e=new Date(l.epochTime);d["Voxel.ServiceLocalTime"]=e.toString(),d["Voxel.ServiceNativeTime"]=`${l.nativeTime.toLocaleString()} ${l.nativeTimeUnits}`}null!=l.depth&&null!=l.depthUnits&&(d["Voxel.ServiceDepth"]=`${l.depth.toLocaleString()} ${l.depthUnits}`);const _=l.faceNormal;d["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const u=e=>{const i=new p(a,t,(()=>this._createVoxelGraphic(h.layerView.layer,d)));e.set(this.type,i,r,_)},c=e.results,m=e.options.store===T.ALL;if((null==c.min.dist||r<c.min.dist)&&u(c.min),(null==c.max.dist||r>c.max.dist)&&u(c.max),m){const t=b(e.ray);u(t),e.results.all.push(t)}}}_createVoxelGraphic(t,i){return new e({layer:t,sourceLayer:t,attributes:i})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,i){this._vxl&&this._vxl.set_upscaling_limits(e,t,i)}}export{W 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.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import s from"../../core/Logger.js";import{createResolver as o}from"../../core/promiseUtils.js";import{dataComponents as i}from"../../core/urlUtils.js";import{normalizeCentralMeridian as n}from"../../geometry/support/normalizeUtils.js";import{isEditBusLayer as d,emitApplyEditsEvent as l}from"../mixins/EditBusLayer.js";import{getMimeTypeFormatId as u,getFilenameFormatId as p}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as c,getEffectiveLayerCapabilities as h}from"../support/layerUtils.js";function m(e){return e&&null!=e.applyEdits}function y(e){return"object"==typeof e&&null!=e&&"objectId"in e&&!!e.objectId}function f(e){return e.every(y)}function g(e){return"object"==typeof e&&null!=e&&"globalId"in e&&!!e.globalId}function b(e){return e.every(g)}async function F(e,t,a,s={}){let i;if(d(e)&&e.url)i=l(e.url,e.layerId,s.gdbVersion,"original-and-current-features"===s.returnServiceEditsOption);else{i=o(),i.promise.then((t=>{(t.addedFeatures.length||t.updatedFeatures.length||t.deletedFeatures.length||t.addedAttachments.length||t.updatedAttachments.length||t.deletedAttachments.length)&&e.emit("edits",t)}));const t={result:i.promise};e.emit("apply-edits",t)}try{const{results:o,edits:n}=await w(e,t,a,s),d=e=>e.filter((e=>!e.error)).map(r),l={edits:n,addedFeatures:d(o.addFeatureResults),updatedFeatures:d(o.updateFeatureResults),deletedFeatures:d(o.deleteFeatureResults),addedAttachments:d(o.addAttachmentResults),updatedAttachments:d(o.updateAttachmentResults),deletedAttachments:d(o.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:o.editMoment?new Date(o.editMoment):null};return o.editedFeatureResults?.length&&(l.editedFeatures=o.editedFeatureResults),i.resolve(l),o}catch(n){throw i.reject(n),n}}async function w(e,t,r,s){if(await e.load(),!m(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!c(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:o,options:i}=await A(e,r,s);return o.addFeatures?.length||o.updateFeatures?.length||o.deleteFeatures?.length||o.addAttachments?.length||o.updateAttachments?.length||o.deleteAttachments?.length?{edits:o,results:await t.applyEdits(o,i)}:{edits:o,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function A(e,r,o){const i=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),n=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments),d=null!=e.infoFor3D;if(!r||!i&&!n)throw new a(`${e.type}-layer:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");const l=h(e);if(!l.data.isVersioned&&o?.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!l.editing.supportsRollbackOnFailure&&o?.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");if(!l.editing.supportsGlobalId&&o?.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!l.editing.supportsGlobalId&&n)throw new a(`${e.type}-layer:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if(!o?.globalIdUsed&&n)throw new a(`${e.type}-layer:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");const u={...o};if(null!=u.rollbackOnFailureEnabled||l.editing.supportsRollbackOnFailure||(u.rollbackOnFailureEnabled=!0),u.rollbackOnFailureEnabled||"original-and-current-features"!==u.returnServiceEditsOption||(!1===u.rollbackOnFailureEnabled&&s.getLogger("esri.layers.graphics.editingSupport").warn(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true, but 'rollBackOnFailure' was set to false. 'rollBackOnFailure' has been overwrritten and set to true."),u.rollbackOnFailureEnabled=!0),!l.editing.supportsReturnServiceEditsInSourceSpatialReference&&u.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(u.returnServiceEditsInSourceSR&&"original-and-current-features"!==u.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsInSourceSR' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const p={...r};if(p.addFeatures=r&&t.isCollection(r.addFeatures)?r.addFeatures.toArray():p.addFeatures||[],p.updateFeatures=r&&t.isCollection(r.updateFeatures)?r.updateFeatures.toArray():p.updateFeatures||[],p.deleteFeatures=r&&t.isCollection(r.deleteFeatures)?r.deleteFeatures.toArray():p.deleteFeatures||[],p.addFeatures.length&&!l.operations.supportsAdd)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support adding features.");if(p.updateFeatures.length&&!l.operations.supportsUpdate)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support updating features.");if(p.deleteFeatures.length&&!l.operations.supportsDelete)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support deleting features.");p.addAttachments=p.addAttachments||[],p.updateAttachments=p.updateAttachments||[],p.deleteAttachments=p.deleteAttachments||[],p.addFeatures=p.addFeatures.map(j),p.updateFeatures=p.updateFeatures.map(j),p.addAssetFeatures=[];const c=o?.globalIdUsed||d;p.addFeatures.forEach((t=>E(t,e,c))),p.updateFeatures.forEach((t=>$(t,e,c))),p.deleteFeatures.forEach((t=>S(t,e,c))),p.addAttachments.forEach((t=>R(t,e))),p.updateAttachments.forEach((t=>R(t,e))),d&&await U(p,e);return{edits:await O(p),options:u}}function v(e,t,r){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,`Feature should have '${t.globalIdField}' when 'globalIdUsed' is true`);if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"`'globalId' of the feature should be passed when 'globalIdUsed' is true")}if("geometry"in e&&null!=e.geometry){if(e.geometry.hasZ&&!1===t.capabilities?.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities?.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function I(e,t){if("geometry"in e&&"mesh"===e.geometry?.type){const{geometry:r}=e;if(r.vertexSpace.isGeoreferenced)throw new a(`${t.type}-layer:georeferenced-mesh-unsupported`,"Uploading georeferenced meshes to a layer is not supported.")}}function E(e,t,a){v(e,t,a),I(e,t)}function S(e,t,a){v(e,t,a)}function $(e,t,r){v(e,t,r),I(e,t);const s=h(t);if("geometry"in e&&null!=e.geometry&&!s?.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function R(e,t){const{feature:r,attachment:s}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!s.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!s.data&&!s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(s.data instanceof File&&!!s.data.name)&&!s.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities?.editing.supportsUploadWithItemId&&s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof s.data){const e=i(s.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}async function O(e){const t=e.addFeatures??[],a=e.updateFeatures??[],r=t.concat(a).map((e=>e.geometry)),s=await n(r),o=t.length,i=a.length;return s.slice(0,o).forEach(((e,a)=>t[a].geometry=e)),s.slice(o,o+i).forEach(((e,t)=>a[t].geometry=e)),e}function j(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function U(e,t){if(null==t.infoFor3D)return;const{infoFor3D:r}=t,s=u("model/gltf-binary",r.supportedFormats)??p("glb",r.supportedFormats);if(!(!!s&&r.editFormats.includes(s)))throw new a(`${t.type}-layer:binary-gltf-asset-not-supported`,"3DObjectFeatureLayer requires binary glTF (.glb) support for updating mesh geometry.");e.addAssetFeatures??=[];const{addAssetFeatures:o}=e;for(const a of e.addFeatures??[])L(a)&&o.push(a);for(const a of e.updateFeatures??[])L(a)&&o.push(a)}function L(e){return"mesh"===e?.geometry?.type}function k(e,t,r,s){if(!m(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!t.uploadAssets)throw new a(`${e.type}-layer:no-asset-upload-support`,"Layer source does not support uploadAssets capability",{layer:e});return t.uploadAssets(r,s)}export{F as applyEdits,b as isFeatureIdentifierArrayWithGlobalId,f as isFeatureIdentifierArrayWithObjectId,g as isFeatureIdentifierWithGlobalId,y as isFeatureIdentifierWithObjectId,k as uploadAssets};
5
+ import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import s from"../../core/Logger.js";import{createResolver as o}from"../../core/promiseUtils.js";import{dataComponents as n}from"../../core/urlUtils.js";import{normalizeCentralMeridian as i}from"../../geometry/support/normalizeUtils.js";import{isEditBusLayer as d,emitApplyEditsEvent as l}from"../mixins/EditBusLayer.js";import{getMimeTypeFormatId as u,getFilenameFormatId as p}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as c,getEffectiveLayerCapabilities as h}from"../support/layerUtils.js";function m(e){return e&&null!=e.applyEdits}function y(e){return"object"==typeof e&&null!=e&&"objectId"in e&&!!e.objectId}function f(e){return e.every(y)}function g(e){return"object"==typeof e&&null!=e&&"globalId"in e&&!!e.globalId}function b(e){return e.every(g)}async function F(e,t,a,s={}){let n;if(d(e)&&e.url)n=l(e.url,e.layerId,s.gdbVersion,"original-and-current-features"===s.returnServiceEditsOption);else{n=o(),n.promise.then((t=>{(t.addedFeatures.length||t.updatedFeatures.length||t.deletedFeatures.length||t.addedAttachments.length||t.updatedAttachments.length||t.deletedAttachments.length)&&e.emit("edits",t)}));const t={result:n.promise};e.emit("apply-edits",t)}try{const{results:o,edits:i}=await w(e,t,a,s),d=e=>e.filter((e=>!e.error)).map(r),l={edits:i,addedFeatures:d(o.addFeatureResults),updatedFeatures:d(o.updateFeatureResults),deletedFeatures:d(o.deleteFeatureResults),addedAttachments:d(o.addAttachmentResults),updatedAttachments:d(o.updateAttachmentResults),deletedAttachments:d(o.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:o.editMoment?new Date(o.editMoment):null};return o.editedFeatureResults?.length&&(l.editedFeatures=o.editedFeatureResults),n.resolve(l),o}catch(i){throw n.reject(i),i}}async function w(e,t,r,s){if(await e.load(),!m(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!c(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:o,options:n}=await A(e,r,s);return o.addFeatures?.length||o.updateFeatures?.length||o.deleteFeatures?.length||o.addAttachments?.length||o.updateAttachments?.length||o.deleteAttachments?.length?{edits:o,results:await t.applyEdits(o,n)}:{edits:o,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function A(e,r,o){const n=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),i=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments),d=null!=e.infoFor3D;if(!r||!n&&!i)throw new a(`${e.type}-layer:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");const l=h(e);if(!l.data.isVersioned&&o?.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!l.editing.supportsRollbackOnFailure&&o?.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");if(!l.editing.supportsGlobalId&&o?.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!l.editing.supportsGlobalId&&i)throw new a(`${e.type}-layer:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if(!o?.globalIdUsed&&i)throw new a(`${e.type}-layer:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");const u={...o};if(null!=u.rollbackOnFailureEnabled||l.editing.supportsRollbackOnFailure||(u.rollbackOnFailureEnabled=!0),u.rollbackOnFailureEnabled||"original-and-current-features"!==u.returnServiceEditsOption||(!1===u.rollbackOnFailureEnabled&&s.getLogger("esri.layers.graphics.editingSupport").warn(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true, but 'rollBackOnFailure' was set to false. 'rollBackOnFailure' has been overwrritten and set to true."),u.rollbackOnFailureEnabled=!0),!l.editing.supportsReturnServiceEditsInSourceSpatialReference&&u.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(u.returnServiceEditsInSourceSR&&"original-and-current-features"!==u.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsInSourceSR' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const p={...r};if(p.addFeatures=r&&t.isCollection(r.addFeatures)?r.addFeatures.toArray():p.addFeatures||[],p.updateFeatures=r&&t.isCollection(r.updateFeatures)?r.updateFeatures.toArray():p.updateFeatures||[],p.deleteFeatures=r&&t.isCollection(r.deleteFeatures)?r.deleteFeatures.toArray():p.deleteFeatures||[],p.addFeatures.length&&!l.operations.supportsAdd)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support adding features.");if(p.updateFeatures.length&&!l.operations.supportsUpdate)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support updating features.");if(p.deleteFeatures.length&&!l.operations.supportsDelete)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support deleting features.");p.addAttachments=p.addAttachments||[],p.updateAttachments=p.updateAttachments||[],p.deleteAttachments=p.deleteAttachments||[],p.addFeatures=p.addFeatures.map(j),p.updateFeatures=p.updateFeatures.map(j),p.addAssetFeatures=[];const c=o?.globalIdUsed||d;p.addFeatures.forEach((t=>E(t,e,c))),p.updateFeatures.forEach((t=>$(t,e,c))),p.deleteFeatures.forEach((t=>S(t,e,c))),p.addAttachments.forEach((t=>R(t,e))),p.updateAttachments.forEach((t=>R(t,e))),d&&await U(p,e);return{edits:await O(p),options:u}}function v(e,t,r){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,`Feature should have '${t.globalIdField}' when 'globalIdUsed' is true`);if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"`'globalId' of the feature should be passed when 'globalIdUsed' is true")}if("geometry"in e&&null!=e.geometry){if(e.geometry.hasZ&&!1===t.capabilities?.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities?.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function I(e,t){if("geometry"in e&&"mesh"===e.geometry?.type&&null!=t.infoFor3D){const{geometry:r}=e;if(r.vertexSpace.isGeoreferenced)throw new a(`${t.type}-layer:georeferenced-mesh-unsupported`,"Uploading georeferenced meshes to a layer is not supported.")}}function E(e,t,a){v(e,t,a),I(e,t)}function S(e,t,a){v(e,t,a)}function $(e,t,r){v(e,t,r),I(e,t);const s=h(t);if("geometry"in e&&null!=e.geometry&&!s?.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function R(e,t){const{feature:r,attachment:s}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!s.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!s.data&&!s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(s.data instanceof File&&!!s.data.name)&&!s.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities?.editing.supportsUploadWithItemId&&s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof s.data){const e=n(s.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}async function O(e){const t=e.addFeatures??[],a=e.updateFeatures??[],r=t.concat(a).map((e=>e.geometry)),s=await i(r),o=t.length,n=a.length;return s.slice(0,o).forEach(((e,a)=>t[a].geometry=e)),s.slice(o,o+n).forEach(((e,t)=>a[t].geometry=e)),e}function j(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function U(e,t){if(null==t.infoFor3D)return;const{infoFor3D:r}=t,s=u("model/gltf-binary",r.supportedFormats)??p("glb",r.supportedFormats);if(!(!!s&&r.editFormats.includes(s)))throw new a(`${t.type}-layer:binary-gltf-asset-not-supported`,"3DObjectFeatureLayer requires binary glTF (.glb) support for updating mesh geometry.");e.addAssetFeatures??=[];const{addAssetFeatures:o}=e;for(const a of e.addFeatures??[])L(a)&&o.push(a);for(const a of e.updateFeatures??[])L(a)&&o.push(a)}function L(e){return"mesh"===e?.geometry?.type}function k(e,t,r,s){if(!m(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!t.uploadAssets)throw new a(`${e.type}-layer:no-asset-upload-support`,"Layer source does not support uploadAssets capability",{layer:e});return t.uploadAssets(r,s)}export{F as applyEdits,b as isFeatureIdentifierArrayWithGlobalId,f as isFeatureIdentifierArrayWithObjectId,g as isFeatureIdentifierWithGlobalId,y as isFeatureIdentifierWithObjectId,k as uploadAssets};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/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{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../RasterInfo.js";import o from"../RasterStorageInfo.js";import n from"../TileInfo.js";import{TilemapCache as c}from"../TilemapCache.js";import m from"./BaseRaster.js";import{setValidBoundary as u}from"../rasterFunctions/pixelUtils.js";import h from"../rasterTransforms/GCSShiftTransform.js";import{fetchServiceRasterInfo as f}from"../../../rest/imageService/fetchRasterInfo.js";import p from"../../../geometry/SpatialReference.js";import d from"../../../geometry/Point.js";import y from"../../../geometry/Extent.js";let x=class extends m{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async open(e){await this.init();const r=e&&e.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const m=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(m.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const u=await this._fetchRasterInfo({signal:r});if(null==u)throw new t("image-server-raster:open","cannot initialize image service");const h="Map"===this.tileType?g(l.tileInfo,l):n.fromJSON(l.tileInfo);i(h);const[f,p]=this._computeMinMaxLOD(u,h),{extent:d,pixelSize:y}=u,x=.5/u.width*y.x,v=Math.max(y.x,y.y),{lods:S}=h;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(y.x-y.y)>x||!S.some((e=>Math.abs(e.resolution-v)<x)))&&(y.x=y.y=f.resolution,u.width=Math.ceil((d.xmax-d.xmin)/y.x-.1),u.height=Math.ceil((d.ymax-d.ymin)/y.y-.1));const I=f.level-p.level,[w,j]=h.size,M=[],b=[];S.forEach(((e,t)=>{e.level>=p.level&&e.level<=f.level&&M.push({x:e.resolution,y:e.resolution}),t<S.length-1&&b.push(Math.round(10*e.resolution/S[t+1].resolution)/10)})),M.sort(((e,t)=>e.x-t.x));const T=this.computeBlockBoundary(d,w,j,h.origin,M,I),_=M.length>1?M.slice(1):null;let O;l.transposeInfo&&(O={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:u.keyProperties?._yxs.PacketSize??0});const R=b.length<=1||b.length>=3&&b.slice(0,b.length-1).every((e=>e===b[0]))?b[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/I))/10;if(u.storageInfo=new o({blockWidth:h.size[0],blockHeight:h.size[1],pyramidBlockWidth:h.size[0],pyramidBlockHeight:h.size[1],pyramidResolutions:_,pyramidScalingFactor:R,compression:h.format,origin:h.origin,firstPyramidLevel:1,maximumPyramidLevel:I,tileInfo:h,transposeInfo:O,blockBoundary:T}),this._fixGCSShift(u),this._set("rasterInfo",u),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:u.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new c({layer:e})}}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,o=null!=l&&!!s.transposedVariableName;if(this._slices&&!o&&null==s.sliceId)return null;const n=o?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${n}/${t}/${i}`,m=this._slices?o?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null,{data:h}=await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal});if(!h)return null;const f=o?l.tileSize:r.tileInfo.size,p=await this.decodePixelBlock(h,{width:f[0],height:f[1],planes:null,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:o,noDataValue:this.rasterInfo.noDataValue});if(null==p)return null;const d=r.blockBoundary[e];if("jpg"!==r.compression||i>d.minCol&&i<d.maxCol&&t>d.minRow&&t<d.maxRow)return p;const{origin:y,blockWidth:x,blockHeight:g}=r,{x:v,y:S}=this.getPyramidPixelSize(e),I=Math.round((a.xmin-y.x)/v)%x,w=Math.round((a.xmax-y.x)/v)%x||x,j=Math.round((y.y-a.ymax)/S)%g,M=Math.round((y.y-a.ymin)/S)%g||g,b=i===d.minCol?I:0,T=t===d.minRow?j:0,_=i===d.maxCol?w:x,O=t===d.maxRow?M:g;return u(p,{x:b,y:T},{width:_-b,height:O-T}),p}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some((e=>{const i=t.find((t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName));if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])})))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.statistics)),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.histograms)),r=await Promise.all([i,s]);return r[0]&&r[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=p.fromJSON(t.spatialReference||e.spatialReference),a=new d({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new l({width:i,height:s,bandCount:3,extent:y.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=f(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then((e=>e.data&&e.data.slices)).catch((()=>null)):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_fixGCSShift(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new h,e.extent=e.transform.forwardTransform(t))}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map((e=>e.level)))),l=t.lodAt(Math.min.apply(null,r.map((e=>e.level)))),{tileType:o}=this;if("Map"===o)return this._levelOffset=r[0].level,[a,l];if("Raster"===o){return[r.find((e=>e.resolution===i.x))??a,l]}const{minScale:n,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find((e=>Math.abs(e.scale-c)<s)),m||(m=r.filter((e=>e.scale>c)).sort(((e,t)=>e.scale>t.scale?1:-1))[0]??a));let u=l;return n>0&&(u=r.find((e=>Math.abs(e.scale-n)<s))??l,this._levelOffset=u.level-l.level),[m,u]}};function g(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return n.fromJSON({...e,lods:e.lods.filter((({level:e})=>null!=e&&e>=r&&e<=a))});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return n.fromJSON({...e,lods:e.lods.filter((e=>{const i=t(e.scale);return i<=r&&i>=a}))})}return n.fromJSON(e)}e([r({type:String,json:{write:!0}})],x.prototype,"datasetFormat",void 0),e([r()],x.prototype,"tileType",void 0),x=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],x);const v=x;export{v as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../RasterInfo.js";import o from"../RasterStorageInfo.js";import n from"../TileInfo.js";import{TilemapCache as c}from"../TilemapCache.js";import m from"./BaseRaster.js";import{setValidBoundary as u}from"../rasterFunctions/pixelUtils.js";import h from"../rasterTransforms/GCSShiftTransform.js";import{fetchServiceRasterInfo as f}from"../../../rest/imageService/fetchRasterInfo.js";import p from"../../../geometry/SpatialReference.js";import d from"../../../geometry/Point.js";import y from"../../../geometry/Extent.js";let x=class extends m{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async open(e){await this.init();const r=e&&e.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const m=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(m.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const u=await this._fetchRasterInfo({signal:r});if(null==u)throw new t("image-server-raster:open","cannot initialize image service");const h="Map"===this.tileType?g(l.tileInfo,l):n.fromJSON(l.tileInfo);i(h);const[f,p]=this._computeMinMaxLOD(u,h),{extent:d,pixelSize:y}=u,x=.5/u.width*y.x,v=Math.max(y.x,y.y),{lods:S}=h;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(y.x-y.y)>x||!S.some((e=>Math.abs(e.resolution-v)<x)))&&(y.x=y.y=f.resolution,u.width=Math.ceil((d.xmax-d.xmin)/y.x-.1),u.height=Math.ceil((d.ymax-d.ymin)/y.y-.1));const I=f.level-p.level,[w,j]=h.size,M=[],b=[];S.forEach(((e,t)=>{e.level>=p.level&&e.level<=f.level&&M.push({x:e.resolution,y:e.resolution}),t<S.length-1&&b.push(Math.round(10*e.resolution/S[t+1].resolution)/10)})),M.sort(((e,t)=>e.x-t.x));const T=this.computeBlockBoundary(d,w,j,h.origin,M,I),_=M.length>1?M.slice(1):null;let O;l.transposeInfo&&(O={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:u.keyProperties?._yxs.PacketSize??0});const R=b.length<=1||b.length>=3&&b.slice(0,-1).every((e=>e===b[0]))?b[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/I))/10;if(u.storageInfo=new o({blockWidth:h.size[0],blockHeight:h.size[1],pyramidBlockWidth:h.size[0],pyramidBlockHeight:h.size[1],pyramidResolutions:_,pyramidScalingFactor:R,compression:h.format,origin:h.origin,firstPyramidLevel:1,maximumPyramidLevel:I,tileInfo:h,transposeInfo:O,blockBoundary:T}),this._fixGCSShift(u),this._set("rasterInfo",u),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:u.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new c({layer:e})}}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,o=null!=l&&!!s.transposedVariableName;if(this._slices&&!o&&null==s.sliceId)return null;const n=o?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${n}/${t}/${i}`,m=this._slices?o?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null,{data:h}=await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal});if(!h)return null;const f=o?l.tileSize:r.tileInfo.size,p=await this.decodePixelBlock(h,{width:f[0],height:f[1],planes:null,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:o,noDataValue:this.rasterInfo.noDataValue});if(null==p)return null;const d=r.blockBoundary[e];if("jpg"!==r.compression||i>d.minCol&&i<d.maxCol&&t>d.minRow&&t<d.maxRow)return p;const{origin:y,blockWidth:x,blockHeight:g}=r,{x:v,y:S}=this.getPyramidPixelSize(e),I=Math.round((a.xmin-y.x)/v)%x,w=Math.round((a.xmax-y.x)/v)%x||x,j=Math.round((y.y-a.ymax)/S)%g,M=Math.round((y.y-a.ymin)/S)%g||g,b=i===d.minCol?I:0,T=t===d.minRow?j:0,_=i===d.maxCol?w:x,O=t===d.maxRow?M:g;return u(p,{x:b,y:T},{width:_-b,height:O-T}),p}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some((e=>{const i=t.find((t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName));if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])})))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.statistics)),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.histograms)),r=await Promise.all([i,s]);return r[0]&&r[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=p.fromJSON(t.spatialReference||e.spatialReference),a=new d({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new l({width:i,height:s,bandCount:3,extent:y.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=f(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then((e=>e.data&&e.data.slices)).catch((()=>null)):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_fixGCSShift(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new h,e.extent=e.transform.forwardTransform(t))}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map((e=>e.level)))),l=t.lodAt(Math.min.apply(null,r.map((e=>e.level)))),{tileType:o}=this;if("Map"===o)return this._levelOffset=r[0].level,[a,l];if("Raster"===o){return[r.find((e=>e.resolution===i.x))??a,l]}const{minScale:n,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find((e=>Math.abs(e.scale-c)<s)),m||(m=r.filter((e=>e.scale>c)).sort(((e,t)=>e.scale>t.scale?1:-1))[0]??a));let u=l;return n>0&&(u=r.find((e=>Math.abs(e.scale-n)<s))??l,this._levelOffset=u.level-l.level),[m,u]}};function g(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return n.fromJSON({...e,lods:e.lods.filter((({level:e})=>null!=e&&e>=r&&e<=a))});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return n.fromJSON({...e,lods:e.lods.filter((e=>{const i=t(e.scale);return i<=r&&i>=a}))})}return n.fromJSON(e)}e([r({type:String,json:{write:!0}})],x.prototype,"datasetFormat",void 0),e([r()],x.prototype,"tileType",void 0),x=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],x);const v=x;export{v 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.28/esri/copyright.txt for details.
4
4
  */
5
- const t=5e4;function n(t){const n=r(t);return n?{isMultipart:!0,data:n.boundary?e(t.data,n,0):null}:{isMultipart:!1,data:null}}function e(n,e,r=0){const a="--"+e.boundary,i=[];for(let t=0;t<a.length;t++)i.push(a.charCodeAt(t));const s=[],c="\n--"+e.boundary+"--";for(let t=0;t<c.length;t++)s.push(c.charCodeAt(t));const l=[10],f=[13,10],u=[],h=i.length,g=new Uint8Array(n,r),p=Math.min(t,g.length-h);let d=0,y=0;for(let t=0;t<p;t++){for(y=0;y<h&&g[t+y]===i[y];y++);y===h&&(d&&u.push(o(g.subarray(d,t),e)),t+=h-1,g[t+1]===l[0]?t+=1:g[t+1]===f[0]&&g[t+2]===f[1]&&(t+=2),d=t+1)}const b=s.length;for(let t=g.length-b-10;t<g.length-b;t++){for(y=0;y<b&&g[t+y]===s[y];y++);if(y===b){u.push(o(g.subarray(d,t),e));break}}return u}function r(t){const n=t.getHeader?.("Content-Type")?.split(";");if(!(n?.[0].trim()??"").startsWith("multipart/"))return null;const e={boundary:"",start:"",type:""};for(let r=1;r<n.length;r++){const t=n[r].indexOf("=");if(t>0){const o=n[r].slice(0,t).trim(),a=n[r].slice(t+1).trim();e[o]=a.startsWith('"')?a.slice(1,a.length-1):a}}return e}function o(t,n){const e=String.fromCharCode.apply(null,t.subarray(0,Math.min(300,t.length))).split("\n"),r=Math.min(e.length,7),o={contentDisposition:"inline"};let a=0;for(let i=0;i<r;i++)if(e[i].length<4)a=a+e[i].length+1;else if("content"===e[i].slice(0,7).toLowerCase()){if(a=a+e[i].length+1,!e[i].includes(":"))continue;const t=e[i].substring(0,e[i].indexOf(":")).trim(),n=e[i].substring(e[i].indexOf(":")+1).trim();switch(t.toLowerCase()){case"content-type":o.contentType=n;break;case"content-description":o.contentDescription=n;break;case"content-transfer-encoding":o.contentTransferEncoding=n;break;case"content-id":o.contentID=n;break;case"content-disposition":o.contentDisposition=n;break;case"content-location":o.contentLocation=n}}else{if(o.contentDisposition.toLowerCase().includes("inline")&&e[i].length>=4&&o.contentType?.toLowerCase().indexOf("image")>-1){let n=!0,e=t.subarray(a,t.length);if(o.contentType.toLowerCase().indexOf("tif")>0){if("base64"===o.contentTransferEncoding){let t="";const n=e;for(let e=0;e<n.length;e+=65535){const r=n.subarray(e,e+65535>n.length-1?n.length-1:e+65535);t+=String.fromCharCode.apply(null,r)}const r=atob(t);e=new Uint8Array(r.length);for(let o=0;o<e.length;o++)e[o]=r.charCodeAt(o)}n=73===e[0]&&73===e[1]||77===e[0]&&77===e[1]}if(n){let n=e.buffer;"base64"!==o.contentTransferEncoding&&(n=new ArrayBuffer(t.length-a),e=new Uint8Array(n),e.set(t.subarray(a,t.length))),o.contentData=n}break}if((""===n.start||o.contentID===n.start)&&o.contentType){if(o.contentType.includes("text")||o.contentType.includes("xml")){o.contentData=String.fromCharCode.apply(null,t.subarray(a,t.length));break}o.contentData=t.subarray(a,t.length)}}return o}export{n as parse};
5
+ const t=5e4;function n(t){const n=r(t);return n?{isMultipart:!0,data:n.boundary?e(t.data,n,0):null}:{isMultipart:!1,data:null}}function e(n,e,r=0){const a="--"+e.boundary,i=[];for(let t=0;t<a.length;t++)i.push(a.charCodeAt(t));const s=[],c="\n--"+e.boundary+"--";for(let t=0;t<c.length;t++)s.push(c.charCodeAt(t));const l=[10],f=[13,10],u=[],h=i.length,g=new Uint8Array(n,r),p=Math.min(t,g.length-h);let d=0,y=0;for(let t=0;t<p;t++){for(y=0;y<h&&g[t+y]===i[y];y++);y===h&&(d&&u.push(o(g.subarray(d,t),e)),t+=h-1,g[t+1]===l[0]?t+=1:g[t+1]===f[0]&&g[t+2]===f[1]&&(t+=2),d=t+1)}const b=s.length;for(let t=g.length-b-10;t<g.length-b;t++){for(y=0;y<b&&g[t+y]===s[y];y++);if(y===b){u.push(o(g.subarray(d,t),e));break}}return u}function r(t){const n=t.getHeader?.("Content-Type")?.split(";");if(!(n?.[0].trim()??"").startsWith("multipart/"))return null;const e={boundary:"",start:"",type:""};for(let r=1;r<n.length;r++){const t=n[r].indexOf("=");if(t>0){const o=n[r].slice(0,t).trim(),a=n[r].slice(t+1).trim();e[o]=a.startsWith('"')?a.slice(1,-1):a}}return e}function o(t,n){const e=String.fromCharCode.apply(null,t.subarray(0,Math.min(300,t.length))).split("\n"),r=Math.min(e.length,7),o={contentDisposition:"inline"};let a=0;for(let i=0;i<r;i++)if(e[i].length<4)a=a+e[i].length+1;else if("content"===e[i].slice(0,7).toLowerCase()){if(a=a+e[i].length+1,!e[i].includes(":"))continue;const t=e[i].substring(0,e[i].indexOf(":")).trim(),n=e[i].substring(e[i].indexOf(":")+1).trim();switch(t.toLowerCase()){case"content-type":o.contentType=n;break;case"content-description":o.contentDescription=n;break;case"content-transfer-encoding":o.contentTransferEncoding=n;break;case"content-id":o.contentID=n;break;case"content-disposition":o.contentDisposition=n;break;case"content-location":o.contentLocation=n}}else{if(o.contentDisposition.toLowerCase().includes("inline")&&e[i].length>=4&&o.contentType?.toLowerCase().indexOf("image")>-1){let n=!0,e=t.subarray(a,t.length);if(o.contentType.toLowerCase().indexOf("tif")>0){if("base64"===o.contentTransferEncoding){let t="";const n=e;for(let e=0;e<n.length;e+=65535){const r=n.subarray(e,e+65535>n.length-1?n.length-1:e+65535);t+=String.fromCharCode.apply(null,r)}const r=atob(t);e=new Uint8Array(r.length);for(let o=0;o<e.length;o++)e[o]=r.charCodeAt(o)}n=73===e[0]&&73===e[1]||77===e[0]&&77===e[1]}if(n){let n=e.buffer;"base64"!==o.contentTransferEncoding&&(n=new ArrayBuffer(t.length-a),e=new Uint8Array(n),e.set(t.subarray(a,t.length))),o.contentData=n}break}if((""===n.start||o.contentID===n.start)&&o.contentType){if(o.contentType.includes("text")||o.contentType.includes("xml")){o.contentData=String.fromCharCode.apply(null,t.subarray(a,t.length));break}o.contentData=t.subarray(a,t.length)}}return o}export{n as parse};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{getReferenceEllipsoidFromWKID as n}from"../../geometry/ellipsoidUtils.js";import i from"../../geometry/Extent.js";import r from"../../geometry/Point.js";import l from"../../geometry/support/WKIDUnitConversion.js";import{isAxesOrderReversedForWkid as o}from"../ogc/crsUtils.js";import{visitXML as s}from"../ogc/xmlUtils.js";import a from"./LOD.js";import c from"./TileInfo.js";const u=90.71428571428571;function p(e){const n=e.replaceAll(/ows:/gi,"");if(!g("Contents",(new DOMParser).parseFromString(n,"text/xml").documentElement))throw new t("wmtslayer:wmts-capabilities-xml-is-not-valid","the wmts get capabilities response is not compliant",{text:e})}function f(e,n){e=e.replaceAll(/ows:/gi,"");const i=(new DOMParser).parseFromString(e,"text/xml").documentElement,r=new Map,l=new Map,o=g("Contents",i);if(!o)throw new t("wmtslayer:wmts-capabilities-xml-is-not-valid");const s=g("OperationsMetadata",i),a=s?.querySelector("[name='GetTile']"),c=a?.getElementsByTagName("Get"),u=c&&Array.prototype.slice.call(c),p=n.url?.indexOf("https"),f=void 0!==p&&p>-1;let d,m,h=n.serviceMode,T=n?.url;if(u&&u.length&&u.some((e=>{const t=g("Constraint",e);return!t||C("AllowedValues","Value",h,t)?(T=e.attributes[0].nodeValue,!0):(!t||C("AllowedValues","Value","RESTful",t)||C("AllowedValues","Value","REST",t)?m=e.attributes[0].nodeValue:t&&!C("AllowedValues","Value","KVP",t)||(d=e.attributes[0].nodeValue),!1)})),!T)if(m)T=m,h="RESTful";else if(d)T=d,h="KVP";else{const e=g("ServiceMetadataURL",i);T=e?.getAttribute("xlink:href")}const y=T.indexOf("1.0.0/");-1===y&&"RESTful"===h?T+="/":y>-1&&(T=T.substring(0,y)),"KVP"===h&&(T+=y>-1?"":"?"),f&&(T=T.replace(/^http:/i,"https:"));const R=w("ServiceIdentification>ServiceTypeVersion",i),S=w("ServiceIdentification>AccessConstraints",i),A=S&&/^none$/i.test(S)?null:S,V=x("Layer",o),b=x("TileMatrixSet",o),E=V.map((e=>{const t=w("Identifier",e);return r.set(t,e),M(t,e,b,f,R)}));return{copyright:A,dimensionMap:l,layerMap:r,layers:E,serviceMode:h,tileUrl:T}}function d(e){return e.layers.forEach((e=>{e.tileMatrixSets?.forEach((e=>{const t=e.tileInfo;t&&96!==t.dpi&&(t.lods?.forEach((n=>{n.scale=96*n.scale/t.dpi,n.resolution=j(t.spatialReference?.wkid,n.scale*u/96,e.id)})),t.dpi=96)}))})),e}function m(e){return e.nodeType===Node.ELEMENT_NODE}function g(e,t){for(let n=0;n<t.childNodes.length;n++){const i=t.childNodes[n];if(m(i)&&i.nodeName===e)return i}return null}function x(e,t){const n=[];for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];m(r)&&r.nodeName===e&&n.push(r)}return n}function h(t,n){const i=[];for(let e=0;e<n.childNodes.length;e++){const r=n.childNodes[e];m(r)&&r.nodeName===t&&i.push(r)}return i.map((e=>e.textContent)).filter(e)}function w(e,t){return e.split(">").forEach((e=>{t&&(t=g(e,t))})),t&&t.textContent}function C(e,t,n,i){let r;return Array.prototype.slice.call(i.childNodes).some((i=>{if(i.nodeName.includes(e)){const e=g(t,i),l=e&&e.textContent;if(l===n||n.split(":")&&n.split(":")[1]===l)return r=i,!0}return!1})),r}function M(e,t,n,i,r){const l=w("Abstract",t),o=h("Format",t);return{id:e,fullExtent:A(t),fullExtents:V(t),description:l,formats:o,styles:b(t,i),title:w("Title",t),tileMatrixSets:E(r,t,n)}}function T(e,t){const n=[],i=e.layerMap?.get(t);if(!i)return null;const r=x("ResourceURL",i),l=x("Dimension",i);let o,s,a,c;return l.length&&(o=w("Identifier",l[0]),s=h("Default",l[0])||h("Value",l[0])),l.length>1&&(a=w("Identifier",l[1]),c=h("Default",l[1])||h("Value",l[1])),e.dimensionMap.set(t,{dimensions:s,dimensions2:c}),r.forEach((e=>{let t=e.getAttribute("template");if("tile"===e.getAttribute("resourceType")){if(o&&s.length)if(t.includes("{"+o+"}"))t=t.replace("{"+o+"}","{dimensionValue}");else{const e=t.toLowerCase().indexOf("{"+o.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue}"+t.substring(e+o.length+2))}if(a&&c.length)if(t.includes("{"+a+"}"))t=t.replace("{"+a+"}","{dimensionValue2}");else{const e=t.toLowerCase().indexOf("{"+a.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue2}"+t.substring(e+a.length+2))}n.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}})),n}function y(e,t,n,i,r,l,o,s){const a=R(e,t,i);if(!(a?.length>0))return"";const{dimensionMap:c}=e,u=c.get(t).dimensions?.[0],p=c.get(t).dimensions2?.[0];return a[o%a.length].template.replaceAll(/\{Style\}/gi,r??"").replaceAll(/\{TileMatrixSet\}/gi,n??"").replaceAll(/\{TileMatrix\}/gi,l).replaceAll(/\{TileRow\}/gi,""+o).replaceAll(/\{TileCol\}/gi,""+s).replaceAll(/\{dimensionValue\}/gi,u).replaceAll(/\{dimensionValue2\}/gi,p)}function R(e,t,n){const i=T(e,t),r=i?.filter((e=>e.format===n));return(r?.length?r:i)??[]}function S(e,t,n,i){const{dimensionMap:r}=e,l=T(e,t);let o="";if(l&&l.length>0){const e=r.get(t).dimensions&&r.get(t).dimensions[0],s=r.get(t).dimensions2&&r.get(t).dimensions2[0];o=l[0].template,o.indexOf(".xxx")===o.length-4&&(o=o.slice(0,o.length-4)),o=o.replaceAll(/\{Style\}/gi,i),o=o.replaceAll(/\{TileMatrixSet\}/gi,n),o=o.replaceAll(/\{TileMatrix\}/gi,"{level}"),o=o.replaceAll(/\{TileRow\}/gi,"{row}"),o=o.replaceAll(/\{TileCol\}/gi,"{col}"),o=o.replaceAll(/\{dimensionValue\}/gi,e),o=o.replaceAll(/\{dimensionValue2\}/gi,s)}return o}function A(e){const t=g("WGS84BoundingBox",e),n=t?w("LowerCorner",t).split(" "):["-180","-90"],i=t?w("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(n[0]),ymin:parseFloat(n[1]),xmax:parseFloat(i[0]),ymax:parseFloat(i[1]),spatialReference:{wkid:4326}}}function V(e){const t=[];return s(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const n=e.getAttribute("crs").toLowerCase(),i=I(n),r=n.includes("epsg")&&o(i.wkid);let l,a,c,u;s(e,{LowerCorner:e=>{[l,a]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([l,a]=[a,l])},UpperCorner:e=>{[c,u]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([c,u]=[u,c])}}),t.push({xmin:l,ymin:a,xmax:c,ymax:u,spatialReference:i})}}),t}function b(e,t){return x("Style",e).map((e=>{const n=g("LegendURL",e),i=g("Keywords",e),r=i?h("Keyword",i):[];let l=n&&n.getAttribute("xlink:href");t&&(l=l&&l.replace(/^http:/i,"https:"));return{abstract:w("Abstract",e),id:w("Identifier",e),isDefault:"true"===e.getAttribute("isDefault"),keywords:r,legendUrl:l,title:w("Title",e)}}))}function E(e,t,n){return x("TileMatrixSetLink",t).map((t=>L(e,t,n)))}function L(e,t,n){const i=g("TileMatrixSet",t).textContent,r=h("TileMatrix",t),l=n.find((e=>{const t=g("Identifier",e),n=t&&t.textContent;return!!(n===i||i.split(":")&&i.split(":")[1]===n)})),o=g("TileMatrixSetLimits",t),s=o&&x("TileMatrixLimits",o),a=new Map;if(s?.length)for(const c of s){const e=g("TileMatrix",c).textContent,t=+g("MinTileRow",c).textContent,n=+g("MaxTileRow",c).textContent,i=+g("MinTileCol",c).textContent,r=+g("MaxTileCol",c).textContent;a.set(e,{minCol:i,maxCol:r,minRow:t,maxRow:n})}const u=w("SupportedCRS",l).toLowerCase(),p=N(l,u),f=p.spatialReference,d=g("TileMatrix",l),m=[parseInt(w("TileWidth",d),10),parseInt(w("TileHeight",d),10)],M=[];if(r.length)r.forEach(((e,t)=>{const n=C("TileMatrix","Identifier",e,l);M.push(k(n,u,t,i,a))}));else{x("TileMatrix",l).forEach(((e,t)=>{M.push(k(e,u,t,i,a))}))}const T=F(e,l,p,m,M[0]).toJSON(),y=new c({dpi:96,spatialReference:f,size:m,origin:p,lods:M}).toJSON();return{id:i,fullExtent:T,tileInfo:y}}function I(e){e=e.toLowerCase();let t=parseInt(e.split(":").pop(),10);900913!==t&&3857!==t||(t=102100);const n=D(e);return null!=n&&(t=n),{wkid:t}}function N(e,t){return v(g("TileMatrix",e),t)}function v(e,t){const n=I(t),[i,l]=w("TopLeftCorner",e).split(" ").map((e=>parseFloat(e))),s=t.includes("epsg")&&o(n.wkid);return new r(s?{x:l,y:i,spatialReference:n}:{x:i,y:l,spatialReference:n})}function F(e,t,n,r,l){const o=g("BoundingBox",t);let s,a,c,u,p,f;if(o&&(s=w("LowerCorner",o).split(" "),a=w("UpperCorner",o).split(" ")),s&&s.length>1&&a&&a.length>1)c=parseFloat(s[0]),p=parseFloat(s[1]),u=parseFloat(a[0]),f=parseFloat(a[1]);else{const e=g("TileMatrix",t),i=parseInt(w("MatrixWidth",e),10),o=parseInt(w("MatrixHeight",e),10);c=n.x,f=n.y,u=c+i*r[0]*l.resolution,p=f-o*r[1]*l.resolution}return O(e,n.spatialReference,n)?new i(p,c,f,u,n.spatialReference):new i(c,p,u,f,n.spatialReference)}function O(e,t,n){return"1.0.0"===e&&o(t.wkid)&&!(n.spatialReference.isGeographic&&n.x<-90&&n.y>=-90)}var U;function D(e){return e.includes("crs84")||e.includes("crs:84")?U.CRS84:e.includes("crs83")||e.includes("crs:83")?U.CRS83:e.includes("crs27")||e.includes("crs:27")?U.CRS27:null}function k(e,t,n,i,r){const l=I(t),o=w("Identifier",e);let s=parseFloat(w("ScaleDenominator",e));const c=j(l.wkid,s,i);s*=96/u;const p=+w("MatrixWidth",e),f=+w("MatrixHeight",e),{maxCol:d=p-1,maxRow:m=f-1,minCol:g=0,minRow:x=0}=r.get(o)??{},{x:h,y:C}=v(e,t);return new a({cols:[g,d],level:n,levelValue:o,origin:[h,C],scale:s,resolution:c,rows:[x,m]})}function j(e,t,i){let r;return r=l.hasOwnProperty(""+e)?l.values[l[e]]:"default028mm"===i?6370997*Math.PI/180:n(e).metersPerDegree,7*t/25e3/r}!function(e){e[e.CRS84=4326]="CRS84",e[e.CRS83=4269]="CRS83",e[e.CRS27=4267]="CRS27"}(U||(U={}));export{y as getTileUrlFromResourceUrls,S as getTileUrlTemplateFromResourceUrls,R as getTileUrlTemplates,f as parseCapabilities,d as parseResourceInfo,p as validateCapabilities};
5
+ import{isSome as e}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{getReferenceEllipsoidFromWKID as n}from"../../geometry/ellipsoidUtils.js";import i from"../../geometry/Extent.js";import r from"../../geometry/Point.js";import l from"../../geometry/support/WKIDUnitConversion.js";import{isAxesOrderReversedForWkid as o}from"../ogc/crsUtils.js";import{visitXML as s}from"../ogc/xmlUtils.js";import a from"./LOD.js";import c from"./TileInfo.js";const u=90.71428571428571;function p(e){const n=e.replaceAll(/ows:/gi,"");if(!g("Contents",(new DOMParser).parseFromString(n,"text/xml").documentElement))throw new t("wmtslayer:wmts-capabilities-xml-is-not-valid","the wmts get capabilities response is not compliant",{text:e})}function f(e,n){e=e.replaceAll(/ows:/gi,"");const i=(new DOMParser).parseFromString(e,"text/xml").documentElement,r=new Map,l=new Map,o=g("Contents",i);if(!o)throw new t("wmtslayer:wmts-capabilities-xml-is-not-valid");const s=g("OperationsMetadata",i),a=s?.querySelector("[name='GetTile']"),c=a?.getElementsByTagName("Get"),u=c&&Array.prototype.slice.call(c),p=n.url?.indexOf("https"),f=void 0!==p&&p>-1;let d,m,h=n.serviceMode,T=n?.url;if(u&&u.length&&u.some((e=>{const t=g("Constraint",e);return!t||C("AllowedValues","Value",h,t)?(T=e.attributes[0].nodeValue,!0):(!t||C("AllowedValues","Value","RESTful",t)||C("AllowedValues","Value","REST",t)?m=e.attributes[0].nodeValue:t&&!C("AllowedValues","Value","KVP",t)||(d=e.attributes[0].nodeValue),!1)})),!T)if(m)T=m,h="RESTful";else if(d)T=d,h="KVP";else{const e=g("ServiceMetadataURL",i);T=e?.getAttribute("xlink:href")}const y=T.indexOf("1.0.0/");-1===y&&"RESTful"===h?T+="/":y>-1&&(T=T.substring(0,y)),"KVP"===h&&(T+=y>-1?"":"?"),f&&(T=T.replace(/^http:/i,"https:"));const R=w("ServiceIdentification>ServiceTypeVersion",i),S=w("ServiceIdentification>AccessConstraints",i),A=S&&/^none$/i.test(S)?null:S,V=x("Layer",o),b=x("TileMatrixSet",o),E=V.map((e=>{const t=w("Identifier",e);return r.set(t,e),M(t,e,b,f,R)}));return{copyright:A,dimensionMap:l,layerMap:r,layers:E,serviceMode:h,tileUrl:T}}function d(e){return e.layers.forEach((e=>{e.tileMatrixSets?.forEach((e=>{const t=e.tileInfo;t&&96!==t.dpi&&(t.lods?.forEach((n=>{n.scale=96*n.scale/t.dpi,n.resolution=j(t.spatialReference?.wkid,n.scale*u/96,e.id)})),t.dpi=96)}))})),e}function m(e){return e.nodeType===Node.ELEMENT_NODE}function g(e,t){for(let n=0;n<t.childNodes.length;n++){const i=t.childNodes[n];if(m(i)&&i.nodeName===e)return i}return null}function x(e,t){const n=[];for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];m(r)&&r.nodeName===e&&n.push(r)}return n}function h(t,n){const i=[];for(let e=0;e<n.childNodes.length;e++){const r=n.childNodes[e];m(r)&&r.nodeName===t&&i.push(r)}return i.map((e=>e.textContent)).filter(e)}function w(e,t){return e.split(">").forEach((e=>{t&&(t=g(e,t))})),t&&t.textContent}function C(e,t,n,i){let r;return Array.prototype.slice.call(i.childNodes).some((i=>{if(i.nodeName.includes(e)){const e=g(t,i),l=e&&e.textContent;if(l===n||n.split(":")&&n.split(":")[1]===l)return r=i,!0}return!1})),r}function M(e,t,n,i,r){const l=w("Abstract",t),o=h("Format",t);return{id:e,fullExtent:A(t),fullExtents:V(t),description:l,formats:o,styles:b(t,i),title:w("Title",t),tileMatrixSets:E(r,t,n)}}function T(e,t){const n=[],i=e.layerMap?.get(t);if(!i)return null;const r=x("ResourceURL",i),l=x("Dimension",i);let o,s,a,c;return l.length&&(o=w("Identifier",l[0]),s=h("Default",l[0])||h("Value",l[0])),l.length>1&&(a=w("Identifier",l[1]),c=h("Default",l[1])||h("Value",l[1])),e.dimensionMap.set(t,{dimensions:s,dimensions2:c}),r.forEach((e=>{let t=e.getAttribute("template");if("tile"===e.getAttribute("resourceType")){if(o&&s.length)if(t.includes("{"+o+"}"))t=t.replace("{"+o+"}","{dimensionValue}");else{const e=t.toLowerCase().indexOf("{"+o.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue}"+t.substring(e+o.length+2))}if(a&&c.length)if(t.includes("{"+a+"}"))t=t.replace("{"+a+"}","{dimensionValue2}");else{const e=t.toLowerCase().indexOf("{"+a.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue2}"+t.substring(e+a.length+2))}n.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}})),n}function y(e,t,n,i,r,l,o,s){const a=R(e,t,i);if(!(a?.length>0))return"";const{dimensionMap:c}=e,u=c.get(t).dimensions?.[0],p=c.get(t).dimensions2?.[0];return a[o%a.length].template.replaceAll(/\{Style\}/gi,r??"").replaceAll(/\{TileMatrixSet\}/gi,n??"").replaceAll(/\{TileMatrix\}/gi,l).replaceAll(/\{TileRow\}/gi,""+o).replaceAll(/\{TileCol\}/gi,""+s).replaceAll(/\{dimensionValue\}/gi,u).replaceAll(/\{dimensionValue2\}/gi,p)}function R(e,t,n){const i=T(e,t),r=i?.filter((e=>e.format===n));return(r?.length?r:i)??[]}function S(e,t,n,i){const{dimensionMap:r}=e,l=T(e,t);let o="";if(l&&l.length>0){const e=r.get(t).dimensions&&r.get(t).dimensions[0],s=r.get(t).dimensions2&&r.get(t).dimensions2[0];o=l[0].template,o.indexOf(".xxx")===o.length-4&&(o=o.slice(0,-4)),o=o.replaceAll(/\{Style\}/gi,i),o=o.replaceAll(/\{TileMatrixSet\}/gi,n),o=o.replaceAll(/\{TileMatrix\}/gi,"{level}"),o=o.replaceAll(/\{TileRow\}/gi,"{row}"),o=o.replaceAll(/\{TileCol\}/gi,"{col}"),o=o.replaceAll(/\{dimensionValue\}/gi,e),o=o.replaceAll(/\{dimensionValue2\}/gi,s)}return o}function A(e){const t=g("WGS84BoundingBox",e),n=t?w("LowerCorner",t).split(" "):["-180","-90"],i=t?w("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(n[0]),ymin:parseFloat(n[1]),xmax:parseFloat(i[0]),ymax:parseFloat(i[1]),spatialReference:{wkid:4326}}}function V(e){const t=[];return s(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const n=e.getAttribute("crs").toLowerCase(),i=I(n),r=n.includes("epsg")&&o(i.wkid);let l,a,c,u;s(e,{LowerCorner:e=>{[l,a]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([l,a]=[a,l])},UpperCorner:e=>{[c,u]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([c,u]=[u,c])}}),t.push({xmin:l,ymin:a,xmax:c,ymax:u,spatialReference:i})}}),t}function b(e,t){return x("Style",e).map((e=>{const n=g("LegendURL",e),i=g("Keywords",e),r=i?h("Keyword",i):[];let l=n&&n.getAttribute("xlink:href");t&&(l=l&&l.replace(/^http:/i,"https:"));return{abstract:w("Abstract",e),id:w("Identifier",e),isDefault:"true"===e.getAttribute("isDefault"),keywords:r,legendUrl:l,title:w("Title",e)}}))}function E(e,t,n){return x("TileMatrixSetLink",t).map((t=>L(e,t,n)))}function L(e,t,n){const i=g("TileMatrixSet",t).textContent,r=h("TileMatrix",t),l=n.find((e=>{const t=g("Identifier",e),n=t&&t.textContent;return!!(n===i||i.split(":")&&i.split(":")[1]===n)})),o=g("TileMatrixSetLimits",t),s=o&&x("TileMatrixLimits",o),a=new Map;if(s?.length)for(const c of s){const e=g("TileMatrix",c).textContent,t=+g("MinTileRow",c).textContent,n=+g("MaxTileRow",c).textContent,i=+g("MinTileCol",c).textContent,r=+g("MaxTileCol",c).textContent;a.set(e,{minCol:i,maxCol:r,minRow:t,maxRow:n})}const u=w("SupportedCRS",l).toLowerCase(),p=N(l,u),f=p.spatialReference,d=g("TileMatrix",l),m=[parseInt(w("TileWidth",d),10),parseInt(w("TileHeight",d),10)],M=[];if(r.length)r.forEach(((e,t)=>{const n=C("TileMatrix","Identifier",e,l);M.push(k(n,u,t,i,a))}));else{x("TileMatrix",l).forEach(((e,t)=>{M.push(k(e,u,t,i,a))}))}const T=F(e,l,p,m,M[0]).toJSON(),y=new c({dpi:96,spatialReference:f,size:m,origin:p,lods:M}).toJSON();return{id:i,fullExtent:T,tileInfo:y}}function I(e){e=e.toLowerCase();let t=parseInt(e.split(":").pop(),10);900913!==t&&3857!==t||(t=102100);const n=D(e);return null!=n&&(t=n),{wkid:t}}function N(e,t){return v(g("TileMatrix",e),t)}function v(e,t){const n=I(t),[i,l]=w("TopLeftCorner",e).split(" ").map((e=>parseFloat(e))),s=t.includes("epsg")&&o(n.wkid);return new r(s?{x:l,y:i,spatialReference:n}:{x:i,y:l,spatialReference:n})}function F(e,t,n,r,l){const o=g("BoundingBox",t);let s,a,c,u,p,f;if(o&&(s=w("LowerCorner",o).split(" "),a=w("UpperCorner",o).split(" ")),s&&s.length>1&&a&&a.length>1)c=parseFloat(s[0]),p=parseFloat(s[1]),u=parseFloat(a[0]),f=parseFloat(a[1]);else{const e=g("TileMatrix",t),i=parseInt(w("MatrixWidth",e),10),o=parseInt(w("MatrixHeight",e),10);c=n.x,f=n.y,u=c+i*r[0]*l.resolution,p=f-o*r[1]*l.resolution}return O(e,n.spatialReference,n)?new i(p,c,f,u,n.spatialReference):new i(c,p,u,f,n.spatialReference)}function O(e,t,n){return"1.0.0"===e&&o(t.wkid)&&!(n.spatialReference.isGeographic&&n.x<-90&&n.y>=-90)}var U;function D(e){return e.includes("crs84")||e.includes("crs:84")?U.CRS84:e.includes("crs83")||e.includes("crs:83")?U.CRS83:e.includes("crs27")||e.includes("crs:27")?U.CRS27:null}function k(e,t,n,i,r){const l=I(t),o=w("Identifier",e);let s=parseFloat(w("ScaleDenominator",e));const c=j(l.wkid,s,i);s*=96/u;const p=+w("MatrixWidth",e),f=+w("MatrixHeight",e),{maxCol:d=p-1,maxRow:m=f-1,minCol:g=0,minRow:x=0}=r.get(o)??{},{x:h,y:C}=v(e,t);return new a({cols:[g,d],level:n,levelValue:o,origin:[h,C],scale:s,resolution:c,rows:[x,m]})}function j(e,t,i){let r;return r=l.hasOwnProperty(""+e)?l.values[l[e]]:"default028mm"===i?6370997*Math.PI/180:n(e).metersPerDegree,7*t/25e3/r}!function(e){e[e.CRS84=4326]="CRS84",e[e.CRS83=4269]="CRS83",e[e.CRS27=4267]="CRS27"}(U||(U={}));export{y as getTileUrlFromResourceUrls,S as getTileUrlTemplateFromResourceUrls,R as getTileUrlTemplates,f as parseCapabilities,d as parseResourceInfo,p as validateCapabilities};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.28.0-next.20230711",
3
+ "version": "4.28.0-next.20230713",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- const b="20230711",a="75bb993211b7e9a84bb2f9c689acb0d2ca2bb5a5";export{b as buildDate,a as commitHash};
5
+ const b="20230713",d="2b13e3558c55ddd1bac2956b5a677fb9ed430119";export{b as buildDate,d 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as w}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as f}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as P}from"./ChapmanAtmosphere.js";import{CloudsComposition as v}from"./CloudsComposition.js";import{isReadyCloudsData as b,CloudsRenderingStages as R}from"./CloudsData.js";import{CloudsGenerator as A}from"./CloudsGenerator.js";import{FadeMode as x}from"./CloudsParameters.js";import{cloudPresets as F}from"./CloudsPresets.js";import{Fog as N,FogParameters as C}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import j from"./MarsAtmosphere.js";import{Precipitation as W}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as O}from"./weather.js";import{ShaderOutput as M}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as T}from"../webgl-engine/lib/RenderSlot.js";import{Update as z}from"../webgl-engine/lib/Update.js";var L;let U=L=class extends t{constructor(e){super(e),this.renderSlots=[T.POSTPROCESSING_ENVIRONMENT_OPAQUE,T.POSTPROCESSING_ENVIRONMENT_TRANSPARENT],this._context=null,this._atmosphere=null,this._oldWeatherParameters=new I,this._newWeatherParameters=new I,this._fadedWeatherParameters=new I,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=O}get usedMemory(){return this._clouds?.usedMemory??0}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new W({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new A({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new v({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new N({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=b(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(this._updateWeatherFading(e.bindParameters,e.time),e.bindParameters.cloudsFade.renderingStage===R.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===M.Color)switch(e.bindParameters.slot){case T.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?._stage?.renderer?.fullResolutionAtmosphere),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),e.bindParameters.cloudsFade.isFading&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case T.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?._stage?.renderer?.fullResolutionAtmosphere),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===z.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e,t){e.cloudsFade.updateFading(e.camera,this.view.state.mode,t,this.view.qualitySettings.fadeDuration),e.cloudsFade.updateParallax(e.camera),e.weatherFading&&(this._updateLighting(e),this._updateFogAtmoshpere(e))}_updateLighting(e){e.cloudsFade.fadeMode!==x.CROSS_FADE&&e.cloudsFade.fadeMode!==x.FADE_IN?e.fadeLighting(0):e.fadeLighting(e.cloudsFade.fadeFactor)}_updateFogAtmoshpere(e){e.cloudsFade.fadeMode!==x.CROSS_FADE&&e.cloudsFade.fadeMode!==x.FADE_IN?this._fadeWeather(0):this._fadeWeather(e.cloudsFade.fadeFactor)}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(F[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,V),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,V),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return P;case y.Local:return E;case y.Mars:return j;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===f.Local?y.Local:null!=this._context&&P.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:w(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{k=L.prototype._getAtmosphereClass,L.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{L.prototype._getAtmosphereClass=k}}}};e([h({constructOnly:!0})],U.prototype,"view",void 0),e([h({readOnly:!0})],U.prototype,"atmosphere",null),e([h({readOnly:!0})],U.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],U.prototype,"updating",null),e([h({readOnly:!0})],U.prototype,"weatherVisible",null),e([h()],U.prototype,"_context",void 0),e([h()],U.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],U.prototype,"_stars",null),e([h({readOnly:!0})],U.prototype,"_precipitation",null),e([h({readOnly:!0})],U.prototype,"_clouds",null),e([h({readOnly:!0})],U.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],U.prototype,"_fog",null),e([h({readOnly:!0})],U.prototype,"weatherEnabled",null),e([h({readOnly:!0})],U.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],U.prototype,"_weatherUpdateParameters",null),U=L=e([l("esri.views.3d.environment.EnvironmentRenderer")],U);class I{constructor(){this.fog=new C,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const D=m(.5,.5,.5),V=m(1.5,1.5,1.5);let k;export{U as EnvironmentRenderer,I as WeatherParameters};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as w}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as f}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as P}from"./ChapmanAtmosphere.js";import{CloudsComposition as v}from"./CloudsComposition.js";import{isReadyCloudsData as b,CloudsRenderingStages as R}from"./CloudsData.js";import{CloudsGenerator as A}from"./CloudsGenerator.js";import{FadeMode as x}from"./CloudsParameters.js";import{cloudPresets as F}from"./CloudsPresets.js";import{Fog as N,FogParameters as C}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import j from"./MarsAtmosphere.js";import{Precipitation as W}from"./Precipitation.js";import{Stars as O}from"./Stars.js";import{weatherHeightLimit as S}from"./weather.js";import{ShaderOutput as M}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as T}from"../webgl-engine/lib/RenderSlot.js";import{Update as z}from"../webgl-engine/lib/Update.js";var L;let U=L=class extends t{constructor(e){super(e),this.renderSlots=[T.POSTPROCESSING_ENVIRONMENT_OPAQUE,T.POSTPROCESSING_ENVIRONMENT_TRANSPARENT],this._context=null,this._atmosphere=null,this._oldWeatherParameters=new I,this._newWeatherParameters=new I,this._fadedWeatherParameters=new I,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}canRender(){return!(null===this._atmosphere&&null===this._stars)}requiresOutput(e){return e===M.Depth&&this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=S}get usedMemory(){return this._clouds?.usedMemory??0}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new O({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new W({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new A({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new v({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new N({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=b(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(this._updateWeatherFading(e.bindParameters,e.time),e.bindParameters.cloudsFade.renderingStage===R.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===M.Color)switch(e.bindParameters.slot){case T.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?._stage?.renderer?.fullResolutionAtmosphere),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),e.bindParameters.cloudsFade.isFading&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case T.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?._stage?.renderer?.fullResolutionAtmosphere),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===z.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e,t){e.cloudsFade.updateFading(e.camera,this.view.state.mode,t,this.view.qualitySettings.fadeDuration),e.cloudsFade.updateParallax(e.camera),e.weatherFading&&(this._updateLighting(e),this._updateFogAtmoshpere(e))}_updateLighting(e){e.cloudsFade.fadeMode!==x.CROSS_FADE&&e.cloudsFade.fadeMode!==x.FADE_IN?e.fadeLighting(0):e.fadeLighting(e.cloudsFade.fadeFactor)}_updateFogAtmoshpere(e){e.cloudsFade.fadeMode!==x.CROSS_FADE&&e.cloudsFade.fadeMode!==x.FADE_IN?this._fadeWeather(0):this._fadeWeather(e.cloudsFade.fadeFactor)}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(F[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,q),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return P;case y.Local:return E;case y.Mars:return j;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===f.Local?y.Local:null!=this._context&&P.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:w(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{V=L.prototype._getAtmosphereClass,L.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{L.prototype._getAtmosphereClass=V}}}};e([h({constructOnly:!0})],U.prototype,"view",void 0),e([h({readOnly:!0})],U.prototype,"atmosphere",null),e([h({readOnly:!0})],U.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],U.prototype,"updating",null),e([h({readOnly:!0})],U.prototype,"weatherVisible",null),e([h()],U.prototype,"_context",void 0),e([h()],U.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],U.prototype,"_stars",null),e([h({readOnly:!0})],U.prototype,"_precipitation",null),e([h({readOnly:!0})],U.prototype,"_clouds",null),e([h({readOnly:!0})],U.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],U.prototype,"_fog",null),e([h({readOnly:!0})],U.prototype,"weatherEnabled",null),e([h({readOnly:!0})],U.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],U.prototype,"_weatherUpdateParameters",null),U=L=e([l("esri.views.3d.environment.EnvironmentRenderer")],U);class I{constructor(){this.fog=new C,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const q=m(.5,.5,.5),D=m(1.5,1.5,1.5);let V;export{U as EnvironmentRenderer,I as WeatherParameters};