@arcgis/core 4.24.2 → 4.24.5

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.
@@ -6,10 +6,10 @@ import{isSome as e}from"../core/maybe.js";import{LayerBlendMode as o}from"../vie
6
6
  void main() {
7
7
  gl_FragColor = ${y?l`vec4(backgroundColor, 1.0)`:l`gridColor(uv)`};
8
8
  }
9
- `),u;const w=m.blendMode!==o.Normal,x=m.baseOpacityMode===g.OnBaseLayer,L=m.baseOpacityMode===g.OnBackground||m.baseOpacityMode===g.OnBaseLayer;return u.fragment.uniforms.add(new s("tex",(e=>e.texture))),u.fragment.uniforms.add(new n("opacity",(e=>e.opacity))),(w||x)&&(u.fragment.uniforms.add(new s("fboColor",(e=>e.fboTexture))),u.fragment.uniforms.add(new n("tileSize",(o=>e(o.fboTexture)?o.fboTexture.descriptor.width:1)))),u.fragment.include(i,m),u.fragment.code.add(l`
9
+ `),u;const w=m.blendMode!==o.Normal,x=m.baseOpacityMode===g.OnBaseLayer,L=m.baseOpacityMode===g.OnBackground||m.baseOpacityMode===g.OnBaseLayer,T=m.premultipliedSource;return u.fragment.uniforms.add(new s("tex",(e=>e.texture))),u.fragment.uniforms.add(new n("opacity",(e=>e.opacity))),(w||x||T)&&(u.fragment.uniforms.add(new s("fboColor",(e=>e.fboTexture))),u.fragment.uniforms.add(new n("tileSize",(o=>e(o.fboTexture)?o.fboTexture.descriptor.width:1)))),u.fragment.include(i,m),u.fragment.code.add(l`
10
10
  void main() {
11
- ${v||x?l`
12
- vec4 bgColor = ${x?l`texture2D(fboColor, gl_FragCoord.xy / tileSize)`:C?l`vec4(backgroundColor, 1.0)`:l`gridColor(uv)`};
11
+ ${v||x||T?l`
12
+ vec4 bgColor = ${C?l`vec4(backgroundColor, 1.0)`:b?l`gridColor(uv)`:l`texture2D(fboColor, gl_FragCoord.xy / tileSize)`};
13
13
  ${L?l`bgColor *= baseOpacity;`:""}`:""}
14
14
  vec4 colorLayer = texture2D(tex, uv);
15
15
  ${w?l`
@@ -18,6 +18,6 @@ import{isSome as e}from"../core/maybe.js";import{LayerBlendMode as o}from"../vie
18
18
  gl_FragColor = applyBlendMode(colorLayer.rgb, colorLayer.a * opacity, Cb, fboTex.a);`:l`
19
19
  vec4 pmColorLayer = vec4(colorLayer.xyz, 1.0);
20
20
  float composeAlpha = colorLayer.a * opacity;
21
- gl_FragColor = ${v||x?m.premultipliedSource?l`bgColor * (1.0 - composeAlpha) + colorLayer * opacity;`:l`mix(bgColor, pmColorLayer, composeAlpha);`:l`pmColorLayer * composeAlpha;`}`}
21
+ gl_FragColor = ${T?l`bgColor * (1.0 - composeAlpha) + colorLayer * opacity;`:v||x?l`mix(bgColor, pmColorLayer, composeAlpha);`:l`pmColorLayer * composeAlpha;`}`}
22
22
  }
