@arcgis/core 4.33.0-next.20250220 → 4.33.0-next.20250221
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.
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/4f764b952c6463fc7c88.js +1 -0
- package/assets/esri/core/workers/chunks/63d8d507f073a8ed42d2.js +1 -0
- package/assets/esri/core/workers/chunks/70574e0e3de729187d98.js +1 -0
- package/assets/esri/core/workers/chunks/78c066e8fe167d4ab817.js +1 -0
- package/assets/esri/core/workers/chunks/875a200f215e472d147e.js +1 -0
- package/assets/esri/core/workers/chunks/{f976233ad5e5b718ba83.js → 8d1f49927738ad3601d2.js} +1 -1
- package/assets/esri/core/workers/chunks/9050dad7e4f093568026.js +1 -0
- package/assets/esri/core/workers/chunks/930544d3b2c1d9c035c7.js +1 -0
- package/assets/esri/core/workers/chunks/{962cad03be1b7aa52ebe.js → 95835a62712fe4f24205.js} +1 -1
- package/assets/esri/core/workers/chunks/{030384851fa745908a6e.js → 9dbdb88cdac993104740.js} +2 -2
- package/assets/esri/core/workers/chunks/{ac11b2168feee63d2f09.js → b7c6d0ff4c085c8d0596.js} +1 -1
- package/assets/esri/core/workers/chunks/e0cd4815149d1ff4d31e.js +1 -0
- package/assets/esri/core/workers/chunks/{0a82c13828ffd4780419.js → f51fc2370fb486233499.js} +1 -1
- package/assets/esri/core/workers/chunks/fcbe65256a71b34ac9cf.js +1 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +4 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ColorMaterial.glsl.js +1 -1
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/ImageMaterial.glsl.js +3 -3
- package/chunks/LineMarker.glsl.js +11 -11
- package/chunks/NativeLine.glsl.js +1 -1
- package/chunks/Path.glsl.js +11 -11
- package/chunks/Pattern.glsl.js +2 -2
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/RibbonLine.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +1 -1
- package/chunks/WaterSurface.glsl.js +9 -9
- package/editing/sharedTemplates/SharedTemplate.js +1 -1
- package/editing/sharedTemplates/SharedTemplateMetadata.js +1 -1
- package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
- package/editing/sharedTemplates/executor/support/createServiceEdit.js +1 -1
- package/editing/sharedTemplates/support/sharedTemplateErrors.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/FeatureTemplateDefinition.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/parts/FeatureTemplateRelationshipPart.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/parts/GroupTemplatePart.js +1 -1
- package/editing/sharedTemplates/templateDefinitions/parts/TemplatePartBase.js +1 -1
- package/interfaces.d.ts +112 -22
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/mixins/RasterJobHandlerMixin.js +5 -0
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/support/Relationship.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/undoredo/support/Services.js +1 -1
- package/views/2d/AnimationManager.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
- package/views/View.js +1 -1
- package/views/animation/easing.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/components/Prompt.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/symbols.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/support/FilterCondition.js +1 -1
- package/widgets/support/GoTo.js +1 -1
- package/widgets/support/goToUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0c85731e9bf3eaeb96a2.js +0 -1
- package/assets/esri/core/workers/chunks/1b36d4400ab841c978c8.js +0 -1
- package/assets/esri/core/workers/chunks/3c44b4bf7fe407ec1d70.js +0 -1
- package/assets/esri/core/workers/chunks/4e3e141b3fd8bb652798.js +0 -1
- package/assets/esri/core/workers/chunks/717d7e9912d948e44d8d.js +0 -1
- package/assets/esri/core/workers/chunks/7bf9ebff90bb02bec8e7.js +0 -1
- package/assets/esri/core/workers/chunks/905cf2bb280479cd4f80.js +0 -1
- package/assets/esri/core/workers/chunks/b8fae500c69ca2cff62a.js +0 -1
- package/assets/esri/core/workers/chunks/b90b7ffc1e9363ed18e0.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{sampleVectorField as o}from"../../../../layers/support/rasterFunctions/vectorFieldUtils.js";import{RasterVFTileContainer as s}from"../../engine/imagery/RasterVFTileContainer.js";import{BaseImageryTileSubView2D as l}from"./BaseImageryTileSubView2D.js";let a=class extends l{constructor(){super(...arguments),this._handle=null,this.type="rasterVF"}canUseWebGLForProcessing(){return!1}async fetchTile(e,t){t={...t,interpolation:"nearest",requestProjectedLocalDirections:!0};const i=await this.layer.fetchTile(e.level,e.row,e.col,t);return"vector-magdir"===this.layer.serviceRasterInfo?.dataType&&i?.pixelBlock&&(i.pixelBlock=await this.layer.convertVectorFieldData(i.pixelBlock,t)),i}updateTileSource(e,t){const i=t.symbolizerParams,{tileData:r}=e;r.key=e.key,r.width=this._tileInfoView.tileInfo.size[0],r.height=this._tileInfoView.tileInfo.size[1];const{symbolTileSize:o}=i,{source:s}=t;if(r.offset=this._getTileSymbolOffset(r.key,o),null!=s?.pixelBlock){const e={extent:s.extent,pixelBlock:s.pixelBlock};r.rawPixelData=e,r.symbolizerParameters=i,r.source=this._sampleVectorFieldData(s.pixelBlock,i,r.offset)}else{const e=[Math.round((this._tileInfoView.tileInfo.size[0]-r.offset[0])/o),Math.round((this._tileInfoView.tileInfo.size[1]-r.offset[1])/o)],t=this.createEmptyTilePixelBlock(e);r.source=t,r.symbolizerParameters=i}return r.invalidateVAO(),Promise.resolve()}updateTileSymbolizerParameters(e,t){const i=t.local,{symbolTileSize:r}=i,{tileData:o}=e;o.offset=this._getTileSymbolOffset(o.key,r);const s=o.symbolizerParameters.symbolTileSize;o.symbolizerParameters=i;const l=o.rawPixelData?.pixelBlock;return null!=l&&s!==r&&(o.source=this._sampleVectorFieldData(l,o.symbolizerParameters,o.offset)),Promise.resolve()}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this._updateSymbolType(this.layer.renderer),this._handle=t((()=>this.layer.renderer),(e=>this._updateSymbolType(e)))}detach(){super.detach(),this.container.removeAllChildren(),this._handle?.remove(),this._handle=null,this.container=null}_getTileSymbolOffset(e,t){const i=e.col*this._tileInfoView.tileInfo.size[0]%t,r=e.row*this._tileInfoView.tileInfo.size[1]%t;return[i>t/2?t-i:-i,r>t/2?t-r:-r]}_sampleVectorFieldData(e,t,i){const{symbolTileSize:r}=t;return o(e,"vector-uv",r,i)}_updateSymbolType(e){"vector-field"===e?.type&&(this.container.symbolTypes="wind-barb"===e.style?["scalar","triangle"]:"simple-scalar"===e.style?["scalar"]:["triangle"])}};e([i()],a.prototype,"container",void 0),e([i()],a.prototype,"layer",void 0),e([i()],a.prototype,"type",void 0),a=e([r("esri.views.2d.layers.imagery.VectorFieldTileView2D")],a);const n=a;export{n as default};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{sampleVectorField as o}from"../../../../layers/support/rasterFunctions/vectorFieldUtils.js";import{RasterVFTileContainer as s}from"../../engine/imagery/RasterVFTileContainer.js";import{BaseImageryTileSubView2D as l}from"./BaseImageryTileSubView2D.js";let a=class extends l{constructor(){super(...arguments),this._handle=null,this.type="rasterVF"}canUseWebGLForProcessing(){return!1}async fetchTile(e,t){t={...t,interpolation:"nearest",requestProjectedLocalDirections:!0};const i=await this.layer.fetchTile(e.level,e.row,e.col,t);return"vector-magdir"===this.layer.serviceRasterInfo?.dataType&&i?.pixelBlock&&(i.pixelBlock=await this.layer.convertVectorFieldData(i.pixelBlock,"vector-magdir",t)),i}updateTileSource(e,t){const i=t.symbolizerParams,{tileData:r}=e;r.key=e.key,r.width=this._tileInfoView.tileInfo.size[0],r.height=this._tileInfoView.tileInfo.size[1];const{symbolTileSize:o}=i,{source:s}=t;if(r.offset=this._getTileSymbolOffset(r.key,o),null!=s?.pixelBlock){const e={extent:s.extent,pixelBlock:s.pixelBlock};r.rawPixelData=e,r.symbolizerParameters=i,r.source=this._sampleVectorFieldData(s.pixelBlock,i,r.offset)}else{const e=[Math.round((this._tileInfoView.tileInfo.size[0]-r.offset[0])/o),Math.round((this._tileInfoView.tileInfo.size[1]-r.offset[1])/o)],t=this.createEmptyTilePixelBlock(e);r.source=t,r.symbolizerParameters=i}return r.invalidateVAO(),Promise.resolve()}updateTileSymbolizerParameters(e,t){const i=t.local,{symbolTileSize:r}=i,{tileData:o}=e;o.offset=this._getTileSymbolOffset(o.key,r);const s=o.symbolizerParameters.symbolTileSize;o.symbolizerParameters=i;const l=o.rawPixelData?.pixelBlock;return null!=l&&s!==r&&(o.source=this._sampleVectorFieldData(l,o.symbolizerParameters,o.offset)),Promise.resolve()}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this._updateSymbolType(this.layer.renderer),this._handle=t((()=>this.layer.renderer),(e=>this._updateSymbolType(e)))}detach(){super.detach(),this.container.removeAllChildren(),this._handle?.remove(),this._handle=null,this.container=null}_getTileSymbolOffset(e,t){const i=e.col*this._tileInfoView.tileInfo.size[0]%t,r=e.row*this._tileInfoView.tileInfo.size[1]%t;return[i>t/2?t-i:-i,r>t/2?t-r:-r]}_sampleVectorFieldData(e,t,i){const{symbolTileSize:r}=t;return o(e,"vector-uv",r,i)}_updateSymbolType(e){"vector-field"===e?.type&&(this.container.symbolTypes="wind-barb"===e.style?["scalar","triangle"]:"simple-scalar"===e.style?["scalar"]:["triangle"])}};e([i()],a.prototype,"container",void 0),e([i()],a.prototype,"layer",void 0),e([i()],a.prototype,"type",void 0),a=e([r("esri.views.2d.layers.imagery.VectorFieldTileView2D")],a);const n=a;export{n as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Graphic.js";import r from"../../../../request.js";import i from"../../../../core/Accessor.js";import s from"../../../../core/Logger.js";import{isAbortError as a}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Graphic.js";import r from"../../../../request.js";import i from"../../../../core/Accessor.js";import s from"../../../../core/Logger.js";import{isAbortError as a}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import m from"../../../../geometry/Extent.js";import{srToRESTValue as p}from"../../../../geometry/support/spatialReferenceUtils.js";import{projectExtent as h}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{snapImageToSymbolTile as y}from"../../../../layers/support/rasterFunctions/vectorFieldUtils.js";import{RasterVFContainer as u}from"../../engine/imagery/RasterVFContainer.js";import d from"./ImageryVFStrategy.js";let x=class extends i{constructor(){super(...arguments),this.attached=!1,this.container=new u,this.type="imageryVF",this._dataParameters={exportParametersVersion:0,bbox:"",symbolTileSize:0,time:""},this._fetchpixels=async(t,e,r,i)=>{const s=await this._projectFullExtentPromise,{layer:a}=this,{symbolTileSize:o}=a.renderer,{extent:n,width:l,height:c}=y(t,e,r,o,s);if(null!=s&&!s.intersects(t))return{extent:n,pixelBlock:null};const m={bbox:`${n.xmin}, ${n.ymin}, ${n.xmax}, ${n.ymax}`,exportParametersVersion:a.exportImageServiceParameters.version,symbolTileSize:o,time:JSON.stringify(this.timeExtent||"")};if(this._canReuseVectorFieldData(m)){const t=this.getPixelData();if(null!=t){if(`${t.extent.xmin}, ${t.extent.ymin}, ${t.extent.xmax}, ${t.extent.ymax}`===m.bbox)return t}}const{pixelData:p}=await a.fetchImage(n,l,c,{timeExtent:this.timeExtent,requestAsImageElement:!1,signal:i});this._dataParameters=m;const h=p?.pixelBlock;if(null==h)return{extent:n,pixelBlock:null};const{dataType:u}=a.rasterInfo;return{extent:n,pixelBlock:"vector-uv"===u&&h?await a.convertVectorFieldData(h,"vector-uv",{signal:i}):h}}}get updating(){return!this.attached||this._strategy.updating}attach(){this._projectFullExtentPromise=this._getProjectedFullExtent(this.view.spatialReference),this._strategy=new d({container:this.container,fetchPixels:this._fetchpixels}),this.addHandles(o((()=>this.layer.renderer),(t=>this._updateSymbolizerParams(t)),n),"attach")}detach(){this._strategy.destroy(),this.container.children.forEach((t=>t.destroy())),this.container.removeAllChildren(),this.removeHandles("attach"),this._strategy=this.container=this._projectFullExtentPromise=null}getPixelData(){const t=this.container.children[0]?.rawPixelData;if(this.updating||!t)return null;const{extent:e,pixelBlock:r}=t;return{extent:e,pixelBlock:r}}hitTest(t){return new e({attributes:{},geometry:t.clone(),layer:this.layer})}update(t){this._strategy.update(t,this._symbolizerParams).catch((t=>{a(t)||s.getLogger(this).error(t)}))}redraw(){const{renderer:t}=this.layer;t&&(this._updateSymbolizerParams(t),this._strategy.redraw(this._symbolizerParams))}_canReuseVectorFieldData(t){const e=this._dataParameters.exportParametersVersion===t.exportParametersVersion,r=this._dataParameters.time===t.time,i=this._dataParameters.symbolTileSize===t.symbolTileSize,s=this._dataParameters.bbox===t.bbox;return e&&r&&i&&s}async _getProjectedFullExtent(t){try{return h(this.layer.fullExtent,t)}catch(e){try{const e=(await r(this.layer.url,{query:{option:"footprints",outSR:p(t),f:"json"}})).data.featureCollection.layers[0].layerDefinition.extent;return e?m.fromJSON(e):null}catch{return null}}}_updateSymbolizerParams(t){"vector-field"===t?.type&&(this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null}))}};t([l()],x.prototype,"attached",void 0),t([l()],x.prototype,"container",void 0),t([l()],x.prototype,"layer",void 0),t([l()],x.prototype,"timeExtent",void 0),t([l()],x.prototype,"type",void 0),t([l()],x.prototype,"view",void 0),t([l()],x.prototype,"updating",null),x=t([c("esri.views.2d.layers.imagery.VectorFieldView2D")],x);const f=x;export{f as default};
|
package/views/View.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../core/Accessor.js";import{createTask as r}from"../core/asyncUtils.js";import a from"../core/Collection.js";import s from"../core/CollectionFlattener.js";import o from"../core/Error.js";import n from"../core/Evented.js";import l from"../core/Handles.js";import has from"../core/has.js";import p from"../core/Loadable.js";import d from"../core/Logger.js";import{destroyMaybe as h,abortMaybe as y}from"../core/maybe.js";import u from"../core/Promise.js";import{after as m}from"../core/promiseUtils.js";import{watch as c,whenOnce as g,when as f,sync as w,syncAndInitial as v}from"../core/reactiveUtils.js";import{property as M}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as _}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as V}from"../core/support/OwningCollection.js";import{UpdatingHandles as R}from"../core/support/UpdatingHandles.js";import S from"../geometry/Extent.js";import j from"../geometry/HeightModelInfo.js";import T from"../geometry/SpatialReference.js";import{equals as E}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as F}from"../support/AnalysesCollection.js";import{GraphicsCollection as k}from"../support/GraphicsCollection.js";import x from"../time/TimeExtent.js";import{system as b,isTimeZoneValid as O}from"../time/timeZoneUtils.js";import L from"./BasemapView.js";import C from"./LayerViewManager.js";import Z from"./Magnifier.js";import I from"./SelectionManager.js";import H from"./Theme.js";import{ToolViewManager as W}from"./ToolViewManager.js";import{makeDefaultHighlightOptions as D}from"./3d/support/DefaultHighlights.js";import q from"./input/Input.js";import{ViewEvents as P}from"./input/ViewEvents.js";import A from"./navigation/Navigation.js";import{DefaultsFromMap as U}from"./support/DefaultsFromMap.js";import z from"./support/HighlightOptions.js";import G from"./support/RequiredFieldsOptions.js";var N;let $=class extends(n.EventedMixin(u.EsriPromiseMixin(i))){static{N=this}constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.handles=new l,this.updatingHandles=new R,this.highlights=D(),this.allLayerViews=new s({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:K}),this.groundView=null,this.basemapView=null,this.displayFilterEnabled=!0,this.fatalError=null,this.graphics=new k,this.analyses=new F,this.typeSpecificPreconditionsReady=!0,this.layerViews=new a,this.magnifier=new Z,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this._readyStateWaitingTask=null,this.supportsGround=!0,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new q,this.navigation=new A,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new P(this),this.persistableViewModels=new a,this.requiredFieldsOptions=new G,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this._userTimeExtent=null,this._lockedTimeExtent=null,this.theme=null,this.handles.add(c((()=>this.preconditionsReady),(e=>{const t=this.ready;if(e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,this._lockedTimeExtent=this.timeExtent,N.views.add(this)):(this._lockedSpatialReference=null,N.views.remove(this)),this.notifyChange("spatialReference"),!e&&t)this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!t){try{this._startup()}catch(i){return void queueMicrotask((()=>{this.fatalError=new o("startup-error",null,i)}))}null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach()}}),w))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then((()=>(this._isValid=!0,g((()=>this.ready)))))),this.basemapView=new L({view:this}),this.layerViewManager=new C({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new W({view:this}),this.selectionManager=new I({view:this}),this.addHandles([f((()=>"map-content-error"===this.readyState&&!this.spatialReference),(()=>{d.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),c((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),v),c((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),w),c((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),v)])}destroy(){this.destroyed||(N.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=h(this.graphics),this.analyses=h(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),h(this.analysisViewManager),this.toolViewManager=h(this.toolViewManager),this.layerViewManager=h(this.layerViewManager),this.selectionManager=h(this.selectionManager),this.basemapView=h(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach((e=>e.destroy())),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.destroy(),this.map=h(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return d.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new U({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(e,t)=>this.getSpatialReferenceSupport(e,t),...this.defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||p.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(d.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),p.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get readyState(){if(this.destroyed)return this._get("readyState");if(!this.map)return"missing-map";if("container"in this&&!this.container)return"missing-container";if(this.fatalError)return"rendering-error";if((this.defaultsFromMap?.ready??!1)&&!this.spatialReference){const e=!("loaded"in this.map)||this.map.loaded,t=this.map.ground.loaded,i=this.map.basemap?.loaded??!0;return e&&i&&t&&!this.map?.allLayers.length?"empty-map":(this._readyStateWaitingTask||(this._readyStateWaitingTask=r((e=>m(has("view-readyState-waiting-delay"),null,e))),this.addHandles(this._readyStateWaitingTask),this.addHandles(this._readyStateWaitingTask,"ready-state-task")),this._readyStateWaitingTask?.finished?"map-content-error":"loading")}return this._readyStateWaitingTask=y(this._readyStateWaitingTask),this.removeHandles("ready-state-task"),this.ready?"ready":"loading"}get spatialReference(){const e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;if(e&&this.defaultsFromMap?.required?.heightModelInfo){const t=e.clone();return t.vcsWkid=this.defaultsFromMap.vcsWkid,t.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,t}return e}set spatialReference(e){const t=!E(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeExtent(){return this._userTimeExtent??this._lockedTimeExtent??this.getDefaultTimeExtent()??null}set timeExtent(e){this._userTimeExtent=e}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??b}set timeZone(e){this._userTimeZone=e,O(e)||d.getLogger(this).warn("#timeZone",`the parsed value '${e}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._cursor??"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new H}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}getDefaultTimeExtent(){return null}importLayerView(e){throw new o("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport(e)}when(e,t){return this.isResolved()&&!this.ready&&d.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(f((()=>this.destroyed||!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}static{this.views=new a}};e([M()],$.prototype,"_userSpatialReference",void 0),e([M({type:a.ofType(z)})],$.prototype,"highlights",void 0),e([M()],$.prototype,"activeTool",null),e([M({readOnly:!0})],$.prototype,"allLayerViews",void 0),e([M()],$.prototype,"groundView",void 0),e([M()],$.prototype,"animation",null),e([M()],$.prototype,"basemapView",void 0),e([M()],$.prototype,"center",null),e([M()],$.prototype,"defaultsFromMapSettings",null),e([M()],$.prototype,"defaultsFromMap",null),e([M()],$.prototype,"displayFilterEnabled",void 0),e([M()],$.prototype,"fatalError",void 0),e([M({type:S})],$.prototype,"extent",null),e([M(V(k,"graphics"))],$.prototype,"graphics",void 0),e([M(V(F,"analyses"))],$.prototype,"analyses",void 0),e([M({readOnly:!0,type:j})],$.prototype,"heightModelInfo",null),e([M({readOnly:!0})],$.prototype,"interacting",null),e([M({readOnly:!0})],$.prototype,"navigating",null),e([M({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],$.prototype,"preconditionsReady",null),e([M({readOnly:!0})],$.prototype,"typeSpecificPreconditionsReady",void 0),e([M({type:a,readOnly:!0})],$.prototype,"layerViews",void 0),e([M()],$.prototype,"resolution",null),e([M({type:Z})],$.prototype,"magnifier",void 0),e([M({value:null,type:t})],$.prototype,"map",null),e([M()],$.prototype,"padding",void 0),e([M({readOnly:!0})],$.prototype,"ready",void 0),e([M()],$.prototype,"_readyStateWaitingTask",void 0),e([M({readOnly:!0})],$.prototype,"readyState",null),e([M({type:T})],$.prototype,"spatialReference",null),e([M()],$.prototype,"stationary",null),e([M({readOnly:!0})],$.prototype,"supportsGround",void 0),e([M({type:x})],$.prototype,"timeExtent",null),e([M({type:String,nonNullable:!0})],$.prototype,"timeZone",null),e([M()],$.prototype,"tools",null),e([M()],$.prototype,"toolViewManager",void 0),e([M({readOnly:!0})],$.prototype,"type",void 0),e([M({type:Number})],$.prototype,"scale",void 0),e([M({readOnly:!0})],$.prototype,"updating",void 0),e([M({readOnly:!0})],$.prototype,"initialExtentRequired",void 0),e([M({readOnly:!0})],$.prototype,"initialExtent",null),e([M()],$.prototype,"cursor",null),e([M({readOnly:!0})],$.prototype,"input",void 0),e([M({type:A,nonNullable:!0})],$.prototype,"navigation",void 0),e([M()],$.prototype,"layerViewManager",void 0),e([M()],$.prototype,"analysisViewManager",void 0),e([M()],$.prototype,"selectionManager",void 0),e([M()],$.prototype,"width",void 0),e([M()],$.prototype,"height",void 0),e([M({readOnly:!0})],$.prototype,"resizing",void 0),e([M({value:null,readOnly:!0})],$.prototype,"size",null),e([M({readOnly:!0})],$.prototype,"suspended",void 0),e([M({readOnly:!0})],$.prototype,"viewEvents",void 0),e([M({readOnly:!0})],$.prototype,"persistableViewModels",void 0),e([M()],$.prototype,"_isValid",void 0),e([M()],$.prototype,"_readyCycleForced",void 0),e([M()],$.prototype,"_lockedSpatialReference",void 0),e([M()],$.prototype,"_userTimeZone",void 0),e([M()],$.prototype,"_lockedTimeZone",void 0),e([M()],$.prototype,"_userTimeExtent",void 0),e([M()],$.prototype,"_lockedTimeExtent",void 0),e([M({type:H})],$.prototype,"theme",void 0),e([M({readOnly:!0,type:H})],$.prototype,"effectiveTheme",null),$=N=e([_("esri.views.View")],$);const B=globalThis.$arcgis;B&&!B.views&&Object.defineProperty(B,"views",{configurable:!1,enumerable:!0,writable:!1,value:$.views});const J=$;function K(e){return e.layerViews}export{J as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../core/Accessor.js";import{createTask as r}from"../core/asyncUtils.js";import s from"../core/Collection.js";import a from"../core/CollectionFlattener.js";import{referenceSetter as o}from"../core/collectionUtils.js";import n from"../core/Error.js";import l from"../core/Evented.js";import p from"../core/Handles.js";import has from"../core/has.js";import h from"../core/Loadable.js";import d from"../core/Logger.js";import{destroyMaybe as y,abortMaybe as u}from"../core/maybe.js";import m from"../core/Promise.js";import{after as c}from"../core/promiseUtils.js";import{watch as g,whenOnce as f,when as w,sync as v,syncAndInitial as _}from"../core/reactiveUtils.js";import{property as M}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as V}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as R}from"../core/support/OwningCollection.js";import{UpdatingHandles as S}from"../core/support/UpdatingHandles.js";import j from"../geometry/Extent.js";import T from"../geometry/HeightModelInfo.js";import E from"../geometry/SpatialReference.js";import{equals as F}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as k}from"../support/AnalysesCollection.js";import{GraphicsCollection as x}from"../support/GraphicsCollection.js";import b from"../time/TimeExtent.js";import{system as O,isTimeZoneValid as L}from"../time/timeZoneUtils.js";import C from"./BasemapView.js";import Z from"./LayerViewManager.js";import I from"./Magnifier.js";import H from"./SelectionManager.js";import W from"./Theme.js";import{ToolViewManager as D}from"./ToolViewManager.js";import{makeDefaultHighlightOptions as q}from"./3d/support/DefaultHighlights.js";import P from"./input/Input.js";import{ViewEvents as U}from"./input/ViewEvents.js";import A from"./navigation/Navigation.js";import{DefaultsFromMap as z}from"./support/DefaultsFromMap.js";import G from"./support/HighlightOptions.js";import N from"./support/RequiredFieldsOptions.js";var $;let B=class extends(l.EventedMixin(m.EsriPromiseMixin(i))){static{$=this}constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.handles=new p,this.updatingHandles=new S,this.allLayerViews=new a({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:Q}),this.groundView=null,this.basemapView=null,this.displayFilterEnabled=!0,this.fatalError=null,this.graphics=new x,this.analyses=new k,this.typeSpecificPreconditionsReady=!0,this.layerViews=new s,this.magnifier=new I,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this._readyStateWaitingTask=null,this.supportsGround=!0,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new P,this.navigation=new A,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new U(this),this.persistableViewModels=new s,this.requiredFieldsOptions=new N,this._isValid=!1,this._readyCycleForced=!1,this._lockedSpatialReference=null,this._userTimeZone=null,this._lockedTimeZone=null,this._userTimeExtent=null,this._lockedTimeExtent=null,this.theme=null,this.handles.add(g((()=>this.preconditionsReady),(e=>{const t=this.ready;if(e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,this._lockedTimeExtent=this.timeExtent,$.views.add(this)):(this._lockedSpatialReference=null,$.views.remove(this)),this.notifyChange("spatialReference"),!e&&t)this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!t){try{this._startup()}catch(i){return void queueMicrotask((()=>{this.fatalError=new n("startup-error",null,i)}))}null!=this.analysisViewManager&&this.analysisViewManager.attach(),this.toolViewManager.attach()}}),v))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(),this.validate()]).then((()=>(this._isValid=!0,f((()=>this.ready)))))),this.basemapView=new C({view:this}),this.layerViewManager=new Z({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new D({view:this}),this.selectionManager=new H({view:this}),this.addHandles([w((()=>"map-content-error"===this.readyState&&!this.spatialReference),(()=>{d.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),g((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),_),g((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),v),g((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),_)])}destroy(){this.destroyed||($.views.remove(this),this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=y(this.graphics),this.analyses=y(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),y(this.analysisViewManager),this.toolViewManager=y(this.toolViewManager),this.layerViewManager=y(this.layerViewManager),this.selectionManager=y(this.selectionManager),this.basemapView=y(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach((e=>e.destroy())),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.destroy(),this.map=y(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return d.getLogger(this).error("#toMap()","Not implemented on this instance of View"),null}get highlights(){return this._get("highlights")??q()}set highlights(e){this._set("highlights",o(e,this._get("highlights")))}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get center(){return null}get defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new z({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(e,t)=>this.getSpatialReferenceSupport(e,t),...this.defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||h.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(e){e!==this._get("map")&&(e?.destroyed&&(d.getLogger(this).warn("#map","The provided map is already destroyed",{map:e}),e=null),h.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",e))}get readyState(){if(this.destroyed)return this._get("readyState");if(!this.map)return"missing-map";if("container"in this&&!this.container)return"missing-container";if(this.fatalError)return"rendering-error";if((this.defaultsFromMap?.ready??!1)&&!this.spatialReference){const e=!("loaded"in this.map)||this.map.loaded,t=this.map.ground.loaded,i=this.map.basemap?.loaded??!0;return e&&i&&t&&!this.map?.allLayers.length?"empty-map":(this._readyStateWaitingTask||(this._readyStateWaitingTask=r((e=>c(has("view-readyState-waiting-delay"),null,e))),this.addHandles(this._readyStateWaitingTask),this.addHandles(this._readyStateWaitingTask,"ready-state-task")),this._readyStateWaitingTask?.finished?"map-content-error":"loading")}return this._readyStateWaitingTask=u(this._readyStateWaitingTask),this.removeHandles("ready-state-task"),this.ready?"ready":"loading"}get spatialReference(){const e=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;if(e&&this.defaultsFromMap?.required?.heightModelInfo){const t=e.clone();return t.vcsWkid=this.defaultsFromMap.vcsWkid,t.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,t}return e}set spatialReference(e){const t=!F(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeExtent(){return this._userTimeExtent??this._lockedTimeExtent??this.getDefaultTimeExtent()??null}set timeExtent(e){this._userTimeExtent=e}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??O}set timeZone(e){this._userTimeZone=e,L(e)||d.getLogger(this).warn("#timeZone",`the parsed value '${e}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._cursor??"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new W}whenLayerView(e){return this.layerViewManager?.whenLayerView(e)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}getDefaultTimeExtent(){return null}importLayerView(e){throw new n("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return null!=this.getSpatialReferenceSupport(e)}when(e,t){return this.isResolved()&&!this.ready&&d.getLogger(this).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(w((()=>this.destroyed||!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}static{this.views=new s}};e([M()],B.prototype,"_userSpatialReference",void 0),e([M({type:s.ofType(G)})],B.prototype,"highlights",null),e([M()],B.prototype,"activeTool",null),e([M({readOnly:!0})],B.prototype,"allLayerViews",void 0),e([M()],B.prototype,"groundView",void 0),e([M()],B.prototype,"animation",null),e([M()],B.prototype,"basemapView",void 0),e([M()],B.prototype,"center",null),e([M()],B.prototype,"defaultsFromMapSettings",null),e([M()],B.prototype,"defaultsFromMap",null),e([M()],B.prototype,"displayFilterEnabled",void 0),e([M()],B.prototype,"fatalError",void 0),e([M({type:j})],B.prototype,"extent",null),e([M(R(x,"graphics"))],B.prototype,"graphics",void 0),e([M(R(k,"analyses"))],B.prototype,"analyses",void 0),e([M({readOnly:!0,type:T})],B.prototype,"heightModelInfo",null),e([M({readOnly:!0})],B.prototype,"interacting",null),e([M({readOnly:!0})],B.prototype,"navigating",null),e([M({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_lockedSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],B.prototype,"preconditionsReady",null),e([M({readOnly:!0})],B.prototype,"typeSpecificPreconditionsReady",void 0),e([M({type:s,readOnly:!0})],B.prototype,"layerViews",void 0),e([M()],B.prototype,"resolution",null),e([M({type:I})],B.prototype,"magnifier",void 0),e([M({value:null,type:t})],B.prototype,"map",null),e([M()],B.prototype,"padding",void 0),e([M({readOnly:!0})],B.prototype,"ready",void 0),e([M()],B.prototype,"_readyStateWaitingTask",void 0),e([M({readOnly:!0})],B.prototype,"readyState",null),e([M({type:E})],B.prototype,"spatialReference",null),e([M()],B.prototype,"stationary",null),e([M({readOnly:!0})],B.prototype,"supportsGround",void 0),e([M({type:b})],B.prototype,"timeExtent",null),e([M({type:String,nonNullable:!0})],B.prototype,"timeZone",null),e([M()],B.prototype,"tools",null),e([M()],B.prototype,"toolViewManager",void 0),e([M({readOnly:!0})],B.prototype,"type",void 0),e([M({type:Number})],B.prototype,"scale",void 0),e([M({readOnly:!0})],B.prototype,"updating",void 0),e([M({readOnly:!0})],B.prototype,"initialExtentRequired",void 0),e([M({readOnly:!0})],B.prototype,"initialExtent",null),e([M()],B.prototype,"cursor",null),e([M({readOnly:!0})],B.prototype,"input",void 0),e([M({type:A,nonNullable:!0})],B.prototype,"navigation",void 0),e([M()],B.prototype,"layerViewManager",void 0),e([M()],B.prototype,"analysisViewManager",void 0),e([M()],B.prototype,"selectionManager",void 0),e([M()],B.prototype,"width",void 0),e([M()],B.prototype,"height",void 0),e([M({readOnly:!0})],B.prototype,"resizing",void 0),e([M({value:null,readOnly:!0})],B.prototype,"size",null),e([M({readOnly:!0})],B.prototype,"suspended",void 0),e([M({readOnly:!0})],B.prototype,"viewEvents",void 0),e([M({readOnly:!0})],B.prototype,"persistableViewModels",void 0),e([M()],B.prototype,"_isValid",void 0),e([M()],B.prototype,"_readyCycleForced",void 0),e([M()],B.prototype,"_lockedSpatialReference",void 0),e([M()],B.prototype,"_userTimeZone",void 0),e([M()],B.prototype,"_lockedTimeZone",void 0),e([M()],B.prototype,"_userTimeExtent",void 0),e([M()],B.prototype,"_lockedTimeExtent",void 0),e([M({type:W})],B.prototype,"theme",void 0),e([M({readOnly:!0,type:W})],B.prototype,"effectiveTheme",null),B=$=e([V("esri.views.View")],B);const J=globalThis.$arcgis;J&&!J.views&&Object.defineProperty(J,"views",{configurable:!1,enumerable:!0,writable:!1,value:B.views});const K=B;function Q(e){return e.layerViews}export{K as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
import{easingFunctions as t}from"../2d/unitBezier.js";const u=t=>t,i=t=>t*t,o=t=>1-i(1-t),n=t=>t<.5?i(2*t)/2:(o(2*(t-.5))+1)/2,a=t=>t*t*t,c=t=>1-a(1-t),s=t=>t<.5?a(2*t)/2:(c(2*(t-.5))+1)/2,e=t=>t*t*t*t,q=t=>1-e(1-t),r=t=>t<.5?e(2*t)/2:(q(2*(t-.5))+1)/2,d=t=>t*t*t*t*t,b=t=>1-d(1-t),p=t=>t<.5?d(2*t)/2:(b(2*(t-.5))+1)/2,h=t=>1-Math.cos(t*Math.PI/2),x=t=>1-h(1-t),M=t=>t<.5?h(2*t)/2:(x(2*(t-.5))+1)/2,f=t=>2**(10*(t-1)),I=t=>1-f(1-t),m=t=>t<.5?f(2*t)/2:(I(2*(t-.5))+1)/2,O=t=>-(Math.sqrt(1-t*t)-1),j=t=>1-O(1-t),l=t=>t<.5?O(2*t)/2:(j(2*(t-.5))+1)/2;function z(t){const u=2*(t-Math.sqrt((t-1)*t)),i=u/2/t;return o=>o<i?t*o*o:u*o-u+1}function B(t,u){return(i,o)=>i<u?u*t(i/u,o):1-t((1-i)/(1-u),o)*(1-u)}const P=B(z(1),1),g=B(z(1),0),k=B(z(1),.5),v=B(z(2),1),w=B(z(2),0),y=B(z(2),.5),A=B(z(3),1),C=B(z(3),0),D=B(z(3),.5),E=B(z(4),1),F=B(z(4),0),G=B(z(4),.5),H={linear:u,"in-quad":i,"out-quad":o,"in-out-quad":n,"in-coast-quad":P,"out-coast-quad":g,"in-out-coast-quad":k,"in-cubic":a,"out-cubic":c,"in-out-cubic":s,"in-coast-cubic":v,"out-coast-cubic":w,"in-out-coast-cubic":y,"in-quart":e,"out-quart":q,"in-out-quart":r,"in-coast-quart":A,"out-coast-quart":C,"in-out-coast-quart":D,"in-quint":d,"out-quint":b,"in-out-quint":p,"in-coast-quint":E,"out-coast-quint":F,"in-out-coast-quint":G,"in-sine":h,"out-sine":x,"in-out-sine":M,"in-expo":f,"out-expo":I,"in-out-expo":m,"in-circ":O,"out-circ":j,"in-out-circ":l,ease:u=>t.ease(u),"ease-in":u=>t.easeIn(u),"ease-out":u=>t.easeOut(u),"ease-in-out":u=>t.easeInOut(u)};export{H as EasingFunctions,O as inCirc,v as inCoastCubic,P as inCoastQuad,A as inCoastQuart,E as inCoastQuint,a as inCubic,f as inExpo,l as inOutCirc,y as inOutCoastCubic,k as inOutCoastQuad,D as inOutCoastQuart,G as inOutCoastQuint,s as inOutCubic,m as inOutExpo,n as inOutQuad,r as inOutQuart,p as inOutQuint,M as inOutSine,i as inQuad,e as inQuart,d as inQuint,h as inSine,u as linear,j as outCirc,w as outCoastCubic,g as outCoastQuad,C as outCoastQuart,F as outCoastQuint,c as outCubic,I as outExpo,o as outQuad,q as outQuart,b as outQuint,x as outSine};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import"../../core/has.js";import t from"../../core/Logger.js";import{BindType as r}from"./BindType.js";const n=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class s{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class i extends s{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.outputs=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!1){const r=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,o=i.uniforms.generateSource(),a=i.code.generateSource(),c=i.main.generateSource(t),u="vertex"===e?f:g,h=i.constants.generateSource(),m=this.outputs.generateSource(e);return`#version 300 es\n${r.join("\n")}\n${u}\n${h.join("\n")}\n${o.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${m.join("\n")}\n${a.join("\n")}\n${c.join("\n")}`}generateBind(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return t=>{for(let r=0;r<s;++r)n[r](e,t)}}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let o=0;o<s;++o)n[o](e,i,t,r)}}}class o{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else n().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class a{constructor(e){this._stage=e,this._bodies=new Array}add(e){return this._bodies.push(e),this._stage}generateSource(t){if(this._bodies.length>0)return[`void main() {\n ${this._bodies.join("\n")||""} \n}`];if(t)throw new e("Shader does not contain main function body.");return[]}}class c{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class u extends s{constructor(){super(...arguments),this.uniforms=new o(this),this.main=new a(this),this.code=new c(this),this.constants=new l(this)}get builder(){return this}}class h{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class m{constructor(){this._entries=new Map}add(e,t){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,t)}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push("vertex"===e
|
|
5
|
+
import e from"../../core/Error.js";import"../../core/has.js";import t from"../../core/Logger.js";import{BindType as r}from"./BindType.js";const n=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class s{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class i extends s{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.outputs=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!1){const r=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,o=i.uniforms.generateSource(),a=i.code.generateSource(),c=i.main.generateSource(t),u="vertex"===e?f:g,h=i.constants.generateSource(),m=this.outputs.generateSource(e);return`#version 300 es\n${r.join("\n")}\n${u}\n${h.join("\n")}\n${o.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${m.join("\n")}\n${a.join("\n")}\n${c.join("\n")}`}generateBind(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return t=>{for(let r=0;r<s;++r)n[r](e,t)}}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let o=0;o<s;++o)n[o](e,i,t,r)}}}class o{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else n().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class a{constructor(e){this._stage=e,this._bodies=new Array}add(e){return this._bodies.push(e),this._stage}generateSource(t){if(this._bodies.length>0)return[`void main() {\n ${this._bodies.join("\n")||""} \n}`];if(t)throw new e("Shader does not contain main function body.");return[]}}class c{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class u extends s{constructor(){super(...arguments),this.uniforms=new o(this),this.main=new a(this),this.code=new c(this),this.constants=new l(this)}get builder(){return this}}class h{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class m{constructor(){this._entries=new Map}add(e,t,r){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,{type:t,invariant:r?.invariant??!1})}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push((r.invariant&&"vertex"===e?"invariant ":"")+("vertex"===e?"out":"in")+` ${r.type} ${n};`))),t}}class _{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?_.ALLOWLIST_VERTEX:_.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}static{this.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"]}static{this.ALLOWLIST_VERTEX=[]}}class d{constructor(){this._entries=new Map}add(e,t,r=0){const s=this._entries.get(r);s?.name!==e||s?.type!==t?this._entries.set(r,{name:e,type:t}):n().warn(`Fragment shader output location ${r} occupied`)}static{this.DEFAULT_TYPE="vec4"}static{this.DEFAULT_NAME="fragColor"}generateSource(e){if("vertex"===e)return[];0===this._entries.size&&this._entries.set(0,{name:d.DEFAULT_NAME,type:d.DEFAULT_TYPE});const t=new Array;return this._entries.forEach(((e,r)=>t.push(`layout(location = ${r}) out ${e.type} ${e.name};`))),t}}class l{constructor(e){this._stage=e,this._entries=new Set}add(e,t,r){let n="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":n=l._numberToFloatStr(r);break;case"int":n=l._numberToIntStr(r);break;case"bool":n=r.toString();break;case"vec2":n=`vec2(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])})`;break;case"vec3":n=`vec3(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])})`;break;case"vec4":n=`vec4(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])}, ${l._numberToFloatStr(r[3])})`;break;case"ivec2":n=`ivec2(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])})`;break;case"ivec3":n=`ivec3(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])})`;break;case"ivec4":n=`ivec4(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])}, ${l._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${t}(${Array.prototype.map.call(r,(e=>l._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${n};`),this._stage}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const g="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump int;\n precision mediump sampler2D;\n#endif",f="precision highp float;\n precision highp sampler2D;\n \n invariant gl_Position;\n ";export{c as Code,s as Includes,a as Main,i as ShaderBuilder,u as Stage,o as Uniforms};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import{removeMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{isPromiseLike as l,debounce as d}from"../../core/promiseUtils.js";import{watch as c,when as u,initial as h,whenOnce as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{generateBracedUUID as f}from"../../core/uuid.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplate as y,isSharedTemplateOrMetadata as v}from"../../editing/templateUtils.js";import{createTemplateExecutor as F}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import _ from"../../layers/GraphicsLayer.js";import{isTable as b}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as M}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as V}from"../../views/draw/support/helpMessageUtils.js";import I from"../../views/draw/support/HighlightHelper.js";import k from"../../views/interactive/sketch/SketchOptions.js";import S from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as C}from"../../views/support/HighlightDefaults.js";import P from"./CreateFeaturesWorkflowData.js";import{isModelUpload as A,handleModelUpload as H}from"./modelUploadUtils.js";import E from"./Workflow.js";import{startCreatingNewFeature as T,findLayerInfo as j,updateGraphicSymbolWhenRequired as U,isTerminalUpdateEventType as L,getVisualVariableAttributes as x,startUpdatingFeatureGeometry as O,createWorkflowSteps as R,avoidFeatureTemplateSelectionWithOnlyOneItem as W,getCreationAttributes as D,getFullTemplateForCreationInfo as N,getServiceLayersById as G,prepareAttachmentsForCreateFeaturesWorkflow as z,showProgressCursor as Z,setUpSketchCreateWatchers as q,setVisualVariablesAndElevationInfoForUpdate as B,visualVariableInteractiveUpdate as K}from"./workflowUtils.js";import J from"../FeatureForm/FeatureFormViewModel.js";import Q from"../Sketch/SketchViewModel.js";var X;const Y=Symbol(),$=Symbol(),ee=Symbol(),te=Symbol(),ae={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ie=X=class extends E{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new J,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return V("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;return e?this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures||"2d"!==t?.type&&"multipoint"===e?[]:[...ae[e]]:[]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ee])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),b(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new k,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new X({data:new P({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e,u=d&&y(d)&&c?.completionResult;if(n){if(ne(s),u){const e=de(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=le(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,oe(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles($);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await T(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,$)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=o(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:n,_sketchViewModel:l}=this,{creationInfo:d,viewModel:u}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=u;if(!m||!d)return;o(this._featureFormHandle);const f=e.sourceLayer,w=j(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||u.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await U(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",(async()=>{v?.updateAttributes(n.getValues()),await U(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&L(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()})),c((()=>n.feature?.sourceLayer),(t=>e.sourceLayer=t)),c((()=>[n.feature,n.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return b(n)?void 0:(this._visualVariableAttributes=x(e),O({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=R(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(A(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ee,Y,$,te]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return W(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,h=[];if(!n)return i();if("2d"===n.type){s&&h.push(e._fadeExistingFeatures(s.layer));const t=d(((e,t)=>Promise.all(e.map((e=>U(e,a,t))))));h.push(c((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=D(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles($)||e.addHandles(await q({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),$),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles($),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await B({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await K(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!A(t.creationInfo))return e._startCreating()},g=async()=>{if(A(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};h.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),u((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),re(l,t),...se(t));const y=r(h);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new _({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new Q({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),c((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),h)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a}=this,{layerInfos:i,view:r}=a.viewModel,s=this._featureFormViewModel,{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,a.addPendingFeature(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:d}=o,c=d(e.geometry,"completion"),u=l(c)?await c:c;o.completionResult=u,s.arcadeEditType="INSERT",s.map=r?.map,s.spatialReference=r?.spatialReference;for(const l of u.edits){let e=null;if(l.addFeatures)for(const r of l.addFeatures){const o=r.clone();o.geometry=null,r.symbol=await M(r,t),n.add(r);const l=a.addPendingFeature(r,o);r.sourceLayer!==e?.layer&&(e=j(i,r.sourceLayer)),s.feature=r,s.formTemplate=e?.formTemplate,await p((()=>!s.updating)),l.submittable=s.submittable}}s.feature=null,await p((()=>!s.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ee))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:d,view:u}=l;if(!u||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=n,f=[];if(this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(n.layer),null===e.fullTemplate&&n.template){const t=await N(n,u);e.fullTemplate=t,t&&y(t)&&(e.templateExecutorInfo={completionResult:null,executor:await F(t),serviceLayersById:await G(n.layer,u)})}z(d),f.push(c((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=Z(u);f.push(w);const g=b(n.layer);try{if(g){const{template:e}=n;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=p??new t({attributes:{...e?.prototype.attributes,...n.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(X._configureSketchViewModel(this)),p?(s.layer.add(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const _=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),M=c((()=>u?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),V=i((()=>{A(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,_,M],ee)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),te),await p((()=>null==e?.activeTool),t.signal),t.abort()}};function re(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new S({layer:e.layer}),s().add(a),a),l=()=>{null!=a&&(s().remove(a),a=n(a))};return r([c((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=o(),a.enabled=t}),m),i(l)])}function se(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new I({view:t});a.push(c((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new I({view:t,highlightName:C});return a.push(c((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function oe(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ne(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=f())}}function le(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:f(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function de(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:f(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([w()],ie.prototype,"createFeatureState",void 0),e([w()],ie.prototype,"data",void 0),e([w({constructOnly:!0})],ie.prototype,"isNested",void 0),e([w()],ie.prototype,"featureFormViewModel",null),e([w()],ie.prototype,"hasPendingEdits",null),e([w()],ie.prototype,"hasPreviousStep",null),e([w()],ie.prototype,"_getDrawMeshHelpMessage",void 0),e([w()],ie.prototype,"helpMessage",null),e([w()],ie.prototype,"layer",null),e([w()],ie.prototype,"parent",null),e([w()],ie.prototype,"parentLayer",null),e([w()],ie.prototype,"keyboardCancellationEnabled",null),e([w()],ie.prototype,"reliesOnOwnerAdminPrivileges",null),e([w()],ie.prototype,"shouldShowAttachments",null),e([w()],ie.prototype,"shouldAllowAttachmentEditing",null),e([w()],ie.prototype,"sketchViewModel",null),e([w()],ie.prototype,"availableCreateTools",null),e([w()],ie.prototype,"_attachmentsActive",null),ie=X=e([g("esri.widgets.Editor.CreateFeaturesWorkflow")],ie);const ce=ie;export{ce as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import{removeMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{isPromiseLike as l,debounce as d}from"../../core/promiseUtils.js";import{watch as c,when as u,initial as h,whenOnce as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{generateBracedUUID as f}from"../../core/uuid.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplate as y,isSharedTemplateOrMetadata as v}from"../../editing/templateUtils.js";import{createTemplateExecutor as F}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import _ from"../../layers/GraphicsLayer.js";import{isTable as b}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as M}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as V}from"../../views/draw/support/helpMessageUtils.js";import I from"../../views/draw/support/HighlightHelper.js";import k from"../../views/interactive/sketch/SketchOptions.js";import S from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as C}from"../../views/support/HighlightDefaults.js";import P from"./CreateFeaturesWorkflowData.js";import{isModelUpload as A,handleModelUpload as H}from"./modelUploadUtils.js";import E from"./Workflow.js";import{setRelationshipFields as T,startCreatingNewFeature as j,findLayerInfo as U,updateGraphicSymbolWhenRequired as L,isTerminalUpdateEventType as x,getVisualVariableAttributes as O,startUpdatingFeatureGeometry as R,createWorkflowSteps as W,avoidFeatureTemplateSelectionWithOnlyOneItem as D,getCreationAttributes as N,getFullTemplateForCreationInfo as G,getServiceLayersById as z,prepareAttachmentsForCreateFeaturesWorkflow as Z,showProgressCursor as q,setUpSketchCreateWatchers as B,setVisualVariablesAndElevationInfoForUpdate as K,visualVariableInteractiveUpdate as J}from"./workflowUtils.js";import Q from"../FeatureForm/FeatureFormViewModel.js";import X from"../Sketch/SketchViewModel.js";var Y;const $=Symbol(),ee=Symbol(),te=Symbol(),ae=Symbol(),ie={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let re=Y=class extends E{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new Q,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return V("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;return e?this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures||"2d"!==t?.type&&"multipoint"===e?[]:[...ie[e]]:[]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([te])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),b(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new k,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new Y({data:new P({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e;c?.completionResult&&T(c.completionResult.relationships);const u=d&&y(d)&&c?.completionResult;if(n){if(le(s),u){const e=ce(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=de(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,ne(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(ee);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await j(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,ee)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=o(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:n,_sketchViewModel:l}=this,{creationInfo:d,viewModel:u}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=u;if(!m||!d)return;o(this._featureFormHandle);const f=e.sourceLayer,w=U(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||u.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await L(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",(async()=>{v?.updateAttributes(n.getValues()),await L(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&x(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()})),c((()=>n.feature?.sourceLayer),(t=>e.sourceLayer=t)),c((()=>[n.feature,n.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return b(n)?void 0:(this._visualVariableAttributes=O(e),R({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=W(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(A(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([te,$,ee,ae]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return D(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,h=[];if(!n)return i();if("2d"===n.type){s&&h.push(e._fadeExistingFeatures(s.layer));const t=d(((e,t)=>Promise.all(e.map((e=>L(e,a,t))))));h.push(c((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=N(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles(ee)||e.addHandles(await B({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),ee),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles(ee),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await K({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await J(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!A(t.creationInfo))return e._startCreating()},g=async()=>{if(A(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};h.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),u((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),se(l,t),...oe(t));const y=r(h);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new _({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new X({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),c((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),h)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a}=this,{layerInfos:i,view:r}=a.viewModel,s=this._featureFormViewModel,{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,a.addPendingFeature(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:d}=o,c=d(e.geometry,"completion"),u=l(c)?await c:c;o.completionResult=u,T(u.relationships),s.arcadeEditType="INSERT",s.map=r?.map,s.spatialReference=r?.spatialReference;for(const l of u.edits){let e=null;if(l.addFeatures)for(const r of l.addFeatures){const o=r.clone();o.geometry=null,r.symbol=await M(r,t),n.add(r);const l=a.addPendingFeature(r,o);r.sourceLayer!==e?.layer&&(e=U(i,r.sourceLayer)),s.feature=r,s.formTemplate=e?.formTemplate,await p((()=>!s.updating)),l.submittable=s.submittable}}s.feature=null,await p((()=>!s.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _setUpCreatingFeaturesStep(){if(this.hasHandles(te))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:d,view:u}=l;if(!u||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=n,f=[];if(this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(n.layer),null===e.fullTemplate&&n.template){const t=await G(n,u);e.fullTemplate=t,t&&y(t)&&(e.templateExecutorInfo={completionResult:null,executor:await F(t),serviceLayersById:await z(n.layer,u)})}Z(d),f.push(c((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=q(u);f.push(w);const g=b(n.layer);try{if(g){const{template:e}=n;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=p??new t({attributes:{...e?.prototype.attributes,...n.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(Y._configureSketchViewModel(this)),p?(s.layer.add(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const _=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),M=c((()=>u?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),V=i((()=>{A(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,_,M],te)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),ae),await p((()=>null==e?.activeTool),t.signal),t.abort()}};function se(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new S({layer:e.layer}),s().add(a),a),l=()=>{null!=a&&(s().remove(a),a=n(a))};return r([c((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=o(),a.enabled=t}),m),i(l)])}function oe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new I({view:t});a.push(c((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new I({view:t,highlightName:C});return a.push(c((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function ne(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function le(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=f())}}function de(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:f(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ce(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:f(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([w()],re.prototype,"createFeatureState",void 0),e([w()],re.prototype,"data",void 0),e([w({constructOnly:!0})],re.prototype,"isNested",void 0),e([w()],re.prototype,"featureFormViewModel",null),e([w()],re.prototype,"hasPendingEdits",null),e([w()],re.prototype,"hasPreviousStep",null),e([w()],re.prototype,"_getDrawMeshHelpMessage",void 0),e([w()],re.prototype,"helpMessage",null),e([w()],re.prototype,"layer",null),e([w()],re.prototype,"parent",null),e([w()],re.prototype,"parentLayer",null),e([w()],re.prototype,"keyboardCancellationEnabled",null),e([w()],re.prototype,"reliesOnOwnerAdminPrivileges",null),e([w()],re.prototype,"shouldShowAttachments",null),e([w()],re.prototype,"shouldAllowAttachmentEditing",null),e([w()],re.prototype,"sketchViewModel",null),e([w()],re.prototype,"availableCreateTools",null),e([w()],re.prototype,"_attachmentsActive",null),re=Y=e([g("esri.widgets.Editor.CreateFeaturesWorkflow")],re);const ue=re;export{ue as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import{Heading as e}from"../../support/Heading.js";import{iconByKind as o}from"../../support/iconUtils.js";import{setFocus as i}from"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";const c="esri-editor__prompt",n={base:c,header:`${c}__header`,heading:`${c}__header__heading`,message:`${c}__message`,divider:`${c}__divider`,actions:`${c}__actions`},s=()=>t({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")});function r({actions:t,context:c,headingLevel:s,message:r,title:p
|
|
5
|
+
import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import{Heading as e}from"../../support/Heading.js";import{iconByKind as o}from"../../support/iconUtils.js";import{setFocus as i}from"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";const c="esri-editor__prompt",n={base:c,header:`${c}__header`,heading:`${c}__header__heading`,message:`${c}__message`,divider:`${c}__divider`,actions:`${c}__actions`,halfWidthButton:`${c}__half-width-button`},s=()=>t({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")});function r({actions:t,context:c,headingLevel:s,message:r,title:d,...p}){const{primary:m,secondary:u}=t;let b;switch(c){case"danger":b="danger";break;case"info":b="brand";break;default:b="neutral"}const h=a("calcite-button",{afterCreate:t=>i(t),appearance:"solid",classes:{[n.halfWidthButton]:!!u},"data-testid":"primary-prompt-button",key:"prompt-primary-button",kind:b,onclick:m.action,width:"full"},m.label),g=u&&a("calcite-button",{appearance:"outline",class:n.halfWidthButton,"data-testid":"secondary-prompt-button",key:"prompt-secondary-button",kind:b,onclick:u.action,width:"full"},u.label);return a("calcite-scrim",{"data-testid":"prompt",key:"prompt"},a("div",{class:`${n.base}--${c}`},a("div",{class:n.header},a("calcite-icon",{icon:o.warning}),a(e,{class:n.heading,level:s},d)),a("div",{class:n.message},r),l(p)??a("div",{class:n.divider}),a("div",{class:n.actions},g,h)))}function l({radios:t,onRadioSelection:e,defaultRadioSelection:o}){return t?.length?a("calcite-radio-button-group",{name:"PromptChoiceList"},t.map((t=>a("calcite-label",{layout:"inline"},a("calcite-radio-button",{checked:t.value===o,value:t.value,onCalciteRadioButtonChange:()=>e?.(t.value)}),t.label)))):void 0}export{r as Prompt,n as css,s as loadPromptComponents};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as i}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import a from"../../core/Error.js";import{handlesGroup as o,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as y,debounce as f,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as I,isSharedFeatureTemplate as T,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as V,isSharedTemplateOrMetadata as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as O}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import F from"../../layers/GraphicsLayer.js";import{featureHasFields as z,fixFields as x,getDisplayFieldName as A}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as M}from"../../layers/support/layerUtils.js";import{calculateTolerance as P}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as E,TransformationType as R}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as G,getSize as D}from"../../renderers/visualVariables/support/visualVariableUtils.js";import Z from"../../symbols/SimpleFillSymbol.js";import q from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Q}from"../../symbols/support/symbolUtils.js";import{getServices as J}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as H}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as K}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as X,filterGraphicHits as Y}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as $}from"../Sketch/support/sketchUtils.js";const _=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function ee(e){return"update"===e.type}function te(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!se(t.renderer))return{rotation:null,size:null};let r=null,i=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=G(t,e)));1===n.length&&(r=re(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&E(t)===R.RealWorldSize&&null!=D(t,e)));return 1===a.length&&(i=ae(a[0],t)),{rotation:r,size:i}}function re(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,oe((o.current+360)%360,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ie(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ne(e,t,r){if(null==t)return 0;const{symbol:i}=N(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(Pe.icon,(await e(n,Pe.icon))[0])||Pe.icon}case"text":return n.size||Pe.text;case"line":return n.size||Pe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ie(await t(n,e.scale/Pe.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/Pe.viewScaleSizeFactor;case"extrude":return n.size||e.scale/Pe.viewScaleSizeFactor;default:return 0}}function ae(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:a,getDefault:async(e,t)=>oe(l(await ne(t,e,i)),a),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,oe(o.current,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:Re(e.valueUnit),axis:e.axis}}function oe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function se(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function le(e,t,r){const i=await Q(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,i)&&(e.symbol=i)}function ce(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const i={mode:H,optionsPerTool:r};if(L(t)){const n=t.defaultTool,a=S(t)?t.definition?.inputGeometryType??e:e;switch(n){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:i};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:i};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:i};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:i};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:i};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:i};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:i};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:i};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:i}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:i};if("rectangle"===n)return{tool:"rectangle",createOptions:i};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:i}}return{tool:e,createOptions:i}}async function ue(e,t,r){const{creationInfo:i,fullTemplate:n}=t;if(!i)throw new a("No creation info provided.");const o=i.layer,s=he(n,i.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(n)||j(n)||await we(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=ce(o.geometryType,n);return e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==i.geometryToPlace?await e.create(p.tool):await e.place(i.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}}),pe({creationAttributes:s,data:t,sketchViewModel:e,view:l,webStyleCache:r})}async function pe(e){return o([await de(e),await ye(e)])}async function de({creationAttributes:e,data:t,sketchViewModel:r,view:i,webStyleCache:n}){const{creationInfo:a}=t,{fullTemplate:o}=t;if(!a||"2d"!==i?.type||S(o)||j(o))return null;const s=f((t=>we(r,a.layer,e,n,t)));return g((()=>i.scale),(e=>s(e)))}async function ye({data:t,sketchViewModel:r,view:i}){const{templateExecutorInfo:n}=t;if(!n)return null;const l=r.activeComponent;if(!i||!$(l))return _().error(new a("Failed to set up template feedback.")),null;const c=new F({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});i.map?.add(c);const{executor:u,serviceLayersById:p}=n,d=i.theme?.accentColor??new e([255,165,0,1]);return o([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!fe(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=me(e,d);t&&c.add(t)}}})),s((()=>{i.map.remove(c),c.destroy()}))])}function fe(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return i(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function me(e,r){let i=null;switch(e.geometry?.type){case"point":case"multipoint":i=new B({angle:0,color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":i=new Z({color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":i=new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:i,attributes:{...e.attributes}})}async function ge(e,t){const r=await J(t).load(),i=M(e)?e.parent:e,n=r.tablesAndLayersLookup.get(i);if(!n)return new Map;const a=new Map;for(const o of n.layersAndTables)p(a,o.layerId,(()=>[])).push(o);return a}function he(e,t={}){return S(e)||j(e)?{}:I(e)?{...e.prototype.attributes,...t}:T(e)?{...e.definition?.defaultValues,...t}:{...t}}async function we(e,r,i,n,a){const o=new t({sourceLayer:r,attributes:i}),{rotation:s,size:l}=te(o);let c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==i[t.field]&&(i[t.field]=await t.getDefault(c,e.view),u=!0)}switch(u&&(c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}be(e.tooltipOptions,l,s)}function be(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function ve(e,t){return e?.find((e=>e.layer===t))}async function Se(e,t,r,i){switch(t.type){case"3d":return je(e,t,r,i);case"2d":return Ie(e,t,r,i)}}async function je(e,t,i,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await i.async((async()=>{const{results:r}=await d(X(t,i),n),a=new Map,o=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};Y(r).forEach((({graphic:e})=>o(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&a.has(t)));return 0!==s.length&&i.stopPropagation(),{updatable:s,graphicsByLayer:a}}));return d(Promise.allSettled(a.map((async({layer:e})=>{const t=o.get(e),i=Te(e);if(t.every((e=>z(i,e))))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);r(i,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=x(e.fieldsIndex,i),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Ie(e,t,r,i){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let a=null;const o=await r.async((async()=>{const{results:n}=await d(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;a=Y(n),a.forEach((({graphic:e})=>e&&o.add(e.layer)));const s=e.filter((e=>o.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(o.map((async({layer:e})=>{const o=e.createQuery();o.returnGeometry=!1,o.outFields=Te(e);const s="renderer"in e?P({renderer:e.renderer,pointerType:r.pointerType}):0;o.geometry=K(n,s,t),o.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(o,{signal:i});return a?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),i)}function Te(e){return x(e.fieldsIndex,[e.objectIdField,A({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ue(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,"scene"===i.type&&null!=i.infoFor3D||(n.outSpatialReference=t);const a=await i.queryFeatures(n,{signal:r});y(r);return a.features[0]}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n}=e;await Le(e);const a={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(a.enableRotation=null!=n.rotation,a.enableScaling=null!=n.size),r.update(t,a)}async function Le(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let o=!1;const{rotation:s,size:l}=n;if([s,l].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.setInitialValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.setInitialValue(i),t.setAttribute(e.field,i),o=!0}})),o){const e="2d"===r.view?.type?r.view.scale:null;await le(t,a,e)}be(r.tooltipOptions,l,s),r.layer.elevationInfo=i.elevationInfo}function ke(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Oe(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Fe(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,o=ke(r.toolEventInfo);if(null!=a&&null!=o){const{field:r,getValue:i}=a;"rotate-stop"===o.type?(a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r))):(a.isUpdatingInteractively=!0,t.setAttribute(r,i(o.angle,e)))}const s=i.size,l=Oe(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:i}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,i(l.xScale,e)))}await le(t,n,"2d"===e.type?e.scale:null)}async function ze({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:i,view:n,onUpdate:a,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await le(t,c,"2d"===n.type?n.scale:null);let d=null;if("2d"===i?.view?.type){const e=f((e=>le(t,c,e)));d=g((()=>i?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=Ze(n,y);await Ve({graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const i in e){const n=e[i];n!==t.getAttribute(i)&&(t.setAttribute(i,n),null==b||b.isUpdatingInteractively||b.field!==i||b.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==i||v.setInitialValue(n),(null==h||h.requiredFields.includes(i))&&(r=!0))}r&&await le(t,c,"2d"===n.type?n.scale:null)})),j=i.on("update",(async e=>{const t=e.graphics[0],o={graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===n.activeTool)return Ve(o);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===n.activeTool),e.signal).then((()=>(e.abort(),Ve(o)))))}await Fe(n,t,e,r,c),a(Be(t),e)})),I=i.on(["undo","redo"],(async e=>{a(Be(e.graphics[0]),e)}));return o([I,j,s((()=>i.cancel())),S,d])}async function xe(e,t,r){const i=e.view;e.layer.add(r);const a=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Ze(i,a);y(t),r.setVisibility?.(c,e)}))}return await Me(i,r),p(!1),o([Ae(i,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ze(i,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ae(e,t,r){if("3d"===e.type){const i=new W({graphic:t});return o([e.trackGraphicState(i),g((()=>i.displaying),r)])}return g((()=>t.visible),r)}async function Me(e,t){if("3d"===e.type){const r=new W({graphic:t}),i=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),i.remove()}else await w((()=>t.visible))}const Pe={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Ce(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function Ee(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,i=U(e);1===i.length&&"scene"!==e.type&&(r.template=i[0],t.shift())}return t}function Re(e){return"unknown"===e?null:e}function Ge(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const De=e=>/-stop/.test(e)||/vertex-/.test(e),Ze=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function qe(e){return"createInteractiveEditSession"in e}function Be(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function Ne(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Qe(e,t){const{template:r}=e;if(null==r)return null;if(V(r))return r.load();if(L(r)){const e=O(t,{makeSharedTemplateFromJSON:Je}),i=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===i.length)throw new a("editor:failed-to-load-template","Unable to load the provided template");return i[0].load()}return r}const Je=e=>k.fromJSON(e);export{Ee as avoidFeatureTemplateSelectionWithOnlyOneItem,qe as canCreateInteractiveEditSession,Be as cloneGraphicExceptMesh,Ce as createWorkflowSteps,Se as fetchCandidates,Ue as fetchFullFeature,ve as findLayerInfo,he as getCreationAttributes,Qe as getFullTemplateForCreationInfo,ge as getServiceLayersById,te as getVisualVariableAttributes,De as isTerminalUpdateEventType,ee as isUpdateWorkflow,Ge as prepareAttachmentsForCreateFeaturesWorkflow,ze as setUpGeometryUpdate,pe as setUpSketchCreateWatchers,Le as setVisualVariablesAndElevationInfoForUpdate,Ne as showProgressCursor,Pe as sizeDefaults,Re as sizeVariableUnitToLengthUnit,ue as startCreatingNewFeature,Ve as startUpdatingFeatureGeometry,xe as swapForEditingSession,le as updateGraphicSymbolWhenRequired,Fe as visualVariableInteractiveUpdate,Ze as whenEditorLayerView,Me as whenGraphicDisplayed};
|
|
5
|
+
import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as i}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import a from"../../core/Error.js";import{handlesGroup as o,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as y,debounce as f,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as I,isSharedFeatureTemplate as T,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as V,isSharedTemplateOrMetadata as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as F}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import O from"../../layers/GraphicsLayer.js";import{featureHasFields as A,fixFields as z,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as M}from"../../layers/support/layerUtils.js";import{calculateTolerance as P}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as E,TransformationType as R}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as G,getSize as D}from"../../renderers/visualVariables/support/visualVariableUtils.js";import Z from"../../symbols/SimpleFillSymbol.js";import q from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Q}from"../../symbols/support/symbolUtils.js";import{getServices as J}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as H}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as K}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as X,filterGraphicHits as Y}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as $}from"../Sketch/support/sketchUtils.js";const _=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function ee(e){return"update"===e.type}function te(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!se(t.renderer))return{rotation:null,size:null};let r=null,i=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=G(t,e)));1===n.length&&(r=re(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&E(t)===R.RealWorldSize&&null!=D(t,e)));return 1===a.length&&(i=ae(a[0],t)),{rotation:r,size:i}}function re(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,oe((o.current+360)%360,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ie(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ne(e,t,r){if(null==t)return 0;const{symbol:i}=N(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(Pe.icon,(await e(n,Pe.icon))[0])||Pe.icon}case"text":return n.size||Pe.text;case"line":return n.size||Pe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ie(await t(n,e.scale/Pe.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/Pe.viewScaleSizeFactor;case"extrude":return n.size||e.scale/Pe.viewScaleSizeFactor;default:return 0}}function ae(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:a,getDefault:async(e,t)=>oe(l(await ne(t,e,i)),a),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,oe(o.current,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:Re(e.valueUnit),axis:e.axis}}function oe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function se(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function le(e,t,r){const i=await Q(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,i)&&(e.symbol=i)}function ce(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const i={mode:H,optionsPerTool:r};if(L(t)){const n=t.defaultTool,a=S(t)?t.definition?.inputGeometryType??e:e;switch(n){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:i};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:i};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:i};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:i};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:i};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:i};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:i};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:i};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:i}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:i};if("rectangle"===n)return{tool:"rectangle",createOptions:i};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:i}}return{tool:e,createOptions:i}}async function ue(e,t,r){const{creationInfo:i,fullTemplate:n}=t;if(!i)throw new a("No creation info provided.");const o=i.layer,s=he(n,i.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(n)||j(n)||await we(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=ce(o.geometryType,n);return e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==i.geometryToPlace?await e.create(p.tool):await e.place(i.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}}),pe({creationAttributes:s,data:t,sketchViewModel:e,view:l,webStyleCache:r})}async function pe(e){return o([await de(e),await ye(e)])}async function de({creationAttributes:e,data:t,sketchViewModel:r,view:i,webStyleCache:n}){const{creationInfo:a}=t,{fullTemplate:o}=t;if(!a||"2d"!==i?.type||S(o)||j(o))return null;const s=f((t=>we(r,a.layer,e,n,t)));return g((()=>i.scale),(e=>s(e)))}async function ye({data:t,sketchViewModel:r,view:i}){const{templateExecutorInfo:n}=t;if(!n)return null;const l=r.activeComponent;if(!i||!$(l))return _().error(new a("Failed to set up template feedback.")),null;const c=new O({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});i.map?.add(c);const{executor:u,serviceLayersById:p}=n,d=i.theme?.accentColor??new e([255,165,0,1]);return o([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!fe(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=me(e,d);t&&c.add(t)}}})),s((()=>{i.map.remove(c),c.destroy()}))])}function fe(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return i(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function me(e,r){let i=null;switch(e.geometry?.type){case"point":case"multipoint":i=new B({angle:0,color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":i=new Z({color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":i=new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:i,attributes:{...e.attributes}})}async function ge(e,t){const r=await J(t).load(),i=M(e)?e.parent:e,n=r.tablesAndLayersLookup.get(i);if(!n)return new Map;const a=new Map;for(const o of n.layersAndTables)p(a,o.layerId,(()=>[])).push(o);return a}function he(e,t={}){return S(e)||j(e)?{}:I(e)?{...e.prototype.attributes,...t}:T(e)?{...e.definition?.defaultValues,...t}:{...t}}async function we(e,r,i,n,a){const o=new t({sourceLayer:r,attributes:i}),{rotation:s,size:l}=te(o);let c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==i[t.field]&&(i[t.field]=await t.getDefault(c,e.view),u=!0)}switch(u&&(c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}be(e.tooltipOptions,l,s)}function be(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function ve(e,t){return e?.find((e=>e.layer===t))}async function Se(e,t,r,i){switch(t.type){case"3d":return je(e,t,r,i);case"2d":return Ie(e,t,r,i)}}async function je(e,t,i,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await i.async((async()=>{const{results:r}=await d(X(t,i),n),a=new Map,o=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};Y(r).forEach((({graphic:e})=>o(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&a.has(t)));return 0!==s.length&&i.stopPropagation(),{updatable:s,graphicsByLayer:a}}));return d(Promise.allSettled(a.map((async({layer:e})=>{const t=o.get(e),i=Te(e);if(t.every((e=>A(i,e))))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);r(i,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=z(e.fieldsIndex,i),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Ie(e,t,r,i){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let a=null;const o=await r.async((async()=>{const{results:n}=await d(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;a=Y(n),a.forEach((({graphic:e})=>e&&o.add(e.layer)));const s=e.filter((e=>o.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(o.map((async({layer:e})=>{const o=e.createQuery();o.returnGeometry=!1,o.outFields=Te(e);const s="renderer"in e?P({renderer:e.renderer,pointerType:r.pointerType}):0;o.geometry=K(n,s,t),o.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(o,{signal:i});return a?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),i)}function Te(e){return z(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ue(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,"scene"===i.type&&null!=i.infoFor3D||(n.outSpatialReference=t);const a=await i.queryFeatures(n,{signal:r});y(r);return a.features[0]}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n}=e;await Le(e);const a={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(a.enableRotation=null!=n.rotation,a.enableScaling=null!=n.size),r.update(t,a)}async function Le(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let o=!1;const{rotation:s,size:l}=n;if([s,l].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.setInitialValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.setInitialValue(i),t.setAttribute(e.field,i),o=!0}})),o){const e="2d"===r.view?.type?r.view.scale:null;await le(t,a,e)}be(r.tooltipOptions,l,s),r.layer.elevationInfo=i.elevationInfo}function ke(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Fe(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Oe(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,o=ke(r.toolEventInfo);if(null!=a&&null!=o){const{field:r,getValue:i}=a;"rotate-stop"===o.type?(a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r))):(a.isUpdatingInteractively=!0,t.setAttribute(r,i(o.angle,e)))}const s=i.size,l=Fe(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:i}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,i(l.xScale,e)))}await le(t,n,"2d"===e.type?e.scale:null)}async function Ae({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:i,view:n,onUpdate:a,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await le(t,c,"2d"===n.type?n.scale:null);let d=null;if("2d"===i?.view?.type){const e=f((e=>le(t,c,e)));d=g((()=>i?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=Ze(n,y);await Ve({graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const i in e){const n=e[i];n!==t.getAttribute(i)&&(t.setAttribute(i,n),null==b||b.isUpdatingInteractively||b.field!==i||b.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==i||v.setInitialValue(n),(null==h||h.requiredFields.includes(i))&&(r=!0))}r&&await le(t,c,"2d"===n.type?n.scale:null)})),j=i.on("update",(async e=>{const t=e.graphics[0],o={graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===n.activeTool)return Ve(o);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===n.activeTool),e.signal).then((()=>(e.abort(),Ve(o)))))}await Oe(n,t,e,r,c),a(Be(t),e)})),I=i.on(["undo","redo"],(async e=>{a(Be(e.graphics[0]),e)}));return o([I,j,s((()=>i.cancel())),S,d])}async function ze(e,t,r){const i=e.view;e.layer.add(r);const a=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Ze(i,a);y(t),r.setVisibility?.(c,e)}))}return await Me(i,r),p(!1),o([xe(i,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ze(i,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function xe(e,t,r){if("3d"===e.type){const i=new W({graphic:t});return o([e.trackGraphicState(i),g((()=>i.displaying),r)])}return g((()=>t.visible),r)}async function Me(e,t){if("3d"===e.type){const r=new W({graphic:t}),i=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),i.remove()}else await w((()=>t.visible))}const Pe={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Ce(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function Ee(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,i=U(e);1===i.length&&"scene"!==e.type&&(r.template=i[0],t.shift())}return t}function Re(e){return"unknown"===e?null:e}function Ge(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const De=e=>/-stop/.test(e)||/vertex-/.test(e),Ze=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function qe(e){return"createInteractiveEditSession"in e}function Be(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function Ne(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Qe(e,t){const{template:r}=e;if(null==r)return null;if(V(r))return r.load();if(L(r)){const e=F(t,{makeSharedTemplateFromJSON:We}),i=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===i.length)throw new a("editor:failed-to-load-template","Unable to load the provided template");return i[0].load()}return r}function Je(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:i,sourceField:n}=t;e.setAttribute(r,i.getAttribute(n))}}const We=e=>k.fromJSON(e);export{Ee as avoidFeatureTemplateSelectionWithOnlyOneItem,qe as canCreateInteractiveEditSession,Be as cloneGraphicExceptMesh,Ce as createWorkflowSteps,Se as fetchCandidates,Ue as fetchFullFeature,ve as findLayerInfo,he as getCreationAttributes,Qe as getFullTemplateForCreationInfo,ge as getServiceLayersById,te as getVisualVariableAttributes,De as isTerminalUpdateEventType,ee as isUpdateWorkflow,Ge as prepareAttachmentsForCreateFeaturesWorkflow,Je as setRelationshipFields,Ae as setUpGeometryUpdate,pe as setUpSketchCreateWatchers,Le as setVisualVariablesAndElevationInfoForUpdate,Ne as showProgressCursor,Pe as sizeDefaults,Re as sizeVariableUnitToLengthUnit,ue as startCreatingNewFeature,Ve as startUpdatingFeatureGeometry,ze as swapForEditingSession,le as updateGraphicSymbolWhenRequired,Oe as visualVariableInteractiveUpdate,Ze as whenEditorLayerView,Me as whenGraphicDisplayed};
|
package/widgets/Editor.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as _}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import y from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as k,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as A,FeatureList as F}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as M,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as W}from"./Editor/components/Notices.js";import{loadPanelContentComponents as E,PanelContent as P,PanelContentSection as L,PanelContentMessage as S}from"./Editor/components/PanelContent.js";import{PanelToolbar as I,loadPanelToolbarComponents as j}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as V,UpdateFeaturePanelContent as O}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js";import z from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js";import{VisibleElements as R,CreateToolVisibilityMap as G}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{globalCss as q}from"./support/globalCss.js";import{incrementHeadingLevel as Z,Heading as K}from"./support/Heading.js";import{renderItem as $}from"./support/ItemList.js";import{connectDelayedLoading as J}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as Q}from"./support/decorators/messageBundle.js";import{vmEvent as X}from"./support/decorators/vmEvent.js";import{tsx as Y}from"./support/jsxFactory.js";import{substitute as ee}from"../intl/substitute.js";const te=Symbol("sketch-setup-handles");let se=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=new N,this._associationSettings=new z,this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?Y("calcite-icon",{class:_.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new y,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderAssociationItemList=()=>this._associationItemList.render(),this._renderAssociationSettings=()=>this._associationSettings.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?Y("div",{class:_.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>Y("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return Y("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?Y("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?Y(I,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>Z(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:ee(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),J({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList.destroy(),this._associationSettings.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([H({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),k(),A(),M(),C(),E(),j(),U(),V(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(_.base,q.widget,q.panel);if(!t)return Y("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return Y("div",{class:s,key:"base"},e.flow?Y("calcite-flow",{key:"flow"},a):a,this._prompt?Y(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return Y("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return Y(t,{heading:s.selectTemplate,key:"templates-panel",...e},Y(P,{key:"feature-templates"},Y(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?Y(t,{heading:o.createFeatures,key:"upload-details-panel",...e},Y(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return Y(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?Y(O,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):Y(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return Y(t,{heading:s.editFeature,key:"update-feature-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return Y(t,{heading:n,key:"viewing-associated-layers-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return Y(s,{heading:r,key:"add-association-select-feature",...e},Y(P,{key:"select-feature"},Y(L,null,this._renderAssociationItemList())),Y(T,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_setUpAssociationSettings(){const{viewModel:e,_associationSettings:t}=this,s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.fullFeature:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{EditorPanel:t,viewModel:s,messagesCommon:o}=this,i=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(i?.associationType),r="ready"!==i?.state;return Y(t,{heading:a,key:"add-association",...e},Y(P,{key:"add-association-content"},Y(L,null,this._renderAssociationSettings())),Y(T,{buttons:[{label:o.add,disabled:r||!i.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:r,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?Y(W,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return Y(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),Y(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?Y(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?Y(T,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return Y(t,{heading:s.widgetLabel,key:"landing-panel",...e},Y(P,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?Y(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?Y(L,{key:"create-actions"},this._renderCreateActions()):null]:Y(S,{key:"no-content"},s.noEditableLayers)),a?Y("div",{class:_.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return Y("div",{class:_.updateActions,key:"update-actions"},Y(K,{level:Z(this.headingLevel)},e.editFeatures),Y("calcite-list",{class:_.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},$({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return Y("div",{key:"create-actions"},Y(K,{level:Z(this.headingLevel)},this.messages.createFeatures),Y("div",{class:_.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=ee(this.messages.multipleFeaturesTemplate,{total:i.length});return Y(t,{heading:a,key:"feature-list",...e},Y(F,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(te);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new G({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],te)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar}}};e([c()],se.prototype,"_featureForm",void 0),e([c()],se.prototype,"_sketchToolbar",void 0),e([c()],se.prototype,"_attachments",void 0),e([c()],se.prototype,"_associationItemList",void 0),e([c()],se.prototype,"_associationSettings",void 0),e([c()],se.prototype,"_featureTemplates",void 0),e([c()],se.prototype,"_filterText",void 0),e([c()],se.prototype,"_prompt",void 0),e([c()],se.prototype,"_spinner",void 0),e([c()],se.prototype,"_deleteButtonCommonInfo",null),e([c()],se.prototype,"_loading",void 0),e([c({readOnly:!0})],se.prototype,"activeWorkflow",null),e([c()],se.prototype,"headingLevel",void 0),e([c()],se.prototype,"hideTemplatesForInactiveLayers",null),e([c()],se.prototype,"icon",null),e([c()],se.prototype,"label",null),e([c()],se.prototype,"labelOptions",null),e([c()],se.prototype,"layerInfos",null),e([c(),Q("esri/widgets/Editor/t9n/Editor")],se.prototype,"messages",void 0),e([c(),Q("esri/t9n/common")],se.prototype,"messagesCommon",void 0),e([c(),Q("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],se.prototype,"messagesTemplates",void 0),e([c(),Q("esri/widgets/Feature/t9n/Feature")],se.prototype,"messagesFeature",void 0),e([c()],se.prototype,"snappingOptions",null),e([c()],se.prototype,"tooltipOptions",null),e([c()],se.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],se.prototype,"valueOptions",null),e([c()],se.prototype,"view",null),e([c(),X(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],se.prototype,"viewModel",void 0),e([c({type:y,nonNullable:!0})],se.prototype,"visibleElements",void 0),e([c()],se.prototype,"_helpMessage",null),se=e([d("esri.widgets.Editor")],se);const oe=se;export{oe as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as _}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import y from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as k,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as A,FeatureList as F}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as M,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as W}from"./Editor/components/Notices.js";import{loadPanelContentComponents as E,PanelContent as P,PanelContentSection as L,PanelContentMessage as S}from"./Editor/components/PanelContent.js";import{PanelToolbar as I,loadPanelToolbarComponents as j}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as V,UpdateFeaturePanelContent as O}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js";import z from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js";import{VisibleElements as R,CreateToolVisibilityMap as G}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{globalCss as q}from"./support/globalCss.js";import{incrementHeadingLevel as Z,Heading as K}from"./support/Heading.js";import{renderItem as $}from"./support/ItemList.js";import{connectDelayedLoading as J}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as Q}from"./support/decorators/messageBundle.js";import{vmEvent as X}from"./support/decorators/vmEvent.js";import{tsx as Y}from"./support/jsxFactory.js";import{substitute as ee}from"../intl/substitute.js";const te=Symbol("sketch-setup-handles");let se=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=new N,this._associationSettings=new z,this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?Y("calcite-icon",{class:_.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new y,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderAssociationItemList=()=>this._associationItemList.render(),this._renderAssociationSettings=()=>this._associationSettings.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?Y("div",{class:_.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>Y("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return Y("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?Y("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?Y(I,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>Z(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:ee(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),J({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList.destroy(),this._associationSettings.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([H({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),k(),A(),M(),C(),E(),j(),U(),V(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(_.base,q.widget,q.panel);if(!t)return Y("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return Y("div",{class:s,key:"base"},e.flow?Y("calcite-flow",{key:"flow"},a):a,this._prompt?Y(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return Y("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return Y(t,{heading:s.selectTemplate,key:"templates-panel",...e},Y(P,{key:"feature-templates"},Y(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?Y(t,{heading:o.createFeatures,key:"upload-details-panel",...e},Y(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return Y(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?Y(O,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):Y(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return Y(t,{heading:s.editFeature,key:"update-feature-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return Y(t,{heading:n,key:"viewing-associated-layers-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return Y(s,{heading:r,key:"add-association-select-feature",...e},Y(P,{key:"select-feature"},Y(L,null,this._renderAssociationItemList())),Y(T,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_setUpAssociationSettings(){const{viewModel:e,_associationSettings:t}=this,s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.fullFeature:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{EditorPanel:t,viewModel:s,messagesCommon:o}=this,i=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(i?.associationType),r="ready"!==i?.state;return Y(t,{heading:a,key:"add-association",...e},Y(P,{key:"add-association-content"},Y(L,null,this._renderAssociationSettings())),Y(T,{buttons:[{label:o.add,disabled:r||!i.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:r,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?Y(W,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return Y(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),Y(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?Y(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?Y(T,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return Y(t,{heading:s.widgetLabel,key:"landing-panel",...e},Y(P,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?Y(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?Y(L,{key:"create-actions"},this._renderCreateActions()):null]:Y(S,{key:"no-content"},s.noEditableLayers)),a?Y("div",{class:_.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return Y("div",{class:_.updateActions,key:"update-actions"},Y(K,{level:Z(this.headingLevel)},e.editFeatures),Y("calcite-list",{class:_.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},$({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return Y("div",{key:"create-actions"},Y(K,{level:Z(this.headingLevel)},this.messages.createFeatures),Y("div",{class:_.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=ee(this.messages.multipleFeaturesTemplate,{total:i.length});return Y(t,{heading:a,key:"feature-list",...e},Y(F,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(te);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new G({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],te)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],se.prototype,"_featureForm",void 0),e([c()],se.prototype,"_sketchToolbar",void 0),e([c()],se.prototype,"_attachments",void 0),e([c()],se.prototype,"_associationItemList",void 0),e([c()],se.prototype,"_associationSettings",void 0),e([c()],se.prototype,"_featureTemplates",void 0),e([c()],se.prototype,"_filterText",void 0),e([c()],se.prototype,"_prompt",void 0),e([c()],se.prototype,"_spinner",void 0),e([c()],se.prototype,"_deleteButtonCommonInfo",null),e([c()],se.prototype,"_loading",void 0),e([c({readOnly:!0})],se.prototype,"activeWorkflow",null),e([c()],se.prototype,"headingLevel",void 0),e([c()],se.prototype,"hideTemplatesForInactiveLayers",null),e([c()],se.prototype,"icon",null),e([c()],se.prototype,"label",null),e([c()],se.prototype,"labelOptions",null),e([c()],se.prototype,"layerInfos",null),e([c(),Q("esri/widgets/Editor/t9n/Editor")],se.prototype,"messages",void 0),e([c(),Q("esri/t9n/common")],se.prototype,"messagesCommon",void 0),e([c(),Q("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],se.prototype,"messagesTemplates",void 0),e([c(),Q("esri/widgets/Feature/t9n/Feature")],se.prototype,"messagesFeature",void 0),e([c()],se.prototype,"snappingOptions",null),e([c()],se.prototype,"tooltipOptions",null),e([c()],se.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],se.prototype,"valueOptions",null),e([c()],se.prototype,"view",null),e([c(),X(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],se.prototype,"viewModel",void 0),e([c({type:y,nonNullable:!0})],se.prototype,"visibleElements",void 0),e([c()],se.prototype,"_helpMessage",null),se=e([d("esri.widgets.Editor")],se);const oe=se;export{oe as default};
|