@arcgis/core 5.0.0-next.30 → 5.0.0-next.31

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 (91) hide show
  1. package/Basemap.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{406d270ae2b3cf9e1f1b.js → 05e55118dc0023d500fc.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{93fe46be3c7fe34b5361.js → 1432e789aa4cba627337.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{6e9d731cb20307b83ab0.js → 1e55f152b60145f33b61.js} +1 -1
  6. package/assets/esri/core/workers/chunks/444026d1938c1078ca97.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a425ffec91d07bbfeb80.js → 565358ea8d1bdc4d1ebc.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d769c1b18e2710e0388b.js → a6324f5f560ffadc6e5d.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{a091623bbfb3d771c8d8.js → d8db2c51b2fb42f37b2a.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{984bb0943d07c86b7e77.js → ded3ef385d5a3a2ec8ca.js} +1 -1
  11. package/config.js +1 -1
  12. package/core/Message.js +1 -1
  13. package/geometry/Circle.js +1 -1
  14. package/geometry/Extent.js +1 -1
  15. package/geometry/geodesicUtils.js +5 -0
  16. package/geometry/support/geodesicUtils.js +1 -1
  17. package/interfaces.d.ts +427 -187
  18. package/kernel.js +1 -1
  19. package/layers/graphics/OptimizedGeometry.js +1 -1
  20. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  21. package/layers/knowledgeGraph/SessionMemoryStorage.js +1 -1
  22. package/layers/support/BuildingFilterBlock.js +1 -1
  23. package/package.json +2 -2
  24. package/rest/support/QueryMixin.js +1 -1
  25. package/support/revision.js +1 -1
  26. package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
  27. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementController.js +1 -1
  28. package/views/2d/grid/gridUtils.js +1 -1
  29. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  30. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  31. package/views/2d/layers/MediaLayerView2D.js +1 -1
  32. package/views/2d/layers/OGCFeatureLayerView2D.js +1 -1
  33. package/views/2d/layers/StreamLayerView2D.js +1 -1
  34. package/views/3d/GroundView3D.js +1 -1
  35. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  36. package/views/3d/environment/SceneViewEnvironment.js +1 -1
  37. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  38. package/views/3d/layers/DimensionLayerView3D.js +1 -1
  39. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  40. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  41. package/views/3d/layers/I3SMeshView3D.js +1 -1
  42. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  43. package/views/3d/layers/LineOfSightLayerView3D.js +1 -1
  44. package/views/3d/layers/MediaLayerView3D.js +1 -1
  45. package/views/3d/layers/OGCFeatureLayerView3D.js +1 -1
  46. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  47. package/views/3d/layers/StreamLayerView3D.js +1 -1
  48. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  49. package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
  50. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  51. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  52. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  53. package/views/SceneView.js +1 -1
  54. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  55. package/views/interactive/sketch/constraintUtils.js +1 -1
  56. package/views/interactive/sketch/constraints.js +1 -1
  57. package/views/layers/DimensionLayerView.js +1 -1
  58. package/views/layers/DimensionLayerViewMixin.js +5 -0
  59. package/views/layers/FeatureLayerView.js +1 -1
  60. package/views/layers/FeatureLayerViewMixin.d.ts +2 -2
  61. package/views/layers/FeatureLayerViewMixin.js +5 -0
  62. package/views/layers/ImageryLayerView.js +1 -1
  63. package/views/layers/ImageryLayerViewMixin.js +5 -0
  64. package/views/layers/LineOfSightLayerView.js +1 -1
  65. package/views/layers/LineOfSightLayerViewMixin.js +5 -0
  66. package/views/layers/MediaLayerView.js +1 -1
  67. package/views/layers/MediaLayerViewMixin.js +5 -0
  68. package/views/layers/OGCFeatureLayerView.js +1 -1
  69. package/views/layers/PointCloudLayerView.js +1 -1
  70. package/views/layers/StreamLayerView.js +1 -1
  71. package/views/layers/ViewshedLayerView.js +1 -1
  72. package/views/layers/ViewshedLayerViewMixin.js +5 -0
  73. package/views/support/LayerLayerViewInfo.js +1 -1
  74. package/views/support/PromiseQueue.js +1 -1
  75. package/views/support/angularMeasurementUtils.js +1 -1
  76. package/views/support/drapedUtils.js +1 -1
  77. package/views/support/geodesicAreaMeasurementUtils.js +1 -1
  78. package/views/support/geodesicLengthMeasurementUtils.js +1 -1
  79. package/views/support/geodesicMeasurementUtils.js +1 -1
  80. package/webscene/Environment.js +1 -1
  81. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  82. package/widgets/Attribution.js +1 -1
  83. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  84. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  85. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  86. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  87. package/widgets/Popup.js +1 -1
  88. package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
  89. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  90. package/widgets/support/forms/expressions/FormExpressionArcadeExecutor.js +1 -1
  91. package/assets/esri/core/workers/chunks/b66e41d626a7d1b81d48.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as t}from"../../core/compilerUtils.js";import e from"../../core/Error.js";import s from"../../core/Logger.js";import{isAborted as r,createAbortError as o,isPromiseLike as a,isAbortError as n}from"../../core/promiseUtils.js";import{signal as i}from"../../core/signal.js";import{Yield as c}from"./Yield.js";class l{constructor(){this._tasks=new Array,this._numPendingTasks=i(0),this._readyToRun=i(!1)}get length(){return this._tasks.length}get updating(){return this._numPendingTasks.value>0}get readyToRun(){return this._readyToRun.value}_updateReadyToRun(){this._readyToRun.value=this._tasks.length>0}destroy(){this.cancelAll()}runTask(t){if(0===this.length)return c;for(;!t.done&&this._process(t);)t.madeProgress()}push(t,e,s){return this._addTask((r,o)=>new d(r,o,t,e,s),Array.prototype.push)}unshift(t,e,s){return this._addTask((r,o)=>new d(r,o,t,e,s),Array.prototype.unshift)}pushGenerator(t,e,s){return this._addTask((r,o)=>new _(r,o,t,e,s),Array.prototype.push)}_process(e){if(0===this._tasks.length)return!1;const s=this._tasks.shift();this._updateReadyToRun();try{if(r(s.signal))this._cancelTask(s,o());else switch(s.type){case 0:this._processSimple(s,e);break;case 1:this._processGenerator(s,e);break;case 2:this._processIterator(s,e);break;default:t(s)}}catch(a){s.reject(a)}return!0}cancelAll(){const t=o();for(const e of this._tasks)this._cancelTask(e,t);this._tasks.length=0,this._updateReadyToRun()}_cancelTask(t,e){if(t.abortCallback){const s=t.abortCallback(e);2===t.type&&t.iterator.return&&h(t.iterator.return()),a(s)?s.then(t.resolve,t.reject):t.resolve(s)}else 2===t.type&&t.iterator.throw&&h(t.iterator.throw(e)),t.reject(e)}_onIteratorResult(t,e){e.done?t.resolve(e.value):(this._tasks.unshift(t),this._updateReadyToRun())}_processSimple(t,e){const s=t.callback(e);a(s)?s.then(t.resolve,t.reject):t.resolve(s)}_processGenerator(t,e){const s=t.generatorFunction(e),r=new k(t.resolve,t.reject,s,t.signal,t.abortCallback);this._processIterator(r,e)}_processIterator(t,e){const s=t.iterator.next(e);a(s)?s.then(e=>this._onIteratorResult(t,e),t.reject):this._onIteratorResult(t,s)}_addTask(t,e){return new Promise((s,r)=>{const o=t(s,r);e.call(this._tasks,o),++this._numPendingTasks.value,this._updateReadyToRun()}).finally(()=>--this._numPendingTasks.value)}}function h(t){a(t)?t.then(u,u):u(t)}function u(t){n(t)||t instanceof Error||t instanceof e||null!=t&&"object"==typeof t&&"done"in t&&t.done||s.getLogger("esri.layers.support.PromiseQueue").warn("Generator iterator was aborted, but it is not done.")}class p{constructor(t,e,s=void 0,r=void 0){this.resolve=t,this.reject=e,this.signal=s,this.abortCallback=r}}class d extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.callback=s,this.type=0}}class _ extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.generatorFunction=s,this.type=1}}class k extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.iterator=s,this.type=2}}export{l as PromiseQueue};