23
23
  `),u}!function(e){e[e.Composite=0]="Composite",e[e.ColorOnly=1]="ColorOnly",e[e.GridOnly=2]="GridOnly",e[e.ColorComposite=3]="ColorComposite",e[e.GridComposite=4]="GridComposite",e[e.COUNT=5]="COUNT"}(c||(c={})),function(e){e[e.One=0]="One",e[e.OnBackground=1]="OnBackground",e[e.OnBaseLayer=2]="OnBaseLayer",e[e.COUNT=3]="COUNT"}(g||(g={}));const u=Object.freeze(Object.defineProperty({__proto__:null,get BlendLayersOutput(){return c},get BaseOpacityMode(){return g},build:m},Symbol.toStringTag,{value:"Module"}));export{c as B,g as a,u as b,m as c};
package/config.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.2";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.5";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
package/interfaces.d.ts CHANGED
@@ -20255,6 +20255,12 @@ declare namespace __esri {
20255
20255
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureReductionBinning.html#popupTemplate)
20256
20256
  */
20257
20257
  popupTemplate: PopupTemplate;
20258
+ /**
20259
+ * The renderer used to style the bins.
20260
+ *
20261
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureReductionBinning.html#renderer)
20262
+ */
20263
+ renderer: Renderer;
20258
20264
  /**
20259
20265
  * The feature reduction type.
20260
20266
  *
@@ -20324,6 +20330,12 @@ declare namespace __esri {
20324
20330
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureReductionBinning.html#popupTemplate)
20325
20331
  */
20326
20332
  popupTemplate?: PopupTemplateProperties;
20333
+ /**
20334
+ * The renderer used to style the bins.
20335
+ *
20336
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureReductionBinning.html#renderer)
20337
+ */
20338
+ renderer?: RendererProperties;
20327
20339
  /**
20328
20340
  * The feature reduction type.
20329
20341
  *
@@ -69038,6 +69050,33 @@ declare namespace __esri {
69038
69050
  mapPoint: Point;
69039
69051
  }
69040
69052
 
69053
+ /**
69054
+ * Object specification for the route hit results returned from [RouteLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html) in [HitTestResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) of the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) method.
69055
+ *
69056
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#RouteHit)
69057
+ */
69058
+ export interface RouteHit extends Object {
69059
+ type: "route";
69060
+ /**
69061
+ * The route layer that contains the element.
69062
+ *
69063
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#RouteHit)
69064
+ */
69065
+ layer: RouteLayer;
69066
+ /**
69067
+ * The point geometry in the spatial reference of the view corresponding with the input screen coordinates.
69068
+ *
69069
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#RouteHit)
69070
+ */
69071
+ mapPoint: Point;
69072
+ /**
69073
+ * The route hit test will contain all intersecting network elements which may include one or more of the following: DirectionLine, DirectionPoint, PointBarrier, PolylineBarrier, PolygonBarrier, Stop, or RouteInfo.
69074
+ *
69075
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#RouteHit)
69076
+ */
69077
+ networkFeature: DirectionLine | DirectionPoint | PointBarrier | PolygonBarrier | PolygonBarrier | RouteInfo | Stop;
69078
+ }
69079
+
69041
69080
  /**
69042
69081
  * An object representing a point on the screen.
69043
69082
  *
@@ -69083,7 +69122,7 @@ declare namespace __esri {
69083
69122
  *
69084
69123
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#ViewHit)
69085
69124
  */
69086
- export type ViewHit = GraphicHit | MediaHit;
69125
+ export type ViewHit = GraphicHit | MediaHit | RouteHit;
69087
69126
 
69088
69127
  interface gamepadGamepadSettings extends Accessor {
69089
69128
  /**
@@ -69709,6 +69748,33 @@ declare namespace __esri {
69709
69748
  mapPoint: Point;
69710
69749
  }
69711
69750
 
69751
+ /**
69752
+ * Object specification for the route hit results returned from [RouteLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html) in [HitTestResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) of the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest) method.
69753
+ *
69754
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#RouteHit)
69755
+ */
69756
+ export interface SceneViewRouteHit extends Object {
69757
+ type: "route";
69758
+ /**
69759
+ * The route layer that contains the element.
69760
+ *
69761
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#RouteHit)
69762
+ */
69763
+ layer: RouteLayer;
69764
+ /**
69765
+ * The point geometry in the spatial reference of the view corresponding with the input screen coordinates.
69766
+ *
69767
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#RouteHit)
69768
+ */
69769
+ mapPoint: Point;
69770
+ /**
69771
+ * The route hit test will contain all intersecting network elements which may include one or more of the following: DirectionLine, DirectionPoint, PointBarrier, PolylineBarrier, PolygonBarrier, Stop, or RouteInfo.
69772
+ *
69773
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#RouteHit)
69774
+ */
69775
+ networkFeature: DirectionLine | DirectionPoint | PointBarrier | PolygonBarrier | PolygonBarrier | RouteInfo | Stop;
69776
+ }
69777
+
69712
69778
  export interface SceneViewConstraintsProperties extends Object {
69713
69779
  /**
69714
69780
  * Specifies a constraint on the minimum and maximum allowed camera altitude.
@@ -70256,7 +70322,7 @@ declare namespace __esri {
70256
70322
  *
70257
70323
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#ViewHit)
70258
70324
  */
70259
- export type SceneViewViewHit = SceneViewGraphicHit | SceneViewMediaHit;
70325
+ export type SceneViewViewHit = SceneViewGraphicHit | SceneViewMediaHit | SceneViewRouteHit;
70260
70326
 
70261
70327
  export interface HitTestResultGround extends Object {
70262
70328
  /**
@@ -99621,6 +99687,12 @@ declare namespace __esri {
99621
99687
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#isResolved)
99622
99688
  */
99623
99689
  isResolved(): boolean;
99690
+ /**
99691
+ * Adds one or more handles which are to be tied to the lifecycle of the widget.
99692
+ *
99693
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#own)
99694
+ */
99695
+ own(handleOrHandles: WatchHandle | WatchHandle[]): void;
99624
99696
  /**
99625
99697
  * *This method is primarily used by developers when implementing custom widgets.* Executes after widget is ready for rendering.
99626
99698
  *
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as o}from"../../renderers/support/types.js";import{clone as t}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{enumeration as i}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import n from"./AggregateField.js";import{labelsVisible as l,popupEnabled as a}from"./commonProperties.js";import{FeatureReduction as d}from"./FeatureReduction.js";import m from"./LabelClass.js";var u;let c=u=class extends d{constructor(e){super(e),this.type="binning",this.fixedBinLevel=3,this.labelingInfo=null,this.labelsVisible=!0,this.popupEnabled=!0,this.popupTemplate=null,this.fields=[]}clone(){return new u({fields:t(this.fields),fixedBinLevel:this.fixedBinLevel,labelingInfo:t(this.labelingInfo),labelsVisible:this.labelsVisible,popupEnabled:this.popupEnabled,popupTemplate:t(this.popupTemplate),renderer:t(this.renderer)})}};e([i({binning:"binning"})],c.prototype,"type",void 0),e([s({type:Number,json:{write:!0}})],c.prototype,"fixedBinLevel",void 0),e([s({type:[m],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo"}}})],c.prototype,"labelingInfo",void 0),e([s(l)],c.prototype,"labelsVisible",void 0),e([s(a)],c.prototype,"popupEnabled",void 0),e([s({type:r,json:{name:"popupInfo",write:!0}})],c.prototype,"popupTemplate",void 0),e([s({type:[n],json:{write:!0,origins:{"web-document":{write:!1},"portal-item":{write:!1}}}})],c.prototype,"fields",void 0),e([s({types:o,json:{write:!0}})],c.prototype,"renderer",void 0),c=u=e([p("esri.layers.support.FeatureReductionBinning")],c);const f=c;export{f as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as o}from"../../renderers/support/types.js";import{clone as t}from"../../core/lang.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{enumeration as i}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import n from"./AggregateField.js";import{labelsVisible as l,popupEnabled as d}from"./commonProperties.js";import{FeatureReduction as a}from"./FeatureReduction.js";import m from"./LabelClass.js";var u;let c=u=class extends a{constructor(e){super(e),this.type="binning",this.fixedBinLevel=3,this.labelingInfo=null,this.labelsVisible=!0,this.popupEnabled=!0,this.popupTemplate=null,this.fields=[],this.renderer=null}clone(){return new u({fields:t(this.fields),fixedBinLevel:this.fixedBinLevel,labelingInfo:t(this.labelingInfo),labelsVisible:this.labelsVisible,popupEnabled:this.popupEnabled,popupTemplate:t(this.popupTemplate),renderer:t(this.renderer)})}};e([i({binning:"binning"})],c.prototype,"type",void 0),e([s({type:Number,json:{write:!0}})],c.prototype,"fixedBinLevel",void 0),e([s({type:[m],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo"}}})],c.prototype,"labelingInfo",void 0),e([s(l)],c.prototype,"labelsVisible",void 0),e([s(d)],c.prototype,"popupEnabled",void 0),e([s({type:r,json:{name:"popupInfo",write:!0}})],c.prototype,"popupTemplate",void 0),e([s({type:[n],json:{write:!0,origins:{"web-document":{write:!1},"portal-item":{write:!1}}}})],c.prototype,"fields",void 0),e([s({types:o,json:{write:!0}})],c.prototype,"renderer",void 0),c=u=e([p("esri.layers.support.FeatureReductionBinning")],c);const f=c;export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.24.2",
3
+ "version": "4.24.5",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const b="20220624",c="7915c1c020ba03688ff44b4994b3ae7405550d5d";export{b as buildDate,c as commitHash};
5
+ const c="20220630",e="5a46844c5ac1b721521da79fb0304de9e8457e2c";export{c as buildDate,e as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import t from"../../core/Error.js";import{pt2px as a,px2pt as n}from"../../core/screenUtils.js";import{getFill as l,getStroke as s,getPatternUrlWithColor as o}from"./gfxUtils.js";import{SymbolSizeDefaults as i,shapes as c,adjustColorBrightness as r}from"./previewUtils.js";import{renderSymbol as m}from"./renderUtils.js";import{getColorLuminance as u}from"../../views/support/colorUtils.js";const h="picture-fill",p="picture-marker",d="simple-fill",f="simple-line",y="simple-marker",v="text",w="Aa",g=i.size,b=i.maxSize,M=i.maxOutlineSize,k=i.lineWidth,x=225,z=document.createElement("canvas");function L(e,t){const a=z.getContext("2d"),n=[];return t&&(t.weight&&n.push(t.weight),t.size&&n.push(t.size+"px"),t.family&&n.push(t.family)),a.font=n.join(" "),a.measureText(e).width}const j=7.2/2.54,C=72/2.54;function S(e){if(0===e.length)return 0;if(e.length>2){const t=n(1),a=parseFloat(e);switch(e.slice(-2)){case"px":return a;case"pt":return a*t;case"in":return 72*a*t;case"pc":return 12*a*t;case"mm":return a*j*t;case"cm":return a*C*t}}return parseFloat(e)}function F(e){const t=e?.size;return{width:null!=t&&"object"==typeof t&&"width"in t?a(t.width):null,height:null!=t&&"object"==typeof t&&"height"in t?a(t.height):null}}async function U(e,t){const a=t.fill,n=e.color;if("pattern"===a?.type&&n&&e.type!==h){const e=await o(a.src,n.toCss(!0));a.src=e,t.fill=a}}function E(e,t){return e>t?"dark":"light"}function Z(e,t){const n="number"==typeof t?.size?t?.size:null,o=null!=n?a(n):null,i=null!=t?.maxSize?a(t.maxSize):null,r=null!=t?.rotation?t.rotation:"angle"in e?e.angle:null,m=l(e);let u=s(e);"dark"!==D(e,245)||t?.ignoreWhiteSymbols||(u={color:"#bdc3c7",width:.75});const x={shape:null,fill:m,stroke:u,offset:[0,0]};u?.width&&(u.width=Math.min(u.width,M));const z=u?.width||0;let j=null!=t?.size&&(null==t?.scale||t?.scale),C=0,U=0,E=!1;switch(e.type){case y:{const t=e.style,n=Math.min(null!=o?o:a(e.size),i||b);switch(C=n,U=n,t){case"circle":x.shape={type:"circle",cx:0,cy:0,r:.5*n},j||(C+=z,U+=z);break;case"cross":x.shape={type:"path",path:[{command:"M",values:[0,.5*U]},{command:"L",values:[C,.5*U]},{command:"M",values:[.5*C,0]},{command:"L",values:[.5*C,U]}]};break;case"diamond":x.shape={type:"path",path:[{command:"M",values:[0,.5*U]},{command:"L",values:[.5*C,0]},{command:"L",values:[C,.5*U]},{command:"L",values:[.5*C,U]},{command:"Z",values:[]}]},j||(C+=z,U+=z);break;case"square":x.shape={type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[C,0]},{command:"L",values:[C,U]},{command:"L",values:[0,U]},{command:"Z",values:[]}]},j||(C+=z,U+=z),r&&(E=!0);break;case"triangle":x.shape={type:"path",path:[{command:"M",values:[.5*C,0]},{command:"L",values:[C,U]},{command:"L",values:[0,U]},{command:"Z",values:[]}]},j||(C+=z,U+=z),r&&(E=!0);break;case"x":x.shape={type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[C,U]},{command:"M",values:[C,0]},{command:"L",values:[0,U]}]},r&&(E=!0);break;case"path":x.shape={type:"path",path:e.path||""},j||(C+=z,U+=z),r&&(E=!0),j=!0}break}case f:{const{width:e,height:a}=F(t),n=null!=a?a:Math.min(null!=o?o:z,i||M),l=null!=e?e:k;u.width=n,C=l,U=n;const s=x?.stroke?.cap||"butt",c="round"===s;j=!0,x.stroke.cap="butt"===s?"square":s,x.shape={type:"path",path:[{command:"M",values:[c?n/2:0,U/2]},{command:"L",values:[c?C-n/2:C,U/2]}]};break}case h:case d:{const e="object"==typeof t?.symbolConfig&&t?.symbolConfig.isSquareFill,{width:a,height:n}=F(t);C=e&&null!=a?a:null!=o?o:g,U=e&&null!=n?n:C,j||(C+=z,U+=z),j=!0,x.shape=e?{type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[C,0]},{command:"L",values:[C,U]},{command:"L",values:[0,U]},{command:"L",values:[0,0]},{command:"Z",values:[]}]}:c.fill[0];break}case p:{let t=a(e.width),n=a(e.height);const l=null!=o?o:Math.max(t,n),s=t/n;t=s<=1?Math.ceil(l*s):l,n=s<=1?l:Math.ceil(l/s),C=Math.min(t,i||b),U=Math.min(n,i||b),x.shape={type:"image",x:-Math.round(C/2),y:-Math.round(U/2),width:C,height:U,src:e.url||""},r&&(E=!0);break}case v:{const t=e,n=t.text||w,l=t.font,s=Math.min(null!=o?o:a(l.size),i||b),c=L(n,{weight:l.weight,size:s,family:l.family}),r=/[\uE600-\uE6FF]/.test(n);C=r?s:c,U=s;let m=.25*S((l?s:0).toString());r&&(m+=5),x.shape={type:"text",text:n,x:t.xoffset||0,y:t.yoffset||m,align:"middle",alignBaseline:t.verticalAlignment,decoration:l&&l.decoration,rotated:t.rotated,kerning:t.kerning},x.font=l&&{size:s,style:l.style,decoration:l.decoration,weight:l.weight,family:l.family};break}}return{shapeDescriptor:x,size:[C,U],renderOptions:{node:t?.node,scale:j,opacity:t?.opacity,rotation:r,useRotationSize:E,effectView:t?.effectView}}}async function q(e,a){const{shapeDescriptor:n,size:l,renderOptions:s}=Z(e,a);if(!n.shape)throw new t("symbolPreview: renderPreviewHTML2D","symbol not supported.");await U(e,n);const o=[[n]];if("object"==typeof a?.symbolConfig&&a?.symbolConfig.applyColorModulation){const e=.6*l[0];o.unshift([{...n,offset:[-e,0],fill:r(n.fill,-.3)}]),o.push([{...n,offset:[e,0],fill:r(n.fill,.3)}]),l[0]+=2*e,s.scale=!1}return m(o,l,s)}function D(t,a=x){const n=l(t),o=s(t),i=!n||"type"in n?null:new e(n),c=o?.color?new e(o?.color):null,r=i?E(u(i),a):null,m=c?E(u(c),a):null;return m?r?r===m?r:a>=x?"light":"dark":m:r}export{D as getContrastingBackgroundTheme,Z as getRenderSymbolParameters,q as previewSymbol2D};
5
+ import e from"../../Color.js";import t from"../../core/Error.js";import{pt2px as a,px2pt as n}from"../../core/screenUtils.js";import{getFill as l,getStroke as s,getPatternUrlWithColor as o}from"./gfxUtils.js";import{SymbolSizeDefaults as i,shapes as c,adjustColorBrightness as r}from"./previewUtils.js";import{renderSymbol as m}from"./renderUtils.js";import{getColorLuminance as u}from"../../views/support/colorUtils.js";const h="picture-fill",p="picture-marker",d="simple-fill",f="simple-line",y="simple-marker",v="text",w="Aa",g=i.size,b=i.maxSize,M=i.maxOutlineSize,k=i.lineWidth,x=225,z=document.createElement("canvas");function L(e,t){const a=z.getContext("2d"),n=[];return t&&(t.weight&&n.push(t.weight),t.size&&n.push(t.size+"px"),t.family&&n.push(t.family)),a.font=n.join(" "),a.measureText(e).width}const j=7.2/2.54,C=72/2.54;function S(e){if(0===e.length)return 0;if(e.length>2){const t=n(1),a=parseFloat(e);switch(e.slice(-2)){case"px":return a;case"pt":return a*t;case"in":return 72*a*t;case"pc":return 12*a*t;case"mm":return a*j*t;case"cm":return a*C*t}}return parseFloat(e)}function F(e){const t=e?.size;return{width:null!=t&&"object"==typeof t&&"width"in t?a(t.width):null,height:null!=t&&"object"==typeof t&&"height"in t?a(t.height):null}}async function U(e,t){const a=t.fill,n=e.color;if("pattern"===a?.type&&n&&e.type!==h){const e=await o(a.src,n.toCss(!0));a.src=e,t.fill=a}}function E(e,t){return e>t?"dark":"light"}function Z(e,t){const n="number"==typeof t?.size?t?.size:null,o=null!=n?a(n):null,i=null!=t?.maxSize?a(t.maxSize):null,r=null!=t?.rotation?t.rotation:"angle"in e?e.angle:null,m=l(e);let u=s(e);"dark"!==D(e,245)||t?.ignoreWhiteSymbols||(u={width:.75,...u,color:"#bdc3c7"});const x={shape:null,fill:m,stroke:u,offset:[0,0]};u?.width&&(u.width=Math.min(u.width,M));const z=u?.width||0;let j=null!=t?.size&&(null==t?.scale||t?.scale),C=0,U=0,E=!1;switch(e.type){case y:{const t=e.style,n=Math.min(null!=o?o:a(e.size),i||b);switch(C=n,U=n,t){case"circle":x.shape={type:"circle",cx:0,cy:0,r:.5*n},j||(C+=z,U+=z);break;case"cross":x.shape={type:"path",path:[{command:"M",values:[0,.5*U]},{command:"L",values:[C,.5*U]},{command:"M",values:[.5*C,0]},{command:"L",values:[.5*C,U]}]};break;case"diamond":x.shape={type:"path",path:[{command:"M",values:[0,.5*U]},{command:"L",values:[.5*C,0]},{command:"L",values:[C,.5*U]},{command:"L",values:[.5*C,U]},{command:"Z",values:[]}]},j||(C+=z,U+=z);break;case"square":x.shape={type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[C,0]},{command:"L",values:[C,U]},{command:"L",values:[0,U]},{command:"Z",values:[]}]},j||(C+=z,U+=z),r&&(E=!0);break;case"triangle":x.shape={type:"path",path:[{command:"M",values:[.5*C,0]},{command:"L",values:[C,U]},{command:"L",values:[0,U]},{command:"Z",values:[]}]},j||(C+=z,U+=z),r&&(E=!0);break;case"x":x.shape={type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[C,U]},{command:"M",values:[C,0]},{command:"L",values:[0,U]}]},r&&(E=!0);break;case"path":x.shape={type:"path",path:e.path||""},j||(C+=z,U+=z),r&&(E=!0),j=!0}break}case f:{const{width:e,height:a}=F(t),n=null!=a?a:Math.min(null!=o?o:z,i||M),l=null!=e?e:k;u.width=n,C=l,U=n;const s=x?.stroke?.cap||"butt",c="round"===s;j=!0,x.stroke.cap="butt"===s?"square":s,x.shape={type:"path",path:[{command:"M",values:[c?n/2:0,U/2]},{command:"L",values:[c?C-n/2:C,U/2]}]};break}case h:case d:{const e="object"==typeof t?.symbolConfig&&t?.symbolConfig.isSquareFill,{width:a,height:n}=F(t);C=e&&null!=a?a:null!=o?o:g,U=e&&null!=n?n:C,j||(C+=z,U+=z),j=!0,x.shape=e?{type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[C,0]},{command:"L",values:[C,U]},{command:"L",values:[0,U]},{command:"L",values:[0,0]},{command:"Z",values:[]}]}:c.fill[0];break}case p:{let t=a(e.width),n=a(e.height);const l=null!=o?o:Math.max(t,n),s=t/n;t=s<=1?Math.ceil(l*s):l,n=s<=1?l:Math.ceil(l/s),C=Math.min(t,i||b),U=Math.min(n,i||b),x.shape={type:"image",x:-Math.round(C/2),y:-Math.round(U/2),width:C,height:U,src:e.url||""},r&&(E=!0);break}case v:{const t=e,n=t.text||w,l=t.font,s=Math.min(null!=o?o:a(l.size),i||b),c=L(n,{weight:l.weight,size:s,family:l.family}),r=/[\uE600-\uE6FF]/.test(n);C=r?s:c,U=s;let m=.25*S((l?s:0).toString());r&&(m+=5),x.shape={type:"text",text:n,x:t.xoffset||0,y:t.yoffset||m,align:"middle",alignBaseline:t.verticalAlignment,decoration:l&&l.decoration,rotated:t.rotated,kerning:t.kerning},x.font=l&&{size:s,style:l.style,decoration:l.decoration,weight:l.weight,family:l.family};break}}return{shapeDescriptor:x,size:[C,U],renderOptions:{node:t?.node,scale:j,opacity:t?.opacity,rotation:r,useRotationSize:E,effectView:t?.effectView}}}async function q(e,a){const{shapeDescriptor:n,size:l,renderOptions:s}=Z(e,a);if(!n.shape)throw new t("symbolPreview: renderPreviewHTML2D","symbol not supported.");await U(e,n);const o=[[n]];if("object"==typeof a?.symbolConfig&&a?.symbolConfig.applyColorModulation){const e=.6*l[0];o.unshift([{...n,offset:[-e,0],fill:r(n.fill,-.3)}]),o.push([{...n,offset:[e,0],fill:r(n.fill,.3)}]),l[0]+=2*e,s.scale=!1}return m(o,l,s)}function D(t,a=x){const n=l(t),o=s(t),i=!n||"type"in n?null:new e(n),c=o?.color?new e(o?.color):null,r=i?E(u(i),a):null,m=c?E(u(c),a):null;return m?r?r===m?r:a>=x?"light":"dark":m:r}export{D as getContrastingBackgroundTheme,Z as getRenderSymbolParameters,q as previewSymbol2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{bidiText as t}from"../../../../../core/BidiText.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{applySome as r,isNone as i,isSome as a,unwrapOrThrow as o,unwrap as n}from"../../../../../core/maybe.js";import{throwIfAborted as l,isAbortError as c}from"../../../../../core/promiseUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/accessorSupport/set.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{diff as h,hasDiff as f}from"../../../../../core/accessorSupport/diffUtils.js";import m from"../../../../../geometry/SpatialReference.js";import{isAggregateId as u}from"../../../engine/webgl/DisplayId.js";import{MeshData as p}from"../../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as g}from"../../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as y}from"../../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as _}from"../../../engine/webgl/util/Matcher.js";import{codepoints as b}from"../textUtils.js";import S from"./BaseProcessor.js";import w from"../support/ResourceManagerProxy.js";function I(e,t){return(!e.minScale||e.minScale>=t)&&(!e.maxScale||e.maxScale<=t)}function v(e){const t=e.message,s={message:{data:{},tileKey:t.tileKey,tileKeyOrigin:t.tileKeyOrigin,version:t.version},transferList:new Array};for(const i in t.data){const e=t.data[i];if(s.message.data[i]=null,a(e)){const t=e.stride,a=e.indices.slice(0),o=e.vertices.slice(0),n=e.records.slice(0),l={stride:t,indices:a,vertices:o,records:n,metrics:r(e.metrics,(e=>e.slice(0)))};s.transferList.push(a,o,n),s.message.data[i]=l}}return s}s.getLogger("esri.views.2d.layers.features.processors.SymbolProcessor");let M=class extends S{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new w(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(e){this._bufferIds.forEach((t=>{t.forEach(e)}))}async update(e,t){const s=t.schema.processors[0];if("symbol"!==s.type)return;const r=h(this._schema,s);f(r,"mesh")&&(e.mesh=!0,e.why.mesh.push("Symbology changed"),this._schema=s,this._factory=this._createFactory(s),this._factory.update(s,this.tileStore.tileScheme.tileInfo))}onTileMessage(e,t,s,r){return l(r),this._onTileData(e,t,s,r)}onTileClear(e){const t={clear:!0};return this._bufferData.delete(e.key.id),this._bufferIds.delete(e.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t})}onTileError(e,t,s){const r=s.signal,i={tileKey:e.id,error:t};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:r})}onTileUpdate(e){for(const t of e.removed)this._bufferData.has(t.key.id)&&this._bufferData.delete(t.key.id),this._bufferIds.has(t.key.id)&&this._bufferIds.delete(t.key.id);for(const t of e.added)this._bufferData.forEach((e=>{for(const s of e)s.message.tileKey===t.id&&this._updateTileMesh("append",t,v(s),[],!1,!1,null)}))}_addBufferData(e,t){this._bufferData.has(e)||this._bufferData.set(e,[]),this._bufferData.get(e).push(v(t))}_createFactory(e){const{geometryType:t,objectIdField:s,fields:i}=this.service,a=(e,t)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",e,t),o={geometryType:t,fields:i,spatialReference:m.fromJSON(this.spatialReference)},n=new y(a,this.tileStore.tileScheme.tileInfo),{matcher:l,aggregateMatcher:c}=e.mesh;return this._store=n,this._matchers.feature=_(l,n,o,this._resourceManagerProxy),this._matchers.aggregate=r(c,(e=>_(e,n,o,this._resourceManagerProxy))),new g(t,s,n)}async _onTileData(e,t,s,r){l(r);const{type:o,addOrUpdate:n,remove:c}=t,d=t.end,h=!!this._schema.mesh.sortKey;if(!n){const t={type:o,addOrUpdate:null,remove:c,clear:!1,end:d,sort:h};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},r)}const f=this._processFeatures(e,n,s,r,t.status.version);try{const s=await f;if(i(s)){const t={type:o,addOrUpdate:null,remove:c,clear:!1,end:d,sort:h};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},r)}const n=[];for(const t of s){let s=!1;const r=t.message.bufferIds,i=e.key.id,o=t.message.tileKey;if(i!==o&&a(r)){if(!this.tileStore.get(o)){this._addBufferData(i,t),n.push(t);continue}let e=this._bufferIds.get(o);e||(e=new Set,this._bufferIds.set(o,e));const a=Array.from(r);for(const t of a){if(e.has(t)){s=!0;break}e.add(t)}}s||(this._addBufferData(i,t),n.push(t))}await Promise.all(n.map((s=>{const i=e.key.id===s.message.tileKey,a=i?t.remove:[],n=i&&t.end;return this._updateTileMesh(o,e,s,a,n,t.clear,r.signal)})))}catch(m){this._handleError(e,m,r)}}async _updateTileMesh(e,t,s,i,a,o,c){const d=e,h=s.message.tileKey,f=!!this._schema.mesh.sortKey;h!==t.key.id&&(a=!1);const m=r(s,(e=>e.message)),u=r(s,(e=>e.transferList))||[],p={type:d,addOrUpdate:m,remove:i,clear:o,end:a,sort:f},g={transferList:n(u)||[],signal:c};return l(g),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:h,data:p},g)}async _processFeatures(e,t,s,r,a){if(i(t)||!t.hasFeatures)return null;const o={transform:e.transform,hasZ:!1,hasM:!1},n=this._factory,c={viewingMode:"",scale:e.scale},d=await this._matchers.feature,h=await this._matchers.aggregate;l(r);const f=this._getLabelInfos(e,t);return await n.analyze(t.getCursor(),this._resourceManagerProxy,d,h,o,c),l(r),this._writeFeatureSet(e,t,o,f,n,s,a)}_writeFeatureSet(e,t,s,r,i,o,n){const l=t.getSize(),c=new p(e.key.id,{features:l,records:l,metrics:0},this._schema.mesh.matcher.symbologyType,o,!0,n),d={viewingMode:"",scale:e.scale},h=t.getCursor();for(;h.next();)try{const t=h.getDisplayId(),o=a(r)?r.get(t):null;i.writeCursor(c,h,s,d,e.level,o,this._resourceManagerProxy)}catch(m){}const f=e.tileInfoView.tileInfo.isWrappable;return c.serialize(f)}_handleError(e,t,s){if(!c(t)){const r={tileKey:e.id,error:t.message};return this.remoteClient.invoke("tileRenderer.onTileError",r,{signal:s.signal})}}_getLabelingSchemaForScale(e){const t=this._schema.mesh.labels;if(i(t))return null;if("subtype"===t.type){const s={type:"subtype",classes:{}};let r=!1;for(const i in t.classes){const a=t.classes[i].filter((t=>I(t,e.scale)));r=r||!!a.length,s.classes[i]=a}return r?s:null}const s=t.classes.filter((t=>I(t,e.scale)));return s.length?{type:"simple",classes:s}:null}_getLabels(e,t){if("subtype"===t.type){const s=this.service.subtypeField,r=o(s,"Expected to find subtype Field"),i=e.readAttribute(r);return null==i?[]:t.classes[i]??[]}return t.classes}_getLabelInfos(e,s){const r=this._getLabelingSchemaForScale(e);if(i(r))return null;const a=new Map,o=s.getCursor();for(;o.next();){const e=o.getDisplayId(),s=[],i=u(e),n=i&&1!==o.readAttribute("cluster_count")?"aggregate":"feature",l=this._getLabels(o,r);for(const r of l){if(r.target!==n)continue;const a=o.getStorage(),l=i&&"feature"===n?a.getComputedStringAtIndex(o.readAttribute("referenceId"),r.fieldIndex):a.getComputedStringAtIndex(e,r.fieldIndex);if(!l)continue;const c=t(l.toString()),d=c[0],h=c[1];this._store.getMosaicItem(r.symbol,b(d)).then((e=>{s[r.index]={glyphs:e.glyphMosaicItems,rtl:h,index:r.index}}))}a.set(e,s)}return a}};M=e([d("esri.views.2d.layers.features.processors.SymbolProcessor")],M);const x=M;export{x as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{bidiText as t}from"../../../../../core/BidiText.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{applySome as r,isNone as i,isSome as a,unwrapOrThrow as o,unwrap as n}from"../../../../../core/maybe.js";import{throwIfAborted as l,isAbortError as c}from"../../../../../core/promiseUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/accessorSupport/set.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{diff as h,hasDiff as f}from"../../../../../core/accessorSupport/diffUtils.js";import m from"../../../../../geometry/SpatialReference.js";import{isAggregateId as u}from"../../../engine/webgl/DisplayId.js";import{MeshData as p}from"../../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as g}from"../../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as y}from"../../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as _}from"../../../engine/webgl/util/Matcher.js";import{codepoints as b}from"../textUtils.js";import S from"./BaseProcessor.js";import w from"../support/ResourceManagerProxy.js";function I(e,t){return(!e.minScale||e.minScale>=t)&&(!e.maxScale||e.maxScale<=t)}function v(e){const t=e.message,s={message:{data:{},tileKey:t.tileKey,tileKeyOrigin:t.tileKeyOrigin,version:t.version},transferList:new Array};for(const i in t.data){const e=t.data[i];if(s.message.data[i]=null,a(e)){const t=e.stride,a=e.indices.slice(0),o=e.vertices.slice(0),n=e.records.slice(0),l={stride:t,indices:a,vertices:o,records:n,metrics:r(e.metrics,(e=>e.slice(0)))};s.transferList.push(a,o,n),s.message.data[i]=l}}return s}s.getLogger("esri.views.2d.layers.features.processors.SymbolProcessor");let M=class extends S{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new w(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(e){this._bufferIds.forEach((t=>{t.forEach(e)}))}async update(e,t){const s=t.schema.processors[0];if("symbol"!==s.type)return;const r=h(this._schema,s);f(r,"mesh")&&(e.mesh=!0,e.why.mesh.push("Symbology changed"),this._schema=s,this._factory=this._createFactory(s),this._factory.update(s,this.tileStore.tileScheme.tileInfo))}onTileMessage(e,t,s,r){return l(r),this._onTileData(e,t,s,r)}onTileClear(e){const t={clear:!0};return this._bufferData.delete(e.key.id),this._bufferIds.delete(e.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t})}onTileError(e,t,s){const r=s.signal,i={tileKey:e.id,error:t};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:r})}onTileUpdate(e){for(const t of e.removed)this._bufferData.has(t.key.id)&&this._bufferData.delete(t.key.id),this._bufferIds.has(t.key.id)&&this._bufferIds.delete(t.key.id);for(const t of e.added)this._bufferData.forEach((e=>{for(const s of e)s.message.tileKey===t.id&&this._updateTileMesh("append",t,v(s),[],!1,!1,null)}))}_addBufferData(e,t){this._bufferData.has(e)||this._bufferData.set(e,[]),this._bufferData.get(e).push(v(t))}_createFactory(e){const{geometryType:t,objectIdField:s,fields:i}=this.service,a=(e,t)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",e,t),o={geometryType:t,fields:i,spatialReference:m.fromJSON(this.spatialReference)},n=new y(a,this.tileStore.tileScheme.tileInfo),{matcher:l,aggregateMatcher:c}=e.mesh;return this._store=n,this._matchers.feature=_(l,n,o,this._resourceManagerProxy),this._matchers.aggregate=r(c,(e=>_(e,n,o,this._resourceManagerProxy))),new g(t,s,n)}async _onTileData(e,t,s,r){l(r);const{type:o,addOrUpdate:n,remove:c,clear:d,end:h}=t,f=!!this._schema.mesh.sortKey;if(!n){const t={type:o,addOrUpdate:null,remove:c,clear:d,end:h,sort:f};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},r)}const m=this._processFeatures(e,n,s,r,t.status.version);try{const s=await m;if(i(s)){const t={type:o,addOrUpdate:null,remove:c,clear:d,end:h,sort:f};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},r)}const n=[];for(const t of s){let s=!1;const r=t.message.bufferIds,i=e.key.id,o=t.message.tileKey;if(i!==o&&a(r)){if(!this.tileStore.get(o)){this._addBufferData(i,t),n.push(t);continue}let e=this._bufferIds.get(o);e||(e=new Set,this._bufferIds.set(o,e));const a=Array.from(r);for(const t of a){if(e.has(t)){s=!0;break}e.add(t)}}s||(this._addBufferData(i,t),n.push(t))}await Promise.all(n.map((s=>{const i=e.key.id===s.message.tileKey,a=i?t.remove:[],n=i&&t.end;return this._updateTileMesh(o,e,s,a,n,t.clear,r.signal)})))}catch(u){this._handleError(e,u,r)}}async _updateTileMesh(e,t,s,i,a,o,c){const d=e,h=s.message.tileKey,f=!!this._schema.mesh.sortKey;h!==t.key.id&&(a=!1);const m=r(s,(e=>e.message)),u=r(s,(e=>e.transferList))||[],p={type:d,addOrUpdate:m,remove:i,clear:o,end:a,sort:f},g={transferList:n(u)||[],signal:c};return l(g),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:h,data:p},g)}async _processFeatures(e,t,s,r,a){if(i(t)||!t.hasFeatures)return null;const o={transform:e.transform,hasZ:!1,hasM:!1},n=this._factory,c={viewingMode:"",scale:e.scale},d=await this._matchers.feature,h=await this._matchers.aggregate;l(r);const f=this._getLabelInfos(e,t);return await n.analyze(t.getCursor(),this._resourceManagerProxy,d,h,o,c),l(r),this._writeFeatureSet(e,t,o,f,n,s,a)}_writeFeatureSet(e,t,s,r,i,o,n){const l=t.getSize(),c=new p(e.key.id,{features:l,records:l,metrics:0},this._schema.mesh.matcher.symbologyType,o,!0,n),d={viewingMode:"",scale:e.scale},h=t.getCursor();for(;h.next();)try{const t=h.getDisplayId(),o=a(r)?r.get(t):null;i.writeCursor(c,h,s,d,e.level,o,this._resourceManagerProxy)}catch(m){}const f=e.tileInfoView.tileInfo.isWrappable;return c.serialize(f)}_handleError(e,t,s){if(!c(t)){const r={tileKey:e.id,error:t.message};return this.remoteClient.invoke("tileRenderer.onTileError",r,{signal:s.signal})}}_getLabelingSchemaForScale(e){const t=this._schema.mesh.labels;if(i(t))return null;if("subtype"===t.type){const s={type:"subtype",classes:{}};let r=!1;for(const i in t.classes){const a=t.classes[i].filter((t=>I(t,e.scale)));r=r||!!a.length,s.classes[i]=a}return r?s:null}const s=t.classes.filter((t=>I(t,e.scale)));return s.length?{type:"simple",classes:s}:null}_getLabels(e,t){if("subtype"===t.type){const s=this.service.subtypeField,r=o(s,"Expected to find subtype Field"),i=e.readAttribute(r);return null==i?[]:t.classes[i]??[]}return t.classes}_getLabelInfos(e,s){const r=this._getLabelingSchemaForScale(e);if(i(r))return null;const a=new Map,o=s.getCursor();for(;o.next();){const e=o.getDisplayId(),s=[],i=u(e),n=i&&1!==o.readAttribute("cluster_count")?"aggregate":"feature",l=this._getLabels(o,r);for(const r of l){if(r.target!==n)continue;const a=o.getStorage(),l=i&&"feature"===n?a.getComputedStringAtIndex(o.readAttribute("referenceId"),r.fieldIndex):a.getComputedStringAtIndex(e,r.fieldIndex);if(!l)continue;const c=t(l.toString()),d=c[0],h=c[1];this._store.getMosaicItem(r.symbol,b(d)).then((e=>{s[r.index]={glyphs:e.glyphMosaicItems,rtl:h,index:r.index}}))}a.set(e,s)}return a}};M=e([d("esri.views.2d.layers.features.processors.SymbolProcessor")],M);const x=M;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import o from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as L}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as b}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as x}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as P}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as C}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as R,projectPointToVector as j}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as I,intersection as V,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as F}from"../../../layers/support/LercDecoder.js";import{printAllocations as H}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import z from"../support/debugFlags.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{ClientType as $}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{sampleElevation as Z,ElevationData as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{LODSnapping as ie,TextureUpdate as re}from"./interfaces.js";import{LayerClass as se,LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{MAX_ROOT_TILES as de,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as pe,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ue,MAX_MEMORY_LOD_BIAS as ce,ELEVATION_NODATA_VALUE as _e}from"./TerrainConst.js";import ge from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as Te,isSurfaceLayerView as ye,isMapTileLayerView as ve,isBlendableLayerView as we,isGroupLayer as Le,isElevationLayerView as Se,isVectorTileLayerView as Ee,useFetchTileForLayer as be,isImageryTileLayerView as De,isTileLayerView as xe,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as Pe}from"./terrainUtils.js";import{SplitLimits as Ce,Tile as Re}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Me}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as Oe,sortTiles as Ne}from"./tileUtils.js";import{TilingSchemeLogic as ke}from"./TilingSchemeLogic.js";import{UpsampleInfo as Be}from"./UpsampleInfo.js";import{isCompositeBlendMode as qe,blendModeFromString as Ge}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as We}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Fe,TaskPriority as He,noBudget as Qe}from"../../support/Scheduler.js";const Xe=o.getLogger("esri.views.3d.terrain.TerrainSurface"),ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new J,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ie,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Ce,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new C,this._frameTask=Fe,this._allTiles=new _,this._upsampleInfoPool=new c(Be),this._rootTilesExtent=A(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=F(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(he);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._set("overlayManager",new ne({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new ge({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:M(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>z.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&z.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=te(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new ke({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester($.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester($.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(He.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this.lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Re.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),H(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ie.ON:ie.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=A(),r=Y(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,A()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:Z(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[se.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!R(s,r,s,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!R(et,s,et,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},l=this.rootTiles;if(u(l))for(const h of l)o(h);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this.lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?re.UNFADED:re.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*de);if(u(this.rootTiles)){if(s.length>de)return void Xe.warn(pe);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>de&&(Xe.warn(ue),s=t.rootTilesInExtent(e,i,de)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=A(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&t.setPendingUpdate(Me.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Me.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this.lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),k(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,k(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),x(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Me.TEXTURE_FADING)?Me.TEXTURE_FADING:!!e.resetPendingUpdate(Me.TEXTURE_NOFADING)&&Me.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Me.SPLIT){if(e.resetPendingUpdate(Me.SPLIT)&&e.updateAgentSuspension(),i===Me.VSPLITMERGE&&e.updateAgents(se.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Me.MERGE),e.resetPendingUpdate(Me.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Me.MERGE),e.isLeaf&&(e.setPendingUpdate(Me.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Oe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){Te(0===this.neighborTilesToUpdate.size),this.deferTileNeighborUpdate=!0}_batchUpdateUpdatedTileNeighbors(){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;if(r.resetPendingUpdate(Me.MERGE)){if(!t)return r.setPendingUpdate(Me.MERGE),e.done;this._mergeTile(r),s=!0,e.madeProgress()}else r.resetPendingUpdate(Me.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&r.resetPendingUpdate(Me.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Me.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(We.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this.lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Me.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&s.setPendingUpdate(Me.SPLIT),s}_mergeTile(e){fe(!e.hasPendingUpdate(Me.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Pe&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Me.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,se.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Qe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),ye(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ve(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(we(e)){const t=Le(e.layer.parent)?"normal":e.layer.blendMode;if(qe(Ge[t]))return!0}return!1}_layerClassFromLayerView(e){return Se(e)?se.ELEVATION:se.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(re.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),we(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(re.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!ye(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===se.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),o=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const l=e.indexOf(i[t]);n[t]=l,t!==l&&(a=!0),l>-1&&(o[l]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(o,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===se.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(se.MAP),e===re.IMMEDIATE?this.renderer.updateTileTexture(t,Me.TEXTURE_NOFADING):t.updateRenderData(se.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=We.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Ee(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===se.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():ve(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[se.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):Xe.warn("TerrainSurface: received data from unknown layer %d %s",se.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,se.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:_e,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:_e},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,se.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ee(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(De(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(xe(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);q(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const l=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,l,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(se.MAP,t.uid);u(r)?e.dataArrived(r,se.MAP,i):(Ue(i),Xe.warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):Xe.warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return Ne(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Pe)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&B(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}};e([S()],Ye.prototype,"_renderer",void 0),e([S()],Ye.prototype,"_hasPendingUpdates",void 0),e([S()],Ye.prototype,"_asyncWorkItems",void 0),e([S()],Ye.prototype,"_allTilesDirty",void 0),e([S()],Ye.prototype,"_allTilesSorted",void 0),e([S()],Ye.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([S()],Ye.prototype,"_frameTask",void 0),e([S({readOnly:!0})],Ye.prototype,"snapLevel",null),e([S({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([S({constructOnly:!0})],Ye.prototype,"view",void 0),e([S()],Ye.prototype,"_userClippingExtent",null),e([S()],Ye.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],Ye.prototype,"extent",null),e([S({readOnly:!0})],Ye.prototype,"groundExtent",null),e([S({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],Ye.prototype,"updating",null),e([S(K)],Ye.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([S()],Ye.prototype,"_maxNumUpdating",void 0),e([S({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([S()],Ye.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([S({readOnly:!0})],Ye.prototype,"viewingMode",null),e([S()],Ye.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],Ye.prototype,"ready",null),e([S({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([S({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([S({readOnly:!0})],Ye.prototype,"spatialReference",null),e([S({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([S({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([S({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([S({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],Ye.prototype,"velvetOverground",null),e([L("_renderer.wireframe")],Ye.prototype,"wireframe",void 0),e([S({value:!1})],Ye.prototype,"suspended",null),e([S({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([S()],Ye.prototype,"_layerViewsDirty",void 0),e([L("_renderer.renderPatchBorders")],Ye.prototype,"renderPatchBorders",void 0),e([L("_renderer.renderingDisabled")],Ye.prototype,"renderingDisabled",void 0),Ye=e([E("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=P(),tt=A(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import o from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as L}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as x}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as C}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as P}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as R,projectPointToVector as j}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as I,intersection as V,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as F}from"../../../layers/support/LercDecoder.js";import{printAllocations as H}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import z from"../support/debugFlags.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{ClientType as $}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{sampleElevation as Z,ElevationData as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{LODSnapping as ie,TextureUpdate as re}from"./interfaces.js";import{LayerClass as se,LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{MAX_ROOT_TILES as de,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as pe,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ue,MAX_MEMORY_LOD_BIAS as ce,ELEVATION_NODATA_VALUE as _e}from"./TerrainConst.js";import ge from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as Te,isSurfaceLayerView as ye,isMapTileLayerView as ve,isBlendableLayerView as we,isGroupLayer as Le,isElevationLayerView as Se,isVectorTileLayerView as be,useFetchTileForLayer as Ee,isImageryTileLayerView as De,isTileLayerView as xe,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as Ce}from"./terrainUtils.js";import{SplitLimits as Pe,Tile as Re}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Me}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as Oe,sortTiles as Ne}from"./tileUtils.js";import{TilingSchemeLogic as ke}from"./TilingSchemeLogic.js";import{UpsampleInfo as Be}from"./UpsampleInfo.js";import{isCompositeBlendMode as qe,blendModeFromString as Ge}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as We}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Fe,TaskPriority as He,noBudget as Qe}from"../../support/Scheduler.js";const Xe=o.getLogger("esri.views.3d.terrain.TerrainSurface"),ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new J,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ie,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Pe,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new P,this._frameTask=Fe,this._allTiles=new _,this._upsampleInfoPool=new c(Be),this._rootTilesExtent=A(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=F(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(he);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._set("overlayManager",new ne({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new ge({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:M(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>z.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&z.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=te(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new ke({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester($.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester($.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(He.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this.lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Re.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),H(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ie.ON:ie.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=A(),r=Y(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,A()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:Z(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[se.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!R(s,r,s,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!R(et,s,et,this.tilingScheme?.spatialReference))return Xe.error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},l=this.rootTiles;if(u(l))for(const h of l)o(h);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,et,this.spatialReference))return Xe.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this.lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?re.UNFADED:re.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*de);if(u(this.rootTiles)){if(s.length>de)return void Xe.warn(pe);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>de&&(Xe.warn(ue),s=t.rootTilesInExtent(e,i,de)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=A(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&t.setPendingUpdate(Me.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.view.state.fixedContentCamera,a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const o=this._iteratorPool.acquire();for(o.reset(e);!o.done;){const e=o.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Me.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Me.RENDERDATA);const t=e.computeVisibility();s||t?(e.updateScreenDepth(n),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))):o.skipSubtree()}o.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this.lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),k(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,k(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),x(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Me.TEXTURE_FADING)?Me.TEXTURE_FADING:!!e.resetPendingUpdate(Me.TEXTURE_NOFADING)&&Me.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next();if(e.loadable){const i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i===Me.SPLIT){e.resetPendingUpdate(Me.MERGE),e.isLeaf&&(e.setPendingUpdate(Me.SPLIT),t.skipSubtree());continue}e.resetPendingUpdate(Me.SPLIT)&&e.updateAgentSuspension(),i===Me.VSPLITMERGE&&e.updateAgents(se.ELEVATION)}if(t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Me.MERGE),e.resetPendingUpdate(Me.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.loadable&&e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Oe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){Te(0===this.neighborTilesToUpdate.size),this.deferTileNeighborUpdate=!0}_batchUpdateUpdatedTileNeighbors(){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1;for(;!e.done;){i=!0;let r=!1;const s=!this._allTiles.some((i=>{if(i.resetPendingUpdate(Me.MERGE)){if(!t)return i.setPendingUpdate(Me.MERGE),e.done;this._mergeTile(i),r=!0,e.madeProgress()}else i.resetPendingUpdate(Me.SPLIT)&&(this._splitTile(i),r=!0,e.madeProgress());return!e.done&&i.resetPendingUpdate(Me.RENDERDATA)&&(this._updateRenderData(i),e.madeProgress()),e.done}));if(r&&(this._allTilesSorted=!1,this._allTilesDirty=!0),s){if(!r)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}i||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Me.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(We.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this.lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Me.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.loadable&&(s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Me.SPLIT&&s.setPendingUpdate(Me.SPLIT)),s}_mergeTile(e){fe(!e.hasPendingUpdate(Me.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Ce&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Me.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,se.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Qe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),ye(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ve(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(we(e)){const t=Le(e.layer.parent)?"normal":e.layer.blendMode;if(qe(Ge[t]))return!0}return!1}_layerClassFromLayerView(e){return Se(e)?se.ELEVATION:se.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(re.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),we(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(re.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!ye(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===se.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),o=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const l=e.indexOf(i[t]);n[t]=l,t!==l&&(a=!0),l>-1&&(o[l]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(o,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===se.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(se.MAP),e===re.IMMEDIATE?this.renderer.updateTileTexture(t,Me.TEXTURE_NOFADING):t.updateRenderData(se.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=We.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||be(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===se.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():ve(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[se.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):Xe.warn("TerrainSurface: received data from unknown layer %d %s",se.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,se.ELEVATION,t,i),this.requestUpdate())};if(Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:_e,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:_e},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,se.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(be(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(De(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(xe(t)&&Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return Xe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);q(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const l=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,l,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(se.MAP,t.uid);u(r)?e.dataArrived(r,se.MAP,i):(Ue(i),Xe.warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):Xe.warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return Ne(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Ce)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&B(this.view?.renderSpatialReference)}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}};e([S()],Ye.prototype,"_renderer",void 0),e([S()],Ye.prototype,"_hasPendingUpdates",void 0),e([S()],Ye.prototype,"_asyncWorkItems",void 0),e([S()],Ye.prototype,"_allTilesDirty",void 0),e([S()],Ye.prototype,"_allTilesSorted",void 0),e([S()],Ye.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([S()],Ye.prototype,"_frameTask",void 0),e([S({readOnly:!0})],Ye.prototype,"snapLevel",null),e([S({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([S({constructOnly:!0})],Ye.prototype,"view",void 0),e([S()],Ye.prototype,"_userClippingExtent",null),e([S()],Ye.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],Ye.prototype,"extent",null),e([S({readOnly:!0})],Ye.prototype,"groundExtent",null),e([S({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],Ye.prototype,"updating",null),e([S(K)],Ye.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([S()],Ye.prototype,"_maxNumUpdating",void 0),e([S({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([S()],Ye.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([S({readOnly:!0})],Ye.prototype,"viewingMode",null),e([S()],Ye.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],Ye.prototype,"ready",null),e([S({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([S({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([S({readOnly:!0})],Ye.prototype,"spatialReference",null),e([S({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([S({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([S({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([S({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],Ye.prototype,"velvetOverground",null),e([L("_renderer.wireframe")],Ye.prototype,"wireframe",void 0),e([S({value:!1})],Ye.prototype,"suspended",null),e([S({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([S()],Ye.prototype,"_layerViewsDirty",void 0),e([L("_renderer.renderPatchBorders")],Ye.prototype,"renderPatchBorders",void 0),e([L("_renderer.renderingDisabled")],Ye.prototype,"renderingDisabled",void 0),Ye=e([b("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=C(),tt=A(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e as default};