@arcgis/core 5.0.0-next.97 → 5.0.0-next.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/WebDocument2D.js +1 -1
  2. package/WebLinkChart.js +1 -1
  3. package/WebMap.d.ts +1 -1
  4. package/WebMap.js +1 -1
  5. package/WebScene.d.ts +1 -1
  6. package/WebScene.js +1 -1
  7. package/applications/Components/templateUtils.d.ts +9 -10
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/02fdf18dadaadf7ff850.js +1 -0
  10. package/assets/esri/core/workers/chunks/{2e5c8a9ffa218407a8aa.js → 09591ec97bcd4a08330f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{f678dbd8cb88fbacd2ce.js → 207fe77857f4cdbe835f.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2b5cd0b528be50b89b21.js +1 -0
  13. package/assets/esri/core/workers/chunks/{09f663089e6d976dce51.js → 2c7ba74a712c26ae42e6.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{5b8106f0039fbe3d55b7.js → 35df48b6f8a4d3616a84.js} +1 -1
  15. package/assets/esri/core/workers/chunks/36b1eb4ec5e651a91ff6.js +1 -0
  16. package/assets/esri/core/workers/chunks/{8d2331e33ce4f9f393f9.js → 382fe05c3bf27b4ed188.js} +1 -1
  17. package/assets/esri/core/workers/chunks/498ac1f2bc3ec2c82d6e.js +1 -0
  18. package/assets/esri/core/workers/chunks/{f7e0d0a2eea4353fdb98.js → 4eeae4a542ebd2052962.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{f95fcad21a7b5298e953.js → 7e7664a16ffe7d93792d.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{bb7281938dcb0a63c78b.js → 89d8d5030f68d741f8dd.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{166efcc022973394498f.js → 9cadb336d89e4b1a2d76.js} +1 -1
  22. package/assets/esri/core/workers/chunks/a77eb93abfdfc63db51a.js +1 -0
  23. package/assets/esri/core/workers/chunks/ae0c959fe7c004a4a828.js +1 -0
  24. package/assets/esri/core/workers/chunks/b9b1825a8ef2af9877dc.js +1 -0
  25. package/assets/esri/core/workers/chunks/c480624ff7890a5233e8.js +1 -0
  26. package/assets/esri/core/workers/chunks/f770ffd2506dad1ca1c8.js +1 -0
  27. package/assets/esri/core/workers/chunks/{f720a5123489cf2b4bbe.js → f9b75cefb22beacdc96e.js} +1 -1
  28. package/assets/esri/themes/base/widgets/_Daylight.scss +6 -0
  29. package/assets/esri/themes/dark/main.css +1 -1
  30. package/assets/esri/themes/light/main.css +1 -1
  31. package/assets/esri/themes/light/view.css +1 -1
  32. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  33. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  34. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  35. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  36. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  37. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  38. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  39. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  40. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  41. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  42. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  43. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  44. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  45. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  46. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  47. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  48. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  49. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  50. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  51. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  52. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  53. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  54. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  55. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  56. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  57. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  58. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  59. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  60. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  61. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  62. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  63. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  64. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  65. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  66. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  67. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  68. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  69. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  70. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  71. package/config.js +1 -1
  72. package/core/Version.js +1 -1
  73. package/editing/sharedTemplates/SharedTemplateMetadata.d.ts +13 -4
  74. package/geometry/operators/support/Transformation.d.ts +2 -1
  75. package/interfaces.d.ts +6 -9
  76. package/kernel.js +1 -1
  77. package/package.json +1 -1
  78. package/support/revision.js +1 -1
  79. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  80. package/views/3d/environment/{SceneViewEnvironment.d.ts → Environment.d.ts} +5 -5
  81. package/views/3d/environment/{SceneViewEnvironment.js → Environment.js} +1 -1
  82. package/views/SceneView.d.ts +5 -5
  83. package/views/SceneView.js +1 -1
  84. package/webmap/utils.js +1 -1
  85. package/webscene/InitialViewProperties.d.ts +2 -2
  86. package/webscene/support/versionUtils.js +2 -0
  87. package/widgets/Editor/CreateFeaturesWorkflowData.d.ts +3 -2
  88. package/widgets/Editor/EditorViewModel.d.ts +3 -2
  89. package/widgets/Editor/types.d.ts +3 -2
  90. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.d.ts +3 -2
  91. package/widgets/FeatureTemplates/TemplateItem.d.ts +3 -2
  92. package/widgets/FeatureTemplates/types.d.ts +3 -2
  93. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  94. package/widgets/OrientedImageryViewer/adapters/draw/HeightMeasurementAdapter.js +2 -0
  95. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  96. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  97. package/widgets/OrientedImageryViewer/components/ImageLocationViewModel.js +2 -0
  98. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  99. package/widgets/OrientedImageryViewer/mixins/DrawHandlerMixin.js +2 -0
  100. package/widgets/OrientedImageryViewer/mixins/SketchHandlerMixin.js +1 -1
  101. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  102. package/widgets/OrientedImageryViewer/types.js +2 -0
  103. package/assets/esri/core/workers/chunks/084bdd0840f26d6da9f6.js +0 -1
  104. package/assets/esri/core/workers/chunks/277582f08a841c0ef88e.js +0 -1
  105. package/assets/esri/core/workers/chunks/77b9c77fde79f770bd86.js +0 -1
  106. package/assets/esri/core/workers/chunks/88e0fe418ae96dd3e08a.js +0 -1
  107. package/assets/esri/core/workers/chunks/934ce3f004c54d542d2c.js +0 -1
  108. package/assets/esri/core/workers/chunks/94c4ef224ff38eca7b87.js +0 -1
  109. package/assets/esri/core/workers/chunks/a6aefb5bb6129d31e525.js +0 -1
  110. package/assets/esri/core/workers/chunks/d0d6f818851d9a2d7938.js +0 -1
  111. package/assets/esri/core/workers/chunks/e56010a523117bd39ff3.js +0 -1
  112. package/editing/types.d.ts +0 -9
  113. package/webmap/Version.d.ts +0 -9
  114. package/webmap/Version.js +0 -2
  115. package/webscene/Version.d.ts +0 -9
  116. package/webscene/Version.js +0 -2
package/WebDocument2D.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{version as t}from"./kernel.js";import i from"./Map.js";import r from"./Viewpoint.js";import{isSome as o}from"./core/arrayUtils.js";import s from"./core/Collection.js";import n from"./core/Error.js";import{LoadableMixin as a}from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as u}from"./core/maybe.js";import{MultiOriginJSONSupportMixin as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as c}from"./core/promiseUtils.js";import{whenOnce as d}from"./core/reactiveUtils.js";import{addQueryParameter as g,isDataProtocol as f,dataComponents as b}from"./core/urlUtils.js";import{property as y,subclass as w}from"./core/accessorSupport/decorators.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import S from"./geometry/SpatialReference.js";import _ from"./portal/PortalItem.js";import{typeKeyword as v}from"./portal/support/portalItemUtils.js";import V from"./support/MapFloorInfo.js";import j from"./time/TimeExtent.js";import I from"./webdoc/RangeInfo.js";import U from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as P}from"./webdoc/support/thumbnailUtils.js";import{loadFromSource as O}from"./webdoc/support/webdocLoadUtils.js";import{getLayerJSON as x}from"./webdoc/support/writeUtils.js";import F from"./webmap/ApplicationProperties.js";import L from"./webmap/Bookmark.js";import R from"./webmap/InitialViewProperties.js";import k from"./webmap/Version.js";import T from"./webmap/background/ColorBackground.js";import{writer as E}from"./core/accessorSupport/decorators/writer.js";import{reader as B}from"./core/accessorSupport/decorators/reader.js";const N=s.ofType(L),J=new Map([["image/jpeg","jpeg"],["image/jpg","jpg"],["image/png","png"],["image/gif","gif"]]),M="ArcGIS Pro",Z=v.JSAPI;let W=class extends(m(a(h(i)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this.resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new N,this.floorInfo=null,this.initialViewProperties=new R,this.portalItem=null,this.sourceVersion=null,this.widgets=null,this._debouncedSaveOperations=c(async(e,t,i)=>{const{save:r,saveAs:o}=await import("./webdoc/support/webdocSaveUtils.js");switch(e){case 0:return r(this.context,this,t);case 1:return o(this.context,this,i,t)}}),this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){this.portalItem=u(this.portalItem)}initialize(){if(this.when().catch(e=>{l.getLogger(this).error("#load()","Failed to load web map",e)}),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=Z}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,i){e&&this._isAuthoringAppVersionSetByUser?i.authoringAppVersion=e:i.authoringAppVersion=t}readInitialViewProperties(e,t){const i=new R;t.background&&(i.background=T.fromJSON(t.background));const o=t.initialState?.timeExtent;o&&(i.timeExtent=j.fromArray(o));const s=t.initialState?.viewpoint;if(s){if(s.rotation){k.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===M&&(s.rotation*=-1)}i.viewpoint=r.fromJSON(s)}return t.mapRangeInfo&&(i.rangeInfo=I.fromJSON(t.mapRangeInfo)),t.spatialReference&&(i.spatialReference=S.fromJSON(t.spatialReference)),t.timeZone&&(i.timeZone=t.timeZone),i}writeInitialViewProperties(e,t,i,r){if(!e)return;e.background?.color&&(t.background=e.background.write({},r));const{timeExtent:o,viewpoint:s}=e;if(s||o){const e={};s&&(e.viewpoint=s.write({},r)),o&&(e.timeExtent=o.toArray()),t.initialState=e}e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(r)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},r)),t.timeZone=e.timeZone}writeLayers(e,t,i,r){t[i]=this._writeLayers(e,r,"operational-layers")}get loaded(){return super.loaded}readSourceVersion(e,t){const[i,r]=t.version.split(".");return new k(parseInt(i,10),parseInt(r,10))}writeSourceVersion(e,t,i){t[i]=`${this.context.currentVersion.major}.${this.context.currentVersion.minor}`}writeTables(e,t,i,r){const o=this._writeLayers(e,r,"tables");o.length&&(t[i]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}get updatingFromView(){return!!this._updateFromPromise}load(e){return this.addResolvingPromise(O(this.context,this)),Promise.resolve(this)}loadAll(){return p(this,e=>{e(this.ground,this.basemap,this.layers,this.tables)})}read(e,t){t={...t,origin:this.context.origin};const i=this._getAuthoringPropsState();A(this,e,t=>super.read(e,t),t),this._restoreAuthoringPropsFromState(i)}write(e,t){if("loaded"!==this.loadStatus){const e=new n("webmap:not-loaded","Web map must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:this.context.origin,restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async updateFrom(e,t){const i=this._updateFromInternal(e,t);this._updateFromPromise=i,await i;i===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.baseMapLayers||[]]).find(t=>t.id===e.id)}async updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename})),this._clearThumbnailOverride())}getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:g(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_collectAllLayersJSON(e){return e.reduce((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e),[])}_writeLayers(e,t,i){t={...t,layerContainerType:i};return e.map(e=>x(e,"tables"===i?null:this.getLayerJSONFromResourceInfo(e),t)).filter(o).toArray()}_validateJSON(e){const t=k.parse(e.version||"","webmap");return this.context.currentVersion.validate(t),e.version=`${t.major}.${t.minor}`,e}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e?.viewing?.search,i=e=>this.allLayers.some(t=>t.id===e);if(t?.layers&&(t.layers=t.layers.filter(e=>i(e.id))),t?.tables&&(t.tables=t.tables.filter(e=>this.tables.some(t=>t.id===e.id))),e){const t=e.editing?.locationTracking;t?.info&&!i(t.info.layerId)&&(e.editing=null)}const r="presentation"in this?this.presentation:null,o=r?.slides;o&&o.forEach(e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter(e=>i(e.id)))})}async _updateFromInternal(e,t){if(t??={},await d(()=>e.ready),this._updateInitialViewProperties(e,t),e.map===this)for(const i of e.allLayerViews)"visible"in i&&"visible"in i.layer&&i._isOverridden("visible")&&(i.layer.visible=i.visible),"featureEffect"in i&&"featureEffect"in i.layer&&i._isOverridden("featureEffect")&&(i.layer.featureEffect=i.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),this.initialViewProperties.spatialReference=e.spatialReference?.clone(),this.initialViewProperties.timeZone=e.timeZone,t.viewpointExcluded||(this.initialViewProperties.viewpoint=new r({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),i=e.extent.clone(),r=i.width/2;return i.xmin=t.x-r,i.xmax=t.x+r,i}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const i=P(e,t.thumbnailSize),r=await e.takeScreenshot({format:"png",width:i.width,height:i.height});this._setAutoGeneratedThumbnail(r.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(f(e)){const t=b(e),i=t?.mediaType,r=i&&J.get(i.toLowerCase())||null,o=`thumbnail${Date.now()}`;return r?`${o}.${r}`:o}return null}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}};e([y()],W.prototype,"_updateFromPromise",void 0),e([y({type:F,json:{write:!0}})],W.prototype,"applicationProperties",void 0),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],W.prototype,"authoringApp",null),e([E("authoringApp")],W.prototype,"writeAuthoringApp",null),e([y({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],W.prototype,"authoringAppVersion",null),e([E("authoringAppVersion")],W.prototype,"writeAuthoringAppVersion",null),e([y({type:N,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],W.prototype,"bookmarks",void 0),e([y({type:V,json:{name:"mapFloorInfo",write:!0}})],W.prototype,"floorInfo",void 0),e([y({type:R,nonNullable:!0,json:{read:{source:["background","initialState.timeExtent","initialState.viewpoint","mapRangeInfo","spatialReference","timeZone"]},write:{ignoreOrigin:!0,target:{background:{type:T},"initialState.timeExtent":{type:j},"initialState.viewpoint":{type:r},mapRangeInfo:{type:I},spatialReference:{type:S},"timeZone:":{type:String}}}}})],W.prototype,"initialViewProperties",void 0),e([B("initialViewProperties")],W.prototype,"readInitialViewProperties",null),e([E("initialViewProperties")],W.prototype,"writeInitialViewProperties",null),e([y({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],W.prototype,"layers",void 0),e([E("layers")],W.prototype,"writeLayers",null),e([y({type:_})],W.prototype,"portalItem",void 0),e([y()],W.prototype,"resourceInfo",void 0),e([y({readOnly:!0,type:k,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],W.prototype,"sourceVersion",void 0),e([B("sourceVersion")],W.prototype,"readSourceVersion",null),e([E("sourceVersion")],W.prototype,"writeSourceVersion",null),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],W.prototype,"tables",void 0),e([E("tables")],W.prototype,"writeTables",null),e([y()],W.prototype,"thumbnailUrl",null),e([y()],W.prototype,"updatingFromView",null),e([y({type:U,json:{write:!0}})],W.prototype,"widgets",void 0),W=e([w("esri.WebDocument2D")],W);const $=W;export{$ as default};
2
+ import{__decorate as e}from"tslib";import{version as t}from"./kernel.js";import i from"./Map.js";import r from"./Viewpoint.js";import{isSome as o}from"./core/arrayUtils.js";import s from"./core/Collection.js";import n from"./core/Error.js";import{LoadableMixin as a}from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as u}from"./core/maybe.js";import{MultiOriginJSONSupportMixin as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as c}from"./core/promiseUtils.js";import{whenOnce as d}from"./core/reactiveUtils.js";import{addQueryParameter as g,isDataProtocol as f,dataComponents as b}from"./core/urlUtils.js";import y from"./core/Version.js";import{property as w,subclass as A}from"./core/accessorSupport/decorators.js";import{readLoadable as S}from"./core/accessorSupport/read.js";import _ from"./geometry/SpatialReference.js";import v from"./portal/PortalItem.js";import{typeKeyword as V}from"./portal/support/portalItemUtils.js";import j from"./support/MapFloorInfo.js";import I from"./time/TimeExtent.js";import U from"./webdoc/RangeInfo.js";import P from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as O}from"./webdoc/support/thumbnailUtils.js";import{loadFromSource as x}from"./webdoc/support/webdocLoadUtils.js";import{getLayerJSON as F}from"./webdoc/support/writeUtils.js";import L from"./webmap/ApplicationProperties.js";import R from"./webmap/Bookmark.js";import k from"./webmap/InitialViewProperties.js";import T from"./webmap/background/ColorBackground.js";import{writer as E}from"./core/accessorSupport/decorators/writer.js";import{reader as B}from"./core/accessorSupport/decorators/reader.js";const N=s.ofType(R),J=new Map([["image/jpeg","jpeg"],["image/jpg","jpg"],["image/png","png"],["image/gif","gif"]]),M="ArcGIS Pro",Z=V.JSAPI;let W=class extends(m(a(h(i)))){constructor(e){super(e),this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1,this._thumbnailFilename=null,this._updateFromPromise=null,this.resourceReferences={portalItem:null,paths:[]},this.applicationProperties=null,this.bookmarks=new N,this.floorInfo=null,this.initialViewProperties=new k,this.portalItem=null,this.sourceVersion=null,this.widgets=null,this._debouncedSaveOperations=c(async(e,t,i)=>{const{save:r,saveAs:o}=await import("./webdoc/support/webdocSaveUtils.js");switch(e){case 0:return r(this.context,this,t);case 1:return o(this.context,this,i,t)}}),this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){this.portalItem=u(this.portalItem)}initialize(){if(this.when().catch(e=>{l.getLogger(this).error("#load()","Failed to load web map",e)}),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=Z}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,i){e&&this._isAuthoringAppVersionSetByUser?i.authoringAppVersion=e:i.authoringAppVersion=t}readInitialViewProperties(e,t){const i=new k;t.background&&(i.background=T.fromJSON(t.background));const o=t.initialState?.timeExtent;o&&(i.timeExtent=I.fromArray(o));const s=t.initialState?.viewpoint;if(s){if(s.rotation){y.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===M&&(s.rotation*=-1)}i.viewpoint=r.fromJSON(s)}return t.mapRangeInfo&&(i.rangeInfo=U.fromJSON(t.mapRangeInfo)),t.spatialReference&&(i.spatialReference=_.fromJSON(t.spatialReference)),t.timeZone&&(i.timeZone=t.timeZone),i}writeInitialViewProperties(e,t,i,r){if(!e)return;e.background?.color&&(t.background=e.background.write({},r));const{timeExtent:o,viewpoint:s}=e;if(s||o){const e={};s&&(e.viewpoint=s.write({},r)),o&&(e.timeExtent=o.toArray()),t.initialState=e}e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(r)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},r)),t.timeZone=e.timeZone}writeLayers(e,t,i,r){t[i]=this._writeLayers(e,r,"operational-layers")}get loaded(){return super.loaded}readSourceVersion(e,t){const[i,r]=t.version.split(".");return new y(parseInt(i,10),parseInt(r,10),"webmap")}writeSourceVersion(e,t,i){t[i]=`${this.context.currentVersion.major}.${this.context.currentVersion.minor}`}writeTables(e,t,i,r){const o=this._writeLayers(e,r,"tables");o.length&&(t[i]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}get updatingFromView(){return!!this._updateFromPromise}load(e){return this.addResolvingPromise(x(this.context,this)),Promise.resolve(this)}loadAll(){return p(this,e=>{e(this.ground,this.basemap,this.layers,this.tables)})}read(e,t){t={...t,origin:this.context.origin};const i=this._getAuthoringPropsState();S(this,e,t=>super.read(e,t),t),this._restoreAuthoringPropsFromState(i)}write(e,t){if("loaded"!==this.loadStatus){const e=new n("webmap:not-loaded","Web map must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:this.context.origin,restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async updateFrom(e,t){const i=this._updateFromInternal(e,t);this._updateFromPromise=i,await i;i===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){const t=this.resourceInfo;return this._collectAllLayersJSON([...t?.baseMap?.baseMapLayers||[],...t?.operationalLayers||[],...this.basemap?.resourceInfo?.data?.baseMapLayers||[]]).find(t=>t.id===e.id)}async updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename})),this._clearThumbnailOverride())}getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:g(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_collectAllLayersJSON(e){return e.reduce((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e),[])}_writeLayers(e,t,i){t={...t,layerContainerType:i};return e.map(e=>F(e,"tables"===i?null:this.getLayerJSONFromResourceInfo(e),t)).filter(o).toArray()}_validateJSON(e){const t=y.parse(e.version||"","webmap");return this.context.currentVersion.validate(t),e.version=`${t.major}.${t.minor}`,e}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e?.viewing?.search,i=e=>this.allLayers.some(t=>t.id===e);if(t?.layers&&(t.layers=t.layers.filter(e=>i(e.id))),t?.tables&&(t.tables=t.tables.filter(e=>this.tables.some(t=>t.id===e.id))),e){const t=e.editing?.locationTracking;t?.info&&!i(t.info.layerId)&&(e.editing=null)}const r="presentation"in this?this.presentation:null,o=r?.slides;o&&o.forEach(e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter(e=>i(e.id)))})}async _updateFromInternal(e,t){if(t??={},await d(()=>e.ready),this._updateInitialViewProperties(e,t),e.map===this)for(const i of e.allLayerViews)"visible"in i&&"visible"in i.layer&&i._isOverridden("visible")&&(i.layer.visible=i.visible),"featureEffect"in i&&"featureEffect"in i.layer&&i._isOverridden("featureEffect")&&(i.layer.featureEffect=i.featureEffect);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){if(t.backgroundExcluded||(this.initialViewProperties.background=e.background?.clone()),this.initialViewProperties.spatialReference=e.spatialReference?.clone(),this.initialViewProperties.timeZone=e.timeZone,t.viewpointExcluded||(this.initialViewProperties.viewpoint=new r({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),i=e.extent.clone(),r=i.width/2;return i.xmin=t.x-r,i.xmax=t.x+r,i}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const i=O(e,t.thumbnailSize),r=await e.takeScreenshot({format:"png",width:i.width,height:i.height});this._setAutoGeneratedThumbnail(r.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(f(e)){const t=b(e),i=t?.mediaType,r=i&&J.get(i.toLowerCase())||null,o=`thumbnail${Date.now()}`;return r?`${o}.${r}`:o}return null}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}};e([w()],W.prototype,"_updateFromPromise",void 0),e([w({type:L,json:{write:!0}})],W.prototype,"applicationProperties",void 0),e([w({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],W.prototype,"authoringApp",null),e([E("authoringApp")],W.prototype,"writeAuthoringApp",null),e([w({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],W.prototype,"authoringAppVersion",null),e([E("authoringAppVersion")],W.prototype,"writeAuthoringAppVersion",null),e([w({type:N,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],W.prototype,"bookmarks",void 0),e([w({type:j,json:{name:"mapFloorInfo",write:!0}})],W.prototype,"floorInfo",void 0),e([w({type:k,nonNullable:!0,json:{read:{source:["background","initialState.timeExtent","initialState.viewpoint","mapRangeInfo","spatialReference","timeZone"]},write:{ignoreOrigin:!0,target:{background:{type:T},"initialState.timeExtent":{type:I},"initialState.viewpoint":{type:r},mapRangeInfo:{type:U},spatialReference:{type:_},"timeZone:":{type:String}}}}})],W.prototype,"initialViewProperties",void 0),e([B("initialViewProperties")],W.prototype,"readInitialViewProperties",null),e([E("initialViewProperties")],W.prototype,"writeInitialViewProperties",null),e([w({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],W.prototype,"layers",void 0),e([E("layers")],W.prototype,"writeLayers",null),e([w({type:v})],W.prototype,"portalItem",void 0),e([w()],W.prototype,"resourceInfo",void 0),e([w({readOnly:!0,type:y,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],W.prototype,"sourceVersion",void 0),e([B("sourceVersion")],W.prototype,"readSourceVersion",null),e([E("sourceVersion")],W.prototype,"writeSourceVersion",null),e([w({json:{read:!1,write:{ignoreOrigin:!0}}})],W.prototype,"tables",void 0),e([E("tables")],W.prototype,"writeTables",null),e([w()],W.prototype,"thumbnailUrl",null),e([w()],W.prototype,"updatingFromView",null),e([w({type:P,json:{write:!0}})],W.prototype,"widgets",void 0),W=e([A("esri.WebDocument2D")],W);const $=W;export{$ as default};
package/WebLinkChart.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import a from"./Basemap.js";import r from"./WebDocument2D.js";import i from"./core/Error.js";import{property as e,subclass as n}from"./core/accessorSupport/decorators.js";import o from"./layers/LinkChartLayer.js";import{getInclusionDefinitionFromCypherResults as h,getInclusionDefinitionFromIdTypePairs as s}from"./layers/knowledgeGraph/layerUtils.js";import{getDefaultChronologicalOverlayLayerId as l,getChronologicalOverlay as y}from"./layers/knowledgeGraph/supportUtils.js";import c from"./linkChart/LayoutSettings.js";import k from"./linkChart/LinkChartProperties.js";import p from"./linkChart/NonspatialDataDisplay.js";import L from"./webmap/InitialViewProperties.js";import{currentVersion as C}from"./webmap/utils.js";import d from"./webmap/Version.js";var u;const w={currentVersion:C,createInitialViewProperties:()=>new L,parseVersion:d.parse,itemType:"Web Link Chart",name:"linkchart",origin:"link-chart"};let f=u=class extends r{constructor(t){super(t),this.mapType="webLinkChart",this.linkChartProperties=new k}get activeLinkChartLayer(){return this.layers.find(({type:t})=>"link-chart"===t)}get context(){return w}async applyLayout(t="organic-standard",r){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");"geographic-organic-standard"!==t||this.basemap?.baseLayers?.length||(this.basemap=a.fromId("topo-vector"),await(this.basemap?.load())),this.linkChartProperties.layoutType=t;const e=r?.layoutSettings??this.linkChartProperties.layoutSettings??new c;this.linkChartProperties.layoutSettings=e;const n={...r,layoutSettings:e};return this.activeLinkChartLayer.applyNewLinkChartLayout(t,n)}changeNonspatialDataDisplay(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");this.linkChartProperties.nonspatialDataDisplay||(this.linkChartProperties.nonspatialDataDisplay=new p),this.linkChartProperties.nonspatialDataDisplay.mode=t}async addRecords(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.addRecords(t,a)}async createSublayerForNamedType(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.createSublayerForNamedType(t)}async removeRecords(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.removeRecords(t)}async expand(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.expand(t,a);return r?.records??[]}async refreshLinkChartData(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.refreshLinkChartCache(t)}async connectBetweenEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.connectBetweenEntities(t,a);return r?.records??[]}async connectFromEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.connectFromEntities(t,a);return r?.records??[]}getMemberIdsByType(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return Array.from(this.activeLinkChartLayer?.dataManager.sublayerCaches.get(t)?.keys()??[])}get diagramNodesExtent(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.linkChartExtent}get entityCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.entityLinkChartDiagramLookup.size}get relationshipCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.relationshipLinkChartDiagramLookup.size}get knowledgeGraph(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer?.knowledgeGraph}add(t,a){if(this.activeLinkChartLayer&&"type"in t&&"link-chart"===t.type)throw new i("linkchart:one-link-chart-layer","Web Link Charts can only have one Link Chart Layer, another cannot be added");if(super.add(t,a),"type"in t&&"link-chart"===t.type){const a=t.initializationLinkChartConfig?.layoutMode;a&&(this.linkChartProperties.layoutType=a);const r=t.initializationLinkChartConfig?.layoutSettings;r&&(this.linkChartProperties.layoutSettings=r)}}static fromJSON(t){if(t)return new u({resourceInfo:t});throw new i("linkchart:empty-resource","Expected a JSON resource but got nothing")}handleChronologicalOverlay(){if(!this.activeLinkChartLayer)return;const t=this.activeLinkChartLayer,a=this.findLayerById(l());if(a&&this.remove(a),"chronological-mono-timeline"===this.linkChartProperties.layoutType||"chronological-multi-timeline"===this.linkChartProperties.layoutType){const a=y(t);this.add(a,0)}}static async fromCypherQuery(t,a,r,i){const e=await h(t,a,i),n=new u,s=new o({url:t.url,initializationInclusionModeDefinition:e,initializationLinkChartConfig:r});return s.load({signal:i?.signal}),n.add(s),n}static fromIdTypePairs(t,a,r,i){const e=s(t,a),n=new u,h=new o({url:t.url,initializationInclusionModeDefinition:e,initializationLinkChartConfig:r});return h.load({signal:i?.signal}),n.add(h),n}};t([e({readOnly:!0})],f.prototype,"activeLinkChartLayer",null),t([e({json:{write:{ignoreOrigin:!0}}})],f.prototype,"mapType",void 0),t([e({type:k,nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],f.prototype,"linkChartProperties",void 0),t([e({readOnly:!0})],f.prototype,"diagramNodesExtent",null),t([e({readOnly:!0})],f.prototype,"entityCount",null),t([e({readOnly:!0})],f.prototype,"relationshipCount",null),t([e({readOnly:!0})],f.prototype,"knowledgeGraph",null),f=u=t([n("esri.WebLinkChart")],f);const m=f;export{m as default};
2
+ import{__decorate as t}from"tslib";import a from"./Basemap.js";import r from"./WebDocument2D.js";import i from"./core/Error.js";import e from"./core/Version.js";import{property as n,subclass as o}from"./core/accessorSupport/decorators.js";import h from"./layers/LinkChartLayer.js";import{getInclusionDefinitionFromCypherResults as s,getInclusionDefinitionFromIdTypePairs as l}from"./layers/knowledgeGraph/layerUtils.js";import{getDefaultChronologicalOverlayLayerId as y,getChronologicalOverlay as c}from"./layers/knowledgeGraph/supportUtils.js";import k from"./linkChart/LayoutSettings.js";import p from"./linkChart/LinkChartProperties.js";import L from"./linkChart/NonspatialDataDisplay.js";import C from"./webmap/InitialViewProperties.js";import{currentVersion as d}from"./webmap/utils.js";var u;const w={currentVersion:d,createInitialViewProperties:()=>new C,parseVersion:e.parse,itemType:"Web Link Chart",name:"linkchart",origin:"link-chart"};let f=u=class extends r{constructor(t){super(t),this.mapType="webLinkChart",this.linkChartProperties=new p}get activeLinkChartLayer(){return this.layers.find(({type:t})=>"link-chart"===t)}get context(){return w}async applyLayout(t="organic-standard",r){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");"geographic-organic-standard"!==t||this.basemap?.baseLayers?.length||(this.basemap=a.fromId("topo-vector"),await(this.basemap?.load())),this.linkChartProperties.layoutType=t;const e=r?.layoutSettings??this.linkChartProperties.layoutSettings??new k;this.linkChartProperties.layoutSettings=e;const n={...r,layoutSettings:e};return this.activeLinkChartLayer.applyNewLinkChartLayout(t,n)}changeNonspatialDataDisplay(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");this.linkChartProperties.nonspatialDataDisplay||(this.linkChartProperties.nonspatialDataDisplay=new L),this.linkChartProperties.nonspatialDataDisplay.mode=t}async addRecords(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.addRecords(t,a)}async createSublayerForNamedType(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.createSublayerForNamedType(t)}async removeRecords(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.removeRecords(t)}async expand(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.expand(t,a);return r?.records??[]}async refreshLinkChartData(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.refreshLinkChartCache(t)}async connectBetweenEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.connectBetweenEntities(t,a);return r?.records??[]}async connectFromEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.connectFromEntities(t,a);return r?.records??[]}getMemberIdsByType(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return Array.from(this.activeLinkChartLayer?.dataManager.sublayerCaches.get(t)?.keys()??[])}get diagramNodesExtent(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.linkChartExtent}get entityCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.entityLinkChartDiagramLookup.size}get relationshipCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.relationshipLinkChartDiagramLookup.size}get knowledgeGraph(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer?.knowledgeGraph}add(t,a){if(this.activeLinkChartLayer&&"type"in t&&"link-chart"===t.type)throw new i("linkchart:one-link-chart-layer","Web Link Charts can only have one Link Chart Layer, another cannot be added");if(super.add(t,a),"type"in t&&"link-chart"===t.type){const a=t.initializationLinkChartConfig?.layoutMode;a&&(this.linkChartProperties.layoutType=a);const r=t.initializationLinkChartConfig?.layoutSettings;r&&(this.linkChartProperties.layoutSettings=r)}}static fromJSON(t){if(t)return new u({resourceInfo:t});throw new i("linkchart:empty-resource","Expected a JSON resource but got nothing")}handleChronologicalOverlay(){if(!this.activeLinkChartLayer)return;const t=this.activeLinkChartLayer,a=this.findLayerById(y());if(a&&this.remove(a),"chronological-mono-timeline"===this.linkChartProperties.layoutType||"chronological-multi-timeline"===this.linkChartProperties.layoutType){const a=c(t);this.add(a,0)}}static async fromCypherQuery(t,a,r,i){const e=await s(t,a,i),n=new u,o=new h({url:t.url,initializationInclusionModeDefinition:e,initializationLinkChartConfig:r});return o.load({signal:i?.signal}),n.add(o),n}static fromIdTypePairs(t,a,r,i){const e=l(t,a),n=new u,o=new h({url:t.url,initializationInclusionModeDefinition:e,initializationLinkChartConfig:r});return o.load({signal:i?.signal}),n.add(o),n}};t([n({readOnly:!0})],f.prototype,"activeLinkChartLayer",null),t([n({json:{write:{ignoreOrigin:!0}}})],f.prototype,"mapType",void 0),t([n({type:p,nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],f.prototype,"linkChartProperties",void 0),t([n({readOnly:!0})],f.prototype,"diagramNodesExtent",null),t([n({readOnly:!0})],f.prototype,"entityCount",null),t([n({readOnly:!0})],f.prototype,"relationshipCount",null),t([n({readOnly:!0})],f.prototype,"knowledgeGraph",null),f=u=t([o("esri.WebLinkChart")],f);const m=f;export{m as default};
package/WebMap.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type WebDocument2D from "./WebDocument2D.js";
2
2
  import type Collection from "./core/Collection.js";
3
+ import type Version from "./core/Version.js";
3
4
  import type UtilityNetwork from "./networks/UtilityNetwork.js";
4
5
  import type GeotriggersInfo from "./webdoc/GeotriggersInfo.js";
5
6
  import type IPSInfo from "./webdoc/IPSInfo.js";
6
- import type Version from "./webmap/Version.js";
7
7
  import type { WebDocument2DProperties } from "./WebDocument2D.js";
8
8
  import type { GeotriggersInfoProperties } from "./webdoc/GeotriggersInfo.js";
9
9
  import type { IPSInfoProperties } from "./webdoc/IPSInfo.js";
package/WebMap.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import o from"./WebDocument2D.js";import e from"./core/Collection.js";import r from"./core/Error.js";import{loadAll as i}from"./core/loadAll.js";import{property as s,subclass as p}from"./core/accessorSupport/decorators.js";import n from"./networks/UtilityNetwork.js";import m from"./webdoc/GeotriggersInfo.js";import a from"./webdoc/IPSInfo.js";import l from"./webmap/InitialViewProperties.js";import{currentVersion as c}from"./webmap/utils.js";import f from"./webmap/Version.js";const w={currentVersion:c,createInitialViewProperties:()=>new l,parseVersion:f.parse,itemType:"Web Map",name:"webmap",origin:"web-map"},u=e.ofType(n);let y=class extends o{constructor(t){super(t),this.geotriggersInfo=null,this.ipsInfo=null,this.presentation=null,this.utilityNetworks=null}destroy(){if(this.utilityNetworks){const t=this.utilityNetworks.removeAll();for(const o of t)o.destroy();this.utilityNetworks.destroy()}}get context(){return w}loadAll(){return i(this,t=>{t(this.ground,this.basemap,this.layers,this.tables,this.ipsInfo?.positioningService?.portalItem)})}static fromJSON(t){if(t)return new this({resourceInfo:t});throw new r("webmap:empty-resource","Expected a JSON resource but got nothing")}static{this.VERSION=c}};t([s({type:m,json:{write:!0}})],y.prototype,"geotriggersInfo",void 0),t([s({type:a,json:{write:!0,name:"mapIPSInfo"}})],y.prototype,"ipsInfo",void 0),t([s({json:{write:!0}})],y.prototype,"presentation",void 0),t([s({type:u,json:{read:!0,write:!0}})],y.prototype,"utilityNetworks",void 0),y=t([p("esri.WebMap")],y);const d=y;export{d as default};
2
+ import{__decorate as t}from"tslib";import o from"./WebDocument2D.js";import e from"./core/Collection.js";import r from"./core/Error.js";import{loadAll as i}from"./core/loadAll.js";import s from"./core/Version.js";import{property as n,subclass as p}from"./core/accessorSupport/decorators.js";import m from"./networks/UtilityNetwork.js";import l from"./webdoc/GeotriggersInfo.js";import a from"./webdoc/IPSInfo.js";import c from"./webmap/InitialViewProperties.js";import{currentVersion as f}from"./webmap/utils.js";const u={currentVersion:f,createInitialViewProperties:()=>new c,parseVersion:s.parse,itemType:"Web Map",name:"webmap",origin:"web-map"},w=e.ofType(m);let y=class extends o{constructor(t){super(t),this.geotriggersInfo=null,this.ipsInfo=null,this.presentation=null,this.utilityNetworks=null}destroy(){if(this.utilityNetworks){const t=this.utilityNetworks.removeAll();for(const o of t)o.destroy();this.utilityNetworks.destroy()}}get context(){return u}loadAll(){return i(this,t=>{t(this.ground,this.basemap,this.layers,this.tables,this.ipsInfo?.positioningService?.portalItem)})}static fromJSON(t){if(t)return new this({resourceInfo:t});throw new r("webmap:empty-resource","Expected a JSON resource but got nothing")}static{this.VERSION=f}};t([n({type:l,json:{write:!0}})],y.prototype,"geotriggersInfo",void 0),t([n({type:a,json:{write:!0,name:"mapIPSInfo"}})],y.prototype,"ipsInfo",void 0),t([n({json:{write:!0}})],y.prototype,"presentation",void 0),t([n({type:w,json:{read:!0,write:!0}})],y.prototype,"utilityNetworks",void 0),y=t([p("esri.WebMap")],y);const d=y;export{d as default};
package/WebScene.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type Map from "./Map.js";
2
+ import type Version from "./core/Version.js";
2
3
  import type Extent from "./geometry/Extent.js";
3
4
  import type HeightModelInfo from "./geometry/HeightModelInfo.js";
4
5
  import type PortalFolder from "./portal/PortalFolder.js";
@@ -9,7 +10,6 @@ import type Widgets from "./webdoc/Widgets.js";
9
10
  import type ApplicationProperties from "./webscene/ApplicationProperties.js";
10
11
  import type InitialViewProperties from "./webscene/InitialViewProperties.js";
11
12
  import type Presentation from "./webscene/Presentation.js";
12
- import type Version from "./webscene/Version.js";
13
13
  import type { MapProperties } from "./Map.js";
14
14
  import type { LoadableMixin, LoadableMixinProperties } from "./core/Loadable.js";
15
15
  import type { MultiOriginJSONSupportMixin } from "./core/MultiOriginJSONSupport.js";
package/WebScene.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./core/Collection.js";import o from"./core/Error.js";import{clone as s}from"./core/lang.js";import{LoadableMixin as a}from"./core/Loadable.js";import{loadAll as n}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as p}from"./core/maybe.js";import{MultiOriginJSONSupportMixin as c,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as m,watch as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import g from"./core/Warning.js";import{property as b,subclass as v}from"./core/accessorSupport/decorators.js";import{updateOrigins as _}from"./core/accessorSupport/originUtils.js";import{readLoadable as S}from"./core/accessorSupport/read.js";import{isEarth as A}from"./geometry/ellipsoidUtils.js";import I from"./geometry/Extent.js";import j from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as L}from"./geometry/projectionUtils.js";import P from"./geometry/SpatialReference.js";import{validateWebSceneError as R}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import V from"./portal/Portal.js";import O from"./portal/PortalItem.js";import{createForItemWrite as M}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as E,typeKeyword as C}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as T}from"./support/basemapUtils.js";import{ensureType as N}from"./support/groundUtils.js";import x from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as F}from"./support/webSceneUtils.js";import{isSpatialReferenceSupported as W}from"./views/support/spatialReferenceSupport.js";import J from"./webdoc/Widgets.js";import{updateItemWithResources as $,saveResources as k}from"./webdoc/support/resourceUtils.js";import{evaluateWriteErrors as B}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as q}from"./webdoc/support/thumbnailUtils.js";import{addLayerUnsupportedError as H}from"./webdoc/support/unsupportedErrors.js";import{isCopyAllowed as D,initializeNewItem as z}from"./webdoc/support/webdocSaveUtils.js";import K from"./webscene/ApplicationProperties.js";import Q from"./webscene/Environment.js";import X from"./webscene/InitialViewProperties.js";import Y from"./webscene/Presentation.js";import Z from"./webscene/TransportationNetwork.js";import ee from"./webscene/Version.js";import{alphaCutoff as te}from"./webscene/support/AlphaCutoff.js";import{getLoader as re}from"./webscene/support/schemaValidatorLoader.js";import{writer as ie}from"./core/accessorSupport/decorators/writer.js";import{reader as oe}from"./core/accessorSupport/decorators/reader.js";var se;const ae=new ee(1,39),ne=()=>{const e=8,t=[],r=ae.major;for(let i=e;i<=ae.minor;i++)t.push(`${r}.${i}`);return t},le="Web Scene";let pe=class extends(a(h(c(r)))){static{se=G}constructor(e){super(e),this[se]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this._afterLoadHooks=[],this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new Y,this.initialViewProperties=new X,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u(async(e,t,r)=>{switch(e){case 0:return this._saveImpl(t);case 1:return this._saveAsImpl(r,t)}}),this._loadContext={origin:"web-scene",initiator:this,hooks:{onAfterLoad:e=>this._afterLoadHooks.push(e)}},this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch(e=>{l.getLogger(this).error("#load()","Failed to load web scene",e)}),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(m(()=>this.allLayers,"change",()=>this._scheduleLayersIdGC()))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=p(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}get loaded(){return super.loaded}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new ee(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${ae.major}.${ae.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}get ground(){return this._get("ground")}set ground(e){const t=N(e);null!=t&&this._set("ground",t)}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t,r){const{viewingMode:i,spatialReference:o}=t,s=new X,a={...t.initialState};return void 0!==o&&(a.spatialReference=o),void 0!==i&&(a.viewingMode=i),s.read(a,r),s}get spatialReference(){return this.initialViewProperties?.spatialReference??P.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then(()=>{t&&t!==this.ground&&t.destroy(),this._validateFeatureLayerSymbolVisibility()})),Promise.resolve(this)}loadAll(){return n(this,e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map(e=>e.basemap),this.tables)})}read(e,t){t??=this._loadContext,t.origin="web-scene";const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(S(this,e,t=>super.read(e,t),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map(e=>({id:e.id})),r=this.presentation.slides,i=t.filter(e=>!r.some(t=>t.visibleLayers.some(t=>t.id===e.id)));r.forEach(e=>e.visibleLayers.addMany(i))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=s(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map(e=>this._verifyWritableLayer(e,r)?e.write({},i):null).filter(e=>!!e).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(H(t,e),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new o("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter(e=>"web-document-write:property-required"===e.name)??[];if(e.length){const t=new o("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw l.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(0,e)}async _saveImpl(e){if(!this.portalItem)throw new o("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(this.portalItem?.type!==le)throw new o("webscene:portal-item-wrong-type",`Portal item needs to have type "${le}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(M(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,0,e),this._updateTypeKeywords(this.portalItem),await $(this.portalItem,i,this._resourceReferences,r),_(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async _saveAsImpl(e,t){let r=O.from(e);if(!r)throw new o("webscene:portal-item-required","saveAs requires a portal item to save to");r.id&&(r=r.clone(),r.id=null);const i=r.portal||V.getDefault();await this._ensureLoadBeforeSave(),r.type=le,r.portal=i;const s=this._enableVerifyItemRelativeUrls(M(r,"web-scene",!0)),a=this.write({},s);await Promise.all(s.resources.pendingOperations),await this._verifySaveAs(a,s,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");this._updateTypeKeywords(r),await i.signIn();const p=this.portalItem,c={item:p,authenticated:!(!p?.id||!p.portal.user)},{copyAllowed:h,itemReloaded:u}=await D(c,i);if(c.authenticated||=u,!h)throw new o(`${s.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m={...t,copyAllResources:!0};return await z(r,c,a,m)&&(this._resourceReferences.portalItem=r),await k(this._resourceReferences,s),this.portalItem=r,d.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),_(s),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),s.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i){if(!A(this.spatialReference))throw new o("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:s,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=i||{};B(t,{errorName:"webscene:save"},{ignoreUnsupported:s,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const p=re();if(n&&p){const t=(await p()).validate(e);if(!t.length)return;const i=`webscene did not validate:\n${t.join("\n")}`;l.getLogger(this).error(`${1===r?"saveAs":"save"}(): ${i}`);const s=t.map(e=>new o("webscene:schema-validation",e));throw F(s)}}_verifySaveAs(e,t,r){return this._verifySave(e,t,1,r)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(){return!1}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=Q.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,this.initialViewProperties.analyses.updateFrom(e),null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this.updateThumbnail(e,{size:t.thumbnailSize})}async updateThumbnail(e,t){const r=q(e,t?.size),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}async _loadFromSource(){this.resourceInfo?await this._loadFromJSON(this.resourceInfo):this.portalItem?.id?await this._loadFromItem(this.portalItem):await this._loadObjectsWithLayers(),await this._afterLoad()}async _afterLoad(){for(;this._afterLoadHooks.length;){const e=this._afterLoadHooks.slice();this._afterLoadHooks.length=0,await Promise.allSettled(e.map(e=>e(this._loadContext)))}}_readAndLoadFromJSON(e){const t=this._loadContext,r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e){const t=new i;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:r}=await import("./layers/support/layersCreator.js"),{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...this._loadContext,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||V.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(t,s,e))}o&&o.length>0&&n.push(r(this.layers,o,l)),e.tables?.length&&n.push(r(this.tables,e.tables,{...l,context:{...l.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(n),await this._loadObjectsWithLayers(),this.ground.layers.addMany(t.filter(e=>"base-elevation"===e.type||"elevation"===e.type))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.groundLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach(t=>{t.basemap&&e.push(t.basemap.load())}),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch(e=>{throw new o("webscene:load-portal-item","Failed to load portal item",{error:e})}),"Web Scene"!==e.type)throw new o("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r=this._loadContext;r.url=w(e.itemUrl),r.portal=e.portal||V.getDefault(),r.portalItem=e,r.readResourcePaths=[],await this._readAndLoadFromJSON(t),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!W(t,1))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||L(e,t)}else{if(!W(t,2))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,s=e.viewpoint,a=i(s);if(a&&!r(a))return Promise.reject(new o("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find(e=>!r(i(e.viewpoint)));if(n){const r=i(n.viewpoint);return Promise.reject(new o("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=R(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateFeatureLayerSymbolVisibility(){this.sourceVersion?.greaterEqual(1,35)||this.layers.forEach(e=>{"feature"===e.type&&e.addHandles(y(()=>e.loaded,()=>{"on-the-ground"===e.elevationInfo?.mode&&"simple"===e.renderer?.type&&"polygon-3d"===e.renderer.symbol?.type&&e.renderer.symbol.symbolLayers.some(t=>"fill"===t.type&&null!=t.material&&((!t.material.color||t.material.color.a*e.opacity<te)&&(e.loadWarnings.push(new g("feature-layer:invisible-draped-symbols","FeatureLayer has fully transparent symbols which will no longer render or highlight",{layer:e})),!0)))},{once:!0,sync:!0}))})}_validateJSON(e){const t=ee.parse(e.version||"","webscene");return ae.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=P.WebMercator.toJSON()),e}_updateTypeKeywords(e){E(e,C.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),E(e,C.DEVELOPER_BASEMAP,T(this.basemap)||this.presentation.slides.some(({basemap:e})=>!!e&&T(e))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||P.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout(()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()},3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some(t=>t.id===e&&t.persistenceEnabled);e?.layers&&(e.layers=e.layers.filter(e=>t(e.id)));const r=this.presentation&&this.presentation.slides;r&&r.forEach(e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter(e=>t(e.id)))})}static fromJSON(e){if(!e)throw new o("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}static{this.version=`${ae.major}.${ae.minor}`}};e([b({type:K,json:{write:!0}})],pe.prototype,"applicationProperties",void 0),e([b({type:I,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],pe.prototype,"clippingArea",void 0),e([ie("clippingArea")],pe.prototype,"writeClippingArea",null),e([b({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],pe.prototype,"clippingEnabled",void 0),e([oe("clippingEnabled",["clippingArea"])],pe.prototype,"readClippingEnabled",null),e([ie("clippingEnabled")],pe.prototype,"writeClippingEnabled",null),e([b({type:x,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],pe.prototype,"floorInfo",void 0),e([b({type:j,json:{write:!0}})],pe.prototype,"heightModelInfo",void 0),e([b({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],pe.prototype,"layers",void 0),e([ie("layers")],pe.prototype,"writeLayers",null),e([b({readOnly:!0,type:ee,json:{type:ne(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],pe.prototype,"sourceVersion",void 0),e([oe("sourceVersion",["version"])],pe.prototype,"readSourceVersion",null),e([ie("sourceVersion")],pe.prototype,"writeSourceVersion",null),e([b({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],pe.prototype,"tables",void 0),e([ie("tables")],pe.prototype,"writeTables",null),e([b()],pe.prototype,"thumbnailUrl",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],pe.prototype,"authoringApp",null),e([ie("authoringApp")],pe.prototype,"writeAuthoringApp",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],pe.prototype,"authoringAppVersion",null),e([ie("authoringAppVersion")],pe.prototype,"writeAuthoringAppVersion",null),e([b({json:{write:{isRequired:!0,enabled:!0,overridePolicy:()=>({isRequired:!0,enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],pe.prototype,"ground",null),e([ie("ground")],pe.prototype,"writeGround",null),e([b({type:i.ofType(Z),json:{write:!0}})],pe.prototype,"transportationNetworks",void 0),e([b({type:Y,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],pe.prototype,"presentation",void 0),e([b({type:X,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new X({viewingMode:"global",spatialReference:P.WebMercator})}})],pe.prototype,"initialViewProperties",void 0),e([oe("initialViewProperties",["initialState","spatialReference","viewingMode"])],pe.prototype,"readInitialViewProperties",null),e([b({type:P,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],pe.prototype,"spatialReference",null),e([b({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],pe.prototype,"viewingMode",null),e([b({type:O})],pe.prototype,"portalItem",void 0),e([b()],pe.prototype,"resourceInfo",void 0),e([b({type:J,json:{write:!0}})],pe.prototype,"widgets",void 0),pe=e([v("esri.WebScene")],pe);const ce=pe;export{ce as default};
2
+ import{__decorate as e}from"tslib";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./core/Collection.js";import o from"./core/Error.js";import{clone as s}from"./core/lang.js";import{LoadableMixin as a}from"./core/Loadable.js";import{loadAll as n}from"./core/loadAll.js";import l from"./core/Logger.js";import{destroyMaybe as p}from"./core/maybe.js";import{MultiOriginJSONSupportMixin as c,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as h}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as m,watch as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import g from"./core/Version.js";import b from"./core/Warning.js";import{property as v,subclass as _}from"./core/accessorSupport/decorators.js";import{updateOrigins as S}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import{isEarth as I}from"./geometry/ellipsoidUtils.js";import j from"./geometry/Extent.js";import L from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as P}from"./geometry/projectionUtils.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as U}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as V}from"./geometry/support/jsonUtils.js";import O from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{createForItemWrite as E}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as C,typeKeyword as T}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as N}from"./support/basemapUtils.js";import{ensureType as x}from"./support/groundUtils.js";import F from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as W}from"./support/webSceneUtils.js";import{isSpatialReferenceSupported as J}from"./views/support/spatialReferenceSupport.js";import $ from"./webdoc/Widgets.js";import{updateItemWithResources as k,saveResources as B}from"./webdoc/support/resourceUtils.js";import{evaluateWriteErrors as q}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as H}from"./webdoc/support/thumbnailUtils.js";import{addLayerUnsupportedError as D}from"./webdoc/support/unsupportedErrors.js";import{isCopyAllowed as z,initializeNewItem as K}from"./webdoc/support/webdocSaveUtils.js";import Q from"./webscene/ApplicationProperties.js";import X from"./webscene/Environment.js";import Y from"./webscene/InitialViewProperties.js";import Z from"./webscene/Presentation.js";import ee from"./webscene/TransportationNetwork.js";import{alphaCutoff as te}from"./webscene/support/AlphaCutoff.js";import{getLoader as re}from"./webscene/support/schemaValidatorLoader.js";import{supportsVisibleElevationLayersInSlides as ie,versionSupportsGround as oe}from"./webscene/support/versionUtils.js";import{writer as se}from"./core/accessorSupport/decorators/writer.js";import{reader as ae}from"./core/accessorSupport/decorators/reader.js";var ne;const le=new g(1,39,"webscene"),pe=()=>{const e=8,t=[],r=le.major;for(let i=e;i<=le.minor;i++)t.push(`${r}.${i}`);return t},ce="Web Scene";let de=class extends(a(h(c(r)))){static{ne=G}constructor(e){super(e),this[ne]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this._afterLoadHooks=[],this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new Z,this.initialViewProperties=new Y,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u(async(e,t,r)=>{switch(e){case 0:return this._saveImpl(t);case 1:return this._saveAsImpl(r,t)}}),this._loadContext={origin:"web-scene",initiator:this,hooks:{onAfterLoad:e=>this._afterLoadHooks.push(e)}},this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch(e=>{l.getLogger(this).error("#load()","Failed to load web scene",e)}),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(m(()=>this.allLayers,"change",()=>this._scheduleLayersIdGC()))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=p(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}get loaded(){return super.loaded}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new g(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${le.major}.${le.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}get ground(){return this._get("ground")}set ground(e){const t=x(e);null!=t&&this._set("ground",t)}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t,r){const{viewingMode:i,spatialReference:o}=t,s=new Y,a={...t.initialState};return void 0!==o&&(a.spatialReference=o),void 0!==i&&(a.viewingMode=i),s.read(a,r),s}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then(()=>{t&&t!==this.ground&&t.destroy(),this._validateFeatureLayerSymbolVisibility()})),Promise.resolve(this)}loadAll(){return n(this,e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map(e=>e.basemap),this.tables)})}read(e,t){t??=this._loadContext,t.origin="web-scene";const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,t=>super.read(e,t),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&ie(this.sourceVersion)){const t=e.baseMap.elevationLayers.map(e=>({id:e.id})),r=this.presentation.slides,i=t.filter(e=>!r.some(t=>t.visibleLayers.some(t=>t.id===e.id)));r.forEach(e=>e.visibleLayers.addMany(i))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=s(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map(e=>this._verifyWritableLayer(e,r)?e.write({},i):null).filter(e=>!!e).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(D(t,e),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new o("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw l.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter(e=>"web-document-write:property-required"===e.name)??[];if(e.length){const t=new o("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw l.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(0,e)}async _saveImpl(e){if(!this.portalItem)throw new o("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(this.portalItem?.type!==ce)throw new o("webscene:portal-item-wrong-type",`Portal item needs to have type "${ce}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(E(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,0,e),this._updateTypeKeywords(this.portalItem),await k(this.portalItem,i,this._resourceReferences,r),S(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new o("webscene:portal-item-required","saveAs requires a portal item to save to");r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=ce,r.portal=i;const s=this._enableVerifyItemRelativeUrls(E(r,"web-scene",!0)),a=this.write({},s);await Promise.all(s.resources.pendingOperations),await this._verifySaveAs(a,s,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");this._updateTypeKeywords(r),await i.signIn();const p=this.portalItem,c={item:p,authenticated:!(!p?.id||!p.portal.user)},{copyAllowed:h,itemReloaded:u}=await z(c,i);if(c.authenticated||=u,!h)throw new o(`${s.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m={...t,copyAllResources:!0};return await K(r,c,a,m)&&(this._resourceReferences.portalItem=r),await B(this._resourceReferences,s),this.portalItem=r,d.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),S(s),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),s.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i){if(!I(this.spatialReference))throw new o("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:s,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=i||{};q(t,{errorName:"webscene:save"},{ignoreUnsupported:s,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const p=re();if(n&&p){const t=(await p()).validate(e);if(!t.length)return;const i=`webscene did not validate:\n${t.join("\n")}`;l.getLogger(this).error(`${1===r?"saveAs":"save"}(): ${i}`);const s=t.map(e=>new o("webscene:schema-validation",e));throw W(s)}}_verifySaveAs(e,t,r){return this._verifySave(e,t,1,r)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(){return!1}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=X.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,this.initialViewProperties.analyses.updateFrom(e),null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this.updateThumbnail(e,{size:t.thumbnailSize})}async updateThumbnail(e,t){const r=H(e,t?.size),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}async _loadFromSource(){this.resourceInfo?await this._loadFromJSON(this.resourceInfo):this.portalItem?.id?await this._loadFromItem(this.portalItem):await this._loadObjectsWithLayers(),await this._afterLoad()}async _afterLoad(){for(;this._afterLoadHooks.length;){const e=this._afterLoadHooks.slice();this._afterLoadHooks.length=0,await Promise.allSettled(e.map(e=>e(this._loadContext)))}}_readAndLoadFromJSON(e){const t=this._loadContext,r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r)}_extractOperationalLayers(e){const t=[];if(!oe(this.sourceVersion)&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(oe(this.sourceVersion)||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e){const t=new i;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:r}=await import("./layers/support/layersCreator.js"),{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...this._loadContext,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||O.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(r(t,s,e))}o&&o.length>0&&n.push(r(this.layers,o,l)),e.tables?.length&&n.push(r(this.tables,e.tables,{...l,context:{...l.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(n),await this._loadObjectsWithLayers(),this.ground.layers.addMany(t.filter(e=>"base-elevation"===e.type||"elevation"===e.type))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.groundLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach(t=>{t.basemap&&e.push(t.basemap.load())}),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch(e=>{throw new o("webscene:load-portal-item","Failed to load portal item",{error:e})}),"Web Scene"!==e.type)throw new o("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r=this._loadContext;r.url=w(e.itemUrl),r.portal=e.portal||O.getDefault(),r.portalItem=e,r.readResourcePaths=[],await this._readAndLoadFromJSON(t),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!J(t,1))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||P(e,t)}else{if(!J(t,2))return Promise.reject(new o("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,s=e.viewpoint,a=i(s);if(a&&!r(a))return Promise.reject(new o("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find(e=>!r(i(e.viewpoint)));if(n){const r=i(n.viewpoint);return Promise.reject(new o("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=U(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateFeatureLayerSymbolVisibility(){this.sourceVersion?.greaterEqual(1,35)||this.layers.forEach(e=>{"feature"===e.type&&e.addHandles(y(()=>e.loaded,()=>{"on-the-ground"===e.elevationInfo?.mode&&"simple"===e.renderer?.type&&"polygon-3d"===e.renderer.symbol?.type&&e.renderer.symbol.symbolLayers.some(t=>"fill"===t.type&&null!=t.material&&((!t.material.color||t.material.color.a*e.opacity<te)&&(e.loadWarnings.push(new b("feature-layer:invisible-draped-symbols","FeatureLayer has fully transparent symbols which will no longer render or highlight",{layer:e})),!0)))},{once:!0,sync:!0}))})}_validateJSON(e){const t=g.parse(e.version||"","webscene");return le.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){C(e,T.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),C(e,T.DEVELOPER_BASEMAP,N(this.basemap)||this.presentation.slides.some(({basemap:e})=>!!e&&N(e))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout(()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()},3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some(t=>t.id===e&&t.persistenceEnabled);e?.layers&&(e.layers=e.layers.filter(e=>t(e.id)));const r=this.presentation&&this.presentation.slides;r&&r.forEach(e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter(e=>t(e.id)))})}static fromJSON(e){if(!e)throw new o("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}static{this.version=`${le.major}.${le.minor}`}};e([v({type:Q,json:{write:!0}})],de.prototype,"applicationProperties",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:V},write:{target:"clippingArea.geometry"}}})],de.prototype,"clippingArea",void 0),e([se("clippingArea")],de.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],de.prototype,"clippingEnabled",void 0),e([ae("clippingEnabled",["clippingArea"])],de.prototype,"readClippingEnabled",null),e([se("clippingEnabled")],de.prototype,"writeClippingEnabled",null),e([v({type:F,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],de.prototype,"floorInfo",void 0),e([v({type:L,json:{write:!0}})],de.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],de.prototype,"layers",void 0),e([se("layers")],de.prototype,"writeLayers",null),e([v({readOnly:!0,type:g,json:{type:pe(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],de.prototype,"sourceVersion",void 0),e([ae("sourceVersion",["version"])],de.prototype,"readSourceVersion",null),e([se("sourceVersion")],de.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],de.prototype,"tables",void 0),e([se("tables")],de.prototype,"writeTables",null),e([v()],de.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],de.prototype,"authoringApp",null),e([se("authoringApp")],de.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],de.prototype,"authoringAppVersion",null),e([se("authoringAppVersion")],de.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,enabled:!0,overridePolicy:()=>({isRequired:!0,enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],de.prototype,"ground",null),e([se("ground")],de.prototype,"writeGround",null),e([v({type:i.ofType(ee),json:{write:!0}})],de.prototype,"transportationNetworks",void 0),e([v({type:Z,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],de.prototype,"presentation",void 0),e([v({type:Y,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new Y({viewingMode:"global",spatialReference:R.WebMercator})}})],de.prototype,"initialViewProperties",void 0),e([ae("initialViewProperties",["initialState","spatialReference","viewingMode"])],de.prototype,"readInitialViewProperties",null),e([v({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],de.prototype,"spatialReference",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],de.prototype,"viewingMode",null),e([v({type:M})],de.prototype,"portalItem",void 0),e([v()],de.prototype,"resourceInfo",void 0),e([v({type:$,json:{write:!0}})],de.prototype,"widgets",void 0),de=e([_("esri.WebScene")],de);const he=de;export{he as default};
@@ -10,7 +10,6 @@ import type FeatureLayer from "../../layers/FeatureLayer.js";
10
10
  import type SubtypeGroupLayer from "../../layers/SubtypeGroupLayer.js";
11
11
  import type FeatureTemplate from "../../layers/support/FeatureTemplate.js";
12
12
  import type FeatureService from "../../rest/featureService/FeatureService.js";
13
- import type { AnyEditingTemplate, AnyEditingTemplateInfo } from "../../editing/types.js";
14
13
  import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
15
14
 
16
15
  /**
@@ -58,7 +57,7 @@ export type LoadedSharedTemplate = SharedTemplate
58
57
  * @experimental
59
58
  * @internal
60
59
  */
61
- export function isSharedGroupTemplate(template: AnyEditingTemplate | null | undefined): boolean;
60
+ export function isSharedGroupTemplate(template: FeatureTemplate | SharedTemplate | null | undefined): boolean;
62
61
 
63
62
  /**
64
63
  * Test if template is a Shared Preset Template
@@ -67,7 +66,7 @@ export function isSharedGroupTemplate(template: AnyEditingTemplate | null | unde
67
66
  * @experimental
68
67
  * @internal
69
68
  */
70
- export function isSharedPresetTemplate(template: AnyEditingTemplate | null | undefined): boolean;
69
+ export function isSharedPresetTemplate(template: FeatureTemplate | SharedTemplate | null | undefined): boolean;
71
70
 
72
71
  /**
73
72
  * Test if template is a standard Feature Template
@@ -76,7 +75,7 @@ export function isSharedPresetTemplate(template: AnyEditingTemplate | null | und
76
75
  * @experimental
77
76
  * @internal
78
77
  */
79
- export function isStandardFeatureTemplate(template: AnyEditingTemplateInfo | null | undefined): template is FeatureTemplate;
78
+ export function isStandardFeatureTemplate(template: FeatureTemplate | SharedTemplateMetadata | null | undefined): template is FeatureTemplate;
80
79
 
81
80
  /**
82
81
  * Test if template is a shared feature template
@@ -85,7 +84,7 @@ export function isStandardFeatureTemplate(template: AnyEditingTemplateInfo | nul
85
84
  * @experimental
86
85
  * @internal
87
86
  */
88
- export function isSharedFeatureTemplate(template: AnyEditingTemplate | null | undefined): template is FeatureTemplate;
87
+ export function isSharedFeatureTemplate(template: FeatureTemplate | SharedTemplate | null | undefined): template is FeatureTemplate;
89
88
 
90
89
  /**
91
90
  * Test if template info is Meta data for a Shared Template
@@ -94,7 +93,7 @@ export function isSharedFeatureTemplate(template: AnyEditingTemplate | null | un
94
93
  * @experimental
95
94
  * @internal
96
95
  */
97
- export function isSharedTemplateMetadata(template: AnyEditingTemplateInfo | null | undefined): template is SharedTemplateMetadata;
96
+ export function isSharedTemplateMetadata(template: FeatureTemplate | SharedTemplateMetadata | null | undefined): template is SharedTemplateMetadata;
98
97
 
99
98
  /**
100
99
  * Test if template is a Shared Template
@@ -103,7 +102,7 @@ export function isSharedTemplateMetadata(template: AnyEditingTemplateInfo | null
103
102
  * @experimental
104
103
  * @internal
105
104
  */
106
- export function isSharedTemplate(template: AnyEditingTemplateInfo | null | undefined): template is SharedTemplate;
105
+ export function isSharedTemplate(template: FeatureTemplate | SharedTemplateMetadata | null | undefined): template is SharedTemplate;
107
106
 
108
107
  /**
109
108
  * Test if template is a Template or Template Info
@@ -112,7 +111,7 @@ export function isSharedTemplate(template: AnyEditingTemplateInfo | null | undef
112
111
  * @experimental
113
112
  * @internal
114
113
  */
115
- export function isSharedTemplateOrMetadata(template: AnyEditingTemplateInfo | null | undefined): template is SharedTemplateMetadata;
114
+ export function isSharedTemplateOrMetadata(template: FeatureTemplate | SharedTemplateMetadata | null | undefined): template is SharedTemplateMetadata;
116
115
 
117
116
  /**
118
117
  * Load a full template definition from its meta data
@@ -122,7 +121,7 @@ export function isSharedTemplateOrMetadata(template: AnyEditingTemplateInfo | nu
122
121
  * @experimental
123
122
  * @internal
124
123
  */
125
- export function getFullTemplate(view: MapViewOrSceneView, templateInfo: AnyEditingTemplateInfo): Promise<AnyLoadedEditingTemplate | null>;
124
+ export function getFullTemplate(view: MapViewOrSceneView, templateInfo: FeatureTemplate | SharedTemplateMetadata): Promise<AnyLoadedEditingTemplate | null>;
126
125
 
127
126
  /**
128
127
  * Create the set of attributes specified in a template
@@ -132,4 +131,4 @@ export function getFullTemplate(view: MapViewOrSceneView, templateInfo: AnyEditi
132
131
  * @experimental
133
132
  * @internal
134
133
  */
135
- export function getCreationAttributes(template: AnyEditingTemplate | null | undefined, overrides?: Record<string, unknown>): Record<string, unknown>;
134
+ export function getCreationAttributes(template: FeatureTemplate | SharedTemplate | null | undefined, overrides?: Record<string, unknown>): Record<string, unknown>;