5
+ import{neverReached as t}from"../../core/compilerUtils.js";import e from"../../core/Error.js";import s from"../../core/Logger.js";import{isAborted as r,createAbortError as o,isPromiseLike as a,isAbortError as n}from"../../core/promiseUtils.js";import{signal as i}from"../../core/signal.js";import{Yield as c}from"./Yield.js";class l{constructor(){this._tasks=new Array,this._numPendingTasks=i(0),this._readyToRun=i(!1)}get length(){return this._tasks.length}get updating(){return this._numPendingTasks.value>0}get readyToRun(){return this._readyToRun.value}_updateReadyToRun(){this._readyToRun.value=this._tasks.length>0}destroy(){this.cancelAll()}runTask(t){if(0===this.length)return c;for(;!t.done&&this._process(t);)t.madeProgress()}push(t,e,s){return this._addTask((r,o)=>new d(r,o,t,e,s),Array.prototype.push)}unshift(t,e,s){return this._addTask((r,o)=>new d(r,o,t,e,s),Array.prototype.unshift)}pushGenerator(t,e,s){return this._addTask((r,o)=>new _(r,o,t,e,s),Array.prototype.push)}_process(e){if(0===this._tasks.length)return!1;const s=this._tasks.shift();this._updateReadyToRun();try{if(r(s.signal))this._cancelTask(s,o());else switch(s.type){case 0:this._processSimple(s,e);break;case 1:this._processGenerator(s,e);break;case 2:this._processIterator(s,e);break;default:t(s)}}catch(a){s.reject(a)}return!0}cancelAll(){const t=o();for(const e of this._tasks)this._cancelTask(e,t);this._tasks.length=0,this._updateReadyToRun()}_cancelTask(t,e){if(t.abortCallback){const s=t.abortCallback(e);2===t.type&&t.iterator.return&&h(t.iterator.return()),a(s)?s.then(t.resolve,t.reject):t.resolve(s)}else 2===t.type&&t.iterator.throw&&h(t.iterator.throw(e)),t.reject(e)}_onIteratorResult(t,e){e.done?t.resolve(e.value):(this._tasks.unshift(t),this._updateReadyToRun())}_processSimple(t,e){const s=t.callback(e);a(s)?s.then(t.resolve,t.reject):t.resolve(s)}_processGenerator(t,e){const s=t.generatorFunction(e),r=new k(t.resolve,t.reject,s,t.signal,t.abortCallback);this._processIterator(r,e)}_processIterator(t,e){const s=t.iterator.next(e);a(s)?s.then(e=>this._onIteratorResult(t,e),t.reject):this._onIteratorResult(t,s)}_addTask(t,e){return new Promise((s,r)=>{const o=t(s,r);e.call(this._tasks,o),++this._numPendingTasks.value,this._updateReadyToRun()}).finally(()=>--this._numPendingTasks.value)}}function h(t){a(t)?t.then(u,u):u(t)}function u(t){n(t)||t instanceof Error||t instanceof e||null!=t&&"object"==typeof t&&"done"in t&&t.done||s.getLogger("esri.layers.support.PromiseQueue").warn("Generator iterator was aborted, but it is not done.")}class p{constructor(t,e,s,r){this.resolve=t,this.reject=e,this.signal=s,this.abortCallback=r}}class d extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.callback=s,this.type=0}}class _ extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.generatorFunction=s,this.type=1}}class k extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.iterator=s,this.type=2}}export{l as PromiseQueue};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{cyclicalDegrees as e,Cyclical as r}from"../../core/Cyclical.js";import{createAngle as t,convertRotationType as o}from"../../core/quantity.js";import{convertUnit as i}from"../../core/units.js";import{angle as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as s,UNIT_Y as a}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{m as c,d as l,h as u}from"../../chunks/vec32.js";import{create as f}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as m}from"../../geometry/projection/projectVectorToVector.js";import{geodesicCompatibleSpatialReference as g,inverseGeodeticSolver as p,InverseGeodeticSolverResult as d,directGeodeticSolver as h}from"../../geometry/support/geodesicUtils.js";import{equals as v}from"../../geometry/support/spatialReferenceUtils.js";function j(e,r){if(null==e||null==r)return;const o=b(e,r);return null!=o?t(o,"radians","geographic"):void 0}const b=(()=>{const e=f(),r=f();return(t,o)=>(u(e,t.x,t.y,t.z??0),u(r,o.x,o.y,o.z??0),y(e,r,t.spatialReference,o.spatialReference))})(),y=(()=>{const e=s(),r=f(),t=f();return(o,s,l,u)=>{if(c(o,s))return;const f=g(l),d=g(u);if(f&&d&&v(f,d)&&m(o,l,r,f)&&m(s,u,t,d)){const{azimuth:e}=p(q,r,t,f);return null!=e?i(e,"degrees","radians"):void 0}e[0]=s[0]-o[0],e[1]=s[1]-o[1];let h=n(a,e);return e[0]<0&&(h=C-h),h}})();function x(e,r,t,o="absolute"){if(r&&t)switch(o){case"absolute":return j(r,t);case"relative":return w(z(e,r,t),"relative");case"relative-bilateral":return w(z(e,r,t),"relative-bilateral")}}function z(e,r,o){if(!e||!r||!o)return;const i=b(e,r),n=b(r,o);return null!=i&&null!=n?t(n-i,"radians","geographic"):void 0}function w(e,r){if(null!=e)switch(r){case"absolute":return M(e);case"relative":{const r=U(e);let o=P.normalize(r,0,!0);return-180===o&&(o=180),t(o,"degrees","geographic")}case"relative-bilateral":{const r=U(e),o=Math.abs(P.normalize(r,0,!0));return t(o,"degrees","geographic")}}}function M(e){const r=U(e),o=I.normalize(r,0,!0);return t(o,"degrees","geographic")}function T(e,r,n){let s=i(e.value,e.unit,"degrees");return s=o(s,e.rotationType,n),s=i(s,"degrees",r),t(s,r,n)}const R=(()=>{const e=f();return(r,t,n,s,a,c="geodesic")=>{l(e,t);const f=U(a);if("geodesic"===c){const o=g(n);if(o&&m(e,n,e,o))return h(r,e,f,s,o),r[2]=t[2],!!m(r,o,r,n)}const p=o(f,"geographic","arithmetic"),d=i(p,"degrees","radians"),v=t[0]+s*Math.cos(d),j=t[1]+s*Math.sin(d),b=t[2];return u(r,v,j,b),!0}})();function U(e){if(null!=e)return o(k(e),e.rotationType,"geographic")}function V(e){if(null!=e)return o(k(e),e.rotationType,"arithmetic")}function k(e){return i(e.value,e.unit,"degrees")}const q=new d,C=2*Math.PI,I=e,P=new r(-180,180);export{T as convertAngle,j as directionBetweenPoints,x as directionForVertices,V as getDegreesArithmetic,U as getDegreesGeographic,w as getNormalizedDirection,M as getNormalizedGeographicOrientation,R as pointFromDistanceAlongAzimuth,y as radiansGeographicBetweenVec};
5
+ import{cyclicalDegrees as e,Cyclical as r}from"../../core/Cyclical.js";import{createAngle as t,convertRotationType as o}from"../../core/quantity.js";import{convertUnit as i}from"../../core/units.js";import{angle as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as s,UNIT_Y as a}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{m as c,d as l,h as u}from"../../chunks/vec32.js";import{create as f}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{geodesicCompatibleSpatialReference as m,inverseGeodeticSolver as g,InverseGeodeticSolverResult as p,directGeodeticSolver as d}from"../../geometry/geodesicUtils.js";import{projectVectorToVector as h}from"../../geometry/projection/projectVectorToVector.js";import{equals as v}from"../../geometry/support/spatialReferenceUtils.js";function j(e,r){if(null==e||null==r)return;const o=b(e,r);return null!=o?t(o,"radians","geographic"):void 0}const b=(()=>{const e=f(),r=f();return(t,o)=>(u(e,t.x,t.y,t.z??0),u(r,o.x,o.y,o.z??0),y(e,r,t.spatialReference,o.spatialReference))})(),y=(()=>{const e=s(),r=f(),t=f();return(o,s,l,u)=>{if(c(o,s))return;const f=m(l),p=m(u);if(f&&p&&v(f,p)&&h(o,l,r,f)&&h(s,u,t,p)){const{azimuth:e}=g(q,r,t,f);return null!=e?i(e,"degrees","radians"):void 0}e[0]=s[0]-o[0],e[1]=s[1]-o[1];let d=n(a,e);return e[0]<0&&(d=C-d),d}})();function x(e,r,t,o="absolute"){if(r&&t)switch(o){case"absolute":return j(r,t);case"relative":return w(z(e,r,t),"relative");case"relative-bilateral":return w(z(e,r,t),"relative-bilateral")}}function z(e,r,o){if(!e||!r||!o)return;const i=b(e,r),n=b(r,o);return null!=i&&null!=n?t(n-i,"radians","geographic"):void 0}function w(e,r){if(null!=e)switch(r){case"absolute":return M(e);case"relative":{const r=U(e);let o=P.normalize(r,0,!0);return-180===o&&(o=180),t(o,"degrees","geographic")}case"relative-bilateral":{const r=U(e),o=Math.abs(P.normalize(r,0,!0));return t(o,"degrees","geographic")}}}function M(e){const r=U(e),o=I.normalize(r,0,!0);return t(o,"degrees","geographic")}function T(e,r,n){let s=i(e.value,e.unit,"degrees");return s=o(s,e.rotationType,n),s=i(s,"degrees",r),t(s,r,n)}const R=(()=>{const e=f();return(r,t,n,s,a,c="geodesic")=>{l(e,t);const f=U(a);if("geodesic"===c){const o=m(n);if(o&&h(e,n,e,o))return d(r,e,f,s,o),r[2]=t[2],!!h(r,o,r,n)}const g=o(f,"geographic","arithmetic"),p=i(g,"degrees","radians"),v=t[0]+s*Math.cos(p),j=t[1]+s*Math.sin(p),b=t[2];return u(r,v,j,b),!0}})();function U(e){if(null!=e)return o(k(e),e.rotationType,"geographic")}function V(e){if(null!=e)return o(k(e),e.rotationType,"arithmetic")}function k(e){return i(e.value,e.unit,"degrees")}const q=new p,C=2*Math.PI,I=e,P=new r(-180,180);export{T as convertAngle,j as directionBetweenPoints,x as directionForVertices,V as getDegreesArithmetic,U as getDegreesGeographic,w as getNormalizedDirection,M as getNormalizedGeographicOrientation,R as pointFromDistanceAlongAzimuth,y as radiansGeographicBetweenVec};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{getMetersPerUnitForSR as e}from"../../core/units.js";import t from"../../geometry/Extent.js";import{calculateTolerance as n}from"../../renderers/support/clickToleranceUtils.js";function r(n,r,i,a=new t){let o=0;if("2d"===i.type)o=r*(i.resolution??0);else if("3d"===i.type){const t=i.overlayPixelSizeInMapUnits(n),a=i.basemapSpatialReference;o=null==a||a.equals(i.spatialReference)?r*t:e(a)/e(i.spatialReference)}const s=n.x-o,l=n.y-o,c=n.x+o,m=n.y+o,{spatialReference:p}=i;return a.xmin=Math.min(s,c),a.ymin=Math.min(l,m),a.xmax=Math.max(s,c),a.ymax=Math.max(l,m),a.spatialReference=p,a}function i(e,t,i){const o=i.toMap(e);if(null==o)return!1;return r(o,n(),i,a).intersects(t)}let a=new t;function o(){a=new t}export{o as cleanupDrapedUtils,r as createQueryGeometry,i as intersectsDrapedGeometry};
5
+ import{getMetersPerUnitForSR as e}from"../../core/units.js";import t from"../../geometry/Extent.js";import{calculateTolerance as n}from"../../renderers/support/clickToleranceUtils.js";function r(n,r,i,a=new t){let o=0;if("2d"===i.type)o=r*(i.resolution??0);else if("3d"===i.type){const t=i.overlayPixelSizeInMapUnits(n),{groundSpatialReference:a}=i;o=null==a||a.equals(i.spatialReference)?r*t:e(a)/e(i.spatialReference)}const s=n.x-o,l=n.y-o,c=n.x+o,m=n.y+o,{spatialReference:p}=i;return a.xmin=Math.min(s,c),a.ymin=Math.min(l,m),a.xmax=Math.max(s,c),a.ymax=Math.max(l,m),a.spatialReference=p,a}function i(e,t,i){const o=i.toMap(e);if(null==o)return!1;return r(o,n(),i,a).intersects(t)}let a=new t;function o(){a=new t}export{o as cleanupDrapedUtils,r as createQueryGeometry,i as intersectsDrapedGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{createArea as e}from"../../core/quantity.js";import{geodesicAreas as r}from"../../geometry/support/geodesicUtils.js";import{geodesicMeasure as t}from"./geodesicMeasurementUtils.js";const s=e=>({geodesicArea(r){const{spatialReference:s}=r;return t(s,n,r=>a(e,r),r)}});async function o(){const e=await import("../../geometry/geometryEngine.js");return s(e)}function n(t){return e(Math.abs(r([t],"square-meters")[0]),"square-meters")}function a(r,t){try{return e(Math.abs(r.geodesicArea(t,"square-meters")),"square-meters")}catch(s){return null}}export{o as loadGeodesicAreaMeasurementUtils};
5
+ import{createArea as e}from"../../core/quantity.js";import{geodesicAreas as r}from"../../geometry/geodesicUtils.js";import{geodesicMeasure as t}from"./geodesicMeasurementUtils.js";const s=e=>({geodesicArea(r){const{spatialReference:s}=r;return t(s,n,r=>a(e,r),r)}});async function o(){const e=await import("../../geometry/geometryEngine.js");return s(e)}function n(t){return e(Math.abs(r([t],"square-meters")[0]),"square-meters")}function a(r,t){try{return e(Math.abs(r.geodesicArea(t,"square-meters")),"square-meters")}catch(s){return null}}export{o as loadGeodesicAreaMeasurementUtils};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{createLength as e}from"../../core/quantity.js";import{create as t}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import r from"../../geometry/Polyline.js";import{l as n,e as s}from"../../chunks/geodeticLengthOperator.js";import{inverseGeodeticSolver as o,InverseGeodeticSolverResult as i,geodesicLengths as c}from"../../geometry/support/geodesicUtils.js";import{equals as a}from"../../geometry/support/spatialReferenceUtils.js";import{geodesicMeasure as u}from"./geodesicMeasurementUtils.js";function m(e){const{spatialReference:t}=e;return u(t,j,h,e)}function f(e,t){if(!a(e.spatialReference,t.spatialReference))return null;const{spatialReference:r}=e;return x[0]=e.x,x[1]=e.y,x[2]=e.hasZ?e.z:0,U[0]=t.x,U[1]=t.y,U[2]=t.hasZ?t.z:0,p(x,U,r)}function p(e,t,r){return u(r,y,d,e,t,r)}const l={geodesicLength:m,geodesicDistanceBetweenPoints:f,geodesicDistance:p};async function g(){return await n(),l}function y(t,r,n){return e(o(w,t,r,n).distance,"meters")}function d(t,r,n){return e(s(R(t,r,n),{unit:"meters"}),"meters")}function j(t){return e(c([t],"meters")[0],"meters")}function h(t){return e(s(t,{unit:"meters"}),"meters")}function R(e,t,n){return new r({spatialReference:n,paths:[[[...e],[...t]]]})}const w=new i,x=t(),U=t();export{g as loadGeodesicLengthMeasurementUtils};
5
+ import{createLength as e}from"../../core/quantity.js";import{create as t}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{inverseGeodeticSolver as r,InverseGeodeticSolverResult as n,geodesicLengths as s}from"../../geometry/geodesicUtils.js";import i from"../../geometry/Polyline.js";import{l as o,e as c}from"../../chunks/geodeticLengthOperator.js";import{equals as a}from"../../geometry/support/spatialReferenceUtils.js";import{geodesicMeasure as m}from"./geodesicMeasurementUtils.js";function u(e){const{spatialReference:t}=e;return m(t,j,h,e)}function f(e,t){if(!a(e.spatialReference,t.spatialReference))return null;const{spatialReference:r}=e;return x[0]=e.x,x[1]=e.y,x[2]=e.hasZ?e.z:0,U[0]=t.x,U[1]=t.y,U[2]=t.hasZ?t.z:0,p(x,U,r)}function p(e,t,r){return m(r,y,d,e,t,r)}const l={geodesicLength:u,geodesicDistanceBetweenPoints:f,geodesicDistance:p};async function g(){return await o(),l}function y(t,n,s){return e(r(w,t,n,s).distance,"meters")}function d(t,r,n){return e(c(R(t,r,n),{unit:"meters"}),"meters")}function j(t){return e(s([t],"meters")[0],"meters")}function h(t){return e(c(t,{unit:"meters"}),"meters")}function R(e,t,r){return new i({spatialReference:r,paths:[[[...e],[...t]]]})}const w=new n,x=t(),U=t();export{g as loadGeodesicLengthMeasurementUtils};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isSupported as e}from"../../geometry/support/geodesicUtils.js";import{isWebMercator as o}from"../../geometry/support/spatialReferenceUtils.js";function r(r){return e(r)||o(r)}function t(o,r,t,...p){return e(o)?r.apply(void 0,p):o.isWebMercator?t.apply(void 0,p):null}const p=1e5;export{p as geodesicDistanceThreshold,t as geodesicMeasure,r as supportsGeodesicMeasurement};
5
+ import{isSupported as e}from"../../geometry/geodesicUtils.js";import{isWebMercator as o}from"../../geometry/support/spatialReferenceUtils.js";function r(r){return e(r)||o(r)}function t(o,r,t,...i){return e(o)?r.apply(void 0,i):o.isWebMercator?t.apply(void 0,i):null}const i=1e5;export{i as geodesicDistanceThreshold,t as geodesicMeasure,r as supportsGeodesicMeasurement};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{JSONSupport as e}from"../core/JSONSupport.js";import{clone as o}from"../core/lang.js";import r from"../core/Logger.js";import{property as i,subclass as n}from"../core/accessorSupport/decorators.js";import s from"../views/3d/environment/SunnyWeather.js";import{weatherTypes as l,validateWeatherType as a}from"../views/3d/environment/weather.js";import{lightingTypes as p}from"./lightingTypes.js";import h from"./SunLighting.js";import c from"./VirtualLighting.js";import{backgroundProperty as g}from"./background/utils.js";var m;const u=(t,e,o)=>({enabled:!o?.isPresentation});let d=class extends e{static{m=this}constructor(t){super(t),this.lighting=new h,this.background=null,this.atmosphereEnabled=!0,this.starsEnabled=!0}set weather(t){a(t?.type,r.getLogger(this))&&this._set("weather",t)}clone(){return new m(this.cloneConstructProperties())}cloneConstructProperties(){return{lighting:this.lighting&&"virtual"===this.lighting.type?c.prototype.clone.call(this.lighting):h.prototype.clone.call(this.lighting),background:o(this.background),atmosphereEnabled:this.atmosphereEnabled,starsEnabled:this.starsEnabled,weather:this.weather.clone()}}};t([i({types:p,nonNullable:!0,json:{write:!0}})],d.prototype,"lighting",void 0),t([i(g)],d.prototype,"background",void 0),t([i({type:Boolean,nonNullable:!0,json:{write:{overridePolicy:u}}})],d.prototype,"atmosphereEnabled",void 0),t([i({type:Boolean,nonNullable:!0,json:{write:{overridePolicy:u}}})],d.prototype,"starsEnabled",void 0),t([i({types:l,nonNullable:!0,json:{write:!0},value:new s})],d.prototype,"weather",null),d=m=t([n("esri.webscene.Environment")],d);const b=d;export{b as default};
5
+ import{__decorate as t}from"tslib";import{JSONSupport as e}from"../core/JSONSupport.js";import{clone as o}from"../core/lang.js";import r from"../core/Logger.js";import{property as i,subclass as n}from"../core/accessorSupport/decorators.js";import s from"../views/3d/environment/SunnyWeather.js";import{weatherTypes as l,validateWeatherType as a}from"../views/3d/environment/weather.js";import{lightingTypes as p}from"./lightingTypes.js";import h from"./SunLighting.js";import c from"./VirtualLighting.js";import{backgroundProperty as g}from"./background/utils.js";var m;const u=(t,e,o)=>({enabled:!o?.isPresentation});let d=class extends e{static{m=this}constructor(t){super(t),this.lighting=new h,this.background=null,this.atmosphereEnabled=!0,this.starsEnabled=!0}set weather(t){a(t?.type,r.getLogger(this))&&this._set("weather",t)}clone(){return new m(this.cloneConstructProperties())}cloneConstructProperties(){return{lighting:this.lighting&&"virtual"===this.lighting.type?c.prototype.clone.call(this.lighting):h.prototype.clone.call(this.lighting),background:o(this.background),atmosphereEnabled:this.atmosphereEnabled,starsEnabled:this.starsEnabled,weather:this.weather.clone()}}};t([i({types:{defaultKeyValue:"sun",...p},nonNullable:!0,json:{write:!0}})],d.prototype,"lighting",void 0),t([i(g)],d.prototype,"background",void 0),t([i({type:Boolean,nonNullable:!0,json:{write:{overridePolicy:u}}})],d.prototype,"atmosphereEnabled",void 0),t([i({type:Boolean,nonNullable:!0,json:{write:{overridePolicy:u}}})],d.prototype,"starsEnabled",void 0),t([i({types:l,nonNullable:!0,json:{write:!0},value:new s})],d.prototype,"weather",null),d=m=t([n("esri.webscene.Environment")],d);const b=d;export{b 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as r,onLocaleChange as i}from"../../intl.js";import{multiplyOpacity as s,getContrast as a}from"../../core/colorUtils.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as o,initial as m}from"../../core/reactiveUtils.js";import{formatDecimal as l,formatImperialArea as p,formatMetricArea as c,formatImperialLength as u,formatMetricLength as h}from"../../core/unitFormatUtils.js";import{convertUnit as d}from"../../core/units.js";import{property as v,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import g from"../../geometry/Point.js";import _ from"../../geometry/Polygon.js";import w from"../../geometry/Polyline.js";import{e as b}from"../../chunks/areaOperator.js";import{e as L,l as j}from"../../chunks/geodeticAreaOperator.js";import{e as S,l as A}from"../../chunks/geodeticDensifyOperator.js";import{e as k,l as G}from"../../chunks/geodeticLengthOperator.js";import{e as x}from"../../chunks/lengthOperator.js";import{e as M}from"../../chunks/simplifyOperator.js";import{polygonCentroidPoint as q}from"../../geometry/support/centroid.js";import{isSupported as O,geodesicDensify as C,geodesicLengths as H,geodesicAreas as R}from"../../geometry/support/geodesicUtils.js";import T from"../../layers/GraphicsLayer.js";import U from"../../symbols/Font.js";import z from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import P from"../../symbols/SimpleMarkerSymbol.js";import E from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as V}from"../../views/2d/interactive/SnappingVisualizer2D.js";import F from"../../views/draw/Draw.js";import{createCoordinateHelper as W}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as I,screenToMap as B,dragManipulatedObject as J}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as N}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as K}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as Q}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as X}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as Y}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Z}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as $}from"../../views/interactive/snapping/snappingUtils.js";const ee=1e5;let te=class extends K{constructor(e){super(e),this._measurementLayer=new T({internal:!0,listMode:"hide",visible:!1,title:"Area measurement layer"}),this._manipulatorLayer=new T({internal:!0,listMode:"hide",visible:!1,title:"Area measurement manipulator layer"}),this._snappingLayer=new T({internal:!0,listMode:"hide",visible:!1,title:"Area measurement snapping layer"}),this._updatingHandles=new f,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){r("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new F({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([i(async()=>{this.messages=await r("esri/core/t9n/Units")}),o(()=>[this.unit,this.messages],()=>{this._updateGraphics()},m),o(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),$(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=n(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=n(this._measurementLayer),this._manipulatorLayer=n(this._manipulatorLayer),this._snappingLayer=n(this._snappingLayer),this._updatingHandles=n(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}reset(){this.manipulators.removeAll(),this._resetVertices(),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._draw.reset(),this._drawActive=!1}_getSnappingContext(e){return new Y({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new X(new Q("point",W(!1,!1,this.view.spatialReference)),2),visualizer:new V(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){if(this._vertices.length<3)return this.reset(),void this._startSketch();this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let r=this._vertices.length;r<e.length;r++){const[i,s]=e[r],a=new g({x:i,y:s,spatialReference:t}),n=re(a,this.view,this._manipulatorLayer);this.manipulators.add(n);const o=X.fromGeometry(a,2);o.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[r].coord=[t.pos[0],t.pos[1]],this._updateGraphics())});const m=I(n,(e,t,r,i)=>{const s=this._getSnappingContext(i),{snappingManager:a}=this,n=this._updatingHandles,{snappingStep:m}=Z({snappingContext:s,snappingManager:a,updatingHandles:n});t.next(B(this.view)).next(t=>{if("start"===t.action){const r=new g(t.mapStart);e.graphic.geometry=r,o.trySetGeometry(r)}return t}).next(...m).next(J({operations:o})).next(()=>{e.graphic.geometry=o.data.geometry})});this._vertices.push({manipulator:n,coord:[i,s],handle:m})}if(this._vertices.length){const r=this._vertices.length-1,i=this._vertices[r],[s,a]=e[r];i.coord[0]===s&&i.coord[1]===a||(i.coord=[s,a],i.manipulator.graphic.geometry=new g({x:s,y:a,spatialReference:t}));const n=this._drawActive?this._vertices[r].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==n||e!==n})}this._updateGraphics()}_updateGraphics(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=ie(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:r,fillGeometry:i,outlineGeometry:n}=e;this._set("measurement",r);const o=r?ne(this.messages,r,this.unit):null;if(this._set("measurementLabel",o),!i&&!n)return;let m,l,p;const{graphics:c}=this._measurementLayer,u=3===c.length,{effectiveTheme:h}=this.view;u?(m=c.at(0),l=c.at(1),p=c.at(2)):(m=new t({symbol:new z({color:s(h.accentColor,.3),outline:null})}),l=new t({symbol:new D({color:h.accentColor,width:2})}),p=new t({symbol:new E({color:h.textColor,font:new U({size:14,family:"sans-serif"}),haloColor:s(a(h.textColor,160),.5),haloSize:2})}),c.removeAll(),c.addMany([m,l,p])),m.geometry=i,l.geometry=n;const d=i?q(i):null,v=d?g.fromJSON(d):null;p.geometry=v,p.symbol.text=o?.area??""}};function re(e,r,i){const a=8,n={style:"circle",color:s(r.effectiveTheme.accentColor,.5),outline:{type:"simple-line",width:0}},o=new P({...n,size:a}),m=new P({...n,size:1.5*a}),l=new t({geometry:e,symbol:o});return new N({view:r,layer:i,graphic:l,focusedSymbol:m})}function ie(e,t){if(2===e.length){const r=new w({paths:[e],spatialReference:t});let i;return i=t.isGeographic?O(t)?C(r,ee):S(r,ee,{unit:"meters"}):t.isWebMercator?S(r,ee,{unit:"meters"}):r,{measurement:null,fillGeometry:null,outlineGeometry:i}}e.push(e[0]);const r=new w({paths:[e],spatialReference:t}),i=new _({rings:[e],spatialReference:t});let s,a,n=null,o=null;if(t.isGeographic)if(O(t)){if(n=C(r,ee),o=C(i,ee),o=M(o),!o)return null;s=H([r],"meters")[0],a=R([o],"square-meters")[0]}else{if(n=S(r,ee,{unit:"meters"}),o=S(i,ee,{unit:"meters"}),o=M(o),!o)return null;s=k(r,{unit:"meters"}),a=L(o,{unit:"square-meters"})}else if(t.isWebMercator){if(n=S(r,ee,{unit:"meters"}),o=S(i,ee,{unit:"meters"}),o=M(o),!o)return null;s=k(r,{unit:"meters"}),a=L(o,{unit:"square-meters"})}else{if(n=r,o=M(i),!o)return null;s=x(r,{unit:"meters"}),a=b(o,{unit:"square-meters"})}return{measurement:{geometry:o,area:a,perimeter:s},fillGeometry:o,outlineGeometry:n}}function se(e){return null!=e}async function ae(e){(e?.isGeographic&&!O(e)||e?.isWebMercator)&&await Promise.all([j(),A(),G()])}function ne(e,t,r){if(!t||!e)return null;const i={area:null,perimeter:null},{area:s,perimeter:a}=t;switch(r){case"metric":i.area=c(e,s,"square-meters");break;case"imperial":i.area=p(e,s,"square-meters");break;default:{const t=d(s,"square-meters",r);i.area=l(e,t,r);break}}const n=oe(r);if(n)switch(n){case"metric":i.perimeter=h(e,a,"meters");break;case"imperial":i.perimeter=u(e,a,"meters");break;default:{const t=d(a,"meters",n);i.perimeter=l(e,t,n);break}}else i.perimeter="";return i}function oe(e){switch(e){case"metric":case"ares":case"hectares":return"metric";case"imperial":case"acres":return"imperial";case"square-inches":return"inches";case"square-feet":return"feet";case"square-yards":return"yards";case"square-miles":return"miles";case"square-nautical-miles":return"nautical-miles";case"square-us-feet":return"us-feet";case"square-meters":return"meters";case"square-kilometers":return"kilometers";case"square-millimeters":return"millimeters";case"square-centimeters":return"centimeters";case"square-decimeters":return"decimeters";default:return null}}e([v()],te.prototype,"_drawActive",void 0),e([v({readOnly:!0})],te.prototype,"cursor",null),e([v({value:!0})],te.prototype,"editable",null),e([v({readOnly:!0})],te.prototype,"measurement",void 0),e([v({readOnly:!0})],te.prototype,"measurementLabel",void 0),e([v()],te.prototype,"messages",void 0),e([v({constructOnly:!0})],te.prototype,"snappingManager",void 0),e([v()],te.prototype,"unit",void 0),e([v()],te.prototype,"updating",null),e([v({constructOnly:!0})],te.prototype,"view",void 0),te=e([y("esri.widgets.AreaMeasurement2D.AreaMeasurement2DTool")],te);export{te as AreaMeasurement2DTool,ie as createAreaMeasurementInfo2D,ne as createAreaMeasurementLabel,se as isSupported,ae as loadGeometryOperators};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as r,onLocaleChange as i}from"../../intl.js";import{multiplyOpacity as s,getContrast as a}from"../../core/colorUtils.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as o,initial as m}from"../../core/reactiveUtils.js";import{formatDecimal as l,formatImperialArea as p,formatMetricArea as c,formatImperialLength as u,formatMetricLength as h}from"../../core/unitFormatUtils.js";import{convertUnit as d}from"../../core/units.js";import{property as v,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{isSupported as g,geodesicDensify as _,geodesicLengths as w,geodesicAreas as b}from"../../geometry/geodesicUtils.js";import L from"../../geometry/Point.js";import j from"../../geometry/Polygon.js";import S from"../../geometry/Polyline.js";import{e as A}from"../../chunks/areaOperator.js";import{e as k,l as G}from"../../chunks/geodeticAreaOperator.js";import{e as x,l as M}from"../../chunks/geodeticDensifyOperator.js";import{e as q,l as O}from"../../chunks/geodeticLengthOperator.js";import{e as C}from"../../chunks/lengthOperator.js";import{e as H}from"../../chunks/simplifyOperator.js";import{polygonCentroidPoint as R}from"../../geometry/support/centroid.js";import T from"../../layers/GraphicsLayer.js";import U from"../../symbols/Font.js";import z from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import P from"../../symbols/SimpleMarkerSymbol.js";import E from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as V}from"../../views/2d/interactive/SnappingVisualizer2D.js";import F from"../../views/draw/Draw.js";import{createCoordinateHelper as W}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as I,screenToMap as B,dragManipulatedObject as J}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as N}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as K}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as Q}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as X}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as Y}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Z}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as $}from"../../views/interactive/snapping/snappingUtils.js";const ee=1e5;let te=class extends K{constructor(e){super(e),this._measurementLayer=new T({internal:!0,listMode:"hide",visible:!1,title:"Area measurement layer"}),this._manipulatorLayer=new T({internal:!0,listMode:"hide",visible:!1,title:"Area measurement manipulator layer"}),this._snappingLayer=new T({internal:!0,listMode:"hide",visible:!1,title:"Area measurement snapping layer"}),this._updatingHandles=new f,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){r("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new F({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([i(async()=>{this.messages=await r("esri/core/t9n/Units")}),o(()=>[this.unit,this.messages],()=>{this._updateGraphics()},m),o(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),$(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=n(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=n(this._measurementLayer),this._manipulatorLayer=n(this._manipulatorLayer),this._snappingLayer=n(this._snappingLayer),this._updatingHandles=n(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}reset(){this.manipulators.removeAll(),this._resetVertices(),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._draw.reset(),this._drawActive=!1}_getSnappingContext(e){return new Y({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new X(new Q("point",W(!1,!1,this.view.spatialReference)),2),visualizer:new V(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){if(this._vertices.length<3)return this.reset(),void this._startSketch();this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let r=this._vertices.length;r<e.length;r++){const[i,s]=e[r],a=new L({x:i,y:s,spatialReference:t}),n=re(a,this.view,this._manipulatorLayer);this.manipulators.add(n);const o=X.fromGeometry(a,2);o.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[r].coord=[t.pos[0],t.pos[1]],this._updateGraphics())});const m=I(n,(e,t,r,i)=>{const s=this._getSnappingContext(i),{snappingManager:a}=this,n=this._updatingHandles,{snappingStep:m}=Z({snappingContext:s,snappingManager:a,updatingHandles:n});t.next(B(this.view)).next(t=>{if("start"===t.action){const r=new L(t.mapStart);e.graphic.geometry=r,o.trySetGeometry(r)}return t}).next(...m).next(J({operations:o})).next(()=>{e.graphic.geometry=o.data.geometry})});this._vertices.push({manipulator:n,coord:[i,s],handle:m})}if(this._vertices.length){const r=this._vertices.length-1,i=this._vertices[r],[s,a]=e[r];i.coord[0]===s&&i.coord[1]===a||(i.coord=[s,a],i.manipulator.graphic.geometry=new L({x:s,y:a,spatialReference:t}));const n=this._drawActive?this._vertices[r].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==n||e!==n})}this._updateGraphics()}_updateGraphics(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=ie(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:r,fillGeometry:i,outlineGeometry:n}=e;this._set("measurement",r);const o=r?ne(this.messages,r,this.unit):null;if(this._set("measurementLabel",o),!i&&!n)return;let m,l,p;const{graphics:c}=this._measurementLayer,u=3===c.length,{effectiveTheme:h}=this.view;u?(m=c.at(0),l=c.at(1),p=c.at(2)):(m=new t({symbol:new z({color:s(h.accentColor,.3),outline:null})}),l=new t({symbol:new D({color:h.accentColor,width:2})}),p=new t({symbol:new E({color:h.textColor,font:new U({size:14,family:"sans-serif"}),haloColor:s(a(h.textColor,160),.5),haloSize:2})}),c.removeAll(),c.addMany([m,l,p])),m.geometry=i,l.geometry=n;const d=i?R(i):null,v=d?L.fromJSON(d):null;p.geometry=v,p.symbol.text=o?.area??""}};function re(e,r,i){const a=8,n={style:"circle",color:s(r.effectiveTheme.accentColor,.5),outline:{type:"simple-line",width:0}},o=new P({...n,size:a}),m=new P({...n,size:1.5*a}),l=new t({geometry:e,symbol:o});return new N({view:r,layer:i,graphic:l,focusedSymbol:m})}function ie(e,t){if(2===e.length){const r=new S({paths:[e],spatialReference:t});let i;return i=t.isGeographic?g(t)?_(r,ee):x(r,ee,{unit:"meters"}):t.isWebMercator?x(r,ee,{unit:"meters"}):r,{measurement:null,fillGeometry:null,outlineGeometry:i}}e.push(e[0]);const r=new S({paths:[e],spatialReference:t}),i=new j({rings:[e],spatialReference:t});let s,a,n=null,o=null;if(t.isGeographic)if(g(t)){if(n=_(r,ee),o=_(i,ee),o=H(o),!o)return null;s=w([r],"meters")[0],a=b([o],"square-meters")[0]}else{if(n=x(r,ee,{unit:"meters"}),o=x(i,ee,{unit:"meters"}),o=H(o),!o)return null;s=q(r,{unit:"meters"}),a=k(o,{unit:"square-meters"})}else if(t.isWebMercator){if(n=x(r,ee,{unit:"meters"}),o=x(i,ee,{unit:"meters"}),o=H(o),!o)return null;s=q(r,{unit:"meters"}),a=k(o,{unit:"square-meters"})}else{if(n=r,o=H(i),!o)return null;s=C(r,{unit:"meters"}),a=A(o,{unit:"square-meters"})}return{measurement:{geometry:o,area:a,perimeter:s},fillGeometry:o,outlineGeometry:n}}function se(e){return null!=e}async function ae(e){(e?.isGeographic&&!g(e)||e?.isWebMercator)&&await Promise.all([G(),M(),O()])}function ne(e,t,r){if(!t||!e)return null;const i={area:null,perimeter:null},{area:s,perimeter:a}=t;switch(r){case"metric":i.area=c(e,s,"square-meters");break;case"imperial":i.area=p(e,s,"square-meters");break;default:{const t=d(s,"square-meters",r);i.area=l(e,t,r);break}}const n=oe(r);if(n)switch(n){case"metric":i.perimeter=h(e,a,"meters");break;case"imperial":i.perimeter=u(e,a,"meters");break;default:{const t=d(a,"meters",n);i.perimeter=l(e,t,n);break}}else i.perimeter="";return i}function oe(e){switch(e){case"metric":case"ares":case"hectares":return"metric";case"imperial":case"acres":return"imperial";case"square-inches":return"inches";case"square-feet":return"feet";case"square-yards":return"yards";case"square-miles":return"miles";case"square-nautical-miles":return"nautical-miles";case"square-us-feet":return"us-feet";case"square-meters":return"meters";case"square-kilometers":return"kilometers";case"square-millimeters":return"millimeters";case"square-centimeters":return"centimeters";case"square-decimeters":return"decimeters";default:return null}}e([v()],te.prototype,"_drawActive",void 0),e([v({readOnly:!0})],te.prototype,"cursor",null),e([v({value:!0})],te.prototype,"editable",null),e([v({readOnly:!0})],te.prototype,"measurement",void 0),e([v({readOnly:!0})],te.prototype,"measurementLabel",void 0),e([v()],te.prototype,"messages",void 0),e([v({constructOnly:!0})],te.prototype,"snappingManager",void 0),e([v()],te.prototype,"unit",void 0),e([v()],te.prototype,"updating",null),e([v({constructOnly:!0})],te.prototype,"view",void 0),te=e([y("esri.widgets.AreaMeasurement2D.AreaMeasurement2DTool")],te);export{te as AreaMeasurement2DTool,ie as createAreaMeasurementInfo2D,ne as createAreaMeasurementLabel,se as isSupported,ae as loadGeometryOperators};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{on as t}from"../core/reactiveUtils.js";import{property as i,subclass as r}from"../core/accessorSupport/decorators.js";import s from"./Widget.js";import o from"./Attribution/AttributionViewModel.js";import{globalCss as n}from"./support/globalCss.js";import{messageBundle as l,accessibleHandler as d,tsx as c}from"./support/widget.js";const p="esri-attribution",h={base:p,poweredBy:`${p}__powered-by`,sources:`${p}__sources`,open:`${p}--open`,sourcesOpen:`${p}__sources--open`,link:`${p}__link`};let a=class extends s{constructor(e,t){super(e,t),this._isOpen=!1,this._attributionTextOverflowed=!1,this._prevSourceNodeHeight=0,this._resizeObserver=new ResizeObserver(e=>e.forEach(({target:e})=>this._checkSourceTextOverflow(e))),this.itemDelimiter=" | ",this.messages=null,this.viewModel=new o}initialize(){this.addHandles(t(()=>this.viewModel?.items,"change",()=>this.scheduleRender()))}destroy(){this._resizeObserver?.disconnect()}get _isInteractive(){return this._isOpen||this._attributionTextOverflowed}get attributionText(){return this.viewModel.items.reduce((e,t)=>(e.includes(t.text)||e.push(t.text),e),[]).join(this.itemDelimiter)}get icon(){return"description"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const e={[h.open]:this._isOpen};return c("div",{bind:this,class:this.classes(h.base,n.widget,e),dir:"ltr",onclick:this._toggleState,onkeydown:this._toggleState},this._renderSourcesNode(),this._renderPoweredBy())}_renderPoweredBy(){return c("div",{class:h.poweredBy},"Powered by"," ",c("a",{class:h.link,href:"https://www.esri.com/",rel:"noreferrer",target:"_blank"},"Esri"))}_renderSourcesNode(){const e=this._isOpen,t=this._isInteractive,i=t?0:void 0,{attributionText:r}=this,s={[h.sourcesOpen]:e,[n.interactive]:t};return c("div",{afterCreate:this._afterSourcesNodeCreate,bind:this,class:this.classes(h.sources,s),innerHTML:r,tabIndex:i})}_afterSourcesNodeCreate(e){this._prevSourceNodeHeight=e.clientWidth,this._resizeObserver.observe(e)}_checkSourceTextOverflow(e){let t=!1;const{clientHeight:i,clientWidth:r,scrollWidth:s}=e,o=s>r,n=this._attributionTextOverflowed!==o;if(this._attributionTextOverflowed=o,n&&(t=!0),this._isOpen){const e=i<this._prevSourceNodeHeight;this._prevSourceNodeHeight=i,e&&(this._isOpen=!1,t=!0)}t&&this.scheduleRender()}_toggleState(){this._isInteractive&&(this._isOpen=!this._isOpen)}};e([i()],a.prototype,"_isOpen",void 0),e([i()],a.prototype,"_isInteractive",null),e([i()],a.prototype,"_attributionTextOverflowed",void 0),e([i()],a.prototype,"_prevSourceNodeHeight",void 0),e([i({readOnly:!0,dependsOn:["viewModel.items.length","itemDelimiter"]})],a.prototype,"attributionText",null),e([i()],a.prototype,"icon",null),e([i()],a.prototype,"itemDelimiter",void 0),e([i()],a.prototype,"label",null),e([i(),l("esri/widgets/Attribution/t9n/Attribution")],a.prototype,"messages",void 0),e([i()],a.prototype,"view",null),e([i({type:o})],a.prototype,"viewModel",void 0),e([d()],a.prototype,"_toggleState",null),a=e([r("esri.widgets.Attribution")],a);const u=a;export{u as default};
5
+ import{__decorate as e}from"tslib";import{on as t}from"../core/reactiveUtils.js";import{property as i,subclass as r}from"../core/accessorSupport/decorators.js";import s from"./Widget.js";import o from"./Attribution/AttributionViewModel.js";import{globalCss as n}from"./support/globalCss.js";import{messageBundle as l,accessibleHandler as h,tsx as a}from"./support/widget.js";const c="esri-attribution",d={base:c,poweredBy:`${c}__powered-by`,sources:`${c}__sources`,open:`${c}--open`,sourcesOpen:`${c}__sources--open`,link:`${c}__link`};let u=class extends s{constructor(e,t){super(e,t),this._isOpen=!1,this._attributionTextOverflowed=!1,this._prevSourceNodeHeight=0,this._sourcesNode=null,this._overflowRequestAnimationFrame=null,this._resizeObserver=new ResizeObserver(e=>{e.forEach(({target:e})=>{this._scheduleOverflowCheck(e)})}),this._mutationObserver=new MutationObserver(e=>{let t=!1;for(const i of e)if("childList"===i.type||"characterData"===i.type||"attributes"===i.type){t=!0;break}t&&this._sourcesNode&&this._scheduleOverflowCheck(this._sourcesNode)}),this.itemDelimiter=" | ",this.messages=null,this.viewModel=new o}initialize(){this.addHandles(t(()=>this.viewModel?.items,"change",()=>this.scheduleRender()))}destroy(){this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),null!=this._overflowRequestAnimationFrame&&(cancelAnimationFrame(this._overflowRequestAnimationFrame),this._overflowRequestAnimationFrame=null)}get _isInteractive(){return this._isOpen||this._attributionTextOverflowed}_scheduleOverflowCheck(e){null==this._overflowRequestAnimationFrame&&(this._overflowRequestAnimationFrame=requestAnimationFrame(()=>{this._overflowRequestAnimationFrame=null,this._checkSourceTextOverflow(e)}))}get attributionText(){return this.viewModel.items.reduce((e,t)=>(e.includes(t.text)||e.push(t.text),e),[]).join(this.itemDelimiter)}get icon(){return"description"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const e={[d.open]:this._isOpen};return a("div",{bind:this,class:this.classes(d.base,n.widget,e),dir:"ltr",onclick:this._toggleState,onkeydown:this._toggleState},this._renderSourcesNode(),this._renderPoweredBy())}_renderPoweredBy(){return a("div",{class:d.poweredBy},"Powered by"," ",a("a",{class:d.link,href:"https://www.esri.com/",rel:"noreferrer",target:"_blank"},"Esri"))}_renderSourcesNode(){const e=this._isOpen,t=this._isInteractive,i=t?0:void 0,{attributionText:r}=this,s={[d.sourcesOpen]:e,[n.interactive]:t};return a("div",{afterCreate:this._afterSourcesNodeCreate,bind:this,class:this.classes(d.sources,s),innerHTML:r,tabIndex:i})}_afterSourcesNodeCreate(e){this._prevSourceNodeHeight=e.clientWidth,this._sourcesNode=e,this._resizeObserver.observe(e),this._mutationObserver.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),this._scheduleOverflowCheck(e)}_checkSourceTextOverflow(e){let t=!1;const{clientHeight:i,clientWidth:r,scrollWidth:s}=e,o=s>r,n=this._attributionTextOverflowed!==o;if(this._attributionTextOverflowed=o,n&&(t=!0),this._isOpen){const e=i<this._prevSourceNodeHeight;this._prevSourceNodeHeight=i,e&&(this._isOpen=!1,t=!0)}t&&this.scheduleRender()}_toggleState(){this._isInteractive&&(this._isOpen=!this._isOpen)}};e([i()],u.prototype,"_isOpen",void 0),e([i()],u.prototype,"_isInteractive",null),e([i()],u.prototype,"_attributionTextOverflowed",void 0),e([i()],u.prototype,"_prevSourceNodeHeight",void 0),e([i({readOnly:!0,dependsOn:["viewModel.items.length","itemDelimiter"]})],u.prototype,"attributionText",null),e([i()],u.prototype,"icon",null),e([i()],u.prototype,"itemDelimiter",void 0),e([i()],u.prototype,"label",null),e([i(),l("esri/widgets/Attribution/t9n/Attribution")],u.prototype,"messages",void 0),e([i()],u.prototype,"view",null),e([i({type:o})],u.prototype,"viewModel",void 0),e([h()],u.prototype,"_toggleState",null),u=e([r("esri.widgets.Attribution")],u);const p=u;export{p 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as i,onLocaleChange as r}from"../../intl.js";import{getContrast as s,multiplyOpacity as n}from"../../core/colorUtils.js";import{handlesGroup as o}from"../../core/handleUtils.js";import{destroyMaybe as a}from"../../core/maybe.js";import{watch as l,initial as p}from"../../core/reactiveUtils.js";import{formatDecimal as m,formatImperialLength as c,formatMetricLength as h}from"../../core/unitFormatUtils.js";import{convertUnit as u}from"../../core/units.js";import{property as d,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as v}from"../../core/support/UpdatingHandles.js";import g from"../../geometry/Point.js";import _ from"../../geometry/Polyline.js";import{e as f,l as w}from"../../chunks/geodeticDensifyOperator.js";import{e as L,l as b}from"../../chunks/geodeticLengthOperator.js";import{e as S}from"../../chunks/lengthOperator.js";import{isSupported as j,geodesicLengths as M,geodesicDensify as x}from"../../geometry/support/geodesicUtils.js";import C from"../../layers/GraphicsLayer.js";import A from"../../symbols/CIMSymbol.js";import D from"../../symbols/Font.js";import k from"../../symbols/SimpleMarkerSymbol.js";import G from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as T}from"../../views/2d/interactive/SnappingVisualizer2D.js";import O from"../../views/draw/Draw.js";import{createCoordinateHelper as H}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,screenToMap as R,dragManipulatedObject as U}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as E}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as I}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as z}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as B}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as F}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as V}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as W}from"../../views/interactive/snapping/snappingUtils.js";const N=1e5;let q=class extends I{constructor(e){super(e),this._measurementLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool measurement layer"}),this._manipulatorLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool manipulator layer"}),this._snappingLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool snapping layer"}),this._updatingHandles=new v,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){i("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new O({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([r(async()=>{this.messages=await i("esri/core/t9n/Units")}),l(()=>[this.unit,this.messages],()=>{this._updatePolylines()},p),l(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),W(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=a(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=a(this._measurementLayer),this._manipulatorLayer=a(this._manipulatorLayer),this._snappingLayer=a(this._snappingLayer),this._updatingHandles=a(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}_getSnappingContext(e){return new F({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new B(new z("point",H(!1,!1,this.view.spatialReference)),2),visualizer:new T(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let l=this._vertices.length;l<e.length;l++){const[i,r]=e[l],s=new g({x:i,y:r,spatialReference:t}),n=J(s,this.view,this._manipulatorLayer);this.manipulators.add(n);const a=B.fromGeometry(s,2),p=[a.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[l].coord=[t.pos[0],t.pos[1]],this._updatePolylines())}),P(n,(e,t,i,r)=>{const s=this._getSnappingContext(r),{snappingManager:n}=this,o=this._updatingHandles,{snappingStep:l}=V({snappingContext:s,snappingManager:n,updatingHandles:o});t.next(R(this.view)).next(t=>{if("start"===t.action){const i=new g(t.mapStart);e.graphic.geometry=i,a.trySetGeometry(i)}return t}).next(...l).next(U({operations:a})).next(()=>{e.graphic.geometry=a.data.geometry})})];this._vertices.push({manipulator:n,coord:[i,r],handle:o(p)})}const i=this._vertices.length-1,r=this._vertices[i],[s,n]=e[i];r.coord[0]===s&&r.coord[1]===n||(r.coord=[s,n],r.manipulator.graphic.geometry=new g({x:s,y:n,spatialReference:t}));const a=this._drawActive?this._vertices[i].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==a||e!==a}),this._updatePolylines()}_updatePolylines(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=K(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:i,drawing:r,original:o}=e;this._set("measurement",i);const a=Y(this.messages,i,this.unit);let l,p;this._set("measurementLabel",a);const{graphics:m}=this._measurementLayer,c=2===m.length,{effectiveTheme:h}=this.view;c?(l=m.at(0),p=m.at(1)):(l=new t({symbol:new A({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[14,12],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:3.5,color:s(h.accentColor).toArray()},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:5,color:h.accentColor.toArray()}]}}})}),p=new t({symbol:new G({color:h.textColor,haloColor:n(s(h.textColor,160),.5),haloSize:2,font:new D({size:14,family:"sans-serif"})})}),m.removeAll(),m.addMany([l,p])),l.geometry=r,p.geometry=o.extent?.center,p.symbol.text=a}};function J(e,i,r){const s=n(i.effectiveTheme.accentColor,.5),o={type:"simple-line",width:0},a=8,l=new k({style:"circle",color:s,size:a,outline:o}),p=new k({style:"circle",color:s,size:1.5*a,outline:o}),m=new t({geometry:e,symbol:l});return new E({view:i,layer:r,graphic:m,focusedSymbol:p})}function K(e,t){const i=new _({paths:[e],spatialReference:t});let r,s;return t.isGeographic?j(t)?(r=M([i],"meters")[0],s=x(i,N)):(r=L(i,{unit:"meters"}),s=f(i,N,{unit:"meters"})):t.isWebMercator?(r=L(i,{unit:"meters"}),s=f(i,N,{unit:"meters"})):(r=S(i,{unit:"meters"}),s=i),{measurement:{geometry:s,length:r},original:i,drawing:s}}function Q(e){return null!=e}async function X(e){(e?.isGeographic&&!j(e)||e?.isWebMercator)&&await Promise.all([w(),b()])}function Y(e,t,i){if(!t||!e)return"";switch(i){case"metric":return h(e,t.length,"meters");case"imperial":return c(e,t.length,"meters");default:return m(e,u(t.length,"meters",i),i)}}e([d()],q.prototype,"_drawActive",void 0),e([d({readOnly:!0})],q.prototype,"cursor",null),e([d({value:!0})],q.prototype,"editable",null),e([d({readOnly:!0})],q.prototype,"measurement",void 0),e([d({readOnly:!0})],q.prototype,"measurementLabel",void 0),e([d()],q.prototype,"messages",void 0),e([d({constructOnly:!0})],q.prototype,"snappingManager",void 0),e([d()],q.prototype,"unit",void 0),e([d()],q.prototype,"updating",null),e([d({constructOnly:!0})],q.prototype,"view",void 0),q=e([y("esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DTool")],q);export{q as DistanceMeasurement2DTool,K as createDistanceMeasurementInfo2D,Y as createDistanceMeasurementLabel,Q as isSupported,X as loadGeometryOperators};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as i,onLocaleChange as r}from"../../intl.js";import{getContrast as s,multiplyOpacity as n}from"../../core/colorUtils.js";import{handlesGroup as o}from"../../core/handleUtils.js";import{destroyMaybe as a}from"../../core/maybe.js";import{watch as l,initial as p}from"../../core/reactiveUtils.js";import{formatDecimal as m,formatImperialLength as c,formatMetricLength as h}from"../../core/unitFormatUtils.js";import{convertUnit as u}from"../../core/units.js";import{property as d,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as v}from"../../core/support/UpdatingHandles.js";import{isSupported as g,geodesicLengths as _,geodesicDensify as f}from"../../geometry/geodesicUtils.js";import w from"../../geometry/Point.js";import L from"../../geometry/Polyline.js";import{e as b,l as S}from"../../chunks/geodeticDensifyOperator.js";import{e as j,l as M}from"../../chunks/geodeticLengthOperator.js";import{e as x}from"../../chunks/lengthOperator.js";import C from"../../layers/GraphicsLayer.js";import A from"../../symbols/CIMSymbol.js";import D from"../../symbols/Font.js";import k from"../../symbols/SimpleMarkerSymbol.js";import G from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as T}from"../../views/2d/interactive/SnappingVisualizer2D.js";import O from"../../views/draw/Draw.js";import{createCoordinateHelper as H}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,screenToMap as R,dragManipulatedObject as U}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as E}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as I}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as z}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as B}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as F}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as V}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as W}from"../../views/interactive/snapping/snappingUtils.js";const N=1e5;let q=class extends I{constructor(e){super(e),this._measurementLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool measurement layer"}),this._manipulatorLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool manipulator layer"}),this._snappingLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool snapping layer"}),this._updatingHandles=new v,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){i("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new O({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([r(async()=>{this.messages=await i("esri/core/t9n/Units")}),l(()=>[this.unit,this.messages],()=>{this._updatePolylines()},p),l(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),W(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=a(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=a(this._measurementLayer),this._manipulatorLayer=a(this._manipulatorLayer),this._snappingLayer=a(this._snappingLayer),this._updatingHandles=a(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}_getSnappingContext(e){return new F({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new B(new z("point",H(!1,!1,this.view.spatialReference)),2),visualizer:new T(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let l=this._vertices.length;l<e.length;l++){const[i,r]=e[l],s=new w({x:i,y:r,spatialReference:t}),n=J(s,this.view,this._manipulatorLayer);this.manipulators.add(n);const a=B.fromGeometry(s,2),p=[a.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[l].coord=[t.pos[0],t.pos[1]],this._updatePolylines())}),P(n,(e,t,i,r)=>{const s=this._getSnappingContext(r),{snappingManager:n}=this,o=this._updatingHandles,{snappingStep:l}=V({snappingContext:s,snappingManager:n,updatingHandles:o});t.next(R(this.view)).next(t=>{if("start"===t.action){const i=new w(t.mapStart);e.graphic.geometry=i,a.trySetGeometry(i)}return t}).next(...l).next(U({operations:a})).next(()=>{e.graphic.geometry=a.data.geometry})})];this._vertices.push({manipulator:n,coord:[i,r],handle:o(p)})}const i=this._vertices.length-1,r=this._vertices[i],[s,n]=e[i];r.coord[0]===s&&r.coord[1]===n||(r.coord=[s,n],r.manipulator.graphic.geometry=new w({x:s,y:n,spatialReference:t}));const a=this._drawActive?this._vertices[i].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==a||e!==a}),this._updatePolylines()}_updatePolylines(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=K(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:i,drawing:r,original:o}=e;this._set("measurement",i);const a=Y(this.messages,i,this.unit);let l,p;this._set("measurementLabel",a);const{graphics:m}=this._measurementLayer,c=2===m.length,{effectiveTheme:h}=this.view;c?(l=m.at(0),p=m.at(1)):(l=new t({symbol:new A({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[14,12],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:3.5,color:s(h.accentColor).toArray()},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:5,color:h.accentColor.toArray()}]}}})}),p=new t({symbol:new G({color:h.textColor,haloColor:n(s(h.textColor,160),.5),haloSize:2,font:new D({size:14,family:"sans-serif"})})}),m.removeAll(),m.addMany([l,p])),l.geometry=r,p.geometry=o.extent?.center,p.symbol.text=a}};function J(e,i,r){const s=n(i.effectiveTheme.accentColor,.5),o={type:"simple-line",width:0},a=8,l=new k({style:"circle",color:s,size:a,outline:o}),p=new k({style:"circle",color:s,size:1.5*a,outline:o}),m=new t({geometry:e,symbol:l});return new E({view:i,layer:r,graphic:m,focusedSymbol:p})}function K(e,t){const i=new L({paths:[e],spatialReference:t});let r,s;return t.isGeographic?g(t)?(r=_([i],"meters")[0],s=f(i,N)):(r=j(i,{unit:"meters"}),s=b(i,N,{unit:"meters"})):t.isWebMercator?(r=j(i,{unit:"meters"}),s=b(i,N,{unit:"meters"})):(r=x(i,{unit:"meters"}),s=i),{measurement:{geometry:s,length:r},original:i,drawing:s}}function Q(e){return null!=e}async function X(e){(e?.isGeographic&&!g(e)||e?.isWebMercator)&&await Promise.all([S(),M()])}function Y(e,t,i){if(!t||!e)return"";switch(i){case"metric":return h(e,t.length,"meters");case"imperial":return c(e,t.length,"meters");default:return m(e,u(t.length,"meters",i),i)}}e([d()],q.prototype,"_drawActive",void 0),e([d({readOnly:!0})],q.prototype,"cursor",null),e([d({value:!0})],q.prototype,"editable",null),e([d({readOnly:!0})],q.prototype,"measurement",void 0),e([d({readOnly:!0})],q.prototype,"measurementLabel",void 0),e([d()],q.prototype,"messages",void 0),e([d({constructOnly:!0})],q.prototype,"snappingManager",void 0),e([d()],q.prototype,"unit",void 0),e([d()],q.prototype,"updating",null),e([d({constructOnly:!0})],q.prototype,"view",void 0),q=e([y("esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DTool")],q);export{q as DistanceMeasurement2DTool,K as createDistanceMeasurementInfo2D,Y as createDistanceMeasurementLabel,Q as isSupported,X as loadGeometryOperators};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import n from"../../core/Logger.js";import{removeMaybe as o,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g,subclass as y}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as _,isStandardFeatureTemplate as F}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import T from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import U from"./Workflow.js";import{createToolFromGeometryType as L,findEditorItemForLayer as j,getServiceEditsFromWorkflowData as x,getServiceInfoForLayer as O,orderEditsByRelationshipDependencies as z,getFullTemplateForCreationInfo as W,getServiceLayersById as D,startCreatingNewFeature as R,findLayerInfo as G,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as K,getVisualVariableAttributes as Z,startUpdatingFeatureGeometry as q,createWorkflowSteps as B,avoidFeatureTemplateSelectionWithOnlyOneItem as J,getCreationAttributes as Q,setUpSketchCreateWatchers as X,setRelationshipFields as Y,prepareAttachmentsForCreateFeaturesWorkflow as $,showProgressCursor as ee,setVisualVariablesAndElevationInfoForUpdate as te,visualVariableInteractiveUpdate as ae}from"./workflowUtils.js";import ie from"../FeatureForm/FeatureFormViewModel.js";import re from"../Sketch/SketchViewModel.js";var se;const ne=Symbol(),oe=Symbol(),le=Symbol(),de=Symbol(),ce={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ue=se=class extends U{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ie,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:n}=a;return k("rectangle"===n||"circle"===n?n:i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=L(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ce[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([le])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{formViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?n.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:n,snappingManager:o,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?j(d.editorItems,u):void 0,p=new se({data:new T({creationInfo:s,editorItem:h,parent:n,sketchOptions:c,snappingManager:o,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:n}=r,o=n.capabilities?.editing.supportsGlobalId&&"globalIdField"in n,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=x(p.data),h=_(c)&&u;if(o){if(fe(s),h){let t=ge(u,l);const a=await(O(n,d.view)?.load());a&&(t=z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=we(s,l);await a(n,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(n,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(n,me(s,e.addFeatureResults,n,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await W(t,a);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:D(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(oe);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await R(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=o(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:n,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;o(this._featureFormHandle);const f=e.sourceLayer,w=G(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(n.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&K(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()}),u(()=>n.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[n.feature,n.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:n}=r,{view:o}=n;if(!o||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=Z(e),q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=B(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([le,ne,oe,de]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return J(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:n}=e,{creationInfo:o,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){o&&p.push(e._fadeExistingFeatures(o.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,n,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=Q(t.fullTemplate,o?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(oe)&&e._updatingHandles.addPromise(X({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:n}).then(t=>e.addHandles(t,oe)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(oe),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:n}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=n;if(e.numPendingFeatures!==o?.maxFeatures&&t||n.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await te({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ae(c,d,i,t)&&await N(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;n.setValue(e,a[e])}if(null!=s){const{field:e}=s;n.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!E(t.creationInfo))return e._startCreating()},v=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),he(s,a,t),...pe(t));const _=r(p);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new re({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:n}=a.viewModel;i.editType="INSERT",i.map=n?.map,i.spatialReference=n?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=o,d=l(e.geometry,"completion"),u=c(d)?await d:d;o.completionResults.push(u),Y(u.relationships),i.editType="INSERT",i.map=n?.map,i.spatialReference=n?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=G(s,a.sourceLayer));const n=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,n)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:n}=r.viewModel,o=r.addPendingFeature(e,t,{isAssociation:i});a??=G(n,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),o.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(le))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=n,f=[],w=[];this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=j(l.editorItems,n.layer),n.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,$(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=ee(c);f.push(g);const y=M(n.layer),{template:_}=n,b=!_||F(_)||v(_)&&"feature"===_.type,I=y&&b;try{if(I){const a=h??new t({attributes:Q(e.fullTemplate,n.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(se._configureSketchViewModel(this)),h?(E(n)&&n.geometryToPlace&&(h.attributes=Q(e.fullTemplate,n.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{E(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],le)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),de),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function he(e,t,a){let s=null;const n=()=>e.snappingOptions.featureSources,o=()=>(s=new C({layer:t}),n().add(s),s),d=()=>{null!=s&&(n().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=n().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=o(),s.enabled=t},f),i(d)])}function pe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function me(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach(({form:e})=>r.push({feature:n,attachment:e}))}}),r}function fe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function we(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ge(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ue.prototype,"allowSave",null),e([g()],ue.prototype,"createFeatureState",void 0),e([g()],ue.prototype,"data",void 0),e([g({constructOnly:!0})],ue.prototype,"isNested",void 0),e([g()],ue.prototype,"formViewModel",null),e([g()],ue.prototype,"hasInvalidFormTemplate",null),e([g()],ue.prototype,"hasPendingEdits",null),e([g()],ue.prototype,"hasPreviousStep",null),e([g()],ue.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ue.prototype,"helpMessage",null),e([g()],ue.prototype,"layer",null),e([g()],ue.prototype,"parent",null),e([g()],ue.prototype,"keyboardCancellationEnabled",null),e([g()],ue.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ue.prototype,"saveActionLabel",null),e([g()],ue.prototype,"shouldShowAttachments",null),e([g()],ue.prototype,"shouldAllowAttachmentEditing",null),e([g()],ue.prototype,"sketchViewModel",null),e([g()],ue.prototype,"availableCreateTools",null),e([g()],ue.prototype,"_attachmentsActive",null),ue=se=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ue);const ye=ue;export{ye as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import n from"../../core/Logger.js";import{removeMaybe as o,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g,subclass as y}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as _,isStandardFeatureTemplate as F}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import T from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import U from"./Workflow.js";import{createToolFromGeometryType as L,findEditorItemForLayer as j,getServiceEditsFromWorkflowData as x,getServiceInfoForLayer as O,orderEditsByRelationshipDependencies as z,getFullTemplateForCreationInfo as W,getServiceLayersById as D,startCreatingNewFeature as R,findLayerInfo as G,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as K,getVisualVariableAttributes as Z,startUpdatingFeatureGeometry as q,createWorkflowSteps as B,avoidFeatureTemplateSelectionWithOnlyOneItem as J,getCreationAttributes as Q,setUpSketchCreateWatchers as X,setRelationshipFields as Y,prepareAttachmentsForCreateFeaturesWorkflow as $,showProgressCursor as ee,setVisualVariablesAndElevationInfoForUpdate as te,visualVariableInteractiveUpdate as ae}from"./workflowUtils.js";import ie from"../FeatureForm/FeatureFormViewModel.js";import re from"../Sketch/SketchViewModel.js";var se;const ne=Symbol(),oe=Symbol(),le=Symbol(),de=Symbol(),ce={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ue=se=class extends U{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ie,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:n}=a;return k("rectangle"===n||"circle"===n?n:i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=L(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ce[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([le])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{formViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?n.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:n,snappingManager:o,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?j(d.editorItems,u):void 0,p=new se({data:new T({creationInfo:s,editorItem:h,parent:n,sketchOptions:c,snappingManager:o,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:n}=r,o=n.capabilities?.editing.supportsGlobalId&&"globalIdField"in n,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=x(p.data),h=_(c)&&u;if(o){if(fe(s),h){let t=ge(u,l);const a=await(O(n,d.view)?.load());a&&(t=z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=we(s,l);await a(n,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(n,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(n,me(s,e.addFeatureResults,n,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await W(t,a);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:D(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(oe);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await R(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=o(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:n,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;o(this._featureFormHandle);const f=e.sourceLayer,w=G(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(n.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&K(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()}),u(()=>n.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[n.feature,n.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:n}=r,{view:o}=n;if(!o||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=Z(e),q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=B(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([le,ne,oe,de]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return J(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:n}=e,{creationInfo:o,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){o&&p.push(e._fadeExistingFeatures(o.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,n,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=Q(t.fullTemplate,o?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(oe)&&e._updatingHandles.addPromise(X({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:n}).then(t=>e.addHandles(t,oe)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(oe),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:n}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=n;if(e.numPendingFeatures!==o?.maxFeatures&&t||n.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await te({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ae(c,d,i,t)&&await N(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;n.setValue(e,a[e])}if(null!=s){const{field:e}=s;n.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!E(t.creationInfo))return e._startCreating()},v=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),he(s,a,t),...pe(t));const _=r(p);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new re({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:n}=a.viewModel;i.editType="INSERT",i.map=n?.map,i.spatialReference=n?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=o,d=l(e.geometry,"completion"),u=c(d)?await d:d;o.completionResults.push(u),Y(u.relationships),i.editType="INSERT",i.map=n?.map,i.spatialReference=n?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=G(s,a.sourceLayer));const n=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,n)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:n}=r.viewModel,o=r.addPendingFeature(e,t,{isAssociation:i});a??=G(n,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),o.updateAttributes(s.getValues()),o.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(le))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=n,f=[],w=[];this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=j(l.editorItems,n.layer),n.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,$(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=ee(c);f.push(g);const y=M(n.layer),{template:_}=n,b=!_||F(_)||v(_)&&"feature"===_.type,I=y&&b;try{if(I){const a=h??new t({attributes:Q(e.fullTemplate,n.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(se._configureSketchViewModel(this)),h?(E(n)&&n.geometryToPlace&&(h.attributes=Q(e.fullTemplate,n.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{E(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],le)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),de),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function he(e,t,a){let s=null;const n=()=>e.snappingOptions.featureSources,o=()=>(s=new C({layer:t}),n().add(s),s),d=()=>{null!=s&&(n().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=n().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=o(),s.enabled=t},f),i(d)])}function pe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function me(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach(({form:e})=>r.push({feature:n,attachment:e}))}}),r}function fe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function we(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ge(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ue.prototype,"allowSave",null),e([g()],ue.prototype,"createFeatureState",void 0),e([g()],ue.prototype,"data",void 0),e([g({constructOnly:!0})],ue.prototype,"isNested",void 0),e([g()],ue.prototype,"formViewModel",null),e([g()],ue.prototype,"hasInvalidFormTemplate",null),e([g()],ue.prototype,"hasPendingEdits",null),e([g()],ue.prototype,"hasPreviousStep",null),e([g()],ue.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ue.prototype,"helpMessage",null),e([g()],ue.prototype,"layer",null),e([g()],ue.prototype,"parent",null),e([g()],ue.prototype,"keyboardCancellationEnabled",null),e([g()],ue.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ue.prototype,"saveActionLabel",null),e([g()],ue.prototype,"shouldShowAttachments",null),e([g()],ue.prototype,"shouldAllowAttachmentEditing",null),e([g()],ue.prototype,"sketchViewModel",null),e([g()],ue.prototype,"availableCreateTools",null),e([g()],ue.prototype,"_attachmentsActive",null),ue=se=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ue);const ye=ue;export{ye 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/units.js";import{distance as s,lerp as o}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{l as a}from"../../../chunks/vec32.js";import i from"../../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../../geometry/projectionUtils.js";import l from"../../../geometry/SpatialReference.js";import{geodesicLengths as f,isSupported as h,inverseGeodeticSolver as p,directGeodeticSolver as m}from"../../../geometry/support/geodesicUtils.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as g}from"./ProfileGenerationError.js";async function w(e,t,s,o,a,i,h){let p,m,d;const w=e.spatialReference,j=w.isGeographic||w.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(h),v=t(e,{unit:"meters"}),n(h)}const P=1/r(o);if(j){await c([{source:w,dest:o},{source:w,dest:l.WGS84}],h);const n=D(e);p=f([n],"meters")[0];const r=R(p,a);if(L(e,p,r)>i)throw new g("too-complex");const j=y(n,t,s);({densifiedPath:m,distances:d}=A(j,r,P)),m=u(m,o)}else{await c([{source:w,dest:o}],h),p=v;const r=R(p,a);if(L(e,p,r)>i)throw new g("too-complex");const l=y(e,t,s);({densifiedPath:m,distances:d}=b(l,r,P)),n(h),m=u(m,o)}return{densifiedPath:m,pathLength:p*P,distances:d}}function R(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function y(e,t,n){if(null==t)return P(e);const r=e.spatialReference,s=t.mode,o=d(t,r);let a=null;switch(n.type){case"2d":a=j(e,s,o);break;case"3d":a=v(e,s,o,n)}return null==a?P(e):new i({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,a)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:s}){const o=(t,n,r,o)=>s?.getElevation(t,n,r,e,o)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,o(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+o(e,t,n,"ground")+r]:([e,t])=>[e,t,o(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+o(e,t,n,"scene")+r]:([e,t])=>[e,t,o(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new i({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,([e,t])=>[e,t])}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let s=0;s<n;++s){const n=e[s],o=n.length,a=new Array(n.length);r[s]=a;for(let e=0;e<o;++e)a[e]=t(n[e])}return r}function x(e){return M(e)&&e.paths.length>0&&e.paths.every(e=>e.length>=2)}function M(e){return null!=e&&"polyline"===e.type}function S(t,n,s,o,a){const{spatialReference:c,hasZ:u}=t,l={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:c,metersPerSR:r(c)},f=[],h=[];let p=0;for(let r=0;r<t.paths.length;++r){const i=t.paths[r],c=new Array,u=new Array;let m=0;for(let t=1;t<i.length;++t){const r=i[t-1],f=i[t],h=o(l,r,f);let d;for(d=m;d<h.distance&&!e(d,h.distance);d+=n)c.push(a(h,d)),u.push((p+d)*s);m=d-h.distance,p+=h.distance,c.push(f),u.push(p*s)}f[r]=c,h[r]=u}return{densifiedPath:new i({spatialReference:c,hasZ:u,paths:f}),distances:h}}function b(e,t,n){const{hasZ:r}=e;return S(e,t,n,z,r?E:k)}function A(e,t,n){const{hasZ:r}=e;return S(e,t,n,U,r?W:G)}function U(e,t,n){return e.distance=0,p(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function z(e,t,n){return e.from=t,e.to=n,e.distance=s(n,t)*e.metersPerSR,e}function G({from:e,azimuth:t,spatialReference:n},r){return m([0,0],e,t,r,n)}function W({from:e,to:n,azimuth:r,distance:s,spatialReference:o},a){const i=a/s,c=[0,0,t(e[2],n[2],i)];return m(c,e,r,a,o),c}function k({from:e,to:t,distance:n},r){return o([0,0],e,t,r/n)}function E({from:e,to:t,distance:n},r){return a([0,0,0],e,t,r/n)}function D(e){return h(e.spatialReference)?e:u(e,l.WGS84)}function I(e){return e.paths.reduce((e,t)=>e+t.length,0)}function L(e,t,n){return I(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce(e=>1+e,0)-1)}export{I as countPoints,w as densifyPath,M as isPolyline,x as isValidInputPath,y as toAbsoluteHeightElevation};
5
+ import{floatEqualUlp as e,lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/units.js";import{distance as s,lerp as o}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{l as a}from"../../../chunks/vec32.js";import{geodesicLengths as i,isSupported as c,inverseGeodeticSolver as u,directGeodeticSolver as l}from"../../../geometry/geodesicUtils.js";import f from"../../../geometry/Polyline.js";import{initializeProjection as h,project as p}from"../../../geometry/projectionUtils.js";import m from"../../../geometry/SpatialReference.js";import{getElevationOffset as d}from"../../../support/elevationInfoUtils.js";import{ProfileGenerationError as g}from"./ProfileGenerationError.js";async function w(e,t,s,o,a,c,u){let l,f,d;const w=e.spatialReference,j=w.isGeographic||w.isWebMercator;let v=0;if(!j){const{execute:t}=await import("../../../geometry/operators/lengthOperator.js");n(u),v=t(e,{unit:"meters"}),n(u)}const P=1/r(o);if(j){await h([{source:w,dest:o},{source:w,dest:m.WGS84}],u);const n=D(e);l=i([n],"meters")[0];const r=R(l,a);if(L(e,l,r)>c)throw new g("too-complex");const j=y(n,t,s);({densifiedPath:f,distances:d}=A(j,r,P)),f=p(f,o)}else{await h([{source:w,dest:o}],u),l=v;const r=R(l,a);if(L(e,l,r)>c)throw new g("too-complex");const i=y(e,t,s);({densifiedPath:f,distances:d}=b(i,r,P)),n(u),f=p(f,o)}return{densifiedPath:f,pathLength:l*P,distances:d}}function R(e,t){const n=e/t.densificationMaxSamples;return Math.max(t.samplingDistance,n)}function y(e,t,n){if(null==t)return P(e);const r=e.spatialReference,s=t.mode,o=d(t,r);let a=null;switch(n.type){case"2d":a=j(e,s,o);break;case"3d":a=v(e,s,o,n)}return null==a?P(e):new f({hasZ:!0,hasM:!1,spatialReference:r,paths:Z(e.paths,a)})}function j({hasZ:e},t,n){return"absolute-height"===t?e?([e,t,r])=>[e,t,r+n]:([e,t])=>[e,t,n]:null}function v({spatialReference:e,hasZ:t},n,r,{elevationProvider:s}){const o=(t,n,r,o)=>s?.getElevation(t,n,r,e,o)??0;switch(n){case"on-the-ground":return([e,t])=>[e,t,o(e,t,0,"ground")];case"absolute-height":return t?([e,t,n])=>[e,t,n+r]:([e,t])=>[e,t,r];case"relative-to-ground":return t?([e,t,n])=>[e,t,n+o(e,t,n,"ground")+r]:([e,t])=>[e,t,o(e,t,0,"ground")+r];case"relative-to-scene":return t?([e,t,n])=>[e,t,n+o(e,t,n,"scene")+r]:([e,t])=>[e,t,o(e,t,0,"scene")+r];default:return null}}function P(e){return e.hasZ?new f({hasZ:!1,hasM:!1,spatialReference:e.spatialReference,paths:Z(e.paths,([e,t])=>[e,t])}):e}function Z(e,t){const n=e.length,r=new Array(n);for(let s=0;s<n;++s){const n=e[s],o=n.length,a=new Array(n.length);r[s]=a;for(let e=0;e<o;++e)a[e]=t(n[e])}return r}function x(e){return M(e)&&e.paths.length>0&&e.paths.every(e=>e.length>=2)}function M(e){return null!=e&&"polyline"===e.type}function S(t,n,s,o,a){const{spatialReference:i,hasZ:c}=t,u={from:null,to:null,distance:0,azimuth:0,reverseAzimuth:0,spatialReference:i,metersPerSR:r(i)},l=[],h=[];let p=0;for(let r=0;r<t.paths.length;++r){const i=t.paths[r],c=new Array,f=new Array;let m=0;for(let t=1;t<i.length;++t){const r=i[t-1],l=i[t],h=o(u,r,l);let d;for(d=m;d<h.distance&&!e(d,h.distance);d+=n)c.push(a(h,d)),f.push((p+d)*s);m=d-h.distance,p+=h.distance,c.push(l),f.push(p*s)}l[r]=c,h[r]=f}return{densifiedPath:new f({spatialReference:i,hasZ:c,paths:l}),distances:h}}function b(e,t,n){const{hasZ:r}=e;return S(e,t,n,z,r?E:k)}function A(e,t,n){const{hasZ:r}=e;return S(e,t,n,U,r?W:G)}function U(e,t,n){return e.distance=0,u(e,t,n,e.spatialReference),e.from=t,e.to=n,e}function z(e,t,n){return e.from=t,e.to=n,e.distance=s(n,t)*e.metersPerSR,e}function G({from:e,azimuth:t,spatialReference:n},r){return l([0,0],e,t,r,n)}function W({from:e,to:n,azimuth:r,distance:s,spatialReference:o},a){const i=a/s,c=[0,0,t(e[2],n[2],i)];return l(c,e,r,a,o),c}function k({from:e,to:t,distance:n},r){return o([0,0],e,t,r/n)}function E({from:e,to:t,distance:n},r){return a([0,0,0],e,t,r/n)}function D(e){return c(e.spatialReference)?e:p(e,m.WGS84)}function I(e){return e.paths.reduce((e,t)=>e+t.length,0)}function L(e,t,n){return I(e)+Math.floor(t/n)+Math.max(0,e.paths.reduce(e=>1+e,0)-1)}export{I as countPoints,w as densifyPath,M as isPolyline,x as isValidInputPath,y as toAbsoluteHeightElevation};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{createArea as n,createLength as r}from"../../core/quantity.js";import{formatArea as a,formatLength as o}from"../../core/quantityFormatUtils.js";import{set as i,determinant as s}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{h as m,f as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import w from"../../geometry/Polyline.js";import{projectWithZConversion as x,project as R}from"../../geometry/projectionUtils.js";import M from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{e as L}from"../../chunks/simplifyOperator.js";import{isSupported as I,geodesicLengths as W,geodesicAreas as k}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as q,imageToWorld as G}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as A,scaleWithFactor as D}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const S=1e5,F="meters",T="square-meters";function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function C(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,i=o-a;return[r+i*Math.cos(n),a+i*Math.sin(n)]}async function J(t,e,n){if(await v(),I(t)){const t=W([e],F)[0];return{area:k([n],T)[0],perimeter:t}}const r=M.WGS84,a=R(e,r),o=R(n,r);let i=j(o,S);if(i=i?L(i):null,!i)return null;const s=W([a],F)[0];return{area:k([i],T)[0],perimeter:s}}async function K(t,n,r,a,o=!1,i){if(n.length<2||!a||!r||!t)return null;const s=zt(r,t);if(!s)return null;const c=n.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map(e=>It([u,l],e,t,o,!1)),m=await Promise.all(f);e(i);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function N(t,n,r,a,o,i=!1,s){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=dt(r,t),u=n.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(e=>Wt([l,f],e,t,o,i,!1)),p=await Promise.all(m);e(s);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function Q(t,e,n=1){const r=Rt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*n/e}async function X(t){await b();const e=t.spatialReference;if(e.isGeographic){if(I(e))return W([t],F)[0];const n=R(t,M.WGS84);return W([n],F)[0]}return e.isWebMercator?O(t,{unit:F}):E(t,{unit:F})}function Y(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map(e=>t.map(t=>t[e]).filter(t=>null!==t)).map(t=>t.length?jt(t):0);return[e,n,r]}function Z(t,e){const n=L(e);if(!n)return null;const r=E(t,{unit:F});return{area:z(n,{unit:T}),perimeter:r}}function $(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function _(t,e){await Promise.all([d(),v(),b()]);let n=j(e,S);if(n=n?L(n):null,!n)return null;const r=O(t,{unit:F});return{area:P(n,{unit:T}),perimeter:r}}async function tt(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await G(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function et(t,n,r,a){const{attributes:o}=r,{location:i}=o,{updateElevationProps:s,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await x(u,M.WebMercator));const l=await q(t,{...c,cameraLocation:u},s);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function nt(t,e,n,r,a=0,o=1,i){const{averageElevation:s,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),w=n.at(0),x=n.at(-1);if(!w||!x)return null;const R=f([w.x,w.y],[x.x,x.y])*t/g;return nt(R,e,n,r,a+1,Math.abs(t-R))}function rt(t,e,n,r,a=0,o=1,i){const{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),w=n.at(0),x=n.at(-1);if(!w||!x)return null;const R=f([w.x,w.y],[x.x,x.y])*t/g;return rt(R,e,n,r,a+1,Math.abs(t-R))}async function at(t,e,n){return t.spatialReference&&!e.spatialReference.equals(t.spatialReference)&&(e=await x(e,t.spatialReference)),new w({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function ot(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function it(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ct(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function ut(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function lt(t,e){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function ft(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:i}=r;for(let t=0;t<i.length;t++){const i=await at(r.camera,r.measurePoints[t],o),s=await at(a.camera,a.measurePoints[t],o),c=await Dt(i,s);if(!c)return null;const u=lt(c,o);u.spatialReference.isWebMercator&&(n=ot(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:it(e,n),horizontalDistance:st(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ct(e),aspect:ut(e)}}}return null}async function mt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:i,measurePoints:s}=r,c=await at(a,o[0],e),u=await at(i,s[0],e),l=await Dt(c,u);return l?lt(l,e)??null:null}async function pt(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:i}=r;for(let l=0;l<i.length;l++){const t=await at(r.camera,r.measurePoints[l],o),e=await at(a.camera,a.measurePoints[l],o),i=await Dt(t,e);if(!i)return null;const s=lt(i,o);n.push([s.x,s.y,s.z??0])}if(n?.length<2)return null;const s=new w({paths:[n],spatialReference:e}),c=new g({rings:[n],spatialReference:e});if(e.isGeographic){const t=await J(e,s,c);return t?.area??null}if(e.isWebMercator){const t=await _(s,c);return t?.area??null}const u=Z(s,c);return u?.area??null}function ht(t,e){if(!t)return null;return{camera:e.geometry.clone(),measurePoints:Array.isArray(t)?t:[t]}}async function yt(t,e){const{updateElevationProps:n,...r}=e;return await G(t,r,n)}async function gt(t,e){const{updateElevationProps:n,...r}=e;return q(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function xt(t){const e=t.map(t=>[t.x,t.y]),n=t[0].spatialReference;return new w({paths:[e],spatialReference:n})}function Rt(t,e){return t.map(t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]}))}function Mt(t,e,n,a,i){const s="measurement"===t?e:n;if(i&&s)return o(a,r(s,F),i,3)||null}function zt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(e.every(t=>0===t)||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],w=[-l,0,l],x=[];for(const R of p)for(const e of h)for(const a of g)for(const u of g)for(const l of w){const f={...t};f.cameraPitch=n+R,f.cameraRoll=r+e,f.cameraLocation=new y({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),x.push(f)}return x}function dt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:i,spatialReference:s}=r;if(e.every(t=>0===t)||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+g,u.cameraLocation=new y({x:a+e,y:o+r,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Pt(t,e,n,a,i){const s="measurement"===t?e:jt(n);if(i&&s)return o(a,r(s,F),i,3)||null}function vt(t,e,r,o,i){const s="measurement"===t?e:r;if(i&&s)return a(o,n(s,T),i,3)||null}function jt(t){return Math.sqrt(t.reduce((t,e)=>t+e**2,0))}function bt(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=A(r,n[0],n[1]);return[a.x,a.y]}function Ot(t){return t.metersPerUnit}function Et(t,e,n){let r=[];return r="panoramic"===e?t.map(([t,e,r])=>{const{x:a,y:o}=A({x:t,y:e,z:r},n[0],n[1]);return[a-.5,-.5-o]}):t.map(([t,e])=>[t-.5,-.5-e]),r}function Lt(t,e){return t.map(t=>A({x:t[0],y:t[1],z:t[2]},e[0],e[1]))}async function It(t,n,r,a=!1,o=!1,i){if(!t||!n||t.length<2)return null;const s=Rt(t,a);if(!s||s.length<2)return null;const[c,u]=[s[0],s.at(-1)];if(!u)return null;const l=[c],m=await G(c,n);e(i);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:w,...x}=n,R=B(p,x),M=f([c.x,c.y],[R.x,R.y]),z=H(c,R);if(!z)return;const d=C([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Ot(n.cameraLocation.spatialReference)/M;if(!o)return P;const v=nt(P,m,l,n,0,1);return v?.value}async function Wt(t,n,r,a,o=!1,i=!1,s){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let w=u.clone();w.spatialReference.isGeographic&&(w=await x(w,M.WebMercator));const R=await q(h,{...m,cameraLocation:w},l);e(s);const z=R.clone();z.z?z.z+=20:z.z=20;const d=U(z,m),P=f([h.x,h.y],[d.x,d.y]),v=H(h,d);if(!v)return;const j=C([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Ot(n.cameraLocation.spatialReference)/P;if(!i)return b;const O=rt(b,R,g,n,0,1);return O?.value}async function kt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await yt(r,e),o=a.map(({x:t,y:e})=>[t,e]);t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new w({paths:[o],spatialReference:i}),c=new g({rings:[o],spatialReference:i});return i.isGeographic?J(i,s,c):i.isWebMercator?_(s,c):Z(s,c)}async function qt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),i=await gt(o,n);e(a);const s=i.map(({x:t,y:e})=>[t,e]);t.push(t[0]),s.push(s[0]);const c=i[0].spatialReference,u=new w({paths:[s],spatialReference:c}),l=new g({rings:[s],spatialReference:c});return c.isGeographic?J(c,u,l):c.isWebMercator?_(u,l):Z(u,l)}async function Gt(t,e,n=!1){const r=Rt(t,n);return X(xt(await yt(r,e)))}async function At(t,n,r=!1,a){const o=Rt(t,r),i=await gt(o,n);e(a);return X(xt(i))}async function Dt(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(e)):(o=E(t),u=E(e));const l=$(t.paths[0],o),f=$(e.paths[0],u),m=Ut(l,f),[p,h,y]=l,[g,w,x]=f.map(t=>-t),[R,M,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];i(n,p,g,R,h,w,M,y,x,z);const j=s(n);if(0===j)return null;i(n,d,g,R,P,w,M,v,x,z);const L=s(n);i(n,p,d,R,h,P,M,y,v,z);const I=s(n);i(n,p,g,d,h,w,P,y,x,v);const W=L/j,k=I/j,q=s(n)/j;return{distance:Math.abs(q/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Bt(r,W,l),pointOnB:Bt(a,k,f)}}function Ut(t,e){const n=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),e[0],e[1],e[2]),o=p(n,r,a);return[o[0],o[1],o[2]]}function Bt(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function St(t,e){const n=l(t[0],t[1],t[2]),r=l(e[0],e[1],e[2]);return h(u(),n,r)}function Ft(t,e,n){const r=D(t,e,n);return[r[0],r[1],r[2]]}export{H as calculateAngle,V as calculateAnglePano,C as calculateCorrectedPixel,K as calculateHeightAccuracy,N as calculateHeightAccuracyPanoramic,Q as calculateHeightFromTemporaryDistance,Y as calculateLocationAccuracyFromDeviations,et as calculateReferenceImagePointPanoramic,tt as calculateTempImagePoint,nt as computeHeightIteratively,rt as computeHeightIterativelyPanoramic,pt as computeTriangulatedAreaMeasurement,ft as computeTriangulatedDistanceMeasurement,mt as computeTriangulatedPoint,ht as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,zt as generateCombinations,dt as generateCombinationsPanoramic,vt as getConvertedArea,Pt as getConvertedDistance,Mt as getConvertedHeight,bt as getModeCorrectedPoint,Et as getModeCorrectedPoints,Lt as getPixelLocationFromSphereVertices,jt as getRootOfSumOfSquaredErrors,Ot as getUnitRateFromSpatialReference,It as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,qt as pixelAreaMeasurementPanoramic,Gt as pixelDistanceMeasurement2D,At as pixelDistanceMeasurementPanoramic,Ft as scale,Dt as solveSkewLinesIntersection,St as subtract};
5
+ import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{createArea as n,createLength as r}from"../../core/quantity.js";import{formatArea as a,formatLength as o}from"../../core/quantityFormatUtils.js";import{set as i,determinant as s}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{h as m,f as p,a as h}from"../../chunks/vec32.js";import{isSupported as y,geodesicLengths as g,geodesicAreas as w}from"../../geometry/geodesicUtils.js";import x from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import M from"../../geometry/Polyline.js";import{projectWithZConversion as z,project as d}from"../../geometry/projectionUtils.js";import P from"../../geometry/SpatialReference.js";import{e as v}from"../../chunks/areaOperator.js";import{l as j,e as b}from"../../chunks/geodeticAreaOperator.js";import{l as O,e as E}from"../../chunks/geodeticDensifyOperator.js";import{l as L,e as I}from"../../chunks/geodeticLengthOperator.js";import{e as W}from"../../chunks/lengthOperator.js";import{e as k}from"../../chunks/simplifyOperator.js";import{imageToWorldPanoramic as q,imageToWorld as G}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as A,scaleWithFactor as D}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const S=1e5,F="meters",T="square-meters";function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function C(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,i=o-a;return[r+i*Math.cos(n),a+i*Math.sin(n)]}async function J(t,e,n){if(await O(),y(t)){const t=g([e],F)[0];return{area:w([n],T)[0],perimeter:t}}const r=P.WGS84,a=d(e,r),o=d(n,r);let i=E(o,S);if(i=i?k(i):null,!i)return null;const s=g([a],F)[0];return{area:w([i],T)[0],perimeter:s}}async function K(t,n,r,a,o=!1,i){if(n.length<2||!a||!r||!t)return null;const s=zt(r,t);if(!s)return null;const c=n.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map(e=>It([u,l],e,t,o,!1)),m=await Promise.all(f);e(i);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function N(t,n,r,a,o,i=!1,s){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=dt(r,t),u=n.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(e=>Wt([l,f],e,t,o,i,!1)),p=await Promise.all(m);e(s);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function Q(t,e,n=1){const r=Rt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*n/e}async function X(t){await L();const e=t.spatialReference;if(e.isGeographic){if(y(e))return g([t],F)[0];const n=d(t,P.WGS84);return g([n],F)[0]}return e.isWebMercator?I(t,{unit:F}):W(t,{unit:F})}function Y(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map(e=>t.map(t=>t[e]).filter(t=>null!==t)).map(t=>t.length?jt(t):0);return[e,n,r]}function Z(t,e){const n=k(e);if(!n)return null;const r=W(t,{unit:F});return{area:v(n,{unit:T}),perimeter:r}}function $(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function _(t,e){await Promise.all([j(),O(),L()]);let n=E(e,S);if(n=n?k(n):null,!n)return null;const r=I(t,{unit:F});return{area:b(n,{unit:T}),perimeter:r}}async function tt(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await G(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function et(t,n,r,a){const{attributes:o}=r,{location:i}=o,{updateElevationProps:s,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await z(u,P.WebMercator));const l=await q(t,{...c,cameraLocation:u},s);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function nt(t,e,n,r,a=0,o=1,i){const{averageElevation:s,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new x({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),y=f([n[0].x,n[0].y],[h.x,h.y]),g=n.at(0),w=n.at(-1);if(!g||!w)return null;const R=f([g.x,g.y],[w.x,w.y])*t/y;return nt(R,e,n,r,a+1,Math.abs(t-R))}function rt(t,e,n,r,a=0,o=1,i){const{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new x({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),y=f([n[0].x,n[0].y],[h.x,h.y]),g=n.at(0),w=n.at(-1);if(!g||!w)return null;const R=f([g.x,g.y],[w.x,w.y])*t/y;return rt(R,e,n,r,a+1,Math.abs(t-R))}async function at(t,e,n){return t.spatialReference&&!e.spatialReference.equals(t.spatialReference)&&(e=await z(e,t.spatialReference)),new M({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function ot(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function it(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ct(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function ut(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function lt(t,e){return new x({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function ft(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:i}=r;for(let t=0;t<i.length;t++){const i=await at(r.camera,r.measurePoints[t],o),s=await at(a.camera,a.measurePoints[t],o),c=await Dt(i,s);if(!c)return null;const u=lt(c,o);u.spatialReference.isWebMercator&&(n=ot(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:it(e,n),horizontalDistance:st(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ct(e),aspect:ut(e)}}}return null}async function mt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:i,measurePoints:s}=r,c=await at(a,o[0],e),u=await at(i,s[0],e),l=await Dt(c,u);return l?lt(l,e)??null:null}async function pt(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:i}=r;for(let l=0;l<i.length;l++){const t=await at(r.camera,r.measurePoints[l],o),e=await at(a.camera,a.measurePoints[l],o),i=await Dt(t,e);if(!i)return null;const s=lt(i,o);n.push([s.x,s.y,s.z??0])}if(n?.length<2)return null;const s=new M({paths:[n],spatialReference:e}),c=new R({rings:[n],spatialReference:e});if(e.isGeographic){const t=await J(e,s,c);return t?.area??null}if(e.isWebMercator){const t=await _(s,c);return t?.area??null}const u=Z(s,c);return u?.area??null}function ht(t,e){if(!t)return null;return{camera:e.geometry.clone(),measurePoints:Array.isArray(t)?t:[t]}}async function yt(t,e){const{updateElevationProps:n,...r}=e;return await G(t,r,n)}async function gt(t,e){const{updateElevationProps:n,...r}=e;return q(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function xt(t){const e=t.map(t=>[t.x,t.y]),n=t[0].spatialReference;return new M({paths:[e],spatialReference:n})}function Rt(t,e){return t.map(t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]}))}function Mt(t,e,n,a,i){const s="measurement"===t?e:n;if(i&&s)return o(a,r(s,F),i,3)||null}function zt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(e.every(t=>0===t)||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],y=[-u,0,u],g=[-l,0,l],w=[];for(const R of p)for(const e of h)for(const a of y)for(const u of y)for(const l of g){const f={...t};f.cameraPitch=n+R,f.cameraRoll=r+e,f.cameraLocation=new x({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function dt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:i,spatialReference:s}=r;if(e.every(t=>0===t)||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const y of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+y,u.cameraLocation=new x({x:a+e,y:o+r,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Pt(t,e,n,a,i){const s="measurement"===t?e:jt(n);if(i&&s)return o(a,r(s,F),i,3)||null}function vt(t,e,r,o,i){const s="measurement"===t?e:r;if(i&&s)return a(o,n(s,T),i,3)||null}function jt(t){return Math.sqrt(t.reduce((t,e)=>t+e**2,0))}function bt(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=A(r,n[0],n[1]);return[a.x,a.y]}function Ot(t){return t.metersPerUnit}function Et(t,e,n){let r=[];return r="panoramic"===e?t.map(([t,e,r])=>{const{x:a,y:o}=A({x:t,y:e,z:r},n[0],n[1]);return[a-.5,-.5-o]}):t.map(([t,e])=>[t-.5,-.5-e]),r}function Lt(t,e){return t.map(t=>A({x:t[0],y:t[1],z:t[2]},e[0],e[1]))}async function It(t,n,r,a=!1,o=!1,i){if(!t||!n||t.length<2)return null;const s=Rt(t,a);if(!s||s.length<2)return null;const[c,u]=[s[0],s.at(-1)];if(!u)return null;const l=[c],m=await G(c,n);e(i);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:w,...x}=n,R=B(p,x),M=f([c.x,c.y],[R.x,R.y]),z=H(c,R);if(!z)return;const d=C([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Ot(n.cameraLocation.spatialReference)/M;if(!o)return P;const v=nt(P,m,l,n,0,1);return v?.value}async function Wt(t,n,r,a,o=!1,i=!1,s){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let w=u.clone();w.spatialReference.isGeographic&&(w=await z(w,P.WebMercator));const x=await q(h,{...m,cameraLocation:w},l);e(s);const R=x.clone();R.z?R.z+=20:R.z=20;const M=U(R,m),d=f([h.x,h.y],[M.x,M.y]),v=H(h,M);if(!v)return;const j=C([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Ot(n.cameraLocation.spatialReference)/d;if(!i)return b;const O=rt(b,x,g,n,0,1);return O?.value}async function kt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await yt(r,e),o=a.map(({x:t,y:e})=>[t,e]);t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new M({paths:[o],spatialReference:i}),c=new R({rings:[o],spatialReference:i});return i.isGeographic?J(i,s,c):i.isWebMercator?_(s,c):Z(s,c)}async function qt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),i=await gt(o,n);e(a);const s=i.map(({x:t,y:e})=>[t,e]);t.push(t[0]),s.push(s[0]);const c=i[0].spatialReference,u=new M({paths:[s],spatialReference:c}),l=new R({rings:[s],spatialReference:c});return c.isGeographic?J(c,u,l):c.isWebMercator?_(u,l):Z(u,l)}async function Gt(t,e,n=!1){const r=Rt(t,n);return X(xt(await yt(r,e)))}async function At(t,n,r=!1,a){const o=Rt(t,r),i=await gt(o,n);e(a);return X(xt(i))}async function Dt(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await L(),o=I(t),u=I(e)):(o=W(t),u=W(e));const l=$(t.paths[0],o),f=$(e.paths[0],u),m=Ut(l,f),[p,h,y]=l,[g,w,x]=f.map(t=>-t),[R,M,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];i(n,p,g,R,h,w,M,y,x,z);const j=s(n);if(0===j)return null;i(n,d,g,R,P,w,M,v,x,z);const b=s(n);i(n,p,d,R,h,P,M,y,v,z);const O=s(n);i(n,p,g,d,h,w,P,y,x,v);const E=b/j,k=O/j,q=s(n)/j;return{distance:Math.abs(q/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Bt(r,E,l),pointOnB:Bt(a,k,f)}}function Ut(t,e){const n=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),e[0],e[1],e[2]),o=p(n,r,a);return[o[0],o[1],o[2]]}function Bt(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function St(t,e){const n=l(t[0],t[1],t[2]),r=l(e[0],e[1],e[2]);return h(u(),n,r)}function Ft(t,e,n){const r=D(t,e,n);return[r[0],r[1],r[2]]}export{H as calculateAngle,V as calculateAnglePano,C as calculateCorrectedPixel,K as calculateHeightAccuracy,N as calculateHeightAccuracyPanoramic,Q as calculateHeightFromTemporaryDistance,Y as calculateLocationAccuracyFromDeviations,et as calculateReferenceImagePointPanoramic,tt as calculateTempImagePoint,nt as computeHeightIteratively,rt as computeHeightIterativelyPanoramic,pt as computeTriangulatedAreaMeasurement,ft as computeTriangulatedDistanceMeasurement,mt as computeTriangulatedPoint,ht as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,zt as generateCombinations,dt as generateCombinationsPanoramic,vt as getConvertedArea,Pt as getConvertedDistance,Mt as getConvertedHeight,bt as getModeCorrectedPoint,Et as getModeCorrectedPoints,Lt as getPixelLocationFromSphereVertices,jt as getRootOfSumOfSquaredErrors,Ot as getUnitRateFromSpatialReference,It as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,qt as pixelAreaMeasurementPanoramic,Gt as pixelDistanceMeasurement2D,At as pixelDistanceMeasurementPanoramic,Ft as scale,Dt as solveSkewLinesIntersection,St as subtract};
package/widgets/Popup.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{ignoreAbortErrors as i,after as o}from"../core/promiseUtils.js";import{watch as n,on as s,initial as r,whenOnce as l}from"../core/reactiveUtils.js";import{waitAnimationFrame as a}from"../core/scheduling.js";import{stripHTML as d}from"../core/string.js";import{property as c,subclass as h}from"../core/accessorSupport/decorators.js";import u from"../support/actions/ActionButton.js";import p from"./Features.js";import g from"./Widget.js";import v from"./Features/FeaturesViewModel.js";import{css as f}from"./Popup/css.js";import m from"./Popup/PopupViewModel.js";import w from"./Popup/PopupVisibleElements.js";import{globalCss as b}from"./support/globalCss.js";import{tsx as _,messageBundle as M,vmEvent as k}from"./support/widget.js";import{isRTL as y}from"./support/widgetUtils.js";const E=200,C={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let D=class extends g{constructor(e,t){super(e,t),this._dockAction=new u({id:"popup-dock-action"}),this._featuresWidget=new p({responsiveActionsEnabled:!0}),this._containerNode=null,this._mainContainerNode=null,this._pointerOffsetInPx=16,this._focusAbortController=null,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.viewModel=new m,this.visibleElements=new w}initialize(){this.addHandles([n(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),r),n(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),r),n(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},r),n(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),n(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),n(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),n(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),n(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),n(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),n(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,r),n(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,r),n(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,r),n(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,r),n(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,r),n(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,r),n(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,r),n(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,r),n(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,r),n(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,r),n(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,r),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new v,this._featuresWidget.destroy()),this._focusAbortController?.abort()}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||C}set dockOptions(e){const t={...C},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...t,...e},s={...t.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._handleFocus()}next(){return this.viewModel.next()}open(e){const t=!!e&&!!e.featureMenuOpen,i={collapsed:!!e&&!!e.collapsed,featureMenuOpen:t};this.set(i),this.viewModel.open(e),e?.shouldFocus&&this._handleFocus(!0)}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:n}=this.viewModel,s=o&&e,r=o&&!e,l=this.selectedFeature?.layer?.title,a=this.selectedFeature?.layer?.id,c={[f.alignTopCenter]:"top-center"===t,[f.alignBottomCenter]:"bottom-center"===t,[f.alignTopLeft]:"top-left"===t,[f.alignBottomLeft]:"bottom-left"===t,[f.alignTopRight]:"top-right"===t,[f.alignBottomRight]:"bottom-right"===t,[f.isDocked]:s,[f.shadow]:r,[f.isDockedTopLeft]:"top-left"===i,[f.isDockedTopCenter]:"top-center"===i,[f.isDockedTopRight]:"top-right"===i,[f.isDockedBottomLeft]:"bottom-left"===i,[f.isDockedBottomCenter]:"bottom-center"===i,[f.isDockedBottomRight]:"bottom-right"===i};return _("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":d(this.title??""),"aria-modal":"false",bind:this,class:this.classes(f.base,c,{[f.baseHidden]:!n&&!e}),"data-layer-id":a,"data-layer-title":l,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:_("div",{class:f.pointer,key:"popup-pointer",role:"presentation"},_("div",{class:this.classes(f.pointerDirection,f.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[f.shadow]:e};return _("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(f.main,b.widget,t)},this._featuresWidget.render())}_getAnimationDurationMS(){const{_containerNode:e}=this;return e?1e3*parseFloat(window.getComputedStyle(e).animationDuration):E}async _handleFocus(e=!1){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const t=this._focusAbortController.signal;e&&await l(()=>!0===this.viewModel?.active,{signal:t}),await i(a(t)),await i(o(this._getAnimationDurationMS(),t)),this._featuresWidget.focus()}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:n,view:s}=e;if(isNaN(i)||isNaN(t)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-t<r.top||"bottom"===n&&o.y+t>s.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:s,view:r}=n;if(null==s||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:h,width:u}=i.getBoundingClientRect(),p=u+t,g=Math.max(h,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"right",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"left",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"bottom",view:r});return f?m?"bottom-right":"top-right":v?m?"bottom-left":"top-left":m?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return y(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=y(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},n=t.width-o.left-o.right,{breakpoints:s}=t;return s&&n<=s.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===n?{top:t+s-r.top,left:e-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:d+s-r.right}:"bottom-left"===n?{top:t+s-r.top,right:d+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:e+s-r.left}:"bottom-right"===n?{top:t+s-r.top,left:e+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const n=this._calculateFullWidth(t),s=this._calculateAlignmentPosition(e.x,e.y,o,n);return s?{top:void 0!==s.top?`${s.top}px`:"auto",left:void 0!==s.left?`${s.left}px`:"auto",bottom:void 0!==s.bottom?`${s.bottom}px`:"auto",right:void 0!==s.right?`${s.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,n]=e,[s,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=e[0]-o,s[1]=e[1]-n,r[0]=t[0]-o,r[1]=t[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!t)return!1;const s=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&n<=(t.height??0);return s||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([c()],D.prototype,"_containerNode",void 0),e([c({readOnly:!0})],D.prototype,"_featureNavigationTop",null),e([c()],D.prototype,"actions",null),e([c({readOnly:!0})],D.prototype,"active",null),e([c()],D.prototype,"alignment",void 0),e([c()],D.prototype,"autoCloseEnabled",null),e([c()],D.prototype,"defaultPopupTemplateEnabled",null),e([c()],D.prototype,"content",null),e([c()],D.prototype,"collapsed",null),e([c({readOnly:!0})],D.prototype,"currentAlignment",null),e([c({readOnly:!0})],D.prototype,"currentDockPosition",null),e([c()],D.prototype,"dockOptions",null),e([c()],D.prototype,"dockEnabled",void 0),e([c({readOnly:!0})],D.prototype,"featureCount",null),e([c()],D.prototype,"featureMenuOpen",null),e([c()],D.prototype,"features",null),e([c()],D.prototype,"goToOverride",null),e([c()],D.prototype,"headingLevel",void 0),e([c()],D.prototype,"highlightEnabled",null),e([c()],D.prototype,"icon",null),e([c()],D.prototype,"initialDisplayMode",null),e([c()],D.prototype,"location",null),e([c()],D.prototype,"label",null),e([c(),M("esri/widgets/Popup/t9n/Popup")],D.prototype,"messages",void 0),e([c()],D.prototype,"promises",null),e([c({readOnly:!0})],D.prototype,"selectedFeature",null),e([c({readOnly:!0})],D.prototype,"selectedDrillInFeature",null),e([c()],D.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],D.prototype,"selectedFeatureWidget",null),e([c()],D.prototype,"title",null),e([c()],D.prototype,"updateLocationEnabled",null),e([c()],D.prototype,"view",null),e([c({type:m}),k(["triggerAction","trigger-action"])],D.prototype,"viewModel",void 0),e([c()],D.prototype,"visible",null),e([c({type:w,nonNullable:!0})],D.prototype,"visibleElements",void 0),D=e([h("esri.widgets.Popup")],D);const P=D;export{P as default};
5
+ import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{ignoreAbortErrors as i,after as o}from"../core/promiseUtils.js";import{watch as n,on as s,initial as r,whenOnce as l}from"../core/reactiveUtils.js";import{waitAnimationFrame as a}from"../core/scheduling.js";import{stripHTML as d}from"../core/string.js";import{property as c,subclass as h}from"../core/accessorSupport/decorators.js";import u from"../geometry/Point.js";import p from"../support/actions/ActionButton.js";import g from"./Features.js";import v from"./Widget.js";import f from"./Features/FeaturesViewModel.js";import{ActionsCollection as m}from"./Popup/actions.js";import{css as w}from"./Popup/css.js";import b from"./Popup/PopupViewModel.js";import _ from"./Popup/PopupVisibleElements.js";import{globalCss as M}from"./support/globalCss.js";import{tsx as k,messageBundle as y,vmEvent as E}from"./support/widget.js";import{isRTL as C}from"./support/widgetUtils.js";const P=200,D={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let A=class extends v{constructor(e,t){super(e,t),this._dockAction=new p({id:"popup-dock-action"}),this._featuresWidget=new g({responsiveActionsEnabled:!0}),this._containerNode=null,this._mainContainerNode=null,this._pointerOffsetInPx=16,this._focusAbortController=null,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.viewModel=new b,this.visibleElements=new _}initialize(){this.addHandles([n(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),r),n(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),r),n(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},r),n(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),n(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),n(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),n(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),n(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),n(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),n(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,r),n(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,r),n(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,r),n(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,r),n(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,r),n(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,r),n(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,r),n(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,r),n(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,r),n(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,r),n(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,r),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new f,this._featuresWidget.destroy()),this._focusAbortController?.abort()}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||D}set dockOptions(e){const t={...D},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const n={...t,...e},s={...t.breakpoint,...o},{breakpoint:r}=n;"object"==typeof r?n.breakpoint={...s,...r}:r&&(n.breakpoint=s),this._set("dockOptions",n),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._handleFocus()}next(){return this.viewModel.next()}open(e){const t=!!e&&!!e.featureMenuOpen,i={collapsed:!!e&&!!e.collapsed,featureMenuOpen:t};this.set(i),this.viewModel.open(e),e?.shouldFocus&&this._handleFocus(!0)}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:n}=this.viewModel,s=o&&e,r=o&&!e,l=this.selectedFeature?.layer?.title,a=this.selectedFeature?.layer?.id,c={[w.alignTopCenter]:"top-center"===t,[w.alignBottomCenter]:"bottom-center"===t,[w.alignTopLeft]:"top-left"===t,[w.alignBottomLeft]:"bottom-left"===t,[w.alignTopRight]:"top-right"===t,[w.alignBottomRight]:"bottom-right"===t,[w.isDocked]:s,[w.shadow]:r,[w.isDockedTopLeft]:"top-left"===i,[w.isDockedTopCenter]:"top-center"===i,[w.isDockedTopRight]:"top-right"===i,[w.isDockedBottomLeft]:"bottom-left"===i,[w.isDockedBottomCenter]:"bottom-center"===i,[w.isDockedBottomRight]:"bottom-right"===i};return k("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":d(this.title??""),"aria-modal":"false",bind:this,class:this.classes(w.base,c,{[w.baseHidden]:!n&&!e}),"data-layer-id":a,"data-layer-title":l,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:k("div",{class:w.pointer,key:"popup-pointer",role:"presentation"},k("div",{class:this.classes(w.pointerDirection,w.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[w.shadow]:e};return k("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(w.main,M.widget,t)},this._featuresWidget.render())}_getAnimationDurationMS(){const{_containerNode:e}=this;return e?1e3*parseFloat(window.getComputedStyle(e).animationDuration):P}async _handleFocus(e=!1){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const t=this._focusAbortController.signal;e&&await l(()=>!0===this.viewModel?.active,{signal:t}),await i(a(t)),await i(o(this._getAnimationDurationMS(),t)),this._featuresWidget.focus()}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:n,view:s}=e;if(isNaN(i)||isNaN(t)||!s||!o)return!1;const r=s.padding;return"right"===n&&o.x+i/2>s.width-r.right||("left"===n&&o.x-i/2<r.left||("top"===n&&o.y-t<r.top||"bottom"===n&&o.y+t>s.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:n}=this,{screenLocation:s,view:r}=n;if(null==s||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:h,width:u}=i.getBoundingClientRect(),p=u+t,g=Math.max(h,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"right",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"left",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:s,side:"bottom",view:r});return f?m?"bottom-right":"top-right":v?m?"bottom-left":"top-left":m?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return C(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=C(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},n=t.width-o.left-o.right,{breakpoints:s}=t;return s&&n<=s.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:n,_pointerOffsetInPx:s}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===n?{top:t+s-r.top,left:e-l-r.left}:"top-left"===n?{bottom:a+s-r.bottom,right:d+s-r.right}:"bottom-left"===n?{top:t+s-r.top,right:d+s-r.right}:"top-right"===n?{bottom:a+s-r.bottom,left:e+s-r.left}:"bottom-right"===n?{top:t+s-r.top,left:e+s-r.left}:"top-center"===n?{bottom:a+s-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const n=this._calculateFullWidth(t),s=this._calculateAlignmentPosition(e.x,e.y,o,n);return s?{top:void 0!==s.top?`${s.top}px`:"auto",left:void 0!==s.left?`${s.left}px`:"auto",bottom:void 0!==s.bottom?`${s.bottom}px`:"auto",right:void 0!==s.right?`${s.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,n]=e,[s,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&s>l||o>l&&s<=l||n<=a&&r>a||n>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,n=i.top+i.bottom,s=[],r=[];s[0]=e[0]-o,s[1]=e[1]-n,r[0]=t[0]-o,r[1]=t[1]-n;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(s,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:n}=i;if(isNaN(o)||isNaN(n))return!1;if(!t)return!1;const s=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&n<=(t.height??0);return s||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([c()],A.prototype,"_containerNode",void 0),e([c({readOnly:!0})],A.prototype,"_featureNavigationTop",null),e([c({type:m})],A.prototype,"actions",null),e([c({readOnly:!0})],A.prototype,"active",null),e([c()],A.prototype,"alignment",void 0),e([c()],A.prototype,"autoCloseEnabled",null),e([c()],A.prototype,"defaultPopupTemplateEnabled",null),e([c()],A.prototype,"content",null),e([c()],A.prototype,"collapsed",null),e([c({readOnly:!0})],A.prototype,"currentAlignment",null),e([c({readOnly:!0})],A.prototype,"currentDockPosition",null),e([c()],A.prototype,"dockOptions",null),e([c()],A.prototype,"dockEnabled",void 0),e([c({readOnly:!0})],A.prototype,"featureCount",null),e([c()],A.prototype,"featureMenuOpen",null),e([c()],A.prototype,"features",null),e([c()],A.prototype,"goToOverride",null),e([c()],A.prototype,"headingLevel",void 0),e([c()],A.prototype,"highlightEnabled",null),e([c()],A.prototype,"icon",null),e([c()],A.prototype,"initialDisplayMode",null),e([c({type:u})],A.prototype,"location",null),e([c()],A.prototype,"label",null),e([c(),y("esri/widgets/Popup/t9n/Popup")],A.prototype,"messages",void 0),e([c()],A.prototype,"promises",null),e([c({readOnly:!0})],A.prototype,"selectedFeature",null),e([c({readOnly:!0})],A.prototype,"selectedDrillInFeature",null),e([c()],A.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],A.prototype,"selectedFeatureWidget",null),e([c()],A.prototype,"title",null),e([c()],A.prototype,"updateLocationEnabled",null),e([c()],A.prototype,"view",null),e([c({type:b}),E(["triggerAction","trigger-action"])],A.prototype,"viewModel",void 0),e([c()],A.prototype,"visible",null),e([c({type:_,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=e([h("esri.widgets.Popup")],A);const O=A;export{O as default};