@arcgis/core 4.27.0-next.20230519 → 4.27.0-next.20230521
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/README.md +12 -10
- package/WebMap.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/03bc91648286b9b75e30.js +1 -0
- package/assets/esri/core/workers/chunks/099cacba30fd93af8ebc.js +1 -0
- package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +1 -0
- package/assets/esri/core/workers/chunks/{b5df3bafd74cbc04dfa2.js → 34ec9623a1bece86a82b.js} +1 -1
- package/assets/esri/core/workers/chunks/{ceb59b3c52d644e7cde8.js → 3ce1fe5e7a841f6dc355.js} +1 -1
- package/assets/esri/core/workers/chunks/{375108906a5b6b0a4857.js → a5bd457d0284419b4f34.js} +1 -1
- package/assets/esri/core/workers/chunks/{cf425d255519cb8b024b.js → df6f54607ad4c6e28d1d.js} +1 -1
- package/assets/esri/core/workers/chunks/{bb1fc781324709eb9f95.js → ff1c005eede0cf964332.js} +1 -1
- package/assets/esri/images/portal/360vr16.png +0 -0
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +1 -2
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +169 -0
- package/assets/esri/themes/base/widgets/_UtilityNetworkTrace.scss +29 -19
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nb.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -0
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -0
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ar.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bg.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ca.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_cs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_da.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_de.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_el.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_es.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_et.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_he.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hu.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_id.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_it.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ja.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ko.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lt.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nb.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-BR.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-PT.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ro.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ru.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_th.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_tr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_uk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_vi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-CN.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-HK.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-TW.json +1 -1
- package/chunks/mat3.js +1 -1
- package/core/libs/gl-matrix-2/mat3.js +1 -1
- package/core/libs/gl-matrix-2/math/mat3.js +1 -1
- package/interfaces.d.ts +24 -0
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/orientedImagery/core/bestImageUtils.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/groundToImageUtils.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
- package/layers/support/rasterFunctions/TableFunction.js +5 -0
- package/layers/support/rasterFunctions/TableFunctionArguments.js +5 -0
- package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/smartMapping/support/adapters/support/layerUtils.js +1 -1
- package/smartMapping/symbology/color.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/FrameTask.js +1 -1
- package/views/2d/LabelManager.js +1 -1
- package/views/2d/engine/Bitmap.js +1 -1
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
- package/views/2d/engine/imagery/RasterBitmap.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/magnifier/MagnifierView2D.js +1 -1
- package/views/MapView.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/Workflow.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Features/FeaturesVisibleElements.js +5 -0
- package/widgets/Features.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +5 -0
- package/widgets/OrientedImageryViewer/symbols.js +5 -0
- package/widgets/OrientedImageryViewer.js +5 -0
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GraphicHandler.js +1 -1
- package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +5 -0
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/0e947d6d045866f909ec.js +0 -1
- package/assets/esri/core/workers/chunks/6b3b277a21de7c434717.js +0 -1
- package/assets/esri/core/workers/chunks/ba519dda35d14056693b.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as i}from"../../../../core/arrayUtils.js";import{bidiText as s}from"../../../../core/BidiText.js";import{HandleOwnerMixin as r}from"../../../../core/HandleOwner.js";import has from"../../../../core/has.js";import{IdentifiableMixin as o}from"../../../../core/Identifiable.js";import{assertIsSome as a}from"../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as h,throwIfAbortError as l}from"../../../../core/promiseUtils.js";import{watch as d}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import g from"../../../../geometry/SpatialReference.js";import{width as u,height as m,create as _}from"../../../../geometry/support/aaBoundingRect.js";import{closeRingsAndFixWinding as f}from"../../../../geometry/support/coordsUtils.js";import{getJsonType as y,isPolygon as b,isPolyline as S,isExtent as w,isPoint as v,isMultipoint as T}from"../../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridianForDisplay as I}from"../../../../geometry/support/normalizeUtilsSync.js";import{getInfo as U}from"../../../../geometry/support/spatialReferenceUtils.js";import{checkProjectionSupport as G,project as M}from"../../../../layers/graphics/data/projectionSupport.js";import{symbolToCIM as j}from"../../../../symbols/cim/CIMSymbolHelper.js";import{errorPolylineSymbol2D as C,errorPolygonSymbol2D as P,errorPointSymbol2D as R}from"../../../../symbols/support/defaults.js";import{FILTER_FLAG_0 as x}from"../../engine/webgl/definitions.js";import{WGLSymbologyType as A}from"../../engine/webgl/enums.js";import{GraphicTile as z}from"../../engine/webgl/GraphicTile.js";import{TileData as q}from"../../engine/webgl/TileData.js";import D from"../../engine/webgl/WGLDisplayObject.js";import{MeshData as F}from"../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as O}from"../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as E}from"../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as H}from"../../engine/webgl/util/Matcher.js";import{createSymbolSchemaOptions as k,createMatcherSchema as N}from"../features/schemaUtils.js";import B from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as L}from"../features/support/ComputedAttributeStorage.js";import{GraphicsReader as V}from"../features/support/GraphicsReader.js";import W from"./GraphicStore.js";import{intersectingInternationalDateline as J,isMarkerSymbol as Z,isTextSymbol as K,polygonFromExtent as Q,TILE_SIZE as X,PIXEL_BUFFER as Y}from"./graphicsUtils.js";import{expandSymbol as $}from"../support/cimSymbolUtils.js";import{getWebGLCapabilities as ee}from"../../../webgl/capabilities.js";import{createSymbolSchema as te}from"../features/createSymbolSchema.js";const ie=has("esri-2d-graphic-debug");function se(e,t,i){let s=i.get(e);return s||(s={tile:t,addedOrModified:[],removed:[]},i.set(e,s)),s}let re=class extends(o(r(t))){constructor(e){super(e),this._storage=new L,this._displayIds=new Map,this._controller=new AbortController,this._tiles=new Map,this._graphicStoreUpdate=!1,this._graphicsSet=new Set,this._matcher=Promise.resolve(null),this._tileUpdateSet=new Set,this._tilesToUpdate=new Map,this._graphicIdToAbortController=new Map,this._attached=!1,this._updatingGraphicsTimer=null,this._hashToExpandedSymbol=new Map,this._hashToExpandedSymbolPromise=new Map,this._hashToCIMSymbolPromise=new Map,this._hashToCIM=new Map,this._processing=!1,this._needsProcessing=!1,this._pendingUpdate={added:new Set,updated:new Set,removed:new Set},this.lastUpdateId=-1,this.renderer=null,this.updateRequested=!1,this.defaultPointSymbolEnabled=!0,this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this._updatingGraphicsTimer&&(clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=null,this.notifyChange("updating")),this._controller.abort(),this.container.destroy(),this._set("graphics",null),this._graphicStore.clear(),this._attributeStore=null,this._hashToExpandedSymbol.clear(),this.view=null,this.renderer=null,this._hashToCIM.clear(),this._hashToCIMSymbolPromise.clear(),this._hashToExpandedSymbolPromise.clear()}_createMatcher(e,t,i){if(e){const s=k(e),r=N({indexCount:0,fields:{}},"feature",e,s);this._matcher=H(r,t,null,i)}}_createDisplayId(e){let t=this._displayIds.get(e);return t||(t=this._storage.createDisplayId(),this._displayIds.set(e,t)),t}initialize(){this._attributeStore=new B({type:"local",initialize:e=>Promise.resolve(this.container.attributeView.initialize(e)),update:e=>this.container.attributeView.requestUpdate(e),render:()=>this.container.requestRender()},ee("2d")),this.container.hasHighlight=()=>this._attributeStore.hasHighlight;const e=e=>{this._createDisplayId(e.uid),this._setFilterState(e.uid,e.visible)},t=e=>{const t=this._displayIds.get(e.uid);this._displayIds.delete(e.uid),this._storage.releaseDisplayId(t)},i=new E(this.container.getMaterialItems.bind(this.container),this.view.featuresTilingScheme.tileInfo);this._graphicStore=new W(this.view.featuresTilingScheme,this.view.state.scale,this.uid,this.graphics,e,t,this._hashToCIM),this._meshFactory=new O(null,this.uid,i),this._templateStore=i,this.handles.add([d((()=>this._effectiveRenderer),(e=>{this._createMatcher(e,i,this.container.stage.resourceManager);for(const t of this.graphics)this._pendingUpdate.updated.add(t);this.requestUpdate()})),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",(()=>{ie&&this.container.enableRenderingBounds((()=>this._graphicStore.getAllBounds())),this.graphics.items.length>0&&this._graphicsChangeHandler({target:this.graphics,added:this.graphics.items,removed:[],moved:[]}),this.handles.add(this.graphics.on("change",(e=>this._graphicsChangeHandler(e))),"graphics");const e=this.container.stage.resourceManager;this._createMatcher(this._effectiveRenderer,i,e),this._graphicStore.setResourceManager(e),this._attached=!0,this.notifyChange("updating")}))]);const s=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:s,removed:[]})}get _effectiveRenderer(){return"function"==typeof this.renderer?this.renderer():this.renderer}get updating(){return!this._attached||null!==this._updatingGraphicsTimer||this._pendingUpdate.added.size>0||this._pendingUpdate.removed.size>0||this._pendingUpdate.updated.size>0||this._tileUpdateSet.size>0||this._tilesToUpdate.size>0||this._attributeStore?.updatingHandles.updating||this._processing}hitTest(e){if(!this.view||!this.view.position)return[];const{resolution:t,rotation:i}=this.view.state;return this._graphicStore.hitTest(e.x,e.y,2,t,i)}update(e){n(this._controller.signal);const t=e.state,{resolution:i}=t;if(this._graphicStore.updateLevel(i),this._graphicStoreUpdate=!0,this.updateRequested=!1,this._pendingUpdate.updated.size>0){if(!this._processing)return void this._updateGraphics();this._needsProcessing=!0}}viewChange(){this.requestUpdate()}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback())}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}graphicUpdateHandler(e){const{graphic:t,property:i}=e;switch(i){case"attributes":case"geometry":case"symbol":this._pendingUpdate.updated.add(t),this.requestUpdate();break;case"visible":this._setFilterState(t.uid,t.visible),this._attributeStore.sendUpdates()}}setHighlight(e){const t=e.map((e=>this._displayIds.get(e))).filter(i);this._attributeStore.setHighlight(e,t)}_getIntersectingTiles(e){const t=this._graphicStore.getBounds(e);if(!t||0===u(t)||0===m(t))return[];const i=J(t,this.view.spatialReference);return null!=i?[...new Set([...this.view.graphicsTileStore.boundsIntersections(i[0]),...this.view.graphicsTileStore.boundsIntersections(i[1])])]:this.view.graphicsTileStore.boundsIntersections(t)}async _updateTile(e){n(this._controller.signal);const t=e.tile,i=this._getGraphicsData(this._templateStore,t,e.addedOrModified),s=await this._processGraphics(t,i);return n(this._controller.signal),this._patchTile(t.key,{type:"update",addOrUpdate:s,remove:e.removed,end:!0,clear:!1,sort:!1}),s}_patchTile(e,t){const i=this._tiles.get(e);i&&(this.container.onTileData(i,t),this.container.requestRender())}_graphicsChangeHandler(e){const t=this._pendingUpdate;for(const i of e.added)t.added.add(i);for(const i of e.moved)t.updated.add(i);for(const i of e.removed)this._pendingUpdate.added.has(i)?t.added.delete(i):t.removed.add(i);this._processing?this._needsProcessing=!0:this._updateGraphics()}_getGraphicsToUpdate(){const e={added:[],removed:[],updated:[]};if(!this.graphics)return e;const t=this._pendingUpdate;for(const i of this.graphics.items)t.added.has(i)?e.added.push(i):t.updated.has(i)&&e.updated.push(i);for(const i of t.removed)this._graphicStore.has(i)&&e.removed.push(i);return t.added.clear(),t.removed.clear(),t.updated.clear(),e}async _updateGraphics(){this._processing=!0;const{added:e,removed:t,updated:i}=this._getGraphicsToUpdate(),s=this._tilesToUpdate;let r;try{if(!this._graphicStoreUpdate){const e=this.view.state,{resolution:t}=e;this._graphicStore.updateLevel(t)}const o=[],a=new Array(e.length+t.length);for(let e=0;e<i.length;e++){const t=i[e],n=this._getIntersectingTiles(t);for(const e of n){r=e.id;se(r,e,s).removed.push(this._displayIds.get(t.uid))}o.push(this._updateGraphic(t,null)),a[e]=t}const n=i.length;for(let t=0;t<e.length;t++){const i=e[t];a[n+t]=i,this._graphicsSet.add(i),o.push(this._addGraphic(i))}for(const e of t){this._abortProcessingGraphic(e.uid);const t=this._getIntersectingTiles(e);for(const i of t){r=i.id;se(r,i,s).removed.push(this._displayIds.get(e.uid))}this._graphicsSet.delete(e),this._graphicStore.remove(e)}let h;this._flipUpdatingGraphics(),await Promise.all(o);for(let e=0;e<a.length;e++){h=a[e];const t=this._getIntersectingTiles(h);for(const e of t){r=e.id;se(r,e,s).addedOrModified.push(h)}}this._graphicStore.updateZ();const l=[];for(const[e,t]of s)l.push(this._updateTile(t));await Promise.all(l)}catch(o){h(o),0}for(const a of t)try{const e=await this._getSymbolForGraphic(a,null);if(e){const t=e.hash();this._hashToExpandedSymbol.delete(t)}}catch(o){h(o),0}s.clear(),this.notifyChange("updating"),this._processing=!1,this._needsProcessing&&(this._needsProcessing=!1,this._updateGraphics())}_getArcadeInfo(e){const t=(e.attributes?Object.keys(e.attributes):[]).map((t=>({name:t,alias:t,type:"string"==typeof e.attributes[t]?"esriFieldTypeString":"esriFieldTypeDouble"})));return null==e.geometry?null:{geometryType:y(e.geometry),spatialReference:g.fromJSON(e.geometry.spatialReference),fields:t}}_getSymbolForGraphic(e,t){return n(this._controller.signal),null!=e.symbol?Promise.resolve(e.symbol):null!=this._effectiveRenderer?this._effectiveRenderer.getSymbolAsync(e,{scale:this.view.scale,signal:null!=t?t.signal:null}):Promise.resolve(this._getNullSymbol(e))}_getCIMSymbol(e,t,i){let s=this._hashToCIM.get(t);if(s)return Promise.resolve(s);const r=j(e);if(null!=r){if("CIMSymbolReference"===r.type)return s=r,this._hashToCIM.set(t,s),Promise.resolve(s);let e=this._hashToCIMSymbolPromise.get(t);return e||(e=r.fetchCIMSymbol(i).then((e=>(this._hashToCIM.set(t,e.data),this._hashToCIMSymbolPromise.delete(t),e))).catch((e=>(this._hashToCIMSymbolPromise.delete(t),l(e),null))),this._hashToCIMSymbolPromise.set(t,e),e)}return Promise.resolve(null)}_expandCIMSymbol(e,t,i,s){const r=this._hashToExpandedSymbol.get(i);if(r)return Promise.resolve(r);let o=this._hashToExpandedSymbolPromise.get(i);if(o)return o;const a=this.container.stage,n=this._getArcadeInfo(t),h=k(null),l=te(e,h);return o=$(l,n,a.resourceManager,s),this._hashToExpandedSymbolPromise.set(i,o),o.then((e=>(this._hashToExpandedSymbol.set(i,e),this._hashToExpandedSymbolPromise.delete(i),e))),o}async _getSymbolResources(e,t){n(this._controller.signal);return this.container.stage?this._getSymbolForGraphic(e,t).then((i=>{if(!i)return null;const r=i.hash();return this._getCIMSymbol(i,r,t).then((i=>null==i?null:this._expandCIMSymbol(i,e,r,t).then((e=>{const t=e.layers.filter((e=>"text"===e.type&&"string"==typeof e.text));if(t&&t.length>0){const i=new Array(t.length);for(let e=0;e<t.length;e++){const r=t[e],o=[],[a]=s(r.text);r.text=a;for(let e=0;e<a.length;e++)o.push(a.charCodeAt(e));i[e]={symbol:r,id:e,glyphIds:o}}const o=new Map;return this.container.getMaterialItems(i).then((i=>{a(i);for(let e=0;e<t.length;e++){const s=t[e];o.set(s.cim,{text:s.text,mosaicItem:i[e].mosaicItem})}return{symbol:e,textInfo:o,hash:r}}))}return{symbol:e,hash:r}}))))})).catch((e=>(l(e),null))):null}async _projectAndNormalizeGeometry(e,t){if(n(this._controller.signal),null==e.geometry||"mesh"===e.geometry.type)return null;let i=e.geometry;if(b(i)){const e=i.rings;i.rings=e}else if(S(i)){const e=i.paths;i.paths=e}else if(w(i)){const s=await this._getSymbolForGraphic(e,t);if(n(this._controller.signal),s&&(Z(s.type)||K(s.type))){i=i.center}else i=Q(i)}await G(i.spatialReference,this.view.spatialReference);const s=I(i),r=M(s,i.spatialReference,this.view.spatialReference);return r&&f(r),r}_onTileUpdate(e){const t=U(this.view.spatialReference);if(e.added&&e.added.length>0)for(const i of e.added)this._addNewTile(i,t);if(e.removed&&e.removed.length>0)for(const i of e.removed)this._removeTile(i.key)}async _addGraphic(e){this._abortProcessingGraphic(e.uid),n(this._controller.signal);const t=new AbortController;this._graphicIdToAbortController.set(e.uid,t);const i={signal:t.signal};try{await this._addOrUpdateGraphic(e,i),n(this._controller.signal),this._graphicIdToAbortController.delete(e.uid)}catch(s){if(this._graphicIdToAbortController.delete(e.uid),!h(s))throw s}}_updateGraphic(e,t){n(this._controller.signal);const i=this._projectAndNormalizeGeometry(e,t),s=this._getSymbolResources(e,t);return Promise.all([i,s]).then((([t,i])=>{n(this._controller.signal),this._graphicStore.addOrModify(e,i,t)}))}_addOrUpdateGraphic(e,t){n(this._controller.signal);const i=this._projectAndNormalizeGeometry(e,t),s=this._getSymbolResources(e,t);return Promise.all([i,s]).then((([t,i])=>{n(this._controller.signal),this._graphicsSet.has(e)&&this._graphicStore.addOrModify(e,i,t)}))}_addTile(e){const t=this.view.featuresTilingScheme.getTileBounds(_(),e),i=this.view.featuresTilingScheme.getTileResolution(e.level),s=new z(e,i,t[0],t[3]);return this._tiles.set(e,s),this.container.addChild(s),s}async _addNewTile(e,t){const i=this._addTile(e.key),s=this._graphicStore.queryTileData(this._templateStore,e);if(0===s.length)return;if(t){const i=Math.round((t.valid[1]-t.valid[0])/e.resolution);for(const e of s)e.geometry&&(v(e.geometry)||T(e.geometry))&&this._wrapPoints(e,i)}const r=e.key;this._tileUpdateSet.add(e.key),this.notifyChange("updating");try{const t={type:"update",clear:!1,addOrUpdate:await this._processGraphics(e,s),remove:[],end:!0,sort:!1};i.patch(t),this._tileUpdateSet.delete(r),this.notifyChange("updating")}catch(o){if(this._tileUpdateSet.delete(r),this.notifyChange("updating"),!h(o))throw o}}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_setFilterState(e,t){const i=this._displayIds.get(e),s=this._attributeStore.getHighlightFlag(e);this._attributeStore.setData(i,0,0,s|(t?x:0))}_getGraphicsData(e,t,i){const s=this.view,r=U(s.spatialReference),o=this._graphicStore.getGraphicsData(e,t,i);if(r){const e=Math.round((r.valid[1]-r.valid[0])/t.resolution);for(const t of o)t.geometry&&(v(t.geometry)||T(t.geometry))&&this._wrapPoints(t,e)}return o}_wrapPoints(e,t){const i=e.geometry;T(i)?this._wrapMultipoint(i,t):this._wrapPoint(e,t)}_wrapMultipoint(e,t){const i=e.points,s=[];let r=0,o=0;for(const[a,n]of i){if(s.push([a+r,n]),r=0,t===X){const e=5*Y;a+o<e?(s.push([t,0]),r=-t):a+o>X-e&&(s.push([-t,0]),r=t)}else a+o<-Y?(s.push([t,0]),r=-t):a+o>X+Y&&(s.push([-t,0]),r=t);o+=a}e.points=s}_wrapPoint(e,t){const i=e.geometry;if(t===X){const s=5*Y;i.x<s?e.geometry={points:[[i.x,i.y],[t,0]]}:i.x>X-s&&(e.geometry={points:[[i.x,i.y],[-t,0]]})}else i.x<-Y?e.geometry={points:[[i.x,i.y],[t,0]]}:i.x>X+Y&&(e.geometry={points:[[i.x,i.y],[-t,0]]})}_processGraphics(e,t,i){if(!(t&&t.length)||!this._meshFactory)return Promise.resolve(null);const s=V.from(t,this.uid,e.transform),r=this._meshFactory;return this._matcher.then((t=>r.analyzeGraphics(s,this.container.stage.resourceManager,t,null,null,i).then((()=>(this._attributeStore.sendUpdates(),this._processAnalyzedGraphics(e,s))))))}_processAnalyzedGraphics(e,t){const i=this._meshFactory,s=t.getSize(),r=t.getCursor(),o={features:s,records:s,metrics:0},a=new F(e.key.id,o,A.DEFAULT,!1,!1),n=[];for(;r.next();){const t=r.readGraphic();t.insertAfter=-1===t.insertAfter?-1:this._displayIds.get(t.insertAfter),t.displayId=this._displayIds.get(t.attributes[this.uid]);const s=new D(t.displayId);s.insertAfter=t.insertAfter,n.push(s),i.writeGraphic(a,r,e.level,this.container.stage.resourceManager)}const h=e.tileInfoView.tileInfo.isWrappable,l=a.serialize(h);if(1!==l.length)return new q;const d=l[0].message;return q.fromVertexData(d,n)}_abortProcessingGraphic(e){this._graphicIdToAbortController.get(e)?.abort()}_getNullSymbol(e){const t=e.geometry;return S(t)?C:b(t)||w(t)?P:this.defaultPointSymbolEnabled?R:null}_flipUpdatingGraphics(){this._updatingGraphicsTimer&&clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=setTimeout((()=>{this._updatingGraphicsTimer=null,this.notifyChange("updating")}),160),this.notifyChange("updating")}};e([p()],re.prototype,"_effectiveRenderer",null),e([p({constructOnly:!0})],re.prototype,"requestUpdateCallback",void 0),e([p()],re.prototype,"container",void 0),e([p({constructOnly:!0})],re.prototype,"graphics",void 0),e([p()],re.prototype,"renderer",void 0),e([p()],re.prototype,"updating",null),e([p()],re.prototype,"view",void 0),e([p()],re.prototype,"updateRequested",void 0),e([p()],re.prototype,"defaultPointSymbolEnabled",void 0),re=e([c("esri.views.2d.layers.support.GraphicsView2D")],re);const oe=re;export{oe as default};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import{bidiText as i}from"../../../../core/BidiText.js";import{HandleOwnerMixin as r}from"../../../../core/HandleOwner.js";import has from"../../../../core/has.js";import{IdentifiableMixin as o}from"../../../../core/Identifiable.js";import{assertIsSome as a}from"../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as h,throwIfAbortError as l}from"../../../../core/promiseUtils.js";import{watch as d}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import g from"../../../../geometry/SpatialReference.js";import{width as u,height as m,create as _}from"../../../../geometry/support/aaBoundingRect.js";import{closeRingsAndFixWinding as f}from"../../../../geometry/support/coordsUtils.js";import{getJsonType as y,isPolygon as b,isPolyline as S,isExtent as w,isPoint as v,isMultipoint as T}from"../../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridianForDisplay as I}from"../../../../geometry/support/normalizeUtilsSync.js";import{getInfo as U}from"../../../../geometry/support/spatialReferenceUtils.js";import{checkProjectionSupport as G,project as M}from"../../../../layers/graphics/data/projectionSupport.js";import{symbolToCIM as j}from"../../../../symbols/cim/CIMSymbolHelper.js";import{errorPolylineSymbol2D as C,errorPolygonSymbol2D as P,errorPointSymbol2D as R}from"../../../../symbols/support/defaults.js";import{FILTER_FLAG_0 as x}from"../../engine/webgl/definitions.js";import{WGLSymbologyType as A}from"../../engine/webgl/enums.js";import{GraphicTile as z}from"../../engine/webgl/GraphicTile.js";import{TileData as q}from"../../engine/webgl/TileData.js";import D from"../../engine/webgl/WGLDisplayObject.js";import{MeshData as F}from"../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as O}from"../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as E}from"../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as H}from"../../engine/webgl/util/Matcher.js";import{createSymbolSchemaOptions as k,createMatcherSchema as N}from"../features/schemaUtils.js";import B from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as L}from"../features/support/ComputedAttributeStorage.js";import{GraphicsReader as V}from"../features/support/GraphicsReader.js";import W from"./GraphicStore.js";import{intersectingInternationalDateline as J,isMarkerSymbol as Z,isTextSymbol as K,polygonFromExtent as Q,TILE_SIZE as X,PIXEL_BUFFER as Y}from"./graphicsUtils.js";import{expandSymbol as $}from"../support/cimSymbolUtils.js";import{getWebGLCapabilities as ee}from"../../../webgl/capabilities.js";import{createSymbolSchema as te}from"../features/createSymbolSchema.js";const se=has("esri-2d-graphic-debug");function ie(e,t,s){let i=s.get(e);return i||(i={tile:t,addedOrModified:[],removed:[]},s.set(e,i)),i}let re=class extends(o(r(t))){constructor(e){super(e),this._storage=new L,this._displayIds=new Map,this._controller=new AbortController,this._tiles=new Map,this._graphicStoreUpdate=!1,this._graphicsSet=new Set,this._matcher=Promise.resolve(null),this._tileUpdateSet=new Set,this._tilesToUpdate=new Map,this._graphicIdToAbortController=new Map,this._attached=!1,this._updatingGraphicsTimer=null,this._hashToExpandedSymbol=new Map,this._hashToExpandedSymbolPromise=new Map,this._hashToCIMSymbolPromise=new Map,this._hashToCIM=new Map,this._processing=!1,this._needsProcessing=!1,this._pendingUpdate={added:new Set,updated:new Set,removed:new Set},this.lastUpdateId=-1,this.renderer=null,this.updateRequested=!1,this.defaultPointSymbolEnabled=!0,this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this._updatingGraphicsTimer&&(clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=null,this.notifyChange("updating")),this._controller.abort(),this.container.destroy(),this._set("graphics",null),this._graphicStore.clear(),this._attributeStore=null,this._hashToExpandedSymbol.clear(),this.view=null,this.renderer=null,this._hashToCIM.clear(),this._hashToCIMSymbolPromise.clear(),this._hashToExpandedSymbolPromise.clear()}_createMatcher(e,t,s){if(e){const i=k(e),r=N({indexCount:0,fields:{}},"feature",e,i);this._matcher=H(r,t,null,s)}}_createDisplayId(e){let t=this._displayIds.get(e);return t||(t=this._storage.createDisplayId(),this._displayIds.set(e,t)),t}initialize(){this._attributeStore=new B({type:"local",initialize:e=>Promise.resolve(this.container.attributeView.initialize(e)),update:e=>this.container.attributeView.requestUpdate(e),render:()=>this.container.requestRender()},ee("2d")),this.container.hasHighlight=()=>this._attributeStore.hasHighlight;const e=e=>{this._createDisplayId(e.uid),this._setFilterState(e.uid,e.visible)},t=e=>{const t=this._displayIds.get(e.uid);this._displayIds.delete(e.uid),this._storage.releaseDisplayId(t)},s=new E(this.container.getMaterialItems.bind(this.container),this.view.featuresTilingScheme.tileInfo);this._graphicStore=new W(this.view.featuresTilingScheme,this.view.state.scale,this.uid,this.graphics,e,t,this._hashToCIM),this._meshFactory=new O(null,this.uid,s),this._templateStore=s,this.handles.add([d((()=>this._effectiveRenderer),(e=>{this._createMatcher(e,s,this.container.stage.resourceManager);for(const t of this.graphics)this._pendingUpdate.updated.add(t);this.requestUpdate()})),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",(()=>{se&&this.container.enableRenderingBounds((()=>this._graphicStore.getAllBounds())),this.graphics.items.length>0&&this._graphicsChangeHandler({target:this.graphics,added:this.graphics.items,removed:[],moved:[]}),this.handles.add(this.graphics.on("change",(e=>this._graphicsChangeHandler(e))),"graphics");const e=this.container.stage.resourceManager;this._createMatcher(this._effectiveRenderer,s,e),this._graphicStore.setResourceManager(e),this._attached=!0,this.notifyChange("updating")}))]);const i=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:i,removed:[]})}get _effectiveRenderer(){return"function"==typeof this.renderer?this.renderer():this.renderer}get updating(){return!this._attached||null!==this._updatingGraphicsTimer||this._pendingUpdate.added.size>0||this._pendingUpdate.removed.size>0||this._pendingUpdate.updated.size>0||this._tileUpdateSet.size>0||this._tilesToUpdate.size>0||this._attributeStore?.updatingHandles.updating||this._processing}hitTest(e){if(!this.view||this.view.suspended)return[];const{resolution:t,rotation:s}=this.view.state;return this._graphicStore.hitTest(e.x,e.y,2,t,s)}update(e){n(this._controller.signal);const t=e.state,{resolution:s}=t;if(this._graphicStore.updateLevel(s),this._graphicStoreUpdate=!0,this.updateRequested=!1,this._pendingUpdate.updated.size>0){if(!this._processing)return void this._updateGraphics();this._needsProcessing=!0}}viewChange(){this.requestUpdate()}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback())}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}graphicUpdateHandler(e){const{graphic:t,property:s}=e;switch(s){case"attributes":case"geometry":case"symbol":this._pendingUpdate.updated.add(t),this.requestUpdate();break;case"visible":this._setFilterState(t.uid,t.visible),this._attributeStore.sendUpdates()}}setHighlight(e){const t=e.map((e=>this._displayIds.get(e))).filter(s);this._attributeStore.setHighlight(e,t)}_getIntersectingTiles(e){const t=this._graphicStore.getBounds(e);if(!t||0===u(t)||0===m(t))return[];const s=J(t,this.view.spatialReference);return null!=s?[...new Set([...this.view.graphicsTileStore.boundsIntersections(s[0]),...this.view.graphicsTileStore.boundsIntersections(s[1])])]:this.view.graphicsTileStore.boundsIntersections(t)}async _updateTile(e){n(this._controller.signal);const t=e.tile,s=this._getGraphicsData(this._templateStore,t,e.addedOrModified),i=await this._processGraphics(t,s);return n(this._controller.signal),this._patchTile(t.key,{type:"update",addOrUpdate:i,remove:e.removed,end:!0,clear:!1,sort:!1}),i}_patchTile(e,t){const s=this._tiles.get(e);s&&(this.container.onTileData(s,t),this.container.requestRender())}_graphicsChangeHandler(e){const t=this._pendingUpdate;for(const s of e.added)t.added.add(s);for(const s of e.moved)t.updated.add(s);for(const s of e.removed)this._pendingUpdate.added.has(s)?t.added.delete(s):t.removed.add(s);this._processing?this._needsProcessing=!0:this._updateGraphics()}_getGraphicsToUpdate(){const e={added:[],removed:[],updated:[]};if(!this.graphics)return e;const t=this._pendingUpdate;for(const s of this.graphics.items)t.added.has(s)?e.added.push(s):t.updated.has(s)&&e.updated.push(s);for(const s of t.removed)this._graphicStore.has(s)&&e.removed.push(s);return t.added.clear(),t.removed.clear(),t.updated.clear(),e}async _updateGraphics(){this._processing=!0;const{added:e,removed:t,updated:s}=this._getGraphicsToUpdate(),i=this._tilesToUpdate;let r;try{if(!this._graphicStoreUpdate){const e=this.view.state,{resolution:t}=e;this._graphicStore.updateLevel(t)}const o=[],a=new Array(e.length+t.length);for(let e=0;e<s.length;e++){const t=s[e],n=this._getIntersectingTiles(t);for(const e of n){r=e.id;ie(r,e,i).removed.push(this._displayIds.get(t.uid))}o.push(this._updateGraphic(t,null)),a[e]=t}const n=s.length;for(let t=0;t<e.length;t++){const s=e[t];a[n+t]=s,this._graphicsSet.add(s),o.push(this._addGraphic(s))}for(const e of t){this._abortProcessingGraphic(e.uid);const t=this._getIntersectingTiles(e);for(const s of t){r=s.id;ie(r,s,i).removed.push(this._displayIds.get(e.uid))}this._graphicsSet.delete(e),this._graphicStore.remove(e)}let h;this._flipUpdatingGraphics(),await Promise.all(o);for(let e=0;e<a.length;e++){h=a[e];const t=this._getIntersectingTiles(h);for(const e of t){r=e.id;ie(r,e,i).addedOrModified.push(h)}}this._graphicStore.updateZ();const l=[];for(const[e,t]of i)l.push(this._updateTile(t));await Promise.all(l)}catch(o){h(o),0}for(const a of t)try{const e=await this._getSymbolForGraphic(a,null);if(e){const t=e.hash();this._hashToExpandedSymbol.delete(t)}}catch(o){h(o),0}i.clear(),this.notifyChange("updating"),this._processing=!1,this._needsProcessing&&(this._needsProcessing=!1,this._updateGraphics())}_getArcadeInfo(e){const t=(e.attributes?Object.keys(e.attributes):[]).map((t=>({name:t,alias:t,type:"string"==typeof e.attributes[t]?"esriFieldTypeString":"esriFieldTypeDouble"})));return null==e.geometry?null:{geometryType:y(e.geometry),spatialReference:g.fromJSON(e.geometry.spatialReference),fields:t}}_getSymbolForGraphic(e,t){return n(this._controller.signal),null!=e.symbol?Promise.resolve(e.symbol):null!=this._effectiveRenderer?this._effectiveRenderer.getSymbolAsync(e,{scale:this.view.state.scale,signal:null!=t?t.signal:null}):Promise.resolve(this._getNullSymbol(e))}_getCIMSymbol(e,t,s){let i=this._hashToCIM.get(t);if(i)return Promise.resolve(i);const r=j(e);if(null!=r){if("CIMSymbolReference"===r.type)return i=r,this._hashToCIM.set(t,i),Promise.resolve(i);let e=this._hashToCIMSymbolPromise.get(t);return e||(e=r.fetchCIMSymbol(s).then((e=>(this._hashToCIM.set(t,e.data),this._hashToCIMSymbolPromise.delete(t),e))).catch((e=>(this._hashToCIMSymbolPromise.delete(t),l(e),null))),this._hashToCIMSymbolPromise.set(t,e),e)}return Promise.resolve(null)}_expandCIMSymbol(e,t,s,i){const r=this._hashToExpandedSymbol.get(s);if(r)return Promise.resolve(r);let o=this._hashToExpandedSymbolPromise.get(s);if(o)return o;const a=this.container.stage,n=this._getArcadeInfo(t),h=k(null),l=te(e,h);return o=$(l,n,a.resourceManager,i),this._hashToExpandedSymbolPromise.set(s,o),o.then((e=>(this._hashToExpandedSymbol.set(s,e),this._hashToExpandedSymbolPromise.delete(s),e))),o}async _getSymbolResources(e,t){n(this._controller.signal);return this.container.stage?this._getSymbolForGraphic(e,t).then((s=>{if(!s)return null;const r=s.hash();return this._getCIMSymbol(s,r,t).then((s=>null==s?null:this._expandCIMSymbol(s,e,r,t).then((e=>{const t=e.layers.filter((e=>"text"===e.type&&"string"==typeof e.text));if(t&&t.length>0){const s=new Array(t.length);for(let e=0;e<t.length;e++){const r=t[e],o=[],[a]=i(r.text);r.text=a;for(let e=0;e<a.length;e++)o.push(a.charCodeAt(e));s[e]={symbol:r,id:e,glyphIds:o}}const o=new Map;return this.container.getMaterialItems(s).then((s=>{a(s);for(let e=0;e<t.length;e++){const i=t[e];o.set(i.cim,{text:i.text,mosaicItem:s[e].mosaicItem})}return{symbol:e,textInfo:o,hash:r}}))}return{symbol:e,hash:r}}))))})).catch((e=>(l(e),null))):null}async _projectAndNormalizeGeometry(e,t){if(n(this._controller.signal),null==e.geometry||"mesh"===e.geometry.type)return null;let s=e.geometry;if(b(s)){const e=s.rings;s.rings=e}else if(S(s)){const e=s.paths;s.paths=e}else if(w(s)){const i=await this._getSymbolForGraphic(e,t);if(n(this._controller.signal),i&&(Z(i.type)||K(i.type))){s=s.center}else s=Q(s)}await G(s.spatialReference,this.view.spatialReference);const i=I(s),r=M(i,s.spatialReference,this.view.spatialReference);return r&&f(r),r}_onTileUpdate(e){const t=U(this.view.spatialReference);if(e.added&&e.added.length>0)for(const s of e.added)this._addNewTile(s,t);if(e.removed&&e.removed.length>0)for(const s of e.removed)this._removeTile(s.key)}async _addGraphic(e){this._abortProcessingGraphic(e.uid),n(this._controller.signal);const t=new AbortController;this._graphicIdToAbortController.set(e.uid,t);const s={signal:t.signal};try{await this._addOrUpdateGraphic(e,s),n(this._controller.signal),this._graphicIdToAbortController.delete(e.uid)}catch(i){if(this._graphicIdToAbortController.delete(e.uid),!h(i))throw i}}_updateGraphic(e,t){n(this._controller.signal);const s=this._projectAndNormalizeGeometry(e,t),i=this._getSymbolResources(e,t);return Promise.all([s,i]).then((([t,s])=>{n(this._controller.signal),this._graphicStore.addOrModify(e,s,t)}))}_addOrUpdateGraphic(e,t){n(this._controller.signal);const s=this._projectAndNormalizeGeometry(e,t),i=this._getSymbolResources(e,t);return Promise.all([s,i]).then((([t,s])=>{n(this._controller.signal),this._graphicsSet.has(e)&&this._graphicStore.addOrModify(e,s,t)}))}_addTile(e){const t=this.view.featuresTilingScheme.getTileBounds(_(),e),s=this.view.featuresTilingScheme.getTileResolution(e.level),i=new z(e,s,t[0],t[3]);return this._tiles.set(e,i),this.container.addChild(i),i}async _addNewTile(e,t){const s=this._addTile(e.key),i=this._graphicStore.queryTileData(this._templateStore,e);if(0===i.length)return;if(t){const s=Math.round((t.valid[1]-t.valid[0])/e.resolution);for(const e of i)e.geometry&&(v(e.geometry)||T(e.geometry))&&this._wrapPoints(e,s)}const r=e.key;this._tileUpdateSet.add(e.key),this.notifyChange("updating");try{const t={type:"update",clear:!1,addOrUpdate:await this._processGraphics(e,i),remove:[],end:!0,sort:!1};s.patch(t),this._tileUpdateSet.delete(r),this.notifyChange("updating")}catch(o){if(this._tileUpdateSet.delete(r),this.notifyChange("updating"),!h(o))throw o}}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_setFilterState(e,t){const s=this._displayIds.get(e),i=this._attributeStore.getHighlightFlag(e);this._attributeStore.setData(s,0,0,i|(t?x:0))}_getGraphicsData(e,t,s){const i=this.view,r=U(i.spatialReference),o=this._graphicStore.getGraphicsData(e,t,s);if(r){const e=Math.round((r.valid[1]-r.valid[0])/t.resolution);for(const t of o)t.geometry&&(v(t.geometry)||T(t.geometry))&&this._wrapPoints(t,e)}return o}_wrapPoints(e,t){const s=e.geometry;T(s)?this._wrapMultipoint(s,t):this._wrapPoint(e,t)}_wrapMultipoint(e,t){const s=e.points,i=[];let r=0,o=0;for(const[a,n]of s){if(i.push([a+r,n]),r=0,t===X){const e=5*Y;a+o<e?(i.push([t,0]),r=-t):a+o>X-e&&(i.push([-t,0]),r=t)}else a+o<-Y?(i.push([t,0]),r=-t):a+o>X+Y&&(i.push([-t,0]),r=t);o+=a}e.points=i}_wrapPoint(e,t){const s=e.geometry;if(t===X){const i=5*Y;s.x<i?e.geometry={points:[[s.x,s.y],[t,0]]}:s.x>X-i&&(e.geometry={points:[[s.x,s.y],[-t,0]]})}else s.x<-Y?e.geometry={points:[[s.x,s.y],[t,0]]}:s.x>X+Y&&(e.geometry={points:[[s.x,s.y],[-t,0]]})}_processGraphics(e,t,s){if(!(t&&t.length)||!this._meshFactory)return Promise.resolve(null);const i=V.from(t,this.uid,e.transform),r=this._meshFactory;return this._matcher.then((t=>r.analyzeGraphics(i,this.container.stage.resourceManager,t,null,null,s).then((()=>(this._attributeStore.sendUpdates(),this._processAnalyzedGraphics(e,i))))))}_processAnalyzedGraphics(e,t){const s=this._meshFactory,i=t.getSize(),r=t.getCursor(),o={features:i,records:i,metrics:0},a=new F(e.key.id,o,A.DEFAULT,!1,!1),n=[];for(;r.next();){const t=r.readGraphic();t.insertAfter=-1===t.insertAfter?-1:this._displayIds.get(t.insertAfter),t.displayId=this._displayIds.get(t.attributes[this.uid]);const i=new D(t.displayId);i.insertAfter=t.insertAfter,n.push(i),s.writeGraphic(a,r,e.level,this.container.stage.resourceManager)}const h=e.tileInfoView.tileInfo.isWrappable,l=a.serialize(h);if(1!==l.length)return new q;const d=l[0].message;return q.fromVertexData(d,n)}_abortProcessingGraphic(e){this._graphicIdToAbortController.get(e)?.abort()}_getNullSymbol(e){const t=e.geometry;return S(t)?C:b(t)||w(t)?P:this.defaultPointSymbolEnabled?R:null}_flipUpdatingGraphics(){this._updatingGraphicsTimer&&clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=setTimeout((()=>{this._updatingGraphicsTimer=null,this.notifyChange("updating")}),160),this.notifyChange("updating")}};e([p()],re.prototype,"_effectiveRenderer",null),e([p({constructOnly:!0})],re.prototype,"requestUpdateCallback",void 0),e([p()],re.prototype,"container",void 0),e([p({constructOnly:!0})],re.prototype,"graphics",void 0),e([p()],re.prototype,"renderer",void 0),e([p()],re.prototype,"updating",null),e([p()],re.prototype,"view",void 0),e([p()],re.prototype,"updateRequested",void 0),e([p()],re.prototype,"defaultPointSymbolEnabled",void 0),re=e([c("esri.views.2d.layers.support.GraphicsView2D")],re);const oe=re;export{oe 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../request.js";import{createTask as r}from"../../../core/asyncUtils.js";import s from"../../../core/Handles.js";import{clamp as t}from"../../../core/mathUtils.js";import{destroyMaybe as i,abortMaybe as
|
|
5
|
+
import e from"../../../request.js";import{createTask as r}from"../../../core/asyncUtils.js";import s from"../../../core/Handles.js";import{clamp as t}from"../../../core/mathUtils.js";import{destroyMaybe as i,abortMaybe as o,disposeMaybe as a}from"../../../core/maybe.js";import{watch as n,initial as l}from"../../../core/reactiveUtils.js";import{isSVG as h}from"../../../core/urlUtils.js";import{c as u}from"../../../chunks/mat3f32.js";import{DisplayObject as m}from"../engine/DisplayObject.js";import{Pos2us as c}from"../engine/webgl/DefaultVertexAttributeLayouts.js";import{WGLDrawPhase as d}from"../engine/webgl/enums.js";import{createMagnifierProgram as _,magnifierProgramTemplate as p}from"../engine/webgl/shaders/MagnifierPrograms.js";import{loadMagnifierResources as f}from"../../magnifier/resources.js";import{BufferObject as g}from"../../webgl/BufferObject.js";import{PrimitiveType as x,Usage as b,PixelFormat as T,TextureWrapMode as y,TextureSamplingMode as k}from"../../webgl/enums.js";import{Texture as R}from"../../webgl/Texture.js";import{TextureDescriptor as v}from"../../webgl/TextureDescriptor.js";import{VertexArrayObject as j}from"../../webgl/VertexArrayObject.js";class A extends m{constructor(){super(),this._handles=new s,this._resourcePixelRatio=1,this.visible=!1}destroy(){this._handles=i(this._handles),this._disposeRenderResources(),this._resourcesTask=o(this._resourcesTask)}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e,this.requestRender()}get magnifier(){return this._magnifier}set magnifier(e){this._magnifier=e,this._handles.removeAll(),this._handles.add([n((()=>e.version),(()=>{this.visible=e.visible&&null!=e.position&&e.size>0,this.requestRender()}),l),n((()=>[e.maskUrl,e.overlayUrl]),(()=>this._reloadResources())),n((()=>e.size),(()=>{this._disposeRenderResources(),this.requestRender()}))])}_createTransforms(){return{dvs:u()}}doRender(e){const r=e.context;if(!this._resourcesTask)return void this._reloadResources();if(e.drawPhase!==d.MAP||!this._canRender())return;this._updateResources(e);const s=this._magnifier;if(null==s.position)return;const i=e.pixelRatio,o=s.size*i,a=1/s.factor,n=Math.ceil(a*o);this._readbackTexture.resize(n,n);const{size:l}=e.state,h=i*l[0],u=i*l[1],m=.5*n,c=.5*n,_=t(i*s.position.x,m,h-m-1),p=t(u-i*s.position.y,c,u-c-1);r.setBlendingEnabled(!0);const f=_-m,g=p-c,b=this._readbackTexture;r.bindTexture(b,0),r.gl.copyTexImage2D(b.descriptor.target,0,b.descriptor.pixelFormat,f,g,n,n,0);const T=this.backgroundColor,y=T?[T.a*T.r/255,T.a*T.g/255,T.a*T.b/255,T.a]:[1,1,1,1],k=(_+s.offset.x*i)/h*2-1,R=(p-s.offset.y*i)/u*2-1,v=o/h*2,j=o/u*2,A=this._program;r.bindVAO(this._vertexArrayObject),r.bindTexture(this._overlayTexture,6),r.bindTexture(this._maskTexture,7),r.useProgram(A),A.setUniform4fv("u_background",y),A.setUniform1i("u_readbackTexture",0),A.setUniform1i("u_overlayTexture",6),A.setUniform1i("u_maskTexture",7),A.setUniform4f("u_drawPos",k,R,v,j),A.setUniform1i("u_maskEnabled",s.maskEnabled?1:0),A.setUniform1i("u_overlayEnabled",s.overlayEnabled?1:0),r.setStencilTestEnabled(!1),r.setColorMask(!0,!0,!0,!0),r.drawArrays(x.TRIANGLE_STRIP,0,4),r.bindVAO()}_canRender(){return this.mask&&this.overlay&&null!=this._magnifier}_reloadResources(){this._resourcesTask&&this._resourcesTask.abort();const s=null!=this._magnifier?this._magnifier.maskUrl:null,t=null!=this._magnifier?this._magnifier.overlayUrl:null;this._resourcesTask=r((async r=>{const i=null==s||null==t?f(r):null,o=null!=s?e(s,{responseType:"image",signal:r}).then((e=>e.data)):i.then((e=>e.mask)),a=null!=t?e(t,{responseType:"image",signal:r}).then((e=>e.data)):i.then((e=>e.overlay)),[n,l]=await Promise.all([o,a]);this.mask=n,this.overlay=l,this._disposeRenderResources(),this.requestRender()}))}_disposeRenderResources(){this._readbackTexture=a(this._readbackTexture),this._overlayTexture=a(this._overlayTexture),this._maskTexture=a(this._maskTexture),this._vertexArrayObject=a(this._vertexArrayObject),this._program=a(this._program)}_updateResources(e){if(e.pixelRatio!==this._resourcePixelRatio&&this._disposeRenderResources(),this._readbackTexture)return;const r=e.context;this._resourcePixelRatio=e.pixelRatio;const s=Math.ceil(this._magnifier.size*e.pixelRatio);this._program=_(r);const t=new Uint16Array([0,1,0,0,1,1,1,0]),i=p.attributes;this._vertexArrayObject=new j(r,i,c,{geometry:g.createVertex(r,b.STATIC_DRAW,t)}),this.overlay.width=s,this.overlay.height=s;const o=new v;o.internalFormat=T.RGBA,o.wrapMode=y.CLAMP_TO_EDGE,o.samplingMode=k.NEAREST,o.flipped=!0,o.preMultiplyAlpha=!h(this.overlay.src)||!e.context.driverTest.svgPremultipliesAlpha.result,this._overlayTexture=new R(r,o,this.overlay),this.mask.width=s,this.mask.height=s,o.pixelFormat=o.internalFormat=T.ALPHA,this._maskTexture=new R(r,o,this.mask);const a=1/this._magnifier.factor;o.pixelFormat=o.internalFormat=T.RGBA,o.width=o.height=Math.ceil(a*s),o.samplingMode=k.LINEAR,o.flipped=!1,this._readbackTexture=new R(r,o)}}export{A as default};
|
package/views/MapView.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import{isSome as s}from"../core/arrayUtils.js";import r from"../core/Collection.js";import n from"../core/CollectionFlattener.js";import a from"../core/Error.js";import has from"../core/has.js";import{isIterable as o}from"../core/iteratorUtils.js";import l from"../core/Logger.js";import{destroyMaybe as p}from"../core/maybe.js";import{throwIfAborted as h}from"../core/promiseUtils.js";import{watch as c,whenOnce as d,sync as u,syncAndInitial as g}from"../core/reactiveUtils.js";import{createScreenPoint as m}from"../core/screenUtils.js";import f from"../core/Warning.js";import{initialize as w}from"../core/workers/workers.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import{cast as _}from"../core/accessorSupport/decorators/cast.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as V}from"../core/accessorSupport/ensureType.js";import S from"../geometry/Extent.js";import j from"../geometry/Point.js";import{load as T,canProjectWithoutEngine as b,project as M,isLoaded as R}from"../geometry/projection.js";import{equals as x}from"../geometry/support/spatialReferenceUtils.js";import L from"../layers/support/TileInfo.js";import{BreakpointsOwner as O}from"./BreakpointsOwner.js";import{DOMContainer as k}from"./DOMContainer.js";import{PopupView as z}from"./PopupView.js";import P from"./View.js";import C from"./ViewAnimation.js";import E from"./2d/AnimationManager.js";import G from"./2d/FrameTask.js";import{layerView2DImporter as N}from"./2d/layerViewModuleImportUtils.js";import D from"./2d/MapViewConstraints.js";import q from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import U from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as A,setExtent as F,rotateTo as I,scaleTo as W,copy as $,create as H,extentToScale as B,resize as J,angleBetween as Q}from"./2d/viewpointUtils.js";import Z from"./2d/input/MapViewInputManager.js";import K from"./2d/layers/features/support/TileStore.js";import Y from"./2d/support/HighlightOptions.js";import{Timeline as X}from"./2d/support/Timeline.js";import ee from"./support/createScreenshotPlan.js";import{encode as te,encodeData as ie,getMaximumResolutionScale as se,getFormatAndQuality as re}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as ne,createScreenPointFromSupportedEvent as ae}from"./support/screenUtils.js";import{check as oe}from"./support/WebGLRequirements.js";import le from"./ui/DefaultUI.js";import pe from"./ui/2d/DefaultUI2D.js";import he from"../webmap/background/ColorBackground.js";let ce,de,ue,ge,me,fe;async function we(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:r,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);de=e,ue=t,ge=i,me=s,fe=r,ce=n}const ye=160;function _e(e){return e&&"esri.Viewpoint"===e.declaredClass}let ve=class extends(O(z(k(P)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new n({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this._stationaryTimer=null,this._gotoTask=null,this.frameTask=new G(this),this._pePromise=null,this.floors=new r,this.highlightOptions=new Y,this.inputManager=new Z({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new X,this.type="2d",this.ui=new pe,this._pixelFormat={flipY:!0,premultipliedAlpha:!0},this.constraints=new D,this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([c((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(ye)}),u),this.on("resize",(e=>this._resizeHandler(e))),c((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),w()}destroy(){this._set("preconditionsReady",!1),this.frameTask=p(this.frameTask),this._gotoTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new K(this.featuresTilingScheme)}get initialExtentRequired(){const{scale:e,constraints:t,center:i,viewpoint:s,extent:r}=this;let n=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!r&&(t?.effectiveLODs||(n=-1),(!i||0===e&&-1===n)&&(!s||null==s.targetGeometry||"extent"!==s.targetGeometry.type&&!s.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!R()||(this._pePromise||(this._pePromise=T().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=e.targetGeometry;return!!b(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame()),this.frameTask&&(this.frameTask.animationInProgress=!1)};e.when(i,i)}get background(){return be(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new j({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void l.getLogger(this).error(new a("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;A(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(c((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),u),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void l.getLogger(this).error(new a("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void l.getLogger(this).error(new a("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;F(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;I(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;W(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){const e=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)));if(has("esri-2d-log-updating")){const t=this.allLayerViews.reduce(((e,t)=>({...e,[t.layer.id]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${e}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(t)}\n`)}return e}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new a("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):null==e.targetGeometry&&(s=new a("mapview:invalid-viewpoint","geometry not defined"))}catch(n){s=new a("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:n})}if(s)return void l.getLogger(this).error(s);this._scaleBeforeChangingSpatialReference=null;const r=new i({targetGeometry:new j,scale:0,rotation:0});$(r,t),this.constraints.constrain(r,this.state.paddedViewState.viewpoint),this.state.viewpoint=r,this.frameTask.requestFrame(),this._set("viewpoint",r)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;W(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),d((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=H(e,this);return this.animation?.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));l.getLogger(this).error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=ne(e)?ae(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let r=new Set,n=!1,a=null,o=null;t?.include?Te(t.include,je(this,(e=>r.add(e)),(e=>{a||(a=new Set),a.add(e)}),(e=>r.add(e)),(()=>n=!0))):(n=!0,r=new Set(this.allLayerViews)),t?.exclude&&Te(t.exclude,je(this,(e=>r.delete(e)),(e=>{o||(o=new Set),o.add(e)})));const l=this.allLayerViews.filter((e=>!e.suspended&&r.has(e))).reverse(),p=this.toMap(i);let h=[...n?this.graphicsView.hitTest(p).map((e=>({type:"graphic",graphic:e,layer:null,mapPoint:p}))):[],...await Promise.all(l.map((e=>e.hitTest(p,i))).toArray())].filter(s).flat().filter(s);return a&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||a?.has(Se(e.graphic))))),o&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||!o?.has(Se(e.graphic))))),{screenPoint:i,results:h}}async takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return te(i,{format:t.format,quality:t.quality,rotation:0,disableDecorations:!1},this._pixelFormat)}async _takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return ie(i,this._pixelFormat)}_createScreenshotPlan(e){e=e??{};const t=this.supersampleScreenshotsEnabled?Math.min(4,se(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:s,quality:r}=re(e.format,e.quality);return ee(e,t,this.size,this.padding,s,r,i,e.rotation)}get test(){return{takeScreenshot:e=>this._takeScreenshot(e)}}toMap(e){if(!this.ready)return null;const t=ne(e)?ae(this,e):e,i=[0,0],[s,r]=this.state.toMap(i,[t.x,t.y]),n=this.spatialReference;return new j({x:s,y:r,spatialReference:n})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),m(i[0],i[1])}on(e,t,i,s){const r=this.inputManager&&this.viewEvents.on(e,t,i,s);return r||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return N.hasLayerViewModule(e)}importLayerView(e){return N.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(l.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=oe(this.type);return has("safari")&&has("safari")<9&&(e=new a("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e?(l.getLogger(this).warn("#validate()",e.message),Promise.reject(e)):we()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new C),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,r=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(t&&!t.done&&(t.stop(),this.frameTask.animationInProgress=!1),this.animation=null),e})),n=new Promise((e=>e(r)));return t.when().catch((()=>{s()&&n.cancel&&n.cancel()})),n}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(h(t),i!==this._gotoTask)throw new a("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,r)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<ye&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:t,map:s,padding:r,size:n}=this;if(!e)return null;const a=s&&"initialViewProperties"in s?s.initialViewProperties:void 0,o={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};e.effectiveLODs?-1!==o.zoom&&(o.scale=e.zoomToScale(o.zoom)):o.zoom=-1;let l=null,p=null,h=0;const c=o.viewpoint&&o.viewpoint.rotation,d=o.viewpoint&&o.viewpoint.targetGeometry;null!=d&&("extent"===d.type?l=d:"point"===d.type&&(p=d,h=o.viewpoint.scale));const u=o.extent||l||a?.viewpoint?.targetGeometry?.extent||t,g=o.center||p||u?.center,m=o.scale||h||a?.viewpoint?.scale||u&&B(u,[n[0]-r.left-r.right,n[1]-r.top-r.bottom]),f=o.rotation||c||a?.viewpoint?.rotation||0;return g&&m?new i({targetGeometry:g,scale:m,rotation:f}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation;if(!s)return Promise.resolve();const r=e.then((e=>{if(h(t),i!==this._gotoTask)throw new a("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,r)}_project(e,t){const i=e&&e.targetGeometry||e;if(!t)return e;if(!i)return null;if(t.imageCoordinateSystem||i.spatialReference?.imageCoordinateSystem)return e;if(x(t,i.spatialReference))return e;const s=M(i,t);if(!s)throw new a("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:i,spatialReference:t});return _e(e)?(e.targetGeometry=s,e):s}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],J(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,void 0),this.state.viewpoint=i}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint(),t=e.targetGeometry;try{this._project(e,this.spatialReference)}catch(o){l.getLogger(this).warn(new f("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:t.toJSON(),spatialReference:this.spatialReference,error:o})),e.targetGeometry=this.defaultsFromMap.extent?.center||new j({x:0,y:0,spatialReference:this.spatialReference})}this.constraints?.fit(e),this._set("state",new q({padding:this._get("padding"),size:this.size,viewpoint:e})),this.graphics.owner=this;const i=new ce(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=i,this._magnifierView=new fe,this._magnifierView.magnifier=this.magnifier;const s=new ge({view:this});this._set("labelManager",s);const r=new E({view:this});this._set("animationManager",r);const n=new me({view:this,animationManager:r});this._set("mapViewNavigation",n),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),i.on("post-render",(()=>this._set("rendering",i.renderRequested))),i.on("will-render",(()=>this._set("rendering",i.renderRequested))),i.on("webgl-error",(e=>this.fatalError=e.error)),c((()=>this.stationary),(e=>i.stationary=e),g),c((()=>this.background),(e=>{i.background=e,this._magnifierView.background=e}),g),c((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),g),c((()=>this.renderingOptions),(e=>i.renderingOptions=e),g),c((()=>this.highlightOptions),(e=>i.highlightOptions=e),g),c((()=>this.state.id),(()=>i.state=this.state),g)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:r}=this.state.paddedViewState,n=new j({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",n),this._set("zoom",-1),this._set("rotation",s),this._set("scale",r),this._set("spatialReference",i),this._set("state",null),this.animation=null}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new U(L.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new de({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ue(e)});this.frameTask.graphicsView=t,this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),this.frameTask.graphicsView=null,e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(null==this._scaleBeforeChangingSpatialReference)this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[r,n]=t.center;let a=null;try{a=this._project(new j({x:r,y:n,spatialReference:t.spatialReference}),e)}catch(p){R()||l.getLogger(this).warn(new f("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:a?.toJSON(),spatialReference:e,error:p}))}a||(a=new j({x:0,y:0,spatialReference:e}));const o=A(new i({targetGeometry:new j,scale:0,rotation:0}),t.viewpoint,a);s.viewpoint=o;try{const i=20,r=[t.size[0]/2,t.size[1]/2],n=[r[0]+i,r[1]],a=t.toMap([0,0],n),{x:l,y:p}=this._project(new j({x:a[0],y:a[1],spatialReference:t.spatialReference}),e);a[0]=l,a[1]=p,s.toScreen(a,a);const h=Q(r,a,n),c=Math.hypot(a[0]-r[0],a[1]-r[1])/i;!Number.isFinite(c)||Math.abs(c)>4?(o.rotation=0,o.targetGeometry=new j({x:0,y:0,spatialReference:e})):(o.scale*=c,o.scale>has("mapview-srswitch-adjust-rotation-scale-threshold")?o.rotation=0:o.rotation+=Number.isFinite(h)?h:0)}catch{}this._get("constraints").constrain(o,void 0),this._get("state").viewpoint=o,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};ve.type="2d",e([y({readOnly:!0})],ve.prototype,"animationManager",void 0),e([y({constructOnly:!0})],ve.prototype,"deactivatedWebGLExtensions",void 0),e([y({constructOnly:!0})],ve.prototype,"debugWebGLExtensions",void 0),e([y({readOnly:!0})],ve.prototype,"featuresTilingScheme",void 0),e([y({readOnly:!0})],ve.prototype,"fullOpacity",void 0),e([y({readOnly:!0})],ve.prototype,"graphicsTileStore",null),e([y()],ve.prototype,"graphicsView",void 0),e([y({readOnly:!0})],ve.prototype,"state",void 0),e([y()],ve.prototype,"initialExtentRequired",null),e([y()],ve.prototype,"labelManager",void 0),e([y({readOnly:!0})],ve.prototype,"resourceManager",null),e([y({readOnly:!0})],ve.prototype,"textureManager",null),e([y({readOnly:!0})],ve.prototype,"mapViewNavigation",void 0),e([y({constructOnly:!0})],ve.prototype,"renderCanvas",void 0),e([y()],ve.prototype,"renderingOptions",void 0),e([y({readOnly:!0})],ve.prototype,"rendering",void 0),e([y({constructOnly:!0})],ve.prototype,"supersampleScreenshotsEnabled",void 0),e([y({readOnly:!0})],ve.prototype,"supportsGround",void 0),e([y()],ve.prototype,"_stationaryTimer",void 0),e([y()],ve.prototype,"_defaultsFromMapSettings",null),e([y()],ve.prototype,"_pePromise",void 0),e([y({readOnly:!0})],ve.prototype,"typeSpecificPreconditionsReady",null),e([y()],ve.prototype,"animation",null),e([y({type:he})],ve.prototype,"background",null),e([y({value:null,type:j,dependsOn:["state.id","ready"]})],ve.prototype,"center",null),e([y({type:D})],ve.prototype,"constraints",null),e([y({value:null,type:S,dependsOn:["state.id","ready"]})],ve.prototype,"extent",null),e([y()],ve.prototype,"floors",void 0),e([y({type:Y})],ve.prototype,"highlightOptions",void 0),e([y({readOnly:!0})],ve.prototype,"inputManager",void 0),e([y()],ve.prototype,"map",void 0),e([y({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],ve.prototype,"padding",null),e([y()],ve.prototype,"resizeAlign",void 0),e([y({readOnly:!0,dependsOn:["state.id"]})],ve.prototype,"resolution",null),e([y({value:0,type:Number,dependsOn:["state.id","ready"]})],ve.prototype,"rotation",null),e([y({value:0,type:Number,dependsOn:["state.id","ready"]})],ve.prototype,"scale",null),e([y({constructOnly:!0})],ve.prototype,"spatialReferenceLocked",void 0),e([y()],ve.prototype,"stationary",null),e([y({type:X,readOnly:!0})],ve.prototype,"timeline",void 0),e([y({readOnly:!0})],ve.prototype,"type",void 0),e([y({readOnly:!0})],ve.prototype,"updating",null),e([y({value:null,type:i,dependsOn:["state.id","ready"]})],ve.prototype,"viewpoint",null),e([y({value:-1,dependsOn:["state.id","ready"]})],ve.prototype,"zoom",null),e([y({readOnly:!0})],ve.prototype,"navigating",null),e([y(),_((e=>e instanceof le?e:V(pe,e)))],ve.prototype,"ui",void 0),ve=e([v("esri.views.MapView")],ve);const Ve=ve;function Se(e){const t=e.getObjectId();return t?`${e.layer?.uid??e.sourceLayer?.uid??"MapView"}/${t}`:`"MapView/${e.uid}`}function je(e,i,s,r,n){return a=>{if(a instanceof t){if(a.layer===e)n?.();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&r?.(t)}s(Se(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Te(e,t){if(e)if(o(e))for(const i of e)if(o(i))for(const e of i)t(e);else t(i);else t(e)}function be(e){return"esri.WebMap"===e?.declaredClass}export{Ve as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import{isSome as s}from"../core/arrayUtils.js";import r from"../core/Collection.js";import n from"../core/CollectionFlattener.js";import a from"../core/Error.js";import has from"../core/has.js";import{isIterable as o}from"../core/iteratorUtils.js";import l from"../core/Logger.js";import{destroyMaybe as p}from"../core/maybe.js";import{throwIfAborted as h}from"../core/promiseUtils.js";import{watch as c,whenOnce as d,sync as u,syncAndInitial as g}from"../core/reactiveUtils.js";import{createScreenPoint as m}from"../core/screenUtils.js";import f from"../core/Warning.js";import{initialize as y}from"../core/workers/workers.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as _}from"../core/accessorSupport/decorators/cast.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as V}from"../core/accessorSupport/ensureType.js";import S from"../geometry/Extent.js";import j from"../geometry/Point.js";import{load as T,canProjectWithoutEngine as b,project as M,isLoaded as R}from"../geometry/projection.js";import{equals as x}from"../geometry/support/spatialReferenceUtils.js";import L from"../layers/support/TileInfo.js";import{BreakpointsOwner as O}from"./BreakpointsOwner.js";import{DOMContainer as k}from"./DOMContainer.js";import{PopupView as z}from"./PopupView.js";import P from"./View.js";import C from"./ViewAnimation.js";import E from"./2d/AnimationManager.js";import G from"./2d/FrameTask.js";import{layerView2DImporter as N}from"./2d/layerViewModuleImportUtils.js";import D from"./2d/MapViewConstraints.js";import q from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import U from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as A,setExtent as F,rotateTo as I,scaleTo as W,copy as $,create as H,extentToScale as B,resize as J,angleBetween as Q}from"./2d/viewpointUtils.js";import Z from"./2d/input/MapViewInputManager.js";import K from"./2d/layers/features/support/TileStore.js";import Y from"./2d/support/HighlightOptions.js";import{Timeline as X}from"./2d/support/Timeline.js";import ee from"./support/createScreenshotPlan.js";import{encode as te,encodeData as ie,getMaximumResolutionScale as se,getFormatAndQuality as re}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as ne,createScreenPointFromSupportedEvent as ae}from"./support/screenUtils.js";import{check as oe}from"./support/WebGLRequirements.js";import le from"./ui/DefaultUI.js";import pe from"./ui/2d/DefaultUI2D.js";import he from"../webmap/background/ColorBackground.js";let ce,de,ue,ge,me,fe;async function ye(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:r,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);de=e,ue=t,ge=i,me=s,fe=r,ce=n}const we=160;function _e(e){return e&&"esri.Viewpoint"===e.declaredClass}let ve=class extends(O(z(k(P)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new n({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this._stationaryTimer=null,this._gotoTask=null,this.frameTask=new G(this),this._pePromise=null,this.floors=new r,this.highlightOptions=new Y,this.inputManager=new Z({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new X,this.type="2d",this.ui=new pe,this._pixelFormat={flipY:!0,premultipliedAlpha:!0},this.constraints=new D,this.padding={top:0,right:0,bottom:0,left:0},this.addHandles([c((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(we)}),u),this.on("resize",(e=>this._resizeHandler(e))),c((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),y()}destroy(){this._set("preconditionsReady",!1),this.frameTask=p(this.frameTask),this._gotoTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new K(this.featuresTilingScheme)}get initialExtentRequired(){const{scale:e,constraints:t,center:i,viewpoint:s,extent:r}=this;let n=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!r&&(t?.effectiveLODs||(n=-1),(!i||0===e&&-1===n)&&(!s||null==s.targetGeometry||"extent"!==s.targetGeometry.type&&!s.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!R()||(this._pePromise||(this._pePromise=T().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=e.targetGeometry;return!!b(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask?.requestFrame()),this.frameTask&&(this.frameTask.animationInProgress=!1)};e.when(i,i)}get background(){return be(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new j({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void l.getLogger(this).error(new a("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;A(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(c((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),u),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void l.getLogger(this).error(new a("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void l.getLogger(this).error(new a("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;F(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;I(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;W(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){const e=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)));if(has("esri-2d-log-updating")){const t=this.allLayerViews.reduce(((e,t)=>({...e,[t.layer.id]:!t.destroyed&&!("layerViews"in t)&&t.updating})),{});console.log(`Updating MapView: ${e}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(t)}\n`)}return e}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new a("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):null==e.targetGeometry&&(s=new a("mapview:invalid-viewpoint","geometry not defined"))}catch(n){s=new a("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:n})}if(s)return void l.getLogger(this).error(s);this._scaleBeforeChangingSpatialReference=null;const r=new i({targetGeometry:new j,scale:0,rotation:0});$(r,t),this.constraints.constrain(r,this.state.paddedViewState.viewpoint),this.state.viewpoint=r,this.frameTask.requestFrame(),this._set("viewpoint",r)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;W(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),d((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=H(e,this);return this.animation?.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));l.getLogger(this).error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=ne(e)?ae(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let r=new Set,n=!1,a=null,o=null;t?.include?Te(t.include,je(this,(e=>r.add(e)),(e=>{a||(a=new Set),a.add(e)}),(e=>r.add(e)),(()=>n=!0))):(n=!0,r=new Set(this.allLayerViews)),t?.exclude&&Te(t.exclude,je(this,(e=>r.delete(e)),(e=>{o||(o=new Set),o.add(e)})));const l=this.allLayerViews.filter((e=>!e.suspended&&r.has(e))).reverse(),p=this.toMap(i);let h=[...n?this.graphicsView.hitTest(p).map((e=>({type:"graphic",graphic:e,layer:null,mapPoint:p}))):[],...await Promise.all(l.map((e=>e.hitTest(p,i))).toArray())].filter(s).flat().filter(s);return a&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||a?.has(Se(e.graphic))))),o&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||!o?.has(Se(e.graphic))))),{screenPoint:i,results:h}}async takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return te(i,{format:t.format,quality:t.quality,rotation:0,disableDecorations:!1},this._pixelFormat)}async _takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return ie(i,this._pixelFormat)}_createScreenshotPlan(e){e=e??{};const t=this.supersampleScreenshotsEnabled?Math.min(4,se(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:s,quality:r}=re(e.format,e.quality);return ee(e,t,this.size,this.padding,s,r,i,e.rotation)}get test(){return{takeScreenshot:e=>this._takeScreenshot(e)}}toMap(e){if(!this.ready)return null;const t=ne(e)?ae(this,e):e,i=[0,0],[s,r]=this.state.toMap(i,[t.x,t.y]),n=this.spatialReference;return new j({x:s,y:r,spatialReference:n})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),m(i[0],i[1])}on(e,t,i,s){const r=this.inputManager&&this.viewEvents.on(e,t,i,s);return r||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return N.hasLayerViewModule(e)}importLayerView(e){return N.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(l.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=oe(this.type);return has("safari")&&has("safari")<9&&(e=new a("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e?(l.getLogger(this).warn("#validate()",e.message),Promise.reject(e)):ye()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new C),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,r=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(t&&!t.done&&(t.stop(),this.frameTask.animationInProgress=!1),this.animation=null),e})),n=new Promise((e=>e(r)));return t.when().catch((()=>{s()&&n.cancel&&n.cancel()})),n}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(h(t),i!==this._gotoTask)throw new a("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,r)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<we&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:t,map:s,padding:r,size:n}=this;if(!e)return null;const a=s&&"initialViewProperties"in s?s.initialViewProperties:void 0,o={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};e.effectiveLODs?-1!==o.zoom&&(o.scale=e.zoomToScale(o.zoom)):o.zoom=-1;let l=null,p=null,h=0;const c=o.viewpoint&&o.viewpoint.rotation,d=o.viewpoint&&o.viewpoint.targetGeometry;null!=d&&("extent"===d.type?l=d:"point"===d.type&&(p=d,h=o.viewpoint.scale));const u=o.extent||l||a?.viewpoint?.targetGeometry?.extent||t,g=o.center||p||u?.center,m=o.scale||h||a?.viewpoint?.scale||u&&B(u,[n[0]-r.left-r.right,n[1]-r.top-r.bottom]),f=o.rotation||c||a?.viewpoint?.rotation||0;return g&&m?new i({targetGeometry:g,scale:m,rotation:f}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation;if(!s)return Promise.resolve();const r=e.then((e=>{if(h(t),i!==this._gotoTask)throw new a("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,r)}_project(e,t){const i=e&&e.targetGeometry||e;if(!t)return e;if(!i)return null;if(t.imageCoordinateSystem||i.spatialReference?.imageCoordinateSystem)return e;if(x(t,i.spatialReference))return e;const s=M(i,t);if(!s)throw new a("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:i,spatialReference:t});return _e(e)?(e.targetGeometry=s,e):s}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],J(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,void 0),this.state.viewpoint=i}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint(),t=e.targetGeometry;try{this._project(e,this.spatialReference)}catch(o){l.getLogger(this).warn(new f("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:t.toJSON(),spatialReference:this.spatialReference,error:o})),e.targetGeometry=this.defaultsFromMap.extent?.center||new j({x:0,y:0,spatialReference:this.spatialReference})}this.constraints?.fit(e),this._set("state",new q({padding:this._get("padding"),size:this.size,viewpoint:e})),this.graphics.owner=this;const i=new ce(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=i,this._magnifierView=new fe,this._magnifierView.magnifier=this.magnifier;const s=new ge({view:this});this._set("labelManager",s);const r=new E({view:this});this._set("animationManager",r);const n=new me({view:this,animationManager:r});this._set("mapViewNavigation",n),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),i.on("post-render",(()=>this._set("rendering",i.renderRequested))),i.on("will-render",(()=>this._set("rendering",i.renderRequested))),i.on("webgl-error",(e=>this.fatalError=e.error)),c((()=>this.stationary),(e=>i.stationary=e),g),c((()=>this.background),(e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color}),g),c((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),g),c((()=>this.renderingOptions),(e=>i.renderingOptions=e),g),c((()=>this.highlightOptions),(e=>i.highlightOptions=e),g),c((()=>this.state.id),(()=>i.state=this.state),g)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:r}=this.state.paddedViewState,n=new j({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",n),this._set("zoom",-1),this._set("rotation",s),this._set("scale",r),this._set("spatialReference",i),this._set("state",null),this.animation=null}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new U(L.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new de({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ue(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(null==this._scaleBeforeChangingSpatialReference)this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[r,n]=t.center;let a=null;try{a=this._project(new j({x:r,y:n,spatialReference:t.spatialReference}),e)}catch(p){R()||l.getLogger(this).warn(new f("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:a?.toJSON(),spatialReference:e,error:p}))}a||(a=new j({x:0,y:0,spatialReference:e}));const o=A(new i({targetGeometry:new j,scale:0,rotation:0}),t.viewpoint,a);s.viewpoint=o;try{const i=20,r=[t.size[0]/2,t.size[1]/2],n=[r[0]+i,r[1]],a=t.toMap([0,0],n),{x:l,y:p}=this._project(new j({x:a[0],y:a[1],spatialReference:t.spatialReference}),e);a[0]=l,a[1]=p,s.toScreen(a,a);const h=Q(r,a,n),c=Math.hypot(a[0]-r[0],a[1]-r[1])/i;!Number.isFinite(c)||Math.abs(c)>4?(o.rotation=0,o.targetGeometry=new j({x:0,y:0,spatialReference:e})):(o.scale*=c,o.scale>has("mapview-srswitch-adjust-rotation-scale-threshold")?o.rotation=0:o.rotation+=Number.isFinite(h)?h:0)}catch{}this._get("constraints").constrain(o,void 0),this._get("state").viewpoint=o,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};ve.type="2d",e([w({readOnly:!0})],ve.prototype,"animationManager",void 0),e([w({constructOnly:!0})],ve.prototype,"deactivatedWebGLExtensions",void 0),e([w({constructOnly:!0})],ve.prototype,"debugWebGLExtensions",void 0),e([w({readOnly:!0})],ve.prototype,"featuresTilingScheme",void 0),e([w({readOnly:!0})],ve.prototype,"fullOpacity",void 0),e([w({readOnly:!0})],ve.prototype,"graphicsTileStore",null),e([w()],ve.prototype,"graphicsView",void 0),e([w({readOnly:!0})],ve.prototype,"state",void 0),e([w()],ve.prototype,"initialExtentRequired",null),e([w()],ve.prototype,"labelManager",void 0),e([w({readOnly:!0})],ve.prototype,"resourceManager",null),e([w({readOnly:!0})],ve.prototype,"textureManager",null),e([w({readOnly:!0})],ve.prototype,"mapViewNavigation",void 0),e([w({constructOnly:!0})],ve.prototype,"renderCanvas",void 0),e([w()],ve.prototype,"renderingOptions",void 0),e([w({readOnly:!0})],ve.prototype,"rendering",void 0),e([w({constructOnly:!0})],ve.prototype,"supersampleScreenshotsEnabled",void 0),e([w({readOnly:!0})],ve.prototype,"supportsGround",void 0),e([w()],ve.prototype,"_stationaryTimer",void 0),e([w()],ve.prototype,"_defaultsFromMapSettings",null),e([w()],ve.prototype,"_pePromise",void 0),e([w({readOnly:!0})],ve.prototype,"typeSpecificPreconditionsReady",null),e([w()],ve.prototype,"animation",null),e([w({type:he})],ve.prototype,"background",null),e([w({value:null,type:j,dependsOn:["state.id","ready"]})],ve.prototype,"center",null),e([w({type:D})],ve.prototype,"constraints",null),e([w({value:null,type:S,dependsOn:["state.id","ready"]})],ve.prototype,"extent",null),e([w()],ve.prototype,"floors",void 0),e([w({type:Y})],ve.prototype,"highlightOptions",void 0),e([w({readOnly:!0})],ve.prototype,"inputManager",void 0),e([w()],ve.prototype,"map",void 0),e([w({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],ve.prototype,"padding",null),e([w()],ve.prototype,"resizeAlign",void 0),e([w({readOnly:!0,dependsOn:["state.id"]})],ve.prototype,"resolution",null),e([w({value:0,type:Number,dependsOn:["state.id","ready"]})],ve.prototype,"rotation",null),e([w({value:0,type:Number,dependsOn:["state.id","ready"]})],ve.prototype,"scale",null),e([w({constructOnly:!0})],ve.prototype,"spatialReferenceLocked",void 0),e([w()],ve.prototype,"stationary",null),e([w({type:X,readOnly:!0})],ve.prototype,"timeline",void 0),e([w({readOnly:!0})],ve.prototype,"type",void 0),e([w({readOnly:!0})],ve.prototype,"updating",null),e([w({value:null,type:i,dependsOn:["state.id","ready"]})],ve.prototype,"viewpoint",null),e([w({value:-1,dependsOn:["state.id","ready"]})],ve.prototype,"zoom",null),e([w({readOnly:!0})],ve.prototype,"navigating",null),e([w(),_((e=>e instanceof le?e:V(pe,e)))],ve.prototype,"ui",void 0),ve=e([v("esri.views.MapView")],ve);const Ve=ve;function Se(e){const t=e.getObjectId();return t?`${e.layer?.uid??e.sourceLayer?.uid??"MapView"}/${t}`:`"MapView/${e.uid}`}function je(e,i,s,r,n){return a=>{if(a instanceof t){if(a.layer===e)n?.();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&r?.(t)}s(Se(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Te(e,t){if(e)if(o(e))for(const i of e)if(o(i))for(const e of i)t(e);else t(i);else t(e)}function be(e){return"esri.WebMap"===e?.declaredClass}export{Ve 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.27/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{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getOwningPortalUrl as k,getEffectiveLayerCapabilities as g}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as v}from"../../portal/support/urlUtils.js";import b from"../Attachments/AttachmentsViewModel.js";import W from"./CreateFeaturesWorkflow.js";import _ from"./CreateWorkflow.js";import{workflowDeprecation as F}from"./deprecationUtils.js";import C from"./UpdateWorkflow.js";import{whenEditorLayerView as E}from"./workflowUtils.js";import{formTemplateHasInvalidFields as I}from"../FeatureForm/featureFormUtils.js";import U from"../FeatureForm/FeatureFormViewModel.js";import A from"../FeatureTemplates/FeatureTemplatesViewModel.js";import O from"../Sketch/SketchViewModel.js";import V from"../Spinner/SpinnerViewModel.js";const M="esri.widgets.Editor.EditorViewModel",j=n.getLogger(M),T=["create","create-features","update"];function S(t,e,a){j.error(new i(t,e,a))}function L(t,e){return t?t.find((t=>t.layer===e)):void 0}let P=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new b({capabilities:{editing:!0}}),this.featureFormViewModel=new U,this.featureTemplatesViewModel=new A,this.sketchViewModel=new O({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new V,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{const t=this.activeWorkflow;t&&this.canGoBack&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})))},this.saveAndResetWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return;const{activeWorkflow:a}=this;await(a?.commit()),a?.reset()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...T]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(j,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)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?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(F(j,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void S("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(F(j,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void S("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(F(j,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void S("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void S("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void S("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void S("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteFeature((async(t,e)=>this._applyEdits(t,e))):S("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return t&&this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate||!1}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!1}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=g(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const{layer:a,suspended:p}of o.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)n.push(this._makeEditableItemForLayer(a.sublayers.at(t),p))}else n.push(this._makeEditableItemForLayer(a,p));for(const a of s.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(const t of a.sublayers)n.push(this._makeEditableItemForLayer(t,!1))}else n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this._editableItems;this._editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&S("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 W.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return _.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return C.create(this,t,((t,e)=>this._applyEdits(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("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("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 k(t.url):null,s={returnServiceEditsOption:(!i||!v(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{if(g(t)?.operations.supportsQuery){const a=await E(this.view,t);return r=await t.applyEdits(e,s),await h((()=>!a.updating)),r}return r=await t.applyEdits(e,s),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("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=>{S("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),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=g(t),r=a?.operations,i=L(this.layerInfos,t),s=I(t),o=this.allowedWorkflows,n=o.includes("create")||o.includes("create-features"),l=o.includes("update"),d=t=>!i||!1!==i.enabled&&!1!==i[t],p=n&&!!r?.supportsAdd&&d("addEnabled"),c=l&&!!r?.supportsUpdate&&d("updateEnabled"),u=!s&&l&&!!r?.supportsDelete&&d("deleteEnabled"),h=[];e||(p&&h.push("create"),c&&h.push("update"),u&&h.push("delete"));const w=c&&!s&&(!i||!1!==i.attributeUpdatesEnabled),f=c&&!s&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),m=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:h,attributeUpdatesEnabled:w,geometryUpdatesEnabled:f,hasAttachments:m,attachmentsOnCreateEnabled:m&&n&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!s&&m&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s}}};t([f()],P.prototype,"_editableItems",void 0),t([f({readOnly:!0})],P.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],P.prototype,"_activityQueue",void 0),t([f({value:[...T]})],P.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],P.prototype,"canCreate",null),t([f({readOnly:!0})],P.prototype,"canUpdate",null),t([f()],P.prototype,"editableItems",null),t([f({readOnly:!0})],P.prototype,"failures",void 0),t([f()],P.prototype,"attachmentsViewModel",void 0),t([f()],P.prototype,"featureFormViewModel",void 0),t([f()],P.prototype,"featureTemplatesViewModel",void 0),t([f()],P.prototype,"labelOptions",null),t([f()],P.prototype,"layerInfos",null),t([f()],P.prototype,"sketchViewModel",void 0),t([f()],P.prototype,"snappingOptions",null),t([f()],P.prototype,"spinnerViewModel",void 0),t([f()],P.prototype,"state",null),t([f({readOnly:!0})],P.prototype,"syncing",null),t([f()],P.prototype,"updating",null),t([f()],P.prototype,"tooltipOptions",null),t([f()],P.prototype,"view",null),t([f()],P.prototype,"pageStack",void 0),t([f()],P.prototype,"showDiscardEditsPrompt",void 0),t([f()],P.prototype,"_candidateCommitted",void 0),t([f()],P.prototype,"page",null),t([f()],P.prototype,"selectedTemplateItem",null),t([f()],P.prototype,"featureFormDisabled",null),t([f()],P.prototype,"canGoBack",null),t([f()],P.prototype,"shouldShowDeleteButton",null),t([f()],P.prototype,"hasPendingEdits",null),t([f()],P.prototype,"useDeprecatedCreateWorkflow",void 0),P=t([m(M)],P);const D=P;export{D 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{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getOwningPortalUrl as k,getEffectiveLayerCapabilities as g}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as v}from"../../portal/support/urlUtils.js";import b from"../Attachments/AttachmentsViewModel.js";import W from"./CreateFeaturesWorkflow.js";import _ from"./CreateWorkflow.js";import{workflowDeprecation as F}from"./deprecationUtils.js";import C from"./UpdateWorkflow.js";import{whenEditorLayerView as E}from"./workflowUtils.js";import{formTemplateHasInvalidFields as I}from"../FeatureForm/featureFormUtils.js";import U from"../FeatureForm/FeatureFormViewModel.js";import A from"../FeatureTemplates/FeatureTemplatesViewModel.js";import O from"../Sketch/SketchViewModel.js";import V from"../Spinner/SpinnerViewModel.js";const M="esri.widgets.Editor.EditorViewModel",j=n.getLogger(M),T=["create","create-features","update"];function S(t,e,a){j.error(new i(t,e,a))}function L(t,e){return t?t.find((t=>t.layer===e)):void 0}let P=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._unsupportedFieldTypes=["date-only","time-only","timestamp-offset"],this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new b({capabilities:{editing:!0}}),this.featureFormViewModel=new U,this.featureTemplatesViewModel=new A,this.sketchViewModel=new O({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new V,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{const t=this.activeWorkflow;t&&this.canGoBack&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})))},this.saveAndResetWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return;const{activeWorkflow:a}=this;await(a?.commit()),a?.reset()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...T]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(j,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)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?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(F(j,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void S("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(F(j,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void S("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(F(j,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void S("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void S("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void S("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void S("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteFeature((async(t,e)=>this._applyEdits(t,e))):S("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!1}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=g(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const{layer:a,suspended:p}of o.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)n.push(this._makeEditableItemForLayer(a.sublayers.at(t),p))}else n.push(this._makeEditableItemForLayer(a,p));for(const a of s.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(const t of a.sublayers)n.push(this._makeEditableItemForLayer(t,!1))}else n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this._editableItems;this._editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&S("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 W.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return _.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return C.create(this,t,((t,e)=>this._applyEdits(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("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("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 k(t.url):null,s={returnServiceEditsOption:(!i||!v(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{if(g(t)?.operations.supportsQuery){const a=await E(this.view,t);return r=await t.applyEdits(e,s),await h((()=>!a.updating)),r}return r=await t.applyEdits(e,s),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("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=>{S("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),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=g(t),r=a?.operations,i=L(this.layerInfos,t),s=I(t),o=t.fields.some((({type:t})=>this._unsupportedFieldTypes.includes(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([f()],P.prototype,"_editableItems",void 0),t([f({readOnly:!0})],P.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],P.prototype,"_activityQueue",void 0),t([f({value:[...T]})],P.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],P.prototype,"canCreate",null),t([f({readOnly:!0})],P.prototype,"canUpdate",null),t([f()],P.prototype,"editableItems",null),t([f({readOnly:!0})],P.prototype,"failures",void 0),t([f()],P.prototype,"attachmentsViewModel",void 0),t([f()],P.prototype,"featureFormViewModel",void 0),t([f()],P.prototype,"featureTemplatesViewModel",void 0),t([f()],P.prototype,"labelOptions",null),t([f()],P.prototype,"layerInfos",null),t([f()],P.prototype,"sketchViewModel",void 0),t([f()],P.prototype,"snappingOptions",null),t([f()],P.prototype,"spinnerViewModel",void 0),t([f()],P.prototype,"state",null),t([f({readOnly:!0})],P.prototype,"syncing",null),t([f()],P.prototype,"updating",null),t([f()],P.prototype,"tooltipOptions",null),t([f()],P.prototype,"view",null),t([f()],P.prototype,"pageStack",void 0),t([f()],P.prototype,"showDiscardEditsPrompt",void 0),t([f()],P.prototype,"_candidateCommitted",void 0),t([f()],P.prototype,"page",null),t([f()],P.prototype,"selectedTemplateItem",null),t([f()],P.prototype,"featureFormDisabled",null),t([f()],P.prototype,"canGoBack",null),t([f()],P.prototype,"shouldShowDeleteButton",null),t([f()],P.prototype,"hasPendingEdits",null),t([f()],P.prototype,"useDeprecatedCreateWorkflow",void 0),P=t([m(M)],P);const D=P;export{D 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t,abortHandle as i}from"../../core/handleUtils.js";import{abortMaybe as a}from"../../core/maybe.js";import{onAbort as s,createAbortError as r,throwIfAborted as o,isAborted as d}from"../../core/promiseUtils.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t,abortHandle as i}from"../../core/handleUtils.js";import{abortMaybe as a}from"../../core/maybe.js";import{onAbort as s,createAbortError as r,throwIfAborted as o,isAborted as d}from"../../core/promiseUtils.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as c}from"../../layers/support/layerUtils.js";import{sceneLayerEditingEnabled as m,i3sPatchingEnabled as h}from"../../support/featureFlags.js";import{highlightsSupported as g}from"../../views/support/layerViewUtils.js";import{Edits as f}from"./Edits.js";import w from"./UpdateWorkflowData.js";import y from"./Workflow.js";import{cloneGraphicExceptMesh as v,createWorkflowSteps as b,fetchCandidates as M,whenEditorLayerView as U,fetchFullFeature as I,findLayerInfo as j,getVisualVariableAttributes as A,setUpGeometryUpdate as E,isTerminalUpdateEventType as F,canCreateInteractiveEditSession as k}from"./workflowUtils.js";var V;const x="candidate-highlight";let D=V=class extends y{constructor(e){super(e),this.type="update"}get shouldShowAttachments(){return!!this.data?.editableItem.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.data?.editableItem.supports.includes("update")}get hasPendingEdits(){return this.data.edits.modified}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.editableItem,t=e.capabilities?.operations.supportsUpdate,i=p(e)?.operations.supportsUpdate;return c(e)&&!e.editingEnabled||!!i&&!t}get hasInvalidFormTemplate(){return this.data.editableItem.hasInvalidFormTemplate}get hasUnsupportedFields(){return this.data.editableItem.hasUnsupportedFields}static create(e,t,i){const a=new V({data:new w({edits:new f,viewModel:e}),onCommit:async e=>{const t=e.edits.feature;if(!t)return;const a=t.sourceLayer,s=v(t);if(!e.edits.attributesModified){const e=a.objectIdField;if(s.attributes={[e]:t.getAttribute(e)},m()&&h()&&"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&(s.attributes[e]=t.getAttribute(e))}}e.edits.geometryModified||(s.geometry=null),await i(a,{updateFeatures:[s]})}});return a._set("steps",this._createWorkflowSteps(a,t)),a}async deleteFeature(e){const t=this.data.edits.feature;await this.reset();const i=t?.sourceLayer;i&&"applyEdits"in i&&await e(i,{deleteFeatures:[t]})}highlight(e){const t=this.data.viewModel.view;if(!t||!e)return;const i=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer||"subtype-sublayer"===e.layer?.type&&e.layer?.parent===t));g(i)&&this.handles.add(i.highlight(e),x)}unhighlight(){this.handles.remove(x)}static _createWorkflowSteps(e,l="awaiting-feature-to-update"){const{data:u,handles:p}=e,c=new Map;return b(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:i}=u.viewModel,d=u.viewModel.view;let n=null;p.add(t((()=>{n=a(n)})),this.id),u.edits.feature=null,u.candidates=[];const l=d.on("immediate-click",(async t=>{i.location=t.mapPoint,i.visible=!0,n?.abort();const{editableItems:a}=u.viewModel;n=new AbortController;const l=await new Promise(((e,i)=>{s(n?.signal,(()=>i(r()))),e(M(a,d,t,n?.signal))}));o(n),u.candidates=l.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),i.visible=1===u.candidates.length,0!==u.candidates.length&&(1===u.candidates.length?(u.edits.feature=u.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>i.visible=!1))):e.next())}));d.focus(),p.add(l,this.id)},async tearDown(){p.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){const{edits:t}=u;t.feature=null,p.add(n((()=>t.feature),(t=>{e.unhighlight(),e.highlight(t)})),this.id)},async tearDown(){e.unhighlight(),p.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){if(p.has("editing-existing-feature"))return;const a=u.edits.feature,s=u.viewModel.view,{attachmentsViewModel:r,editableItems:o,featureFormViewModel:l,layerInfos:g,sketchViewModel:f,spinnerViewModel:w}=u.viewModel;u.editableItem=o.find((e=>e.layer===a.layer));const y=new AbortController;p.add(i(y),this.id);const v=U(s,a.layer),b=I(a,s.spatialReference,y.signal),M=await v,V=await b;if(d(y))return;u.edits.updateGeometry(V.geometry),u.edits.updateAttributes(V.attributes),u.edits.trackChanges();const x=u.editableItem.supports,D=x.includes("create"),C=x.includes("update");r.set({capabilities:{editing:!0,operations:{add:D||C,update:C,delete:C}},graphic:V,filesEnabled:!1,mode:"view"});const S=V.sourceLayer,T=null!=S&&"feature"===S.type?j(g,S):void 0,P=T?.formTemplate,W=s.spatialReference;l.set({arcadeEditType:"UPDATE",feature:V,formTemplate:P,spatialReference:W,view:s}),p.add([l.on("value-change",(e=>{u.edits.updateAttributes(l.getValues()),V.attributes=u.edits.feature.attributes,_&&_.setAttribute(e.fieldName,e.value)})),n((()=>r.mode),(e=>{"add"===e&&u.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&u.viewModel.activeWorkflow.go("editing-attachment")}))],this.id);if(u.editableItem.geometryUpdatesEnabled){f.allowDeleteKey=!1;const t=A(V),{interactive:i,visual:a}=await E(V,t,f,s,(({geometry:e,attributes:i},a)=>{if(null!=t.rotation){const{field:e}=t.rotation;l.setValue(e,i[e])}if(null!=t.size){const{field:e}=t.size;l.setValue(e,i[e])}u.edits.updateAttributes(i),u.edits.updateGeometry(e),l.feature.geometry=e,"scene"===S?.type&&null!=S?.infoFor3D&&m()&&h()&&_&&"mesh"===e?.type&&_.setGeometry(e),("undo"===a.type||"redo"===a.type||"update"===a.type&&null!=a.toolEventInfo&&F(a.toolEventInfo.type))&&l.notifyFeatureGeometryChanged()}),c);p.add([i,a],this.id),p.add(i,e._handleKeys.beforeCommit),p.add(a,e._handleKeys.afterCommit)}else e.highlight(V);const _=k(M)?M.createInteractiveEditSession(a):null;_&&(p.add(t((()=>_.rollback())),this.id),p.add(t((()=>_.commit())),e._handleKeys.afterCommit)),w.visible=!1},async tearDown({canceled:t}){t&&(e.unhighlight(),p.remove(this.id))}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){u.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){u.viewModel.attachmentsViewModel.mode="view"}})})}};e([l()],D.prototype,"shouldShowAttachments",null),e([l()],D.prototype,"shouldAllowAttachmentEditing",null),e([l()],D.prototype,"hasPendingEdits",null),e([l()],D.prototype,"helpMessage",null),e([l()],D.prototype,"reliesOnOwnerAdminPrivileges",null),e([l()],D.prototype,"hasInvalidFormTemplate",null),e([l()],D.prototype,"hasUnsupportedFields",null),D=V=e([u("esri.widgets.Editor.UpdateWorkflow")],D);const C=D;export{C 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let l=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async cancel(t={force:!0}){return!1!==t.force?this._cancel():new Promise(((t,s)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel().then(t)},deny:()=>s(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await this.onCommit(this.data),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0}),this.data&&this.data.viewModel.sketchViewModel.layer.removeAll()),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],l.prototype,"data",void 0),t([n()],l.prototype,"hasNextStep",null),t([n()],l.prototype,"hasPreviousStep",null),t([n()],l.prototype,"onCommit",void 0),t([n()],l.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],l.prototype,"hasInvalidFormTemplate",null),t([n()],l.prototype,"shouldShowAttachments",null),t([n()],l.prototype,"shouldAllowAttachmentEditing",null),t([n()],l.prototype,"started",void 0),t([n({readOnly:!0})],l.prototype,"stepId",null),t([n()],l.prototype,"steps",void 0),t([n({readOnly:!0})],l.prototype,"type",void 0),t([n()],l.prototype,"helpMessage",null),t([n()],l.prototype,"hasPendingEdits",null),t([n()],l.prototype,"keyboardCancellationEnabled",null),t([n()],l.prototype,"commit",null),l=t([a("esri.widgets.Editor.Workflow")],l);const p=l;export{p as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let l=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async cancel(t={force:!0}){return!1!==t.force?this._cancel():new Promise(((t,s)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel().then(t)},deny:()=>s(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await this.onCommit(this.data),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0}),this.data&&this.data.viewModel.sketchViewModel.layer.removeAll()),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],l.prototype,"data",void 0),t([n()],l.prototype,"hasNextStep",null),t([n()],l.prototype,"hasPreviousStep",null),t([n()],l.prototype,"onCommit",void 0),t([n()],l.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],l.prototype,"hasInvalidFormTemplate",null),t([n()],l.prototype,"hasUnsupportedFields",null),t([n()],l.prototype,"shouldShowAttachments",null),t([n()],l.prototype,"shouldAllowAttachmentEditing",null),t([n()],l.prototype,"started",void 0),t([n({readOnly:!0})],l.prototype,"stepId",null),t([n()],l.prototype,"steps",void 0),t([n({readOnly:!0})],l.prototype,"type",void 0),t([n()],l.prototype,"helpMessage",null),t([n()],l.prototype,"hasPendingEdits",null),t([n()],l.prototype,"keyboardCancellationEnabled",null),t([n()],l.prototype,"commit",null),l=t([a("esri.widgets.Editor.Workflow")],l);const p=l;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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,on as n,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as A,incrementHeadingLevel as F}from"./support/Heading.js";import M from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as L}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",j=`${P}__panel`,U=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${j}-toolbar`,panelContent:`${j}-content`,panelContentMessage:`${j}-content__message`,panelContentSection:`${j}-content__section`,panelContentSectionGroup:`${j}-content__section__group`,panelContentScrimContainer:`${j}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,ownerAdminNotice:`${P}__owner-admin-notice`,invalidFormNotice:`${P}__invalid-form-notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:U,promptHeader:`${U}__header`,promptHeading:`${U}__header__heading`,promptMessage:`${U}__message`,promptDivider:`${U}__divider`,promptActions:`${U}__actions`,widgetIcon:"esri-icon-edit"},B={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function $(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let V=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroup(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...B},this._renderSelectIcon=()=>I("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...i)=>{const{messagesCommon:a,viewModel:n,visibleElements:r}=this,l=n.sketchViewModel,c=n.syncing||this._attachments.submitting;return I("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},I("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[I("calcite-button",{key:"undo-button",label:a.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},a.undo),I("calcite-button",{key:"redo-button",label:a.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},a.redo)]),...i)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"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._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),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.previous(),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},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([a((()=>F(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),a((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}}})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"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"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=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 view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...B,...e,snappingControlsElements:{...B.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(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;if(!e)return I("div",{key:"empty",class:D.base});const{state:t}=e;return I("div",{key:"base",class:D.base},I("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return I("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:i}=this;return I(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:i,heading:o.selectTemplate,headingLevel:s},I("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:i,headingLevel:a,_onBack:n,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.data.edits.modified||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?i.update:i.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):I("div",{key:"panel-content-section",class:D.panelContentSection},this._renderOwnerAdminNoticeIfApplicable(t),this._renderInvalidFormTemplateNoticeIfApplicable(t),I("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&I("div",{key:"attachments"},I(A,{level:F(a)},o.attachments),this._attachments.render())));return I(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:a,handleBack:n},I("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&I("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:i.delete}:null]))}_renderInvalidFormTemplateNoticeIfApplicable(e){if(e?.hasInvalidFormTemplate)return I("calcite-notice",{open:!0,icon:O,kind:"brand",scale:"s",class:D.invalidFormNotice},I("div",{slot:"message"},this.messages.formFieldUpdateError))}_renderOwnerAdminNoticeIfApplicable(e){if(e?.reliesOnOwnerAdminPrivileges)return I("calcite-notice",{open:!0,kind:"info",scale:"s",class:D.ownerAdminNotice},I("div",{slot:"message"},this.messages.ownerAdminNotice))}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:i,messages:a,messagesCommon:n}=this;return I(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:a.addAttachment,headingLevel:i,handleBack:o},I("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?n.cancel:n.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:i,headingLevel:a,messages:n,messagesCommon:r}=this;return i?I(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:n.editAttachment,headingLevel:a,handleBack:o},I("div",{key:"attachments",class:D.panelContent},t.render()),i.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return I("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return I("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:i,...a},n)=>I("calcite-button",{key:`action-${n}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...a},i))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:i}=e,a=i.secondary;let n;switch(o){case"danger":n="danger";break;case"info":n="brand";break;default:n="neutral"}const r=I("calcite-button",{afterCreate:$,appearance:"solid",key:"prompt-primary-button",kind:n,onclick:i.primary.action,scale:"m",width:a?"half":"full"},i.primary.label),l=a&&I("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:n,onclick:a.action,scale:"m",width:"half"},a.label);return I("calcite-scrim",{key:"prompt"},I("div",{class:`${D.promptContainer}--${o}`},I("div",{class:D.promptHeader},I("calcite-icon",{icon:O}),I(A,{class:D.promptHeading,level:this.headingLevel},t)),I("div",{class:D.promptMessage},s),I("div",{class:D.promptDivider}),I("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:i}=this,{canUpdate:a}=i,n=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!a&&0===n;return I(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},I("div",{key:"landing-content",class:D.panelContent},a&&I("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),n>0&&I("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&I("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,i=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return i?I("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},i):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return I("div",{key:"update-actions"},I(A,{level:F(this.headingLevel)},t.editFeatures),I("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return I("div",{key:"create-actions"},I(A,{level:F(t)},s.createFeatures),I("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderCustomTemplateGroup(e){return e.group.items.some((e=>this.viewModel.itemHasInvalidFormTemplate(e)))?I("calcite-notice",{open:!0,icon:O,kind:"brand",scale:"s"},I("div",{slot:"message"},this.messages.formFieldCreateError)):null}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=I("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return I("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return I("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return I("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:i}=s;return o?.template===e.template&&o?.layer===e.layer?i:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:i,messages:a,messagesTemplates:n,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(a.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:i}=s.layer,a=l.find((e=>e.layer===s.layer));if(!a)return null;const{attachmentsOnUpdateEnabled:n,supports:r}=a;return(r.includes("update")||r.includes("delete")||n)&&(!o||t?.toLowerCase().includes(o)||i?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return I(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:i,handleBack:o},I("div",{key:"feature-list",class:D.panelContent},I("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:n.filterPlaceholder,noItems:n.noItems,noMatches:n.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?I("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},I("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&I(L,{tooltipOptions:this.tooltipOptions}),t&&I(M,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:o}=e,i=m(t);return i&&o[i]&&`${o[i]}`||S(this.messages.untitledFeatureTemplate,{id:o[s]})}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:n}=this,r=n?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}},a.promise.finally((()=>{this._clearPrompt(),r&&n?.focus()}))}_onSave(){this.viewModel.saveAndResetWorkflow()}_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}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_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}}}}};e([c()],V.prototype,"_featureForm",void 0),e([c()],V.prototype,"_attachments",void 0),e([c()],V.prototype,"_featureTemplates",void 0),e([c()],V.prototype,"_filterText",void 0),e([c()],V.prototype,"_prompt",void 0),e([c()],V.prototype,"_spinner",void 0),e([c()],V.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],V.prototype,"activeWorkflow",null),e([c()],V.prototype,"allowedWorkflows",null),e([c()],V.prototype,"useDeprecatedCreateWorkflow",null),e([c()],V.prototype,"headingLevel",void 0),e([c()],V.prototype,"iconClass",void 0),e([c()],V.prototype,"label",null),e([c()],V.prototype,"labelOptions",null),e([c()],V.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([c()],V.prototype,"snappingOptions",null),e([c()],V.prototype,"tooltipOptions",null),e([c()],V.prototype,"supportingWidgetDefaults",void 0),e([c()],V.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([c()],V.prototype,"visibleElements",void 0),e([d("visibleElements")],V.prototype,"castVisibleElements",null),e([T()],V.prototype,"_onSave",null),e([T()],V.prototype,"_onDelete",null),e([T()],V.prototype,"_onBack",null),e([T()],V.prototype,"_onAttachmentAdd",null),e([T()],V.prototype,"_onAttachmentUpdate",null),e([T()],V.prototype,"_onAttachmentDelete",null),V=e([p(x)],V);const N=V;export{N as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as i,on as a,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},B={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function $(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...B},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:i,viewModel:a,visibleElements:r}=this,l=a.sketchViewModel,c=a.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:i.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},i.undo),L("calcite-button",{key:"redo-button",label:i.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},i.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"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._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),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.previous(),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},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([i((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),i((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),a((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),i((()=>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"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),i((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),i((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"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"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=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 view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...B,...e,snappingControlsElements:{...B.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(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;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:i,_onBack:a,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.data.edits.modified||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(i)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:i,handleBack:a},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesCommon:a}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:i.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?a.cancel:a.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:i,messages:a,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:a.editAttachment,headingLevel:i,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...i},a)=>L("calcite-button",{key:`action-${a}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...i},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,i=n.secondary;let a;switch(o){case"danger":a="danger";break;case"info":a="brand";break;default:a="neutral"}const r=L("calcite-button",{afterCreate:$,appearance:"solid",key:"prompt-primary-button",kind:a,onclick:n.primary.action,scale:"m",width:i?"half":"full"},n.primary.label),l=i&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:a,onclick:i.action,scale:"m",width:"half"},i.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:i}=n,a=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!i&&0===a;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},i&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),a>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesTemplates:a,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(i.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,i=l.find((e=>e.layer===s.layer));if(!i)return null;const{attachmentsOnUpdateEnabled:a,supports:r}=i;return(r.includes("update")||r.includes("delete")||a)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:a.filterPlaceholder,noItems:a.noItems,noMatches:a.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:o}=e,n=m(t);return n&&o[n]&&`${o[n]}`||S(this.messages.untitledFeatureTemplate,{id:o[s]})}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const i=n(),{view:a}=this,r=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>i.resolve(!0)},secondary:{label:o,action:()=>i.resolve(!1)}}},i.promise.finally((()=>{this._clearPrompt(),r&&a?.focus()}))}_onSave(){this.viewModel.saveAndResetWorkflow()}_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}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_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}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
|