@geoscene/core 4.23.11 → 4.23.12

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.
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.23/geoscene/copyright.txt for details.
4
4
  */
5
- import{getAssetUrl as e}from"../assets.js";import{fetchMessageBundle as r}from"../intl/messages.js";async function a(e){if(!e)return;const a=e.indexOf("-vector")>-1?e.slice(0,e.indexOf("-vector")):e,s=await r("geoscene/t9n/basemaps");return s[e]||s[a]}const s ={"geoq-community":{get thumbnailUrl(){return e("geoscene/images/basemap/community.jpg")},id:"geoq-community",classic:true,title:"彩色版基础底图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"彩色版基础底图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer"}]},"geoq-gray":{get thumbnailUrl(){return e("geoscene/images/basemap/gray.jpg")},id:"geoq-gray",classic:true,title:"灰色不含兴趣点版中国基础地图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"灰色不含兴趣点版中国基础地图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer"}]},"geoq-blue":{get thumbnailUrl(){return e("geoscene/images/basemap/blue.jpg")},id:"geoq-blue",classic:true,title:"蓝黑色不含兴趣点版中国基础地图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"蓝黑色不含兴趣点版中国基础地图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer"}]},"geoq-warm":{get thumbnailUrl(){return e("geoscene/images/basemap/warm.jpg")},id:"geoq-warm",classic:true,title:"暖色不含兴趣点版中国基础地图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"暖色不含兴趣点版中国基础地图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer"}]},"tianditu-topography":{classic:true,title:"天地图-地形地图(球面墨卡托投影)",baseMapLayers:[{"templateUrl":"https://{subDomain}.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=ter&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_6884","title":"天地图-地形地图(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"},{"templateUrl":"https://{subDomain}.tianditu.gov.cn/cta_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cta&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_4525","title":"天地图-地形注记(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"}]},"tianditu-image":{classic:true,title:"天地图-影像地图(球面墨卡托投影)",baseMapLayers:[{"templateUrl":"https://{subDomain}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=img&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_3572","title":"天地图-影像地图(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"},{"templateUrl":"https://{subDomain}.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cia&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_5882","title":"天地图-影像注记(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"}]},"tianditu-vector":{classic:true,title:"天地图-矢量(含注记)(球面墨卡托投影)",baseMapLayers:[{"templateUrl":"https://{subDomain}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=vec&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_8803","title":"天地图-矢量地图(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"},{"templateUrl":"https://{subDomain}.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cva&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_2198","title":"天地图-矢量注记(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"}]}};export{s as esriBasemapDefinitions,a as getBasemapTitle};
5
+ import{getAssetUrl as e}from"../assets.js";import{fetchMessageBundle as r}from"../intl/messages.js";async function a(e){if(!e)return;const a=e.indexOf("-vector")>-1?e.slice(0,e.indexOf("-vector")):e,s=await r("geoscene/t9n/basemaps");return s[e]||s[a]}const s ={"geoscene-community":{get thumbnailUrl(){return e("geoscene/images/basemap/community.jpg")},id:"geoscene-community",classic:true,title:"彩色版基础底图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"彩色版基础底图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer"}]},"geoscene-gray":{get thumbnailUrl(){return e("geoscene/images/basemap/gray.jpg")},id:"geoscene-gray",classic:true,title:"灰色不含兴趣点版中国基础地图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"灰色不含兴趣点版中国基础地图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer"}]},"geoscene-blue":{get thumbnailUrl(){return e("geoscene/images/basemap/blue.jpg")},id:"geoscene-blue",classic:true,title:"蓝黑色不含兴趣点版中国基础地图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"蓝黑色不含兴趣点版中国基础地图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer"}]},"geoscene-warm":{get thumbnailUrl(){return e("geoscene/images/basemap/warm.jpg")},id:"geoscene-warm",classic:true,title:"暖色不含兴趣点版中国基础地图",baseMapLayers:[{layerType:"ArcGISTiledMapServiceLayer",showLegend:!1,title:"暖色不含兴趣点版中国基础地图",url:"//map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer"}]},"tianditu-topography":{classic:true,title:"天地图-地形地图(球面墨卡托投影)",baseMapLayers:[{"templateUrl":"https://{subDomain}.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=ter&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_6884","title":"天地图-地形地图(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"},{"templateUrl":"https://{subDomain}.tianditu.gov.cn/cta_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cta&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_4525","title":"天地图-地形注记(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"}]},"tianditu-image":{classic:true,title:"天地图-影像地图(球面墨卡托投影)",baseMapLayers:[{"templateUrl":"https://{subDomain}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=img&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_3572","title":"天地图-影像地图(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"},{"templateUrl":"https://{subDomain}.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cia&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_5882","title":"天地图-影像注记(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"}]},"tianditu-vector":{classic:true,title:"天地图-矢量(含注记)(球面墨卡托投影)",baseMapLayers:[{"templateUrl":"https://{subDomain}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=vec&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_8803","title":"天地图-矢量地图(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"},{"templateUrl":"https://{subDomain}.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cva&STYLE=default&FORMAT=tiles&TILEMATRIXSET=w&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb","copyright":"天地图","fullExtent":{"xmin":-20037508.342787,"ymin":-20037508.34278,"xmax":20037508.34278,"ymax":20037508.342787,"spatialReference":{"wkid":102100}},"subDomains":["t0","t1","t2","t3","t4","t5","t6","t7"],"opacity":1,"visibility":true,"id":"WebTiled_2198","title":"天地图-矢量注记(球面墨卡托投影)","type":"WebTiledLayer","layerType":"WebTiledLayer"}]}};export{s as esriBasemapDefinitions,a as getBasemapTitle};
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.23/geoscene/copyright.txt for details.
4
4
  */
5
- import e from"../Ground.js";import r from"../core/Logger.js";import{ensureType as o}from"../core/accessorSupport/ensureType.js";const i=r.getLogger("geoscene.support.groundUtils"),t={"world-elevation":{id:"worldElevation",url:"//elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer",layerType:"ArcGISTiledElevationServiceLayer"},"world-topobathymetry":{id:"worldTopoBathymetry",url:"//elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/TopoBathy3D/ImageServer",layerType:"ArcGISTiledElevationServiceLayer"}};function a(r){let a=null;if("string"==typeof r)if(r in t){const o=t[r];a=new e({resourceInfo:{data:{layers:[o]}}})}else i.warn(`Unable to find ground definition for: ${r}. Try "world-elevation"`);else a=o(e,r);return a}export{a as ensureType,t as groundElevationLayers};
5
+ import e from"../Ground.js";import r from"../core/Logger.js";import{ensureType as o}from"../core/accessorSupport/ensureType.js";const i=r.getLogger("geoscene.support.groundUtils"),t={"world-elevation":{id:"worldElevation",url:"//links.geoscene.cn/geoscene/rest/services/elevation3d/WorldElevation3D/Terrain3D/ImageServer",layerType:"ArcGISTiledElevationServiceLayer"},"world-topobathymetry":{id:"worldTopoBathymetry",url:"//links.geoscene.cn/geoscene/rest/services/WorldElevation3D/TopoBathy3D/ImageServer",layerType:"ArcGISTiledElevationServiceLayer"}};function a(r){let a=null;if("string"==typeof r)if(r in t){const o=t[r];a=new e({resourceInfo:{data:{layers:[o]}}})}else i.warn(`Unable to find ground definition for: ${r}. Try "world-elevation"`);else a=o(e,r);return a}export{a as ensureType,t as groundElevationLayers};
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.23/geoscene/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import t from"../../core/Error.js";import{throwIfAbortError as r}from"../../core/promiseUtils.js";import{normalize as o,removeFile as s}from"../../core/urlUtils.js";import n from"../../portal/Portal.js";import l from"../../portal/PortalQueryParams.js";import{enableWebStyleForceWOSR as a}from"../../support/featureFlags.js";const f={};async function u(e,t){try{return{data:(await b(e,t)).data,baseUrl:s(e),styleUrl:e}}catch(o){return r(o),null}}function i(e,t,r){const o=t&&t.portal||n.getDefault();let s;const l=`${o.url} - ${o.user&&o.user.username} - ${e}`;return f[l]||(f[l]=y(e,o,r).then((e=>(s=e,e.fetchData()))).then((t=>({data:t,baseUrl:s.itemUrl,styleName:e})))),f[l]}function y(e,r,o){return r.load(o).then((()=>{const t=new l({disableExtraQuery:!0,query:`owner:${w} AND type:${h} AND typekeywords:"${e}"`});return r.queryItems(t,o)})).then((({results:r})=>{let s=null;const n=e.toLowerCase();if(r&&Array.isArray(r))for(const e of r){if(e.typeKeywords.some((e=>e.toLowerCase()===n))&&e.type===h&&e.owner===w){s=e;break}}if(!s)throw new t("symbolstyleutils:style-not-found",`The style '${e}' could not be found`,{styleName:e});return s.load(o)}))}function m(e,r,o){return e.styleUrl?u(e.styleUrl,o):e.styleName?i(e.styleName,r,o):Promise.reject(new t("symbolstyleutils:style-url-and-name-missing","Either styleUrl or styleName is required to resolve a style"))}function c(e){return null===e||"CIMSymbolReference"===e.type?e:{type:"CIMSymbolReference",symbol:e}}function p(e,t){if("cimRef"===t)return e.cimRef;if(e.formatInfos&&!a())for(const r of e.formatInfos)if("gltf"===r.type)return r.href;return e.webRef}function d(e){for(const t of e.typeKeywords)if(/^Esri.*Style$/.test(t)&&"Esri Style"!==t)return t}function b(t,r){const s={responseType:"json",query:{f:"json"},...r};return e(o(t),s)}const w="esri_en",h="Style",j="https://cdn.arcgis.com/sharing/rest/content/items/220936cc6ed342c9937abd8f180e7d1e/resources/styles/cim/{SymbolName}.json?f=json";export{j as Style2DUrlTemplate,m as fetchStyle,c as makeCIMSymbolRef,b as requestJSON,d as styleNameFromItem,p as symbolUrlFromStyleItem};
5
+ import e from"../../request.js";import t from"../../core/Error.js";import{throwIfAbortError as r}from"../../core/promiseUtils.js";import{normalize as o,removeFile as s}from"../../core/urlUtils.js";import n from"../../portal/Portal.js";import l from"../../portal/PortalQueryParams.js";import{enableWebStyleForceWOSR as a}from"../../support/featureFlags.js";const f={};async function u(e,t){try{return{data:(await b(e,t)).data,baseUrl:s(e),styleUrl:e}}catch(o){return r(o),null}}function i(e,t,r){const o=t&&t.portal||n.getDefault();let s;const l=`${o.url} - ${o.user&&o.user.username} - ${e}`;return f[l]||(f[l]=y(e,o,r).then((e=>(s=e,e.fetchData()))).then((t=>({data:t,baseUrl:s.itemUrl,styleName:e})))),f[l]}function y(e,r,o){return r.load(o).then((()=>{const t=new l({disableExtraQuery:!0,query:`owner:${w} AND type:${h} AND typekeywords:"${e}"`});return r.queryItems(t,o)})).then((({results:r})=>{let s=null;const n=e.toLowerCase();if(r&&Array.isArray(r))for(const e of r){if(e.typeKeywords.some((e=>e.toLowerCase()===n))&&e.type===h&&e.owner===w){s=e;break}}if(!s)throw new t("symbolstyleutils:style-not-found",`The style '${e}' could not be found`,{styleName:e});return s.load(o)}))}function m(e,r,o){return e.styleUrl?u(e.styleUrl,o):e.styleName?i(e.styleName,r,o):Promise.reject(new t("symbolstyleutils:style-url-and-name-missing","Either styleUrl or styleName is required to resolve a style"))}function c(e){return null===e||"CIMSymbolReference"===e.type?e:{type:"CIMSymbolReference",symbol:e}}function p(e,t){if("cimRef"===t)return e.cimRef;if(e.formatInfos&&!a())for(const r of e.formatInfos)if("gltf"===r.type)return r.href;return e.webRef}function d(e){for(const t of e.typeKeywords)if(/^Esri.*Style$/.test(t)&&"Esri Style"!==t)return t}function b(t,r){const s={responseType:"json",query:{f:"json"},...r};return e(o(t),s)}const w="esri_en",h="Style",j="https://links.geoscene.cn/geoscene/sharing/rest/content/items/220936cc6ed342c9937abd8f180e7d1e/resources/styles/cim/{SymbolName}.json?f=json";export{j as Style2DUrlTemplate,m as fetchStyle,c as makeCIMSymbolRef,b as requestJSON,d as styleNameFromItem,p as symbolUrlFromStyleItem};
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.23/geoscene/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{typeCast as t}from"../../core/compilerUtils.js";import a from"../../core/Evented.js";import{isSome as s}from"../../core/maybe.js";import{watch as i,whenOnce as r,initial as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as c,canProjectWithoutEngine as m,load as h}from"../../geometry/projection.js";import{equals as u}from"../../geometry/support/spatialReferenceUtils.js";import{esriBasemapDefinitions as f}from"../../support/basemapDefinitions.js";import{ensureType as d,destroyCache as g,findSpatialReference as v,getWellKnownBasemapId as B}from"../../support/basemapUtils.js";let b=class extends a.EventedAccessor{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=d("hybrid",this._basemapCache),this.view=null,this.toggle=this.toggle.bind(this)}initialize(){i((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),o)}destroy(){this.view=null,g(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return v(this.view,this.nextBasemap)}get activeBasemap(){var e,t,a;return d(null!=(e=null==(t=this.view)||null==(a=t.map)?void 0:a.basemap)?e:"topo",this._basemapCache)}castNextBasemap(e){return d(e,this._basemapCache)}get state(){var e;return null!=(e=this.view)&&e.ready?this._loadingProjectionEngine?"loading":"ready":"disabled"}async toggle(){if("disabled"===this.state)return;const{activeBasemap:e,nextBasemap:t}=this,a=!("spatialReferenceLocked"in this.view)||this.view.spatialReferenceLocked;if(!a){if(await r((()=>!this._nextBasemapSpatialReferenceTask.updating)),t!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;if(!s(a)||u(this.view.spatialReference,a)||c()||m(this.view.spatialReference,a)||(this._loadingProjectionEngine=!0,await h(),this._loadingProjectionEngine=!1),t!==this.nextBasemap||e!==this.activeBasemap)return}this.view.map.basemap=t,a||!s(this._nextBasemapSpatialReferenceTask.spatialReference)||u(this.view.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(this.view.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e,this.emit("toggle",{previous:e,current:t})}static getThumbnailUrl(e){if(!e)return null;const{thumbnailUrl:a}=e;if(a)return a;const s=B(e);if(s)return f[s].thumbnailUrl;const i=e.baseLayers.find((e=>!!t(e)().get("portalItem.thumbnailUrl")));return i?t(i)().get("portalItem.thumbnailUrl"):null}};e([n()],b.prototype,"_loadingProjectionEngine",void 0),e([n({readOnly:!0})],b.prototype,"_nextBasemapSpatialReferenceTask",null),e([n({readOnly:!0})],b.prototype,"activeBasemap",null),e([n()],b.prototype,"nextBasemap",void 0),e([p("nextBasemap")],b.prototype,"castNextBasemap",null),e([n({readOnly:!0})],b.prototype,"state",null),e([n()],b.prototype,"view",void 0),e([n()],b.prototype,"toggle",null),b=e([l("geoscene.widgets.BasemapToggle.BasemapToggleViewModel")],b);const y=b;export{y as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{typeCast as t}from"../../core/compilerUtils.js";import a from"../../core/Evented.js";import{isSome as s}from"../../core/maybe.js";import{watch as i,whenOnce as r,initial as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as c,canProjectWithoutEngine as m,load as h}from"../../geometry/projection.js";import{equals as u}from"../../geometry/support/spatialReferenceUtils.js";import{esriBasemapDefinitions as f}from"../../support/basemapDefinitions.js";import{ensureType as d,destroyCache as g,findSpatialReference as v,getWellKnownBasemapId as B}from"../../support/basemapUtils.js";let b=class extends a.EventedAccessor{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=d("tianditu-topography",this._basemapCache),this.view=null,this.toggle=this.toggle.bind(this)}initialize(){i((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),o)}destroy(){this.view=null,g(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return v(this.view,this.nextBasemap)}get activeBasemap(){var e,t,a;return d(null!=(e=null==(t=this.view)||null==(a=t.map)?void 0:a.basemap)?e:"topo",this._basemapCache)}castNextBasemap(e){return d(e,this._basemapCache)}get state(){var e;return null!=(e=this.view)&&e.ready?this._loadingProjectionEngine?"loading":"ready":"disabled"}async toggle(){if("disabled"===this.state)return;const{activeBasemap:e,nextBasemap:t}=this,a=!("spatialReferenceLocked"in this.view)||this.view.spatialReferenceLocked;if(!a){if(await r((()=>!this._nextBasemapSpatialReferenceTask.updating)),t!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;if(!s(a)||u(this.view.spatialReference,a)||c()||m(this.view.spatialReference,a)||(this._loadingProjectionEngine=!0,await h(),this._loadingProjectionEngine=!1),t!==this.nextBasemap||e!==this.activeBasemap)return}this.view.map.basemap=t,a||!s(this._nextBasemapSpatialReferenceTask.spatialReference)||u(this.view.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(this.view.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e,this.emit("toggle",{previous:e,current:t})}static getThumbnailUrl(e){if(!e)return null;const{thumbnailUrl:a}=e;if(a)return a;const s=B(e);if(s)return f[s].thumbnailUrl;const i=e.baseLayers.find((e=>!!t(e)().get("portalItem.thumbnailUrl")));return i?t(i)().get("portalItem.thumbnailUrl"):null}};e([n()],b.prototype,"_loadingProjectionEngine",void 0),e([n({readOnly:!0})],b.prototype,"_nextBasemapSpatialReferenceTask",null),e([n({readOnly:!0})],b.prototype,"activeBasemap",null),e([n()],b.prototype,"nextBasemap",void 0),e([p("nextBasemap")],b.prototype,"castNextBasemap",null),e([n({readOnly:!0})],b.prototype,"state",null),e([n()],b.prototype,"view",void 0),e([n()],b.prototype,"toggle",null),b=e([l("geoscene.widgets.BasemapToggle.BasemapToggleViewModel")],b);const y=b;export{y as default};