@arcgis/core 4.34.0 → 4.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{9786e854ae9f40975cee.js → 0638a36eaacb56cf89fa.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{151defe707bceb3a56a4.js → 222c2ae818353539cab2.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{4b7c99f9a716a929178d.js → 70c7d3128c9242d10873.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{8ec6ad6d76b4755a4cf6.js → 9e09b5fd04ff1fb18888.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{292403693cba4562a02d.js → bcf2bda17bda0210f898.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{dec0ed841f9ff1ceff43.js → c0d787297d2128fe3c38.js} +1 -1
  8. package/assets/esri/themes/base/widgets/_UtilityNetworkTrace.scss +3 -0
  9. package/assets/esri/themes/dark/main.css +1 -1
  10. package/assets/esri/themes/light/main.css +1 -1
  11. package/assets/esri/themes/light/view.css +1 -1
  12. package/interfaces.d.ts +23 -6
  13. package/kernel.js +1 -1
  14. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  15. package/layers/VideoLayer.js +1 -1
  16. package/layers/support/SubtypeSublayer.js +1 -1
  17. package/package.json +2 -2
  18. package/support/revision.js +1 -1
  19. package/symbols/cim/cimAnalyzer.js +1 -1
  20. package/time/timeZoneUtils.js +1 -1
  21. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  22. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  23. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  24. package/views/3d/support/popupHitTest.js +1 -1
  25. package/views/VideoView.js +1 -1
  26. package/views/draw/support/Reshape.js +1 -1
  27. package/views/popupAdapter.js +1 -1
  28. package/views/support/LayerViewManager.js +1 -1
  29. package/views/ui/UI.js +1 -1
  30. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  31. package/widgets/Editor/MergeFeaturesWorkflowData.js +1 -1
  32. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  33. package/widgets/Editor/SplitFeatureWorkflowData.js +1 -1
  34. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  35. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  36. package/widgets/Editor/UpdateWorkflow.js +1 -1
  37. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  38. package/widgets/Editor/workflowUtils.js +1 -1
  39. package/widgets/Editor.js +1 -1
  40. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  41. package/widgets/FeatureTable/FieldColumn.js +1 -1
  42. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  43. package/widgets/UtilityNetworkTrace.js +1 -1
  44. package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -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.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w,forEachSymbolLayer as z}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as R}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as M}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as I}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as O}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as F}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as U}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as D}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as L}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as H,updateStageObjectGeometry as k,getLocalOriginForPoint as B,extendPointGraphicElevationContext as $,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as se}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as oe}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";const ne=_(0,0,1),le=16,ce=1.5,he=[ee*Y,ee*Y];class ue extends G{static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ge(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=O(this.symbolLayer),i=pe(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=L(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):le);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&R(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new I({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=_e("relative",s),a=new oe(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new oe(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:_e(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;me(t)&&(e.verticalOffset=new re(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(de(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=fe(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ye(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=de(this._getPrimitive())?ce:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(de(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):le)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ae(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ae(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=U(e.color,r),e.outlineColor=U(e.outlineColor,r),this._materials[1]=new ae(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=H(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;let a=!1;if(this._cimData){if(!this._cimData.symbol)return null;z(this._cimData.symbol,e=>{e.colorLocked&&(a=!0)});const r=this._generateTextureCIM(t,e),n={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(n);const l=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/l,r.parameters.height/l]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const n=e.renderingInfo,l=a?x(255,255,255,255):this._getDrivenUInt8Color(n,this._materialColor,null==this._getPrimitive()),c=this._getDrivenRotation(n);let h=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];h=this._getScaleFactor(n,e)}h*=this._symbolTextureRatio;const u=d(s[0]*h,s[1]*h),m=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,l,c,u):this._createAs3DShape(t,r,i,l,c,u,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=H(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=k(s,this._context,o,i);if(null==a)return!1;const n=B(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,$(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(ue.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=pe(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=fe(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:ne,color:i,rotation:s,size:o,centerOffsetAndDistance:be,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,a,n);if(null==m)return null;const d=new V(this,m.object,null,F,a);return d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=E(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),$(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=te;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=ie(r,{normal:ne,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),d=new se(m,{layerViewUid:h,graphicUid:c}),p=new D(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=Z(ve,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function de(e){return null!=e&&("cross"===e||"x"===e)}function pe(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function _e(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function fe({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ye(e){return e.resource?.href?null:e.resource?.primitive??M}function ge(e){return 1===(e.material?.color?.a??0)&&null!=ye(e)}const xe={mode:"relative-to-ground",offset:0},be=x(0,0,0,1),ve=f();export{ue as Graphics3DIconSymbolLayer};
