@arcgis/core 4.30.0-next.20240313 → 4.30.0-next.20240314

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 (52) hide show
  1. package/arcade/functions/knowledgegraph.js +1 -1
  2. package/arcade/functions/maths.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/14b9001a3233075dd1b7.js +1 -0
  5. package/assets/esri/core/workers/chunks/2d0a01d0957b3e4512f6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{cccf63c65070c6a47b16.js → 5dc63f28bc608c56d3e6.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{a1a557cbfb0aa915f81b.js → 95d7b168991ddb3a96ca.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{67ab6af927ea04c01a40.js → a658dd87b1b59e9cf2a3.js} +1 -1
  9. package/chunks/terrainUtilsPlanar.js +1 -1
  10. package/chunks/terrainUtilsSpherical.js +1 -1
  11. package/core/arrayUtils.js +1 -1
  12. package/interfaces.d.ts +4 -4
  13. package/package.json +1 -1
  14. package/rest/geoprocessor/utils.js +1 -1
  15. package/support/revision.js +1 -1
  16. package/undoredo/support/ApplySet.js +5 -0
  17. package/undoredo/support/ApplySetItem.js +5 -0
  18. package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
  19. package/views/2d/layers/features/FeatureContainer.js +1 -1
  20. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  21. package/views/3d/layers/TiledLayerView3D.js +1 -1
  22. package/views/3d/terrain/ExtentHelper.js +1 -1
  23. package/views/3d/terrain/TilingScheme.js +1 -1
  24. package/views/3d/terrain/terrainUtils.js +1 -1
  25. package/views/draw/DrawAction.js +1 -1
  26. package/views/draw/support/Box.js +1 -1
  27. package/views/draw/support/GraphicMover.js +1 -1
  28. package/views/draw/support/Reshape.js +1 -1
  29. package/views/input/ViewEvents.js +1 -1
  30. package/views/input/gamepad/GamepadSource.js +1 -1
  31. package/views/input/recognizers/DoubleTapDrag.js +1 -1
  32. package/views/input/recognizers/PointerClickHoldAndDrag.js +1 -1
  33. package/views/input/recognizers/SingleAndDoubleClick.js +1 -1
  34. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  35. package/views/interactive/snapping/FeatureSnappingSourceInfo.js +1 -1
  36. package/views/interactive/snapping/LineSnapper.js +1 -1
  37. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  38. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  39. package/views/interactive/snapping/SnappingManager.js +1 -1
  40. package/views/interactive/snapping/SnappingVisualizer.js +1 -1
  41. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  42. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  43. package/views/interactive/snapping/featureSources/featureServiceSource/PendingFeatureTile.js +1 -1
  44. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  45. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  46. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  47. package/views/webgl/ContextState.js +1 -1
  48. package/views/webgl/RenderingContext.js +1 -1
  49. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  50. package/widgets/OrientedImageryViewer/utils.js +1 -1
  51. package/assets/esri/core/workers/chunks/a1978ae86e466020dd28.js +0 -1
  52. package/assets/esri/core/workers/chunks/bf041907bac8fae05c2b.js +0 -1
package/interfaces.d.ts CHANGED
@@ -99920,7 +99920,7 @@ declare namespace __esri {
99920
99920
  *
99921
99921
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Features-FeaturesViewModel.html#open)
99922
99922
  */
99923
- location?: Geometry;
99923
+ location?: Point;
99924
99924
  /**
99925
99925
  * Sets the [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Features-FeaturesViewModel.html#features), which populates the title and content based on each graphic's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html).
99926
99926
  *
@@ -100002,7 +100002,7 @@ declare namespace __esri {
100002
100002
  *
100003
100003
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Features.html#open)
100004
100004
  */
100005
- location?: Geometry;
100005
+ location?: Point;
100006
100006
  /**
100007
100007
  * Sets pending [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Features.html#promises) on the widget.
100008
100008
  *
@@ -106270,7 +106270,7 @@ declare namespace __esri {
106270
106270
 
106271
106271
  export class Popup {
106272
106272
  /**
106273
- * Defines actions that may be executed by clicking the icon or image symbolizing them in the popup.
106273
+ * [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionButton.html) or [action toggle](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionToggle.html) objects.
106274
106274
  *
106275
106275
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions)
106276
106276
  */
@@ -106520,7 +106520,7 @@ declare namespace __esri {
106520
106520
 
106521
106521
  interface PopupProperties extends WidgetProperties, GoToProperties {
106522
106522
  /**
106523
- * Defines actions that may be executed by clicking the icon or image symbolizing them in the popup.
106523
+ * [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionButton.html) or [action toggle](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-actions-ActionToggle.html) objects.
106524
106524
  *
106525
106525
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions)
106526
106526
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.30.0-next.20240313",
3
+ "version": "4.30.0-next.20240314",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import r from"../../geometry/SpatialReference.js";import{normalizeCentralMeridian as t}from"../../geometry/support/normalizeUtils.js";import a from"../../layers/support/Field.js";import n from"../../layers/support/MapImage.js";import{parseUrl as o,encode as s}from"../utils.js";import i from"../support/DataFile.js";import u from"../support/FeatureSet.js";import m from"../support/LinearUnit.js";import c from"../support/ParameterValue.js";import{dataTypeJsonMap as f,multiValuePrefix as l}from"../support/parameterValueUtils.js";import p from"../support/RasterData.js";async function y(r,a,n,s,i){const u={},m={},c=[];return S(s,c,u),t(c).then((t=>{const{outSpatialReference:c,processExtent:f,processSpatialReference:l,returnColumnName:p,returnFeatureCollection:y,returnM:S,returnZ:d}=n,{path:N}=o(r);for(const e in u){const[r,a]=u[e];m[e]=t.slice(r,a)}const j=c?c.wkid||c:null,g=l?l.wkid||l:null,O="execute"===a?{returnColumnName:p||void 0,returnFeatureCollection:y||void 0,returnM:S||void 0,returnZ:d||void 0}:null,R=J({...f?{context:{extent:f,outSR:j,processSR:g}}:{"env:outSR":j,"env:processSR":g},...s,...O,f:"json"},null,m),v={...i,query:R};return e(`${N}/${a}`,v)}))}function S(e,r,t){for(const a in e){const n=e[a];if(n&&"object"==typeof n&&n instanceof u){const{features:e}=n;t[a]=[r.length,r.length+e.length],e.forEach((e=>{r.push(e.geometry)}))}}}async function d(e,t){switch(e){case"boolean":case"double":case"long":case"string":case"value-table":return t;case"date":return new Date(t);case"data-file":return i.fromJSON(t);case"linear-unit":return m.fromJSON(t);case"feature-record-set-layer":if("url"in t)return i.fromJSON(t);if("layerDefinition"in t){const e=new(0,(await import("../../layers/FeatureLayer.js")).default),{layerDefinition:a,featureSet:n}=t;return e.read({layerDefinition:a,featureSet:n},{origin:"portal-item"}),e.spatialReference=r.fromJSON(n.spatialReference??a.spatialReference??a.extent.spatialReference),e}return u.fromJSON(t);case"record-set":return"url"in t?i.fromJSON(t):u.fromJSON(t);case"raster-data":case"raster-data-layer":return"mapImage"in t?n.fromJSON(t.mapImage):p.fromJSON(t);case"field":return a.fromJSON(t)}}function N(e){return e.startsWith(l)}function j(e){return e.replace(l,"")}async function g(e){const r=f.fromJSON(e.dataType),{paramName:t}=e,a=N(r)?await Promise.all(e.value.map((e=>d(j(r),e)))):await d(r,e.value);return new c({dataType:r,paramName:t,value:a})}function J(e,r,t){for(const a in e){const r=e[a];Array.isArray(r)?e[a]=JSON.stringify(r.map((e=>J({item:e},!0).item))):r instanceof Date&&(e[a]=r.getTime())}return s(e,r,t)}export{S as collectGeometries,y as constructRequest,g as decode,J as gpEncode};
5
+ import e from"../../request.js";import r from"../../geometry/SpatialReference.js";import{normalizeCentralMeridian as t}from"../../geometry/support/normalizeUtils.js";import a from"../../layers/support/Field.js";import n from"../../layers/support/MapImage.js";import{parseUrl as o,encode as s}from"../utils.js";import i from"../support/DataFile.js";import u from"../support/FeatureSet.js";import m from"../support/LinearUnit.js";import c from"../support/ParameterValue.js";import{dataTypeJsonMap as l,multiValuePrefix as f}from"../support/parameterValueUtils.js";import p from"../support/RasterData.js";async function y(r,a,n,s,i){const u={},m={},c=[];return S(s,c,u),t(c).then((t=>{const{outSpatialReference:c,processExtent:l,processSpatialReference:f,returnColumnName:p,returnFeatureCollection:y,returnM:S,returnZ:d}=n,{path:j}=o(r);for(const e in u){const[r,a]=u[e];m[e]=t.slice(r,a)}const N=c?c.wkid||c:null,g=f?f.wkid||f:null,J="execute"===a?{returnColumnName:p||void 0,returnFeatureCollection:y||void 0,returnM:S||void 0,returnZ:d||void 0}:null,O=R({...l?{context:{extent:l,outSR:N,processSR:g}}:{"env:outSR":N,"env:processSR":g},...s,...J,f:"json"},null,m),v={...i,query:O};return e(`${j}/${a}`,v)}))}function S(e,r,t){for(const a in e){const n=e[a];if(n&&"object"==typeof n&&n instanceof u){const{features:e}=n;t[a]=[r.length,r.length+e.length],e.forEach((e=>{r.push(e.geometry)}))}}}async function d(e,t){switch(e){case"boolean":case"double":case"long":case"string":case"value-table":return t;case"date":return new Date(t);case"data-file":return i.fromJSON(t);case"linear-unit":return m.fromJSON(t);case"feature-record-set-layer":if("url"in t)return i.fromJSON(t);if("layerDefinition"in t){const e=new(0,(await import("../../layers/FeatureLayer.js")).default),{layerDefinition:a,featureSet:n}=t;return e.read({layerDefinition:a,featureSet:n},{origin:"portal-item"}),e.spatialReference=r.fromJSON(n.spatialReference??a.spatialReference??a.extent.spatialReference),e}return u.fromJSON(t);case"record-set":return"url"in t?i.fromJSON(t):u.fromJSON(t);case"raster-data":case"raster-data-layer":return"mapImage"in t?n.fromJSON(t.mapImage):p.fromJSON(t);case"field":return a.fromJSON(t)}}function j(e){return e.startsWith(f)}function N(e){return e.replace(f,"")}async function g(e){const r=l.fromJSON(e.dataType),{paramName:t}=e,a=j(r)?await Promise.all(e.value.map((e=>d(N(r),e)))):await d(r,e.value);return new c({dataType:r,paramName:t,value:a})}function R(e,r,t){for(const a in e){const r=e[a];Array.isArray(r)?e[a]=r.map((e=>R({item:e},!0).item)):r instanceof Date&&(e[a]=r.getTime())}return s(e,r,t)}export{S as collectGeometries,y as constructRequest,g as decode,R as gpEncode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- const f="20240313",b="bbf0bcc995d9b20e877f330138ffaf06e6ef9bc7";export{f as buildDate,b as commitHash};
5
+ const f="20240314",a="2b017c05f36ff0a580f29f0d80c1970a8aba24b0";export{f as buildDate,a as commitHash};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
+ */
5
+ import{isDeleteItem as t,isAddAttachmentItem as e,isDeleteAttachmentItem as a,isAddItem as r,isModifyItem as s}from"./ApplySetItem.js";class p{constructor(){this.applyItems=new Map,this.featureState=null}get items(){return[...this.applyItems.values()]}get deleteItems(){return this.items.filter(t)}_add(t){this.applyItems.set(t.featureChangeId,t)}revert(){this.featureState?.clearAll(),this.applyItems.clear()}push(p){if(e(p)||a(p))return void this._add(p);const i=this.applyItems.get(p.featureChangeId);i?(r(i)&&t(p)&&(this.applyItems.delete(i.featureChangeId),this.featureState?.removeLocalState(i)),r(i)&&s(p)&&(i.graphic=p.graphic,this.featureState?.updateLocalState(i)),s(i)&&t(p)&&(this.applyItems.delete(i.featureChangeId),p.graphic=i.revertGraphic,this._add(p),this.featureState?.removeLocalState(i),this.featureState?.applyLocalState(p)),s(i)&&s(p)&&(i.graphic=p.graphic,this.featureState?.updateLocalState(i))):(this._add(p),this.featureState?.applyLocalState(p))}}export{p as ApplySet};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
+ */
5
+ let t=-1383920;function e(t,e=""){""!==e&&t.reasonsIncluded.add(e)}function a(t){return"delete"===t.type}function r(t){return"modify"===t.type}function s(t){return"add"===t.type}function n(t){return"addAttachment"===t.type}function c(t){return"deleteAttachment"===t.type}class i{constructor(t){this.reasonsIncluded=new Set,this.graphic=t.graphic.clone(),this.layer=t.layer,e(this,t.reason)}get featureChangeId(){return`${this.layer.id}:${this.graphic.attributes[this.layer.objectIdField].toString()}`}}class h extends i{constructor(t){super(t),this.type="delete"}}class d extends i{constructor(e){super(e),this.type="add";const a=t--;e.graphic.attributes[e.layer.objectIdField]=a,this.graphic.attributes[e.layer.objectIdField]=a}}class o extends i{constructor(t){super(t),this.type="modify",this.revertGraphic=t.originalGraphic.clone()}}class u extends i{constructor(t){super(t),this.type="addAttachment",this.attachmentData=null,this.attachmentData=t.attachmentData}}class l extends i{constructor(t){super(t),this.type="deleteAttachment",this.attachment=t.attachment}get featureChangeId(){return`${this.layer.id}:attach:${this.attachment.id.toString()}`}}export{u as ApplySetAddAttachmentItem,d as ApplySetAddItem,l as ApplySetDeleteAttachmentItem,h as ApplySetDeleteItem,i as ApplySetItemBase,o as ApplySetModifyItem,n as isAddAttachmentItem,s as isAddItem,c as isDeleteAttachmentItem,a as isDeleteItem,r as isModifyItem};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import{findLast as e}from"../../../../../core/arrayUtils.js";import r from"../../../../../core/Logger.js";import{numericHash as o}from"../../../../../core/string.js";import{ShaderBuilder2D as n}from"./ShaderBuilder2D.js";import{Float as s,Int as i,Vec4 as p,Vec2 as a}from"./graph/glsl.js";import{GlslShaderWriter as c}from"./graph/GlslGraphWriter.js";import{ShaderGraphContext as u}from"./graph/ShaderGraphContext.js";import{setReachableUids as y}from"./graph/ShaderGraphNode.js";import{TypedShaderProgram as d}from"./typed/TypedShaderProgram.js";function h(t){return new t}function f(t,e,r){const o=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:o.slice()}),t.constructor[e].push(r)}function l(t,e){return(r,o)=>{f(r,"locations",{typeCtor:e,propertyKey:o,parameterIndex:null,index:t})}}const m=t=>(e,r)=>{f(e,"builtins",{builtin:t,propertyKey:r})},g=t=>(e,r,o)=>{f(e,"inputs",{inputCtor:t,propertyKey:r,parameterIndex:o})},_=t=>(e,r)=>{f(e,"uniforms",{typeCtor:t,propertyKey:r})},K=t=>(e,r)=>{f(e,"options",{typeCtor:t,propertyKey:r})},x=(t,e)=>{f(t,"defines",{propertyKey:e})};function C(t){return(e,r)=>{f(e,"transformFeedbackBindings",{propertyKey:r,parameterIndex:null,index:t})}}const I=(t,e)=>(r,o)=>{r.constructor.builtins.push({builtin:t,propertyKey:o,typeCtor:e})};class b{}b.builtins=[],t([I("gl_VertexID",i)],b.prototype,"glVertexID",void 0);class v{}class w{}w.builtins=[],t([I("gl_FragCoord",p)],w.prototype,"glFragCoord",void 0),t([I("gl_PointCoord",a)],w.prototype,"glPointCoord",void 0);class F{}t([m("gl_FragColor")],F.prototype,"glFragColor",void 0);class P{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class j{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=e(this._shaderModuleClass.inputs,(t=>"vertex"===t.propertyKey&&0===t.parameterIndex));if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return e(this._shaderModuleClass.inputs,(t=>"vertex"===t.propertyKey&&1===t.parameterIndex))}get fragmentInput(){const t=e(this._shaderModuleClass.inputs,(t=>"fragment"===t.propertyKey));if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,e=new Set;for(const o of this.locations)e.has(o.index)?r.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${o.propertyKey} to ${o.index}. Index already in use`,{locationsMap:t}):(t.set(o.propertyKey,o.index),e.add(o.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map((([t,e])=>`${t}.${e}`)).join("."),r=o(e);this._locationInfo={hash:r,locations:t}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,r,o){try{const{vertex:n,fragment:s,uniformBindings:i}=this._generateShaders(t,e,r,o);return new d(n,s,this.renamedLocationsMap,this.locationInfo,i,this.transformFeedbackBindings)}catch(n){return console.error("Failed to create program",{error:n}),new d("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find((e=>e.propertyKey===t));if(e)return{type:"option",className:e.typeCtor};const r=this._uniforms.find((e=>e.propertyKey===t));if(!r)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:r.typeCtor}}getShaderKey(t,e,r,o){const n=Object.keys(r).map((t=>`${t}.${r[t]}`)).join("."),s=Object.keys(o).map((t=>`${t}.${o[t]}`)).join("."),i=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${t.hash}.${n}.${s}.${i}`}_generateShaders(t,e,r,o){const n=[];this._setDefines(r),this._setOptionalUniforms(n,e),this._setRequiredUniforms(n);const s=this._hydrateVertexInput(o),i=this._injectPackPrecisionFactor(s,t),p=this._hydrateComputeInput(),a=p&&this._injectPackPrecisionFactor(p,t),d=this.vertex(i,a),h=this._hydrateFragmentInput(d),f=this.fragment(h),l=new Set;for(const c in f){const t=f[c];y(l,t)}const m=this._getVertexInputBuiltins(),g=u.createVertex({...s,...p},d,m,n,this.transformFeedbackBindings,l);(new c).write(g);const _=this._getFragmentInputBuiltins(f);_.set("glPointCoord","gl_PointCoord");const K=u.createFragment(h,f,_,n,g,this.transformFeedbackBindings);(new c).write(K);const x=this._createShaderBuilder(g,K),C=x.generate("vertex",!1),I=x.generate("fragment",!1);return this.logShader&&(console.log(C),console.log(I)),{vertex:C,fragment:I,uniformBindings:n}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const r of this._options){e[r.propertyKey]?this[r.propertyKey]=this._hydrateUniformGroup(t,r):this[r.propertyKey]=null}}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const r=new(0,e.typeCtor);for(const o of r._uniforms??[]){const n=h(o.typeCtor),s=`u_${e.propertyKey}_${o.propertyKey}`,i=n.type,p=[e.propertyKey,o.propertyKey].join(".");if("type"in o.typeCtor&&"array"===o.typeCtor.type){const e=n;t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:n})}else t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformHydrated:n});r[o.propertyKey]=n}return r}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,r=e.locations.reduce(((e,r)=>!1===t[r.propertyKey]?e:{...e,[r.propertyKey]:h(r.typeCtor)}),{});for(const{propertyKey:o,typeCtor:n}of e.builtins){const t=h(n);r[o]=t}return r}_hydrateComputeInput(){if(null==this.computeInput)return null;return this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:h(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const r={};for(const o in t){const n=t[o],i=e.attributes.find((t=>t.name===o));if(i?.packPrecisionFactor){if("float"!==n.type&&"vec2"!==n.type&&"vec3"!==n.type&&"vec4"!==n.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${n.type}`);r[o]=n.divide(new s(i.packPrecisionFactor))}else r[o]=n}return r}_hydrateFragmentInput(t){const e={};for(const r in t)e[r]=t[r];for(const{propertyKey:r,typeCtor:o}of w.builtins){const t=h(o);e[r]=t}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:r,propertyKey:o}of t.builtins)e.set(o,r);return e}_getFragmentInputBuiltins(t){const e=t.constructor,r=new Map;for(const o of e.builtins??[])r.set(o.propertyKey,o.builtin);return r}_createShaderBuilder(t,e){const r=new n;return this._insertDebugInfo(r),t.insertVertexShader(r),e.insertFragmentShader(r),r}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}export{v as ComputeVertexInput,w as FragmentInput,F as FragmentOutput,j as GraphShaderModule,P as UniformGroup,b as VertexInput,m as builtin,x as define,g as input,l as location,K as option,C as transformFeedback,_ as uniform};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Logger.js";import{numericHash as r}from"../../../../../core/string.js";import{ShaderBuilder2D as o}from"./ShaderBuilder2D.js";import{Float as n,Int as s,Vec4 as i,Vec2 as p}from"./graph/glsl.js";import{GlslShaderWriter as a}from"./graph/GlslGraphWriter.js";import{ShaderGraphContext as c}from"./graph/ShaderGraphContext.js";import{setReachableUids as u}from"./graph/ShaderGraphNode.js";import{TypedShaderProgram as d}from"./typed/TypedShaderProgram.js";function y(t){return new t}function h(t,e,r){const o=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:o.slice()}),t.constructor[e].push(r)}function f(t,e){return(r,o)=>{h(r,"locations",{typeCtor:e,propertyKey:o,parameterIndex:null,index:t})}}const l=t=>(e,r)=>{h(e,"builtins",{builtin:t,propertyKey:r})},m=t=>(e,r,o)=>{h(e,"inputs",{inputCtor:t,propertyKey:r,parameterIndex:o})},g=t=>(e,r)=>{h(e,"uniforms",{typeCtor:t,propertyKey:r})},_=t=>(e,r)=>{h(e,"options",{typeCtor:t,propertyKey:r})},K=(t,e)=>{h(t,"defines",{propertyKey:e})};function x(t){return(e,r)=>{h(e,"transformFeedbackBindings",{propertyKey:r,parameterIndex:null,index:t})}}const C=(t,e)=>(r,o)=>{r.constructor.builtins.push({builtin:t,propertyKey:o,typeCtor:e})};class I{}I.builtins=[],t([C("gl_VertexID",s)],I.prototype,"glVertexID",void 0);class b{}class v{}v.builtins=[],t([C("gl_FragCoord",i)],v.prototype,"glFragCoord",void 0),t([C("gl_PointCoord",p)],v.prototype,"glPointCoord",void 0);class w{}t([l("gl_FragColor")],w.prototype,"glFragColor",void 0);class F{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class P{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=this._shaderModuleClass.inputs.findLast((t=>"vertex"===t.propertyKey&&0===t.parameterIndex));if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return this._shaderModuleClass.inputs.findLast((t=>"vertex"===t.propertyKey&&1===t.parameterIndex))}get fragmentInput(){const t=this._shaderModuleClass.inputs.findLast((t=>"fragment"===t.propertyKey));if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,r=new Set;for(const o of this.locations)r.has(o.index)?e.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${o.propertyKey} to ${o.index}. Index already in use`,{locationsMap:t}):(t.set(o.propertyKey,o.index),r.add(o.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map((([t,e])=>`${t}.${e}`)).join("."),o=r(e);this._locationInfo={hash:o,locations:t}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,r,o){try{const{vertex:n,fragment:s,uniformBindings:i}=this._generateShaders(t,e,r,o);return new d(n,s,this.renamedLocationsMap,this.locationInfo,i,this.transformFeedbackBindings)}catch(n){return console.error("Failed to create program",{error:n}),new d("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find((e=>e.propertyKey===t));if(e)return{type:"option",className:e.typeCtor};const r=this._uniforms.find((e=>e.propertyKey===t));if(!r)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:r.typeCtor}}getShaderKey(t,e,r,o){const n=Object.keys(r).map((t=>`${t}.${r[t]}`)).join("."),s=Object.keys(o).map((t=>`${t}.${o[t]}`)).join("."),i=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${t.hash}.${n}.${s}.${i}`}_generateShaders(t,e,r,o){const n=[];this._setDefines(r),this._setOptionalUniforms(n,e),this._setRequiredUniforms(n);const s=this._hydrateVertexInput(o),i=this._injectPackPrecisionFactor(s,t),p=this._hydrateComputeInput(),d=p&&this._injectPackPrecisionFactor(p,t),y=this.vertex(i,d),h=this._hydrateFragmentInput(y),f=this.fragment(h),l=new Set;for(const a in f){const t=f[a];u(l,t)}const m=this._getVertexInputBuiltins(),g=c.createVertex({...s,...p},y,m,n,this.transformFeedbackBindings,l);(new a).write(g);const _=this._getFragmentInputBuiltins(f);_.set("glPointCoord","gl_PointCoord");const K=c.createFragment(h,f,_,n,g,this.transformFeedbackBindings);(new a).write(K);const x=this._createShaderBuilder(g,K),C=x.generate("vertex",!1),I=x.generate("fragment",!1);return this.logShader&&(console.log(C),console.log(I)),{vertex:C,fragment:I,uniformBindings:n}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const r of this._options){e[r.propertyKey]?this[r.propertyKey]=this._hydrateUniformGroup(t,r):this[r.propertyKey]=null}}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const r=new(0,e.typeCtor);for(const o of r._uniforms??[]){const n=y(o.typeCtor),s=`u_${e.propertyKey}_${o.propertyKey}`,i=n.type,p=[e.propertyKey,o.propertyKey].join(".");if("type"in o.typeCtor&&"array"===o.typeCtor.type){const e=n;t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:n})}else t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformHydrated:n});r[o.propertyKey]=n}return r}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,r=e.locations.reduce(((e,r)=>!1===t[r.propertyKey]?e:{...e,[r.propertyKey]:y(r.typeCtor)}),{});for(const{propertyKey:o,typeCtor:n}of e.builtins){const t=y(n);r[o]=t}return r}_hydrateComputeInput(){if(null==this.computeInput)return null;return this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:y(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const r={};for(const o in t){const s=t[o],i=e.attributes.find((t=>t.name===o));if(i?.packPrecisionFactor){if("float"!==s.type&&"vec2"!==s.type&&"vec3"!==s.type&&"vec4"!==s.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${s.type}`);r[o]=s.divide(new n(i.packPrecisionFactor))}else r[o]=s}return r}_hydrateFragmentInput(t){const e={};for(const r in t)e[r]=t[r];for(const{propertyKey:r,typeCtor:o}of v.builtins){const t=y(o);e[r]=t}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:r,propertyKey:o}of t.builtins)e.set(o,r);return e}_getFragmentInputBuiltins(t){const e=t.constructor,r=new Map;for(const o of e.builtins??[])r.set(o.propertyKey,o.builtin);return r}_createShaderBuilder(t,e){const r=new o;return this._insertDebugInfo(r),t.insertVertexShader(r),e.insertFragmentShader(r),r}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}export{b as ComputeVertexInput,v as FragmentInput,w as FragmentOutput,P as GraphShaderModule,F as UniformGroup,I as VertexInput,l as builtin,K as define,m as input,f as location,_ as option,x as transformFeedback,g as uniform};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import"../../../../core/Logger.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as r,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/InstanceStore.js";import{RenderState as h}from"./RenderState.js";import{renderHighlight as d}from"../support/util.js";class l{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class u extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._layerView=e}renderChildren(e){if(this.attributeView.update(),this._renderState){const e=Array.from(this._renderState.tiles()).filter((e=>e.needsUpload));if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this.requestRender())}for(const t of this.children)t.setTransform(e.state);if(super.renderChildren(e),this.hasAnimation){e.painter.effects.integrate.draw(e,e.attributeView)}switch(e.drawPhase){case r.MAP:return this._renderMapPhase(e);case r.HIGHLIGHT:return this._renderHighlightPhase(e);case r.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight()}get _layer(){return this._layerView.layer}_getExclusivePostprocessingInstance({drawPhase:e}){if(null==this._instanceStore)return null;let t=0,s=null;for(const i of this._instanceStore.values())i.techniqueRef.drawPhase&e&&(t++,i.techniqueRef.postProcessingEnabled&&(s=i));return t>1?null:s}_getOverrideStencilRef({drawPhase:e}){if(null==this._instanceStore)return null;let t=null;for(const s of this._instanceStore.values()){if(!(s.techniqueRef.drawPhase&e))continue;const{overrideStencilRef:i}=s.techniqueRef;if(null==t)t=i;else if(t!==i){t=null;break}}return t}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter((e=>this._visibleTiles.has(e.key.id))):[]}async updateAttributeView(e){this.requestRender(),await this.updatingHandles.addPromise(this.attributeView.requestUpdate(e)),this.hasLabels&&this._layerView.view.labelManager.requestUpdate()}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new l(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new h((()=>this._stage),e,this._tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const i of t)s.set(i.fieldName,{minValue:i.minValue,maxValue:i.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this.requestRender()}swapRenderState(){if(this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState)for(const e of this._renderState.tiles())e.upload();this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){if(e(s),!this._subscriptions.has(t.id))return;const i=this._subscriptions.get(t.id);if(i.version!==t.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${t.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${t.id}] FeatureContainer - Dropping message, outdated version]`,t)}return}const r=this._renderStateNext??this._renderState;if(!r)throw new Error("InternalError: No renderState defined");if(r.version!==t.version&&console.error(`InternalError: Version mismatch. [renderState: ${r.version}, message: ${t.version}]`),r.updateTile(t),t.end){this._subscriptions.get(t.id).end()}this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find((({x:t,y:s})=>t===e.x&&s===e.y));const i=t();return s?s.resolvers.push(i):(s={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(s)),this.requestRender(),i.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const i of this.children)if(i.getSortKeys(t).forEach(((e,t)=>s.set(t,e))),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}updateTransitionProperties(e,t){super.updateTransitionProperties(e,t),this._layerView.featureEffectView.transitionStep(e,t),this._layerView.featureEffectView.transitioning&&this.requestRender()}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,i=e.state.scale;i<=(t||1/0)&&i>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){const t=this._getOverrideStencilRef(e);if(null==t)super.setStencilReference(e);else for(const s of this.children)s.stencilRef=t(s)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&d(e,!1,(e=>{this._renderFeatures(e,n.Highlight)}))}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,i=t.getBoundFramebufferObject(),r=t.getViewport(),a=e.passOptions;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),this._renderFeatures(e,n.All),s.draw(e),s.unbind(),t.bindFramebuffer(i),t.restoreViewport(r),e.passOptions=a}_renderFeatures(e,t){for(const i of this.children){if(!i.visible)continue;const s=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,r=i.getDisplayList(e.drawPhase,this._instanceStore,s);e.selection=t,r?.render(e)}const s=this._getExclusivePostprocessingInstance(e);null!=s&&s.techniqueRef.postProcess(e,s)}}export{u as FeatureContainer};
5
+ import has from"../../../../core/has.js";import"../../../../core/Logger.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as r,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/InstanceStore.js";import{RenderState as h}from"./RenderState.js";import{renderHighlight as d}from"../support/util.js";class l{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class u extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._layerView=e}renderChildren(e){if(this.attributeView.update(),this._renderState){const e=Array.from(this._renderState.tiles()).filter((e=>e.needsUpload));if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this.requestRender())}for(const t of this.children)t.setTransform(e.state);if(this.hasAnimation){e.painter.effects.integrate.draw(e,e.attributeView)}switch(super.renderChildren(e),e.drawPhase){case r.MAP:return this._renderMapPhase(e);case r.HIGHLIGHT:return this._renderHighlightPhase(e);case r.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight()}get _layer(){return this._layerView.layer}_getExclusivePostprocessingInstance({drawPhase:e}){if(null==this._instanceStore)return null;let t=0,s=null;for(const i of this._instanceStore.values())i.techniqueRef.drawPhase&e&&(t++,i.techniqueRef.postProcessingEnabled&&(s=i));return t>1?null:s}_getOverrideStencilRef({drawPhase:e}){if(null==this._instanceStore)return null;let t=null;for(const s of this._instanceStore.values()){if(!(s.techniqueRef.drawPhase&e))continue;const{overrideStencilRef:i}=s.techniqueRef;if(null==t)t=i;else if(t!==i){t=null;break}}return t}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter((e=>this._visibleTiles.has(e.key.id))):[]}async updateAttributeView(e){this.requestRender(),await this.updatingHandles.addPromise(this.attributeView.requestUpdate(e)),this.hasLabels&&this._layerView.view.labelManager.requestUpdate()}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new l(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new h((()=>this._stage),e,this._tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const i of t)s.set(i.fieldName,{minValue:i.minValue,maxValue:i.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this.requestRender()}swapRenderState(){if(this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState)for(const e of this._renderState.tiles())e.upload();this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){if(e(s),!this._subscriptions.has(t.id))return;const i=this._subscriptions.get(t.id);if(i.version!==t.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${t.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${t.id}] FeatureContainer - Dropping message, outdated version]`,t)}return}const r=this._renderStateNext??this._renderState;if(!r)throw new Error("InternalError: No renderState defined");if(r.version!==t.version&&console.error(`InternalError: Version mismatch. [renderState: ${r.version}, message: ${t.version}]`),r.updateTile(t),t.end){this._subscriptions.get(t.id).end()}this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find((({x:t,y:s})=>t===e.x&&s===e.y));const i=t();return s?s.resolvers.push(i):(s={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(s)),this.requestRender(),i.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const i of this.children)if(i.getSortKeys(t).forEach(((e,t)=>s.set(t,e))),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}updateTransitionProperties(e,t){super.updateTransitionProperties(e,t),this._layerView.featureEffectView.transitionStep(e,t),this._layerView.featureEffectView.transitioning&&this.requestRender()}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,i=e.state.scale;i<=(t||1/0)&&i>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){const t=this._getOverrideStencilRef(e);if(null==t)super.setStencilReference(e);else for(const s of this.children)s.stencilRef=t(s)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&d(e,!1,(e=>{this._renderFeatures(e,n.Highlight)}))}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,i=t.getBoundFramebufferObject(),r=t.getViewport(),a=e.passOptions;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),this._renderFeatures(e,n.All),s.draw(e),s.unbind(),t.bindFramebuffer(i),t.restoreViewport(r),e.passOptions=a}_renderFeatures(e,t){for(const i of this.children){if(!i.visible)continue;const s=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,r=i.getDisplayList(e.drawPhase,this._instanceStore,s);e.selection=t,r?.render(e)}const s=this._getExclusivePostprocessingInstance(e);null!=s&&s.techniqueRef.postProcess(e,s)}}export{u as FeatureContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Color.js";import{multiplyOpacity as n}from"../../../core/colorUtils.js";import"../../../core/has.js";import{destroyHandle as i}from"../../../core/handleUtils.js";import{m as t}from"../../../chunks/vec32.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{onTheGroundElevationInfo as a,absoluteHeightElevationInfo as l}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as s,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as p}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as d}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as m}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as u}from"../layers/interfaces.js";import{RenderOccludedFlag as f}from"../webgl-engine/lib/Material.js";import{toDehydratedPoint as g,create as v}from"../../interactive/sketch/normalizedPoint.js";import{defaults as h}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{LineSegmentHintType as C}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as S}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as j}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as w}from"../../interactive/support/viewUtils.js";class O extends S{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof j?n.length:0)-(e instanceof j?e.length:0)))}visualizeIntersectionPoint(e,n){const{spatialReference:t,view:r}=n,o=D(n);return i(new d({view:r,primitive:"circle",geometry:g(e.intersectionPoint,t),elevationInfo:e.isDraped?a:l,size:20,outlineSize:2,color:o.intersectionPointColor,outlineColor:o.intersectionPointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizePoint(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=R(e.point,e.domain,n);return i(new d({view:t,primitive:"circle",geometry:g(a,r),elevationInfo:x(e,n),size:20,outlineSize:2,color:o.pointColor,outlineColor:o.pointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizeLine(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=R(e.lineStart,e.domain,n),l=R(e.lineEnd,e.domain,n);return i(this._createLineSegmentHint(e.type,a,l,r,x(e,n),t,o,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(e,n){const{view:r,spatialReference:o}=n,a=D(n),{isDraped:l}=e,s=x(e,n),c=R(e.lineStart,e.domain,n),d=R(e.lineEnd,e.domain,n),m=H(c,o,s,r,l),g=H(d,o,s,r,l),v=t(g,m,g,.5),E=new p({view:r,attached:!1,offset:h.parallelLineHintOffset,length:h.parallelLineHintLength,width:h.parallelLineHintWidth,color:a.parallelSignColor,location:v,renderOccluded:l?f.OccludeAndTransparent:f.Opaque,isDraped:l,renderGroup:u.SnappingHint,isDecoration:!0});return E.setDirectionFromPoints(m,v),E.attached=!0,i(E)}visualizeRightAngleQuad(e,n){const{view:t,spatialReference:r}=n,o=D(n),a=x(e,n),{isDraped:l}=e,s=R(e.previousVertex,e.domain,n),c=R(e.centerVertex,e.domain,n),p=R(e.nextVertex,e.domain,n),d=H(s,r,a,t,l),g=H(c,r,a,t,l),v=H(p,r,a,t,l);return i(new m({view:t,attached:!0,color:l?o.rightAngleColorDraped:o.rightAngleColor,renderOccluded:l?f.OccludeAndTransparent:f.Transparent,outlineRenderOccluded:l?f.OccludeAndTransparent:f.Opaque,outlineColor:o.rightAngleOutlineColor,outlineSize:h.rightAngleHintOutlineSize,size:h.rightAngleHintSize,isDraped:l,geometry:{previous:d,center:g,next:v},renderGroup:u.SnappingHint,isDecoration:!0}))}_createLineSegmentHint(e,n,i,t,r,o,a,l=!1,p=!0,d=!0){const m=H(n,t,r,o,l),g=H(i,t,r,o,l),v=new s({view:o,extensionType:c.FADED,start:m,end:g,isDraped:l,color:a.lineColor,renderOccluded:l?f.OccludeAndTransparent:f.Opaque,renderGroup:u.SnappingHint,isDecoration:!0});switch(e){case C.TARGET:v.width=h.lineHintWidthTarget,v.fadedExtensions={start:0,end:h.lineHintFadedExtensions};break;case C.REFERENCE_EXTENSION:v.width=h.lineHintWidthReference,v.fadedExtensions={start:0,end:0};break;case C.REFERENCE:v.width=h.lineHintWidthReference,v.fadedExtensions={start:p?h.lineHintFadedExtensions:0,end:d?h.lineHintFadedExtensions:0}}return v.attached=!0,v}}function D(i){const{effectiveTheme:t}=i.view,r=e.toUnitRGBA(t.accentColor),o=[0,0,0,0];return{intersectionPointColor:o,intersectionPointOutlineColor:r,pointColor:o,pointOutlineColor:r,lineColor:r,lineOutlineColor:void 0,parallelSignColor:r,rightAngleColor:r,rightAngleColorDraped:e.toUnitRGBA(n(t.accentColor,.5)),rightAngleOutlineColor:r}}function R(e,n,i){const t=A(n,i);return null==t?e:v(e[0],e[1],t)}function x(e,n){return null!=A(e.domain,n)?n.selfSnappingZ.elevationInfo:e.isDraped?a:l}function A(e,{selfSnappingZ:n}){return e===E.SELF&&null!=n?n.value:null}function H(e,n,i,t,a){const l=r();if(a){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;o(e,n,l,i)}else w(e,n,i,t,l);return l}export{O as SnappingVisualizer3D};
5
+ import e from"../../../Color.js";import{multiplyOpacity as n}from"../../../core/colorUtils.js";import"../../../core/has.js";import{destroyHandle as i}from"../../../core/handleUtils.js";import{m as t}from"../../../chunks/vec32.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{onTheGroundElevationInfo as l,absoluteHeightElevationInfo as a}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as s,ExtensionType as p}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as c}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as d}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as m}from"../layers/interfaces.js";import{RenderOccludedFlag as f}from"../webgl-engine/lib/Material.js";import{toDehydratedPoint as g,create as v}from"../../interactive/sketch/normalizedPoint.js";import{defaults as h}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{LineSegmentHintType as C}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as j}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as w}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as S}from"../../interactive/support/viewUtils.js";class O extends j{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof w?n.length:0)-(e instanceof w?e.length:0)))}visualizeIntersectionPoint(e,n){const{spatialReference:t,view:r}=n,o=R(n);return i(new d({view:r,primitive:"circle",geometry:g(e.intersectionPoint,t),elevationInfo:e.isDraped?l:a,size:20,outlineSize:2,color:o.intersectionPointColor,outlineColor:o.intersectionPointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizePoint(e,n){const{view:t,spatialReference:r}=n,o=R(n),l=x(e.point,e.domain,n);return i(new d({view:t,primitive:"circle",geometry:g(l,r),elevationInfo:A(e,n),size:20,outlineSize:2,color:o.pointColor,outlineColor:o.pointOutlineColor,pixelSnappingEnabled:!1,isDecoration:!0,attached:!0}))}visualizeLine(e,n){const{view:t,spatialReference:r}=n,o=R(n),l=x(e.lineStart,e.domain,n),a=x(e.lineEnd,e.domain,n);return i(D(e.type,l,a,r,A(e,n),t,o,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(e,n){const{view:r,spatialReference:o}=n,l=R(n),{isDraped:a}=e,s=A(e,n),p=x(e.lineStart,e.domain,n),d=x(e.lineEnd,e.domain,n),u=z(p,o,s,r,a),g=z(d,o,s,r,a),v=t(g,u,g,.5),E=new c({view:r,attached:!1,offset:h.parallelLineHintOffset,length:h.parallelLineHintLength,width:h.parallelLineHintWidth,color:l.parallelSignColor,location:v,renderOccluded:a?f.OccludeAndTransparent:f.Opaque,isDraped:a,renderGroup:m.SnappingHint,isDecoration:!0});return E.setDirectionFromPoints(u,v),E.attached=!0,i(E)}visualizeRightAngleQuad(e,n){const{view:t,spatialReference:r}=n,o=R(n),l=A(e,n),{isDraped:a}=e,s=x(e.previousVertex,e.domain,n),p=x(e.centerVertex,e.domain,n),c=x(e.nextVertex,e.domain,n),d=z(s,r,l,t,a),g=z(p,r,l,t,a),v=z(c,r,l,t,a);return i(new u({view:t,attached:!0,color:a?o.rightAngleColorDraped:o.rightAngleColor,renderOccluded:a?f.OccludeAndTransparent:f.Transparent,outlineRenderOccluded:a?f.OccludeAndTransparent:f.Opaque,outlineColor:o.rightAngleOutlineColor,outlineSize:h.rightAngleHintOutlineSize,size:h.rightAngleHintSize,isDraped:a,geometry:{previous:d,center:g,next:v},renderGroup:m.SnappingHint,isDecoration:!0}))}}function D(e,n,i,t,r,o,l,a=!1,c=!0,d=!0){const u=z(n,t,r,o,a),g=z(i,t,r,o,a),v=new s({view:o,extensionType:p.FADED,start:u,end:g,isDraped:a,color:l.lineColor,renderOccluded:a?f.OccludeAndTransparent:f.Opaque,renderGroup:m.SnappingHint,isDecoration:!0});switch(e){case C.TARGET:v.width=h.lineHintWidthTarget,v.fadedExtensions={start:0,end:h.lineHintFadedExtensions};break;case C.REFERENCE_EXTENSION:v.width=h.lineHintWidthReference,v.fadedExtensions={start:0,end:0};break;case C.REFERENCE:v.width=h.lineHintWidthReference,v.fadedExtensions={start:c?h.lineHintFadedExtensions:0,end:d?h.lineHintFadedExtensions:0}}return v.attached=!0,v}function R(i){const{effectiveTheme:t}=i.view,r=e.toUnitRGBA(t.accentColor),o=[0,0,0,0];return{intersectionPointColor:o,intersectionPointOutlineColor:r,pointColor:o,pointOutlineColor:r,lineColor:r,lineOutlineColor:void 0,parallelSignColor:r,rightAngleColor:r,rightAngleColorDraped:e.toUnitRGBA(n(t.accentColor,.5)),rightAngleOutlineColor:r}}function x(e,n,i){const t=H(n,i);return null==t?e:v(e[0],e[1],t)}function A(e,n){return null!=H(e.domain,n)?n.selfSnappingZ.elevationInfo:e.isDraped?l:a}function H(e,{selfSnappingZ:n}){return e===E.SELF&&null!=n?n.value:null}function z(e,n,i,t,l){const a=r();if(l){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;o(e,n,a,i)}else S(e,n,i,t,a);return a}export{O as SnappingVisualizer3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{whenOnce as i}from"../../../core/reactiveUtils.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 a}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerViewPerformanceInfo as l}from"./support/LayerViewPerformanceInfo.js";import{updatingProgress as s,updatingProgressValue as n}from"../support/updatingProperties.js";import{checkIfTileInfoSupportedForView as o}from"../terrain/terrainUtils.js";const c=c=>{let p=class extends c{get imageFormatIsOpaque(){return!1}get fullExtent(){return this.layer.fullExtent}get isOpaque(){return this.fullOpacity>=1&&this.imageFormatIsOpaque}get dataScaleRange(){const e=this.tileInfo.lods;let t=e[0].scale,i=e[e.length-1].scale;if("tilemapCache"in this.layer&&this.layer.tilemapCache){const{effectiveMinLOD:e,effectiveMaxLOD:r}=this.layer.tilemapCache;t=this.tileInfo.lodAt(e).scale,i=this.tileInfo.lodAt(r).scale}return{minScale:t,maxScale:i}}get dataLevelRange(){const{minScale:e,maxScale:t}=this.dataScaleRange;return this.levelRangeFromScaleRange(e,t)}get displayLevelRange(){const e=this.layer.minScale||this.dataScaleRange.minScale,t=this.layer.maxScale||this.dataScaleRange.maxScale,i=this.levelRangeFromScaleRange(e,t);return this.layer.maxScale&&i.maxLevel++,i}get performanceInfo(){return new l(this.view.basemapTerrain.getUsedMemoryForLayerView(this))}getTileUrl(e,t,i){return this.layer.getTileUrl(e,t,i)}_addTilingSchemeMatchPromise(){if(null==this.fullExtent)return this.addResolvingPromise(Promise.reject(new t("tilingscheme:extent-not-defined","This layer doesn't define a fullExtent.")));const e=this._getTileInfoSupportError(this.tileInfo,this.fullExtent);if(e)return this.addResolvingPromise(Promise.reject(e));const r=i((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t=this._getTileInfoCompatibilityError(this.tileInfo,e);if(t)throw t}));this.addResolvingPromise(r)}_getTileInfoSupportError(e,i){const r=o(e,i,this.view.spatialReference,this.view.state.viewingMode);if(r){const e={layer:this.layer,error:r};let i;switch(r.name){case"tilingscheme:spatial-reference-mismatch":case"tilingscheme:global-unsupported-spatial-reference":case"tilingscheme:local-unsupported-spatial-reference":i=new t("layerview:spatial-reference-incompatible","The spatial reference of this layer does not meet the requirements of the view",e);break;default:i=new t("layerview:tiling-scheme-unsupported","The tiling scheme of this layer is not supported by SceneView",e)}return i}return null}_getTileInfoCompatibilityError(e,i){return null!=e&&i.compatibleWith(e)?null:new t("layerview:tiling-scheme-incompatible","The tiling scheme of this layer is incompatible with the tiling scheme of the surface")}levelRangeFromScaleRange(e,t){const i={minLevel:0,maxLevel:1/0},r=this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.tilingScheme;if(!r)return i;const a=r.levels[0],l=e=>{const t=Math.log(a.scale/e)/Math.LN2;return.5-Math.abs(.5-t%1)<1e-9?Math.round(t):Math.ceil(t)};return null!=e&&e>0&&(i.minLevel=Math.max(0,l(e))),null!=t&&t>0&&(i.maxLevel=Math.max(0,l(t))),i}isUpdating(){return!!(this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.updating)}};return e([r({readOnly:!0})],p.prototype,"imageFormatIsOpaque",null),e([r({readOnly:!0})],p.prototype,"updating",void 0),e([r(s)],p.prototype,"updatingProgress",void 0),e([r(n)],p.prototype,"updatingProgressValue",void 0),e([r()],p.prototype,"fullExtent",null),e([r({readOnly:!0})],p.prototype,"isOpaque",null),e([r()],p.prototype,"dataScaleRange",null),e([r({readOnly:!0})],p.prototype,"dataLevelRange",null),e([r({readOnly:!0})],p.prototype,"displayLevelRange",null),e([r()],p.prototype,"layer",void 0),p=e([a("esri.views.3d.layers.TiledLayerView3D")],p),p};export{c as TiledLayerView3D};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{whenOnce as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{LayerViewPerformanceInfo as l}from"./support/LayerViewPerformanceInfo.js";import{updatingProgress as s,updatingProgressValue as n}from"../support/updatingProperties.js";import{checkIfTileInfoSupportedForView as o}from"../terrain/terrainUtils.js";const c=c=>{let p=class extends c{get imageFormatIsOpaque(){return!1}get fullExtent(){return this.layer.fullExtent}get isOpaque(){return this.fullOpacity>=1&&this.imageFormatIsOpaque}get dataScaleRange(){const e=this.tileInfo.lods;let t=e[0].scale,i=e[e.length-1].scale;if("tilemapCache"in this.layer&&this.layer.tilemapCache){const{effectiveMinLOD:e,effectiveMaxLOD:a}=this.layer.tilemapCache;t=this.tileInfo.lodAt(e).scale,i=this.tileInfo.lodAt(a).scale}return{minScale:t,maxScale:i}}get dataLevelRange(){const{minScale:e,maxScale:t}=this.dataScaleRange;return this.levelRangeFromScaleRange(e,t)}get displayLevelRange(){const e=this.layer.minScale||this.dataScaleRange.minScale,t=this.layer.maxScale||this.dataScaleRange.maxScale,i=this.levelRangeFromScaleRange(e,t);return this.layer.maxScale&&i.maxLevel++,i}get performanceInfo(){return new l(this.view.basemapTerrain.getUsedMemoryForLayerView(this))}getTileUrl(e,t,i){return this.layer.getTileUrl(e,t,i)}_addTilingSchemeMatchPromise(){if(null==this.fullExtent)return this.addResolvingPromise(Promise.reject(new t("tilingscheme:extent-not-defined","This layer doesn't define a fullExtent.")));const e=this._getTileInfoSupportError(this.tileInfo,this.fullExtent);if(e)return this.addResolvingPromise(Promise.reject(e));const a=i((()=>this.view?.basemapTerrain?.tilingSchemeLocked)).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t="tilemapCache"in this.layer?this.layer.tilemapCache?.effectiveMaxLOD:void 0,i=this._getTileInfoCompatibilityError(this.tileInfo,e,t);if(i)throw i}));this.addResolvingPromise(a)}_getTileInfoSupportError(e,i){const a=o(e,i,this.view.spatialReference,this.view.state.viewingMode,"tilemapCache"in this.layer?this.layer.tilemapCache?.effectiveMaxLOD:void 0);if(a){const e={layer:this.layer,error:a};let i;switch(a.name){case"tilingscheme:spatial-reference-mismatch":case"tilingscheme:global-unsupported-spatial-reference":case"tilingscheme:local-unsupported-spatial-reference":i=new t("layerview:spatial-reference-incompatible","The spatial reference of this layer does not meet the requirements of the view",e);break;default:i=new t("layerview:tiling-scheme-unsupported","The tiling scheme of this layer is not supported by SceneView",e)}return i}return null}_getTileInfoCompatibilityError(e,i,a){return null!=e&&i.compatibleWith(e,a)?null:new t("layerview:tiling-scheme-incompatible","The tiling scheme of this layer is incompatible with the tiling scheme of the surface")}levelRangeFromScaleRange(e,t){const i={minLevel:0,maxLevel:1/0},a=this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.tilingScheme;if(!a)return i;const r=a.levels[0],l=e=>{const t=Math.log(r.scale/e)/Math.LN2;return.5-Math.abs(.5-t%1)<1e-9?Math.round(t):Math.ceil(t)};return null!=e&&e>0&&(i.minLevel=Math.max(0,l(e))),null!=t&&t>0&&(i.maxLevel=Math.max(0,l(t))),i}isUpdating(){return!!(this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.updating)}};return e([a({readOnly:!0})],p.prototype,"imageFormatIsOpaque",null),e([a({readOnly:!0})],p.prototype,"updating",void 0),e([a(s)],p.prototype,"updatingProgress",void 0),e([a(n)],p.prototype,"updatingProgressValue",void 0),e([a()],p.prototype,"fullExtent",null),e([a({readOnly:!0})],p.prototype,"isOpaque",null),e([a()],p.prototype,"dataScaleRange",null),e([a({readOnly:!0})],p.prototype,"dataLevelRange",null),e([a({readOnly:!0})],p.prototype,"displayLevelRange",null),e([a()],p.prototype,"layer",void 0),p=e([r("esri.views.3d.layers.TiledLayerView3D")],p),p};export{c as TiledLayerView3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{projectWithoutEngine as s}from"../../../geometry/projection.js";import{fromExtent as l,empty as i,expand as o,allFinite as a,equals as c}from"../../../geometry/support/aaBoundingRect.js";import{isIntegratedMeshOperationalLayer as p,isTiledLayer as u}from"../../../layers/support/layerUtils.js";import{ViewingMode as y}from"../../ViewingMode.js";import{webmercatorWorldExtent as d,geographicWorldExtent as f}from"./TerrainConst.js";import{getTiledLayerInfo as E,isProjectableRasterLayer as m}from"./terrainUtils.js";let x=class extends t{constructor(e){super(e)}initialize(){this.addHandles([this.layerViews.on("change",(()=>this.notifyChange("stencilEnabledExtents")))])}destroy(){}get layerViewsExtent(){return this._computeLayerViewsExtent()}get tiledLayersExtent(){return this._computeTiledLayersExtent()}get stencilEnabledExtents(){return this._computeStencilEnabledExtents()}_computeStencilEnabledExtents(){const e=[];return this.layerViews.forEach((t=>{const r=t.layer;if(p(r.operationalLayerType)&&null!=this.viewSpatialReference){const t=L(r.fullExtent,this.viewSpatialReference);null!=t&&e.push(l(t))}})),e}};function h(e,t){return e===y.Global?new w(t):new g(t)}e([r({readOnly:!0})],x.prototype,"layerViewsExtent",null),e([r({readOnly:!0})],x.prototype,"tiledLayersExtent",null),e([r({readOnly:!0})],x.prototype,"stencilEnabledExtents",null),e([r()],x.prototype,"viewSpatialReference",void 0),e([r()],x.prototype,"tilingScheme",void 0),e([r()],x.prototype,"defaultTiledLayersExtent",void 0),e([r({constructOnly:!0})],x.prototype,"layers",void 0),e([r({constructOnly:!0})],x.prototype,"layerViews",void 0),x=e([n("esri.views.3d.terrain.ExtentHelper")],x);let w=class extends x{_computeLayerViewsExtent(){return this._globalExtent}_computeTiledLayersExtent(){return this._globalExtent}get _globalExtent(){return this.viewSpatialReference.isWebMercator?d:f}};w=e([n("esri.views.3d.terrain.ExtentHelper.ExtentHelperGlobal")],w);let g=class extends x{_computeLayerViewsExtent(){const e=i(),t=this.viewSpatialReference;this.layerViews.forEach((r=>{const n=r.layer;if(r.isResolved()&&("graphics"!==n.type||!n.internal)){const n=L("fullExtentInLocalViewSpatialReference"in r&&r.fullExtentInLocalViewSpatialReference||r.layer.fullExtent,t);o(e,n,e)}}));const r=a(e)?e:null,n=this._get("layerViewsExtent");return c(r,n)?n:r}_computeTiledLayersExtent(){const e=this.tilingScheme;if(!e)return null;const t=this.viewSpatialReference,r=i();this.layers.forEach((n=>{if(n.loaded&&u(n)){const s=E(n,t,y.Local);if(null==s)return;const{tileInfo:l,fullExtent:i}=s;null!=l&&null!=i&&(m(n)||e.compatibleWith(l)&&i.spatialReference.equals(e.spatialReference))&&o(r,i,r)}})),o(r,this.defaultTiledLayersExtent,r);const n=a(r)?r:null,s=this._get("tiledLayersExtent");return c(n,s)?s:n}};function L(e,t){return null==e||e.spatialReference.equals(t)?e:s(e,e.spatialReference,t)}g=e([n("esri.views.3d.terrain.ExtentHelper.ExtentHelperLocal")],g);export{x as ExtentHelper,h as create};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{projectWithoutEngine as i}from"../../../geometry/projection.js";import{fromExtent as l,empty as s,expand as o,allFinite as a,equals as c}from"../../../geometry/support/aaBoundingRect.js";import{isIntegratedMeshOperationalLayer as p,isTiledLayer as u}from"../../../layers/support/layerUtils.js";import{ViewingMode as y}from"../../ViewingMode.js";import{webmercatorWorldExtent as f,geographicWorldExtent as d}from"./TerrainConst.js";import{getTiledLayerInfo as E,isProjectableRasterLayer as m}from"./terrainUtils.js";let x=class extends t{constructor(e){super(e)}initialize(){this.addHandles([this.layerViews.on("change",(()=>this.notifyChange("stencilEnabledExtents")))])}destroy(){}get layerViewsExtent(){return this._computeLayerViewsExtent()}get tiledLayersExtent(){return this._computeTiledLayersExtent()}get stencilEnabledExtents(){return this._computeStencilEnabledExtents()}_computeStencilEnabledExtents(){const e=[];return this.layerViews.forEach((t=>{const r=t.layer;if("operationalLayerType"in r&&p(r.operationalLayerType)&&null!=this.viewSpatialReference){const t=L(r.fullExtent,this.viewSpatialReference);null!=t&&e.push(l(t))}})),e}};function h(e,t){return e===y.Global?new w(t):new g(t)}e([r({readOnly:!0})],x.prototype,"layerViewsExtent",null),e([r({readOnly:!0})],x.prototype,"tiledLayersExtent",null),e([r({readOnly:!0})],x.prototype,"stencilEnabledExtents",null),e([r()],x.prototype,"viewSpatialReference",void 0),e([r()],x.prototype,"tilingScheme",void 0),e([r()],x.prototype,"defaultTiledLayersExtent",void 0),e([r({constructOnly:!0})],x.prototype,"layers",void 0),e([r({constructOnly:!0})],x.prototype,"layerViews",void 0),x=e([n("esri.views.3d.terrain.ExtentHelper")],x);let w=class extends x{_computeLayerViewsExtent(){return this._globalExtent}_computeTiledLayersExtent(){return this._globalExtent}get _globalExtent(){return this.viewSpatialReference.isWebMercator?f:d}};w=e([n("esri.views.3d.terrain.ExtentHelper.ExtentHelperGlobal")],w);let g=class extends x{_computeLayerViewsExtent(){const e=s(),t=this.viewSpatialReference;this.layerViews.forEach((r=>{const n=r.layer;if(r.isResolved()&&("graphics"!==n.type||!n.internal)){const n=L("fullExtentInLocalViewSpatialReference"in r&&r.fullExtentInLocalViewSpatialReference||r.layer.fullExtent,t);o(e,n,e)}}));const r=a(e)?e:null,n=this._get("layerViewsExtent");return c(r,n)?n:r}_computeTiledLayersExtent(){const e=this.tilingScheme;if(!e)return null;const t=this.viewSpatialReference,r=s();this.layers.forEach((n=>{if(n.loaded&&u(n)){const i=E(n,t,y.Local);if(null==i)return;const{tileInfo:l,fullExtent:s}=i,a="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;null!=l&&null!=s&&(m(n)||e.compatibleWith(l,a)&&s.spatialReference.equals(e.spatialReference))&&o(r,s,r)}})),o(r,this.defaultTiledLayersExtent,r);const n=a(r)?r:null,i=this._get("tiledLayersExtent");return c(n,i)?i:n}};function L(e,t){return null==e||e.spatialReference.equals(t)?e:i(e,e.spatialReference,t)}g=e([n("esri.views.3d.terrain.ExtentHelper.ExtentHelperLocal")],g);export{x as ExtentHelper,h as create};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import"../../../geometry.js";import e from"../../../core/Error.js";import{deg2rad as i,floatEqualAbsolute as t,floatEqualRelative as s}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import n from"../../../geometry/Extent.js";import l from"../../../geometry/SpatialReference.js";import{create as o}from"../../../geometry/support/aaBoundingRect.js";import{isGeographic as a}from"../../../geometry/support/spatialReferenceUtils.js";import{x2lon as h,y2lat as c}from"../../../geometry/support/webMercatorUtils.js";import m from"../../../layers/support/LOD.js";import u from"../../../layers/support/TileInfo.js";import p from"../../../geometry/Point.js";const g=12;class f{constructor(e){const i=f.checkUnsupported(e);if(null!=i)throw i;const t=e;this.spatialReference=t.spatialReference,this._isWebMercator=this.spatialReference.isWebMercator,this._isGCS=a(this.spatialReference),this.origin=[t.origin.x,t.origin.y],this.pixelSize=t.size[0],this.dpi=t.dpi;const s=t.lods.reduce(((e,i,t)=>(i.level<e.min&&(e.min=i.level,e.minIndex=t),e.max=Math.max(e.max,i.level),e)),{min:1/0,minIndex:0,max:-1/0}),r=t.lods[s.minIndex],n=2**r.level;let l=r.resolution*n,o=r.scale*n;this.levels=new Array(s.max+1);for(let a=0;a<this.levels.length;a++)this.levels[a]={resolution:l,scale:o,tileSize:[l*t.size[0],l*t.size[1]]},l/=2,o/=2}clone(){return new f(this.toTileInfo())}toTileInfo(){return new u({dpi:this.dpi,origin:new p({x:this.origin[0],y:this.origin[1],spatialReference:this.spatialReference}),size:[this.pixelSize,this.pixelSize],spatialReference:this.spatialReference,lods:this.levels.map(((e,i)=>new m({level:i,scale:e.scale,resolution:e.resolution})))})}getExtent(e,i,t,s){const r=this.levels[e],n=r.tileSize[0],l=r.tileSize[1];s[0]=this.origin[0]+t*n,s[2]=this.origin[0]+(t+1)*n,s[3]=this.origin[1]-i*l,s[1]=this.origin[1]-(i+1)*l}convertExtentToRadians(e,t){this._isWebMercator?(t[0]=h(e[0]),t[1]=c(e[1]),t[2]=h(e[2]),t[3]=c(e[3])):this._isGCS&&(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=i(e[2]),t[3]=i(e[3]))}getExtentGeometry(e,i,t,s=new n){return this.getExtent(e,i,t,v),s.spatialReference=this.spatialReference,s.xmin=v[0],s.ymin=v[1],s.xmax=v[2],s.ymax=v[3],s.zmin=void 0,s.zmax=void 0,s}ensureMaxLod(e){if(null==e)return!1;let i=!1;for(;this.levels.length<=e;){const{resolution:e,scale:t}=this.levels[this.levels.length-1],s=e/2*this.pixelSize;this.levels.push({resolution:e/2,scale:t/2,tileSize:[s,s]}),i=!0}return i}capMaxLod(e){this.levels.length>e+1&&(this.levels.length=e+1)}getMaxLod(){return this.levels.length-1}scaleAtLevel(e){return this.levels[0].scale/2**e}levelAtScale(e){const i=this.levels[0].scale;return e>=i?0:Math.log(i/e)*Math.LOG2E}resolutionAtLevel(e){return this.levels[0].resolution/2**e}compatibleWith(e){if(!(e instanceof f)){if(f.checkUnsupported(e))return!1;e=new f(e)}if(!e.spatialReference.equals(this.spatialReference))return!1;if(e.pixelSize!==this.pixelSize)return!1;const i=Math.min(this.levels.length,e.levels.length)-1,s=this.levels[i].resolution;let r=.5*s;if(!t(e.origin[0],this.origin[0],r)||!t(e.origin[1],this.origin[1],r))return!1;return r=.5*s/2**i/this.pixelSize*g,t(s,e.levels[i].resolution,r)}rootTilesInExtent(e,i=null,t=1/0){const s=new Array,r=this.levels[0].tileSize;if(null==e||0===r[0]||0===r[1])return s;f.computeRowColExtent(e,r,this.origin,v);let n=v[1],l=v[3],o=v[0],a=v[2];const h=a-o,c=l-n;if(h*c>t){const e=Math.floor(Math.sqrt(t));c>e&&(n=n+Math.floor(.5*c)-Math.floor(.5*e),l=n+e),h>e&&(o=o+Math.floor(.5*h)-Math.floor(.5*e),a=o+e)}for(let m=n;m<l;m++)for(let e=o;e<a;e++)s.push([0,m,e]);return null!=i&&(i[0]=this.origin[0]+o*r[0],i[1]=this.origin[1]-l*r[1],i[2]=this.origin[0]+a*r[0],i[3]=this.origin[1]-n*r[1]),s}static computeRowColExtent(e,i,t,s){const r=.001*(e[2]-e[0]+(e[3]-e[1]));s[0]=Math.max(0,Math.floor((e[0]+r-t[0])/i[0])),s[2]=Math.max(0,Math.ceil((e[2]-r-t[0])/i[0])),s[1]=Math.max(0,Math.floor((t[1]-e[3]+r)/i[1])),s[3]=Math.max(0,Math.ceil((t[1]-e[1]-r)/i[1]))}static isPowerOfTwo(e){const i=e.lods,t=i[0].resolution*2**i[0].level;return!i.some((e=>!s(e.resolution,t/2**e.level)))}static hasGapInLevels(e){const i=e.lods.map((e=>e.level));i.sort(((e,i)=>e-i));for(let t=1;t<i.length;t++)if(i[t]!==i[0]+t)return!0;return!1}static tileSizeSupported(e){const i=e.size[1];return i===e.size[0]&&!(i&i-1)&&i>=128&&i<=512}static hasOriginPerLODs(e){const i=e.origin;return e.lods.some((e=>null!=e.origin&&(e.origin[0]!==i.x||e.origin[1]!==i.y)))}static getMissingTileInfoError(){return new e("tilingscheme:tile-info-missing","Tiling scheme must have tiling information")}static checkUnsupported(i){return null==i?x():i.lods.length<1?new e("tilingscheme:generic","Tiling scheme must have at least one level"):f.isPowerOfTwo(i)?f.hasGapInLevels(i)?new e("tilingscheme:gaps","Tiling scheme levels must not have gaps between min and max level"):f.tileSizeSupported(i)?f.hasOriginPerLODs(i)?new e("tilingscheme:multiple-origin","Tiling scheme levels must not have their own origin"):null:new e("tilingscheme:tile-size","Tiles must be square and size must be one of [128, 256, 512]"):new e("tilingscheme:power-of-two","Tiling scheme must be power of two")}static fromExtent(e,i){const t=e[2]-e[0],s=e[3]-e[1],n=r(i),l=1.2*Math.max(t,s),o=256,a=l/o,h=a*n*(96/.0254),c=new f(new u({size:[o,o],origin:new p({x:e[0]-.5*(l-t),y:e[3]+.5*(l-s)}),lods:[new m({level:0,resolution:a,scale:h})],spatialReference:i}));return c.ensureMaxLod(20),c}static makeWebMercatorAuxiliarySphere(e){const i=new f(f.WebMercatorAuxiliarySphereTileInfo);return i.ensureMaxLod(e),i}static makeGCSWithTileSize(e,i=256,t=16){const s=256/i,r=new f(new u({size:[i,i],origin:new p({x:-180,y:90,spatialReference:e}),spatialReference:e,lods:[new m({level:0,resolution:.703125*s,scale:295497598.570834*s})]}));return r.ensureMaxLod(t),r}get test(){return{isWebMercator:this._isWebMercator,isGCS:this._isGCS}}}function x(){return new e("tilingscheme:tile-info-missing","Tiling scheme must have tiling information")}f.WebMercatorAuxiliarySphereTileInfo=new u({size:[256,256],origin:new p({x:-20037508.342787,y:20037508.342787,spatialReference:l.WebMercator}),spatialReference:l.WebMercator,lods:[new m({level:0,resolution:156543.03392800014,scale:591657527.591555})]}),f.WebMercatorAuxiliarySphere=f.makeWebMercatorAuxiliarySphere(19);const v=o();export{f as TilingScheme,x as getMissingTileInfoError};
5
+ import"../../../geometry.js";import e from"../../../core/Error.js";import{deg2rad as i,floatEqualAbsolute as t,floatEqualRelative as s}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/unitUtils.js";import n from"../../../geometry/Extent.js";import l from"../../../geometry/SpatialReference.js";import{create as o}from"../../../geometry/support/aaBoundingRect.js";import{isGeographic as a}from"../../../geometry/support/spatialReferenceUtils.js";import{x2lon as h,y2lat as c}from"../../../geometry/support/webMercatorUtils.js";import m from"../../../layers/support/LOD.js";import u from"../../../layers/support/TileInfo.js";import p from"../../../geometry/Point.js";const g=12;class f{constructor(e){const i=f.checkUnsupported(e);if(null!=i)throw i;const t=e;this.spatialReference=t.spatialReference,this._isWebMercator=this.spatialReference.isWebMercator,this._isGCS=a(this.spatialReference),this.origin=[t.origin.x,t.origin.y],this.pixelSize=t.size[0],this.dpi=t.dpi;const s=t.lods.reduce(((e,i,t)=>(i.level<e.min&&(e.min=i.level,e.minIndex=t),e.max=Math.max(e.max,i.level),e)),{min:1/0,minIndex:0,max:-1/0}),r=t.lods[s.minIndex],n=2**r.level;let l=r.resolution*n,o=r.scale*n;this.levels=new Array(s.max+1);for(let a=0;a<this.levels.length;a++)this.levels[a]={resolution:l,scale:o,tileSize:[l*t.size[0],l*t.size[1]]},l/=2,o/=2}clone(){return new f(this.toTileInfo())}toTileInfo(){return new u({dpi:this.dpi,origin:new p({x:this.origin[0],y:this.origin[1],spatialReference:this.spatialReference}),size:[this.pixelSize,this.pixelSize],spatialReference:this.spatialReference,lods:this.levels.map(((e,i)=>new m({level:i,scale:e.scale,resolution:e.resolution})))})}getExtent(e,i,t,s){const r=this.levels[e],n=r.tileSize[0],l=r.tileSize[1];s[0]=this.origin[0]+t*n,s[2]=this.origin[0]+(t+1)*n,s[3]=this.origin[1]-i*l,s[1]=this.origin[1]-(i+1)*l}convertExtentToRadians(e,t){this._isWebMercator?(t[0]=h(e[0]),t[1]=c(e[1]),t[2]=h(e[2]),t[3]=c(e[3])):this._isGCS&&(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=i(e[2]),t[3]=i(e[3]))}getExtentGeometry(e,i,t,s=new n){return this.getExtent(e,i,t,v),s.spatialReference=this.spatialReference,s.xmin=v[0],s.ymin=v[1],s.xmax=v[2],s.ymax=v[3],s.zmin=void 0,s.zmax=void 0,s}ensureMaxLod(e){if(null==e)return!1;let i=!1;for(;this.levels.length<=e;){const{resolution:e,scale:t}=this.levels[this.levels.length-1],s=e/2*this.pixelSize;this.levels.push({resolution:e/2,scale:t/2,tileSize:[s,s]}),i=!0}return i}capMaxLod(e){this.levels.length>e+1&&(this.levels.length=e+1)}getMaxLod(){return this.levels.length-1}scaleAtLevel(e){return this.levels[0].scale/2**e}levelAtScale(e){const i=this.levels[0].scale;return e>=i?0:Math.log(i/e)*Math.LOG2E}resolutionAtLevel(e){return this.levels[0].resolution/2**e}compatibleWith(e,i=1/0){if(f.checkUnsupported(e))return!1;const s=new f(e);if(!s.spatialReference.equals(this.spatialReference))return!1;if(s.pixelSize!==this.pixelSize)return!1;const r=Math.min(this.levels.length-1,s.levels.length-1,i),n=this.levels[r].resolution;let l=.5*n;if(!t(s.origin[0],this.origin[0],l)||!t(s.origin[1],this.origin[1],l))return!1;return l=.5*n/2**r/this.pixelSize*g,t(n,s.levels[r].resolution,l)}rootTilesInExtent(e,i=null,t=1/0){const s=new Array,r=this.levels[0].tileSize;if(null==e||0===r[0]||0===r[1])return s;f.computeRowColExtent(e,r,this.origin,v);let n=v[1],l=v[3],o=v[0],a=v[2];const h=a-o,c=l-n;if(h*c>t){const e=Math.floor(Math.sqrt(t));c>e&&(n=n+Math.floor(.5*c)-Math.floor(.5*e),l=n+e),h>e&&(o=o+Math.floor(.5*h)-Math.floor(.5*e),a=o+e)}for(let m=n;m<l;m++)for(let e=o;e<a;e++)s.push([0,m,e]);return null!=i&&(i[0]=this.origin[0]+o*r[0],i[1]=this.origin[1]-l*r[1],i[2]=this.origin[0]+a*r[0],i[3]=this.origin[1]-n*r[1]),s}static computeRowColExtent(e,i,t,s){const r=.001*(e[2]-e[0]+(e[3]-e[1]));s[0]=Math.max(0,Math.floor((e[0]+r-t[0])/i[0])),s[2]=Math.max(0,Math.ceil((e[2]-r-t[0])/i[0])),s[1]=Math.max(0,Math.floor((t[1]-e[3]+r)/i[1])),s[3]=Math.max(0,Math.ceil((t[1]-e[1]-r)/i[1]))}static isPowerOfTwo(e){const i=e.lods,t=i[0].resolution*2**i[0].level;return!i.some((e=>!s(e.resolution,t/2**e.level)))}static hasGapInLevels(e){const i=e.lods.map((e=>e.level));i.sort(((e,i)=>e-i));for(let t=1;t<i.length;t++)if(i[t]!==i[0]+t)return!0;return!1}static tileSizeSupported(e){const i=e.size[1];return i===e.size[0]&&!(i&i-1)&&i>=128&&i<=512}static hasOriginPerLODs(e){const i=e.origin;return e.lods.some((e=>null!=e.origin&&(e.origin[0]!==i.x||e.origin[1]!==i.y)))}static getMissingTileInfoError(){return new e("tilingscheme:tile-info-missing","Tiling scheme must have tiling information")}static checkUnsupported(i){return null==i?x():i.lods.length<1?new e("tilingscheme:generic","Tiling scheme must have at least one level"):f.isPowerOfTwo(i)?f.hasGapInLevels(i)?new e("tilingscheme:gaps","Tiling scheme levels must not have gaps between min and max level"):f.tileSizeSupported(i)?f.hasOriginPerLODs(i)?new e("tilingscheme:multiple-origin","Tiling scheme levels must not have their own origin"):null:new e("tilingscheme:tile-size","Tiles must be square and size must be one of [128, 256, 512]"):new e("tilingscheme:power-of-two","Tiling scheme must be power of two")}static fromExtent(e,i){const t=e[2]-e[0],s=e[3]-e[1],n=r(i),l=1.2*Math.max(t,s),o=256,a=l/o,h=a*n*(96/.0254),c=new f(new u({size:[o,o],origin:new p({x:e[0]-.5*(l-t),y:e[3]+.5*(l-s)}),lods:[new m({level:0,resolution:a,scale:h})],spatialReference:i}));return c.ensureMaxLod(20),c}static makeWebMercatorAuxiliarySphere(e){const i=new f(f.WebMercatorAuxiliarySphereTileInfo);return i.ensureMaxLod(e),i}static makeGCSWithTileSize(e,i=256,t=16){const s=256/i,r=new f(new u({size:[i,i],origin:new p({x:-180,y:90,spatialReference:e}),spatialReference:e,lods:[new m({level:0,resolution:.703125*s,scale:295497598.570834*s})]}));return r.ensureMaxLod(t),r}get test(){return{isWebMercator:this._isWebMercator,isGCS:this._isGCS}}}function x(){return new e("tilingscheme:tile-info-missing","Tiling scheme must have tiling information")}f.WebMercatorAuxiliarySphereTileInfo=new u({size:[256,256],origin:new p({x:-20037508.342787,y:20037508.342787,spatialReference:l.WebMercator}),spatialReference:l.WebMercator,lods:[new m({level:0,resolution:156543.03392800014,scale:591657527.591555})]}),f.WebMercatorAuxiliarySphere=f.makeWebMercatorAuxiliarySphere(19);const v=o();export{f as TilingScheme,x as getMissingTileInfoError};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Collection.js";import{isCGCS2000 as n,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{ViewingMode as o}from"../../ViewingMode.js";import{ImageWithType as l}from"../support/StreamDataLoader.js";import{NeighborIndex as i}from"./ITile.js";import{t as u}from"../../../chunks/terrainUtilsPlanar.js";import{t as f}from"../../../chunks/terrainUtilsSpherical.js";const c={[o.Global]:f,[o.Local]:u};function a(t,n){t||console.warn("Terrain: "+n)}let T=!1,s=!1;function S(t){s=t,T=T||t}function E(t){T=t}function p(t,n){if(T&&!t){const t=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(n??"")+" at "+t),new Error("Assertion failed"+(n?": "+n:""))}}function m(t){return O(t)?{fullExtent:t.fullExtent,minScale:t.layer.minScale,maxScale:t.layer.maxScale,tilemapCache:null}:t.layer}function H(t){return"imagery-tile"===t?.type||"wcs"===t?.type}function O(t){return"imagery-tile-3d"===t?.type}function y(t){return"tile-3d"===t?.type}function _(t){return"vector-tile-3d"===t?.type}function I(t){return"wmts-3d"===t?.type}function d(t){return"elevation-3d"===t?.type}function R(t){return"group"===t?.type}function U(t){return t&&(y(t)||I(t)||O(t)||_(t))}function W(t){return t&&(y(t)||O(t)||_(t)||I(t))}function N(t){return W(t)||d(t)}function x(t){const n=t?.sourceLayerInfo?.data;return null!=n&&"type"in n&&"raster-tile"===n.type}function A(t){return h(t?.sourceLayerInfo)||!!t?.isVTLBackground}function L(t){const n=t?.sourceLayerInfo?.data;return null!=n&&"type"in n&&"tile-texture"===n.type}function g(t){const n=t?.sourceLayerInfo?.data;return n instanceof HTMLImageElement||n instanceof l||n instanceof HTMLCanvasElement||n instanceof ImageData}function h(t){return null!=t?.data&&"type"in t.data&&"vector-tile"===t.data.type}function w(t){return null!=t&&"release"in t&&t.release(),null}function j(t){return t.fetchTile&&!1!==t.hasOverriddenFetchTile}function C(t,n,e,r){return c[r].checkIfTileInfoSupportedForViewSR(t,e,n)}function b(t,n,e){let r=null,l=null;if("wmts"===t?.type){const o=v(t,n,e);r=o.tileInfo,l=o.fullExtent}else{l=H(t)?t.getCompatibleFullExtent(n):t.fullExtent;const i=e===o.Local;if(H(t))r=t.getCompatibleTileInfo(n,l,i);else if("vector-tile"===t?.type){r=i&&!V(n)||k.force512VTL?t.tileInfo:t.tileInfo.getCompatibleForVTL(256)}else r=t.tileInfo}return null!=r&&null!=l&&null==C(r,l,n,e)?{tileInfo:r,fullExtent:l}:null}function v(n,e,o){const l=r(n);if(null!=l){if(!t.isCollection(l))return{tileInfo:l.tileInfo,fullExtent:l.fullExtent};{const t=l.find((t=>null==C(t.tileInfo,t.fullExtent,e,o)));if(t)return{tileInfo:t.tileInfo,fullExtent:t.fullExtent}}}return{tileInfo:null,fullExtent:null}}function V(t){return t.isWGS84||t.isWebMercator||n(t)||!e(t)}const k={force512VTL:!1};function M(t){return"["+t[0]+","+t[1]+","+t[2]+"]"}function F(t){return"("+t[0]+","+t[1]+","+t[2]+")"}function D(t,n,e=Z){return Math.abs(t-n)<e}function G(t){return t===i.NORTH_EAST?i.SOUTH_WEST:t===i.NORTH_WEST?i.SOUTH_EAST:t===i.SOUTH_WEST?i.NORTH_EAST:i.NORTH_WEST}function B(t){return t===i.NORTH?i.SOUTH:t===i.EAST?i.WEST:t===i.SOUTH?i.NORTH:i.EAST}function P(t){return t===i.NORTH_WEST||t===i.SOUTH_WEST}function q(t){return t===i.NORTH_WEST||t===i.NORTH_EAST}function z(t){return t===i.NORTH_WEST||t===i.WEST||t===i.SOUTH_WEST}function J(t){return t===i.NORTH_EAST||t===i.EAST||t===i.SOUTH_EAST}function K(t){return t===i.SOUTH_EAST||t===i.SOUTH||t===i.SOUTH_WEST}function Q(t){return t===i.NORTH_EAST||t===i.NORTH||t===i.NORTH_WEST}const X=[i.NORTH,i.EAST,i.SOUTH,i.WEST],Y=[i.NORTH_EAST,i.SOUTH_EAST,i.SOUTH_WEST,i.NORTH_WEST],Z=1e-5;export{D as almostEquals,C as checkIfTileInfoSupportedForView,E as enableInternalTerrainChecks,T as enableTerrainInternalChecks,S as enableTerrainWaterproofnessChecks,s as enableWaterproofnessTests,Z as eps,m as getLayerWithExtentRange,v as getTileInfoAndExtentFromWMTSLayer,b as getTiledLayerInfo,p as internalAssert,U as isBlendableLayerView,J as isEast,d as isElevationLayerView,R as isGroupLayerView,O as isImageryTileLayerView,x as isImageryTileRenderInfo,W as isMapTileLayerView,Q as isNorth,q as isNorthCorner,H as isProjectableRasterLayer,g as isRasterTileRenderInfo,K as isSouth,N as isSurfaceLayerView,L as isTextureTileRenderInfo,y as isTileLayerView,_ as isVectorTileLayerView,h as isVectorTilePerLayerInfo,A as isVectorTileRenderInfo,I as isWMTSLayerView,z as isWest,P as isWestCorner,M as lij2s,Y as neighborCornerIndices,X as neighborEdgeIndices,G as oppositeCorner,B as oppositeEdge,w as releaseTileData,k as test,j as useFetchTileForLayer,F as v32s,V as vtlAssumes256PixelSizeAsDefault,a as weakAssert};
5
+ import t from"../../../core/Collection.js";import{isCGCS2000 as n,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{ViewingMode as o}from"../../ViewingMode.js";import{ImageWithType as l}from"../support/StreamDataLoader.js";import{NeighborIndex as i}from"./ITile.js";import{t as u}from"../../../chunks/terrainUtilsPlanar.js";import{t as f}from"../../../chunks/terrainUtilsSpherical.js";const c={[o.Global]:f,[o.Local]:u};function a(t,n){t||console.warn("Terrain: "+n)}let T=!1,s=!1;function S(t){s=t,T=T||t}function E(t){T=t}function p(t,n){if(T&&!t){const t=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(n??"")+" at "+t),new Error("Assertion failed"+(n?": "+n:""))}}function m(t){return O(t)?{fullExtent:t.fullExtent,minScale:t.layer.minScale,maxScale:t.layer.maxScale,tilemapCache:null}:t.layer}function H(t){return"imagery-tile"===t?.type||"wcs"===t?.type}function O(t){return"imagery-tile-3d"===t?.type}function y(t){return"tile-3d"===t?.type}function _(t){return"vector-tile-3d"===t?.type}function I(t){return"wmts-3d"===t?.type}function d(t){return"elevation-3d"===t?.type}function R(t){return"group"===t?.type}function U(t){return t&&(y(t)||I(t)||O(t)||_(t))}function W(t){return t&&(y(t)||O(t)||_(t)||I(t))}function x(t){return W(t)||d(t)}function N(t){const n=t?.sourceLayerInfo?.data;return null!=n&&"type"in n&&"raster-tile"===n.type}function A(t){return g(t?.sourceLayerInfo)||!!t?.isVTLBackground}function L(t){const n=t?.sourceLayerInfo?.data;return null!=n&&"type"in n&&"tile-texture"===n.type}function h(t){const n=t?.sourceLayerInfo?.data;return n instanceof HTMLImageElement||n instanceof l||n instanceof HTMLCanvasElement||n instanceof ImageData}function g(t){return null!=t?.data&&"type"in t.data&&"vector-tile"===t.data.type}function w(t){return null!=t&&"release"in t&&t.release(),null}function C(t){return t.fetchTile&&!1!==t.hasOverriddenFetchTile}function j(t,n,e,r,o){return c[r].checkIfTileInfoSupportedForViewSR(t,e,n,o)}function v(t,n,e){let r=null,l=null;if("wmts"===t?.type){const o=b(t,n,e);r=o.tileInfo,l=o.fullExtent}else{l=H(t)?t.getCompatibleFullExtent(n):t.fullExtent;const i=e===o.Local;if(H(t))r=t.getCompatibleTileInfo(n,l,i);else if("vector-tile"===t?.type){r=i&&!M(n)||V.force512VTL?t.tileInfo:t.tileInfo.getCompatibleForVTL(256)}else r=t.tileInfo}const i="tilemapCache"in t?t.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=l&&null==j(r,l,n,e,i)?{tileInfo:r,fullExtent:l}:null}function b(n,e,o){const l=r(n);if(null!=l){if(!t.isCollection(l))return{tileInfo:l.tileInfo,fullExtent:l.fullExtent};{const t=l.find((t=>null==j(t.tileInfo,t.fullExtent,e,o)));if(t)return{tileInfo:t.tileInfo,fullExtent:t.fullExtent}}}return{tileInfo:null,fullExtent:null}}function M(t){return t.isWGS84||t.isWebMercator||n(t)||!e(t)}const V={force512VTL:!1};function k(t){return"["+t[0]+","+t[1]+","+t[2]+"]"}function F(t){return"("+t[0]+","+t[1]+","+t[2]+")"}function D(t,n,e=Z){return Math.abs(t-n)<e}function G(t){return t===i.NORTH_EAST?i.SOUTH_WEST:t===i.NORTH_WEST?i.SOUTH_EAST:t===i.SOUTH_WEST?i.NORTH_EAST:i.NORTH_WEST}function B(t){return t===i.NORTH?i.SOUTH:t===i.EAST?i.WEST:t===i.SOUTH?i.NORTH:i.EAST}function P(t){return t===i.NORTH_WEST||t===i.SOUTH_WEST}function q(t){return t===i.NORTH_WEST||t===i.NORTH_EAST}function z(t){return t===i.NORTH_WEST||t===i.WEST||t===i.SOUTH_WEST}function J(t){return t===i.NORTH_EAST||t===i.EAST||t===i.SOUTH_EAST}function K(t){return t===i.SOUTH_EAST||t===i.SOUTH||t===i.SOUTH_WEST}function Q(t){return t===i.NORTH_EAST||t===i.NORTH||t===i.NORTH_WEST}const X=[i.NORTH,i.EAST,i.SOUTH,i.WEST],Y=[i.NORTH_EAST,i.SOUTH_EAST,i.SOUTH_WEST,i.NORTH_WEST],Z=1e-5;export{D as almostEquals,j as checkIfTileInfoSupportedForView,E as enableInternalTerrainChecks,T as enableTerrainInternalChecks,S as enableTerrainWaterproofnessChecks,s as enableWaterproofnessTests,Z as eps,m as getLayerWithExtentRange,b as getTileInfoAndExtentFromWMTSLayer,v as getTiledLayerInfo,p as internalAssert,U as isBlendableLayerView,J as isEast,d as isElevationLayerView,R as isGroupLayerView,O as isImageryTileLayerView,N as isImageryTileRenderInfo,W as isMapTileLayerView,Q as isNorth,q as isNorthCorner,H as isProjectableRasterLayer,h as isRasterTileRenderInfo,K as isSouth,x as isSurfaceLayerView,L as isTextureTileRenderInfo,y as isTileLayerView,_ as isVectorTileLayerView,g as isVectorTilePerLayerInfo,A as isVectorTileRenderInfo,I as isWMTSLayerView,z as isWest,P as isWestCorner,k as lij2s,Y as neighborCornerIndices,X as neighborEdgeIndices,G as oppositeCorner,B as oppositeEdge,w as releaseTileData,V as test,C as useFetchTileForLayer,F as v32s,M as vtlAssumes256PixelSizeAsDefault,a as weakAssert};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{destroyMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as n}from"../../core/promiseUtils.js";import{createScreenPointArray as s}from"../../core/screenUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../layers/GraphicsLayer.js";import{makeDehydratedPoint as d}from"../../layers/graphics/dehydratedPoint.js";import{ViewingMode as h}from"../ViewingMode.js";import{SnappingVisualizer2D as l}from"../2d/interactive/SnappingVisualizer2D.js";import{createCoordinateHelper as c}from"../interactive/coordinateHelper.js";import{EditGeometry as m,Component as _}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as y}from"../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as u}from"../interactive/snapping/SnappingContext.js";import{SnappingOperation as g}from"../interactive/snapping/SnappingOperation.js";var v;let f=v=class extends t.EventedAccessor{constructor(e){super(e),this._hasZ=null,this._cursorScreenPoint=null,this._activePointerId=null,this._stagedVertexUnsnapped=null,this._lastVertexUnsnapped=null,this.interactiveUndoDisabled=!1,this.history=[],this.redoHistory=[],this.snapToScene=!1,this.view=null,this.elevationInfo=null,this.defaultZ=0,this._coordinateHelper=c(!!e.hasZ,!1,e.view.spatialReference),this._snappingManager=e.snappingManager,this._editGeometryOperations=new y(new m(e.editGeometryType??"polygon",this._coordinateHelper),h.Local),this._snappingGraphicsLayer=new p({id:v.SNAPPING_GRAPHICS_LAYER_ID,listMode:"hide",internal:!0}),this._snappingContext=new u({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:"mouse",visualizer:new l(this._snappingGraphicsLayer)}),this._activeComponent=new _(e.view.spatialReference,h.Local),this._editGeometryOperations.data.components.push(this._activeComponent)}normalizeCtorArgs(e){const t={...e};return delete t.editGeometryType,delete t.snappingManager,t}initialize(){this._snappingOperation=new g({view:this.view}),"2d"===this.view.type&&this.view.map.layers.add(this._snappingGraphicsLayer)}destroy(){this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy(),null!=this._snappingManager&&this._snappingManager.doneSnapping(),this._snappingOperation=r(this._snappingOperation),this._editGeometryOperations.destroy()}get _committedVertices(){return this._editGeometryOperations.data.components[0].vertices.map((e=>e.pos))}get vertices(){return null!=this._stagedVertex?[...this._committedVertices,this._coordinateHelper.pointToArray(this._stagedVertex)]:this._committedVertices}get hasZ(){return null!=this._hasZ?this._hasZ:"3d"===this.view.type}set hasZ(e){this._hasZ=e,this.notifyChange("hasZ")}get _stagedVertex(){return this._snappingOperation.stagedPoint}set _stagedVertex(e){this._snappingOperation.stagedPoint=i(e)}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this.canUndo&&this._editGeometryOperations.undo()}redo(){this.canRedo&&this._editGeometryOperations.redo()}getCoordsFromScreenPoint(e){const t=e&&this.screenToMap(e);return null==t?null:t.hasZ?[t.x,t.y,t.z]:[t.x,t.y]}getCoordsAndPointFromScreenPoint(e){const t=this.screenToMap(e);return null==t?null:t.hasZ?{vertex:[t.x,t.y,t.z],mapPoint:t}:{vertex:[t.x,t.y],mapPoint:t}}screenToMap(e){let t=null;if("3d"===this.view.type)if(this.hasZ){const i=this.elevationInfo??x;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(s(e.x,e.y),i,this._getGeometryZValue())}else{const i=this.elevationInfo??G;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(s(e.x,e.y),i,0),null!=t&&(t.z=void 0)}else t=this.view.toMap(e),null!=t&&(t.z=this.hasZ?this._getGeometryZValue():void 0);return t}_pushCursorVertex(e,t){const i=d(e[0],e[1],void 0,this.view.spatialReference);this._stagedVertexUnsnapped=i;const r=this._snappingManager;if(null==r)return this._stagedVertex=i,void t();n(this._snappingOperation.snap({point:i},r,this._snappingContext)).then((()=>{t()}))}_popCursorVertex(){this._stagedVertexUnsnapped=null,this._stagedVertex=null}_getGeometryZValue(){return this.defaultZ}_abortSnapping(){this._snappingOperation.abort()}_isDuplicateOfLastVertex(e){const t=this._editGeometryOperations.data.components[0].getLastVertex()?.pos;if(t&&e[0]===t[0]&&e[1]===t[1])return!0;const{x:i,y:r}=this._coordinateHelper.vectorToDehydratedPoint(e);return null!=this._lastVertexUnsnapped&&i===this._lastVertexUnsnapped.x&&r===this._lastVertexUnsnapped.y}_shouldHandlePointerEvent(e){return this._isPrimaryPointerAction(e)&&(null==this._activePointerId||this._activePointerId===e.pointerId)}_vertexAddHandler(e){const t=null!=this._stagedVertex?this._coordinateHelper.pointToArray(this._stagedVertex):this.getCoordsFromScreenPoint(this._cursorScreenPoint);null!=t&&this._addVertex(t,e.native)}_drawCompleteHandler(e){this._completeDrawing(e.native)}_isPrimaryPointerAction(e){return"mouse"!==e.pointerType||0===e.button}};f.SNAPPING_GRAPHICS_LAYER_ID="DrawAction-snapping-graphics-layer",e([o({readOnly:!0})],f.prototype,"vertices",null),e([o({type:Boolean,nonNullable:!0})],f.prototype,"interactiveUndoDisabled",void 0),e([o({readOnly:!0})],f.prototype,"history",void 0),e([o({readOnly:!0})],f.prototype,"redoHistory",void 0),e([o()],f.prototype,"snapToScene",void 0),e([o()],f.prototype,"view",void 0),e([o()],f.prototype,"elevationInfo",void 0),e([o({nonNullable:!0})],f.prototype,"defaultZ",void 0),e([o()],f.prototype,"hasZ",null),e([o()],f.prototype,"_snappingOperation",void 0),e([o()],f.prototype,"_stagedVertex",null),f=v=e([a("esri.views.draw.DrawAction")],f);const x={mode:"absolute-height",offset:0},G={mode:"on-the-ground",offset:0},w=f;export{w as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{destroyMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as n}from"../../core/promiseUtils.js";import{createScreenPointArray as s}from"../../core/screenUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../layers/GraphicsLayer.js";import{makeDehydratedPoint as d}from"../../layers/graphics/dehydratedPoint.js";import{ViewingMode as l}from"../ViewingMode.js";import{SnappingVisualizer2D as h}from"../2d/interactive/SnappingVisualizer2D.js";import{createCoordinateHelper as c}from"../interactive/coordinateHelper.js";import{EditGeometry as m,Component as _}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as u}from"../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as y}from"../interactive/snapping/SnappingContext.js";import{SnappingOperation as g}from"../interactive/snapping/SnappingOperation.js";var v;let f=v=class extends t.EventedAccessor{constructor(e){super(e),this._hasZ=null,this._cursorScreenPoint=null,this._activePointerId=null,this._stagedVertexUnsnapped=null,this._lastVertexUnsnapped=null,this.interactiveUndoDisabled=!1,this.history=[],this.redoHistory=[],this.snapToScene=!1,this.view=null,this.elevationInfo=null,this.defaultZ=0,this._coordinateHelper=c(!!e.hasZ,!1,e.view.spatialReference),this._snappingManager=e.snappingManager,this._editGeometryOperations=new u(new m(e.editGeometryType??"polygon",this._coordinateHelper),l.Local),this._snappingGraphicsLayer=new p({id:v.SNAPPING_GRAPHICS_LAYER_ID,listMode:"hide",internal:!0}),this._snappingContext=new y({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:"mouse",visualizer:new h(this._snappingGraphicsLayer)}),this._activeComponent=new _(e.view.spatialReference,l.Local),this._editGeometryOperations.data.components.push(this._activeComponent)}normalizeCtorArgs(e){const t={...e};return delete t.editGeometryType,delete t.snappingManager,t}initialize(){this._snappingOperation=new g({view:this.view}),"2d"===this.view.type&&this.view.map.layers.add(this._snappingGraphicsLayer)}destroy(){this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy(),null!=this._snappingManager&&this._snappingManager.doneSnapping(),this._snappingOperation=r(this._snappingOperation),this._editGeometryOperations.destroy()}get _committedVertices(){return this._editGeometryOperations.data.components[0].vertices.map((e=>e.pos))}get vertices(){return null!=this._stagedVertex?[...this._committedVertices,this._coordinateHelper.pointToArray(this._stagedVertex)]:this._committedVertices}get hasZ(){return null!=this._hasZ?this._hasZ:"3d"===this.view.type}set hasZ(e){this._hasZ=e,this.notifyChange("hasZ")}get _stagedVertex(){return this._snappingOperation.stagedPoint}set _stagedVertex(e){this._snappingOperation.stagedPoint=i(e)}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this.canUndo&&this._editGeometryOperations.undo()}redo(){this.canRedo&&this._editGeometryOperations.redo()}getCoordsFromScreenPoint(e){const t=e&&this.screenToMap(e);return null==t?null:t.hasZ?[t.x,t.y,t.z]:[t.x,t.y]}getCoordsAndPointFromScreenPoint(e){const t=this.screenToMap(e);return null==t?null:t.hasZ?{vertex:[t.x,t.y,t.z],mapPoint:t}:{vertex:[t.x,t.y],mapPoint:t}}screenToMap(e){let t=null;if("3d"===this.view.type)if(this.hasZ){const i=this.elevationInfo??x;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(s(e.x,e.y),i,this._getGeometryZValue())}else{const i=this.elevationInfo??G;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(s(e.x,e.y),i,0),null!=t&&(t.z=void 0)}else t=this.view.toMap(e),null!=t&&(t.z=this.hasZ?this._getGeometryZValue():void 0);return t}_pushCursorVertex(e,t){const i=d(e[0],e[1],void 0,this.view.spatialReference);this._stagedVertexUnsnapped=i;const r=this._snappingManager;if(null==r)return this._stagedVertex=i,void t();n(this._snappingOperation.snap({point:i},r,this._snappingContext)).then((()=>{t()}))}_popCursorVertex(){this._stagedVertexUnsnapped=null,this._stagedVertex=null}_getGeometryZValue(){return this.defaultZ}_abortSnapping(){this._snappingOperation.abort()}_isDuplicateOfLastVertex(e){const t=this._editGeometryOperations.data.components[0].getLastVertex()?.pos;if(t&&e[0]===t[0]&&e[1]===t[1])return!0;const{x:i,y:r}=this._coordinateHelper.vectorToDehydratedPoint(e);return null!=this._lastVertexUnsnapped&&i===this._lastVertexUnsnapped.x&&r===this._lastVertexUnsnapped.y}_shouldHandlePointerEvent(e){return w(e)&&(null==this._activePointerId||this._activePointerId===e.pointerId)}_vertexAddHandler(e){const t=null!=this._stagedVertex?this._coordinateHelper.pointToArray(this._stagedVertex):this.getCoordsFromScreenPoint(this._cursorScreenPoint);null!=t&&this._addVertex(t,e.native)}_drawCompleteHandler(e){this._completeDrawing(e.native)}};f.SNAPPING_GRAPHICS_LAYER_ID="DrawAction-snapping-graphics-layer",e([o({readOnly:!0})],f.prototype,"vertices",null),e([o({type:Boolean,nonNullable:!0})],f.prototype,"interactiveUndoDisabled",void 0),e([o({readOnly:!0})],f.prototype,"history",void 0),e([o({readOnly:!0})],f.prototype,"redoHistory",void 0),e([o()],f.prototype,"snapToScene",void 0),e([o()],f.prototype,"view",void 0),e([o()],f.prototype,"elevationInfo",void 0),e([o({nonNullable:!0})],f.prototype,"defaultZ",void 0),e([o()],f.prototype,"hasZ",null),e([o()],f.prototype,"_snappingOperation",void 0),e([o()],f.prototype,"_stagedVertex",null),f=v=e([a("esri.views.draw.DrawAction")],f);const x={mode:"absolute-height",offset:0},G={mode:"on-the-ground",offset:0};function w(e){return"mouse"!==e.pointerType||0===e.button}const V=f;export{V 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../Graphic.js";import i from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as _}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as d}from"../../../geometry/support/coordsUtils.js";import m from"../../../geometry/support/rotate.js";import u from"../../../symbols/SimpleFillSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import v from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as y,scale as f,getRotationAngle as G,getScaleRatio as b}from"./drawUtils.js";import w from"./GraphicMover.js";import x from"./HighlightHelper.js";import{addUniqueLayer as S}from"./layerUtils.js";import{settings as k}from"./settings.js";import R from"../../interactive/sketch/SketchOptions.js";import{ExtentRotateTooltipInfo as M,ExtentScaleTooltipInfo as H}from"../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as I}from"../../interactive/tooltip/Tooltip.js";import{TranslateTooltipInfo as C}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoDistanceBetweenPoints2D as O}from"../../support/automaticLengthMeasurementUtils.js";import{autoSize2D as j}from"../../support/extentUtils.js";import T from"../../../geometry/Point.js";import E from"../../../geometry/Polygon.js";import L from"../../../geometry/Polyline.js";class z{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-start"}}class P{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move"}}class B{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-stop"}}class Y{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-start"}}class N{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate"}}class U{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-stop"}}class A{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-start"}}class X{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale"}}class F{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-stop"}}const D=k.transformGraphics,V={centerIndicator:new v({style:"cross",size:D.center.size,color:D.center.color}),fill:{default:new u({color:D.fill.color,outline:{color:D.fill.outlineColor,join:"round",width:1}}),active:new u({color:D.fill.stagedColor,outline:{color:D.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new v({style:"square",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"square",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotator:{default:new v({style:"circle",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"circle",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotatorLine:new g({color:D.line.color,width:1})};let q=class extends i.EventedAccessor{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=V,this.sketchOptions=new R,this.view=null,this._getBounds=(()=>{const t=p();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("multipoint"===s.type){const e=d(s);[i,o,r,a]=_(t,[e])}else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=d(s);[i,o,r,a]=_(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new x({view:t}),this.tooltip=new I({view:t}),this._setup(),this.addHandles([r((()=>t?.ready),(()=>{const{layer:t,view:e}=this;S(e,t)}),{once:!0,initial:!0}),a((()=>this.preserveAspectRatio),(()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))})),a((()=>t?.scale),(()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()})),a((()=>this.graphics),(()=>this.refresh())),a((()=>this.layer),((t,e)=>{e&&this._resetGraphics(e),this.refresh()})),a((()=>this.highlightsEnabled),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),a((()=>this.sketchOptions.tooltips.effectiveEnabled),(t=>{this.tooltip=t?new I({view:this.view}):s(this.tooltip)}),h),a((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),c),this.on("move-start",(t=>this.callbacks?.onMoveStart?.(t))),this.on("move",(t=>this.callbacks?.onMove?.(t))),this.on("move-stop",(t=>this.callbacks?.onMoveStop?.(t))),this.on("rotate-start",(t=>this.callbacks?.onRotateStart?.(t))),this.on("rotate",(t=>this.callbacks?.onRotate?.(t))),this.on("rotate-stop",(t=>this.callbacks?.onRotateStop?.(t))),this.on("scale-start",(t=>this.callbacks?.onScaleStart?.(t))),this.on("scale",(t=>this.callbacks?.onScale?.(t))),this.on("scale-stop",(t=>this.callbacks?.onScaleStop?.(t)))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=y(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",new B(this.graphics,null,t,e))}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",new F(this.graphics,null,t,e))}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new T(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=m(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",new U(this.graphics,null,t))}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach((t=>!t.destroyed&&t.destroy())),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,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)}})}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(p()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map((t=>this._getGraphicInfo(t)))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(p(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h}=this,c=t.graphic;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,t.viewEvent),c===a?(this.view.cursor="grabbing",this.emit("rotate-start",new Y(this.graphics,c,e))):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",new A(this.graphics,c,i,s))):this.emit("move-start",new z(this.graphics,c,t.dx,t.dy))}_onGraphicMoveCallback(t){const e=t.graphic;if(this._startInfo)if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",new X(this.graphics,e,this._xScale,this._yScale));else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",new N(this.graphics,e,this._angleOfRotation));else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",new P(this.graphics,e,i,s))}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c}=this;this.refresh(),e===c?(this.view.cursor="pointer",this.emit("rotate-stop",new U(this.graphics,e,i))):h.includes(e)?this.emit("scale-stop",new F(this.graphics,e,r,a)):this.emit("move-stop",new B(this.graphics,e,s,o))}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,a.cursor="pointer",void this._updateTooltip(h);if(s.includes(h)||h===e)return void(a.cursor="move");if(!i.includes(h))return void(a.cursor="pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}a.cursor=n}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s,view:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),o.cursor="default",this._updateTooltip()}_toPrecision(t,e=2){return Number.parseFloat(t.toFixed(e))}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:p}=e,{resolution:_,transform:d}=o.state,m=i.indexOf(t);1!==m&&5!==m||this._updateX(t,r),3!==m&&7!==m||this._updateY(t,a);const{x:u,y:g}=t.geometry,v=d[0]*u+d[2]*g+d[4],G=d[1]*u+d[3]*g+d[5],w=h?.map((t=>t.geometry))??[],x=w.every((t=>"point"===t.type));if((0===p||0===c)&&x){const t=this._toPrecision((u-n)/_),i=this._toPrecision((l-g)/_);for(let e=0;e<w.length;e++)this.graphics[e].geometry=y(w[e],t,i,o,!0);return this._centerGraphic.geometry=new T(u,g,o.spatialReference),void(this._backgroundGraphic.geometry=y(e.box,t,i,o,!0))}if(s){const t=this._toPrecision(d[0]*r+d[2]*a+d[4],2),e=this._toPrecision(d[1]*r+d[3]*a+d[5],2),i=this._toPrecision(d[0]*n+d[2]*l+d[4],2),s=this._toPrecision(d[1]*n+d[3]*l+d[5],2);let o=b(t,e,i,s,v,G);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of w){const t=w.indexOf(h);this.graphics[t].geometry=f(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=u-n,i=l-g;if(1===m||5===m?t=0:3!==m&&7!==m||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let d=(p+(n>r?t:-1*t))/p,v=(c+(l<a?i:-1*i))/c;1!==m&&5!==m&&0!==d&&Math.abs(d)!==1/0||(d=1),3!==m&&7!==m&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=d,this._yScale=v;const G=(s-r)/_,b=(h-a)/_,x=f(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=y(x,G,b,o,!0);const{centerX:S,centerY:k}=this._getGraphicInfo(this._backgroundGraphic),R=(S-r)/_,M=-1*(k-a)/_;for(const e of w){const t=w.indexOf(e),i=f(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=y(i,R,M,o,!0)}this._centerGraphic.geometry=new T(S,k,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new T(s,o,h),n=new T(e,i,h),l=t.geometry;this._angleOfRotation=G(c,l,n);const p=this._startInfo.graphicInfos?.map((t=>t.geometry))??[];for(const _ of p){const t=p.indexOf(_),e=m(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=m(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=m(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=y(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=y(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e(null,i.centerIndicator,t),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e(null,i.fill.default,t),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e(null,i.rotatorLine,t),this._rotateHandleGraphic=new e(null,i.rotator.default,t),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e(null,i.handles.default,t));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach((t=>t.visible=!1))}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach(((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)}))}_updateBackgroundGraphic(){const t=this._getCoordinates();this._backgroundGraphic.geometry=new E({rings:t,spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(p()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new T(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new T(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new L({paths:[[t.x,t.y],[e.x,e.y]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new T(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new T(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new T(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some((t=>null!=t?.geometry&&"extent"===t.geometry.type))}_getBoxBounds(t){const e=this.graphics.map((t=>t.geometry));return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(p());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new M({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s,view:o}=this;if(null==t)return;const r=this._getCoordinates(),a=j({topLeft:r[0],topRight:r[1],bottomRight:r[2],bottomLeft:r[3],spatialReference:o.spatialReference});if(null==a)return;const{xSize:h,ySize:c}=a,n=Math.abs(e),l=Math.abs(i);t.info=new H({sketchOptions:s,xScale:n,yScale:l,xSize:h,ySize:c})}_updateMoveTooltip(t){const{tooltip:e,sketchOptions:i,view:s}=this;if(null==e)return;const r=new C({sketchOptions:i});if(t){const{x:e,y:i}=t.origin,a=s.toMap(t),h=s.toMap({x:e,y:i}),c=O(h,a);r.distance=null!=c?c:o}e.info=r}};t([n()],q.prototype,"tooltip",void 0),t([n({readOnly:!0})],q.prototype,"type",void 0),t([n()],q.prototype,"callbacks",void 0),t([n()],q.prototype,"enableMovement",void 0),t([n()],q.prototype,"enableRotation",void 0),t([n()],q.prototype,"enableScaling",void 0),t([n()],q.prototype,"graphics",void 0),t([n()],q.prototype,"highlightsEnabled",void 0),t([n()],q.prototype,"layer",void 0),t([n()],q.prototype,"preserveAspectRatio",void 0),t([n()],q.prototype,"showCenterGraphic",void 0),t([n({readOnly:!0})],q.prototype,"state",null),t([n()],q.prototype,"symbols",void 0),t([n({type:R})],q.prototype,"sketchOptions",void 0),t([n({constructOnly:!0})],q.prototype,"view",void 0),q=t([l("esri.views.draw.support.Box")],q);const J=q;export{J as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../Graphic.js";import i from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as _}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as d}from"../../../geometry/support/coordsUtils.js";import m from"../../../geometry/support/rotate.js";import u from"../../../symbols/SimpleFillSymbol.js";import g from"../../../symbols/SimpleLineSymbol.js";import v from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as y,scale as f,getRotationAngle as G,getScaleRatio as b}from"./drawUtils.js";import w from"./GraphicMover.js";import x from"./HighlightHelper.js";import{addUniqueLayer as S}from"./layerUtils.js";import{settings as k}from"./settings.js";import R from"../../interactive/sketch/SketchOptions.js";import{ExtentRotateTooltipInfo as M,ExtentScaleTooltipInfo as H}from"../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as I}from"../../interactive/tooltip/Tooltip.js";import{TranslateTooltipInfo as C}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoDistanceBetweenPoints2D as O}from"../../support/automaticLengthMeasurementUtils.js";import{autoSize2D as j}from"../../support/extentUtils.js";import T from"../../../geometry/Point.js";import E from"../../../geometry/Polygon.js";import L from"../../../geometry/Polyline.js";class z{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-start"}}class B{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move"}}class Y{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.dx=i,this.dy=s,this.type="move-stop"}}class N{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-start"}}class U{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate"}}class A{constructor(t,e,i){this.graphics=t,this.mover=e,this.angle=i,this.type="rotate-stop"}}class P{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-start"}}class X{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale"}}class F{constructor(t,e,i,s){this.graphics=t,this.mover=e,this.xScale=i,this.yScale=s,this.type="scale-stop"}}const D=k.transformGraphics,V={centerIndicator:new v({style:"cross",size:D.center.size,color:D.center.color}),fill:{default:new u({color:D.fill.color,outline:{color:D.fill.outlineColor,join:"round",width:1}}),active:new u({color:D.fill.stagedColor,outline:{color:D.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new v({style:"square",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"square",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotator:{default:new v({style:"circle",size:D.vertex.size,color:D.vertex.color,outline:{color:D.vertex.outlineColor,width:1}}),hover:new v({style:"circle",size:D.vertex.hoverSize,color:D.vertex.hoverColor,outline:{color:D.vertex.hoverOutlineColor,width:1}})},rotatorLine:new g({color:D.line.color,width:1})};let q=class extends i.EventedAccessor{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=V,this.sketchOptions=new R,this.view=null,this._getBounds=(()=>{const t=p();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("multipoint"===s.type){const e=d(s);[i,o,r,a]=_(t,[e])}else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=d(s);[i,o,r,a]=_(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new x({view:t}),this.tooltip=new I({view:t}),this._setup(),this.addHandles([r((()=>t?.ready),(()=>{const{layer:t,view:e}=this;S(e,t)}),{once:!0,initial:!0}),a((()=>this.preserveAspectRatio),(()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))})),a((()=>t?.scale),(()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()})),a((()=>this.graphics),(()=>this.refresh())),a((()=>this.layer),((t,e)=>{e&&this._resetGraphics(e),this.refresh()})),a((()=>this.highlightsEnabled),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),a((()=>this.sketchOptions.tooltips.effectiveEnabled),(t=>{this.tooltip=t?new I({view:this.view}):s(this.tooltip)}),h),a((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),c),this.on("move-start",(t=>this.callbacks?.onMoveStart?.(t))),this.on("move",(t=>this.callbacks?.onMove?.(t))),this.on("move-stop",(t=>this.callbacks?.onMoveStop?.(t))),this.on("rotate-start",(t=>this.callbacks?.onRotateStart?.(t))),this.on("rotate",(t=>this.callbacks?.onRotate?.(t))),this.on("rotate-stop",(t=>this.callbacks?.onRotateStop?.(t))),this.on("scale-start",(t=>this.callbacks?.onScaleStart?.(t))),this.on("scale",(t=>this.callbacks?.onScale?.(t))),this.on("scale-stop",(t=>this.callbacks?.onScaleStop?.(t)))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=y(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",new Y(this.graphics,null,t,e))}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",new F(this.graphics,null,t,e))}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new T(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=m(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",new A(this.graphics,null,t))}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach((t=>!t.destroyed&&t.destroy())),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,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)}})}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(p()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map((t=>this._getGraphicInfo(t)))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(p(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h}=this,c=t.graphic;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,t.viewEvent),c===a?(this.view.cursor="grabbing",this.emit("rotate-start",new N(this.graphics,c,e))):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",new P(this.graphics,c,i,s))):this.emit("move-start",new z(this.graphics,c,t.dx,t.dy))}_onGraphicMoveCallback(t){const e=t.graphic;if(this._startInfo)if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",new X(this.graphics,e,this._xScale,this._yScale));else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",new U(this.graphics,e,this._angleOfRotation));else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",new B(this.graphics,e,i,s))}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c}=this;this.refresh(),e===c?(this.view.cursor="pointer",this.emit("rotate-stop",new A(this.graphics,e,i))):h.includes(e)?this.emit("scale-stop",new F(this.graphics,e,r,a)):this.emit("move-stop",new Y(this.graphics,e,s,o))}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,a.cursor="pointer",void this._updateTooltip(h);if(s.includes(h)||h===e)return void(a.cursor="move");if(!i.includes(h))return void(a.cursor="pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}a.cursor=n}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s,view:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),o.cursor="default",this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:p}=e,{resolution:_,transform:d}=o.state,m=i.indexOf(t);1!==m&&5!==m||this._updateX(t,r),3!==m&&7!==m||this._updateY(t,a);const{x:u,y:g}=t.geometry,v=d[0]*u+d[2]*g+d[4],G=d[1]*u+d[3]*g+d[5],w=h?.map((t=>t.geometry))??[],x=w.every((t=>"point"===t.type));if((0===p||0===c)&&x){const t=J((u-n)/_),i=J((l-g)/_);for(let e=0;e<w.length;e++)this.graphics[e].geometry=y(w[e],t,i,o,!0);return this._centerGraphic.geometry=new T(u,g,o.spatialReference),void(this._backgroundGraphic.geometry=y(e.box,t,i,o,!0))}if(s){const t=J(d[0]*r+d[2]*a+d[4],2),e=J(d[1]*r+d[3]*a+d[5],2),i=J(d[0]*n+d[2]*l+d[4],2),s=J(d[1]*n+d[3]*l+d[5],2);let o=b(t,e,i,s,v,G);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of w){const t=w.indexOf(h);this.graphics[t].geometry=f(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=u-n,i=l-g;if(1===m||5===m?t=0:3!==m&&7!==m||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let d=(p+(n>r?t:-1*t))/p,v=(c+(l<a?i:-1*i))/c;1!==m&&5!==m&&0!==d&&Math.abs(d)!==1/0||(d=1),3!==m&&7!==m&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=d,this._yScale=v;const G=(s-r)/_,b=(h-a)/_,x=f(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=y(x,G,b,o,!0);const{centerX:S,centerY:k}=this._getGraphicInfo(this._backgroundGraphic),R=(S-r)/_,M=-1*(k-a)/_;for(const e of w){const t=w.indexOf(e),i=f(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=y(i,R,M,o,!0)}this._centerGraphic.geometry=new T(S,k,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new T(s,o,h),n=new T(e,i,h),l=t.geometry;this._angleOfRotation=G(c,l,n);const p=this._startInfo.graphicInfos?.map((t=>t.geometry))??[];for(const _ of p){const t=p.indexOf(_),e=m(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=m(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=m(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=y(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=y(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=y(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e(null,i.centerIndicator,t),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e(null,i.fill.default,t),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e(null,i.rotatorLine,t),this._rotateHandleGraphic=new e(null,i.rotator.default,t),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e(null,i.handles.default,t));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach((t=>t.visible=!1))}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach(((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)}))}_updateBackgroundGraphic(){const t=this._getCoordinates();this._backgroundGraphic.geometry=new E({rings:t,spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(p()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new T(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new T(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new L({paths:[[t.x,t.y],[e.x,e.y]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new T(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new T(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new T(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some((t=>null!=t?.geometry&&"extent"===t.geometry.type))}_getBoxBounds(t){const e=this.graphics.map((t=>t.geometry));return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(p());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new M({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s,view:o}=this;if(null==t)return;const r=this._getCoordinates(),a=j({topLeft:r[0],topRight:r[1],bottomRight:r[2],bottomLeft:r[3],spatialReference:o.spatialReference});if(null==a)return;const{xSize:h,ySize:c}=a,n=Math.abs(e),l=Math.abs(i);t.info=new H({sketchOptions:s,xScale:n,yScale:l,xSize:h,ySize:c})}_updateMoveTooltip(t){const{tooltip:e,sketchOptions:i,view:s}=this;if(null==e)return;const r=new C({sketchOptions:i});if(t){const{x:e,y:i}=t.origin,a=s.toMap(t),h=s.toMap({x:e,y:i}),c=O(h,a);r.distance=null!=c?c:o}e.info=r}};function J(t,e=2){return Number.parseFloat(t.toFixed(e))}t([n()],q.prototype,"tooltip",void 0),t([n({readOnly:!0})],q.prototype,"type",void 0),t([n()],q.prototype,"callbacks",void 0),t([n()],q.prototype,"enableMovement",void 0),t([n()],q.prototype,"enableRotation",void 0),t([n()],q.prototype,"enableScaling",void 0),t([n()],q.prototype,"graphics",void 0),t([n()],q.prototype,"highlightsEnabled",void 0),t([n()],q.prototype,"layer",void 0),t([n()],q.prototype,"preserveAspectRatio",void 0),t([n()],q.prototype,"showCenterGraphic",void 0),t([n({readOnly:!0})],q.prototype,"state",null),t([n()],q.prototype,"symbols",void 0),t([n({type:R})],q.prototype,"sketchOptions",void 0),t([n({constructOnly:!0})],q.prototype,"view",void 0),q=t([l("esri.views.draw.support.Box")],q);const K=q;export{K as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as i}from"../../../chunks/tslib.es6.js";import"../../../symbols.js";import t from"../../../core/Evented.js";import{clone as e}from"../../../core/lang.js";import{watch as s,when as r}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../../layers/GraphicsLayer.js";import{cloneMove as c}from"./drawUtils.js";import n from"./HighlightHelper.js";import{addUniqueLayer as l,findLayerView as p}from"./layerUtils.js";import{GraphicClickEvent as d,GraphicDoubleClickEvent as g,GraphicPointerDownEvent as v,GraphicPointerUpEvent as m,GraphicPointerOutEvent as _,GraphicMoveStartEvent as y,GraphicMoveEvent as u,GraphicMoveStopEvent as f,GraphicPointerOverEvent as G}from"./input/GraphicMoverEvents.js";import{ViewEventPriorities as w}from"../../input/InputManager.js";import{GraphicManipulator as b}from"../../interactive/GraphicManipulator.js";import{createScreenPointFromEvent as k}from"../../support/screenUtils.js";import O from"../../../symbols/SimpleMarkerSymbol.js";import x from"../../../symbols/SimpleLineSymbol.js";import H from"../../../symbols/SimpleFillSymbol.js";const M="indicator-symbols";let E=class extends t.EventedAccessor{constructor(i){super(i),this._activeGraphic=null,this._dragEvent=null,this._hoverGraphic=null,this._indicators=[],this._initialDragGeometry=null,this._manipulators=[],this._layerViews=null,this.type="graphic-mover",this.callbacks={onGraphicClick(){},onGraphicDoubleClick(){},onGraphicMoveStart(){},onGraphicMove(){},onGraphicMoveStop(){},onGraphicPointerOver(){},onGraphicPointerOut(){},onGraphicPointerDown(){},onGraphicPointerUp(){}},this.enableMoveAllGraphics=!1,this.graphics=[],this.indicatorsEnabled=!1,this.layer=new a({listMode:"hide",internal:!0,title:"GraphicMover highlight layer"}),this.view=null}initialize(){l(this.view,this.layer),this._highlightHelper=new n({view:this.view}),this.refresh(),this.addHandles([s((()=>this.graphics.length),(()=>this.refresh())),r((()=>this.view?.ready),(()=>{this.addHandles([this.view.on("immediate-click",(i=>this._clickHandler(i)),w.TOOL),this.view.on("double-click",(i=>this._doubleClickHandler(i)),w.TOOL),this.view.on("pointer-down",(i=>this._pointerDownHandler(i)),w.TOOL),this.view.on("pointer-move",(i=>this._pointerMoveHandler(i)),w.TOOL),this.view.on("pointer-up",(i=>this._pointerUpHandler(i)),w.TOOL),this.view.on("drag",(i=>this._dragHandler(i)),w.TOOL),this.view.on("key-down",(i=>this._keyDownHandler(i)),w.TOOL)])}),{once:!0,initial:!0}),s((()=>this.view),(i=>{this._highlightHelper.removeAll(),this._highlightHelper.view=i}))])}destroy(){this._removeIndicators(),this.view.map?.remove(this.layer),this.layer.destroy(),this.reset(),this._manipulators.forEach((i=>i.destroy())),this._manipulators=null}set highlightsEnabled(i){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",i),i&&this._highlightHelper?.add(this.graphics)}get state(){const i=this.view.ready,t=this.graphics.length>0,e=this._activeGraphic;return i&&t?e?"moving":"active":i?"ready":"disabled"}refresh(){this.reset(),this._setup()}reset(){this._activeGraphic=null,this._hoverGraphic=null,this._dragEvent=null,this._highlightHelper.removeAll()}updateGeometry(i,t){const e=this.graphics[i];e&&(e.set("geometry",t),this._setUpIndicators())}_setup(){this._setUpHighlights(),this._setUpIndicators(),this._setUpManipulators(),this._syncLayerViews()}_clickHandler(i){const t=this._findTargetGraphic(k(i));if(t){const e=new d(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e)}}_doubleClickHandler(i){const t=this._findTargetGraphic(k(i));if(t){const e=new g(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-double-click",e),this.callbacks.onGraphicDoubleClick&&this.callbacks.onGraphicDoubleClick(e)}}_pointerDownHandler(i){const t=this._findTargetGraphic(k(i));if(t){this._activeGraphic=t;const{x:e,y:s}=i,r=new v(t,this.graphics.indexOf(t),e,s,i);this.emit("graphic-pointer-down",r),this.callbacks.onGraphicPointerDown&&this.callbacks.onGraphicPointerDown(r)}else this._activeGraphic=null}_pointerUpHandler(i){if(this._activeGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._activeGraphic),r=new m(this._activeGraphic,s,t,e,i);this.emit("graphic-pointer-up",r),this.callbacks.onGraphicPointerUp&&this.callbacks.onGraphicPointerUp(r)}}_pointerMoveHandler(i){if(this._dragEvent)return;const t=this._findTargetGraphic(k(i));if(t){const{x:e,y:s}=i;if(this._hoverGraphic){if(this._hoverGraphic===t)return;const r=this.graphics.indexOf(this._hoverGraphic),o=new _(this.graphics[r],r,e,s,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",o),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(o)}const r=this.graphics.indexOf(t),o=new G(t,r,e,s,i);return this._hoverGraphic=t,this.emit("graphic-pointer-over",o),void(this.callbacks.onGraphicPointerOver&&this.callbacks.onGraphicPointerOver(o))}if(this._hoverGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._hoverGraphic),r=new _(this.graphics[s],s,t,e,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",r),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(r)}}_dragHandler(i){if("start"!==i.action&&!this._dragEvent||!this._activeGraphic?.geometry)return;"start"===i.action&&this._removeIndicators(),i.stopPropagation();const{action:t,x:s,y:r}=i,o=this.graphics.indexOf(this._activeGraphic),h=this._dragEvent?s-this._dragEvent.x:0,a=this._dragEvent?r-this._dragEvent.y:0,n=s-i.origin.x,l=r-i.origin.y,p="start"===t?this._activeGraphic.geometry:this._initialDragGeometry,d=c(p,n,l,this.view);if(this._activeGraphic.geometry=d,this.enableMoveAllGraphics&&this.graphics.forEach((i=>{i!==this._activeGraphic&&(i.geometry=c(i.geometry,h,a,this.view))})),this._dragEvent=i,"start"===t){this._initialDragGeometry=e(p);const t=new y(this._activeGraphic,this.graphics,o,s,r,h,a,n,l,i);this.emit("graphic-move-start",t),this.callbacks.onGraphicMoveStart&&this.callbacks.onGraphicMoveStart(t),t.defaultPrevented&&this._activeGraphic.set("geometry",p)}else if("update"===t){const t=new u(this._activeGraphic,this.graphics,o,s,r,h,a,n,l,i);this.emit("graphic-move",t),this.callbacks.onGraphicMove&&this.callbacks.onGraphicMove(t),t.defaultPrevented&&(this._activeGraphic.geometry=p)}else{const t=new f(this._activeGraphic,this.graphics,o,s,r,h,a,n,l,i);this._dragEvent=null,this._activeGraphic=null,this._setUpIndicators(),this.emit("graphic-move-stop",t),this.callbacks.onGraphicMoveStop&&this.callbacks.onGraphicMoveStop(t),t.defaultPrevented&&(this.graphics[o].set("geometry",this._initialDragGeometry),this._setUpIndicators()),this._initialDragGeometry=null}}_keyDownHandler(i){"a"!==i.key&&"d"!==i.key&&"n"!==i.key||"moving"!==this.state||i.stopPropagation()}_findTargetGraphic(i){const t=this.view.toMap(i),e=this.graphics;let s=null,r=Number.MAX_VALUE;this._syncLayerViews();const o=this._layerViews.flatMap((i=>"graphicsViews"in i?Array.from(i.graphicsViews(),(i=>i.hitTest(t))).flat():i.graphicsView.hitTest(t))).filter((i=>e.includes(i))).sort(((i,t)=>e.indexOf(i)-e.indexOf(t)));return o.length?o[0]:(this._manipulators.forEach((t=>{const e=t.intersectionDistance(i);null!=e&&e<r&&(r=e,s=t.graphic)})),s)}_syncLayerViews(){this._layerViews=[];const i=new Set;for(const t of this.graphics){const e=p(this.view,t.layer);e&&i.add(e)}this._layerViews=[...i]}_setUpManipulators(){const{graphics:i,view:t}=this;this._manipulators.forEach((i=>i.destroy())),this._manipulators=i.length?i.map((i=>new b({graphic:i,view:t}))):[]}_setUpHighlights(){this.highlightsEnabled&&this._highlightHelper.add(this.graphics)}_setUpIndicators(){if(this._removeIndicators(),this.indicatorsEnabled){for(const i of this.graphics){const t=i.clone();t.symbol=this._getSymbolForIndicator(i),this._indicators.push(t),this.addHandles(s((()=>i.symbol),(()=>this._setUpIndicators())),M)}this.layer.addMany(this._indicators)}}_removeIndicators(){this.removeHandles(M),this._indicators.length&&(this.layer.removeMany(this._indicators),this._indicators.forEach((i=>i.destroy())),this._indicators=[])}_getSymbolForIndicator(i){const t=12;if(null==i.symbol)return null;switch(i.symbol.type){case"cim":return new O({style:"circle",size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}});case"picture-marker":{const{xoffset:t,yoffset:e,height:s,width:r}=i.symbol,o=s===r?r:Math.max(s,r);return new O({xoffset:t,yoffset:e,size:o,style:"square",color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-marker":{const{xoffset:t,yoffset:e,size:s,style:r}=i.symbol;return new O({xoffset:t,yoffset:e,style:"circle"===r?"circle":"square",size:s+2,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-fill":return new H({color:[0,0,0,0],outline:{style:"dash",color:[255,127,0,1],width:1}});case"simple-line":return new x({color:[255,127,0,1],style:"dash",width:1});case"text":{const{xoffset:e,yoffset:s}=i.symbol;return new O({xoffset:e,yoffset:s,size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}default:return null}}};i([o()],E.prototype,"_activeGraphic",void 0),i([o({readOnly:!0})],E.prototype,"type",void 0),i([o()],E.prototype,"callbacks",void 0),i([o()],E.prototype,"enableMoveAllGraphics",void 0),i([o()],E.prototype,"graphics",void 0),i([o({value:!1})],E.prototype,"highlightsEnabled",null),i([o()],E.prototype,"indicatorsEnabled",void 0),i([o()],E.prototype,"layer",void 0),i([o({readOnly:!0})],E.prototype,"state",null),i([o()],E.prototype,"view",void 0),E=i([h("esri.views.draw.support.GraphicMover")],E);const j=E;export{j as default};
5
+ import{_ as i}from"../../../chunks/tslib.es6.js";import"../../../symbols.js";import t from"../../../core/Evented.js";import{clone as e}from"../../../core/lang.js";import{watch as s,when as r}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../../layers/GraphicsLayer.js";import{cloneMove as c}from"./drawUtils.js";import n from"./HighlightHelper.js";import{addUniqueLayer as l,findLayerView as p}from"./layerUtils.js";import{GraphicClickEvent as d,GraphicDoubleClickEvent as g,GraphicPointerDownEvent as v,GraphicPointerUpEvent as m,GraphicPointerOutEvent as _,GraphicMoveStartEvent as y,GraphicMoveEvent as u,GraphicMoveStopEvent as f,GraphicPointerOverEvent as G}from"./input/GraphicMoverEvents.js";import{ViewEventPriorities as w}from"../../input/InputManager.js";import{GraphicManipulator as b}from"../../interactive/GraphicManipulator.js";import{createScreenPointFromEvent as k}from"../../support/screenUtils.js";import O from"../../../symbols/SimpleMarkerSymbol.js";import x from"../../../symbols/SimpleLineSymbol.js";import H from"../../../symbols/SimpleFillSymbol.js";const M="indicator-symbols";let E=class extends t.EventedAccessor{constructor(i){super(i),this._activeGraphic=null,this._dragEvent=null,this._hoverGraphic=null,this._indicators=[],this._initialDragGeometry=null,this._manipulators=[],this._layerViews=null,this.type="graphic-mover",this.callbacks={onGraphicClick(){},onGraphicDoubleClick(){},onGraphicMoveStart(){},onGraphicMove(){},onGraphicMoveStop(){},onGraphicPointerOver(){},onGraphicPointerOut(){},onGraphicPointerDown(){},onGraphicPointerUp(){}},this.enableMoveAllGraphics=!1,this.graphics=[],this.indicatorsEnabled=!1,this.layer=new a({listMode:"hide",internal:!0,title:"GraphicMover highlight layer"}),this.view=null}initialize(){l(this.view,this.layer),this._highlightHelper=new n({view:this.view}),this.refresh(),this.addHandles([s((()=>this.graphics.length),(()=>this.refresh())),r((()=>this.view?.ready),(()=>{this.addHandles([this.view.on("immediate-click",(i=>this._clickHandler(i)),w.TOOL),this.view.on("double-click",(i=>this._doubleClickHandler(i)),w.TOOL),this.view.on("pointer-down",(i=>this._pointerDownHandler(i)),w.TOOL),this.view.on("pointer-move",(i=>this._pointerMoveHandler(i)),w.TOOL),this.view.on("pointer-up",(i=>this._pointerUpHandler(i)),w.TOOL),this.view.on("drag",(i=>this._dragHandler(i)),w.TOOL),this.view.on("key-down",(i=>this._keyDownHandler(i)),w.TOOL)])}),{once:!0,initial:!0}),s((()=>this.view),(i=>{this._highlightHelper.removeAll(),this._highlightHelper.view=i}))])}destroy(){this._removeIndicators(),this.view.map?.remove(this.layer),this.layer.destroy(),this.reset(),this._manipulators.forEach((i=>i.destroy())),this._manipulators=null}set highlightsEnabled(i){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",i),i&&this._highlightHelper?.add(this.graphics)}get state(){const i=this.view.ready,t=this.graphics.length>0,e=this._activeGraphic;return i&&t?e?"moving":"active":i?"ready":"disabled"}refresh(){this.reset(),this._setup()}reset(){this._activeGraphic=null,this._hoverGraphic=null,this._dragEvent=null,this._highlightHelper.removeAll()}updateGeometry(i,t){const e=this.graphics[i];e&&(e.set("geometry",t),this._setUpIndicators())}_setup(){this._setUpHighlights(),this._setUpIndicators(),this._setUpManipulators(),this._syncLayerViews()}_clickHandler(i){const t=this._findTargetGraphic(k(i));if(t){const e=new d(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e)}}_doubleClickHandler(i){const t=this._findTargetGraphic(k(i));if(t){const e=new g(t,this.graphics.indexOf(t),i.x,i.y,i);this.emit("graphic-double-click",e),this.callbacks.onGraphicDoubleClick&&this.callbacks.onGraphicDoubleClick(e)}}_pointerDownHandler(i){const t=this._findTargetGraphic(k(i));if(t){this._activeGraphic=t;const{x:e,y:s}=i,r=new v(t,this.graphics.indexOf(t),e,s,i);this.emit("graphic-pointer-down",r),this.callbacks.onGraphicPointerDown&&this.callbacks.onGraphicPointerDown(r)}else this._activeGraphic=null}_pointerUpHandler(i){if(this._activeGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._activeGraphic),r=new m(this._activeGraphic,s,t,e,i);this.emit("graphic-pointer-up",r),this.callbacks.onGraphicPointerUp&&this.callbacks.onGraphicPointerUp(r)}}_pointerMoveHandler(i){if(this._dragEvent)return;const t=this._findTargetGraphic(k(i));if(t){const{x:e,y:s}=i;if(this._hoverGraphic){if(this._hoverGraphic===t)return;const r=this.graphics.indexOf(this._hoverGraphic),h=new _(this.graphics[r],r,e,s,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",h),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(h)}const r=this.graphics.indexOf(t),h=new G(t,r,e,s,i);return this._hoverGraphic=t,this.emit("graphic-pointer-over",h),void(this.callbacks.onGraphicPointerOver&&this.callbacks.onGraphicPointerOver(h))}if(this._hoverGraphic){const{x:t,y:e}=i,s=this.graphics.indexOf(this._hoverGraphic),r=new _(this.graphics[s],s,t,e,i);this._hoverGraphic=null,this.emit("graphic-pointer-out",r),this.callbacks.onGraphicPointerOut&&this.callbacks.onGraphicPointerOut(r)}}_dragHandler(i){if("start"!==i.action&&!this._dragEvent||!this._activeGraphic?.geometry)return;"start"===i.action&&this._removeIndicators(),i.stopPropagation();const{action:t,x:s,y:r}=i,h=this.graphics.indexOf(this._activeGraphic),o=this._dragEvent?s-this._dragEvent.x:0,a=this._dragEvent?r-this._dragEvent.y:0,n=s-i.origin.x,l=r-i.origin.y,p="start"===t?this._activeGraphic.geometry:this._initialDragGeometry,d=c(p,n,l,this.view);if(this._activeGraphic.geometry=d,this.enableMoveAllGraphics&&this.graphics.forEach((i=>{i!==this._activeGraphic&&(i.geometry=c(i.geometry,o,a,this.view))})),this._dragEvent=i,"start"===t){this._initialDragGeometry=e(p);const t=new y(this._activeGraphic,this.graphics,h,s,r,o,a,n,l,i);this.emit("graphic-move-start",t),this.callbacks.onGraphicMoveStart&&this.callbacks.onGraphicMoveStart(t),t.defaultPrevented&&this._activeGraphic.set("geometry",p)}else if("update"===t){const t=new u(this._activeGraphic,this.graphics,h,s,r,o,a,n,l,i);this.emit("graphic-move",t),this.callbacks.onGraphicMove&&this.callbacks.onGraphicMove(t),t.defaultPrevented&&(this._activeGraphic.geometry=p)}else{const t=new f(this._activeGraphic,this.graphics,h,s,r,o,a,n,l,i);this._dragEvent=null,this._activeGraphic=null,this._setUpIndicators(),this.emit("graphic-move-stop",t),this.callbacks.onGraphicMoveStop&&this.callbacks.onGraphicMoveStop(t),t.defaultPrevented&&(this.graphics[h].set("geometry",this._initialDragGeometry),this._setUpIndicators()),this._initialDragGeometry=null}}_keyDownHandler(i){"a"!==i.key&&"d"!==i.key&&"n"!==i.key||"moving"!==this.state||i.stopPropagation()}_findTargetGraphic(i){const t=this.view.toMap(i),e=this.graphics;let s=null,r=Number.MAX_VALUE;this._syncLayerViews();const h=this._layerViews.flatMap((i=>"graphicsViews"in i?Array.from(i.graphicsViews(),(i=>i.hitTest(t))).flat():i.graphicsView.hitTest(t))).filter((i=>e.includes(i))).sort(((i,t)=>e.indexOf(i)-e.indexOf(t)));return h.length?h[0]:(this._manipulators.forEach((t=>{const e=t.intersectionDistance(i);null!=e&&e<r&&(r=e,s=t.graphic)})),s)}_syncLayerViews(){this._layerViews=[];const i=new Set;for(const t of this.graphics){const e=p(this.view,t.layer);e&&i.add(e)}this._layerViews=[...i]}_setUpManipulators(){const{graphics:i,view:t}=this;this._manipulators.forEach((i=>i.destroy())),this._manipulators=i.length?i.map((i=>new b({graphic:i,view:t}))):[]}_setUpHighlights(){this.highlightsEnabled&&this._highlightHelper.add(this.graphics)}_setUpIndicators(){if(this._removeIndicators(),this.indicatorsEnabled){for(const i of this.graphics){const t=i.clone();t.symbol=j(i),this._indicators.push(t),this.addHandles(s((()=>i.symbol),(()=>this._setUpIndicators())),M)}this.layer.addMany(this._indicators)}}_removeIndicators(){this.removeHandles(M),this._indicators.length&&(this.layer.removeMany(this._indicators),this._indicators.forEach((i=>i.destroy())),this._indicators=[])}};function j(i){const t=12;if(null==i.symbol)return null;switch(i.symbol.type){case"cim":return new O({style:"circle",size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}});case"picture-marker":{const{xoffset:t,yoffset:e,height:s,width:r}=i.symbol,h=s===r?r:Math.max(s,r);return new O({xoffset:t,yoffset:e,size:h,style:"square",color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-marker":{const{xoffset:t,yoffset:e,size:s,style:r}=i.symbol;return new O({xoffset:t,yoffset:e,style:"circle"===r?"circle":"square",size:s+2,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}case"simple-fill":return new H({color:[0,0,0,0],outline:{style:"dash",color:[255,127,0,1],width:1}});case"simple-line":return new x({color:[255,127,0,1],style:"dash",width:1});case"text":{const{xoffset:e,yoffset:s}=i.symbol;return new O({xoffset:e,yoffset:s,size:t,color:[0,0,0,0],outline:{color:[255,127,0,1],width:1}})}default:return null}}i([h()],E.prototype,"_activeGraphic",void 0),i([h({readOnly:!0})],E.prototype,"type",void 0),i([h()],E.prototype,"callbacks",void 0),i([h()],E.prototype,"enableMoveAllGraphics",void 0),i([h()],E.prototype,"graphics",void 0),i([h({value:!1})],E.prototype,"highlightsEnabled",null),i([h()],E.prototype,"indicatorsEnabled",void 0),i([h()],E.prototype,"layer",void 0),i([h({readOnly:!0})],E.prototype,"state",null),i([h()],E.prototype,"view",void 0),E=i([o("esri.views.draw.support.GraphicMover")],E);const U=E;export{U as default};