@arcgis/core 4.26.0-next.20230119 → 4.26.0-next.20230121

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 (98) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/Feature.js +1 -1
  3. package/arcade/featureset/support/shared.js +1 -1
  4. package/arcade/featureset/support/sqlUtils.js +1 -1
  5. package/arcade/languageUtils.js +1 -1
  6. package/arcade/lib/arcade-parser.js +1 -1
  7. package/arcade/lib/parser.js +1 -1
  8. package/arcade/lib/scanner.js +1 -1
  9. package/arcade/lib/types.js +1 -1
  10. package/arcade/validation/arcadeValidator.js +1 -1
  11. package/arcade/validation/diagnosticMessages.js +1 -1
  12. package/arcade/validation/languageKeywords.js +5 -0
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/{e6c6e3c9750829ec82c1.js → 09ac51aeb0f6fe16aa30.js} +1 -1
  15. package/assets/esri/core/workers/chunks/293594192932f0e00ecf.js +1 -0
  16. package/assets/esri/core/workers/chunks/4f4064eabbbc4a66f95a.js +1 -0
  17. package/assets/esri/core/workers/chunks/{0417369a1d563a6280ff.js → 63706a04e173000994db.js} +1 -1
  18. package/assets/esri/core/workers/chunks/6a90b1d73d5941ebb112.js +1 -0
  19. package/assets/esri/core/workers/chunks/{0c242aa92ab4f0c996db.js → 70f1fe5f36bc4abff2d2.js} +1 -1
  20. package/assets/esri/core/workers/chunks/96d4c50f74a9c0dcdb66.js +1 -0
  21. package/assets/esri/core/workers/chunks/b26a671d3523b8a48404.js +1 -0
  22. package/assets/esri/core/workers/chunks/{5dfed65b615b33588488.js → db96a2dc1879b4944cb8.js} +1 -1
  23. package/assets/esri/core/workers/chunks/fcf033c581f58d006cf6.js +1 -0
  24. package/assets/esri/core/workers/chunks/{5e872adb3a5e84c49865.js → fde8827bd7f1a97a6db3.js} +1 -1
  25. package/assets/esri/themes/base/widgets/_Editor.scss +9 -14
  26. package/assets/esri/themes/dark/main.css +1 -1
  27. package/assets/esri/themes/light/main.css +1 -1
  28. package/assets/esri/themes/light/view.css +1 -1
  29. package/chunks/languageUtils.js +1 -1
  30. package/core/scheduling.js +1 -1
  31. package/interfaces.d.ts +24 -12
  32. package/layers/StreamLayer.js +1 -1
  33. package/layers/VoxelWasmPerSceneView.js +1 -1
  34. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  35. package/layers/graphics/controllers/StreamController.js +1 -1
  36. package/layers/graphics/data/StreamFeatureManager.js +1 -1
  37. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  38. package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
  39. package/layers/support/FeatureReductionBinning.js +1 -1
  40. package/layers/support/FeatureReductionCluster.js +1 -1
  41. package/layers/support/StreamConnection.js +1 -1
  42. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  43. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  44. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  45. package/package.json +1 -1
  46. package/support/revision.js +1 -1
  47. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  48. package/views/2d/interactive/editingTools/MediaTransformToolsWrapper.js +1 -1
  49. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  50. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  51. package/views/2d/layers/StreamLayerView2D.js +1 -1
  52. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  53. package/views/2d/layers/features/schemaUtils.js +1 -1
  54. package/views/2d/layers/features/sources/GeoEventSource.js +1 -1
  55. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  56. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  57. package/views/2d/layers/support/FeatureLayerProxy.js +1 -1
  58. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  59. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  60. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  61. package/views/3d/layers/I3SMeshView3D.js +1 -1
  62. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  63. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  64. package/views/3d/layers/PointCloudWorker.js +1 -1
  65. package/views/3d/layers/RouteLayerView3D.js +1 -1
  66. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  67. package/views/3d/layers/SceneLayerView3D.js +1 -1
  68. package/views/3d/layers/StreamLayerView3D.js +1 -1
  69. package/views/3d/layers/TileLayerView3D.js +1 -1
  70. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  71. package/views/3d/layers/i3s/I3SLodHandling.js +1 -1
  72. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  73. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  74. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  75. package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
  76. package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
  77. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  78. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  79. package/views/3d/layers/support/I3STreeDebugger.js +1 -1
  80. package/views/3d/layers/support/SceneLayerViewRequiredFields.js +1 -1
  81. package/views/3d/terrain/TerrainSurface.js +1 -1
  82. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  83. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  84. package/views/PopupView.js +1 -1
  85. package/views/SceneView.js +1 -1
  86. package/views/interactive/SegmentLabels.js +1 -1
  87. package/views/layers/ImageryLayerView.js +1 -1
  88. package/views/layers/SceneLayerView.js +1 -1
  89. package/views/layers/StreamLayerView.js +1 -1
  90. package/widgets/Editor.js +1 -1
  91. package/widgets/Fullscreen/FullscreenViewModel.js +1 -1
  92. package/widgets/Home/HomeViewModel.js +1 -1
  93. package/assets/esri/core/workers/chunks/0efee8d9fc5632346cb4.js +0 -1
  94. package/assets/esri/core/workers/chunks/10e715aa4ac96d7dd1b4.js +0 -1
  95. package/assets/esri/core/workers/chunks/2dfb17fa5b6a5d239942.js +0 -1
  96. package/assets/esri/core/workers/chunks/2e3962506c353b562a88.js +0 -1
  97. package/assets/esri/core/workers/chunks/7320e6d8f207399bc8f1.js +0 -1
  98. package/assets/esri/core/workers/chunks/a194f90ffe13b3d448b0.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.26/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeFunction as e}from"../arcade/FunctionWrapper.js";import n from"../arcade/ImmutableArray.js";import t from"../arcade/ImmutablePathArray.js";import r from"../arcade/ImmutablePointArray.js";import{ArcadeDate as a,createDateTimeZone as i}from"../arcade/ArcadeDate.js";import o from"../geometry/Extent.js";import l from"../geometry/Geometry.js";import u from"../geometry/Multipoint.js";import s from"../geometry/Point.js";import f from"../geometry/Polygon.js";import c from"../geometry/Polyline.js";import{DateTime as m}from"luxon";import{isNone as d}from"../core/maybe.js";import{format as y,parse as p}from"../core/number.js";import{isClockwise as h}from"../geometry/support/coordsUtils.js";import{getLocale as g}from"../intl/locale.js";import{esriFieldToJson as b,layerGeometryEsriRestConstants as x}from"../arcade/featureset/support/shared.js";import{ArcadeModule as S}from"../arcade/ArcadeModule.js";import{ArcadeExecutionError as N,ExecutionErrorCodes as T}from"../arcade/executionError.js";class M{constructor(e){this.value=e}}class k{constructor(e){this.value=e}}const R=k,j=M,A={type:"VOID"},D={type:"BREAK"},F={type:"CONTINUE"};function I(e,n,t){return""===n||null==n||n===t||n===t?e:e=e.split(n).join(t)}function C(n){return n instanceof e}function w(e){return e instanceof S}function v(e){return!!_(e)||(!!Y(e)||(!!U(e)||(!!L(e)||(null===e||(e===A||"number"==typeof e)))))}function O(e,n){return void 0===e?n:e}function Z(e){return null==e?"":J(e)||V(e)?"Array":U(e)?"Date":_(e)?"String":L(e)?"Boolean":Y(e)?"Number":"esri.arcade.Attachment"===e?.declaredClass?"Attachment":"esri.arcade.Portal"===e?.declaredClass?"Portal":"esri.arcade.Dictionary"===e?.declaredClass?"Dictionary":e instanceof S?"Module":z(e)?"Feature":e instanceof s?"Point":e instanceof f?"Polygon":e instanceof c?"Polyline":e instanceof u?"Multipoint":e instanceof o?"Extent":C(e)?"Function":G(e)?"FeatureSet":E(e)?"FeatureSetCollection":e===A?"":"number"==typeof e&&isNaN(e)?"Number":"Unrecognised Type"}function _(e){return"string"==typeof e||e instanceof String}function L(e){return"boolean"==typeof e}function Y(e){return"number"==typeof e}function P(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function J(e){return e instanceof Array}function z(e){return"esri.arcade.Feature"===e?.arcadeDeclaredClass}function G(e){return!0===(e&&e.declaredRootClass&&"esri.arcade.featureset.support.FeatureSet"===e.declaredRootClass)}function E(e){return!0===(e&&e.declaredRootClass&&"esri.arcade.featureSetCollection"===e.declaredRootClass)}function V(e){return e instanceof n}function U(e){return e instanceof a}function H(e){return e instanceof Date}function q(e,n,t,r,a){if(e.length<n||e.length>t)throw new N(r,T.WrongNumberOfParameters,a)}function B(e){return e<0?-Math.round(-e):Math.round(e)}function W(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n=>{const t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===n?t:3&t|8).toString(16)}))}function $(e,n){return isNaN(e)||null==n||""===n?e.toString():(n=I(n,"‰",""),n=I(n,"¤",""),y(e,{pattern:n}))}function Q(e,n){return null==n||""===n?e.toISOString(!0):e.toFormat(X(n),{locale:g(),numberingSystem:"latn"})}function X(e){e=e.replace(/LTS|LT|LL?L?L?|l{1,4}/g,"[$&]");let n="";const t=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;for(const r of e.match(t)||[])switch(r){case"D":n+="d";break;case"DD":n+="dd";break;case"DDD":n+="o";break;case"d":n+="c";break;case"ddd":n+="ccc";break;case"dddd":n+="cccc";break;case"M":n+="L";break;case"MM":n+="LL";break;case"MMM":n+="LLL";break;case"MMMM":n+="LLLL";break;case"YY":n+="yy";break;case"Y":case"YYYY":n+="yyyy";break;case"Q":n+="q";break;case"Z":n+="ZZ";break;case"ZZ":n+="ZZZ";break;case"S":n+="'S'";break;case"SS":n+="'SS'";break;case"SSS":n+="u";break;case"A":case"a":n+="a";break;case"m":case"mm":case"h":case"hh":case"H":case"HH":case"s":case"ss":case"X":case"x":n+=r;break;default:r.length>=2&&"["===r.slice(0,1)&&"]"===r.slice(-1)?n+=`'${r.slice(1,-1)}'`:n+=`'${r}'`}return n}function K(e,n,t){switch(t){case">":return e>n;case"<":return e<n;case">=":return e>=n;case"<=":return e<=n}return!1}function ee(e,n,t){if(null===e){if(null===n||n===A)return K(null,null,t);if(Y(n))return K(0,n,t);if(_(n))return K(0,oe(n),t);if(L(n))return K(0,oe(n),t);if(U(n))return K(0,n.toNumber(),t)}if(e===A){if(null===n||n===A)return K(null,null,t);if(Y(n))return K(0,n,t);if(_(n))return K(0,oe(n),t);if(L(n))return K(0,oe(n),t);if(U(n))return K(0,n.toNumber(),t)}else if(Y(e)){if(Y(n))return K(e,n,t);if(L(n))return K(e,oe(n),t);if(null===n||n===A)return K(e,0,t);if(_(n))return K(e,oe(n),t);if(U(n))return K(e,n.toNumber(),t)}else if(_(e)){if(_(n))return K(te(e),te(n),t);if(U(n))return K(oe(e),n.toNumber(),t);if(Y(n))return K(oe(e),n,t);if(null===n||n===A)return K(oe(e),0,t);if(L(n))return K(oe(e),oe(n),t)}else if(U(e)){if(U(n))return K(e.toNumber(),n.toNumber(),t);if(null===n||n===A)return K(e.toNumber(),0,t);if(Y(n))return K(e.toNumber(),n,t);if(L(n))return K(e.toNumber(),oe(n),t);if(_(n))return K(e.toNumber(),oe(n),t)}else if(L(e)){if(L(n))return K(e,n,t);if(Y(n))return K(oe(e),oe(n),t);if(U(n))return K(oe(e),n.toNumber(),t);if(null===n||n===A)return K(oe(e),0,t);if(_(n))return K(oe(e),oe(n),t)}return!!ne(e,n)&&("<="===t||">="===t)}function ne(e,n){if(e===n)return!0;if(null===e&&n===A||null===n&&e===A)return!0;if(U(e)&&U(n))return e.equals(n);if(e instanceof t)return e.equalityTest(n);if(e instanceof r)return e.equalityTest(n);if(e instanceof s&&n instanceof s){const t=e.cache._arcadeCacheId,r=n.cache._arcadeCacheId;if(null!=t)return t===r}if(void 0!==e&&void 0!==n&&null!==e&&null!==n&&"object"==typeof e&&"object"==typeof n){if(e._arcadeCacheId===n._arcadeCacheId&&void 0!==e._arcadeCacheId&&null!==e._arcadeCacheId)return!0;if(e._underlyingGraphic===n._underlyingGraphic&&void 0!==e._underlyingGraphic&&null!==e._underlyingGraphic)return!0}return!1}function te(e,t){if(_(e))return e;if(null===e)return"";if(Y(e))return $(e,t);if(L(e))return e.toString();if(U(e))return Q(e,t);if(e instanceof l)return JSON.stringify(e.toJSON());if(J(e)){const n=[];for(let t=0;t<e.length;t++)n[t]=ie(e[t]);return"["+n.join(",")+"]"}if(e instanceof n){const n=[];for(let t=0;t<e.length();t++)n[t]=ie(e.get(t));return"["+n.join(",")+"]"}return null!==e&&"object"==typeof e&&void 0!==e.castToText?e.castToText():C(e)?"object, Function":e===A?"":w(e)?"object, Module":""}function re(e){const t=[];if(!J(e))return null;if(e instanceof n){for(let n=0;n<e.length();n++)t[n]=oe(e.get(n));return t}for(let n=0;n<e.length;n++)t[n]=oe(e[n]);return t}function ae(e,t,r=!1){if(_(e))return e;if(null===e)return"";if(Y(e))return $(e,t);if(L(e))return e.toString();if(U(e))return Q(e,t);if(e instanceof l)return e instanceof o?'{"xmin":'+e.xmin.toString()+',"ymin":'+e.ymin.toString()+","+(e.hasZ?'"zmin":'+e.zmin.toString()+",":"")+(e.hasM?'"mmin":'+e.mmin.toString()+",":"")+'"xmax":'+e.xmax.toString()+',"ymax":'+e.ymax.toString()+","+(e.hasZ?'"zmax":'+e.zmax.toString()+",":"")+(e.hasM?'"mmax":'+e.mmax.toString()+",":"")+'"spatialReference":'+he(e.spatialReference)+"}":he(e.toJSON(),((e,n)=>e.key===n.key?0:"spatialReference"===e.key?1:"spatialReference"===n.key||e.key<n.key?-1:e.key>n.key?1:0));if(J(e)){const n=[];for(let t=0;t<e.length;t++)n[t]=ie(e[t],r);return"["+n.join(",")+"]"}if(e instanceof n){const n=[];for(let t=0;t<e.length();t++)n[t]=ie(e.get(t),r);return"["+n.join(",")+"]"}return null!==e&&"object"==typeof e&&void 0!==e.castToText?e.castToText(r):C(e)?"object, Function":e===A?"":w(e)?"object, Module":""}function ie(e,t=!1){if(null===e)return"null";if(L(e)||Y(e)||_(e))return JSON.stringify(e);if(e instanceof l)return ae(e,null,t);if(e instanceof n)return ae(e,null,t);if(e instanceof Array)return ae(e,null,t);if(U(e))return t?JSON.stringify(e.getTime()):JSON.stringify(Q(e,""));if(null!==e&&"object"==typeof e){if(void 0!==e.castToText)return e.castToText(t)}else if(e===A)return"null";return"null"}function oe(e,n){return Y(e)?e:null===e||""===e?0:U(e)?NaN:L(e)?e?1:0:J(e)||""===e||void 0===e?NaN:void 0!==n&&_(e)?(n=I(n,"‰",""),n=I(n,"¤",""),p(e,{pattern:n})):e===A?0:Number(e)}function le(e,n){if(U(e))return e;if(_(e)){const t=ue(e,n);if(t)return a.dateTimeToArcadeDate(t)}return null}function ue(e,n){const t=/ (\d\d)/,r=i(n);let a=m.fromISO(e,{zone:r});return a.isValid||t.test(e)&&(e=e.replace(t,"T$1"),a=m.fromISO(e,{zone:n}),a.isValid)?a:null}function se(e){return L(e)?e:_(e)?"true"===(e=e.toLowerCase()):!!Y(e)&&(0!==e&&!isNaN(e))}function fe(e,n){return d(e)?null:(null!==e.spatialReference&&void 0!==e.spatialReference||(e.spatialReference=n),e)}function ce(e){if(null===e)return null;if(e instanceof s)return"NaN"===e.x||null===e.x||isNaN(e.x)?null:e;if(e instanceof f){if(0===e.rings.length)return null;for(const n of e.rings)if(n.length>0)return e;return null}if(e instanceof c){if(0===e.paths.length)return null;for(const n of e.paths)if(n.length>0)return e;return null}return e instanceof u?0===e.points.length?null:e:e instanceof o?"NaN"===e.xmin||null===e.xmin||isNaN(e.xmin)?null:e:null}function me(e,n){if(!e)return n;if(!e.domain)return n;let t=null;if("string"===e.field.type||"esriFieldTypeString"===e.field.type)n=te(n);else{if(null==n)return null;if(""===n)return n;n=oe(n)}for(let r=0;r<e.domain.codedValues.length;r++){const a=e.domain.codedValues[r];a.code===n&&(t=a)}return null===t?n:t.name}function de(e,n){if(!e)return n;if(!e.domain)return n;let t=null;n=te(n);for(let r=0;r<e.domain.codedValues.length;r++){const a=e.domain.codedValues[r];a.name===n&&(t=a)}return null===t?n:t.code}function ye(e,n,t=null,r=null){if(!n)return null;if(!n.fields)return null;let a,i,o=null;for(let l=0;l<n.fields.length;l++){const t=n.fields[l];t.name.toLowerCase()===e.toString().toLowerCase()&&(o=t)}if(null===o)throw new N(null,T.FieldNotFound,null,{key:e});return null===r&&t&&n.typeIdField&&(r=t.hasField(n.typeIdField)?t.field(n.typeIdField):null),null!=r&&n.types.some((e=>e.id===r&&(a=e.domains&&e.domains[o.name],a&&"inherited"===a.type&&(a=pe(o.name,n),i=!0),!0))),i||a||(a=pe(e,n)),{field:o,domain:a}}function pe(e,n){let t;return n.fields.some((n=>(n.name.toLowerCase()===e.toLowerCase()&&(t=n.domain),!!t))),t}function he(e,n){n||(n={}),"function"==typeof n&&(n={cmp:n});const t="boolean"==typeof n.cycles&&n.cycles,r=n.cmp&&(a=n.cmp,function(e){return function(n,t){const r={key:n,value:e[n]},i={key:t,value:e[t]};return a(r,i)}});var a;const i=[];return function e(n){if(n&&n.toJSON&&"function"==typeof n.toJSON&&(n=n.toJSON()),void 0===n)return;if("number"==typeof n)return isFinite(n)?""+n:"null";if("object"!=typeof n)return JSON.stringify(n);let a,o;if(Array.isArray(n)){for(o="[",a=0;a<n.length;a++)a&&(o+=","),o+=e(n[a])||"null";return o+"]"}if(null===n)return"null";if(i.includes(n)){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const l=i.push(n)-1,u=Object.keys(n).sort(r&&r(n));for(o="",a=0;a<u.length;a++){const t=u[a],r=e(n[t]);r&&(o&&(o+=","),o+=JSON.stringify(t)+":"+r)}return i.splice(l,1),"{"+o+"}"}(e)}function ge(e){if(null===e)return null;const n=[];for(const t of e)t&&t.arcadeDeclaredClass&&"esri.arcade.Feature"===t.arcadeDeclaredClass?n.push(t.geometry()):n.push(t);return n}function be(e,n){if(!(n instanceof s))throw new N(null,T.InvalidParameter,null);e.push(n.hasZ?n.hasM?[n.x,n.y,n.z,n.m]:[n.x,n.y,n.z]:[n.x,n.y])}function xe(e,n){if(J(e)||V(e)){let t=!1,a=!1,i=[],o=n;if(J(e)){for(const n of e)be(i,n);i.length>0&&(o=e[0].spatialReference,t=e[0].hasZ,a=e[0].hasM)}else if(e instanceof r)i=e._elements,i.length>0&&(t=e._hasZ,a=e._hasM,o=e.get(0).spatialReference);else{if(!V(e))throw new N(null,T.InvalidParameter,null);for(const n of e.toArray())be(i,n);i.length>0&&(o=e.get(0).spatialReference,t=!0===e.get(0).hasZ,a=!0===e.get(0).hasM)}if(0===i.length)return null;return h(i,a,t)||(i=i.slice(0).reverse()),new f({rings:[i],spatialReference:o,hasZ:t,hasM:a})}return e}function Se(e,n){if(J(e)||V(e)){let t=!1,a=!1,i=[],o=n;if(J(e)){for(const n of e)be(i,n);i.length>0&&(o=e[0].spatialReference,t=!0===e[0].hasZ,a=!0===e[0].hasM)}else if(e instanceof r)i=e._elements,i.length>0&&(t=e._hasZ,a=e._hasM,o=e.get(0).spatialReference);else if(V(e)){for(const n of e.toArray())be(i,n);i.length>0&&(o=e.get(0).spatialReference,t=!0===e.get(0).hasZ,a=!0===e.get(0).hasM)}return 0===i.length?null:new c({paths:[i],spatialReference:o,hasZ:t,hasM:a})}return e}function Ne(e,n){if(J(e)||V(e)){let t=!1,a=!1,i=[],o=n;if(J(e)){for(const n of e)be(i,n);i.length>0&&(o=e[0].spatialReference,t=!0===e[0].hasZ,a=!0===e[0].hasM)}else if(e instanceof r)i=e._elements,i.length>0&&(t=e._hasZ,a=e._hasM,o=e.get(0).spatialReference);else if(V(e)){for(const n of e.toArray())be(i,n);i.length>0&&(o=e.get(0).spatialReference,t=!0===e.get(0).hasZ,a=!0===e.get(0).hasM)}return 0===i.length?null:new u({points:i,spatialReference:o,hasZ:t,hasM:a})}return e}function Te(e,t=!1){const r=[];if(null===e)return r;if(!0===J(e)){for(let n=0;n<e.length;n++){const a=te(e[n]);""===a&&!0!==t||r.push(a)}return r}if(e instanceof n){for(let n=0;n<e.length();n++){const a=te(e.get(n));""===a&&!0!==t||r.push(a)}return r}if(v(e)){const n=te(e);return""===n&&!0!==t||r.push(n),r}return[]}let Me=0;function ke(e){return Me++,Me%100==0?(Me=0,new Promise((n=>{setTimeout((()=>{n(e)}),0)}))):e}function Re(e,n,t){switch(t){case"&":return e&n;case"|":return e|n;case"^":return e^n;case"<<":return e<<n;case">>":return e>>n;case">>>":return e>>>n}}function je(e,t=null){return null==e?null:L(e)||Y(e)||_(e)?e:e instanceof l?!0===t?.keepGeometryType?e:e.toJSON():e instanceof n?e.toArray().map((e=>je(e,t))):e instanceof Array?e.map((e=>je(e,t))):H(e)?e:U(e)?e.toJSDate():null!==e&&"object"==typeof e&&void 0!==e.castAsJson?e.castAsJson(t):null}async function Ae(e,n,t,r,a){const i=await De(e,n,t);a[r]=i}async function De(e,t=null,r=null){if(e instanceof n&&(e=e.toArray()),null==e)return null;if(v(e)||e instanceof l||H(e)||U(e))return je(e,r);if(e instanceof Array){const n=[],a=[];for(const i of e)null===i||v(i)||i instanceof l||H(i)||U(i)?a.push(je(i,r)):(a.push(null),n.push(Ae(i,t,r,a.length-1,a)));return n.length>0&&await Promise.all(n),a}return null!==e&&"object"==typeof e&&void 0!==e.castAsJsonAsync?e.castAsJsonAsync(t,r):null}function Fe(e,n,t){const r=e.fullSchema();if(null===r)return null;if(!r.fields)return null;return ye(n,r,e,t)}function Ie(e){const n=e.fullSchema();return null===n?null:n.fields&&n.typeIdField?{subtypeField:n.typeIdField,subtypes:n.types?n.types.map((e=>({name:e.name,code:e.id}))):[]}:null}function Ce(e,n,t,r){const a=e.fullSchema();if(null===a)return null;if(!a.fields)return null;const i=ye(n,a,e,r);if(void 0===t)try{t=e.field(n)}catch(o){return null}return me(i,t)}function we(e,n,t,r){const a=e.fullSchema();if(null===a)return null;if(!a.fields)return null;if(void 0===t){try{t=e.field(n)}catch(i){return null}return t}return de(ye(n,a,e,r),t)}function ve(e){return e?.timeReference?.timeZone?e?.timeReference?.timeZone:"system"}function Oe(e){const n=e.fullSchema();if(null===n)return null;if(!n.fields)return null;const t=[];for(const r of n.fields)t.push(b(r));return{objectIdField:n.objectIdField,globalIdField:n.globalIdField,geometryType:void 0===x[n.geometryType]?"":x[n.geometryType],fields:t,datesInUnknownTimezone:!0===n.datesInUnknownTimezone,preferredTimeReference:n.preferredTimeReference||null,editFieldsInfo:n.editFieldsInfo||null,timeInfo:n.timeInfo||null,dateFieldsTimeReference:n.dateFieldsTimeReference||null}}const Ze=Object.freeze(Object.defineProperty({__proto__:null,ImplicitResult:R,ImplicitResultE:k,ReturnResult:j,ReturnResultE:M,absRound:B,autoCastArrayOfPointsToMultiPoint:Ne,autoCastArrayOfPointsToPolygon:xe,autoCastArrayOfPointsToPolyline:Se,autoCastFeatureToGeometry:ge,binaryOperator:Re,breakResult:D,castAsJson:je,castAsJsonAsync:De,continueResult:F,defaultTimeZone:ve,defaultUndefined:O,equalityTest:ne,featureDomainCodeLookup:we,featureDomainValueLookup:Ce,featureFullDomain:Fe,featureSchema:Oe,featureSubtypes:Ie,fixNullGeometry:ce,fixSpatialReference:fe,formatDate:Q,formatNumber:$,generateUUID:W,getDomain:ye,getDomainCode:de,getDomainValue:me,getType:Z,greaterThanLessThan:ee,isArray:J,isBoolean:L,isDate:U,isFeature:z,isFeatureSet:G,isFeatureSetCollection:E,isFunctionParameter:C,isImmutableArray:V,isInteger:P,isJsDate:H,isModule:w,isNumber:Y,isSimpleType:v,isString:_,multiReplace:I,pcCheck:q,stableStringify:he,standardiseDateFormat:X,tick:ke,toBoolean:se,toDate:le,toNumber:oe,toNumberArray:re,toString:te,toStringArray:Te,toStringExplicit:ae,voidOperation:A},Symbol.toStringTag,{value:"Module"}));export{M as $,O as A,Z as B,ve as C,X as D,B as E,ce as F,ge as G,Se as H,R as I,xe as J,Ne as K,I as L,W as M,Oe as N,Ie as O,Fe as P,Ce as Q,j as R,we as S,G as T,E as U,re as V,ke as W,Te as X,ye as Y,me as Z,de as _,L as a,k as a0,w as a1,H as a2,$ as a3,Q as a4,he as a5,Y as b,_ as c,je as d,De as e,v as f,oe as g,se as h,C as i,te as j,U as k,le as l,J as m,Ze as n,D as o,F as p,fe as q,ee as r,ne as s,ae as t,Re as u,A as v,z as w,V as x,q as y,P as z};
5
+ import{ArcadeFunction as e}from"../arcade/FunctionWrapper.js";import n from"../arcade/ImmutableArray.js";import t from"../arcade/ImmutablePathArray.js";import r from"../arcade/ImmutablePointArray.js";import{ArcadeDate as a,createDateTimeZone as i}from"../arcade/ArcadeDate.js";import o from"../geometry/Extent.js";import l from"../geometry/Geometry.js";import u from"../geometry/Multipoint.js";import s from"../geometry/Point.js";import f from"../geometry/Polygon.js";import c from"../geometry/Polyline.js";import{DateTime as m}from"luxon";import{isNone as d}from"../core/maybe.js";import{format as y,parse as p}from"../core/number.js";import{isClockwise as h}from"../geometry/support/coordsUtils.js";import{getLocale as g}from"../intl/locale.js";import{esriFieldToJson as b,layerGeometryEsriRestConstants as x}from"../arcade/featureset/support/shared.js";import{ArcadeModule as S}from"../arcade/ArcadeModule.js";import{ArcadeExecutionError as N,ExecutionErrorCodes as T}from"../arcade/executionError.js";class M{constructor(e){this.value=e}}class k{constructor(e){this.value=e}}const j=k,A=M,R={type:"VOID"},D={type:"BREAK"},F={type:"CONTINUE"};function I(e,n,t){return""===n||null==n||n===t||n===t?e:e=e.split(n).join(t)}function C(n){return n instanceof e}function w(e){return e instanceof S}function O(e){return!!v(e)||(!!Y(e)||(!!U(e)||(!!L(e)||(null===e||(e===R||"number"==typeof e)))))}function Z(e,n){return void 0===e?n:e}function _(e){return null==e?"":J(e)||V(e)?"Array":U(e)?"Date":v(e)?"String":L(e)?"Boolean":Y(e)?"Number":"esri.arcade.Attachment"===e?.declaredClass?"Attachment":"esri.arcade.Portal"===e?.declaredClass?"Portal":"esri.arcade.Dictionary"===e?.declaredClass?"Dictionary":e instanceof S?"Module":z(e)?"Feature":e instanceof s?"Point":e instanceof f?"Polygon":e instanceof c?"Polyline":e instanceof u?"Multipoint":e instanceof o?"Extent":C(e)?"Function":G(e)?"FeatureSet":E(e)?"FeatureSetCollection":e===R?"":"number"==typeof e&&isNaN(e)?"Number":"Unrecognised Type"}function v(e){return"string"==typeof e||e instanceof String}function L(e){return"boolean"==typeof e}function Y(e){return"number"==typeof e}function P(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function J(e){return e instanceof Array}function z(e){return"esri.arcade.Feature"===e?.arcadeDeclaredClass}function G(e){return"esri.arcade.featureset.support.FeatureSet"===e?.declaredRootClass}function E(e){return"esri.arcade.featureSetCollection"===e?.declaredRootClass}function V(e){return e instanceof n}function U(e){return e instanceof a}function H(e){return null!=e&&"object"==typeof e}function q(e){return e instanceof Date}function B(e,n,t,r,a){if(e.length<n||e.length>t)throw new N(r,T.WrongNumberOfParameters,a)}function W(e){return e<0?-Math.round(-e):Math.round(e)}function $(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n=>{const t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===n?t:3&t|8).toString(16)}))}function Q(e,n){return isNaN(e)||null==n||""===n?e.toString():(n=I(n,"‰",""),n=I(n,"¤",""),y(e,{pattern:n}))}function X(e,n){return null==n||""===n?e.toISOString(!0):e.toFormat(K(n),{locale:g(),numberingSystem:"latn"})}function K(e){e=e.replace(/LTS|LT|LL?L?L?|l{1,4}/g,"[$&]");let n="";const t=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;for(const r of e.match(t)||[])switch(r){case"D":n+="d";break;case"DD":n+="dd";break;case"DDD":n+="o";break;case"d":n+="c";break;case"ddd":n+="ccc";break;case"dddd":n+="cccc";break;case"M":n+="L";break;case"MM":n+="LL";break;case"MMM":n+="LLL";break;case"MMMM":n+="LLLL";break;case"YY":n+="yy";break;case"Y":case"YYYY":n+="yyyy";break;case"Q":n+="q";break;case"Z":n+="ZZ";break;case"ZZ":n+="ZZZ";break;case"S":n+="'S'";break;case"SS":n+="'SS'";break;case"SSS":n+="u";break;case"A":case"a":n+="a";break;case"m":case"mm":case"h":case"hh":case"H":case"HH":case"s":case"ss":case"X":case"x":n+=r;break;default:r.length>=2&&"["===r.slice(0,1)&&"]"===r.slice(-1)?n+=`'${r.slice(1,-1)}'`:n+=`'${r}'`}return n}function ee(e,n,t){switch(t){case">":return e>n;case"<":return e<n;case">=":return e>=n;case"<=":return e<=n}return!1}function ne(e,n,t){if(null===e){if(null===n||n===R)return ee(null,null,t);if(Y(n))return ee(0,n,t);if(v(n))return ee(0,le(n),t);if(L(n))return ee(0,le(n),t);if(U(n))return ee(0,n.toNumber(),t)}if(e===R){if(null===n||n===R)return ee(null,null,t);if(Y(n))return ee(0,n,t);if(v(n))return ee(0,le(n),t);if(L(n))return ee(0,le(n),t);if(U(n))return ee(0,n.toNumber(),t)}else if(Y(e)){if(Y(n))return ee(e,n,t);if(L(n))return ee(e,le(n),t);if(null===n||n===R)return ee(e,0,t);if(v(n))return ee(e,le(n),t);if(U(n))return ee(e,n.toNumber(),t)}else if(v(e)){if(v(n))return ee(re(e),re(n),t);if(U(n))return ee(le(e),n.toNumber(),t);if(Y(n))return ee(le(e),n,t);if(null===n||n===R)return ee(le(e),0,t);if(L(n))return ee(le(e),le(n),t)}else if(U(e)){if(U(n))return ee(e.toNumber(),n.toNumber(),t);if(null===n||n===R)return ee(e.toNumber(),0,t);if(Y(n))return ee(e.toNumber(),n,t);if(L(n))return ee(e.toNumber(),le(n),t);if(v(n))return ee(e.toNumber(),le(n),t)}else if(L(e)){if(L(n))return ee(e,n,t);if(Y(n))return ee(le(e),le(n),t);if(U(n))return ee(le(e),n.toNumber(),t);if(null===n||n===R)return ee(le(e),0,t);if(v(n))return ee(le(e),le(n),t)}return!!te(e,n)&&("<="===t||">="===t)}function te(e,n){if(e===n)return!0;if(null===e&&n===R||null===n&&e===R)return!0;if(U(e)&&U(n))return e.equals(n);if(e instanceof t)return e.equalityTest(n);if(e instanceof r)return e.equalityTest(n);if(e instanceof s&&n instanceof s){const t=e.cache._arcadeCacheId,r=n.cache._arcadeCacheId;if(null!=t)return t===r}if(H(e)&&H(n)){if(e._arcadeCacheId===n._arcadeCacheId&&void 0!==e._arcadeCacheId&&null!==e._arcadeCacheId)return!0;if(e._underlyingGraphic===n._underlyingGraphic&&void 0!==e._underlyingGraphic&&null!==e._underlyingGraphic)return!0}return!1}function re(e,t){if(v(e))return e;if(null===e)return"";if(Y(e))return Q(e,t);if(L(e))return e.toString();if(U(e))return X(e,t);if(e instanceof l)return JSON.stringify(e.toJSON());if(J(e)){const n=[];for(let t=0;t<e.length;t++)n[t]=oe(e[t]);return"["+n.join(",")+"]"}if(e instanceof n){const n=[];for(let t=0;t<e.length();t++)n[t]=oe(e.get(t));return"["+n.join(",")+"]"}return null!==e&&"object"==typeof e&&void 0!==e.castToText?e.castToText():C(e)?"object, Function":e===R?"":w(e)?"object, Module":""}function ae(e){const t=[];if(!J(e))return null;if(e instanceof n){for(let n=0;n<e.length();n++)t[n]=le(e.get(n));return t}for(let n=0;n<e.length;n++)t[n]=le(e[n]);return t}function ie(e,t,r=!1){if(v(e))return e;if(null===e)return"";if(Y(e))return Q(e,t);if(L(e))return e.toString();if(U(e))return X(e,t);if(e instanceof l)return e instanceof o?'{"xmin":'+e.xmin.toString()+',"ymin":'+e.ymin.toString()+","+(e.hasZ?'"zmin":'+e.zmin.toString()+",":"")+(e.hasM?'"mmin":'+e.mmin.toString()+",":"")+'"xmax":'+e.xmax.toString()+',"ymax":'+e.ymax.toString()+","+(e.hasZ?'"zmax":'+e.zmax.toString()+",":"")+(e.hasM?'"mmax":'+e.mmax.toString()+",":"")+'"spatialReference":'+ge(e.spatialReference)+"}":ge(e.toJSON(),((e,n)=>e.key===n.key?0:"spatialReference"===e.key?1:"spatialReference"===n.key||e.key<n.key?-1:e.key>n.key?1:0));if(J(e)){const n=[];for(let t=0;t<e.length;t++)n[t]=oe(e[t],r);return"["+n.join(",")+"]"}if(e instanceof n){const n=[];for(let t=0;t<e.length();t++)n[t]=oe(e.get(t),r);return"["+n.join(",")+"]"}return null!==e&&"object"==typeof e&&void 0!==e.castToText?e.castToText(r):C(e)?"object, Function":e===R?"":w(e)?"object, Module":""}function oe(e,t=!1){if(null===e)return"null";if(L(e)||Y(e)||v(e))return JSON.stringify(e);if(e instanceof l)return ie(e,null,t);if(e instanceof n)return ie(e,null,t);if(e instanceof Array)return ie(e,null,t);if(U(e))return t?JSON.stringify(e.getTime()):JSON.stringify(X(e,""));if(null!==e&&"object"==typeof e){if(void 0!==e.castToText)return e.castToText(t)}else if(e===R)return"null";return"null"}function le(e,n){return Y(e)?e:null===e||""===e?0:U(e)?NaN:L(e)?e?1:0:J(e)||""===e||void 0===e?NaN:void 0!==n&&v(e)?(n=I(n,"‰",""),n=I(n,"¤",""),p(e,{pattern:n})):e===R?0:Number(e)}function ue(e,n){if(U(e))return e;if(v(e)){const t=se(e,n);if(t)return a.dateTimeToArcadeDate(t)}return null}function se(e,n){const t=/ (\d\d)/,r=i(n);let a=m.fromISO(e,{zone:r});return a.isValid||t.test(e)&&(e=e.replace(t,"T$1"),a=m.fromISO(e,{zone:n}),a.isValid)?a:null}function fe(e){return L(e)?e:v(e)?"true"===(e=e.toLowerCase()):!!Y(e)&&(0!==e&&!isNaN(e))}function ce(e,n){return d(e)?null:(null!==e.spatialReference&&void 0!==e.spatialReference||(e.spatialReference=n),e)}function me(e){if(null===e)return null;if(e instanceof s)return"NaN"===e.x||null===e.x||isNaN(e.x)?null:e;if(e instanceof f){if(0===e.rings.length)return null;for(const n of e.rings)if(n.length>0)return e;return null}if(e instanceof c){if(0===e.paths.length)return null;for(const n of e.paths)if(n.length>0)return e;return null}return e instanceof u?0===e.points.length?null:e:e instanceof o?"NaN"===e.xmin||null===e.xmin||isNaN(e.xmin)?null:e:null}function de(e,n){if(!e)return n;if(!e.domain)return n;let t=null;if("string"===e.field.type||"esriFieldTypeString"===e.field.type)n=re(n);else{if(null==n)return null;if(""===n)return n;n=le(n)}for(let r=0;r<e.domain.codedValues.length;r++){const a=e.domain.codedValues[r];a.code===n&&(t=a)}return null===t?n:t.name}function ye(e,n){if(!e)return n;if(!e.domain)return n;let t=null;n=re(n);for(let r=0;r<e.domain.codedValues.length;r++){const a=e.domain.codedValues[r];a.name===n&&(t=a)}return null===t?n:t.code}function pe(e,n,t=null,r=null){if(!n)return null;if(!n.fields)return null;let a,i,o=null;for(let l=0;l<n.fields.length;l++){const t=n.fields[l];t.name.toLowerCase()===e.toString().toLowerCase()&&(o=t)}if(null===o)throw new N(null,T.FieldNotFound,null,{key:e});return null===r&&t&&n.typeIdField&&(r=t.hasField(n.typeIdField)?t.field(n.typeIdField):null),null!=r&&n.types.some((e=>e.id===r&&(a=e.domains&&e.domains[o.name],a&&"inherited"===a.type&&(a=he(o.name,n),i=!0),!0))),i||a||(a=he(e,n)),{field:o,domain:a}}function he(e,n){let t;return n.fields.some((n=>(n.name.toLowerCase()===e.toLowerCase()&&(t=n.domain),!!t))),t}function ge(e,n){n||(n={}),"function"==typeof n&&(n={cmp:n});const t="boolean"==typeof n.cycles&&n.cycles,r=n.cmp&&(a=n.cmp,function(e){return function(n,t){const r={key:n,value:e[n]},i={key:t,value:e[t]};return a(r,i)}});var a;const i=[];return function e(n){if(n&&n.toJSON&&"function"==typeof n.toJSON&&(n=n.toJSON()),void 0===n)return;if("number"==typeof n)return isFinite(n)?""+n:"null";if("object"!=typeof n)return JSON.stringify(n);let a,o;if(Array.isArray(n)){for(o="[",a=0;a<n.length;a++)a&&(o+=","),o+=e(n[a])||"null";return o+"]"}if(null===n)return"null";if(i.includes(n)){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const l=i.push(n)-1,u=Object.keys(n).sort(r&&r(n));for(o="",a=0;a<u.length;a++){const t=u[a],r=e(n[t]);r&&(o&&(o+=","),o+=JSON.stringify(t)+":"+r)}return i.splice(l,1),"{"+o+"}"}(e)}function be(e){if(null===e)return null;const n=[];for(const t of e)t&&t.arcadeDeclaredClass&&"esri.arcade.Feature"===t.arcadeDeclaredClass?n.push(t.geometry()):n.push(t);return n}function xe(e,n){if(!(n instanceof s))throw new N(null,T.InvalidParameter,null);e.push(n.hasZ?n.hasM?[n.x,n.y,n.z,n.m]:[n.x,n.y,n.z]:[n.x,n.y])}function Se(e,n){if(J(e)||V(e)){let t=!1,a=!1,i=[],o=n;if(J(e)){for(const n of e)xe(i,n);i.length>0&&(o=e[0].spatialReference,t=e[0].hasZ,a=e[0].hasM)}else if(e instanceof r)i=e._elements,i.length>0&&(t=e._hasZ,a=e._hasM,o=e.get(0).spatialReference);else{if(!V(e))throw new N(null,T.InvalidParameter,null);for(const n of e.toArray())xe(i,n);i.length>0&&(o=e.get(0).spatialReference,t=!0===e.get(0).hasZ,a=!0===e.get(0).hasM)}if(0===i.length)return null;return h(i,a,t)||(i=i.slice(0).reverse()),new f({rings:[i],spatialReference:o,hasZ:t,hasM:a})}return e}function Ne(e,n){if(J(e)||V(e)){let t=!1,a=!1,i=[],o=n;if(J(e)){for(const n of e)xe(i,n);i.length>0&&(o=e[0].spatialReference,t=!0===e[0].hasZ,a=!0===e[0].hasM)}else if(e instanceof r)i=e._elements,i.length>0&&(t=e._hasZ,a=e._hasM,o=e.get(0).spatialReference);else if(V(e)){for(const n of e.toArray())xe(i,n);i.length>0&&(o=e.get(0).spatialReference,t=!0===e.get(0).hasZ,a=!0===e.get(0).hasM)}return 0===i.length?null:new c({paths:[i],spatialReference:o,hasZ:t,hasM:a})}return e}function Te(e,n){if(J(e)||V(e)){let t=!1,a=!1,i=[],o=n;if(J(e)){for(const n of e)xe(i,n);i.length>0&&(o=e[0].spatialReference,t=!0===e[0].hasZ,a=!0===e[0].hasM)}else if(e instanceof r)i=e._elements,i.length>0&&(t=e._hasZ,a=e._hasM,o=e.get(0).spatialReference);else if(V(e)){for(const n of e.toArray())xe(i,n);i.length>0&&(o=e.get(0).spatialReference,t=!0===e.get(0).hasZ,a=!0===e.get(0).hasM)}return 0===i.length?null:new u({points:i,spatialReference:o,hasZ:t,hasM:a})}return e}function Me(e,t=!1){const r=[];if(null===e)return r;if(!0===J(e)){for(let n=0;n<e.length;n++){const a=re(e[n]);""===a&&!0!==t||r.push(a)}return r}if(e instanceof n){for(let n=0;n<e.length();n++){const a=re(e.get(n));""===a&&!0!==t||r.push(a)}return r}if(O(e)){const n=re(e);return""===n&&!0!==t||r.push(n),r}return[]}let ke=0;function je(e){return ke++,ke%100==0?(ke=0,new Promise((n=>{setTimeout((()=>{n(e)}),0)}))):e}function Ae(e,n,t){switch(t){case"&":return e&n;case"|":return e|n;case"^":return e^n;case"<<":return e<<n;case">>":return e>>n;case">>>":return e>>>n}}function Re(e,t=null){return null==e?null:L(e)||Y(e)||v(e)?e:e instanceof l?!0===t?.keepGeometryType?e:e.toJSON():e instanceof n?e.toArray().map((e=>Re(e,t))):e instanceof Array?e.map((e=>Re(e,t))):q(e)?e:U(e)?e.toJSDate():null!==e&&"object"==typeof e&&void 0!==e.castAsJson?e.castAsJson(t):null}async function De(e,n,t,r,a){const i=await Fe(e,n,t);a[r]=i}async function Fe(e,t=null,r=null){if(e instanceof n&&(e=e.toArray()),null==e)return null;if(O(e)||e instanceof l||q(e)||U(e))return Re(e,r);if(e instanceof Array){const n=[],a=[];for(const i of e)null===i||O(i)||i instanceof l||q(i)||U(i)?a.push(Re(i,r)):(a.push(null),n.push(De(i,t,r,a.length-1,a)));return n.length>0&&await Promise.all(n),a}return null!==e&&"object"==typeof e&&void 0!==e.castAsJsonAsync?e.castAsJsonAsync(t,r):null}function Ie(e,n,t){const r=e.fullSchema();if(null===r)return null;if(!r.fields)return null;return pe(n,r,e,t)}function Ce(e){const n=e.fullSchema();return null===n?null:n.fields&&n.typeIdField?{subtypeField:n.typeIdField,subtypes:n.types?n.types.map((e=>({name:e.name,code:e.id}))):[]}:null}function we(e,n,t,r){const a=e.fullSchema();if(null===a)return null;if(!a.fields)return null;const i=pe(n,a,e,r);if(void 0===t)try{t=e.field(n)}catch(o){return null}return de(i,t)}function Oe(e,n,t,r){const a=e.fullSchema();if(null===a)return null;if(!a.fields)return null;if(void 0===t){try{t=e.field(n)}catch(i){return null}return t}return ye(pe(n,a,e,r),t)}function Ze(e){return e?.timeReference?.timeZone?e?.timeReference?.timeZone:"system"}function _e(e){const n=e.fullSchema();if(null===n)return null;if(!n.fields)return null;const t=[];for(const r of n.fields)t.push(b(r));return{objectIdField:n.objectIdField,globalIdField:n.globalIdField,geometryType:void 0===x[n.geometryType]?"":x[n.geometryType],fields:t,datesInUnknownTimezone:!0===n.datesInUnknownTimezone,preferredTimeReference:n.preferredTimeReference||null,editFieldsInfo:n.editFieldsInfo||null,timeInfo:n.timeInfo||null,dateFieldsTimeReference:n.dateFieldsTimeReference||null}}const ve=Object.freeze(Object.defineProperty({__proto__:null,ImplicitResult:j,ImplicitResultE:k,ReturnResult:A,ReturnResultE:M,absRound:W,autoCastArrayOfPointsToMultiPoint:Te,autoCastArrayOfPointsToPolygon:Se,autoCastArrayOfPointsToPolyline:Ne,autoCastFeatureToGeometry:be,binaryOperator:Ae,breakResult:D,castAsJson:Re,castAsJsonAsync:Fe,continueResult:F,defaultTimeZone:Ze,defaultUndefined:Z,equalityTest:te,featureDomainCodeLookup:Oe,featureDomainValueLookup:we,featureFullDomain:Ie,featureSchema:_e,featureSubtypes:Ce,fixNullGeometry:me,fixSpatialReference:ce,formatDate:X,formatNumber:Q,generateUUID:$,getDomain:pe,getDomainCode:ye,getDomainValue:de,getType:_,greaterThanLessThan:ne,isArray:J,isBoolean:L,isDate:U,isFeature:z,isFeatureSet:G,isFeatureSetCollection:E,isFunctionParameter:C,isImmutableArray:V,isInteger:P,isJsDate:q,isModule:w,isNumber:Y,isObject:H,isSimpleType:O,isString:v,multiReplace:I,pcCheck:B,stableStringify:ge,standardiseDateFormat:K,tick:je,toBoolean:fe,toDate:ue,toNumber:le,toNumberArray:ae,toString:re,toStringArray:Me,toStringExplicit:ie,voidOperation:R},Symbol.toStringTag,{value:"Module"}));export{M as $,Z as A,_ as B,Ze as C,K as D,W as E,me as F,be as G,Ne as H,j as I,Se as J,Te as K,I as L,$ as M,_e as N,Ce as O,Ie as P,we as Q,A as R,Oe as S,G as T,E as U,ae as V,je as W,Me as X,pe as Y,de as Z,ye as _,L as a,k as a0,w as a1,H as a2,q as a3,Q as a4,X as a5,ge as a6,Y as b,v as c,Re as d,Fe as e,O as f,le as g,fe as h,C as i,re as j,U as k,ue as l,J as m,ve as n,D as o,F as p,ce as q,ne as r,te as s,ie as t,Ae as u,R as v,z as w,V as x,B as y,P as z};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{assumeNonNull as e}from"./maybe.js";import{nextTick as t}from"./nextTick.js";import r from"./PerformanceSampler.js";import s from"./PooledArray.js";import{createResolver as o,isAborted as n,createAbortError as a}from"./promiseUtils.js";import{Milliseconds as i}from"./time.js";class c{constructor(e){this.phases=e,this.paused=!1,this.ticks=-1,this.removed=!1}}class m{constructor(e){this.callback=e,this.isActive=!0}remove(){this.isActive=!1}}let l=0,p=0;const u={time:i(0),deltaTime:i(0),elapsedFrameTime:i(0),frameDuration:i(0)},f=["prepare","preRender","render","postRender","update","finish"],h=[],d=new s;class w{constructor(e){this._task=e}remove(){this._task.removed=!0}pause(){this._task.paused=!0}resume(){this._task.paused=!1}}const k={frameTasks:d,willDispatch:!1,clearFrameTasks:j,dispatch:b,executeFrameTasks:D};function v(e){const r=new m(e);return h.push(r),k.willDispatch||(k.willDispatch=!0,t(b)),r}function A(e){const t=new c(e);return d.push(t),null==T&&(l=performance.now(),T=requestAnimationFrame(x)),new w(t)}let T=null;function j(e=!1){d.forAll((e=>{e.removed=!0})),e&&_()}function F(e){p=Math.max(0,e)}function x(){const e=performance.now();T=null,T=d.length>0?requestAnimationFrame(x):null,k.executeFrameTasks(e)}function D(e){const t=i(e-l);l=e;const r=p>0?p:1e3/60,s=Math.max(0,t-r);for(let o=0;o<f.length;o++){const n=performance.now(),a=f[o];d.forAll((n=>{if(n.paused||n.removed)return;0===o&&n.ticks++;n.phases[a]&&(u.time=e,u.deltaTime=0===n.ticks?i(0):t,u.elapsedFrameTime=i(performance.now()-e),u.frameDuration=i(r-s),n.phases[a]?.call(n,u))})),R[o].record(performance.now()-n)}_(),q.record(performance.now()-e)}const g=new s;function _(){d.forAll((e=>{e.removed&&g.push(e)})),d.removeUnorderedMany(g.data,g.length),g.clear()}function b(){for(;h.length;){const t=e(h.shift());t.isActive&&t.callback()}k.willDispatch=!1}function y(e=1,r){const s=o(),i=()=>{n(r)?s.reject(a()):0===e?s():(--e,t((()=>i())))};return i(),s.promise}function M(){const e=o(),t=A({postRender:()=>{t.remove(),v(e)}});return e.promise}const R=f.map((e=>new r(e))),q=new r("total");export{w as FrameTaskHandle,A as addFrameTask,k as debug,R as performanceInfo,q as performanceTotal,v as schedule,F as setFrameDuration,M as waitAnimationFrame,y as waitTicks};
5
+ import{assumeNonNull as e}from"./maybe.js";import{nextTick as t}from"./nextTick.js";import r from"./PerformanceSampler.js";import s from"./PooledArray.js";import{createResolver as o,isAborted as n,createAbortError as a}from"./promiseUtils.js";import{Milliseconds as i}from"./time.js";class c{constructor(e){this.phases=e,this.paused=!1,this.ticks=-1,this.removed=!1}}class m{constructor(e){this.callback=e,this.isActive=!0}remove(){this.isActive=!1}}let l=0,p=0;const u={time:i(0),deltaTime:i(0),elapsedFrameTime:i(0),frameDuration:i(0)},f=["prepare","preRender","render","postRender","update","finish"],h=[],d=new s;class w{constructor(e){this._task=e}remove(){this._task.removed=!0}pause(){this._task.paused=!0}resume(){this._task.paused=!1}}const k={frameTasks:d,willDispatch:!1,clearFrameTasks:j,dispatch:b,executeFrameTasks:D};function v(e){const r=new m(e);return h.push(r),k.willDispatch||(k.willDispatch=!0,t(b)),r}function A(e){const t=new c(e);return d.push(t),null==T&&(l=performance.now(),T=requestAnimationFrame(x)),new w(t)}let T=null;function j(e=!1){d.forAll((e=>{e.removed=!0})),e&&_()}function F(e){p=Math.max(0,e)}function x(){const e=performance.now();T=null,T=d.length>0?requestAnimationFrame(x):null,k.executeFrameTasks(e)}function D(e){const t=i(e-l);l=e;const r=p>0?p:1e3/60,s=Math.max(0,t-r);u.time=e,u.frameDuration=i(r-s);for(let o=0;o<f.length;o++){const r=performance.now(),s=f[o];d.forAll((r=>{if(r.paused||r.removed)return;0===o&&r.ticks++;r.phases[s]&&(u.elapsedFrameTime=i(performance.now()-e),u.deltaTime=0===r.ticks?i(0):t,r.phases[s]?.call(r,u))})),R[o].record(performance.now()-r)}_(),q.record(performance.now()-e)}const g=new s;function _(){d.forAll((e=>{e.removed&&g.push(e)})),d.removeUnorderedMany(g.data,g.length),g.clear()}function b(){for(;h.length;){const t=e(h.shift());t.isActive&&t.callback()}k.willDispatch=!1}function y(e=1,r){const s=o(),i=()=>{n(r)?s.reject(a()):0===e?s():(--e,t((()=>i())))};return i(),s.promise}function M(){const e=o(),t=A({postRender:()=>{t.remove(),v(e)}});return e.promise}const R=f.map((e=>new r(e))),q=new r("total");export{w as FrameTaskHandle,A as addFrameTask,k as debug,R as performanceInfo,q as performanceTotal,v as schedule,F as setFrameDuration,M as waitAnimationFrame,y as waitTicks};
package/interfaces.d.ts CHANGED
@@ -6557,7 +6557,7 @@ declare namespace __esri {
6557
6557
  */
6558
6558
  readonly isWrappable: boolean;
6559
6559
  /**
6560
- * The factor to convert one unit value in the spatial reference's [`unit`](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#unit) to meter.
6560
+ * The factor to convert one unit value in the spatial reference's [unit](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#unit) to meters.
6561
6561
  *
6562
6562
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#metersPerUnit)
6563
6563
  */
@@ -39773,7 +39773,7 @@ declare namespace __esri {
39773
39773
  */
39774
39774
  data?: any;
39775
39775
  /**
39776
- * The status code of the http response.
39776
+ * _Since 4.26_ The status code of the http response.
39777
39777
  *
39778
39778
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#RequestResponse)
39779
39779
  */
@@ -85741,12 +85741,6 @@ declare namespace __esri {
85741
85741
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85742
85742
  */
85743
85743
  layer: FeatureLayer;
85744
- /**
85745
- * Indicates whether to display the attachments widget in the Editor's UI.
85746
- *
85747
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85748
- */
85749
- allowAttachments?: boolean;
85750
85744
  /**
85751
85745
  * Indicates whether to enable editing on the layer.
85752
85746
  *
@@ -85772,23 +85766,41 @@ declare namespace __esri {
85772
85766
  */
85773
85767
  deleteEnabled?: boolean;
85774
85768
  /**
85775
- * A template that defines the feature's form content.
85769
+ * Indicates whether to enable or disable attribute updates from the feature's form.
85776
85770
  *
85777
85771
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85778
85772
  */
85779
- formTemplate?: FormTemplate;
85773
+ attributeUpdatesEnabled?: boolean;
85780
85774
  /**
85781
- * Indicates whether to enable or disable attribute update from the feature's form.
85775
+ * Indicates whether to display the attachments widget in the Editor's UI.
85782
85776
  *
85783
85777
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85784
85778
  */
85785
- attributeUpdatesEnabled?: boolean;
85779
+ allowAttachments?: boolean;
85780
+ /**
85781
+ * _(Since 4.26)_ Indicates whether to enable or disable attachments while creating features.
85782
+ *
85783
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85784
+ */
85785
+ attachmentsOnCreateEnabled?: boolean;
85786
+ /**
85787
+ * _(Since 4.26)_ Indicates whether to enable or disable attachments while updating existing features.
85788
+ *
85789
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85790
+ */
85791
+ attachmentsOnUpdateEnabled?: boolean;
85786
85792
  /**
85787
85793
  * Indicates whether to enable or disable geometry updates.
85788
85794
  *
85789
85795
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85790
85796
  */
85791
85797
  geometryUpdatesEnabled?: boolean;
85798
+ /**
85799
+ * A template that defines the feature's form content.
85800
+ *
85801
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#LayerInfo)
85802
+ */
85803
+ formTemplate?: FormTemplate;
85792
85804
  }
85793
85805
 
85794
85806
  /**
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import t from"../renderers/SimpleRenderer.js";import o from"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import{rendererTypes as s,webSceneRendererTypes as n}from"../renderers/support/types.js";import p from"../request.js";import{symbolTypesRenderer as a}from"../symbols.js";import l from"../core/Error.js";import m from"../core/Logger.js";import{isSome as d}from"../core/maybe.js";import{MultiOriginJSONMixin as c}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as y}from"../core/promiseUtils.js";import{property as f}from"../core/accessorSupport/decorators/property.js";import{Integer as u}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{createTypeReader as j}from"../core/accessorSupport/extensions/serializableProperty/reader.js";import{featureGeometryTypeKebabDictionary as v}from"../geometry/support/typeUtils.js";import S from"./Layer.js";import{ArcGISService as b}from"./mixins/ArcGISService.js";import{BlendLayer as I}from"./mixins/BlendLayer.js";import{CustomParametersMixin as w}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as x}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as R}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as P}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as L}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as D}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as F}from"./mixins/TemporalLayer.js";import{labelsVisible as E,legendEnabled as U,maxScale as O,minScale as k,popupEnabled as N,screenSizePerspectiveEnabled as A,url as C}from"./support/commonProperties.js";import{defineFieldProperties as _}from"./support/fieldProperties.js";import{fixRendererFields as J,fixTimeInfoFields as G}from"./support/fieldUtils.js";import q from"./support/LabelClass.js";import{reader as V}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as M}from"../renderers/support/styleUtils.js";import W from"../rest/support/Query.js";import{createPopupTemplate as B}from"../support/popupUtils.js";import Q from"../symbols/support/ElevationInfo.js";import H from"../geometry/SpatialReference.js";import K from"../geometry/Extent.js";const X=_();let Y=class extends(R(x(I(F(D(L(b(P(T(c(w(S)))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new z,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=H.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.webSocketUrl=null}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new l("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const r=d(e)?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(y).then((()=>this._fetchService(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){J(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,r,s){const n=(r=r.layerDefinition||r).drawingInfo&&r.drawingInfo.renderer||void 0;if(n){const e=i(n,r,s)||void 0;return e||m.getLogger(this.declaredClass).error("Failed to create renderer",{rendererDefinition:r.drawingInfo.renderer,layer:this,context:s}),e}if(r.defaultSymbol)return r.types&&r.types.length?new o({defaultSymbol:Z(r.defaultSymbol,r,s),field:r.typeIdField,uniqueValueInfos:r.types.map((e=>({id:e.id,symbol:Z(e.symbol,e,s)})))}):new t({symbol:Z(r.defaultSymbol,r,s)})}async connect(e){const[{createConnection:r}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),t=this.geometryType?v.toJSON(this.geometryType):null,{customParameters:o=null,definitionExpression:i=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:p=20,spatialReference:a=this.spatialReference}=e||this.createConnectionParameters();return r(this.parsedUrl,this.spatialReference,a,t,{geometry:s,where:i},n,p,o??void 0)}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(e){return B(this,e)}createQuery(){const e=new W;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,r){if(!this.fields)return null;let t=null;return this.fields.some((r=>(r.name===e&&(t=r.domain),!!t))),t}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}async _fetchService(e){if(!!this.webSocketUrl){if(!this.timeInfo?.trackIdField)throw new l("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField)throw new l("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");if(!this.fields)throw new l("stream-layer:missing-metadata","The stream layer fields must be specified.");if(!this.geometryType)throw new l("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.url=this.webSocketUrl}else if(!this.sourceJSON){const{data:r}=await p(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=r}return this.sourceJSON={...this.sourceJSON??{},objectIdField:"__esri_stream_id__"},this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),J(this.renderer,this.fieldsIndex),G(this.timeInfo,this.fieldsIndex),M(this,{origin:"service"})}};e([f({type:String})],Y.prototype,"copyright",void 0),e([f({readOnly:!0})],Y.prototype,"defaultPopupTemplate",null),e([f({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Y.prototype,"definitionExpression",void 0),e([f({type:String})],Y.prototype,"displayField",void 0),e([f({type:Q})],Y.prototype,"elevationInfo",void 0),e([f(X.fields)],Y.prototype,"fields",void 0),e([f(X.fieldsIndex)],Y.prototype,"fieldsIndex",void 0),e([f({type:K})],Y.prototype,"geometryDefinition",void 0),e([f({type:v.apiValues,json:{read:{reader:v.read}}})],Y.prototype,"geometryType",void 0),e([f(E)],Y.prototype,"labelsVisible",void 0),e([f({type:[q],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo",reader:V},write:{target:"layerDefinition.drawingInfo.labelingInfo"}}})],Y.prototype,"labelingInfo",void 0),e([f(U)],Y.prototype,"legendEnabled",void 0),e([f({type:["show","hide"]})],Y.prototype,"listMode",void 0),e([f({type:u})],Y.prototype,"maxReconnectionAttempts",void 0),e([f({type:u})],Y.prototype,"maxReconnectionInterval",void 0),e([f(O)],Y.prototype,"maxScale",void 0),e([f(k)],Y.prototype,"minScale",void 0),e([f({type:String})],Y.prototype,"objectIdField",void 0),e([f({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],Y.prototype,"operationalLayerType",void 0),e([f(N)],Y.prototype,"popupEnabled",void 0),e([f({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],Y.prototype,"popupTemplate",void 0),e([f({type:z})],Y.prototype,"purgeOptions",void 0),e([f({types:s,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:n,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],Y.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","defaultSymbol"]),h("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],Y.prototype,"readRenderer",null),e([f(A)],Y.prototype,"screenSizePerspectiveEnabled",void 0),e([f()],Y.prototype,"sourceJSON",void 0),e([f({type:H,json:{origins:{service:{read:{source:"spatialReference"}}}}})],Y.prototype,"spatialReference",void 0),e([f({json:{read:!1}})],Y.prototype,"type",void 0),e([f(C)],Y.prototype,"url",void 0),e([f({type:Number})],Y.prototype,"updateInterval",void 0),e([f({type:String})],Y.prototype,"webSocketUrl",void 0),Y=e([g("esri.layers.StreamLayer")],Y);const Z=j({types:a}),$=Y;export{$ as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import t from"../renderers/SimpleRenderer.js";import o from"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import{rendererTypes as s,webSceneRendererTypes as n}from"../renderers/support/types.js";import p from"../request.js";import{symbolTypesRenderer as a}from"../symbols.js";import l from"../core/Error.js";import{handlesGroup as m}from"../core/handleUtils.js";import d from"../core/Logger.js";import{isSome as c}from"../core/maybe.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as f}from"../core/promiseUtils.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import{Integer as h}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{reader as g}from"../core/accessorSupport/decorators/reader.js";import{subclass as j}from"../core/accessorSupport/decorators/subclass.js";import{createTypeReader as v}from"../core/accessorSupport/extensions/serializableProperty/reader.js";import{featureGeometryTypeKebabDictionary as S}from"../geometry/support/typeUtils.js";import b from"./Layer.js";import{ArcGISService as I}from"./mixins/ArcGISService.js";import{BlendLayer as w}from"./mixins/BlendLayer.js";import{CustomParametersMixin as x}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as R}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as P}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as T}from"./mixins/OperationalLayer.js";import{PortalLayer as L}from"./mixins/PortalLayer.js";import{RefreshableLayer as D}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as F}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as E}from"./mixins/TemporalLayer.js";import{labelsVisible as U,legendEnabled as O,maxScale as k,minScale as N,popupEnabled as A,screenSizePerspectiveEnabled as C,url as _}from"./support/commonProperties.js";import{defineFieldProperties as J}from"./support/fieldProperties.js";import{fixRendererFields as M,fixTimeInfoFields as G}from"./support/fieldUtils.js";import q from"./support/LabelClass.js";import{reader as V}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as W}from"../renderers/support/styleUtils.js";import B from"../rest/support/Query.js";import{createPopupTemplate as Q}from"../support/popupUtils.js";import H from"../symbols/support/ElevationInfo.js";import K from"../geometry/SpatialReference.js";import X from"../geometry/Extent.js";const Y=J();let Z=class extends(P(R(w(E(F(D(I(T(L(y(x(b)))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new z,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=K.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.webSocketUrl=null}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new l("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const r=c(e)?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(f).then((()=>this._fetchService(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){M(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,r,s){const n=(r=r.layerDefinition||r).drawingInfo&&r.drawingInfo.renderer||void 0;if(n){const e=i(n,r,s)||void 0;return e||d.getLogger(this.declaredClass).error("Failed to create renderer",{rendererDefinition:r.drawingInfo.renderer,layer:this,context:s}),e}if(r.defaultSymbol)return r.types&&r.types.length?new o({defaultSymbol:$(r.defaultSymbol,r,s),field:r.typeIdField,uniqueValueInfos:r.types.map((e=>({id:e.id,symbol:$(e.symbol,e,s)})))}):new t({symbol:$(r.defaultSymbol,r,s)})}async connect(e){const[{createConnection:r}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),t=this.geometryType?S.toJSON(this.geometryType):null,{customParameters:o=null,definitionExpression:i=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:p=20,spatialReference:a=this.spatialReference}=e||this.createConnectionParameters(),l=r(this.parsedUrl,this.spatialReference,a,t,{geometry:s,where:i},n,p,o??void 0),d=m([this.on("send-message",(e=>l.sendMessage(e))),this.on("receive-message",(e=>l.receiveMessage(e)))]);return l.once("destroy",d.remove),l}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(e){return Q(this,e)}createQuery(){const e=new B;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,r){if(!this.fields)return null;let t=null;return this.fields.some((r=>(r.name===e&&(t=r.domain),!!t))),t}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}sendMessage(e){this.emit("send-message",e)}receiveMessage(e){this.emit("receive-message",e)}async _fetchService(e){if(!!this.webSocketUrl){if(!this.timeInfo?.trackIdField)throw new l("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField)throw new l("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");if(!this.fields)throw new l("stream-layer:missing-metadata","The stream layer fields must be specified.");if(!this.geometryType)throw new l("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.url=this.webSocketUrl}else if(!this.sourceJSON){const{data:r}=await p(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=r}return this.sourceJSON={...this.sourceJSON??{},objectIdField:"__esri_stream_id__"},this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),M(this.renderer,this.fieldsIndex),G(this.timeInfo,this.fieldsIndex),W(this,{origin:"service"})}};e([u({type:String})],Z.prototype,"copyright",void 0),e([u({readOnly:!0})],Z.prototype,"defaultPopupTemplate",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Z.prototype,"definitionExpression",void 0),e([u({type:String})],Z.prototype,"displayField",void 0),e([u({type:H})],Z.prototype,"elevationInfo",void 0),e([u(Y.fields)],Z.prototype,"fields",void 0),e([u(Y.fieldsIndex)],Z.prototype,"fieldsIndex",void 0),e([u({type:X})],Z.prototype,"geometryDefinition",void 0),e([u({type:S.apiValues,json:{read:{reader:S.read}}})],Z.prototype,"geometryType",void 0),e([u(U)],Z.prototype,"labelsVisible",void 0),e([u({type:[q],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo",reader:V},write:{target:"layerDefinition.drawingInfo.labelingInfo"}}})],Z.prototype,"labelingInfo",void 0),e([u(O)],Z.prototype,"legendEnabled",void 0),e([u({type:["show","hide"]})],Z.prototype,"listMode",void 0),e([u({type:h})],Z.prototype,"maxReconnectionAttempts",void 0),e([u({type:h})],Z.prototype,"maxReconnectionInterval",void 0),e([u(k)],Z.prototype,"maxScale",void 0),e([u(N)],Z.prototype,"minScale",void 0),e([u({type:String})],Z.prototype,"objectIdField",void 0),e([u({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],Z.prototype,"operationalLayerType",void 0),e([u(A)],Z.prototype,"popupEnabled",void 0),e([u({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],Z.prototype,"popupTemplate",void 0),e([u({type:z})],Z.prototype,"purgeOptions",void 0),e([u({types:s,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:n,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],Z.prototype,"renderer",null),e([g("service","renderer",["drawingInfo.renderer","defaultSymbol"]),g("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],Z.prototype,"readRenderer",null),e([u(C)],Z.prototype,"screenSizePerspectiveEnabled",void 0),e([u()],Z.prototype,"sourceJSON",void 0),e([u({type:K,json:{origins:{service:{read:{source:"spatialReference"}}}}})],Z.prototype,"spatialReference",void 0),e([u({json:{read:!1}})],Z.prototype,"type",void 0),e([u(_)],Z.prototype,"url",void 0),e([u({type:Number})],Z.prototype,"updateInterval",void 0),e([u({type:String})],Z.prototype,"webSocketUrl",void 0),Z=e([j("esri.layers.StreamLayer")],Z);const $=v({types:a}),ee=Z;export{ee 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.26/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 r from"../core/Logger.js";import{isSome as i,removeMaybe as s,isNone as a}from"../core/maybe.js";import{isAbortError as n}from"../core/promiseUtils.js";import{watch as o}from"../core/reactiveUtils.js";import{i as l}from"../chunks/vec3.js";import{c as h}from"../chunks/vec3f64.js";import{renderSRFromViewSR as d}from"../geometry/support/coordinateSystem.js";import{PointIndex as _,PlaneIndex as u}from"../geometry/support/frustum.js";import{WasmCullMode as c,VoxelRequestType as m,UpdateFlags as g,ContainerType as x}from"../libs/vxl/enums.js";import{loadVoxelWASM as p}from"../libs/vxl/VxlModule.js";import{ViewingMode as f}from"../views/ViewingMode.js";import{VoxelTarget as y}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as v}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as b}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as w}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{newIntersectorResult as T}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as R,StoreResults as E}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as L}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as F}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as C}from"../views/webgl/context-util.js";import{CompareFunction as V,Face as S,StencilOperation as U}from"../views/webgl/enums.js";const P=r.getLogger("esri.layers.VoxelWasmPerSceneView");var I;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(I||(I={}));class k{constructor(e){this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._renderPluginContext=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._shaderOutput=w.Color,this._renderSlot=F.VOXEL,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=R.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===I.Error?P.error(t):P.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this._view._stage&&(this._dbg(I.Lifetime,"--removeRenderPlugin--"),this._view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}_initialize(){this._dbg(I.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this._readyWatchHandle=o((()=>this._view.ready),(e=>{e&&"local"===this._view.viewingMode?(this._dbg(I.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this._view._stage.addRenderPlugin([this._renderSlot],this),this._pluginIsActive=!0):(this._dbg(I.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),{initial:!0}),this._qualityWatchHandle=o((()=>this._view?.qualityProfile),(e=>{this._dbg(I.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),{initial:!0}),this._timeExtentWatchHandle=o((()=>this._view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this._view?.timeExtent);this._dbg(I.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=o((()=>this._view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))}initializeRenderContext(e){this._dbg(I.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===C.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(I.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(I.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(I.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 r=!!this._rctx,i=!!this._renderTargetToRestore;if(!r||!i)return 0;const s=this._renderTargetToRestore.fbo.depthStencilTexture;return s?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(s,e,!0),1):(this._dbg(I.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,r){if(!this._rctx)return void this._dbg(I.Error,"modifyAllocation callback has no rendering context!");const i=e;1===r?this._rctx.instanceCounter.increment(i,t):this._rctx.instanceCounter.decrement(i,t)}_setBlendState(e,t,r,i){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,r),this._rctx.setBlendEquation(i)):this._dbg(I.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(I.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,r){this._rctx?(this._rctx.setDepthFunction(r),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(V.ALWAYS,0,255),this._rctx.setStencilOpSeparate(S.FRONT,U.KEEP,U.INCR,U.KEEP),this._rctx.setStencilOpSeparate(S.BACK,U.KEEP,U.DECR,U.KEEP)):this._dbg(I.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case c.None:this._rctx.setFaceCullingEnabled(!1);break;case c.Back:this._rctx.setCullFace(S.BACK),this._rctx.setFaceCullingEnabled(!0);break;case c.Front:this._rctx.setCullFace(S.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(I.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,r,i){this._rctx?this._rctx.setViewport(e,t,r,i):this._dbg(I.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const r=this._vxl.estimate_memory_usage(t);r>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(r))}}))}_syncRequestsResponses(){this._layers.forEach(((e,r)=>{const i=[];e.responses.forEach(((t,s)=>{i.push(s),this._dbg(I.RequestResponse,"responding for requestID:"+s+" size:"+t.size),this._vxl.respond(r,s,t),t.requestType!==m.TreeIndex&&t.requestType!==m.Section||(e.needMemoryUsageUpdate=!0)}));const s=e.responses;for(const t of i)s.delete(t);const a=this._vxl.get_new_requests(r),o=e.abortController.signal;for(const l in a){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const r=a[l],i={responseType:"array-buffer",signal:o};this._dbg(I.RequestResponse,"making requestID:"+l+" url:"+r.url),t(r.url,i).then((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(I.RequestResponse,"have response for requestID:"+l);let i=0;if(t.data.byteLength>0){i=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,i,t.data.byteLength),r=new Uint8Array(t.data);for(let i=0;i<t.data.byteLength;++i)e[i]=r[i]}s.set(+l,{responseType:r.responseType,ptr:i,size:t.data.byteLength,success:!0,requestType:r.requestType})})).catch((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),n(t)||(this._dbg(I.Error,`requestID:${l} failed, error=${t.toString()}`),s.set(+l,{responseType:r.responseType,ptr:0,size:0,success:!1,requestType:r.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){return!(this._vxl||!this._vxlPromise)||!!this._layers.has(e)&&this._layers.get(e).outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((r,i)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const r=this._vxl.get_layer_epoch_times(i,e.layer.currentVariableId);for(let e=0;e<r.length;++e)t.push(r[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((r,i)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(i))})),t}setEnabled(e,t){this._layers.forEach(((r,i)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(i,t),r.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const r={mask:g.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,r,!0)}setCurrentVariable(e,t){const r={mask:g.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,r,!0)}setRenderMode(e,t){const r={mask:g.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,r,!0)}setVerticalExaggerationAndOffset(e,t,r,i){const s={mask:g.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:r,verticalOffset:i}};return this._doMaskedUIUpdate(e,s,!0)}setVariableStyles(e,t){const r={mask:g.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setVolumeStyles(e,t){const r={mask:g.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setEnableDynamicSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:x.DynamicSections};return this._doMaskedUIUpdate(e,r,!0)}setEnableIsosurfaces(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:x.Isosurfaces};return this._doMaskedUIUpdate(e,r,!0)}setEnableSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:x.StaticSections};return this._doMaskedUIUpdate(e,r,!0)}setAnalysisSlice(e,t,r,i){const s={mask:g.AnalysisSlice,analysisSlice:{point:r,normal:i,enabled:t}};return this._doMaskedUIUpdate(e,s,!0)}_doMaskedUIUpdate(e,t,r){if(!this._vxl)return!1;let i=!1;return this._layers.forEach(((r,s)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(i=1===this._vxl.handle_masked_ui_update(s,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),i&&r&&this._renderPluginContext.requestRender(),i}_addTriangleToWasmBuffer(e,t,r,i,s){return e[3*t+0]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],e[3*(t+=1)+0]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)+0]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],t+=1}_addNormalToWasmBuffer(e,t,r){return e[3*t+0]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,r=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),i=new Float32Array(this._vxl.HEAPF32.buffer,r,3*e),s=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,s,e),n=this._frustum.points[_.NEAR_BOTTOM_LEFT],o=this._frustum.points[_.NEAR_BOTTOM_RIGHT],l=this._frustum.points[_.NEAR_TOP_RIGHT],h=this._frustum.points[_.NEAR_TOP_LEFT],d=this._frustum.points[_.FAR_BOTTOM_LEFT],c=this._frustum.points[_.FAR_BOTTOM_RIGHT],m=this._frustum.points[_.FAR_TOP_RIGHT],g=this._frustum.points[_.FAR_TOP_LEFT];let x=0,p=0;const f=this._frustum.planes[u.NEAR];x=this._addTriangleToWasmBuffer(i,x,l,o,n),p=this._addNormalToWasmBuffer(a,p,f),x=this._addTriangleToWasmBuffer(i,x,n,h,l),p=this._addNormalToWasmBuffer(a,p,f);const y=this._frustum.planes[u.FAR];x=this._addTriangleToWasmBuffer(i,x,d,c,m),p=this._addNormalToWasmBuffer(a,p,y),x=this._addTriangleToWasmBuffer(i,x,m,g,d),p=this._addNormalToWasmBuffer(a,p,y);const v=this._frustum.planes[u.TOP];x=this._addTriangleToWasmBuffer(i,x,m,l,h),p=this._addNormalToWasmBuffer(a,p,v),x=this._addTriangleToWasmBuffer(i,x,h,g,m),p=this._addNormalToWasmBuffer(a,p,v);const b=this._frustum.planes[u.BOTTOM];x=this._addTriangleToWasmBuffer(i,x,n,o,c),p=this._addNormalToWasmBuffer(a,p,b),x=this._addTriangleToWasmBuffer(i,x,c,d,n),p=this._addNormalToWasmBuffer(a,p,b);const w=this._frustum.planes[u.LEFT];x=this._addTriangleToWasmBuffer(i,x,h,n,d),p=this._addNormalToWasmBuffer(a,p,w),x=this._addTriangleToWasmBuffer(i,x,d,g,h),p=this._addNormalToWasmBuffer(a,p,w);const T=this._frustum.planes[u.RIGHT];x=this._addTriangleToWasmBuffer(i,x,l,m,c),p=this._addNormalToWasmBuffer(a,p,T),x=this._addTriangleToWasmBuffer(i,x,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(r,3*e,s,e,255,0,0,64),this._vxl._free(r),this._vxl._free(s),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=b.create(f.Local,d(!1,this._view.spatialReference))),null===this._frustum&&(this._frustum=new v(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,r)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(r),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},r=new Promise(((e,r)=>{t.resolveCallback=e,t.rejectCallback=r}));return this._newLayers.push(t),r}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 r=this._newLayers.length;return 0===r&&(this._dbg(I.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}let t=-1;this._layers.forEach(((r,i)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){t=i,r.abortController.abort(),this._vxl.remove_layer(t);const s=this.layerUid.indexOf(e.layer.uid);-1!==s&&this.layerUid.splice(s,1)}})),t>=0&&this._layers.delete(t);const r=this._layers.size;return 0===r&&(this._dbg(I.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}_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,r=Number.MAX_VALUE,s=!1;return i(e)&&(e.isAllTime?s=!0:(i(e.start)&&(s=!0,t=e.start.getTime()/1e3),i(e.end)&&(s=!0,r=e.end.getTime()/1e3))),{startTime:t,endTime:r,useTime:s}}_addVoxelLayer(e){const t=e.layer;let r=-1;const i=t.getConfiguration();if(i.length<1)return-1;const s={str:i,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(s))return-1;const a=this._getTimeArgs(this._view?.timeExtent),n=this._view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(r=this._vxl.add_layer(t.serviceRoot,s.ptr,s.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this._view.qualityProfile)),s.isReusable||this._vxl._free(s.ptr),r>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const i=new AbortController;if(this._layers.set(r,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:i,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let r="";for(const i of e.layer.variables)"Int16"!==i.renderingFormat.type&&"UInt16"!==i.renderingFormat.type||(t.push(i.name),i.id===e.layer.currentVariableId&&(r=i.name));""!==r&&P.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&P.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 r="";for(const i of e.layer.variables)"Float32"===i.renderingFormat.type&&(t.push(i.name),i.id===e.layer.currentVariableId&&(r=i.name));""!==r&&P.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&P.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&P.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),r}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,r=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(r[0],r[1],r[2],t[0],t[1],t[2]);const i=this._vxl.cull();this._dbg(I.RequestResponse,"missingResourceCount="+i),this._moreToLoad=i>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==this._shaderOutput||e.bindParameters.slot!==this._renderSlot)return;for(const r of this._newLayers){const e=this._addVoxelLayer(r.layerView);-1===e?r.rejectCallback(-1):r.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(I.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._syncRequestsResponses(),this._lastFrameWasStationary=this._view.stationary,this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0),this._vxl.begin_color_frame(!this._view._stage.renderer.isFeatureEnabled(L.HighQualityVoxel),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(I.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._renderTargetToRestore.fbo=null,e.rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),e.rctx.externalVertexArrayObjectUpdate(),e.rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(I.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=p(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(I.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this._view?.timeExtent),r=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),i=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),s=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(r,i,s,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(I.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,r){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const i=r.viewport[3]-t;if(e<0||e>r.viewport[2]||t<0||t>r.viewport[3])return this._dbg(I.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${i.toFixed(0)}]]`),null;this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()};const s=r.viewForward,a=r.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],s[0],s[1],s[2]),this.updateWasmCamera(r),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,i);if(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(),n.success){return n.distanceToCamera}return null}pickObject(e,t,r,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=Math.round(e),a=Math.round(t);if(s<0||s>r.viewport[2]||a<0||a>r.viewport[3])return this._dbg(I.Error,`[js] pickObject: outOfRange, screenXY=[${s}, ${a}], vp=[${r.viewport.toString()}]`),null;this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()};const n=r.viewForward,o=r.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(r),this._vxl.begin_frame();let l=null;if(0===i.length)l=this._vxl.pick_object(s,a,0,0);else{const e={str:JSON.stringify({layerIds:i}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(s,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return 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(),l}intersect(e,t,r,i,s){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(s[0]<0||s[0]>e.camera.viewport[2]||s[1]<0||s[1]>e.camera.viewport[3])return this._dbg(I.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${s[0].toFixed(0)}, ${s[1].toFixed(0)}]`),null;const n=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&n.push(t.layerView.wasmLayerId)}));const o=this.pickObject(s[0],s[1],e.camera,n);if(a(o)||-1===o.layerId)return;const d=this._layers.get(o.layerId);if(d){const t=d.layerView.layer.uid,s=o.distanceToCamera/l(r,i),a=h();a[0]=o.worldX,a[1]=o.worldY,a[2]=o.worldZ;const n={};if(0===o.uniqueValue.length?n["Voxel.ServiceValue"]=`${o.continuousValue.toLocaleString()} ${o.continuousValueUnits}`:n["Voxel.ServiceValue"]=o.uniqueValue,n["Voxel.ServiceVariableLabel"]=o.variableLabel,n["Voxel.Position"]=o.voxelSpacePosition,o.nativeTime.length>0){const e=new Date(o.epochTime);n["Voxel.ServiceLocalTime"]=e.toString(),n["Voxel.ServiceNativeTime"]=o.nativeTime}o.hasDepth&&(n["Voxel.ServiceDepth"]=`${o.depth.toLocaleString()} ${o.depthUnits}`);const _=e=>{const r=new y(a,t,(()=>this._createVoxelGraphic(d.layerView.layer,n)));e.set(this.type,r,s,null)},u=e.results,c=e.options.store===E.ALL;if((null==u.min.dist||s<u.min.dist)&&_(u.min),(null==u.max.dist||s>u.max.dist)&&_(u.max),c){const t=T(e.ray);_(t),e.results.all.push(t)}}}_createVoxelGraphic(t,r){return new e({layer:t,sourceLayer:t,attributes:r})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,r){this._vxl&&this._vxl.set_upscaling_limits(e,t,r)}}export{k as default};
5
+ import e from"../Graphic.js";import t from"../request.js";import has from"../core/has.js";import r from"../core/Logger.js";import{isSome as i,removeMaybe as s,isNone as a}from"../core/maybe.js";import{isAbortError as n}from"../core/promiseUtils.js";import{watch as o}from"../core/reactiveUtils.js";import{i as l}from"../chunks/vec3.js";import{c as h}from"../chunks/vec3f64.js";import{renderSRFromViewSR as d}from"../geometry/support/coordinateSystem.js";import{PointIndex as _,PlaneIndex as u}from"../geometry/support/frustum.js";import{WasmCullMode as c,VoxelRequestType as m,UpdateFlags as g,ContainerType as x}from"../libs/vxl/enums.js";import{loadVoxelWASM as p}from"../libs/vxl/VxlModule.js";import{ViewingMode as f}from"../views/ViewingMode.js";import{VoxelTarget as y}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as v}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as b}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as w}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{newIntersectorResult as T}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as R,StoreResults as E}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as L}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as F}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as C}from"../views/webgl/context-util.js";import{CompareFunction as V,Face as S,StencilOperation as U}from"../views/webgl/enums.js";const P=r.getLogger("esri.layers.VoxelWasmPerSceneView");var W;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(W||(W={}));class I{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=w.Color,this._renderSlot=F.VOXEL,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=R.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===W.Error?P.error(t):P.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this._view._stage&&(this._dbg(W.Lifetime,"--removeRenderPlugin--"),this._view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}_initialize(){this._dbg(W.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this._readyWatchHandle=o((()=>this._view.ready),(e=>{e&&"local"===this._view.viewingMode?(this._dbg(W.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this._view._stage.addRenderPlugin([this._renderSlot],this),this._pluginIsActive=!0):(this._dbg(W.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),{initial:!0}),this._qualityWatchHandle=o((()=>this._view?.qualityProfile),(e=>{this._dbg(W.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),{initial:!0}),this._timeExtentWatchHandle=o((()=>this._view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this._view?.timeExtent);this._dbg(W.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=o((()=>this._view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))}initializeRenderContext(e){this._dbg(W.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===C.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(W.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(W.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(W.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 r=!!this._rctx,i=!!this._renderTargetToRestore;if(!r||!i)return 0;const s=this._renderTargetToRestore.fbo.depthStencilTexture;return s?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(s,e,!0),1):(this._dbg(W.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,r){if(!this._rctx)return void this._dbg(W.Error,"modifyAllocation callback has no rendering context!");const i=e;1===r?this._rctx.instanceCounter.increment(i,t):this._rctx.instanceCounter.decrement(i,t)}_setBlendState(e,t,r,i){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,r),this._rctx.setBlendEquation(i)):this._dbg(W.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(W.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,r){this._rctx?(this._rctx.setDepthFunction(r),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(V.ALWAYS,0,255),this._rctx.setStencilOpSeparate(S.FRONT,U.KEEP,U.INCR,U.KEEP),this._rctx.setStencilOpSeparate(S.BACK,U.KEEP,U.DECR,U.KEEP)):this._dbg(W.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case c.None:this._rctx.setFaceCullingEnabled(!1);break;case c.Back:this._rctx.setCullFace(S.BACK),this._rctx.setFaceCullingEnabled(!0);break;case c.Front:this._rctx.setCullFace(S.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(W.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,r,i){this._rctx?this._rctx.setViewport(e,t,r,i):this._dbg(W.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const r=this._vxl.estimate_memory_usage(t);r>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(r))}}))}_syncRequestsResponses(){this._layers.forEach(((e,r)=>{const i=[];e.responses.forEach(((t,s)=>{i.push(s),this._dbg(W.RequestResponse,"responding for requestID:"+s+" size:"+t.size),this._vxl.respond(r,s,t),t.requestType!==m.TreeIndex&&t.requestType!==m.Section||(e.needMemoryUsageUpdate=!0)}));const s=e.responses;for(const t of i)s.delete(t);const a=this._vxl.get_new_requests(r),o=e.abortController.signal;for(const l in a){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const r=a[l],i={responseType:"array-buffer",signal:o};this._dbg(W.RequestResponse,"making requestID:"+l+" url:"+r.url),t(r.url,i).then((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(W.RequestResponse,"have response for requestID:"+l);let i=0;if(t.data.byteLength>0){i=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,i,t.data.byteLength),r=new Uint8Array(t.data);for(let i=0;i<t.data.byteLength;++i)e[i]=r[i]}s.set(+l,{responseType:r.responseType,ptr:i,size:t.data.byteLength,success:!0,requestType:r.requestType})})).catch((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),n(t)||(this._dbg(W.Error,`requestID:${l} failed, error=${t.toString()}`),s.set(+l,{responseType:r.responseType,ptr:0,size:0,success:!1,requestType:r.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(((r,i)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const r=this._vxl.get_layer_epoch_times(i,e.layer.currentVariableId);for(let e=0;e<r.length;++e)t.push(r[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((r,i)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(i))})),t}setEnabled(e,t){this._layers.forEach(((r,i)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(i,t),r.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const r={mask:g.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,r,!0)}setCurrentVariable(e,t){const r={mask:g.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,r,!0)}setRenderMode(e,t){const r={mask:g.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,r,!0)}setVerticalExaggerationAndOffset(e,t,r,i){const s={mask:g.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:r,verticalOffset:i}};return this._doMaskedUIUpdate(e,s,!0)}setVariableStyles(e,t){const r={mask:g.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setVolumeStyles(e,t){const r={mask:g.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setEnableDynamicSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:x.DynamicSections};return this._doMaskedUIUpdate(e,r,!0)}setEnableIsosurfaces(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:x.Isosurfaces};return this._doMaskedUIUpdate(e,r,!0)}setEnableSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:x.StaticSections};return this._doMaskedUIUpdate(e,r,!0)}setAnalysisSlice(e,t,r,i){const s={mask:g.AnalysisSlice,analysisSlice:{point:r,normal:i,enabled:t}};return this._doMaskedUIUpdate(e,s,!0)}_doMaskedUIUpdate(e,t,r){if(!this._vxl)return!1;let i=!1;return this._layers.forEach(((r,s)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(i=1===this._vxl.handle_masked_ui_update(s,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),i&&r&&this._renderPluginContext.requestRender(),i}_addTriangleToWasmBuffer(e,t,r,i,s){return e[3*t+0]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],e[3*(t+=1)+0]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)+0]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],t+=1}_addNormalToWasmBuffer(e,t,r){return e[3*t+0]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,r=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),i=new Float32Array(this._vxl.HEAPF32.buffer,r,3*e),s=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,s,e),n=this._frustum.points[_.NEAR_BOTTOM_LEFT],o=this._frustum.points[_.NEAR_BOTTOM_RIGHT],l=this._frustum.points[_.NEAR_TOP_RIGHT],h=this._frustum.points[_.NEAR_TOP_LEFT],d=this._frustum.points[_.FAR_BOTTOM_LEFT],c=this._frustum.points[_.FAR_BOTTOM_RIGHT],m=this._frustum.points[_.FAR_TOP_RIGHT],g=this._frustum.points[_.FAR_TOP_LEFT];let x=0,p=0;const f=this._frustum.planes[u.NEAR];x=this._addTriangleToWasmBuffer(i,x,l,o,n),p=this._addNormalToWasmBuffer(a,p,f),x=this._addTriangleToWasmBuffer(i,x,n,h,l),p=this._addNormalToWasmBuffer(a,p,f);const y=this._frustum.planes[u.FAR];x=this._addTriangleToWasmBuffer(i,x,d,c,m),p=this._addNormalToWasmBuffer(a,p,y),x=this._addTriangleToWasmBuffer(i,x,m,g,d),p=this._addNormalToWasmBuffer(a,p,y);const v=this._frustum.planes[u.TOP];x=this._addTriangleToWasmBuffer(i,x,m,l,h),p=this._addNormalToWasmBuffer(a,p,v),x=this._addTriangleToWasmBuffer(i,x,h,g,m),p=this._addNormalToWasmBuffer(a,p,v);const b=this._frustum.planes[u.BOTTOM];x=this._addTriangleToWasmBuffer(i,x,n,o,c),p=this._addNormalToWasmBuffer(a,p,b),x=this._addTriangleToWasmBuffer(i,x,c,d,n),p=this._addNormalToWasmBuffer(a,p,b);const w=this._frustum.planes[u.LEFT];x=this._addTriangleToWasmBuffer(i,x,h,n,d),p=this._addNormalToWasmBuffer(a,p,w),x=this._addTriangleToWasmBuffer(i,x,d,g,h),p=this._addNormalToWasmBuffer(a,p,w);const T=this._frustum.planes[u.RIGHT];x=this._addTriangleToWasmBuffer(i,x,l,m,c),p=this._addNormalToWasmBuffer(a,p,T),x=this._addTriangleToWasmBuffer(i,x,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(r,3*e,s,e,255,0,0,64),this._vxl._free(r),this._vxl._free(s),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=b.create(f.Local,d(!1,this._view.spatialReference))),null===this._frustum&&(this._frustum=new v(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,r)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(r),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},r=new Promise(((e,r)=>{t.resolveCallback=e,t.rejectCallback=r}));return this._newLayers.push(t),r}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 r=this._newLayers.length;return 0===r&&(this._dbg(W.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}let t=-1;this._layers.forEach(((r,i)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){t=i,r.abortController.abort(),this._vxl.remove_layer(t);const s=this.layerUid.indexOf(e.layer.uid);-1!==s&&this.layerUid.splice(s,1)}})),t>=0&&this._layers.delete(t);const r=this._layers.size;return 0===r&&(this._dbg(W.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}_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,r=Number.MAX_VALUE,s=!1;return i(e)&&(e.isAllTime?s=!0:(i(e.start)&&(s=!0,t=e.start.getTime()/1e3),i(e.end)&&(s=!0,r=e.end.getTime()/1e3))),{startTime:t,endTime:r,useTime:s}}_addVoxelLayer(e){const t=e.layer;let r=-1;const i=t.getConfiguration();if(i.length<1)return-1;const s={str:i,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(s))return-1;const a=this._getTimeArgs(this._view?.timeExtent),n=this._view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(r=this._vxl.add_layer(t.serviceRoot,s.ptr,s.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this._view.qualityProfile)),s.isReusable||this._vxl._free(s.ptr),r>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const i=new AbortController;if(this._layers.set(r,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:i,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let r="";for(const i of e.layer.variables)"Int16"!==i.renderingFormat.type&&"UInt16"!==i.renderingFormat.type||(t.push(i.name),i.id===e.layer.currentVariableId&&(r=i.name));""!==r&&P.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&P.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 r="";for(const i of e.layer.variables)"Float32"===i.renderingFormat.type&&(t.push(i.name),i.id===e.layer.currentVariableId&&(r=i.name));""!==r&&P.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&P.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&P.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),r}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,r=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(r[0],r[1],r[2],t[0],t[1],t[2]);const i=this._vxl.cull();this._dbg(W.RequestResponse,"missingResourceCount="+i),this._moreToLoad=i>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==this._shaderOutput||e.bindParameters.slot!==this._renderSlot)return;for(const r of this._newLayers){const e=this._addVoxelLayer(r.layerView);-1===e?r.rejectCallback(-1):r.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(W.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._syncRequestsResponses(),this._lastFrameWasStationary=this._view.stationary,this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0),this._vxl.begin_color_frame(!this._view._stage.renderer.isFeatureEnabled(L.HighQualityVoxel),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(W.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._renderTargetToRestore.fbo=null,e.rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),e.rctx.externalVertexArrayObjectUpdate(),e.rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(W.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=p(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(W.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this._view?.timeExtent),r=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),i=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),s=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(r,i,s,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(W.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,r){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const i=r.viewport[3]-t;if(e<0||e>r.viewport[2]||t<0||t>r.viewport[3])return this._dbg(W.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${i.toFixed(0)}]]`),null;this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()};const s=r.viewForward,a=r.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],s[0],s[1],s[2]),this.updateWasmCamera(r),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,i);if(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(),n.success){return n.distanceToCamera}return null}pickObject(e,t,r,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=Math.round(e),a=Math.round(t);if(s<0||s>r.viewport[2]||a<0||a>r.viewport[3])return this._dbg(W.Error,`[js] pickObject: outOfRange, screenXY=[${s}, ${a}], vp=[${r.viewport.toString()}]`),null;this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()};const n=r.viewForward,o=r.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(r),this._vxl.begin_frame();let l=null;if(0===i.length)l=this._vxl.pick_object(s,a,0,0);else{const e={str:JSON.stringify({layerIds:i}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(s,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return 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(),l}intersect(e,t,r,i,s){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(s[0]<0||s[0]>e.camera.viewport[2]||s[1]<0||s[1]>e.camera.viewport[3])return this._dbg(W.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${s[0].toFixed(0)}, ${s[1].toFixed(0)}]`),null;const n=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&n.push(t.layerView.wasmLayerId)}));const o=this.pickObject(s[0],s[1],e.camera,n);if(a(o)||-1===o.layerId)return;const d=this._layers.get(o.layerId);if(d){const t=d.layerView.layer.uid,s=o.distanceToCamera/l(r,i),a=h();a[0]=o.worldX,a[1]=o.worldY,a[2]=o.worldZ;const n={};if(0===o.uniqueValue.length?n["Voxel.ServiceValue"]=`${o.continuousValue.toLocaleString()} ${o.continuousValueUnits}`:n["Voxel.ServiceValue"]=o.uniqueValue,n["Voxel.ServiceVariableLabel"]=o.variableLabel,n["Voxel.Position"]=o.voxelSpacePosition,o.nativeTime.length>0){const e=new Date(o.epochTime);n["Voxel.ServiceLocalTime"]=e.toString(),n["Voxel.ServiceNativeTime"]=o.nativeTime}o.hasDepth&&(n["Voxel.ServiceDepth"]=`${o.depth.toLocaleString()} ${o.depthUnits}`);const _=e=>{const r=new y(a,t,(()=>this._createVoxelGraphic(d.layerView.layer,n)));e.set(this.type,r,s,null)},u=e.results,c=e.options.store===E.ALL;if((null==u.min.dist||s<u.min.dist)&&_(u.min),(null==u.max.dist||s>u.max.dist)&&_(u.max),c){const t=T(e.ray);_(t),e.results.all.push(t)}}}_createVoxelGraphic(t,r){return new e({layer:t,sourceLayer:t,attributes:r})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,r){this._vxl&&this._vxl.set_upscaling_limits(e,t,r)}}export{I 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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import i from"../../../core/Handles.js";import has from"../../../core/has.js";import s from"../../../core/Logger.js";import{isNone as r,isSome as a}from"../../../core/maybe.js";import d from"../../../core/PooledArray.js";import{EsriPromiseMixin as o}from"../../../core/Promise.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{watch as h,initial as l,sync as u}from"../../../core/reactiveUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as p}from"../../../geometry/projection.js";import{create as g,intersectsSphere as m}from"../../../geometry/support/aaBoundingRect.js";import{makeDehydratedPoint as y}from"../dehydratedFeatures.js";import{PromiseQueue as x}from"../../support/PromiseQueue.js";import{viewingModeFromString as f}from"../../../views/ViewingMode.js";import{addCallback as b}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as N}from"../../../views/3d/layers/i3s/I3SIndex.js";import v from"../../../views/3d/layers/i3s/I3SLodHandling.js";import{NodeState as w,CacheState as C}from"../../../views/3d/layers/i3s/I3SNode.js";import D from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as L}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as S,getIndexCrs as I,findIntersectingNodes as V}from"../../../views/3d/layers/i3s/I3SUtil.js";import A from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{FadeDirection as F}from"../../../views/3d/layers/support/I3SLayerView.js";import{toBoundingRect as O}from"../../../views/3d/support/extentUtils.js";import{ClientType as P,maxDownloadSlots as U}from"../../../views/3d/support/index.js";import{extractSafeScaleBounds as M,scaleBoundsPredicate as q}from"../../../views/support/layerViewUtils.js";import{noBudget as G}from"../../../views/support/Scheduler.js";const j="esri.layers.graphics.controllers.I3SOnDemandController",Q=s.getLogger(j),T=100,E=2,H=1e4,R=1e-4,k=1.2,B=500,z=1.5;let K=class extends(o(t)){get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store?.lodType}get isGraphics3D(){return"points"===this.layer.profile}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(r(this.layer.priority)||"High"===this.layer.priority)}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(P.I3S_INDEX);return new L(e,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(P.I3S_DATA);return new L(e,this.layer.apiKey)}get crsVertex(){return S(this.layer)}get crsIndex(){return I(this.layer)}get layer(){return this.layerView.i3slayer}get running(){return this.updating}get rootNodeVisible(){if(a(this._index)){const e=this._index.rootNode;if(a(e))return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}constructor(e){super(e),this.screenSizeFactor=0,this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.scaleVisibilityEnabled=!0,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._idleStateCallbacks=null,this._newLoadingNodes=new d({deallocator:null}),this._loadedNodeScales=new Map,this._modificationsNodeFilteringArray=new d,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._handles=new i,this._idleQueue=new x,this._elevationUpdateNodes=new d({deallocator:null}),this._errorCount=0}initialize(){const{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new v(e),this._defaultGeometrySchema=t.store.defaultGeometrySchema,this.disableIDBCache=has("disable-feature:idb-cache"),"fields"in t&&(this._fields=t.fields,this._attributeStorageInfo=t.attributeStorageInfo),this.addResolvingPromise(Promise.all([t.indexInfo,t.when(),e.when()]).then((([i])=>{if(this.destroyed||!e||e.destroyed)return;const{view:s}=e,{resourceController:r}=s;this._setClippingArea(s.clippingArea),this.addHandles([h((()=>s?.pointsOfInterest?.focus?.renderLocation),(e=>this._pointOfInterestChanged(e)),l),h((()=>r.memoryController.memoryFactor),(()=>this._setCameraDirty()),u),h((()=>e.suspended),(e=>{const t=e?()=>this._updateViewData():()=>this._updateIdleState(!0),i=e?()=>{}:()=>this._updateIdleState(!1);!e&&a(this._index)&&this._index.invalidateAllElevationRanges(),this._idleStateCallbacks?(e&&this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=r.scheduler.registerIdleStateCallbacks(t,i)}),l),b(e.view.resourceController.scheduler,this),h((()=>e.uncompressedTextureDownsamplingEnabled),(()=>this.restartNodeLoading())),h((()=>[this.featureTarget,this.fixedFeatureTarget]),(()=>{this._setCameraDirty(),this._stableFeatureLOD=!1})),h((()=>s.state?.contentCamera),(()=>this._setCameraDirty())),h((()=>t.elevationInfo),(e=>this._elevationInfoChanged(e))),h((()=>t.effectiveScaleRange),(()=>this._scaleBoundsChanged())),h((()=>e.lodFactor),(()=>this._setCameraDirty())),h((()=>e.availableFields),(()=>this._requiredFieldsChange())),h((()=>e.holeFilling),(e=>a(this._index)&&(this._index.holeFilling=e)))]),this._updateScaleHandles(),this._viewportQueries=new A(this.crsIndex,s.renderCoordsHelper,s.state.contentCamera,!s.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?s.basemapTerrain:s.elevationProvider,f(s.viewingMode),this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._index=new N(t,i,this.indexStreamController,this._viewportQueries,Q,e.holeFilling,(t=>e.isNodeLoaded(t)),(t=>e.isNodeReloading(t)),(e=>this._shouldLoadNode(e)),(e=>this._enableFromGPUCache(e,w.Leaf)),(e=>this._needsUpdate(e)),(()=>!this.indexStreamController.busy),(t=>e.computeVisibilityObb?e.computeVisibilityObb(t):null),e?.computeNodeFiltering?t=>e.computeNodeFiltering(t):void 0),this._index.updateElevationInfo(this.layer.elevationInfo,this.isMeshPyramid),this._index.imModificationsChanged(!!e.hasModifications),this._startNodeLoading()}))),this._tmpPoint=y(0,0,0,this.crsIndex)}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;a(t)&&i?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll((e=>{const i=t.getNode(e);a(i)&&this._modificationsNodeFilteringArray.push(i)})),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._handles.destroy(),this._nodeLoader=null,W.prune(),a(X)&&(X.hide(),X=null)}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map((i=>{const s=J(e,i),r=J(t,i);return s>=0&&r>=0?{index:s,name:t[r].name,field:t[r],attributeStorageInfo:e[s]}:null})).filter((e=>null!=e&&e.name!==i))}_requiredFieldsChange(){const e=this._getRequiredAttributes();$(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=g();O(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){a(this._viewportQueries)&&(this._viewportQueries.setPointOfInterest(e),a(this._index)&&(this._index.progressiveLoadPenalty=Y.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),a(this._viewportQueries)&&a(this._index)&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateElevationChanged(e,t){const i=this._index;if(r(i)||r(i.rootNode)||r(t))return null;this.crsIndex.equals(t)||(p(e,t,Z,this.crsIndex),e=Z);const s=this._elevationUpdateNodes;return s.clear(),V(e,i.rootNode,i,(e=>s.push(e.index))),s.length&&(s.forAll((e=>i.updateElevationChanged(e))),this._setCameraDirty()),s}getParentIndex(e){return a(this._index)&&this._index.getParentIndex(e)}removeAllGeometryObbs(){a(this._index)&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return a(this._viewportQueries)?this._viewportQueries.getRenderMbs(e):null}_elevationInfoChanged(e){r(this._index)||(this._index.updateElevationInfo(e,this.isMeshPyramid),this._setCameraDirty())}_updateScaleHandles(){const e="scale-bounds";this._handles.remove(e),this._areScaleBoundsActive&&this._handles.add(this.layerView.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),e)}_scaleBoundsChanged(){this._areScaleBoundsActive||this._loadedNodeScales.clear(),this._updateScaleHandles(),this._setCameraDirty()}_scaleUpdateHandler(e){this._updateScaleInBoundingRect(e.extent,e.spatialReference),this._setCameraDirty()}_updateScaleInBoundingRect(e,t){const i=this._index;if(r(i))return;const s=i.rootNode;!r(s)&&p(e,t,Z,this.crsIndex)&&this._loadedNodeScales.forEach(((e,t)=>{const s=i.getNode(t);a(s)&&m(Z,s.mbs)&&this._loadedNodeScales.set(t,this._computeScale(s))}))}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get _areScaleBoundsActive(){const{minScale:e,maxScale:t}=M(this.layer);return this.scaleVisibilityEnabled&&(e>0||t>0)}get unloadedMemoryEstimate(){return r(this._index)||this.layerView.suspended?0:this._index.unloadedMemoryEstimate*this._lodDropFactor}get indexDepth(){return a(this._index)?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData||(this._disableMemCache=!0),this._disableMemCache=e}runTask(e,t){return this.layerView.suspended?(this._updateViewData(),this._evaluateUpdating(),-1/0):!this.layerView.visible||r(this._index)?-1/0:(this._processWithErrorLogging(e,t),this._index.maxPriority)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(i){this._errorCount<50?Q.error("Error during processing: "+i):50===this._errorCount&&Q.error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),null==this._nodeLoader||r(this._index)||(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this._isIntegratedMesh&&(e.enabled=!1),e.run((()=>this._processIndex(e))),this._updateFeatureLOD(),e.run((()=>this._processCache(e))),this._isIntegratedMesh&&(e.enabled=!0),e.run((()=>this._processNodes(e,t))),this._idleQueue.runTask(e),e.run((()=>this._prefetchIndex())),t.numIndexLoading+=this._index.indexLoading,t.numNodesLoading+=this._downloadingCount,e.run((()=>this._lodHandling.lodGlobalHandling(e))),this._evaluateUpdating())}_processIndex(e){if(r(this._index))return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update(Array.from(this._loadingNodes.keys()),e,(e=>this.updateNodeModificationStatus(e))),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(r(this._index)||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||r(this._index)||r(this._viewportQueries))return;const e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.indexMissing>B){if(this._featureLOD<=R)return;this._featureLOD/=z,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=H||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this._lod,r=this._index.checkFeatureTarget(t,s);r!==s&&(this._featureLOD=r/this._baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*k||e&&i.estimate>t))return;if(this._featureLOD<=R)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(H,Math.max(R,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(r(t))return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);a(s)&&(!this.layerView.isNodeLoaded(s.index)&&this._isNodeInScaleBounds(s));s=t.getParent(s.index))if(this._enableFromGPUCache(s,w.Hole)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(r(this._index))return!1;let i=(this._isIdle?T:E)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());a(t)&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const a=this._index.getNode(s.add.back());if(r(a)||a.cacheState!==C.Cached&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(a),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach((e=>e.abort())),this._loadingNodes.clear(),this._updatingNodes.forEach((e=>e.abort())),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=E)&&(this._downloadingCount<U&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView.suspended)e=this._cameraDirty,t=e?0:1;else{const i=(a(this._index)?this._index.indexMissing:0)+3*(a(this._index)?this._index.updates.add.length:0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.running||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||a(this._index)&&this._index.isPrefetching),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}this.updating=e,this.updatingProgress=t}_updateViewData(){if(!this._cameraDirty||r(this._index)||r(this._viewportQueries))return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this.screenSizeFactor=1/(t.perScreenPixelRatio/2),this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=Y.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.resourceController.memoryController.memoryFactor<1?1:this.layerView.progressiveLoadFactor}get _lod(){return this._featureLOD*this._baseLOD}get _baseLOD(){const e=this.layerView.lodFactor,t=this.layerView.view.resourceController.memoryController.memoryFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*t}get _lodDropFactor(){if(this.fixedFeatureTarget)return 1;const e=this.layerView.view.resourceController.memoryController;return(Math.min(e.memoryFactor,.5)-e.minQuality)/(.5-e.minQuality)}isGeometryVisible(e){return a(this._index)&&this._index.isGeometryVisible(e.index)}updateVisibility(e){a(this._index)&&this._index.invalidateNodeVisibilityCache(e)}invalidateGeometryVisibility(e){a(this._index)&&this._index.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){a(this._index)&&this._index.invalidateVisibilityObbs()}modificationsChanged(){a(this._index)&&this._index.imModificationsChanged(!!this.layerView.hasModifications),this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e))&&(!(r(this._index)||!this._index.isGeometryVisible(e.index))&&this._isNodeInScaleBounds(e))}_shouldDropNode(e){if(r(this._viewportQueries))return!1;const t=this._lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||r(e)||r(this._viewportQueries))return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,uncompressedTextureDownsamplingEnabled:this.layerView.uncompressedTextureDownsamplingEnabled,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new D(this.layer,this.dataStreamController,Q,this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e=>this._isNodeInScaleBounds(e)),((e,t)=>this._removeNodes(e,t,ee.fadeout)),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(r(t)||r(this._viewportQueries))return!1;W.clear(),this.layerView.getLoadedNodeIndices(W);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return W.filterInPlace((e=>{const i=t.getNode(e);return r(i)||!t.isGeometryVisible(e)||s(i)||!this._isNodeInScaleBounds(i)})),W.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(W,e,ee.pop),!(i&&this._lodDropFactor<1)&&(0===W.length||(W.clear(),!1))}markNodeToRemove(e){W.push(e)}removeMarkedNodes(){this._removeNodes(W,G,ee.pop)}_removeNodes(e,t,i){const s=e.length;if(0!==s&&!t.done){for(a(this._index)&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),r=this._index;i===ee.fadeout&&this.layerView.nodeFadeoutEnabled&&a(r)&&r.isGeometryVisible(s)?this.layerView.fadeNode(s,F.FadeOut,!0):this.layerView.removeNode(s),t.madeProgress()}if(this._loadedNodeScales.size>0)for(let t=e.length;t<s;t++){const i=e.data[t];this._loadedNodeScales.delete(i)}}}_needsUpdate(e){if(!e.resources.hasFeatureData||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}_updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t);($(this.layerView.getLoadedAttributes(e.index),this._requiredAttributes)?Promise.resolve(this.layerView.getAttributeData(e.index)):this._nodeLoader.loadAttributes(e,this._requiredAttributes,t.signal)).then((i=>this.schedule((()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:i},t.signal)),t.signal))).catch((i=>{if(!n(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)})).catch((()=>{})).then((()=>{this._updatingNodes.delete(e.index),this._evaluateUpdating()})),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void Q.error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).then((i=>{i&&a(this._index)&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())})).catch((e=>{if(!n(e))throw e})).finally((()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()}))}_loadAndAddNode(e,t){return e.cacheState===C.Uncached?this._loadUncached(e,t).then((()=>!1)):this._loadCached(e,t).then((t=>!t&&(e.cacheState=C.Uncached,!0))).catch((t=>!n(t)&&(e.cacheState=C.Uncached,!0)))}_enableFromGPUCache(e,t){if(this._disableMemCache||r(this._index))return!1;if(t===w.Hole&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e);return a(t)&&a(t.attributeInfo)&&$(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){a(this._index)&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateLoadStatus(e,t){const i=this._index;a(i)&&i.updateChildrenLoaded(e,t?1:-1)}_loadCached(e,t){if(this._enableFromGPUCache(e,w.Leaf))return Promise.resolve(!0);const i=this.layerView;return!this.disableIDBCache&&i.loadCachedNodeData&&i.addCachedNodeData?this.schedule((()=>i.loadCachedNodeData(e,t,((t,i)=>this._nodeLoader.loadTextures(e,t,i)))),t).then((s=>{if(r(s))return!1;const a=this._requiredAttributes;return this.reschedule((()=>this._nodeLoader.loadAttributes(e,a,t)),t).then((r=>this.reschedule((()=>i.addCachedNodeData(e,s,{loadedAttributes:a,attributeData:r},t)),t))).then((()=>(this._nodeAdded(),!0)))})):Promise.resolve(!1)}_loadUncached(e,t){return this._downloadingCount++,this._nodeLoader.loadNodeData(e,t).catch((e=>{throw this._downloadingCount--,e})).then((i=>(this._downloadingCount--,this.schedule((()=>this.layerView.addNode(e,i,t)),t)))).then((()=>{this._nodeAdded(),e.cacheState=C.Cached})).catch((t=>{if(!n(t))throw Q.error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,a(this._index)&&this._index.requestUpdate(),t}))}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&a(this._index)&&this._index.resetFailedNodes())}_getScale(e){if(this._loadedNodeScales.has(e.index))return this._loadedNodeScales.get(e.index);const t=this._computeScale(e);return this.layerView.isNodeLoaded(e.index)&&this._loadedNodeScales.set(e.index,t),t}_computeScale(e){this._tmpPoint.x=e.mbs[0],this._tmpPoint.y=e.mbs[1],this._tmpPoint.z=e.mbs[2];const t=e.mbs[3];return this.layerView.view.basemapTerrain.getSphereScale(this._tmpPoint,t)}_isNodeInScaleBounds(e){if(!this._areScaleBoundsActive)return!0;const t=this._getScale(e),{minScale:i,maxScale:s}=M(this.layer);return q(t,i,s)}updateStats(e){e.index=a(this._index)?this._index.size:0,this.isGraphics3D&&(e.detail=this._featureLOD,e.target=this.featureTarget*this._baseLOD),a(this._index)&&this._index.updateStats(e)}get test(){const e=this;return{index:this._index,set disableUpdates(t){e._updatesDisabled=t,t?e.cancelNodeLoading():e.requestUpdate()},set disableIDBCache(t){e.disableIDBCache=t},set ignoreServiceObb(t){a(e._index)&&(e._index.ignoreServiceObb=t)},shouldLoadNode:t=>e._shouldLoadNode(t)}}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),a(this._index)&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;a(t)&&t.layerFilterChanged(e),this._setCameraDirty()}};e([_({readOnly:!0})],K.prototype,"isMeshPyramid",null),e([_({readOnly:!0})],K.prototype,"isGraphics3D",null),e([_({readOnly:!0})],K.prototype,"useMaximumNumberOfFeatures",null),e([_({readOnly:!0})],K.prototype,"indexStreamController",null),e([_({readOnly:!0})],K.prototype,"dataStreamController",null),e([_({readOnly:!0})],K.prototype,"crsVertex",null),e([_({readOnly:!0})],K.prototype,"crsIndex",null),e([_()],K.prototype,"screenSizeFactor",void 0),e([_()],K.prototype,"featureTarget",void 0),e([_()],K.prototype,"fixedFeatureTarget",void 0),e([_()],K.prototype,"layerView",void 0),e([_()],K.prototype,"layer",null),e([_()],K.prototype,"updating",void 0),e([_({readOnly:!0})],K.prototype,"running",null),e([_()],K.prototype,"updatingProgress",void 0),e([_({readOnly:!0})],K.prototype,"leavesReached",void 0),e([_({constructOnly:!0})],K.prototype,"scaleVisibilityEnabled",void 0),e([_({readOnly:!0,dependsOn:[]})],K.prototype,"rootNodeVisible",null),K=e([c(j)],K);const W=new d({deallocator:null});let X;function $(e,t){return a(e)&&e.length===t.length&&e.every((e=>J(t,e.name)>=0))}function J(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const Y={factorIM:.2,factor3dObject:.05,distancePenalty:10},Z=g();var ee;!function(e){e[e.pop=0]="pop",e[e.fadeout=1]="fadeout"}(ee||(ee={}));const te=K;export{te as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import i from"../../../core/Handles.js";import has from"../../../core/has.js";import s from"../../../core/Logger.js";import{isNone as r,isSome as a}from"../../../core/maybe.js";import d from"../../../core/PooledArray.js";import{EsriPromiseMixin as o}from"../../../core/Promise.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{watch as h,initial as l,sync as u}from"../../../core/reactiveUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{projectBoundingRect as p}from"../../../geometry/projection.js";import{create as g,intersectsSphere as m}from"../../../geometry/support/aaBoundingRect.js";import{makeDehydratedPoint as y}from"../dehydratedFeatures.js";import{PromiseQueue as x}from"../../support/PromiseQueue.js";import{viewingModeFromString as f}from"../../../views/ViewingMode.js";import{addCallback as b}from"../../../views/3d/layers/i3s/I3SFrameTask.js";import{I3SIndex as N}from"../../../views/3d/layers/i3s/I3SIndex.js";import v from"../../../views/3d/layers/i3s/I3SLodHandling.js";import{NodeState as w,CacheState as C}from"../../../views/3d/layers/i3s/I3SNode.js";import D from"../../../views/3d/layers/i3s/I3SNodeLoader.js";import{I3SStreamDataController as L}from"../../../views/3d/layers/i3s/I3SStreamDataController.js";import{getVertexCrs as S,getIndexCrs as I,findIntersectingNodes as V}from"../../../views/3d/layers/i3s/I3SUtil.js";import A from"../../../views/3d/layers/i3s/I3SViewportQueries.js";import{FadeDirection as F}from"../../../views/3d/layers/support/I3SLayerView.js";import{toBoundingRect as O}from"../../../views/3d/support/extentUtils.js";import{ClientType as P,maxDownloadSlots as U}from"../../../views/3d/support/index.js";import{extractSafeScaleBounds as M,scaleBoundsPredicate as q}from"../../../views/support/layerViewUtils.js";import{noBudget as G}from"../../../views/support/Scheduler.js";const j="esri.layers.graphics.controllers.I3SOnDemandController",Q=s.getLogger(j),T=100,E=2,H=1e4,R=1e-4,k=1.2,B=500,z=1.5;let K=class extends(o(t)){get isMeshPyramid(){return"mesh-pyramids"===this.layer.profile||"MeshPyramid"===this.layer.store?.lodType}get isGraphics3D(){return"points"===this.layer.profile}get useMaximumNumberOfFeatures(){return!this.isMeshPyramid&&(r(this.layer.priority)||"High"===this.layer.priority)}get indexStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(P.I3S_INDEX);return new L(e,this.layer.apiKey)}get dataStreamController(){const e=this.layerView.view.resourceController.createStreamDataRequester(P.I3S_DATA);return new L(e,this.layer.apiKey)}get crsVertex(){return S(this.layer)}get crsIndex(){return I(this.layer)}get layer(){return this.layerView.i3slayer}get running(){return this.updating}get rootNodeVisible(){if(a(this._index)){const e=this._index.rootNode;if(a(e))return this._updateViewData(),this._index.isNodeVisible(e.index)}return!0}get index(){return this._index}constructor(e){super(e),this.screenSizeFactor=0,this.featureTarget=5e4,this.fixedFeatureTarget=!1,this.updating=!0,this.updatingProgress=1,this.leavesReached=!1,this.scaleVisibilityEnabled=!0,this._featureLOD=1,this._stableFeatureLOD=!1,this._isIdle=!1,this._cameraDirty=!0,this._invisibleDirty=!1,this._idleStateCallbacks=null,this._newLoadingNodes=new d({deallocator:null}),this._loadedNodeScales=new Map,this._modificationsNodeFilteringArray=new d,this._downloadingCount=0,this._loadingNodes=new Map,this._updatingNodes=new Map,this._progressMaxNumNodes=1,this._requiredAttributes=new Array,this._requiredAttributesDirty=!0,this._updatesDisabled=!1,this.disableIDBCache=!1,this._disableMemCache=!1,this._restartNodeLoading=!1,this._fields=null,this._attributeStorageInfo=null,this._handles=new i,this._idleQueue=new x,this._elevationUpdateNodes=new d({deallocator:null}),this._errorCount=0}initialize(){const{layerView:e,layer:t}=this;this._disableMemCache=!e.loadCachedGPUData||!e.addCachedGPUData,this._lodHandling=new v(e),this._defaultGeometrySchema=t.store.defaultGeometrySchema,this.disableIDBCache=has("disable-feature:idb-cache"),"fields"in t&&(this._fields=t.fields,this._attributeStorageInfo=t.attributeStorageInfo),this.addResolvingPromise(Promise.all([t.indexInfo,t.when(),e.when()]).then((([i])=>{if(this.destroyed||!e||e.destroyed||!i)return;const{view:s}=e,{resourceController:r}=s;this._setClippingArea(s.clippingArea),this.addHandles([h((()=>s?.pointsOfInterest?.focus?.renderLocation),(e=>this._pointOfInterestChanged(e)),l),h((()=>r.memoryController.memoryFactor),(()=>this._setCameraDirty()),u),h((()=>e.suspended),(e=>{const t=e?()=>this._updateViewData():()=>this._updateIdleState(!0),i=e?()=>{}:()=>this._updateIdleState(!1);!e&&a(this._index)&&this._index.invalidateAllElevationRanges(),this._idleStateCallbacks?(e&&this.cancelNodeLoading(),this.restartNodeLoading(),this._idleStateCallbacks.idleBegin=t,this._idleStateCallbacks.idleEnd=i):this._idleStateCallbacks=r.scheduler.registerIdleStateCallbacks(t,i)}),l),b(e.view.resourceController.scheduler,this),h((()=>e.uncompressedTextureDownsamplingEnabled),(()=>this.restartNodeLoading())),h((()=>[this.featureTarget,this.fixedFeatureTarget]),(()=>{this._setCameraDirty(),this._stableFeatureLOD=!1})),h((()=>s.state?.contentCamera),(()=>this._setCameraDirty())),h((()=>t.elevationInfo),(e=>this._elevationInfoChanged(e))),h((()=>t.effectiveScaleRange),(()=>this._scaleBoundsChanged())),h((()=>e.lodFactor),(()=>this._setCameraDirty())),h((()=>e.availableFields),(()=>this._requiredFieldsChange())),h((()=>e.holeFilling),(e=>a(this._index)&&(this._index.holeFilling=e)))]),this._updateScaleHandles(),this._viewportQueries=new A(this.crsIndex,s.renderCoordsHelper,s.state.contentCamera,!s.state.fixedContentCamera||this.isGraphics3D,this._clippingArea,this.isMeshPyramid?s.basemapTerrain:s.elevationProvider,f(s.viewingMode),this.layer.elevationInfo,{progressiveLoadFactor:this._getProgressiveLoadFactor(),screenspaceErrorBias:this._lod,angleDependentLoD:this._lod<.5}),this._index=new N(t,i,this.indexStreamController,this._viewportQueries,Q,e.holeFilling,(t=>e.isNodeLoaded(t)),(t=>e.isNodeReloading(t)),(e=>this._shouldLoadNode(e)),(e=>this._enableFromGPUCache(e,w.Leaf)),(e=>this._needsUpdate(e)),(()=>!this.indexStreamController.busy),(t=>e.computeVisibilityObb?e.computeVisibilityObb(t):null),e?.computeNodeFiltering?t=>e.computeNodeFiltering(t):void 0),this._index.updateElevationInfo(this.layer.elevationInfo,this.isMeshPyramid),this._index.imModificationsChanged(!!e.hasModifications),this._startNodeLoading()}))),this._tmpPoint=y(0,0,0,this.crsIndex)}updateNodeModificationStatus(e){const t=this._index,i=this.layerView;a(t)&&i?.updateNodeModificationStatus&&(this._modificationsNodeFilteringArray.clear(),e.forAll((e=>{const i=t.getNode(e);a(i)&&this._modificationsNodeFilteringArray.push(i)})),i.updateNodeModificationStatus(this._modificationsNodeFilteringArray),this._invisibleDirty=!0)}destroy(){this.cancelNodeLoading(),this._idleStateCallbacks&&(this._isIdle=!1,this._idleStateCallbacks.remove(),this._idleStateCallbacks=null),this._handles.destroy(),this._nodeLoader=null,W.prune(),a(X)&&(X.hide(),X=null)}_getRequiredAttributes(){if(null==this._attributeStorageInfo||!this._fields||!this.layerView.availableFields)return[];const e=this._attributeStorageInfo,t=this._fields,i=this.layer.objectIdField;return this.layerView.availableFields.map((i=>{const s=J(e,i),r=J(t,i);return s>=0&&r>=0?{index:s,name:t[r].name,field:t[r],attributeStorageInfo:e[s]}:null})).filter((e=>null!=e&&e.name!==i))}_requiredFieldsChange(){const e=this._getRequiredAttributes();$(this._requiredAttributes,e)||(this._requiredAttributes=e,this._requiredAttributesDirty=!1,this.restartNodeLoading())}requestUpdate(){this._requiredAttributesDirty=!0,this.restartNodeLoading()}_setClippingArea(e){const t=g();O(e,t,this.layerView.view.renderSpatialReference)?this._clippingArea=t:this._clippingArea=null}_pointOfInterestChanged(e){a(this._viewportQueries)&&(this._viewportQueries.setPointOfInterest(e),a(this._index)&&(this._index.progressiveLoadPenalty=Y.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate()))}updateClippingArea(e){this._setClippingArea(e),a(this._viewportQueries)&&a(this._index)&&(this._viewportQueries.updateClippingArea(this._clippingArea),this._index.invalidateVisibilityCache()),this._setCameraDirty()}_setCameraDirty(){this._cameraDirty=!0,this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateElevationChanged(e,t){const i=this._index;if(r(i)||r(i.rootNode)||r(t))return null;this.crsIndex.equals(t)||(p(e,t,Z,this.crsIndex),e=Z);const s=this._elevationUpdateNodes;return s.clear(),V(e,i.rootNode,i,(e=>s.push(e.index))),s.length&&(s.forAll((e=>i.updateElevationChanged(e))),this._setCameraDirty()),s}getParentIndex(e){return a(this._index)?this._index.getParentIndex(e):-1}removeAllGeometryObbs(){a(this._index)&&this._index.removeAllGeometryObbs()}getRenderMbs(e){return a(this._viewportQueries)?this._viewportQueries.getRenderMbs(e):null}_elevationInfoChanged(e){r(this._index)||(this._index.updateElevationInfo(e,this.isMeshPyramid),this._setCameraDirty())}_updateScaleHandles(){const e="scale-bounds";this._handles.remove(e),this._areScaleBoundsActive&&this._handles.add(this.layerView.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),e)}_scaleBoundsChanged(){this._areScaleBoundsActive||this._loadedNodeScales.clear(),this._updateScaleHandles(),this._setCameraDirty()}_scaleUpdateHandler(e){this._updateScaleInBoundingRect(e.extent,e.spatialReference),this._setCameraDirty()}_updateScaleInBoundingRect(e,t){const i=this._index;if(r(i))return;const s=i.rootNode;!r(s)&&p(e,t,Z,this.crsIndex)&&this._loadedNodeScales.forEach(((e,t)=>{const s=i.getNode(t);a(s)&&m(Z,s.mbs)&&this._loadedNodeScales.set(t,this._computeScale(s))}))}restartNodeLoading(){this._restartNodeLoading=!0,this.cancelNodeLoading(),this._evaluateUpdating()}schedule(e,t){return this._idleQueue.push(e,t)}reschedule(e,t){return this._idleQueue.unshift(e,t)}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get _areScaleBoundsActive(){const{minScale:e,maxScale:t}=M(this.layer);return this.scaleVisibilityEnabled&&(e>0||t>0)}get unloadedMemoryEstimate(){return r(this._index)||this.layerView.suspended?0:this._index.unloadedMemoryEstimate*this._lodDropFactor}get indexDepth(){return a(this._index)?this._index.maxLevel:0}set disableMemCache(e){this.layerView.loadCachedGPUData&&this.layerView.addCachedGPUData||(this._disableMemCache=!0),this._disableMemCache=e}runTask(e,t){return this.layerView.suspended?(this._updateViewData(),this._evaluateUpdating(),-1/0):!this.layerView.visible||r(this._index)?-1/0:(this._processWithErrorLogging(e,t),this._index.maxPriority)}_processWithErrorLogging(e,t){try{this._process(e,t)}catch(i){this._errorCount<50?Q.error("Error during processing: "+i):50===this._errorCount&&Q.error("Too many errors for this layer. Further errors will not be displayed."),this._errorCount++}}_process(e,t){this._restartNodeLoading&&this._startNodeLoading(),null==this._nodeLoader||r(this._index)||(this._updateViewData(),this._invisibleDirty&&this._removeInvisibleNodes(e)&&(this._invisibleDirty=!1),this._isIntegratedMesh&&(e.enabled=!1),e.run((()=>this._processIndex(e))),this._updateFeatureLOD(),e.run((()=>this._processCache(e))),this._isIntegratedMesh&&(e.enabled=!0),e.run((()=>this._processNodes(e,t))),this._idleQueue.runTask(e),e.run((()=>this._prefetchIndex())),t.numIndexLoading+=this._index.indexLoading,t.numNodesLoading+=this._downloadingCount,e.run((()=>this._lodHandling.lodGlobalHandling(e))),this._evaluateUpdating())}_processIndex(e){if(r(this._index))return!1;if(this._index.dirty){this._newLoadingNodes.clear(),this._index.update(Array.from(this._loadingNodes.keys()),e,(e=>this.updateNodeModificationStatus(e))),this._disableMemCache||(this._newLoadingNodes.pushArray(this._index.updates.add.data,this._index.updates.add.length),this._newLoadingNodes.pushArray(this._index.updates.missing.data,this._index.updates.missing.length));const t=this._index.featureEstimate.leavesReached;this._index.isLoading||t===this._get("leavesReached")||this._set("leavesReached",t)}return this._index.load()}_prefetchIndex(){return!(r(this._index)||this._loadingNodes.size>0||this._index.updates.add.length>0)&&this._index.prefetch()}_updateFeatureLOD(){if(!this.useMaximumNumberOfFeatures||r(this._index)||r(this._viewportQueries))return;const e=!this._index.isLoading,t=this.featureTarget*this._baseLOD,i=this._index.featureEstimate;if(i.estimate=i.estimate||t/2,this._index.indexMissing>B){if(this._featureLOD<=R)return;this._featureLOD/=z,this._stableFeatureLOD=!1}else if(e&&i.estimate<t){if(i.leavesReached||this._featureLOD>=H||this._stableFeatureLOD)return;const e=Math.min(10,Math.max(t/i.estimate,1.001));this._featureLOD*=e;const s=this._lod,r=this._index.checkFeatureTarget(t,s);r!==s&&(this._featureLOD=r/this._baseLOD,this._stableFeatureLOD=!0)}else{if(!(i.estimate>t*k||e&&i.estimate>t))return;if(this._featureLOD<=R)return;this._featureLOD/=1+.25*(i.estimate/t-1),this._stableFeatureLOD=!1}this._featureLOD=Math.min(H,Math.max(R,this._featureLOD)),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.requestUpdate()}_processCache(e){const t=this._index;if(r(t))return!1;for(;this._newLoadingNodes.length>0&&!e.done;){const i=this._newLoadingNodes.pop();for(let s=t.getParent(i);a(s)&&(!this.layerView.isNodeLoaded(s.index)&&this._isNodeInScaleBounds(s));s=t.getParent(s.index))if(this._enableFromGPUCache(s,w.Hole)){e.madeProgress();break}}return e.hasProgressed}_processNodes(e,t){if(r(this._index))return!1;let i=(this._isIdle?T:E)-this._loadingNodes.size;const s=this._index.updates;for(s.cancel.forEach(this._cancelNode,this),s.cancel=[];s.remove.length>0&&!e.done;)this.layerView.removeNode(s.remove.pop()),e.madeProgress();for(;s.update.length>0&&!e.done;){const t=this._index.getNode(s.update.pop());a(t)&&(this._updateLoadedNode(t),e.madeProgress())}for(;s.add.length>0&&!e.done&&i>0;){--i;const a=this._index.getNode(s.add.back());if(r(a)||a.cacheState!==C.Cached&&!this._hasNodeLoadToken(t))break;s.add.pop(),this._loadNode(a),e.madeProgress()}return e.hasProgressed}_cancelAllNodes(){this._loadingNodes.forEach((e=>e.abort())),this._loadingNodes.clear(),this._updatingNodes.forEach((e=>e.abort())),this._updatingNodes.clear()}_cancelNode(e){const t=this._loadingNodes.get(e);t&&(t.abort(),this._loadingNodes.delete(e))}_hasNodeLoadToken(e){return!(!this._isIdle&&e.numNodesLoading+this._loadingNodes.size>=E)&&(this._downloadingCount<U&&!this.dataStreamController.busy)}_evaluateUpdating(){let e=!1,t=0;if(this.layerView.suspended)e=this._cameraDirty,t=e?0:1;else{const i=(a(this._index)?this._index.indexMissing:0)+3*(a(this._index)?this._index.updates.add.length:0)+2*this._loadingNodes.size;e=!!(i>0||this._updatingNodes.size>0||this._restartNodeLoading||this._cameraDirty||this._idleQueue.running||this._lodHandling&&this._lodHandling.requiresLODGlobalHandling||a(this._index)&&this._index.isPrefetching),0===i&&(this._progressMaxNumNodes=1),this._progressMaxNumNodes=Math.max(i,this._progressMaxNumNodes),t=1-i/this._progressMaxNumNodes}this.updating=e,this.updatingProgress=t}_updateViewData(){if(!this._cameraDirty||r(this._index)||r(this._viewportQueries))return;const e=this.layerView.view,{contentCamera:t,fixedContentCamera:i}=e.state;this.screenSizeFactor=1/(t.perScreenPixelRatio/2),this._viewportQueries.updateCamera(t,!i||this.isGraphics3D),this._viewportQueries.setPointOfInterest(e.pointsOfInterest.focus.renderLocation),this._viewportQueries.updateScreenSpaceErrorBias(this._lod),this._index.invalidateVisibilityCache(),this._index.progressiveLoadPenalty=Y.distancePenalty*this._viewportQueries.distCameraToPOI(),this._index.requestUpdate(),this._stableFeatureLOD=!1,this._invisibleDirty=!0,this._cameraDirty=!1,this.notifyChange("rootNodeVisible")}_getProgressiveLoadFactor(){return this.layerView.view.resourceController.memoryController.memoryFactor<1?1:this.layerView.progressiveLoadFactor}get _lod(){return this._featureLOD*this._baseLOD}get _baseLOD(){const e=this.layerView.lodFactor,t=this.layerView.view.resourceController.memoryController.memoryFactor;return this.fixedFeatureTarget?1:(e>0?e:1)*t}get _lodDropFactor(){if(this.fixedFeatureTarget)return 1;const e=this.layerView.view.resourceController.memoryController;return(Math.min(e.memoryFactor,.5)-e.minQuality)/(.5-e.minQuality)}isGeometryVisible(e){return a(this._index)&&this._index.isGeometryVisible(e.index)}updateVisibility(e){a(this._index)&&this._index.invalidateNodeVisibilityCache(e)}invalidateGeometryVisibility(e){a(this._index)&&this._index.invalidateGeometryVisibility(e)}invalidateVisibilityObbs(){a(this._index)&&this._index.invalidateVisibilityObbs()}modificationsChanged(){a(this._index)&&this._index.imModificationsChanged(!!this.layerView.hasModifications),this._invisibleDirty=!0}_shouldLoadNode(e){return!(!this._lodHandling.shouldLoadNode(e)||this._shouldDropNode(e))&&(!(r(this._index)||!this._index.isGeometryVisible(e.index))&&this._isNodeInScaleBounds(e))}_shouldDropNode(e){if(r(this._viewportQueries))return!1;const t=this._lodDropFactor;if(t>=1||!this._lodHandling.hasNoVisibleChildren(e))return!1;return Math.abs(this._viewportQueries.calcCameraDistanceToCenter(e))-this._viewportQueries.minDistance>(this._viewportQueries.maxDistance-this._viewportQueries.minDistance)*t}_startNodeLoading(){this._restartNodeLoading=!1;const e=this._index;if(this._updatesDisabled||r(e)||r(this._viewportQueries))return;this._updateViewData(),this._requiredAttributesDirty&&(this._requiredAttributes=this._getRequiredAttributes(),this._requiredAttributesDirty=!1);const t={textureEncodings:this.layerView.supportedTextureEncodings,uncompressedTextureDownsamplingEnabled:this.layerView.uncompressedTextureDownsamplingEnabled,textureUsageMask:this.layerView.rendererTextureUsage,loadFeatureData:this.useMaximumNumberOfFeatures};this._nodeLoader=new D(this.layer,this.dataStreamController,Q,this._defaultGeometrySchema,this._requiredAttributes,t),e.requestUpdate(),this._lodHandling.startNodeLoading((e=>this._isNodeInScaleBounds(e)),((e,t)=>this._removeNodes(e,t,ee.fadeout)),e,{maxLodLevel:this._viewportQueries.maxLodLevel}),this._evaluateUpdating()}isNodeLoading(){return null!=this._nodeLoader&&null!=this._index}cancelNodeLoading(){this.isNodeLoading()&&(this.indexStreamController.cancelAll(),this.dataStreamController.cancelAll(),this._idleQueue.cancelAll(),this._cancelAllNodes(),this._nodeLoader=null,this._evaluateUpdating())}_removeInvisibleNodes(e){const t=this._index;if(r(t)||r(this._viewportQueries))return!1;W.clear(),this.layerView.getLoadedNodeIndices(W);const i=0===this._viewportQueries.maxDistance,s=i?()=>!1:e=>this._shouldDropNode(e);return W.filterInPlace((e=>{const i=t.getNode(e);return r(i)||!t.isGeometryVisible(e)||s(i)||!this._isNodeInScaleBounds(i)})),W.length>0&&this._lodHandling.setLodGlobalDirty(),this._removeNodes(W,e,ee.pop),!(i&&this._lodDropFactor<1)&&(0===W.length||(W.clear(),!1))}markNodeToRemove(e){W.push(e)}removeMarkedNodes(){this._removeNodes(W,G,ee.pop)}_removeNodes(e,t,i){const s=e.length;if(0!==s&&!t.done){for(a(this._index)&&this._index.requestUpdate();e.length>0&&!t.done;){const s=e.pop(),r=this._index;i===ee.fadeout&&this.layerView.nodeFadeoutEnabled&&a(r)&&r.isGeometryVisible(s)?this.layerView.fadeNode(s,F.FadeOut,!0):this.layerView.removeNode(s),t.madeProgress()}if(this._loadedNodeScales.size>0)for(let t=e.length;t<s;t++){const i=e.data[t];this._loadedNodeScales.delete(i)}}}_needsUpdate(e){if(!e.resources.hasFeatureData||this._updatingNodes.has(e.index))return!1;const t=this.layerView.getLoadedAttributes(e.index);return null!=t&&t!==this._requiredAttributes}_updateLoadedNode(e){const t=new AbortController;this._updatingNodes.set(e.index,t);($(this.layerView.getLoadedAttributes(e.index),this._requiredAttributes)?Promise.resolve(this.layerView.getAttributeData(e.index)):this._nodeLoader.loadAttributes(e,this._requiredAttributes,t.signal)).then((i=>this.schedule((()=>this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:i},t.signal)),t.signal))).catch((i=>{if(!n(i))return this.layerView.updateAttributes(e.index,{loadedAttributes:this._requiredAttributes,attributeData:{}},t.signal)})).catch((()=>{})).then((()=>{this._updatingNodes.delete(e.index),this._evaluateUpdating()})),this._evaluateUpdating()}_loadNode(e){if(this._loadingNodes.has(e.index))return void Q.error("already loading node "+e.index);const t=new AbortController;this._loadingNodes.set(e.index,t),this._evaluateUpdating(),this._loadAndAddNode(e,t.signal).then((i=>{i&&a(this._index)&&this._loadingNodes.get(e.index)===t&&(this._loadingNodes.delete(e.index),this._index.requestUpdate())})).catch((e=>{if(!n(e))throw e})).finally((()=>{this._loadingNodes.get(e.index)===t&&this._loadingNodes.delete(e.index),this._evaluateUpdating()}))}_loadAndAddNode(e,t){return e.cacheState===C.Uncached?this._loadUncached(e,t).then((()=>!1)):this._loadCached(e,t).then((t=>!t&&(e.cacheState=C.Uncached,!0))).catch((t=>!n(t)&&(e.cacheState=C.Uncached,!0)))}_enableFromGPUCache(e,t){if(this._disableMemCache||r(this._index))return!1;if(t===w.Hole&&!this._index.useNodeAsHole(e.index))return!0;const i=this._loadCachedGPUData(e);return!!i&&(this.layerView.addCachedGPUData(e,i,t),this._nodeAdded(),!0)}_loadCachedGPUData(e){const t=this.layerView.loadCachedGPUData(e);return a(t)&&a(t.attributeInfo)&&$(t.attributeInfo.loadedAttributes,this._requiredAttributes)?t:(this.layerView.deleteCachedGPUData(t),null)}_nodeAdded(){a(this._index)&&this._index.requestUpdate(),this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating()}updateLoadStatus(e,t){const i=this._index;a(i)&&i.updateChildrenLoaded(e,t?1:-1)}_loadCached(e,t){if(this._enableFromGPUCache(e,w.Leaf))return Promise.resolve(!0);const i=this.layerView;return!this.disableIDBCache&&i.loadCachedNodeData&&i.addCachedNodeData?this.schedule((()=>i.loadCachedNodeData(e,t,((t,i)=>this._nodeLoader.loadTextures(e,t,i)))),t).then((s=>{if(r(s))return!1;const a=this._requiredAttributes;return this.reschedule((()=>this._nodeLoader.loadAttributes(e,a,t)),t).then((r=>this.reschedule((()=>i.addCachedNodeData(e,s,{loadedAttributes:a,attributeData:r},t)),t))).then((()=>(this._nodeAdded(),!0)))})):Promise.resolve(!1)}_loadUncached(e,t){return this._downloadingCount++,this._nodeLoader.loadNodeData(e,t).catch((e=>{throw this._downloadingCount--,e})).then((i=>(this._downloadingCount--,this.schedule((()=>this.layerView.addNode(e,i,t)),t)))).then((()=>{this._nodeAdded(),e.cacheState=C.Cached})).catch((t=>{if(!n(t))throw Q.error("#loadNodeData()",this.layer,`Failed to load node '${e.id}'`,t),e.failed=!0,a(this._index)&&this._index.requestUpdate(),t}))}_updateIdleState(e){e!==this._isIdle&&(this._isIdle=e,this._evaluateUpdating(),e&&this._index&&a(this._index)&&this._index.resetFailedNodes())}_getScale(e){if(this._loadedNodeScales.has(e.index))return this._loadedNodeScales.get(e.index);const t=this._computeScale(e);return this.layerView.isNodeLoaded(e.index)&&this._loadedNodeScales.set(e.index,t),t}_computeScale(e){this._tmpPoint.x=e.mbs[0],this._tmpPoint.y=e.mbs[1],this._tmpPoint.z=e.mbs[2];const t=e.mbs[3];return this.layerView.view.basemapTerrain.getSphereScale(this._tmpPoint,t)}_isNodeInScaleBounds(e){if(!this._areScaleBoundsActive)return!0;const t=this._getScale(e),{minScale:i,maxScale:s}=M(this.layer);return q(t,i,s)}updateStats(e){e.index=a(this._index)?this._index.size:0,this.isGraphics3D&&(e.detail=this._featureLOD,e.target=this.featureTarget*this._baseLOD),a(this._index)&&this._index.updateStats(e)}get test(){const e=this;return{index:this._index,set disableUpdates(t){e._updatesDisabled=t,t?e.cancelNodeLoading():e.requestUpdate()},set disableIDBCache(t){e.disableIDBCache=t},set ignoreServiceObb(t){a(e._index)&&(e._index.ignoreServiceObb=t)},shouldLoadNode:t=>e._shouldLoadNode(t)}}notifyLODUpdate(){this._lodHandling.setLodGlobalDirty(),this._evaluateUpdating(),a(this._index)&&this._index.requestUpdate()}geometryFilterChanged(e){const t=this._index;a(t)&&t.layerFilterChanged(e),this._setCameraDirty()}};e([_({readOnly:!0})],K.prototype,"isMeshPyramid",null),e([_({readOnly:!0})],K.prototype,"isGraphics3D",null),e([_({readOnly:!0})],K.prototype,"useMaximumNumberOfFeatures",null),e([_({readOnly:!0})],K.prototype,"indexStreamController",null),e([_({readOnly:!0})],K.prototype,"dataStreamController",null),e([_({readOnly:!0})],K.prototype,"crsVertex",null),e([_({readOnly:!0})],K.prototype,"crsIndex",null),e([_()],K.prototype,"screenSizeFactor",void 0),e([_()],K.prototype,"featureTarget",void 0),e([_()],K.prototype,"fixedFeatureTarget",void 0),e([_()],K.prototype,"layerView",void 0),e([_()],K.prototype,"layer",null),e([_()],K.prototype,"updating",void 0),e([_({readOnly:!0})],K.prototype,"running",null),e([_()],K.prototype,"updatingProgress",void 0),e([_({readOnly:!0})],K.prototype,"leavesReached",void 0),e([_({constructOnly:!0})],K.prototype,"scaleVisibilityEnabled",void 0),e([_({readOnly:!0,dependsOn:[]})],K.prototype,"rootNodeVisible",null),K=e([c(j)],K);const W=new d({deallocator:null});let X;function $(e,t){return a(e)&&e.length===t.length&&e.every((e=>J(t,e.name)>=0))}function J(e,t){const i=t.toLowerCase();for(let s=0;s<e.length;s++)if(e[s].name.toLowerCase()===i)return s;return-1}const Y={factorIM:.2,factor3dObject:.05,distancePenalty:10},Z=g();var ee;!function(e){e[e.pop=0]="pop",e[e.fadeout=1]="fadeout"}(ee||(ee={}));const te=K;export{te 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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{HandleOwnerMixin as o}from"../../../core/HandleOwner.js";import{destroyMaybe as s,isSome as i}from"../../../core/maybe.js";import{EsriPromiseMixin as a}from"../../../core/Promise.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{StreamFeatureManager as l}from"../data/StreamFeatureManager.js";import{createConnection as h}from"../sources/connections/createConnection.js";import{EventedSet as d}from"../../../views/3d/support/EventedSet.js";import{featureGeometryTypeKebabDictionary as u}from"../../../geometry/support/typeUtils.js";const m=2500;let y=class extends t{getObjectId(){return this.objectId}};e([c({type:Number,json:{read:!0}})],y.prototype,"objectId",void 0),y=e([p("esri.layers.graphics.controllers.StreamGraphic")],y);class f{constructor(e){this.onUpdate=e,this._idToGraphic=new Map}destroy(){this._idToGraphic.clear()}add(e){this._idToGraphic.set(e.objectId,e)}get(e){return this._idToGraphic.get(e)}forEach(e){this._idToGraphic.forEach(e)}removeById(e){const t=this._idToGraphic.get(e);return t?(t.sourceLayer=t.layer=null,this._idToGraphic.delete(e),t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._idToGraphic.size}}let _=class extends(o(a(r))){constructor(){super(...arguments),this.graphics=new d,this._updateInfo={websocket:0,client:0},this._updateIntervalId=null,this._outSpatialReference=null}initialize(){this.addResolvingPromise(this.layer.when((()=>this._startup())))}destroy(){this.clear()}_clearInterval(){null!==this._updateIntervalId&&(clearInterval(this._updateIntervalId),this._updateIntervalId=null)}clear(){this._clearInterval(),this.connection=s(this.connection),this.store=s(this.store),this.graphics.clear(),this.handles.removeAll()}get updating(){return!this.connection||"connected"===this.connection.connectionStatus}_startup(){const{layer:e,layerView:t}=this,{spatialReference:r,definitionExpression:o,geometryDefinition:s,objectIdField:i,timeInfo:a,purgeOptions:c,maxReconnectionAttempts:p,maxReconnectionInterval:d,customParameters:m}=e,y=e.geometryType?u.toJSON(e.geometryType):null,_=r,I=t.view.spatialReference,g={geometry:s,where:o};this.clear(),this._set("connection",h(e.parsedUrl,_,I,y,g,p,d,m??void 0)),this._outSpatialReference=I.toJSON(),this.store=new f(this._onUpdate.bind(this)),this.featuresManager=new l(this.store,i,a.toJSON(),c);const v="startup-watches";this.handles.remove(v),this.handles.add([this.connection.on("data-received",(e=>this._onFeature(e))),n((()=>[e.definitionExpression,e.geometryDefinition,e.purgeOptions]),(()=>this._startup()))],v),this._initUpdateInterval()}_onFeature(e){this._updateInfo.websocket++,this.layerView.hasEventListener("data-received")&&this.layerView.emit("data-received",{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry});try{i(e.geometry)&&!e.geometry.spatialReference&&(e.geometry.spatialReference=this._outSpatialReference);const t=y.fromJSON(e);t.sourceLayer=t.layer=this.layer,this.featuresManager.add(t)}catch{}}_onUpdate(e,t){i(t)&&this.graphics.removeMany(t),i(e)&&(this._updateInfo.client+=e.length,this.graphics.addMany(e))}_initUpdateInterval(){this._clearInterval();const{updateInterval:e}=this.layer;let t=performance.now();this._updateIntervalId=setInterval((()=>{const e=performance.now(),r=e-t;if(r>m){t=e;const o=Math.round(this._updateInfo.client/(r/1e3)),s=Math.round(this._updateInfo.websocket/(r/1e3));this._updateInfo.client=0,this._updateInfo.websocket=0,this.layerView.emit("update-rate",{client:o,websocket:s})}this.featuresManager.checkForUpdates()}),e)}pauseStream(){this._clearInterval()}resumeStream(){this._initUpdateInterval()}};e([c({constructOnly:!0})],_.prototype,"layer",void 0),e([c({constructOnly:!0})],_.prototype,"layerView",void 0),e([c()],_.prototype,"connection",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),_=e([p("esri.layers.graphics.controllers.StreamController")],_);export{_ as StreamController,y as StreamGraphic};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{destroyMaybe as o,isSome as i}from"../../../core/maybe.js";import{EsriPromiseMixin as a}from"../../../core/Promise.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{StreamFeatureManager as h}from"../data/StreamFeatureManager.js";import{createConnection as d}from"../sources/connections/createConnection.js";import{EventedSet as l}from"../../../views/3d/support/EventedSet.js";import{featureGeometryTypeKebabDictionary as u}from"../../../geometry/support/typeUtils.js";const m=2500;let y=class extends t{getObjectId(){return this.objectId}};e([c({type:Number,json:{read:!0}})],y.prototype,"objectId",void 0),y=e([p("esri.layers.graphics.controllers.StreamGraphic")],y);class f{constructor(e){this.onUpdate=e,this._idToGraphic=new Map}destroy(){this._idToGraphic.clear()}add(e){this._idToGraphic.set(e.objectId,e)}get(e){return this._idToGraphic.get(e)}forEach(e){this._idToGraphic.forEach(e)}removeById(e){const t=this._idToGraphic.get(e);return t?(t.sourceLayer=t.layer=null,this._idToGraphic.delete(e),t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._idToGraphic.size}}let g=class extends(s(a(r))){constructor(){super(...arguments),this.isPaused=!1,this.graphics=new l,this._updateInfo={websocket:0,client:0},this._updateIntervalId=null,this._outSpatialReference=null}initialize(){this.addResolvingPromise(this.layer.when((()=>this._startup())))}destroy(){this.clear()}_clearInterval(){null!==this._updateIntervalId&&(clearInterval(this._updateIntervalId),this._updateIntervalId=null)}clear(){this._clearInterval(),this.connection=o(this.connection),this.store=o(this.store),this.graphics.clear(),this.handles.removeAll()}get updating(){return!this.connection||"connected"===this.connection.connectionStatus}_startup(){const{layer:e,layerView:t}=this,{spatialReference:r,definitionExpression:s,geometryDefinition:o,objectIdField:i,timeInfo:a,purgeOptions:c,maxReconnectionAttempts:p,maxReconnectionInterval:l,customParameters:m}=e,y=e.geometryType?u.toJSON(e.geometryType):null,g=r,I=t.view.spatialReference,v={geometry:o,where:s};this.clear(),this._set("connection",d(e.parsedUrl,g,I,y,v,p,l,m??void 0)),this._outSpatialReference=I.toJSON(),this.store=new f(this._onUpdate.bind(this)),this.featuresManager=new h(this.store,i,a.toJSON(),c);const _="startup-watches";this.handles.remove(_),this.handles.add([e.on("send-message",(e=>this.connection.sendMessage(e))),e.on("receive-message",(e=>this.connection.receiveMessage(e))),this.connection.on("data-received",(e=>this._onFeature(e))),this.connection.on("message-received",(e=>this._onWebSocketMessage(e))),n((()=>[e.definitionExpression,e.geometryDefinition,e.purgeOptions]),(()=>this._startup()))],_),this._initUpdateInterval()}_onWebSocketMessage(e){if(this.layerView.emit("message-received",e),"type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this.featuresManager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this.featuresManager.removeByTrackId(t);break;case"clear":this.store.forEach((e=>this.featuresManager.removeById(e.objectId)))}}_onFeature(e){this._updateInfo.websocket++,this.layerView.hasEventListener("data-received")&&this.layerView.emit("data-received",{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry});try{i(e.geometry)&&!e.geometry.spatialReference&&(e.geometry.spatialReference=this._outSpatialReference);const t=y.fromJSON(e);t.sourceLayer=t.layer=this.layer,this.featuresManager.add(t)}catch{}}_onUpdate(e,t){i(t)&&this.graphics.removeMany(t),i(e)&&(this._updateInfo.client+=e.length,this.graphics.addMany(e))}_initUpdateInterval(){this._clearInterval();const{updateInterval:e}=this.layer;let t=performance.now();this._updateIntervalId=setInterval((()=>{const e=performance.now(),r=e-t;if(r>m){t=e;const s=Math.round(this._updateInfo.client/(r/1e3)),o=Math.round(this._updateInfo.websocket/(r/1e3));this._updateInfo.client=0,this._updateInfo.websocket=0,this.layerView.emit("update-rate",{client:s,websocket:o})}this.featuresManager.checkForUpdates()}),e)}pauseStream(){this.isPaused=!0,this._clearInterval()}resumeStream(){this.isPaused=!1,this._initUpdateInterval()}};e([c()],g.prototype,"isPaused",void 0),e([c({constructOnly:!0})],g.prototype,"layer",void 0),e([c({constructOnly:!0})],g.prototype,"layerView",void 0),e([c()],g.prototype,"connection",void 0),e([c({readOnly:!0})],g.prototype,"updating",null),g=e([p("esri.layers.graphics.controllers.StreamController")],g);export{g as StreamController,y as StreamGraphic};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/CircularArray.js";import{clamp as e}from"../../../core/mathUtils.js";import{isNone as s,isSome as i,unwrap as r}from"../../../core/maybe.js";const o="__esri_stream_id__",d="__esri_timestamp__",a=1e3;class h{constructor(t,e,s,i,r=128){this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=performance.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=s,this._purgeOptions=i,this.store=t,this.objectIdField=e,this.purgeInterval=r,this._useGeneratedIds=this.objectIdField===o}add(r){if(this._useGeneratedIds){const t=this._nextId();r.attributes[this.objectIdField]=t,r.objectId=t}else r.objectId=r.attributes[this.objectIdField];const o=r.objectId;if(this._addOrUpdated.set(o,r),this._maxAge=Math.max(this._maxAge,r.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return s(this._trackIdLessObservations)&&(this._trackIdLessObservations=new t(1e5)),void this._trackIdLessObservations.enqueue(o);const d=r.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(d)){const s=i(this._purgeOptions)&&null!=this._purgeOptions.maxObservations?this._purgeOptions.maxObservations:a,r=e(s,0,a);this._trackIdToObservations.set(d,new t(r))}const h=this._trackIdToObservations.get(d)?.enqueue(o);i(h)&&(this._addOrUpdated.has(h)?this._addOrUpdated.delete(h):this._removed.push(h))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const r=[];if(i(e))for(const o of e){const t=this.store.removeById(o);i(t)&&r.push(t)}if(i(t))for(const i of t)i.attributes[d]=s,this.store.add(i);(t||r?.length)&&this.store.update(t,r)}_getToAdd(){if(!this._addOrUpdated.size)return null;const t=new Array(this._addOrUpdated.size);let e=0;return this._addOrUpdated.forEach((s=>t[e++]=s)),this._addOrUpdated.clear(),t}_getToRemove(){const t=this._removed;return this._removed.length?(this._removed=[],t):null}_nextId(){const t=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,t}_purge(t){const e=this._purgeOptions;i(e)&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeByAgeReceived(t,e),this._purgeTracks())}_purgeSomeByDisplayCount(t){if(!t.displayCount)return;let e=this.store.size;if(e>t.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(e>t.displayCount&&s.size){const t=r(s.dequeue());this._removed.push(t),e--}if(i(this._trackIdLessObservations)){let s=e-t.displayCount;for(;s-- >0;){const t=this._trackIdLessObservations.dequeue();i(t)&&this._removed.push(t)}}}}_purgeByAge(t){const e=this._timeInfo?.startTimeField;if(!t.age||!e)return;const s=60*t.age*1e3,i=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<i&&this._removed.push(t.objectId)}))}_purgeByAgeReceived(t,e){if(!e.ageReceived)return;const s=t-60*e.ageReceived*1e3;this.store.forEach((t=>{t.attributes[d]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}export{o as DEFAULT_STREAM_ID_FIELD,d as ESRI_TIMESTAMP,h as StreamFeatureManager};
5
+ import t from"../../../core/CircularArray.js";import{clamp as e}from"../../../core/mathUtils.js";import{isNone as s,isSome as i,unwrap as r}from"../../../core/maybe.js";const o="__esri_stream_id__",d="__esri_timestamp__",a=1e3;class h{constructor(t,e,s,i,r=128){this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=performance.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=s,this._purgeOptions=i,this.store=t,this.objectIdField=e,this.purgeInterval=r,this._useGeneratedIds=this.objectIdField===o}removeById(t){this._removed.push(t)}removeByTrackId(t){const e=this._trackIdToObservations.get(t);if(e)for(const s of e.entries)this._removed.push(s)}add(r){if(this._useGeneratedIds){const t=this._nextId();r.attributes[this.objectIdField]=t,r.objectId=t}else r.objectId=r.attributes[this.objectIdField];const o=r.objectId;if(this._addOrUpdated.set(o,r),this._maxAge=Math.max(this._maxAge,r.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return s(this._trackIdLessObservations)&&(this._trackIdLessObservations=new t(1e5)),void this._trackIdLessObservations.enqueue(o);const d=r.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(d)){const s=i(this._purgeOptions)&&null!=this._purgeOptions.maxObservations?this._purgeOptions.maxObservations:a,r=e(s,0,a);this._trackIdToObservations.set(d,new t(r))}const h=this._trackIdToObservations.get(d)?.enqueue(o);i(h)&&(this._addOrUpdated.has(h)?this._addOrUpdated.delete(h):this._removed.push(h))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const r=[];if(i(e))for(const o of e){const t=this.store.removeById(o);i(t)&&r.push(t)}if(i(t))for(const i of t)i.attributes[d]=s,this.store.add(i);(t||r?.length)&&this.store.update(t,r)}_getToAdd(){if(!this._addOrUpdated.size)return null;const t=new Array(this._addOrUpdated.size);let e=0;return this._addOrUpdated.forEach((s=>t[e++]=s)),this._addOrUpdated.clear(),t}_getToRemove(){const t=this._removed;return this._removed.length?(this._removed=[],t):null}_nextId(){const t=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,t}_purge(t){const e=this._purgeOptions;i(e)&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeByAgeReceived(t,e),this._purgeTracks())}_purgeSomeByDisplayCount(t){if(!t.displayCount)return;let e=this.store.size;if(e>t.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(e>t.displayCount&&s.size){const t=r(s.dequeue());this._removed.push(t),e--}if(i(this._trackIdLessObservations)){let s=e-t.displayCount;for(;s-- >0;){const t=this._trackIdLessObservations.dequeue();i(t)&&this._removed.push(t)}}}}_purgeByAge(t){const e=this._timeInfo?.startTimeField;if(!t.age||!e)return;const s=60*t.age*1e3,i=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<i&&this._removed.push(t.objectId)}))}_purgeByAgeReceived(t,e){if(!e.ageReceived)return;const s=t-60*e.ageReceived*1e3;this.store.forEach((t=>{t.attributes[d]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}export{o as DEFAULT_STREAM_ID_FIELD,d as ESRI_TIMESTAMP,h as StreamFeatureManager};