@arcgis/core 4.24.0-next.20220429 → 4.24.0-next.20220430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{3a43a2918b44781aaf85.js → 055a0ebf22a82f859474.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{3273b6be43eeb49ee842.js → 0b12ff7b2ed2838afbb8.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0e25548573baf855e394.js +1 -0
  5. package/assets/esri/core/workers/chunks/{c388ac33496f004d56f3.js → 135a90ae61f3b3cae91b.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{54f9b1ab9d472bf4baca.js → 1facbda248863cf72cbd.js} +1 -1
  7. package/assets/esri/core/workers/chunks/2133499e642193f6738f.js +1 -0
  8. package/assets/esri/core/workers/chunks/{3c572629f46e5093223c.js → 30333a95dc0a44e23fb5.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{7afe89eafab00afb31f2.js → 30837d93116f0337972f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/31df729c17470245288c.js +2 -0
  11. package/assets/esri/core/workers/chunks/{c0bf663240df7be68131.js.LICENSE.txt → 31df729c17470245288c.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/{e5d6f3815ecab8560404.js → 4130ea1f5a9f197168d7.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{f5855075104c12bf71d8.js → 59e341b2db44351bf557.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{73630d52768e3d932f30.js → 5a10b58533b4116115ac.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{dc193247a1980360ec4f.js → 8e98ff9404a802352037.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{863cfe35ee640bac103f.js → 94e51fe1c539df6257c2.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{cbe7e6283a427a618d4b.js → 9519a02b9b8db88a3150.js} +1 -1
  18. package/assets/esri/core/workers/chunks/a59ee7d2b98c85f27dd2.js +1 -0
  19. package/assets/esri/core/workers/chunks/{92ef9b0c61640e0ecbb4.js → a5dbab94697757c87c49.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{147d3ee9aa81d7b2b7fa.js → a6406a248b7b2ed65f35.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{ebdf61eb364ac0856f40.js → acbd0f4d72d1f5d8e4e8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/ad68fe924456d6d7d4f0.js +1 -0
  23. package/assets/esri/core/workers/chunks/b06c949fc7d08e376a5f.js +1 -0
  24. package/assets/esri/core/workers/chunks/c9b09099488d0e719dfb.js +1 -0
  25. package/assets/esri/core/workers/chunks/{4a05d0dfa73ff570e1fa.js → d15e6662d90718411d62.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{b74b9dceabbf7b1aec39.js → d16aac3461af9cee0c29.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{b9d9be39cd64f28dd478.js → d60dd3e1028f714f2258.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{cab6decfcb3f596a3837.js → d8c59b1d73650c060dfb.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{d24339b37cc9316e6d99.js → dcb6e1b33402d7fa455b.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{a8da24116180d708cf81.js → df653bca2b14dffc82d1.js} +1 -1
  31. package/chunks/index.js +1 -1
  32. package/config.js +1 -1
  33. package/interfaces.d.ts +8 -0
  34. package/layers/mixins/PortalLayer.js +1 -1
  35. package/package.json +2 -2
  36. package/request.js +1 -1
  37. package/support/revision.js +1 -1
  38. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  39. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  40. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  41. package/views/3d/terrain/PatchRenderData.js +1 -1
  42. package/views/3d/terrain/TerrainSurface.js +1 -1
  43. package/views/3d/terrain/Tile.js +1 -1
  44. package/widgets/FeatureTable/Grid/Grid.js +2 -2
  45. package/widgets/Sketch/SketchViewModel.js +1 -1
  46. package/assets/esri/core/workers/chunks/3f6b17c9d2629ed396da.js +0 -1
  47. package/assets/esri/core/workers/chunks/68d57660c7c71b82ff3c.js +0 -1
  48. package/assets/esri/core/workers/chunks/6ef8de3aa9a8d9c22161.js +0 -1
  49. package/assets/esri/core/workers/chunks/b548bf032c8af34fe155.js +0 -1
  50. package/assets/esri/core/workers/chunks/bbcae04235830debd814.js +0 -1
  51. package/assets/esri/core/workers/chunks/c0bf663240df7be68131.js +0 -2
  52. package/assets/esri/core/workers/chunks/cd9668acbe3babd2b188.js +0 -1
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";import{buildDate as r}from"./support/revision.js";var s;const t={apiKey:void 0,applicationUrl:null==(s=globalThis.location)?void 0:s.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:{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,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(t,globalThis.esriConfig,!0),delete t.has),!t.assetsPath){const e="4.24.0";t.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}-next.${r}/assets`}t.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(t,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),t.request.corsEnabledServers=[],t.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{t as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";import{buildDate as r}from"./support/revision.js";var s;const t={apiKey:void 0,applicationUrl:null==(s=globalThis.location)?void 0:s.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:{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(t,globalThis.esriConfig,!0),delete t.has),!t.assetsPath){const e="4.24.0";t.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}-next.${r}/assets`}t.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(t,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),t.request.corsEnabledServers=[],t.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{t as default};
package/interfaces.d.ts CHANGED
@@ -1171,6 +1171,14 @@ declare namespace __esri {
1171
1171
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request)
1172
1172
  */
1173
1173
  maxUrlLength?: number;
1174
+ /**
1175
+ * **Since:** 4.24 The fetch and image network request priority.
1176
+ *
1177
+ * @default high
1178
+ *
1179
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request)
1180
+ */
1181
+ priority?: "auto" | "high" | "low";
1174
1182
  /**
1175
1183
  * A proxy rule defines a proxy for a set of resources with an identical URL prefix.
1176
1184
  *
@@ -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 t}from"../../chunks/tslib.es6.js";import{id as r}from"../../kernel.js";import e from"../../request.js";import{result as s}from"../../core/asyncUtils.js";import o from"../../core/Error.js";import i from"../../core/Logger.js";import{isNone as a,isSome as l}from"../../core/maybe.js";import{throwIfAborted as n,isAbortError as p,throwIfAbortError as m}from"../../core/promiseUtils.js";import{normalize as u,hasSamePortal as c}from"../../core/urlUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../../core/accessorSupport/decorators/writer.js";import g from"../../portal/Portal.js";import I from"../../portal/PortalItem.js";import j from"../../portal/PortalUser.js";const v=i.getLogger("esri.layers.mixins.PortalLayer"),w=i=>{let w=class extends i{constructor(){super(...arguments),this.resourceReferences={portalItem:null,paths:[]},this.userHasEditingPrivileges=!0}destroy(){var t;null==(t=this.portalItem)||t.destroy(),this.portalItem=null}set portalItem(t){t!==this._get("portalItem")&&(this.removeOrigin("portal-item"),this._set("portalItem",t))}readPortalItem(t,r,e){if(r.itemId)return new I({id:r.itemId,portal:e&&e.portal})}writePortalItem(t,r){t&&t.id&&(r.itemId=t.id)}async loadFromPortal(t,r){if(this.portalItem&&this.portalItem.id)try{const e=await import("../../portal/support/layersLoader.js");return n(r),await e.load({instance:this,supportedTypes:t.supportedTypes,validateItem:t.validateItem,supportsData:t.supportsData},r)}catch(e){throw p(e)||v.warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${e}`),e}}async finishLoadEditablePortalLayer(t){this._set("userHasEditingPrivileges",await this._fetchUserHasEditingPrivileges(t).catch((t=>(m(t),!0))))}async _fetchUserHasEditingPrivileges(t){const e=this.url?null==r?void 0:r.findCredential(this.url):null;if(!e)return!0;const s=P.credential===e?P.user:await this._fetchEditingUser(t);return P.credential=e,P.user=s,a(s)||null==s.privileges||s.privileges.includes("features:user:edit")}async _fetchEditingUser(t){var o,i;const a=null==(o=this.portalItem)||null==(i=o.portal)?void 0:i.user;if(a)return a;const n=r.findServerInfo(this.url);if(null==n||!n.owningSystemUrl)return null;const p=`${n.owningSystemUrl}/sharing/rest`,m=g.getDefault();if(m&&m.loaded&&u(m.restUrl)===u(p))return m.user;const c=`${p}/community/self`,d=l(t)?t.signal:null,h=await s(e(c,{authMode:"no-prompt",query:{f:"json"},signal:d}));return h.ok?j.fromJSON(h.value.data):null}read(t,r){r&&(r.layer=this),super.read(t,r)}write(t,r){const e=r&&r.portal,s=this.portalItem&&this.portalItem.id&&(this.portalItem.portal||g.getDefault());return e&&s&&!c(s.restUrl,e.restUrl)?(r.messages&&r.messages.push(new o("layer:cross-portal",`The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save the scene, set the layer.portalItem to null or save the scene to the same portal as the item associated with the layer`,{layer:this})),null):super.write(t,{...r,layer:this})}};return t([d({type:I})],w.prototype,"portalItem",null),t([h("web-document","portalItem",["itemId"])],w.prototype,"readPortalItem",null),t([y("web-document","portalItem",{itemId:{type:String}})],w.prototype,"writePortalItem",null),t([d({clonable:!1})],w.prototype,"resourceReferences",void 0),t([d({readOnly:!0})],w.prototype,"userHasEditingPrivileges",void 0),w=t([f("esri.layers.mixins.PortalLayer")],w),w},P={credential:null,user:null};export{w as PortalLayer};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{id as r}from"../../kernel.js";import e from"../../request.js";import{result as s}from"../../core/asyncUtils.js";import o from"../../core/Error.js";import i from"../../core/Logger.js";import{isNone as a,isSome as l}from"../../core/maybe.js";import{throwIfAborted as p,isAbortError as n,throwIfAbortError as m}from"../../core/promiseUtils.js";import{normalize as u,hasSamePortal as c}from"../../core/urlUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../../core/accessorSupport/decorators/writer.js";import g from"../../portal/Portal.js";import I from"../../portal/PortalItem.js";import j from"../../portal/PortalUser.js";const v=i.getLogger("esri.layers.mixins.PortalLayer"),w=i=>{let w=class extends i{constructor(){super(...arguments),this.resourceReferences={portalItem:null,paths:[]},this.userHasEditingPrivileges=!0}destroy(){var t;null==(t=this.portalItem)||t.destroy(),this.portalItem=null}set portalItem(t){t!==this._get("portalItem")&&(this.removeOrigin("portal-item"),this._set("portalItem",t))}readPortalItem(t,r,e){if(r.itemId)return new I({id:r.itemId,portal:e&&e.portal})}writePortalItem(t,r){t&&t.id&&(r.itemId=t.id)}async loadFromPortal(t,r){if(this.portalItem&&this.portalItem.id)try{const e=await import("../../portal/support/layersLoader.js");return p(r),await e.load({instance:this,supportedTypes:t.supportedTypes,validateItem:t.validateItem,supportsData:t.supportsData},r)}catch(e){throw n(e)||v.warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${e}`),e}}async finishLoadEditablePortalLayer(t){this._set("userHasEditingPrivileges",await this._fetchUserHasEditingPrivileges(t).catch((t=>(m(t),!0))))}async _fetchUserHasEditingPrivileges(t){const e=this.url?null==r?void 0:r.findCredential(this.url):null;if(!e)return!0;const s=P.credential===e?P.user:await this._fetchEditingUser(t);return P.credential=e,P.user=s,a(s)||null==s.privileges||s.privileges.includes("features:user:edit")}async _fetchEditingUser(t){var o,i;const a=null==(o=this.portalItem)||null==(i=o.portal)?void 0:i.user;if(a)return a;const p=r.findServerInfo(this.url);if(null==p||!p.owningSystemUrl)return null;const n=`${p.owningSystemUrl}/sharing/rest`,m=g.getDefault();if(m&&m.loaded&&u(m.restUrl)===u(n))return m.user;const c=`${n}/community/self`,d=l(t)?t.signal:null,h=await s(e(c,{authMode:"no-prompt",query:{f:"json"},signal:d}));return h.ok?j.fromJSON(h.value.data):null}read(t,r){r&&(r.layer=this),super.read(t,r)}write(t,r){const e=r&&r.portal,s=this.portalItem&&this.portalItem.id&&(this.portalItem.portal||g.getDefault());return e&&s&&!c(s.restUrl,e.restUrl)?(r.messages&&r.messages.push(new o("layer:cross-portal",`The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save, set layer.portalItem to null or save to the same portal as the item associated with the layer`,{layer:this})),null):super.write(t,{...r,layer:this})}};return t([d({type:I})],w.prototype,"portalItem",null),t([h("web-document","portalItem",["itemId"])],w.prototype,"readPortalItem",null),t([y("web-document","portalItem",{itemId:{type:String}})],w.prototype,"writePortalItem",null),t([d({clonable:!1})],w.prototype,"resourceReferences",void 0),t([d({readOnly:!0})],w.prototype,"userHasEditingPrivileges",void 0),w=t([f("esri.layers.mixins.PortalLayer")],w),w},P={credential:null,user:null};export{w as PortalLayer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.24.0-next.20220429",
3
+ "version": "4.24.0-next.20220430",
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": [
@@ -29,7 +29,7 @@
29
29
  "@esri/calcite-colors": "~6.0.1",
30
30
  "@esri/calcite-components": "1.0.0-beta.80",
31
31
  "@popperjs/core": "~2.11.5",
32
- "focus-trap": "~6.8.1",
32
+ "focus-trap": "~6.9.0",
33
33
  "luxon": "~2.3.2",
34
34
  "sortablejs": "~1.15.0"
35
35
  },
package/request.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 e from"./config.js";import{id as t}from"./kernel.js";import r from"./core/Error.js";import s from"./core/has.js";import{clone as o}from"./core/lang.js";import{unwrap as n}from"./core/maybe.js";import{onAbort as a,isAbortError as i,createAbortError as l,isAborted as u}from"./core/promiseUtils.js";import{isDataProtocol as c,isBlobProtocol as d,normalize as p,getInterceptor as m,isTrustedServer as h,getOrigin as f,toHTTPS as y,addQueryParameter as w,objectToQuery as g,getProxyRule as b,getProxyUrl as q,addQueryParameters as T,hasSameOrigin as k,getAppUrl as S,addProxyRule as O}from"./core/urlUtils.js";import{supportsApiKey as x}from"./support/apiKeyUtils.js";import{loadImageAsync as v}from"./support/requestUtils.js";async function C(e,t){var r;const o=c(e),i=d(e);i||o||(e=p(e));const l={url:e,requestOptions:{...n(t)}};let u=m(e);if(u){const e=await K(u,l);if(null!=e)return{data:e,getHeader:_,requestOptions:l.requestOptions,url:l.url};u.after||u.error||(u=null)}if(e=l.url,"image"===(t=l.requestOptions).responseType){if(s("host-webworker")||s("host-node"))throw R("request:invalid-parameters",new Error("responseType 'image' is not supported in Web Workers or Node environment"),l)}else if(o)throw R("request:invalid-parameters",new Error("Data URLs are not supported for responseType = "+t.responseType),l);if("head"===t.method){if(t.body)throw R("request:invalid-parameters",new Error("body parameter cannot be set when method is 'head'"),l);if(o||i)throw R("request:invalid-parameters",new Error("data and blob URLs are not supported for method 'head'"),l)}if(await H(),E)return E.execute(e,t);const h=new AbortController;a(t,(()=>h.abort()));const f={controller:h,credential:null,credentialToken:null,fetchOptions:null,hasToken:!1,interceptor:u,params:l,redoRequest:!1,useIdentity:L.useIdentity,useProxy:!1,useSSL:!1,withCredentials:!1},y=await z(f);return null==(r=u)||null==r.after||r.after(y),y}let E;const L=e.request,U="FormData"in globalThis,j=[499,498,403,401],P=["COM_0056","COM_0057","SB_0008"],D=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i],_=()=>null,F=Symbol();function I(e){const t=f(e);t&&!C._corsServers.includes(t)&&C._corsServers.push(t)}function M(e){const t=f(e);return!t||t.endsWith(".arcgis.com")||C._corsServers.includes(t)||h(t)}function R(e,t,s,n){let a="Error";const u={url:s.url,requestOptions:s.requestOptions,getHeader:_,ssl:!1};if(t instanceof r)return t.details?(t.details=o(t.details),t.details.url=s.url,t.details.requestOptions=s.requestOptions):t.details=u,t;if(t){const e=n&&(e=>n.headers.get(e)),r=n&&n.status,s=t.message;s&&(a=s),e&&(u.getHeader=e),u.httpStatus=(null!=t.httpCode?t.httpCode:t.code)||r||0,u.subCode=t.subcode,u.messageCode=t.messageCode,"string"==typeof t.details?u.messages=[t.details]:u.messages=t.details,u.raw=F in t?t[F]:t}return i(t)?l():new r(e,a,u)}async function H(){s("host-webworker")?E||(E=await import("./core/workers/request.js")):C._abortableFetch||(C._abortableFetch=globalThis.fetch.bind(globalThis))}async function A(){t||await import("./identity/IdentityManager.js")}async function B(r){const s=r.params.url,o=r.params.requestOptions,n=r.controller.signal,a=o.body;let i=null,l=null,c=null;if(U&&"HTMLFormElement"in globalThis&&(a instanceof FormData?i=a:a instanceof HTMLFormElement&&(l=a,i=new FormData(l))),"string"==typeof a&&(c=a),r.fetchOptions={cache:o.cacheBust&&!C._abortableFetch.polyfill?"no-cache":"default",credentials:"same-origin",headers:o.headers||{},method:"head"===o.method?"HEAD":"GET",mode:"cors",redirect:"follow",signal:n},(i||c)&&(r.fetchOptions.body=i||c),"anonymous"===o.authMode&&(r.useIdentity=!1),r.hasToken=!!(/token=/i.test(s)||o.query&&o.query.token||i&&i.get&&i.get("token")||l&&l.elements.token),!r.hasToken&&e.apiKey&&x(s)&&(o.query||(o.query={}),o.query.token=e.apiKey,r.hasToken=!0),r.useIdentity&&!r.hasToken&&!r.credentialToken&&!N(s)&&!u(n)){let e;"immediate"===o.authMode?(await A(),e=await t.getCredential(s,{signal:n}),r.credential=e):"no-prompt"===o.authMode?(await A(),e=await t.getCredential(s,{prompt:!1,signal:n}).catch((()=>{})),r.credential=e):t&&(e=t.findCredential(s)),e&&(r.credentialToken=e.token,r.useSSL=!!e.ssl)}}function N(e){return D.some((t=>t.test(e)))}async function $(e){let r=e.params.url;const o=e.params.requestOptions,n=e.fetchOptions,a=d(r)||c(r),i=o.responseType||"json",u=a?0:null!=o.timeout?o.timeout:L.timeout;let p=!1;if(!a){e.useSSL&&(r=y(r)),o.cacheBust&&"default"===n.cache&&(r=w(r,"request.preventCache",Date.now()));let a={...o.query};e.credentialToken&&(a.token=e.credentialToken);let i=g(a);s("esri-url-encodes-apostrophe")&&(i=i.replace(/'/g,"%27"));const l=r.length+1+i.length;let u;p="delete"===o.method||"post"===o.method||"put"===o.method||!!o.body||l>L.maxUrlLength;const c=o.useProxy||!!b(r);if(c){const e=q(r);u=e.path,!p&&u.length+1+l>L.maxUrlLength&&(p=!0),e.query&&(a={...e.query,...a})}if("HEAD"===n.method&&(p||c)){if(p){if(l>L.maxUrlLength)throw R("request:invalid-parameters",new Error("URL exceeds maximum length"),e.params);throw R("request:invalid-parameters",new Error("cannot use POST request when method is 'head'"),e.params)}if(c)throw R("request:invalid-parameters",new Error("cannot use proxy when method is 'head'"),e.params)}if(p?(n.method="delete"===o.method?"DELETE":"put"===o.method?"PUT":"POST",o.body?r=T(r,a):(n.body=g(a),n.headers["Content-Type"]="application/x-www-form-urlencoded")):r=T(r,a),c&&(e.useProxy=!0,r=`${u}?${r}`),a.token&&U&&n.body instanceof FormData){const e=n.body;e.set?e.set("token",a.token):e.append("token",a.token)}if(o.hasOwnProperty("withCredentials"))e.withCredentials=o.withCredentials;else if(!k(r,S()))if(h(r))e.withCredentials=!0;else if(t){const s=t.findServerInfo(r);s&&s.webTierAuth&&(e.withCredentials=!0)}e.withCredentials&&(n.credentials="include")}let m,x,v=0,E=!1;u>0&&(v=setTimeout((()=>{E=!0,e.controller.abort()}),u));try{if("native-request-init"===o.responseType)x=n,x.url=r;else if("image"!==o.responseType||"default"!==n.cache||"GET"!==n.method||p||W(o.headers)||!a&&!e.useProxy&&L.proxyUrl&&!M(r)){if(m=await C._abortableFetch(r,n),e.useProxy||I(r),"native"===o.responseType)x=m;else if("HEAD"!==n.method)if(m.ok){switch(i){case"array-buffer":x=await m.arrayBuffer();break;case"blob":case"image":x=await m.blob();break;default:x=await m.text()}if(v&&(clearTimeout(v),v=0),"json"===i||"xml"===i||"document"===i)if(x)switch(i){case"json":x=JSON.parse(x);break;case"xml":x=G(x,"application/xml");break;case"document":x=G(x,"text/html")}else x=null;if(x){if("array-buffer"===i||"blob"===i){const e=m.headers.get("Content-Type");if(/application\/json|text\/plain/i.test(e)&&x["blob"===i?"size":"byteLength"]<=750)try{const e=await new Response(x).json();e.error&&(x=e)}catch{}}"image"===i&&x instanceof Blob&&(x=await X(URL.createObjectURL(x),e,!0))}}else x=await m.text()}else x=await X(r,e)}catch(j){if("AbortError"===j.name){if(E)throw new Error("Timeout exceeded");throw l("Request canceled")}if(!(!m&&j instanceof TypeError&&L.proxyUrl)||o.body||"delete"===o.method||"head"===o.method||"post"===o.method||"put"===o.method||e.useProxy||M(r))throw j;e.redoRequest=!0,O({proxyUrl:L.proxyUrl,urlPrefix:f(r)})}finally{v&&clearTimeout(v)}return[m,x]}async function K(e,t){if(null!=e.responseData)return e.responseData;if(e.headers&&(t.requestOptions.headers={...t.requestOptions.headers,...e.headers}),e.query&&(t.requestOptions.query={...t.requestOptions.query,...e.query}),e.before){let o,n;try{n=await e.before(t)}catch(s){o=R("request:interceptor",s,t)}if((n instanceof Error||n instanceof r)&&(o=R("request:interceptor",n,t)),o)throw e.error&&e.error(o),o;return n}}function W(e){if(e)for(const t of Object.getOwnPropertyNames(e))if(e[t])return!0;return!1}function G(e,t){let r;try{r=(new DOMParser).parseFromString(e,t)}catch{}if(!r||r.getElementsByTagName("parsererror").length)throw new SyntaxError("XML Parse error");return r}async function z(e){var r,s;let o,n;await B(e);try{do{[o,n]=await $(e)}while(!await J(e,o,n))}catch(l){const t=R("request:server",l,e.params,o);throw t.details.ssl=e.useSSL,e.interceptor&&e.interceptor.error&&e.interceptor.error(t),t}const a=e.params.url;if(/\/sharing\/rest\/(accounts|portals)\/self/i.test(a)&&!e.hasToken&&!e.credentialToken&&null!=(r=n)&&null!=(s=r.user)&&s.username&&!h(a)){const e=f(a,!0);e&&L.trustedServers.push(e)}const i=e.credential;if(i&&t){const e=t.findServerInfo(i.server);let r=e&&e.owningSystemUrl;if(r){r=r.replace(/\/?$/,"/sharing");const e=t.findCredential(r,i.userId);e&&-1===t._getIdenticalSvcIdx(r,e)&&e.resources.unshift(r)}}return{data:n,getHeader:o?e=>o.headers.get(e):_,requestOptions:e.params.requestOptions,ssl:e.useSSL,url:e.params.url}}async function J(e,r,s){if(e.redoRequest)return e.redoRequest=!1,!1;const o=e.params.requestOptions;if(!r||"native"===o.responseType||"native-request-init"===o.responseType)return!0;let n,a,i,l;if(!r.ok)throw n=new Error(`Unable to load ${r.url} status: ${r.status}`),n[F]=s,n;null!=s&&s.error&&(n=s.error),n&&(a=Number(n.code),i=n.hasOwnProperty("subcode")?Number(n.subcode):null,l=n.messageCode,l=l&&l.toUpperCase());const u=o.authMode;if(403===a&&(4===i||n.message&&n.message.toLowerCase().includes("ssl")&&!n.message.toLowerCase().includes("permission"))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&("no-prompt"!==u||498===a)&&j.includes(a)&&!N(e.params.url)&&(403!==a||!P.includes(l)&&(null==i||2===i&&e.credentialToken))){await A();try{const r=await t.getCredential(e.params.url,{error:R("request:server",n,e.params),prompt:"no-prompt"!==u,signal:e.controller.signal,token:e.credentialToken});return e.credential=r,e.credentialToken=r.token,e.useSSL=e.useSSL||r.ssl,!1}catch(c){if("no-prompt"===u)return e.credential=null,e.credentialToken=null,!1;n=c}}if(n)throw n;return!0}function X(e,t,r=!1){const s=t.controller.signal,o=new Image;return t.withCredentials?o.crossOrigin="use-credentials":o.crossOrigin="anonymous",o.alt="",o.src=e,v(o,e,r,s)}C._abortableFetch=null,C._corsServers=["https://server.arcgisonline.com","https://services.arcgisonline.com"];export{C as default};
5
+ import e from"./config.js";import{id as t}from"./kernel.js";import r from"./core/Error.js";import s from"./core/has.js";import{clone as o}from"./core/lang.js";import{unwrap as n}from"./core/maybe.js";import{onAbort as a,isAbortError as i,createAbortError as l,isAborted as u}from"./core/promiseUtils.js";import{isDataProtocol as c,isBlobProtocol as d,normalize as p,getInterceptor as m,isTrustedServer as h,getOrigin as f,toHTTPS as y,addQueryParameter as w,objectToQuery as g,getProxyRule as b,getProxyUrl as q,addQueryParameters as T,hasSameOrigin as k,getAppUrl as S,addProxyRule as O}from"./core/urlUtils.js";import{supportsApiKey as x}from"./support/apiKeyUtils.js";import{loadImageAsync as v}from"./support/requestUtils.js";async function C(e,t){var r;const o=c(e),i=d(e);i||o||(e=p(e));const l={url:e,requestOptions:{...n(t)}};let u=m(e);if(u){const e=await K(u,l);if(null!=e)return{data:e,getHeader:_,requestOptions:l.requestOptions,url:l.url};u.after||u.error||(u=null)}if(e=l.url,"image"===(t=l.requestOptions).responseType){if(s("host-webworker")||s("host-node"))throw R("request:invalid-parameters",new Error("responseType 'image' is not supported in Web Workers or Node environment"),l)}else if(o)throw R("request:invalid-parameters",new Error("Data URLs are not supported for responseType = "+t.responseType),l);if("head"===t.method){if(t.body)throw R("request:invalid-parameters",new Error("body parameter cannot be set when method is 'head'"),l);if(o||i)throw R("request:invalid-parameters",new Error("data and blob URLs are not supported for method 'head'"),l)}if(await H(),E)return E.execute(e,t);const h=new AbortController;a(t,(()=>h.abort()));const f={controller:h,credential:null,credentialToken:null,fetchOptions:null,hasToken:!1,interceptor:u,params:l,redoRequest:!1,useIdentity:L.useIdentity,useProxy:!1,useSSL:!1,withCredentials:!1},y=await z(f);return null==(r=u)||null==r.after||r.after(y),y}let E;const L=e.request,U="FormData"in globalThis,j=[499,498,403,401],P=["COM_0056","COM_0057","SB_0008"],D=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i],_=()=>null,F=Symbol();function I(e){const t=f(e);t&&!C._corsServers.includes(t)&&C._corsServers.push(t)}function M(e){const t=f(e);return!t||t.endsWith(".arcgis.com")||C._corsServers.includes(t)||h(t)}function R(e,t,s,n){let a="Error";const u={url:s.url,requestOptions:s.requestOptions,getHeader:_,ssl:!1};if(t instanceof r)return t.details?(t.details=o(t.details),t.details.url=s.url,t.details.requestOptions=s.requestOptions):t.details=u,t;if(t){const e=n&&(e=>n.headers.get(e)),r=n&&n.status,s=t.message;s&&(a=s),e&&(u.getHeader=e),u.httpStatus=(null!=t.httpCode?t.httpCode:t.code)||r||0,u.subCode=t.subcode,u.messageCode=t.messageCode,"string"==typeof t.details?u.messages=[t.details]:u.messages=t.details,u.raw=F in t?t[F]:t}return i(t)?l():new r(e,a,u)}async function H(){s("host-webworker")?E||(E=await import("./core/workers/request.js")):C._abortableFetch||(C._abortableFetch=globalThis.fetch.bind(globalThis))}async function A(){t||await import("./identity/IdentityManager.js")}async function B(r){const s=r.params.url,o=r.params.requestOptions,n=r.controller.signal,a=o.body;let i=null,l=null,c=null;if(U&&"HTMLFormElement"in globalThis&&(a instanceof FormData?i=a:a instanceof HTMLFormElement&&(l=a,i=new FormData(l))),"string"==typeof a&&(c=a),r.fetchOptions={cache:o.cacheBust&&!C._abortableFetch.polyfill?"no-cache":"default",credentials:"same-origin",headers:o.headers||{},method:"head"===o.method?"HEAD":"GET",mode:"cors",priority:L.priority,redirect:"follow",signal:n},(i||c)&&(r.fetchOptions.body=i||c),"anonymous"===o.authMode&&(r.useIdentity=!1),r.hasToken=!!(/token=/i.test(s)||o.query&&o.query.token||i&&i.get&&i.get("token")||l&&l.elements.token),!r.hasToken&&e.apiKey&&x(s)&&(o.query||(o.query={}),o.query.token=e.apiKey,r.hasToken=!0),r.useIdentity&&!r.hasToken&&!r.credentialToken&&!N(s)&&!u(n)){let e;"immediate"===o.authMode?(await A(),e=await t.getCredential(s,{signal:n}),r.credential=e):"no-prompt"===o.authMode?(await A(),e=await t.getCredential(s,{prompt:!1,signal:n}).catch((()=>{})),r.credential=e):t&&(e=t.findCredential(s)),e&&(r.credentialToken=e.token,r.useSSL=!!e.ssl)}}function N(e){return D.some((t=>t.test(e)))}async function $(e){let r=e.params.url;const o=e.params.requestOptions,n=e.fetchOptions,a=d(r)||c(r),i=o.responseType||"json",u=a?0:null!=o.timeout?o.timeout:L.timeout;let p=!1;if(!a){e.useSSL&&(r=y(r)),o.cacheBust&&"default"===n.cache&&(r=w(r,"request.preventCache",Date.now()));let a={...o.query};e.credentialToken&&(a.token=e.credentialToken);let i=g(a);s("esri-url-encodes-apostrophe")&&(i=i.replace(/'/g,"%27"));const l=r.length+1+i.length;let u;p="delete"===o.method||"post"===o.method||"put"===o.method||!!o.body||l>L.maxUrlLength;const c=o.useProxy||!!b(r);if(c){const e=q(r);u=e.path,!p&&u.length+1+l>L.maxUrlLength&&(p=!0),e.query&&(a={...e.query,...a})}if("HEAD"===n.method&&(p||c)){if(p){if(l>L.maxUrlLength)throw R("request:invalid-parameters",new Error("URL exceeds maximum length"),e.params);throw R("request:invalid-parameters",new Error("cannot use POST request when method is 'head'"),e.params)}if(c)throw R("request:invalid-parameters",new Error("cannot use proxy when method is 'head'"),e.params)}if(p?(n.method="delete"===o.method?"DELETE":"put"===o.method?"PUT":"POST",o.body?r=T(r,a):(n.body=g(a),n.headers["Content-Type"]="application/x-www-form-urlencoded")):r=T(r,a),c&&(e.useProxy=!0,r=`${u}?${r}`),a.token&&U&&n.body instanceof FormData){const e=n.body;e.set?e.set("token",a.token):e.append("token",a.token)}if(o.hasOwnProperty("withCredentials"))e.withCredentials=o.withCredentials;else if(!k(r,S()))if(h(r))e.withCredentials=!0;else if(t){const s=t.findServerInfo(r);s&&s.webTierAuth&&(e.withCredentials=!0)}e.withCredentials&&(n.credentials="include")}let m,x,v=0,E=!1;u>0&&(v=setTimeout((()=>{E=!0,e.controller.abort()}),u));try{if("native-request-init"===o.responseType)x=n,x.url=r;else if("image"!==o.responseType||"default"!==n.cache||"GET"!==n.method||p||W(o.headers)||!a&&!e.useProxy&&L.proxyUrl&&!M(r)){if(m=await C._abortableFetch(r,n),e.useProxy||I(r),"native"===o.responseType)x=m;else if("HEAD"!==n.method)if(m.ok){switch(i){case"array-buffer":x=await m.arrayBuffer();break;case"blob":case"image":x=await m.blob();break;default:x=await m.text()}if(v&&(clearTimeout(v),v=0),"json"===i||"xml"===i||"document"===i)if(x)switch(i){case"json":x=JSON.parse(x);break;case"xml":x=G(x,"application/xml");break;case"document":x=G(x,"text/html")}else x=null;if(x){if("array-buffer"===i||"blob"===i){const e=m.headers.get("Content-Type");if(/application\/json|text\/plain/i.test(e)&&x["blob"===i?"size":"byteLength"]<=750)try{const e=await new Response(x).json();e.error&&(x=e)}catch{}}"image"===i&&x instanceof Blob&&(x=await X(URL.createObjectURL(x),e,!0))}}else x=await m.text()}else x=await X(r,e)}catch(j){if("AbortError"===j.name){if(E)throw new Error("Timeout exceeded");throw l("Request canceled")}if(!(!m&&j instanceof TypeError&&L.proxyUrl)||o.body||"delete"===o.method||"head"===o.method||"post"===o.method||"put"===o.method||e.useProxy||M(r))throw j;e.redoRequest=!0,O({proxyUrl:L.proxyUrl,urlPrefix:f(r)})}finally{v&&clearTimeout(v)}return[m,x]}async function K(e,t){if(null!=e.responseData)return e.responseData;if(e.headers&&(t.requestOptions.headers={...t.requestOptions.headers,...e.headers}),e.query&&(t.requestOptions.query={...t.requestOptions.query,...e.query}),e.before){let o,n;try{n=await e.before(t)}catch(s){o=R("request:interceptor",s,t)}if((n instanceof Error||n instanceof r)&&(o=R("request:interceptor",n,t)),o)throw e.error&&e.error(o),o;return n}}function W(e){if(e)for(const t of Object.getOwnPropertyNames(e))if(e[t])return!0;return!1}function G(e,t){let r;try{r=(new DOMParser).parseFromString(e,t)}catch{}if(!r||r.getElementsByTagName("parsererror").length)throw new SyntaxError("XML Parse error");return r}async function z(e){var r,s;let o,n;await B(e);try{do{[o,n]=await $(e)}while(!await J(e,o,n))}catch(l){const t=R("request:server",l,e.params,o);throw t.details.ssl=e.useSSL,e.interceptor&&e.interceptor.error&&e.interceptor.error(t),t}const a=e.params.url;if(/\/sharing\/rest\/(accounts|portals)\/self/i.test(a)&&!e.hasToken&&!e.credentialToken&&null!=(r=n)&&null!=(s=r.user)&&s.username&&!h(a)){const e=f(a,!0);e&&L.trustedServers.push(e)}const i=e.credential;if(i&&t){const e=t.findServerInfo(i.server);let r=e&&e.owningSystemUrl;if(r){r=r.replace(/\/?$/,"/sharing");const e=t.findCredential(r,i.userId);e&&-1===t._getIdenticalSvcIdx(r,e)&&e.resources.unshift(r)}}return{data:n,getHeader:o?e=>o.headers.get(e):_,requestOptions:e.params.requestOptions,ssl:e.useSSL,url:e.params.url}}async function J(e,r,s){if(e.redoRequest)return e.redoRequest=!1,!1;const o=e.params.requestOptions;if(!r||"native"===o.responseType||"native-request-init"===o.responseType)return!0;let n,a,i,l;if(!r.ok)throw n=new Error(`Unable to load ${r.url} status: ${r.status}`),n[F]=s,n;null!=s&&s.error&&(n=s.error),n&&(a=Number(n.code),i=n.hasOwnProperty("subcode")?Number(n.subcode):null,l=n.messageCode,l=l&&l.toUpperCase());const u=o.authMode;if(403===a&&(4===i||n.message&&n.message.toLowerCase().includes("ssl")&&!n.message.toLowerCase().includes("permission"))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&("no-prompt"!==u||498===a)&&j.includes(a)&&!N(e.params.url)&&(403!==a||!P.includes(l)&&(null==i||2===i&&e.credentialToken))){await A();try{const r=await t.getCredential(e.params.url,{error:R("request:server",n,e.params),prompt:"no-prompt"!==u,signal:e.controller.signal,token:e.credentialToken});return e.credential=r,e.credentialToken=r.token,e.useSSL=e.useSSL||r.ssl,!1}catch(c){if("no-prompt"===u)return e.credential=null,e.credentialToken=null,!1;n=c}}if(n)throw n;return!0}function X(e,t,r=!1){const s=t.controller.signal,o=new Image;return t.withCredentials?o.crossOrigin="use-credentials":o.crossOrigin="anonymous",o.alt="",o.fetchpriority=L.priority,o.src=e,v(o,e,r,s)}C._abortableFetch=null,C._corsServers=["https://server.arcgisonline.com","https://services.arcgisonline.com"];export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const a="20220429",c="642d90ab81c5e854aa1a4ceac1cace325fd97254";export{a as buildDate,c as commitHash};
5
+ const e="20220430",c="3f856ced90e1325295c9dc20a75090301ee241b4";export{e as buildDate,c 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"../../../../core/pbf.js";import{isAborted as t}from"../../../../core/promiseUtils.js";import{loadLibtess as r}from"../../../../geometry/libtess.js";import s from"./Feature.js";import{TriangleIndexBuffer as i}from"./IndexMemoryBuffer.js";import o from"./SourceLayerData.js";import{FillVertexBuffer as n,OutlineVertexBuffer as c,LineVertexBuffer as l,CircleVertexBuffer as a,SymbolVertexBuffer as u}from"./VertexMemoryBuffer.js";import f from"./buckets/CircleBucket.js";import p from"./buckets/FillBucket.js";import h from"./buckets/LineBucket.js";import m from"./buckets/SymbolBucket.js";import{StyleLayerType as _}from"./style/StyleDefinition.js";import{TileClipper as y,SimpleBuilder as d}from"../webgl/TileClipper.js";import{TileStatus as k}from"../../tiling/enums.js";const T=8,g=14,w=5;class B{constructor(t,r,s,i,o){if(this._pbfTiles={},this._tileClippers={},this._client=s,this._tile=r,o){this._styleLayerUIDs=new Set;for(const e of o)this._styleLayerUIDs.add(e)}this._styleRepository=i,this._layers=this._styleRepository.layers;const[n,c,l]=r.tileKey.split("/").map(parseFloat);this._level=n;const a=T+Math.max((this._level-g)*w,0);for(const u of Object.keys(t)){const r=t[u];this._pbfTiles[u]=new e(new Uint8Array(r.protobuff),new DataView(r.protobuff));if(r.refKey){const[e]=r.refKey.split("/").map(parseFloat),t=n-e;if(t>0){const e=(1<<t)-1,r=c&e,s=l&e;this._tileClippers[u]=new y(t,r,s,8,a)}}this._tileClippers[u]||(this._tileClippers[u]=new d)}}_canParseStyleLayer(e){return!this._styleLayerUIDs||this._styleLayerUIDs.has(e)}async parse(e){const t=r(),s=this._initialize(e),{returnedBuckets:i}=s;this._processLayers(s),this._linkReferences(s),this._filterFeatures(s);const o=[],n=new Set,c=(e,t)=>{n.has(e)||(o.push({name:e,repeat:t}),n.add(e))},l={};for(const r of i)r.getResources(r.tileClipper,c,l);if(this._tile.status===k.INVALID)return[];const a=this._fetchResources(o,l,e);return Promise.all([...a,t]).then((()=>this._processFeatures(s.returnedBuckets)))}_initialize(e){return{signal:e&&e.signal,sourceNameToTileData:this._parseTileData(this._pbfTiles),layers:this._layers,zoom:this._level,sourceNameToTileClipper:this._tileClippers,sourceNameToUniqueSourceLayerBuckets:{},sourceNameToUniqueSourceLayers:{},returnedBuckets:[],layerIdToBucket:{},referencerUIDToReferencedId:new Map}}_processLayers(e){const{sourceNameToTileData:t,layers:r,zoom:s,sourceNameToTileClipper:i,sourceNameToUniqueSourceLayerBuckets:o,sourceNameToUniqueSourceLayers:n,returnedBuckets:c,layerIdToBucket:l,referencerUIDToReferencedId:a}=e;for(let u=r.length-1;u>=0;u--){const e=r[u];if(!this._canParseStyleLayer(e.uid)||e.minzoom&&s<Math.floor(e.minzoom)||e.maxzoom&&s>=e.maxzoom||e.type===_.BACKGROUND)continue;if(!t[e.source]||!i[e.source])continue;const f=t[e.source],p=i[e.source],h=e.sourceLayer,m=f[h];if(m){let t=n[e.source];if(t||(t=n[e.source]=new Set),t.add(e.sourceLayer),e.refLayerId)a.set(e.uid,e.refLayerId);else{const t=this._createBucket(e);if(t){t.layerUIDs=[e.uid],t.layerExtent=m.extent,t.tileClipper=p;let r=o[e.source];r||(r=o[e.source]={});let s=r[h];s||(s=r[h]=[]),s.push(t),c.push(t),l[e.id]=t}}}}}_linkReferences(e){const{layerIdToBucket:t,referencerUIDToReferencedId:r}=e;r.forEach(((e,r)=>{t[e=e]&&t[e].layerUIDs.push(r)}))}_filterFeatures(e){const{signal:r,sourceNameToTileData:i,sourceNameToUniqueSourceLayerBuckets:o,sourceNameToUniqueSourceLayers:n}=e,c=10*this._level,l=10*(this._level+1),a=[],u=[];for(const t of Object.keys(n)){n[t].forEach((e=>{a.push(e),u.push(t)}))}for(let f=0;f<a.length;f++){const e=u[f],n=a[f];if(!i[e]||!o[e])continue;const p=i[e][n],h=o[e][n];if(!h||0===h.length)continue;if(t(r))return;const m=p.getData();for(;m.nextTag(2);){const e=m.getMessage(),t=new s(e,p);e.release();const r=t.values;if(r){const e=r._minzoom;if(e&&e>=l)continue;const t=r._maxzoom;if(t&&t<=c)continue}for(const s of h)s.pushFeature(t)}}}_fetchResources(e,t,r){const s=[],i=this._tile.getWorkerTileHandler();let o,n;e.length>0&&(o=i.fetchSprites(e,this._client,r),s.push(o));for(const c in t){const e=t[c];e.size>0&&(n=i.fetchGlyphs(this._tile.tileKey,c,e,this._client,r),s.push(n))}return s}_processFeatures(e){const t=e.filter((e=>e.hasFeatures()||this._canParseStyleLayer(e.layer.uid)));for(const r of t)r.processFeatures(r.tileClipper);return t}_parseTileData(e){const t={};for(const r of Object.keys(e)){const s=e[r],i={};for(;s.next();)switch(s.tag()){case 3:{const e=s.getMessage(),t=new o(e);e.release(),i[t.name]=t;break}default:s.skip()}t[r]=i}return t}_createBucket(e){switch(e.type){case _.BACKGROUND:return null;case _.FILL:return this._createFillBucket(e);case _.LINE:return this._createLineBucket(e);case _.CIRCLE:return this._createCircleBucket(e);case _.SYMBOL:return this._createSymbolBucket(e)}}_createFillBucket(e){return new p(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new n(e.fillMaterial.getStride()),new i,new c(e.outlineMaterial.getStride()),new i)}_createLineBucket(e){return new h(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new l(e.lineMaterial.getStride()),new i)}_createCircleBucket(e){return new f(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new a(e.circleMaterial.getStride()),new i)}_createSymbolBucket(e){const t=this._tile;return new m(e,this._level,new u(e.iconMaterial.getStride()),new i,new u(e.textMaterial.getStride()),new i,t.placementEngine,t.getWorkerTileHandler())}}export{B as default};
5
+ import e from"../../../../core/pbf.js";import{isAborted as t}from"../../../../core/promiseUtils.js";import{loadLibtess as r}from"../../../../geometry/libtess.js";import s from"./Feature.js";import{TriangleIndexBuffer as i}from"./IndexMemoryBuffer.js";import o from"./SourceLayerData.js";import{FillVertexBuffer as n,OutlineVertexBuffer as c,LineVertexBuffer as l,CircleVertexBuffer as a,SymbolVertexBuffer as u}from"./VertexMemoryBuffer.js";import f from"./buckets/CircleBucket.js";import p from"./buckets/FillBucket.js";import h from"./buckets/LineBucket.js";import m from"./buckets/SymbolBucket.js";import{StyleLayerType as _}from"./style/StyleDefinition.js";import{TileClipper as y,SimpleBuilder as d}from"../webgl/TileClipper.js";import{TileStatus as k}from"../../tiling/enums.js";const T=8,g=14,w=5;class B{constructor(t,r,s,i,o){if(this._pbfTiles={},this._tileClippers={},this._client=s,this._tile=r,o){this._styleLayerUIDs=new Set;for(const e of o)this._styleLayerUIDs.add(e)}this._styleRepository=i,this._layers=this._styleRepository.layers;const[n,c,l]=r.tileKey.split("/").map(parseFloat);this._level=n;const a=T+Math.max((this._level-g)*w,0);for(const u of Object.keys(t)){const r=t[u];this._pbfTiles[u]=new e(new Uint8Array(r.protobuff),new DataView(r.protobuff));if(r.refKey){const[e]=r.refKey.split("/").map(parseFloat),t=n-e;if(t>0){const e=(1<<t)-1,r=c&e,s=l&e;this._tileClippers[u]=new y(t,r,s,8,a)}}this._tileClippers[u]||(this._tileClippers[u]=new d)}}_canParseStyleLayer(e){return!this._styleLayerUIDs||this._styleLayerUIDs.has(e)}async parse(e){const t=r(),s=this._initialize(e),{returnedBuckets:i}=s;this._processLayers(s),this._linkReferences(s),this._filterFeatures(s);const o=[],n=new Set,c=(e,t)=>{n.has(e)||(o.push({name:e,repeat:t}),n.add(e))},l={};for(const r of i)r.getResources(r.tileClipper,c,l);if(this._tile.status===k.INVALID)return[];const a=this._fetchResources(o,l,e);return Promise.all([...a,t]).then((()=>this._processFeatures(s.returnedBuckets)))}_initialize(e){return{signal:e&&e.signal,sourceNameToTileData:this._parseTileData(this._pbfTiles),layers:this._layers,zoom:this._level,sourceNameToTileClipper:this._tileClippers,sourceNameToUniqueSourceLayerBuckets:{},sourceNameToUniqueSourceLayers:{},returnedBuckets:[],layerIdToBucket:{},referencerUIDToReferencedId:new Map}}_processLayers(e){const{sourceNameToTileData:t,layers:r,zoom:s,sourceNameToTileClipper:i,sourceNameToUniqueSourceLayerBuckets:o,sourceNameToUniqueSourceLayers:n,returnedBuckets:c,layerIdToBucket:l,referencerUIDToReferencedId:a}=e;for(let u=r.length-1;u>=0;u--){const e=r[u];if(!this._canParseStyleLayer(e.uid)||e.minzoom&&s<Math.floor(e.minzoom)||e.maxzoom&&s>=e.maxzoom||e.type===_.BACKGROUND)continue;if(!t[e.source]||!i[e.source])continue;const f=t[e.source],p=i[e.source],h=e.sourceLayer,m=f[h];if(m){let t=n[e.source];if(t||(t=n[e.source]=new Set),t.add(e.sourceLayer),e.refLayerId)a.set(e.uid,e.refLayerId);else{const t=this._createBucket(e);if(t){t.layerUIDs=[e.uid],t.layerExtent=m.extent,t.tileClipper=p;let r=o[e.source];r||(r=o[e.source]={});let s=r[h];s||(s=r[h]=[]),s.push(t),c.push(t),l[e.id]=t}}}}}_linkReferences(e){const{layerIdToBucket:t,referencerUIDToReferencedId:r}=e;r.forEach(((e,r)=>{t[e]&&t[e].layerUIDs.push(r)}))}_filterFeatures(e){const{signal:r,sourceNameToTileData:i,sourceNameToUniqueSourceLayerBuckets:o,sourceNameToUniqueSourceLayers:n}=e,c=10*this._level,l=10*(this._level+1),a=[],u=[];for(const t of Object.keys(n)){n[t].forEach((e=>{a.push(e),u.push(t)}))}for(let f=0;f<a.length;f++){const e=u[f],n=a[f];if(!i[e]||!o[e])continue;const p=i[e][n],h=o[e][n];if(!h||0===h.length)continue;if(t(r))return;const m=p.getData();for(;m.nextTag(2);){const e=m.getMessage(),t=new s(e,p);e.release();const r=t.values;if(r){const e=r._minzoom;if(e&&e>=l)continue;const t=r._maxzoom;if(t&&t<=c)continue}for(const s of h)s.pushFeature(t)}}}_fetchResources(e,t,r){const s=[],i=this._tile.getWorkerTileHandler();let o,n;e.length>0&&(o=i.fetchSprites(e,this._client,r),s.push(o));for(const c in t){const e=t[c];e.size>0&&(n=i.fetchGlyphs(this._tile.tileKey,c,e,this._client,r),s.push(n))}return s}_processFeatures(e){const t=e.filter((e=>e.hasFeatures()||this._canParseStyleLayer(e.layer.uid)));for(const r of t)r.processFeatures(r.tileClipper);return t}_parseTileData(e){const t={};for(const r of Object.keys(e)){const s=e[r],i={};for(;s.next();)switch(s.tag()){case 3:{const e=s.getMessage(),t=new o(e);e.release(),i[t.name]=t;break}default:s.skip()}t[r]=i}return t}_createBucket(e){switch(e.type){case _.BACKGROUND:return null;case _.FILL:return this._createFillBucket(e);case _.LINE:return this._createLineBucket(e);case _.CIRCLE:return this._createCircleBucket(e);case _.SYMBOL:return this._createSymbolBucket(e)}}_createFillBucket(e){return new p(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new n(e.fillMaterial.getStride()),new i,new c(e.outlineMaterial.getStride()),new i)}_createLineBucket(e){return new h(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new l(e.lineMaterial.getStride()),new i)}_createCircleBucket(e){return new f(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new a(e.circleMaterial.getStride()),new i)}_createSymbolBucket(e){const t=this._tile;return new m(e,this._level,new u(e.iconMaterial.getStride()),new i,new u(e.textMaterial.getStride()),new i,t.placementEngine,t.getWorkerTileHandler())}}export{B 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{getJsonType as r}from"../../../../../geometry/support/jsonUtils.js";import{convertFromGraphics as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{FeatureSetReader as e}from"./FeatureSetReader.js";import{FeatureSetReaderJSON as s}from"./FeatureSetReaderJSON.js";class o extends s{constructor(r,t){super(r,t,null)}static from(s){const n=e.createInstance(),i=[],c=s.filter((r=>!!r.geometry));for(const e of c){const s=r(e.geometry);t(i,[e],s,!1,!1,"uid")}return new o(n,i)}get geometryType(){const r=this._current;return r?r.geometryType:null}get insertAfter(){return this._current.insertAfter}readGraphic(){return this._current}getCursor(){return this.copy()}copy(){const r=new o(this.instance,this._features);return this.copyInto(r),r}}export{o as GraphicsReader};
5
+ import{getJsonType as r}from"../../../../../geometry/support/jsonUtils.js";import{convertFromGraphics as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{FeatureSetReader as e}from"./FeatureSetReader.js";import{FeatureSetReaderJSON as s}from"./FeatureSetReaderJSON.js";class o extends s{constructor(r,t){super(r,t,null)}static from(s,n){const i=e.createInstance(),c=[],u=s.filter((r=>!!r.geometry));for(const e of u){const s=r(e.geometry);t(c,[e],s,!1,!1,n)}return new o(i,c)}get geometryType(){const r=this._current;return r?r.geometryType:null}get insertAfter(){return this._current.insertAfter}readGraphic(){return this._current}getCursor(){return this.copy()}copy(){const r=new o(this.instance,this._features);return this.copyInto(r),r}}export{o as GraphicsReader};
@@ -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"../../../../core/Accessor.js";import{bidiText as s}from"../../../../core/BidiText.js";import{HandleOwnerMixin as i}from"../../../../core/HandleOwner.js";import r from"../../../../core/has.js";import{isSome as o,isNone as a}from"../../../../core/maybe.js";import{throwIfAborted as h,isAbortError as n,throwIfAbortError as l}from"../../../../core/promiseUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/SpatialReference.js";import{width as g,height as m,create as u}from"../../../../geometry/support/aaBoundingRect.js";import{closeRingsAndFixWinding as _}from"../../../../geometry/support/coordsUtils.js";import{getJsonType as f,isPolygon as y,isPolyline as b,isExtent as S,isPoint as w,isMultipoint as T}from"../../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridianSync as v}from"../../../../geometry/support/normalizeUtilsSync.js";import{getInfo as I}from"../../../../geometry/support/spatialReferenceUtils.js";import{checkProjectionSupport as U,project as G}from"../../../../layers/graphics/data/projectionSupport.js";import{symbolToCIM as M}from"../../../../symbols/cim/CIMSymbolHelper.js";import{errorPolylineSymbol2D as C,errorPolygonSymbol2D as j,errorPointSymbol2D as P}from"../../../../symbols/support/defaults.js";import{FILTER_FLAG_0 as x}from"../../engine/webgl/definitions.js";import{WGLSymbologyType as A}from"../../engine/webgl/enums.js";import{GraphicTile as R}from"../../engine/webgl/GraphicTile.js";import{TileData as q}from"../../engine/webgl/TileData.js";import D from"../../engine/webgl/WGLDisplayObject.js";import{MeshData as F}from"../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as O}from"../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as z}from"../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as H}from"../../engine/webgl/util/Matcher.js";import{createMatcherSchema as k,createSymbolSchemaOptions as E}from"../features/schemaUtils.js";import N from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as V}from"../features/support/ComputedAttributeStorage.js";import{GraphicsReader as B}from"../features/support/GraphicsReader.js";import L from"./GraphicStore.js";import{intersectingInternationalDateline as W,isMarkerSymbol as J,isTextSymbol as Z,polygonFromExtent as K,TILE_SIZE as Q,PIXEL_BUFFER as X}from"./graphicsUtils.js";import{expandSymbol as Y}from"../support/cimSymbolUtils.js";import{GraphicsView as $}from"../../../layers/GraphicsView.js";import{getWebGLCapabilities as ee}from"../../../webgl/capabilities.js";import{createSymbolSchema as te}from"../features/createSymbolSchema.js";const se=r("esri-2d-graphic-debug");function ie(e,t,s){if(s.has(e))return s.get(e);const i={tile:t,addedOrModified:[],removed:[]};return s.set(e,i),i}let re=class extends($(i(t))){constructor(e){super(e),this._storage=new V,this._displayIds=new Map,this._controller=new AbortController,this._tiles=new Map,this._graphicStoreUpdate=!1,this._graphicsSet=new Set,this._matcher=Promise.resolve(null),this._tileUpdateSet=new Set,this._tilesToUpdate=new Map,this._graphicIdToAbortController=new Map,this._attached=!1,this._updatingGraphicsTimer=null,this._hashToExpandedSymbol=new Map,this._hashToExpandedSymbolPromise=new Map,this._hashToCIMSymbolPromise=new Map,this._hashToCIM=new Map,this._processing=!1,this._needsProcessing=!1,this._pendingUpdate={added:new Set,updated:new Set,removed:new Set},this.lastUpdateId=-1,this.updateRequested=!1,this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this._updatingGraphicsTimer&&(clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=null,this.notifyChange("updating")),this._controller.abort(),this.container.destroy(),this._set("graphics",null),this._graphicStore.clear(),this._attributeStore=null,this._hashToExpandedSymbol.clear(),this.view=null,this.renderer=null,this._hashToCIM.clear(),this._hashToCIMSymbolPromise.clear(),this._hashToExpandedSymbolPromise.clear()}_createMatcher(e,t,s){if(e){const i=k({indexCount:0,fields:{}},"feature",e);this._matcher=H(i,t,null,s)}}_createDisplayId(e){return this._displayIds.has(e)||this._displayIds.set(e,this._storage.createDisplayId()),this._displayIds.get(e)}initialize(){this._attributeStore=new N({type:"local",initialize:e=>Promise.resolve(this.container.attributeView.initialize(e)),update:e=>this.container.attributeView.requestUpdate(e),render:()=>this.container.requestRender()},ee("2d")),this.container.hasHighlight=()=>this._attributeStore.hasHighlight;const e=e=>{this._createDisplayId(e.uid),this._setFilterState(e.uid,e.visible)},t=e=>{const t=this._displayIds.get(e.uid);this._displayIds.delete(e.uid),this._storage.releaseDisplayId(t)},s=new z(this.container.getMaterialItems.bind(this.container),this.view.featuresTilingScheme.tileInfo);this._graphicStore=new L(this.view.featuresTilingScheme,this.view.state.scale,this.uid,this.graphics,e,t,this._hashToCIM),this._meshFactory=new O(null,this.uid,s),this._templateStore=s,this.handles.add([this.watch("renderer",(e=>{this._createMatcher(e,s,this.container.stage.resourceManager);for(const t of this.graphics)this._pendingUpdate.updated.add(t);this.requestUpdate()})),this.view.graphicsTileStore.on("update",(e=>this._onTileUpdate(e))),this.container.on("attach",(()=>{se&&this.container.enableRenderingBounds((()=>this._graphicStore.getAllBounds())),this.graphics.items.length>0&&this._graphicsChangeHandler({target:this.graphics,added:this.graphics.items,removed:[],moved:[]}),this.handles.add(this.graphics.on("change",(e=>this._graphicsChangeHandler(e))),"graphics");const e=this.container.stage.resourceManager;this._createMatcher(this.renderer,s,e),this._graphicStore.setResourceManager(e),this._attached=!0,this.notifyChange("updating")}))]);const i=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:i,removed:[]})}get updating(){return!this._attached||null!==this._updatingGraphicsTimer||this._tileUpdateSet.size>0||this._tilesToUpdate.size>0}hitTest(e){if(!this.view||!this.view.position)return null;const{resolution:t,rotation:s}=this.view.state;return this._graphicStore.hitTest(e.x,e.y,2,t,s)}update(e){h(this._controller.signal);const t=e.state,{resolution:s}=t;if(this._graphicStore.updateLevel(s),this._graphicStoreUpdate=!0,this.updateRequested=!1,this._pendingUpdate.updated.size>0){if(!this._processing)return void this._updateGraphics();this._needsProcessing=!0}}viewChange(){this.requestUpdate()}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback())}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}graphicUpdateHandler(e){const{graphic:t,property:s,newValue:i}=e;switch(s){case"attributes":case"geometry":case"symbol":this._pendingUpdate.updated.add(t),this.requestUpdate();break;case"visible":this._setFilterState(t.uid,i),this._attributeStore.sendUpdates()}}setHighlight(e){const t=e.map((e=>this._displayIds.get(e)));this._attributeStore.setHighlight(e,t)}_getIntersectingTiles(e){const t=this._graphicStore.getBounds(e);if(!t||0===g(t)||0===m(t))return[];const s=W(t,this.view.spatialReference);return o(s)?[...new Set([...this.view.graphicsTileStore.boundsIntersections(s[0]),...this.view.graphicsTileStore.boundsIntersections(s[1])])]:this.view.graphicsTileStore.boundsIntersections(t)}async _updateTile(e){h(this._controller.signal);const t=e.tile,s=this._getGraphicsData(this._templateStore,t,e.addedOrModified),i=await this._processGraphics(t,s);return h(this._controller.signal),this._patchTile(t.key,{type:"update",addOrUpdate:i,remove:e.removed,end:!0,clear:!1,sort:!1}),i}_patchTile(e,t){if(!this._tiles.has(e))return;const s=this._tiles.get(e);this.container.onTileData(s,t),this.container.requestRender()}_graphicsChangeHandler(e){const t=this._pendingUpdate;for(const s of e.added)t.added.add(s);for(const s of e.moved)t.updated.add(s);for(const s of e.removed)this._pendingUpdate.added.has(s)?t.added.delete(s):t.removed.add(s);this._processing?this._needsProcessing=!0:this._updateGraphics()}_getGraphicsToUpdate(){const e={added:[],removed:[],updated:[]};if(!this.graphics)return e;const t=this._pendingUpdate;for(const s of this.graphics.items)t.added.has(s)?e.added.push(s):t.updated.has(s)&&e.updated.push(s);for(const s of t.removed)this._graphicStore.has(s)&&e.removed.push(s);return t.added.clear(),t.removed.clear(),t.updated.clear(),e}async _updateGraphics(){this._processing=!0;const{added:e,removed:t,updated:s}=this._getGraphicsToUpdate(),i=this._tilesToUpdate;let r;try{if(!this._graphicStoreUpdate){const e=this.view.state,{resolution:t}=e;this._graphicStore.updateLevel(t)}const o=[],a=new Array(e.length+t.length);for(let e=0;e<s.length;e++){const t=s[e],h=this._getIntersectingTiles(t);for(const e of h){r=e.id;ie(r,e,i).removed.push(this._displayIds.get(t.uid))}o.push(this._updateGraphic(t,null)),a[e]=t}const h=s.length;for(let t=0;t<e.length;t++){const s=e[t];a[h+t]=s,this._graphicsSet.add(s),o.push(this._addGraphic(s))}for(const e of t){this._abortProcessingGraphic(e.uid);const t=this._getIntersectingTiles(e);for(const s of t){r=s.id;ie(r,s,i).removed.push(this._displayIds.get(e.uid))}this._graphicsSet.delete(e),this._graphicStore.remove(e)}let n;this._flipUpdatingGraphics(),await Promise.all(o);for(let e=0;e<a.length;e++){n=a[e];const t=this._getIntersectingTiles(n);for(const e of t){r=e.id;ie(r,e,i).addedOrModified.push(n)}}this._graphicStore.updateZ();const l=[];for(const[e,t]of i)l.push(this._updateTile(t));await Promise.all(l)}catch(o){n(o),0}for(const a of t)try{const e=await this._getSymbolForGraphic(a,{});if(e){const t=e.hash();this._hashToExpandedSymbol.delete(t)}}catch(o){n(o),0}i.clear(),this.notifyChange("updating"),this._processing=!1,this._needsProcessing&&(this._needsProcessing=!1,this._updateGraphics())}_getArcadeInfo(e){const t=(e.attributes?Object.keys(e.attributes):[]).map((t=>({name:t,alias:t,type:"string"==typeof e.attributes[t]?"esriFieldTypeString":"esriFieldTypeDouble"})));return a(e.geometry)?null:{geometryType:f(e.geometry),spatialReference:c.fromJSON(e.geometry.spatialReference),fields:t}}_getSymbolForGraphic(e,t){return h(this._controller.signal),o(e.symbol)?Promise.resolve(e.symbol):o(this.renderer)?this.renderer.getSymbolAsync(e,{scale:this.view.scale,abortOptions:t}):Promise.resolve(this._getNullSymbol(e))}_getCIMSymbol(e,t,s){let i=this._hashToCIM.get(t);if(i)return Promise.resolve(i);const r=M(e);if(o(r)){if("CIMSymbolReference"===r.type)return i=r,this._hashToCIM.set(t,i),Promise.resolve(i);let e=this._hashToCIMSymbolPromise.get(t);return e||(e=r.fetchCIMSymbol(s).then((e=>(this._hashToCIM.set(t,e.data),this._hashToCIMSymbolPromise.delete(t),e))).catch((e=>(this._hashToCIMSymbolPromise.delete(t),l(e),null))),this._hashToCIMSymbolPromise.set(t,e),e)}return Promise.resolve(null)}_expandCIMSymbol(e,t,s,i){const r=this._hashToExpandedSymbol.get(s);if(r)return Promise.resolve(r);let o=this._hashToExpandedSymbolPromise.get(s);if(o)return o;const a=this.container.stage,h=this._getArcadeInfo(t),n=E(null),l=te(e,n);return o=Y(l,h,a.resourceManager,i),this._hashToExpandedSymbolPromise.set(s,o),o.then((e=>(this._hashToExpandedSymbol.set(s,e),this._hashToExpandedSymbolPromise.delete(s),e))),o}async _getSymbolResources(e,t){h(this._controller.signal);return this.container.stage?this._getSymbolForGraphic(e,t).then((i=>{const r=i.hash();return this._getCIMSymbol(i,r,t).then((i=>a(i)?null:this._expandCIMSymbol(i,e,r,t).then((e=>{const t=e.layers.filter((e=>"text"===e.type&&"string"==typeof e.text));if(t&&t.length>0){const i=new Array(t.length);for(let e=0;e<t.length;e++){const r=t[e],o=[],[a]=s(r.text);r.text=a;for(let e=0;e<a.length;e++)o.push(a.charCodeAt(e));i[e]={symbol:r,id:e,glyphIds:o}}const o=new Map;return this.container.getMaterialItems(i).then((s=>{for(let e=0;e<t.length;e++){const i=t[e];o.set(i.cim,{text:i.text,mosaicItem:s[e].mosaicItem})}return{symbol:e,textInfo:o,hash:r}}))}return{symbol:e,hash:r}}))))})).catch((e=>(l(e),null))):null}async _projectAndNormalizeGeometry(e,t){if(h(this._controller.signal),a(e.geometry)||"mesh"===e.geometry.type)return null;let s=e.geometry;if(y(s)){const e=s.rings;s.rings=e}else if(b(s)){const e=s.paths;s.paths=e}else if(S(s)){const i=await this._getSymbolForGraphic(e,t);if(h(this._controller.signal),J(i.type)||Z(i.type)){s=s.center}else s=K(s)}await U(s.spatialReference,this.view.spatialReference);const i=v(s),r=G(i,s.spatialReference,this.view.spatialReference);return _(r),r}_onTileUpdate(e){const t=I(this.view.spatialReference);if(e.added&&e.added.length>0)for(const s of e.added)this._addNewTile(s,t);if(e.removed&&e.removed.length>0)for(const s of e.removed)this._removeTile(s.key)}async _addGraphic(e){this._abortProcessingGraphic(e.uid),h(this._controller.signal);const t=new AbortController;this._graphicIdToAbortController.set(e.uid,t);const s={signal:t.signal};try{await this._addOrUpdateGraphic(e,s),h(this._controller.signal),this._graphicIdToAbortController.delete(e.uid)}catch(i){if(this._graphicIdToAbortController.delete(e.uid),!n(i))throw i}}_updateGraphic(e,t){h(this._controller.signal);const s=this._projectAndNormalizeGeometry(e,t),i=this._getSymbolResources(e,t);return Promise.all([s,i]).then((([t,s])=>{h(this._controller.signal),this._graphicStore.addOrModify(e,s,t)}))}_addOrUpdateGraphic(e,t){h(this._controller.signal);const s=this._projectAndNormalizeGeometry(e,t),i=this._getSymbolResources(e,t);return Promise.all([s,i]).then((([t,s])=>{h(this._controller.signal),this._graphicsSet.has(e)&&this._graphicStore.addOrModify(e,s,t)}))}_addTile(e){const t=this.view.featuresTilingScheme.getTileBounds(u(),e),s=new R(e,t[0],t[3]);return this._tiles.set(e,s),this.container.addChild(s),s}async _addNewTile(e,t){const s=this._addTile(e.key),i=this._graphicStore.queryTileData(this._templateStore,e);if(0===i.length)return;if(t){const s=Math.round((t.valid[1]-t.valid[0])/e.resolution);for(const e of i)e.geometry&&(w(e.geometry)||T(e.geometry))&&this._wrapPoints(e,s)}const r=e.key;this._tileUpdateSet.add(e.key),this.notifyChange("updating");try{const t={type:"update",clear:!1,addOrUpdate:await this._processGraphics(e,i),remove:[],end:!0,sort:!1};s.patch(t),this._tileUpdateSet.delete(r),this.notifyChange("updating")}catch(o){if(this._tileUpdateSet.delete(r),this.notifyChange("updating"),!n(o))throw o}}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_setFilterState(e,t){const s=this._displayIds.get(e),i=this._attributeStore.getHighlightFlag(e);this._attributeStore.setData(s,0,0,i|(t?x:0))}_getGraphicsData(e,t,s){const i=this.view,r=I(i.spatialReference),o=this._graphicStore.getGraphicsData(e,t,s);if(r){const e=Math.round((r.valid[1]-r.valid[0])/t.resolution);for(const t of o)t.geometry&&(w(t.geometry)||T(t.geometry))&&this._wrapPoints(t,e)}return o}_wrapPoints(e,t){const s=e.geometry;T(s)?this._wrapMultipoint(s,t):this._wrapPoint(e,t)}_wrapMultipoint(e,t){const s=e.points,i=[];let r=0,o=0;for(const[a,h]of s){if(i.push([a+r,h]),r=0,t===Q){const e=5*X;a+o<e?(i.push([t,0]),r=-t):a+o>Q-e&&(i.push([-t,0]),r=t)}else a+o<-X?(i.push([t,0]),r=-t):a+o>Q+X&&(i.push([-t,0]),r=t);o+=a}e.points=i}_wrapPoint(e,t){const s=e.geometry;if(t===Q){const i=5*X;s.x<i?e.geometry={points:[[s.x,s.y],[t,0]]}:s.x>Q-i&&(e.geometry={points:[[s.x,s.y],[-t,0]]})}else s.x<-X?e.geometry={points:[[s.x,s.y],[t,0]]}:s.x>Q+X&&(e.geometry={points:[[s.x,s.y],[-t,0]]})}_processGraphics(e,t,s){if(!(t&&t.length)||!this._meshFactory)return null;const i=B.from(t),r=this._meshFactory;return this._matcher.then((t=>r.analyzeGraphics(i,this.container.stage.resourceManager,t,null,null,s).then((()=>(this._attributeStore.sendUpdates(),this._processAnalyzedGraphics(e,i))))))}_processAnalyzedGraphics(e,t){const s=this._meshFactory,i=t.getSize(),r=t.getCursor(),o={features:i,records:i,metrics:0},a=new F(e.key.id,o,A.DEFAULT,!1,!1),h=[];for(;r.next();){const t=r.readGraphic();t.insertAfter=-1===t.insertAfter?-1:this._displayIds.get(t.insertAfter),t.displayId=this._displayIds.get(t.attributes[this.uid]);const i=new D(t.displayId);i.insertAfter=t.insertAfter,h.push(i),s.writeGraphic(a,r,e.level,this.container.stage.resourceManager)}const n=e.tileInfoView.tileInfo.isWrappable,l=a.serialize(n);if(1!==l.length)return new q;const d=l[0].message;return q.fromVertexData(d,h)}_abortProcessingGraphic(e){if(this._graphicIdToAbortController.has(e)){this._graphicIdToAbortController.get(e).abort()}}_getNullSymbol(e){const t=e.geometry;return b(t)?C:y(t)||S(t)?j:P}_flipUpdatingGraphics(){this._updatingGraphicsTimer&&clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=setTimeout((()=>{this._updatingGraphicsTimer=null,this.notifyChange("updating")}),160),this.notifyChange("updating")}};e([d({constructOnly:!0})],re.prototype,"requestUpdateCallback",void 0),e([d()],re.prototype,"container",void 0),e([d({constructOnly:!0})],re.prototype,"graphics",void 0),e([d()],re.prototype,"updating",null),e([d()],re.prototype,"view",void 0),e([d()],re.prototype,"updateRequested",void 0),re=e([p("esri.views.2d.layers.support.GraphicsView2D")],re);const oe=re;export{oe as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{bidiText as s}from"../../../../core/BidiText.js";import{HandleOwnerMixin as i}from"../../../../core/HandleOwner.js";import r from"../../../../core/has.js";import{isSome as o,isNone as a}from"../../../../core/maybe.js";import{throwIfAborted as h,isAbortError as n,throwIfAbortError as l}from"../../../../core/promiseUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/SpatialReference.js";import{width as g,height as m,create as u}from"../../../../geometry/support/aaBoundingRect.js";import{closeRingsAndFixWinding as _}from"../../../../geometry/support/coordsUtils.js";import{getJsonType as f,isPolygon as y,isPolyline as b,isExtent as S,isPoint as w,isMultipoint as T}from"../../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridianSync as v}from"../../../../geometry/support/normalizeUtilsSync.js";import{getInfo as I}from"../../../../geometry/support/spatialReferenceUtils.js";import{checkProjectionSupport as U,project as G}from"../../../../layers/graphics/data/projectionSupport.js";import{symbolToCIM as M}from"../../../../symbols/cim/CIMSymbolHelper.js";import{errorPolylineSymbol2D as C,errorPolygonSymbol2D as j,errorPointSymbol2D as P}from"../../../../symbols/support/defaults.js";import{FILTER_FLAG_0 as x}from"../../engine/webgl/definitions.js";import{WGLSymbologyType as A}from"../../engine/webgl/enums.js";import{GraphicTile as R}from"../../engine/webgl/GraphicTile.js";import{TileData as q}from"../../engine/webgl/TileData.js";import D from"../../engine/webgl/WGLDisplayObject.js";import{MeshData as F}from"../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as O}from"../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as z}from"../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as H}from"../../engine/webgl/util/Matcher.js";import{createMatcherSchema as k,createSymbolSchemaOptions as E}from"../features/schemaUtils.js";import N from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as V}from"../features/support/ComputedAttributeStorage.js";import{GraphicsReader as B}from"../features/support/GraphicsReader.js";import L from"./GraphicStore.js";import{intersectingInternationalDateline as W,isMarkerSymbol as J,isTextSymbol as Z,polygonFromExtent as K,TILE_SIZE as Q,PIXEL_BUFFER as X}from"./graphicsUtils.js";import{expandSymbol as Y}from"../support/cimSymbolUtils.js";import{GraphicsView as $}from"../../../layers/GraphicsView.js";import{getWebGLCapabilities as ee}from"../../../webgl/capabilities.js";import{createSymbolSchema as te}from"../features/createSymbolSchema.js";const se=r("esri-2d-graphic-debug");function ie(e,t,s){if(s.has(e))return s.get(e);const i={tile:t,addedOrModified:[],removed:[]};return s.set(e,i),i}let re=class extends($(i(t))){constructor(e){super(e),this._storage=new V,this._displayIds=new Map,this._controller=new AbortController,this._tiles=new Map,this._graphicStoreUpdate=!1,this._graphicsSet=new Set,this._matcher=Promise.resolve(null),this._tileUpdateSet=new Set,this._tilesToUpdate=new Map,this._graphicIdToAbortController=new Map,this._attached=!1,this._updatingGraphicsTimer=null,this._hashToExpandedSymbol=new Map,this._hashToExpandedSymbolPromise=new Map,this._hashToCIMSymbolPromise=new Map,this._hashToCIM=new Map,this._processing=!1,this._needsProcessing=!1,this._pendingUpdate={added:new Set,updated:new Set,removed:new Set},this.lastUpdateId=-1,this.updateRequested=!1,this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this._updatingGraphicsTimer&&(clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=null,this.notifyChange("updating")),this._controller.abort(),this.container.destroy(),this._set("graphics",null),this._graphicStore.clear(),this._attributeStore=null,this._hashToExpandedSymbol.clear(),this.view=null,this.renderer=null,this._hashToCIM.clear(),this._hashToCIMSymbolPromise.clear(),this._hashToExpandedSymbolPromise.clear()}_createMatcher(e,t,s){if(e){const i=k({indexCount:0,fields:{}},"feature",e);this._matcher=H(i,t,null,s)}}_createDisplayId(e){return this._displayIds.has(e)||this._displayIds.set(e,this._storage.createDisplayId()),this._displayIds.get(e)}initialize(){this._attributeStore=new N({type:"local",initialize:e=>Promise.resolve(this.container.attributeView.initialize(e)),update:e=>this.container.attributeView.requestUpdate(e),render:()=>this.container.requestRender()},ee("2d")),this.container.hasHighlight=()=>this._attributeStore.hasHighlight;const e=e=>{this._createDisplayId(e.uid),this._setFilterState(e.uid,e.visible)},t=e=>{const t=this._displayIds.get(e.uid);this._displayIds.delete(e.uid),this._storage.releaseDisplayId(t)},s=new z(this.container.getMaterialItems.bind(this.container),this.view.featuresTilingScheme.tileInfo);this._graphicStore=new L(this.view.featuresTilingScheme,this.view.state.scale,this.uid,this.graphics,e,t,this._hashToCIM),this._meshFactory=new O(null,this.uid,s),this._templateStore=s,this.handles.add([this.watch("renderer",(e=>{this._createMatcher(e,s,this.container.stage.resourceManager);for(const t of this.graphics)this._pendingUpdate.updated.add(t);this.requestUpdate()})),this.view.graphicsTileStore.on("update",(e=>this._onTileUpdate(e))),this.container.on("attach",(()=>{se&&this.container.enableRenderingBounds((()=>this._graphicStore.getAllBounds())),this.graphics.items.length>0&&this._graphicsChangeHandler({target:this.graphics,added:this.graphics.items,removed:[],moved:[]}),this.handles.add(this.graphics.on("change",(e=>this._graphicsChangeHandler(e))),"graphics");const e=this.container.stage.resourceManager;this._createMatcher(this.renderer,s,e),this._graphicStore.setResourceManager(e),this._attached=!0,this.notifyChange("updating")}))]);const i=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:i,removed:[]})}get updating(){return!this._attached||null!==this._updatingGraphicsTimer||this._tileUpdateSet.size>0||this._tilesToUpdate.size>0}hitTest(e){if(!this.view||!this.view.position)return null;const{resolution:t,rotation:s}=this.view.state;return this._graphicStore.hitTest(e.x,e.y,2,t,s)}update(e){h(this._controller.signal);const t=e.state,{resolution:s}=t;if(this._graphicStore.updateLevel(s),this._graphicStoreUpdate=!0,this.updateRequested=!1,this._pendingUpdate.updated.size>0){if(!this._processing)return void this._updateGraphics();this._needsProcessing=!0}}viewChange(){this.requestUpdate()}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback())}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}graphicUpdateHandler(e){const{graphic:t,property:s,newValue:i}=e;switch(s){case"attributes":case"geometry":case"symbol":this._pendingUpdate.updated.add(t),this.requestUpdate();break;case"visible":this._setFilterState(t.uid,i),this._attributeStore.sendUpdates()}}setHighlight(e){const t=e.map((e=>this._displayIds.get(e)));this._attributeStore.setHighlight(e,t)}_getIntersectingTiles(e){const t=this._graphicStore.getBounds(e);if(!t||0===g(t)||0===m(t))return[];const s=W(t,this.view.spatialReference);return o(s)?[...new Set([...this.view.graphicsTileStore.boundsIntersections(s[0]),...this.view.graphicsTileStore.boundsIntersections(s[1])])]:this.view.graphicsTileStore.boundsIntersections(t)}async _updateTile(e){h(this._controller.signal);const t=e.tile,s=this._getGraphicsData(this._templateStore,t,e.addedOrModified),i=await this._processGraphics(t,s);return h(this._controller.signal),this._patchTile(t.key,{type:"update",addOrUpdate:i,remove:e.removed,end:!0,clear:!1,sort:!1}),i}_patchTile(e,t){if(!this._tiles.has(e))return;const s=this._tiles.get(e);this.container.onTileData(s,t),this.container.requestRender()}_graphicsChangeHandler(e){const t=this._pendingUpdate;for(const s of e.added)t.added.add(s);for(const s of e.moved)t.updated.add(s);for(const s of e.removed)this._pendingUpdate.added.has(s)?t.added.delete(s):t.removed.add(s);this._processing?this._needsProcessing=!0:this._updateGraphics()}_getGraphicsToUpdate(){const e={added:[],removed:[],updated:[]};if(!this.graphics)return e;const t=this._pendingUpdate;for(const s of this.graphics.items)t.added.has(s)?e.added.push(s):t.updated.has(s)&&e.updated.push(s);for(const s of t.removed)this._graphicStore.has(s)&&e.removed.push(s);return t.added.clear(),t.removed.clear(),t.updated.clear(),e}async _updateGraphics(){this._processing=!0;const{added:e,removed:t,updated:s}=this._getGraphicsToUpdate(),i=this._tilesToUpdate;let r;try{if(!this._graphicStoreUpdate){const e=this.view.state,{resolution:t}=e;this._graphicStore.updateLevel(t)}const o=[],a=new Array(e.length+t.length);for(let e=0;e<s.length;e++){const t=s[e],h=this._getIntersectingTiles(t);for(const e of h){r=e.id;ie(r,e,i).removed.push(this._displayIds.get(t.uid))}o.push(this._updateGraphic(t,null)),a[e]=t}const h=s.length;for(let t=0;t<e.length;t++){const s=e[t];a[h+t]=s,this._graphicsSet.add(s),o.push(this._addGraphic(s))}for(const e of t){this._abortProcessingGraphic(e.uid);const t=this._getIntersectingTiles(e);for(const s of t){r=s.id;ie(r,s,i).removed.push(this._displayIds.get(e.uid))}this._graphicsSet.delete(e),this._graphicStore.remove(e)}let n;this._flipUpdatingGraphics(),await Promise.all(o);for(let e=0;e<a.length;e++){n=a[e];const t=this._getIntersectingTiles(n);for(const e of t){r=e.id;ie(r,e,i).addedOrModified.push(n)}}this._graphicStore.updateZ();const l=[];for(const[e,t]of i)l.push(this._updateTile(t));await Promise.all(l)}catch(o){n(o),0}for(const a of t)try{const e=await this._getSymbolForGraphic(a,{});if(e){const t=e.hash();this._hashToExpandedSymbol.delete(t)}}catch(o){n(o),0}i.clear(),this.notifyChange("updating"),this._processing=!1,this._needsProcessing&&(this._needsProcessing=!1,this._updateGraphics())}_getArcadeInfo(e){const t=(e.attributes?Object.keys(e.attributes):[]).map((t=>({name:t,alias:t,type:"string"==typeof e.attributes[t]?"esriFieldTypeString":"esriFieldTypeDouble"})));return a(e.geometry)?null:{geometryType:f(e.geometry),spatialReference:c.fromJSON(e.geometry.spatialReference),fields:t}}_getSymbolForGraphic(e,t){return h(this._controller.signal),o(e.symbol)?Promise.resolve(e.symbol):o(this.renderer)?this.renderer.getSymbolAsync(e,{scale:this.view.scale,abortOptions:t}):Promise.resolve(this._getNullSymbol(e))}_getCIMSymbol(e,t,s){let i=this._hashToCIM.get(t);if(i)return Promise.resolve(i);const r=M(e);if(o(r)){if("CIMSymbolReference"===r.type)return i=r,this._hashToCIM.set(t,i),Promise.resolve(i);let e=this._hashToCIMSymbolPromise.get(t);return e||(e=r.fetchCIMSymbol(s).then((e=>(this._hashToCIM.set(t,e.data),this._hashToCIMSymbolPromise.delete(t),e))).catch((e=>(this._hashToCIMSymbolPromise.delete(t),l(e),null))),this._hashToCIMSymbolPromise.set(t,e),e)}return Promise.resolve(null)}_expandCIMSymbol(e,t,s,i){const r=this._hashToExpandedSymbol.get(s);if(r)return Promise.resolve(r);let o=this._hashToExpandedSymbolPromise.get(s);if(o)return o;const a=this.container.stage,h=this._getArcadeInfo(t),n=E(null),l=te(e,n);return o=Y(l,h,a.resourceManager,i),this._hashToExpandedSymbolPromise.set(s,o),o.then((e=>(this._hashToExpandedSymbol.set(s,e),this._hashToExpandedSymbolPromise.delete(s),e))),o}async _getSymbolResources(e,t){h(this._controller.signal);return this.container.stage?this._getSymbolForGraphic(e,t).then((i=>{const r=i.hash();return this._getCIMSymbol(i,r,t).then((i=>a(i)?null:this._expandCIMSymbol(i,e,r,t).then((e=>{const t=e.layers.filter((e=>"text"===e.type&&"string"==typeof e.text));if(t&&t.length>0){const i=new Array(t.length);for(let e=0;e<t.length;e++){const r=t[e],o=[],[a]=s(r.text);r.text=a;for(let e=0;e<a.length;e++)o.push(a.charCodeAt(e));i[e]={symbol:r,id:e,glyphIds:o}}const o=new Map;return this.container.getMaterialItems(i).then((s=>{for(let e=0;e<t.length;e++){const i=t[e];o.set(i.cim,{text:i.text,mosaicItem:s[e].mosaicItem})}return{symbol:e,textInfo:o,hash:r}}))}return{symbol:e,hash:r}}))))})).catch((e=>(l(e),null))):null}async _projectAndNormalizeGeometry(e,t){if(h(this._controller.signal),a(e.geometry)||"mesh"===e.geometry.type)return null;let s=e.geometry;if(y(s)){const e=s.rings;s.rings=e}else if(b(s)){const e=s.paths;s.paths=e}else if(S(s)){const i=await this._getSymbolForGraphic(e,t);if(h(this._controller.signal),J(i.type)||Z(i.type)){s=s.center}else s=K(s)}await U(s.spatialReference,this.view.spatialReference);const i=v(s),r=G(i,s.spatialReference,this.view.spatialReference);return _(r),r}_onTileUpdate(e){const t=I(this.view.spatialReference);if(e.added&&e.added.length>0)for(const s of e.added)this._addNewTile(s,t);if(e.removed&&e.removed.length>0)for(const s of e.removed)this._removeTile(s.key)}async _addGraphic(e){this._abortProcessingGraphic(e.uid),h(this._controller.signal);const t=new AbortController;this._graphicIdToAbortController.set(e.uid,t);const s={signal:t.signal};try{await this._addOrUpdateGraphic(e,s),h(this._controller.signal),this._graphicIdToAbortController.delete(e.uid)}catch(i){if(this._graphicIdToAbortController.delete(e.uid),!n(i))throw i}}_updateGraphic(e,t){h(this._controller.signal);const s=this._projectAndNormalizeGeometry(e,t),i=this._getSymbolResources(e,t);return Promise.all([s,i]).then((([t,s])=>{h(this._controller.signal),this._graphicStore.addOrModify(e,s,t)}))}_addOrUpdateGraphic(e,t){h(this._controller.signal);const s=this._projectAndNormalizeGeometry(e,t),i=this._getSymbolResources(e,t);return Promise.all([s,i]).then((([t,s])=>{h(this._controller.signal),this._graphicsSet.has(e)&&this._graphicStore.addOrModify(e,s,t)}))}_addTile(e){const t=this.view.featuresTilingScheme.getTileBounds(u(),e),s=new R(e,t[0],t[3]);return this._tiles.set(e,s),this.container.addChild(s),s}async _addNewTile(e,t){const s=this._addTile(e.key),i=this._graphicStore.queryTileData(this._templateStore,e);if(0===i.length)return;if(t){const s=Math.round((t.valid[1]-t.valid[0])/e.resolution);for(const e of i)e.geometry&&(w(e.geometry)||T(e.geometry))&&this._wrapPoints(e,s)}const r=e.key;this._tileUpdateSet.add(e.key),this.notifyChange("updating");try{const t={type:"update",clear:!1,addOrUpdate:await this._processGraphics(e,i),remove:[],end:!0,sort:!1};s.patch(t),this._tileUpdateSet.delete(r),this.notifyChange("updating")}catch(o){if(this._tileUpdateSet.delete(r),this.notifyChange("updating"),!n(o))throw o}}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_setFilterState(e,t){const s=this._displayIds.get(e),i=this._attributeStore.getHighlightFlag(e);this._attributeStore.setData(s,0,0,i|(t?x:0))}_getGraphicsData(e,t,s){const i=this.view,r=I(i.spatialReference),o=this._graphicStore.getGraphicsData(e,t,s);if(r){const e=Math.round((r.valid[1]-r.valid[0])/t.resolution);for(const t of o)t.geometry&&(w(t.geometry)||T(t.geometry))&&this._wrapPoints(t,e)}return o}_wrapPoints(e,t){const s=e.geometry;T(s)?this._wrapMultipoint(s,t):this._wrapPoint(e,t)}_wrapMultipoint(e,t){const s=e.points,i=[];let r=0,o=0;for(const[a,h]of s){if(i.push([a+r,h]),r=0,t===Q){const e=5*X;a+o<e?(i.push([t,0]),r=-t):a+o>Q-e&&(i.push([-t,0]),r=t)}else a+o<-X?(i.push([t,0]),r=-t):a+o>Q+X&&(i.push([-t,0]),r=t);o+=a}e.points=i}_wrapPoint(e,t){const s=e.geometry;if(t===Q){const i=5*X;s.x<i?e.geometry={points:[[s.x,s.y],[t,0]]}:s.x>Q-i&&(e.geometry={points:[[s.x,s.y],[-t,0]]})}else s.x<-X?e.geometry={points:[[s.x,s.y],[t,0]]}:s.x>Q+X&&(e.geometry={points:[[s.x,s.y],[-t,0]]})}_processGraphics(e,t,s){if(!(t&&t.length)||!this._meshFactory)return null;const i=B.from(t,this.uid),r=this._meshFactory;return this._matcher.then((t=>r.analyzeGraphics(i,this.container.stage.resourceManager,t,null,null,s).then((()=>(this._attributeStore.sendUpdates(),this._processAnalyzedGraphics(e,i))))))}_processAnalyzedGraphics(e,t){const s=this._meshFactory,i=t.getSize(),r=t.getCursor(),o={features:i,records:i,metrics:0},a=new F(e.key.id,o,A.DEFAULT,!1,!1),h=[];for(;r.next();){const t=r.readGraphic();t.insertAfter=-1===t.insertAfter?-1:this._displayIds.get(t.insertAfter),t.displayId=this._displayIds.get(t.attributes[this.uid]);const i=new D(t.displayId);i.insertAfter=t.insertAfter,h.push(i),s.writeGraphic(a,r,e.level,this.container.stage.resourceManager)}const n=e.tileInfoView.tileInfo.isWrappable,l=a.serialize(n);if(1!==l.length)return new q;const d=l[0].message;return q.fromVertexData(d,h)}_abortProcessingGraphic(e){if(this._graphicIdToAbortController.has(e)){this._graphicIdToAbortController.get(e).abort()}}_getNullSymbol(e){const t=e.geometry;return b(t)?C:y(t)||S(t)?j:P}_flipUpdatingGraphics(){this._updatingGraphicsTimer&&clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=setTimeout((()=>{this._updatingGraphicsTimer=null,this.notifyChange("updating")}),160),this.notifyChange("updating")}};e([d({constructOnly:!0})],re.prototype,"requestUpdateCallback",void 0),e([d()],re.prototype,"container",void 0),e([d({constructOnly:!0})],re.prototype,"graphics",void 0),e([d()],re.prototype,"updating",null),e([d()],re.prototype,"view",void 0),e([d()],re.prototype,"updateRequested",void 0),re=e([p("esri.views.2d.layers.support.GraphicsView2D")],re);const oe=re;export{oe 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{equals as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as o}from"../../../core/maybe.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as n}from"../../../geometry/support/aaBoundingRect.js";import"../../../geometry/support/Ellipsoid.js";import{glLayout as a}from"../support/buffer/glUtil.js";import{sampleElevationOr0 as l}from"./ElevationData.js";import{GeometryState as u,neighborEdgeIndices as h,oppositeEdge as m,eps as d,neighborCornerIndices as c,oppositeCorner as g}from"./GeometryState.js";import"./interfaces.js";import{LayerClass as f}from"./LayerClass.js";import{PatchGeometry as p,releaseGeometry as y}from"./PatchGeometry.js";import{internalAssert as x}from"./terrainUtils.js";import{TextureFader as v,ActivationTime as _}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import"./Tile.js";import D from"./TileOverlayData.js";import{fallsWithinLayer as S}from"./tileUtils.js";import{Default3D as b}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{VertexArrayObject as T}from"../../webgl/VertexArrayObject.js";class L{constructor(){this.geometryInfo=new p,this.intersectionData=null,this.geometryState=null,this._textureRef=new v((()=>this.tile.surface.textureFadeDuration)),this.overlay=new D,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1}init(e){this.tile=e,this.clear();const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,s(t.boundingBox),t.numSurfaceIndices=0,t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new u,this.localOrigin=null,this.overlay.clear()}clear(){const e=this.releaseGeometry();return this.releaseTexture(),this._textureRef.clear(),e}updateGeometryIfChanged(e,t){const r=this.updateGeometryStateAndPrepareForGeometryGeneration(t);this._hasGeometry=!0;return this.updateNeighborDataAndGeometryIfNeeded(r,e)}updateNeighborDataAndGeometryIfNeeded(e=!1,t=this.vao.context){const r=this._updateNeighborData(),i=e||this._geometryStateChangedSinceLastUpdate||r;return i&&(this._updateGeometry(t),this._geometryStateChangedSinceLastUpdate=!1),i}_calculateEdgeResolution(e,t){const o=this.tile,s=this.geometryState.numVerticesPerSide-1;if(!o.surface.isGlobal){const t=o.surface.extent;if(r(t)&&(0===e&&o.extent[3]>t[3]||1===e&&o.extent[2]>t[2]||2===e&&o.extent[1]<t[1]||3===e&&o.extent[0]<t[0]))return s}const n=o.level,a=h[e],l=t||o.findNeighborTile(a,(e=>e.isLoaded||e.level===n));var u;if(!l||l.isLeaf&&!l.isLoaded)return x(i(null==(u=o.surface)?void 0:u.rootTiles)||o.surface.updatingRootTiles||!o.shouldHaveNeighbor(a)),s;if(l.isLoaded){const t=l,r=t.renderData.geometryState,i=n-t.level;if(0===i){const e=r.numVerticesPerSide-1;return Math.max(e,s)}const o=2**i,a=r.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,a)}x(!l.isLeaf);let d=s;return l.forAllSubtreeOnSide(m(a),(e=>e===o||(e.isLoaded?(d=Math.max(d,2**(e.level-n)),!0):(x(!e.isLeaf),!1)))),d}_updateNeighborData(){const e=this.tile,r=t=>t.isLoaded||t.level===e.level,i=e=>e.isLoaded,o=[null,null,null,null],s=[null,null,null,null];(()=>{for(let t=0;t<4;++t){const i=e.findNeighborTile(h[t],r);o[t]=i,s[t]=null!=i&&i.isLoaded?i:null}})();const n=[null,null,null,null];(()=>{for(let t=0;t<4;++t)n[t]=e.findNeighborTile(c[t],i)})();const a=this.geometryState.neighborData;let u=!1;(()=>{for(let t=0;t<4;++t){const r=a.edgeResolutions[t],i=o[t],s=this._calculateEdgeResolution(t,i);a.edgeResolutions[t]=s,r!==s&&(u=!0,i&&i!==e&&!i.isLoaded&&i.level===e.level&&(a.modifiedEdgeResolutions[t]=!0))}})();(()=>{const r=[null,null,null,null],i=(i,o)=>{let s=1/0;for(let t=0;t<4;++t){const o=c[t],n=i[t];if(n){const i=n.findCorner(g(o),(t=>(null==t?void 0:t.isLoaded)||t===e));r[t]=i,s=Math.min(s,i.level)}else r[t]=null}for(let m=0;m<4;++m){const i=r[(m+3)%4],s=r[m];if(i&&i.level<e.level&&i===s){const r=i,s=1==(1&m),n=(e.getNeighborEdgeStartVertexIndex(m,r)+(0===o||1===o&&!s||3===o&&s?1:0))/2**(e.level-r.level),a=s?0===o||1===o?r.extent[0]:r.extent[2]:t(r.extent[0],r.extent[2],n),u=s?t(r.extent[1],r.extent[3],n):0===o||3===o?r.extent[1]:r.extent[3];return l(a,u,r.renderData.geometryState.samplerData)}}let n=0,a=0;for(let e=0;e<4;++e){const t=r[e];if(t&&t.level===s){var u,h;const r=0===e||1===e,i=0===e||3===e,o=t.extent;a+=l(o[r?0:2],o[i?1:3],null==(u=t.renderData)||null==(h=u.geometryState)?void 0:h.samplerData),n++}}return n?a/n:0},o=this.geometryState.neighborData.cornerElevations,a=(e,t)=>{const r=i(t,e);return o[e]!==r&&(o[e]=r,!0)};for(let t=0;t<4;++t){const r=n[t],i=s[t],o=[r,s[(t+1)%4],e,i],l=o.map(((e,r)=>o[(r+4-t)%4])),h=a(t,l);u||(u=h)}})();return(()=>{const t=(t,r)=>{if(null==t||!t.isLoaded||t.lij[0]>e.lij[0])return null;const i=t.renderData.geometryState;return{neighborSamplerData:i.samplerData,neighborEdgeOverlapResolution:i.neighborData.edgeResolutions[r+2],version:i.samplerDataVersion,neighborVerticesPerSide:i.numVerticesPerSide,neighborTile:t}},r=a.edges;for(let o=0;o<4;++o){var i;const n=s[o];n&&(x(null==n?void 0:n.isLoaded),x((null==n?void 0:n.lij[0])<=e.lij[0]));const a=r[o],l=null==a?void 0:a.version,h=t(n,o),m=null!=(i=null==h?void 0:h.version)?i:null,d=null!=a!=(null!=h),c=a&&h&&l!==m,g=a&&h&&(null==a?void 0:a.neighborTile)!==(null==h?void 0:h.neighborTile),f=d||c||g;u||(u=f),!f&&l||(r[o]=h)}})(),u}updateEdgeAfterResolutionChange(e){var t,r;const i=this._calculateEdgeResolution(e),o=this.geometryState.neighborData.edgeResolutions,s=o[e];x((null!=(t=null==(r=this.geometryState.neighborData.edges[e])?void 0:r.neighborTile.level)?t:0)<=this.tile.level),i!==s&&(o[e]=i,this._updateGeometry(this.vao.context))}_updateGeometry(e){this._releaseGeometry(),this._createGeometry(e)}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}updateGeometryStateAndPrepareForGeometryGeneration(t){const r=this._getElevationInfo(),i=r.samplerData?this.tile.getElevationBasedVerticesPerSide(r.maxTileLevel):this.tile.getDefaultVerticesPerRowOnLevel(),o=Math.max(i,5);let s=this.tile.clippingArea;this.tile.intersectsClippingArea&&!this.tile.isWithinClippingArea||(s=null);const n=this.geometryState;let a=!1;return n.numVerticesPerSide!==o&&(n.numVerticesPerSide=o,n.samplerDataVersion++,a=!0),r.changed&&(n.samplerData=r.samplerData,n.samplerDataVersion++,a=!0),e(n.clippingArea,s)||(n.clippingArea=s,a=!0),n.wireframe!==t&&(n.wireframe=t,a=!0),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=a),this._hasGeometry=!0,a}_createGeometry(e){this.tile.createGeometry(this.geometryState,this.localOrigin);const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new T(e,b,{geometry:a(t.layout)},{geometry:G.createVertex(e,i.STATIC_DRAW,t.buffer)},G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,!!this._vao&&(this._vao.dispose(),this._vao=null,y(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=_.Immediate){r(e)&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[f.ELEVATION],i=t.length;let o=new Array(i),s=0,n=0,a=!1;for(let l=0;l<i;l++){const i=t[l];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[f.ELEVATION][l].data,u=r&&r.samplerData;e&&e[s]===u||(a=!0),o[s++]=u,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(l,f.ELEVATION);if(S(this.tile,t.layer,!1)){const t=i.data;e&&e[s]===t.samplerData||(a=!0),o[s++]=t.samplerData,n=this.tile.level}}}return r(e)&&e.length!==s&&(a=!0),s>0?o.length=s:o=null,{changed:a,samplerData:o,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=o(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return this.geometryInfo.indices.byteLength+this.geometryInfo.vertexAttributes.byteLength+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){}}function j(e,t){return t[0]>=e[0]-d&&t[2]<=e[2]+d&&t[1]>=e[1]-d&&t[3]<=e[3]+d}function I(e,t,i){if(r(i))for(const r of i)if(r){const i=r.x0,o=r.width,s=i+(o-1)/r.dx,n=r.y1,a=n-(o-1)/r.dy;if(e>=i-d&&e<=s+d&&a-d<=t&&t<=n+d)return!0}return!1}function R(e,t){for(const r of t)if(r){const t=r.x0,i=r.width,o=t+(i-1)/r.dx,s=r.y1,a=s-(i-1)/r.dy;if(j(n(t,a,o,s),e))return!0}return!1}export{L as PatchRenderData,I as isElevationSampleIn,R as isExtentInSampler};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as o}from"../../../core/maybe.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as n}from"../../../geometry/support/aaBoundingRect.js";import"../../../geometry/support/Ellipsoid.js";import{glLayout as a}from"../support/buffer/glUtil.js";import{sampleElevationOr0 as l}from"./ElevationData.js";import{GeometryState as u,neighborEdgeIndices as h,oppositeEdge as m,eps as d,neighborCornerIndices as c,oppositeCorner as g}from"./GeometryState.js";import"./interfaces.js";import{LayerClass as f}from"./LayerClass.js";import{PatchGeometry as p,releaseGeometry as y}from"./PatchGeometry.js";import{internalAssert as x}from"./terrainUtils.js";import{TextureFader as v,ActivationTime as _}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import"./Tile.js";import D from"./TileOverlayData.js";import{fallsWithinLayer as S}from"./tileUtils.js";import{Default3D as b}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{VertexArrayObject as T}from"../../webgl/VertexArrayObject.js";class L{constructor(){this.geometryInfo=new p,this.intersectionData=null,this.geometryState=null,this._textureRef=new v((()=>this.tile.surface.textureFadeDuration)),this.overlay=new D,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1}init(e){this.tile=e,this.clear();const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,s(t.boundingBox),t.numSurfaceIndices=0,t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new u,this.localOrigin=null,this.overlay.clear()}clear(){const e=this._releaseGeometry();return this.releaseTexture(),this._textureRef.clear(),e}updateGeometryIfChanged(e,t){const r=this.updateGeometryStateAndPrepareForGeometryGeneration(t);this._hasGeometry=!0;return this.updateNeighborDataAndGeometryIfNeeded(r,e)}updateNeighborDataAndGeometryIfNeeded(e=!1,t=this.vao.context){const r=this._updateNeighborData(),i=e||this._geometryStateChangedSinceLastUpdate||r;return i&&(this._updateGeometry(t),this._geometryStateChangedSinceLastUpdate=!1),i}_calculateEdgeResolution(e,t){const o=this.tile,s=this.geometryState.numVerticesPerSide-1;if(!o.surface.isGlobal){const t=o.surface.extent;if(r(t)&&(0===e&&o.extent[3]>t[3]||1===e&&o.extent[2]>t[2]||2===e&&o.extent[1]<t[1]||3===e&&o.extent[0]<t[0]))return s}const n=o.level,a=h[e],l=t||o.findNeighborTile(a,(e=>e.isLoaded||e.level===n));var u;if(!l||l.isLeaf&&!l.isLoaded)return x(i(null==(u=o.surface)?void 0:u.rootTiles)||o.surface.updatingRootTiles||!o.shouldHaveNeighbor(a)),s;if(l.isLoaded){const t=l,r=t.renderData.geometryState,i=n-t.level;if(0===i){const e=r.numVerticesPerSide-1;return Math.max(e,s)}const o=2**i,a=r.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,a)}x(!l.isLeaf);let d=s;return l.forAllSubtreeOnSide(m(a),(e=>e===o||(e.isLoaded?(d=Math.max(d,2**(e.level-n)),!0):(x(!e.isLeaf),!1)))),d}_updateNeighborData(){const e=this.tile,r=t=>t.isLoaded||t.level===e.level,i=e=>e.isLoaded,o=[null,null,null,null],s=[null,null,null,null];(()=>{for(let t=0;t<4;++t){const i=e.findNeighborTile(h[t],r);o[t]=i,s[t]=null!=i&&i.isLoaded?i:null}})();const n=[null,null,null,null];(()=>{for(let t=0;t<4;++t)n[t]=e.findNeighborTile(c[t],i)})();const a=this.geometryState.neighborData;let u=!1;(()=>{for(let t=0;t<4;++t){const r=a.edgeResolutions[t],i=o[t],s=this._calculateEdgeResolution(t,i);a.edgeResolutions[t]=s,r!==s&&(u=!0,i&&i!==e&&!i.isLoaded&&i.level===e.level&&(a.modifiedEdgeResolutions[t]=!0))}})();(()=>{const r=[null,null,null,null],i=(i,o)=>{let s=1/0;for(let t=0;t<4;++t){const o=c[t],n=i[t];if(n){const i=n.findCorner(g(o),(t=>(null==t?void 0:t.isLoaded)||t===e));r[t]=i,s=Math.min(s,i.level)}else r[t]=null}for(let m=0;m<4;++m){const i=r[(m+3)%4],s=r[m];if(i&&i.level<e.level&&i===s){const r=i,s=1==(1&m),n=(e.getNeighborEdgeStartVertexIndex(m,r)+(0===o||1===o&&!s||3===o&&s?1:0))/2**(e.level-r.level),a=s?0===o||1===o?r.extent[0]:r.extent[2]:t(r.extent[0],r.extent[2],n),u=s?t(r.extent[1],r.extent[3],n):0===o||3===o?r.extent[1]:r.extent[3];return l(a,u,r.renderData.geometryState.samplerData)}}let n=0,a=0;for(let e=0;e<4;++e){const t=r[e];if(t&&t.level===s){var u,h;const r=0===e||1===e,i=0===e||3===e,o=t.extent;a+=l(o[r?0:2],o[i?1:3],null==(u=t.renderData)||null==(h=u.geometryState)?void 0:h.samplerData),n++}}return n?a/n:0},o=this.geometryState.neighborData.cornerElevations,a=(e,t)=>{const r=i(t,e);return o[e]!==r&&(o[e]=r,!0)};for(let t=0;t<4;++t){const r=n[t],i=s[t],o=[r,s[(t+1)%4],e,i],l=o.map(((e,r)=>o[(r+4-t)%4])),h=a(t,l);u||(u=h)}})();return(()=>{const t=(t,r)=>{if(null==t||!t.isLoaded||t.lij[0]>e.lij[0])return null;const i=t.renderData.geometryState;return{neighborSamplerData:i.samplerData,neighborEdgeOverlapResolution:i.neighborData.edgeResolutions[r+2],version:i.samplerDataVersion,neighborVerticesPerSide:i.numVerticesPerSide,neighborTile:t}},r=a.edges;for(let o=0;o<4;++o){var i;const n=s[o];n&&(x(null==n?void 0:n.isLoaded),x((null==n?void 0:n.lij[0])<=e.lij[0]));const a=r[o],l=null==a?void 0:a.version,h=t(n,o),m=null!=(i=null==h?void 0:h.version)?i:null,d=null!=a!=(null!=h),c=a&&h&&l!==m,g=a&&h&&(null==a?void 0:a.neighborTile)!==(null==h?void 0:h.neighborTile),f=d||c||g;u||(u=f),!f&&l||(r[o]=h)}})(),u}updateEdgeAfterResolutionChange(e){var t,r;const i=this._calculateEdgeResolution(e),o=this.geometryState.neighborData.edgeResolutions,s=o[e];x((null!=(t=null==(r=this.geometryState.neighborData.edges[e])?void 0:r.neighborTile.level)?t:0)<=this.tile.level),i!==s&&(o[e]=i,this._updateGeometry(this.vao.context))}_updateGeometry(e){this._releaseGeometry(),this._createGeometry(e)}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}updateGeometryStateAndPrepareForGeometryGeneration(t){const r=this._getElevationInfo(),i=r.samplerData?this.tile.getElevationBasedVerticesPerSide(r.maxTileLevel):this.tile.getDefaultVerticesPerRowOnLevel(),o=Math.max(i,5);let s=this.tile.clippingArea;this.tile.intersectsClippingArea&&!this.tile.isWithinClippingArea||(s=null);const n=this.geometryState;let a=!1;return n.numVerticesPerSide!==o&&(n.numVerticesPerSide=o,n.samplerDataVersion++,a=!0),r.changed&&(n.samplerData=r.samplerData,n.samplerDataVersion++,a=!0),e(n.clippingArea,s)||(n.clippingArea=s,a=!0),n.wireframe!==t&&(n.wireframe=t,a=!0),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=a),this._hasGeometry=!0,a}_createGeometry(e){this.tile.createGeometry(this.geometryState,this.localOrigin);const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new T(e,b,{geometry:a(t.layout)},{geometry:G.createVertex(e,i.STATIC_DRAW,t.buffer)},G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,!!this._vao&&(this._vao.dispose(),this._vao=null,y(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=_.Immediate){r(e)&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[f.ELEVATION],i=t.length;let o=new Array(i),s=0,n=0,a=!1;for(let l=0;l<i;l++){const i=t[l];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[f.ELEVATION][l].data,u=r&&r.samplerData;e&&e[s]===u||(a=!0),o[s++]=u,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(l,f.ELEVATION);if(S(this.tile,t.layer,!1)){const t=i.data;e&&e[s]===t.samplerData||(a=!0),o[s++]=t.samplerData,n=this.tile.level}}}return r(e)&&e.length!==s&&(a=!0),s>0?o.length=s:o=null,{changed:a,samplerData:o,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=o(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return this.geometryInfo.indices.byteLength+this.geometryInfo.vertexAttributes.byteLength+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){}}function j(e,t){return t[0]>=e[0]-d&&t[2]<=e[2]+d&&t[1]>=e[1]-d&&t[3]<=e[3]+d}function I(e,t,i){if(r(i))for(const r of i)if(r){const i=r.x0,o=r.width,s=i+(o-1)/r.dx,n=r.y1,a=n-(o-1)/r.dy;if(e>=i-d&&e<=s+d&&a-d<=t&&t<=n+d)return!0}return!1}function R(e,t){for(const r of t)if(r){const t=r.x0,i=r.width,o=t+(i-1)/r.dx,s=r.y1,a=s-(i-1)/r.dy;if(j(n(t,a,o,s),e))return!0}return!1}export{L as PatchRenderData,I as isElevationSampleIn,R as isExtentInSampler};
@@ -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 l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as u,isSome as p}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 y,syncAndInitial as T,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as S}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as x}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as R}from"../../../chunks/vec3f64.js";import{c as b}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as j}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as C,projectPointToVector as U}from"../../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../../geometry/projectionEllipsoid.js";import{create as M,equals as I,intersection as V,empty as k,expand as O,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as q,copy as B}from"../../../geometry/support/frustum.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as W}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as F}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as Q}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X,scaleToZoom as z}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{sampleElevation as ee,ElevationData as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{DEFAULT_TILE_BACKGROUND as ue,MAX_ROOT_TILES as pe,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ce,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as _e,MAX_MEMORY_LOD_BIAS as ge,ELEVATION_NODATA_VALUE as me}from"./TerrainConst.js";import fe from"./TerrainRenderer.js";import ye from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Te,isSurfaceLayerView as ve,isMapTileLayerView as we,isElevationLayerView as Se,isVectorTileLayerView as Le,useFetchTileForLayer as Ee,isImageryTileLayerView as xe,isTileLayerView as De,releaseTileData as Pe,ENABLE_WATERPROOFNESS_TESTS as Re}from"./terrainUtils.js";import{SplitLimits as be,Tile as je}from"./Tile.js";import{printAllocations as Ce}from"./TilePerLayerInfo.js";import{TileUpdate as Ue}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Me,hasLoadableSiblings as Ie,sortTilesByPOI as Ve,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as Oe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ne}from"./UpsampleInfo.js";import{RenderRequestType as qe}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Be,TaskPriority as Ge,noBudget as We}from"../../support/Scheduler.js";const Fe=l.getLogger("esri.views.3d.terrain.TerrainSurface"),He=.25;let Qe=class extends(a.EventedMixin(i)){constructor(e){var t,i;super(e),this._elevationBounds=new Z,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Me,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=Ke,this._performanceInfo=new ye,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=R(),this._eyePosSurfaceSR=R(),this._splitLimits=new be,this._snapLevel=1/0,this._frustum=q(),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 j,this._frameTask=Be,this._allTiles=new _,this._upsampleInfoPool=new c(Ne),this._rootTilesExtent=M(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundImage=ue,this.backgroundColor=null,this._updatingRootTiles=!1,this._layerViewsDirty=!1,this._isGlobal=!(null!=(t=e.view)&&null!=(i=t.state)&&i.isLocal)}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new W(e.newCache("elevation-query")),this._set("overlayManager",new le({surface:this})),this._handles.add([y((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),y((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new fe({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:A(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([y((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),T),y((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),y((()=>this._background),(()=>{this._handleLayerViewChanges(),this._renderer.setTileBackground(this._background)}),T),y((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),y((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>{var e,t,i;return null==(e=this.view)||null==(t=e.defaultsFromMap)||null==(i=t.mapCollections)?void 0:i.map((({layers:e})=>e))},getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Oe({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Ge.TERRAIN_SURFACE,this),this._handles.add([y((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),y((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),y((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),y((()=>{var e,t;const i=this.view,r=i.state;return[this.lodBias,this.lodSnapping,null==(e=i.resourceController)||null==(t=e.memoryController)?void 0:t.memoryFactor,r.camera,r.contentCamera,r.fixedContentCamera]}),(()=>this._viewChangeUpdate()),T),y((()=>{var e,t;return null==(e=this.view.qualitySettings)||null==(t=e.tiledSurface)?void 0:t.textureFadeDuration}),(e=>this._renderer.textureFadingEnabled=e>0),w),y((()=>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),je.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),Q(),Ce()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){var e,t;const i=null==(e=this.view.pointsOfInterest)||null==(t=e.contentCameraOnSurface)?void 0:t.scale;if(i){const e=this.view.state.contentCamera;let t=X(this.view,e.eye,e.viewForward,e.up).tilt;t>90&&(t=180-t);const r=2*(t/90)**2,s=z(this.view,i)-r;Math.abs(this._snapLevel-s)>He&&(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?re.ON:re.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(u(t)||u(e))return null;const i=M(),r=$(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,M()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return p(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){var e;return null==(e=this.tilingSchemeLogic)?void 0:e.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._renderer.updating||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 p(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){var e,t;return null!=(e=null==(t=this.tilingScheme)?void 0:t.spatialReference)?e:null}get _background(){return null!=this.backgroundColor?this.backgroundColor:this.backgroundImage}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){var e,t;const i=!this.renderingDisabled&&!this.opaque;null==(e=this.view)||null==(t=e._stage)||t.renderView.setRenderParameters({transparentTerrain:i})}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,Je);return u(s)?null:ee(Je[0],Je[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=Je){var a;const n=this.rootTiles;if(u(n)||!n.length)return null;if(0===n[0].layerInfo[ae.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!C(s,r,s,null==(a=this.tilingScheme)?void 0:a.spatialReference))return Fe.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let l of n){if(!l.containsPoint(s))continue;for(;l&&!l.rendered&&!l.isLeaf;){let e=0;s[0]>.5*(l.extent[0]+l.extent[2])&&(e+=1),s[1]<.5*(l.extent[1]+l.extent[3])&&(e+=2),l=l.children[e]}const e=l.renderData;return(e?e.geometryState.samplerData:null)?l:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!U(e,Je,this.spatialReference))return Fe.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(p(t))for(let e of t)if(e.containsPoint(Je)){for(;null!=e.children[0];){let t=0;Je[0]>e.children[0].extent[2]&&(t+=1),Je[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!U(e,Je,this.spatialReference))return Fe.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Je[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,Je))if(null!=e.children[0])for(const t of e.children)r(t);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}},s=this.rootTiles;if(p(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._renderer.isTransparent=this._allTransparentSurfaceLayers();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?se.UNFADED:se.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(Te(!!e,"tiling scheme cannot be reset to undefined"),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 et[0]=e,et[1]=t,et[2]=i,s.init(et,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=Ze;let s=t.rootTilesInExtent(e,i,5*pe);if(p(this.rootTiles)){if(s.length>pe)return void Fe.warn(ce);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,ze);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>ze(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>pe&&(Fe.warn(_e),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=M(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),e.updateNeighborsAfterGeometryChange())})),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)===Ue.SPLIT&&t.setPendingUpdate(Ue.SPLIT),this._loadTile(t),t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),p(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(Ue.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(u(e))return;const t=Ie(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(Ue.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ue.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?(u(this._splitLimits.frustum)&&(this._splitLimits.frustum=q()),B(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,B(this._frustum,e.frustum),x(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),C(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Ye(e)?(this._loadChildren(e),this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness()))):$e(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),e.updateNeighborsAfterGeometryChange(),this._elevationUpdate(e),this._usedMemory=Ke}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ue.TEXTURE_FADING)?Ue.TEXTURE_FADING:!!e.resetPendingUpdate(Ue.TEXTURE_NOFADING)&&Ue.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=Ke,t.madeProgress())}_elevationUpdate(e){it.spatialReference=this.spatialReference,it.tile=e,it.extent=e.extent,this.emit("elevation-change",it)}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.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!==Ue.SPLIT){if(e.resetPendingUpdate(Ue.SPLIT)&&e.updateAgentSuspension(),i===Ue.VSPLITMERGE&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ue.MERGE),e.resetPendingUpdate(Ue.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(Ue.MERGE),e.isLeaf&&(e.setPendingUpdate(Ue.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ve(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=0,r=!1;for(;!e.done;){let s=!1;i=0;const a=!this._allTiles.some((a=>{if(r)i+=a.usedMemory;else if(!a.loadable)return e.done;if(a.resetPendingUpdate(Ue.MERGE)){if(!t)return a.setPendingUpdate(Ue.MERGE),e.done;this._mergeTile(a),s=!0,e.madeProgress()}else a.resetPendingUpdate(Ue.SPLIT)&&(this._splitTile(a),s=!0,e.madeProgress());return!e.done&&a.resetPendingUpdate(Ue.RENDERDATA)&&(this._updateRenderData(a),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!r){r=!0;continue}if(this._usedMemory=i,!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}0===i&&(this._allTilesDirty=!0),this._sortTiles(e)}_updateElevation(e){return this._allTiles.some((t=>(t.resetPendingUpdate(Ue.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(qe.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ge}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(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(){p(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&&e.updateNeighborsAfterGeometryChange(),this._tilePool.release(e),i}_unloadTile(e){e.unload(this._renderer)}_splitTile(e){Te(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(Ue.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){rt.spatialReference=this.spatialReference,rt.extent=e.extent,rt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",rt)}_createTile(e,t,i,r){Te(!!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)===Ue.SPLIT&&s.setPendingUpdate(Ue.SPLIT),s}_mergeTile(e){Te(!e.hasPendingUpdate(Ue.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(Te(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),e.updateNeighborsAfterGeometryChange(),this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Re&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this._checkTileAndNeighborsWaterproofness(e),Te(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))),e.updateNeighborsAfterGeometryChange(e.level+1),t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e)}_loadParent(e){this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),t.updateNeighborsAfterGeometryChange(),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(Ue.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 te(e.lij,e.extent,i);e.dataArrived(t,ae.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=We){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),ve(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._layerIndexByUid[e].get(s.uid);i<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._allTransparentSurfaceLayers(),e.madeProgress()}_allTransparentSurfaceLayers(){var e,t;let i=0===(null==(e=this.view.map)||null==(t=e.ground)?void 0:t.opacity);for(const r of this.view.allLayerViews.items)if(we(r)&&!F(r.layer)&&0!==r.fullOpacity)return i=!1,i;return i}_layerClassFromLayerView(e){return Se(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(y((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(y((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(y((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._layerIndexByUid[i].get(e.uid);null!=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;const r=k();e.forEach((e=>{const s=e.layer;if(!s||e.suspended||!ve(e))return;const a=e.fullExtent;if(!a)return void Fe.warn("Terrain: Map or elevation layer does not have fullExtent: "+s.id);O(r,a,r);const n=this._layerClassFromLayerView(e);if(n===ae.MAP){const t=e.displayLevelRange;t.maxLevel!==1/0&&(null===i||t.maxLevel>i)&&(i=t.maxLevel)}t[n].push(e)}));for(const s of ne){const e=this._layerViews[s],i=t[s];i.reverse();const r=i.length;let a=e.length!==r;const n=new Array(r),l=new Array(e.length);this._layerIndexByUid[s].clear();for(let t=0;t<r;t++){const r=i[t].uid;this._layerIndexByUid[s].set(r,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,s);this._layerViews[s]=i,this._restartAllAgents(s),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===ae.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(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ue.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._renderer.isTransparent=this._allTransparentSurfaceLayers()}_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=qe.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||Le(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===ae.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():we(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(--this._asyncWorkItems,m(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=Ke,this.requestUpdate(),this._elevationDataArrived(e,s,r)):Fe.warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{--this._asyncWorkItems,g(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:me,signal:i.signal}).then((e=>{if(m(i))return Fe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void s(f());this._frameTask.schedule((()=>r(e)),i.signal,s)}),s);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:me},i.signal))).then((e=>{r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue})}),s)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Pe(s),m(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Pe(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Le(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(xe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return Fe.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 l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const o=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,o,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._layerIndexByUid[ae.MAP].get(t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(Pe(i),Fe.warn("TerrainSurface: received data from unknown layer"))}_dataMissing(e,t,i,r){const s=this._layerIndexByUid[t].get(i.uid);null!=s?e.dataMissing(s,t,r):Fe.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?(this._usedMemory===Ke&&(this._usedMemory=0,this._allTiles.forAll((e=>this._usedMemory+=e.usedMemory))),this._usedMemory):0}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._layerIndexByUid[i].get(e.uid);return this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(u(e)||u(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 Te(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:()=>{p(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){tt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&tt.push(e)}));const t=tt.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Re)return;const e=this.rootTiles;if(u(e))return;const t=e=>{var t,i,r,s;return null!=(t=(null==e||null==(i=e.renderData)||null==(r=i.geometryInfo)||null==(s=r.indices)?void 0:s.length)>0)&&t},i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{var s,a,n;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"),null==(s=e.renderData)||!s.geometryInfo||(null!=(a=null==(n=e.renderData.geometryInfo.indices)?void 0:n.length)?a: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=>{var t,i;const r=null==(t=null==(i=e.parent)?void 0:i.visible)||t,a=e.visible;e.computeVisibility();const n=e.visible;if(a!==n&&r&&console.error(" Tile[",e.lij,"] has out of date visibility: ",a," instead of ",n),!e.isLeaf)for(const l of e.children)s(l)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}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([L()],Qe.prototype,"_renderer",void 0),e([L()],Qe.prototype,"_hasPendingUpdates",void 0),e([L()],Qe.prototype,"_asyncWorkItems",void 0),e([L()],Qe.prototype,"_allTilesDirty",void 0),e([L()],Qe.prototype,"_allTilesSorted",void 0),e([L()],Qe.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Qe.prototype,"_watchUpdatingTracking",void 0),e([L()],Qe.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Qe.prototype,"snapLevel",null),e([L({readOnly:!0})],Qe.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Qe.prototype,"view",void 0),e([L()],Qe.prototype,"_userClippingExtent",null),e([L()],Qe.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Qe.prototype,"extent",null),e([L({readOnly:!0})],Qe.prototype,"groundExtent",null),e([L({readOnly:!0})],Qe.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Qe.prototype,"updating",null),e([L(J)],Qe.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Qe.prototype,"updatingProgressValue",null),e([L()],Qe.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Qe.prototype,"baseOpacity",void 0),e([L({readOnly:!0})],Qe.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Qe.prototype,"viewingMode",null),e([L()],Qe.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Qe.prototype,"ready",null),e([L({value:he.FRONT_TO_BACK})],Qe.prototype,"renderOrder",null),e([L({readOnly:!0})],Qe.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Qe.prototype,"spatialReference",null),e([L()],Qe.prototype,"backgroundImage",void 0),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Qe.prototype,"backgroundColor",void 0),e([L()],Qe.prototype,"_background",null),e([L({value:!1})],Qe.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Qe.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Qe.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Qe.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Qe.prototype,"velvetOverground",null),e([S("_renderer.wireframe")],Qe.prototype,"wireframe",void 0),e([L({value:!1})],Qe.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Qe.prototype,"textureFadeDuration",void 0),e([L()],Qe.prototype,"_layerViewsDirty",void 0),e([S("_renderer.renderPatchBorders")],Qe.prototype,"renderPatchBorders",void 0),e([S("_renderer.renderingDisabled")],Qe.prototype,"renderingDisabled",void 0),Qe=e([E("esri.views.3d.terrain.TerrainSurface")],Qe);const Xe=Qe;function ze(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Ye(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Ye(e))))}function $e(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const Ke=-1,Je=b(),Ze=M(),et=[0,0,0],tt=new _,it={spatialReference:null,tile:null,extent:null,context:"ground"},rt={spatialReference:null,extent:null,scale:0};export{Xe 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 l from"../../../core/Logger.js";import{clamp as o}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 T}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as S}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as L}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 x}from"../../../chunks/mat4f64.js";import{c as D}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as P}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as R}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as C,projectPointToVector as j}from"../../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../../geometry/projectionEllipsoid.js";import{create as M,equals as I,intersection as V,empty as k,expand as O,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as q,copy as B}from"../../../geometry/support/frustum.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as W}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as F}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as Q}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X,scaleToZoom as z}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{sampleElevation as ee,ElevationData as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{DEFAULT_TILE_BACKGROUND as pe,MAX_ROOT_TILES as ue,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ce,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as _e,MAX_MEMORY_LOD_BIAS as ge,ELEVATION_NODATA_VALUE as me}from"./TerrainConst.js";import Te from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ye,internalAssert as ve,isSurfaceLayerView as we,isMapTileLayerView as Se,isElevationLayerView as Le,isVectorTileLayerView as Ee,useFetchTileForLayer as be,isImageryTileLayerView as xe,isTileLayerView as De,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as Pe}from"./terrainUtils.js";import{SplitLimits as Re,Tile as Ce}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Ae}from"./TileUpdate.js";import{IteratorPreorder as Me,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as ke,sortTiles as Oe}from"./tileUtils.js";import{TilingSchemeLogic as Ne}from"./TilingSchemeLogic.js";import{UpsampleInfo as qe}from"./UpsampleInfo.js";import{RenderRequestType as Be}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Ge,TaskPriority as We,noBudget as Fe}from"../../support/Scheduler.js";const He=l.getLogger("esri.views.3d.terrain.TerrainSurface"),Qe=.25;let Xe=class extends(a.EventedMixin(i)){constructor(e){var t,i;super(e),this._elevationBounds=new Z,this._iteratorPool=new c(Me,(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=Je,this._performanceInfo=new fe,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Re,this._snapLevel=1/0,this._frustum=q(),this._viewProjectionMatrix=x(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new R,this._frameTask=Ge,this._allTiles=new _,this._upsampleInfoPool=new c(qe),this._rootTilesExtent=M(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundImage=pe,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!(null!=(t=e.view)&&null!=(i=t.state)&&i.isLocal)}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new W(e.newCache("elevation-query")),this._set("overlayManager",new le({surface:this})),this._handles.add([f((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),f((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new Te({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:A(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([f((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),f((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),f((()=>this._background),(()=>{this._handleLayerViewChanges(),this._renderer.setTileBackground(this._background)}),y),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),f((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>{var e,t,i;return null==(e=this.view)||null==(t=e.defaultsFromMap)||null==(i=t.mapCollections)?void 0:i.map((({layers:e})=>e))},getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Ne({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(We.TERRAIN_SURFACE,this),this._handles.add([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),f((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),f((()=>{var e,t;const i=this.view,r=i.state;return[this.lodBias,this.lodSnapping,null==(e=i.resourceController)||null==(t=e.memoryController)?void 0:t.memoryFactor,r.camera,r.contentCamera,r.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),f((()=>{var e,t;return null==(e=this.view.qualitySettings)||null==(t=e.tiledSurface)?void 0:t.textureFadeDuration}),(e=>this._renderer.textureFadingEnabled=e>0),w),f((()=>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),Ce.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),Q(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){var e,t;const i=null==(e=this.view.pointsOfInterest)||null==(t=e.contentCameraOnSurface)?void 0:t.scale;if(i){const e=this.view.state.contentCamera;let t=X(this.view,e.eye,e.viewForward,e.up).tilt;t>90&&(t=180-t);const r=2*(t/90)**2,s=z(this.view,i)-r;Math.abs(this._snapLevel-s)>Qe&&(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?re.ON:re.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=M(),r=$(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,M()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){var e;return null==(e=this.tilingSchemeLogic)?void 0:e.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._renderer.updating||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(){var e,t;return null!=(e=null==(t=this.tilingScheme)?void 0:t.spatialReference)?e:null}get _background(){return null!=this.backgroundColor?this.backgroundColor:this.backgroundImage}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){var e,t;const i=!this.renderingDisabled&&!this.opaque;null==(e=this.view)||null==(t=e._stage)||t.renderView.setRenderParameters({transparentTerrain:i})}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,Ze);return p(s)?null:ee(Ze[0],Ze[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=Ze){var a;const n=this.rootTiles;if(p(n)||!n.length)return null;if(0===n[0].layerInfo[ae.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!C(s,r,s,null==(a=this.tilingScheme)?void 0:a.spatialReference))return He.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let l of n){if(!l.containsPoint(s))continue;for(;l&&!l.rendered&&!l.isLeaf;){let e=0;s[0]>.5*(l.extent[0]+l.extent[2])&&(e+=1),s[1]<.5*(l.extent[1]+l.extent[3])&&(e+=2),l=l.children[e]}const e=l.renderData;return(e?e.geometryState.samplerData:null)?l:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!j(e,Ze,this.spatialReference))return He.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(Ze)){for(;null!=e.children[0];){let t=0;Ze[0]>e.children[0].extent[2]&&(t+=1),Ze[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,Ze,this.spatialReference))return He.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Ze[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,Ze))if(null!=e.children[0])for(const t of e.children)r(t);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,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._renderer.isTransparent=this._allTransparentSurfaceLayers();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?se.UNFADED:se.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(ye(!!e,"tiling scheme cannot be reset to undefined"),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 tt[0]=e,tt[1]=t,tt[2]=i,s.init(tt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=et;let s=t.rootTilesInExtent(e,i,5*ue);if(u(this.rootTiles)){if(s.length>ue)return void He.warn(ce);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ye);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ye(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>ue&&(He.warn(_e),s=t.rootTilesInExtent(e,i,ue)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=M(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)===Ae.SPLIT&&t.setPendingUpdate(Ae.SPLIT),this._loadTile(t),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(Ae.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(Ae.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ae.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=q()),B(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,B(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),C(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&($e(e)?(this._loadChildren(e),this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness()))):Ke(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=Je,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(Ae.TEXTURE_FADING)?Ae.TEXTURE_FADING:!!e.resetPendingUpdate(Ae.TEXTURE_NOFADING)&&Ae.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=Je,t.madeProgress())}_elevationUpdate(e){rt.spatialReference=this.spatialReference,rt.tile=e,rt.extent=e.extent,this.emit("elevation-change",rt)}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.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!==Ae.SPLIT){if(e.resetPendingUpdate(Ae.SPLIT)&&e.updateAgentSuspension(),i===Ae.VSPLITMERGE&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ae.MERGE),e.resetPendingUpdate(Ae.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(Ae.MERGE),e.isLeaf&&(e.setPendingUpdate(Ae.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(ke(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){ve(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();let i=0;this._prepareBatchTileGeometryUpdate();let r=!1;for(;!e.done;){let s=!1;i=0;const a=!this._allTiles.some((a=>{if(r)i+=a.usedMemory;else if(!a.loadable)return e.done;if(a.resetPendingUpdate(Ae.MERGE)){if(!t)return a.setPendingUpdate(Ae.MERGE),e.done;this._mergeTile(a),s=!0,e.madeProgress()}else a.resetPendingUpdate(Ae.SPLIT)&&(this._splitTile(a),s=!0,e.madeProgress());return!e.done&&a.resetPendingUpdate(Ae.RENDERDATA)&&(this._updateRenderData(a),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!r){r=!0;continue}if(this._usedMemory=i,!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}0===i&&(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Ae.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(Be.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ge}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(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){ye(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(Ae.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){st.spatialReference=this.spatialReference,st.extent=e.extent,st.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",st)}_createTile(e,t,i,r){ye(!!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)===Ae.SPLIT&&s.setPendingUpdate(Ae.SPLIT),s}_mergeTile(e){ye(!e.hasPendingUpdate(Ae.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(ye(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),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._checkTileAndNeighborsWaterproofness(e),ye(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._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),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(Ae.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 te(e.lij,e.extent,i);e.dataArrived(t,ae.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=Fe){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),we(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._layerIndexByUid[e].get(s.uid);i<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._allTransparentSurfaceLayers(),e.madeProgress()}_allTransparentSurfaceLayers(){var e,t;let i=0===(null==(e=this.view.map)||null==(t=e.ground)?void 0:t.opacity);for(const r of this.view.allLayerViews.items)if(Se(r)&&!F(r.layer)&&0!==r.fullOpacity)return i=!1,i;return i}_layerClassFromLayerView(e){return Le(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(f((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(f((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(f((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._layerIndexByUid[i].get(e.uid);null!=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;const r=k();e.forEach((e=>{const s=e.layer;if(!s||e.suspended||!we(e))return;const a=e.fullExtent;if(!a)return void He.warn("Terrain: Map or elevation layer does not have fullExtent: "+s.id);O(r,a,r);const n=this._layerClassFromLayerView(e);if(n===ae.MAP){const t=e.displayLevelRange;t.maxLevel!==1/0&&(null===i||t.maxLevel>i)&&(i=t.maxLevel)}t[n].push(e)}));for(const s of ne){const e=this._layerViews[s],i=t[s];i.reverse();const r=i.length;let a=e.length!==r;const n=new Array(r),l=new Array(e.length);this._layerIndexByUid[s].clear();for(let t=0;t<r;t++){const r=i[t].uid;this._layerIndexByUid[s].set(r,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,s);this._layerViews[s]=i,this._restartAllAgents(s),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===ae.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(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ae.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._renderer.isTransparent=this._allTransparentSurfaceLayers()}_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=Be.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===ae.ELEVATION?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():Se(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(--this._asyncWorkItems,m(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=Je,this.requestUpdate(),this._elevationDataArrived(e,s,r)):He.warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{--this._asyncWorkItems,g(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:me,signal:i.signal}).then((e=>{if(m(i))return He.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void s(T());this._frameTask.schedule((()=>r(e)),i.signal,s)}),s);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:me},i.signal))).then((e=>{r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue})}),s)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,ae.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(xe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return He.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(T());a(e)}),n);let l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const o=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,o,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._layerIndexByUid[ae.MAP].get(t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(Ue(i),He.warn("TerrainSurface: received data from unknown layer"))}_dataMissing(e,t,i,r){const s=this._layerIndexByUid[t].get(i.uid);null!=s?e.dataMissing(s,t,r):He.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?(this._usedMemory===Je&&(this._usedMemory=0,this._allTiles.forAll((e=>this._usedMemory+=e.usedMemory))),this._usedMemory):0}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._layerIndexByUid[i].get(e.uid);return 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 ye(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(){it.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&it.push(e)}));const t=it.toArray();return Oe(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=>{var t,i,r,s;return null!=(t=(null==e||null==(i=e.renderData)||null==(r=i.geometryInfo)||null==(s=r.indices)?void 0:s.length)>0)&&t},i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{var s,a,n;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"),null==(s=e.renderData)||!s.geometryInfo||(null!=(a=null==(n=e.renderData.geometryInfo.indices)?void 0:n.length)?a: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=>{var t,i;const r=null==(t=null==(i=e.parent)?void 0:i.visible)||t,a=e.visible;e.computeVisibility();const n=e.visible;if(a!==n&&r&&console.error(" Tile[",e.lij,"] has out of date visibility: ",a," instead of ",n),!e.isLeaf)for(const l of e.children)s(l)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}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([L()],Xe.prototype,"_renderer",void 0),e([L()],Xe.prototype,"_hasPendingUpdates",void 0),e([L()],Xe.prototype,"_asyncWorkItems",void 0),e([L()],Xe.prototype,"_allTilesDirty",void 0),e([L()],Xe.prototype,"_allTilesSorted",void 0),e([L()],Xe.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Xe.prototype,"_watchUpdatingTracking",void 0),e([L()],Xe.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Xe.prototype,"snapLevel",null),e([L({readOnly:!0})],Xe.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Xe.prototype,"view",void 0),e([L()],Xe.prototype,"_userClippingExtent",null),e([L()],Xe.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Xe.prototype,"extent",null),e([L({readOnly:!0})],Xe.prototype,"groundExtent",null),e([L({readOnly:!0})],Xe.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Xe.prototype,"updating",null),e([L(J)],Xe.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Xe.prototype,"updatingProgressValue",null),e([L()],Xe.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Xe.prototype,"baseOpacity",void 0),e([L({readOnly:!0})],Xe.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Xe.prototype,"viewingMode",null),e([L()],Xe.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Xe.prototype,"ready",null),e([L({value:he.FRONT_TO_BACK})],Xe.prototype,"renderOrder",null),e([L({readOnly:!0})],Xe.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Xe.prototype,"spatialReference",null),e([L()],Xe.prototype,"backgroundImage",void 0),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Xe.prototype,"backgroundColor",void 0),e([L()],Xe.prototype,"_background",null),e([L({value:!1})],Xe.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Xe.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Xe.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Xe.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Xe.prototype,"velvetOverground",null),e([S("_renderer.wireframe")],Xe.prototype,"wireframe",void 0),e([L({value:!1})],Xe.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Xe.prototype,"textureFadeDuration",void 0),e([L()],Xe.prototype,"_layerViewsDirty",void 0),e([S("_renderer.renderPatchBorders")],Xe.prototype,"renderPatchBorders",void 0),e([S("_renderer.renderingDisabled")],Xe.prototype,"renderingDisabled",void 0),Xe=e([E("esri.views.3d.terrain.TerrainSurface")],Xe);const ze=Xe;function Ye(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function $e(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>$e(e))))}function Ke(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const Je=-1,Ze=P(),et=M(),tt=[0,0,0],it=new _,rt={spatialReference:null,tile:null,extent:null,context:"ground"},st={spatialReference:null,extent:null,scale:0};export{ze as default};