@arcgis/core 4.27.0-rc.1 → 4.27.0-rc.2

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 (98) hide show
  1. package/README.md +2 -2
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{92e7f224a80195e606d6.js → 1f69fb9687de9ebfcf90.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{0a02ac5628d1739372c6.js → 2b55295590b4a0503749.js} +1 -1
  5. package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
  6. package/assets/esri/core/workers/chunks/{f339db2b599fa9585283.js → 5e6471dd2a08e66b47d0.js} +79 -81
  7. package/assets/esri/core/workers/chunks/{474d9b334812533bab36.js → 6cd248d065f6d1616294.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d8bd3f498b3fa8153404.js → 6f510f28526c73ab453c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
  10. package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +1 -0
  13. package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
  14. package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
  15. package/assets/esri/core/workers/chunks/{c6efe2e04ea6a55bb6e3.js → f6e68befe2812b90b40d.js} +1 -1
  16. package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
  17. package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
  18. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/chunks/DefaultMaterial.glsl.js +3 -2
  23. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  24. package/core/timeUtils.js +1 -1
  25. package/geometry/Mesh.js +1 -1
  26. package/geometry/support/meshVertexSpaceUtils.js +5 -0
  27. package/interfaces.d.ts +179 -31
  28. package/kernel.js +1 -1
  29. package/layers/VideoLayer.js +1 -1
  30. package/layers/graphics/controllers/StreamController.js +1 -1
  31. package/layers/graphics/data/QueryEngine.js +1 -1
  32. package/layers/graphics/data/attributeSupport.js +1 -1
  33. package/layers/graphics/editingSupport.js +1 -1
  34. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  35. package/layers/video/VideoController.js +1 -1
  36. package/layers/video/videoUtils.js +5 -0
  37. package/package.json +1 -1
  38. package/rest/support/meshFeatureSet.js +1 -1
  39. package/smartMapping/symbology/flow.js +1 -1
  40. package/statistics/utils.js +1 -1
  41. package/support/revision.js +1 -1
  42. package/symbols/cim/CIMSymbolHelper.js +1 -1
  43. package/views/2d/layers/StreamLayerView2D.js +1 -1
  44. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  45. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  46. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  47. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  48. package/views/3d/layers/I3SMeshView3D.js +1 -1
  49. package/views/3d/layers/II3SMeshView3D.js +1 -1
  50. package/views/3d/layers/SceneLayerView3D.js +1 -1
  51. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  52. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  53. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  54. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  55. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  56. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  57. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  58. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  59. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
  60. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
  61. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
  62. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  63. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
  64. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
  65. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  66. package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
  67. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  68. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  69. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  70. package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
  71. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  72. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  73. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  74. package/views/draw/DrawGraphicTool.js +1 -1
  75. package/views/layers/GroupLayerView.js +1 -1
  76. package/widgets/Daylight/DaylightViewModel.js +1 -1
  77. package/widgets/Editor/EditorViewModel.js +1 -1
  78. package/widgets/Editor/UpdateWorkflow.js +1 -1
  79. package/widgets/Editor/Workflow.js +1 -1
  80. package/widgets/Editor/workflowUtils.js +1 -1
  81. package/widgets/Editor.js +1 -1
  82. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  83. package/widgets/Feature/FeatureRelationship.js +1 -1
  84. package/widgets/FeatureForm/EditableInput.d.ts +2 -2
  85. package/widgets/FeatureTable/FieldColumn.js +1 -1
  86. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  87. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  88. package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
  89. package/widgets/UtilityNetworkTrace.js +1 -1
  90. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  91. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  92. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  93. package/widgets/ValuePicker.js +1 -1
  94. package/assets/esri/core/workers/chunks/07651ef8348f702d59ac.js +0 -1
  95. package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
  96. package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
  97. package/assets/esri/core/workers/chunks/90da1ed112b82712d0ef.js +0 -1
  98. package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{c as a}from"../../../../chunks/mat3f64.js";import{w as r,m as n,a as o,u as c}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f64.js";import{s as u,i as m,a as _,l,k as d,c as p,g as f,n as x,e as g,j as w}from"../../../../chunks/vec2.js";import{a as M}from"../../../../chunks/vec2f64.js";import{k as b,c as S,o as C,m as T,s as j}from"../../../../chunks/vec3.js";import{c as y}from"../../../../chunks/vec3f64.js";import{s as D,t as v}from"../../../../chunks/vec4.js";import{c as z}from"../../../../chunks/vec4f64.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{CascadeCamera as O}from"./CascadeCamera.js";import{applyTextureResizeModulo as R}from"./textureUtils.js";import{assert as U,logWithBase as F,verify as N,rayRay2D as k}from"./Util.js";import{TextureType as A,ClearBufferBit as L,TextureWrapMode as H,TextureSamplingMode as Q,RenderbufferFormat as V}from"../../../webgl/enums.js";import{FramebufferObject as I}from"../../../webgl/FramebufferObject.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as B}from"../../../webgl/Texture.js";import{TextureDescriptor as G}from"../../../webgl/TextureDescriptor.js";var X;!function(t){t[t.Highlight=0]="Highlight",t[t.Default=1]="Default"}(X||(X={}));class q{constructor(){this.camera=new O,this.lightMat=h()}}class W{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class J{get depthTexture(){return this._fbo?.colorTexture}get textureSize(){return this._textureSize}get numCascades(){return this._numCascades}get cascadeDistances(){return D(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}constructor(t,s){this._rctx=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureSize=0,this._numCascades=1,this.settings=new W,this._projectionView=h(),this._projectionViewInverse=h(),this._modelViewLight=h(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=z(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureSize=Math.min(has("esri-mobile")?2048:8192,this._rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._fbo=i(this._fbo),this._discardAllSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}getSnapshot(t){return this.enabled?this._snapshots[t]:null}get cascades(){for(let t=0;t<this._numCascades;++t)rt[t]=this._cascades[t];return rt.length=this._numCascades,rt}start(t,s,e,i,a){U(this.enabled),this._textureSize=this._computeTextureSize(t,a,i),this._ensureDepthTexture();const{near:r,far:n}=this._clampNearFar(e);this._computeCascadeDistances(n,r,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:c}=t;for(let h=0;h<this._numCascades;++h)this._constructCascade(h,c,o,s);this._lastOrigin=null,this.clear()}finish(t){U(this.enabled),this._rctx.bindFramebuffer(t)}getShadowMapMatrices(t){if(!this._lastOrigin||!b(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||y(),S(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(nt,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)ot[16*s+t]=nt[t]}}return ot}takeCascadeSnapshotTo(t,s){U(this.enabled);const e=this._ensureSnapshot(s);this._bindFbo();const i=this._rctx,a=i.bindTexture(e,B.TEXTURE_UNIT_FOR_UPDATES);i.gl.copyTexSubImage2D(A.TEXTURE_2D,0,t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[2],t.camera.viewport[3]),i.bindTexture(a,B.TEXTURE_UNIT_FOR_UPDATES)}clear(){const t=this._rctx;this._bindFbo(),t.setClearColor(1,1,1,1),t.clearSafe(L.COLOR_BUFFER_BIT|L.DEPTH_BUFFER_BIT)}_computeTextureSize(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=Math.max(t.fullWidth,t.fullHeight)*i,r=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return Math.floor(Math.min(this._maxTextureSize,R((1===this.numCascades?1:2)*a*r)))}_ensureDepthTexture(){if(this._fbo?.width===this._textureSize)return;const t=new G(this._textureSize);t.wrapMode=H.CLAMP_TO_EDGE,t.samplingMode=Q.NEAREST,this._fbo?.dispose(),this._fbo=new I(this._rctx,t,new P(V.DEPTH_COMPONENT16,this._textureSize))}_ensureSnapshot(t){let s=this._snapshots[t];if(null!=s&&s.descriptor.width===this._textureSize)return s;this._discardSnapshot(t);const e=new G;return e.wrapMode=H.CLAMP_TO_EDGE,e.samplingMode=Q.NEAREST,e.width=this._textureSize,e.height=this._textureSize,s=new B(this._rctx,e),this._snapshots[t]=s,s}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardAllSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){const t=this._rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],c=-this._cascadeDistances[t+1],h=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),u=(s[10]*c+s[14])/Math.abs(s[11]*c+s[15]);U(h<u);for(let r=0;r<8;++r){D(Y,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?h:u,1);const t=Z[r];v(t,Y,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}C(at,Z[0]),a.camera.viewMatrix=r(K,this._modelViewLight,at);for(let r=0;r<8;++r)T(Z[r],Z[r],a.camera.viewMatrix);let m=Z[0][2],_=Z[0][2];for(let r=1;r<8;++r)m=Math.min(m,Z[r][2]),_=Math.max(_,Z[r][2]);m-=200,_+=200,a.camera.near=-_,a.camera.far=-m,jt(e,i,m,_,a.camera),n(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const l=this._textureSize/(1===this.numCascades?1:2);a.camera.viewport=[t%2==0?0:l,0===Math.floor(t/2)?0:l,l,l]}_setupMatrices(t,s){n(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===E.Global?t.eye:j(at,0,0,1);c(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_clampNearFar(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(F(t/e,4)),a);const r=(t-e)/this._numCascades,n=(t/e)**(1/this._numCascades);let o=e,c=e;for(let h=0;h<this._numCascades+1;++h)this._cascadeDistances[h]=s(o,c,this.settings.splitSchemeLambda),o*=n,c+=r}get gpuMemoryUsage(){return this._snapshots.reduce(((t,s)=>t+(s?.gpuMemoryUsage??0)),this._fbo?.gpuMemoryUsage??0)}get test(){return{cascades:this._cascades,textureSize:this._textureSize}}}const K=h(),Y=z(),Z=[];for(let yt=0;yt<8;++yt)Z.push(z());const $=M(),tt=M(),st=M(),et=M(),it=M(),at=y(),rt=[],nt=h(),ot=new Array(64),ct=M(),ht=M(),ut=[M(),M(),M(),M()],mt=M(),_t=M(),lt=M(),dt=M(),pt=M(),ft=M(),xt=M();function gt(t,s,e,i,a,r,n,o){u(ct,0,0);for(let u=0;u<4;++u)m(ct,ct,t[u]);_(ct,ct,.25),u(ht,0,0);for(let u=4;u<8;++u)m(ht,ht,t[u]);_(ht,ht,.25),l(ut[0],t[4],t[5],.5),l(ut[1],t[5],t[6],.5),l(ut[2],t[6],t[7],.5),l(ut[3],t[7],t[4],.5);let c=0,h=d(ut[0],ct);for(let u=1;u<4;++u){const t=d(ut[u],ct);t<h&&(h=t,c=u)}p(mt,ut[c],t[c+4]);const M=mt[0];let b,S;mt[0]=-mt[1],mt[1]=M,p(_t,ht,ct),f(_t,mt)<0&&x(mt,mt),l(mt,mt,_t,e),g(mt,mt),b=S=f(p(lt,t[0],ct),mt);for(let u=1;u<8;++u){const s=f(p(lt,t[u],ct),mt);s<b?b=s:s>S&&(S=s)}w(i,ct),_(lt,mt,b-s),m(i,i,lt);let C=-1,T=1,j=0,y=0;for(let u=0;u<8;++u){p(dt,t[u],i),g(dt,dt);const s=mt[0]*dt[1]-mt[1]*dt[0];s>0?s>C&&(C=s,j=u):s<T&&(T=s,y=u)}N(C>0,"leftArea"),N(T<0,"rightArea"),_(pt,mt,b),m(pt,pt,ct),_(ft,mt,S),m(ft,ft,ct),xt[0]=-mt[1],xt[1]=mt[0];const D=k(i,t[y],ft,m(lt,ft,xt),1,a),v=k(i,t[j],ft,lt,1,r),z=k(i,t[j],pt,m(lt,pt,xt),1,n),E=k(i,t[y],pt,lt,1,o);N(D,"rayRay"),N(v,"rayRay"),N(z,"rayRay"),N(E,"rayRay")}function wt(t,s){return 3*s+t}const Mt=M();function bt(t,s){return u(Mt,t[s],t[s+3]),Mt}const St=M(),Ct=a();function Tt(t,s,e,i,a){p(St,e,i),_(St,St,.5),Ct[0]=St[0],Ct[1]=St[1],Ct[2]=0,Ct[3]=St[1],Ct[4]=-St[0],Ct[5]=0,Ct[6]=St[0]*St[0]+St[1]*St[1],Ct[7]=St[0]*St[1]-St[1]*St[0],Ct[8]=1,Ct[wt(0,2)]=-f(bt(Ct,0),t),Ct[wt(1,2)]=-f(bt(Ct,1),t);let r=f(bt(Ct,0),e)+Ct[wt(0,2)],n=f(bt(Ct,1),e)+Ct[wt(1,2)],o=f(bt(Ct,0),i)+Ct[wt(0,2)],c=f(bt(Ct,1),i)+Ct[wt(1,2)];r=-(r+o)/(n+c),Ct[wt(0,0)]+=Ct[wt(1,0)]*r,Ct[wt(0,1)]+=Ct[wt(1,1)]*r,Ct[wt(0,2)]+=Ct[wt(1,2)]*r,r=1/(f(bt(Ct,0),e)+Ct[wt(0,2)]),n=1/(f(bt(Ct,1),e)+Ct[wt(1,2)]),Ct[wt(0,0)]*=r,Ct[wt(0,1)]*=r,Ct[wt(0,2)]*=r,Ct[wt(1,0)]*=n,Ct[wt(1,1)]*=n,Ct[wt(1,2)]*=n,Ct[wt(2,0)]=Ct[wt(1,0)],Ct[wt(2,1)]=Ct[wt(1,1)],Ct[wt(2,2)]=Ct[wt(1,2)],Ct[wt(1,2)]+=1,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=f(bt(Ct,1),e)+Ct[wt(1,2)],c=f(bt(Ct,2),e)+Ct[wt(2,2)],r=-.5*(r/n+o/c),Ct[wt(1,0)]+=Ct[wt(2,0)]*r,Ct[wt(1,1)]+=Ct[wt(2,1)]*r,Ct[wt(1,2)]+=Ct[wt(2,2)]*r,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=-n/r,Ct[wt(1,0)]*=o,Ct[wt(1,1)]*=o,Ct[wt(1,2)]*=o,a[0]=Ct[0],a[1]=Ct[1],a[2]=0,a[3]=Ct[2],a[4]=Ct[3],a[5]=Ct[4],a[6]=0,a[7]=Ct[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Ct[6],a[13]=Ct[7],a[14]=0,a[15]=Ct[8]}function jt(t,s,i,a,r){const n=1/Z[0][3],o=1/Z[4][3];U(n<o);let c=n+Math.sqrt(n*o);const h=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));c/=h,gt(Z,c,h,$,tt,st,et,it),Tt($,tt,et,it,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}export{J as ShadowMap,X as SnapshotSlot};
5
+ import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{c as a}from"../../../../chunks/mat3f64.js";import{w as r,m as n,a as o,u as c}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f64.js";import{s as u,i as m,a as _,l,k as d,c as p,g as f,n as x,e as g,j as w}from"../../../../chunks/vec2.js";import{a as M}from"../../../../chunks/vec2f64.js";import{k as b,c as S,o as C,m as T,s as j}from"../../../../chunks/vec3.js";import{c as y}from"../../../../chunks/vec3f64.js";import{s as D,t as v}from"../../../../chunks/vec4.js";import{c as z}from"../../../../chunks/vec4f64.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{CascadeCamera as O}from"./CascadeCamera.js";import{applyTextureResizeModulo as R}from"./textureUtils.js";import{assert as U,logWithBase as F,verify as N,rayRay2D as k}from"./Util.js";import{TextureType as A,ClearBufferBit as L,TextureWrapMode as H,TextureSamplingMode as Q,RenderbufferFormat as V}from"../../../webgl/enums.js";import{FramebufferObject as I}from"../../../webgl/FramebufferObject.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as B}from"../../../webgl/Texture.js";import{TextureDescriptor as G}from"../../../webgl/TextureDescriptor.js";var X;!function(t){t[t.Highlight=0]="Highlight",t[t.Default=1]="Default"}(X||(X={}));class q{constructor(){this.camera=new O,this.lightMat=h()}}class W{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class J{get depthTexture(){return this._fbo?.colorTexture}get textureSize(){return this._textureSize}get numCascades(){return this._numCascades}get cascadeDistances(){return D(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}constructor(t,s){this._rctx=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureSize=0,this._numCascades=1,this.settings=new W,this._projectionView=h(),this._projectionViewInverse=h(),this._modelViewLight=h(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=z(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureSize=Math.min(has("esri-mobile")?2048:8192,this._rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._fbo=i(this._fbo),this._discardAllSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}getSnapshot(t){return this.enabled?this._snapshots[t]:null}get cascades(){for(let t=0;t<this._numCascades;++t)rt[t]=this._cascades[t];return rt.length=this._numCascades,rt}start(t,s,e,i,a){U(this.enabled),this._textureSize=this._computeTextureSize(t,a,i),this._ensureDepthTexture();const{near:r,far:n}=this._clampNearFar(e);this._computeCascadeDistances(n,r,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:c}=t;for(let h=0;h<this._numCascades;++h)this._constructCascade(h,c,o,s);this._lastOrigin=null,this.clear()}finish(t){U(this.enabled),this._rctx.bindFramebuffer(t)}getShadowMapMatrices(t,s){if(!this._lastOrigin||!b(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||y(),S(this._lastOrigin,t);for(let e=0;e<this._numCascades;++e){r(nt,this._cascades[e].lightMat,t),null!=s&&n(nt,nt,s);for(let t=0;t<16;++t)ot[16*e+t]=nt[t]}}return ot}takeCascadeSnapshotTo(t,s){U(this.enabled);const e=this._ensureSnapshot(s);this._bindFbo();const i=this._rctx,a=i.bindTexture(e,B.TEXTURE_UNIT_FOR_UPDATES);i.gl.copyTexSubImage2D(A.TEXTURE_2D,0,t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[2],t.camera.viewport[3]),i.bindTexture(a,B.TEXTURE_UNIT_FOR_UPDATES)}clear(){const t=this._rctx;this._bindFbo(),t.setClearColor(1,1,1,1),t.clearSafe(L.COLOR_BUFFER_BIT|L.DEPTH_BUFFER_BIT)}_computeTextureSize(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=Math.max(t.fullWidth,t.fullHeight)*i,r=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return Math.floor(Math.min(this._maxTextureSize,R((1===this.numCascades?1:2)*a*r)))}_ensureDepthTexture(){if(this._fbo?.width===this._textureSize)return;const t=new G(this._textureSize);t.wrapMode=H.CLAMP_TO_EDGE,t.samplingMode=Q.NEAREST,this._fbo?.dispose(),this._fbo=new I(this._rctx,t,new P(V.DEPTH_COMPONENT16,this._textureSize))}_ensureSnapshot(t){let s=this._snapshots[t];if(null!=s&&s.descriptor.width===this._textureSize)return s;this._discardSnapshot(t);const e=new G;return e.wrapMode=H.CLAMP_TO_EDGE,e.samplingMode=Q.NEAREST,e.width=this._textureSize,e.height=this._textureSize,s=new B(this._rctx,e),this._snapshots[t]=s,s}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardAllSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){const t=this._rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],c=-this._cascadeDistances[t+1],h=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),u=(s[10]*c+s[14])/Math.abs(s[11]*c+s[15]);U(h<u);for(let r=0;r<8;++r){D(Y,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?h:u,1);const t=Z[r];v(t,Y,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}C(at,Z[0]),a.camera.viewMatrix=r(K,this._modelViewLight,at);for(let r=0;r<8;++r)T(Z[r],Z[r],a.camera.viewMatrix);let m=Z[0][2],_=Z[0][2];for(let r=1;r<8;++r)m=Math.min(m,Z[r][2]),_=Math.max(_,Z[r][2]);m-=200,_+=200,a.camera.near=-_,a.camera.far=-m,jt(e,i,m,_,a.camera),n(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const l=this._textureSize/(1===this.numCascades?1:2);a.camera.viewport=[t%2==0?0:l,0===Math.floor(t/2)?0:l,l,l]}_setupMatrices(t,s){n(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===E.Global?t.eye:j(at,0,0,1);c(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_clampNearFar(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(F(t/e,4)),a);const r=(t-e)/this._numCascades,n=(t/e)**(1/this._numCascades);let o=e,c=e;for(let h=0;h<this._numCascades+1;++h)this._cascadeDistances[h]=s(o,c,this.settings.splitSchemeLambda),o*=n,c+=r}get gpuMemoryUsage(){return this._snapshots.reduce(((t,s)=>t+(s?.gpuMemoryUsage??0)),this._fbo?.gpuMemoryUsage??0)}get test(){return{cascades:this._cascades,textureSize:this._textureSize}}}const K=h(),Y=z(),Z=[];for(let yt=0;yt<8;++yt)Z.push(z());const $=M(),tt=M(),st=M(),et=M(),it=M(),at=y(),rt=[],nt=h(),ot=new Array(64),ct=M(),ht=M(),ut=[M(),M(),M(),M()],mt=M(),_t=M(),lt=M(),dt=M(),pt=M(),ft=M(),xt=M();function gt(t,s,e,i,a,r,n,o){u(ct,0,0);for(let u=0;u<4;++u)m(ct,ct,t[u]);_(ct,ct,.25),u(ht,0,0);for(let u=4;u<8;++u)m(ht,ht,t[u]);_(ht,ht,.25),l(ut[0],t[4],t[5],.5),l(ut[1],t[5],t[6],.5),l(ut[2],t[6],t[7],.5),l(ut[3],t[7],t[4],.5);let c=0,h=d(ut[0],ct);for(let u=1;u<4;++u){const t=d(ut[u],ct);t<h&&(h=t,c=u)}p(mt,ut[c],t[c+4]);const M=mt[0];let b,S;mt[0]=-mt[1],mt[1]=M,p(_t,ht,ct),f(_t,mt)<0&&x(mt,mt),l(mt,mt,_t,e),g(mt,mt),b=S=f(p(lt,t[0],ct),mt);for(let u=1;u<8;++u){const s=f(p(lt,t[u],ct),mt);s<b?b=s:s>S&&(S=s)}w(i,ct),_(lt,mt,b-s),m(i,i,lt);let C=-1,T=1,j=0,y=0;for(let u=0;u<8;++u){p(dt,t[u],i),g(dt,dt);const s=mt[0]*dt[1]-mt[1]*dt[0];s>0?s>C&&(C=s,j=u):s<T&&(T=s,y=u)}N(C>0,"leftArea"),N(T<0,"rightArea"),_(pt,mt,b),m(pt,pt,ct),_(ft,mt,S),m(ft,ft,ct),xt[0]=-mt[1],xt[1]=mt[0];const D=k(i,t[y],ft,m(lt,ft,xt),1,a),v=k(i,t[j],ft,lt,1,r),z=k(i,t[j],pt,m(lt,pt,xt),1,n),E=k(i,t[y],pt,lt,1,o);N(D,"rayRay"),N(v,"rayRay"),N(z,"rayRay"),N(E,"rayRay")}function wt(t,s){return 3*s+t}const Mt=M();function bt(t,s){return u(Mt,t[s],t[s+3]),Mt}const St=M(),Ct=a();function Tt(t,s,e,i,a){p(St,e,i),_(St,St,.5),Ct[0]=St[0],Ct[1]=St[1],Ct[2]=0,Ct[3]=St[1],Ct[4]=-St[0],Ct[5]=0,Ct[6]=St[0]*St[0]+St[1]*St[1],Ct[7]=St[0]*St[1]-St[1]*St[0],Ct[8]=1,Ct[wt(0,2)]=-f(bt(Ct,0),t),Ct[wt(1,2)]=-f(bt(Ct,1),t);let r=f(bt(Ct,0),e)+Ct[wt(0,2)],n=f(bt(Ct,1),e)+Ct[wt(1,2)],o=f(bt(Ct,0),i)+Ct[wt(0,2)],c=f(bt(Ct,1),i)+Ct[wt(1,2)];r=-(r+o)/(n+c),Ct[wt(0,0)]+=Ct[wt(1,0)]*r,Ct[wt(0,1)]+=Ct[wt(1,1)]*r,Ct[wt(0,2)]+=Ct[wt(1,2)]*r,r=1/(f(bt(Ct,0),e)+Ct[wt(0,2)]),n=1/(f(bt(Ct,1),e)+Ct[wt(1,2)]),Ct[wt(0,0)]*=r,Ct[wt(0,1)]*=r,Ct[wt(0,2)]*=r,Ct[wt(1,0)]*=n,Ct[wt(1,1)]*=n,Ct[wt(1,2)]*=n,Ct[wt(2,0)]=Ct[wt(1,0)],Ct[wt(2,1)]=Ct[wt(1,1)],Ct[wt(2,2)]=Ct[wt(1,2)],Ct[wt(1,2)]+=1,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=f(bt(Ct,1),e)+Ct[wt(1,2)],c=f(bt(Ct,2),e)+Ct[wt(2,2)],r=-.5*(r/n+o/c),Ct[wt(1,0)]+=Ct[wt(2,0)]*r,Ct[wt(1,1)]+=Ct[wt(2,1)]*r,Ct[wt(1,2)]+=Ct[wt(2,2)]*r,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=-n/r,Ct[wt(1,0)]*=o,Ct[wt(1,1)]*=o,Ct[wt(1,2)]*=o,a[0]=Ct[0],a[1]=Ct[1],a[2]=0,a[3]=Ct[2],a[4]=Ct[3],a[5]=Ct[4],a[6]=0,a[7]=Ct[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Ct[6],a[13]=Ct[7],a[14]=0,a[15]=Ct[8]}function jt(t,s,i,a,r){const n=1/Z[0][3],o=1/Z[4][3];U(n<o);let c=n+Math.sqrt(n*o);const h=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));c/=h,gt(Z,c,h,$,tt,st,et,it),Tt($,tt,et,it,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}export{J as ShadowMap,X as SnapshotSlot};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{f as o}from"../../../../chunks/vec3f64.js";import{ViewingMode as t}from"../../../ViewingMode.js";import{ShaderOutput as r}from"../core/shaderLibrary/ShaderOutput.js";import{PathVertexPositionPassParameters as i}from"../core/shaderLibrary/attributes/PathVertexPosition.glsl.js";import{NormalsDoubleSidedMode as s}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as n}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReloadableShaderModule as a}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l}from"../core/shaderTechnique/ShaderTechnique.js";import{parameter as p}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{blendingDefault as c,oitBlending as u,oitDepthTest as d,OITPolygonOffset as h}from"../lib/OrderIndependentTransparency.js";import{Program as m}from"../lib/Program.js";import{stencilWriteMaskOn as v,stencilBaseAllZerosParams as y}from"../lib/StencilUtils.js";import{TransparencyPassType as f}from"../lib/TransparencyPassType.js";import{VertexAttribute as b}from"../lib/VertexAttribute.js";import{DefaultTechniqueConfiguration as O}from"./DefaultTechniqueConfiguration.js";import{P}from"../../../../chunks/Path.glsl.js";import{makePipelineState as g,frontFaceCullingParams as T,defaultDepthWriteParams as j,defaultColorWriteParams as S}from"../../../webgl/renderState.js";const R=new Map([[b.POSITION,0],[b.PROFILERIGHT,1],[b.PROFILEUP,2],[b.PROFILEVERTEXANDNORMAL,3],[b.FEATUREVALUE,4]]);class N extends i{constructor(){super(...arguments),this.ambient=o(.2,.2,.2),this.diffuse=o(.8,.8,.8),this.specular=o(0,0,0),this.opacity=1}}class C extends l{initializeConfiguration(e,o){o.spherical=e.viewingMode===t.Global,o.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result}initializeProgram(e){return new m(e.rctx,C.shader.get().build(this.configuration),R)}initializePipeline(){const e=this.configuration.transparencyPassType,o=this.configuration,t=e===f.NONE,i=e===f.FrontFace;return g({blending:o.output!==r.Color&&o.output!==r.Alpha||!o.transparent?null:t?c:u(e),culling:o.hasSlicePlane&&!o.transparent&&o.doubleSidedMode!==s.None?T:null,depthTest:{func:d(e)},depthWrite:t||i?j:null,colorWrite:S,stencilWrite:o.hasOccludees?v:null,stencilTest:o.hasOccludees?y:null,polygonOffset:t||i?null:h})}}C.shader=new a(P,(()=>import("../shaders/Path.glsl.js")));class E extends O{constructor(){super(...arguments),this.output=r.Color,this.doubleSidedMode=s.None,this.transparencyPassType=f.NONE,this.spherical=!1,this.receiveShadows=!1,this.receiveAmbientOcclusion=!1,this.vvSize=!1,this.vvColor=!1,this.vvOpacity=!1,this.hasSlicePlane=!1,this.transparent=!1,this.hasOccludees=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1,this.doublePrecisionRequiresObfuscation=!1}}e([p({count:r.COUNT})],E.prototype,"output",void 0),e([p({count:s.COUNT})],E.prototype,"doubleSidedMode",void 0),e([p({count:f.COUNT})],E.prototype,"transparencyPassType",void 0),e([p()],E.prototype,"spherical",void 0),e([p()],E.prototype,"receiveShadows",void 0),e([p()],E.prototype,"receiveAmbientOcclusion",void 0),e([p()],E.prototype,"vvSize",void 0),e([p()],E.prototype,"vvColor",void 0),e([p()],E.prototype,"vvOpacity",void 0),e([p()],E.prototype,"hasSlicePlane",void 0),e([p()],E.prototype,"transparent",void 0),e([p()],E.prototype,"hasOccludees",void 0),e([p()],E.prototype,"hasMultipassTerrain",void 0),e([p()],E.prototype,"cullAboveGround",void 0),e([p()],E.prototype,"doublePrecisionRequiresObfuscation",void 0),e([p({constValue:n.Disabled})],E.prototype,"pbrMode",void 0),e([p({constValue:!0})],E.prototype,"hasVvInstancing",void 0),e([p({constValue:!1})],E.prototype,"useCustomDTRExponentForWater",void 0),e([p({constValue:!1})],E.prototype,"useFillLights",void 0);export{N as PathPassParameters,C as PathTechnique,E as PathTechniqueConfiguration,R as vertexAttributeLocations};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{f as o,c as t}from"../../../../chunks/vec3f64.js";import{ViewingMode as i}from"../../../ViewingMode.js";import{ShaderOutput as r}from"../core/shaderLibrary/ShaderOutput.js";import{PathVertexPositionPassParameters as s}from"../core/shaderLibrary/attributes/PathVertexPosition.glsl.js";import{NormalsDoubleSidedMode as n}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as a}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReloadableShaderModule as l}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as p}from"../core/shaderTechnique/ShaderTechnique.js";import{parameter as c}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{blendingDefault as u,oitBlending as d,oitDepthTest as h,OITPolygonOffset as m}from"../lib/OrderIndependentTransparency.js";import{Program as v}from"../lib/Program.js";import{stencilWriteMaskOn as y,stencilBaseAllZerosParams as f}from"../lib/StencilUtils.js";import{TransparencyPassType as b}from"../lib/TransparencyPassType.js";import{VertexAttribute as g}from"../lib/VertexAttribute.js";import{DefaultTechniqueConfiguration as O}from"./DefaultTechniqueConfiguration.js";import{P}from"../../../../chunks/Path.glsl.js";import{makePipelineState as T,frontFaceCullingParams as j,defaultDepthWriteParams as S,defaultColorWriteParams as R}from"../../../webgl/renderState.js";const N=new Map([[g.POSITION,0],[g.PROFILERIGHT,1],[g.PROFILEUP,2],[g.PROFILEVERTEXANDNORMAL,3],[g.FEATUREVALUE,4]]);class C extends s{constructor(){super(...arguments),this.ambient=o(.2,.2,.2),this.diffuse=o(.8,.8,.8),this.specular=o(0,0,0),this.opacity=1,this.origin=t(),this.modelTransformation=null}}class E extends p{initializeConfiguration(e,o){o.spherical=e.viewingMode===i.Global,o.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result}initializeProgram(e){return new v(e.rctx,E.shader.get().build(this.configuration),N)}initializePipeline(){const e=this.configuration.transparencyPassType,o=this.configuration,t=e===b.NONE,i=e===b.FrontFace;return T({blending:o.output!==r.Color&&o.output!==r.Alpha||!o.transparent?null:t?u:d(e),culling:o.hasSlicePlane&&!o.transparent&&o.doubleSidedMode!==n.None?j:null,depthTest:{func:h(e)},depthWrite:t||i?S:null,colorWrite:R,stencilWrite:o.hasOccludees?y:null,stencilTest:o.hasOccludees?f:null,polygonOffset:t||i?null:m})}}E.shader=new l(P,(()=>import("../shaders/Path.glsl.js")));class M extends O{constructor(){super(...arguments),this.output=r.Color,this.doubleSidedMode=n.None,this.transparencyPassType=b.NONE,this.spherical=!1,this.receiveShadows=!1,this.receiveAmbientOcclusion=!1,this.vvSize=!1,this.vvColor=!1,this.vvOpacity=!1,this.hasSlicePlane=!1,this.transparent=!1,this.hasOccludees=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1,this.doublePrecisionRequiresObfuscation=!1}}e([c({count:r.COUNT})],M.prototype,"output",void 0),e([c({count:n.COUNT})],M.prototype,"doubleSidedMode",void 0),e([c({count:b.COUNT})],M.prototype,"transparencyPassType",void 0),e([c()],M.prototype,"spherical",void 0),e([c()],M.prototype,"receiveShadows",void 0),e([c()],M.prototype,"receiveAmbientOcclusion",void 0),e([c()],M.prototype,"vvSize",void 0),e([c()],M.prototype,"vvColor",void 0),e([c()],M.prototype,"vvOpacity",void 0),e([c()],M.prototype,"hasSlicePlane",void 0),e([c()],M.prototype,"transparent",void 0),e([c()],M.prototype,"hasOccludees",void 0),e([c()],M.prototype,"hasMultipassTerrain",void 0),e([c()],M.prototype,"cullAboveGround",void 0),e([c()],M.prototype,"doublePrecisionRequiresObfuscation",void 0),e([c({constValue:a.Disabled})],M.prototype,"pbrMode",void 0),e([c({constValue:!0})],M.prototype,"hasVvInstancing",void 0),e([c({constValue:!1})],M.prototype,"useCustomDTRExponentForWater",void 0),e([c({constValue:!1})],M.prototype,"useFillLights",void 0);export{C as PathPassParameters,E as PathTechnique,M as PathTechniqueConfiguration,N as vertexAttributeLocations};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{secondsFromMilliseconds as e}from"../../../../core/time.js";import{f as t}from"../../../../chunks/vec2f64.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ShaderOutput as a}from"../core/shaderLibrary/ShaderOutput.js";import{AnimationTimer as i}from"../lib/AnimationTimer.js";import{MaterialParameters as s}from"../lib/Material.js";import{OITPolygonOffsetLimit as n}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as o}from"../lib/RenderSlot.js";import{DefaultBufferWriter as h}from"./DefaultBufferWriter.js";import{PositionUVLayoutObjectAndLayerId as c,PositionUVLayout as p}from"./DefaultLayouts.js";import{TriangleMaterial as m}from"./TriangleMaterial.js";import{WaterGLMaterial as l}from"./WaterGLMaterial.js";import{WaterTechniqueConfiguration as u}from"./WaterTechnique.js";class f extends m{constructor(e){super(e,new d),this._configuration=new u,this.animation=new i}getConfiguration(e,t){return this._configuration.output=e,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.receiveShadows=this.parameters.receiveShadows,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.hasScreenSpaceReflections=this.parameters.hasScreenSpaceReflections,this._configuration.hasCloudsReflections=this.parameters.hasCloudsReflections,this._configuration.isDraped=this.parameters.isDraped,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<n,this._configuration.hasMultipassTerrain=t.multipassTerrain.enabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}update(t){const r=Math.min(t.camera.relativeElevation,t.camera.distance);this.animation.enabled=Math.sqrt(this.parameters.waveTextureRepeat/this.parameters.waveStrength)*r<A;const a=this.animation.advance(t);return this.setParameters({timeElapsed:e(this.animation.time)*this.parameters.animationSpeed},!1),this.animation.enabled&&a}requiresSlot(e,t){switch(t){case a.Normal:return e===o.DRAPED_WATER;case a.Color:if(this.parameters.isDraped)return e===o.DRAPED_MATERIAL;break;case a.Alpha:break;case a.Highlight:case a.ObjectAndLayerIdColor:return e===o.OPAQUE_MATERIAL||e===o.DRAPED_MATERIAL;default:return!1}let r=o.OPAQUE_MATERIAL;return this.parameters.transparent&&(r=this.parameters.writeDepth?o.TRANSPARENT_MATERIAL:o.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),e===r}createGLMaterial(e){return new l(e)}createBufferWriter(){return new h(has("enable-feature:objectAndLayerId-rendering")?c:p)}}class d extends s{constructor(){super(...arguments),this.waveStrength=.06,this.waveTextureRepeat=32,this.waveDirection=t(1,0),this.waveVelocity=.05,this.flowStrength=.015,this.flowOffset=-.5,this.animationSpeed=.35,this.timeElapsed=0,this.color=r(0,0,0,0),this.transparent=!0,this.writeDepth=!0,this.hasSlicePlane=!1,this.isDraped=!1,this.receiveShadows=!0,this.hasScreenSpaceReflections=!1,this.hasCloudsReflections=!1}}const A=35e3;export{f as WaterMaterial,d as WaterMaterialParameters};
5
+ import has from"../../../../core/has.js";import{secondsFromMilliseconds as e}from"../../../../core/time.js";import{f as t}from"../../../../chunks/vec2f64.js";import{c as r}from"../../../../chunks/vec3f64.js";import{f as a}from"../../../../chunks/vec4f64.js";import{ShaderOutput as i}from"../core/shaderLibrary/ShaderOutput.js";import{AnimationTimer as s}from"../lib/AnimationTimer.js";import{MaterialParameters as n}from"../lib/Material.js";import{OITPolygonOffsetLimit as o}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as h}from"../lib/RenderSlot.js";import{DefaultBufferWriter as c}from"./DefaultBufferWriter.js";import{PositionUVLayoutObjectAndLayerId as m,PositionUVLayout as p}from"./DefaultLayouts.js";import{TriangleMaterial as l}from"./TriangleMaterial.js";import{WaterGLMaterial as u}from"./WaterGLMaterial.js";import{WaterTechniqueConfiguration as f}from"./WaterTechnique.js";class d extends l{constructor(e){super(e,new A),this._configuration=new f,this.animation=new s}getConfiguration(e,t){return this._configuration.output=e,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.receiveShadows=this.parameters.receiveShadows,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.hasScreenSpaceReflections=this.parameters.hasScreenSpaceReflections,this._configuration.hasCloudsReflections=this.parameters.hasCloudsReflections,this._configuration.isDraped=this.parameters.isDraped,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<o,this._configuration.hasMultipassTerrain=t.multipassTerrain.enabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}update(t){const r=Math.min(t.camera.relativeElevation,t.camera.distance);this.animation.enabled=Math.sqrt(this.parameters.waveTextureRepeat/this.parameters.waveStrength)*r<T;const a=this.animation.advance(t);return this.setParameters({timeElapsed:e(this.animation.time)*this.parameters.animationSpeed},!1),this.animation.enabled&&a}requiresSlot(e,t){switch(t){case i.Normal:return e===h.DRAPED_WATER;case i.Color:if(this.parameters.isDraped)return e===h.DRAPED_MATERIAL;break;case i.Alpha:break;case i.Highlight:case i.ObjectAndLayerIdColor:return e===h.OPAQUE_MATERIAL||e===h.DRAPED_MATERIAL;default:return!1}let r=h.OPAQUE_MATERIAL;return this.parameters.transparent&&(r=this.parameters.writeDepth?h.TRANSPARENT_MATERIAL:h.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),e===r}createGLMaterial(e){return new u(e)}createBufferWriter(){return new c(has("enable-feature:objectAndLayerId-rendering")?m:p)}}class A extends n{constructor(){super(...arguments),this.waveStrength=.06,this.waveTextureRepeat=32,this.waveDirection=t(1,0),this.waveVelocity=.05,this.flowStrength=.015,this.flowOffset=-.5,this.animationSpeed=.35,this.timeElapsed=0,this.color=a(0,0,0,0),this.transparent=!0,this.writeDepth=!0,this.hasSlicePlane=!1,this.isDraped=!1,this.receiveShadows=!0,this.hasScreenSpaceReflections=!1,this.hasCloudsReflections=!1,this.origin=r(),this.modelTransformation=null}}const T=35e3;export{d as WaterMaterial,A as WaterMaterialParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{k as e}from"../../../../chunks/vec3.js";import{Z as l}from"../../../../chunks/vec3f64.js";function u({normalTexture:u,metallicRoughnessTexture:n,metallicFactor:r,roughnessFactor:s,emissiveTexture:o,emissiveFactor:t,occlusionTexture:c}){return null==u&&null==n&&null==o&&(null==t||e(t,l))&&null==c&&(null==s||1===s)&&(null==r||1===r||0===r)}export{u as useSchematicPBR};
5
+ import{k as e}from"../../../../chunks/vec3.js";import{Z as l}from"../../../../chunks/vec3f64.js";function u({normalTexture:u,metallicRoughnessTexture:n,metallicFactor:r,roughnessFactor:s,emissiveTexture:o,emissiveFactor:t,occlusionTexture:c}){return null==u&&null==n&&null==o&&(null==t||e(t,l))&&null==c&&(null==s||1===s)&&(null==r||1===r||0===r)}const n=[1,1,.5],r=[0,.6,.2],s=[0,1,.2];export{n as defaultAdvancedMRRFactors,s as defaultEsriSymbologyMRRFactors,r as defaultSchematicMRRFactors,u as useSchematicPBR};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{ReloadableShaderModule as e}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{Default3D as i}from"../lib/DefaultVertexAttributeLocations.js";import{Program as o}from"../lib/Program.js";import{a as t}from"../../../../chunks/AtmosphereCompositing.glsl.js";import{BlendFactor as s,CompareFunction as n}from"../../../webgl/enums.js";import{makePipelineState as m,separateBlendingParams as a,defaultColorWriteParams as l,simpleBlendingParams as h}from"../../../webgl/renderState.js";class p extends r{initializeProgram(e){return new o(e.rctx,p.shader.get().build(this.configuration),i)}initializePipeline(){return this.configuration.haze?m({blending:a(s.ONE,s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ONE),depthTest:{func:n.ALWAYS},colorWrite:l}):m({blending:h(s.ONE,s.ONE_MINUS_SRC_ALPHA),depthTest:{func:n.ALWAYS},colorWrite:l})}}p.shader=new e(t,(()=>import("./AtmosphereCompositing.glsl.js")));export{p as AtmosphereCompositingTechnique};
5
+ import{ReloadableShaderModule as e}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{Default3D as i}from"../lib/DefaultVertexAttributeLocations.js";import{Program as o}from"../lib/Program.js";import{a as t}from"../../../../chunks/AtmosphereCompositing.glsl.js";import{BlendFactor as s,CompareFunction as n}from"../../../webgl/enums.js";import{makePipelineState as m,separateBlendingParams as a,defaultColorWriteParams as l,simpleBlendingParams as h}from"../../../webgl/renderState.js";class p extends r{initializeProgram(e){return new o(e.rctx,p.shader.get().build(this.configuration),i)}initializePipeline(){return this.configuration.haze?m({blending:a(s.ONE,s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ONE),depthTest:{func:n.ALWAYS},colorWrite:l}):m({blending:h(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),depthTest:{func:n.ALWAYS},colorWrite:l})}}p.shader=new e(t,(()=>import("./AtmosphereCompositing.glsl.js")));export{p as AtmosphereCompositingTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{f as e,c as t}from"../../../../chunks/vec3f64.js";import{f as i}from"../../../../chunks/vec4f64.js";import{ViewingMode as r}from"../../../ViewingMode.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as o}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as a}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormalPassParameters as l,VertexNormalDrawParameters as n}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{defaultMaskAlphaCutoff as h}from"../core/shaderLibrary/util/AlphaCutoff.js";import{ReloadableShaderModule as c}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as u}from"../core/shaderTechnique/ShaderTechnique.js";import{CullFaceOptions as p,DepthTestFunction as d,AlphaDiscardMode as m}from"../lib/basicInterfaces.js";import{Default3D as f}from"../lib/DefaultVertexAttributeLocations.js";import{RenderOccludedFlag as b}from"../lib/Material.js";import{blendingDefault as g,oitBlending as S,oitDepthTest as T,getOITPolygonOffset as y}from"../lib/OrderIndependentTransparency.js";import{Program as P}from"../lib/Program.js";import{stencilWriteMaskOn as j,stencilToolMaskBaseParams as x,stencilBaseAllZerosParams as v}from"../lib/StencilUtils.js";import{TransparencyPassType as O}from"../lib/TransparencyPassType.js";import{D as A}from"../../../../chunks/DefaultMaterial.glsl.js";import{CompareFunction as C}from"../../../webgl/enums.js";import{makePipelineState as L,cullingParams as M,defaultDepthWriteParams as D,defaultColorWriteParams as w}from"../../../webgl/renderState.js";class F extends l{constructor(){super(...arguments),this.isSchematic=!1,this.usePBR=!1,this.mrrFactors=e(0,1,.5),this.hasVertexColors=!1,this.hasSymbolColors=!1,this.doubleSided=!1,this.doubleSidedType="normal",this.cullFace=p.Back,this.isInstanced=!1,this.hasInstancedColor=!1,this.emissiveFactor=e(0,0,0),this.instancedDoublePrecision=!1,this.normalType=o.Attribute,this.receiveSSAO=!0,this.receiveShadows=!0,this.castShadows=!0,this.shadowMappingEnabled=!1,this.ambient=e(.2,.2,.2),this.diffuse=e(.8,.8,.8),this.externalColor=i(1,1,1,1),this.colorMixMode="multiply",this.opacity=1,this.layerOpacity=1,this.origin=t(),this.hasSlicePlane=!1,this.hasSliceHighlight=!0,this.offsetTransparentBackfaces=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.modelTransformation=null,this.transparent=!1,this.writeDepth=!0,this.customDepthTest=d.Less,this.textureAlphaMode=m.Blend,this.textureAlphaCutoff=h,this.textureAlphaPremultiplied=!1,this.hasOccludees=!1,this.renderOccluded=b.Occlude}}class _ extends n{constructor(){super(...arguments),this.origin=t(),this.slicePlaneLocalOrigin=this.origin}}class k extends u{initializeConfiguration(e,t){t.spherical=e.viewingMode===r.Global,t.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result,t.textureCoordinateType=t.hasColorTexture||t.hasMetallicRoughnessTexture||t.hasEmissionTexture||t.hasOcclusionTexture||t.hasNormalTexture?a.Default:a.None,t.objectAndLayerIdColorInstanced=t.instanced}initializeProgram(e){return this._initializeProgram(e,k.shader)}_initializeProgram(e,t){return new P(e.rctx,t.get().build(this.configuration),f)}_convertDepthTestFunction(e){return e===d.Lequal?C.LEQUAL:C.LESS}_makePipeline(e,t){const i=this.configuration,r=e===O.NONE,o=e===O.FrontFace;return L({blending:i.output!==s.Color&&i.output!==s.Alpha||!i.transparent?null:r?g:S(e),culling:N(i)?M(i.cullFace):null,depthTest:{func:T(e,this._convertDepthTestFunction(i.customDepthTest))},depthWrite:(r||o)&&i.writeDepth?D:null,colorWrite:w,stencilWrite:i.hasOccludees?j:null,stencilTest:i.hasOccludees?t?x:v:null,polygonOffset:r||o?null:y(i.enableOffset)})}initializePipeline(){return this._occludeePipelineState=this._makePipeline(this.configuration.transparencyPassType,!0),this._makePipeline(this.configuration.transparencyPassType,!1)}getPipelineState(e,t){return t?this._occludeePipelineState:super.getPipelineState(e,t)}}function N(e){return e.cullFace!==p.None||!e.hasSlicePlane&&(!e.transparent&&!e.doubleSidedMode)}k.shader=new c(A,(()=>import("./DefaultMaterial.glsl.js")));export{_ as DefaultMaterialDrawParameters,F as DefaultMaterialPassParameters,k as DefaultMaterialTechnique};
5
+ import{g as e,f as t,c as i}from"../../../../chunks/vec3f64.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ViewingMode as s}from"../../../ViewingMode.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as a}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as l}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormalPassParameters as n,VertexNormalDrawParameters as h}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{defaultMaskAlphaCutoff as c}from"../core/shaderLibrary/util/AlphaCutoff.js";import{ReloadableShaderModule as u}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as p}from"../core/shaderTechnique/ShaderTechnique.js";import{CullFaceOptions as m,DepthTestFunction as d,AlphaDiscardMode as f}from"../lib/basicInterfaces.js";import{Default3D as b}from"../lib/DefaultVertexAttributeLocations.js";import{RenderOccludedFlag as g}from"../lib/Material.js";import{blendingDefault as S,oitBlending as T,oitDepthTest as y,getOITPolygonOffset as j}from"../lib/OrderIndependentTransparency.js";import{Program as P}from"../lib/Program.js";import{stencilWriteMaskOn as x,stencilToolMaskBaseParams as v,stencilBaseAllZerosParams as O}from"../lib/StencilUtils.js";import{TransparencyPassType as A}from"../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as C}from"../materials/pbrUtils.js";import{D as L}from"../../../../chunks/DefaultMaterial.glsl.js";import{CompareFunction as M}from"../../../webgl/enums.js";import{makePipelineState as D,cullingParams as w,defaultDepthWriteParams as F,defaultColorWriteParams as _}from"../../../webgl/renderState.js";class k extends n{constructor(){super(...arguments),this.isSchematic=!1,this.usePBR=!1,this.mrrFactors=e(C),this.hasVertexColors=!1,this.hasSymbolColors=!1,this.doubleSided=!1,this.doubleSidedType="normal",this.cullFace=m.Back,this.isInstanced=!1,this.hasInstancedColor=!1,this.emissiveFactor=t(0,0,0),this.instancedDoublePrecision=!1,this.normalType=a.Attribute,this.receiveSSAO=!0,this.receiveShadows=!0,this.castShadows=!0,this.shadowMappingEnabled=!1,this.ambient=t(.2,.2,.2),this.diffuse=t(.8,.8,.8),this.externalColor=r(1,1,1,1),this.colorMixMode="multiply",this.opacity=1,this.layerOpacity=1,this.origin=i(),this.hasSlicePlane=!1,this.hasSliceHighlight=!0,this.offsetTransparentBackfaces=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.modelTransformation=null,this.transparent=!1,this.writeDepth=!0,this.customDepthTest=d.Less,this.textureAlphaMode=f.Blend,this.textureAlphaCutoff=c,this.textureAlphaPremultiplied=!1,this.hasOccludees=!1,this.renderOccluded=g.Occlude}}class N extends h{constructor(){super(...arguments),this.origin=i(),this.slicePlaneLocalOrigin=this.origin}}class q extends p{initializeConfiguration(e,t){t.spherical=e.viewingMode===s.Global,t.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result,t.textureCoordinateType=t.hasColorTexture||t.hasMetallicRoughnessTexture||t.hasEmissionTexture||t.hasOcclusionTexture||t.hasNormalTexture?l.Default:l.None,t.objectAndLayerIdColorInstanced=t.instanced}initializeProgram(e){return this._initializeProgram(e,q.shader)}_initializeProgram(e,t){return new P(e.rctx,t.get().build(this.configuration),b)}_convertDepthTestFunction(e){return e===d.Lequal?M.LEQUAL:M.LESS}_makePipeline(e,t){const i=this.configuration,r=e===A.NONE,s=e===A.FrontFace;return D({blending:i.output!==o.Color&&i.output!==o.Alpha||!i.transparent?null:r?S:T(e),culling:z(i)?w(i.cullFace):null,depthTest:{func:y(e,this._convertDepthTestFunction(i.customDepthTest))},depthWrite:(r||s)&&i.writeDepth?F:null,colorWrite:_,stencilWrite:i.hasOccludees?x:null,stencilTest:i.hasOccludees?t?v:O:null,polygonOffset:r||s?null:j(i.enableOffset)})}initializePipeline(){return this._occludeePipelineState=this._makePipeline(this.configuration.transparencyPassType,!0),this._makePipeline(this.configuration.transparencyPassType,!1)}getPipelineState(e,t){return t?this._occludeePipelineState:super.getPipelineState(e,t)}}function z(e){return e.cullFace!==m.None||!e.hasSlicePlane&&(!e.transparent&&!e.doubleSidedMode)}q.shader=new u(L,(()=>import("./DefaultMaterial.glsl.js")));export{N as DefaultMaterialDrawParameters,k as DefaultMaterialPassParameters,q as DefaultMaterialTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{f as e}from"../../../../chunks/vec4f64.js";import{NoParameters as r}from"../core/shaderModules/interfaces.js";import{ReloadableShaderModule as t}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as i}from"../core/shaderTechnique/ShaderTechnique.js";import{Default3D as o}from"../lib/DefaultVertexAttributeLocations.js";import{Program as s}from"../lib/Program.js";import{ShadowConfiguration as a}from"./ShadowConfiguration.js";import{S as h}from"../../../../chunks/ShadowHighlight.glsl.js";import{BlendFactor as n,PrimitiveType as l}from"../../../webgl/enums.js";import{makePipelineState as d,separateBlendingParams as m,defaultColorWriteParams as c}from"../../../webgl/renderState.js";class u extends r{constructor(){super(...arguments),this.shadowColor=e(1,0,1,1),this.shadowOpacity=.2,this.occludedShadowOpacity=.1,this.opacityElevation=1,this.dayNightTerminator=1}}class p extends i{constructor(e){super(e,new a,(()=>this.destroy()))}initializeProgram(e){return new s(e.rctx,p.shader.get().build(this.configuration),o)}initializePipeline(){return d({blending:m(n.SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),colorWrite:c,depthTest:null,depthWrite:null})}get primitiveType(){return l.TRIANGLE_STRIP}}p.shader=new t(h,(()=>import("./ShadowHighlight.glsl.js")));export{u as ShadowHighlightPassParameters,p as ShadowHighlightTechnique};
5
+ import{f as r}from"../../../../chunks/vec4f64.js";import{ReadShadowMapPassParameters as e}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{ReloadableShaderModule as i}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as t}from"../core/shaderTechnique/ShaderTechnique.js";import{Default3D as o}from"../lib/DefaultVertexAttributeLocations.js";import{Program as s}from"../lib/Program.js";import{ShadowConfiguration as a}from"./ShadowConfiguration.js";import{S as h}from"../../../../chunks/ShadowHighlight.glsl.js";import{BlendFactor as n,PrimitiveType as l}from"../../../webgl/enums.js";import{makePipelineState as d,separateBlendingParams as m,defaultColorWriteParams as c}from"../../../webgl/renderState.js";class p extends e{constructor(){super(...arguments),this.shadowColor=r(1,0,1,1),this.shadowOpacity=.2,this.occludedShadowOpacity=.1,this.opacityElevation=1,this.dayNightTerminator=1}}class u extends t{constructor(r){super(r,new a,(()=>this.destroy()))}initializeProgram(r){return new s(r.rctx,u.shader.get().build(this.configuration),o)}initializePipeline(){return d({blending:m(n.SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),colorWrite:c,depthTest:null,depthWrite:null})}get primitiveType(){return l.TRIANGLE_STRIP}}u.shader=new i(h,(()=>import("./ShadowHighlight.glsl.js")));export{p as ShadowHighlightPassParameters,u as ShadowHighlightTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{makeHandle as r}from"../../core/handleUtils.js";import{destroyMaybe as l}from"../../core/maybe.js";import{createLength as n,zeroMeters as a,zeroSquareMeters as s}from"../../core/quantityUtils.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as h}from"../../core/unitUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getConvertedElevation as m}from"../../support/elevationInfoUtils.js";import{createSquare as g,createRectangle as f,createCircle as v,createEllipse as _,createPolygon as w,createPolyline as O,createMultipoint as T}from"./support/createUtils.js";import{getDrawHelpMessage as G}from"./support/helpMessageUtils.js";import{createViewAlignedCoordinateSystem as x}from"./support/surfaceCoordinateSystems.js";import{InteractiveToolBase as V}from"../interactive/InteractiveToolBase.js";import S from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{DrawPointTooltipInfo as I,DrawPolylineTooltipInfo as j,DrawPolygonTooltipInfo as M,DrawMeshTooltipInfo as U,DrawRectangleTooltipInfo as C,DrawCircleTooltipInfo as z}from"../interactive/tooltip/DrawTooltipInfos.js";import{Tooltip as k}from"../interactive/tooltip/Tooltip.js";import{autoAreaByElevationMode as P}from"../support/automaticAreaMeasurementUtils.js";import{autoLengthByElevationMode as A,autoHorizontalDistanceByElevationModeBetweenPoints as R}from"../support/automaticLengthMeasurementUtils.js";class D{constructor(){this.regularVertices=null,this.activeVertex=null,this.full=null,this.outline=null,this.circle=null,this.rectangle=null}}let E=class extends(o(i.EventedMixin(V))){constructor(e){super(e),this._graphic=null,this._createOperationGeometry=null,this.defaultZ=0,this.geometryType=null,this.hasZ=!0,this.labelOptions=new S,this.geometryToPlace=null,this.mode=null,this.snappingManager=null,this.snapToScene=!1,this.tooltip=null,this.tooltipOptions=new b}initialize(){this.internalGraphicsLayer=new y({listMode:"hide",internal:!0}),this.view.map.layers.add(this.internalGraphicsLayer),this.drawOperation=this.makeDrawOperation(),this.handles.add([this.drawOperation.on("vertex-add",(e=>this.onVertexAdd(e))),this.drawOperation.on("vertex-remove",(e=>this.onVertexRemove(e))),this.drawOperation.on("vertex-update",(e=>this.onVertexUpdate(e))),this.drawOperation.on("cursor-update",(e=>this.onCursorUpdate(e))),this.drawOperation.on("complete",(e=>this.onComplete(e))),p((()=>this.tooltipOptions.enabled),(e=>{this.tooltip=e?new k({view:this.view,info:this._tooltipInfo}):l(this.tooltip)}),c),p((()=>this._tooltipInfo),(e=>{null!=this.tooltip&&(this.tooltip.info=e)}),c)]),this.finishToolCreation()}destroy(){this.drawOperation=l(this.drawOperation),this.tooltip=l(this.tooltip),this._destroyAllVisualisations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=l(this.internalGraphicsLayer),this._set("view",null)}get _defaultElevation(){return n(this.defaultZ,"meters")}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(e){this._set("centered",e),this._updateGraphic()}set enabled(e){this.drawOperation.interactive=e,this._set("enabled",e)}set forceUniformSize(e){this._set("forceUniformSize",e),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(e){this._set("graphicSymbol",e),null!=this._graphic&&(this._graphic.symbol=e)}get updating(){return this.drawOperation?.updating??!1}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(e){this.drawOperation.onInputEvent(e)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo()}_destroyAllVisualisations(){this.handles.remove(Z.outline),this.handles.remove(Z.regularVertices),this.handles.remove(Z.activeVertex),this.handles.remove(L)}_createOrUpdateGraphic(e){if(null!=this._graphic)return this._updateGraphicGeometry(this._graphic,e),this._graphic;const i=this._graphic=new t({...this.graphicProperties,symbol:this.graphicSymbol});return this._updateGraphicGeometry(i,e),this.internalGraphicsLayer.add(i),this.handles.add(this.initializeGraphic(i)),this.notifyChange("graphic"),this.handles.add(r((()=>{this.internalGraphicsLayer.remove(i),l(i),this._graphic===i&&(this._graphic=null)})),L),i}_updateGraphicGeometry(e,t){e.geometry=t}_getCreateOperationGeometry(e={operationComplete:!1}){const{drawOperation:t}=this;if(null==t||0===t.numVertices)return null;const{coordinateHelper:i,view:o}=t,r=t.stagedVertex,l=t.committedVertices,n=l.slice(),a=null!=r;a&&n.push(i.pointToArray(r));const s=a?i.pointToArray(r):l.splice(-1)[0],p=n.length,c=o.spatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new D;switch(this.geometryType){case"point":case"mesh":u.regularVertices=l,u.activeVertex=s,u.full=i.arrayToPoint(n[0]);break;case"multipoint":u.regularVertices=l,u.activeVertex=s,p>0&&(u.full=T(n,c));break;case"polyline":u.regularVertices=l,u.activeVertex=s,p>0&&(u.full=O([n],c,h));break;case"polygon":u.regularVertices=l,u.activeVertex=s,p>0&&(u.full=w([n],c,h,!0));break;case"circle":if(p>0){const t=x(o,n[0]);if(1===p&&e.operationComplete){const e=n[0],i=t.makeMapPoint(e[0]+N*o.resolution,e[1]);u.circle=v([e,i],t,!0),u.full=null!=u.circle?u.circle.geometry:null}else 2===p&&(this.forceUniformSize?(u.circle=v(n,t,this.centered),u.full=null!=u.circle?u.circle.geometry:null):(u.rectangle=_(n,t,this.centered),u.full=u.rectangle.geometry))}break;case"rectangle":if(p>0){const t=x(o,n[0]);if(1===p&&e.operationComplete){const e=n[0],i=t.makeMapPoint(e[0]+N*o.resolution,e[1]);u.rectangle=g([e,i],t,!0),u.full=u.rectangle.geometry}else 2===p&&(u.rectangle=this.forceUniformSize?g(n,t,this.centered):f(n,t,this.centered),u.full=u.rectangle.geometry)}break;default:return null}switch(this.geometryType){case"point":case"multipoint":break;case"polyline":case"polygon":p>1&&(u.outline=O([n],c,h));break;case"circle":case"rectangle":null!=u.full&&"polygon"===u.full.type&&(u.outline=w(u.full.rings,c,h))}return u}initializeGraphic(e){return null}onComplete(e){this._updateGraphic();let t=null;if(this.drawOperation.isCompleted){const e=this._getCreateOperationGeometry({operationComplete:!0});null!=e&&(t=this._createOrUpdateGraphic(e.full).clone())}this._createOperationGeometry=null,this.emit("complete",{graphic:t,...e})}onCursorUpdate(e){this._updateGraphic(),this.emit("cursor-update",e)}onDeactivate(){this.drawOperation.isCompleted||this.drawOperation.cancel()}onVertexAdd(e){this._updateGraphic(),this.emit("vertex-add",e)}onVertexRemove(e){this._updateGraphic(),this.emit("vertex-remove",e)}onVertexUpdate(e){this._updateGraphic(),this.emit("vertex-update",e)}_updateGraphic(){const e=this._getCreateOperationGeometry();this._createOperationGeometry=e,null!=e?(null!=e.outline?this.handles.add(this.onOutlineChanged(e.outline),Z.outline):this.handles.remove(Z.outline),null!=e.regularVertices?this.handles.add(this.onRegularVerticesChanged(e.regularVertices),Z.regularVertices):this.handles.remove(Z.regularVertices),null!=e.activeVertex?this.handles.add(this.onActiveVertexChanged(e.activeVertex),Z.activeVertex):this.handles.remove(Z.activeVertex),null!=e.full?this._createOrUpdateGraphic(e.full):this.handles.remove(L)):this._destroyAllVisualisations()}get _tooltipInfo(){const{drawOperation:e}=this;if(!e)return null;switch(this.geometryType){case"point":return this._drawPointTooltipInfo;case"polyline":return this._drawPolylineTooltipInfo;case"polygon":return this._drawPolygonTooltipInfo;case"rectangle":return this._drawRectangleTooltipInfo;case"circle":return this._drawCircleTooltipInfo;case"mesh":return this._drawMeshTooltipInfo;default:return null}}get _drawPointTooltipInfo(){const{view:e,graphic:t}=this,i=t?.geometry;return"point"!==i?.type||"2d"===e.type&&0===this.defaultZ?null:new I({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,viewType:e.type,helpMessage:G("point",i,e)})}get _drawPolylineTooltipInfo(){const e=this._createOperationGeometry,t=null!=e?e.full:null;if("polyline"!==t?.type)return null;const i=A(t,this._elevationMode),{view:o}=this;return new j({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,totalLength:i??a,viewType:o.type,helpMessage:G("polyline",t,o)})}get _drawPolygonTooltipInfo(){const e=this._createOperationGeometry,t=null!=e?e.full:null;if("polygon"!==t?.type)return null;const i=P(t,this._elevationMode),{view:o}=this;return new M({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,area:i??s,viewType:o.type,helpMessage:G("polygon",t,o)})}get _drawMeshTooltipInfo(){const{view:e,graphic:t}=this,i=t?.geometry;return"mesh"!==i?.type||"2d"===e.type&&0===this.defaultZ?null:new U({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,viewType:e.type,helpMessage:G("mesh",i,e)})}get _drawRectangleTooltipInfo(){return null==this.drawOperation?null:new C({tooltipOptions:this.tooltipOptions,xSize:this._xSize??a,ySize:this._ySize??a,area:this._fullGeometryArea??s})}get _drawCircleTooltipInfo(){if(null==this.drawOperation)return null;const e=this.forceUniformSize;return new z({tooltipOptions:this.tooltipOptions,radius:e?this._circleRadius??a:null,xSize:e?null:this._xSize??a,ySize:e?null:this._ySize??a,area:this._fullGeometryArea??s})}get _circleRadius(){const e=this._createOperationGeometry;return null!=e&&null!=e.circle&&null!=e.circle.center&&null!=e.circle.edge?R(e.circle.center,e.circle.edge,this._elevationMode):null}get _xSize(){const e=this._createOperationGeometry;if(null==e?.rectangle)return null;const{midpoints:t}=e.rectangle;return null!=t?R(t.left,t.right,this._elevationMode):null}get _ySize(){const e=this._createOperationGeometry;if(null==e?.rectangle)return null;const{midpoints:t}=e.rectangle;return null!=t?R(t.top,t.bottom,this._elevationMode):null}get _fullGeometryArea(){const e=this._createOperationGeometry,t=null!=e?e.full:null;return"polygon"!==t?.type?null:P(t,this._elevationMode)}get _elevationTooltipDetail(){return{mode:this.drawOperation.elevationInfo.mode,...this._vertexTooltipElevation}}get _vertexTooltipElevation(){const{tooltipOptions:e,view:t,drawOperation:i}=this;if(null==i)return this._defaultElevation;const o=i.stagedVertex??i.lastVertex;if(null==o||"2d"===t.type)return this._defaultElevation;const r={mode:e.elevation.mode,offset:0},l=(m(t,o,i.elevationInfo,r)??0)*h(o.spatialReference);return n(l,"meters")}get _elevationMode(){return this.drawOperation.isDraped?"on-the-ground":"absolute-height"}};e([u()],E.prototype,"_createOperationGeometry",void 0),e([u()],E.prototype,"_defaultElevation",null),e([u({value:!0})],E.prototype,"centered",null),e([u({nonNullable:!0})],E.prototype,"defaultZ",void 0),e([u()],E.prototype,"drawOperation",void 0),e([u({value:!0})],E.prototype,"enabled",null),e([u({value:!0})],E.prototype,"forceUniformSize",null),e([u({constructOnly:!0})],E.prototype,"geometryType",void 0),e([u()],E.prototype,"graphic",null),e([u({constructOnly:!0})],E.prototype,"graphicProperties",void 0),e([u()],E.prototype,"graphicSymbol",null),e([u({constructOnly:!0})],E.prototype,"hasZ",void 0),e([u({constructOnly:!0,type:S})],E.prototype,"labelOptions",void 0),e([u({constructOnly:!0})],E.prototype,"geometryToPlace",void 0),e([u({constructOnly:!0})],E.prototype,"mode",void 0),e([u()],E.prototype,"snappingManager",void 0),e([u()],E.prototype,"snapToScene",void 0),e([u()],E.prototype,"tooltip",void 0),e([u({constructOnly:!0,type:b})],E.prototype,"tooltipOptions",void 0),e([u({readOnly:!0})],E.prototype,"type",void 0),e([u({readOnly:!0})],E.prototype,"updating",null),e([u({constructOnly:!0,nonNullable:!0})],E.prototype,"view",void 0),e([u()],E.prototype,"_tooltipInfo",null),e([u()],E.prototype,"_drawPointTooltipInfo",null),e([u()],E.prototype,"_drawPolylineTooltipInfo",null),e([u()],E.prototype,"_drawPolygonTooltipInfo",null),e([u()],E.prototype,"_drawMeshTooltipInfo",null),e([u()],E.prototype,"_drawRectangleTooltipInfo",null),e([u()],E.prototype,"_drawCircleTooltipInfo",null),e([u()],E.prototype,"_circleRadius",null),e([u()],E.prototype,"_xSize",null),e([u()],E.prototype,"_ySize",null),e([u()],E.prototype,"_fullGeometryArea",null),e([u()],E.prototype,"_elevationTooltipDetail",null),e([u()],E.prototype,"_vertexTooltipElevation",null),e([u()],E.prototype,"_elevationMode",null),E=e([d("esri.views.draw.DrawGraphicTool")],E);const L="create-operation-graphic",Z={outline:"outline-visual",regularVertices:"regular-vertices-visual",activeVertex:"active-vertex-visual"};function H(e){switch(e){case"point":case"polyline":case"polygon":case"multipoint":return e;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const N=48;export{D as CreateOperationGeometry,E as DrawGraphicTool,H as geometryTypeToDrawOperationGeometryType};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{makeHandle as r}from"../../core/handleUtils.js";import{destroyMaybe as l}from"../../core/maybe.js";import{createLength as n,zeroMeters as a,zeroSquareMeters as s}from"../../core/quantityUtils.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as h}from"../../core/unitUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getConvertedElevation as m}from"../../support/elevationInfoUtils.js";import{createSquare as g,createRectangle as f,createCircle as v,createEllipse as _,createPolygon as w,createPolyline as O,createMultipoint as T}from"./support/createUtils.js";import{getDrawHelpMessage as G}from"./support/helpMessageUtils.js";import{createViewAlignedCoordinateSystem as x}from"./support/surfaceCoordinateSystems.js";import{InteractiveToolBase as V}from"../interactive/InteractiveToolBase.js";import b from"../interactive/sketch/SketchLabelOptions.js";import S from"../interactive/sketch/SketchTooltipOptions.js";import{DrawPointTooltipInfo as I,DrawPolylineTooltipInfo as j,DrawPolygonTooltipInfo as M,DrawMeshTooltipInfo as U,DrawRectangleTooltipInfo as C,DrawCircleTooltipInfo as z}from"../interactive/tooltip/DrawTooltipInfos.js";import{Tooltip as k}from"../interactive/tooltip/Tooltip.js";import{autoAreaByElevationMode as P}from"../support/automaticAreaMeasurementUtils.js";import{autoLengthByElevationMode as A,autoHorizontalDistanceByElevationModeBetweenPoints as R}from"../support/automaticLengthMeasurementUtils.js";class D{constructor(){this.regularVertices=null,this.activeVertex=null,this.full=null,this.outline=null,this.circle=null,this.rectangle=null}}let E=class extends(o(i.EventedMixin(V))){constructor(e){super(e),this._graphic=null,this._createOperationGeometry=null,this.defaultZ=0,this.geometryType=null,this.hasZ=!0,this.labelOptions=new b,this.geometryToPlace=null,this.mode=null,this.snappingManager=null,this.snapToScene=!1,this.tooltip=null,this.tooltipOptions=new S}initialize(){this.internalGraphicsLayer=new y({listMode:"hide",internal:!0}),this.view.map.layers.add(this.internalGraphicsLayer),this.drawOperation=this.makeDrawOperation(),this.handles.add([this.drawOperation.on("vertex-add",(e=>this.onVertexAdd(e))),this.drawOperation.on("vertex-remove",(e=>this.onVertexRemove(e))),this.drawOperation.on("vertex-update",(e=>this.onVertexUpdate(e))),this.drawOperation.on("cursor-update",(e=>this.onCursorUpdate(e))),this.drawOperation.on("complete",(e=>this.onComplete(e))),p((()=>this.tooltipOptions.enabled),(e=>{this.tooltip=e?new k({view:this.view,info:this._tooltipInfo}):l(this.tooltip)}),c),p((()=>this._tooltipInfo),(e=>{null!=this.tooltip&&(this.tooltip.info=e)}),c)]),this.finishToolCreation()}destroy(){this.drawOperation=l(this.drawOperation),this.tooltip=l(this.tooltip),this._destroyAllVisualisations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=l(this.internalGraphicsLayer),this._set("view",null)}get _defaultElevation(){return n(this.defaultZ,"meters")}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(e){this._set("centered",e),this._updateGraphic()}set enabled(e){this.drawOperation.interactive=e,this._set("enabled",e)}set forceUniformSize(e){this._set("forceUniformSize",e),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(e){this._set("graphicSymbol",e),null!=this._graphic&&(this._graphic.symbol=e)}get updating(){return this.drawOperation?.updating??!1}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(e){this.drawOperation.onInputEvent(e)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo()}_destroyAllVisualisations(){this.handles.remove(Z.outline),this.handles.remove(Z.regularVertices),this.handles.remove(Z.activeVertex),this.handles.remove(L)}_createOrUpdateGraphic(e){if(null!=this._graphic)return this._updateGraphicGeometry(this._graphic,e),this._graphic;const i=this._graphic=new t({...this.graphicProperties,symbol:this.graphicSymbol});return this._updateGraphicGeometry(i,e),this.internalGraphicsLayer.add(i),this.handles.add(this.initializeGraphic(i)),this.notifyChange("graphic"),this.handles.add(r((()=>{this.internalGraphicsLayer.remove(i),l(i),this._graphic===i&&(this._graphic=null)})),L),i}_updateGraphicGeometry(e,t){e.geometry=t}_getCreateOperationGeometry(e={operationComplete:!1}){const{drawOperation:t}=this;if(null==t||0===t.numVertices)return null;const{coordinateHelper:i,view:o}=t,r=t.stagedVertex,l=t.committedVertices,n=l.slice(),a=null!=r;a&&n.push(i.pointToArray(r));const s=a?i.pointToArray(r):l.splice(-1)[0],p=n.length,c=o.spatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new D;switch(this.geometryType){case"point":case"mesh":u.regularVertices=l,u.activeVertex=s,u.full=i.arrayToPoint(n[0]);break;case"multipoint":u.regularVertices=l,u.activeVertex=s,p>0&&(u.full=T(n,c));break;case"polyline":u.regularVertices=l,u.activeVertex=s,p>0&&(u.full=O([n],c,h));break;case"polygon":u.regularVertices=l,u.activeVertex=s,p>0&&(u.full=w([n],c,h,!0));break;case"circle":if(p>0){const t=x(o,n[0]);if(1===p&&e.operationComplete){const e=n[0],i=t.makeMapPoint(e[0]+N*o.resolution,e[1]);u.circle=v([e,i],t,!0),u.full=null!=u.circle?u.circle.geometry:null}else 2===p&&(this.forceUniformSize?(u.circle=v(n,t,this.centered),u.full=null!=u.circle?u.circle.geometry:null):(u.rectangle=_(n,t,this.centered),u.full=u.rectangle.geometry))}break;case"rectangle":if(p>0){const t=x(o,n[0]);if(1===p&&e.operationComplete){const e=n[0],i=t.makeMapPoint(e[0]+N*o.resolution,e[1]);u.rectangle=g([e,i],t,!0),u.full=u.rectangle.geometry}else 2===p&&(u.rectangle=this.forceUniformSize?g(n,t,this.centered):f(n,t,this.centered),u.full=u.rectangle.geometry)}break;default:return null}switch(this.geometryType){case"point":case"multipoint":break;case"polyline":u.outline=p>1?O([n],c,h):null;break;case"polygon":u.outline=p>1?w([n],c,h):null;break;case"circle":case"rectangle":u.outline="polygon"===u.full?.type?w(u.full.rings,c,h):null}return u}initializeGraphic(e){return null}onComplete(e){this._updateGraphic();let t=null;if(this.drawOperation.isCompleted){const e=this._getCreateOperationGeometry({operationComplete:!0});null!=e&&(t=this._createOrUpdateGraphic(e.full).clone())}this._createOperationGeometry=null,this.emit("complete",{graphic:t,...e})}onCursorUpdate(e){this._updateGraphic(),this.emit("cursor-update",e)}onDeactivate(){this.drawOperation.isCompleted||this.drawOperation.cancel()}onVertexAdd(e){this._updateGraphic(),this.emit("vertex-add",e)}onVertexRemove(e){this._updateGraphic(),this.emit("vertex-remove",e)}onVertexUpdate(e){this._updateGraphic(),this.emit("vertex-update",e)}_updateGraphic(){const e=this._getCreateOperationGeometry();this._createOperationGeometry=e,null!=e?(null!=e.outline?this.handles.add(this.onOutlineChanged(e.outline),Z.outline):this.handles.remove(Z.outline),null!=e.regularVertices?this.handles.add(this.onRegularVerticesChanged(e.regularVertices),Z.regularVertices):this.handles.remove(Z.regularVertices),null!=e.activeVertex?this.handles.add(this.onActiveVertexChanged(e.activeVertex),Z.activeVertex):this.handles.remove(Z.activeVertex),null!=e.full?this._createOrUpdateGraphic(e.full):this.handles.remove(L)):this._destroyAllVisualisations()}get _tooltipInfo(){const{drawOperation:e}=this;if(!e)return null;switch(this.geometryType){case"point":return this._drawPointTooltipInfo;case"polyline":return this._drawPolylineTooltipInfo;case"polygon":return this._drawPolygonTooltipInfo;case"rectangle":return this._drawRectangleTooltipInfo;case"circle":return this._drawCircleTooltipInfo;case"mesh":return this._drawMeshTooltipInfo;default:return null}}get _drawPointTooltipInfo(){const{view:e,graphic:t}=this,i=t?.geometry;return"point"!==i?.type||"2d"===e.type&&0===this.defaultZ?null:new I({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,viewType:e.type,helpMessage:G("point",i,e)})}get _drawPolylineTooltipInfo(){const e=this._createOperationGeometry,t=null!=e?e.full:null;if("polyline"!==t?.type)return null;const i=A(t,this._elevationMode),{view:o}=this;return new j({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,totalLength:i??a,viewType:o.type,helpMessage:G("polyline",t,o)})}get _drawPolygonTooltipInfo(){const e=this._createOperationGeometry,t=null!=e?e.full:null;if("polygon"!==t?.type)return null;const i=P(t,this._elevationMode),{view:o}=this;return new M({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,area:i??s,viewType:o.type,helpMessage:G("polygon",t,o)})}get _drawMeshTooltipInfo(){const{view:e,graphic:t}=this,i=t?.geometry;return"mesh"!==i?.type||"2d"===e.type&&0===this.defaultZ?null:new U({tooltipOptions:this.tooltipOptions,elevation:this._elevationTooltipDetail,viewType:e.type,helpMessage:G("mesh",i,e)})}get _drawRectangleTooltipInfo(){return null==this.drawOperation?null:new C({tooltipOptions:this.tooltipOptions,xSize:this._xSize??a,ySize:this._ySize??a,area:this._fullGeometryArea??s})}get _drawCircleTooltipInfo(){if(null==this.drawOperation)return null;const e=this.forceUniformSize;return new z({tooltipOptions:this.tooltipOptions,radius:e?this._circleRadius??a:null,xSize:e?null:this._xSize??a,ySize:e?null:this._ySize??a,area:this._fullGeometryArea??s})}get _circleRadius(){const e=this._createOperationGeometry;return null!=e&&null!=e.circle&&null!=e.circle.center&&null!=e.circle.edge?R(e.circle.center,e.circle.edge,this._elevationMode):null}get _xSize(){const e=this._createOperationGeometry;if(null==e?.rectangle)return null;const{midpoints:t}=e.rectangle;return null!=t?R(t.left,t.right,this._elevationMode):null}get _ySize(){const e=this._createOperationGeometry;if(null==e?.rectangle)return null;const{midpoints:t}=e.rectangle;return null!=t?R(t.top,t.bottom,this._elevationMode):null}get _fullGeometryArea(){const e=this._createOperationGeometry,t=null!=e?e.full:null;return"polygon"!==t?.type?null:P(t,this._elevationMode)}get _elevationTooltipDetail(){return{mode:this.drawOperation.elevationInfo.mode,...this._vertexTooltipElevation}}get _vertexTooltipElevation(){const{tooltipOptions:e,view:t,drawOperation:i}=this;if(null==i)return this._defaultElevation;const o=i.stagedVertex??i.lastVertex;if(null==o||"2d"===t.type)return this._defaultElevation;const r={mode:e.elevation.mode,offset:0},l=(m(t,o,i.elevationInfo,r)??0)*h(o.spatialReference);return n(l,"meters")}get _elevationMode(){return this.drawOperation.isDraped?"on-the-ground":"absolute-height"}};e([u()],E.prototype,"_createOperationGeometry",void 0),e([u()],E.prototype,"_defaultElevation",null),e([u({value:!0})],E.prototype,"centered",null),e([u({nonNullable:!0})],E.prototype,"defaultZ",void 0),e([u()],E.prototype,"drawOperation",void 0),e([u({value:!0})],E.prototype,"enabled",null),e([u({value:!0})],E.prototype,"forceUniformSize",null),e([u({constructOnly:!0})],E.prototype,"geometryType",void 0),e([u()],E.prototype,"graphic",null),e([u({constructOnly:!0})],E.prototype,"graphicProperties",void 0),e([u()],E.prototype,"graphicSymbol",null),e([u({constructOnly:!0})],E.prototype,"hasZ",void 0),e([u({constructOnly:!0,type:b})],E.prototype,"labelOptions",void 0),e([u({constructOnly:!0})],E.prototype,"geometryToPlace",void 0),e([u({constructOnly:!0})],E.prototype,"mode",void 0),e([u()],E.prototype,"snappingManager",void 0),e([u()],E.prototype,"snapToScene",void 0),e([u()],E.prototype,"tooltip",void 0),e([u({constructOnly:!0,type:S})],E.prototype,"tooltipOptions",void 0),e([u({readOnly:!0})],E.prototype,"type",void 0),e([u({readOnly:!0})],E.prototype,"updating",null),e([u({constructOnly:!0,nonNullable:!0})],E.prototype,"view",void 0),e([u()],E.prototype,"_tooltipInfo",null),e([u()],E.prototype,"_drawPointTooltipInfo",null),e([u()],E.prototype,"_drawPolylineTooltipInfo",null),e([u()],E.prototype,"_drawPolygonTooltipInfo",null),e([u()],E.prototype,"_drawMeshTooltipInfo",null),e([u()],E.prototype,"_drawRectangleTooltipInfo",null),e([u()],E.prototype,"_drawCircleTooltipInfo",null),e([u()],E.prototype,"_circleRadius",null),e([u()],E.prototype,"_xSize",null),e([u()],E.prototype,"_ySize",null),e([u()],E.prototype,"_fullGeometryArea",null),e([u()],E.prototype,"_elevationTooltipDetail",null),e([u()],E.prototype,"_vertexTooltipElevation",null),e([u()],E.prototype,"_elevationMode",null),E=e([d("esri.views.draw.DrawGraphicTool")],E);const L="create-operation-graphic",Z={outline:"outline-visual",regularVertices:"regular-vertices-visual",activeVertex:"active-vertex-visual"};function H(e){switch(e){case"point":case"polyline":case"polygon":case"multipoint":return e;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const N=48;export{D as CreateOperationGeometry,E as DrawGraphicTool,H as geometryTypeToDrawOperationGeometryType};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as i}from"../../chunks/tslib.es6.js";import e from"../../core/Collection.js";import{referenceSetter as s,castForReferenceSetter as r}from"../../core/collectionUtils.js";import{watch as t,sync as l}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import o from"./LayerView.js";let h=class extends o{constructor(i){super(i),this.type="group",this.layerViews=new e}destroy(){this.handles.removeAll();const i=this.layerViews.toArray();for(const e of i)e.destroy();this.layerViews.length=0}_allLayerViewVisibility(i){this.layerViews.forEach((e=>{e.visible=i}))}initialize(){this.handles.add([this.layerViews.on("change",(i=>this._layerViewsChangeHandler(i))),t((()=>this.layer?.visibilityMode),(()=>{this.layer&&this._applyVisibility((()=>this._allLayerViewVisibility(this.visible)),(()=>this._applyExclusiveVisibility(null)))}),l),t((()=>this.visible),(i=>{this._applyVisibility((()=>this._allLayerViewVisibility(i)),(()=>{}))}),l)],"grouplayerview"),this._layerViewsChangeHandler({target:null,added:this.layerViews.toArray(),removed:[],moved:[]})}set layerViews(i){this._set("layerViews",s(i,this._get("layerViews")))}get updatingProgress(){return 0===this.layerViews.length?1:this.layerViews.reduce(((i,e)=>i+e.updatingProgress),0)/this.layerViews.length}isUpdating(){return this.layerViews.some((i=>i.updating))}_hasLayerViewVisibleOverrides(){return this.layerViews.some((i=>i._isOverridden("visible")))}_findLayerViewForLayer(i){return i&&this.layerViews.find((e=>e.layer===i))}_firstVisibleOnLayerOrder(){const i=this.layer.layers.find((i=>{const e=this._findLayerViewForLayer(i);return!!e?.visible}));return i&&this._findLayerViewForLayer(i)}_applyExclusiveVisibility(i){null==i&&null==(i=this._firstVisibleOnLayerOrder())&&this.layerViews.length>0&&(i=this._findLayerViewForLayer(this.layer.layers.at(0))),this.layerViews.forEach((e=>{e.visible=e===i}))}_layerViewsChangeHandler(i){this.handles.remove("grouplayerview:visible"),this.handles.add(this.layerViews.map((i=>t((()=>i.visible),(e=>this._applyVisibility((()=>{e!==this.visible&&(i.visible=this.visible)}),(()=>this._applyExclusiveVisibility(e?i:null)))),l))).toArray(),"grouplayerview:visible");const e=i.added[i.added.length-1];this._applyVisibility((()=>this._allLayerViewVisibility(this.visible)),(()=>this._applyExclusiveVisibility(e?.visible?e:null)))}_applyVisibility(i,e){this._hasLayerViewVisibleOverrides()&&("inherited"===this.layer?.visibilityMode?i():"exclusive"===this.layer?.visibilityMode&&e())}};i([a({cast:r})],h.prototype,"layerViews",null),i([a({readOnly:!0})],h.prototype,"updatingProgress",null),i([a()],h.prototype,"view",void 0),h=i([y("esri.views.layers.GroupLayerView")],h);const n=h;export{n as default};
5
+ import{_ as i}from"../../chunks/tslib.es6.js";import e from"../../core/Collection.js";import{referenceSetter as s,castForReferenceSetter as r}from"../../core/collectionUtils.js";import{watch as t,sync as l}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import o from"./LayerView.js";let h=class extends o{constructor(i){super(i),this.type="group",this.layerViews=new e}destroy(){this.handles.removeAll(),this.layerViews.length=0}_allLayerViewVisibility(i){this.layerViews.forEach((e=>{e.visible=i}))}initialize(){this.handles.add([this.layerViews.on("change",(i=>this._layerViewsChangeHandler(i))),t((()=>this.layer?.visibilityMode),(()=>{this.layer&&this._applyVisibility((()=>this._allLayerViewVisibility(this.visible)),(()=>this._applyExclusiveVisibility(null)))}),l),t((()=>this.visible),(i=>{this._applyVisibility((()=>this._allLayerViewVisibility(i)),(()=>{}))}),l)],"grouplayerview"),this._layerViewsChangeHandler({target:null,added:this.layerViews.toArray(),removed:[],moved:[]})}set layerViews(i){this._set("layerViews",s(i,this._get("layerViews")))}get updatingProgress(){return 0===this.layerViews.length?1:this.layerViews.reduce(((i,e)=>i+e.updatingProgress),0)/this.layerViews.length}isUpdating(){return this.layerViews.some((i=>i.updating))}_hasLayerViewVisibleOverrides(){return this.layerViews.some((i=>i._isOverridden("visible")))}_findLayerViewForLayer(i){return i&&this.layerViews.find((e=>e.layer===i))}_firstVisibleOnLayerOrder(){const i=this.layer.layers.find((i=>{const e=this._findLayerViewForLayer(i);return!!e?.visible}));return i&&this._findLayerViewForLayer(i)}_applyExclusiveVisibility(i){null==i&&null==(i=this._firstVisibleOnLayerOrder())&&this.layerViews.length>0&&(i=this._findLayerViewForLayer(this.layer.layers.at(0))),this.layerViews.forEach((e=>{e.visible=e===i}))}_layerViewsChangeHandler(i){this.handles.remove("grouplayerview:visible"),this.handles.add(this.layerViews.map((i=>t((()=>i.visible),(e=>this._applyVisibility((()=>{e!==this.visible&&(i.visible=this.visible)}),(()=>this._applyExclusiveVisibility(e?i:null)))),l))).toArray(),"grouplayerview:visible");const e=i.added[i.added.length-1];this._applyVisibility((()=>this._allLayerViewVisibility(this.visible)),(()=>this._applyExclusiveVisibility(e?.visible?e:null)))}_applyVisibility(i,e){this._hasLayerViewVisibleOverrides()&&("inherited"===this.layer?.visibilityMode?i():"exclusive"===this.layer?.visibilityMode&&e())}};i([a({cast:r})],h.prototype,"layerViews",null),i([a({readOnly:!0})],h.prototype,"updatingProgress",null),i([a()],h.prototype,"view",void 0),h=i([y("esri.views.layers.GroupLayerView")],h);const n=h;export{n as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{makeHandle as e}from"../../core/handleUtils.js";import{applySome as s,removeMaybe as n}from"../../core/maybe.js";import{when as l,initial as a,watch as o,on as r,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,resetUTCDate as p,offsetDate as u}from"../../core/timeUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../views/SceneView.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as w}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as S,sliderPosToDateTime as D,getSeasonFromDate as T,getNorthernHemisphereSeason as U,getSeasonDate as v,Hemisphere as P,calculatePlaySpeed as L}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as b}from"./support/SliderWithDropdownViewModel.js";import O from"../support/DatePickerViewModel.js";import{formatSliderLabel as E,getSunriseAndSunsetTimes as C}from"../support/timeWidgetUtils.js";let M=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new O,this.timeSliderViewModel=new b({min:0,max:1439,values:[0],labelFormatFunction:E,inputFormatFunction:E}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.handles.add([l((()=>this.view),(t=>t.when((()=>this._updateLighting()))),a),o((()=>s(this._lighting,(t=>"virtual"!==t.type?t.date:null))),(t=>this._scheduleLightingUpdate(t))),r((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),o((()=>!0===s(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),a),o((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),o((()=>this.timeSliderViewModel?.utcOffset),(t=>{null!=t&&(this.utcOffset=t)})),o((()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel})),(({utcOffset:t,sliderViewModel:i})=>{i&&(i.utcOffset=t)}),h),o((()=>this.timeSliderViewModel.timezonePickerOpen),(()=>this.stopPlaying())),o((()=>this.timeSliderViewModel.values),(t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))),o((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),o((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=p(this._lightingDateDisplay,t))}get timeSliderPosition(){return S(this._lightingDateDisplay)}set timeSliderPosition(t){this._setTimeSliderPosition(t,{forceLightingUpdate:!0})}_setTimeSliderPosition(t,i){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction(),i.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=D(this._lightingDateDisplay,t))}_timezoneFromCamera(t,i){if(null==i||!t.cameraTrackingEnabled)return 0;const e=w([i.longitude,i.latitude]);return null==e?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){return s(this._lighting,(t=>t.directShadowsEnabled))??!1}set directShadowsEnabled(t){s(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||null==i)return;const e=i.lighting,s=this._oldLighting;this._oldLighting=e;const n={directShadowsEnabled:e.directShadowsEnabled,cameraTrackingEnabled:e.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=s&&s.type===l?s:t?new _:new f,a.set(n),i.lighting=a,t||(this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return T(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=U(t,this._currentHemisphere);this.localDate=v(this.localDate,i,P.NORTHERN)}get _currentHemisphere(){const t=s(this.view,(t=>t.camera?.position?.latitude));return null==t||t>=0?P.NORTHERN:P.SOUTHERN}get _environment(){return s(this.view,(t=>t.environment))}get _lighting(){return s(this._environment,(t=>t.lighting))}get _lightingType(){return s(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return u(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(null==i||!this.sunLightingEnabled||"virtual"===i.type)return;const e=u(t,-this._cachedDisplayUTCOffset,"hours");e.getTime()!==i.date.getTime()&&(i.date=e,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,s=this._lighting;if(null==e||null==s||"virtual"===s.type)return;const n=t||s.date,l=s.displayUTCOffset,a=null!==l?l:this._timezoneFromCamera(s,e.camera?.position);this._cachedLightingDateUTC.getTime()!==n.getTime()&&(this._cachedLightingDateUTC=new Date(n.getTime())),this._cachedDisplayUTCOffset!==a&&(this._cachedDisplayUTCOffset=a)}_timezoneWillChange(t){const i=this._lighting;if(null==i||"virtual"===i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=_.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=n(this._lightingUpdateHandle)),this._lightingUpdateHandle)return;const i=Date.now()-this._lastLightingUpdate,s=this.lightingUpdateInterval-i;let l=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===l&&(this._lightingUpdateHandle=null)};if(s<=0)this._lightingUpdateHandle=l=g(a);else{const t=setTimeout(a,s);this._lightingUpdateHandle=l=e((()=>clearTimeout(t)))}}_cancelLightingUpdate(){this._lightingUpdateHandle=n(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null!=t&&this.sunLightingEnabled&&"virtual"!==t.type&&(this.dayPlaying||this.yearPlaying)){const i=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const e=L(this._sunrise,this._sunset,t.date)*this.playSpeedMultiplier/100*i;if(e>0){let i=new Date(t.date.getTime()+e);const s=t.displayUTCOffset??0;if(((i.getUTCHours()+s)%24+24)%24<((t.date.getUTCHours()+s)%24+24)%24){const s=864e5;i=new Date(t.date.getTime()+e-s)}t.date=i}}else{if(i>1e3){this._lastTime=Date.now();const i=(t.date.getUTCMonth()+1)%12,e=new Date(t.date.getTime());e.setUTCMonth(i),t.date=e}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const i=s(this.view,(t=>t.camera?.position));if(null==i)return;const{latitude:e,longitude:n}=i,{date:l,displayUTCOffset:a}=t,o=C(l,e,n,a);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}};t([c({type:m})],M.prototype,"view",void 0),t([c({type:O,nonNullable:!0})],M.prototype,"datePickerViewModel",void 0),t([c({type:b,nonNullable:!0})],M.prototype,"timeSliderViewModel",void 0),t([c()],M.prototype,"isSupported",null),t([c()],M.prototype,"lightingUpdateInterval",void 0),t([c()],M.prototype,"utcOffset",null),t([c()],M.prototype,"localDate",null),t([c()],M.prototype,"timeSliderPosition",null),t([c()],M.prototype,"directShadowsEnabled",null),t([c()],M.prototype,"sunLightingEnabled",null),t([c({type:["none","day","year"],value:"none"})],M.prototype,"playingState",null),t([c()],M.prototype,"dayPlaying",null),t([c()],M.prototype,"yearPlaying",null),t([c()],M.prototype,"playSpeedMultiplier",void 0),t([c()],M.prototype,"currentSeason",null),t([c()],M.prototype,"_lastTime",void 0),t([c()],M.prototype,"_sunrise",void 0),t([c()],M.prototype,"_sunset",void 0),t([c()],M.prototype,"_cachedLightingDateUTC",void 0),t([c()],M.prototype,"_cachedDisplayUTCOffset",void 0),t([c()],M.prototype,"_firstInteraction",void 0),t([c()],M.prototype,"_currentHemisphere",null),t([c()],M.prototype,"_environment",null),t([c()],M.prototype,"_lighting",null),t([c()],M.prototype,"_lightingType",null),t([c()],M.prototype,"_lightingDateDisplay",null),M=t([y("esri.widgets.Daylight.DaylightViewModel")],M);const V=M;export{V as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{makeHandle as e}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{applySome as s,removeMaybe as l}from"../../core/maybe.js";import{when as a,initial as o,watch as r,on as h,syncAndInitial as g}from"../../core/reactiveUtils.js";import{schedule as d}from"../../core/scheduling.js";import{truncateLocalTime as p,isValidDate as u,resetUTCDate as c,offsetDate as y}from"../../core/timeUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../views/SceneView.js";import w from"../../views/3d/environment/SunLighting.js";import S from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as D}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as T,sliderPosToDateTime as v,getSeasonFromDate as U,getNorthernHemisphereSeason as P,getSeasonDate as L,Hemisphere as b,calculatePlaySpeed as O}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as E}from"./support/SliderWithDropdownViewModel.js";import C from"../support/DatePickerViewModel.js";import{formatSliderLabel as M,getSunriseAndSunsetTimes as j}from"../support/timeWidgetUtils.js";const V="esri.widgets.Daylight.DaylightViewModel";let H=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new C,this.timeSliderViewModel=new E({min:0,max:1439,values:[0],labelFormatFunction:M,inputFormatFunction:M}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.handles.add([a((()=>this.view),(t=>t.when((()=>this._updateLighting()))),o),r((()=>{const t=this._lighting;return"sun"===t?.type?I(t):null}),(t=>this._scheduleLightingUpdate(t))),h((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),r((()=>!0===s(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),o),r((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),r((()=>this.timeSliderViewModel?.utcOffset),(t=>{null!=t&&(this.utcOffset=t)})),r((()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel})),(({utcOffset:t,sliderViewModel:i})=>{i&&(i.utcOffset=t)}),g),r((()=>this.timeSliderViewModel.timezonePickerOpen),(()=>this.stopPlaying())),r((()=>this.timeSliderViewModel.values),(t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))),r((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),r((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return p(this._lightingDateDisplay)}set localDate(t){u(t)&&t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=c(this._lightingDateDisplay,t))}get timeSliderPosition(){return T(this._lightingDateDisplay)}set timeSliderPosition(t){this._setTimeSliderPosition(t,{forceLightingUpdate:!0})}_setTimeSliderPosition(t,i){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction(),i.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=v(this._lightingDateDisplay,t))}_timezoneFromCamera(t,i){if(null==i||!t.cameraTrackingEnabled)return 0;const e=D([i.longitude,i.latitude]);return null==e?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){return s(this._lighting,(t=>t.directShadowsEnabled))??!1}set directShadowsEnabled(t){s(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||null==i)return;const e=i.lighting,n=this._oldLighting;this._oldLighting=e;const s={directShadowsEnabled:e.directShadowsEnabled,cameraTrackingEnabled:e.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=n&&n.type===l?n:t?new w:new S,a.set(s),i.lighting=a,t||(this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return U(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=P(t,this._currentHemisphere);this.localDate=L(this.localDate,i,b.NORTHERN)}get _currentHemisphere(){const t=s(this.view,(t=>t.camera?.position?.latitude));return null==t||t>=0?b.NORTHERN:b.SOUTHERN}get _environment(){return s(this.view,(t=>t.environment))}get _lighting(){return s(this._environment,(t=>t.lighting))}get _lightingType(){return s(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return y(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(null==i||!this.sunLightingEnabled||"virtual"===i.type||!u(t))return;const e=I(i),n=y(t,-this._cachedDisplayUTCOffset,"hours");n.getTime()!==e.getTime()&&(i.date=n,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,n=this._lighting;if(null==e||null==n||"virtual"===n.type)return;t??=I(n);const s=n.displayUTCOffset,l=null!==s?s:this._timezoneFromCamera(n,e.camera?.position);this._cachedLightingDateUTC.getTime()!==t.getTime()&&(this._cachedLightingDateUTC=new Date(t.getTime())),this._cachedDisplayUTCOffset!==l&&(this._cachedDisplayUTCOffset=l)}_timezoneWillChange(t){const i=this._lighting;if(null==i||"virtual"===i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=w.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=l(this._lightingUpdateHandle),!u(t)))return;if(this._lightingUpdateHandle)return;const i=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-i;let s=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===s&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=s=d(a);else{const t=setTimeout(a,n);this._lightingUpdateHandle=s=e((()=>clearTimeout(t)))}}_cancelLightingUpdate(){this._lightingUpdateHandle=l(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null==t||!this.sunLightingEnabled||"virtual"===t.type)return;const i=I(t);if(this.dayPlaying||this.yearPlaying){const e=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const n=O(this._sunrise,this._sunset,i)*this.playSpeedMultiplier/100*e;if(n>0){let e=new Date(i.getTime()+n);const s=t.displayUTCOffset??0;if(((e.getUTCHours()+s)%24+24)%24<((i.getUTCHours()+s)%24+24)%24){const t=864e5;e=new Date(i.getTime()+n-t)}t.date=e}}else{if(e>1e3){this._lastTime=Date.now();const e=(i.getUTCMonth()+1)%12,n=new Date(i.getTime());n.setUTCMonth(e),t.date=n}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const i=s(this.view,(t=>t.camera?.position));if(null==i)return;const{latitude:e,longitude:n}=i,{date:l,displayUTCOffset:a}=t,o=j(l,e,n,a);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}};function I(t){return u(t.date)||(n.getLogger(V).warn("Invalid date. Reverting to the current date/time."),t.date=new Date),t.date}t([m({type:f})],H.prototype,"view",void 0),t([m({type:C,nonNullable:!0})],H.prototype,"datePickerViewModel",void 0),t([m({type:E,nonNullable:!0})],H.prototype,"timeSliderViewModel",void 0),t([m()],H.prototype,"isSupported",null),t([m()],H.prototype,"lightingUpdateInterval",void 0),t([m()],H.prototype,"utcOffset",null),t([m()],H.prototype,"localDate",null),t([m()],H.prototype,"timeSliderPosition",null),t([m()],H.prototype,"directShadowsEnabled",null),t([m()],H.prototype,"sunLightingEnabled",null),t([m({type:["none","day","year"],value:"none"})],H.prototype,"playingState",null),t([m()],H.prototype,"dayPlaying",null),t([m()],H.prototype,"yearPlaying",null),t([m()],H.prototype,"playSpeedMultiplier",void 0),t([m()],H.prototype,"currentSeason",null),t([m()],H.prototype,"_lastTime",void 0),t([m()],H.prototype,"_sunrise",void 0),t([m()],H.prototype,"_sunset",void 0),t([m()],H.prototype,"_cachedLightingDateUTC",void 0),t([m()],H.prototype,"_cachedDisplayUTCOffset",void 0),t([m()],H.prototype,"_firstInteraction",void 0),t([m()],H.prototype,"_currentHemisphere",null),t([m()],H.prototype,"_environment",null),t([m()],H.prototype,"_lighting",null),t([m()],H.prototype,"_lightingType",null),t([m()],H.prototype,"_lightingDateDisplay",null),H=t([_(V)],H);const k=H;export{k as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as W}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import M from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new j,this.sketchViewModel=new M({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&await(this.activeWorkflow?.back(this.showDiscardEditsPrompt))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1==!!t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(b)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()];if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!W(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import o from"../../core/Evented.js";import{HandleOwnerMixin as s}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as W}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import M from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(s(o.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new j,this.sketchViewModel=new M({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow())},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),c((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const o={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(o);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(o):this.startCreateFeaturesWorkflowAtFeatureCreation(o)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,o=!(i&&"visible"in i)||!!i.visible;return e.visible&&o&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1==!!t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],o=r?.allTables.toArray().filter(W)??[];await Promise.all(o.map((t=>t.load())));const s=o.filter((t=>k(t))),n=[...i.reverse(),...s.reverse()];if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,o={returnServiceEditsOption:(!i||!b(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,o),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),o=A(t),s=t.fields.some((({type:t})=>O.has(t))),n=o||s,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:o,hasUnsupportedFields:s}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;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/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import{abortMaybe as i}from"../../core/maybe.js";import{onAbort as o,createAbortError as r,throwIfAborted as s,debounce as n}from"../../core/promiseUtils.js";import l from"../../core/Queue.js";import{whenOnce as d,watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isNonSpatialTable as u}from"../../layers/support/layerUtils.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import{UpdateFeatureWorkflow as f}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as m}from"./UpdateRecordWorkflow.js";import g from"./UpdateWorkflowData.js";import k from"./Workflow.js";import{createWorkflowSteps as y,fetchCandidates as v}from"./workflowUtils.js";var W;const _="candidate-highlight",b="esri.widgets.Editor.UpdateWorkflow";let S=W=class extends k{constructor(t){super(t),this._workflowStack=new l((t=>{let e;for(e of t);return e})),this.type="update"}initialize(){const{featureFormViewModel:t}=this.data.viewModel,e=t.relatedRecordCallbacks;t.relatedRecordCallbacks={addRelatedRecord:()=>{},editRelatedRecord:({relatedFeature:t})=>this.startUpdating(t)},this.addHandles(a((()=>t.relatedRecordCallbacks=e)))}get activeEditableItem(){const{activeWorkflow:t}=this;return U(t)?t.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((t=>t.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(t){this.activeWorkflow?(this.activeWorkflow.hasPendingEdits&&await(t?.()),await this.cancelActiveWorkflow({force:!0})):this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((t=>t.commit())),await super.commit()}static create(t,e,a){const i=new W({data:new g({applyEditsCallback:a,viewModel:t}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,e)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startUpdating(t){try{const e=await this._createNestedWorkflow(t);await this._pushWorkflow(e)}catch(a){throw new e("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new e("editor:nothing-to-delete","There is no feature to delete");U(t)?await t.deleteAndCommit():await t.cancel()}async cancelAll(){await this._drainWorkflowStack((t=>t.cancel({force:!0})))}async _createNestedWorkflow(t){const e=u(t.sourceLayer)?m:f,{applyEditsCallback:a,viewModel:i}=this.data,o=await e.create({feature:t,viewModel:i,applyEdits:a});return await d((()=>!o.updating)),o}async _drainWorkflowStack(t){const e=this._workflowStack,a=[];for(;e.length>0;){const i=e.pop(),o=t(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(t){const e=this.data.viewModel.view;if(!e||!t)return;const a=t&&e.allLayerViews.items.find((({layer:e})=>e===t.layer||"subtype-sublayer"===t.layer?.type&&t.layer?.parent===e));h(a)&&this.handles.add(a.highlight(t),_)}async _popWorkflow(){this._workflowStack.pop()?.destroy();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new e("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflow(t){const a="update-feature"===t.type||"create-features"===t.type;this.activeWorkflow?.exit({removeSketchHandles:a}),await t.start(),this._workflowStack.push(t);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new e("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const t=this._workflowStack;try{const e=t.peek();return await(e?.enter()),{activeWorkflow:e,failureCount:0}}catch(e){t.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(_)}static _createWorkflowSteps(t,l="awaiting-feature-to-update"){const{data:p,handles:w}=t;return y(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=p.viewModel,n=p.viewModel.view;let l=null;w.add(a((()=>{l=i(l)})),this.id),p.rootFeature=null,p.candidates=[];const d=n.on("immediate-click",(async a=>{e.location=a.mapPoint,e.visible=!0,l?.abort();const{editableItems:i}=p.viewModel;l=new AbortController;const d=await new Promise(((t,e)=>{o(l?.signal,(()=>e(r()))),t(v(i,n,a,l?.signal))}));s(l),p.candidates=d.reduce(((t,e)=>e.error?t:[...t,...e.value]),[]),e.visible=1===p.candidates.length,0!==p.candidates.length&&(1===p.candidates.length?(p.rootFeature=p.candidates[0],t.go("editing-existing-feature").catch((()=>{})).then((()=>e.visible=!1))):t.next())}));n.focus(),w.add(d,this.id)},async tearDown(){w.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){p.rootFeature=null,w.add(c((()=>p.rootFeature),(e=>{t._unhighlight(),t._highlight(e)})),this.id)},async tearDown(){t._unhighlight(),w.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:a,viewModel:i}=t.data;if(!a)throw new e("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await t.startUpdating(a),i.spinnerViewModel.visible=!1;const o=n((async()=>{await d((()=>!t.updating)),t.previous()}));t.addHandles(c((()=>t.nestedWorkflowCount),((t,e)=>{0===t&&0!==e&&o()})))},async tearDown(){await t.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}})})}};t([p()],S.prototype,"activeEditableItem",null),t([p()],S.prototype,"activeWorkflow",null),t([p()],S.prototype,"nestedWorkflowCount",null),t([p()],S.prototype,"shouldShowAttachments",null),t([p()],S.prototype,"shouldAllowAttachmentEditing",null),t([p()],S.prototype,"hasPendingEdits",null),t([p()],S.prototype,"helpMessage",null),t([p()],S.prototype,"reliesOnOwnerAdminPrivileges",null),t([p()],S.prototype,"hasInvalidFormTemplate",null),t([p()],S.prototype,"hasUnsupportedFields",null),t([p()],S.prototype,"updating",null),S=W=t([w(b)],S);const U=t=>!!t&&/update-/.test(t.type),C=S;export{C as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import{abortMaybe as i}from"../../core/maybe.js";import{onAbort as o,createAbortError as r,throwIfAborted as s,debounce as n}from"../../core/promiseUtils.js";import l from"../../core/Queue.js";import{whenOnce as d,watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isNonSpatialTable as u}from"../../layers/support/layerUtils.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import{UpdateFeatureWorkflow as f}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as m}from"./UpdateRecordWorkflow.js";import g from"./UpdateWorkflowData.js";import k from"./Workflow.js";import{createWorkflowSteps as v,fetchCandidates as y}from"./workflowUtils.js";var W;const _="candidate-highlight",b="esri.widgets.Editor.UpdateWorkflow";let S=W=class extends k{constructor(t){super(t),this._workflowStack=new l((t=>{let e;for(e of t);return e})),this.type="update"}initialize(){const{featureFormViewModel:t}=this.data.viewModel,e=t.relatedRecordCallbacks;t.relatedRecordCallbacks={addRelatedRecord:()=>{},editRelatedRecord:({relatedFeature:t})=>this.startUpdating(t)},this.addHandles(a((()=>t.relatedRecordCallbacks=e)))}get activeEditableItem(){const{activeWorkflow:t}=this;return U(t)?t.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((t=>t.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(t=(()=>Promise.resolve(!0))){if(this.activeWorkflow){if(this.activeWorkflow.hasPendingEdits){if(!await t())return}this.activeWorkflow.hasPreviousStep?await this.activeWorkflow.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((t=>t.commit())),await super.commit()}static create(t,e,a){const i=new W({data:new g({applyEditsCallback:a,viewModel:t}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,e)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startUpdating(t){try{const e=await this._createNestedWorkflow(t);await this._pushWorkflow(e)}catch(a){throw new e("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new e("editor:nothing-to-delete","There is no feature to delete");U(t)?await t.deleteAndCommit():await t.cancel(),1===this.nestedWorkflowCount?this.emit("complete"):await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((t=>t.cancel({force:!0})))}async _createNestedWorkflow(t){const e=u(t.sourceLayer)?m:f,{applyEditsCallback:a,viewModel:i}=this.data,o=await e.create({feature:t,viewModel:i,applyEdits:a});return await d((()=>!o.updating)),o}async _drainWorkflowStack(t){const e=this._workflowStack,a=[];for(;e.length>0;){const i=e.pop(),o=t(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(t){const e=this.data.viewModel.view;if(!e||!t)return;const a=t&&e.allLayerViews.items.find((({layer:e})=>e===t.layer||"subtype-sublayer"===t.layer?.type&&t.layer?.parent===e));h(a)&&this.handles.add(a.highlight(t),_)}async _popWorkflow(){this._workflowStack.pop()?.destroy();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new e("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflow(t){const a="update-feature"===t.type||"create-features"===t.type;this.activeWorkflow?.exit({removeSketchHandles:a}),await t.start(),this._workflowStack.push(t);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new e("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const t=this._workflowStack;try{const e=t.peek();return await(e?.enter()),{activeWorkflow:e,failureCount:0}}catch(e){t.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(_)}static _createWorkflowSteps(t,l="awaiting-feature-to-update"){const{data:p,handles:w}=t;return v(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=p.viewModel,n=p.viewModel.view;let l=null;w.add(a((()=>{l=i(l)})),this.id),p.rootFeature=null,p.candidates=[];const d=n.on("immediate-click",(async a=>{e.location=a.mapPoint,e.visible=!0,l?.abort();const{editableItems:i}=p.viewModel;l=new AbortController;const d=await new Promise(((t,e)=>{o(l?.signal,(()=>e(r()))),t(y(i,n,a,l?.signal))}));s(l),p.candidates=d.reduce(((t,e)=>e.error?t:[...t,...e.value]),[]),e.visible=1===p.candidates.length,0!==p.candidates.length&&(1===p.candidates.length?(p.rootFeature=p.candidates[0],t.go("editing-existing-feature").catch((()=>{})).then((()=>e.visible=!1))):t.next())}));n.focus(),w.add(d,this.id)},async tearDown(){w.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){p.rootFeature=null,w.add(c((()=>p.rootFeature),(e=>{t._unhighlight(),t._highlight(e)})),this.id)},async tearDown(){t._unhighlight(),w.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:a,viewModel:i}=t.data;if(!a)throw new e("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await t.startUpdating(a),i.spinnerViewModel.visible=!1;const o=n((async()=>{await d((()=>!t.updating)),t.previous()}));t.addHandles(c((()=>t.nestedWorkflowCount),((t,e)=>{0===t&&0!==e&&o()})))},async tearDown(){await t.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}})})}};t([p()],S.prototype,"activeEditableItem",null),t([p()],S.prototype,"activeWorkflow",null),t([p()],S.prototype,"nestedWorkflowCount",null),t([p()],S.prototype,"shouldShowAttachments",null),t([p()],S.prototype,"shouldAllowAttachmentEditing",null),t([p()],S.prototype,"hasPendingEdits",null),t([p()],S.prototype,"helpMessage",null),t([p()],S.prototype,"reliesOnOwnerAdminPrivileges",null),t([p()],S.prototype,"hasInvalidFormTemplate",null),t([p()],S.prototype,"hasUnsupportedFields",null),t([p()],S.prototype,"updating",null),S=W=t([w(b)],S);const U=t=>!!t&&/update-/.test(t.type),C=S;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async back(t){this.hasPendingEdits&&await(t?.()),this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,o)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>o(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],p.prototype,"data",void 0),t([n()],p.prototype,"hasNextStep",null),t([n()],p.prototype,"hasPreviousStep",null),t([n()],p.prototype,"onCommit",void 0),t([n()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],p.prototype,"hasInvalidFormTemplate",null),t([n()],p.prototype,"hasUnsupportedFields",null),t([n()],p.prototype,"shouldShowAttachments",null),t([n()],p.prototype,"shouldAllowAttachmentEditing",null),t([n()],p.prototype,"started",void 0),t([n({readOnly:!0})],p.prototype,"stepId",null),t([n()],p.prototype,"steps",void 0),t([n({readOnly:!0})],p.prototype,"type",void 0),t([n()],p.prototype,"helpMessage",null),t([n()],p.prototype,"hasPendingEdits",null),t([n()],p.prototype,"keyboardCancellationEnabled",null),p=t([a("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async back(t=(()=>Promise.resolve(!0))){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,o)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>o(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],p.prototype,"data",void 0),t([n()],p.prototype,"hasNextStep",null),t([n()],p.prototype,"hasPreviousStep",null),t([n()],p.prototype,"onCommit",void 0),t([n()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],p.prototype,"hasInvalidFormTemplate",null),t([n()],p.prototype,"hasUnsupportedFields",null),t([n()],p.prototype,"shouldShowAttachments",null),t([n()],p.prototype,"shouldAllowAttachmentEditing",null),t([n()],p.prototype,"started",void 0),t([n({readOnly:!0})],p.prototype,"stepId",null),t([n()],p.prototype,"steps",void 0),t([n({readOnly:!0})],p.prototype,"type",void 0),t([n()],p.prototype,"helpMessage",null),t([n()],p.prototype,"hasPendingEdits",null),t([n()],p.prototype,"keyboardCancellationEnabled",null),p=t([a("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};