@arcgis/core 4.29.0-next.20240221 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0bc21d2a0b65bd4e9d76.js +1 -0
- package/assets/esri/core/workers/chunks/{6e50220f8e2d392e2855.js → 5b275309d78453a9319e.js} +1 -1
- package/assets/esri/core/workers/chunks/{6fd8047741a0df006ddd.js → 69f6558b538d1b2d3086.js} +1 -1
- package/assets/esri/core/workers/chunks/{63c2ca47e8df5e9b5574.js → 87fb028c66de06bf6d75.js} +1 -1
- package/assets/esri/core/workers/chunks/9307d485a9e5f9fa77d1.js +1 -0
- package/assets/esri/core/workers/chunks/{958402a4f6dd0d23546d.js → a4c3da057ec2a07bbbe8.js} +1 -1
- package/assets/esri/core/workers/chunks/{48c6a9ed53cf4f9255b0.js → b454c6b992bcdbab36a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.js} +1 -1
- package/config.js +1 -1
- package/copyright.txt +56 -28
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/interfaces.d.ts +8 -8
- package/kernel.js +1 -1
- package/layers/orientedImagery/core/CameraOrientation.js +1 -1
- package/layers/orientedImagery/core/ElevationSourceDefinitions.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +5 -0
- package/layers/orientedImagery/transformations/updateElevation.js +5 -0
- package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +5 -0
- package/layers/support/EditingCapabilities.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/package.json +1 -1
- package/rest/print.js +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/layers/support/editableLayerViews.js +5 -0
- package/views/webgl/testDoublePrecisionArithmetic.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/25f73748df0ee82d06cb.js +0 -1
- package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.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 u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as R,DrapeSourceType as f,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import{ShaderOutput as S}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as P}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as O}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{Camera as j}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as q}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as I}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as U}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as k}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as H}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as G}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{ClearBufferBit as J,TextureSamplingMode as K}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends E{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new P,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new j,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[q.DRAPED_MATERIAL,e=>e!==S.Highlight||this.hasHighlights],[q.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._shaderTechniques=new O({rctx:this._rctx,viewingMode:y.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new F(this._rctx,new I(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new A(r.textureRepository,this._shaderTechniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=q.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=k.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new G(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(Y.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._shaderTechniques=a(this._shaderTechniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMemoryForMaterial(e){return Array.from(this._renderers.values()).reduce(((r,t)=>r+t.getMemoryForMaterial(e)),0)}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===R.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===H.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?C.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?C.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?C.Enabled:C.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets)(r.content!==v.ColorNoRasterImage||this._needsColorWithoutRasterImage)&&(this._drawTarget(w.INNER,r,e),this._drawTarget(w.OUTER,r,e))}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===S.Highlight&&!this.hasHighlights||n===S.Normal&&!this.hasWater||!s.hasSomeSizedView())return;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===S.Normal?q.DRAPED_WATER:q.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=se),!this.renders(r.content))return void(this._renderContext.renderOccludedMask=L);const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(J.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,re[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===S.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniqueRepository.acquire(z);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),e===w.OUTER&&u.generateMipMap(),this._renderContext.renderOccludedMask=L}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(J.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new ee(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new Z(e);i.samplingMode=K.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t);const a=new U;a.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniques.acquire(N,a)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),sortedDrapeSources:Array.from(this._sortedRenderers).map((({drapeSource:e})=>e)),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([c()],$.prototype,"hasHighlights",void 0),e([c()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],$.prototype,"_shaderTechniques",void 0),e([c({constructOnly:!0})],$.prototype,"view",void 0),e([c()],$.prototype,"worldToPCSRatio",void 0),e([c()],$.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([c()],$.prototype,"isEmpty",null),e([c({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([u("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.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 u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import{ShaderOutput as S}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as P}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as O}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{Camera as j}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as q}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as I}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as U}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as H}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as G}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{ClearBufferBit as J,TextureSamplingMode as K}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends E{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new P,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new j,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[q.DRAPED_MATERIAL,e=>e!==S.Highlight||this.hasHighlights],[q.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._shaderTechniques=new O({rctx:this._rctx,viewingMode:y.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new F(this._rctx,new I(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new A(r.textureRepository,this._shaderTechniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=q.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=U.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new G(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(Y.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._shaderTechniques=a(this._shaderTechniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMemoryForMaterial(e){return Array.from(this._renderers.values()).reduce(((r,t)=>r+t.getMemoryForMaterial(e)),0)}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===H.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?C.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?C.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?C.Enabled:C.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===S.Highlight&&!this.hasHighlights||n===S.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===S.Normal?q.DRAPED_WATER:q.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=se),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(J.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,re[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===S.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniqueRepository.acquire(z);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(J.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new ee(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new Z(e);i.samplingMode=K.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniques.acquire(N,a)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),sortedDrapeSources:Array.from(this._sortedRenderers).map((({drapeSource:e})=>e)),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([c()],$.prototype,"hasHighlights",void 0),e([c()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],$.prototype,"_shaderTechniques",void 0),e([c({constructOnly:!0})],$.prototype,"view",void 0),e([c()],$.prototype,"worldToPCSRatio",void 0),e([c()],$.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([c()],$.prototype,"isEmpty",null),e([c({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([u("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../core/Logger.js";import{equals as t,isGeographic as r,isWebMercator as i,isWGS84 as o}from"../../../geometry/support/spatialReferenceUtils.js";import{getMimeTypeFormatId as s,getFilenameFormatId as n}from"../../../layers/support/infoFor3D.js";import{ViewingMode as a}from"../../ViewingMode.js";const d="esri.views.layers.support.editableLayerViews";function c(c,l){const{associatedLayer:g}=c,p=g?.infoFor3D;if(!!!p)return!1;const{supportedFormats:u,queryFormats:f}=p,w=s("model/gltf-binary",u)??n("glb",u);if(!(null!=w&&f.includes(w)))return e.getLogger(d).warnOnce(`SceneLayer (${c.title??"Untitled layer"}, ${c.id}) does not support geometry edits because it does not support GLB queries.`),!1;const y=c.spatialReference,m=g.spatialReference;if(!t(y,m))return e.getLogger(d).warnOnce(`SceneLayer (${c.title??"Untitled layer"}, ${c.id}) does not support geometry edits because its spatial reference (wkid:${y.wkid}) is different from its associated FeatureLayer's spatial reference (wkid:${m.wkid}).`),!1;const $=g.sourceJSON.sourceSpatialReference;if(!(null==$||t($,m)))return e.getLogger(d).warnOnce(`SceneLayer (${c.title??"Untitled layer"}, ${c.id}) does not support geometry edits because the spatial reference of its associated FeatureLayer's service (wkid:${m.wkid}) is different from its source spatial reference (wkid:${$.wkid}).`),!1;const{view:{spatialReference:L,state:{viewingMode:k}}}=l,b=r(y),v=k===a.Global;if(b&&!v)return e.getLogger(d).warnOnce(`SceneLayer (${c.title??"Untitled layer"}, ${c.id}) does not support geometry edits in local viewing mode because its spatial reference (wkid:${y.wkid}) is geographic. Please consider changing the viewing mode to global.`),!1;if(!b&&v)return e.getLogger(d).warnOnce(`SceneLayer (${c.title??"Untitled layer"}, ${c.id}) does not support geometry edits in global viewing mode because its spatial reference (wkid:${y.wkid}) is projected. Please consider changing the viewing mode to local.`),!1;return!!(t(y,L)||v&&i(L)&&o(y))||(e.getLogger(d).warnOnce(`SceneLayer (${c.title??"Untitled layer"}, ${c.id}) does not support geometry edits because its spatial reference (wkid:${y.wkid}) does not match the view spatial reference (wkid:${L.wkid}).`),!1)}export{c as isGeometryEditableSceneLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unpackFloatRGBA as e}from"../../core/floatRGBA.js";import has from"../../core/has.js";import{disposeMaybe as n}from"../../core/maybe.js";import{fromValues as
|
|
5
|
+
import{unpackFloatRGBA as e}from"../../core/floatRGBA.js";import has from"../../core/has.js";import{disposeMaybe as n}from"../../core/maybe.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{BufferObject as r}from"./BufferObject.js";import{encodeDoubleArray as o}from"./doublePrecisionUtils.js";import{TextureWrapMode as i,TextureSamplingMode as s,Usage as c,DataType as a,PrimitiveType as u,PixelFormat as f,PixelType as l}from"./enums.js";import{FramebufferObject as p}from"./FramebufferObject.js";import{TextureDescriptor as m}from"./TextureDescriptor.js";import{VertexArrayObject as v}from"./VertexArrayObject.js";import{VertexElementDescriptor as h}from"./VertexElementDescriptor.js";import{WebGLDriverTestModule as d}from"./WebGLDriverTestModule.js";class _ extends d{constructor(e){super(),this._rctx=e,this._program=A(this._rctx,!1),this._obfuscated=A(this._rctx,!0)}dispose(){super.dispose(),this._obfuscated=n(this._obfuscated)}_test(e){if(has("force-double-precision-obfuscation"))return!0;if(null==this._obfuscated)return!1;const n=this._rctx,t=n.getBoundFramebufferObject(),{x:r,y:o,width:i,height:s}=n.getViewport(),c=this._runProgram(e),a=this._runProgram(this._obfuscated);return n.setViewport(r,o,i,s),n.bindFramebuffer(t),0!==c&&(0===a||c/a>5)}_runProgram(n){const d=this._rctx;d.resetState();const _=new m(1);_.wrapMode=i.CLAMP_TO_EDGE,_.samplingMode=s.NEAREST;const A=new p(d,_),b=r.createVertex(d,c.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),g=new v(d,new Map([["position",0]]),{geometry:[new h("position",2,a.UNSIGNED_SHORT,0,4)]},{geometry:b}),B=t(5633261.287538229,2626832.878767164,1434988.0495278358),w=t(5633271.46742708,2626873.6381334523,1434963.231608387),F=new Float32Array(6);o(B,F,3);const O=new Float32Array(6);o(w,O,3),d.useProgram(n),n.setUniform3f("u_highA",F[0],F[2],F[4]),n.setUniform3f("u_lowA",F[1],F[3],F[5]),n.setUniform3f("u_highB",O[0],O[2],O[4]),n.setUniform3f("u_lowB",O[1],O[3],O[5]),d.bindFramebuffer(A),d.setViewport(0,0,1,1),d.bindVAO(g),d.drawArrays(u.TRIANGLE_STRIP,0,4);const E=new Uint8Array(4);A.readPixels(0,0,1,1,f.RGBA,l.UNSIGNED_BYTE,E),g.dispose(),A.dispose();const x=(B[2]-w[2])/25,I=e(E);return Math.abs(x-I)}}function A(e,n){const t=`\n\n precision highp float;\n\n attribute vec2 position;\n\n uniform vec3 u_highA;\n uniform vec3 u_lowA;\n uniform vec3 u_highB;\n uniform vec3 u_lowB;\n\n varying vec4 v_color;\n\n ${n?"#define DOUBLE_PRECISION_REQUIRES_OBFUSCATION":""}\n\n #ifdef DOUBLE_PRECISION_REQUIRES_OBFUSCATION\n\n vec3 dpPlusFrc(vec3 a, vec3 b) {\n return mix(a, a + b, vec3(notEqual(b, vec3(0))));\n }\n\n vec3 dpMinusFrc(vec3 a, vec3 b) {\n return mix(vec3(0), a - b, vec3(notEqual(a, b)));\n }\n\n vec3 dpAdd(vec3 hiA, vec3 loA, vec3 hiB, vec3 loB) {\n vec3 t1 = dpPlusFrc(hiA, hiB);\n vec3 e = dpMinusFrc(t1, hiA);\n vec3 t2 = dpMinusFrc(hiB, e) + dpMinusFrc(hiA, dpMinusFrc(t1, e)) + loA + loB;\n return t1 + t2;\n }\n\n #else\n\n vec3 dpAdd(vec3 hiA, vec3 loA, vec3 hiB, vec3 loB) {\n vec3 t1 = hiA + hiB;\n vec3 e = t1 - hiA;\n vec3 t2 = ((hiB - e) + (hiA - (t1 - e))) + loA + loB;\n return t1 + t2;\n }\n\n #endif\n\n const float MAX_RGBA_FLOAT =\n 255.0 / 256.0 +\n 255.0 / 256.0 / 256.0 +\n 255.0 / 256.0 / 256.0 / 256.0 +\n 255.0 / 256.0 / 256.0 / 256.0 / 256.0;\n\n const vec4 FIXED_POINT_FACTORS = vec4(1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0);\n\n vec4 float2rgba(const float value) {\n // Make sure value is in the domain we can represent\n float valueInValidDomain = clamp(value, 0.0, MAX_RGBA_FLOAT);\n\n // Decompose value in 32bit fixed point parts represented as\n // uint8 rgba components. Decomposition uses the fractional part after multiplying\n // by a power of 256 (this removes the bits that are represented in the previous\n // component) and then converts the fractional part to 8bits.\n vec4 fixedPointU8 = floor(fract(valueInValidDomain * FIXED_POINT_FACTORS) * 256.0);\n\n // Convert uint8 values (from 0 to 255) to floating point representation for\n // the shader\n const float toU8AsFloat = 1.0 / 255.0;\n\n return fixedPointU8 * toU8AsFloat;\n }\n\n void main() {\n vec3 val = dpAdd(u_highA, u_lowA, -u_highB, -u_lowB);\n\n v_color = float2rgba(val.z / 25.0);\n\n gl_Position = vec4(position * 2.0 - 1.0, 0.0, 1.0);\n }\n `,r="\n precision highp float;\n\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }\n ";return e.programCache.acquire(t,r,new Map([["position",0]]))}export{_ as DoublePrecisionRequiresObfuscation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,initial as h,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import g from"../../layers/GraphicsLayer.js";import{isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import{ViewEventPriorities as v}from"../../views/input/InputManager.js";import _ from"../../views/interactive/sketch/SketchOptions.js";import M from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as F}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as I,handleModelUpload as k}from"./modelUploadUtils.js";import b from"./Workflow.js";import{startCreatingNewFeature as V,findLayerInfo as A,updateGraphicSymbolWhenRequired as H,isTerminalUpdateEventType as S,getVisualVariableAttributes as j,startUpdatingFeature as C,createWorkflowSteps as O,avoidFeatureTemplateSelectionWithOnlyOneItem as U,showProgressCursor as E,visualVariableInteractiveUpdate as D,prepareAttachmentsForCreateFeaturesWorkflow as G}from"./workflowUtils.js";import L from"../FeatureForm/FeatureFormViewModel.js";import T from"../Sketch/SketchViewModel.js";var P;const W=Symbol(),x=Symbol(),N=Symbol();let z=P=class extends b{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new L,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>H(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.numPendingFeatures>0)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 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}return y(a,i?.geometry)}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.editorItem?.capabilities.create.attachments.enabled??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)},sketchViewModel:this._sketchViewModel}}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([N])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this._sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,snappingManager:n,startAt:o,viewModel:l}=e,c=e.sketchOptions??new _,d=r?.layer,h=d?l.findEditorItemForLayer(d):void 0,p=new P({data:new F({creationInfo:r,editorItem:h,parent:s,sketchOptions:c,snappingManager:n,viewModel:l}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=p._attachmentFileInfos;if(n){const e=q(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const l=await a(s,{addFeatures:r});if(o.size>0){const e=l?.addFeatureResults??[];await t(s,Z(r,e,s,o))}}});return p._set("steps",this._createWorkflowSteps(p,o)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(x);const{creationInfo:t}=this.data;if(!t)return;this.createFeatureState="create-new";const a=await V(this._sketchViewModel,t,e);this.addHandles(a,x)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{_featureFormViewModel:i,_sketchViewModel:r}=this,{creationInfo:o,viewModel:l}=this.data,{attachmentsViewModel:d,layerInfos:h,view:p}=l;if(!p||!o)return;const u=o.layer,f=A(h,u),m=f?.formTemplate,g=p.spatialReference;i.set({arcadeEditType:"INSERT",feature:e,formTemplate:m,spatialReference:g,map:p.map}),"add"!==d.mode&&"edit"!==d.mode||l.activeWorkflow?.previous(),d.graphic=e,d.fileInfos.removeAll(),d.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>d.addFile(e,t))),this._removeHighlight(e),await H(e,t,"2d"===p.type?p.scale:null),this.removeHandles(x),n(this._featureFormHandle),"2d"===p.type){const a=c((()=>p.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,x)}return this._featureFormHandle=s([i.on("value-change",(async()=>{e.attributes=i.getValues(),await H(e,t,"2d"===p.type?p.scale:null)})),r.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&S(e.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=j(e),w(u)?void 0:C({graphic:e,sketchViewModel:r,sourceLayer:u,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=O(["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&&(I(t)?e.addHandles(await k({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),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,x])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([N,W,x]),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 U(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{creationInfo:n,viewModel:o}=i,{view:l}=o,c=e._sketchViewModel;let h=null;const p=[];if(!l)return r();"2d"===l.type&&n&&p.push(e._fadeExistingFeatures(n.layer)),p.push(c.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),c.on("update",(async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e,s=a.graphics[0];if("complete"===a.state){if(s!==h&&(e._lastActiveGraphics.push(s),e._highlight(s)),h=null,e.numPendingFeatures===n?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([E(l),l.on("click",(e=>e.preventDefault()))],W),await d((()=>!r.updating)),e.removeHandles(W),e._startCreating(t)}"start"===a.state&&e._removeHighlight(s);const c=e._visualVariableAttributes;await D(l,s,a,c,t);const p=s.attributes,{rotation:u,size:f}=c;if(null!=u){const{field:e}=u;r.setValue(e,p[e])}if(null!=f){const{field:e}=f;r.setValue(e,p[e])}})),c.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),h=i})),l.on("immediate-click",(async a=>{if(I(n))return;const{results:i}=await l.hitTest(a,{include:c.layer}),r=i.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===n?.layer));if(!r)return;const s=r.graphic;if("transform"===c.activeTool||"reshape"===c.activeTool){if(c.updateGraphics.at(0)===s)return;await e.updatePendingFeature(s,t)}}),v.TOOL),r((()=>{e._preventDefaultActionOnCancel=!0,c.cancel()})),R(c,i));const u=s(p);return c.addHandles(u),u}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new g({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide"}),i=new T({layer:a,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:t});this._sketchViewModel=i,t?.map.add(a),this.addHandles(r((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})))}async _setUpCreatingFeaturesStep(){if(this.hasHandles(N))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:o,view:l}=a;if(!l||!e?.layer)throw new i("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:d,layer:p}=e,u=this._sketchViewModel,f=new Map,m=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},this.data.editorItem=a.findEditorItemForLayer(e.layer),G(o),m.push(c((()=>o.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const g=E(l);m.push(g);const y=w(e.layer);try{if(y){const a=d??new t({attributes:{...e.template?.prototype.attributes,...e.attributeOverrides},sourceLayer:p});await this._startUpdating(a,f)}else m.push(P._configureSketchViewModel(this,f)),d?(u.layer.add(d),await this._startUpdating(d,f)):await this._startCreating(f)}finally{g.remove()}const v=r((()=>this.pendingFeatures.drain((e=>u.layer.remove(e))))),_=c((()=>l?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),M=r((()=>{I(e)&&a.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&m.push(this._featureFormHandle),this.addHandles(m,this._handleKeys.beforeCommit),this.addHandles([r((()=>o.fileInfos.removeAll())),s(m),M,v,_],N)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new M({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function Z(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function q(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([f({constructOnly:!0})],z.prototype,"isNested",void 0),e([f()],z.prototype,"featureFormViewModel",null),e([f()],z.prototype,"hasPendingEdits",null),e([f()],z.prototype,"_getDrawMeshHelpMessage",void 0),e([f()],z.prototype,"helpMessage",null),e([f()],z.prototype,"layer",null),e([f()],z.prototype,"parent",null),e([f()],z.prototype,"parentLayer",null),e([f()],z.prototype,"keyboardCancellationEnabled",null),e([f()],z.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],z.prototype,"shouldShowAttachments",null),e([f()],z.prototype,"shouldAllowAttachmentEditing",null),e([f()],z.prototype,"sketchViewModel",null),z=P=e([m("esri.widgets.Editor.CreateFeaturesWorkflow")],z);const K=z;export{K as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,initial as h,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import g from"../../layers/GraphicsLayer.js";import{isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import{ViewEventPriorities as v}from"../../views/input/InputManager.js";import _ from"../../views/interactive/sketch/SketchOptions.js";import M from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as F}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as I}from"./modelUploadUtils.js";import k from"./Workflow.js";import{startCreatingNewFeature as V,findLayerInfo as A,updateGraphicSymbolWhenRequired as H,isTerminalUpdateEventType as S,getVisualVariableAttributes as j,startUpdatingFeature as C,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as O,showProgressCursor as E,visualVariableInteractiveUpdate as D,prepareAttachmentsForCreateFeaturesWorkflow as G}from"./workflowUtils.js";import L from"../FeatureForm/FeatureFormViewModel.js";import T from"../Sketch/SketchViewModel.js";var P;const W=Symbol(),x=Symbol(),N=Symbol();let z=P=class extends k{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new L,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>H(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.numPendingFeatures>0)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 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}return y(a,i?.geometry)}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.editorItem?.capabilities.create.attachments.enabled??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)},sketchViewModel:this._sketchViewModel}}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([N])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this._sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,snappingManager:n,startAt:o,viewModel:l}=e,c=e.sketchOptions??new _,d=r?.layer,h=d?l.findEditorItemForLayer(d):void 0,p=new P({data:new F({creationInfo:r,editorItem:h,parent:s,sketchOptions:c,snappingManager:n,viewModel:l}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=p._attachmentFileInfos;if(n){const e=q(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const l=await a(s,{addFeatures:r});if(o.size>0){const e=l?.addFeatureResults??[];await t(s,Z(r,e,s,o))}}});return p._set("steps",this._createWorkflowSteps(p,o)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(x);const{creationInfo:t}=this.data;if(!t)return;this.createFeatureState="create-new";const a=await V(this._sketchViewModel,t,e);this.addHandles(a,x)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{_featureFormViewModel:i,_sketchViewModel:r}=this,{creationInfo:o,viewModel:l}=this.data,{attachmentsViewModel:d,layerInfos:h,view:p}=l;if(!p||!o)return;const u=o.layer,f=A(h,u),m=f?.formTemplate,g=p.spatialReference;i.set({arcadeEditType:"INSERT",feature:e,formTemplate:m,spatialReference:g,map:p.map}),"add"!==d.mode&&"edit"!==d.mode||l.activeWorkflow?.previous(),d.graphic=e,d.fileInfos.removeAll(),d.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>d.addFile(e,t))),this._removeHighlight(e),await H(e,t,"2d"===p.type?p.scale:null),this.removeHandles(x),n(this._featureFormHandle),"2d"===p.type){const a=c((()=>p.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,x)}return this._featureFormHandle=s([i.on("value-change",(async()=>{e.attributes=i.getValues(),await H(e,t,"2d"===p.type?p.scale:null)})),r.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&S(e.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=j(e),w(u)?void 0:C({graphic:e,sketchViewModel:r,sourceLayer:u,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["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&&(b(t)?e.addHandles(await I({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),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,x])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([N,W,x]),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 O(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{creationInfo:n,viewModel:o}=i,{view:l}=o,c=e._sketchViewModel;let h=null;const p=[];if(!l)return r();"2d"===l.type&&n&&p.push(e._fadeExistingFeatures(n.layer)),p.push(c.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),c.on("update",(async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e,s=a.graphics[0];if("complete"===a.state){if(s!==h&&(e._lastActiveGraphics.push(s),e._highlight(s)),h=null,e.numPendingFeatures===n?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if(!r.submittable){r.submit();const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([E(l),l.on("click",(e=>e.preventDefault()))],W),await d((()=>!r.updating)),e.removeHandles(W),e._startCreating(t)}"start"===a.state&&e._removeHighlight(s);const c=e._visualVariableAttributes;await D(l,s,a,c,t);const p=s.attributes,{rotation:u,size:f}=c;if(null!=u){const{field:e}=u;r.setValue(e,p[e])}if(null!=f){const{field:e}=f;r.setValue(e,p[e])}})),c.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),h=i})),l.on("immediate-click",(async a=>{if(b(n))return;const{results:i}=await l.hitTest(a,{include:c.layer}),r=i.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===n?.layer));if(!r)return;const s=r.graphic;if("transform"===c.activeTool||"reshape"===c.activeTool){if(c.updateGraphics.at(0)===s)return;if(!e._featureFormViewModel.submittable)return;await e.updatePendingFeature(s,t)}}),v.TOOL),r((()=>{e._preventDefaultActionOnCancel=!0,c.cancel()})),R(c,i));const u=s(p);return c.addHandles(u),u}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new g({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide"}),i=new T({layer:a,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:t});this._sketchViewModel=i,t?.map.add(a),this.addHandles(r((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})))}async _setUpCreatingFeaturesStep(){if(this.hasHandles(N))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:o,view:l}=a;if(!l||!e?.layer)throw new i("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:d,layer:p}=e,u=this._sketchViewModel,f=new Map,m=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},this.data.editorItem=a.findEditorItemForLayer(e.layer),G(o),m.push(c((()=>o.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const g=E(l);m.push(g);const y=w(e.layer);try{if(y){const a=d??new t({attributes:{...e.template?.prototype.attributes,...e.attributeOverrides},sourceLayer:p});await this._startUpdating(a,f)}else m.push(P._configureSketchViewModel(this,f)),d?(u.layer.add(d),await this._startUpdating(d,f)):await this._startCreating(f)}finally{g.remove()}const v=r((()=>this.pendingFeatures.drain((e=>u.layer.remove(e))))),_=c((()=>l?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),M=r((()=>{b(e)&&a.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&m.push(this._featureFormHandle),this.addHandles(m,this._handleKeys.beforeCommit),this.addHandles([r((()=>o.fileInfos.removeAll())),s(m),M,v,_],N)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new M({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function Z(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function q(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([f({constructOnly:!0})],z.prototype,"isNested",void 0),e([f()],z.prototype,"featureFormViewModel",null),e([f()],z.prototype,"hasPendingEdits",null),e([f()],z.prototype,"_getDrawMeshHelpMessage",void 0),e([f()],z.prototype,"helpMessage",null),e([f()],z.prototype,"layer",null),e([f()],z.prototype,"parent",null),e([f()],z.prototype,"parentLayer",null),e([f()],z.prototype,"keyboardCancellationEnabled",null),e([f()],z.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],z.prototype,"shouldShowAttachments",null),e([f()],z.prototype,"shouldAllowAttachmentEditing",null),e([f()],z.prototype,"sketchViewModel",null),z=P=e([m("esri.widgets.Editor.CreateFeaturesWorkflow")],z);const K=z;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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",G=()=>l.getLogger(x),D=["create-features","update"];function q(t,e,a){G().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...D]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(G(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>{if(!F(t))return!1;const{geometryType:a,spatialReference:r}=t;if("mesh"===a){if("3d"!==e.type)return!1;const{isGeographic:t}=r;switch(e.viewingMode){case"global":return t;case"local":return!t}}return!0})).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...D]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;export{N as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedProperty as r,deprecated as i}from"../../core/deprecate.js";import s from"../../core/Error.js";import o from"../../core/Evented.js";import{makeHandle as n}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{abortMaybe as p,removeMaybe as d,destroyMaybe as c}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as h}from"../../core/promiseUtils.js";import{watch as w,on as f,when as m,whenOnce as y,syncAndInitial as k,initial as g,sync as v}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import I from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import V from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import U from"../../views/interactive/snapping/SnappingOptions.js";import T from"../Attachments/AttachmentsViewModel.js";import L from"./CreateFeaturesWorkflow.js";import A from"./UpdateWorkflow.js";import{whenEditorLayerView as j}from"./workflowUtils.js";import S from"./support/EditorItem.js";import P from"../FeatureTemplates/FeatureTemplatesViewModel.js";import R from"../Sketch/SketchViewModel.js";import H from"../Spinner/SpinnerViewModel.js";const x="esri.widgets.Editor.EditorViewModel",D=()=>l.getLogger(x),G=["create-features","update"];function q(t,e,a){D().error(new s(t,e,a))}function B(t,e){return t?.find((t=>t.layer===e))}let Q=class extends o.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new I({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new T({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new P({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.ownSketchViewModel=new R({layer:this._sketchGraphicsLayer}),this.sketchOptions=new V,this.snappingOptions=new U,this.spinnerViewModel=new H,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t){if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,r=a?.filter((t=>!!e?.includes(t.layer)));return[e,r,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditorItems()),k),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),f((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),f((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),m((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),g),f((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),k),m((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),f((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const r={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),f((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,r=a?e.activeWorkflow?.layer:e?.layer,i=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:r,parentLayer:i})}),v),w((()=>this.view),(t=>{if(this._snappingManager=c(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new O({view:t,options:e})}),k),w((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),k)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=d(this._sketchEventListenerHandle)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){r(l.getLogger(this),"allowedWorkflows",{replacement:"Editor.visibleElements",version:"4.29",warnOnce:!0}),t&&0!==t.length||(t=[...G]),this._set("allowedWorkflows",t)}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,r=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!r&&t.push(e.layer)}return t}get editableItems(){return r(l.getLogger(this),"editableItems",{replacement:"editorItems",version:"4.29",warnOnce:!0}),this.editorItems.map((t=>{const{capabilities:e,disabled:a,hasInvalidFormTemplate:r,layer:i}=t,s=[],o=e.create,n=e.update,l=e.delete;return o.enabled&&s.push("create"),n.enabled&&s.push("update"),l.enabled&&s.push("delete"),{layer:i,supports:s,suspended:a,attributeUpdatesEnabled:n.attributes,geometryUpdatesEnabled:n.geometry,attachmentsOnCreateEnabled:o.attachments.enabled,attachmentsOnUpdateEnabled:n.attachments.enabled,hasInvalidFormTemplate:r,hasAttachments:e.attachments.enabled}}))}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}set layerInfos(t){const e=t?.some((t=>"allowAttachments"in t));e&&i(D(),"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),this._set("layerInfos",t)}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await y((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",r),await r.start(),a.resolve()}async startCreateFeaturesWorkflowAtFeatureEdit(t){await y((()=>!this.updating));const e=this._createUpdatingResolver(),{initialFeature:a}=t,r=a.sourceLayer,i=r?this.findEditorItemForLayer(r):void 0;if(!i?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:a,layer:i.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start(),e.resolve()}async startUpdateWorkflowAtFeatureSelection(){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start(),t.resolve()}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("awaiting-update-feature-candidate");a.data.candidates=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async startUpdateWorkflowAtFeatureEdit(t){if(await y((()=>!this.updating)),!this.canUpdate)return void q("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();await this._cancelWorkflow();const a=this._createUpdateWorkflow("editing-existing-feature");a.data.rootFeature=t,this._set("activeWorkflow",a),await a.start(),e.resolve()}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():q("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,n((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,r=a.editableLayers.toArray()??[],i=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...r.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...i.map((t=>t.load()))]),u(t),[...r.reverse(),...i.reverse()].filter((t=>F(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){p(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const r=[],i=[],s=[],{layerInfos:o}=this;for(const l of a){const e=B(o,l),a=await j(t,l).catch((()=>null));(e?r:a?i:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&r.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...r,...i,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&q("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return L.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return A.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await M(t.url):null,s={returnServiceEditsOption:(!i||!C(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const i=await j(a,t).catch((()=>null));return r=await t.applyEdits(e,s),i&&await y((()=>!i.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{q("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue)}))}_createUpdatingResolver(){const t=h();return this._updatingHandles.addPromise(t.promise),t}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([_({readOnly:!0})],Q.prototype,"activeWorkflow",void 0),t([_({readOnly:!0})],Q.prototype,"_activityQueue",void 0),t([_({value:[...G]})],Q.prototype,"allowedWorkflows",null),t([_({readOnly:!0})],Q.prototype,"canCreate",null),t([_()],Q.prototype,"canCreateVisible",null),t([_({readOnly:!0})],Q.prototype,"canUpdate",null),t([_()],Q.prototype,"canUpdateVisible",null),t([_()],Q.prototype,"featureTemplatesLayers",null),t([_()],Q.prototype,"editableItems",null),t([_()],Q.prototype,"editorItems",void 0),t([_({readOnly:!0})],Q.prototype,"failures",void 0),t([_()],Q.prototype,"hideTemplatesForInactiveLayers",void 0),t([_()],Q.prototype,"attachmentsViewModel",void 0),t([_()],Q.prototype,"featureFormViewModel",null),t([_()],Q.prototype,"featureTemplatesViewModel",void 0),t([_()],Q.prototype,"labelOptions",null),t([_()],Q.prototype,"layerInfos",null),t([_()],Q.prototype,"ownSketchViewModel",void 0),t([_()],Q.prototype,"sketchOptions",void 0),t([_()],Q.prototype,"sketchViewModel",null),t([_({type:U,nonNullable:!0})],Q.prototype,"snappingOptions",void 0),t([_()],Q.prototype,"spinnerViewModel",void 0),t([_()],Q.prototype,"state",null),t([_({readOnly:!0})],Q.prototype,"syncing",null),t([_()],Q.prototype,"updating",null),t([_()],Q.prototype,"tooltipOptions",null),t([_()],Q.prototype,"valueOptions",null),t([_()],Q.prototype,"view",null),t([_()],Q.prototype,"pageStack",void 0),t([_()],Q.prototype,"showDiscardEditsPrompt",void 0),t([_()],Q.prototype,"_candidateCommitted",void 0),t([_()],Q.prototype,"page",null),t([_()],Q.prototype,"featureFormDisabled",null),t([_()],Q.prototype,"canGoBack",null),t([_()],Q.prototype,"shouldShowDeleteButton",null),t([_()],Q.prototype,"hasPendingEdits",null),Q=t([W(x)],Q);const N=Q;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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}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 a from"../../../layers/support/EditingCapabilities.js";import{isRelatableFeatureSupportedLayer as n}from"../../Feature/support/featureUtils.js";let
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}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 a from"../../../layers/support/EditingCapabilities.js";import{isGeometryEditableSceneLayer as l}from"../../../views/layers/support/editableLayerViews.js";import{isRelatableFeatureSupportedLayer as n}from"../../Feature/support/featureUtils.js";let s=class extends a{constructor(e){super(e),this.layerInfo=null,this.layerView=null}get attachments(){const e=this.defaults.attachments.enabled,t=this.layerInfo;return{enabled:e&&!1!==t?.allowAttachments&&!1!==t?.enabled}}get create(){const{attachments:e,defaults:t,layerInfo:r,layer:a,layerView:l}=this,n=t.create,s=!1!==r?.enabled&&!1!==r?.addEnabled,i=n.enabled&&s;return{attributes:i&&n.attributes,enabled:i,geometry:i&&n.geometry&&o(a,l),attachments:{enabled:e.enabled&&i&&!1!==r?.attachmentsOnCreateEnabled},reliesOnOwnerAdminPrivileges:n.reliesOnOwnerAdminPrivileges}}get defaults(){return new a({layer:this.layer})}get delete(){const{defaults:e,layerInfo:t}=this,r=e.delete,a=!1!==t?.enabled&&!1!==t?.deleteEnabled;return{enabled:r.enabled&&a,reliesOnOwnerAdminPrivileges:r.reliesOnOwnerAdminPrivileges}}get formTemplate(){const{layer:e,layerInfo:t}=this;return t?.formTemplate?t.formTemplate:e&&"formTemplate"in e?e.formTemplate:null}get relationship(){const{layer:e}=this,t=!(!n(e)||!e.relationships?.length),r=!!this.formTemplate?.elements?.some((e=>"relationship"===e.type));return{enabled:t&&r}}get update(){const{attachments:e,defaults:t,layerInfo:r,layer:a,layerView:l}=this,n=t.update,s=!1!==r?.enabled&&!1!==r?.updateEnabled,i=n.enabled&&s,p=i&&n.attributes&&!1!==r?.attributeUpdatesEnabled,d=i&&n.geometry&&!1!==r?.geometryUpdatesEnabled&&o(a,l),m=e.enabled&&!1!==r?.attachmentsOnUpdateEnabled;return{attributes:p,enabled:i,geometry:d,attachments:{enabled:m,create:m&&n.attachments.create,update:m&&n.attachments.update},reliesOnOwnerAdminPrivileges:n.reliesOnOwnerAdminPrivileges}}};function o(e,t){return"scene"!==e.type||null!=t&&"type"in t&&"scene-layer-3d"===t.type&&l(e,t)}e([t()],s.prototype,"attachments",null),e([t()],s.prototype,"create",null),e([t()],s.prototype,"defaults",null),e([t()],s.prototype,"delete",null),e([t()],s.prototype,"formTemplate",null),e([t()],s.prototype,"layerInfo",void 0),e([t()],s.prototype,"layerView",void 0),e([t()],s.prototype,"relationship",null),e([t()],s.prototype,"update",null),s=e([r("esri.widgets.Editor.support.EditorEditingCapabilities")],s);const i=s;export{i 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import i from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as l}from"../../FeatureForm/featureFormUtils.js";let a=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new i({layer:this.layer,layerInfo:this.layerInfo,layerView:this.layerView})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return l(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){if(this.disabled)return!1;const{enabled:e,geometry:t}=this.capabilities.create;return this.isTable?e:e&&t}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],a.prototype,"_suspended",null),e([r()],a.prototype,"capabilities",null),e([r()],a.prototype,"disabled",void 0),e([r()],a.prototype,"editable",null),e([r()],a.prototype,"formTemplate",null),e([r()],a.prototype,"hasInvalidFormTemplate",null),e([r()],a.prototype,"isTable",null),e([r()],a.prototype,"layer",void 0),e([r()],a.prototype,"layerInfo",void 0),e([r()],a.prototype,"layerView",void 0),e([r()],a.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],a.prototype,"supportsUpdateWorkflow",null),e([r()],a.prototype,"visible",null),a=e([s("esri.widgets.editor.support.EditorItem")],a);const p=a;export{p as default};
|
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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{mappedFind as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as r,initial as a,on as n,when as l}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../views/interactive/sketch/SketchValueOptions.js";import c from"./Attachments.js";import h from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as f}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{warningIcon as _}from"./Editor/icons.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as F,CreateFeaturesPanelContent as M}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as b,FeatureList as C}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as E,FooterActions as W}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as A,Notice as T}from"./Editor/components/Notices.js";import{loadPanelContentComponents as j,PanelContent as P,PanelContentSection as L,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as U,loadPanelToolbarComponents as S}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as O,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as x,UpdateFeaturePanelContent as B}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as V,UploadDetails as G}from"./Editor/components/UploadDetails.js";import{renderItem as R}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as q}from"./support/componentsUtils.js";import{globalCss as H}from"./support/globalCss.js";import{incrementHeadingLevel as N,Heading as z}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as J}from"./support/decorators/vmEvent.js";import{tsx as K}from"./support/jsxFactory.js";import{substitute as Q}from"../intl/substitute.js";let X=class extends w{constructor(e,t){super(e,t),this._featureForm=new h,this._attachments=new c({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?K("calcite-icon",{class:f.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.headingLevel=4,this.iconClass=f.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new k,this._renderSelectIcon=()=>K("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t},...s)=>K("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,onCalciteFlowItemBack:this._onBack,onCalciteFlowItemScroll:this._featureForm?.onScroll},K(U,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:this.visibleElements}),...s),this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPrompt("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):this._showPrompt({title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._prompt={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._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._prompt={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._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null}}initialize(){this.addHandles([r((()=>N(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),a),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}),a),r((()=>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}),a),r((()=>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"})}),a),l((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.ownSketchViewModel.set(e.sketch)}),a),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._prompt={title:t.errorWarningTitle,message:Q(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}}})),r((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),r((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return Promise.all([q({"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js")}),F(),b(),E(),A(),j(),S(),O(),x(),V()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _loading(){const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){t(s.getLogger(this),"allowedWorkflows",{replacement:"visibleElements",version:"4.29",warnOnce:!0}),this.viewModel.allowedWorkflows=e}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=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()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this,t=this.classes(f.base,H.widget,H.panel);return e?K("div",{class:t,key:"base"},K("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e)))),this._prompt?K(D,{...this._prompt,headingLevel:this.headingLevel}):void 0):K("div",{class:t,key:"empty"})}_renderPage(e){switch(e){case"disabled":break;case"ready":return this._renderReady();case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo();case"creating-features-upload-details":return this._renderUploadDetails();case"creating-features":return this._renderCreatingFeatures();case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature();case"awaiting-update-feature-candidate":return this._renderFeatureList();case"adding-attachment":return this._renderAttachmentAdding();case"editing-attachment":return this._renderAttachmentEditing()}return K("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(){const{EditorPanel:e,messages:t}=this;return K(e,{heading:t.selectTemplate,key:"templates-panel"},K(P,{key:"feature-templates"},K(L,null,this._featureTemplates.render())))}_renderUploadDetails(){const{EditorPanel:e,activeWorkflow:t,messages:s}=this;if("create-features"!==t?.type)return null;const o=t.data.upload;return o?K(e,{heading:s.createFeatures,key:"upload-details-panel"},K(G,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(){const{EditorPanel:e,activeWorkflow:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this;if(!t)return null;const a="create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&"create-features"===t?.activeWorkflow?.type&&t.activeWorkflow?.numPendingFeatures>0;return K(e,{heading:s.createFeatures,key:"create-features-panel"},a?K(B,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}):K(M,{helpMessage:this._helpMessage}))}_renderUpdateFeature(){const{EditorPanel:e,messages:t,messagesCommon:s,headingLevel:o,viewModel:i}=this;return K(e,{heading:t.editFeature,key:"update-feature-panel"},K(B,{editorViewModel:i,headingLevel:o,messages:t,messagesCommon:s,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this,i=o(e.group.items,(e=>s.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?K(T,{icon:_,message:i}):null}_renderAttachmentAdding(){const{EditorPanel:e,_attachments:t,messages:s,messagesCommon:o}=this;return K(e,{heading:s.addAttachment,key:"attachment-adding-panel"},K(P,{key:"attachments"},t.render()),K(W,{buttons:[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentAdd}]}))}_renderAttachmentEditing(){const{EditorPanel:e,_attachments:t,activeWorkflow:s,messages:o,messagesCommon:i}=this;return s?K(e,{heading:o.editAttachment,key:"attachment-editing-panel"},K(P,{key:"attachments"},t.render()),s.shouldAllowAttachmentEditing?K(W,{buttons:[{label:i.update,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:t.submitting,label:i.delete}]}):void 0):null}_renderReady(){const{EditorPanel:e,messages:t,viewModel:s,visibleElements:o}=this,i=this._helpMessage;return K(e,{heading:t.widgetLabel,key:"landing-panel"},K(P,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?K(L,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?K(L,{key:"create-actions"},this._renderCreateActions()):null]:K(I,{key:"no-content"},t.noEditableLayers)),i?K("div",{class:f.helpMessage,key:"footer-actions",slot:"footer"},i):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 K("div",{class:f.updateActions,key:"update-actions"},K(z,{level:N(this.headingLevel)},e.editFeatures),K("calcite-list",{class:f.updateActionsList,selectionAppearance:"border",selectionMode:"single"},R({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 K("div",{key:"create-actions"},K(z,{level:N(this.headingLevel)},this.messages.createFeatures),K("div",{class:f.featureTemplatesContainer,key:"templates"},this._featureTemplates.render()))}_renderFeatureList(){const{EditorPanel:e,viewModel:t}=this,{activeWorkflow:s}=t;if("update"!==s?.type)return null;const o=s.data.candidates,i=Q(this.messages.multipleFeaturesTemplate,{total:o.length});return K(e,{heading:i,key:"feature-list"},K(C,{editorItems:t.editorItems,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:s,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,s)=>t.selectFeature(e,s)}))}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const r=i(),{view:a}=this,n=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>r.resolve(!0)},secondary:{label:o,action:()=>r.resolve(!1)}}},r.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}};e([d()],X.prototype,"_featureForm",void 0),e([d()],X.prototype,"_attachments",void 0),e([d()],X.prototype,"_featureTemplates",void 0),e([d()],X.prototype,"_filterText",void 0),e([d()],X.prototype,"_prompt",void 0),e([d()],X.prototype,"_spinner",void 0),e([d()],X.prototype,"_deleteButtonCommonInfo",null),e([d()],X.prototype,"_loading",null),e([d({readOnly:!0})],X.prototype,"activeWorkflow",null),e([d()],X.prototype,"allowedWorkflows",null),e([d()],X.prototype,"headingLevel",void 0),e([d()],X.prototype,"hideTemplatesForInactiveLayers",null),e([d()],X.prototype,"iconClass",void 0),e([d()],X.prototype,"label",null),e([d()],X.prototype,"labelOptions",null),e([d()],X.prototype,"layerInfos",null),e([d(),$("esri/widgets/Editor/t9n/Editor")],X.prototype,"messages",void 0),e([d(),$("esri/t9n/common")],X.prototype,"messagesCommon",void 0),e([d(),$("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],X.prototype,"messagesTemplates",void 0),e([d()],X.prototype,"snappingOptions",null),e([d()],X.prototype,"tooltipOptions",null),e([d()],X.prototype,"supportingWidgetDefaults",void 0),e([d({type:p,nonNullable:!0})],X.prototype,"valueOptions",null),e([d()],X.prototype,"view",null),e([d(),J(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],X.prototype,"viewModel",void 0),e([d({type:k,nonNullable:!0})],X.prototype,"visibleElements",void 0),e([d()],X.prototype,"_helpMessage",null),X=e([m("esri.widgets.Editor")],X);const Y=X;export{Y as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{mappedFind as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as r,initial as a,on as n,when as l}from"../core/reactiveUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../views/interactive/sketch/SketchValueOptions.js";import c from"./Attachments.js";import h from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as f}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{warningIcon as _}from"./Editor/icons.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as F,CreateFeaturesPanelContent as M}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as b,FeatureList as C}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as E,FooterActions as W}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as A,Notice as T}from"./Editor/components/Notices.js";import{loadPanelContentComponents as j,PanelContent as P,PanelContentSection as L,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as U,loadPanelToolbarComponents as S}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as O,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as x,UpdateFeaturePanelContent as V}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as B,UploadDetails as G}from"./Editor/components/UploadDetails.js";import{renderItem as R}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as q}from"./support/componentsUtils.js";import{globalCss as H}from"./support/globalCss.js";import{incrementHeadingLevel as N,Heading as z}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as $}from"./support/decorators/messageBundle.js";import{vmEvent as J}from"./support/decorators/vmEvent.js";import{tsx as K}from"./support/jsxFactory.js";import{substitute as Q}from"../intl/substitute.js";let X=class extends w{constructor(e,t){super(e,t),this._featureForm=new h,this._attachments=new c({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?K("calcite-icon",{class:f.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.headingLevel=4,this.iconClass=f.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new k,this._renderSelectIcon=()=>K("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t},...s)=>K("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,onCalciteFlowItemBack:this._onBack,onCalciteFlowItemScroll:this._featureForm?.onScroll},K(U,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:this.visibleElements}),...s),this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPrompt("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):this._showPrompt({title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._prompt={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._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._prompt={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._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null}}initialize(){this.addHandles([r((()=>N(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),a),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}),a),r((()=>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}),a),r((()=>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"})}),a),r((()=>[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))}),a),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._prompt={title:t.errorWarningTitle,message:Q(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}}})),r((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),r((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return Promise.all([q({"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js")}),F(),b(),E(),A(),j(),S(),O(),x(),B()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _loading(){const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){t(s.getLogger(this),"allowedWorkflows",{replacement:"visibleElements",version:"4.29",warnOnce:!0}),this.viewModel.allowedWorkflows=e}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=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()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this,t=this.classes(f.base,H.widget,H.panel);return e?K("div",{class:t,key:"base"},K("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e)))),this._prompt?K(D,{...this._prompt,headingLevel:this.headingLevel}):void 0):K("div",{class:t,key:"empty"})}_renderPage(e){switch(e){case"disabled":break;case"ready":return this._renderReady();case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo();case"creating-features-upload-details":return this._renderUploadDetails();case"creating-features":return this._renderCreatingFeatures();case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature();case"awaiting-update-feature-candidate":return this._renderFeatureList();case"adding-attachment":return this._renderAttachmentAdding();case"editing-attachment":return this._renderAttachmentEditing()}return K("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(){const{EditorPanel:e,messages:t}=this;return K(e,{heading:t.selectTemplate,key:"templates-panel"},K(P,{key:"feature-templates"},K(L,null,this._featureTemplates.render())))}_renderUploadDetails(){const{EditorPanel:e,activeWorkflow:t,messages:s}=this;if("create-features"!==t?.type)return null;const o=t.data.upload;return o?K(e,{heading:s.createFeatures,key:"upload-details-panel"},K(G,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(){const{EditorPanel:e,activeWorkflow:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:r}=this;if(!t)return null;const a="create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&"create-features"===t?.activeWorkflow?.type&&t.activeWorkflow?.numPendingFeatures>0;return K(e,{heading:s.createFeatures,key:"create-features-panel"},a?K(V,{editorViewModel:r,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}):K(M,{helpMessage:this._helpMessage}))}_renderUpdateFeature(){const{EditorPanel:e,messages:t,messagesCommon:s,headingLevel:o,viewModel:i}=this;return K(e,{heading:t.editFeature,key:"update-feature-panel"},K(V,{editorViewModel:i,headingLevel:o,messages:t,messagesCommon:s,renderAttachments:()=>this._attachments.render(),renderFeatureForm:()=>this._featureForm.render(),onDelete:this._onDelete,onSave:this._onSave}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this,i=o(e.group.items,(e=>s.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?K(T,{icon:_,message:i}):null}_renderAttachmentAdding(){const{EditorPanel:e,_attachments:t,messages:s,messagesCommon:o}=this;return K(e,{heading:s.addAttachment,key:"attachment-adding-panel"},K(P,{key:"attachments"},t.render()),K(W,{buttons:[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentAdd}]}))}_renderAttachmentEditing(){const{EditorPanel:e,_attachments:t,activeWorkflow:s,messages:o,messagesCommon:i}=this;return s?K(e,{heading:o.editAttachment,key:"attachment-editing-panel"},K(P,{key:"attachments"},t.render()),s.shouldAllowAttachmentEditing?K(W,{buttons:[{label:i.update,disabled:t.submitting||!t.selectedFile,onClick:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:t.submitting,label:i.delete}]}):void 0):null}_renderReady(){const{EditorPanel:e,messages:t,viewModel:s,visibleElements:o}=this,i=this._helpMessage;return K(e,{heading:t.widgetLabel,key:"landing-panel"},K(P,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?K(L,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?K(L,{key:"create-actions"},this._renderCreateActions()):null]:K(I,{key:"no-content"},t.noEditableLayers)),i?K("div",{class:f.helpMessage,key:"footer-actions",slot:"footer"},i):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 K("div",{class:f.updateActions,key:"update-actions"},K(z,{level:N(this.headingLevel)},e.editFeatures),K("calcite-list",{class:f.updateActionsList,selectionAppearance:"border",selectionMode:"single"},R({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 K("div",{key:"create-actions"},K(z,{level:N(this.headingLevel)},this.messages.createFeatures),K("div",{class:f.featureTemplatesContainer,key:"templates"},this._featureTemplates.render()))}_renderFeatureList(){const{EditorPanel:e,viewModel:t}=this,{activeWorkflow:s}=t;if("update"!==s?.type)return null;const o=s.data.candidates,i=Q(this.messages.multipleFeaturesTemplate,{total:o.length});return K(e,{heading:i,key:"feature-list"},K(C,{editorItems:t.editorItems,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:s,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,s)=>t.selectFeature(e,s)}))}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const r=i(),{view:a}=this,n=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>r.resolve(!0)},secondary:{label:o,action:()=>r.resolve(!1)}}},r.promise.finally((()=>{this._clearPrompt(),n&&a?.focus()}))}};e([d()],X.prototype,"_featureForm",void 0),e([d()],X.prototype,"_attachments",void 0),e([d()],X.prototype,"_featureTemplates",void 0),e([d()],X.prototype,"_filterText",void 0),e([d()],X.prototype,"_prompt",void 0),e([d()],X.prototype,"_spinner",void 0),e([d()],X.prototype,"_deleteButtonCommonInfo",null),e([d()],X.prototype,"_loading",null),e([d({readOnly:!0})],X.prototype,"activeWorkflow",null),e([d()],X.prototype,"allowedWorkflows",null),e([d()],X.prototype,"headingLevel",void 0),e([d()],X.prototype,"hideTemplatesForInactiveLayers",null),e([d()],X.prototype,"iconClass",void 0),e([d()],X.prototype,"label",null),e([d()],X.prototype,"labelOptions",null),e([d()],X.prototype,"layerInfos",null),e([d(),$("esri/widgets/Editor/t9n/Editor")],X.prototype,"messages",void 0),e([d(),$("esri/t9n/common")],X.prototype,"messagesCommon",void 0),e([d(),$("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],X.prototype,"messagesTemplates",void 0),e([d()],X.prototype,"snappingOptions",null),e([d()],X.prototype,"tooltipOptions",null),e([d()],X.prototype,"supportingWidgetDefaults",void 0),e([d({type:p,nonNullable:!0})],X.prototype,"valueOptions",null),e([d()],X.prototype,"view",null),e([d(),J(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],X.prototype,"viewModel",void 0),e([d({type:k,nonNullable:!0})],X.prototype,"visibleElements",void 0),e([d()],X.prototype,"_helpMessage",null),X=e([m("esri.widgets.Editor")],X);const Y=X;export{Y 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{lerp as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{distance as r,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{k as o}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as i,project as c}from"../../../geometry/projection.js";import u from"../../../geometry/SpatialReference.js";import{geodesicLengths as l,isSupported as f,inverseGeodeticSolver as h,directGeodeticSolver as p}from"../../../geometry/support/geodesicUtils.js";import{ProfileGenerationError as
|
|
5
|
+
import{lerp as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{distance as r,lerp as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{k as o}from"../../../chunks/vec32.js";import a from"../../../geometry/Polyline.js";import{initializeProjection as i,project as c}from"../../../geometry/projection.js";import u from"../../../geometry/SpatialReference.js";import{geodesicLengths as l,isSupported as f,inverseGeodeticSolver as h,directGeodeticSolver as p}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as m}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as d,ProfileGenerationErrorCause as g}from"./ProfileGenerationError.js";async function w(e,r,s,o,a,f,h){let p,m,w;const j=e.spatialReference,v=j.isGeographic||j.isWebMercator;let P=0;if(!v){const{planarLength:n}=await import("../../../geometry/geometryEngineAsync.js");t(h),P=await n(e,"meters"),t(h)}const Z=1/n(o),x=a.geodesicDistanceThreshold??1/0;if(v||P>=x){await i([{source:j,dest:o},{source:j,dest:u.WGS84}],h);const t=W(e);p=l([t],"meters")[0];const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const v=R(t,r,s);({densifiedPath:m,distances:w}=b(v,n,Z)),m=c(m,o)}else{await i([{source:j,dest:o}],h),p=P;const n=y(p,a);if(D(e,p,n)>f)throw new d(g.TooComplex);const u=R(e,r,s);({densifiedPath:m,distances:w}=S(u,n,Z)),t(h),m=c(m,o)}return{densifiedPath:m,pathLength:p*Z,distances:w}}function y(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function R(e,t,n){if(null==t)return P(e);const r=e.spatialReference,s=t.mode,o=m(t,r);let i=null;switch(n.type){case"2d":i=j(e,s,o);break;case"3d":i=v(e,s,o,n)}return null==i?P(e):new a({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,i)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:s}){const o=(t,n,r,o)=>s?.getElevation(t,n,r,e,o)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,o(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+o(e,t,n,"ground")+r]:([e,t])=>[e,t,o(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+o(e,t,n,"scene")+r]:([e,t])=>[e,t,o(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new a({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,(([e,t])=>[e,t]))}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let s=0;s<n;++s){const n=e[s],o=n.length,a=new Array(n.length);r[s]=a;for(let e=0;e<o;++e)a[e]=t(n[e])}return r}function x(e){return M(e)&&e.paths.length>0&&e.paths.every((e=>e.length>=2))}function M(e){return null!=e&&"polyline"===e.type}function A(e,t,r,s,o){const{spatialReference:i,hasZ:c}=e,u={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:i,metersPerSR:n(i)},l=[],f=[];let h=0;for(let n=0;n<e.paths.length;++n){const a=e.paths[n],i=new Array,c=new Array;let p=0;for(let e=1;e<a.length;++e){const n=a[e-1],l=a[e],f=s(u,n,l);let m;for(m=p;m<f.distance;m+=t)i.push(o(f,m)),c.push((h+m)*r);p=m-f.distance,h+=f.distance,i.push(l),c.push(h*r)}l[n]=i,f[n]=c}return{densifiedPath:new a({spatialReference:i,hasZ:c,paths:l}),distances:f}}function S(e,t,n){const{hasZ:r}=e;return A(e,t,n,z,r?T:E)}function b(e,t,n){const{hasZ:r}=e;return A(e,t,n,U,r?k:G)}function U(e,t,n){return e.distance=0,h(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function z(e,t,n){return e.from=t,e.to=n,e.distance=r(n,t)*e.metersPerSR,e}function G({from:e,azimuth:t,spatialReference:n},r){return p([0,0],e,t,r,n)}function k({from:t,to:n,azimuth:r,distance:s,spatialReference:o},a){const i=a/s,c=[0,0,e(t[2],n[2],i)];return p(c,t,r,a,o),c}function E({from:e,to:t,distance:n},r){return s([0,0],e,t,r/n)}function T({from:e,to:t,distance:n},r){return o([0,0,0],e,t,r/n)}function W(e){return f(e.spatialReference)?e:c(e,u.WGS84)}function C(e){return e.paths.reduce(((e,t)=>e+t.length),0)}function D(e,t,n){return C(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce((e=>1+e),0)-1)}export{C as countPoints,w as densifyPath,M as isPolyline,x as isValidInputPath,R as toAbsoluteHeightElevation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../core/Logger.js";import{eachAlways as r}from"../../../core/promiseUtils.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as o}from"./featureUtils.js";import{globalCss as i}from"../../support/globalCss.js";const n="esri.widgets.Feature.support.arcadeFeatureUtils",s=()=>e.getLogger(n);function
|
|
5
|
+
import e from"../../../core/Logger.js";import{eachAlways as r}from"../../../core/promiseUtils.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as o}from"./featureUtils.js";import{globalCss as i}from"../../support/globalCss.js";const n="esri.widgets.Feature.support.arcadeFeatureUtils",s=()=>e.getLogger(n);function c(e){return"string"==typeof e?a(o(e)):Array.isArray(e)?p(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function p(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?a(o(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?a(o(t)):t}</td></tr>`})).join("");return`<table class="${i.table}">${r}</table>`}function l(){return import("../../../arcade.js")}function d(e){return"createQuery"in e&&"queryFeatures"in e}async function f({graphic:e,view:r,options:t}){const{isAggregate:a,layer:o}=e;if(!a||!o||"2d"!==r?.type)return[];const i=await r.whenLayerView(o);if(!d(i))return[];const n=i.createQuery(),s=e.getObjectId();n.aggregateIds=null!=s?[s]:[];const{features:c}=await i.queryFeatures(n,t);return c}function g({layer:e,aggregatedFeatures:r,interceptor:a}){const{fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:c}=e;return new t({fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:c,interceptor:a,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}async function y({expressionInfo:e,arcade:r,interceptor:t,spatialReference:a,map:o,graphic:i,location:n,view:c,options:p}){if(!e?.expression)return null;const{isAggregate:u}=i,l=(i.sourceLayer||i.layer)??void 0,d=u?"feature-reduction-popup":"popup",y=r.createArcadeProfile(d),m=r.createArcadeExecutor(e.expression,y).catch((r=>s().error("arcade-executor-error",{error:r,expressionInfo:e}))),[w,h]=await Promise.all([f({graphic:i,view:c,options:p}),m]);if(!h)return null;const F="feature-reduction-popup"===d?g({layer:l,aggregatedFeatures:w,interceptor:t}):void 0,$={..."feature-reduction-popup"===d?{$aggregatedFeatures:F}:{$datastore:l?.url,$layer:"feature"===l?.type?l:"scene"===l?.type&&null!=l.associatedLayer?l.associatedLayer:void 0,$map:o,$userInput:n,$graph:"knowledge-graph-sublayer"===l?.type?l?.parentCompositeLayer?.knowledgeGraph:void 0},$feature:i},v={abortSignal:p?.signal??void 0,interceptor:t??void 0,rawOutput:!0,spatialReference:a??void 0,timeZone:c?.timeZone};return await h.executeAsync($,v).catch((r=>s().error("arcade-execution-error",{error:r,graphic:i,expressionInfo:e}))).finally((()=>F?.destroy()))}async function m({expressionInfos:e,spatialReference:t,graphic:a,interceptor:o,map:i,view:n,location:s,options:p}){if(!e?.length)return{};const u=await l(),d={};for(const r of e)d[`expression/${r.name}`]=y({expressionInfo:r,arcade:u,interceptor:o,spatialReference:t,map:i,graphic:a,location:s,view:n,options:p});const f=await r(d),g={};for(const r in f)g[r]=c(f[r].value);return g}export{y as createCompiledExpression,m as createCompiledExpressions,l as loadArcade};
|