5
+ import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as p,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as z}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as C}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as I}from"../../../../symbols/support/utils.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as F,needsElevationUpdates2D as T}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as E}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as A,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as $}from"./pointUtils.js";import{initFastSymbolUpdatesState as N,updateFastSymbolUpdatesState as q,evaluateModelTransformScale as J,ConvertOptions as Z}from"../support/FastSymbolUpdates.js";import{createTexture as W,requiresHalfTexelOffset as K,defaultBoundingBox as Q,defaultSymbolSizeRatio as X,defaultTexSize as Y}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as ee}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as te}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as re}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as ie}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";const ae=_(0,0,1),ne=16,le=1.5,ce=[Y*X,Y*X];class he extends V{static{this.PRIMITIVE_SIZE=ce}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=I(this.symbolLayer),i=pe(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ne);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?z(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&C(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new M({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=de("relative",s),a=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:de(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;ue(t)&&(e.verticalOffset=new te(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(me(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>W(t));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=Q;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=_e(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return fe(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=me(this._getPrimitive())?le:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(me(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):ne)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new oe(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=N(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new oe(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=E(e.color,r),e.outlineColor=E(e.outlineColor,r),this._materials[1]=new oe(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=A(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._generateTextureCIM(t,e),a={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(a);const n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/n,r.parameters.height/n]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getDrivenUInt8Color(a,this._materialColor,null==this._getPrimitive()),l=this._getDrivenRotation(a);let c=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=p(s[0]*c,s[1]*c),u=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===u.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,n,l,h):this._createAs3DShape(t,r,i,n,l,h,u,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=A(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=H(s,this._context,o,i);if(null==a)return!1;const n=k(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,B(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=F(he.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=T(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!q(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=pe(h))return;const m=this._getIconSize(),p=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,p,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=_e(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ge}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=re(r,{normal:ae,color:i,rotation:s,size:o,centerOffsetAndDistance:xe,featureAttribute:l,olidColor:h}),m=$(this._context,t,u,a,n);if(null==m)return null;const p=new D(this,m.object,null,j,a);return p.alignedSampledElevation=m.sampledElevation,p.needsElevationUpdates=T(a.mode)||"absolute-height"===a.mode,p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),B(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=ee;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=re(r,{normal:ae,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),p=new ie(m,{layerViewUid:h,graphicUid:c}),d=new U(this,[p],null,this._context.drapeSourceRenderer);return d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=d())=>{const[o,a]=J(be,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=d())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new Z({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function ue(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function me(e){return null!=e&&("cross"===e||"x"===e)}function pe(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function de(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function fe(e){return e.resource?.href?null:e.resource?.primitive??R}function ye(e){return 1===(e.material?.color?.a??0)&&null!=fe(e)}const ge={mode:"relative-to-ground",offset:0},xe=x(0,0,0,1),be=f();export{he as Graphics3DIconSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{isIntegratedMeshLayer as e,isTiledLayer as a}from"../../../layers/support/layerUtils.js";import{hitTestSelectSimilarDistance as r}from"../../support/hitTestSelectUtils.js";import{isInEffectiveScaleRange as t}from"../../support/layerViewUtils.js";async function n(n,o){const{results:c,ground:y}=await r(n,o),p=(!y.layer||!e(y.layer))&&y.mapPoint,f=[],u=l(n),d=p?s(n,u):i;let m=0,w=0;const g=()=>{const e=d.layerViews[w++];if(!p||!e||!("fetchPopupFeaturesAtLocation"in e))return;const r=y.mapPoint,s=e.layer;if(a(s)&&"effectiveScaleRange"in s){const a=n.basemapTerrain.getScale(r);if(!t(e.layer.effectiveScaleRange,a))return}f.push({mapPoint:r,layerView:e})};let h=null;for(;m<c.length||w<d.layerViews.length;){const e=c[m];if(e&&"graphic"!==e.type)++m;else if("scene"!==e?.layer?.type||e?.layer?.parent!==n?.map?.basemap)if(e){const a=e.layer?.uid,r=d.layerUids.has(a)&&e.distance===y.distance,t=u.get(e.layer?.uid);if(h??=e.mapPoint,w<d.layerViews.length&&(r||(e.distance??0)>y.distance)&&d.layerViews[w]!==t){g();continue}f.push({graphic:e.graphic,layerView:t}),++m}else g();else++m}return h??=y.mapPoint,{hits:f,location:h}}function s(e,a){const r=new Set,t=new Set;for(let s=e.basemapTerrain.numLayers(1)-1;s>=0;s--){const a=e.basemapTerrain.layerViewByIndex(s,1);r.add(a.layer.uid),t.add(a)}const n=e.overlayManager.renderer.layers;for(const{uid:s}of n){const e=a.get(s);e&&(r.add(s),t.add(e))}return{layerUids:r,layerViews:Array.from(t).reverse()}}const i={layerUids:new Set,layerViews:[]};function l(e){const a=new Map;for(const r of e.allLayerViews){const e=r.layer.uid;a.set(e,r)}return a}export{n as popupHitTest};
5
+ import{isIntegratedMeshLayer as e,isTiledLayer as a,isLayerWithFlowRenderer as r}from"../../../layers/support/layerUtils.js";import{hitTestSelectSimilarDistance as t}from"../../support/hitTestSelectUtils.js";import{isScaleRangeActive as n,scaleBoundsPredicate as i}from"../../support/layerViewUtils.js";async function s(s,y){const{results:p,ground:f}=await t(s,y),u=(!f.layer||!e(f.layer))&&f.mapPoint,d=[],m=c(s),w=u?l(s,m):o;let g=0,h=0;const V=()=>{const e=w.layerViews[h++];if(!u||!e||!("fetchPopupFeaturesAtLocation"in e))return;const t=f.mapPoint,l=e.layer;if(a(l)&&"effectiveScaleRange"in l){const{minScale:e,maxScale:a}=l.effectiveScaleRange;if(n(e,a)){if(r(l)&&!i(s.scale,e,a))return;const n=s.basemapTerrain.getScale(t);if(!i(n,e,a))return}}d.push({mapPoint:t,layerView:e})};let S=null;for(;g<p.length||h<w.layerViews.length;){const e=p[g];if(e&&"graphic"!==e.type)++g;else if("scene"!==e?.layer?.type||e?.layer?.parent!==s?.map?.basemap)if(e){const a=e.layer?.uid,r=w.layerUids.has(a)&&e.distance===f.distance,t=m.get(e.layer?.uid);if(S??=e.mapPoint,h<w.layerViews.length&&(r||(e.distance??0)>f.distance)&&w.layerViews[h]!==t){V();continue}d.push({graphic:e.graphic,layerView:t}),++g}else V();else++g}return S??=f.mapPoint,{hits:d,location:S}}function l(e,a){const r=new Set,t=new Set;for(let i=e.basemapTerrain.numLayers(1)-1;i>=0;i--){const a=e.basemapTerrain.layerViewByIndex(i,1);r.add(a.layer.uid),t.add(a)}const n=e.overlayManager.renderer.layers;for(const{uid:i}of n){const e=a.get(i);e&&(r.add(i),t.add(e))}return{layerUids:r,layerViews:Array.from(t).reverse()}}const o={layerUids:new Set,layerViews:[]};function c(e){const a=new Map;for(const r of e.allLayerViews){const e=r.layer.uid;a.set(e,r)}return a}export{s as popupHitTest};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import{EventedMixin as r}from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import{EsriPromiseMixin as a}from"../core/Promise.js";import{watch as n,initial as l,whenOnce as p,syncAndInitial as m}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import f from"../geometry/Extent.js";import u from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import{load as j,execute as w}from"../geometry/operators/projectOperator.js";import b from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as v}from"../layers/support/MediaElementView.js";import M from"../layers/support/TileInfo.js";import S from"../layers/support/VideoElement.js";import{DOMContainer as _}from"./DOMContainer.js";import{Viewport2DBaseMixin as C}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as V}from"./Viewport2DMixin.js";import x from"./2d/AnimationManager.js";import G from"./2d/MapViewConstraints.js";import"../core/Error.js";import"../core/scheduling.js";import"../core/Logger.js";import"../core/mathUtils.js";import"../config.js";import"../symbols/cim/defaultCIMValues.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"../symbols/Font.js";import"../core/ObjectPool.js";import"../geometry/support/spatialReferenceUtils.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectEnclosingPolygon.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectRadial.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectSuppress.js";import"../symbols/cim/effects/EffectTaperedPolygon.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../symbols/cim/constants.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import{Container as P}from"./2d/engine/Container.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./webgl/enums.js";import"./2d/engine/webgl/shaders/BackgroundPrograms.js";import"./webgl/Program.js";import"./webgl/checkWebGLError.js";import"./webgl/VertexAttributeLayouts.js";import"./webgl/BufferObject.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/cpuMapped/MappedMesh.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/shaders/TileInfoPrograms.js";import"./webgl/Texture.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"../request.js";import"../core/urlUtils.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./webgl/FramebufferObject.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./webgl/Renderbuffer.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/shaderGraph/techniques/animated/attributes.js";import"./2d/engine/webgl/mesh/templates/templateUtils.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../core/sql/UnknownTimeZone.js";import"luxon";import"../intl/locale.js";import"../layers/support/fieldUtils.js";import"../time/constants.js";import"./2d/engine/webgl/animations/instructions.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/renderState.js";import"./3d/webgl-engine/core/shaderModules/glsl.js";import"./webgl/testSVGPremultipliedAlpha.js";import{ManagedCanvas as E}from"./2d/engine/ManagedCanvas.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/meshing/definitions.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"../chunks/earcut.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtils.js";import"./2d/layers/support/util.js";import D from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/unitUtils.js";import"../geometry/ellipsoidUtils.js";import"../geometry/operators/support/GeographicTransformation.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import"../geometry/support/Ellipsoid.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import q from"./2d/engine/webgl/Overlay.js";import z from"./2d/engine/webgl/OverlayContainer.js";import O from"./navigation/Navigation.js";import T from"./ui/DefaultUI.js";import W from"./ui/video/DefaultUIVideo.js";const A=new t("#000");let U;async function k(){const[,{ParentStage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);U=e}const B=.01,F=["feature","geojson","csv","stream","ogc-feature","catalog","wfs","parquet","graphics","group"];let H=class extends(V(C(_(r(a(s)))))){constructor(e){super(e),this._isValid=!1,this._prevZoomEnabled=!1,this._prevRotationEnabled=!1,this.stage=null,this.childStage=null,this._operationalDataView=null,this.operationalDataVisible=!1,this.layer=null,this.map=null,this.navigation=new O,this.ready=!1,this.spatialReference=new y({wkid:0}),this.stateManager=new R({constraints:new G({view:this,minScale:1,maxScale:B})}),this.type="2d",this.ui=new W,this.view2dType="video",this.addHandles([n(()=>this.preconditionsReady,e=>e?this._startup():this._teardown()),n(()=>this.layer,()=>this.addResolvingPromise(p(()=>this.ready)),l),n(()=>this.videoSize,([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}),n(()=>this.size,e=>{this._operationalDataView&&this._operationalDataView.stateManager.resize(e[0],e[1])}),n(()=>[this.layer?.frameEffect,this._effectsContainer],()=>{this._effectsContainer&&(this._effectsContainer.effect=this.layer?.frameEffect??null)},m)])}initialize(){this._prevZoomEnabled="zoom"===this.navigation.actionMap.mouseWheel&&this.ui.components.includes("zoom"),this._prevRotationEnabled="rotate"===this.navigation.actionMap.dragSecondary&&this.ui.components.includes("compass"),this.addHandles([n(()=>[this.operationalDataVisible,this.childStage],()=>{this.childStage&&(this.childStage.videoScreenRenderer.visible=this.operationalDataVisible),this.operationalDataVisible&&(this.scale=1,this.rotation=0),this.navigation&&(this._prevZoomEnabled&&(this.navigation.actionMap.mouseWheel=this.operationalDataVisible?"none":"zoom",this.navigation.actionMap.dragPrimary=this.operationalDataVisible?"none":"pan",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"zoom"!==e):[...new Set([...this.ui.components,"zoom"])])),this._prevRotationEnabled&&(this.navigation.actionMap.dragSecondary=this.operationalDataVisible?"none":"rotate",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"compass"!==e):[...new Set([...this.ui.components,"compass"])])))},m)]),this.addResolvingPromise(k().then(()=>(this._isValid=!0,p(()=>this.ready))))}destroy(){this._teardown(),this.removeAllHandles(),this._set("preconditionsReady",!1),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get preconditionsReady(){return!(!this._isValid||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}async hitTest(e,t){return this._operationalDataView&&this._operationalDataView.ready?this._operationalDataView.hitTest(e,t):{screenPoint:e,results:[]}}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference);const t={renderingOptions:this.renderingOptions,backgroundColor:A,groundControlPoints:()=>this.layer?.groundControlPoints,getSize:()=>this.videoSize},i=new U(this.surface,t,new E(this.surface));this.stage=i,this._prepareStage(this.stage),this.childStage=i.childStage,this._prepareChildStage(this.childStage);const s=new x({view:this});this._set("animationManager",s);const r=new D({view:this,animationManager:s});this._set("mapViewNavigation",r),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.stage.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer.removeAllChildren(),this._overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager.teardown(),this.frameTask.stop(),this.stationaryManager.clear()}_getViewpoint(){return new i({targetGeometry:new u({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([n(()=>this.stationary,t=>e.stationary=t,m),n(()=>this.state.id,()=>e.state=this.state,m),n(()=>this.renderingOptions,t=>e.renderingOptions=t,m)],"video-view"),this._extent=new f({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new v({element:new S({video:this.layer?.videoElement,georeference:new b({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new q(this._videoElementView);this._overlayContainer=new z,this._overlayContainer.addChild(t),this._effectsContainer=new P,this._effectsContainer.addChild(this._overlayContainer),this.stage.addChild(this._effectsContainer);const i=document.createElement("div");i.classList.add("esri-video-poster"),this.container?.classList.add("esri-video-view"),this.container?.appendChild(i)}_prepareChildStage(e){this.addHandles([n(()=>this.map,async t=>{if(!t)return;const{default:i}=await import("./video/VideoOperationalDataView.js");this._operationalDataView=new i({stage:e,layerViewFilter:e=>new Set(F).has(e.type),width:this.size[0],height:this.size[1],map:t}),p(()=>this._operationalDataView?.ready).then(()=>{e.videoScreenRenderer.visible=this.operationalDataVisible})},m),n(()=>this.layer?.groundControlPoints,async()=>{if(!this.layer?.groundControlPoints||!e.state)return;const t=this.layer.groundControlPoints,i=t?.length;if(!i)return;await j();const s=new Array(i),r=e.state.spatialReference;for(let e=0;e<i;e++){const{lat:i,lon:o}=t[e];s[e]=w(new u(o,i),r)}let o=1/0,a=1/0,n=-1/0,l=-1/0;for(const e of s)o=Math.min(o,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),l=Math.max(l,e.y);const p=f.fromJSON({xmin:o,ymin:a,xmax:n,ymax:l,spatialReference:r});await(this._operationalDataView?.goTo(p,{animate:!1}).catch(()=>{}))},m)])}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>B;r/=2)i.push(r);i.push(B);const{lods:s}=M.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}};e([h()],H.prototype,"_overlayContainer",void 0),e([h()],H.prototype,"_isValid",void 0),e([h()],H.prototype,"_effectsContainer",void 0),e([h()],H.prototype,"constraintsInfo",null),e([h()],H.prototype,"operationalDataVisible",void 0),e([h()],H.prototype,"layer",void 0),e([h()],H.prototype,"map",void 0),e([h({type:O,nonNullable:!0})],H.prototype,"navigation",void 0),e([h({readOnly:!0})],H.prototype,"preconditionsReady",null),e([h({readOnly:!0})],H.prototype,"ready",void 0),e([h({readOnly:!0})],H.prototype,"rendering",null),e([h()],H.prototype,"scale",null),e([h()],H.prototype,"spatialReference",void 0),e([h()],H.prototype,"stateManager",void 0),e([h()],H.prototype,"type",void 0),e([h(),d(e=>e instanceof T?e:g(W,e))],H.prototype,"ui",void 0),e([h({readOnly:!0})],H.prototype,"videoSize",null),e([h({readOnly:!0})],H.prototype,"view2dType",void 0),H=e([c("esri.views.VideoView")],H);const L=H;export{L as default};
5
+ import{__decorate as e}from"tslib";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import{EventedMixin as r}from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import{EsriPromiseMixin as a}from"../core/Promise.js";import{watch as n,initial as l,whenOnce as p,syncAndInitial as m}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import f from"../geometry/Extent.js";import u from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import{load as j,execute as w}from"../geometry/operators/projectOperator.js";import b from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as v}from"../layers/support/MediaElementView.js";import _ from"../layers/support/TileInfo.js";import M from"../layers/support/VideoElement.js";import{DOMContainer as S}from"./DOMContainer.js";import{Viewport2DBaseMixin as C}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as V}from"./Viewport2DMixin.js";import x from"./2d/AnimationManager.js";import G from"./2d/MapViewConstraints.js";import"../core/Error.js";import"../core/scheduling.js";import"../core/Logger.js";import"../core/mathUtils.js";import"../config.js";import"../symbols/cim/defaultCIMValues.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"../symbols/Font.js";import"../core/ObjectPool.js";import"../geometry/support/spatialReferenceUtils.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectEnclosingPolygon.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectRadial.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectSuppress.js";import"../symbols/cim/effects/EffectTaperedPolygon.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../symbols/cim/constants.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import{Container as P}from"./2d/engine/Container.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./webgl/enums.js";import"./2d/engine/webgl/shaders/BackgroundPrograms.js";import"./webgl/Program.js";import"./webgl/checkWebGLError.js";import"./webgl/VertexAttributeLayouts.js";import"./webgl/BufferObject.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/cpuMapped/MappedMesh.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/shaders/TileInfoPrograms.js";import"./webgl/Texture.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"../request.js";import"../core/urlUtils.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./webgl/FramebufferObject.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./webgl/Renderbuffer.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/shaderGraph/techniques/animated/attributes.js";import"./2d/engine/webgl/mesh/templates/templateUtils.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../core/sql/UnknownTimeZone.js";import"luxon";import"../intl/locale.js";import"../layers/support/fieldUtils.js";import"../time/constants.js";import"./2d/engine/webgl/animations/instructions.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/renderState.js";import"./3d/webgl-engine/core/shaderModules/glsl.js";import"./webgl/testSVGPremultipliedAlpha.js";import{ManagedCanvas as E}from"./2d/engine/ManagedCanvas.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/meshing/definitions.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"../chunks/earcut.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtils.js";import"./2d/layers/support/util.js";import D from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/unitUtils.js";import"../geometry/ellipsoidUtils.js";import"../geometry/operators/support/GeographicTransformation.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import"../geometry/support/Ellipsoid.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import q from"./2d/engine/webgl/Overlay.js";import z from"./2d/engine/webgl/OverlayContainer.js";import O from"./navigation/Navigation.js";import T from"./ui/DefaultUI.js";import W from"./ui/video/DefaultUIVideo.js";const A=new t("#000");let U;async function k(){const[,{ParentStage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);U=e}const B=.01,F=["feature","geojson","csv","stream","ogc-feature","catalog","wfs","parquet","graphics","group"];let H=class extends(V(C(S(r(a(s)))))){constructor(e){super(e),this._isValid=!1,this._prevZoomEnabled=!1,this._prevRotationEnabled=!1,this.stage=null,this.childStage=null,this._operationalDataView=null,this.operationalDataVisible=!1,this.layer=null,this.map=null,this.navigation=new O,this.ready=!1,this.spatialReference=new y({wkid:0}),this.stateManager=new R({constraints:new G({view:this,minScale:1,maxScale:B})}),this.type="2d",this.ui=new W,this.view2dType="video",this.addHandles([n(()=>this.preconditionsReady,e=>e?this._startup():this._teardown()),n(()=>this.layer,(e,t)=>{t&&(this._teardown(),this._startup()),this.addResolvingPromise(p(()=>this.ready))},l),n(()=>this.videoSize,([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}),n(()=>this.size,e=>{this._operationalDataView&&this._operationalDataView.stateManager.resize(e[0],e[1])}),n(()=>[this.layer?.frameEffect,this._effectsContainer],()=>{this._effectsContainer&&(this._effectsContainer.effect=this.layer?.frameEffect??null)},m)])}initialize(){this._prevZoomEnabled="zoom"===this.navigation.actionMap.mouseWheel&&this.ui.components.includes("zoom"),this._prevRotationEnabled="rotate"===this.navigation.actionMap.dragSecondary&&this.ui.components.includes("compass"),this.addHandles([n(()=>[this.operationalDataVisible,this.childStage],()=>{this.childStage&&(this.childStage.videoScreenRenderer.visible=this.operationalDataVisible),this.operationalDataVisible&&(this.scale=1,this.rotation=0),this.navigation&&(this._prevZoomEnabled&&(this.navigation.actionMap.mouseWheel=this.operationalDataVisible?"none":"zoom",this.navigation.actionMap.dragPrimary=this.operationalDataVisible?"none":"pan",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"zoom"!==e):[...new Set([...this.ui.components,"zoom"])])),this._prevRotationEnabled&&(this.navigation.actionMap.dragSecondary=this.operationalDataVisible?"none":"rotate",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"compass"!==e):[...new Set([...this.ui.components,"compass"])])))},m)]),this.addResolvingPromise(k().then(()=>(this._isValid=!0,p(()=>this.ready))))}destroy(){this._teardown(),this.removeAllHandles(),this._set("preconditionsReady",!1),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get preconditionsReady(){return!(!this._isValid||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}async hitTest(e,t){return this._operationalDataView&&this._operationalDataView.ready?this._operationalDataView.hitTest(e,t):{screenPoint:e,results:[]}}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference);const t={renderingOptions:this.renderingOptions,backgroundColor:A,groundControlPoints:()=>this.layer?.groundControlPoints,getSize:()=>this.videoSize},i=new U(this.surface,t,new E(this.surface));this.stage=i,this._prepareStage(this.stage),this.childStage=i.childStage,this._prepareChildStage(this.childStage);const s=new x({view:this});this._set("animationManager",s);const r=new D({view:this,animationManager:s});this._set("mapViewNavigation",r),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.stage.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer.removeAllChildren(),this._overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager.teardown(),this.frameTask.stop(),this.stationaryManager.clear()}_getViewpoint(){return new i({targetGeometry:new u({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([n(()=>this.stationary,t=>e.stationary=t,m),n(()=>this.state.id,()=>e.state=this.state,m),n(()=>this.renderingOptions,t=>e.renderingOptions=t,m)],"video-view"),this._extent=new f({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new v({element:new M({video:this.layer?.videoElement,georeference:new b({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new q(this._videoElementView);this._overlayContainer=new z,this._overlayContainer.addChild(t),this._effectsContainer=new P,this._effectsContainer.addChild(this._overlayContainer),this.stage.addChild(this._effectsContainer);const i=document.createElement("div");i.classList.add("esri-video-poster"),this.container?.classList.add("esri-video-view"),this.container?.appendChild(i)}_prepareChildStage(e){this.addHandles([n(()=>this.map,async t=>{if(!t)return;const{default:i}=await import("./video/VideoOperationalDataView.js");this._operationalDataView=new i({stage:e,layerViewFilter:e=>new Set(F).has(e.type),width:this.size[0],height:this.size[1],map:t}),p(()=>this._operationalDataView?.ready).then(()=>{e.videoScreenRenderer.visible=this.operationalDataVisible})},m),n(()=>this.layer?.groundControlPoints,async()=>{if(!this.layer?.groundControlPoints||!e.state)return;const t=this.layer.groundControlPoints,i=t?.length;if(!i)return;await j();const s=new Array(i),r=e.state.spatialReference;for(let e=0;e<i;e++){const{lat:i,lon:o}=t[e];s[e]=w(new u(o,i),r)}let o=1/0,a=1/0,n=-1/0,l=-1/0;for(const e of s)o=Math.min(o,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),l=Math.max(l,e.y);const p=f.fromJSON({xmin:o,ymin:a,xmax:n,ymax:l,spatialReference:r});await(this._operationalDataView?.goTo(p,{animate:!1}).catch(()=>{}))},m)])}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>B;r/=2)i.push(r);i.push(B);const{lods:s}=_.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}};e([h()],H.prototype,"_overlayContainer",void 0),e([h()],H.prototype,"_isValid",void 0),e([h()],H.prototype,"_effectsContainer",void 0),e([h()],H.prototype,"constraintsInfo",null),e([h()],H.prototype,"operationalDataVisible",void 0),e([h()],H.prototype,"layer",void 0),e([h()],H.prototype,"map",void 0),e([h({type:O,nonNullable:!0})],H.prototype,"navigation",void 0),e([h({readOnly:!0})],H.prototype,"preconditionsReady",null),e([h({readOnly:!0})],H.prototype,"ready",void 0),e([h({readOnly:!0})],H.prototype,"rendering",null),e([h()],H.prototype,"scale",null),e([h()],H.prototype,"spatialReference",void 0),e([h()],H.prototype,"stateManager",void 0),e([h()],H.prototype,"type",void 0),e([h(),d(e=>e instanceof T?e:g(W,e))],H.prototype,"ui",void 0),e([h({readOnly:!0})],H.prototype,"videoSize",null),e([h({readOnly:!0})],H.prototype,"view2dType",void 0),H=e([c("esri.views.VideoView")],H);const L=H;export{L 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{getOrCreateMapValue as a}from"../../../core/MapUtils.js";import{destroyMaybe as h,assertIsSome as p,abortMaybe as c}from"../../../core/maybe.js";import{pausable as l,when as d,watch as m,initial as v,sync as u}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import f from"../../../geometry/Polyline.js";import{fromGeometry as G,toGeometry as x}from"../../../geometry/operators/support/apiConverter.js";import{closeRingsAndFixWinding as M,geometryToCoordinates as b}from"../../../geometry/support/coordsUtils.js";import{isPoint as C}from"../../../geometry/support/typeUtils.js";import{interpolateCircle as S}from"../../../geometry/support/curves/circleUtils.js";import{deriveCircleFromCircularArc as E,toEllipticArc7 as w}from"../../../geometry/support/curves/circularArcUtils.js";import{getEndpoint as O,isCircularArc as V,isEllipticArc4 as I,isBezierCurve as P,isCoordinate as k,isEllipticArc7 as H}from"../../../geometry/support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as R}from"../../../geometry/support/curves/ellipticArc4Utils.js";import{wrapAtan2 as T}from"../../../geometry/support/curves/mathUtils.js";import A from"../../../layers/GraphicsLayer.js";import{SnappingVisualizer2D as j}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as L}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as U,cloneMove as F}from"./drawUtils.js";import D from"./GraphicMover.js";import z from"./HighlightHelper.js";import{addUniqueLayer as K,isConnectedReshapeSupportedLayer as N}from"./layerUtils.js";import{createTooltipInfos as q,connectTooltip as Z,updateTranslateTooltipInfo as $,updateTranslateVertexTooltipInfo as B}from"./reshapeTooltipUtils.js";import{defaultSymbols as J,createMidpointGraphics as Q,createVertexGraphics as W,createCurveControlPointGraphics as X,createCurveConstructionLineGraphics as Y,attributeKeys as tt,getMidpoint as et,controlPointKinds as it,saveUpdatedCurveOrCoordinate as st,toolIdAttribute as ot,splitCurve as rt,isSingleSegmentCircle as nt,isSingleSegmentEllipse as at}from"./reshapeUtils.js";import{ViewEventPriorities as ht}from"../../input/InputManager.js";import{createCoordinateHelper as pt}from"../../interactive/coordinateHelper.js";import{sketchKeys as ct}from"../../interactive/keybindings.js";import{EditGeometryOperations as lt}from"../../interactive/editGeometry/EditGeometryOperations.js";import dt from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as mt}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as vt,enterInputModeIfAvailable as ut}from"../../interactive/tooltip/tooltipCommonUtils.js";const yt=Symbol();let _t=class extends r{constructor(t){super(t),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=null,this.enableMidpoints=!0,this.enableCurveOnMidpoint=!1,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.snappingManager=null,this.symbols=J,this.sketchOptions=new dt,this.type="reshape",this.vertexGraphics=new s,this.curveControlPointGraphics=new s,this.constructionLineGraphics=new s,this.midpointGraphics=new s,this.selectedManipulators=new s,this.view=null}initialize(){const t=this.view;this._highlightHelper=new z({view:t}),this._setup(),this._updateHandlesOnExternalGeometryChange=l(()=>this.graphic?.geometry,t=>{if(!t)return;const e=new Set(this.selectedManipulators.map(wt));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(t=>e.has(wt(t))).forEach(t=>this._addToSelection(t));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n,curveControlPointGraphics:a}=this,h=n.concat(r,a).items;i&&h.push(o),s?.set("graphics",h)},u),this.tooltip=vt(()=>({view:t,options:this.sketchOptions.tooltips})),this.tooltipInfos=q(this.sketchOptions),this.addHandles([d(()=>t?.ready,()=>{const{layer:t,view:e}=this;K(e,t),this.addHandles(e.on("key-down",t=>this._keyDownHandler(t),ht.TOOL))},{once:!0,initial:!0}),m(()=>this.graphic,()=>this.refresh()),m(()=>this.layer,(t,e)=>{e&&(this._clearSelection(),this._resetGraphics(e)),this.refresh()}),m(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),m(()=>this.enableMidpoints,()=>this.refresh()),Z(this.tooltip,()=>this._tooltipsContext),m(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),v),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=h(this._connectedReshapeManager),this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??pt(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedManipulator(){return 1===this.selectedManipulators.length?this.selectedManipulators.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:t,automaticLengthMeasurementUtils:e,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedManipulator,automaticAreaMeasurementUtils:t,automaticLengthMeasurementUtils:e,updateGeometry:(t,e,i,s,o)=>{this._setUpGeometryHelper();const r=t===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(t);const n=!0;if(this._syncGeometryAfterVertexMove(t,e,s,o,n),r){const{view:t}=this,s=t.toScreen(i),o=t.toScreen(e),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(t),this._emitReshapeStopEvent(t);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const t=this.view.ready,e=!(!this.graphic||!this.layer);return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return t===this.graphic||this._isMidpoint(t)||this._isCurveControlPoint(t)||this._isVertex(t)||this._isConstructionLine(t)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedManipulators:t}=this;t.length&&this._removeVertices(t)}_setup(){const{graphic:t,layer:e}=this;if(!e||null==t?.geometry)return;const i=t.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&M(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const t=this.graphic.geometry;null!=t&&"mesh"!==t.type&&"extent"!==t.type?this._editGeometryOperations??=lt.fromGeometry(t,2,{allowCurves:!0}):this._logGeometryTypeError()}_saveSnappingContextForHandle(t,e){this._snappingGraphicsLayer=new A({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;p(i),this._snappingContext=new mt({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:e.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new j(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(t)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(yt)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=c(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(t){this._removeMidpointGraphics(t),this._removeVertexGraphics(t),this._removeCurveGraphics(t),this._updateTooltip()}_removeMidpointGraphics(t=this.layer){const{midpointGraphics:e}=this;t?.removeMany(e.items),e.drain(h)}_removeVertexGraphics(t=this.layer){const{vertexGraphics:e}=this;t?.removeMany(e.items),e.drain(h)}_removeCurveGraphics(t=this.layer){const{curveControlPointGraphics:e,constructionLineGraphics:i}=this;t?.removeMany(e.items),t?.removeMany(i.items),e.drain(h),i.drain(h)}_setupGraphics(){const t=this.graphic.geometry;if(null!=t&&("polyline"===t.type||"polygon"===t.type||"multipoint"===t.type)){const e=gt(t);this.enableMidpoints&&"multipoint"!==t.type&&this._setUpMidpointGraphics(e),this.enableVertices&&(this._setUpVertexGraphics(e),this._setupCurveGraphics(e))}}_setUpMidpointGraphics(t){this._removeMidpointGraphics();const e=Q(t,this.symbols,this._coordinateHelper,"polygon"===this.graphic.geometry?.type);this.midpointGraphics.addMany(e),this.layer.addMany(e)}_setUpVertexGraphics(t){this._removeVertexGraphics();const e=W(t,this.symbols,this._coordinateHelper);this.vertexGraphics.addMany(e),this._storeRelatedVertexIndices(),this.layer.addMany(e)}_setupCurveGraphics(t){this._removeCurveGraphics();const e=X(t,this.symbols,this._coordinateHelper),i=Y(t,this.symbols,this._coordinateHelper);this.curveControlPointGraphics.addMany(e),this.constructionLineGraphics.addMany(i),this.layer.addMany(i),this.layer.addMany(e)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",t),hover:this.symbols.vertices.hover?.clone().set("color",t)},controlPoints:{...this.symbols.controlPoints,default:this.symbols.controlPoints.default.clone().set("color",t),hover:this.symbols.controlPoints.hover?.clone().set("color",t)},midpoints:{...this.symbols.midpoints},constructionLines:this.symbols.constructionLines.clone().set("color",t)};for(const e of this.vertexGraphics)this._isSelected(e)?e.symbol=this.symbols.vertices.selected:this._hoverGraphic===e?e.symbol=this.symbols.vertices.hover:e.symbol=this.symbols.vertices.default;for(const e of this.curveControlPointGraphics)this._isSelected(e)?e.symbol=this.symbols.controlPoints.selected:this._hoverGraphic===e?e.symbol=this.symbols.controlPoints.hover:e.symbol=this.symbols.controlPoints.default;for(const e of this.constructionLineGraphics)e.symbol=this.symbols.constructionLines}_storeRelatedVertexIndices(){const t=this.vertexGraphics.items;if(!t)return;const e=t.map(({geometry:t})=>({x:t.x,y:t.y}));for(let i=0;i<e.length;i++){const s=[];for(let t=0;t<e.length;t++){if(i===t)continue;const o=e[i],r=e[t];o.x===r.x&&o.y===r.y&&s.push(t)}t[i].attributes[tt.relatedGraphicIndices]=s}}_setupMover(){const{enableMovement:t,graphic:e,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i,this.curveControlPointGraphics).items;t&&"multipoint"!==e.geometry?.type&&r.push(e),this._mover=new D({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:t}=this;null!=t&&0!==t.length&&(this._connectedReshapeManager=new L({providerFactories:t,view:this.view}))}_onGraphicClickCallback(t){t.viewEvent.stopPropagation();const e=t.graphic,i=this._isCurveControlPoint(e);if(e===this.graphic)this.clearSelection(),this.emit("graphic-click",t),this.callbacks.onGraphicClick?.(t);else if(this._isMidpoint(e)){if(2===t.viewEvent.button)return;const i=this.graphic.clone(),s=this._handleMidpointClickOrStartMove(t);this.refresh(),s.length&&this._emitVertexAddEvent([e],i,s)}else if(this._isVertex(e)||i){if(t.viewEvent.stopPropagation(),2===t.viewEvent.button)return void(i||this._removeVertices(e));t.viewEvent.native.shiftKey||this._clearSelection(),this.selectedManipulators.includes(e)?this._removeFromSelection(e,!0):this._addToSelection(e)}}_setUpOperation(t){const{graphic:e,dx:i,dy:s}=t,o=e===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(e,t),this._activeOperationInfo={target:this.graphic,mover:e,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(t){const{dx:e,dy:i,graphic:s}=t,o=this._connectedReshapeManager,r=o?Vt(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(t),this._emitMoveStartEvent(e,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,e,i,t,()=>{this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(e,i)}))}const{selectedManipulators:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),i=this._handleMidpointClickOrStartMove(t);i.length&&(this._emitVertexAddEvent([s],e,i),this._refreshGraphicIndicesAttributes(i[0]))}this._addToSelection(s)}if(this._setUpOperation(t),r){const t=n.filter(t=>this._isVertex(t));o?.startVertexMove(r,It(t))}this._emitReshapeStartEvent(s),this._onHandleMove(s,e,i,t,()=>{this._updateTooltip(s,t.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(t){const e=this._activeOperationInfo;if(!e)return;const{dx:i,dy:s,graphic:o}=t;e.totalDx+=i,e.totalDy+=s;const{operationType:r}=e,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,t,()=>{this._updateTooltip(o,t.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,t,()=>{this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const e=gt(n);this._updateVertexGraphicLocations(e);const{dxMap:o,dyMap:r}=U(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(t){const e=this._activeOperationInfo;if(!e)return;const{dx:i,dy:s,graphic:o}=t,{operationType:r}=e;e.totalDx+=i,e.totalDy+=s,this._onHandleMove(o,i,s,t,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)||o.getAttribute(tt.curveFromStraightEdgeFlag)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(t){const{_coordinateHelper:e}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=e.arrayToPoint(O(t[s][o]))}this._updateMidpointGraphicLocations(t),this._updateCurveGraphicLocations(t)}_updateMidpointGraphicLocations(t){const{_coordinateHelper:e}=this;for(const i of this.midpointGraphics){const{pathIndex:s,pointIndexStart:o,pointIndexEnd:r}=i.attributes,n=t[s];i.geometry=et(n[o],n[r],e)}}_updateCurveGraphicLocations(t){const{spatialReference:e}=this._coordinateHelper,i=new Map;for(const s of this.selectedManipulators){const[t,e]=Et(s);null!=t&&null!=e&&s.getAttribute(tt.controlPointKind)&&a(i,t,()=>new Set)?.add(e)}for(const s of this.curveControlPointGraphics){const[e,o]=Et(s);if(i.get(e)?.has(o))continue;const r=t[e][o];if(V(r)||I(r)){const i=O(t[e][o-1]),n=V(r)?E(i,r):R(i,r),[a,h]=S(n,.25);s.geometry=new g({x:a,y:h,spatialReference:this._coordinateHelper.spatialReference})}else if(P(r)){const t=s.getAttribute(tt.controlPointKind),[e,i]=t===it.bezier.cp1?r.b[1]:r.b[2];s.geometry=new g({x:e,y:i,spatialReference:this._coordinateHelper.spatialReference})}}for(const s of this.constructionLineGraphics){const i=s.getAttribute(tt.controlPointKind),[o,r]=Et(s),n=t[o],a=O(n[r-1]),h=O(n[r]),p=t[o][r];i===it.bezier.line1?s.geometry=new f({paths:[[[a[0],a[1]],[...p.b[1]]]],spatialReference:e}):s.geometry=new f({paths:[[[h[0],h[1]],[...p.b[2]]]],spatialReference:e})}}_refreshGraphicIndicesAttributes(t){const{componentIndex:e,vertexIndex:i}=t,s=t=>{const[s,o]=Et(t);s===e&&o>=i&&t.setAttribute(tt.pointIndex,o+1)};this.vertexGraphics.forEach(s),this.curveControlPointGraphics.forEach(s),this.constructionLineGraphics.forEach(s);for(const o of this.midpointGraphics){if(o.getAttribute(tt.pathIndex)!==e)continue;const t=o.getAttribute(tt.pointIndexStart);t>=i&&(o.setAttribute(tt.pointIndexStart,t+1),o.setAttribute(tt.pointIndexEnd,o.getAttribute(tt.pointIndexEnd)+1))}}_getVertexFromEditGeometry(t){const[e,i]=Et(t);return p(this._editGeometryOperations),this._editGeometryOperations.data.parts[e].vertices[i]}_onHandleMove(t,e,s,o,r){c(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=t.geometry,h="graphic-move-stop"===o.type;if(a&&C(a))if(null!=this.snappingManager&&this.selectedManipulators.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(t,new g(this._stagedVertex),e,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(t,new g(this._stagedVertex),e,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(t,i,e,s,h),r()}}_syncGeometryAfterVertexMove(t,e,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(!r)return;const{_coordinateHelper:n}=this,a=n.pointToVector(e),h=this._getVertexFromEditGeometry(t);if(h){const t=n.getZ(a),e=a[0]-h.pos[0],i=a[1]-h.pos[1],s=null!=t?t-h.pos[2]:0;"point"!==r.type&&"mesh"!==r.type||this._editGeometryOperations?.moveVertices([h],e,i,s),this._connectedReshapeManager?.translate(e,i,s)}if("point"===r.type)t.geometry=e;else if("mesh"===r.type)t.geometry=r.centerAt(e);else{if(t!==this.graphic){const o=n.spatialReference,[a,h]=Et(t);let p=ft(r);const c=n.pointToArray(e);this._updateGeometryFromGraphic(t,p,a,h,c,o,"polygon"===r.type),this._isVertex(t)||this._isCurveControlPoint(t)?(p=this._moveRelatedCoordinates(p,t,c),p=this._moveSelectedHandleCoordinates(p,t,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p),this._updateCurveGraphicLocations(p)):this._isMidpoint(t)&&this._updateCurveGraphicLocations(p),st(r,p)}this._updateGraphicGeometry(r.clone()),this._editGeometryOperations=lt.fromGeometry(r,2,{allowCurves:!0}),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(t),e):t.geometry=e)}}_moveRelatedCoordinates(t,e,i){const{relatedGraphicIndices:s}=e.attributes,o=this._coordinateHelper.spatialReference;if(!s?.length)return t;for(const r of s){const s=this.vertexGraphics.at(r),[n,a]=Et(s);St(t,n,a,i,o),s.geometry=e.geometry}return t}_moveSelectedHandleCoordinates(t,e,i,s,o){const r=this._coordinateHelper.spatialReference;for(const n of this.selectedManipulators)if(n!==e){const[e,a]=Et(n),h=n.getAttribute(tt.relatedGraphicIndices),p=F(n.geometry,i,s,this.view),c=b(p);if(n.geometry=p,this._updateGeometryFromGraphic(n,t,e,a,c,r,o),h?.length)for(const i of h){const e=this.vertexGraphics.at(i),[s,o]=Et(e);St(t,s,o,c,r),e.geometry=p}}return t}_updateGeometryFromGraphic(t,e,i,s,o,r,n){const a=e[i].length-1;this._isCurveControlPoint(t)?xt(e,i,s,[o[0],o[1]],t.getAttribute(tt.controlPointKind)):(St(e,i,s,o,r),n&&(0===s?St(e,i,a,o,r):s===a&&(e[i][0]=o)))}_onGraphicPointerOverCallback(t){const e=t.graphic;this._hoverGraphic=e;const i=this._isVertex(e);i&&!this._isSelected(e)?e.symbol=this.symbols.vertices.hover:this._isCurveControlPoint(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.controlPoints.hover),this._updateTooltip(i?e:null),this._updateHoverCursor(e)}_onGraphicPointerOutCallback(t){const e=t.graphic;this._hoverGraphic=null,this._isVertex(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.vertices.default),this._isCurveControlPoint(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.controlPoints.default),this.removeHandles(yt),this._updateTooltip()}_handleMidpointClickOrStartMove(t){const{graphic:e}=t,i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return[];const s=i.clone(),o=[],{[tt.pathIndex]:r,[tt.pointIndexStart]:n,[tt.pointIndexEnd]:a}=e.attributes,h=b(e.geometry),p=0===a?n+1:a;e.attributes={[tt.tool]:ot,[tt.pathIndex]:r,[tt.pointIndex]:p,[tt.relatedGraphicIndices]:[]};const c=ft(s),l=c[r][a];if(k(l)){if(this.enableCurveOnMidpoint&&t.viewEvent.native.shiftKey){const t=O(c[r][p]);c[r].splice(p,1,{c:[t,[h[0],h[1]]]}),e.setAttribute(tt.controlPointKind,it.circle.interior),e.setAttribute(tt.curveFromStraightEdgeFlag,!0),this.midpointGraphics.remove(e),this.curveControlPointGraphics.push(e),st(s,c)}else c[r].splice(p,0,h),o.push({coordinates:c[r][p],componentIndex:r,vertexIndex:p})}else{const t=O(c[r][n]),e=rt(t,l,.5,this._coordinateHelper);c[r].splice(a,1,...e),o.push({coordinates:O(c[r][p]),componentIndex:r,vertexIndex:p})}return this._updateGraphicGeometry(s),o}_addToSelection(t){const e=Ot(t);for(const i of e)this._isCurveControlPoint(i)?i.symbol=this.symbols.controlPoints.selected:i.symbol=this.symbols.vertices.selected,this.selectedManipulators.add(i),this._updateTooltip(i);this._emitSelectEvent(e)}_removeFromSelection(t,e){if(this._isVertex(t)){const{vertices:i}=this.symbols;t.symbol=e?i.hover:i.default}else if(this._isCurveControlPoint(t)){const{controlPoints:i}=this.symbols;t.symbol=e?i.hover:i.default}this.selectedManipulators.remove(t),this._emitDeselectEvent([t]),this._updateTooltip()}_clearSelection(){const t=this.selectedManipulators.toArray(),{controlPoints:e,vertices:i}=this.symbols;if(t.length>0){for(const s of t)this._isVertex(s)?s.symbol=i.default:this._isCurveControlPoint(s)&&(s.symbol=e.default);this.selectedManipulators.removeAll(),this._emitDeselectEvent(t),this._updateTooltip()}}_keyDownHandler(t){null==this._activeOperationInfo&&ut(t,this.tooltip)||ct.delete.includes(t.key)&&!t.repeat&&this.selectedManipulators.length&&this._removeVertices(this.selectedManipulators)}_removeVertices(t){const e=this.graphic.geometry,i=this.vertexGraphics.length;if(null==e||"polygon"!==e.type&&"polyline"!==e.type&&"multipoint"!==e.type)return;if("polygon"===e.type&&i<4||"multipoint"===e.type&&i<2||"polyline"===e.type&&i<3)return;const s=this.graphic.clone(),o=e.clone();let r=ft(o);const n=[],a=Ot(t);for(const h of a){if(this._isCurveControlPoint(h))continue;const{x:t,y:e}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=O(s[o]);if(t===a&&e===h){n.push({coordinates:O(r[i][o]),componentIndex:i,vertexIndex:o}),r[i].splice(Number(o),1);const t=r[i][o];t&&!k(t)&&(r[i][o]=O(t))}}}}if("polygon"===o.type)r=r.filter(t=>{if(t.length<2)return!1;const[e,i]=O(t[0]),[s,o]=O(t[t.length-1]);return(2!==t.length||e!==s||i!==o)&&(e===s&&i===o||t.push(t[0]),!0)});else if("polyline"===o.type)for(const h of r)1===h.length&&r.splice(r.indexOf(h),1);st(o,r),this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,s,n)}_isVertex(t){return this.vertexGraphics.includes(t)}_isCurveControlPoint(t){return this.curveControlPointGraphics.includes(t)}_isConstructionLine(t){return this.constructionLineGraphics.includes(t)}_isSelected(t){return(this._isVertex(t)||this.curveControlPointGraphics.includes(t))&&this.selectedManipulators.includes(t)}_isMidpoint(t){return this.midpointGraphics.includes(t)}_updateHoverCursor(t){const e=this._isMidpoint(t)?"copy":"move";this.addHandles(this.view.acquireCursor(e,"high"),yt)}_updateTooltip(t,e){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedManipulator?i=r.selectedVertex:t===this.graphic?(i=r.translateGraphic,$(i,o,this._tooltipsContext,e)):t&&this.selectedManipulators.length>1&&(i=r.translateVertices,B(i,o,n,this._tooltipsContext,e)),this.activeTooltipInfo=i}_updateGraphicGeometry(t){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=t,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(t,e){const i={type:"move-start",mover:this.graphic,dx:t,dy:e};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(t,e){const i={type:"move",mover:this.graphic,dx:t,dy:e};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(t,e){if(null==t||null==e){const i=this._activeOperationInfo;if(!i)return;t=i.totalDx,e=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:t,dy:e};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(t){const e={type:"reshape-start",graphic:this.graphic,mover:t,selected:this.selectedManipulators.toArray()};this.emit("reshape-start",e),this.callbacks.onReshapeStart?.(e)}_emitReshapeEvent(t){const e={type:"reshape",graphic:this.graphic,mover:t,selected:this.selectedManipulators.toArray()};this.emit("reshape",e),this.callbacks.onReshape?.(e)}_emitReshapeStopEvent(t){const e={type:"reshape-stop",graphic:this.graphic,mover:t,selected:this.selectedManipulators.toArray()};this.emit("reshape-stop",e),this.callbacks.onReshapeStop?.(e)}_emitSelectEvent(t){const e={type:"vertex-select",added:t};this.emit("select",e),this.callbacks.onVertexSelect?.(e)}_emitDeselectEvent(t){const e={type:"vertex-deselect",removed:t};this.emit("deselect",e),this.callbacks.onVertexDeselect?.(e)}_emitVertexAddEvent(t,e,i){const s={type:"vertex-add",added:t,graphic:this.graphic,oldGraphic:e,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(t,e,i){const s={type:"vertex-remove",removed:t,graphic:this.graphic,oldGraphic:e,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function gt(t){const e=ft(t.clone());if("polygon"===t.type)for(const i of e){const t=i[i.length-1];if(!k(t))continue;const e=i[0];e[0]===t[0]&&e[1]===t[1]&&i.length>2&&i.pop()}return e}function ft(t){return"polygon"===t.type?t.curveRings?.slice()??t.rings.slice():"polyline"===t.type?t.curvePaths?.slice()??t.paths.slice():t.points.map(t=>[t])}function Gt(t,e,i,s){const o=t[e][i];if(V(o))o.c[1]=s;else if(I(o)){const o=O(t[e][i]);t[e][i]={c:[o,s]}}}function xt(t,e,i,s,o){switch(o){case it.circle.interior:Gt(t,e,i,s);break;case it.bezier.cp1:t[e][i].b[1]=s;break;case it.bezier.cp2:t[e][i].b[2]=s}}function Mt(t,e){return t<1e-8*e}function bt(t,{cx:e,cy:i,isInvalid:s,thetaStart:o,thetaEnd:r},n,a){const[h,p]=t,[c,l]=n,d=c-h,m=l-p;e-=h,i-=p;const v=a?o>r:o<r,[u,y]=s?[e,i]:v?[-i,e]:[i,-e],[_,g]=[d,m],[f,G]=[u,y],x=_*G-g*f,M=(d**2+m**2)/2;if(Mt(Math.abs(x),M))return[(h+c)/2,(p+l)/2];const[b,C]=[G/x*M,-f/x*M],S=b**2+C**2,[E,w]=[d/2-b,m/2-C];if(Mt(E**2+w**2,S)){const[t,e]=v?[-C,b]:[C,-b];return[t+b+h,e+C+p]}const O=Math.sqrt((b**2+C**2)/(E**2+w**2))*Math.sign(d*u+m*y);return[E*O+b+h,w*O+C+p]}function Ct(t,e,i){const s=G(new f({curvePaths:[[t,e]],spatialReference:i})),{curvePaths:o}=x(s,i),r=o[0][1];return H(r)?r:w(t,r)}function St(t,e,i,s,o){const r=t[e][i],n=t[e].at(i+1);if(nt(t,e)){const i=t[e][1];return t[e][0]=[...s],void(t[e][1]={a:[[...s],[...i.a[1]],0,0]})}if(at(t,e)){const i=t[e][1],[o,r]=i.a[1],[n,a]=s,h=Math.hypot(n-o,a-r),[p,c]=[n-o,a-r],l=T(c,p);return t[e][0]=[...s],void(t[e][1]={a:[[...s],[...i.a[1]],0,0,l,h,i.a[6]]})}const a=O(r);if(k(r))r.splice(0,r.length,...s);else if(P(r))r.b[0].splice(0,r.b[0].length,...s);else if(V(r)||I(r)){const o=O(t[e][i-1]),n=V(r)?E(o,r):R(o,r);t[e].splice(i,1,{c:[[...s],bt(o,n,s,!0)]})}else if(H(r)){r.a[0].splice(0,r.a[0].length,...s);const n=O(t[e][i-1]);r.a=Ct(n,r,o).a}if(n&&!k(n)&&!P(r))if(V(n)||I(n)){const o=O(n),r=V(n)?E(a,n):R(a,n);t[e].splice(i+1,1,{c:[o,bt(o,r,s,!1)]})}else if(H(n)){const t=O(r);n.a=Ct(t,n,o).a}}function Et({attributes:t}){return[t?.[tt.pathIndex]||0,t?.[tt.pointIndex]||0]}function wt({attributes:t}){return`${t?.[tt.pathIndex]}-${t?.[tt.pointIndex]}`}function Ot(t){return t instanceof e?[t]:[...t]}function Vt(t){const e=t.sourceLayer??t.layer;return N(e)?{graphic:t,layer:e}:null}function It(t){return t.toArray().map(({attributes:t})=>({pathIndex:t[tt.pathIndex],vertexIndex:t[tt.pointIndex]}))}t([y()],_t.prototype,"_activeOperationInfo",void 0),t([y()],_t.prototype,"_connectedReshapeManager",void 0),t([y()],_t.prototype,"_coordinateHelper",null),t([y()],_t.prototype,"_editGeometryOperations",void 0),t([y()],_t.prototype,"tooltip",void 0),t([y()],_t.prototype,"tooltipInfos",void 0),t([y()],_t.prototype,"activeTooltipInfo",void 0),t([y({constructOnly:!0})],_t.prototype,"automaticAreaMeasurementUtils",void 0),t([y({constructOnly:!0})],_t.prototype,"automaticLengthMeasurementUtils",void 0),t([y()],_t.prototype,"_selectedManipulator",null),t([y()],_t.prototype,"_tooltipsContext",null),t([y()],_t.prototype,"callbacks",void 0),t([y()],_t.prototype,"connectedReshapeProviders",void 0),t([y()],_t.prototype,"enableMidpoints",void 0),t([y()],_t.prototype,"enableCurveOnMidpoint",void 0),t([y()],_t.prototype,"enableMovement",void 0),t([y()],_t.prototype,"enableVertices",void 0),t([y()],_t.prototype,"graphic",void 0),t([y()],_t.prototype,"highlightName",void 0),t([y()],_t.prototype,"highlightsEnabled",void 0),t([y()],_t.prototype,"layer",void 0),t([y()],_t.prototype,"snappingManager",void 0),t([y({readOnly:!0})],_t.prototype,"state",null),t([y()],_t.prototype,"symbols",void 0),t([y({type:dt})],_t.prototype,"sketchOptions",void 0),t([y({readOnly:!0})],_t.prototype,"type",void 0),t([y({readOnly:!0})],_t.prototype,"vertexGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"curveControlPointGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"constructionLineGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"midpointGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"selectedManipulators",void 0),t([y()],_t.prototype,"view",void 0),_t=t([_("esri.views.draw.support.Reshape")],_t);const Pt=_t;export{Pt as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{getOrCreateMapValue as a}from"../../../core/MapUtils.js";import{destroyMaybe as h,assertIsSome as p,abortMaybe as c}from"../../../core/maybe.js";import{pausable as l,when as d,watch as m,initial as v,sync as u}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import f from"../../../geometry/Polyline.js";import{fromGeometry as G,toGeometry as x}from"../../../geometry/operators/support/apiConverter.js";import{closeRingsAndFixWinding as M,geometryToCoordinates as b}from"../../../geometry/support/coordsUtils.js";import{isPoint as C}from"../../../geometry/support/typeUtils.js";import{interpolateCircle as S}from"../../../geometry/support/curves/circleUtils.js";import{deriveCircleFromCircularArc as E,toEllipticArc7 as w}from"../../../geometry/support/curves/circularArcUtils.js";import{getEndpoint as O,isCircularArc as V,isEllipticArc4 as I,isBezierCurve as P,isCoordinate as k,isEllipticArc7 as H}from"../../../geometry/support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as R}from"../../../geometry/support/curves/ellipticArc4Utils.js";import{wrapAtan2 as T}from"../../../geometry/support/curves/mathUtils.js";import A from"../../../layers/GraphicsLayer.js";import{SnappingVisualizer2D as j}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as L}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as U,cloneMove as F}from"./drawUtils.js";import D from"./GraphicMover.js";import z from"./HighlightHelper.js";import{addUniqueLayer as K,isConnectedReshapeSupportedLayer as N}from"./layerUtils.js";import{createTooltipInfos as q,connectTooltip as Z,updateTranslateTooltipInfo as $,updateTranslateVertexTooltipInfo as B}from"./reshapeTooltipUtils.js";import{defaultSymbols as J,createMidpointGraphics as Q,createVertexGraphics as W,createCurveControlPointGraphics as X,createCurveConstructionLineGraphics as Y,attributeKeys as tt,getMidpoint as et,controlPointKinds as it,saveUpdatedCurveOrCoordinate as st,toolIdAttribute as ot,splitCurve as rt,isSingleSegmentCircle as nt,isSingleSegmentEllipse as at}from"./reshapeUtils.js";import{ViewEventPriorities as ht}from"../../input/InputManager.js";import{createCoordinateHelper as pt}from"../../interactive/coordinateHelper.js";import{sketchKeys as ct}from"../../interactive/keybindings.js";import{EditGeometryOperations as lt}from"../../interactive/editGeometry/EditGeometryOperations.js";import dt from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as mt}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as vt,enterInputModeIfAvailable as ut}from"../../interactive/tooltip/tooltipCommonUtils.js";const yt=Symbol();let _t=class extends r{constructor(t){super(t),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=null,this.enableMidpoints=!0,this.enableCurveOnMidpoint=!1,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.snappingManager=null,this.symbols=J,this.sketchOptions=new dt,this.type="reshape",this.vertexGraphics=new s,this.curveControlPointGraphics=new s,this.constructionLineGraphics=new s,this.midpointGraphics=new s,this.selectedManipulators=new s,this.view=null}initialize(){const t=this.view;this._highlightHelper=new z({view:t}),this._setup(),this._updateHandlesOnExternalGeometryChange=l(()=>this.graphic?.geometry,t=>{if(!t)return;const e=new Set(this.selectedManipulators.map(wt));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(t=>e.has(wt(t))).forEach(t=>this._addToSelection(t));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n,curveControlPointGraphics:a}=this,h=n.concat(r,a).items;i&&h.push(o),s?.set("graphics",h)},u),this.tooltip=vt(()=>({view:t,options:this.sketchOptions.tooltips})),this.tooltipInfos=q(this.sketchOptions),this.addHandles([d(()=>t?.ready,()=>{const{layer:t,view:e}=this;K(e,t),this.addHandles(e.on("key-down",t=>this._keyDownHandler(t),ht.TOOL))},{once:!0,initial:!0}),m(()=>this.graphic,()=>this.refresh()),m(()=>this.layer,(t,e)=>{e&&(this._clearSelection(),this._resetGraphics(e)),this.refresh()}),m(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),m(()=>this.enableMidpoints,()=>this.refresh()),Z(this.tooltip,()=>this._tooltipsContext),m(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),v),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=h(this._connectedReshapeManager),this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??pt(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedManipulator(){return 1===this.selectedManipulators.length?this.selectedManipulators.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:t,automaticLengthMeasurementUtils:e,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedManipulator,automaticAreaMeasurementUtils:t,automaticLengthMeasurementUtils:e,updateGeometry:(t,e,i,s,o)=>{this._setUpGeometryHelper();const r=t===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(t);const n=!0;if(this._syncGeometryAfterVertexMove(t,e,s,o,n),r){const{view:t}=this,s=t.toScreen(i),o=t.toScreen(e),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(t),this._emitReshapeStopEvent(t);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const t=this.view.ready,e=!(!this.graphic||!this.layer);return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return t===this.graphic||this._isMidpoint(t)||this._isCurveControlPoint(t)||this._isVertex(t)||this._isConstructionLine(t)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedManipulators:t}=this;t.length&&this._removeVertices(t)}_setup(){const{graphic:t,layer:e}=this;if(!e||null==t?.geometry)return;const i=t.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&M(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const t=this.graphic.geometry;null!=t&&"mesh"!==t.type&&"extent"!==t.type?this._editGeometryOperations??=lt.fromGeometry(t,2,{allowCurves:!0}):this._logGeometryTypeError()}_saveSnappingContextForHandle(t,e){this._snappingGraphicsLayer=new A({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;p(i),this._snappingContext=new mt({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:e.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new j(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(t)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(yt)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=c(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(t){this._removeMidpointGraphics(t),this._removeVertexGraphics(t),this._removeCurveGraphics(t),this._updateTooltip()}_removeMidpointGraphics(t=this.layer){const{midpointGraphics:e}=this;t?.removeMany(e.items),e.drain(h)}_removeVertexGraphics(t=this.layer){const{vertexGraphics:e}=this;t?.removeMany(e.items),e.drain(h)}_removeCurveGraphics(t=this.layer){const{curveControlPointGraphics:e,constructionLineGraphics:i}=this;t?.removeMany(e.items),t?.removeMany(i.items),e.drain(h),i.drain(h)}_setupGraphics(){const t=this.graphic.geometry;if(null!=t&&("polyline"===t.type||"polygon"===t.type||"multipoint"===t.type)){const e=gt(t);this.enableMidpoints&&"multipoint"!==t.type&&this._setUpMidpointGraphics(e),this.enableVertices&&(this._setUpVertexGraphics(e),this._setupCurveGraphics(e))}}_setUpMidpointGraphics(t){this._removeMidpointGraphics();const e=Q(t,this.symbols,this._coordinateHelper,"polygon"===this.graphic.geometry?.type);this.midpointGraphics.addMany(e),this.layer.addMany(e)}_setUpVertexGraphics(t){this._removeVertexGraphics();const e=W(t,this.symbols,this._coordinateHelper);this.vertexGraphics.addMany(e),this._storeRelatedVertexIndices(),this.layer.addMany(e)}_setupCurveGraphics(t){this._removeCurveGraphics();const e=X(t,this.symbols,this._coordinateHelper),i=Y(t,this.symbols,this._coordinateHelper);this.curveControlPointGraphics.addMany(e),this.constructionLineGraphics.addMany(i),this.layer.addMany(i),this.layer.addMany(e)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",t),hover:this.symbols.vertices.hover?.clone().set("color",t)},controlPoints:{...this.symbols.controlPoints,default:this.symbols.controlPoints.default.clone().set("color",t),hover:this.symbols.controlPoints.hover?.clone().set("color",t)},midpoints:{...this.symbols.midpoints},constructionLines:this.symbols.constructionLines.clone().set("color",t)};for(const e of this.vertexGraphics)this._isSelected(e)?e.symbol=this.symbols.vertices.selected:this._hoverGraphic===e?e.symbol=this.symbols.vertices.hover:e.symbol=this.symbols.vertices.default;for(const e of this.curveControlPointGraphics)this._isSelected(e)?e.symbol=this.symbols.controlPoints.selected:this._hoverGraphic===e?e.symbol=this.symbols.controlPoints.hover:e.symbol=this.symbols.controlPoints.default;for(const e of this.constructionLineGraphics)e.symbol=this.symbols.constructionLines}_storeRelatedVertexIndices(){const t=this.vertexGraphics.items;if(!t)return;const e=t.map(({geometry:t})=>({x:t.x,y:t.y}));for(let i=0;i<e.length;i++){const s=[];for(let t=0;t<e.length;t++){if(i===t)continue;const o=e[i],r=e[t];o.x===r.x&&o.y===r.y&&s.push(t)}t[i].attributes[tt.relatedGraphicIndices]=s}}_setupMover(){const{enableMovement:t,graphic:e,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i,this.curveControlPointGraphics).items;t&&"multipoint"!==e.geometry?.type&&r.push(e),this._mover=new D({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:t}=this;null!=t&&0!==t.length&&(this._connectedReshapeManager=new L({providerFactories:t,view:this.view}))}_onGraphicClickCallback(t){t.viewEvent.stopPropagation();const e=t.graphic,i=this._isCurveControlPoint(e);if(e===this.graphic)this.clearSelection(),this.emit("graphic-click",t),this.callbacks.onGraphicClick?.(t);else if(this._isMidpoint(e)){if(2===t.viewEvent.button)return;const i=this.graphic.clone(),s=this._handleMidpointClickOrStartMove(t);this.refresh(),s.length&&this._emitVertexAddEvent([e],i,s)}else if(this._isVertex(e)||i){if(t.viewEvent.stopPropagation(),2===t.viewEvent.button)return void(i||this._removeVertices(e));t.viewEvent.native.shiftKey||this._clearSelection(),this.selectedManipulators.includes(e)?this._removeFromSelection(e,!0):this._addToSelection(e)}}_setUpOperation(t){const{graphic:e,dx:i,dy:s}=t,o=e===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(e,t),this._activeOperationInfo={target:this.graphic,mover:e,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(t){const{dx:e,dy:i,graphic:s}=t,o=this._connectedReshapeManager,r=o?Vt(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(t),this._emitMoveStartEvent(e,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,e,i,t,()=>{this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(e,i)}))}const{selectedManipulators:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),i=this._handleMidpointClickOrStartMove(t);i.length&&(this._emitVertexAddEvent([s],e,i),this._refreshGraphicIndicesAttributes(i[0]))}this._addToSelection(s)}if(this._setUpOperation(t),r){const t=n.filter(t=>this._isVertex(t));o?.startVertexMove(r,It(t))}this._emitReshapeStartEvent(s),this._onHandleMove(s,e,i,t,()=>{this._updateTooltip(s,t.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(t){const e=this._activeOperationInfo;if(!e)return;const{dx:i,dy:s,graphic:o}=t;e.totalDx+=i,e.totalDy+=s;const{operationType:r}=e,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,t,()=>{this._updateTooltip(o,t.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,t,()=>{this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const e=gt(n);this._updateVertexGraphicLocations(e);const{dxMap:o,dyMap:r}=U(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(t){const e=this._activeOperationInfo;if(!e)return;const{dx:i,dy:s,graphic:o}=t,{operationType:r}=e;e.totalDx+=i,e.totalDy+=s,this._onHandleMove(o,i,s,t,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)||o.getAttribute(tt.curveFromStraightEdgeFlag)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(t){const{_coordinateHelper:e}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=e.arrayToPoint(O(t[s][o]))}this._updateMidpointGraphicLocations(t),this._updateCurveGraphicLocations(t)}_updateMidpointGraphicLocations(t){const{_coordinateHelper:e}=this;for(const i of this.midpointGraphics){const{pathIndex:s,pointIndexStart:o,pointIndexEnd:r}=i.attributes,n=t[s];i.geometry=et(n[o],n[r],e)}}_updateCurveGraphicLocations(t){const{spatialReference:e}=this._coordinateHelper,i=new Map;for(const s of this.selectedManipulators){const[t,e]=Et(s);null!=t&&null!=e&&s.getAttribute(tt.controlPointKind)&&a(i,t,()=>new Set)?.add(e)}for(const s of this.curveControlPointGraphics){const[e,o]=Et(s);if(i.get(e)?.has(o))continue;const r=t[e][o];if(V(r)||I(r)){const i=O(t[e][o-1]),n=V(r)?E(i,r):R(i,r),[a,h]=S(n,.25);s.geometry=new g({x:a,y:h,spatialReference:this._coordinateHelper.spatialReference})}else if(P(r)){const t=s.getAttribute(tt.controlPointKind),[e,i]=t===it.bezier.cp1?r.b[1]:r.b[2];s.geometry=new g({x:e,y:i,spatialReference:this._coordinateHelper.spatialReference})}}for(const s of this.constructionLineGraphics){const i=s.getAttribute(tt.controlPointKind),[o,r]=Et(s),n=t[o],a=O(n[r-1]),h=O(n[r]),p=t[o][r];i===it.bezier.line1?s.geometry=new f({paths:[[[a[0],a[1]],[...p.b[1]]]],spatialReference:e}):s.geometry=new f({paths:[[[h[0],h[1]],[...p.b[2]]]],spatialReference:e})}}_refreshGraphicIndicesAttributes(t){const{componentIndex:e,vertexIndex:i}=t,s=t=>{const[s,o]=Et(t);s===e&&o>=i&&t.setAttribute(tt.pointIndex,o+1)};this.vertexGraphics.forEach(s),this.curveControlPointGraphics.forEach(s),this.constructionLineGraphics.forEach(s);for(const o of this.midpointGraphics){if(o.getAttribute(tt.pathIndex)!==e)continue;const t=o.getAttribute(tt.pointIndexStart);t>=i&&(o.setAttribute(tt.pointIndexStart,t+1),o.setAttribute(tt.pointIndexEnd,o.getAttribute(tt.pointIndexEnd)+1))}}_getVertexFromEditGeometry(t){const[e,i]=Et(t);return p(this._editGeometryOperations),this._editGeometryOperations.data.parts[e].vertices[i]}_onHandleMove(t,e,s,o,r){c(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=t.geometry,h="graphic-move-stop"===o.type;if(a&&C(a))if(null!=this.snappingManager&&this.selectedManipulators.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(t,new g(this._stagedVertex),e,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(t,new g(this._stagedVertex),e,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(t,i,e,s,h),r()}else r()}_syncGeometryAfterVertexMove(t,e,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(!r)return;const{_coordinateHelper:n}=this,a=n.pointToVector(e),h=this._getVertexFromEditGeometry(t);if(h){const t=n.getZ(a),e=a[0]-h.pos[0],i=a[1]-h.pos[1],s=null!=t?t-h.pos[2]:0;"point"!==r.type&&"mesh"!==r.type||this._editGeometryOperations?.moveVertices([h],e,i,s),this._connectedReshapeManager?.translate(e,i,s)}if("point"===r.type)t.geometry=e;else if("mesh"===r.type)t.geometry=r.centerAt(e);else{if(t!==this.graphic){const o=n.spatialReference,[a,h]=Et(t);let p=ft(r);const c=n.pointToArray(e);this._updateGeometryFromGraphic(t,p,a,h,c,o,"polygon"===r.type),this._isVertex(t)||this._isCurveControlPoint(t)?(p=this._moveRelatedCoordinates(p,t,c),p=this._moveSelectedHandleCoordinates(p,t,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p),this._updateCurveGraphicLocations(p)):this._isMidpoint(t)&&this._updateCurveGraphicLocations(p),st(r,p)}this._updateGraphicGeometry(r.clone()),this._editGeometryOperations=lt.fromGeometry(r,2,{allowCurves:!0}),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(t),e):t.geometry=e)}}_moveRelatedCoordinates(t,e,i){const{relatedGraphicIndices:s}=e.attributes,o=this._coordinateHelper.spatialReference;if(!s?.length)return t;for(const r of s){const s=this.vertexGraphics.at(r),[n,a]=Et(s);St(t,n,a,i,o),s.geometry=e.geometry}return t}_moveSelectedHandleCoordinates(t,e,i,s,o){const r=this._coordinateHelper.spatialReference;for(const n of this.selectedManipulators)if(n!==e){const[e,a]=Et(n),h=n.getAttribute(tt.relatedGraphicIndices),p=F(n.geometry,i,s,this.view),c=b(p);if(n.geometry=p,this._updateGeometryFromGraphic(n,t,e,a,c,r,o),h?.length)for(const i of h){const e=this.vertexGraphics.at(i),[s,o]=Et(e);St(t,s,o,c,r),e.geometry=p}}return t}_updateGeometryFromGraphic(t,e,i,s,o,r,n){const a=e[i].length-1;this._isCurveControlPoint(t)?xt(e,i,s,[o[0],o[1]],t.getAttribute(tt.controlPointKind)):(St(e,i,s,o,r),n&&(0===s?St(e,i,a,o,r):s===a&&(e[i][0]=o)))}_onGraphicPointerOverCallback(t){const e=t.graphic;this._hoverGraphic=e;const i=this._isVertex(e);i&&!this._isSelected(e)?e.symbol=this.symbols.vertices.hover:this._isCurveControlPoint(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.controlPoints.hover),this._updateTooltip(i?e:null),this._updateHoverCursor(e)}_onGraphicPointerOutCallback(t){const e=t.graphic;this._hoverGraphic=null,this._isVertex(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.vertices.default),this._isCurveControlPoint(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.controlPoints.default),this.removeHandles(yt),this._updateTooltip()}_handleMidpointClickOrStartMove(t){const{graphic:e}=t,i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return[];const s=i.clone(),o=[],{[tt.pathIndex]:r,[tt.pointIndexStart]:n,[tt.pointIndexEnd]:a}=e.attributes,h=b(e.geometry),p=0===a?n+1:a;e.attributes={[tt.tool]:ot,[tt.pathIndex]:r,[tt.pointIndex]:p,[tt.relatedGraphicIndices]:[]};const c=ft(s),l=c[r][a];if(k(l)){if(this.enableCurveOnMidpoint&&t.viewEvent.native.shiftKey){const t=O(c[r][p]);c[r].splice(p,1,{c:[t,[h[0],h[1]]]}),e.setAttribute(tt.controlPointKind,it.circle.interior),e.setAttribute(tt.curveFromStraightEdgeFlag,!0),this.midpointGraphics.remove(e),this.curveControlPointGraphics.push(e),st(s,c)}else c[r].splice(p,0,h),o.push({coordinates:c[r][p],componentIndex:r,vertexIndex:p})}else{const t=O(c[r][n]),e=rt(t,l,.5,this._coordinateHelper);c[r].splice(a,1,...e),o.push({coordinates:O(c[r][p]),componentIndex:r,vertexIndex:p})}return this._updateGraphicGeometry(s),o}_addToSelection(t){const e=Ot(t);for(const i of e)this._isCurveControlPoint(i)?i.symbol=this.symbols.controlPoints.selected:i.symbol=this.symbols.vertices.selected,this.selectedManipulators.add(i),this._updateTooltip(i);this._emitSelectEvent(e)}_removeFromSelection(t,e){if(this._isVertex(t)){const{vertices:i}=this.symbols;t.symbol=e?i.hover:i.default}else if(this._isCurveControlPoint(t)){const{controlPoints:i}=this.symbols;t.symbol=e?i.hover:i.default}this.selectedManipulators.remove(t),this._emitDeselectEvent([t]),this._updateTooltip()}_clearSelection(){const t=this.selectedManipulators.toArray(),{controlPoints:e,vertices:i}=this.symbols;if(t.length>0){for(const s of t)this._isVertex(s)?s.symbol=i.default:this._isCurveControlPoint(s)&&(s.symbol=e.default);this.selectedManipulators.removeAll(),this._emitDeselectEvent(t),this._updateTooltip()}}_keyDownHandler(t){null==this._activeOperationInfo&&ut(t,this.tooltip)||ct.delete.includes(t.key)&&!t.repeat&&this.selectedManipulators.length&&this._removeVertices(this.selectedManipulators)}_removeVertices(t){const e=this.graphic.geometry,i=this.vertexGraphics.length;if(null==e||"polygon"!==e.type&&"polyline"!==e.type&&"multipoint"!==e.type)return;if("polygon"===e.type&&i<4||"multipoint"===e.type&&i<2||"polyline"===e.type&&i<3)return;const s=this.graphic.clone(),o=e.clone();let r=ft(o);const n=[],a=Ot(t);for(const h of a){if(this._isCurveControlPoint(h))continue;const{x:t,y:e}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=O(s[o]);if(t===a&&e===h){n.push({coordinates:O(r[i][o]),componentIndex:i,vertexIndex:o}),r[i].splice(Number(o),1);const t=r[i][o];t&&!k(t)&&(r[i][o]=O(t))}}}}if("polygon"===o.type)r=r.filter(t=>{if(t.length<2)return!1;const[e,i]=O(t[0]),[s,o]=O(t[t.length-1]);return(2!==t.length||e!==s||i!==o)&&(e===s&&i===o||t.push(t[0]),!0)});else if("polyline"===o.type)for(const h of r)1===h.length&&r.splice(r.indexOf(h),1);st(o,r),this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,s,n)}_isVertex(t){return this.vertexGraphics.includes(t)}_isCurveControlPoint(t){return this.curveControlPointGraphics.includes(t)}_isConstructionLine(t){return this.constructionLineGraphics.includes(t)}_isSelected(t){return(this._isVertex(t)||this.curveControlPointGraphics.includes(t))&&this.selectedManipulators.includes(t)}_isMidpoint(t){return this.midpointGraphics.includes(t)}_updateHoverCursor(t){const e=this._isMidpoint(t)?"copy":"move";this.addHandles(this.view.acquireCursor(e,"high"),yt)}_updateTooltip(t,e){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedManipulator?i=r.selectedVertex:t===this.graphic?(i=r.translateGraphic,$(i,o,this._tooltipsContext,e)):t&&this.selectedManipulators.length>1&&(i=r.translateVertices,B(i,o,n,this._tooltipsContext,e)),this.activeTooltipInfo=i}_updateGraphicGeometry(t){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=t,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(t,e){const i={type:"move-start",mover:this.graphic,dx:t,dy:e};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(t,e){const i={type:"move",mover:this.graphic,dx:t,dy:e};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(t,e){if(null==t||null==e){const i=this._activeOperationInfo;if(!i)return;t=i.totalDx,e=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:t,dy:e};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(t){const e={type:"reshape-start",graphic:this.graphic,mover:t,selected:this.selectedManipulators.toArray()};this.emit("reshape-start",e),this.callbacks.onReshapeStart?.(e)}_emitReshapeEvent(t){const e={type:"reshape",graphic:this.graphic,mover:t,selected:this.selectedManipulators.toArray()};this.emit("reshape",e),this.callbacks.onReshape?.(e)}_emitReshapeStopEvent(t){const e={type:"reshape-stop",graphic:this.graphic,mover:t,selected:this.selectedManipulators.toArray()};this.emit("reshape-stop",e),this.callbacks.onReshapeStop?.(e)}_emitSelectEvent(t){const e={type:"vertex-select",added:t};this.emit("select",e),this.callbacks.onVertexSelect?.(e)}_emitDeselectEvent(t){const e={type:"vertex-deselect",removed:t};this.emit("deselect",e),this.callbacks.onVertexDeselect?.(e)}_emitVertexAddEvent(t,e,i){const s={type:"vertex-add",added:t,graphic:this.graphic,oldGraphic:e,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(t,e,i){const s={type:"vertex-remove",removed:t,graphic:this.graphic,oldGraphic:e,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function gt(t){const e=ft(t.clone());if("polygon"===t.type)for(const i of e){const t=i[i.length-1];if(!k(t))continue;const e=i[0];e[0]===t[0]&&e[1]===t[1]&&i.length>2&&i.pop()}return e}function ft(t){return"polygon"===t.type?t.curveRings?.slice()??t.rings.slice():"polyline"===t.type?t.curvePaths?.slice()??t.paths.slice():t.points.map(t=>[t])}function Gt(t,e,i,s){const o=t[e][i];if(V(o))o.c[1]=s;else if(I(o)){const o=O(t[e][i]);t[e][i]={c:[o,s]}}}function xt(t,e,i,s,o){switch(o){case it.circle.interior:Gt(t,e,i,s);break;case it.bezier.cp1:t[e][i].b[1]=s;break;case it.bezier.cp2:t[e][i].b[2]=s}}function Mt(t,e){return t<1e-8*e}function bt(t,{cx:e,cy:i,isInvalid:s,thetaStart:o,thetaEnd:r},n,a){const[h,p]=t,[c,l]=n,d=c-h,m=l-p;e-=h,i-=p;const v=a?o>r:o<r,[u,y]=s?[e,i]:v?[-i,e]:[i,-e],[_,g]=[d,m],[f,G]=[u,y],x=_*G-g*f,M=(d**2+m**2)/2;if(Mt(Math.abs(x),M))return[(h+c)/2,(p+l)/2];const[b,C]=[G/x*M,-f/x*M],S=b**2+C**2,[E,w]=[d/2-b,m/2-C];if(Mt(E**2+w**2,S)){const[t,e]=v?[-C,b]:[C,-b];return[t+b+h,e+C+p]}const O=Math.sqrt((b**2+C**2)/(E**2+w**2))*Math.sign(d*u+m*y);return[E*O+b+h,w*O+C+p]}function Ct(t,e,i){const s=G(new f({curvePaths:[[t,e]],spatialReference:i})),{curvePaths:o}=x(s,i),r=o[0][1];return H(r)?r:w(t,r)}function St(t,e,i,s,o){const r=t[e][i],n=t[e].at(i+1);if(nt(t,e)){const i=t[e][1];return t[e][0]=[...s],void(t[e][1]={a:[[...s],[...i.a[1]],0,0]})}if(at(t,e)){const i=t[e][1],[o,r]=i.a[1],[n,a]=s,h=Math.hypot(n-o,a-r),[p,c]=[n-o,a-r],l=T(c,p);return t[e][0]=[...s],void(t[e][1]={a:[[...s],[...i.a[1]],0,0,l,h,i.a[6]]})}const a=O(r);if(k(r))r.splice(0,r.length,...s);else if(P(r))r.b[0].splice(0,r.b[0].length,...s);else if(V(r)||I(r)){const o=O(t[e][i-1]),n=V(r)?E(o,r):R(o,r);t[e].splice(i,1,{c:[[...s],bt(o,n,s,!0)]})}else if(H(r)){r.a[0].splice(0,r.a[0].length,...s);const n=O(t[e][i-1]);r.a=Ct(n,r,o).a}if(n&&!k(n)&&!P(r))if(V(n)||I(n)){const o=O(n),r=V(n)?E(a,n):R(a,n);t[e].splice(i+1,1,{c:[o,bt(o,r,s,!1)]})}else if(H(n)){const t=O(r);n.a=Ct(t,n,o).a}}function Et({attributes:t}){return[t?.[tt.pathIndex]||0,t?.[tt.pointIndex]||0]}function wt({attributes:t}){return`${t?.[tt.pathIndex]}-${t?.[tt.pointIndex]}`}function Ot(t){return t instanceof e?[t]:[...t]}function Vt(t){const e=t.sourceLayer??t.layer;return N(e)?{graphic:t,layer:e}:null}function It(t){return t.toArray().map(({attributes:t})=>({pathIndex:t[tt.pathIndex],vertexIndex:t[tt.pointIndex]}))}t([y()],_t.prototype,"_activeOperationInfo",void 0),t([y()],_t.prototype,"_connectedReshapeManager",void 0),t([y()],_t.prototype,"_coordinateHelper",null),t([y()],_t.prototype,"_editGeometryOperations",void 0),t([y()],_t.prototype,"tooltip",void 0),t([y()],_t.prototype,"tooltipInfos",void 0),t([y()],_t.prototype,"activeTooltipInfo",void 0),t([y({constructOnly:!0})],_t.prototype,"automaticAreaMeasurementUtils",void 0),t([y({constructOnly:!0})],_t.prototype,"automaticLengthMeasurementUtils",void 0),t([y()],_t.prototype,"_selectedManipulator",null),t([y()],_t.prototype,"_tooltipsContext",null),t([y()],_t.prototype,"callbacks",void 0),t([y()],_t.prototype,"connectedReshapeProviders",void 0),t([y()],_t.prototype,"enableMidpoints",void 0),t([y()],_t.prototype,"enableCurveOnMidpoint",void 0),t([y()],_t.prototype,"enableMovement",void 0),t([y()],_t.prototype,"enableVertices",void 0),t([y()],_t.prototype,"graphic",void 0),t([y()],_t.prototype,"highlightName",void 0),t([y()],_t.prototype,"highlightsEnabled",void 0),t([y()],_t.prototype,"layer",void 0),t([y()],_t.prototype,"snappingManager",void 0),t([y({readOnly:!0})],_t.prototype,"state",null),t([y()],_t.prototype,"symbols",void 0),t([y({type:dt})],_t.prototype,"sketchOptions",void 0),t([y({readOnly:!0})],_t.prototype,"type",void 0),t([y({readOnly:!0})],_t.prototype,"vertexGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"curveControlPointGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"constructionLineGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"midpointGraphics",void 0),t([y({readOnly:!0})],_t.prototype,"selectedManipulators",void 0),t([y()],_t.prototype,"view",void 0),_t=t([_("esri.views.draw.support.Reshape")],_t);const Pt=_t;export{Pt 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.34/esri/copyright.txt for details.
4
4
  */
5
- const e="popup",n="manual";function o(e){const{popupElement:n,popup:o}=e||{};return n??o??null}function p(e){return null!=e&&"open"in e&&"declaredClass"in e}function i(e){return!!e&&"arcgis-popup"===e.tagName.toLowerCase()&&"open"in e}function t(o,t,l){const[s,a,u]=t;if(l){const[n,o,t]=l;n&&p(o)&&(o.view=null,n.remove(o,e),o!==a&&a&&o.destroy()),n&&t&&i(t)&&(t.view=null,n.remove(t,e),t!==u&&u&&t.remove())}s&&p(a)&&(a.view=o,s.add(a,{key:e,position:n,internal:!0})),s&&u&&i(u)&&(u.view=o,s.add(u,{key:e,position:n,internal:!0}))}async function l(e,n){const{popup:o,popupElement:t}=e;if(p(o)){const e=await o.viewModel.handleViewClick(n);e?.promises?.length&&o.open(e)}else if(t&&i(t)){const e=await t.handleViewClick(n);e?.promises?.length&&t.open(e)}else n?.defer(async()=>{await e.setupPopup();const{popup:o,popupElement:t}=e;if(p(o)&&!e.destroyed&&e.ready&&e.popupEnabled){const e=await o.viewModel.handleViewClick(n);e?.promises?.length&&o.open(e)}else if(t&&i(t)){const e=await t.handleViewClick(n);e?.promises?.length&&t.open(e)}})}function s(e,n){const{popup:o,popupElement:t}=e;if(p(o))return o.open(n);t&&i(t)&&t.open(n)}function a(e,n){p(e)&&e.close(),n&&i(n)&&(n.visible=!1)}export{t as addPopup,a as closePopup,p as isPopup,i as isPopupElement,s as openPopupWithOptions,l as openPopupWithViewClick,o as popupFromView};
5
+ const n="popup",e="manual";function o(n){const{popupElement:e,popup:o}=n||{};return e??o??null}function i(n){return null!=n&&"open"in n&&"declaredClass"in n}function p(n){return!!n&&"arcgis-popup"===n.tagName.toLowerCase()&&"open"in n}function t(o,t,l){const[u,a,s]=t;if(l){const[e,o,t]=l;e&&i(o)&&(o.view=null,e.remove(o,n),o!==a&&a&&o.destroy()),e&&t&&p(t)&&(t.view=null,e.remove(t,n),t!==s&&s&&t.remove())}u&&i(a)&&(a.view=o,u.add(a,{key:n,position:e,internal:!0})),u&&s&&p(s)&&(s.view=o,u.add(s,{key:n,position:e,internal:!0}))}async function l(n,e){const{popup:o,popupElement:t}=n;i(o)?await s(o,null,e):t&&p(t)?await s(null,t,e):e?.defer(async()=>{await n.setupPopup();const{popup:o,popupElement:t}=n;i(o)&&!n.destroyed&&n.ready&&n.popupEnabled?await s(o,null,e):t&&p(t)&&await s(null,t,e)})}function u(n,e){const{popup:o,popupElement:t}=n;if(i(o))return o.open(e);t&&p(t)&&t.open(e)}function a(n,e){i(n)&&n.close(),e&&p(e)&&(e.visible=!1)}async function s(n,e,o){if(i(n)){const e=await n.viewModel.handleViewClick(o);return void(e?.promises?.length?n.open(e):n.visible&&n.close())}if(e&&p(e)){const n=await e.handleViewClick(o);n?.promises?.length?e.open(n):e.visible&&(e.visible=!1)}}export{t as addPopup,a as closePopup,i as isPopup,p as isPopupElement,u as openPopupWithOptions,l as openPopupWithViewClick,o as popupFromView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import t from"../../core/Error.js";import i from"../../core/Logger.js";import{someMap as o}from"../../core/MapUtils.js";import{createResolver as s,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as y,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{destroyMap as u}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as m}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new f,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=s(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,t=[],i=this.view.ready,o=e=>{if(null!=e)for(const s of e)if(s){if(!1===this.layerViewFilter?.(s))continue;r.add(s);const e=this._layerLayerViewInfoMap.get(s);e&&i?e.start():e||this._recyclingInfoMap.has(s)||t.push(s),"layers"in s&&s.layers&&o(s.layers)}};for(const n of this._rootCollectionNames)o(w(this,n));const s=new Array,a=e=>{const r=e.tryRecycle(t);r?(this._recyclingInfoMap.set(e.layer,e),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating")}).catch(r=>{n(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"))})):s.push(e)};for(const n of this._layerLayerViewInfoMap.values())r.has(n.layer)||(this._layerLayerViewInfoMap.delete(n.layer),a(n));for(const n of this._recyclingInfoMap.values())r.has(n.layer)||(this._recyclingInfoMap.delete(n.layer),a(n));for(const n of t)this._createLayerView(n);this._refreshCollections(),s.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null},this._layersToLayerViews=new Map(e.layerviewMapping)}initialize(){this.addHandles([l(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),y(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule(),h)]),this._preloadLayerViewModules(),this._reschedule()}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),u(this._recyclingInfoMap),u(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||o(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),u(this._layerLayerViewInfoMap))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new t("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const t=this._layerLayerViewInfoMap.get(e);if(!t?.done)return!0;const i=t.layerView;return!(!i||!r||i.parent===r)||!!(t.done&&i&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,i))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,t){if(!e||!r)return void r?.removeAll();let i=0;for(const o of e){const e=this._layerLayerViewInfoMap.get(o);if(!e?.layerView)continue;const{layerView:s}=e;s.layer=o,s.parent=t,r.at(i)!==s&&r.splice(i,0,s),"layers"in o&&g(s)&&this._populateLayerViewsOwners(o.layers,s.layerViews,s),++i}i<r.length&&r.splice(i)}_createLayerView(e){e.load().catch(r=>{i.getLogger("LayerViewManager").error(`Error loading layer "${e.title}"`,r)}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new m(e,this.view,this.layerViewImporter);r.promise?.then(()=>this._refreshCollections(),r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||i.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()}),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",void 0),e([c({constructOnly:!0})],_.prototype,"layerviewMapping",void 0),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V as default};
5
+ import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import t from"../../core/Error.js";import i from"../../core/Logger.js";import{someMap as o}from"../../core/MapUtils.js";import{createResolver as s,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as y,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{destroyMap as u}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as m}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new f,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=s(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,t=[],i=this.view.ready,o=e=>{if(null!=e)for(const s of e)if(s){if(!1===this.layerViewFilter?.(s))continue;r.add(s);const e=this._layerLayerViewInfoMap.get(s);e&&i?e.start():e||this._recyclingInfoMap.has(s)||t.push(s),"layers"in s&&s.layers&&o(s.layers)}};for(const n of this._rootCollectionNames)o(w(this,n));const s=new Array,a=e=>{const r=e.tryRecycle(t);r?(this._recyclingInfoMap.set(e.layer,e),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating")}).catch(r=>{n(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"))})):s.push(e)};for(const n of this._layerLayerViewInfoMap.values())r.has(n.layer)||(this._layerLayerViewInfoMap.delete(n.layer),a(n));for(const n of this._recyclingInfoMap.values())r.has(n.layer)||(this._recyclingInfoMap.delete(n.layer),a(n));for(const n of t)this._createLayerView(n);this._refreshCollections(),s.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null},this._layersToLayerViews=new Map(e.layerviewMapping)}initialize(){this.addHandles([l(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),y(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule(),h)]),this._preloadLayerViewModules(),this._reschedule()}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),u(this._recyclingInfoMap),u(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||o(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),u(this._layerLayerViewInfoMap))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new t("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const t=this._layerLayerViewInfoMap.get(e);if(!t?.done)return!0;const i=t.layerView;return!(!i||!r||i.parent===r)||!!(t.done&&i&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,i))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,t){if(!e||!r)return void r?.removeAll();let i=0;for(const o of e){const e=this._layerLayerViewInfoMap.get(o);if(!e?.layerView)continue;const{layerView:s}=e;s.layer=o,s.parent=t,r.at(i)!==s&&r.splice(i,0,s),"layers"in o&&g(s)&&this._populateLayerViewsOwners(o.layers,s.layerViews,s),++i}i<r.length&&r.splice(i)}_createLayerView(e){e.load().catch(()=>{}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new m(e,this.view,this.layerViewImporter);r.promise?.then(()=>this._refreshCollections(),r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||i.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()}),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",void 0),e([c({constructOnly:!0})],_.prototype,"layerviewMapping",void 0),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V as default};
package/views/ui/UI.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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import"../../intl.js";import o from"../../core/Accessor.js";import{isSome as n}from"../../core/arrayUtils.js";import{EventedAccessor as e}from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{setCalciteModeClass as c}from"../../support/modeUtils.js";import l from"./Component.js";import{isRTL as h}from"../../widgets/support/widgetUtils.js";import{getLocale as m,onLocaleChange as u}from"../../intl/locale.js";const f={left:0,top:0,bottom:0,right:0},_={bottom:30,top:15,right:15,left:15},g="esri-ui",y={ui:g,corner:`${g}-corner`,innerContainer:`${g}-inner-container`,manualContainer:`${g}-manual-container`,cornerContainer:`${g}-corner-container`,topLeft:`${g}-top-left`,topRight:`${g}-top-right`,bottomLeft:`${g}-bottom-left`,bottomRight:`${g}-bottom-right`};function C(t){return t&&!t._started&&"function"==typeof t.postMixInProperties&&"function"==typeof t.buildRendering&&"function"==typeof t.postCreate&&"function"==typeof t.startup}function v(t){return 0===t?"0":`${t}px`}function b(t){const o="object"==typeof t&&null!==t&&Object.getPrototypeOf(t);return(null===o||o===Object.prototype)&&("component"in t||"index"in t||"position"in t)?t:null}function w(t,{top:o,bottom:n,left:e,right:i}){t.style.top=o,t.style.bottom=n,t.style.left=e,t.style.right=i}let P=class extends e{constructor(t){super(t),this._cornerNameToContainerLookup={},this._positionNameToContainerLookup={},this._components=new Array,this._componentMap=new Map,this._removeWidgetHandleKey=Symbol("componentOnRemoveSymbol"),this._locale=m(),this.view=null,this._applyViewPadding=()=>{const t=this.container;t&&w(t,this._toPixelPosition(this._getViewPadding()))},this._applyUIPadding=()=>{const t=this._innerContainer;t&&w(t,this._toPixelPosition(this.padding))},this._initContainers()}initialize(){this.addHandles([r(()=>[this.view?.padding,this.container],this._applyViewPadding,s),r(()=>this.padding,this._applyUIPadding,s),r(()=>[this.container,this._locale],([t,o])=>{t&&t.setAttribute("lang",o)},s),u(t=>{this._locale=t})])}destroy(){this.removeAllHandles(),this.container=null;for(const t of this._components)t.destroy();this._components.length=0,this._componentMap.clear(),this.view=null,this._set("view",null)}set container(t){const o=this._get("container");t!==o&&(t&&(t.classList.add(y.ui),c(t),this._attachContainers(t)),o&&(o.classList.remove(y.ui),w(o,{top:"",bottom:"",left:"",right:""}),o.textContent=""),this._set("container",t))}get height(){const t=this.view?.height??0;if(0===t)return t;const o=this._getViewPadding(),{top:n,bottom:e}=o;return Math.max(t-n-e,0)}get padding(){return this._get("padding")}set padding(t){this._overrideIfSome("padding",t)}castPadding(t){return"number"==typeof t?{bottom:t,top:t,right:t,left:t}:{..._,...t}}get width(){const t=this.view?.width??0;if(0===t)return t;const o=this._getViewPadding(),{left:n,right:e}=o;return Math.max(t-n-e,0)}add(t,o){let n,e,i;if(Array.isArray(t))return void t.forEach(t=>this.add(t,o));const r=b(t);r&&({index:n,position:o,component:t,key:e}=r),o&&"object"==typeof o&&({index:n,key:e,position:o,internal:i}=o),!t||o&&!this._isValidPosition(o)||this._add(t,o,n??this._getNumComponentsAtPosition(o),e,i)}remove(t,o){if(!t)return;if(Array.isArray(t))return t.map(t=>this.remove(t,o));const n=this._find(t);if(n){const t=this._componentMap.get(n);if(!t||t.key!==o)return;const e=this._components.indexOf(n),i=n.node.parentNode;return i?.removeChild(n.node),this._componentMap.delete(n),n.widget?.removeHandlesReference(this._removeWidgetHandleKey),this._components.forEach(o=>{const n=this._componentMap.get(o);n&&n.position===t.position&&n.index>t.index&&n.index--}),this._components.splice(e,1)[0]}}empty(t,o={removeInternal:!1}){if(Array.isArray(t)){for(const n of t)this.empty(n,o);return}const n=this._positionNameToContainerLookup[t??"manual"],e=Array.prototype.slice.call(n.children).map(t=>this._findByNode(t)).filter(t=>{if(null==t)return!1;return!(this._componentMap.get(t)?.internal??!1)||o.removeInternal});for(const i of e)this.remove(i)}move(t,o){if(Array.isArray(t)&&t.forEach(t=>this.move(t,o)),!t)return;let n;const e=b(t)||b(o);if(e&&(n=e.index,o=e.position,t=e.component||t),o&&!this._isValidPosition(o))return;const i=this.remove(t);i&&this.add(i,{position:o,index:n})}find(t){if(!t)return null;const o=this._findById(t);return o&&(o.widget||o.node)}getComponents(t,o={includeInternal:!1}){return t?Array.isArray(t)?t.flatMap(t=>this._getComponentsAtPosition(t,o)):this._getComponentsAtPosition(t,o):this._components.filter(t=>o.includeInternal||!this._componentMap.get(t)?.internal).map(({widget:t,node:o})=>t??o)}getPosition(t){for(const o in this._positionNameToContainerLookup){if(this._positionNameToContainerLookup[o].contains(t))return o}return null}_add(t,n,e,r,s){t instanceof l||(t=new l({node:t}));const{widget:a}=t;null!=a&&a instanceof o&&a.addHandles(i(()=>{queueMicrotask(()=>this.remove(t))}),this._removeWidgetHandleKey);this._components.some(t=>this._componentMap.get(t)?.position===n&&this._componentMap.get(t)?.index===e)&&this._components.forEach(t=>{const o=this._componentMap.get(t);o&&o.position===n&&o.index>=e&&o.index++}),this._place({component:t,position:n,index:e}),this._components.push(t),this._componentMap.set(t,{key:r,position:n,internal:s,index:e})}_find(t){return t?t instanceof l?this._findByComponent(t):"string"==typeof t?this._findById(t):"domNode"in t?this._findByNode(t.domNode):this._findByNode(t):null}_getViewPadding(){return this.view?.padding??f}_attachContainers(t){t.appendChild(this._innerContainer),t.appendChild(this._manualContainer)}_initContainers(){const t=document.createElement("div");t.classList.add(y.innerContainer,y.cornerContainer);const o=document.createElement("div");o.classList.add(y.innerContainer,y.manualContainer);const n=document.createElement("div");n.classList.add(y.topLeft,y.corner),t.appendChild(n);const e=document.createElement("div");e.classList.add(y.topRight,y.corner),t.appendChild(e);const i=document.createElement("div");i.classList.add(y.bottomLeft,y.corner),t.appendChild(i);const r=document.createElement("div");r.classList.add(y.bottomRight,y.corner),t.appendChild(r),this._innerContainer=t,this._manualContainer=o;const s=h();this._cornerNameToContainerLookup={"top-left":n,"top-right":e,"bottom-left":i,"bottom-right":r,"top-leading":s?e:n,"top-trailing":s?n:e,"bottom-leading":s?r:i,"bottom-trailing":s?i:r},this._positionNameToContainerLookup={manual:o,...this._cornerNameToContainerLookup}}_isValidPosition(t){return!!this._positionNameToContainerLookup[t]}_place(t){const o=t.position??"manual",{component:n,index:e}=t,i=this._positionNameToContainerLookup[o],r=null!=e&&e>-1;if(C(n.widget)&&n.widget.startup(),!r)return void i.appendChild(n.node);const s=Array.from(i.children);if(0!==s.length){for(const t of s){const o=this._findByNode(t);if(o&&e<(this._componentMap.get(o)?.index??0))return void t.parentNode?.insertBefore(n.node,t)}i.appendChild(n.node)}else i.appendChild(n.node)}_toPixelPosition(t){return{top:v(t.top),left:v(t.left),right:v(t.right),bottom:v(t.bottom)}}_findByComponent(t){return this._components.find(o=>o===t)??null}_findById(t){return this._components.find(({id:o})=>o===t)??null}_findByNode(t){return t?this._components.find(({node:o})=>o===t):null}_getComponentsAtPosition(t,o){const e=this._positionNameToContainerLookup[t];return Array.prototype.slice.call(e.children).map(t=>this._findByNode(t)).filter(n).filter(t=>o.includeInternal||!this._componentMap.get(t)?.internal).map(({widget:t,node:o})=>t??o)}_getNumComponentsAtPosition(t){const o=this._positionNameToContainerLookup[t];return o?.children.length??0}};t([a()],P.prototype,"_locale",void 0),t([a()],P.prototype,"container",null),t([a()],P.prototype,"height",null),t([a({value:_})],P.prototype,"padding",null),t([p("padding")],P.prototype,"castPadding",null),t([a()],P.prototype,"view",void 0),t([a()],P.prototype,"width",null),P=t([d("esri.views.ui.UI")],P);const x=P;export{x as default};
5
+ import{__decorate as t}from"tslib";import"../../intl.js";import o from"../../core/Accessor.js";import{isSome as n}from"../../core/arrayUtils.js";import{EventedAccessor as e}from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{setCalciteModeClass as c}from"../../support/modeUtils.js";import l from"./Component.js";import{isRTL as h}from"../../widgets/support/widgetUtils.js";import{getLocale as m,onLocaleChange as u}from"../../intl/locale.js";const f={left:0,top:0,bottom:0,right:0},_={bottom:30,top:15,right:15,left:15},g="esri-ui",y={ui:g,corner:`${g}-corner`,innerContainer:`${g}-inner-container`,manualContainer:`${g}-manual-container`,cornerContainer:`${g}-corner-container`,topLeft:`${g}-top-left`,topRight:`${g}-top-right`,bottomLeft:`${g}-bottom-left`,bottomRight:`${g}-bottom-right`};function C(t){return t&&!t._started&&"function"==typeof t.postMixInProperties&&"function"==typeof t.buildRendering&&"function"==typeof t.postCreate&&"function"==typeof t.startup}function v(t){return 0===t?"0":`${t}px`}function b(t){const o="object"==typeof t&&null!==t&&Object.getPrototypeOf(t);return(null===o||o===Object.prototype)&&("component"in t||"index"in t||"position"in t)?t:null}function w(t,{top:o,bottom:n,left:e,right:i}){t.style.top=o,t.style.bottom=n,t.style.left=e,t.style.right=i}let L=class extends e{constructor(t){super(t),this._cornerNameToContainerLookup={},this._positionNameToContainerLookup={},this._components=new Array,this._componentMap=new Map,this._removeWidgetHandleKey=Symbol("componentOnRemoveSymbol"),this._locale=m(),this.view=null,this._applyViewPadding=()=>{const t=this.container;t&&w(t,this._toPixelPosition(this._getViewPadding()))},this._applyUIPadding=()=>{const t=this._innerContainer;t&&w(t,this._toPixelPosition(this.padding))},this._initContainers()}initialize(){this.addHandles([r(()=>[this.view?.padding,this.container],this._applyViewPadding,s),r(()=>this.padding,this._applyUIPadding,s),r(()=>[this.container,this._locale],([t,o])=>{t&&t.setAttribute("lang",o)},s),u(t=>{this._locale=t})])}destroy(){this.removeAllHandles(),this.container=null;for(const t of this._components)t.destroy();this._components.length=0,this._componentMap.clear(),this.view=null,this._set("view",null)}set container(t){const o=this._get("container");t!==o&&(t&&(t.classList.add(y.ui),c(t),this._attachContainers(t)),o&&(o.classList.remove(y.ui),w(o,{top:"",bottom:"",left:"",right:""}),o.textContent=""),this._set("container",t))}get height(){const t=this.view?.height??0;if(0===t)return t;const o=this._getViewPadding(),{top:n,bottom:e}=o;return Math.max(t-n-e,0)}get padding(){return this._get("padding")}set padding(t){this._overrideIfSome("padding",t)}castPadding(t){return"number"==typeof t?{bottom:t,top:t,right:t,left:t}:{..._,...t}}get width(){const t=this.view?.width??0;if(0===t)return t;const o=this._getViewPadding(),{left:n,right:e}=o;return Math.max(t-n-e,0)}add(t,o){let n,e,i;if(Array.isArray(t))return void t.forEach(t=>this.add(t,o));const r=b(t);r&&({index:n,position:o,component:t,key:e}=r),o&&"object"==typeof o&&({index:n,key:e,position:o,internal:i}=o),!t||o&&!this._isValidPosition(o)||this._add(t,o,n??this._getNumComponentsAtPosition(o),e,i)}remove(t,o){if(!t)return;if(Array.isArray(t))return t.map(t=>this.remove(t,o));const n=this._find(t);if(n){const t=this._componentMap.get(n);if(!t||t.key!==o)return;const e=this._components.indexOf(n),i=n.node.parentNode;return i?.removeChild(n.node),this._componentMap.delete(n),n.widget?.removeHandlesReference(this._removeWidgetHandleKey),this._components.forEach(o=>{const n=this._componentMap.get(o);n&&n.position===t.position&&n.index>t.index&&n.index--}),this._components.splice(e,1)[0]}}empty(t,o={removeInternal:!1}){if(Array.isArray(t)){for(const n of t)this.empty(n,o);return}const n=this._positionNameToContainerLookup[t??"manual"],e=Array.prototype.slice.call(n.children).map(t=>this._findByNode(t)).filter(t=>{if(null==t)return!1;return!(this._componentMap.get(t)?.internal??!1)||o.removeInternal});for(const i of e)this.remove(i)}move(t,o){if(Array.isArray(t)&&t.forEach(t=>this.move(t,o)),!t)return;let n;const e=b(t)||b(o);if(e&&(n=e.index,o=e.position,t=e.component||t),o&&!this._isValidPosition(o))return;const i=this.remove(t);i&&this.add(i,{position:o,index:n})}find(t){if(!t)return null;const o=this._findById(t);return o&&(o.widget||o.node)}getComponents(t,o={includeInternal:!1}){return t?Array.isArray(t)?t.flatMap(t=>this._getComponentsAtPosition(t,o)):this._getComponentsAtPosition(t,o):this._components.filter(t=>o.includeInternal||!this._componentMap.get(t)?.internal).map(({widget:t,node:o})=>t??o)}getPosition(t){for(const o in this._positionNameToContainerLookup){if(this._positionNameToContainerLookup[o].contains(t))return o}return null}_add(t,n,e,r,s){t instanceof l||(t=new l({node:t}));const{widget:a}=t;null!=a&&a instanceof o&&a.addHandles(i(()=>{queueMicrotask(()=>this.remove(t))}),this._removeWidgetHandleKey);const p=this._positionNameToContainerLookup[n];this._components.some(t=>{const o=this._componentMap.get(t)?.position,n=o?this._positionNameToContainerLookup[o]:null;return p===n&&this._componentMap.get(t)?.index===e})&&this._components.forEach(t=>{const o=this._componentMap.get(t),n=o?.position,i=n?this._positionNameToContainerLookup[n]:null;o&&i===p&&o.index>=e&&o.index++}),this._place({component:t,position:n,index:e}),this._components.push(t),this._componentMap.set(t,{key:r,position:n,internal:s,index:e})}_find(t){return t?t instanceof l?this._findByComponent(t):"string"==typeof t?this._findById(t):"domNode"in t?this._findByNode(t.domNode):this._findByNode(t):null}_getViewPadding(){return this.view?.padding??f}_attachContainers(t){t.appendChild(this._innerContainer),t.appendChild(this._manualContainer)}_initContainers(){const t=document.createElement("div");t.classList.add(y.innerContainer,y.cornerContainer);const o=document.createElement("div");o.classList.add(y.innerContainer,y.manualContainer);const n=document.createElement("div");n.classList.add(y.topLeft,y.corner),t.appendChild(n);const e=document.createElement("div");e.classList.add(y.topRight,y.corner),t.appendChild(e);const i=document.createElement("div");i.classList.add(y.bottomLeft,y.corner),t.appendChild(i);const r=document.createElement("div");r.classList.add(y.bottomRight,y.corner),t.appendChild(r),this._innerContainer=t,this._manualContainer=o;const s=h();this._cornerNameToContainerLookup={"top-left":n,"top-right":e,"bottom-left":i,"bottom-right":r,"top-leading":s?e:n,"top-trailing":s?n:e,"bottom-leading":s?r:i,"bottom-trailing":s?i:r},this._positionNameToContainerLookup={manual:o,...this._cornerNameToContainerLookup}}_isValidPosition(t){return!!this._positionNameToContainerLookup[t]}_place(t){const o=t.position??"manual",{component:n,index:e}=t,i=this._positionNameToContainerLookup[o],r=null!=e&&e>-1;if(C(n.widget)&&n.widget.startup(),!r)return void i.appendChild(n.node);const s=Array.from(i.children);if(0!==s.length){for(const t of s){const o=this._findByNode(t);if(o&&e<(this._componentMap.get(o)?.index??0))return void t.parentNode?.insertBefore(n.node,t)}i.appendChild(n.node)}else i.appendChild(n.node)}_toPixelPosition(t){return{top:v(t.top),left:v(t.left),right:v(t.right),bottom:v(t.bottom)}}_findByComponent(t){return this._components.find(o=>o===t)??null}_findById(t){return this._components.find(({id:o})=>o===t)??null}_findByNode(t){return t?this._components.find(({node:o})=>o===t):null}_getComponentsAtPosition(t,o){const e=this._positionNameToContainerLookup[t];return Array.prototype.slice.call(e.children).map(t=>this._findByNode(t)).filter(n).filter(t=>o.includeInternal||!this._componentMap.get(t)?.internal).map(({widget:t,node:o})=>t??o)}_getNumComponentsAtPosition(t){const o=this._positionNameToContainerLookup[t];return o?.children.length??0}};t([a()],L.prototype,"_locale",void 0),t([a()],L.prototype,"container",null),t([a()],L.prototype,"height",null),t([a({value:_})],L.prototype,"padding",null),t([p("padding")],L.prototype,"castPadding",null),t([a()],L.prototype,"view",void 0),t([a()],L.prototype,"width",null),L=t([d("esri.views.ui.UI")],L);const N=L;export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as a}from"../../core/handleUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{on as s,whenOnce as n,watch as l,initial as d}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../layers/GraphicsLayer.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import f from"./MergeFeaturesWorkflowData.js";import y from"./Workflow.js";import{updateGraphicSymbolWhenRequired as g,makeMinimalAttributes as F}from"./workflowUtils.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as j}from"./support/errors.js";import{mergeFeatures as V}from"./support/mergeFeaturesUtils.js";import b from"../FeatureForm/FeatureFormViewModel.js";var H;const A=Symbol();let E=H=class extends y{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get hasPendingEdits(){return!1}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get shouldShowAttachments(){return this.data.editorItem.capabilities.attachments.enabled}static async create(e){const{applyEdits:t,applyEditsFeatureService:r,...i}=e,{editorItem:a,features:o}=i;if(v(i.viewModel,"merge-features"),_(a),M(o,2),k(o),i.keyFeature&&!o.includes(i.keyFeature))throw new j;const s=await V(o),n=new H({data:new f({...i,mergedGeometry:s}),onCommit:L(t)});return n._set("steps",S()),n}async enter(){this._configureAttachmentsViewModel()}exit(){}isKeyFeature(e){return this.data.keyFeature===e}isTemporaryHighlightFeature(e){return this.data.temporaryHighlightFeature===e}async setKeyFeature(e){const{data:t}=this;if(e!==t.keyFeature){if(!t.features.includes(e))throw new j;t.keyFeature=e,await this._createAndInitializeEdits(e)}}async start(){return await super.start(),this._makeSketchController()}getFeatureTitle(e){return this.data.getFeatureTitle(e)}async _createAndInitializeEdits(e){const{data:t}=this,r=e.clone();r.geometry=t.mergedGeometry;const i=new w({feature:r});t.edits=i,i.trackChanges(e),await this._setFeatureOnFormViewModel(r),this._setFeatureOnAttachmentsViewModel(e)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,r=e.viewModel.view,i=new b({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(s(()=>i,"value-change",({feature:i,fieldName:a,value:o})=>{const s=e.edits;i&&s&&(s.setAttribute(a,o),g(i,t,r?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,r=new p({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=r,t?.map.add(r)}_makeSketchController(){return{enter:async()=>{this.addHandles(z(this.data),A)},exit:()=>{this.removeHandles(A)}}}async _setFeatureOnFormViewModel(e){const t=this._formViewModel;t.feature=e,await n(()=>!t.updating)}_configureAttachmentsViewModel(){const{data:e}=this,{keyFeature:t,viewModel:r}=e,{attachmentsViewModel:i}=r;i.set({capabilities:{editing:!1},graphic:t,filesEnabled:!1,mode:"view"})}_setFeatureOnAttachmentsViewModel(e){this.data.viewModel.attachmentsViewModel.graphic=e}};e([h()],E.prototype,"formViewModel",null),e([h()],E.prototype,"hasPendingEdits",null),e([h()],E.prototype,"layer",null),e([h()],E.prototype,"parent",null),e([h()],E.prototype,"shouldShowAttachments",null),e([h()],E.prototype,"type",void 0),e([h()],E.prototype,"_formViewModel",void 0),e([h()],E.prototype,"_graphicsLayer",void 0),e([h()],E.prototype,"_highlightHelper",void 0),E=H=e([m("esri.widgets.Editor.MergeFeaturesWorkflow")],E);const I=E;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function L(e){return async r=>{const{edits:i,keyFeature:a}=r,o=i?.feature?.cloneShallow(),s=r.editorItem.layer;if(!i||!o)throw new t("editing:missing-feature","Workflow data has no edits to submit.");i.attributesModified||(o.attributes=F(o,r.editorItem.layer));const n=[];for(const e of r.features){if(e===a)continue;const t=e.cloneShallow();t.attributes=F(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[o],deleteFeatures:n})}}function z(e){const t=e.viewModel.view;if(!t)return r();const o=new c({view:t});for(const r of e.features)o.add(r);const s=new c({view:t,highlightName:u}),n=l(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new c({view:t,highlightName:u}),m=l(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return i([a(o),n,a(s),m,a(h)])}export{I as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as a}from"../../core/handleUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{on as s,whenOnce as n,watch as l,initial as d}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../layers/GraphicsLayer.js";import p from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import f from"./MergeFeaturesWorkflowData.js";import y from"./Workflow.js";import{updateGraphicSymbolWhenRequired as g,makeMinimalAttributes as F}from"./workflowUtils.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as j}from"./support/errors.js";import{mergeFeatures as V}from"./support/mergeFeaturesUtils.js";import b from"../FeatureForm/FeatureFormViewModel.js";var H;const I=Symbol();let A=H=class extends y{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new p({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get hasPendingEdits(){return!1}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get shouldShowAttachments(){return this.data.editorItem.capabilities.attachments.enabled}static async create(e){const{applyEdits:t,applyEditsFeatureService:r,...i}=e,{editorItem:a,features:o}=i;if(v(i.viewModel,"merge-features"),_(a),M(o,2),k(o),i.keyFeature&&!o.includes(i.keyFeature))throw new j;const s=await V(o),n=new H({data:new f({...i,mergedGeometry:s}),onCommit:L(t)});return n._set("steps",S()),n}async enter(){this._configureAttachmentsViewModel()}exit(){}isKeyFeature(e){return this.data.keyFeature===e}isTemporaryHighlightFeature(e){return this.data.temporaryHighlightFeature===e}async setKeyFeature(e){const{data:t}=this;if(e!==t.keyFeature){if(!t.features.includes(e))throw new j;t.keyFeature=e,await this._createAndInitializeEdits(e)}}async start(){return await super.start(),this._makeSketchController()}getFeatureTitle(e){return this.data.getFeatureTitle(e)}async _createAndInitializeEdits(e){const{data:t}=this,r=e.clone();r.geometry=t.mergedGeometry;const i=new w({feature:r});t.edits=i;const a=t.getInitialFeature(e)||e;i.trackChanges(a),await this._setFeatureOnFormViewModel(r,a),this._setFeatureOnAttachmentsViewModel(e)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,r=e.viewModel.view,i=new b({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(s(()=>i,"value-change",({feature:i,fieldName:a,value:o})=>{const s=e.edits;i&&s&&(s.setAttribute(a,o),g(i,t,r?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,r=new c({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=r,t?.map.add(r)}_makeSketchController(){return{enter:async()=>{this.addHandles(z(this.data),I)},exit:()=>{this.removeHandles(I)}}}async _setFeatureOnFormViewModel(e,t){const r=this._formViewModel;r.feature=e,r.overrideInitialFeature(t),await n(()=>!r.updating)}_configureAttachmentsViewModel(){const{data:e}=this,{keyFeature:t,viewModel:r}=e,{attachmentsViewModel:i}=r;i.set({capabilities:{editing:!1},graphic:t,filesEnabled:!1,mode:"view"})}_setFeatureOnAttachmentsViewModel(e){this.data.viewModel.attachmentsViewModel.graphic=e}};e([h()],A.prototype,"formViewModel",null),e([h()],A.prototype,"hasPendingEdits",null),e([h()],A.prototype,"layer",null),e([h()],A.prototype,"parent",null),e([h()],A.prototype,"shouldShowAttachments",null),e([h()],A.prototype,"type",void 0),e([h()],A.prototype,"_formViewModel",void 0),e([h()],A.prototype,"_graphicsLayer",void 0),e([h()],A.prototype,"_highlightHelper",void 0),A=H=e([m("esri.widgets.Editor.MergeFeaturesWorkflow")],A);const E=A;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function L(e){return async r=>{const{edits:i,keyFeature:a}=r,o=i?.feature?.cloneShallow(),s=r.editorItem.layer;if(!i||!o)throw new t("editing:missing-feature","Workflow data has no edits to submit.");i.attributesModified||(o.attributes=F(o,r.editorItem.layer));const n=[];for(const e of r.features){if(e===a)continue;const t=e.cloneShallow();t.attributes=F(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[o],deleteFeatures:n})}}function z(e){const t=e.viewModel.view;if(!t)return r();const o=new p({view:t});for(const r of e.features)o.add(r);const s=new p({view:t,highlightName:u}),n=l(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new p({view:t,highlightName:u}),m=l(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return i([a(o),n,a(s),m,a(h)])}export{E 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import r from"../../core/ReactiveMap.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";let s=class extends t{constructor(e){super(e),this._featureTitleMap=null,this.editorItem=null,this.features=[],this.keyFeature=null,this.edits=null,this.mergedGeometry=null,this.parent=null,this.temporaryHighlightFeature=null,this.viewModel=null}async initialize(){const{features:e,timeZone:t}=this,{layer:o}=this.editorItem;if(this.keyFeature??=e[0],!("getFeatureTitle"in o))return;const i=await Promise.all(e.map(async e=>[e,await o.getFeatureTitle(e,{fetchMissingFields:!1,timeZone:t})]));this._featureTitleMap=new r(i)}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(e){null==e?this._clearOverride("timeZone"):this._override("timeZone",e)}getFeatureTitle(e){return this._featureTitleMap?.get(e)}};e([o()],s.prototype,"_featureTitleMap",void 0),e([o({constructOnly:!0})],s.prototype,"editorItem",void 0),e([o({constructOnly:!0})],s.prototype,"features",void 0),e([o()],s.prototype,"keyFeature",void 0),e([o()],s.prototype,"edits",void 0),e([o()],s.prototype,"mergedGeometry",void 0),e([o()],s.prototype,"parent",void 0),e([o()],s.prototype,"temporaryHighlightFeature",void 0),e([o()],s.prototype,"timeZone",null),e([o()],s.prototype,"viewModel",void 0),s=e([i("esri.widgets.Editor.MergeFeaturesWorkflowData")],s);const a=s;export{a as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import i from"../../core/ReactiveMap.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";let s=class extends t{constructor(e){super(e),this._featureTitleMap=null,this.editorItem=null,this.features=[],this.initialFeatures=[],this.keyFeature=null,this.edits=null,this.mergedGeometry=null,this.parent=null,this.temporaryHighlightFeature=null,this.viewModel=null}async initialize(){const{features:e,timeZone:t}=this,{layer:r}=this.editorItem;if(this.keyFeature??=e[0],0===this.initialFeatures.length&&(this.initialFeatures=e.slice()),!("getFeatureTitle"in r))return;const o=await Promise.all(e.map(async e=>[e,await r.getFeatureTitle(e,{fetchMissingFields:!1,timeZone:t})]));this._featureTitleMap=new i(o)}get _initialFeatureMap(){const e=new Map(this.initialFeatures.map(e=>[e.getObjectId(),e])),t=new Map(this.features.map(e=>[e.getObjectId(),e])),i=new Map;for(const[r,o]of t){const t=e.get(r);r&&t&&i.set(o,t)}return i}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(e){null==e?this._clearOverride("timeZone"):this._override("timeZone",e)}getFeatureTitle(e){return this._featureTitleMap?.get(e)}getInitialFeature(e){return this._initialFeatureMap.get(e)}};e([r()],s.prototype,"_featureTitleMap",void 0),e([r()],s.prototype,"_initialFeatureMap",null),e([r({constructOnly:!0})],s.prototype,"editorItem",void 0),e([r({constructOnly:!0})],s.prototype,"features",void 0),e([r()],s.prototype,"initialFeatures",void 0),e([r()],s.prototype,"keyFeature",void 0),e([r()],s.prototype,"edits",void 0),e([r()],s.prototype,"mergedGeometry",void 0),e([r()],s.prototype,"parent",void 0),e([r()],s.prototype,"temporaryHighlightFeature",void 0),e([r()],s.prototype,"timeZone",null),e([r()],s.prototype,"viewModel",void 0),s=e([o("esri.widgets.Editor.MergeFeaturesWorkflowData")],s);const a=s;export{a as default};