@vertigis/arcgis-extensions 41.4.4 → 41.5.0

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.
@@ -16,7 +16,7 @@
16
16
  <li><a href="../modules/version.html">version</a></li>
17
17
  <li><a href="version.version.html">version</a></li></ul>
18
18
  <h1>Variable version<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
19
- <div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;41.4.4&quot;</span><span class="tsd-signature-symbol"> = &quot;41.4.4&quot;</span></div>
19
+ <div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;41.5.0&quot;</span><span class="tsd-signature-symbol"> = &quot;41.5.0&quot;</span></div>
20
20
  <div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
21
21
  </div></div>
22
22
  <div class="col-sidebar">
package/json/LayerJson.js CHANGED
@@ -1 +1 @@
1
- import e from"@arcgis/core/core/Collection.js";import{isBuildingSceneLayer as r,isCSVLayer as t,isElevationLayer as i,isFeatureLayer as o,isGeoJSONLayer as a,isGeoRssLayer as n,isGraphicsLayer as y,isGroupLayer as l,isImageryLayer as s,isImageryTileLayer as p,isIntegratedMeshLayer as c,isKMLLayer as f,isMapImageLayer as u,isMapNotesLayer as m,isOpenStreetMapLayer as d,isPointCloudLayer as S,isRouteLayer as L,isSceneLayer as g,isStreamLayer as T,isSubtypeGroupLayer as G,isTiledImageServiceLayer as I,isTileLayer as b,isVectorTileLayer as v,isWebTileLayer as J,isWMSLayer as A,isWMTSLayer as M}from"../utilities/_layers.js";import{groupBy as j}from"../utilities/array.js";import{isBasemap as w,isGround as O,isMap as D,isWebMap as h,isWebScene as C}from"../utilities/mapping.js";import{graphicToJson as N}from"./FeatureJson.js";import{geometryTypeToJson as x}from"./GeometryJson.js";export async function jsonToLayer(e){return(await import("../portal/LayerBase.js")).LayerBase.toEsriApiLayer(e)}export async function applyJsonToLayer(e,r){e&&Object.keys(e).some((e=>"$ref"!==e&&"layerType"!==e))&&await(await import("../portal/LayerBase.js")).LayerBase.applyToEsriApiLayer(e,r)}export function layerToJson(r){const t=e=>e?"GroupLayer"===e.layerType?[e,...e.layers?.flatMap(t)??[]]:[e]:[],{parent:i}=r;let a;try{if(l(i)){const e=layerToJson(i);a=t(e)?.find((e=>e.id===r.id))}else if(h(i)||C(i)){const e=i.toJSON();a=e.operationalLayers?.flatMap(t)?.find((e=>e.id===r.id))}else if(O(i)){const e=i.toJSON();a=e.layers?.find((e=>e.id===r.id))}else if(w(i)){const e=i.toJSON();a=e.baseMapLayers?.find((e=>e.id===r.id))}}catch{}if(!a){if(y(r))return function(e){const r={id:e.id,title:e.title,layerType:"ArcGISFeatureLayer",visibility:e.visible,opacity:e.opacity,listMode:e.listMode,featureCollection:{layers:[]}},t=j(e.graphics.toArray(),(e=>x(e.geometry.type))),i="graphic-id";for(const[o,a]of t.entries())r.featureCollection.layers.push({layerDefinition:{geometryType:o,name:E(o)},featureSet:{features:a.map((r=>({geometry:r.geometry.toJSON(),attributes:{...r.attributes,[i]:e.graphics.indexOf(r)},symbol:r.symbol?.toJSON(),popupInfo:r.popupTemplate?.toJSON()}))),geometryType:o}});return r}(r);if(o(r)&&e.isCollection(r.source))return function(e){const r=e.write({},{layerContainerType:"operational-layers",origin:"web-map"}),t={featureSet:{features:e.source.map(N).toArray(),geometryType:x(e.geometryType)}};return t.layerDefinition=r.layerDefinition??{},delete r.layerDefinition,t.layerDefinition.geometryType=x(e.geometryType),t.layerDefinition.objectIdField=e.objectIdField,t.layerDefinition.hasZ=!0,t.layerDefinition.elevationInfo=e.elevationInfo?.write(),t.popupInfo=r.popupInfo,delete r.popupInfo,t.layerDefinition.fields=e.fields.map((e=>e.toJSON())),t.layerDefinition.extent=e.fullExtent?.toJSON(),r.featureCollection={layers:[t],showLegend:e.legendEnabled},r}(r);a=r.write({},{layerContainerType:"operational-layers",origin:C(P(r))?"web-scene":"web-map"})}return a}function P(e){let{parent:r}=e;for(;r?.parent;)r=r.parent;return D(r)?r:void 0}function E(e){switch(e){case"esriGeometryPoint":return"Points";case"esriGeometryMultipoint":return"Multipoints";case"esriGeometryPolyline":return"Polylines";case"esriGeometryEnvelope":case"esriGeometryPolygon":return"Polygons";default:return"Unknown Geometry"}}export function getLayerJsonType(e){return t(e)?"CSV":T(e)?"ArcGISStreamLayer":o(e)||y(e)||m(e)||L(e)?"ArcGISFeatureLayer":a(e)?"GeoJSON":n(e)?"GeoRSS":s(e)?"ArcGISImageServiceLayer":p(e)?"ArcGISTiledImageServiceLayer":f(e)?"KML":u(e)?"ArcGISMapServiceLayer":d(e)?"OpenStreetMap":J(e)?"WebTiledLayer":v(e)?"VectorTileLayer":I(e)?"ArcGISTiledImageServiceLayer":b(e)?"ArcGISTiledMapServiceLayer":i(e)?"ArcGISTiledElevationServiceLayer":g(e)?"ArcGISSceneServiceLayer":S(e)?"PointCloudLayer":c(e)?"IntegratedMeshLayer":l(e)?"GroupLayer":A(e)?"WMS":M(e)?"WebTiledLayer":r(e)?"BuildingSceneLayer":G(e)?"SubtypeGroupLayer":void 0}
1
+ import e from"@arcgis/core/core/Collection.js";import{isBuildingSceneLayer as r,isCSVLayer as t,isElevationLayer as o,isFeatureLayer as i,isGeoJSONLayer as a,isGeoRssLayer as n,isGraphicsLayer as y,isGroupLayer as l,isImageryLayer as s,isImageryTileLayer as p,isIntegratedMeshLayer as c,isKMLLayer as f,isMapImageLayer as u,isMapNotesLayer as m,isOpenStreetMapLayer as d,isPointCloudLayer as S,isRouteLayer as L,isSceneLayer as g,isStreamLayer as T,isSubtypeGroupLayer as G,isTiledImageServiceLayer as I,isTileLayer as b,isVectorTileLayer as J,isWebTileLayer as v,isWMSLayer as A,isWMTSLayer as M}from"../utilities/_layers.js";import{groupBy as h}from"../utilities/array.js";import{isBasemap as j,isGround as w,isMap as O,isWebMap as C,isWebScene as D}from"../utilities/mapping.js";import{graphicToJson as N}from"./FeatureJson.js";import{geometryTypeToJson as P}from"./GeometryJson.js";export async function jsonToLayer(e){return(await import("../portal/LayerBase.js")).LayerBase.toEsriApiLayer(e)}export async function applyJsonToLayer(e,r){e&&Object.keys(e).some((e=>"$ref"!==e&&"layerType"!==e))&&await(await import("../portal/LayerBase.js")).LayerBase.applyToEsriApiLayer(e,r)}export const layerToParentJsonCache={lookup:void 0};export function layerToJson(r){const t=e=>e?"GroupLayer"===e.layerType?[e,...e.layers?.flatMap(t)??[]]:[e]:[],{parent:o}=r;let a;const n=(e,r)=>{const{lookup:t}=layerToParentJsonCache;if(!t?.has(e)){const o=r();return t?.set(e,o),o}return t.get(e)};try{if(l(o)){const e=layerToJson(o);a=t(e)?.find((e=>e.id===r.id))}else if(C(o)||D(o)){const e=n(o,(()=>o.toJSON()));a=e.operationalLayers?.flatMap(t)?.find((e=>e.id===r.id))}else if(w(o)){const e=n(o,(()=>o.toJSON()));a=e.layers?.find((e=>e.id===r.id))}else if(j(o)){const e=n(o,(()=>o.toJSON()));a=e.baseMapLayers?.find((e=>e.id===r.id))}}catch{}if(!a){if(y(r))return function(e){const r={id:e.id,title:e.title,layerType:"ArcGISFeatureLayer",visibility:e.visible,opacity:e.opacity,listMode:e.listMode,featureCollection:{layers:[]}},t=h(e.graphics.toArray(),(e=>P(e.geometry.type))),o="graphic-id";for(const[i,a]of t.entries())r.featureCollection.layers.push({layerDefinition:{geometryType:i,name:E(i)},featureSet:{features:a.map((r=>({geometry:r.geometry.toJSON(),attributes:{...r.attributes,[o]:e.graphics.indexOf(r)},symbol:r.symbol?.toJSON(),popupInfo:r.popupTemplate?.toJSON()}))),geometryType:i}});return r}(r);if(i(r)&&e.isCollection(r.source))return function(e){const r=e.write({},{layerContainerType:"operational-layers",origin:"web-map"}),t={featureSet:{features:e.source.map(N).toArray(),geometryType:P(e.geometryType)}};return t.layerDefinition=r.layerDefinition??{},delete r.layerDefinition,t.layerDefinition.geometryType=P(e.geometryType),t.layerDefinition.objectIdField=e.objectIdField,t.layerDefinition.hasZ=!0,t.layerDefinition.elevationInfo=e.elevationInfo?.write(),t.popupInfo=r.popupInfo,delete r.popupInfo,t.layerDefinition.fields=e.fields.map((e=>e.toJSON())),t.layerDefinition.extent=e.fullExtent?.toJSON(),r.featureCollection={layers:[t],showLegend:e.legendEnabled},r}(r);a=r.write({},{layerContainerType:"operational-layers",origin:D(x(r))?"web-scene":"web-map"})}return a}function x(e){let{parent:r}=e;for(;r?.parent;)r=r.parent;return O(r)?r:void 0}function E(e){switch(e){case"esriGeometryPoint":return"Points";case"esriGeometryMultipoint":return"Multipoints";case"esriGeometryPolyline":return"Polylines";case"esriGeometryEnvelope":case"esriGeometryPolygon":return"Polygons";default:return"Unknown Geometry"}}export function getLayerJsonType(e){return t(e)?"CSV":T(e)?"ArcGISStreamLayer":i(e)||y(e)||m(e)||L(e)?"ArcGISFeatureLayer":a(e)?"GeoJSON":n(e)?"GeoRSS":s(e)?"ArcGISImageServiceLayer":p(e)?"ArcGISTiledImageServiceLayer":f(e)?"KML":u(e)?"ArcGISMapServiceLayer":d(e)?"OpenStreetMap":v(e)?"WebTiledLayer":J(e)?"VectorTileLayer":I(e)?"ArcGISTiledImageServiceLayer":b(e)?"ArcGISTiledMapServiceLayer":o(e)?"ArcGISTiledElevationServiceLayer":g(e)?"ArcGISSceneServiceLayer":S(e)?"PointCloudLayer":c(e)?"IntegratedMeshLayer":l(e)?"GroupLayer":A(e)?"WMS":M(e)?"WebTiledLayer":r(e)?"BuildingSceneLayer":G(e)?"SubtypeGroupLayer":void 0}
@@ -1 +1 @@
1
- import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{EntityBase as s}from"../Entity.js";import{InvalidOperationError as a}from"../InvalidOperationError.js";import{isBasemapExtension as n,isBookmark as o,isGroundExtension as r,isLayerPreset as p,isMenu as h,isTableExtension as m,ItemType as l}from"../ItemType.js";import{TableExtension as d}from"../data/TableExtension.js";import{applyJsonToWebMap as c}from"../json/WebMapJson.js";import{applyJsonToWebScene as b}from"../json/WebSceneJson.js";import{LayerPreset as _}from"../layer-preset/LayerPreset.js";import{Menu as u}from"../menus/Menu.js";import{DefaultArcGISRequestHelper as E}from"../support/ArcGISRequestHelper.js";import{FormatSettings as w}from"../support/FormatSettings.js";import{InitializableCollectionProxy as f}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection as x}from"../support/ReadOnlyInitializableCollection.js";import{serializable as y}from"../support/Serializable.js";import{WellKnownBasemap as M}from"../support/esri.js";import{ReadOnlyCollection as g}from"../utilities/ReadOnlyCollection.js";import{basemapsAreEquivalent as I,createStandardBasemap as S,getStandardBasemapId as v,isStandardBasemap as z}from"../utilities/basemaps.js";import{checkArg as O}from"../utilities/checkArg.js";import{compare as A}from"../utilities/collection.js";import{load as P}from"../utilities/esri.js";import{isGroupLayerExtension as C}from"../utilities/extensions.js";import{find as T}from"../utilities/iterable.js";import{layersAreEquivalent as V}from"../utilities/layers.js";import{getLogger as j}from"../utilities/log.js";import{getMapSpatialReference as k,isMap as B,isWebMap as L,isWebScene as N}from"../utilities/mapping.js";import{toPortalItem as R}from"../utilities/portal.js";import{parallelEach as W}from"../utilities/promise.js";import{onCollectionPropertyChange as J,onEach as H}from"../utilities/watch.js";import{BasemapExtension as q}from"./BasemapExtension.js";import{Bookmark as G}from"./Bookmark.js";import{GroundExtension as F}from"./GroundExtension.js";import{MapConstraints as D}from"./MapConstraints.js";import{UnsupportedLayerExtension as U}from"./UnsupportedLayerExtension.js";import{_assignLayerExtensions as $,LayerExtension as X}from"./_LayerExtension.js";import{LayerExtensionCollectionBase as Y}from"./support/_LayerExtensionCollection.js";const K=j("MapExtension");let Q=class extends s{get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?N(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":N(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new E),this._requestHelper}set requestHelper(e){this._requestHelper=e}get basemapExtension(){return this._basemapExtension}set basemapExtension(e){const t=this._basemapExtension;if(t!==e)if(t&&t._setMapExtension(void 0),e){if(e._setMapExtension(this),this.isInitialized&&!e.basemap){if(e.isInitialized)throw e._setMapExtension(void 0),new a("Cannot set MapExtension.basemapExtension without a valid Esri Basemap object");e.initialize()}this._ensureIsBasemapOption(e),this.map&&e.basemap&&e.basemap!==this.map.basemap?this.map.basemap=e.basemap:this._basemapExtension=e}else this.map.basemap=void 0,this._basemapExtension=void 0}get groundExtension(){return this._groundExtension||(this.groundExtension=new F({ground:this.map?.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new a("Cannot set map.ground to undefined");const t=this._groundExtension;t!==e&&(t&&t._setMapExtension(void 0),e._setMapExtension(this),e._resolveGround(),e.ground?(this._groundExtensions.set(e.ground,e),this.map&&e.ground!==this.map.ground?this.map.ground=e.ground:this._groundExtension=e):this._groundExtension=e)}get basemapOptions(){return this._basemapOptions}get bookmarks(){return this._bookmarks}get initialBasemapExtension(){return this._initialBasemapExtension}get initialLayerPreset(){return this._initialLayerPreset}set initialLayerPreset(e){if(!e)return void(this._initialLayerPreset=void 0);const t=p(e)?e:new _(e);this._initialLayerPreset=t}get _spatialReference(){return k(this.map)}get webMapItemTitle(){if(this._webMapItem)return this._webMapItem.title}get webSceneItemTitle(){if(this._webSceneItem)return this._webSceneItem.title}get title(){return this._title?this._title:this._webMapItem&&"map"===this.viewMode?this.webMapItemTitle:this._webSceneItem&&"scene"===this.viewMode?this.webSceneItemTitle:void 0}set title(e){this._title=e}get contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,e&&this.isInitialized&&!e.isInitialized&&(async()=>{try{await e.initialize()}catch(e){e instanceof Error&&K.error({message:"An error occurred while initializing context menu.",error:e})}})()}get _allLayerViews(){const e=i=>{const s=[i];return t.isCollection(i.sublayerViews)?s.push(...i.sublayerViews.toArray().flatMap(e)):t.isCollection(i.layerViews)&&s.push(...i.layerViews.toArray().flatMap(e)),s};return this._layerViews.toArray().flatMap(e)}get layerExtensions(){return this._layerExtensions}constructor(e){super(e),this.isSwitchingMap=!1,this._layerViews=new t,this._itemType=l.MAP_EXTENSION,this._skipBasemapOptions=!1;let s={...e};this._basemapOptions=new ee(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new t,this.constraints=new D,this.watch(["_map","_scene"],(e=>{e&&(H(e.layers,"layerview-create",(e=>{this._layerViews.add(e.layerView)})),H(e.layers,"layerview-destroy",(e=>{this._layerViews.remove(e.layerView)})))}));const{webMap:a,webScene:n,initialViewMode:o,map:r,basemapOptions:p}=s;if(this._webMap=a,this._webScene=n,this._webMapItem=se(a),this._webSceneItem=se(n),this.initialViewMode=o,N(r)&&n)throw new i("Cannot specify webScene property if map is initialized to a WebScene instance.");if(B(r)&&a)throw new i("Cannot specify webMap property if map is initialized to a 2D Map instance.");if(N(r)||L(r)||B(r))this.assignProperties({basemapOptions:p}),this._skipBasemapOptions=!!p;else{const{layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n,...o}=s;this._deferredProperties={layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n},s=o,a&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(s),this.watch("map.basemap",(()=>this._onBasemapChange()),!0),this.watch("map.ground",(()=>this._onGroundChange()),!0),this.allLayerExtensions=new ie(this),this.map?.basemap&&this._onBasemapChange()}getAllFeatureSources(e=(()=>!0)){const t=[],i=a=>{a.hasFeatures&&t.push(a);for(const t of a.sublayerExtensions.initializedItems.filter(e).toArray())s(t);if(C(a))for(const t of a.layerExtensions.initializedItems.filter(e).toArray())i(t)},s=i=>{t.push(i);for(const t of i.sublayerExtensions.initializedItems.filter(e).toArray())s(t)};for(const t of this.layerExtensions.initializedItems.filter(e).toArray())i(t);for(const i of this.tableExtensions.initializedItems.filter(e).toArray())t.push(i);if(this.basemapExtension){for(const t of this.basemapExtension.baseLayerExtensions.initializedItems.filter(e).toArray())i(t);for(const t of this.basemapExtension.referenceLayerExtensions.initializedItems.filter(e).toArray())i(t)}return t}isSupportedViewMode(e){return e===this.viewMode||!(!this.webMap&&!this.webScene)&&("scene"===e?!!this.webScene:!!this.webMap)}async switchViewMode(e){if(O("viewMode",e).isNotMissing().satisfies((e=>this.isSupportedViewMode(e)),"Unsupported view mode."),this.viewMode===e)return;let t;"scene"===e?(await this._createScene(),t=this._scene):(await this._createMap(),t=this._map),t.basemap=this.map.basemap,await this.switchMap(t),this.notifyChange("viewMode"),this.notifyChange("title")}async switchMap(e){if(O("newMap",e).isNotMissing(),e===this.map)return;if(!this.map)return void this._setMap(e);this.isSwitchingMap=!0,this.isInitialized&&await oe(e);const t=new Map;this.map.layers.forEach((e=>t.set(e,this.layerExtensions.forLayer(e))));const{basemapExtension:i}=this;this._setMap(e),this._updateBookmarks();const s=[];for(const e of this.map.layers.toArray()){const i=T(t.entries(),(([t])=>V(t,e)));if(i)s.push((async()=>{const t=i[1];await t._switchLayer(e),this._layerExtensions._register(t)})());else{const t=this._layerExtensions._forLayer(e);t?.layer!==e&&s.push(t._switchLayer(e))}}this.map.basemap&&i&&I(this.map.basemap,i.basemap)&&s.push((async()=>{await i._switchBasemap(this.map.basemap),this.basemapExtension=i})()),this.isInitialized&&s.push(this._initializeChildren()),await Promise.all(s),this.isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new a("Cannot unset both webMap and webScene.");this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=se(e),await P(this._webMapItem),"map"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createMap(),await this.switchMap(this._map),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("scene")),this.notifyChange("webMap"),this.notifyChange("initialViewMode"),this.notifyChange("title")}async setWebScene(e){if(!e&&this.webScene&&!this.webMap)throw new a("Cannot unset both webMap and webScene.");this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=se(e),await P(this._webSceneItem),"scene"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createScene(),await this.switchMap(this._scene),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("map")),this.notifyChange("webScene"),this.notifyChange("initialViewMode"),this.notifyChange("title")}getDefaults(){const e=super.getDefaults();return e.initialViewMode="map",e}async _createScene(){if(!this._scene&&this.webScene)return this._createScenePromise=this._createScenePromise??(async()=>{const e=(await import("@arcgis/core/WebScene")).default;ae(this.webScene)?(this._webSceneItem.type="Web Scene",this._scene=new e({portalItem:this._webSceneItem})):this._scene=e.fromJSON(this.webScene)})()}async _createMap(){if(!this._map&&this.webMap)return this._createMapPromise=this._createMapPromise??(async()=>{const e=(await import("@arcgis/core/WebMap")).default;ae(this.webMap)?(this._webMapItem.type="Web Map",this._map=new e({portalItem:this._webMapItem})):this._map=e.fromJSON(this.webMap)})()}_getSerializableProperties(){return{...super._getSerializableProperties(),layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{if(this.map&&e){const t="map"===this.viewMode,i=(t?this._scene:this._map)?.layers.toArray()??[],s=e.filter((e=>!i.includes(e.layer)&&!i.some((t=>e.layer&&(X._matchesRef(t,e.layer)||V(t,e.layer))))));$(this.layerExtensions,s)}},serialize:e=>{if(this._deferredProperties?.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,i=(t?this._map:this._scene)?.layers.toArray();let s=(t?this._scene:this._map)?.layers.toArray()??[];return s=s.filter((e=>!i.find((t=>V(t,e))))),this.layerExtensions.concat(s.map((e=>this._layerExtensions._forLayer(e)))).filter((t=>!(t instanceof U||"initial"===e)||!t.dynamicallyAddedLayer)).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?A(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(m(e)?e:d.create(e),t)},onMatch:(e,t,i,s)=>{m(t)||e.assignProperties(t),i!==s&&this.tableExtensions.reorder(e,s)},equals:(e,t)=>m(t)?t===e:!!d._matchesRef(e,t.table)||e.id===t.id}):this._deferredProperties={...this._deferredProperties,tableExtensions:e}},serialize:()=>this._deferredProperties?.tableExtensions?this._deferredProperties?.tableExtensions:this.tableExtensions.toArray()},basemapExtension:{serializeModes:["project"],deserialize:e=>{if(this.map)if(e)if(n(e))this.basemapExtension=e;else{if(this.basemapExtension)return this.basemapExtension.assignPropertiesAsync(e);this.basemapExtension=q.create(e)}else this.basemapExtension=void 0;else this._deferredProperties={...this._deferredProperties,basemapExtension:e}},serialize:()=>this._deferredProperties?.basemapExtension?this._deferredProperties?.basemapExtension:this.basemapExtension},basemapOptions:{serializeModes:["initial"],deserialize:e=>{this._skipBasemapOptions?this._skipBasemapOptions=!1:(A(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(n(e)?e:q.create(e),t)},onMatch:(e,t,i,s)=>{n(t)||e.assignProperties(t),i!==s&&this.basemapOptions.reorder(e,s)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(n(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const i=e.toJSON();return I(i.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&W(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())))},serialize:()=>this._deferredProperties?.basemapOptions?this._deferredProperties?.basemapOptions:this.basemapOptions.toArray()},groundExtension:{serializeModes:["initial"],deserialize:e=>{if(this.map){if(!r(e))return this.groundExtension.assignPropertiesAsync(e);this.groundExtension=e}else this._deferredProperties={...this._deferredProperties,groundExtension:e}},serialize:()=>this._deferredProperties?.groundExtension?this._deferredProperties?.groundExtension:this.groundExtension},bookmarks:{serialize:()=>this.bookmarks.map((e=>e.toJSON())).toArray(),deserialize:e=>{this.bookmarks.addMany(e.map((e=>o(e)?e:new G(e))))}},webMap:{serializeModes:["initial"],deserialize:!1},webScene:{serializeModes:["initial"],deserialize:!1},initialLayerPreset:"initial",initialViewMode:{serializeModes:["initial","project"],serialize:e=>"project"===e?this.viewMode:"scene"!==this.initialViewMode||!this.webScene&&this.webMap?"map":"scene",deserialize:e=>{this.viewMode!==e&&(this._deserializedViewMode=e),this._initialViewMode=e},isDefault:(e,t)=>"project"!==t&&"map"===e},formatSettings:"initial",constraints:"initial",title:"initial",onClick:"initial",onHover:"initial",onHoverEnd:"initial",onInitialized:"initial",onViewpointChanged:"initial",contextMenu:{serializeModes:["initial"],deserialize:e=>{e?h(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=u.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>({operationalLayers:this.layerExtensions.toArray().filter((e=>e.layer)).map((e=>e._getProjectWebmapJSON())),tables:this.tableExtensions.toArray().filter((e=>e.table)).map((e=>({id:e.table.id,title:e.table.title})))}),deserialize:e=>{if(!this.map)throw new i("Cannot specify JSON object for the 'map' property. It must be an ArcGIS API Map instance. To specify JSON, use 'webMap' or 'webScene' instead.");if(B(e)||L(e)||N(e)){if(e!==this.map)throw new i("properties.map","Property 'map' is read-only.")}else this._deserializedMapPromise=(async()=>{this._deserializedViewMode&&this.webMap&&this.webScene&&(this._deserializedViewModePromise=this.switchViewMode(this._deserializedViewMode),await this._deserializedViewModePromise,this._deserializedViewMode=void 0,this._deserializedViewModePromise=void 0),await this._applyMapProperties(e,this.map),this._deserializedMapPromise=void 0})()}},requestHelper:{serialize:!1}}}async _applyMapProperties(e,t,i){await W(this.basemapOptions.toArray(),(e=>e._createBackingBasemap()));let s=e;const a=this.basemapOptions.find((e=>I(e.basemap,s.baseMap)));a&&(t.basemap=a.basemap,s={...s,baseMap:{...s.baseMap,title:t.basemap.title}}),N(t)?await b(s,t,i):await c(s,t,i)}_createFormatSettings(){return new w}_createLayerExtensionCollection(){return new Z(this)}_createTableExtensionCollection(){return new te(this)}async _onInitialize(){await super._onInitialize();const{basemapOptions:e,basemapExtension:t,webMap:i,webScene:s,...a}=this._deferredProperties??{};if(this.map||("scene"===this.initialViewMode?(await this._createScene(),this._setMap(this._scene)):(await this._createMap(),this._setMap(this._map))),this._webMapItem||this._webSceneItem?(await Promise.all([oe(this.map),P(this._webMapItem),P(this._webSceneItem)]),ne(this._webMapItem,"webMap","Web Map"),ne(this._webSceneItem,"webScene","Web Scene")):await oe(this.map),t&&(!n(t)&&t.basemap?this.basemapExtension=q.create(t):await this.assignPropertiesAsync({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),e){const t=e.find((e=>n(e)&&I(this.map.basemap,e.toJSON().basemap)));if(t){const e=t.toJSON().basemap?.id??t.basemap?.id,i=t.toJSON().basemap?.title;await t._switchBasemap(this.map.basemap),this.basemapExtension=t,e&&(this.map.basemap.id=e),i&&(this.map.basemap.title=i)}await this.assignPropertiesAsync({basemapOptions:e})}await this.assignPropertiesAsync(a),this._deferredProperties=void 0,this._initialBasemapExtension=this.basemapExtension,this._updateBookmarks();for(const e of this.layerExtensions.toArray())await e._createBackingLayer();await Promise.all(this.tableExtensions.map((e=>e._createBackingTable())).toArray())}async _postInitialize(){await super._postInitialize(),await this._createStandardBasemapOptions(),await W(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new t(this.layerExtensions.filter((e=>!!e.layer)));e.remove=e=>{this.layerExtensions.remove(e)};const i=new t(this.tableExtensions.filter((e=>!!e.table)));if(i.remove=e=>{this.tableExtensions.remove(e)},yield e,yield i,this.basemapExtension){const e=new t;e.add(this.basemapExtension),yield e}const s=new t;s.add(this.groundExtension),yield s}_initMapFromProperties(e){const t=e.map;B(t)||L(t)||N(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!ae(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!ae(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){N(e)?this._scene=e:this._map=e,this._currentMap=e,this.basemapExtension?.basemap&&!e.basemap&&(e.basemap=this.basemapExtension.basemap),this.groundExtension?.ground&&!e.ground&&(e.ground=this.groundExtension.ground),this.notifyChange("map")}_onBasemapChange(){if(this._basemapExtension){if(this.basemapExtension.basemap==this.map.basemap)return;this._basemapExtension._setMapExtension(void 0)}if(this.map.basemap){let e=this.basemapOptions.find((e=>e.basemap===this.map.basemap));e||(e=q.create({basemap:this.map.basemap}),this._basemapOptions.addInternal(e,0)),e.mapExtension!==this&&e._setMapExtension(this),this._basemapExtension=e}else this._basemapExtension=void 0;this.notifyChange("basemapExtension")}_onGroundChange(){if(this._groundExtension){if(this.groundExtension.ground===this.map.ground)return void(this._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,this.groundExtension));this.groundExtension._setMapExtension(void 0)}this._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,new F({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,this.notifyChange("groundExtension")}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e&&e.isWebMercator&&await W([M.SATELLITE,M.HYBRID_VECTOR,M.STREETS_VECTOR,M.TOPO_VECTOR,M.STREETS_NAVIGATION_VECTOR,M.STREETS_NIGHT_VECTOR,M.TERRAIN_VECTOR,M.DARK_GRAY_VECTOR,M.GRAY_VECTOR,M.OCEANS_VECTOR,M.OPEN_STREET_MAP_VECTOR],(async e=>{const t=await S(e);I(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(q.create({basemap:t}),void 0,!1)}))}_ensureIsBasemapOption(e){const t=this.basemapOptions.findIndex((t=>t.basemap===e.basemap));t>=0?this._basemapOptions.getItemAt(t)!==e&&(this._basemapOptions.removeAtInternal(t),this._basemapOptions.addInternal(e,t)):this._basemapOptions.addInternal(e,0)}_updateBookmarks(){this.bookmarks.removeMany(this.bookmarks.filter((e=>"map"===e.source))),L(this.map)&&this.map.bookmarks?.length>0?this.map.bookmarks.forEach((e=>{this.bookmarks.add(new G({source:"map",title:e.name,viewpoint:e.viewpoint}))})):N(this.map)&&this.map.presentation?.slides?.length>0&&this.map.presentation.slides.forEach((e=>{const t={source:"map",title:e.title.text,viewpoint:e.viewpoint},i=new G(t);this.bookmarks.add(i)}))}};Q=e([y],Q);export{Q as MapExtension};class Z extends Y{get _mapExtension(){return this._parent}constructor(e){super(e,"map.layers")}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(l.LAYER_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}}class ee extends f{constructor(e){super(new t),this.isExplicitlyModified=!1,this._mapExtension=e}add(e,t){return super.add(e,t),this.isExplicitlyModified=!0,1===this.length&&this._mapExtension.map&&!this._mapExtension.basemapExtension&&(this._mapExtension.basemapExtension=e),this}addMany(e,t){return super.addMany(e,t),this.isExplicitlyModified=!0,this}addInternal(e,t,i=!0){const s=e=>{const t="-vector";return e?.endsWith(t)?e.substring(0,e.length-7):e};let a;if(e.basemap){const t=s(e.basemap.id);if(a=this.findIndex((e=>s(e.basemap?.id)===t)),z(e.basemap)&&a>=0){if(!i)return;super.removeAt(a)}}super.add(e,t??(a>=0?a:void 0))}removeAt(e){const t=super.removeAt(e);return t&&(this.isExplicitlyModified=!0,t===this._mapExtension.basemapExtension&&(e<this.length?this._mapExtension.basemapExtension=this.getItemAt(e):this.length?this._mapExtension.basemapExtension=this.getItemAt(e-1):this._mapExtension.basemapExtension=void 0)),t}removeAll(){this._mapExtension.basemapExtension=void 0,super.removeAll()}removeAtInternal(e){return super.removeAt(e)}removeAllInternal(){for(;this.length;)this.removeAtInternal(this.length-1)}reorder(e,t){return super.reorder(e,t),this.isExplicitlyModified=!0,e}reorderInternal(e,t){return super.reorder(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.basemap}}class te extends f{get _collection(){return this._tables.map((e=>this._forTable(e))).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){return this._mapExtension.map?.tables??new g(new t)}constructor(e){super(),this._tableExtensionMap=new WeakMap,this._uninitializedTableExtensions=new Set,this._mapExtension=e,J(this._mapExtension,"map.tables",(e=>{const t={added:(e.added||[]).map((e=>this._forTable(e))),moved:(e.moved||[]).map((e=>this._forTable(e))),removed:(e.removed||[]).map((e=>this._forTable(e))),target:this};this.emit("change",t)})),this._mapExtension.watch("map.tables.length",(()=>this.notifyChange("length")))}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(l.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}clone(){const e=new te(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return O("id",e).isNotMissing(),this.find((t=>t.id===e))}findByTableId(e){return O("id",e).isNotMissing(),this.find((t=>t._tableId===e))}forTable(e){if(O("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(O("tableX",e).isNotMissing(),e.mapExtension&&e.mapExtension.tableExtensions.remove(e),e._setMapExtension(this._mapExtension),e.table){const i=this._tableExtensionMap.get(e.table);if(this._tableExtensionMap.set(e.table,e),i&&i!==e&&this._onRemoved(i),this._tables.includes(e.table))if(void 0===t){const t={added:[e],moved:[],removed:i?[i]:[],target:this};this.emit("change",t)}else this._tables.reorder(e.table,t);else this._tables.add(e.table,t)}else{this._uninitializedTableExtensions.add(e);const t={added:[e],moved:[],removed:[],target:this};this.emit("change",t)}return this._onAdded(e),this}removeAt(e){const t=this.getItemAt(e);if(void 0!==t){if(this._uninitializedTableExtensions.has(t)){this._uninitializedTableExtensions.delete(t);const e={added:[],moved:[],removed:[t],target:this};this.emit("change",e)}else this._tables.remove(t.table);return this._onRemoved(t),t}}reorder(e,t){if(e&&this._tables.includes(e.table))return this._tables.reorder(e.table,t),e}sort(e){return this._tables.sort(((t,i)=>e(this._forTable(t),this._forTable(i)))),this}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.table}_onAdded(e){}_onRemoved(e){e._setMapExtension(void 0)}_forTable(e){for(const e of this._uninitializedTableExtensions)e._resolveTable(),e.table&&(this._tableExtensionMap.set(e.table,e),this._uninitializedTableExtensions.delete(e));if(!this._tableExtensionMap.has(e)){const t=d.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class ie extends x{get _collection(){let e=this._mapExtension.layerExtensions.flatten((e=>C(e)?e.layerExtensions:[]));return this._mapExtension.basemapExtension&&(e=e.concat(this._mapExtension.basemapExtension.baseLayerExtensions.toArray()).concat(this._mapExtension.basemapExtension.referenceLayerExtensions.toArray())),e=e.concat(this._mapExtension.groundExtension.layerExtensions.toArray()),e}constructor(e){super(),this._mapExtension=e}findById(e){return O("id",e).isNotMissing(),this.find((t=>t.id===e))}findByLayerId(e){return O("id",e).isNotMissing(),this.find((t=>t._layerId===e))}forLayer(e){return O("layer",e).isNotMissing(),this.findByLayerId(e.id)}emit(e,i){if("change"===e){const s=new t;s.addMany(i.added);const a=s.flatten((e=>C(e)?e.layerExtensions:[])).toArray(),n=new t;n.addMany(i.removed);const o=n.flatten((e=>C(e)?e.layerExtensions:[])).toArray(),r=new t;r.addMany(i.moved);const p=r.flatten((e=>C(e)?e.layerExtensions:[])).toArray();super.emit(e,{added:a,removed:o,moved:p,target:this})}return super.emit(e,i)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function se(e){if("object"!=typeof e||!e||!e.baseMap)return R(e)}function ae(e){return"object"!=typeof e||e&&!e.baseMap}function ne(e,t,i){if(e?.type&&e.type!==i)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}async function oe(e){await P(e),e.basemap&&(await P(e.basemap),e.basemap.id=v(e.basemap)??e.basemap.id)}
1
+ import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{EntityBase as s}from"../Entity.js";import{InvalidOperationError as a}from"../InvalidOperationError.js";import{isBasemapExtension as n,isBookmark as o,isGroundExtension as r,isLayerPreset as p,isMenu as h,isTableExtension as m,ItemType as l}from"../ItemType.js";import{TableExtension as d}from"../data/TableExtension.js";import{layerToParentJsonCache as c}from"../json/LayerJson.js";import{applyJsonToWebMap as b}from"../json/WebMapJson.js";import{applyJsonToWebScene as _}from"../json/WebSceneJson.js";import{LayerPreset as u}from"../layer-preset/LayerPreset.js";import{Menu as E}from"../menus/Menu.js";import{DefaultArcGISRequestHelper as w}from"../support/ArcGISRequestHelper.js";import{FormatSettings as f}from"../support/FormatSettings.js";import{InitializableCollectionProxy as x}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection as y}from"../support/ReadOnlyInitializableCollection.js";import{serializable as M}from"../support/Serializable.js";import{WellKnownBasemap as g}from"../support/esri.js";import{ReadOnlyCollection as I}from"../utilities/ReadOnlyCollection.js";import{basemapsAreEquivalent as S,createStandardBasemap as v,getStandardBasemapId as z,isStandardBasemap as O}from"../utilities/basemaps.js";import{checkArg as A}from"../utilities/checkArg.js";import{compare as P}from"../utilities/collection.js";import{load as C}from"../utilities/esri.js";import{isGroupLayerExtension as T}from"../utilities/extensions.js";import{find as j}from"../utilities/iterable.js";import{layersAreEquivalent as V}from"../utilities/layers.js";import{getLogger as k}from"../utilities/log.js";import{getMapSpatialReference as B,isMap as L,isWebMap as N,isWebScene as R}from"../utilities/mapping.js";import{toPortalItem as W}from"../utilities/portal.js";import{parallelEach as J}from"../utilities/promise.js";import{onCollectionPropertyChange as H,onEach as q}from"../utilities/watch.js";import{BasemapExtension as G}from"./BasemapExtension.js";import{Bookmark as F}from"./Bookmark.js";import{GroundExtension as D}from"./GroundExtension.js";import{MapConstraints as U}from"./MapConstraints.js";import{UnsupportedLayerExtension as $}from"./UnsupportedLayerExtension.js";import{_assignLayerExtensions as X,LayerExtension as Y}from"./_LayerExtension.js";import{LayerExtensionCollectionBase as K}from"./support/_LayerExtensionCollection.js";const Q=k("MapExtension");let Z=class extends s{get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?R(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":R(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new w),this._requestHelper}set requestHelper(e){this._requestHelper=e}get basemapExtension(){return this._basemapExtension}set basemapExtension(e){const t=this._basemapExtension;if(t!==e)if(t&&t._setMapExtension(void 0),e){if(e._setMapExtension(this),this.isInitialized&&!e.basemap){if(e.isInitialized)throw e._setMapExtension(void 0),new a("Cannot set MapExtension.basemapExtension without a valid Esri Basemap object");e.initialize()}this._ensureIsBasemapOption(e),this.map&&e.basemap&&e.basemap!==this.map.basemap?this.map.basemap=e.basemap:this._basemapExtension=e}else this.map.basemap=void 0,this._basemapExtension=void 0}get groundExtension(){return this._groundExtension||(this.groundExtension=new D({ground:this.map?.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new a("Cannot set map.ground to undefined");const t=this._groundExtension;t!==e&&(t&&t._setMapExtension(void 0),e._setMapExtension(this),e._resolveGround(),e.ground?(this._groundExtensions.set(e.ground,e),this.map&&e.ground!==this.map.ground?this.map.ground=e.ground:this._groundExtension=e):this._groundExtension=e)}get basemapOptions(){return this._basemapOptions}get bookmarks(){return this._bookmarks}get initialBasemapExtension(){return this._initialBasemapExtension}get initialLayerPreset(){return this._initialLayerPreset}set initialLayerPreset(e){if(!e)return void(this._initialLayerPreset=void 0);const t=p(e)?e:new u(e);this._initialLayerPreset=t}get _spatialReference(){return B(this.map)}get webMapItemTitle(){if(this._webMapItem)return this._webMapItem.title}get webSceneItemTitle(){if(this._webSceneItem)return this._webSceneItem.title}get title(){return this._title?this._title:this._webMapItem&&"map"===this.viewMode?this.webMapItemTitle:this._webSceneItem&&"scene"===this.viewMode?this.webSceneItemTitle:void 0}set title(e){this._title=e}get contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,e&&this.isInitialized&&!e.isInitialized&&(async()=>{try{await e.initialize()}catch(e){e instanceof Error&&Q.error({message:"An error occurred while initializing context menu.",error:e})}})()}get _allLayerViews(){const e=i=>{const s=[i];return t.isCollection(i.sublayerViews)?s.push(...i.sublayerViews.toArray().flatMap(e)):t.isCollection(i.layerViews)&&s.push(...i.layerViews.toArray().flatMap(e)),s};return this._layerViews.toArray().flatMap(e)}get layerExtensions(){return this._layerExtensions}constructor(e){super(e),this.isSwitchingMap=!1,this._layerViews=new t,this._itemType=l.MAP_EXTENSION,this._skipBasemapOptions=!1;let s={...e};this._basemapOptions=new te(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new t,this.constraints=new U,this.watch(["_map","_scene"],(e=>{e&&(q(e.layers,"layerview-create",(e=>{this._layerViews.add(e.layerView)})),q(e.layers,"layerview-destroy",(e=>{this._layerViews.remove(e.layerView)})))}));const{webMap:a,webScene:n,initialViewMode:o,map:r,basemapOptions:p}=s;if(this._webMap=a,this._webScene=n,this._webMapItem=ae(a),this._webSceneItem=ae(n),this.initialViewMode=o,R(r)&&n)throw new i("Cannot specify webScene property if map is initialized to a WebScene instance.");if(L(r)&&a)throw new i("Cannot specify webMap property if map is initialized to a 2D Map instance.");if(R(r)||N(r)||L(r))this.assignProperties({basemapOptions:p}),this._skipBasemapOptions=!!p;else{const{layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n,...o}=s;this._deferredProperties={layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n},s=o,a&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(s),this.watch("map.basemap",(()=>this._onBasemapChange()),!0),this.watch("map.ground",(()=>this._onGroundChange()),!0),this.allLayerExtensions=new se(this),this.map?.basemap&&this._onBasemapChange()}getAllFeatureSources(e=(()=>!0)){const t=[],i=a=>{a.hasFeatures&&t.push(a);for(const t of a.sublayerExtensions.initializedItems.filter(e).toArray())s(t);if(T(a))for(const t of a.layerExtensions.initializedItems.filter(e).toArray())i(t)},s=i=>{t.push(i);for(const t of i.sublayerExtensions.initializedItems.filter(e).toArray())s(t)};for(const t of this.layerExtensions.initializedItems.filter(e).toArray())i(t);for(const i of this.tableExtensions.initializedItems.filter(e).toArray())t.push(i);if(this.basemapExtension){for(const t of this.basemapExtension.baseLayerExtensions.initializedItems.filter(e).toArray())i(t);for(const t of this.basemapExtension.referenceLayerExtensions.initializedItems.filter(e).toArray())i(t)}return t}isSupportedViewMode(e){return e===this.viewMode||!(!this.webMap&&!this.webScene)&&("scene"===e?!!this.webScene:!!this.webMap)}async switchViewMode(e){if(A("viewMode",e).isNotMissing().satisfies((e=>this.isSupportedViewMode(e)),"Unsupported view mode."),this.viewMode===e)return;let t;"scene"===e?(await this._createScene(),t=this._scene):(await this._createMap(),t=this._map),t.basemap=this.map.basemap,await this.switchMap(t),this.notifyChange("viewMode"),this.notifyChange("title")}async switchMap(e){if(A("newMap",e).isNotMissing(),e===this.map)return;if(!this.map)return void this._setMap(e);this.isSwitchingMap=!0,this.isInitialized&&await re(e);const t=new Map;this.map.layers.forEach((e=>t.set(e,this.layerExtensions.forLayer(e))));const{basemapExtension:i}=this;this._setMap(e),this._updateBookmarks();const s=[];for(const e of this.map.layers.toArray()){const i=j(t.entries(),(([t])=>V(t,e)));if(i)s.push((async()=>{const t=i[1];await t._switchLayer(e),this._layerExtensions._register(t)})());else{const t=this._layerExtensions._forLayer(e);t?.layer!==e&&s.push(t._switchLayer(e))}}this.map.basemap&&i&&S(this.map.basemap,i.basemap)&&s.push((async()=>{await i._switchBasemap(this.map.basemap),this.basemapExtension=i})()),this.isInitialized&&s.push(this._initializeChildren()),await Promise.all(s),this.isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new a("Cannot unset both webMap and webScene.");this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=ae(e),await C(this._webMapItem),"map"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createMap(),await this.switchMap(this._map),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("scene")),this.notifyChange("webMap"),this.notifyChange("initialViewMode"),this.notifyChange("title")}async setWebScene(e){if(!e&&this.webScene&&!this.webMap)throw new a("Cannot unset both webMap and webScene.");this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=ae(e),await C(this._webSceneItem),"scene"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createScene(),await this.switchMap(this._scene),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("map")),this.notifyChange("webScene"),this.notifyChange("initialViewMode"),this.notifyChange("title")}getDefaults(){const e=super.getDefaults();return e.initialViewMode="map",e}async _createScene(){if(!this._scene&&this.webScene)return this._createScenePromise=this._createScenePromise??(async()=>{const e=(await import("@arcgis/core/WebScene")).default;ne(this.webScene)?(this._webSceneItem.type="Web Scene",this._scene=new e({portalItem:this._webSceneItem})):this._scene=e.fromJSON(this.webScene)})()}async _createMap(){if(!this._map&&this.webMap)return this._createMapPromise=this._createMapPromise??(async()=>{const e=(await import("@arcgis/core/WebMap")).default;ne(this.webMap)?(this._webMapItem.type="Web Map",this._map=new e({portalItem:this._webMapItem})):this._map=e.fromJSON(this.webMap)})()}_getSerializableProperties(){return{...super._getSerializableProperties(),layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{if(this.map&&e){const t="map"===this.viewMode,i=(t?this._scene:this._map)?.layers.toArray()??[],s=e.filter((e=>!i.includes(e.layer)&&!i.some((t=>e.layer&&(Y._matchesRef(t,e.layer)||V(t,e.layer))))));X(this.layerExtensions,s)}},serialize:e=>{if(this._deferredProperties?.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,i=(t?this._map:this._scene)?.layers.toArray();let s=(t?this._scene:this._map)?.layers.toArray()??[];return s=s.filter((e=>!i.find((t=>V(t,e))))),this.layerExtensions.concat(s.map((e=>this._layerExtensions._forLayer(e)))).filter((t=>!(t instanceof $||"initial"===e)||!t.dynamicallyAddedLayer)).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?P(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(m(e)?e:d.create(e),t)},onMatch:(e,t,i,s)=>{m(t)||e.assignProperties(t),i!==s&&this.tableExtensions.reorder(e,s)},equals:(e,t)=>m(t)?t===e:!!d._matchesRef(e,t.table)||e.id===t.id}):this._deferredProperties={...this._deferredProperties,tableExtensions:e}},serialize:()=>this._deferredProperties?.tableExtensions?this._deferredProperties?.tableExtensions:this.tableExtensions.toArray()},basemapExtension:{serializeModes:["project"],deserialize:e=>{if(this.map)if(e)if(n(e))this.basemapExtension=e;else{if(this.basemapExtension)return this.basemapExtension.assignPropertiesAsync(e);this.basemapExtension=G.create(e)}else this.basemapExtension=void 0;else this._deferredProperties={...this._deferredProperties,basemapExtension:e}},serialize:()=>this._deferredProperties?.basemapExtension?this._deferredProperties?.basemapExtension:this.basemapExtension},basemapOptions:{serializeModes:["initial"],deserialize:e=>{this._skipBasemapOptions?this._skipBasemapOptions=!1:(P(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(n(e)?e:G.create(e),t)},onMatch:(e,t,i,s)=>{n(t)||e.assignProperties(t),i!==s&&this.basemapOptions.reorder(e,s)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(n(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const i=e.toJSON();return S(i.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())))},serialize:()=>this._deferredProperties?.basemapOptions?this._deferredProperties?.basemapOptions:this.basemapOptions.toArray()},groundExtension:{serializeModes:["initial"],deserialize:e=>{if(this.map){if(!r(e))return this.groundExtension.assignPropertiesAsync(e);this.groundExtension=e}else this._deferredProperties={...this._deferredProperties,groundExtension:e}},serialize:()=>this._deferredProperties?.groundExtension?this._deferredProperties?.groundExtension:this.groundExtension},bookmarks:{serialize:()=>this.bookmarks.map((e=>e.toJSON())).toArray(),deserialize:e=>{this.bookmarks.addMany(e.map((e=>o(e)?e:new F(e))))}},webMap:{serializeModes:["initial"],deserialize:!1},webScene:{serializeModes:["initial"],deserialize:!1},initialLayerPreset:"initial",initialViewMode:{serializeModes:["initial","project"],serialize:e=>"project"===e?this.viewMode:"scene"!==this.initialViewMode||!this.webScene&&this.webMap?"map":"scene",deserialize:e=>{this.viewMode!==e&&(this._deserializedViewMode=e),this._initialViewMode=e},isDefault:(e,t)=>"project"!==t&&"map"===e},formatSettings:"initial",constraints:"initial",title:"initial",onClick:"initial",onHover:"initial",onHoverEnd:"initial",onInitialized:"initial",onViewpointChanged:"initial",contextMenu:{serializeModes:["initial"],deserialize:e=>{e?h(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=E.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>{c.lookup=new WeakMap;const e=this.layerExtensions.toArray().filter((e=>e.layer)).map((e=>e._getProjectWebmapJSON())),t=this.tableExtensions.toArray().filter((e=>e.table)).map((e=>({id:e.table.id,title:e.table.title})));return c.lookup=void 0,{operationalLayers:e,tables:t}},deserialize:e=>{if(!this.map)throw new i("Cannot specify JSON object for the 'map' property. It must be an ArcGIS API Map instance. To specify JSON, use 'webMap' or 'webScene' instead.");if(L(e)||N(e)||R(e)){if(e!==this.map)throw new i("properties.map","Property 'map' is read-only.")}else this._deserializedMapPromise=(async()=>{this._deserializedViewMode&&this.webMap&&this.webScene&&(this._deserializedViewModePromise=this.switchViewMode(this._deserializedViewMode),await this._deserializedViewModePromise,this._deserializedViewMode=void 0,this._deserializedViewModePromise=void 0),await this._applyMapProperties(e,this.map),this._deserializedMapPromise=void 0})()}},requestHelper:{serialize:!1}}}async _applyMapProperties(e,t,i){await J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap()));let s=e;const a=this.basemapOptions.find((e=>S(e.basemap,s.baseMap)));a&&(t.basemap=a.basemap,s={...s,baseMap:{...s.baseMap,title:t.basemap.title}}),R(t)?await _(s,t,i):await b(s,t,i)}_createFormatSettings(){return new f}_createLayerExtensionCollection(){return new ee(this)}_createTableExtensionCollection(){return new ie(this)}async _onInitialize(){await super._onInitialize();const{basemapOptions:e,basemapExtension:t,webMap:i,webScene:s,...a}=this._deferredProperties??{};if(this.map||("scene"===this.initialViewMode?(await this._createScene(),this._setMap(this._scene)):(await this._createMap(),this._setMap(this._map))),this._webMapItem||this._webSceneItem?(await Promise.all([re(this.map),C(this._webMapItem),C(this._webSceneItem)]),oe(this._webMapItem,"webMap","Web Map"),oe(this._webSceneItem,"webScene","Web Scene")):await re(this.map),t&&(!n(t)&&t.basemap?this.basemapExtension=G.create(t):await this.assignPropertiesAsync({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),e){const t=e.find((e=>n(e)&&S(this.map.basemap,e.toJSON().basemap)));if(t){const e=t.toJSON().basemap?.id??t.basemap?.id,i=t.toJSON().basemap?.title;await t._switchBasemap(this.map.basemap),this.basemapExtension=t,e&&(this.map.basemap.id=e),i&&(this.map.basemap.title=i)}await this.assignPropertiesAsync({basemapOptions:e})}await this.assignPropertiesAsync(a),this._deferredProperties=void 0,this._initialBasemapExtension=this.basemapExtension,this._updateBookmarks();for(const e of this.layerExtensions.toArray())await e._createBackingLayer();await Promise.all(this.tableExtensions.map((e=>e._createBackingTable())).toArray())}async _postInitialize(){await super._postInitialize(),await this._createStandardBasemapOptions(),await J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new t(this.layerExtensions.filter((e=>!!e.layer)));e.remove=e=>{this.layerExtensions.remove(e)};const i=new t(this.tableExtensions.filter((e=>!!e.table)));if(i.remove=e=>{this.tableExtensions.remove(e)},yield e,yield i,this.basemapExtension){const e=new t;e.add(this.basemapExtension),yield e}const s=new t;s.add(this.groundExtension),yield s}_initMapFromProperties(e){const t=e.map;L(t)||N(t)||R(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!ne(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!ne(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){R(e)?this._scene=e:this._map=e,this._currentMap=e,this.basemapExtension?.basemap&&!e.basemap&&(e.basemap=this.basemapExtension.basemap),this.groundExtension?.ground&&!e.ground&&(e.ground=this.groundExtension.ground),this.notifyChange("map")}_onBasemapChange(){if(this._basemapExtension){if(this.basemapExtension.basemap==this.map.basemap)return;this._basemapExtension._setMapExtension(void 0)}if(this.map.basemap){let e=this.basemapOptions.find((e=>e.basemap===this.map.basemap));e||(e=G.create({basemap:this.map.basemap}),this._basemapOptions.addInternal(e,0)),e.mapExtension!==this&&e._setMapExtension(this),this._basemapExtension=e}else this._basemapExtension=void 0;this.notifyChange("basemapExtension")}_onGroundChange(){if(this._groundExtension){if(this.groundExtension.ground===this.map.ground)return void(this._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,this.groundExtension));this.groundExtension._setMapExtension(void 0)}this._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,new D({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,this.notifyChange("groundExtension")}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e&&e.isWebMercator&&await J([g.SATELLITE,g.HYBRID_VECTOR,g.STREETS_VECTOR,g.TOPO_VECTOR,g.STREETS_NAVIGATION_VECTOR,g.STREETS_NIGHT_VECTOR,g.TERRAIN_VECTOR,g.DARK_GRAY_VECTOR,g.GRAY_VECTOR,g.OCEANS_VECTOR,g.OPEN_STREET_MAP_VECTOR],(async e=>{const t=await v(e);S(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(G.create({basemap:t}),void 0,!1)}))}_ensureIsBasemapOption(e){const t=this.basemapOptions.findIndex((t=>t.basemap===e.basemap));t>=0?this._basemapOptions.getItemAt(t)!==e&&(this._basemapOptions.removeAtInternal(t),this._basemapOptions.addInternal(e,t)):this._basemapOptions.addInternal(e,0)}_updateBookmarks(){this.bookmarks.removeMany(this.bookmarks.filter((e=>"map"===e.source))),N(this.map)&&this.map.bookmarks?.length>0?this.map.bookmarks.forEach((e=>{this.bookmarks.add(new F({source:"map",title:e.name,viewpoint:e.viewpoint}))})):R(this.map)&&this.map.presentation?.slides?.length>0&&this.map.presentation.slides.forEach((e=>{const t={source:"map",title:e.title.text,viewpoint:e.viewpoint},i=new F(t);this.bookmarks.add(i)}))}};Z=e([M],Z);export{Z as MapExtension};class ee extends K{get _mapExtension(){return this._parent}constructor(e){super(e,"map.layers")}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(l.LAYER_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}}class te extends x{constructor(e){super(new t),this.isExplicitlyModified=!1,this._mapExtension=e}add(e,t){return super.add(e,t),this.isExplicitlyModified=!0,1===this.length&&this._mapExtension.map&&!this._mapExtension.basemapExtension&&(this._mapExtension.basemapExtension=e),this}addMany(e,t){return super.addMany(e,t),this.isExplicitlyModified=!0,this}addInternal(e,t,i=!0){const s=e=>{const t="-vector";return e?.endsWith(t)?e.substring(0,e.length-7):e};let a;if(e.basemap){const t=s(e.basemap.id);if(a=this.findIndex((e=>s(e.basemap?.id)===t)),O(e.basemap)&&a>=0){if(!i)return;super.removeAt(a)}}super.add(e,t??(a>=0?a:void 0))}removeAt(e){const t=super.removeAt(e);return t&&(this.isExplicitlyModified=!0,t===this._mapExtension.basemapExtension&&(e<this.length?this._mapExtension.basemapExtension=this.getItemAt(e):this.length?this._mapExtension.basemapExtension=this.getItemAt(e-1):this._mapExtension.basemapExtension=void 0)),t}removeAll(){this._mapExtension.basemapExtension=void 0,super.removeAll()}removeAtInternal(e){return super.removeAt(e)}removeAllInternal(){for(;this.length;)this.removeAtInternal(this.length-1)}reorder(e,t){return super.reorder(e,t),this.isExplicitlyModified=!0,e}reorderInternal(e,t){return super.reorder(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.basemap}}class ie extends x{get _collection(){return this._tables.map((e=>this._forTable(e))).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){return this._mapExtension.map?.tables??new I(new t)}constructor(e){super(),this._tableExtensionMap=new WeakMap,this._uninitializedTableExtensions=new Set,this._mapExtension=e,H(this._mapExtension,"map.tables",(e=>{const t={added:(e.added||[]).map((e=>this._forTable(e))),moved:(e.moved||[]).map((e=>this._forTable(e))),removed:(e.removed||[]).map((e=>this._forTable(e))),target:this};this.emit("change",t)})),this._mapExtension.watch("map.tables.length",(()=>this.notifyChange("length")))}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(l.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}clone(){const e=new ie(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return A("id",e).isNotMissing(),this.find((t=>t.id===e))}findByTableId(e){return A("id",e).isNotMissing(),this.find((t=>t._tableId===e))}forTable(e){if(A("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(A("tableX",e).isNotMissing(),e.mapExtension&&e.mapExtension.tableExtensions.remove(e),e._setMapExtension(this._mapExtension),e.table){const i=this._tableExtensionMap.get(e.table);if(this._tableExtensionMap.set(e.table,e),i&&i!==e&&this._onRemoved(i),this._tables.includes(e.table))if(void 0===t){const t={added:[e],moved:[],removed:i?[i]:[],target:this};this.emit("change",t)}else this._tables.reorder(e.table,t);else this._tables.add(e.table,t)}else{this._uninitializedTableExtensions.add(e);const t={added:[e],moved:[],removed:[],target:this};this.emit("change",t)}return this._onAdded(e),this}removeAt(e){const t=this.getItemAt(e);if(void 0!==t){if(this._uninitializedTableExtensions.has(t)){this._uninitializedTableExtensions.delete(t);const e={added:[],moved:[],removed:[t],target:this};this.emit("change",e)}else this._tables.remove(t.table);return this._onRemoved(t),t}}reorder(e,t){if(e&&this._tables.includes(e.table))return this._tables.reorder(e.table,t),e}sort(e){return this._tables.sort(((t,i)=>e(this._forTable(t),this._forTable(i)))),this}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.table}_onAdded(e){}_onRemoved(e){e._setMapExtension(void 0)}_forTable(e){for(const e of this._uninitializedTableExtensions)e._resolveTable(),e.table&&(this._tableExtensionMap.set(e.table,e),this._uninitializedTableExtensions.delete(e));if(!this._tableExtensionMap.has(e)){const t=d.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class se extends y{get _collection(){let e=this._mapExtension.layerExtensions.flatten((e=>T(e)?e.layerExtensions:[]));return this._mapExtension.basemapExtension&&(e=e.concat(this._mapExtension.basemapExtension.baseLayerExtensions.toArray()).concat(this._mapExtension.basemapExtension.referenceLayerExtensions.toArray())),e=e.concat(this._mapExtension.groundExtension.layerExtensions.toArray()),e}constructor(e){super(),this._mapExtension=e}findById(e){return A("id",e).isNotMissing(),this.find((t=>t.id===e))}findByLayerId(e){return A("id",e).isNotMissing(),this.find((t=>t._layerId===e))}forLayer(e){return A("layer",e).isNotMissing(),this.findByLayerId(e.id)}emit(e,i){if("change"===e){const s=new t;s.addMany(i.added);const a=s.flatten((e=>T(e)?e.layerExtensions:[])).toArray(),n=new t;n.addMany(i.removed);const o=n.flatten((e=>T(e)?e.layerExtensions:[])).toArray(),r=new t;r.addMany(i.moved);const p=r.flatten((e=>T(e)?e.layerExtensions:[])).toArray();super.emit(e,{added:a,removed:o,moved:p,target:this})}return super.emit(e,i)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function ae(e){if("object"!=typeof e||!e||!e.baseMap)return W(e)}function ne(e){return"object"!=typeof e||e&&!e.baseMap}function oe(e,t,i){if(e?.type&&e.type!==i)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}async function re(e){await C(e),e.basemap&&(await C(e.basemap),e.basemap.id=z(e.basemap)??e.basemap.id)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vertigis/arcgis-extensions",
3
3
  "license": "SEE LICENSE IN LICENSE",
4
- "version": "41.4.4",
4
+ "version": "41.5.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://dev.azure.com/vertigis/Studio/_git/arcgis-extensions-ts"
@@ -1 +1 @@
1
- import{executeQuery as e,executeCount as t,constrainQueryTimeExtentToView as r}from"../../support/_query.js";import{AsyncQueue as s}from"../../utilities/asyncIterable.js";import{isSubtypeSublayerExtension as i}from"../../utilities/extensions.js";import{removeZValues as o}from"../../utilities/geometry.js";import{isSubtypeSublayer as u}from"../../utilities/layers.js";import{IdentifyOptions as n}from"./IdentifyOptions.js";import{IdentifyProviderBase as l}from"./IdentifyProviderBase.js";export class SubtypeSublayerQueryIdentifyProvider extends l{isSupported(e,t,r){return i(e)&&u(e.sublayer)&&!!e.sublayer.layer}_identify(t,r,s){const i=t,{layer:o}=i.sublayer,u=this._createIdentifyQuery(o,r,s,s.outFields??t.featureSettings.outFields);return u.where=`${o.subtypeField}=${i.sublayer.subtypeCode}`,e(u,i,o,s.cancelToken)}_identifyMany(t,i,o){if(1===t.length){const e={...n.DEFAULTS,...n.fromFeatureSource(t[0]),...o};return this._identify(t[0],i,e)}const u=new s,l=t.length;let a=0;const y=t.reduce(((e,t)=>{const r=t,s={...n.DEFAULTS,...n.fromFeatureSource(r),...o},i=s.outFields??r.featureSettings.outFields;if(e.has(r.sublayer.layer)){const t=e.get(r.sublayer.layer);let o=!1;for(const{sources:e,identifyOptions:n,outFields:a}of t)if(l=s,(u=n).returnGeometry===l.returnGeometry&&(u.outSpatialReference===l.outSpatialReference||u.outSpatialReference?.equals(l.outSpatialReference))&&u.maxAllowableOffset===l.maxAllowableOffset&&u.maxResults===l.maxResults&&i.length===a.length&&i.every((e=>a.includes(e)))){e.push(r),o=!0;break}o||t.push({sources:[r],identifyOptions:s,outFields:i})}else e.set(r.sublayer.layer,[{sources:[r],identifyOptions:s,outFields:i}]);var u,l;return e}),new Map);for(const[t,s]of y)for(const{sources:o,identifyOptions:n,outFields:y}of s)(async()=>{if(u.isDone)return;const s=new Map,c=[];for(const e of o)s.set(e.sublayer.subtypeCode,e),c.push(e.sublayer.subtypeCode);const f=this._createIdentifyQuery(t,i,n,y);let d=!1;f.outFields.includes(t.subtypeField)||(d=!0,f.outFields=[...f.outFields,t.subtypeField]),f.where=`${t.subtypeField} IN (${c.join(",")})`,r(f,o[0]);try{for await(const r of e(f,(e=>{if(null!=e.attributes)return s.get(e.attributes[t.subtypeField])}),t,n.cancelToken)){if(u.isDone)return;d&&r.attributes.delete(t.subtypeField),u.add(r)}}catch(e){u.reject(e)}finally{a+=o.length,a===l&&u.done()}})();return u}_count(e,r,s){const i=e,{layer:o}=i.sublayer,u=this._createBasicQuery(o,r,s,s.outFields??e.featureSettings.outFields);return u.num=s.maxResults,u.where=`${o.subtypeField}=${i.sublayer.subtypeCode}`,t(u,i,o,s.cancelToken)}_createIdentifyQuery(e,t,r,s){const i=this._createBasicQuery(e,t,r,s);return i.outSpatialReference=r.outSpatialReference,i.maxAllowableOffset=r.maxAllowableOffset,e.capabilities.query.supportsPagination&&(i.num=r.maxResults),i}_createBasicQuery(e,t,r,s){const i=e.createQuery();return i.geometry=t,i.geometry&&(e.hasZ||e.capabilities?.data?.supportsZ)&&(i.geometry=o(t.clone())),i.outFields=s,i.returnGeometry=r.returnGeometry,i}}
1
+ import{executeQuery as e,executeCount as t,constrainQueryTimeExtentToView as s}from"../../support/_query.js";import{AsyncQueue as r}from"../../utilities/asyncIterable.js";import{isSubtypeSublayerExtension as i}from"../../utilities/extensions.js";import{removeZValues as o}from"../../utilities/geometry.js";import{isSubtypeSublayer as u}from"../../utilities/layers.js";import{caseInsensitiveEquals as n}from"../../utilities/string.js";import{IdentifyOptions as l}from"./IdentifyOptions.js";import{IdentifyProviderBase as a}from"./IdentifyProviderBase.js";export class SubtypeSublayerQueryIdentifyProvider extends a{isSupported(e,t,s){return i(e)&&u(e.sublayer)&&!!e.sublayer.layer}_identify(t,s,r){const i=t,{layer:o}=i.sublayer,u=this._createIdentifyQuery(o,s,r,r.outFields??t.featureSettings.outFields);return u.where=`${o.subtypeField}=${i.sublayer.subtypeCode}`,e(u,i,o,r.cancelToken)}_identifyMany(t,i,o){if(1===t.length){const e={...l.DEFAULTS,...l.fromFeatureSource(t[0]),...o};return this._identify(t[0],i,e)}const u=new r,a=t.length;let y=0;const c=t.reduce(((e,t)=>{const s=t,r={...l.DEFAULTS,...l.fromFeatureSource(s),...o},i=r.outFields??s.featureSettings.outFields;if(e.has(s.sublayer.layer)){const t=e.get(s.sublayer.layer);let o=!1;for(const{sources:e,identifyOptions:l,outFields:a}of t)if(n=r,(u=l).returnGeometry===n.returnGeometry&&(u.outSpatialReference===n.outSpatialReference||u.outSpatialReference?.equals(n.outSpatialReference))&&u.maxAllowableOffset===n.maxAllowableOffset&&u.maxResults===n.maxResults&&i.length===a.length&&i.every((e=>a.includes(e)))){e.push(s),o=!0;break}o||t.push({sources:[s],identifyOptions:r,outFields:i})}else e.set(s.sublayer.layer,[{sources:[s],identifyOptions:r,outFields:i}]);var u,n;return e}),new Map);for(const[t,r]of c)for(const{sources:o,identifyOptions:l,outFields:c}of r)(async()=>{if(u.isDone)return;const r=new Map,f=[];for(const e of o)r.set(e.sublayer.subtypeCode,e),f.push(e.sublayer.subtypeCode);const d=this._createIdentifyQuery(t,i,l,c);let p=!1;d.outFields.includes(t.subtypeField)||(p=!0,d.outFields=[...d.outFields,t.subtypeField]),d.where=`${t.subtypeField} IN (${f.join(",")})`,s(d,o[0]);try{for await(const s of e(d,(e=>{if(null!=e.attributes){const s=e.attributes;let i=s[t.subtypeField];if(void 0===i){i=s[Object.keys(s).find((e=>n(e,t.subtypeField)))]}return r.get(i)}}),t,l.cancelToken)){if(u.isDone)return;p&&s.attributes.delete(t.subtypeField),u.add(s)}}catch(e){u.reject(e)}finally{y+=o.length,y===a&&u.done()}})();return u}_count(e,s,r){const i=e,{layer:o}=i.sublayer,u=this._createBasicQuery(o,s,r,r.outFields??e.featureSettings.outFields);return u.num=r.maxResults,u.where=`${o.subtypeField}=${i.sublayer.subtypeCode}`,t(u,i,o,r.cancelToken)}_createIdentifyQuery(e,t,s,r){const i=this._createBasicQuery(e,t,s,r);return i.outSpatialReference=s.outSpatialReference,i.maxAllowableOffset=s.maxAllowableOffset,e.capabilities.query.supportsPagination&&(i.num=s.maxResults),i}_createBasicQuery(e,t,s,r){const i=e.createQuery();return i.geometry=t,i.geometry&&(e.hasZ||e.capabilities?.data?.supportsZ)&&(i.geometry=o(t.clone())),i.outFields=r,i.returnGeometry=s.returnGeometry,i}}
package/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * The current version of the Geocortex ArcGIS Extensions API.
3
3
  */
4
- export declare const version = "41.4.4";
4
+ export declare const version = "41.5.0";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const version="41.4.4";
1
+ export const version="41.5.0";